I have this very simple assembly code:
start:
add ax, 100
; if ax overflow add to bx 1
jmp start
but i don't know how to detect ax register overflow, can anyone help me?
ADD instruction sets appropriate FLAGS reflecting the overflow condition. There are two kinds of overflow: signed and unsigned. You have to decide what's appropriate and use jc/jnc for unsigned and jo/jno for signed.
add ax, 100
jnc noUnsignedOverflow
...
noUnsignedOverflow:
add ax, 100
jno noSignedOverflow
...
noSignedOverflow:
Use jo (jump if overflow) or jno (jump if no overflow)
Check out the Intel x86 JUMP quick reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With