Amos Professional Manual  Contents  Index

# App. A: Machine Code

AMOS Professional Basic includes a range of commands that provide the advanced programmer with total access to the inner workings of the Amiga's hardware. In experienced hands these instructions can be invaluable. But be warned, if you are not completely sure what you are doing, these commands may be lethal for your programs!

All the important hardware routines are built in to AMOS Professional Basic, allowing you to exploit the Amiga's full potential using the simple commands already detailed in this User Guide. In other words, if you prefer to opt for the simple life, you are free to ignore this machine code section altogether. You certainly do not need these functions to create superb computer games.

Converting numbers
Human beings normally count in multiples of ten, based on the number of fingers most of us possess. These "decimal" numbers are expressed by a group of characters from 0 to 9, and the relative position of these "digits" determines whether a character represents the number of ones, or tens, or millions, and so on.

So in the decimal system, the number 1234 is equivalent to:

```1*1000 + 2*100 + 3*10 + 4
```

Computers do not posses ten fingers, but count in a "binary" system instead, which means that each digit can only be in one of two possible states, non-existent or existent. This is represented by either a 0 or a 1.

As with the decimal system, the meaning of a binary digit depends entirely on its position in a binary number. Both systems rely on the fact that the value of digits change depending on their position from right to left in the number. The human system uses a base of ten, but the computer prefers a base of 2. So as you move from right to left, the values of binary numbers increase by a factor of two. In other words, the digit at the extreme right of a binary number represents the number of ones, the next one along represents the number of twos, then fours, eights, and so on.

Examine the number 15. In the decimal system this is depicted as follows:

```1*10 + 5
```

But in binary, the same number is stored like this:

```1*8 + 1*4 + 1*2 + 1
```

Which can be written as follows:

```1111
```
Back    Next
14.A.01