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

Please write an x86 MASM assembly program implementing the following (I\'m using

ID: 3588625 • Letter: P

Question

Please write an x86 MASM assembly program implementing the following (I'm using visual studio 2015):

Requirements 1. (7 points) Implement the following expression in assembly language: Assume that vall, val2, and val3 are 8-bit integer variables Initialize vall with 12, val2 with 9, and val3 with 2 -You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. - Use the debugger to verify your answer. ubmit the following: Use movzx, movzx, or neg instructions whenever needed. o S Lastnamel.asm

Explanation / Answer

section .data

val1 db 12

val2 db 9

val3 db 2

section .text

global _start ;must be declared for using gcc

_start: ;tell linker entry point

mov ax,[val1] ;value in val1 into ax

mov cx,[val3] ;value in val3 into cx

neg cx ; -val3

add cx,ax ; -val3+val1

mov bx,[val2] ;value in val2 into bx

neg bx ; - val2

mov dx,7 ;dc = 7

add bx,dx ; -val2 + 7

sub bx,cx ; -val2 + 7 - (-val3+val1) INTO bx

mov eax, 1 ;system call number (sys_exit)

int 0x80 ;call kernel