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

Write a program which does the following 4000h - 800h - 200h - 500h You need to

ID: 3533613 • Letter: W

Question

Write a program which does the following 4000h - 800h - 200h - 500h You need to use only one 16 bit register AX. All the numbers involved in the calculation (4000h, 800h, 200h, and 500h) are stored in variables. The final result of the calculation is stored in AX. Display the contents of all registers by calling DumpRegs at the end of the program.
THIS IS WHAT I HAVE DONE. I AM JUST A BEGINNER IN ASSEMBLY LANGUAGE SO I DO NOT KNOW WHAT IS WRONG WITH MY CODES:






TITLE Subtract (Sub.asm) ;This program subtracts 16-bit unsigned ; integers and stores the sum in a variable.
INCLUDE irvine16.inc .data
Val1 WORD 4000h Val2 WORD 800h Val3 WORD 200h Val4 WORD 500h finalVal WORD ?
.code main PROC mov ax, Val1 ; start with 4000h (ax=4000h) sub ax, Val2 ; subtract 800h sub ax, Val3 ; subtract 200h sub ax, val4 ; subtract 500h mov finalVal, ax ; store the result (2500h) call DumpRegs ; display the registers exit main ENDP END main



Write a program which does the following 4000h - 800h - 200h - 500h You need to use only one 16 bit register AX. All the numbers involved in the calculation (4000h, 800h, 200h, and 500h) are stored in variables. The final result of the calculation is stored in AX. Display the contents of all registers by calling DumpRegs at the end of the program.
THIS IS WHAT I HAVE DONE. I AM JUST A BEGINNER IN ASSEMBLY LANGUAGE SO I DO NOT KNOW WHAT IS WRONG WITH MY CODES:






TITLE Subtract (Sub.asm) ;This program subtracts 16-bit unsigned ; integers and stores the sum in a variable.
INCLUDE irvine16.inc .data
Val1 WORD 4000h Val2 WORD 800h Val3 WORD 200h Val4 WORD 500h finalVal WORD ?
.code main PROC mov ax, Val1 ; start with 4000h (ax=4000h) sub ax, Val2 ; subtract 800h sub ax, Val3 ; subtract 200h sub ax, val4 ; subtract 500h mov finalVal, ax ; store the result (2500h) call DumpRegs ; display the registers exit main ENDP END main







TITLE Subtract (Sub.asm) ;This program subtracts 16-bit unsigned ; integers and stores the sum in a variable.
INCLUDE irvine16.inc .data
Val1 WORD 4000h Val2 WORD 800h Val3 WORD 200h Val4 WORD 500h finalVal WORD ?
.code main PROC mov ax, Val1 ; start with 4000h (ax=4000h) sub ax, Val2 ; subtract 800h sub ax, Val3 ; subtract 200h sub ax, val4 ; subtract 500h mov finalVal, ax ; store the result (2500h) call DumpRegs ; display the registers exit main ENDP END main



Explanation / Answer

#include<iostream.h>

void dumpregs()

{

cout<< "var1="<<var1<< var2="<<var2<<" var3="<<var3<< var4="<<var4;

}

int var1,var2,var3,var4,final;

void main()

{

cout<<"enter value";

cin>>var1>>var2>>var3>>var4;

final=var1-var2-var3-var4;

dumpregs();

cout<<"Final result ="<<final;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote