Last active
August 6, 2026 08:17
-
-
Save LightningStalker/4c41ed79d1c175bebb00a6d388c35057 to your computer and use it in GitHub Desktop.
read ASCII hexidecimal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; read hex value from ASCII | |
| ASC equ $fa ; ASCII char passed in | |
| RESULT equ $fb ; result location | |
| org $300 ; Apple II small program area | |
| start: | |
| lda ASC ; mov char -> accumulator | |
| cmp #$3a ; >= ':'? | |
| bcs isalpha ; could be 0xa - 0xf | |
| cmp #$30 ; '0' | |
| bcc err ; <? | |
| and #$f ; A - $30 | |
| sta RESULT ; ready | |
| rts ; done | |
| isalpha: | |
| cmp #$67 ; 'g' | |
| bcs err ; >=? | |
| sbc #0 ; carry should be set: - 1 | |
| and #$1f ; mask high bits | |
| cmp #6 ; 'G' or 'g' | |
| bcs err ; >=? | |
| adc #10 ; align to value | |
| sta RESULT ; return answer | |
| rts | |
| err: ; error known | |
| lda #$ff ; return 0xff | |
| sta RESULT | |
| rts | |
| brk | |
| ; BRUN READHEX | |
| ldx #0 | |
| test: | |
| stx ASC | |
| jsr start | |
| sta $2000, x | |
| inx | |
| bne test | |
| brk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment