8.0 Some things about numbers
Using an integer in most programming languages or floating point only depends on the declaration of the variable. In assembly language, it is completely different. The calculation of floating point numbers is done by special pseudo code and FPU coordinator (floating point unit). Floating point instructions will be discussed later. Let's take a look at some things about integers. There is a Signed integer and unsigned (no symbol) integer in the C language. Signed is intended to have a number of symbols ( or -). Unsigned is always positive. Find out the difference in the table below (again, this is an example of Byte, which works in other big hours).
value
00
01
02
03
...
7f
80
...
FC
FD
FE
FF
No symbolic meaning
00
01
02
03
...
7f
80
...
FC
FD
FE
FF
Significance
00
01
02
03
...
7f
-80
...
-04
-03
-02
-
Therefore, in the number of symbols, a Byte is divided into two sections: 0 ~ 7f for positive values. 80 ~ ff is used for negative values. For DWORD values, it is also the same: 0 ~ 7FFFFFFH is positive, 80000000 ~ ffffffh is negative, just as you may have noticed, the highest bit of negative value has a collection because they are larger than 80000000H. This is called symbol bit.
3. 1 Is there a symbol or no symbol?
You and the processor can't see that a value is Signed or unsigned. The good news is for addition and subtraction, one number is Signed or unsigned does not matter.
Calculate: -4 9
Fffffffc 00000009 = 00000005 (this is right)
Calculate: 5 - (- 9)
00000005-ffffffff7 = 0000000E (this is also right, 5--9 = 4)
The bad news is not the case for multiplication, division and comparison (COMPARE). Therefore, there is special preparation pseudo code for Signed number: IMUL and IDIV
Imul also has a good place than Mul lies in it can accept direct value:
Immied Imul Dest, SRC, 8-Bit Immedimul Dest, SRC
IDIV SRC
They are almost almost the same as MUL, DIV, just they can calculate the SIGNED value. Comparison (Compare) can be used as unsigned. But logo makes different settings. Therefore, there are different JUMP instructions for symbols and unsigned numbers:
CMP AX, BXJA Somewhere
JA is an unsigned jump instruction. If it is greater than jump. Considering this AX = FFFH (FFFFH when no symbols, it is -1) and BX = 0005H (5 in no symbols, 5). Since fffh is larger than 0005 when no symbols, JA instructions will jump, but if it is JG (refer to a symbol jump):
CMP AX, BXJG Somewhere
The JG instruction will not jump because -1 is not 5 big.
Just remember this: