Hello experts!
Can anyone tell me please, how to clear an array in asm?
ARRAY: DS.B 64
VAR1: DS.B 1
VAR2: DS.B 2
clr VAR1 ;clear VAR1
clr VAR2 ;clear VAR2, deletes only the first address
clr VAR2+1 ;clear VAR2, deletes the 2nd address too
clr ARRAY ;deletes only the first address but how can I clear the rest of the reserved space
would be very nice if someone could help me!
best regards
Ingo Kauf
已解决! 转到解答。
First of all, try to use symbols rather than the actual numbers, at all times. It makes the code more readable and more easily updateable. Regarding your question, something like this:
ARRAY_SIZE equ 64
Array rmb ARRAY_SIZE
...
ldhx #Array
Loop
clr ,x
aix #1
cphx #Array+ARRAY_SIZE
blo Loop
...
First of all, try to use symbols rather than the actual numbers, at all times. It makes the code more readable and more easily updateable. Regarding your question, something like this:
ARRAY_SIZE equ 64
Array rmb ARRAY_SIZE
...
ldhx #Array
Loop
clr ,x
aix #1
cphx #Array+ARRAY_SIZE
blo Loop
...
Hello Ingo,
There is generally more than one method of solving a particular problem. For example, provided the array size is less than 256 bytes, the following method may provide a simpler solution.
ARRAY_SIZE equ 64
array: rmb ARRAY_SIZE
...
ldhx #ARRAY_SIZE
clra
LOOP:
sta array-1,x
dbnzx LOOP
Regards,
Mac