Reference no: EM132363679
Assignment : 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:
Add DATA
a. MOV [0100H],DL07100H 00H
b. MOV CX,[DI] 07000H 020CDH
c. MOV AL,[BP+DI] 07000H0CDH
(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) accessedand the values of data to be transferred to the destination (either 1 byte or 2 bytes involved) by each of the following instructions:
ADDRESS DATA
a. MOV [SI+100H],AL 07100H 00H
b. MOV DL,[BX+SI] 07000H CDH
3. Based on the above screenshots, determine the 20-bit address(s)of the memory location(s) accessedand the values of data to be transferred to the destination (either 1 byte or 2 bytes involved) by each of the following instructions:
ADDRESS DATA
a. MOV AL,[BP+200H] 08700H 46H
b. MOV AL,[BP+SI-100H] 08500H 00H
Emu8086 Programming and Understanding
4. Write instructionsto copy 1254H toAX and save the data to memory locations with addresses of DS:1000H and DS:1001H. (2 marks)
MOV AX, 01254H
MOV [01001H], AX
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 thosetwo memory locations? (2 marks)
08000H 08001H
6.What is the length (number of bytes) of the machine code of the instruction MOV SI,1000H? Give explanation. (2 marks)
3 Bytes, this instruction is an immediate to register and the data type is a word.
7. What are the 20-bit addresses of the memory locationsstoring the machine code of the instruction in Question 6?(3 marks)
07100H 07101H 07102H
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.
16FFCh 16FFDh
9. After the execution of the instruction POP AX, what is the data in AX? (2 marks)
0000h
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.
010100h containing 08h
AX: FC08H
SS: 1000H
SP:0102H
101002H 45H
11. What is wrong with the following instructions?
INC [SI]
The operand of INC should be a register as it cannot be applied to a memory space.
12. After JMP 0020H is executed, what is the new value of IP?(1 mark)0020H
Enter the instruction in emu8086, find how many bytes the machine code of JMP 0020H has?
2 Bytes
13. After JMP 13CEH:0200H is executed, what are the new values of IP&CS?
IP:0020H CS:13CEH
Enter the instruction in emu8086, find how many bytes the machine code of JMP 13CEH:0200H has? (1 mark) 5 Bytes
14. After CALL 13CFH:0200H is executed, what are the new values of IP&CS?
IP:0020H CS:13CEH
Enter the instruction in emu8086, find how many bytes the machine code of CALL 13CFH:0200H has? 5 Bytes
15. Based on the above screenshot and given that AX=0000H ,DS=0700H and SI=0001H, what data will be saved to AXin ADD AX,[SI] instruction?
0FF20h
State the addresses of the memory locations of the source operand and data in those memory locations. (3 marks)07001h: 020h, 07002h:0FFh
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;
DATA SEGMENT
SOURCE_BLOCK DW 16 DUP(0)
BLOCK_END DW 0
ENDS
CODE SEGMENT
START:
MOV SI,0
MOV [SI],WORD PTR 0000H
MOV [SI+2],1000H
MOV [SI+4],2000H
MOV [SI+6],3000H
MOV [SI+8],4000H
MOV [SI+10],5000H
MOV [SI+12],6000H
MOV [SI+14],7000H
MOV [SI+16],8000H
MOV [SI+18],9000H
MOV [SI+20],0A000H
MOV [SI+22],0B000H
MOV [SI+24],0C000H
MOV [SI+26],0D000H
MOV [SI+28],0E000H
MOV [SI+30],0F000H
ENDS
END START
(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).
17.
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.
a. Copy the list fileto your submission.
b. Explain the function and final outcomeof the program.
Set data1 as the data segment, load the offset of label addr to BX and access memory space as bytes even through it is declared as words
Set the first three bytes to 01h and return
c. Find values of code1 and data1, and show how to calculate 20-bit values of lopand addr.
Code1:0100h data1:0102h lop:0100Bh addr: 01020h
d. Run theprogram. After you finish, show how to verify the data saved in memory. Include a screenshot as proof.
e. *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.
There might be some problem with the segment value generation in the emulator
The instruction of ‘mov ax, seg code1' cannot be compiles
The instruction of ‘mov ax, code1' just move zero to ax.
18.(Analysis of an assembly program)
This is a problem solvingquestion 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 linkby 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, Saturdayof Week 7.
Themain 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 subroutinesdo_plus, do_minus, do_mult, do_div to perform addition, subtraction, multiplication and division.
Open the uploadedassembly 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 flowchartof theprogram.The flowchartshould 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.)
0726F
What are the 20-bit addresses of the memory locations used to store the two signed numbers? (Screenshot is required to justify your answer.)
07270 and 07272
What are the ranges of them? Why?
-32768 to 32767. The memory space of each number is a word and it a signed number.
How does the program detects a wrong operator (i.e., none of +, -, *, /)?
If the operator is less than ‘*' or greater than ‘/', it is a wrong operator.
After this checking, it is still a wrong operator if it is not one of +, -, *, /
Can the detection be correct if a user types comma "," or full stop "."?
Yes, the program still works correctly.
How is the sign of the result determined and printed?
Check if the result is negative. If yes, print char ‘-‘ and put the absolute of the value.
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?
Make sure the program exits at the same place even if there are different situations.
In the exit codes, it prints the goodbye info.
Note: The command "scan_num"reads in the ASCIIcodesof 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 characterpreviously 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 withecho 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
Attachment:- Assignment - Microprocessor Systems.rar