300076 Microprocessor Systems

  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:

                                                Add                 DATA

  1. MOV [0100H],DL    07100H     00H
  2. MOV CX,[DI]       07000H   020CDH
  3. MOV AL,[BP+DI]    07000H     0CDH

(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:

                                                   ADDRESS      DATA

  1. MOV [SI+100H],AL    07100H    00H
  2. MOV DL,[BX+SI]      07000H    CDH

(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:

                                                         ADDRESS        DATA

  1. MOV AL,[BP+200H]       08700H     46H
  2. MOV AL,[BP+SI-100H]    08500H     00H

(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)

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 those two 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 locations storing 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.(2 marks)

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.  (5 marks)

010100h containing 08h

AX: FC08H

SS: 1000H

SP:0102H

101002H    45H

11. What is wrong with the following instructions?(2 marks)

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?

(1 mark)  2 Bytes

13.

After JMP 13CEH:0200H is executed, what are the new values of IP&CS? (2 marks)

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?  (2 marks)

IP:0020H  CS:13CEH

Enter the instruction in emu8086, find how many bytes the machine code of

CALL 13CFH:0200H has?  (1 mark)  5 Bytes

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) 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). (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.

  1. Copy the list file to your submission.
=================================================================================================== [LINE]     LOC: MACHINE CODE                          SOURCE ===================================================================================================   [   1]        :                                       code1       segment [   2]    0000: B8 02 00                                                mov     ax,data1 [   3]    0003: 8E D8                                                    mov     ds,ax [   4]    0005: BB 00 00                                               mov     bx, offset addr [   5]    0008: B9 03 00                                                mov     cx,3 [   6]    000B: C6 07 01                              lop:           mov     byte ptr [bx], 1 [   7]    000E: 43                                                          inc       bx [   8]    000F: 49                                                          dec      cx [   9]    0010: 75 F9                                                     jnz       lop; decrement cx, if not zero, go back to lop [  10]    0012: B8 00 4C                              mov ax,4c00h [  11]    0015: CD 21                                                   int 21h [  12]        :                                                      ends [  13]        :                                       [  14]        :                                          data1   segment           [  15]    0020: 30 00 30 00 30 00 30 00 30 00 30 00              addr dw           10 dup (30h)                 30 00 30 00 30 00 30 00             [  16]        :                                                      ends [  17]        :                                                      [  18]        :                                                      end [  19]        :                                       [  20]        :                                       [  21]        :                                       [  22]        :                                          ===================================================================================================
  • Explain the function and final outcome of the program.  (2 marks)

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

  • Find values of code1 and data1, and show how to calculate 20-bit values of lop and addr. (4 marks)

Code1:0100h data1:0102h      lop:0100Bh  addr: 01020h

  • 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)

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) (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.)

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 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