In: Computer Science
Please make sure to read the instructions carefully! Must use P8!
Assembler Listing |
Screen Shot of Output Area |
Explain the status bits NZVC |
Greetings!!
A) Code:
BR main ;jump to main
prompt: .ascii "Enter a number: \x00" ;prompt message
out: .ascii "Output:\n" ;output message
nl: .ascii "\n" ;newline character
n: .word 2 ;declaring variable n
main: stro prompt,d ;display prompt message
deci n,d ;read number from the user
stro out,d ;display output message
deco n,d ;display the number as it is
stro nl,d ;newline
lda n,d ;load number to accumulator
suba 2,i ;subtract 2 from accumulator
sta n,d ;save to memory
deco n,d ;display number
stro nl,d ;newline
suba 2,i ;subtract 2
sta n,d ;save to memory
deco n,d ;display number
stro nl,d ;newline
suba 2,i ;subtract 2
sta n,d ;save to memory
deco n,d ;display number
stop
.end
Assembly listing:
-------------------------------------------------------------------------------
Object
Addr code Symbol Mnemon Operand Comment
-------------------------------------------------------------------------------
0000 04001F BR main
0003 456E74 prompt: .ASCII "Enter a number: \x00"
657220
61206E
756D62
65723A
2000
0014 4F7574 out: .ASCII "Output:\n"
707574
3A0A
001C 0A nl: .ASCII "\n"
001D 0002 n: .WORD 2
001F 410003 main: STRO prompt,d
0022 31001D DECI n,d
0025 410014 STRO out,d
0028 39001D DECO n,d
002B 41001C STRO nl,d
002E C1001D LDA n,d
0031 800002 SUBA 2,i
0034 E1001D STA n,d
0037 39001D DECO n,d
003A 41001C STRO nl,d
003D 800002 SUBA 2,i
0040 E1001D STA n,d
0043 39001D DECO n,d
0046 41001C STRO nl,d
0049 800002 SUBA 2,i
004C E1001D STA n,d
004F 39001D DECO n,d
0052 00 STOP
0053 .END
-------------------------------------------------------------------------------
Symbol table
--------------------------------------
Symbol Value Symbol Value
--------------------------------------
main 001F n 001D
nl 001C out 0014
prompt 0003
--------------------------------------
B) Output:
C) Flags:
Hope this helps