Answered step by step
Verified Expert Solution
Question
1 Approved Answer
here is an assembly code for muliply and division. can someone explain why my debug for dx say 2 0 0 0 , ax for
here is an assembly code for muliply and division. can someone explain why my debug for dx say ax for eax for and edx for The code is correct but I don't understand why ax dx eax and edx are in those numbers. please explain by using calculations. Thank you!gdb b start imull eax #multipli eax bu itself
#After imull, eax
#edx:eax:since the result fits in eax, edx is zero
movw opWord, sax #load opWord into ax
movw opWord, sdx #load opWord into dx
idivw sourceWord #divide dx:ax by sourceWord
#before idivw, dx:ax
#idivw sourceWord
#Quotientdx:axsourceWord:
#Qoutienyax remainder dx
movl opLong, seax #Load opLong into eax
movl opLong, sedx #Load opLong into edx
idivl sourceLong #divide edx:eax by sourceLong
#before idivl, edx:eax:
#idivl sourceLong
#Quotient edx:eaxsourceLong :
done:
nop
Function start" not defined.
Make breakpoint pending on future shared library load? y or n y
Breakpoint start pending.
gdb P $dx
gdb b
Breakpoint at x
gdb P $ax
gdb b
Note: breakpoint also set at pc x
Breakpoint at x
gdb P $dx
gdb p $eax
gdb p $edx
gdb
data
opByte: byte
opWord: word
opLong: long
sourceByte: byte
sourceWord: word
sourceLong: long
text
global main
main:
movw opWord, ax #Load opWord into ax
imulw ax #multiply ax by itself
#After imulw, ax
#dx:ax:since the result fits in eax, dx is zero
movl opLong, eax #Load opLong into eax
imull eax #multipli eax bu itself
#After imull, eax
#edx:eax:since the result fits in eax, edx is zero
movw opWord, ax #load opWord into ax
movw opWord, dx #load opWord into dx
idivw sourceWord #divide dx:ax by sourceWord
#before idivw, dx:ax
#idivw sourceWord
#Quotientdx:axsourceWord:
#Qoutienyax remainder dx
movl opLong, eax #Load opLong into eax
movl opLong, edx #Load opLong into edx
idivl sourceLong #divide edx:eax by sourceLong
#before idivl, edx:eax:
#idivl sourceLong
#Quotient edx:eaxsourceLong :
#Quotient remainder edx
done:
nop
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