Day 3 (copied from status update on 7/26/2021)
Well, now I've got some new instructions under my belt. It's still the really basic stuff mind you (add, sub, swap, clr, exg etc.), but now I've got a decent handle on what it's like to move memory around. Right now I'm trying to memorize the technicalities (like how you cannot move word or long-word sized data in and out of memory if the address is an odd number, as the 68k will crash with an "address error"), and tomorrow I'll probably dip my toes into bit-specific instructions such as not.
The tutorial I've been using online has little things at the end of each section to test your knowledge. Here's the last one I went through:
move.w #$0010,d0
move.w d0,$00000040
move.w d0,d1
add.w d1,d1
add.w d0,d1
sub.w $00000040,d1
swap d1
move.w d0,d1
movea.l #$00000040,a4
add.w (a4),d1
move.w d1,(a4)
exg.l d1,d0
swap d0
clr.w d0
Basically, each data register had the value of 00000000 to start with, and I needed to figure out what d0 contained after all of this information was processed.
Here's my work:
move.w #$0010,d0 (d0 now has 00000010)
move.w d0,$00000040 (offset 00000040 and 00000041 have byte 00 and 10 respectively)
move.w d0,d1 (d1 now has 00000010)
add.w d1,d1 (d1 now has 00000020)
add.w d0,d1 (d1 now has 00000030)
sub.w $00000040,d1 (d1 now has 00000020)
swap d1 (d1 now has 20000000)
move.w d0,d1 (d1 now has 20000010)
movea.l #$00000040,a4 (a4 now has $00000040, #$00000010)
add.w (a4),d1 (d1 now has 20000020)
move.w d1,(a4) (a4 now has $00000040, #$20000020)
exg.l d1,d0 (d1 now has 000000010, d0 now has 20000020)
swap d0 (d0 now has 00202000
clr.w d0 (d0 now has 00200000)
I came to the conclusion that d0 had 00200000 in memory, which was correct!
- 1
2 Comments
Recommended Comments