A2osX/BIN/CC.S.txt

1175 lines
24 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
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/cc
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
_DBG_SYM .EQ 0
_DBG_SCOPE .EQ 0
_DBG_OUT .EQ 0
*--------------------------------------
FILES.MAX .EQ 4
LIBS.MAX .EQ 4
SCOPE.MAX .EQ 16
LOOKUP.MAX .EQ 16
*--------------------------------------
SYM.T .EQ 0
SYM.T.VOID .EQ 1
SYM.T.UCHAR .EQ 2
SYM.T.SCHAR .EQ 3
SYM.T.UINT .EQ 4
SYM.T.SINT .EQ 5
SYM.T.ULONG .EQ 6
SYM.T.SLONG .EQ 7
SYM.T.FLOAT .EQ 8
SYM.T.SU .EQ 9
SYM.T.ENUM .EQ 10
SYM.T.VARIADIC .EQ $FF
SYM.Q .EQ 1
SYM.Q.POINTER .EQ %01000000
SYM.Q.PPOINTER .EQ %10000000
SYM.Q.PPPOINTER .EQ %11000000
SYM.Q.ARRAY .EQ %00010000
SYM.Q.AARRAY .EQ %00100000
SYM.Q.AAARRAY .EQ %00110000
SYM.Q.CONST .EQ %00001000
SYM.Q.VOLATILE .EQ %00000100
SYM.Q.FUNC .EQ %00000010
SYM.Q.FASTCALL .EQ %00000001
SYM.SC .EQ 2
SYM.SC.STATIC .EQ 0
SYM.SC.AUTO .EQ 2
SYM.SC.REGISTER .EQ 4
SYM.SC.EXTERN .EQ 6
SYM.SC.TYPEDEF .EQ 8
SYM.SC.DEFINE .EQ 10
SYM.SC.TAG .EQ 12
SYM.DefSize .EQ 3
SYM.SizeOf .EQ 4
SYM.Addr .EQ 6
SYM.BitO .EQ 8
SYM.BitW .EQ 9
SYM.ScopeID .EQ 10
*
*
SYM.Def .EQ 14 Funtions : fTQ,a1TQ,a2TQ....
*
SYM .EQ 16
SYM.F.MAX .EQ 64
*--------------------------------------
SU.F.T .EQ 0
SU.F.Q .EQ 1
SU.F.O .EQ 2
SU.F.BitO .EQ 4
SU.F.BitW .EQ 5
SU.F.Name .EQ 6
*--------------------------------------
SCOPE.ID .EQ 0
SCOPE.LocalPtr .EQ 2
SCOPE.FrameSize .EQ 3
*
SCOPE .EQ 4
*--------------------------------------
STMT.hMEM .EQ 3 switch/case
STMT.MemPtr .EQ 2
STMT.TERM .EQ 1
STMT.KW .EQ 0
*
STMT .EQ 4
*--------------------------------------
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
ArgIndex .BS 1
bPass2 .BS 1
ZPCCCode .BS 2
ZPCCConst .BS 2
ZPCCData .BS 2
ScopePtr .BS 1
StmtPtr .BS 1
ScopeStk .BS 2
StmtStk .BS 2
ZPLineBufPtr .BS 2
ZPLookupPtr .BS 2
ZPSymBufPtr .BS 2
ZPLookupSymPtr .BS 2
bLocalScope .BS 1
StmtPreOp .BS 1
ExpState .BS 1
*ExpState.VinYA .EQ $10
ExpState.AonStack .EQ $20
ExpState.AinPTR .EQ $40
ExpState.VonStack .EQ $80
* .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Size
.DA #256 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
*--------------------------------------
L.MSG.GREETINGS .DA MSG.GREETINGS
L.MSG.USAGE .DA MSG.USAGE
L.MSG.READING .DA MSG.READING
L.MSG.LINKING .DA MSG.LINKING
L.MSG.LINKING2 .DA MSG.LINKING2
L.MSG.GENERATING .DA MSG.GENERATING
.DO _DBG_SYM=1
L.MSG.DEBUG.SYMN .DA MSG.DEBUG.SYMN
L.MSG.DEBUG.SYMU .DA MSG.DEBUG.SYMU
L.MSG.DEBUG.SYMS .DA MSG.DEBUG.SYMS
L.MSG.DEBUG.SYMG .DA MSG.DEBUG.SYMG
L.MSG.DEBUG.SYMNL .DA MSG.DEBUG.SYMNL
L.MSG.DEBUG.SYMSL .DA MSG.DEBUG.SYMSL
.FIN
.DO _DBG_SCOPE=1
L.MSG.DEBUG.SCIN .DA MSG.DEBUG.SCIN
L.MSG.DEBUG.SC .DA MSG.DEBUG.SC
L.MSG.DEBUG.SCOUT .DA MSG.DEBUG.SCOUT
.FIN
.DO _DBG_OUT=1
L.MSG.DEBUG.CSOUT .DA MSG.DEBUG.CSOUT
L.MSG.DEBUG.OUT .DA MSG.DEBUG.OUT
.FIN
L.MSG.VERBOSE .DA MSG.VERBOSE
L.MSG.RTSTK .DA MSG.RTSTK
L.MSG.ERROR .DA MSG.ERROR
L.MSG.SUMMARY .DA MSG.SUMMARY
L.MSG.NOMAIN .DA MSG.NOMAIN
L.MSG.ALLDONE .DA MSG.ALLDONE
L.ENV.INCLUDE .DA ENV.INCLUDE
L.ENV.LIB .DA ENV.LIB
L.LIB.O .DA LIB.O
*--------------------------------------
L.CC.AOPS .DA CC.AOPS
L.CC.PREOPS .DA CC.PREOPS
L.CC.POSTOPS .DA CC.POSTOPS
L.CC.BOPS .DA CC.BOPS
L.CC.DIRS .DA CC.DIRS
L.CC.KW .DA CC.KW
L.CC.KW2.IF .DA CC.KW2.IF
L.CC.KW2.DO .DA CC.KW2.DO
L.CC.SCSPEC .DA CC.SCSPEC
L.CC.TYPEQUAL .DA CC.TYPEQUAL
L.CC.TYPESPEC .DA CC.TYPESPEC
L.CC.TYPES .DA CC.TYPES
L.CC.FTYPES .DA CC.FTYPES
*--------------------------------------
J.CC.DIRS .DA DIR.DEFINE
.DA DIR.INCLUDE
.DA DIR.IFDEF
.DA DIR.IFNDEF
.DA DIR.ELSE
.DA DIR.ENDIF
*--------------------------------------
J.CC.PREOPS .DA EXP.Ref
.DA EXP.Deref
.DA EXP.Abs
.DA EXP.negate
.DA EXP.lnot
.DA EXP.bnot
.DA EXP.preinc
.DA EXP.predec
*--------------------------------------
J.CC.POSTOPS .DA EXP.postinc
.DA EXP.postdec
.DA EXP.idx
.DA EXP.SU
.DA EXP.pSU
*--------------------------------------
J.CC.KW .DA KW.IF
.DA KW.WHILE
KW.ELSE.ID .EQ *-J.CC.KW
.DA KW.ELSE
.DA KW.DO
.DA KW.FOR
KW.SWITCH.ID .EQ *-J.CC.KW
.DA KW.SWITCH
.DA KW.CASE
.DA KW.DEFAULT
.DA KW.BREAK
.DA KW.CONTINUE
.DA KW.RETURN
.DA KW.SIZEOF
*--------------------------------------
J.CC.KW.END .DA KW.IF.END
.DA KW.WHILE.END
.DA KW.ELSE.END
.DA KW.DO.END
.DA KW.FOR.END
.DA KW.SWITCH.END
*--------------------------------------
J.CC.SCSPEC .DA DECL.AUTO
.DA DECL.REGISTER
.DA DECL.STATIC
.DA DECL.EXTERN
.DA DECL.TYPEDEF
J.CC.TYPEQUAL .DA TYPE.CONST
.DA TYPE.VOLATILE
J.CC.TYPESPEC .DA TYPE.STRUCT
.DA TYPE.UNION
.DA TYPE.ENUM
.DA TYPE.SIGNED
.DA TYPE.UNSIGNED
.DA TYPE.SHORT
J.CC.TYPES .DA TYPE.VOID
.DA TYPE.CHAR
.DA TYPE.INT
.DA TYPE.LONG
.DA TYPE.FLOAT
J.CC.UTYPES .DA TYPE.UCHAR
.DA TYPE.UINT
.DA TYPE.ULONG
J.CC.STYPES .DA TYPE.SCHAR
.DA TYPE.SINT
.DA TYPE.SLONG
*--------------------------------------
L.CC.MAIN .DA CC.MAIN
L.CC.SYSCALL .DA CC.SYSCALL
L.CC.FPUCALL .DA CC.FPUCALL
*--------------------------------------
L.PCC.FH .DA PCC.FH
L.PCC.DEBUG .DA PCC.DEBUG
L.PCC.SLEEP .DA PCC.SLEEP
L.PCC.ENTER .DA PCC.ENTER
L.PCC.LEAVE .DA PCC.LEAVE
L.PCC.ADDLOCAL .DA PCC.ADDLOCAL
L.PCC.SetRetValue .DA PCC.SetRetValue
L.PCC.8to16 .DA PCC.8to16
L.PCC.JmpOnYA .DA PCC.JmpOnYA
L.PCC.Pop16 .DA PCC.Pop16
L.PCC.TestZero1 .DA PCC.TestZero1
L.PCC.TestZero2 .DA PCC.TestZero2
L.PCC.TestZeroX .DA PCC.TestZeroX
L.PCC.TestnZero1 .DA PCC.TestnZero1
L.PCC.TestnZero2 .DA PCC.TestnZero2
L.PCC.TestnZeroX .DA PCC.TestnZeroX
L.PCC.PushLAddrH .DA PCC.PushLAddrH
L.PCC.PushLAddrL .DA PCC.PushLAddrL
L.PCC.PushIAddr .DA PCC.PushIAddr
L.PCC.PushUAddr .DA PCC.PushUAddr
L.PCC.GetLAddr1 .DA PCC.GetLAddr1
L.PCC.GetIAddr1 .DA PCC.GetIAddr1
L.PCC.GetUAddr1 .DA PCC.GetUAddr1
L.PCC.PopAddr1 .DA PCC.PopAddr1
L.PCC.PopValue1 .DA PCC.PopValue1
L.PCC.PopValue2 .DA PCC.PopValue2
L.PCC.PopValueX .DA PCC.PopValueX
L.PCC.GetLAddr2 .DA PCC.GetLAddr2
L.PCC.GetIAddr2 .DA PCC.GetIAddr2
L.PCC.GetUAddr2 .DA PCC.GetUAddr2
L.PCC.PopAddr2 .DA PCC.PopAddr2
L.PCC.Deref2 .DA PCC.Deref2
L.PCC.PushDeref2 .DA PCC.PushDeref2
L.PCC.PushValue1 .DA PCC.PushValue1
L.PCC.PushValue2 .DA PCC.PushValue2
L.PCC.PushValueY .DA PCC.PushValueY
L.PCC.Inc1 .DA PCC.Inc1
L.PCC.Inc2 .DA PCC.Inc2
L.PCC.Inc4 .DA PCC.Inc4
L.PCC.Dec1 .DA PCC.Dec1
L.PCC.Dec2 .DA PCC.Dec2
L.PCC.Dec4 .DA PCC.Dec4
*--------------------------------------
L.PCC.bBOPS .DA PCC.BOPS.bMUL
.DA PCC.BOPS.bDIV
.DA PCC.BOPS.bMOD
.DA PCC.BOPS.ADD
.DA PCC.BOPS.SUB
.DA PCC.BOPS.SHL
.DA PCC.BOPS.SHR
.DA PCC.BOPS.L
.DA PCC.BOPS.G
.DA PCC.BOPS.LE
.DA PCC.BOPS.GE
.DA PCC.BOPS.EQ
.DA PCC.BOPS.NE
.DA PCC.BOPS.LAND
.DA PCC.BOPS.AND
.DA PCC.BOPS.LOR
.DA PCC.BOPS.OR
.DA PCC.BOPS.EOR
*--------------------------------------
L.PCC.cBOPS .DA PCC.BOPS.cMUL
.DA PCC.BOPS.cDIV
.DA PCC.BOPS.cMOD
.DA PCC.BOPS.ADD
.DA PCC.BOPS.SUB
.DA PCC.BOPS.SHL
.DA PCC.BOPS.SHR
.DA PCC.BOPS.L
.DA PCC.BOPS.G
.DA PCC.BOPS.LE
.DA PCC.BOPS.GE
.DA PCC.BOPS.EQ
.DA PCC.BOPS.NE
.DA PCC.BOPS.LAND
.DA PCC.BOPS.AND
.DA PCC.BOPS.LOR
.DA PCC.BOPS.OR
.DA PCC.BOPS.EOR
*--------------------------------------
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
CS.RUN >PUSHW L.MSG.GREETINGS
>PUSHW A2osX.KVER
>PUSHBI 2
>SYSCALL PrintF
bcs CS.INIT.RTS
lda #hFilePtr
>STA.G hFilePtr
lda #LineCntPtr
>STA.G LineCntPtr
>LDYAI 256
>SYSCALL GetMem
bcs CS.INIT.RTS
>STYA.G LineBufPtr
txa
>STA.G hLineBuf
jsr CS.RUN.ARGS
bcs CS.INIT.RTS
jsr CORE.Init
bcs CS.INIT.RTS
jsr CODE.Init
bcs CS.INIT.RTS
jsr FIO.FOpen1st
bcs CS.INIT.RTS
*--------------------------------------
CS.RUN.CLOOP jsr CORE.CompileFile
cmp #MLI.E.EOF
bne .9
* bne .1
jsr FIO.FClose
bne CS.RUN.CLOOP
*--------------------------------------
.1 jsr PrintSummary
bcs .99
* >DEBUG
jsr CC.Link
bcs .99
* >DEBUG
jsr CC.Link.CheckMain
bcs .99
dec bPass2
jsr FIO.FCreate
bcs .99
jsr CODE.Init
bcs .99
jsr FIO.FOpen1st
bcs .99
*--------------------------------------
.2 jsr CORE.CompileFile
cmp #MLI.E.EOF
bne .9
jsr FIO.FClose
bne .2
*--------------------------------------
>LDYA L.MSG.ALLDONE
>SYSCALL PutS
lda #0 Exit Code = Success
sec
rts
.9 pha
jsr PrintErrorMsg
pla
sec
.99 rts
*--------------------------------------
CS.RUN.ARGS inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .8
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
beq .90
ldx #OptionVars-OptionList-1
.1 cmp OptionList,x
beq .2
dex
bpl .1
bra .90
.2 cpx #2 LIB
bcc .3
inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .90
jsr FIO.LoadLIB.o
bcc CS.RUN.ARGS
rts
.3 ldy OptionVars,x
lda #$ff
sta (pData),y
bra CS.RUN.ARGS
.4 >LDA.G CC.InFileArg
bne .5
lda ArgIndex
>STA.G CC.InFileArg
bra CS.RUN.ARGS
.5 >LDA.G CC.OutFileArg
bne .90
lda ArgIndex
>STA.G CC.OutFileArg
bra CS.RUN.ARGS
.8 >LDA.G CC.InFileArg
beq .90
>LDA.G CC.OutFileArg
beq .90
clc
.9 rts
.90 >PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
lda #E.SYN
sec
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT jsr CODE.Quit
jsr CORE.Quit
.1 >LDA.G LibCount
beq .6
dec
sta (pData),y
clc
adc #hLibOs
tay
lda (pData),y
>SYSCALL FreeMem
bra .1
.6 >LDA.G hLineBuf
beq .8
>SYSCALL FreeMem
.8 clc
rts
*--------------------------------------
PrintVerboseMsg
.DO _DBG_SCOPE=1
>PUSHW L.MSG.DEBUG.SC
jsr SCOPE.Push
lda ScopePtr
>PUSHA
tay
iny
iny
>PUSHB (ScopeStk),y
iny
>PUSHB (ScopeStk),y
>PUSHBI 5
>SYSCALL PrintF
* >DEBUG
.FIN
ldy #S.PS.hStdOut
* ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.VERBOSE
>LDA.G LineCntPtr
inc
tay
lda (pData),y
>PUSHA
dey
lda (pData),y
>PUSHA
>PUSHW.G LineBufPtr
>PUSHBI 4
>SYSCALL FPrintF
rts
*--------------------------------------
PrintErrorMsg >LDA.G CC.hDefineBuf
beq .10
>LDYA.G CC.SaveDefine
>STYA ZPLineBufPtr
.10 >LDA.G bVerbose
bmi .1
jsr PrintVerboseMsg
.1 lda ZPLineBufPtr
sec
>SBC.G LineBufPtr
tax
>LDYA.G LineBufPtr
>STYA ZPLineBufPtr
txa
beq .3
ldy #0
lda #'-'
.2 sta (ZPLineBufPtr),y
iny
dex
bne .2
txa
.3 sta (ZPLineBufPtr),y
.8 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.ERROR
>PUSHW ZPLineBufPtr
>PUSHBI 2
>SYSCALL FPrintF
rts
*--------------------------------------
PrintSummary >PUSHW L.MSG.SUMMARY
lda ZPCCCode+1
sec
sbc #$20
>PUSHA
>PUSHB ZPCCCode
>PUSHW ZPCCConst
>PUSHW ZPCCData
>PUSHBI 6
>SYSCALL PrintF
rts
*--------------------------------------
.INB usr/src/bin/cc.s.code
.INB usr/src/bin/cc.s.core
.INB usr/src/bin/cc.s.decl
.INB usr/src/bin/cc.s.dir
.INB usr/src/bin/cc.s.exp
.INB usr/src/bin/cc.s.f
.INB usr/src/bin/cc.s.fio
.INB usr/src/bin/cc.s.kw
.INB usr/src/bin/cc.s.link
.INB usr/src/bin/cc.s.scope
.INB usr/src/bin/cc.s.stmt
.INB usr/src/bin/cc.s.sym
.INB usr/src/bin/cc.s.type
*--------------------------------------
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.GREETINGS .CZ "\r\nA2osX C Compiler %d.%d\r\n\r\n"
MSG.USAGE .CS "Usage : CC <option> srcfile.c dstfile\r\n"
.CS " -V : Verbose output\r\n"
.CZ " -L Libname1 -L Libname2 ...\r\n"
MSG.READING .CZ "*** Reading file: %s\r\n"
MSG.LINKING .CZ "*** Linking..."
MSG.LINKING2 .CZ "*** %H:%H:%18s T/Q=%h/%h, SC=%h, Def=%h, SizeOf=%H, @=%H\r\n"
MSG.GENERATING .CZ "*** Generating: %s\r\n"
.DO _DBG_SYM=1
MSG.DEBUG.SYMN .CZ "New SymID=%H[%H],T=%h,Q=%h,SC=%h "
MSG.DEBUG.SYMU .CZ "Upd SymID=%H,T=%h,Q=%h,SC=%h,@=%H\r\n"
MSG.DEBUG.SYMS .CZ "Sto SymID=%H,T=%h,Q=%h,SC=%h,@=%H\r\n"
MSG.DEBUG.SYMG .CZ "Get SymID=%H,T=%h,Q=%h,SC=%h\r\n"
MSG.DEBUG.SYMNL .CZ "New (%s) ID=%H[%H],T=%h,Q=%h,SC=%h "
MSG.DEBUG.SYMSL .CZ "Sto ID=%H,T=%h,Q=%h,SC=%h\r\n"
.FIN
.DO _DBG_SCOPE=1
MSG.DEBUG.SCIN .CZ "Scope { %H (%h:%h:%h)\r\n"
MSG.DEBUG.SC .CZ "Scope = %H (%h:%h:%h)\r\n"
MSG.DEBUG.SCOUT .CZ "Scope } %H (%h:%h:%h) -> "
.FIN
.DO _DBG_OUT=1
MSG.DEBUG.CSOUT .CZ "\r\n%H-"
MSG.DEBUG.OUT .CZ "%h"
.FIN
MSG.VERBOSE .CZ "%5D> %s\r\n"
MSG.RTSTK .CZ "<pBase=%H, pVar=%H, (pVar)=%H, pStack=%H>\r\n"
MSG.ERROR .CZ " %s^\r\n"
MSG.SUMMARY .CZ "*** Compilation OK : Code size=%5D, Const size=%5D, Data size=%5D\r\n"
MSG.NOMAIN .CZ "*** No 'main()' function defined."
MSG.ALLDONE .CZ "*** All Done."
*--------------------------------------
OptionList .AS "VvLl"
OptionVars .DA #bVerbose,#bVerbose
*--------------------------------------
ENV.INCLUDE .AZ "INCLUDE"
ENV.LIB .AZ "LIB"
LIB.O .AZ ".o"
*--------------------------------------
CC.EscChars .AS "abefnrtv"
.HS 5C27223F \'"?
CC.EscChars.Cnt .EQ *-CC.EscChars
CC.EscCodes .HS 07081B0C0A0D090B
.HS 5C27223F
*--------------------------------------
CC.OPChars .AS "!~+-*/%=&|^<>["
CC.OPChars.Cnt .EQ *-CC.OPChars
*--------------------------------------
* Assignment Operators: = += -= *= /= %= <<= >>= &= ^= |=
*--------------------------------------
CC.AOPS .PS "="
.PS "+="
.PS "-="
.PS "*="
.PS "/="
.PS "%="
.PS "<<="
.PS ">>="
.PS "&="
.PS "^="
.PS "!="
.HS 00
*--------------------------------------
* Pre Operators: & * + - ! ~ ++ --
*--------------------------------------
CC.PREOPS .PS "&" ref
.PS "*" deref
.PS "+" abs
.PS "-" negate
.PS "!" logical not
.PS "~" bitwise not
.PS "++" pre increase
.PS "--" pre decrease
.HS 00
*--------------------------------------
* Post Operators: ++ --
*--------------------------------------
CC.POSTOPS .PS "++"
.PS "--"
.PS "["
.PS "."
.PS "->"
.HS 00
*-- Binary ---- H to L precedence -----
* Arithmetic Operators: * / %
* Arithmetic Operators: + -
* Shift Operators: << >>
* Relational Operators: < > >= < >= == !=
* Bitwise Operators: & | ^ ~
* Logical Operators: && ||
*--------------------------------------
CC.BOPS .PS "*"
.PS "/"
.PS "%"
.PS "+"
.PS "-"
.PS "<<"
.PS ">>"
.PS "<"
.PS "<="
.PS ">"
.PS ">="
.PS "=="
.PS "!="
.PS "&"
.PS "|"
.PS "^"
.PS "&&"
.PS "||"
.HS 00
*--------------------------------------
* Reserved Directives:
*--------------------------------------
CC.DIRS .PS "define"
.PS "include"
.PS "ifdef"
.PS "ifndef"
.PS "else"
.PS "endif"
.HS 00
*--------------------------------------
* Reserved Keywords:
*--------------------------------------
CC.KW .PS "if"
.PS "while"
.PS "else"
.PS "do"
.PS "for"
.PS "switch"
.PS "case"
.PS "default"
.PS "break"
.PS "continue"
.PS "return"
.PS "sizeof"
.HS 00
CC.KW2.IF .PS "else"
.HS 00
CC.KW2.DO .PS "while"
.HS 00
*--------------------------------------
CC.SCSPEC .PS "auto"
.PS "register"
.PS "static"
.PS "extern"
.PS "typedef"
.HS 00
*--------------------------------------
CC.TYPEQUAL .PS "const" ALL
.PS "volatile"
CC.TYPESPEC .PS "struct"
.PS "union"
.PS "enum"
.PS "signed" char,int,long
.PS "unsigned" char,int,long
.PS "short" int
CC.TYPES .PS "void"
.PS "char"
.PS "int"
.PS "long"
.PS "float"
.HS 00
*--------------------------------------
CC.Type2FPU .DA #FPU.wMUL,#FPU.iMUL,#FPU.uMUL,#FPU.lMUL,#FPU.fMUL
*--------------------------------------
CC.FTYPES .PS "fastcall"
* .HS 00
*--------------------------------------
CC.TYPESIZE .HS 0001010202040405
CC.TYPESIGN .HS 0000FF00FF00FFFF
*--------------------------------------
CC.MAIN .AZ "main"
CC.MAIN.DEF .DA #SYM.T.SINT,#0,#SYM.T.SINT,#0,#SYM.T.UCHAR,#SYM.Q.PPOINTER,0
CC.MAIN.DEF.LEN .EQ *-CC.MAIN.DEF
*--------------------------------------
CC.SYSCALL .PS "chtyp"
.DA #_ChTyp
.PS "chmod"
.DA #_ChMod
.PS "fstat"
.DA #_FStat
.PS "stat"
.DA #_Stat
.PS "mkdir"
.DA #_MKDir
.PS "mknod"
.DA #_MKNod
.PS "mkfifo"
.DA #_MKFIFO
.PS "pipe"
.DA #_Pipe
.PS "opendir"
.DA #_OpenDir
.PS "readdir"
.DA #_ReadDir
.PS "closedir"
.DA #_CloseDir
.PS "open"
.DA #_Open
.PS "close"
.DA #_Close
.PS "read"
.DA #_Read
.PS "write"
.DA #_Write
.PS "chown"
.DA #_ChOwn
.PS "fputc"
.DA #_FPutC
.PS "putchar"
.DA #_PutChar
.PS "getc"
.DA #_GetC
.PS "getchar"
.DA #_GetChar
.PS "fputs"
.DA #_FPutS
.PS "puts"
.DA #_PutS
.PS "fgets"
.DA #_FGetS
.PS "ungetc"
.DA #_UngetC
.PS "fopen"
.DA #_FOpen
.PS "fclose"
.DA #_FClose
.PS "fread"
.DA #_FRead
.PS "fwrite"
.DA #_FWrite
.PS "fflush"
.DA #_FFlush
.PS "fseek"
.DA #_FSeek
.PS "ftell"
.DA #_FTell
.PS "feof"
.DA #_FEOF
.PS "remove"
.DA #_Remove
.PS "rename"
.DA #_Rename
.PS "printf"
.DA #_PrintF
.PS "fprintf"
.DA #_FPrintF
.PS "sprintf"
.DA #_SPrintF
.PS "scanf"
.DA #_ScanF
.PS "fscanf"
.DA #_FScanF
.PS "sscanf"
.DA #_SScanF
* .PS "$50"
* .DA #0
* .PS "$52"
* .DA #0
* .PS "$54"
* .DA #0
* .PS "$56"
* .DA #0
* .PS "$58"
* .DA #0
* .PS "$5A"
* .DA #0
* .PS "$5C"
* .DA #0
.PS "setattr"
.DA #_SetAttr
* .PS "mount"
* .DA #0
* .PS "umount"
* .DA #0
* .PS "loadstkobj"
* .DA #0
* .PS "getstkobj"
* .DA #0
* .PS "shift"
* .DA #0
* .PS "argv"
* .DA #0
* .PS "argvDup"
* .DA #0
* .PS "geterrmsg"
* .DA #0
.PS "atof"
.DA #_AToF
.PS "atoi"
.DA #_AToI
.PS "atol"
.DA #_AToL
.PS "strtof"
.DA #_StrToF
.PS "strtol"
.DA #_StrToL
.PS "strtoul"
.DA #_StrToUL
.PS "realpath"
.DA #_RealPath
.PS "expand"
.DA #_Expand
.PS "strlen"
.DA #_StrLen
.PS "strcpy"
.DA #_StrCpy
.PS "strcat"
.DA #_StrCat
.PS "strdup"
.DA #_StrDup
.PS "strupr"
.DA #_StrUpr
.PS "strlwr"
.DA #_StrLwr
.PS "strcmp"
.DA #_StrCmp
.PS "strcasecmp"
.DA #_StrCaseCmp
* .PS "getdevbyname"
* .DA #0
* .PS "getdevstatus"
* .DA #0
* .PS "mkdev"
* .DA #0
* .PS "ioctl"
* .DA #0
* .PS "loadlib"
* .DA #0
* .PS "unloadlib"
* .DA #0
* .PS "loaddrv"
* .DA #0
* .PS "insdrv"
* .DA #0
.PS "execl"
.DA #_ExecL
* .PS "execv"
* .DA #0
.PS "fork"
.DA #_Fork
.PS "kill"
.DA #_Kill
* .PS "loadfile"
* .DA #0
* .PS "loadtxtfile"
* .DA #0
* .PS "filesearch"
* .DA #0
* .PS "getmemstat"
* .DA #0
* .PS "strvnew"
* .DA #0
* .PS "strvset"
* .DA #0
* .PS "strvget"
* .DA #0
* .PS "strvfree"
* .DA #0
.PS "putenv"
.DA #_PutEnv
.PS "setenv"
.DA #_SetEnv
.PS "getenv"
.DA #_GetEnv
.PS "unsetenv"
.DA #_UnsetEnv
.PS "time"
.DA #_Time
.PS "strftime"
.DA #_StrFTime
* .PS "ptime2time"
* .DA #0
.PS "ctime2time"
.DA #_CTime2Time
.PS "md5"
.DA #_MD5
.PS "md5init"
.DA #_MD5Init
.PS "md5update"
.DA #_MD5Update
.PS "md5finalize"
.DA #_MD5Finalize
.PS "getpwuid"
.DA #_GetPWUID
.PS "getpwname"
.DA #_GetPWName
.PS "putpw"
.DA #_PutPW
.PS "getgrpgid"
.DA #_GetGRGID
.PS "getgrpname"
.DA #_GetGRName
.PS "putgr"
.DA #_PutGR
* .PS "opensession"
* .DA #0
* .PS "closesession"
* .DA #0
* .PS "slistgetdata"
* .DA #0
* .PS "slistadddata"
* .DA #0
* .PS "slistsetdata"
* .DA #0
* .PS "slistgetbyid"
* .DA #0
* .PS "slistnewkey"
* .DA #0
* .PS "slistlookup"
* .DA #0
* .PS "slistfree"
* .DA #0
* .PS "slistnew"
* .DA #0
.PS "malloc"
.DA #_GetMem
.PS "realloc"
.DA #_Realloc
* .PS "getmemptr"
* .DA #0
* .PS "freemem"
* .DA #_FreeMem
.PS "free"
.DA #_Free
* .PS "newstkobj"
* .DA #0
* .PS "getstkobjptr"
* .DA #0
* .PS "freestkobj"
* .DA #0
.DA #0
*--------------------------------------
CC.FPUCALL .PS "pwr"
.DA #FPU.PWR
.PS "log"
.DA #FPU.LOG
.PS "sqr"
.DA #FPU.SQR
.PS "exp"
.DA #FPU.EXP
.PS "cos"
.DA #FPU.COS
.PS "sin"
.DA #FPU.SIN
.PS "tan"
.DA #FPU.TAN
.PS "atan"
.DA #FPU.ATAN
.PS "lrintf"
.DA #FPU.QINT
.DA #0
*--------------------------------------
.INB usr/src/bin/cc.s.pcc
*--------------------------------------
.DUMMY
.OR 0
DS.START
PathBuf .BS MLI.MAXPATH+1
*bDebug .BS 1
bVerbose .BS 1
LibCount .BS 1
hLibNs .BS LIBS.MAX
hLibOs .BS LIBS.MAX
CC.InFileArg .BS 1
CC.OutFileArg .BS 1
CC.hOutFile .BS 1
hFilePtr .BS 1
hFiles .BS FILES.MAX
LineCntPtr .BS 1
.BS 1 for inc inc
LineCnts .BS FILES.MAX*2
hLineBuf .BS 1
LineBufPtr .BS 2
CC.CmdSave .BS 1
CC.hDefineBuf .BS 1
CC.hDefines .BS 1
CC.SaveDefine .BS 2
CC.DirState .BS 1
CC.DirDepth .BS 1
CC.hTags .BS 1
CC.hScopeStk .BS 1
CC.hStmtStk .BS 1
CC.hSyms .BS 1
CC.ScopeID .BS 2
CC.bInitCode .BS 1
*--------------------------------------
CC.hSymBuf .BS 1
CC.SymID .BS 2
CC.SymIDSave .BS 2
CC.ArgBuf .BS SYM
CC.Label .BS 3 _X\0
CC.LabelID .BS 2
CC.LabelBuf .BS SYM
*--------------------------------------
CC.LookupSymSize .BS 2
CC.LookupSymPtr .BS 2
CC.LookupIdx .BS 1
CC.hLookupBufs .BS LOOKUP.MAX
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s
ASM