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: