<<< SBB Instruction, Cont | Index | >>> |
Given:
.DATA op1 QWORD 0A2B2A40675981234h ; first 64-bit operand for addition op2 QWORD 08010870001234502h ; second 64-bit operand for addition sum DWORD 3 dup(?) ; 96-bit sum = ????????????????????????h op3 DWORD 3 dup(2) ; 96-bit oper to sub 20000000200000002h ; Result sum = ????????????????????????h
Write an assembly program to compute
(a) the sum of two 64-bit integers. Store the result as 96-bit sum:
sum = (op1 + op1)
(b) Subtract 96-bit op3 integer from the sum. Store the difference back in the sum memory:
sum = (sum - op3)
Every CPU instruction in your program must have a brief comment!
The penalty for not following this rule is 15 pts deduction...
Enter computation results by replacing corresponding question marks in the program comments.
Things to consider:
The largest operand size on 32-bit CPU is a DWORD, therefore, computation must be implemented as a series of chained additions and subtractions of doublewords, starting from low to high.
Recall how a QWORD is stored in memory . Since program is running on a 32-bit Intel-based CPU, all multibyte values are stored in a reversed sequence order. Therefore, to load QWORD into EBX:EAX, we need to discriminate between high and low parts as follows:
mov ebx, DWORD PTR [op1 + 4] ; high-part of QWORD mov eax, DWORD PTR [op1 + 0] ; low-part of QWORD
Use the same approach to manipulate 96-bit values, such as sum and op3. Again, all bytes must be stored in a reversed sequence order.
Optional (25 xtra pts.) Improve the program by having it display both sum and diff in hexadecimal format on the screen.
What to submit:
Submit only your ASM source (not the EXE or project.)
<<< SBB Instruction, Cont | Index | >>> |