汇编中的复杂 IF 语句 [英] complex IF statement in assembly
本文介绍了汇编中的复杂 IF 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How should I write such an if
statement in assembly?
if ((a == b AND a > c) OR c == b) { ...
Platform: Intel 32-bit machine, NASM syntax.
Update
For variable types and value, use whatever is more easy to understand. Integers would works fine for me, I guess.
解决方案
In generic assembly, it will be basically something like this (a
in ax
, b
in bx
, c
in cx
):
cmp bx, cx
jeq istrue
cmp ax, cx
jle isfalse
cmp ax, bx
jeq istrue
isfalse:
; do false bit
jmp nextinstr
istrue:
; do true bit
nextinstr:
; carry on
If there's no false bit, it can be simplified to:
cmp bx, cx
jeq istrue
cmp ax, bx
jne nextinstr
cmp ax, cx
jle nextinstr
istrue:
; do true bit
nextinstr:
; carry on
这篇关于汇编中的复杂 IF 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文