The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Vineel Kumar Reddy Kovvuri on May 18, 2007, 02:23:51 PM

Title: how processor interprets signed and unsigned numbers .......
Post by: Vineel Kumar Reddy Kovvuri on May 18, 2007, 02:23:51 PM


Hi everybody

I am new to assembly .
I have few doubts  plz help me.
the question is when ever we perform
the following operation

mov al,11111111b

after the execution of the above instruction
how does the processor interpret the
value in al ?
whether it interpret the value in al to
-1 or it interpret the value in al to 255

thanks in advance
Title: Re: how processor interprets signed and unsigned numbers .......
Post by: hutch-- on May 18, 2007, 03:12:04 PM
It doesn't, to draw the distinction between signed and unsigned numbers, you evaluate the number in the register with things like different conditional jumps. Its the distinction between menmonics like JA versus JG and many others like it that give you the difference.
Title: Re: how processor interprets signed and unsigned numbers .......
Post by: Vineel Kumar Reddy Kovvuri on May 18, 2007, 04:10:31 PM


How is the processor able to set the status register . If it doesn't know the distinction.   :'(

consider the following
mov  al,11111111b
inc al

the above instruction is changing only auxially flag. why is not setting carry flag ??? even though there is a carry out of al byte                                             

can some one help me when these status flags are set and when they are not .......

please help meee......
Title: Re: how processor interprets signed and unsigned numbers .......
Post by: tenkey on May 18, 2007, 05:14:43 PM
You don't want CF to change during a multiprecision ADD (using ADC). INC allows you to update addresses without affecting CF. This is a holdover from the Intel 8080, which did not have a full blown LEA instruction. It's also shorter than the equivalent LEA instruction.

If you want to check both signed and unsigned overflow, you need to use the standard ADD instruction.

The Intel documents tell all.

A simplified system to use:

* ADD/ADC, SUB/SBB, and CMP to set all arithmetic flags
* assume only ZF is predictable for INC/DEC, and CF is untouched
* AND, OR, and TEST to set nonoverflow flags (overflow flags are cleared)
* assume only CF is predictable for the shift and rotate instructions

Check the documents for full information.
Title: Re: how processor interprets signed and unsigned numbers .......
Post by: Vineel Kumar Reddy Kovvuri on May 18, 2007, 06:38:50 PM


thank you sir for mentioning that inc will not change CF flag

Can you please telll me
when a cmp instruction is executed what flags will be
effected and when will they get affected by considering following cases

1.The operands are unsigned
2.The operands are signed
3.One operand is signed and other is unsigned


thanks in advance





Title: Re: how processor interprets signed and unsigned numbers .......
Post by: dsouza123 on May 18, 2007, 11:38:23 PM
Use help files such as opcodes.hlp that comes with MASM32
for each instruction it mentions what flags if any are modified/referenced
another usefull file is x86eas.hlp

Using either it would show inc does not modify the carry flag.

The CPU isn't treating numbers as signed or unsigned
it just always sets the flags according to its circuitry,
just bit manipulations that are tested for,
using various other instructions.

To learn you need to lookup instructions in help files,
write code, and debug it to see if your understanding
of the instructions is correct.

Examine the files opcodes.hlp and x86eas.hlp for flags affected.
Or run the code through an assembly level debugger such as
Ollydbg a very good debugger available online.