https://youtu.be/QAvuyAzO_Uo
http://www.chibiakumas.com/z80/index.php#Lesson2
Now you've got Winape up and running, and had a go at programming, we can get on with learning some more commands!
We're still going to do simple things, but let's use the CPC's screen this time, so you can see the results of your code!
We'll learn our first Z80 commands in this lesson
Video: Lesson 2 - Memory copy, Symbol definitions, Loops and Conditional Jumps!
Video: Lesson 2 - Memory copy, Symbol definitions, Loops and Conditional Jumps!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens
Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809
Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809
Re: Video: Lesson 2 - Memory copy, Symbol definitions, Loops and Conditional Jumps!
Hi hi,
I've been going over these first video's again and I have a question about the LDIR command.
When using it in the small program you made in this video:
org &8000 - we're setting the location of the program
ld hl,&0000 - we're loading &0000 as the source address (beginning of RAM(?) where BASIC(?) is loaded onto by the cpc
ld de,&C000 - making the destination address the start of the screen RAM
ld bc,&4000 - loads the number of bytes to be copied
ldir - load incriment repeat
ret - returns us to where the program was called.
I'm understanding the majority of this except why the program continues onto &c001 then &c002 etc etc.
Is this done because the LDIR command sees that the byte count is &4000?
SOOO it copies from hl to de, incrementing it's destination by one byte at a time? thus carrying on until it has copied &4000 bytes?
Does this also increment the hl? I think this is what you were saying in the video.
It's the same as (only MUCH faster):
10 b=&C000
20 for n=&0000 to &4000
30 a=peek(n)
40 poke b,a
50 b=b+1
60 NEXT n
70 end
I'm new to BASIC too haha!
I feel like having written this post I've answered my own question, having spent a few minutes working out how to do the same thing in BASIC.
Every day is a school day!
I've been going over these first video's again and I have a question about the LDIR command.
When using it in the small program you made in this video:
org &8000 - we're setting the location of the program
ld hl,&0000 - we're loading &0000 as the source address (beginning of RAM(?) where BASIC(?) is loaded onto by the cpc
ld de,&C000 - making the destination address the start of the screen RAM
ld bc,&4000 - loads the number of bytes to be copied
ldir - load incriment repeat
ret - returns us to where the program was called.
I'm understanding the majority of this except why the program continues onto &c001 then &c002 etc etc.
Is this done because the LDIR command sees that the byte count is &4000?
SOOO it copies from hl to de, incrementing it's destination by one byte at a time? thus carrying on until it has copied &4000 bytes?
Does this also increment the hl? I think this is what you were saying in the video.
It's the same as (only MUCH faster):
10 b=&C000
20 for n=&0000 to &4000
30 a=peek(n)
40 poke b,a
50 b=b+1
60 NEXT n
70 end
I'm new to BASIC too haha!
I feel like having written this post I've answered my own question, having spent a few minutes working out how to do the same thing in BASIC.
Every day is a school day!
You don't fail, You learn how it's not done.
https://www.gee-k.net : Where I blog about my random geeky goings on.
https://www.gee-k.net : Where I blog about my random geeky goings on.
Re: Video: Lesson 2 - Memory copy, Symbol definitions, Loops and Conditional Jumps!
Yes, you are correct... LDIR copies from (HL)->(DE), then does INC HL and INC DE, finally DEC BC and repeats until BC=0
if you're using WINAPE, you can put a breakpoint (click on the grey margin - a red blob will appear) on the LDIR command, and watch the registers change (and memory fill) by stepping one tick at a time with F7
Hope this helps!
if you're using WINAPE, you can put a breakpoint (click on the grey margin - a red blob will appear) on the LDIR command, and watch the registers change (and memory fill) by stepping one tick at a time with F7
Hope this helps!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens
Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809
Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809
Re: Video: Lesson 2 - Memory copy, Symbol definitions, Loops and Conditional Jumps!
Many thanks for confirming.
Slowly but surely I'm getting there.
I wrote my first 'complicated' BASIC program last week, so i'm hoping to convert it into ASM + BASIC to make it run a bit faster.
Then i'm hoping to make it look much better and easier to use. i.e. just using the arrow keys on the keyboard to scroll through selections etc etc.
I have a long way to go yet, but i'll get there.
Thanks for your help!
Slowly but surely I'm getting there.
I wrote my first 'complicated' BASIC program last week, so i'm hoping to convert it into ASM + BASIC to make it run a bit faster.
Then i'm hoping to make it look much better and easier to use. i.e. just using the arrow keys on the keyboard to scroll through selections etc etc.
I have a long way to go yet, but i'll get there.
Thanks for your help!
You don't fail, You learn how it's not done.
https://www.gee-k.net : Where I blog about my random geeky goings on.
https://www.gee-k.net : Where I blog about my random geeky goings on.