How can you know what value the different registers get when I am running the program? like we see in picture 1, after line 8 the R30 register(Z-Pointer) is changed to 0x94 and if I run one more line R29 become 0x01. but R28 and R31 have no value change.
.cseg
.org 0
rjmp start
.org 0x46
start:
ldi r31,high(tabell*2)
ldi r30, low(tabell*2) //line 8
ldi r29,high(behandlet)
ldi r28,low(behandlet)
tabell:
.db 0xc2,0x09,0x64,0xab
.db 0x73, 0x01, 0x0c, 0xfb
.dseg
.org 0x100
behandlet:
.byte 8
Picture 1:
Not sure what you are confused about. Just figure out the address of the symbols involved, and apply the given operations. Finally place the result into the given destination register.
Line 8: ldi r30, low(tabell*2)
Okay, so we need to figure out the address of tabell
. Since start
is at 0x46
and this is program memory, each instruction counts as 1. Thus, tabell
is at 0x4A
. Multiplying by 2 gives us 0x94
, and taking the low byte is a no-op obviously. So that's why r30
changes to 0x94
.
Next line: ldi r29,high(behandlet)
That's even simpler, since behandlet
is directly after an org 0x100
, so that is its address. Taking the high byte of that is obviously 0x01
.
r28
and r31
don't change, since they are already zero, and the respective instructions also load them with zero. See above for why high(tabell*2)
and low(behandlet)
are both 0
.