Subversion Repositories MB01 Project

Rev

Blame | Last modification | View Log | Download | RSS feed

;; cbm emulation

;;CBMP0 .EQU    $7F00

; sezione COMMON -- questo permette di includere il file in piu' file

DPCBM:  .SECTION page0, ref_only, common

        .ABSOLUTE               ;; inizia sempre da $00
        .ORG    0x00

;;MAXLF .EQU    $10             ; max. logical files
MAXLF   .EQU    11              ; max. logical files
MAXVIEC .EQU    8               ; max. virtual iec device #
                .DS     16
                
subflg          .DB     ; ($10)
                .DB     ; ($11)
                .DB     ; ($12)
                .DB     ; ($13)
lineno          .DW     ; ($14-$15) line number used by editor
tmppt           .DB     ; ($16)
tcnt            .DB     ; ($17) temp. counter/index     
                .DW     ; ($18-$19)
                .DW     ; ($1A-$1B)
                .DW     ; ($1C-$1D)
                .DW     ; ($1E-$1F)
                .DB     ; ($20)

; basic/p-code virtual machine work area 
                .DW     ; ($21-$22)
                .DW     ; ($23-$24)             
                .DW     ; ($25-$26)
                .DW     ; ($27-$28)
                .DW     ; ($29-$2A)             
                .DW     ; ($2B-$2C)
                .DW     ; ($2D-$2E)
arytab          .DW     ; ($2F-$30)
strend          .DW     ; ($31-$32)
freetop         .DW     ; ($33-$34)
freespc         .DW     ; ($35-$36)
memsiz          .DW     ; ($37-$38)
curline         .DW     ; ($39-$3A) current line number in execution
oldline         .DW     ; ($3B-$3C) previous line number in execution
oldtxt          .DW     ; ($3D-$3E) saved pointer to text in basic execution
datlin          .DW     ; ($3F-$40)
datptr          .DW     ; ($41-$42)
inpptr          .DW     ; ($43-$44)
varnam          .DW     ; ($45-$46)
varpnt          .DW     ; ($47-$48)
forpnt          .DW     ; ($49-$4A) basic
opptr           .DW     ; ($4B-$4C) basic
opmask          .DB     ; ($4D)
defpnt          .DW     ; ($4E-$4F)
dscpnt          .DW     ; ($50-$51)
dsclen          .DB     ; ($52)
prompt          .DB     ; ($53) prompt flag/CMD channel - editor/basic ($13)

; equates for p-code virtual machine
prtrap          .EQU    oldline         ; ($3B) p-code trap errors flag
pcstack         .EQU    oldline+1       ; ($3C-$3D) p-code save stack
prterr          .EQU    oldtxt+1        ; ($3E) p-code run time error number
psrline         .EQU    datlin          ; ($3F-$40) pascal source line number
prseed          .EQU    datptr          ; ($41-$42) p-code random generator
pbrkcnt         .EQU    inpptr          ; ($43) p-code counter for break check
tmpy            .EQU    inpptr+1        ; ($44) p-code temp. for save Y
inqidx          .EQU    varnam          ; ($45) p-code index to input buffer
inqcnt          .EQU    varnam+1        ; ($46) p-code input buffer counter 
tmpv1           .EQU    varpnt          ; ($47) p-code temp.
tmpv2           .EQU    varpnt+1        ; ($48) p-code temp.
tmpa            .EQU    forpnt          ; ($49) p-code temp. save A
tmpwa           .EQU    forpnt+1        ; ($4A) p-code tmp. save byte to write
tmpx            .EQU    opptr           ; ($4B) p-code tmp. save X when print
pcterr          .EQU    opptr+1         ; ($4C) p-code compiler error flag
tmpdsk          .EQU    opmask          ; ($4D) p-code default temp. disk unit
defprn          .EQU    defpnt          ; ($4E) p-code default printer #device
pcdbg           .EQU    defpnt+1        ; ($4F) p-code debug run after error
pcptr           .EQU    dscpnt          ; ($50-$51) pointer to p-code (debug)
autolf          .EQU    dsclen          ; ($52) p-code auto line feed flag

