1
我想加上值1到value2使用32位寄存器,並給予64位(等於16位數)下的值。是否可以使用2個寄存器(32 + 32 = 64位)的空間?我認爲這可以通過使用PTROPERATOR但我不知道如何使用PTR指令。彙編語言8086添加使用32位寄存&值在64位?
我已經制作了添加程序。它在控制檯中使用兩個值並給出結果。它只能在32位(8位)下取值。如果我們給出一個更高的值,那麼它會在控制檯中給出整數溢出錯誤。
我使用KIP.R.IRVINE鏈接庫彙編語言
我們將如何給通過使用32位寄存器,一個64位的值?我們如何使32位寄存器獲得64位值?
下面是32位加法
INCLUDE Irvine32.inc
.data
Addition BYTE "A: Add two Integer Numbers", 0
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
;----Displays addition Text-----
mov edx, OFFSET Addition
call WriteString
call Crlf
;-------------------------------
; calling procedures here
call InputValues
call addValue
call outputValue
call Crlf
jmp exitLabel
main ENDP
; the PROCEDURES which i have made is here
InputValues PROC
;----------- For 1st Value--------
call Crlf
mov edx,OFFSET inputValue1st ; input text1
call WriteString
; here it is taking 1st value
call ReadInt ; read integer
mov num1, eax ; store the value
;-----------For 2nd Value----------
mov edx,OFFSET inputValue2nd ; input text2
call WriteString
; here it is taking 2nd value
call ReadInt ; read integer
mov num2, eax ; store the value
ret
InputValues ENDP
;---------Adding Sum----------------
addValue PROC
; compute the sum
mov eax, num2 ; moves num2 to eax
add eax, num1 ; adds num2 to num1
mov sum, eax ; the val is stored in eax
ret
addValue ENDP
;--------For Sum Output Result----------
outputValue PROC
; output result
mov edx, OFFSET outputSumMsg ; Output text
call WriteString
mov eax, sum
call WriteInt ; prints the value in eax
ret
outputValue ENDP
exitLabel:
exit
END main
'PTR'不是指令和明顯64位不適合在32位。兩個32位數的總和只有33位,而額外的位在進位標誌中。 – harold 2013-04-20 18:01:12
我可以使用2位32位,並給64位值,但我沒有想法如何使用它... – 2013-04-20 20:02:47