Write a program to divide the signed eight-bit numbers in a
table of data by 2, and store in another table
; Program to divide a table by two
; and store the results in memory
prog: equ $0800
data: equ $0900
count: equ 5
CODE: section .text ;The stuff which follows is program code
org prog ;set program counter to 0x0800
ldab #count ;Use B as counter
ldx #table1 ;Use X as data pointer to table1
ldy #table2 ;Use Y as data pointer to table2
loop: ldaa 1,x+ ;Get entry from table1; increment pointer to next entry
asra ;Divide by two (signed)
staa 1,y+ ;Save in table2; increment pointer to next entry
dbne b,loop ;Decrement counter; counter != 0 => more entries to divide
swi ;Done
DATA: section .data ;The stuff which follows is data
org data
table1: dc.b $07,$c2,$3a,$68,$F3
table2: ds.b count