可以运行装配程序
因此,该项目基本上是关于可以使用4个基本操作的计算器进行编码:加法,减法,乘法和划分,以汇编语言。很抱歉,这些评论是用法语编写的,我想您无论如何都不需要它们理解代码。
可能会有所帮助:我的老师说我报告了一个不属于其放置位置的堆栈部分。 当我运行代码时,我会得到以下错误:
(56) error A2006: undefined symbol : scan_num
(89) error A2006: undefined symbol : scan_num
(100)error A2006: undefined symbol : do_plus
(103)error A2006: undefined symbol : do_minus
(106) error A2006: undefined symbol : do_mult
(109) error A2006: undefined symbol : do_div
(128) error A2006: undefined symbol : main
这是我的代码:
SSEG SEGMENT STACK
DB 32 DUP("STACK---")
SSEG ENDS
;===========================================================code segment
assume cs:cseg, ds:cseg, es:cseg
cseg segment
org 100h
;----------
name "CALCULATRICE"
PUTC MACRO char
PUSH AX
MOV AL,char
MOV AH, 0Eh
INT 10h
POP AX
ENDM
jmp start
;------------- Zone de donnée
msg0 db "BELLAL MOHAMED BUT1 2021/2022",0Dh,0Ah
db "CALCULATOR3000 gerant les quatres opérations basiques ( + - * / )",0Dh,0Ah,"$"
msg1 db 0Dh,0Ah,0Dh,0Ah, "Entrer le premier terme de l'opération: $"
msg2 db "Choisissez l'opérateur à utiliser: + - * / : $"
msg3 db "Entrer le second terme de l'opération: $"
msg4 db 0Dh, 0Ah,"Le résultat est: $"
msg5 db 0Dh, 0Ah," ",0Dh,0Ah,"$"
err1 db "Saisie incorrecte",0Dh,0Ah,"$"
smth db "Et .... $"
opr db "?" ; variable contenant l'opérateur
num1 dw ? ; variable contenant le premier terme de l'opération
num2 dw ? ; variable contenant le deuxième terme de l'opération
;--------------- PROGRAMME
start:
mov dx, offset msg0
mov ah, 9
int 21h
lea dx, msg1
mov ah, 09h ; afficher le premier message
int 21h
; récupérer un nombre saisi par l'utilisateur et on le stock dans
; le registre CX
call scan_num
mov num1, cx ; stocker le nombre dans num1
; nouvelle ligne
putc 0Dh
putc 0Ah
lea dx, msg2
mov ah, 09h ; affiche le deuxième message
int 21h
; récupérer l'opérateur
mov ah, 1
int 21h
mov opr, al
; nouvelle ligne
putc 0Dh
putc 0Ah
cmp opr, "q" ; q pour quitter
je exit
cmp opr, "*"
jb wrong_opr
cmp opr, "/"
ja wrong_opr
lea dx, msg3
mov ah, 09h
int 21h
call scan_num
mov num2, cx
lea dx, msg4
mov ah, 09h
int 21h
;------------- CALCULER
cmp opr, "+"
je do_plus
cmp opr, "-"
je do_minus
cmp opr, "*"
je do_mult
cmp opr, "/"
je do_div
;---------- CAS PAR DEFAUT
wrong_opr:
lea dx, err1
mov ah, 09h
int 21h
exit:
lea dx, msg5
mov ah, 09h
int 21h
mov ah, 0
;---------
cseg ends
end main
So the project is basically about coding a calculator that can use the 4 basic operations: addition, subtraction, multiplication, and division, in assembly language. I'm sorry but the comments are written in French I guess you won't need them to understand the code anyway.
May help: My teacher said that I reported a stack segment that doesn't belong to where it is placed.
When I run the code I get these errors :
(56) error A2006: undefined symbol : scan_num
(89) error A2006: undefined symbol : scan_num
(100)error A2006: undefined symbol : do_plus
(103)error A2006: undefined symbol : do_minus
(106) error A2006: undefined symbol : do_mult
(109) error A2006: undefined symbol : do_div
(128) error A2006: undefined symbol : main
Here is my code:
SSEG SEGMENT STACK
DB 32 DUP("STACK---")
SSEG ENDS
;===========================================================code segment
assume cs:cseg, ds:cseg, es:cseg
cseg segment
org 100h
;----------
name "CALCULATRICE"
PUTC MACRO char
PUSH AX
MOV AL,char
MOV AH, 0Eh
INT 10h
POP AX
ENDM
jmp start
;------------- Zone de donnée
msg0 db "BELLAL MOHAMED BUT1 2021/2022",0Dh,0Ah
db "CALCULATOR3000 gerant les quatres opérations basiques ( + - * / )",0Dh,0Ah,"quot;
msg1 db 0Dh,0Ah,0Dh,0Ah, "Entrer le premier terme de l'opération: quot;
msg2 db "Choisissez l'opérateur à utiliser: + - * / : quot;
msg3 db "Entrer le second terme de l'opération: quot;
msg4 db 0Dh, 0Ah,"Le résultat est: quot;
msg5 db 0Dh, 0Ah," ",0Dh,0Ah,"quot;
err1 db "Saisie incorrecte",0Dh,0Ah,"quot;
smth db "Et .... quot;
opr db "?" ; variable contenant l'opérateur
num1 dw ? ; variable contenant le premier terme de l'opération
num2 dw ? ; variable contenant le deuxième terme de l'opération
;--------------- PROGRAMME
start:
mov dx, offset msg0
mov ah, 9
int 21h
lea dx, msg1
mov ah, 09h ; afficher le premier message
int 21h
; récupérer un nombre saisi par l'utilisateur et on le stock dans
; le registre CX
call scan_num
mov num1, cx ; stocker le nombre dans num1
; nouvelle ligne
putc 0Dh
putc 0Ah
lea dx, msg2
mov ah, 09h ; affiche le deuxième message
int 21h
; récupérer l'opérateur
mov ah, 1
int 21h
mov opr, al
; nouvelle ligne
putc 0Dh
putc 0Ah
cmp opr, "q" ; q pour quitter
je exit
cmp opr, "*"
jb wrong_opr
cmp opr, "/"
ja wrong_opr
lea dx, msg3
mov ah, 09h
int 21h
call scan_num
mov num2, cx
lea dx, msg4
mov ah, 09h
int 21h
;------------- CALCULER
cmp opr, "+"
je do_plus
cmp opr, "-"
je do_minus
cmp opr, "*"
je do_mult
cmp opr, "/"
je do_div
;---------- CAS PAR DEFAUT
wrong_opr:
lea dx, err1
mov ah, 09h
int 21h
exit:
lea dx, msg5
mov ah, 09h
int 21h
mov ah, 0
;---------
cseg ends
end main
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用代码标签作为指令操作数,则它也需要在您的代码中与结肠在其线路上的某个地方存在,或者如果您的汇编程序允许,则它也需要与colon一起使用。
您可能已经注意到,您没有看到
forgation_opr
的类似错误消息。那是因为您在源代码中具有该标签。您会收到其他标签的错误消息,因为它们不在您的程序中。
这是我现在修复它的方法:
然后您可以执行以下操作。我故意以次优的方式编写了这篇文章,以使其更容易阅读。
那应该足以使这些错误消失。当然,您仍然必须弄清楚如何完成任务。
If you use a code label as an instruction operand, it needs to also exist somewhere in your code on its own line with a colon after it, or a
proc
statement if your assembler allows it.You may have noticed that you didn't see a similar error message for
wrong_opr
. That's because you have that label in your source code.You got the error messages for the other labels because they're not in your program.
Here's how I'd fix it for now:
And then you can do the following. I purposely wrote this in a sub-optimal manner to make it easier to read.
That should be enough to get those errors to go away. Of course, you'll still have to figure out how you want to accomplish the task.