Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HCS12 code Help

I am a newbie programmer and using the HCS12 microcontroller.
I am trying to do the following:
1.Calculate the sum of all numbers in an array.place this total in SUM
2.Calculate the sum of all negative numbers in the array.Place this total in NSum.
3.Count the number of occurrances of the number 1 in the array.Place this total in Identical.

I began with the following code, but I do not know how to code step #2 and #3 above. Here is the code:
org $1000
sum: rmb 1
nsum: rmb 1
arcnt: rmb 1
org $1500
ldaa #15
staa arcnt
ldx #array
clr sum
loop: ldaa 0,x
adda 0,x
staa sum
;Is the number negative?
nsum
nsum:
;Count the occurances of the number 1.
stab Identical
Identical:
org $2000
array: fcb 1,05,0b,0a,f6,14,ec,1,1e,e2,28,d8,32,ce,1


Sign In or Register to comment.