simple command launch for BYE command

This commit is contained in:
David Schmenk 2014-05-06 19:18:36 -07:00
parent 3858728528
commit 689e0542ce
7 changed files with 373 additions and 145 deletions

View File

@ -37,8 +37,9 @@ end
; CALL LOADED SYSTEM PROGRAM ; CALL LOADED SYSTEM PROGRAM
; ;
asm exec asm exec
LDX #$FF LDX #$FE
TXS TXS
LDX ESTKSZ/2
BIT ROMEN BIT ROMEN
JMP $2000 JMP $2000
end end
@ -64,8 +65,7 @@ SETMLP DEC ESTKL,X
BNE SETMLP BNE SETMLP
INC DSTH INC DSTH
BNE SETMLP BNE SETMLP
+ INX ++ INX
INX
RTS RTS
end end
; ;
@ -139,7 +139,6 @@ FORCPYLP
DEC ESTKH,X DEC ESTKH,X
BNE FORCPYLP BNE FORCPYLP
MEMEXIT INX MEMEXIT INX
INX
INX INX
RTS RTS
end end
@ -149,11 +148,9 @@ end
; ;
asm cout asm cout
LDA ESTKL,X LDA ESTKL,X
INX
ORA #$80 ORA #$80
BIT ROMIN BIT ROMEN
JSR $FDED JSR $FDED
BIT LCBNK2
RTS RTS
end end
; ;
@ -161,11 +158,10 @@ end
; RDKEY() ; RDKEY()
; ;
asm cin asm cin
BIT ROMIN BIT ROMEN
STX ESP STX ESP
JSR $FD0C JSR $FD0C
LDX ESP LDX ESP
BIT LCBNK2
DEX DEX
STA ESTKL,X STA ESTKL,X
LDY #$00 LDY #$00
@ -182,7 +178,7 @@ asm prstr
STA SRCL STA SRCL
LDA ESTKH,X LDA ESTKH,X
STA SRCH STA SRCH
BIT ROMIN BIT ROMEN
LDA (SRC),Y LDA (SRC),Y
STA ESTKL,X STA ESTKL,X
BEQ + BEQ +
@ -193,20 +189,16 @@ asm prstr
TYA TYA
CMP ESTKL,X CMP ESTKL,X
BNE - BNE -
+ INX + RTS
BIT LCBNK2
RTS
end end
; ;
; PRINT BYTE ; PRINT BYTE
; ;
asm prbyte asm prbyte
LDA ESTKL,X LDA ESTKL,X
INX
STX ESP STX ESP
BIT ROMIN BIT ROMEN
JSR $FDDA JSR $FDDA
BIT LCBNK2
LDX ESP LDX ESP
RTS RTS
end end
@ -218,9 +210,8 @@ asm rdstr
LDA ESTKL,X LDA ESTKL,X
STA $33 STA $33
STX ESP STX ESP
BIT ROMIN BIT ROMEN
JSR $FD6A JSR $FD6A
BIT LCBNK2
STX $01FF STX $01FF
- LDA $01FF,X - LDA $01FF,X
AND #$7F AND #$7F
@ -249,7 +240,7 @@ end
; EXIT ; EXIT
; ;
asm reboot asm reboot
BIT ROMIN BIT ROMEN
LDA #$00 LDA #$00
STA $3F4 ; INVALIDATE POWER-UP BYTE STA $3F4 ; INVALIDATE POWER-UP BYTE
JMP ($FFFC) ; RESET JMP ($FFFC) ; RESET

234
PLASMA/src/cmdexec.pla Normal file
View File

