home *** CD-ROM | disk | FTP | other *** search
- ;************************************************************************
- ;* *
- ;* SYSTEM.ASM: Simple, dumb routine to jump anywhere in memory. *
- ;* At the prompt, input a hex number, or a slash (/) followed *
- ;* by a decimal number. Control is then passed to that address. *
- ;* Useful for jumping to ROM monitors, etc. Written by *
- ;* Mark D. Pickerill 28 January 1988. *
- ;* *
- ;************************************************************************
- ;
- CR: EQU 0DH ; Carriage return
- LF: EQU 0AH ; Line feed
- BDOS: EQU 0005H ; Bdos entry point
- ;
- ORG 0100H ; The usual start of tpa bs...
- ;
- SYSTEM: MVI C,09H ; Print string function
- LXI D,PROMPT ; Point at prompt
- CALL BDOS ; Print it
- JMP AROUND ; Around string
- PROMPT: DB CR,LF,LF,'*? $' ; Prompt
- ;
- INBUF: DB 0AH,00H ; Ten characters max, zero char. count
- DB 00H,00H,00H,00H ; Four more zeroed buffer locations
- DB 00H,00H,00H,00H ; Four more
- DB 00H,00H,00H ; Total of 11, one padded for safety
- ;
- AROUND: MVI C,0AH ; Read console buffer
- LXI D,INBUF ; Point to pre-initialized buffer
- CALL BDOS ; Get it
- LDA INBUF+1 ; Get actual characters read
- ORA A ; Force flags
- JZ EXIT ; No characters, exit
- LXI H,INBUF+2 ; Beginning of data in buffer
- MOV A,M ; Get byte
- CPI '/' ; Slash for decimal?
- JZ DECIMAL ; Yes
- XCHG ; Save buffer pointer
- ;
- READHL: LXI H,0000 ; Clear
- RDHL2: XCHG ; Restore buffer pointer
- MOV A,M ; Get character
- INX H ; Next
- XCHG ; Re-save buffer pointer
- ORA A ; Force flags
- JZ GO ; Line end
- CPI 'Z'+1 ; Upper case?
- JC JAWOHL ; Yes
- ANI 5FH ; Make upper case
- JAWOHL: CALL NIB ; To binary
- JC EXIT ; Not hex
- DAD H ; Times 2
- DAD H ; Times 4
- DAD H ; Times 8
- DAD H ; Times 16
- ORA L ; Add new char
- MOV L,A ;
- JMP RDHL2 ; Next
- ;
- GO: PCHL ; Go there
- ;
- ; Convert ascii characters to binary
- ;
- NIB: SUI '0' ; Ascii bias
- RC ; <0
- CPI 'F'-'0'+1 ;
- CMC ; Invert
- RC ; Error, >f
- CPI 10 ;
- CMC ; Invert
- RNC ; Number is 0-9
- SUI 'A'-'9'-1 ;
- CPI 10 ; Skip : to
- RET ; Letters a-f
- ;
- DECIMAL:INX H ; Point past /
- ; Ascii decimal to 16 bit in hl
- XCHG ; Save pointer
- LXI H,0000 ; Clear
- DBIN2: XCHG ; Get pointer
- MOV A,M ; Get byte
- INX H ; Point to next
- XCHG ; & save
- ORA A ; Force flags
- JZ GO ; Line end
- SUI '0' ; Convert to bin
- JC EXIT ; <0
- CPI 10 ;
- JNC EXIT ; >10
- MOV B,H ; Copy hl
- MOV C,L ; Into bc
- DAD H ; Times 2
- DAD H ; Times 4
- DAD B ; Times 5
- DAD H ; Times 10
- MOV C,A ; New byte
- MVI B,0 ; Clear
- DAD B ; Add new byte
- JMP DBIN2 ; Next
- ;
- EXIT: MVI C,09H ; Print string
- LXI D,BAD ; Bad input, abort
- CALL BDOS ; Print it
- RET ; To bdos
- ;
- BAD: DB CR,LF,LF,'?',CR,LF,'$'
- END ; Of line