11 lines
706 B
Z80 Assembly
11 lines
706 B
Z80 Assembly
;for this example the array's size, the data we want to write, and where we want to write the data, are all known in advance.
|
|
|
|
ld hl,Array ;hl points to the 0th element of row 0.
|
|
ld c,5 ;one-indexed row length
|
|
ld b,0 ;set bc = row length
|
|
add hl,bc ;now hl points to the 0th element of row 1.
|
|
inc hl ;now hl points to the 1st element of row 1.
|
|
inc hl ;now hl points to the 2nd element of row 1. This is where we planned on storing our new value.
|
|
ld a,20 ;get the value 20 which we want to store here
|
|
ld (hl),a ;store 20 into the desired slot. (Retrieving a value is the same process except we skip the step above and
|
|
; execute "ld a,(hl)" at this point instead.)
|