*** Commodore 64 machine code for beginners *** To make things easy using the monitor (eg. `ACTION REPLAY`) you can consider the Commodore 64 is made up of a street with 65536 (0 - 65535) addresses, at each address there is a house (byte). In each house there are 8 rooms (bits 0 to 7). A room (bit) can be furnished a certain amount of furniture (bit code) and if so the room is classed full.A room with no furntiure placed in it then the room is classed as empty. If the 8 rooms with furniture and the furniture added together (0 to 255max.) they will make a value number (furnished amount) that is in the house. From now on in this manual we will call houses `bytes` , rooms `bits` and furniture `bit code`. If bit `0` is full then the `bit code` is `1` If bit `1` is full then the `bit code` is `2` If bit `2` is full then the `bit code` is `4` If bit `3` is full then the `bit code` is `8` If bit `4` is full then the `bit code` is `16` If bit `5` is full then the `bit code` is `32` If bit `6` is full then the `bit code` is `64` If bit `7` is full then the `bit code` is `128` If a `bit` is empty the `bit code` is zero. If all the 8 `bits` are empty then the value number for the byte is zero. To program in machine code we simply store a number value in each available byte that we need.We can increase or decrease its value if needed. Using the number value in a byte with a given command the program can be made to shift from one address to another address. Example:- Address Code C ommand C000 AD C5 00 LDA $00C5 C003 C9 3C CMP #$3C C005 D0 F9 BNE $C000 C007 4C 21 C0 JMP $C021 C00A <= next available address. The above program indicates a jump to address C021 if `space` key is pressed.The program uses addresses C000 to C009.Ten bytes in all are used up. A byte can only hold a number value in the range of 0 to 255. A byte number value is made up of bits that are full with their bit codes added together,otherwise with no bit codes the byte number value is zero. Example:- value number `132` can be put in byte address `49152` Bit 7 6 5 4 3 2 1 0 * * Bit code when fu ll 128 64 32 16 8 4 2 1 In the above example the asterisks show that bits 7 and 2 are made full. The remaining six bits are empty. Add bits 7 and 2 values together you will get 132. In order that we can use the monitor (eg.`ACTION REPLAY`),it uses a language that uses numbers that are in `hex.`. Decimal works with a base of 10. Hex works with a base of 16. Example:- De c. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 5 Hex. 0 1 2 3 4 5 6 7 8 9 A B C D E F As you see in the above example numbers from 10 to 15 in hex are letters,so `194` in decimal would be `C2` in hex. Example:- left character right character Bit 7 6 5 4 3 2 1 0 * * * Dec. bit code 128 64 32 16 8 4 2 1 Hex. bit code 8 4 2 1 8 4 2 1 Add the asterisk number values for the left character then for the right character to get the number`C2` (`194` decimal). A hex number and zero page addresses are always made up of 2 characters.Zero page addresses are in the range of 00 to FF (hex.) (0 to 255 decimal). Normally hex addresses are always made up of 4 characters. Example:- `C000` (hex.) (`49152` decimal). Here is a table for decimal addresses to be changed to hex addresses with the above example:- 1st char. 2nd char. 3rd char. 4th char. De c. 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 Hex. 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 * * Add the asterisk value numbers together to get `C000` (hex.) (`49152` decimal).