Supposed to do:
The array sample contains 8 8-bit signed binary numbers (integers) as shown below. Write a
program which computes the sum of non-negative numbers and the sum of negative numbers, and
stores them psum and nsum, respectively. Your program should work for any 8 numbers
stored in samples. RAMStart=$0800 and ROMStart=$4000.
samples DC.B $01,$12,$F0,$33,$C9,$25,$E3,$08
psum DS.B 1
nsum DS.B 1
what does it do:
Not what it is supposed to. It only loops into the plus branch....
Problem:
not sure why it is doing this.
Updated Code:
Code:
ORG RAMStart
samples dc.b $01,$12,$F0,$33,$C9,$25,$E3,$08
psum ds.b 1
nsum ds.b 1
number dc.b $08
; Insert here your data definition.
; code section
ORG ROMStart
Entry:
ldab number
ldx #samples
start:
ldaa 1,x-
tsta
bmi minus
bpl plus
minus:
adda nsum
staa nsum
decb
tstb
bne start
bra stop
plus:
adda psum
staa psum
decb
tstb
bne start
bra stop
stop:
RTS