mirror of
https://github.com/byteworksinc/Linker.git
synced 2024-10-05 21:55:14 +00:00
1 line
19 KiB
NASM
1 line
19 KiB
NASM
|
keep obj/file
mcopy file.mac
****************************************************************
*
* File2
*
* This module contains the subroutines that depend on the file
* system and shell.
*
* This version uses shell 2.0 calls.
*
****************************************************************
copy directPage
****************************************************************
*
* FileCommon - common data for the file module
*
****************************************************************
*
FileCommon privdata
;
; Constants
;
fileBuffSize equ 8*1024 max size of a file name buffer
;
; Shell call records
;
ffDCB dc i'14' fast file DCB
ffAction ds 2
ffIndex ds 2
ffFlags ds 2
ffFileHandle ds 4
ffPathName ds 4
ffAccess ds 2
ffFileType ds 2
ffAuxType ds 4
ffStorageType ds 2
ffCreate ds 8
ffMod ds 8
ffOption ds 4
ffFileLength ds 4
ffBlocksUsed ds 4
ffCheckSum ds 2
stlf_dcb dc i'11' set linfo DCB
stlf_src ds 4 source file
stlf_out ds 4 output file
stlf_prm dc a4'PRM' parameter list
stlf_lan dc a4'LAN' language specific string
stlf_mer ds 1 maximum error allowed
stlf_mef ds 1 maximum error found
stlf_lop ds 1 operations flag
stlf_kep ds 1 keep flag
stlf_ltm ds 4 set of letters with -
stlf_ltp ds 4 set of letters with +
stlf_org ds 4 origin
prm dc i'4,0'
lan dc i'4,0'
;
; global variables
;
libRefnum ds 2 refnum for the open library file
name ds 256 file name
end
****************************************************************
*
* AppendOSNames - append two GS/OS path names
*
* Inputs:
* p1,p2 - pointers to input format GS/OS names
* flags -
* 0 - return an input string
* 1 - return an output string
*
* Outputs:
* X-A - nil for out of memory, otherwise a pointer to the string
*
* Notes:
* This subroutine reserves a memory buffer based on
* the actual length of the expanded path name. The
* caller is responsible for disposing of the memory.
*
****************************************************************
*
AppendOSNames private
out equ 1 return pointer
chars equ 5 pointer to input format portion of out
sub (4:p1,4:p2,2:flags),8
clc find the length of the buffer
lda [p1]
adc [p2]
inc A
inc A
ldx flags
beq lb1
inc A
inc A
sta chars
lb1 pea 0 allocate the memory
pha
jsr MLalloc
sta out
stx out+2
ora out
beq lb7
lda flags if flags then
beq lb2
lda chars set the length of the buffer
sta [out]
add4 out,#2,chars chars = out+2
bra lb3 else
lb2 move4 out,chars chars = out
lb3 anop endif
clc set the length
lda [p1]
adc [p2]
sta [chars]
lda [p1] move in the first string
beq lb4a
tax
ldy #2
short M
lb4 lda [p1],Y
sta [chars],Y
iny
dex
bne lb4
long M
lb4a clc update chars
lda [p1]
adc chars
sta chars
bcc lb5
inc chars+2
lb5 lda [p2] move in the second string
beq lb7
tax
ldy #2
short M
lb6 lda [p2],Y
sta [chars],Y
iny
dex
bne lb6
long M
lb7 ret 4:out
end
****************************************************************
*
* CloseLibrary - close a library file
*
* Inputs:
* dictionary - ptr to dictionary buffer
* libRefnum - reference number for the library file
*
****************************************************************
*
CloseLibrary start
using FileCommon
ph4 dictionary dispose of the dictionary buffer
jsr Free
lda libRefnum close the library file
sta clRefnum
OSClose clRec
rts
clRec dc i'1'
clRefnum ds 2
end
****************************************************************
*
* ConvertString - convert an output string to an input string
*
* Inputs:
* str - output string pointer
*
* Outputs:
* Returns a pointer to the input string buffer
*
* Notes:
* Allocates an appropriate size buffer.
*
****************************************************************
*
ConvertString private
ptr equ 1
sub (4:str),4
add4 str,#2
lda [str]
inc A
inc A
pea 0
pha
jsr MLalloc
sta ptr
stx ptr+2
lda [str]
tay
iny
short M
lb1 lda [str],Y
sta [ptr],Y
dey
bpl lb1
long M
ret 4:ptr
end
****************************************************************
*
* GetLibFile - get a library file name from the library directory
*
|