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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!