How to clear an array in assembly language?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to clear an array in assembly language?

跳至解决方案
6,730 次查看
mnemonic
Contributor III

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 

标签 (1)
0 项奖励
回复
1 解答
3,591 次查看
tonyp
Senior Contributor II

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

 ...

 

Message Edited by tonyp on 2009-08-14 11:30 AM

在原帖中查看解决方案

0 项奖励
回复
3 回复数
3,592 次查看
tonyp
Senior Contributor II

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

 ...

 

Message Edited by tonyp on 2009-08-14 11:30 AM
0 项奖励
回复
3,591 次查看
bigmac
Specialist III

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

 

0 项奖励
回复
3,591 次查看
mnemonic
Contributor III

Thank you very much! This was very fast!

 

I will work on this at evening.

 

best regards,

 

Ingo Kauf

0 项奖励
回复