2014-03-29 33 views
0

我在大會寫了這個程序。我正在爲8086處理器使用MALM編譯器。該程序是爲了表明3個消息和採取3個值。我只是beginnier並有問題,以確定做的錯誤。計劃顯示隨機的符號代替文字

dane1 segment 
a db 30,0 
    db 31 dup(?) 
    db '$' 
d db ? 
    db'$' 
b db 30,0 
    db 31 dup(?) 
    db '$' 
tx1 db "Enter the first number (max 30 characters) :",10,13,"$" 
    db ? 
tx2 db "Enter the symbol *,+,-,/: ",10,13,"$" 
    db ? 
tx3 db "Enter the second number (max 30 characters): ",10,13,"$" 
    db ? 
nline db 10,13,"$" 
    db ? 
dane1 ends 
code1 segment 
start1: 
    mov sp,offset wstosu ;stack initzialization 
    mov ax,seg wstosu 
    mov ss,ax 

    ;showing the first message 
    mov dx, offset tx1 
    mov ax, seg tx1 
    mov ds, ax 
    mov ah,9 
    int 21h 

    ;getting input 
    mov ax, seg dane1 
    mov ds,ax 
    mov dx,offset a 
    mov ah,0AH 

    ;loading input to a 
    mov bh,0 
    mov bl,byte ptr ds:[a+1] 
    add bx,offset a+2 
    mov byte ptr ds:[bx],'$' 
    int 21h 

    mov dx, offset nline 
    mov ax, seg nline 
    mov ds,ax 
    mov ah,9 
    int 21h 

    ;showing the second message 
    mov dx, offset tx2 
    mov ax, seg tx2 
    mov ds, ax 
    mov ah,9 
    int 21h 

    ;getting input 
    mov ax, seg dane1 
    mov ds, ax 
    mov dx, offset d 
    mov ah, 0AH 

    ;loading input to d 
    mov bh, 0 
    mov bl, byte ptr ds:[d+1] 
    add bx, offset d+2 
    mov byte ptr ds:[bx],'$' 
    int 21h 

    ;new line 
    mov dx, offset nline 
    mov ax, seg nline 
    mov ds, ax 
    mov ah, 9 
    int 21h 

    ;showing third message 
    mov dx, offset tx3 
    mov ax, seg tx3 
    mov ds, ax 
    mov ah,9 
    int 21h 

    mov ah,4ch 
    int 21h 


code1 ends 
stos1 segment stack 
    dw 200 dup(?) 
wstosu dw ? 
stos1 ends 
end start1 

EDIT1: 我更改代碼爲@Micheal建議,但仍然得到隨機的符號時,我儘量表現TX2。

EDIT2: 我設法以某種方式顯示信息,而不是隨機的符號,但現在程序不等待第二次輸入。我會很樂意提供任何幫助。

回答

1

你假設寄存器仍然認爲,至今已改變的值:

mov ax,seg dane1   
mov ds, ax 
mov dx, offset tx1 
mov ah, 09h <-- Here you're altering the high 8 bits of ax 
int 21h  <-- int 21h/function 9h will destroy al 

mov ds,ax  <-- Here you assume that ax still holds seg dane1, which it doesn't 

有可能是在你的代碼的其他問題,這只是最明顯的一個。

+0

我改變如你所說的代碼,但仍然得到隨機符號。你知道問題在哪裏嗎? –

+0

我改變了代碼,但現在程序不等待輸入。我會很樂意提供任何幫助。 –