2017-10-21 23:40:19 +00:00
|
|
|
mcopy objout.macros
|
2017-07-15 00:45:40 +00:00
|
|
|
datachk off
|
2017-10-21 23:40:19 +00:00
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* CnOut - write a byte to the constant buffer
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* i - byte to write
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
CnOut start CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
maxCBuffLen equ 191 max index into the constant buffer
|
|
|
|
|
|
|
|
lda cBuffLen if cBuffLen = maxCBuffLen then
|
|
|
|
cmp #maxCBuffLen
|
|
|
|
bne lb1
|
|
|
|
jsl Purge Purge;
|
|
|
|
lb1 phb cBuff[cBuffLen] := i;
|
|
|
|
plx
|
|
|
|
ply
|
|
|
|
pla
|
|
|
|
phy
|
|
|
|
phx
|
|
|
|
plb
|
|
|
|
ldx cBuffLen
|
|
|
|
short M
|
|
|
|
sta cBuff,X
|
|
|
|
long M
|
|
|
|
inc cBuffLen cBuffLen := cBuffLen+1;
|
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* CnOut2 - write a word to the constant buffer
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* i - word to write
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
CnOut2 start CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
maxCBuffLen equ 191 max index into the constant buffer
|
|
|
|
|
|
|
|
lda cBuffLen if cBuffLen+1 >= maxCBuffLen then
|
|
|
|
inc A
|
|
|
|
cmp #maxCBuffLen
|
|
|
|
blt lb1
|
|
|
|
jsl Purge Purge;
|
|
|
|
lb1 phb cBuff[cBuffLen] := i;
|
|
|
|
plx
|
|
|
|
ply
|
|
|
|
pla
|
|
|
|
phy
|
|
|
|
phx
|
|
|
|
plb
|
|
|
|
ldx cBuffLen
|
|
|
|
sta cBuff,X
|
|
|
|
inx cBuffLen := cBuffLen+2;
|
|
|
|
inx
|
|
|
|
stx cBuffLen
|
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* COut - write a code byte to the object file
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* b - byte to write (on stack)
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
COut start CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
phb OutByte(b);
|
|
|
|
pla
|
|
|
|
ply
|
|
|
|
plx
|
|
|
|
phy
|
|
|
|
pha
|
|
|
|
plb
|
|
|
|
jsr OutByte
|
2016-11-28 01:11:12 +00:00
|
|
|
inc4 blkcnt blkcnt := blkcnt+1;
|
2017-10-21 23:40:19 +00:00
|
|
|
inc4 pc pc := pc+1;
|
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* Out2 - write a word to the output file
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* w - word to write (on stack)
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
Out2 start CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
phb OutWord(w);
|
|
|
|
pla
|
|
|
|
ply
|
|
|
|
plx
|
|
|
|
phy
|
|
|
|
pha
|
|
|
|
plb
|
|
|
|
jsr OutWord
|
2016-11-28 01:11:12 +00:00
|
|
|
add4 blkcnt,#2 blkcnt := blkcnt+2;
|
2017-10-21 23:40:19 +00:00
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* Out - write a byte to the output file
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* b - byte to write (on stack)
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
Out start CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
phb OutByte(b);
|
|
|
|
pla
|
|
|
|
ply
|
|
|
|
plx
|
|
|
|
phy
|
|
|
|
pha
|
|
|
|
plb
|
|
|
|
jsr OutByte
|
2016-11-28 01:11:12 +00:00
|
|
|
inc4 blkcnt blkcnt := blkcnt+1;
|
2017-10-21 23:40:19 +00:00
|
|
|
rtl
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* OutByte - write a byte to the object file
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* X - byte to write
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
OutByte private CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
|
2022-12-07 03:49:20 +00:00
|
|
|
lda objLen if objLen+segDisp >= buffSize then
|
2017-10-21 23:40:19 +00:00
|
|
|
clc
|
|
|
|
adc segDisp
|
2016-11-28 01:11:12 +00:00
|
|
|
lda objLen+2
|
|
|
|
adc segDisp+2
|
|
|
|
beq lb2
|
2022-12-07 03:49:20 +00:00
|
|
|
and minusBuffSize+2
|
|
|
|
beq lb2
|
|
|
|
phx MakeSpaceInObjBuffer;
|
|
|
|
jsl MakeSpaceInObjBuffer
|
2018-02-11 03:55:24 +00:00
|
|
|
plx
|
|
|
|
clc
|
2016-11-28 01:11:12 +00:00
|
|
|
lb2 anop carry must be clear
|
|
|
|
lda objPtr+2 p := pointer(ord4(objPtr)+segDisp);
|
|
|
|
adc segDisp+2
|
|
|
|
pha
|
|
|
|
lda objPtr
|
|
|
|
pha
|
2017-10-21 23:40:19 +00:00
|
|
|
tsc p^ := b;
|
|
|
|
phd
|
|
|
|
tcd
|
|
|
|
ldy segDisp
|
|
|
|
short M
|
|
|
|
txa
|
|
|
|
sta [1],Y
|
|
|
|
long M
|
2016-11-28 01:11:12 +00:00
|
|
|
inc4 segDisp segDisp := segDisp+1;
|
2017-10-21 23:40:19 +00:00
|
|
|
|
2018-02-11 03:55:24 +00:00
|
|
|
pld
|
2017-10-21 23:40:19 +00:00
|
|
|
tsc
|
|
|
|
clc
|
|
|
|
adc #4
|
|
|
|
tcs
|
|
|
|
rts
|
|
|
|
end
|
|
|
|
|
|
|
|
****************************************************************
|
|
|
|
*
|
|
|
|
* OutWord - write a word to the object file
|
|
|
|
*
|
|
|
|
* Inputs:
|
|
|
|
* X - word to write
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
*
|
2017-07-15 00:45:40 +00:00
|
|
|
OutWord private CodeGen
|
2017-10-21 23:40:19 +00:00
|
|
|
|
2022-12-07 03:49:20 +00:00
|
|
|
lda objLen if objLen+segDisp+1 >= buffSize then
|
2017-10-21 23:40:19 +00:00
|
|
|
sec
|
|
|
|
adc segDisp
|
2016-11-28 01:11:12 +00:00
|
|
|
lda objLen+2
|
|
|
|
adc segDisp+2
|
|
|
|
beq lb2
|
2022-12-07 03:49:20 +00:00
|
|
|
and minusBuffSize+2
|
|
|
|
beq lb2
|
|
|
|
phx MakeSpaceInObjBuffer;
|
|
|
|
jsl MakeSpaceInObjBuffer
|
2018-02-11 03:55:24 +00:00
|
|
|
plx
|
2022-12-07 03:49:20 +00:00
|
|
|
clc
|
|
|
|
lb2 anop carry must be clear
|
|
|
|
lda objPtr+2 p := pointer(ord4(objPtr)+segDisp);
|
2016-11-28 01:11:12 +00:00
|
|
|
adc segDisp+2
|
|
|
|
pha
|
|
|
|
lda objPtr
|
|
|
|
pha
|
2017-10-21 23:40:19 +00:00
|
|
|
tsc p^ := b;
|
|
|
|
phd
|
|
|
|
tcd
|
|
|
|
ldy segDisp
|
|
|
|
txa
|
|
|
|
sta [1],Y
|
2016-11-28 01:11:12 +00:00
|
|
|
add4 segDisp,#2 segDisp := segDisp+2;
|
2017-10-21 23:40:19 +00:00
|
|
|
|
|
|
|
pld
|
|
|
|
tsc
|
|
|
|
clc
|
|
|
|
adc #4
|
|
|
|
tcs
|
|
|
|
rts
|
|
|
|
end
|