Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. ;---------------------------------------------------------------------
  2. ; Read (using bsread) a pair of ASCII chars representing a printable
  3. ; byte value, and convert it to that byte value, returning it in A.
  4.  
  5. asc_0 .equ 30
  6. asc_9 .equ 39
  7. asc_A .equ 41
  8. asc_F .equ 46
  9.  
  10. .area ZP
  11. rab_temp: .ds 1
  12. .area CODE
  13.  
  14. rd_ascii_byte: ; XXX test framework has 14 char limit
  15. jsr bsread
  16. jsr rab_decode
  17. asl ; store top nybble
  18. asl
  19. asl
  20. asl
  21. sta rab_temp
  22. jsr bsread
  23. jsr rab_decode
  24. ora rab_temp
  25. rts
  26.  
  27. ; Decode an ASCII char to a binary digit
  28. rab_decode: cmp #asc_0
  29. bmi rab_error
  30. cmp #asc_9+1
  31. bpl rab_hex
  32. sec
  33. sbc #asc_0 ; to numeric value
  34. rts
  35. rab_hex: cmp #asc_A
  36. bmi rab_error
  37. cmp #asc_F+1
  38. bpl rab_error
  39. sec
  40. sbc #asc_A-0A ; to numeric value
  41. rts
  42.  
  43. rab_error: brk ; let the test framework catch this
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement