So I'm taking Digital Systems and we're learning assembly. Last week, all I had to do was look at an asm and give some locations...this week, I need to "write a program which performs addition of the nine numbers and stores the result into a memory location. The nine numbers are given in decimal: 3,-5,13,24,11,25,36,2,8." We're using Wookie, and the program starts at $C000 and the data array starts at $0010. For a basic algorithm I know that I need to initialize, read the first number, start a loop, add number to location, read next number, end loop, and store the final number. However, I have NO IDEA how to go about implementing this into a program. Can anyone help?
So far, here's what I have: am I even close to right?
* Date: 9/22/2008
* Description: This program loads 9 numbers, computes the sum and stores
* the result in memory.
*
* Pseudocode:
* begin
* Read the first values of array
* Store in Accumulator A
* Loop Read the next values of array
* add to store
* increment counter
* end loop
* if counter = 0
* then go to end
* else repeat the loop
* end
******************************************************************
ORG $0010
DATA1 FCB 3,-5,13,24,11,25,36,2,8
DATA2 RMB 10
COUNTER RMB 9
ORG $C000
LDAB #9 Initialize the COUNTER
STAB COUNTER by placing 9 into COUNTER
LDAA #DATA1 Initialize the index register
LOOP LDAA 0,X Loading from DATA1
DECB Decrement the element
ADDA
INX Increment DATA1 pointer
DEC COUNTER Have all elements been handled?
BNE LOOP If not repeat LOOP
SWI If so exit LOOP
END
lol, looks pretty close to me, and I've never coded on that cpu.
But I did code on the 6502 and 6510, which used $C000 for user space! (and very similar opcodes).
But I did code on the 6502 and 6510, which used $C000 for user space! (and very similar opcodes).
But I did code on the 6502 and 6510, which used $C000 for user space! (and very similar opcodes).
The old VIC-20, Commodore64 series? I've taught myself assembly on those machines way back when...