Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Coding - Intel X86 Procedures Lab #5: Direct Addressing, Input, and ASC

ID: 3802693 • Letter: A

Question

Assembly Coding - Intel X86 Procedures

Lab #5: Direct Addressing, Input, and ASCII code Purpose: The main purpose of this lab assignment is to demonstrate understanding of how to use procedures (subroutines). It requires modification of the previous lab You have up to 1 week to complete this lab Introduction: Procedures typically are passed parameters (if needed) before they are called. The output of the procedure can also be a parameter if necessary. In Intel Assembly parameters can be passed via registers or the stack Procedure: Write an assembly program that receives the variables X and Y from the keyboard and in the following: DW X DW loc DD DW Sum DW loc Y 160 X 2 Y 1000 Sum loc/8 Y +Y/4. Y/100 W Sum 7 5 A typical session will look like the following Input X- 60 Input Y- 8 Calculating W Output W- 10

Explanation / Answer

section   .text
global _start
  
_start:  
mov y,0
mov x,0
call sum
  
sum:
mul y,'160'
mul x,'2'
add y,x
mov loc,y
mov y,'1000'
sub y,'1'
div loc,'8'  
div y,'4'
mov a,y
div y,'100'
mov b,y
add a,b
add loc,y
add a,loc
mov sum,a
mov dx,0
mov ax,sum
mov bx,7
div bx
add dx,5
mov w,dx
ret

section .data
x dw
y dw
loc dd 0
w dw 0
sum dw 0

msg db "The output is:", 0xA,0xD