Question
Write a general-purpose program that is able to add two 8 bytes length numbers. Numbers are saved in EBX: EAX and EDX: ECX Consider this
Write a general-purpose program that is able to add two 8 bytes length numbers. Numbers are saved in EBX: EAX and EDX: ECX Consider this sample call: Number1 QWORD = 1234567898765432h Number2 QWORD = 1234567898765432h Please write code in Masm (Microsoft assembly) No High-Level Assembly. And please don't separate the variables, keep it as it is. If you do split it please do it in the code part. If possible please use 1 loop anything more than inc, dec, mov, xchg, I don't know how to do that yet. Here is what I have, but it's not running properly. I have to manually do the carry and cannot use ADC. And these are the only instructions I can use
.386 .model flat,stdcall .stack 4096 ExitProcess proto,dwExitCode:dword
.data Number1 QWORD ? ; 1234567898765432 Number2 QWORD ? ; 1234567898765432 result QWORD ? ; 2468ACF130ECA864 carry DWORD 0 temp DWORD ?
.code MOV DWORD PTR Number1, eax MOV DWORD PTR (Number1 + 4), ebx MOV DWORD PTR Number2, ecx MOV DWORD PTR (Number2 + 4), edx MOV esi, 0 MOV ecx, 4
;-------------- L1: MOVZX eax, WORD PTR Number1[esi] MOVZX ecx, WORD PTR Number2[esi] ADD eax, ecx ADD eax, carry MOV WORD PTR result[esi], ax MOV temp, eax MOVZX eax, WORD PTR (temp +2) MOV carry, eax add esi, 2 LOOP L1 invoke ExitProcess,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