home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
ZCPR33
/
A-R
/
MATH24.LBR
/
M24INP.ZZ0
/
M24INP.Z80
Wrap
Text File
|
2000-06-30
|
2KB
|
76 lines
; Module M24INP
; Steven M. Cohen
; March 10, 1987
;
EXT VPRINT,EREOL,BLINE,N24EVAL,RADIX,COUT
PUBLIC NUMINP,INPNUM,RADIXDSP
;
BUZZER EQU 7
;
; NUMINP and INPNUM numeric input routines
; these allow input in either binary, decimal or hex.
; NUMINP prints as part of the input line a three character
; display indicating the default radix to be used (others require a trailing
; character)
; both routines print a ": " after what presumably would be a prompt string
; and clear the rest of the input line
;
; INPUTS: DE points to 3 byte buffer where result will be stored
; OUTPUTS: DE still points to this buffer which is now updated
; REGISTERS AFFECTED - HL, PSW
;
NUMINP:
CALL RADIXDSP ; display primary input radix
INPNUM:
CALL VPRINT
DB ': ',0 ; print colon and space
CALL EREOL ; clear away rest of line
XOR A
CPL ; to capitalize input line
LD HL,NUMBUF ; read into number buffer
CALL BLINE ; do it
CALL N24EVAL ; get number in de and check for error
RET NC ; return if no error
LD A,BUZZER ; ERROR, buzz
JP COUT ; and return via COUT
;
NUMBUF: db 25
ds 1
ds 26
BIN: DB 'BIN' ;binary indicator
DEC: DB 'DEC' ;decimal indicator
HEXA: DB 'HEX' ;hexadecimal indicator
;
RADIXDSP: ; radix display routine
PUSH HL
PUSH DE
PUSH BC
CALL RADIX
DB 0 ;REQUEST DEFAULT RADIX
LD DE,RDXLOC
CP 2 ;binary
JR NZ,R10
LD HL,BIN
JR RDXD2
R10: CP 10 ;decimal
JR NZ,R16
LD HL,DEC
JR RDXD2
R16: LD HL,HEXA ;then it must be hex
RDXD2:
LDI
LDI
LDI ;hot patch it
CALL VPRINT
DB '('
RDXLOC: DS 3 ;three bytes go here
DB ')',0
POP BC
POP DE
POP HL
RET
LDI ;hot patch it
CALL VPRINT
DB '('
RDXLOC: DS 3 ;three bytes go here
DB ')