tmpwrk          .DS 4   ; ($54-$57) temp. area editor/virtual iec
tmpb0           .DB     ; ($58)
argbits         .DB     ; ($59)     FAC #1 guard bits
tmpb2           .DB     ; ($5A) tmp. byte - used by fpu
txtlen          .DB     ; ($5B) tmp. word length of text to insert in buffer
tmpb1           .DB     ; ($5C) tmp. byte used by editor and float point unit
tmpval          .DW     ; ($5D-$5E) temp. word used by editor/fpu
tlnptr          .DW     ; ($5F-$60) temp. line text pointer used by editor/fpu  
facexp          .DB     ; ($61)     FAC #1 exponent
facm            .DS 4   ; ($62-$65) FAC #1 mantissa
facsgn          .DB     ; ($66)     FAC #1 sign
sercnt          .DB     ; ($67)     FAC #1 series evaluation
facov           .DB     ; ($68)     FAC #1 overflow
argexp          .DB     ; ($69)     FAC #2 exponent
argm            .DS 4   ; ($6A-$6D) FAC #2 mantissa
argsgn          .DB     ; ($6E)     FAC #2 sign
arisgn          .DB     ; ($6F)     FAC #1 & #2 sign comparison
facbits         .DB     ; ($70)     FAC #1 guard bits
fbufpt          .DW     ; ($71-$72) FAC series evaluation pointer
fbufpt2         .DB     ; ($73)     FAC series evaluation bank (progr. bank)

; tmp. variables (equates) used by float point unit
factmp          .EQU    tmpwrk          ; ($54-$57) used by fpu mult/div
cprmsk          .EQU    tmpb2           ; ($5A) used by trigs. funcs.
faclsb          .EQU    txtlen          ; ($5B) used by float point unit
dccnt           .EQU    tmpval          ; ($5D) digit count after decimal dot
expval          .EQU    tmpval+1        ; ($5E) exponent value when convert
dotfg           .EQU    tlnptr          ; ($5F) flag decimal dot when convert
expsgn          .EQU    tlnptr+1        ; ($60) flag exponent sign when conver
sgnfg           .EQU    sercnt          ; ($67) flag: minus sign when convert
decidx          .EQU    fbufpt          ; ($71) string index when convert
s2fer           .EQU    fbufpt+1        ; ($72) string to float flag error
decidx2         .EQU    fbufpt+2        ; ($73) used when convert float to str          

s2fstk          .DW     ; ($74-$75) save stack when string to float conversion  
longp           LP      ; ($76-$77-$78) temp. long pointer
s2fptr          .DB     ; ($79) flag trap overflow err. string to float conv.

txtp            .DW     ; ($7A-$7B) current pointer to text
pcdsk           .DB     ; ($7C) flag for pascal compiler
                        ; <7> : compile in memory

iecrp           LP      ; ($7D) iec: pointer to read buffer for include file
iecalt          .DB     ; ($80) iec: flag read from include file
iectp           LP      ; ($81) iec: pointer to read main text buffer
iecndx          .DB     ; ($84) iec: index main text buffer
ieceof          .DB     ; ($85) iec: end of file flag main text buffer
iecwp           LP      ; ($86) iec: pointer to write buffer
iecfg           .DB     ; ($89) iec: flag main text buffer      
iecndx2         .DW     ; ($8A) iec: index buffer include file
iecbuf          .DB     ; ($8C) iec: byte buffer
svbnk           .DB     ; ($8D) save vbnk when run pascal compiler
ieceof2         .DB     ; ($8E) iec: flag eof include file 
vxflag          .DB     ; ($8F) flag valid text in x-bank
kstat           .DB     ; ($90) CBM emulated IEC status
errno           .DB     ; ($91) saved error number
keyfg           .DB     ; ($92) keyboard flag: KbdFlag 
keyctl          .DB     ; ($93) flag control key from get key
keysh           .DB     ; ($94) flag keyboard: KbdShift
keytg           .DB     ; ($95) flag keyboard: KbdToggle
basic           .DB     ; ($96) flag current 'basic' mode
                        ;       <7>: flag basic mode
                        ;       <6>: flag pascal compiler running                       
