0

キーボードから2つの数字を読み取り、それらが等しい場合はメッセージを表示しようとしています。

メッセージを表示するために私は正しいことをしていないと思います。私はいくつかのコンパイルエラーを取得します(私はそれらをインラインでコメントとして書きました)

 title Program1
 data segment
 mesajEgale db "equal$"
 mesajInegale db "inequal$"
  data ends

cod segment
assume cs:cod,ds:data
start :
  read:
mov ah,01h  
int 21h   //read number
mov bl,al //move first number in bl 
int 21h //read second nubmer
cmp al,bl //compare if the two numbers are equal
jnz unequal 
equal:
mov ax,data
    mov  ds,ax
    mov ds,mesajEgale // error here :Argument to operation or isntruction has illegal     size
    mov dx,offset mesajEgale
    mov ah,09h
    int 21h,4c00h
    int 21h
    //need to jump to end here

   unequal:
   mov ax,data
    mov  ds,ax
    mov ds,mesajInegale
    mov dx,offset mesajInegale
    mov ah,09h
    int 21h,4c00h
    int 21h

cod ends
end start

私が間違っていることを教えてもらえますか?

ありがとう。

4

1 に答える 1

1

まず第一に、これはDOSで実行されると思いますか?それ以外の場合int 21hは機能しません。

DOSを想定すると、次のように機能するはずです(テストされていません)。

    mov  ax, data  ; Set segment registers right away, and leave them.
    mov  ds, ax

read:
    mov ah, 01h  
    int 21h        ; Read char from stdin to AL.

    mov bl, al

    mov ah, 01h    ; I never assume the registers won't be corrupted upon return.
    int 21h

    cmp al, bl     ; Are the read numbers equal?
    jnz unequal 
equal:
    mov dx, offset mesajEgale
    jmp print
unequal:
    mov dx, offset mesajInegale
print:
    mov ah,09h      ; Write string at ds:dx to stdout
    int 21h         ; No need to duplicate this code!
于 2013-01-12T18:14:15.073 に答える