News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Newbie Question: reset byte based on boolean argument

Started by kwadrofonik, February 22, 2007, 05:55:27 AM

Previous topic - Next topic

kwadrofonik

*sigh*

Once again after staring at the same code for long enough I figured out what I did wrong. I used XOR where there should have been a NAND. Removing the cmc solves the issue...


       cmp       edx, 1         ;if edx < 1 then CF = 1 else CF = 0
       sbb       ebx, ebx       ;if edx < 1 then ebx = -1 else ebx = 0
       
       movzx     ecx, byte [edi]
       and       ecx, ebx       ;if edx < 1 then ecx stays the same else ecx = 0
       sub       eax, ecx       ;subtract trailing byte

       inc       ebx            ;if ebx = -1 then ebx = 0 else ebx = 1
       sub       edx, ebx       ;if ebx = -1 then edx stays the same else edx = edx - 1



cheers