Home | S-100 Boards | History | New Boards | Software | Boards For Sale |
Forum | Other Web Sites | News | Index |
; BDOS EQUATES for running these routines under CPM; |
; Main consol output routine using CPM. |
; Main consol input routine using CPM. |
; DISPLAY BIT PATTERN IN [A] |
; DISPLAY BIT PATTERN IN [A] ANI 80H JZ BITS4 MVI C,'1' BITS3:CALL CO MOV A,E RAL MOV E,A DCR B JNZ BITS2 JMP BQ2 BITS4:MVI C,'0' JMP BITS3 |
; Obtain 2 HEX digits in [A] from keyboard; If abort, Carry flag set & ESC is returned in [A]; All registers unchanged except [A] (INTEL) GETHEX: PUSH B MVI C,RDCON CALL BDOS ;Get a character from keyboard & ECHO CPI ESC JZ HEXABORT CPI '/' ;check 0-9, A-F JC HEXABORT CPI '9'+1 JNC HEXABORT CALL ASBIN ;Convert to binary RLC ;Shift to high nibble RLC RLC RLC MOV B,A ;Store it PUSH B MOV C,RDCON CALL BDOS ;Get 2nd character from keyboard & ECHO POP B CPI ESC JZ HEXABORT CPI '/' ;check 0-9, A-F JC HEXABORT CPI '9'+1 JNC HEXABORT CALL ASBIN ;Convert to binary ORA B ;add in the first digit ORA A ;To return NC POP B RET;HEXABORT: STC ;Set Carry flag MVI A,ESC POP B RET; ;Convert LC to UCUPPER:CPI 'a' ;must be >= lowercase a RC ; else go back... CPI 'z'+1 ;must be <= lowercase z RNC ; else go back... SUI 'a'-'A' ;subtract lowercase bias RET; ASBIN:SUI 30H ;ASCII TO BINARY CONVERSION ROUTINE CPI 0AH RM SUI 07H RET |
; DISPLAY CURRNT VALUE IN [A] (ZILOG) |
; DISPLAY CURRNT VALUE IN [A] (INTEL) |
; Binary to ASCII Decimal String Conversion Print Routine |
; Do a hexdump of the data in that is in a 512 byte (typically a BIOS DMA) buffer; [HL] points to the buffer. Change values for [DE] below for different size buffers ; No registers modified (INTEL) HEXDUMP: |
;Convert BCD number (Two digits only) in A to Binary ;No registers modified (INTEL) BCDTOBIN: PUSH B PUSH D MOV B,A ;Save it ANI 0FH ;Mask most significant four bits MOV C,A ;Save unpacked BCDI in C register MOV A,B ;Get BCD again ANI 0F0H ;Mask least significant four bits RRC ;Convert most significant four bits into unpacked BCD2 RRC RRC RRC MOV B,A ;Save unpacked BCD2 in B register XRA A ;Clear accumulator (sum = 0) MVI D,0AH ;Set D as a multiplier of 10 Sum: ADD D ;Add 10 until (B) = 0 DCR B ;Decrement BCD2 by one JNZ Sum ;Is multiplication complete? i if not, go back and add again ADD C ;Add BCD1 POP D POP B RET ;Return with binary value in [A] | |
;Generalized Subroutine to convert binary number in [A] into its equivalent BCD number ;stored in RAM. Will return right most 2 digits in [A]
;No registers modified (INTEL)
BINTOBCD: ;Convert binary number in [A] to BCD in RAM
PUSH B ;Save BC register pair contents
PUSH D ;Save DE register pair contents
MVI B,64H ;Load divisor decimal 100 in B register
MVI C,0AH ;Load divisor decimal 10 in C register
MVI D,00H ;Initialize Digit 1
MVI E,00H ;Initialize Digit 2
STEP1: CMP B ;Check if number < Decimal 100
JC STEP2 ;if yes go to step 2
SUB B ;Subtract decimal 100
INR E ;update quotient
JMP STEP1 ;go to step 1
STEP2: CMP C ;Check if number < Decimal 10
JC STEP3 ;if yes go to step 3
SUB C ;Subtract decimal 10
INR D ;Update quotient
JMP STEP2 ;Continue division by 10
STEP3: STA Digit0 ;Store Digit 0
MOV A,D ;Get Digit 1
STA Digit1 ;Store Digit 1
RLC ;Shift it up 4 bits
RLC
RLC
RLC
ANI 0F0H
MOV D,A ;Temp store in D
MOV A,E ;Get Digit 2
STA Digit2 ;Store Digit 2
LDA Digit0
ORA D ;Add in 10's digit
POP D ;Restore DE register pair
POP B ;Restore BC register pair
RET ;Return to main program
Digit0: DB 0 ;Store for Bin->BCD
Digit1: DB 0
Digit2: DB 0
This page was last modified on 05/14/2016