汇编语言中的 IF ELSE 和 ENDIF 指令是什么?我正在尝试制作一个程序,其中显示一些条件真实消息
Dosseg
.model small
.stack 100h
.data
X db 89
z db ?
msg1 db "helooquot;
.code
main proc
mov ax,@data
mov ds,ax
mov z,offset x
;X=89
Y=-3
IF (z LT 0) OR (z GT 79)
lea dx,msg1
mov ah,9
int 21h
ENDIF
IF (Y LT 0)
lea dx,msg1
mov ah,9
int 21h
ENDIF
mov ah,4ch
int 21h
MAIN ENDP
END MAIN
Dosseg
.model small
.stack 100h
.data
X db 89
z db ?
msg1 db "helooquot;
.code
main proc
mov ax,@data
mov ds,ax
mov z,offset x
;X=89
Y=-3
IF (z LT 0) OR (z GT 79)
lea dx,msg1
mov ah,9
int 21h
ENDIF
IF (Y LT 0)
lea dx,msg1
mov ah,9
int 21h
ENDIF
mov ah,4ch
int 21h
MAIN ENDP
END MAIN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如问题所示,
if
else
endif
是包含或排除汇编代码行的汇编时间条件。在 Microsoft Masm(6.11 或更高版本)中,.if
.else
.endif
是运行时条件。链接到 Masm 点指令:https: //learn.microsoft.com/en-us/cpp/assembler/masm/directives-reference?view=msvc-170
As shown in the question,
if
else
endif
are assembly time conditionals that either include or exclude lines of assembly code. In Microsoft Masm (6.11 or later),.if
.else
.endif
are run time conditionals. Link to Masm dot directives:https://learn.microsoft.com/en-us/cpp/assembler/masm/directives-reference?view=msvc-170
在结构化编程中,我们有 if-then 语句,它的模式如下:
在汇编语言的 if-goto-label 风格(仍然是 C 语言)中,相同的模式如下:
在 if-goto-label 风格中,我们告诉程序何时跳过 then 部分,与 C 相比,我们告诉程序何时执行 then 部分。因此,需要否定 if-goto-label 的条件。
构造
if ( condition ) goto endIf1;
是条件分支的 C 版本。在汇编语言中,条件分支通常作为比较和比较来完成。分支序列。例如:变为:
变为:
In structured programming we have the if-then statement, which has a pattern like this:
In assembly language's if-goto-label style (while still in C) the same pattern is like this:
In the if-goto-label style, we tell the program when to skip the then-part, as compared with C where we tell the program when to execute the then-part. Thus, the condition for if-goto-label needs to be negated.
The construct
if ( condition ) goto endIf1;
is C's version of a conditional branch. In assembly language that conditional branch is usually done as a compare & branch sequence. For example:becomes:
which becomes:
以下是使用
ifdef
的适当时机的示例:Here's an example of an appropriate time to use
ifdef
: