Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Initialization
- *= $200 ; Start at $200 -> 512
- io_clrw = $E000
- io_putc = $E001
- io_putn = $E002
- io_puth = $E003
- io_getc = $E004
- io_chol = $E005
- io_cvel = $E006
- ; Start Calculator System
- STA io_clrw ; Clean Screen
- LDY #$0
- InputLoop: ; <--------------------------------------------------+
- JSR Input ; |
- ;JSR Output ; |
- PHA ; |
- JSR IsNumber ; |
- JSR Outhex ; |
- PLA ; |
- STA InputString, Y ; |
- INY ; |
- ; |
- ; if Input == KEY_ENTER |
- CMP #$0D ; jmp InputLoopFail ---+ |
- BEQ InputLoopCalc ; else | |
- JMP InputLoop ; jmp InputLoop -----|--+
- InputLoopCalc: ; <--------------------------+
- JSR Error
- JMP Exit ; -------+
- InputLoopError: ; |
- JSR Error ; |
- JMP Exit ; -------+
- ; |
- ; v
- ; |
- Exit: ; <------+
- BRK ; End of Program
- ; Subroutines (Standard)
- Output ; input: ascii char per Accumulator
- STA io_putc
- RTS
- Outhex ; input: ascii char per Acumulator
- STA io_puth
- RTS
- Input ; output: ascii char per Accumulator
- .Input_wait:
- LDA io_getc
- BEQ .Input_wait
- RTS
- Error ;
- LDA #'E'
- STA io_putc
- LDA #'r'
- STA io_putc
- STA io_putc
- PHA
- LDA #'o'
- STA io_putc
- PLA
- STA io_putc
- RTS
- IsNumber
- CMP #$39
- BCC .IsNumber_Next
- JMP .IsNumber_Not
- .IsNumber_Next:
- CMP #$30
- BCS .IsNumber_True
- JMP .IsNumber_Not
- .IsNumber_True:
- LDA #$1 ; True
- JMP .IsNumber_Exit
- .IsNumber_Not:
- LDA #$0 ; False
- JMP .IsNumber_Exit
- .IsNumber_Exit:
- RTS
- PrintString
- RTS
- ; Subroutines (Calc)
- ; Global Variables
- InputString: .DB $00
- ; Global Constants
- KeyEnter: .BYTE $0D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement