Assembly Language
Assembly Language
Bit value 1 1 1 1 1 1 1 1
Bit number 7 6 5 4 3 2 1 0
The value of a binary number is based on the presence of 1 bits and their positional value. So,
the value of a given binary number is −
1 + 2 + 4 + 8 +16 + 32 + 64 + 128 = 255
which is same as 28 - 1.
0 0 0
1 1 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
To convert a binary number to its hexadecimal equivalent, break it into groups of 4 consecutive
groups each, starting from the right, and write those groups over the corresponding digits of the
hexadecimal number.
Example − Binary number 1000 1100 1101 0001 is equivalent to hexadecimal - 8CD1
To convert a hexadecimal number to binary, just write each hexadecimal digit into its 4-digit
binary equivalent.
Example − Hexadecimal number FAD8 is equivalent to binary - 1111 1010 1101 1000
Binary Arithmetic
The following table illustrates four simple rules for binary addition −
0 1 1 1
+0 +0 +1 +1
=0 =1 =10 =11
Rules (iii) and (iv) show a carry of a 1-bit into the next left position.
Example
Decimal Binary
60 00111100
+42 00101010
102 01100110
A negative binary value is expressed in two's complement notation. According to this rule, to
convert a binary number to its negative value is to reverse its bit values and add 1.
Example
Number 53 00110101
Add 1 00000001
To subtract one value from another, convert the number being subtracted to two's complement
format and add the numbers.
Example
Subtract 42 from 53
Number 53 00110101
Number 42 00101010
Add 1 00000001
53 - 42 = 11 00001011
x: memory address
When the processor gets the numeric data from memory to register, it again reverses the bytes.
There are two kinds of memory addresses −
Absolute address - a direct reference of specific location.
Segment address (or offset) - starting address of a memory segment with the offset value.