@ -0,0 +1,234 @@
const iobuffer = $0800
const databuff = $0C00
const memmap = $BF58
const autorun = $01FF
byte cmdline[] = "CMD"
word cmd = @cmdline
byte syshalt[] = "SYSTEM HALTED..."
byte perr
;
; Utility functions
;
; CALL PRODOS
; SYSCALL(CMD, PARAMS)
;
asm prodos
LDA ESTKL,X
LDY ESTKH,X
STA PARAMS
STY PARAMS+1
INX
LDA ESTKL,X
STA CMD
STX ESP
JSR $BF00
CMD: !BYTE 00
PARAMS: !WORD 0000
LDX ESP
STA ESTKL,X
LDY #$00
STY ESTKH,X
RTS
end
;
; CALL LOADED SYSTEM PROGRAM
;
asm exec
LDX #$FE
TXS
LDX ESTKSZ/2
BIT ROMEN
JMP $2000
end
;
; SET MEMORY TO 0
; MEMCLR(ADDR, SIZE)
;
asm memclr
LDY #$00
LDA ESTKL+1,X
STA DSTL
LDA ESTKH+1,X
STA DSTH
INC ESTKL,X
INC ESTKH,X
TYA
SETMLP DEC ESTKL,X
BNE +
DEC ESTKH,X
BEQ ++
+ STA (DST),Y
INY
BNE SETMLP
INC DSTH
BNE SETMLP
++ INX
RTS
end
;
; COPY MEMORY
; MEMCPY(DSTADDR, SRCADDR, SIZE)
;
asm memcpy
LDY #$00
LDA ESTKL,X
BNE +
LDA ESTKH,X
BEQ MEMEXIT
+ LDA ESTKL+2,X
STA DSTL
LDA ESTKH+2,X
STA DSTH
LDA ESTKL+1,X
STA SRCL
LDA ESTKH+1,X
STA SRCH
INC ESTKH,X
CPYLP LDA (SRC),Y
STA (DST),Y
INC DSTL
BNE +
INC DSTH
+ INC SRCL
BNE +
INC SRCH
+ DEC ESTKL,X
BNE CPYLP
DEC ESTKH,X
BNE CPYLP
MEMEXIT INX
INX
RTS
end
;
; CHAR OUT
; COUT(CHAR)
;
asm cout
LDA ESTKL,X
ORA #$80
BIT ROMEN
JSR $FDED
RTS
end
;
; CHAR IN
; RDKEY()
;
asm cin
BIT ROMEN
STX ESP
JSR $FD0C
LDX ESP
DEX
STA ESTKL,X
LDY #$00
STY ESTKH,X
RTS
end
;
; PRINT STRING
; PRSTR(STR)
;
asm prstr
LDY #$00
LDA ESTKL,X
STA SRCL
LDA ESTKH,X
STA SRCH
BIT ROMEN
LDA (SRC),Y
STA ESTKL,X
BEQ +
- INY
LDA (SRC),Y
ORA #$80
JSR $FDED
TYA
CMP ESTKL,X
BNE -
+ RTS
end
;
; EXIT
;
asm reboot
BIT ROMEN
LDA #$00
STA $3F4 ; INVALIDATE POWER-UP BYTE
JMP ($FFFC) ; RESET
end
def crout
cout($0D)
end
;
; ProDOS routines
;
def open(path, buff)
byte params[6]
params.0 = 3
params:1 = path
params:3 = buff
params.5 = 0
perr = prodos($C8, @params)
return params.5
end
def close(refnum)
byte params[2]
params.0 = 1
params.1 = refnum
perr = prodos($CC, @params)
return perr
end
def read(refnum, buff, len)
byte params[8]
params.0 = 4
params.1 = refnum
params:2 = buff
params:4 = len
params:6 = 0
perr = prodos($CA, @params)
return params:6
end
def resetmemfiles
;
; Close all files
;
^$BFD8 = 0
close(0)
;
; Set memory bitmap
;
memclr(memmap, 24)
^memmap.0 = $CF
^memmap.23 = $01
end
def execsys(sysfile)
byte refnum
if ^sysfile
memcpy($280, sysfile, ^sysfile + 1)
refnum = open(sysfile, iobuffer)
if refnum
if read(refnum, $2000, $FFFF)
resetmemfiles()
memcpy($280, sysfile, ^$280 + 1)
exec()
fin
fin
fin
end
resetmemfiles()
if ^autorun
cmd = autorun
fin
execsys(cmd)
prstr(@syshalt)
cin()
reboot()
done

View File

