Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CHANGE THE CODE so that it reads 4 difderent inreger values from the user: N1, N2, N3 and N4. All values may be positive, negative
CHANGE THE CODE so that it reads 4 difderent inreger values from the user: N1, N2, N3 and N4. All values may be positive, negative or zero. ;------------------------------------ include c: \asmio\asm32.inc includelib c:\asmio\asm32.lib includelib c:\asmio\user32.lib includelib c:\asmio\kernel132.lib .const NULL = 0 .data? n1 dword ? n2 dword ? .data Input byte "Enter a number: ", NULL sumMs byte "N1 + N2 = ", NULL difMs byte "N1 - N2 = ", NULL .code main proc mov edx, OFFSET Input call WriteString call readInt mov n1, eax mov edx, OFFSET Input call WriteString call readInt mov n2, eax add eax, nl call crLf mov edx, OFFSET sumMs call WriteString call writeInt mov eax, n1 mov eax, n2 call crLf mov edx, OFFSET difMs call WriteString call WriteInt call readInt ret 0 main endp end main ;------------------------------------- 3. Change the code so that it reads 4 different integer values from the user: N1, N2, N3 and N4. All values may be positive, negative or zero. 4. After the user input the four values about compute the following quantity N1 + 2*N2 - N3 Note: (1) The final result of the expression above has to be in register EAX for printing. (2) Both addition and subtraction must be done through a register. In Assembler it is not allowed to add or subtract two numbers directly such as in: add N1,N2. To add two variables we need to use the register eax instead. For example, to compute 2 *N2 we need to add N2 twice in register eax, such as: mov eax, N2 ; move N2 to eax register add N2, eax ; add eax = N2 to N2 = 2 * N2 5. Keep the final result above in the EAX register for printing (See lines 57 - 60). 6. Prepare the final message below by creating the variable below in the .data segment: Output byte "The final result ", NULL 7. Check that your program produced the correct amount for the values: N1 N2 N3 3 Answer -10 -4 ON OWN 0 2
CHANGE THE CODE so that it reads 4 difderent inreger values from the user: N1, N2, N3 and N4. All values may be positive, negative or zero.
;------------------------------------
include c: \asmio\asm32.inc
includelib c:\asmio\asm32.lib
includelib c:\asmio\user32.lib
includelib c:\asmio\kernel132.lib
.const
NULL = 0
.data?
n1 dword ?
n2 dword ?
.data
Input byte "Enter a number: ", NULL
sumMs byte "N1 + N2 = ", NULL
difMs byte "N1 - N2 = ", NULL
.code
main proc
mov edx, OFFSET Input
call WriteString
call readInt
mov n1, eax
mov edx, OFFSET Input
call WriteString
call readInt
mov n2, eax
add eax, nl
call crLf
mov edx, OFFSET sumMs
call WriteString
call writeInt
mov eax, n1
mov eax, n2
call crLf
mov edx, OFFSET difMs
call WriteString
call WriteInt
call readInt
ret 0
main endp
end main
;-------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started