The Monitor

There are 4 registers `A`, `X` , `Y` and `Carry flag` we can use to store a number in. `A` , `X` and `Y` can only hold a number value in the range of `00` to `FF`. `Carry flag` can only be set to zero (`00`) or `01`. List of commands:- CLC set carry flag to zero `00` SEC set carry flag to `01` ADC #$[ number ] add `A` with given number ADC $[ address ] add `A` with value in given address SBC #$[ number ] subtract `A` with given number SBC $[ address ] subtract `A` with value in given address LDA #$[ number ] load given number into `A` LDA $[ address ] load value in given address into `A` LDA $[ address ] , X " " " " " " " LDA $[ address ] , Y " " " " " " " LDA ( $[ zero page address ] , X ) " " " " " " " LDA ( $[ zero page address ] ) , Y " " " " " " " STA $[ address ] store value in `A` into given address STA $[ address ] , X " " " " " " " STA $[ address ] ,Y " " " " " " " STA ( $[ zero page address ] , X ) " " " " " " " STA ( $[ zero page address ] ) , Y " " " " " " " LDX #$ [ number ] load given number into `X` LDX $[ address ] load value in given address into `X` STX $[ address ] store value in `X` into given address LDY #$[ number ] load given number into `Y` LDY $[ address ] load value in given address into `Y` STY $[ address ] store value in `Y` into given address DEC $[ address ] decrease value in given address by `01` INC $[ address ] increase value in given address by `01` DEX decrease value in `X` by `01` INX increase value in `X` by `01` DEY decrease value in `Y` by `01` INY increase value in `Y` by `01` CMP #$[ number ] compare value in `A` with given number CMP $[ address ] compare value in `A` with given address CPX #$[ number ] compare value in `X` with given number CPX $[ address ] compare value in `X` with given address CPY #$[ number ] compare value in `Y` with given number CPY $[ address ] compare value in `Y` with given address BCC $[ address ] branch to given address if `Carry flag is set to `00` BCS $[ address ] branch to given address if `Carry flag` is set to`01` BMI $[ address ] branch to given address if result is minus BPL $[ address ] branch to given address if result is plus BEQ $[ address ] branch to given address if result is equal BNE $[ address ] branch to given address if result is not equal TAX transfere value in `A` into `X` TXA transfere value in `X` into `A` TAY transfere value in `A` into `Y` TYA transfere value in `Y` into `A` NOP go to next address JMP $[ address ] jump to given address JSR $[ address ] jump to given address saving leaving address RTS return to previous saved address and move to next address. CMP,CPX and CPY commands can only be immediate before BCC, BCS,BMI,BPL,BEQ or BNE commands. BCC, BCS,BMI,BPL,BEQ and BNE commands can only branch 126 addresses back or 128 addresses forward. You can set up 2 zero page addresses to make a secondary address. Example:- If you load `00` into address `$FB` and load `04` into address `$FC` you have a secondary address which is `$0400` and can read what value is in address `$0400` by the following program example:- .A 4000 LDA #$51 [load `A` with value `51`] .A 4002 STA $0400 [store value of `A` (`51`) into address `$0400`] .A 4005 LDA #$00 [load `A` with value `00`] .A 4007 STA $FB [store value of `A` (`00`) into address `$FB`] .A 4009 LDA #$04 [load `A` with value `04`] .A 400B STA $FC [store value of `A` (`04`) into address `$FC`] .A 400D LDX #$00 [load `X` with value `00`] .A 400F LDA ( $FB ,X ) [load `A` the value (`51`) of address `$0400`] .A 4011 STA $07C0 [store the value (`51`) of `A` into address `$07C0`] .A 4014 JMP$400D [jump to address 400D to keep program running] Please do not enter in the `Monitor` after the commands the `brackets [ ]` and the `information`.The information is only there for reference. When` programming` a `command` in the `Monitor` you must always put #$ before a number to tell the computer its a `number` and $ before an address to tell the computer its an `address`. The sign `$` also indicates if placed before an address or a number is to inform the computer the address or number is in hex. The above program at address `$400F` the command `LDA ( $FB , X )` reads what value is in secondary address `$0400` which is `a ball` printed on the top left hand screen and at address `$4011 ` the command `STA $07C0` prints ` the ball ` on the bottom left hand screen. Please note `LDX#$00` must always be written immediate before the secondary address command e.g. `LDA ($FB,X)` or e.g. `STA ($FB,X)` so that `X` will always be set to `00`. If you entered the above program in the `Monitor` you can run the program by clearing the screen by pressing `shift/home` on the keyboard and type .G4000 then press `Return` or you can type .X then press `Return` to return to `basic` and type SYS16384 then press `Return`. When you write a program line and enter it in the `Monitor` e.g. :- .A 4000 LDA #$00 The next address (e.g. .A 4002 ) will come up automatically for you next to use. Press `Return` after you type in a command. These above are just the commands I use. There are more commands for you in the book `Commodore 64 progammer`s reference guide` if you want to use them also for your programs.