How to clear an array in assembly language?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to clear an array in assembly language?

ソリューションへジャンプ
7,801件の閲覧回数
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 解決策
4,662件の閲覧回数
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 返答(返信)
4,663件の閲覧回数
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 件の賞賛
返信
4,662件の閲覧回数
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 件の賞賛
返信
4,662件の閲覧回数
mnemonic
Contributor III

Thank you very much! This was very fast!

 

I will work on this at evening.

 

best regards,

 

Ingo Kauf

0 件の賞賛
返信