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
/
BDSC
/
BDSC-2
/
L2-225.ARK
/
RDRL.MAC
< prev
next >
Wrap
Text File
|
1988-05-21
|
2KB
|
170 lines
ext cread1
public rdrl
cseg
rdrl:
push b
call readcode
lxi h,cdrec
pop b
ret
READBIT:
PUSH H
LXI H,HOLDBYTE
MOV A,M
INX H
INR M
JNZ RDSAMEBYT
CALL READFILECHR
MVI M,0F8H
RDSAMEBYT:
ADD A
DCX H
MOV M,A
POP H
RET
READ8BITS:
MVI C,8
READCBITS:
MVI B,0
SHIFTBIT:
CALL READBIT
MOV A,B
RAL
MOV B,A
DCR C
JNZ SHIFTBIT
RET
;Read code item
READCODE:
XRA A
STA segtype
sta itemtype
sta dataword+1
sta entryname
CALL READBIT
JC CODE1
CALL READ8BITS ;read absolute byte
sta dataword
RET
CODE1:
MVI C,2
CALL READCBITS
ORA A
JZ CODE100 ;special link item?
;here it's a relative 16-bit address
CALL CDSEGADDR
mvi a,1
sta itemtype
RET
CODE100:
mvi a,2
sta itemtype
PUSH H
MVI C,4 ;read the control field
sta linktype
CALL READCBITS
CPI 5
PUSH PSW
JC CDSYMARG ;go read B-field
CPI 0FH ;end file?
JZ CDINST
;here link items 5,6,7,8,9,10,11,12,13,14
; which have an A-field
MVI C,2 ;read the A-field address type
CALL READCBITS
CALL CDSEGADDR
;link items 0,1,2,3,4 have only a B-field
CDSYMARG:
POP PSW
PUSH PSW
;items 8,9,10,11,12,13,14 have only an A-field
CPI 8
JNC CDINST
PUSH D
MVI C,3 ;get length of symbol
CALL READCBITS
LXI H,ENTRYNAME
MOV M,A ;enter the length
cpi 7 ;if 7 length, make 8 with wild '?' at end
jz .cds0
ora a
JNZ .cds1
.cds0: INR M ;if 0 length, make it 1 long
.cds1: INX H
MVI M,' ' ;... with first char = SP
MOV E,A
;E = length
NXTCDCHAR:
DCR E ;if now length = 0, done reading symbol
JM .cds2
CALL READ8BITS
MOV M,A
INX H
JMP NXTCDCHAR
.cds2: mov a,m ;8th bit already set if len "8"
cpi '?' or 80h
jz .cds2a
dcx h ;else set 8th bit
mov a,m
ori 80H
mov m,a
.cds2a: POP D
CDINST:
POP PSW
LXI H,0FF00H
cpi 15 ;if eof, align for next REL read
jz .cds3a
CPI 14
JNZ .cds3
.cds3a: SHLD HOLDBYTE
.cds3:
sta linktype
POP H
RET
CDSEGADDR:
STA segtype ;SEGREF
CALL READ8BITS ;DE = 16 bit address
MOV E,B
CALL READ8BITS
MOV D,B
xchg
shld dataword
ret
holdbyte: db 0,0ffh
cdrec:
itemtype: db 0 ;0=code, 1=address, 2=link item
segtype: db 0
linktype: db 0
dataword: dw 0
entryname: db 0,0,0,0,0,0,0,0,'?' or 80h
READFILECHR:
PUSH H
PUSH D
push b
call cread1
mov a,l
pop b
POP D
POP H
RET
end