1

割り当てのためにいくつかのコードを変更することになっています。私の問題は、コード自体が正しく機能していないことです。サンプル コードを動作させるだけで、タスクの助けを求めているわけではありません。そうは言っても、どんな助けも大歓迎です。

まず最初に、これが私が使用するはずのコードです。

;Program to add two single digit numbers - answer must also be a single digit number.

.model small
.stack 100h
.data

prompt1 db  13, 10, 'Enter the first number to add:', 13, 10, '$'
prompt2 db  13, 10, 'Enter the second number:', 13, 10, '$'
answer      db  13, 10, 'The answer is:', '$'
num1        db  ?
num2        db  ?

.code

start:
        mov ax, @data
        mov ds, ax
        mov ax, offset prompt1  ;prompt to enter first number
        call puts
        call getc           ;collect first number
        mov num1, al            ;and save

        mov ax, offset prompt2  ;prompt to enter 2nd number
        call puts
        call getc           ;collect second number
        mov num2, al            ;and save





mov ax, offset answer       ;display answer message
        call puts

        mov al, num1
        add al, num2            ;calculate answer
        sub al, '0'         ;convert to a character for display

        mov dl, al
        call putc           ;and display it

        mov ax, 4c00h
        int 21h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

puts:                   ; display a string terminating in $
    push ax bx cx dx    ; save ax, bx, cx, dx
    mov  dx, ax     ; address of string must be stored in dx
    mov  ah, 9h
    int   21h       ; MSDOS called to display string
    pop dx cx bx ax ; restore dx cx bx ax
ret

getc:   
    push   bx cx dx ; save bx cx dx
    mov  dx, ax     ; address of string must be stored in dx
    mov  ah, 1h     ; char read into al, and output on screen
    int   21h       ; MSDOS called to read char
    pop dx cx bx        ; restore dx cx bx
    ret

putc:   
    push   ax bx cx dx  ; save ax bx cx dx
    mov  ah, 02h
    int   21h               ; MSDOS called to display char
    pop  dx cx bx ax    ; restore dx cx bx ax
    ret

end start

コンパイルして実行しようとすると発生するエラーは 48 行目で、次のとおりです。

wrong parameters: PUSH ax bx cx dx

問題の行は次のとおりです。

push ax bx cx dx    ; save ax, bx, cx, dx

ありとあらゆる助けをいただければ幸いです。

4

1 に答える 1