runf            .DB     ; ($97) flag current run mode
ldtnd           .DB     ; ($98) number of open files
dfltn           .DB     ; ($99) default input device
dflto           .DB     ; ($9A) default output device
skpbk           .DB     ; ($9B) skip blank flag
w2sf            .DB     ; ($9C) integer to string flag conversion
msgflg          .DB     ; ($9D) flag message
autof           .DB     ; ($9E) flag auto-increment line numbering
wauto           .DW     ; ($9F-$A0) auto-increment for line numbering
tbnk            .DB     ; ($A1) bank that hold basic/pascal text                
vbnk            .DB     ; ($A2) bank that hold basic var/pascal pcode-stack             
cbnk            .DB     ; ($A3) compiler bank/temp. bank for exchange
jbnk            .DB     ; ($A4) bank for obj, when compiling (3 bank max.)
xbnk            .DB     ; ($A5) exchange bank for text buffer
dbnk            .DB     ; ($A6) bank for ram disk (jbnk + 3)
botmem          .DW     ; ($A7-$A8) start of memory on the text bank
topmem          .DW     ; ($A9-$AA) top of memory on the text bank
txtbeg          .DW     ; ($AB-$AC) begin of text buffer
txtend          .DW     ; ($AD-$AE) end of text buffer + 1
txttop          .DW     ; ($AF-$B0) top of memory + 1 reserved to text buffer
varbeg          .DW     ; ($B1-$B2) start of basic var/pcode 
vartop          .DW     ; ($B3-$B4) top of basic var/pcode + 1
xtop            .DW     ; ($B5-$B6) top of text + 1 in x-bank           
fnlen           .DB     ; ($B7) length of current filename
lacur           .DB     ; ($B8) current logical file number
sacur           .DB     ; ($B9) current secondary address
facur           .DB     ; ($BA) current device number
fnadr           .DW     ; ($BB-$BC) pointer to current filename
fnadr2          .DB     ; ($BD) - bank that hold file name
objdsk          .DB     ; ($BE) compiler: option '1' specified
truedsk         .DB     ; ($BF) true disk for load pascal soource file
curstk          .DW     ; ($C0-$C1) current stack when in edit mode
pcodef          .DB     ; ($C2) flag p-code present for execution

latb            .DS     MAXLF           ; logical files table
fatb            .DS     MAXLF           ; devices numbers table
satb            .DS     MAXLF           ; secondary addresses table

;=============================================================

cmdlin          .DW     ; command line ptr for pscal program
fpcflag         .DB     ; fpc flags (new style)
                        ; <7>: new style compiler
                        ; <6>: no save exec. file
                        ; <5>: save obj. file

        .RELATIVE
        .ENDS

; basic work area starting at $FF00 of bank that hold text buffer
CBMHIM: .SECTION ref_only, common
        .ABSOLUTE
        .ORG    $FF00
;       .ORG    0

TBUFMAX         .EQU    $A2     ; size of input buffer
VALIDSGN        .EQU    $AA55   ; valid signature

cbmwork         .DS     4       ; first 4 bytes free for insert text line
TXTBUF          .DS     TBUFMAX ; input buffer for text insertion
NUMSTR          .DS     32      ; room for numeric string

TMPPTR          .DW             ; temp. pointer
                .DW
                .DW
                .DW
                .DW
GFNAME          .DS     32      ; global file name 
                .DS     8
                
        ;;.ORG  $FFF8
