Electronic Assignment Cover Sheet
School of Computing, Engineering& Mathematics
Student Name (First Name, Surname)
Student Number
Unit Name and Number
300076 Microprocessor Systems
Tutorial Group Number
N/A
Tutorial Day and Time
N/A
Class Day and Time
N/A
Unit Convenor
Dr Shahzad Asif
Title of Assignment
Assignment 1
Due Date
Midnight, Friday 23 August 2019
(Distributed: Tuesday 30 July 2019)
Date Submitted
Campus Enrolment
Sydney City Campus
STUDENT DECLARATION – by submitting your assignment electronically, you are agreeing that:
I hold a copy of this assignment if the original is lost or damaged.
I hereby certify that no part of this assignment or product has been copied from any other student’s work or from any other source except where due acknowledgement is made in the assignment.
No part of the assignment/product has been written/produced for me by any other person except where collaboration has been authorised by the subject lecturer/tutor concerned
I am aware that this work may be reproduced and submitted to plagiarism detection software programs for the purpose of detecting possible plagiarism (which may retain a copy on its database for future plagiarism checking).
Submission:Your submission should be one word document ONLY. The document should include questions, solutions, program, and screenshots. Submit your document online, no later than the due date.
Instructions:
This assignment is an individual work (except Question 18). You can discuss questions with other students, but the final document should be written solely by you, using your descriptions and explanations.
If you type your work on a university computer, your work could be copied by other students. All submissions will be checked by Turnitin. Any identical works will be given a 0 mark. It is your responsibility to protect your work against plagiarism. If you don’t understand some questions, do NOT copy solutions from other students, please ask help from the lecturer. You are liable for any consequences from plagiarism.
300076 Microprocessor Systems
Assignment 1
Addressing modes
1.
Based on the above screenshots, determine the 20-bit address(s)of the memory location(s) accessed and the values of data to be transferred to the destination (either 1 byte or 2 bytes involved) by each of the following instructions:
• MOV [0100H],DL
• MOV CX,[DI]
• MOV AL,[BP+DI]
(Note: The default segment register for BP is SS.) (6 marks)
2.
Based on the above screenshots, determine the 20-bit address(s)of the memory location(s) accessed and the values of data to be transferred to the destination (either 1 byte or 2 bytes involved) by each of the following instructions:
• MOV [SI+100H],AL
• MOV DL,[BX+SI]
(4 marks)
3.
Based on the above screenshots, determine the 20-bit address(s)of the memory location(s) accessed and the values of data to be transferred to the destination (either 1 byte or 2 bytes involved) by each of the following instructions:
• MOV AL,[BP+200H]
• MOV AL,[BP+SI-100H]
(4 marks)
Emu8086 Programming and Understanding
4.Write instructions to copy 1254H to AX and save the data to memory locations with addresses of DS:1000H and DS:1001H. (2 marks)
Questions 5-7 are based on the following screenshot.
5. The data in ax will be copied to two memory locations. What are the 20-bit addresses of those two memory locations? (2 marks)
6. What is the length (number of bytes) of the machine code of the instruction MOV SI,1000H? Give explanation. (2 marks)
7. What are the 20-bit addresses of the memory locations storing the machine code of the instruction in Question 6?(3 marks)
8.
The data in AX is to be saved to two memory locations in the stack. Determine the 20-bit addresses of those two memory locations in the stack.(2 marks)
9.
After the execution of the instruction POP AX, what is the data in AX? (2 marks)
10. The last stored items in the stack are the following hexadecimal values: 08H (very last), FCH, 45H, E5H, 78H, 59H, etc. Assume SS=1000H and SP=0100H. Register AX contains AD6CH. What is the 20-bit address of the location containing 08H? Specify the following after executing pop ax: contents of AX; contents of SS; contents of SP; 20-bit address of the memory location SP pointing to; contents of the memory location SP pointing to. (5 marks)
11. What is wrong with the following instructions?(2 marks)
INC [SI]
12.
After JMP 0020H is executed, what is the new value of IP? (1 mark)
Enter the instruction in emu8086, find how many bytes the machine code of JMP 0020H has?
(1 mark)
13.
After JMP 13CEH:0200H is executed, what are the new values of IP&CS? (2 marks)
Enter the instruction in emu8086, find how many bytes the machine code of
JMP 13CEH:0200H has? (1 mark)
14.
After CALL 13CFH:0200H is executed, what are the new values of IP&CS? (2 marks)
Enter the instruction in emu8086, find how many bytes the machine code of
CALL 13CFH:0200H has? (1 mark)
15.
Based on the above screenshot and given that AX=0000H , DS=0700H and SI=0001H, what data will be saved to AX in ADD AX,[SI] instruction?(2 marks)
State the addresses of the memory locations of the source operand and data in those memory locations. (3 marks)
Assembly Programming
16. Write an assembly program to allocate a block of 16 words in memory called SOURCE_BLOCK, and initialize them with values 0000H, 1000H, 2000H, 3000H, 4000H, 5000H, 6000H, 7000H, 8000H, 9000H, A000H, B000H, C000H, D000H, E000H, F000H.Tasks are:
(1) include the program in your submission and type it in emu8086;
(2) record offset address(s) of label(s)based on the information from the list file; (For address labels in the second or third segment, a subtraction should be carried out for each address label to calculate its offset address.)
(3) run your program to save data in memory; (4) use the RAM displayto demonstrate that they are loaded in memory.
Screenshot is required as proof for (2) and (4). (7 marks)
17.(13 marks)
Type the following assembly program in emu8086.
code1 segment
mov ax,data1
mov ds,ax
mov bx,offsetaddr
mov cx,3
lop: mov byte ptr [bx], 1
inc bx
dec cx
jnz lop; decrement cx, if not zero, go back to lop
mov ax,4c00h
int 21h
ends
data1 segment
addrdw 10 dup (30h)
ends
end
Click on emulate.
• Copy the list file to your submission.
• Explain the function and final outcome of the program. (2 marks)
• Find values of code1 and data1, and show how to calculate 20-bit values of lop and addr. (4 marks)
• Run the program. After you finish, show how to verify the data saved in memory. Include a screenshot as proof.(2 marks)
• *Add some instructions to copy the value of code1into two memory locations and use RAM display command to verify that its value is the segment value for the code segment. Include a screenshot as proof. This is a challenging question and no answer will be given before submission.(5 marks)
18.(Analysis of an assembly program) (25 marks)
This is a problem solving question and can be done in group. All members in a group can submit identical work. Each group should not have more than 3 students. In your submission, please clearly state your group members.
For this question, the lecturer won’t give solutions. Your group should seek continuous guidance/advice from the lecturer via email and face-to-face consultation.
All students must attend lecture and their registered tutorial classes in week 8, to present their work in tutorial class using powerpoint slides. No credit will be given for this question without oral presentation.
The powerpoint slides should be submitted to the Assignment 1submission link by 5:00 pm of Friday of week 7, so that the Lecturer can upload them beforehand.
Please form a group now. The presentation schedule will be announced at 10:00am, Saturday of Week 7.
The main program (in lines 53-156, opened using emu8086) of clc3.asm contains five blocks: getting the first number, getting the operator, getting the second number, calculation and exit. In lines 159 -204, there are four subroutines do_plus, do_minus, do_mult, do_div to perform addition, subtraction, multiplication and division.
Open the uploaded assembly program clc3.asm using emu8086. Execute the program to help you understand its function and ensure that you understand the functions of individual instructions and are able to find those five blocks and four subroutines.
Task 1: Each group should draw a flowchart of the program. The flowchart should contain rectangular boxes for the aforementioned five blocks and four subroutines, and diamond boxes with branches and associated conditions (e.g., how a subroutine jumps back to the main program).
Task 2: In addition to the flow chart for the program, answer the following questions:
What is the 20-bit address of the memory location used to store the arithmetic operator? (Screenshot is required to justify your answer.)
What are the 20-bit addresses of the memory locations used to store the two signed numbers? (Screenshot is required to justify your answer.)
What are the ranges of them? Why?
How does the program detects a wrong operator (i.e., none of +, -, *, /)?
Can the detection be correct if a user types comma “,” or full stop “.”?
How is the sign of the result determined and printed?
Task 3: For the four subroutines: do_plus, do_minus, do_mult, do_div, answer the following question:
Why do those four subroutines have jmp exit as the last instruction?
Note: The command “scan_num”reads in the ASCIIcodes of the typed digits and convert them to a binary value and store it in CX. The command “print_num” prints the number in AX using their decimal digits. They are procedures in emu8086 library. The functions of these two commands are not required for Assignment 1.
DOS/BIOS instructions used in the program:
The following two instructions ALTOGETHER print on screen (output) a string previously stored from ds:dx.
MOV AH, 09H
INT 21H
The following two instructions ALTOGETHER print a character previously stored in AL and advance the current cursor position.
MOV AH, 0Eh
INT 10h
The following two instructions ALTOGETHER read a character from keyboard into AL with echo on screen. If no key pressed, the processor keeps checking for a key.
MOV AH, 1
INT 21H
The following two instructions ALTOGETHER read a character from keyboard into AL with NO echo on screen. If no key pressed, the processor keeps waiting for a key.
MOV AH, 0
INT 16H
Total marks: 64 +25= 89
Outcomes achieved in Assignment 1 based on your submission (to be filled in by the marker)
Question
Under-standing of
machine
code
Under-standing of
memory display
Under-standing of
indirect addressing modes
Ability to calculate20-bit address
Under-standing of
infor-mation
in the list file
Under-standing: of structure of stack
Under-standing of impact of push,pop on stack
Under-standing of
program controlinstruc-tions
Ability to find data in the data segment
Ability to use and under-standing
of loop
Ability to analyze a long program
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18