assembly - MOV label, HL table -
i have instruction mov label, hl
. understand first row, second don't, if it's instruction mov label, hl
, why need address low , high values of label? zr?
and can explain me rows execute.
this table looks definition of instruction (code 22h) when cpu executes it. instruction, in whole, has 5 steps execute whole process. you, programmer, still looks 1 instruction.
z80 old 8 bit technology , @ time not read 64 bits @ once (or more caches of today). each read or write memory 1 step , 1 byte @ time.
the table explains happening on each step. particularly important if trying build computer cpu. however, less important if programming chip unless includes timing needs correct cycle.
so mov label, hl
move 16 bits memory @ address label register hl
.
(1) first processor reads 1 byte @ pc , finds out instruction 22h. ah! that's mov label, hl
.
(2,3) process knows has read 2 more bytes pc, representing memory address. z80 being little endian, first reads low byte (from pc + 1) , high byte (from pc + 2).
(4,5) address loaded step (2,3) in temporary register (internal cpu buffer called zr
) , used read 2 bytes memory. these 2 bytes saved in hl
register. hl
means high , low bytes. byte @ zr
loaded in l
, byte @ zr + 1
loaded in h
(again, loading register in little endian).
note: pc end being incremented 3 , possibly increment 1 each time used read 1 byte.
so loads contents of hl
double register @ once memory buffer specified label
(a hard coded address in 64kb addressable memory.)
for example, if start hl
set 0x0000
, have instruction:
mov 0x2345, hl
and @ address 0x2345
have byte 0x12
, @ address 0x2346
have byte 0x56
then hl
ends being: 0x5612
.
and instruction encoded as: 0x22 0x45 0x23
Comments
Post a Comment