FriedSpace.com

Space for Cooking up Great Ideas

Space for Cooking up Great Ideas

FriedSpace

Assembly Language

Announcements

Since each bit of a register or memory location can store a one or a zero, we have to learn about binary arithmetic.

This is similar to the ordinary decimal (base 10) arithmetic that we are used to, except instead of there being 10 possible digits in each place (0-9), there are now only two possible digits we can use (0-1).

This means that the places in binary numbers correspond to powers of 2. The following table illustrates this.

Binary | Decimal |

1 | 2^0 = 1 |

10 | 2^1 = 2 |

100 | 2^2 = 4 |

1000 | 2^3 = 8 |

10000 | 2^4 = 16 |

100000 | 2^5 = 32 |

1000000 | 2^6 = 64 |

10000000 | 2^7 = 128 |

To make other binary numbers, we simply add powers of 2 together. For example:

Binary | Decimal |

1101 | 2^3 + 2^2 + 2^0 = 8 + 4 + 1 = 13 |

101 | 2^2+2^0 = 4 + 1 = 5 |

1001 | 2^3 + 2^0 = 8 + 1 = 9 |

10100 | 2^4 + 2^2 = 16 + 4 = 20 |

Each number can be expressed uniquely as a binary number.

To write a binary number in assembly language, we append a `b` to the number to indicate that it is binary, e.g. `11010110b`. This corresponds to the decimal number 214. So now we have two ways to move the number 214 into a register, e.g.

MOV AH, 11010110b MOV BH, 214