我将从控制台窗口输入的两个值相乘。我正在使用32 位寄存器 eax, ebx,但它没有将值相乘。该程序正在运行,但它没有成倍增加。任何人都可以检测到问题吗?这段代码有什么问题?我在汇编语言中使用 KIP.R.IRVINE 链接库。
这是代码:
INCLUDE Irvine32.inc
.data
inputValue1st BYTE "Input the 1st integer = ",0
inputValue2nd BYTE "Input the 2nd integer = ",0
outputSumMsg BYTE "The sum of the two integers is = ",0
num1 DD ?
num2 DD ?
sum DD ?
.code
main PROC
; here we are calling our Procedures
call InputValues
call multiplyValue
call outputValue
call Crlf
exit
main ENDP
InputValues PROC
;----------- For 1st Value--------
; input message
call Crlf
mov edx,OFFSET inputValue1st
call WriteString
call ReadInt ; read integer
mov num1, eax ; store the value
;-----------For 2nd Value----------
; output the prompt message
mov edx,OFFSET inputValue2nd
call WriteString
call ReadInt ; read integer
mov num2, ebx ; store the value
ret
InputValues ENDP
;---------multiply----------------
multiplyValue PROC
; compute the sum
mov eax, num1 ; moves num1 to eax
mov ebx, num2 ; moves num2 to ebx
mul ebx ; num1 * num2 = 6 * 2
mov sum, eax ; the val is stored in ebx
ret
multiplyValue ENDP
;--------For Sum Output Result----------
outputValue PROC
; output result
mov edx, OFFSET outputSumMsg
call WriteString
mov eax, sum
call WriteInt ; prints the value in eax
ret
outputValue ENDP
End main
还有一个问题:我需要在其中使用进位标志吗?如果是这样,那么它的代码会是什么样子?