home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / sysutl / system.lbr / SYSTEM.AZM / SYSTEM.ASM
Encoding:
Assembly Source File  |  1988-01-31  |  2.9 KB  |  108 lines

  1. ;************************************************************************
  2. ;*                                    *
  3. ;*    SYSTEM.ASM:  Simple, dumb routine to jump anywhere in memory.    *
  4. ;*    At the prompt, input a hex number, or a slash (/) followed    *
  5. ;*    by a decimal number.  Control is then passed to that address.    *
  6. ;*    Useful for jumping to ROM monitors, etc.  Written by        *
  7. ;*    Mark D. Pickerill  28 January 1988.                *
  8. ;*                                    *
  9. ;************************************************************************
  10.                 ;
  11. CR:    EQU    0DH        ; Carriage return
  12. LF:    EQU    0AH        ; Line feed
  13. BDOS:    EQU    0005H        ; Bdos entry point
  14.                 ;
  15.     ORG    0100H        ; The usual start of tpa bs...
  16.                 ;
  17. SYSTEM:    MVI    C,09H        ; Print string function
  18.     LXI    D,PROMPT    ; Point at prompt
  19.     CALL    BDOS        ; Print it
  20.     JMP    AROUND        ; Around string
  21. PROMPT:    DB    CR,LF,LF,'*? $'    ; Prompt
  22.                 ;
  23. INBUF:    DB    0AH,00H        ; Ten characters max, zero char. count
  24.     DB    00H,00H,00H,00H    ; Four more zeroed buffer locations
  25.     DB    00H,00H,00H,00H    ; Four more
  26.     DB    00H,00H,00H    ; Total of 11, one padded for safety
  27.                 ;
  28. AROUND:    MVI    C,0AH        ; Read console buffer
  29.     LXI    D,INBUF        ; Point to pre-initialized buffer
  30.     CALL    BDOS        ; Get it
  31.     LDA    INBUF+1        ; Get actual characters read
  32.     ORA    A        ; Force flags
  33.     JZ    EXIT        ; No characters, exit
  34.     LXI    H,INBUF+2    ; Beginning of data in buffer
  35.     MOV    A,M        ; Get byte
  36.     CPI    '/'        ; Slash for decimal?
  37.     JZ    DECIMAL        ; Yes
  38.     XCHG            ; Save buffer pointer
  39.                 ;
  40. READHL:    LXI    H,0000        ; Clear
  41. RDHL2:    XCHG            ; Restore buffer pointer
  42.     MOV    A,M        ; Get character
  43.     INX    H        ; Next
  44.     XCHG            ; Re-save buffer pointer
  45.     ORA    A        ; Force flags
  46.     JZ    GO        ; Line end
  47.     CPI    'Z'+1        ; Upper case?
  48.     JC    JAWOHL        ; Yes
  49.     ANI    5FH        ; Make upper case
  50. JAWOHL:    CALL    NIB        ; To binary
  51.     JC    EXIT        ; Not hex
  52.     DAD    H        ; Times 2
  53.     DAD    H        ; Times 4
  54.     DAD    H        ; Times 8
  55.     DAD    H        ; Times 16
  56.     ORA    L        ; Add new char
  57.     MOV    L,A        ;
  58.     JMP    RDHL2        ; Next
  59.                 ;
  60. GO:    PCHL            ; Go there
  61.                 ;
  62.                 ; Convert ascii characters to binary
  63.                 ;
  64. NIB:    SUI    '0'        ; Ascii bias
  65.     RC            ; <0
  66.     CPI    'F'-'0'+1    ;
  67.     CMC            ; Invert
  68.     RC            ; Error, >f
  69.     CPI    10        ;
  70.     CMC            ; Invert
  71.     RNC            ; Number is 0-9
  72.     SUI    'A'-'9'-1    ;
  73.     CPI    10        ; Skip : to
  74.     RET            ; Letters a-f
  75.                 ;
  76. DECIMAL:INX    H        ; Point past /
  77.                 ; Ascii decimal to 16 bit in hl
  78.     XCHG            ; Save pointer
  79.     LXI    H,0000        ; Clear
  80. DBIN2:    XCHG            ; Get pointer
  81.     MOV    A,M        ; Get byte
  82.     INX    H        ; Point to next
  83.     XCHG            ; & save
  84.     ORA    A        ; Force flags
  85.     JZ    GO        ; Line end
  86.     SUI    '0'        ; Convert to bin
  87.     JC    EXIT        ; <0
  88.     CPI    10        ;
  89.     JNC    EXIT        ; >10
  90.     MOV    B,H        ; Copy hl
  91.     MOV    C,L        ; Into bc
  92.     DAD    H        ; Times 2
  93.     DAD    H        ; Times 4
  94.     DAD    B        ; Times 5
  95.     DAD    H        ; Times 10
  96.     MOV    C,A        ; New byte
  97.     MVI    B,0        ; Clear
  98.     DAD    B        ; Add new byte
  99.     JMP    DBIN2        ; Next
  100.                 ;
  101. EXIT:    MVI    C,09H        ; Print string
  102.     LXI    D,BAD        ; Bad input, abort
  103.     CALL    BDOS        ; Print it
  104.     RET            ; To bdos
  105.                 ;
  106. BAD:    DB    CR,LF,LF,'?',CR,LF,'$'
  107.     END            ; Of line
  108.