2013-04-22 236 views
0

彙編語言8086:我們如何使用兩個32位寄存器(32 + 32 = 64)來使其能夠讀取64位值?彙編語言8086

我必須做一個計劃,除了需要在控制檯的兩個值,給我們造成..如果我們給予較高的就只能採取下32位(8位數字)值價值然後它會給控制檯winbdow整數溢出錯誤..

如果我想給更多,然後在輸入1和輸入2的32位值我會怎麼做呢?它可通過使DWORD(32位)的陣列來實現,並把半(16位)的一半(16位)值

例如:(?)

ARRAY1 DWORD 2 DUP

數組2 DWORD 2 DUP(?)

我希望通過使用32位寄存器將value1添加到value2,並給出64位(等於16位)以下的值..可以使用2 reg(32 + 32 = 64位) ?...

我們如何使32位的2寄存器,使其64位我知道這是可能的,但我不知道該怎麼做...因爲我是新的彙編語言

我正在使用KIP.R.IRVINE鏈接彙編程序庫語言

我們將如何使用2 32位寄存器給予64位值?或者我們如何讓2位32位寄存器取得64位的值? 我不知道如何爲it..need幫助編碼

這裏代碼是32位加法代碼:

INCLUDE Irvine32.inc 
    ; In above i am calling KIP.R.IRVINE Link Library for assembly language 

.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 

回答

1

8086(我已經使用和所有其他處理器)保留一組「條件代碼」,其中包括「攜帶位」(這些引用的條款適用於您的Google搜索快感)。

當您添加兩個無符號的32位數量時,如果總數超過32位,則進位位將被置位。您可以隨意添加多達32位(或64位)數量,只要您將前一個添加的進位位合併即可。

+0

這是ADC指令 – James 2013-04-22 19:44:12

+0

Parsifal.if我想給第一個值和第二個值超過32位..然後它是一個問題.. – 2013-04-22 20:16:45

+0

如果你需要在32位處理器上使用64位數字,而不是隻允許64bit結果來自32bit數學,那麼你必須編寫所有你自己的數學函數,在兩個32位寄存器中吃64bit。在不彙編的世界裏有各種各樣的「BigNum」庫。 – 2013-04-22 21:31:34