Uploaded by Amos Maina

Assign 501.docx

advertisement
Prof. Shahid Zaheer
CIS-271-601HY
3/26/2017
Assign 501
6. Convert the following assembly language pseudo-ops into hexadecimal machine language:
(a) .BYTE 13
Hexadecimal: 0D
(b) .ASCII “Frog\x00”
Hexadecimal:
46726F6700
(c) .WORD -6
Hexadecimal: FFFA
8. Predict the output of the following assembly language program:
LDBA 0x000E, d
STBA 0xFC16, d
LDBA 0x000D, d
STBA 0Xfc16, d
STOP
.ASCII “is”
.END
OUTPUT: si
9. Predict the output of the following assembly language program if the input is g. Predict the output if
the input is A. Explain the difference between two results:
LDBA 0xFC15, d
ANDA 0x000A, d
STBA 0xFC16, d
STOP
This study source was downloaded by 100000849090400 from CourseHero.com on 11-30-2022 11:44:41 GMT -06:00
https://www.coursehero.com/file/28125493/Assign-501docx/
.WORD 0x00DF
.END
If the INPUT is g, the OUTPUT is G. When input is g, which is 0110 0111 in machine language. Instruction
lord g from input, and Bitwise AND to 000A, which is 00DF, 0000 0000 1101 1111 in machine language,
so the result is 0100 0111 which is G.
If the INPUT is A, the OUTPUT is A. When input is A, which is 0100 0001 in machine language.
Instruction lord A from input, and Bitwise AND to 000A, which is 00DF, 0000 0000 1101 1111 in machine
language, so the result is 0100 0001 which is A.
11. Predict the output of the program in Figure 5.13 if the dot commands are changed to
.WORD 0xFE63 ;First
.BYTE 0x00
;Second
.BYTE ‘b’
;Third
.WORD 1401
;Fourth
Output:
-413
98
0062
by
12.Determine the object code and predict the output of the following assembly language programs:
(b)
DECO ‘Q’, i
LDBA ‘\n’, i
STBA 0xFC16, d
DECO 0xFFC3, i
LDBA ‘\n’, i
STBA 0xFC16, d
LDBA 0x007D, i
This study source was downloaded by 100000849090400 from CourseHero.com on 11-30-2022 11:44:41 GMT -06:00
https://www.coursehero.com/file/28125493/Assign-501docx/
STBA 0xFC16, d
STOP
.END
Output:
81
-61
}
14. In the following code, determine the values of the symbols this, that, and theOther. Write the object
code in hexadecimal. (Do not predict the output.)
BR
theOther
this:
.WORD
17
that:
.WORD
19
theOther: DECO
this, d
DECO
that, d
STOP
.END
Symbol
Value
this
0003
that
0005
theOther
0007
Object code in Hexadecimal: 12 00 07 00 11 00 13 39 00 03 39 00 05 00 zz
16. In the following code, determine the value of the symbol this. Predict and explain the output of the
assembly language program:
this:
DECO this, d
STOP
This study source was downloaded by 100000849090400 from CourseHero.com on 11-30-2022 11:44:41 GMT -06:00
https://www.coursehero.com/file/28125493/Assign-501docx/
.END
Symbol
Value
this
0000
OUTPUT: 14592
DECO is 390000 in hexadecimal instruction, the CPU interprets 39 as the opcode for the decimal output
instruction with direct addressing. It interprets the word at Mem[0000], which is 3900 (hex), as a decimal
number and output its value, which is 14592
20. Write an assembly language program that prints your first name on the screen. Use the
.ASCII pseudo-op to store the characters at the bottom of your program. Use the LDBA
instruction with direct addressing to output the characters from the string. The name you print
must contain more than two letters.
;A program to output my first name "Cindy"
;
LDBA 0x001F,d ;Load byte accumulator 'C'
STBA 0xFC16,d ;Store byte accumulator output device
LDBA 0x0020,d ;Load byte accumulator 'i'
STBA 0xFC16,d ;Store byte accumulator output device
LDBA 0x0021,d ;Load byte accumulator 'n'
STBA 0xFC16,d ;Store byte accumulator output device
LDBA 0x0022,d ;Load byte accumulator 'd'
STBA 0xFC16,d ;Store byte accumulator output device
LDBA 0x0023,d ;Load byte accumulator 'y'
STBA 0xFC16,d ;Store byte accumulator output device
STOP ;Stop
.ASCII "Cindy" ;ASCII "Cindy" characters
.END
21. Write an assembly language program that prints your first name on the screen. Use immediate
addressing with a character constant to designate the operand of LDBA for each letter of your name.
LDBA 'C',i ;Output 'C'
STBA 0xFC16,d
LDBA 'i', i ;Output 'i'
STBA 0xFC16,d
LDBA 'n',i ;Output 'n'
STBA 0xFC16,d
This study source was downloaded by 100000849090400 from CourseHero.com on 11-30-2022 11:44:41 GMT -06:00
https://www.coursehero.com/file/28125493/Assign-501docx/
LDBA 'd',i ;Output 'd'
STBA 0xFC16,d
LDBA 'y',i ;Output 'y'
STBA 0xFC16,d
STOP
.END
23. Write an assembly language program that prints your first name on the screen. Use
immediate addressing with a hexadecimal constant to designate the operand of LDBA for each
letter of your name.
LDBA 0x0043,i ;Output 'C'
STBA 0xFC16,d
LDBA 0x0069,i ;Output 'i'
STBA 0xFC16,d
LDBA 0x006E,i ;Output 'n'
STBA 0xFC16,d
LDBA 0x0064,i ;Output 'd'
STBA 0xFC16,d
LDBA 0x0079,i ;Output 'y'
STBA 0xFC16,d
STOP
.END
This study source was downloaded by 100000849090400 from CourseHero.com on 11-30-2022 11:44:41 GMT -06:00
https://www.coursehero.com/file/28125493/Assign-501docx/
Powered by TCPDF (www.tcpdf.org)
Download