TXTEND2         .DW             ; saved text end + 1
TXTVSGN         .DW             ; valid text buffer signature
XTOP2           .DW             ; saved text end + 1 in exchange bank
XBVSGN          .DW             ; valid x-bank buffer signature

        .RELATIVE
        .ENDS

.COMMENT @
cbmwork         .EQU    $FF00   ; first 4 bytes free for insert text line
TXTBUF          .EQU    $FF04   ; input buffer for text insertion
NUMSTR          .EQU    $FFA6   ; room for numeric string

TMPPTR          .EQU    $FFC6           ; temp. pointer

TXTEND2         .EQU    $FFF8           ; saved text end + 1
TXTVSGN         .EQU    $FFFA           ; valid text buffer signature
XTOP2           .EQU    $FFFC           ; saved text end + 1 in exchange bank
XBVSGN          .EQU    $FFFE           ; valid x-bank buffer signature
@

; basic/pascal work area starting at $FF00 of bank that hold variables/p-code
CBMHIV: .SECTION common, ref_only
        .ABSOLUTE
        .ORG    $FF00
;       .ORG    0

QINSIZ          .EQU    $5A     ; input buffer max. 90 chars.
NUMSIZ          .EQU    $20     ; size of numeric buffer for conversion
MAX2LF          .EQU    ((MAXLF + 1) * 2) ; size of p-code logical files table
MAXFNLEN        .EQU    19      ; max. length of file name '@x:yyyyyyyyyyyyyyyy'

MINBUF          .DS     QINSIZ
MNUMSTR         .DS     NUMSIZ
MTMPW0          .DW
MTMPW1          .DW
MTMPB0          .DB
MFNAME          .DS     16      ; file name buffer
MTMPNAM         .DS     15      ; tmp. file name
MPOW10          .DS     10      ; power of 10 table
MTRUE           .DS     6
MFALSE          .DS     6
MSTDF0          .DS     4       ; descriptor for file #0 (consolle)
MSTDF1          .DS     4       ; descriptor for file #1 (disk command chann.)
MSTDF2          .DS     4       ; descriptor for file #2 (used by compiler)
MMSET           .DS     16      ; set variables
MFILET          .DS     MAX2LF  ; table of logical files: #0 consolle, #1 disk
FAC1TMP         .DS     5       ; these 3 used by float routines
FAC2TMP         .DS     5
FAC3TMP         .DS     5
FAC4TMP         .DS     5       ; free to use
MTPTR           .DW             ; used by new/dispose
MTMPW2          .DW

        .RELATIVE
        .ENDS

.COMMENT @
MINBUF          .EQU    $FF00
MNUMSTR         .EQU    $FF5A
MTMPW0          .EQU    $FF7A
MTMPW1          .EQU    $FF7C
MTMPB0          .EQU    $FF7E
MFNAME          .EQU    $FF7F   ; file name buffer
MTMPNAM         .EQU    $FF8F   ; tmp. file name
MPOW10          .EQU    $FF9E   ; power of 10 table
MTRUE           .EQU    $FFA8
MFALSE          .EQU    $FFAE
MSTDF0          .EQU    $FFB4   ; descriptor for file #0 (consolle)
MSTDF1          .EQU    $FFB8   ; descriptor for file #1 (disk command chann.)
MSTDF2          .EQU    $FFBC   ; descriptor for file #2 (used by compiler)
MMSET           .EQU    $FFC0   ; set variables
MFILET          .EQU    $FFD0   ; table of logical files: #0 consolle, #1 disk
FAC1TMP         .EQU    $FFE8   ; these 3 used by float routines
FAC2TMP         .EQU    $FFED
FAC3TMP         .EQU    $FFF2
FAC4TMP         .EQU    $FFF7   ; free to use
MTPTR           .EQU    $FFFC   ; used by new/dispose
MTMPW2          .EQU    $FFFE
@

; temp. file names in x-bank
PASSRC          .EQU    $FF00
OBJDST          .EQU    $FF20
EXEDST          .EQU    $FF40
OBJDEL          .EQU    $FF60