Assembly 英特尔8086-推送命令引发错误
我应该修改一些作业代码。我的问题是代码本身不能正常工作。我不是在任务中寻求帮助,只是让示例代码开始工作。尽管如此,我们还是非常感谢您的帮助 首先,这是我的代码;我应该与以下人员一起工作:Assembly 英特尔8086-推送命令引发错误,assembly,x86,emu8086,Assembly,X86,Emu8086,我应该修改一些作业代码。我的问题是代码本身不能正常工作。我不是在任务中寻求帮助,只是让示例代码开始工作。尽管如此,我们还是非常感谢您的帮助 首先,这是我的代码;我应该与以下人员一起工作: ;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
;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
非常感谢您的任何帮助。正如Axel所说,您已经运行了多个推送和弹出指令。或者也可以使用PUSHA和POPA指令一次推/弹出所有寄存器?我已经很久没有完成组装了,但你不能一个接一个地推吗<代码>按bx,
按cx
,按dx
,按相反顺序对pop
执行相同操作。您使用的是哪种汇编程序?语法push
只有TASM AFAIKI支持,我使用的是emu8086,我已经让它工作了。反对意见编辑中的信息将您的解决方案作为答案,而不是对问题的编辑。不要在标题中加上“已解决”:单击其中一个答案上的复选标记,将其标记为解决方案。您应该在将自己的答案作为答案发布后(或之前)恢复编辑。由于Ross回滚了您的错误编辑,您仍然可以通过查看编辑历史记录找到您键入的所有内容。e、 g.降价来源为(从第3版点击“来源”)。我应该在之前的评论中解释这一点,然后自己将其回滚。我已经按照axels的说明进行了操作,现在它可以正常工作了。我添加到OP的编辑中的额外信息