【发布时间】:2017-04-29 05:29:29
【问题描述】:
我对汇编编程很陌生,主要是想从 youtube 视频和“x86 处理器的汇编语言”pdf 中学习。该程序现在还没有接近完成,但我已经遇到了 3 个我无法弄清楚的错误。
- 文件中的无效字符(第 1 行)
- 无效的指令操作数(第 27、46、26 行)
-
符号类型冲突(第 15 行)
.model small .data message db "Please enter a for mutiplication or b for division $" message2 db " Enter the first number $" message3 db " Enter the second number $" message4 db " * $" message5 db " / $" message6 db " = $" .code main proc mov ax, seg message mov ds, ax mov dx, offset message mov ah, 9h int 21h mov ah, 1h ;input stored in al int 21h mov bl, al ; menu selection input stored in bl so al can be used freely mov ah, seg message2 mov ds, ah mov dx, offset message2 mov ah, 9h int 21h mov ah, 1h; input stored in al int 21h mov cl, al ; first number input stored in cl so al can be used freely mov dl, bl mov ah, 2h int 21h mov dl, al ;second number imput stored in dl so al can be used again sub cl, 30h ;convert characters to decimal sub dl, 30h mov ax, cl ;preform division div dl mov al, cl ;preform multiplication mul dl add cl, 30h ; convert decimal back to the characters add dl, 30h main endp end main
最终我想将输入范围限制在 1-100 之间,我也很感激任何关于如何做到这一点的提示,任何帮助都将不胜感激
【问题讨论】:
-
删除试图从
message获取段的行。在代码顶部,您可以使用mov ax, @datamov ds, ax设置一次 DS。 -
不允许使用
mov ax, cl行。 CL 是 8 位寄存器,AX 是 16 位寄存器。 -
当我现在使用“@data”时,它给了我一个新的错误“未定义的符号:Dgroup”与“@data”的行。我在这里想念什么?我需要使用 IsDefined 吗?
-
你用什么来组装这个?你的链接器是什么?几乎听起来您的链接器可能无法理解 16 位。
-
我正在使用 Microsoft Visual Studio 我打开了一个 win32 项目,其中构建自定义设置为 masm