我们可以一次使用两个32位寄存器(32 + 32 = 64)来使其能够读取64位的值吗?汇编语言8086
汇编语言8086:我们可以一次使用两个32位寄存器(32 + 32 = 64)来使其能够读取64位的值吗?汇编语言8086
我不得不做出另外它需要在控制台的两个值,给我们造成..就只能采取下32位(8位),如果我们给予较高的值,则值的程序它会给控制台上的整数溢出错误
如果我想在输入1和输入2中给出更多的32位值,我该怎么做?
我想使用32位寄存器将值value1添加到value2并给出64位(等于16位数)下的值..可以使用2 reg(32 + 32 = 64位)的空间吗? ...
我们如何能2寄存器32位,使其64位我知道这是可能的,但我不知道怎么做了......因为我在汇编语言是新
我正在使用汇编语言的KIP.R.IRVINE链接库
我们如何通过使用2 32位reg来提供64位值?或者我们如何让2位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
您可以结合使用ADC
与ADD
做某些内容添加到存储在2个32位寄存器,64位整数。
您可以使用SHLD
与SHL
一起向左移动存储在2个32位寄存器中的64位整数。
如果可以执行64位加法和64位移位,则可以轻松地将64位整数乘以10(hint: 10=8+2, x*10=x*8+x*2
)。
您可能需要它才能从控制台读取64位整数。您需要将它们读取为ASCII strings
,然后使用重复乘法10和加法(hint: 1234 = (((0+1)*10+2)*10+3)*10+4
)将其转换为64位整数。
上面应该有足够的信息来读取64位整数并添加它们。
为了打印总和,您需要将64位除以10,以便将64位整数转换为ASCII string
的十进制表示形式(hint: 4=1234 mod 10 (then 123 = 1234/10), 3 = 123 mod 10 (then 12 = 123/10), 2 = 12 mod 10 (then 1 = 12/10), 1 = 1 mod 10 (then 0 = 1/10, stop)
)。
我现在不打算解释如何使用2 DIVs
通过10来执行64位除法。让其他人先工作。
8086没有32位寄存器,如'eax'和'edx'。你想创建32位386+代码还是8086+的16位代码?你在你的代码中使用'eax'和'edx',但要求8086的解决方案。这不是一致的。 – nrz 2013-04-20 23:52:58