Advertisement
c32

command parser not debugged

c32
Dec 3rd, 2018
3,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.88 KB | None | 0 0
  1. ld de,0;the command char pointer
  2.  
  3. exx ; switch bc , de and hl with their shadow ones
  4. ld b,1 ; the command char pointer for the bit instruction. it counts as bits so 1=00000001 2=00000010 3=00000100
  5. ld c,0 ; the blacklist
  6. exx ; go back to the normal bc de and hl
  7.  
  8. ld iy,COMMAND_TABLE; iy beacaus we can use it as a pointer to something with an offset in hust 2 bytes!
  9. ld hl,COMMAND_TABLE
  10.  
  11. call wait_for_a_key_and_then_put_it_in_the_c_register_without_modfying_any_other_register
  12. xor 13 ; is it the ascii code for carrage return?
  13. jr z,done ; our job is done, the shadow c holds the blacklist
  14.  
  15. ld b,(iy+1) ; get the pointer to the string of the commands from the COMMAND_TABLE to bc
  16. ld c,(iy+0)
  17.  
  18. ld ix,0    ; move bc to ix
  19. add ix,bc
  20.  
  21. add ix,de ; move the pointer of the string to the current char peing read
  22.  
  23. ld a,(ix+0) ; load the char from the current string and the current offset
  24.  
  25. xor b ; if b ( the char from the keyboard ) == a , the the zero flag will be set
  26.  
  27. jr z,SKIP_BLACKLIST
  28.  
  29. exx
  30. ld a,c
  31. or b ; now the bit corresponding the current command is set
  32. rlc c ; shift c one bit left , bit 7 goes to bit 0 and carry
  33. exx
  34. inc iy ; we haven't finished checking the 8 commands
  35. inc iy ; go to the next command in the  COMMAND_TABLE
  36. jr c,checknextchar ; if carry is set then we have gone through all bits of c so all 8 commands
  37. jr loop
  38. checknextchar:
  39. inc de ; check the new chars
  40. ld iy,COMMAND_TABLE ; lets check the first command first
  41. jr loop
  42.  
  43.  
  44.  
  45.  
  46. COMMAND_TABLE: ; make an array with pointers to the strings
  47. COMMAND0
  48. COMMAND1
  49. COMMAND2
  50. COMMAND3
  51. COMMAND4
  52. COMMAND5
  53. COMMAND6
  54. COMMAND7
  55.  
  56.  
  57. COMMAND0:.dm "reset",0xff ; the keyboard wont enter 0xff right?
  58. COMMAND1:.dm "poke",0xff ; null terminated strings
  59. COMMAND2:.dm "peek",0xff
  60. COMMAND3:.dm "boot_fuzix",0xff
  61. COMMAND4:.db 0xFF
  62. COMMAND5:.db 0xFF
  63. COMMAND6:.db 0xFF
  64. COMMAND7:.db 0xFF
  65.  
  66.  
  67. done: ; inspec the shadow c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement