A2osX/BIN/CC.S.CODE.txt

345 lines
5.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------------
CODE.Init stz ZPCCConst
stz ZPCCConst+1
stz bInitCode
>LDYAI PCC.FH.CS
>STYA ZPCCCode
>LDYAI 20 char *ARGV[10]
>STYA ZPCCData
lda #'_'
>STA.G CC.CPSPFX+1
lda #'A'
>STA.G CC.CPSID
iny CC.CPSID+1
sta (pData),y
clc
.99 rts
*--------------------------------------
CODE.Quit >LDA.G CC.hOutFile
beq .8
>SYSCALL FClose
.8 clc
rts
*--------------------------------------
CODE.nAddLocal eor #$FF
inc
CODE.AddLocal jsr CODE.LDAI
bcs .9
>LDYA L.PCC.ADDLOCAL
jmp CODE.EmitPCC
.9 rts
*--------------------------------------
CODE.SetRetValue
jsr CODE.LDXI
bcs .9
>LDYA L.PCC.SetRetValue
jmp CODE.EmitPCC
.9 rts
*--------------------------------------
CODE.PUSHAXI pha
txa
jsr CODE.PUSHI
bcs CODE.LDAXI.RTS
pla
*--------------------------------------
CODE.PUSHI jsr CODE.LDAI
bcs CODE.LDAXI.RTS
bra CODE.PUSHA
*--------------------------------------
CODE.LDYAI pha
lda #$A0 LDY #imm
jsr CODE.EmitByte
bcs CODE.LDAXI.RTS
tya
jsr CODE.EmitByte
bcs CODE.LDAXI.RTS
lda #$A9 LDA #imm
jsr CODE.EmitByte
bcs CODE.LDAXI.RTS
pla
jmp CODE.EmitByte
*--------------------------------------
CODE.LDAXI jsr CODE.LDAI
bcc CODE.LDXI
CODE.LDAXI.RTS rts
*--------------------------------------
CODE.LDYI lda #$A0 LDY #imm
jsr CODE.EmitByte
bcs .9
tya
jmp CODE.EmitByte
.9 rts
*--------------------------------------
CODE.LDXI lda #$A2 LDX #imm
jsr CODE.EmitByte
bcs .9
txa
jmp CODE.EmitByte
.9 rts
*--------------------------------------
CODE.LDAI pha
lda #$A9 LDA #imm
jsr CODE.EmitByte
bcs .9
pla
jmp CODE.EmitByte
.9 plx
rts
*--------------------------------------
CODE.PUSHYA jsr CODE.PUSHA
lda #$98 TYA
jsr CODE.EmitByte
*--------------------------------------
CODE.PUSHA lda #$C6 DEC zp
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
lda #$92 STA (zp)
jsr CODE.EmitByte
lda #pStack
jmp CODE.EmitByte
*--------------------------------------
CODE.PULLYA jsr CODE.PULLA
lda #$48 PHA
jsr CODE.EmitByte
jsr CODE.PULLA
lda #$7A PLY
bra CODE.EmitByte
*--------------------------------------
CODE.PULLA lda #$B2 LDA (zp)
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
*--------------------------------------
CODE.INCPSTACK lda #$E6 INC zp
jsr CODE.EmitByte
lda #pStack
bra CODE.EmitByte
*--------------------------------------
CODE.SYSCALL jsr CODE.LDXI
bcs .9
lda #$20 JSR
ldx #A2osX.SYSCALL
ldy /A2osX.SYSCALL
bra CODE.TOABSYX
.9 rts
*--------------------------------------
CODE.FPUCALL jsr CODE.LDXI
bcs .9
lda #$20 JSR
ldx #A2osX.FPUCALL
ldy /A2osX.FPUCALL
bra CODE.TOABSYX
.9 rts
*--------------------------------------
CODE.LIBCALL jsr CODE.LDXI
bcs .9
tya
dec
dec
dec
asl
asl
clc
adc #PCC.PH.JMPLIBs
tax
lda #0
adc /PCC.PH.JMPLIBs
tay
lda #$20 JSR
bra CODE.TOABSYX
.9 rts
*--------------------------------------
CODE.TOABSYX jsr CODE.EmitByte A=opcode : JMP, JSR .....
bcs .9
txa
jsr CODE.EmitByte
bcs .9
tya
bra CODE.EmitByte
.9 rts
*--------------------------------------
CODE.DEBUG >LDYA L.PCC.DEBUG
*--------------------------------------
CODE.EmitPCC >STYA ZPLookupPtr
lda (ZPLookupPtr)
tax
dex
ldy #1
.1 lda (ZPLookupPtr),y
jsr CODE.EmitByte
bcs .9
iny
dex
bne .1
.9 rts
*--------------------------------------
CODE.EmitByte clc if Pass 1...
bit bPass2
bpl .1
phx
phy
tax
>PUSHB.G CC.hOutFile
txa
>PUSHA
>SYSCALL fputc
ply
plx
.1 inc ZPCCCode
bne .8
inc ZPCCCode+1
.8 rts CC/CS from fputc
*--------------------------------------
CODE.EmitDATA clc
bit bPass2
bpl .1
phx
phy
tax
>PUSHB.G CC.hOutFile
txa
>PUSHA
>SYSCALL fputc
ply
plx
.1 inc ZPCCConst
bne .8
inc ZPCCConst+1
.8 rts CC/CS from fputc
*--------------------------------------
CODE.EmitTail jsr CODE.DSSelect
bcs .99
stz ArgIndex
.1 lda ArgIndex
>CMP.G LibCount
beq .8
clc
adc #hLibNs
tay
lda (pData),y
pha
>PUSHB.G CC.hOutFile
pla
>SYSCALL ArgV
>PUSHYA
>SYSCALL fputs
bcs .99
jsr .8
bcs .99
inc ArgIndex
bra .1
.8 >PUSHB.G CC.hOutFile
lda #0
>PUSHA
>SYSCALL fputc
.99 rts
*--------------------------------------
CODE.CSSelect clc
bit bPass2
bpl .8
>PUSHB.G CC.hOutFile
>PUSHWZ
lda ZPCCCode+1
sec
sbc #$20
>PUSHA
lda ZPCCCode
>PUSHA
>PUSHBI SEEK.SET
>SYSCALL fseek
.8 rts
*--------------------------------------
CODE.DSSelect clc
bit bPass2
bpl .8
>PUSHB.G CC.hOutFile
>PUSHWZ
lda ZPCCConst
clc
adc PCC.FH+PCC.FH.CONST
tay
lda ZPCCConst+1
adc PCC.FH+PCC.FH.CONST+1
sec
sbc #$20
>PUSHYA
>PUSHBI SEEK.SET
>SYSCALL fseek
.8 rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.code
LOAD usr/src/bin/cc.s
ASM