Modify the code below: Add code to display both sum and diff in a hexadecimal format on the screen, all bytes must be stored in a reversed sequence order.   code:   .386 ; Tells MASM to use Intel 80386 instruction set. .MODEL FLAT ; Flat memory model option casemap:none ; Treat labels as case-sensitive INCLUDE IO.H ; header file for input/output .STACK 100h ; (default is 1-kilobyte stack) .const ; Constant data segment .DATA ; Begin initialized data segment 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 2h, 0h, 0h ; 96-bit operand to subtract: 20000000200000002h .CODE ; Begin code segment _main PROC ; Beginning of code ;----------------------------------------------------------------------------- ; add two 64 bit numbers and store the result as 96 bit sum ;----------------------------------------------------------------------------- mov EAX, DWORD PTR [op1] ; EAX = low bits of first 64 bit integer mov EBX, DWORD PTR [op1 + 4] ; EBX = high bits of first 64 bit integer mov ECX, DWORD PTR [op2] ; ECX = low bits of second 64 bit integer mov EDX, DWORD PTR [op2 + 4] ; EDX = High bits of second 64 bit integer add EAX, ECX ; EAX = EAX + ECX adds low bits of the two 64 bit integers adc EBX, EDX ; EBX = EBX + EDX + CF adds high bits of the two 64 bit integers mov DWORD PTR [sum], EAX ; store the low bits sum mov DWORD PTR [sum + 4], EBX ; store the high bits sum adc DWORD PTR [sum + 8], 0 ; adds sum + 8 + CF ;--------------------------------------------------------------------------------- ; subtract 96 bit op3 from the sum and store the result in sum ;-------------------------------------------------------------------------------- mov EAX, DWORD PTR [op3 + 0] ; EAX = low bits of 96 bit op3 sub DWORD PTR [sum + 0], EAX ; subtract the low bits mov EAX, DWORD PTR [op3 + 4] ; EAX = middle bits of 96 bit op3 sbb DWORD PTR [sum + 4], EAX ; subtract the middle bits and carry flag mov EAX, DWORD PTR [op3 + 8] ; EAX = high bits of 96 bit op3 sbb DWORD PTR [sum + 8], EAX ; subtract the high bits and carry flag ret _main ENDP

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Modify the code below:

Add code to display both sum and diff in a hexadecimal format on the screen, all bytes must be stored in a reversed sequence order.

 

code:

 

.386 ; Tells MASM to use Intel 80386 instruction set.
.MODEL FLAT ; Flat memory model
option casemap:none ; Treat labels as case-sensitive

INCLUDE IO.H ; header file for input/output

.STACK 100h ; (default is 1-kilobyte stack)

.const ; Constant data segment

.DATA ; Begin initialized data segment

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 2h, 0h, 0h ; 96-bit operand to subtract: 20000000200000002h

.CODE ; Begin code segment
_main PROC ; Beginning of code
;-----------------------------------------------------------------------------
; add two 64 bit numbers and store the result as 96 bit sum
;-----------------------------------------------------------------------------
mov EAX, DWORD PTR [op1] ; EAX = low bits of first 64 bit integer
mov EBX, DWORD PTR [op1 + 4] ; EBX = high bits of first 64 bit integer

mov ECX, DWORD PTR [op2] ; ECX = low bits of second 64 bit integer
mov EDX, DWORD PTR [op2 + 4] ; EDX = High bits of second 64 bit integer

add EAX, ECX ; EAX = EAX + ECX adds low bits of the two 64 bit integers
adc EBX, EDX ; EBX = EBX + EDX + CF adds high bits of the two 64 bit integers

mov DWORD PTR [sum], EAX ; store the low bits sum
mov DWORD PTR [sum + 4], EBX ; store the high bits sum
adc DWORD PTR [sum + 8], 0 ; adds sum + 8 + CF

;---------------------------------------------------------------------------------
; subtract 96 bit op3 from the sum and store the result in sum
;--------------------------------------------------------------------------------
mov EAX, DWORD PTR [op3 + 0] ; EAX = low bits of 96 bit op3
sub DWORD PTR [sum + 0], EAX ; subtract the low bits

mov EAX, DWORD PTR [op3 + 4] ; EAX = middle bits of 96 bit op3
sbb DWORD PTR [sum + 4], EAX ; subtract the middle bits and carry flag

mov EAX, DWORD PTR [op3 + 8] ; EAX = high bits of 96 bit op3
sbb DWORD PTR [sum + 8], EAX ; subtract the high bits and carry flag
ret

_main ENDP

END _main ; Marks the end of the module and sets the program entry point label

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Assembly Language
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education