@ -306,6 +306,12 @@ void emit_header(void)
printf("\t%s\t_SUBSEG\t\t\t; BYTECODE SUB-SEGMENT\n", DW); printf("\t%s\t_SUBSEG\t\t\t; BYTECODE SUB-SEGMENT\n", DW);
printf("\t%s\t_INIT\t\t\t; MODULE INITIALIZATION ROUTINE\n", DW); printf("\t%s\t_INIT\t\t\t; MODULE INITIALIZATION ROUTINE\n", DW);
} }
else
{
printf("\tJSR\t$3D0\n");
printf("\t%s\t$00\t\t\t; MODULE INITIALIZATION ROUTINE\n", DB);
printf("\t%s\t_INIT\t\t\t;\n", DW);
}
} }
void emit_rld(void) void emit_rld(void)
{ {

View File

@ -1,62 +0,0 @@
SRC = TMP
SRCL = SRC
SRCH = SRC+1
DST = SRC+2
DSTL = DST
DSTH = DST+1
ESP = DST+2
!PSEUDOPC $1000 {
;*
;* CLEAR COMMAND LINE LENGTH BYTE IF CALLED FROM 'BYE'
;*
LDY #$00
LDX #$FE ; LEAVE ROOM FOR COMMAND LINE LENGTH BYTE
TXS
BVS +
STY $01FF ; CLEAR AUTORUN COMMAND WHEN CALLED FROM 'BYE'
;*
;* MOVE REST OF CMD FROM LANGUAGE CARD
;*
+ STY $06
STY $08
LDA #$D2
STA $07
LDA #$11
STA $09
BIT LCRDEN+LCBNK2
- LDA ($06),Y
STA ($08),Y
INY
BNE -
INC $07
INC $09
LDA $07
CMP #$E0
BNE -
;*
;* DEACTIVATE 80 COL CARDS
;*
BIT ROMEN
LDY #4
- LDA DISABLE80,Y
JSR $FDED
DEY
BPL -
BIT $C054 ; SET TEXT MODE
BIT $C051
BIT $C058
JSR $FC58 ; HOME
;*
;* JUMP TO INTERPRETER
;*
BIT LCRDEN+LCBNK2
LDX #$00
LDA #$BF
STX IFPL
STA IFPH
JSR INTERP
!BYTE 0
!WORD START
DISABLE80 !BYTE 21, 13, '1', 26, 13
!SOURCE "cmd.a"
}

View File

@ -2,6 +2,7 @@
AFLAGS = -o $@ AFLAGS = -o $@
LFLAGS = -C default.cfg LFLAGS = -C default.cfg
PLVM = plvm PLVM = plvm
PLVM02 = PLVM02.SYS
PLASM = plasm PLASM = plasm
INCS = tokens.h symbols.h lex.h parse.h codegen.h INCS = tokens.h symbols.h lex.h parse.h codegen.h
OBJS = plasm.c parse.o lex.o codegen.o OBJS = plasm.c parse.o lex.o codegen.o
@ -20,10 +21,10 @@ TXTTYPE = .TXT
#SYSTYPE = \#ff0000 #SYSTYPE = \#ff0000
#TXTTYPE = \#040000 #TXTTYPE = \#040000
all: $(PLASM) $(PLVM) TESTLIB all: $(PLASM) $(PLVM) $(PLVM02) TESTLIB
clean: clean:
-rm *.o *~ *.a *.BIN TESTLIB $(PLASM) $(PLVM) -rm *.o *~ *.a *.SYM *.SYS *.BIN TESTLIB $(PLASM) $(PLVM)
$(PLASM): $(OBJS) $(INCS) $(PLASM): $(OBJS) $(INCS)
cc $(OBJS) -o $(PLASM) cc $(OBJS) -o $(PLASM)
@ -31,6 +32,12 @@ $(PLASM): $(OBJS) $(INCS)
$(PLVM): plvm.c $(PLVM): plvm.c
cc plvm.c -o $(PLVM) cc plvm.c -o $(PLVM)
cmdexec.a: cmdexec.pla $(PLASM)
./$(PLASM) -A < cmdexec.pla > cmdexec.a
$(PLVM02): plvm02.s cmdexec.a
acme -o $(PLVM02) -l PLVM02.SYM plvm02.s
TESTLIB: testlib.pla $(PLVM) $(PLASM) TESTLIB: testlib.pla $(PLVM) $(PLASM)
./$(PLASM) -AM < testlib.pla > testlib.a ./$(PLASM) -AM < testlib.pla > testlib.a
acme --setpc 4096 -o TESTLIB testlib.a acme --setpc 4096 -o TESTLIB testlib.a

View File

@ -879,7 +879,6 @@ int parse_stmnt(void)
scantoken = ID_TOKEN; scantoken = ID_TOKEN;
else else
scan(); scan();
printf("Structure offset = %d\n", elem_offset);
} }
if (scantoken == SET_TOKEN) if (scantoken == SET_TOKEN)
{ {

View File

@ -42,7 +42,7 @@ VMZP = ESTK+ESTKSZ
IFP = VMZP IFP = VMZP
IFPL = IFP IFPL = IFP
IFPH = IFP+1 IFPH = IFP+1
IP = IFP+2 IP = IFP+2
IPL = IP IPL = IP
IPH = IP+1 IPH = IP+1
IPY = IP+2 IPY = IP+2
@ -53,6 +53,13 @@ TMPX = TMP+2
NPARMS = TMPL NPARMS = TMPL
FRMSZ = TMPH FRMSZ = TMPH
DVSIGN = TMPX DVSIGN = TMPX
SRC = $06
SRCL = SRC
SRCH = SRC+1
DST = SRC+2
DSTL = DST
DSTH = DST+1
ESP = DST+2
;********************************************************** ;**********************************************************
;* ;*
;* INTERPRETER INSTRUCTION POINTER INCREMENT MACRO ;* INTERPRETER INSTRUCTION POINTER INCREMENT MACRO
@ -69,9 +76,8 @@ DVSIGN = TMPX
;* ;*
;*********************************************** ;***********************************************
* = $2000 * = $2000
CLD LDX #$FE
BIT LCRWEN+LCBNK2 TXS
BIT LCRWEN+LCBNK2
;* ;*
;* INSTALL PAGE 3 VECTORS ;* INSTALL PAGE 3 VECTORS
;* ;*
@ -83,86 +89,81 @@ DVSIGN = TMPX
;* ;*
;* MOVE VM INTO LANGUAGE CARD ;* MOVE VM INTO LANGUAGE CARD
;* ;*
BIT LCRWEN+LCBNK2
BIT LCRWEN+LCBNK2
LDA #<VMCORE LDA #<VMCORE
STA $06 STA SRCL
LDA #>VMCORE LDA #>VMCORE
STA $07 STA SRCH
LDA #$00 LDA #$00
STA $08 STA DSTL
LDA #$D0 LDA #$D0
STA $09 STA DSTH
LDY #$00 LDY #$00
- LDA ($06),Y ; COPY VM+CMD INTO LANGUAGE CARD - LDA (SRC),Y ; COPY VM+CMD INTO LANGUAGE CARD
STA ($08),Y STA (DST),Y
INY INY
BNE - BNE -
INC $07 INC SRCH
INC $09 INC DSTH
LDA $09 LDA DSTH
CMP #$E0 CMP #$E0
BNE - BNE -
;* ;*
;* INIT STACKS, FRAMES, AND HEAPS
;*
LDX #$FE
TXS
LDX #$00
STX $01FF
LDX #ESTKSZ/2
;*
;* LOOK FOR STARTUP FILE ;* LOOK FOR STARTUP FILE
;* ;*
JSR PRODOS ; OPEN AUTORUN JSR PRODOS ; OPEN AUTORUN
!BYTE $C8 !BYTE $C8
!WORD OPENPARMS !WORD OPENPARMS
BCC + BCC +
JMP EXIT JMP NOAUTO
+ LDA REFNUM + LDA REFNUM
STA NLPARMS+1 STA NLPARMS+1
JSR PRODOS JSR PRODOS
!BYTE $C9 !BYTE $C9
!WORD NLPARMS !WORD NLPARMS
BCC + BCC +
JMP EXIT JMP NOAUTO
+ LDA REFNUM + LDA REFNUM
STA READPARMS+1 STA READPARMS+1
JSR PRODOS JSR PRODOS
!BYTE $CA !BYTE $CA
!WORD READPARMS !WORD READPARMS
BCC + BCC +
JMP EXIT JMP NOAUTO
+ LDX READPARMS+6 + LDX READPARMS+6
STX $01FF STX $01FF
EXIT JSR PRODOS NOAUTO JSR PRODOS
!BYTE $CC !BYTE $CC
!WORD CLOSEPARMS !WORD CLOSEPARMS
LDY #$00 LDY #$00
STY $06 STY SRCL
LDA #$D1 LDA #$D1
STA $07 STA SRCH
- LDA ($06),Y ; LOAD FIRST PAGE OF CMD INTO PLACE - LDA (SRC),Y ; LOAD FIRST PAGE OF CMD INTO PLACE
STA $1000,Y STA $1000,Y
INY INY
BNE - BNE -
LDA #$7F LDA #$7F
ADC #$01 ; SET V FLAG ADC #$01 ; SET V FLAG
JMP $1007 ; CALL CMD JMP $1007 ; CALL CMD
AUTORUN !BYTE 7,"AUTORUN" AUTORUN !BYTE 7
!TEXT "AUTORUN"
OPENPARMS !BYTE 3 OPENPARMS !BYTE 3
!WORD AUTORUN !WORD AUTORUN
!WORD $0800 !WORD $0800
REFNUM !BYTE 0 REFNUM !BYTE 0
NLPARMS !BYTE 3 NLPARMS !BYTE 3
!BYTE 0 !BYTE 0
!BYTE $7F !BYTE $7F
!BYTE $0D !BYTE $0D
READPARMS !BYTE 4 READPARMS !BYTE 4
!BYTE 0 !BYTE 0
!WORD $0200 !WORD $0200
!WORD $0080 !WORD $0080
!WORD 0 !WORD 0
CLOSEPARMS !BYTE 1 CLOSEPARMS !BYTE 1
!BYTE 0 !BYTE 0
PAGE3 = * PAGE3 = *
!PSEUDOPC $03D0 { !PSEUDOPC $03D0 {
;* ;*
@ -202,8 +203,59 @@ OPXTBL !WORD ZEROX,ADDX,SUBX,MULX,DIVX,MODX,INCRX,DECRX ; 00 02 04 06 08 0
;* ;*
;* COMMAND PROCESSING ;* COMMAND PROCESSING
;* ;*
!SOURCE loadcmd.s !PSEUDOPC $1000 {
; !BINARY CMDLINE.BIN ;*
;* CLEAR COMMAND LINE LENGTH BYTE IF CALLED FROM 'BYE'
;*
LDY #$00
LDX #$FE ; LEAVE ROOM FOR COMMAND LINE LENGTH BYTE
TXS
BVS +
STY $01FF ; CLEAR AUTORUN COMMAND WHEN CALLED FROM 'BYE'
;*
;* MOVE REST OF CMD FROM LANGUAGE CARD
;*
+ STY SRCL
STY DSTL
LDA #$D2
STA SRCH
LDA #$11
STA DSTH
BIT LCRDEN+LCBNK2
- LDA (SRC),Y
STA (DST),Y
INY
BNE -
INC SRCL
INC DSTL
LDA SRCL
CMP #$E0
BNE -
;*
;* DEACTIVATE 80 COL CARDS
;*
BIT ROMEN
LDY #4
- LDA DISABLE80,Y
JSR $FDED
DEY
BPL -
BIT $C054 ; SET TEXT MODE
BIT $C051
BIT $C058
JSR $FC58 ; HOME
JMP START
DISABLE80 !BYTE 21, 13, '1', 26, 13
;*
;* JUMP TO INTERPRETER
;*
START LDA #$00
STA IFPL
LDA #$BF
STA IFPH
LDX ESTKSZ/2
!SOURCE "cmdexec.a"
}
;* ;*
;* ENTER INTO BYTECODE INTERPRETER ;* ENTER INTO BYTECODE INTERPRETER
;* ;*
@ -1872,4 +1924,5 @@ LEAVEX STA ALTRDOFF
RETX STA ALTRDOFF RETX STA ALTRDOFF
CLI CLI
RTS RTS
VMEND = *
} }