I am trying to reverse my own code, its 16-bit Real mode assembly. I wrote the following function:
inc di
mov cx , [di]
add cl , 0x46
jo exit
sub cl , 0x46
cmp cl , '0'
jl exit
sub cl , '5'
jns exit
jnp exit
after I compiled it and run in Qemu, the code is changed into the following code:
as you can see the first 3 line are different:
inc edi
mov ecx, DWORD PTR ds:0x7046c180
BYTE PTR es:[edi],dx
how this is possible? how the cpu knows to perform the commands:
mov cx , [di]
add cl , 0x46
jo exit
as far as I know the command :
mov ecx, DWORD PTR ds:0x7046c180
move the data from the pointer 0x7046c180
to ecx
, but it's equal to 00000000
.
Can someone explain to me why the compiler changed my instruction into this, and how it is working the same as my code without the jo
instruction?