FriedSpace.com

Space for Cooking up Great Ideas

Space for Cooking up Great Ideas

FriedSpace

Assembly Language

Announcements

Since it is rather annoying to write out many ones and zeroes, there is a shorthand way of writing binary, called hexadecimal. Each four binary bits are encoded by a single hexadecimal digit. Here is a table showing what each hexadecimal digit stands for.

Hexadecimal | Binary | Hexadecimal | Binary |

0 | 0000 | 8 | 1000 |

1 | 0001 | 9 | 1001 |

2 | 0010 | A | 1010 |

3 | 0011 | B | 1011 |

4 | 0100 | C | 1100 |

5 | 0101 | D | 1101 |

6 | 0110 | E | 1110 |

7 | 0111 | F | 1111 |

To write hexadecimal numbers in assembly language, we append the number with an `h` and prepend it with a 0. So now we have a third way of writing the number 214 in assembly language. It is `0D6h`.

We can also specify numbers to be moved into registers, in hexadecimal.

MOV CH,0D6h

Of course hexadecimal is base 16, where there are 16 different possibilities for each digit (0-F), and where each place corresponds to a power of 16.

E.g. `045C3h` corresponds to the decimal number `4x16^3 + 5x16^2 + 12x16^1 + 3x16^0 = 16384 + 1280 + 192 + 3 = 17859.`