Assembly Language Assignment

Basic Add code:
Load r0 7
Load r1 8
Add r2 r0 r1
Store 9 r2
add 3 numbers, the one stored in memory location 6, 7, and 8.
Store answer in location 9
Branching Example:   Add all the numbers between 1 and ???
Put a 1 in location 10 and a 0 in locations 11 and 12. 
Location 10 will be the amount you count by
Location 11 will be the total sum
Location 12 will be the next number to add:

LOAD R3 10
LOAD R0 11
LOAD R1 12
ADD R2 R0 R1
ADD R1 R1 R3

Teaching the computer to multiply
Put 1 in location 31, used for decrementing
Put one number to multiply in location 30
Put the other number to multiply in location 29

Enter the folowing code:

Load r0 29
Add r2 r0 r2
Load r0 30
Load r1 31
Sub r3 r0 r1
Bzero 10
Store 30 r3
Load r0 29
Add r2 r0 r2
Branch 2
Store 28 r2

XC Assignment:  Teach the computer to divide:
Put the larger number in 29 and the smaller in 30.  Only use ones that divide in evenly.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>