home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
simtel
/
sigm
/
vols000
/
vol064
/
space.src
< prev
next >
Wrap
Text File
|
1984-04-29
|
2KB
|
122 lines
;TYPE
;$STRING80 = STRING 80;
;$STRING0 = STRING 0;
;$STRING255 = STRING 255;
;BYTE = 0..255;
;VAR
;DATA:$STRING255;
;NUMBER:INTEGER;
;
;FUNCTION LENGTH(X:$STRING255):INTEGER;EXTERNAL;
EXTD L168,LENGTH
;PROCEDURE SETLENGTH(VAR X:$STRING0; Y:INTEGER);EXTERNAL;
EXTD L169,SETLENGT
;
;{function to return "x" number of spaces to a write command or statement..
;corresponds to BASIC commands such as SPACE$(X) or TAB(x)...
;although in structured programming, it is stylistically better to format
;output using format commands such as x:9:2 for a real number or
;name:30 for a string, this function is often useful in designing a layout,
;and certainly is more "readable" in a program...}
;
;
;FUNCTION SPACE(X:BYTE):$STRING255;
;VAR
;I:INTEGER;
;S:$STRING255;
;
;BEGIN
L170
NAME SPACE
ENTRY SPACE
SPACE:
ENTR D,2,258
;SETLENGTH(S,0);
STMT D,1
PUSH IX
POP H
DCX H
DCX H
PUSH H
MOV H,A
MOV L,A
PUSH H
CALL L169
;IF (X > 0) AND (X < 256) THEN FOR I:=1 TO X DO APPEND(S,' ');
STMT D,2
MOV H,A
MOV L,8(IX)
MVI A,0
CMP L
MOV A,H
JNC L187
MOV H,A
MOV L,8(IX)
LXI D,256
LESS D,0
JNC L184
STMT D,3
MOV 0(IX),A
MVI -1(IX),1
PUSH IX
MOV H,A
MOV L,8(IX)
XTHL
L209
MOV D,M
DCX H
MOV E,M
XTHL
PUSH H
GE D,0
JNC L210
STMT D,4
PUSH IX
POP H
DCX H
DCX H
PUSH H
LXI H,255
PUSH H
LXI H,288
PUSH H
LXI H,2
PUSH H
CALL L137
CTRL M,4
POP H
XTHL
INR M
INX H
JRNZ L229
INR M
JV L230
L229
JMP L209
L210
POP D
L230
POP D
L184
L186 EQU L184
L187 EQU L186
;
;SPACE:=S;
STMT D,5
PUSH IX
POP H
DCX H
DCX H
RCHK S,255
XCHG
PUSH IX
POP H
LXI B,264
DADD B
XCHG
LXI B,256
LDDR
;END;
STMT D,6
EXIT D,1