how processor interprets signed and unsigned numbers .......

Started by Vineel Kumar Reddy Kovvuri, May 18, 2007, 02:23:51 PM

Previous topic - Next topic

Vineel Kumar Reddy Kovvuri



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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vineel Kumar Reddy Kovvuri



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......

tenkey

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.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

Vineel Kumar Reddy Kovvuri



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






dsouza123

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.