;{++++++++++++++++++++++++++++++++++++++++++++++++}
;{+						 +}
;{+	 STANDARD LIBRARY UTILITY FUNCTIONS	 +}
;{+						 +}
;{++++++++++++++++++++++++++++++++++++++++++++++++}
;
;
;function isalpha(ch: char): boolean;
;begin
	NAME ISALPHA
	ENTRY ISALPHA
ISALPHA:
	ENTR	D,2,0
;  isalpha := ( ('A'<=ch) and (ch<='Z') ) or
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,65
	XCHG
	LE	D,0
	JNC	L147
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,91
	MOV	A,H
	JC	L141
L147:
;	     ( ('a'<=ch) and (ch<='z') );
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,97
	XCHG
	LE	D,0
	JNC	L165
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,123
	MOV	A,H
	JRNC	L165
L141:
	INR	A
L165:
	MOV	L,A
	XRA	A
	MOV	H,A
	MOV	2(IX),L
;end;
	EXIT	D,1
;
;
;function isupper(ch: char): boolean;
;begin
	NAME ISUPPER
	ENTRY ISUPPER
ISUPPER:
	ENTR	D,2,0
;  isupper := ( ('A'<=ch) and (ch<='Z') );
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,65	;"A"
	XCHG
	LE	D,0
	JNC	L190
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,91	;"Z"
	MOV	A,H
	JRNC	L190
	INR	A
L190:
	MOV	L,A
	XRA	A
	MOV	H,A
	MOV	2(IX),L
;end;
	EXIT	D,1
;
;
;function islower(ch: char): boolean;
;begin
	NAME ISLOWER
	ENTRY ISLOWER
ISLOWER:
	ENTR	D,2,0
;  islower := (('a'<=ch) and (ch<='z'));
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,97	;"a"
	XCHG
	LE	D,0
	JNC	L215
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,123	;"z"
	MOV	A,H
	JRNC	L215
	INR	A
L215:
	MOV	L,A
	XRA	A
	MOV	H,A
	MOV	2(IX),L
;end;
	EXIT	D,1
;
;
;function isdigit(ch: char): boolean;
;begin
	NAME ISDIGIT
	ENTRY ISDIGIT
ISDIGIT:
	ENTR	D,2,0
;  isdigit := (('0'<=ch) and (ch<='9'));
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,48	;"0"
	XCHG
	LE	D,0
	JNC	L240
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,58	;"9"
	MOV	A,H
	JRNC	L240
	INR	A
L240:
	MOV	L,A
	XRA	A
	MOV	H,A
	MOV	2(IX),L
;end;
	EXIT	D,1
;
;
;function isspace(ch: char): boolean;
;{ returns true if char is a space or a tab char }
;begin
	NAME ISSPACE
	ENTRY ISSPACE
ISSPACE:
	ENTR	D,2,0
;  isspace := ( (ch=' ') or (ch=CHR(9)) );
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,32	;" "
	MOV	A,H
	JZ	L263
	MOV	H,A
	MOV	L,8(IX)
	PUSH	H
	LXI	H,9
	POP	D
	DSB1	D,0
	JRNZ	L258
L263:
	INR	A
L258:
	MOV	L,A
	XRA	A
	MOV	H,A
	MOV	2(IX),L
;end;
	EXIT	D,1
;
;
;function toupper(ch: char): char;
;begin
	NAME TOUPPER
	ENTRY TOUPPER
TOUPPER:
	ENTR	D,2,0
;  if  (('a'<=ch) and (ch<='z')) then
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,97	;"a"
	XCHG
	LE	D,0
	JNC	L297
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,123	;"z"
	MOV	A,H
	JNC	L297
;    toupper := chr(ord(ch)-32)
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,-32	; subtract offset - 32
	DADD	D,0
	MOV	2(IX),L
	JMP	L330
;  else
;    toupper := ch;
L297:
	MOV	H,A
	MOV	L,8(IX)
	MOV	2(IX),L
L330:
;end;
	EXIT	D,1
;
;
;function tolower(ch: char): char;
;begin
	NAME TOLOWER
	ENTRY TOLOWER
TOLOWER:
	ENTR	D,2,0
;  if ( ('A'<=ch) and (ch<='Z') ) then
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,65	;"A"
	XCHG
	LE	D,0
	JNC	L348
	MOV	H,A
	MOV	L,8(IX)
	MOV	A,L
	CMPI	D,91	;"Z"
	MOV	A,H
	JNC	L348
;    tolower := chr(ord(ch)+32)
	MOV	H,A
	MOV	L,8(IX)
	LXI	D,32	;add in offset 32
	DADD	D,0
	MOV	2(IX),L ;save it and exit
	JMP	L381
;  else
;    tolower := ch;
L348:
	MOV	H,A
	MOV	L,8(IX)
	MOV	2(IX),L
L381:
;end;
	EXIT	D,1


t and exit
	JMP	L381
;  else
;    tolower :=