home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpmug
/
cpmug035.ark
/
HEXOUT.ASM
< prev
next >
Wrap
Assembly Source File
|
1984-04-29
|
2KB
|
59 lines
ORG 51ECH
* THE FOLLOWING TWO ROUTINES ARE USED TO DISPLAY HEX NUMBERS
* ON THE CRT SCREEN. THE FIRST PRINTS TWO DIGITS FROM THE BYTE IN
* REGISTER A. THE SECOND PRINTS FOUR DIGITS FROM THE WORD IN
* THE HL PAIR.
*
* THIS ROUTINE TAKES A NUMBER IN A, PRINTS IT AS HEXADECIMAL.
* -THANKS TO PHIL BUTLER FOR ALGORITHM
CO EQU 502AH
HEXPRT: PUSH PSW
PUSH PSW ;SAVE A COPY OF NUMBER
RRC
RRC
RRC
RRC ;SLIDE HI-NYBBLE TO RIGHT 4 BITS
ANI 0FH ;STRIP OFF OTHER NYBBLE
CALL HCHOUT ;PRINT LEFT NYBBLE
POP PSW ;GET COPY BACK
ANI 0FH
CALL HCHOUT ;PRINT RIGHT NYBBLE
POP PSW
RET
*
HCHOUT: CPI 0AH ;HAVE WE A DIGIT (0-9) OR ALPHA?
JP ALPHA
ADI 30H
CALL CO ;WE MADE AN ASCII AND PRINTED IT
RET
ALPHA: ADI 37H
CALL CO ;WE MMADE AN ALPHABETIC ASCII & PRINTED IT
RET
*
* THIS ROUTINE TAKES A NUMBER IN HL AND PRINTS IT AS A FOUR
* DIGIT HEXADECIMAL NUMBER.
DISPHL: PUSH PSW
MOV A,H ;GET HI-BYTE
CALL HEXPRT ;PRINT IT
MOV A,L ;GET LO-BYTE
CALL HEXPRT ;PPRINT IT
POP PSW
RET
*
* THIS NEXT ROUTINE REALLY DOES NOT BELONG WITH THE OTHER TWO,
* BUT IT WOULD BE A CRIME TO PUT IT IN A FILE BY ITSELF. THEREFORE
* IT IS INCLUDED HERE FOR YOUR READING PLEASURE.
*
* "CONSTAT"
*
* THIS ROUTINE USES THE CP/M BUILT-IN-FUNCTION #11 TO INTERROGATE
* THE STATUS OF THE TTY. THE A REGISTER IS RETURNED WITH THE
* LEAST SIGNIFICANT BYTE = 1 IF THERE IS AN INPUT CHARACTER WAITING
* FROM THE KEYBOARD.
BDOS EQU 5
CONSTAT: PUSH B ! PUSH D ! PUSH H !
MVI C,11
CALL BDOS
POP H ! POP D ! POP B
RET