A2osX/BIN/CC.S.CODE.txt

376 lines
6.0 KiB
Plaintext
Raw Permalink Normal View History

NEW
AUTO 3,1
2022-06-12 20:42:22 +00:00
*--------------------------------------
2023-01-26 07:07:08 +00:00
CODE.Init >STZ.G CC.bInitCode
2022-08-20 14:37:37 +00:00
>STA.G CC.ScopeID
iny
sta (pData),y
2022-06-12 20:42:22 +00:00
>LDYAI PCC.FH.CS
>STYA ZPCCCode
2022-08-20 14:37:37 +00:00
ldy #SCOPE-1
lda #0
.1 sta (ScopeStk),y reset initial Scope ID, LocalPtr, FrameSize
dey
bpl .1
2023-01-26 07:07:08 +00:00
stz ZPCCConst
stz ZPCCConst+1
jsr CODE.DSSelect
bcs .99
stz ArgIndex
.2 lda ArgIndex
>CMP.G LibCount
beq .8
clc
adc #hLibNs
tay
lda (pData),y
>SYSCALL ArgV
>STYA ZPPtr1
ldy #0
.3 lda (ZPPtr1),y
beq .4
jsr CODE.EmitDATA
bcs .99
iny
bne .3
.4 jsr CODE.EmitDATA \0
bcs .99
inc ArgIndex
bra .2
.8 lda #0
jsr CODE.EmitDATA \0
bcs .99
jsr CODE.CSSelect
bcs .99
>LDYAI 20 char *ARGV[10]
>STYA ZPCCData
2022-06-12 20:42:22 +00:00
clc
.99 rts
2022-06-12 20:42:22 +00:00
*--------------------------------------
CODE.Quit >LDA.G CC.hOutFile
beq .8
2022-08-20 14:37:37 +00:00
2022-06-12 20:42:22 +00:00
>SYSCALL FClose
.8 clc
rts
*--------------------------------------
CODE.AddLocal eor #$FF
2022-01-30 21:47:08 +00:00
inc
CODE.RemLocal jsr CODE.LDAI
2022-08-20 14:37:37 +00:00
bcs .9
2022-01-30 21:47:08 +00:00
2022-08-20 14:37:37 +00:00
>LDYA L.PCC.ADDLOCAL
jmp CODE.EmitPCC
2022-01-30 21:47:08 +00:00
2022-08-20 14:37:37 +00:00
.9 rts
2022-01-30 21:47:08 +00:00
*--------------------------------------
CODE.SetRetValue
jsr CODE.LDXI
2022-06-12 20:42:22 +00:00
bcs .9
2022-08-20 14:37:37 +00:00
>LDYA L.PCC.SetRetValue
jmp CODE.EmitPCC
2022-06-12 20:42:22 +00:00
2022-08-20 14:37:37 +00:00
.9 rts
*--------------------------------------
CODE.PUSHAXI pha
txa
jsr CODE.PUSHI
bcs CODE.LDAXI.RTS
2022-08-20 14:37:37 +00:00
pla
2022-06-12 20:42:22 +00:00
*--------------------------------------
CODE.PUSHI jsr CODE.LDAI
2022-08-20 14:37:37 +00:00
bcs CODE.LDAXI.RTS
bra CODE.PUSHA
*--------------------------------------
2022-01-30 21:47:08 +00:00
CODE.LDYAI pha
lda #$A0 LDY #imm
jsr CODE.EmitByte
2022-08-20 14:37:37 +00:00
bcs CODE.LDAXI.RTS
tya
jsr CODE.EmitByte
2022-08-20 14:37:37 +00:00
bcs CODE.LDAXI.RTS
lda #$A9 LDA #imm
jsr CODE.EmitByte
2022-08-20 14:37:37 +00:00
bcs CODE.LDAXI.RTS
pla
2022-01-30 21:47:08 +00:00
jmp CODE.EmitByte
*--------------------------------------
2022-08-20 14:37:37 +00:00
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
*--------------------------------------
2022-01-30 21:47:08 +00:00
CODE.LDXI lda #$A2 LDX #imm
jsr CODE.EmitByte
2022-08-20 14:37:37 +00:00
bcs .9
2022-01-30 21:47:08 +00:00
txa
jmp CODE.EmitByte
2022-08-20 14:37:37 +00:00
.9 rts
2022-01-30 21:47:08 +00:00
*--------------------------------------
CODE.LDAI pha
lda #$A9 LDA #imm
jsr CODE.EmitByte
2022-08-20 14:37:37 +00:00
bcs .9
2022-01-30 21:47:08 +00:00
pla
jmp CODE.EmitByte
2022-08-20 14:37:37 +00:00
.9 plx
rts
*--------------------------------------
CODE.PUSHYA jsr CODE.PUSHA
2022-08-20 14:37:37 +00:00
lda #$98 TYA
jsr CODE.EmitByte
*--------------------------------------
CODE.PUSHA lda #$C6 DEC zp
jsr CODE.EmitByte
lda #pStack
jsr CODE.EmitByte
2022-01-30 21:47:08 +00:00
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
*--------------------------------------
2022-08-20 14:37:37 +00:00
CODE.SYSCALL jsr CODE.LDXI
bcs .9
lda #$20 JSR
ldx #A2osX.SYSCALL
ldy /A2osX.SYSCALL
bra CODE.TOABSYX
.9 rts
*--------------------------------------
2022-08-20 14:37:37 +00:00
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
2022-08-20 14:37:37 +00:00
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
2022-08-20 14:37:37 +00:00
bcs .9
tya
2022-06-12 20:42:22 +00:00
bra CODE.EmitByte
2022-08-20 14:37:37 +00:00
.9 rts
2022-08-20 14:37:37 +00:00
*--------------------------------------
CODE.DEBUG >LDYA L.PCC.DEBUG
*--------------------------------------
CODE.EmitPCC >STYA ZPLookupPtr
lda (ZPLookupPtr)
tax
dex
2022-08-20 14:37:37 +00:00
ldy #1
.1 lda (ZPLookupPtr),y
jsr CODE.EmitByte
bcs .9
iny
dex
bne .1
.9 rts
*--------------------------------------
2022-06-12 20:42:22 +00:00
CODE.EmitByte clc if Pass 1...
bit bPass2
bpl .1
phx
phy
2022-12-13 06:55:13 +00:00
pha
.DO _DBG_OUT=1
2022-12-13 06:55:13 +00:00
lda ZPCCCode
and #$1F
bne .11
2022-12-13 06:55:13 +00:00
>PUSHW L.MSG.DEBUG.CSOUT
>PUSHW ZPCCCode
>PUSHBI 2
>SYSCALL PrintF
2022-12-13 06:55:13 +00:00
.11 >PUSHW L.MSG.DEBUG.OUT
pla
pha
>PUSHA
>PUSHBI 1
>SYSCALL PrintF
2022-08-20 14:37:37 +00:00
2022-12-13 06:55:13 +00:00
.FIN
2022-06-12 20:42:22 +00:00
>PUSHB.G CC.hOutFile
2022-12-13 06:55:13 +00:00
pla
2022-06-12 20:42:22 +00:00
>PUSHA
>SYSCALL fputc
2022-08-20 14:37:37 +00:00
2022-06-12 20:42:22 +00:00
ply
plx
.1 inc ZPCCCode
bne .8
inc ZPCCCode+1
2022-06-12 20:42:22 +00:00
.8 rts CC/CS from fputc
*--------------------------------------
CODE.EmitDATA clc
bit bPass2
bpl .1
phx
phy
tax
>PUSHB.G CC.hOutFile
txa
2022-12-13 06:55:13 +00:00
2022-06-12 20:42:22 +00:00
>PUSHA
>SYSCALL fputc
ply
plx
.1 inc ZPCCConst
bne .8
inc ZPCCConst+1
.8 rts CC/CS from fputc
*--------------------------------------
CODE.CSSelect clc
bit bPass2
bpl .8
2022-08-20 14:37:37 +00:00
2022-06-12 20:42:22 +00:00
>PUSHB.G CC.hOutFile
2022-08-20 14:37:37 +00:00
>PUSHWZ
2023-01-26 16:38:20 +00:00
* >DEBUG
2022-06-12 20:42:22 +00:00
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
2022-08-20 14:37:37 +00:00
>PUSHWZ
2023-01-26 16:38:20 +00:00
* >DEBUG
2023-01-26 07:07:08 +00:00
lda PCC.FH+PCC.FH.CONST
2022-06-12 20:42:22 +00:00
clc
2023-01-26 07:07:08 +00:00
adc ZPCCConst
2022-06-12 20:42:22 +00:00
tay
2023-01-26 07:07:08 +00:00
lda PCC.FH+PCC.FH.CONST+1
adc ZPCCConst+1
2022-06-12 20:42:22 +00:00
sec
sbc #$20
2022-06-22 06:26:44 +00:00
2022-06-12 20:42:22 +00:00
>PUSHYA
>PUSHBI SEEK.SET
>SYSCALL fseek
.8 rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.code
LOAD usr/src/bin/cc.s
ASM