Numbering systems (Notes)

http://www.emu8086.com/assembler_tutorial/numbering_systems_tutorial.html 1. Decimal System

 

1. Decimal System

Note:

2. Binary System

  

3. Hexadecimal System

Decimal
(base 10)
Binary
(base 2)
Hexadecimal
(base 16)
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F
 

4. Converting from decimal system to any other

divide the decimal value by the base of the desired system,

remember the result and keep the remainder,

the divide process continues until the result is zero.


The remainders are then used to represent a value in that system


EXAMPLES

a. From decimal to hexadecimal
Let's convert the value of 39 (base 10) to Hexadecimal System (base 16): 

 

As you see we got this hexadecimal number: 27h.
All remainders were below 10 in the above example, so we do not use any letters. 

Here is another more complex example:
let's convert decimal number 43868 to hexadecimal form:

 

 

b. From decimal to binary
Method 1: using 2 as the divider

Method 2: convert to hexadecimal number, and then convert it to binary number:

 

As you see we got this binary number: 1010101101011100b

 

5. Signed Numbers 


There is no way to say for sure whether the hexadecimal byte 0FFh is positive or negative, it can represent both decimal value "255" and "- 1". 

8 bits can be used to create 256 combinations (including zero), so we simply presume that first 128 combinations (0..127) will represent positive numbers and next 128 combinations (128..256) will represent negative numbers. 

In order to get "- 5", we should subtract 5 from the number of combinations (256), so it we'll get: 256 - 5 = 251

Using this complex way to represent negative numbers has some meaning, in math when you add "- 5" to "5" you should get zero.
This is what happens when processor adds two bytes 
5 and 251, the result gets over 255, because of the overflow processor gets zero! 

 

When combinations 128..256 are used the high bit is always 1, so this maybe used to determine the sign of a number. 

The same principle is used for words (16 bit values), 16 bits create 65536 combinations, first 32768 combinations (0..32767) are used to represent positive numbers, and next 32768 combinations (32767..65535) represent negative numbers.



There are some handy tools in emu8086 to convert numbers, and make calculations of any numerical expressions, all you need is a click on Mathmenu: 

 

Base converter allows you to convert numbers from any system and to any system. Just type a value in any text-box, and the value will be automatically converted to all other systems. You can work both with 8 bit and 16 bit values. 

Multi base calculator can be used to make calculations between numbers in different systems and convert numbers from one system to another. Type an expression and press enter, result will appear in chosen numbering system. You can work with values up to 32 bits. When Signed is checked evaluator assumes that all values (except decimal and double words) should be treated as signed. Double words are always treated as signed values, so 0FFFFFFFFh is converted to -1.
For example you want to calculate: 0FFFFh * 10h + 0FFFFh (maximum memory location that can be accessed by 8086 CPU). If you check Signed andWord you will get -17 (because it is evaluated as (-1) * 16 + (-1) . To make calculation with unsigned values uncheck Signed so that the evaluation will be 65535 * 16 + 65535 and you should get 1114095
You can also use the base converter to convert non-decimal digits to signed decimal values, and do the calculation with decimal values (if it's easier for you). 

These operation are supported:


~       not (inverts all bits).
*       multiply.
/       divide.
%       modulus.
+       sum.
-       subtract (and unary -).
<<      shift left.
>>      shift right.
&       bitwise AND.
^       bitwise XOR.
|       bitwise OR.


Binary numbers must have "b" suffix, example:
00011011b

Hexadecimal numbers must have "h" suffix, and start with a zero
when first digit is a letter (A..F), example:
0ABCDh

Octal (base 8) numbers must have "o" suffix, example:
77o

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值