- #1
intellect
- 9
- 0
Write an assembly language program that uses ten memory locations (variables) filled with 0, starting at Address 30, and that stores the values 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, and 22 in them. Your program will store 2 at Address 30, 4 at address 31, 6 at address 32, etc. Your program must use a loop. [/B]
I have my attempted solution below. The two problems I'm having are that 1) the numbers are incrementing by one instead of two (location 30-2, location 31-3, etc.), and 2) I can't get the program to stop after the number 22 is displayed in location 40. Could you please help me? Thank you.
lod-c 2 ; Start with a 2 in location 12
sto 12
lod 12 ; This instruction is stored in location 2
inc
sto 13 ; This instruction is stored in location 4
lod 2 ; Add 1 to the number in location 2
inc
sto 2
lod 4 ; Add 1 to the number in location 4
inc
sto 4
jmz done
jmp 2 ; Go back to the instruction in location 2
done: hlt
I have my attempted solution below. The two problems I'm having are that 1) the numbers are incrementing by one instead of two (location 30-2, location 31-3, etc.), and 2) I can't get the program to stop after the number 22 is displayed in location 40. Could you please help me? Thank you.
lod-c 2 ; Start with a 2 in location 12
sto 12
lod 12 ; This instruction is stored in location 2
inc
sto 13 ; This instruction is stored in location 4
lod 2 ; Add 1 to the number in location 2
inc
sto 2
lod 4 ; Add 1 to the number in location 4
inc
sto 4
jmz done
jmp 2 ; Go back to the instruction in location 2
done: hlt