mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-05 17:32:02 +00:00
Reduce stack usage for ENTER/LEAVE but incompatible bytecode
This commit is contained in:
parent
3651cb6373
commit
b176847778
@ -354,7 +354,7 @@ void emit_header(void)
|
||||
{
|
||||
printf("\t%s\t_SEGEND-_SEGBEGIN\t; LENGTH OF HEADER + CODE/DATA + BYTECODE SEGMENT\n", DW);
|
||||
printf("_SEGBEGIN%c\n", LBL);
|
||||
printf("\t%s\t$DA7F\t\t\t; MAGIC #\n", DW);
|
||||
printf("\t%s\t$6502\t\t\t; MAGIC #\n", DW);
|
||||
printf("\t%s\t_SYSFLAGS\t\t\t; SYSTEM FLAGS\n", DW);
|
||||
printf("\t%s\t_SUBSEG\t\t\t; BYTECODE SUB-SEGMENT\n", DW);
|
||||
printf("\t%s\t_DEFCNT\t\t\t; BYTECODE DEF COUNT\n", DW);
|
||||
@ -802,7 +802,7 @@ void emit_leave(void)
|
||||
{
|
||||
emit_pending_seq();
|
||||
if (localsize)
|
||||
printf("\t%s\t$5A\t\t\t; LEAVE\n", DB);
|
||||
printf("\t%s\t$5A,$%02X\t\t\t; LEAVE\t%d\n", DB, localsize, localsize);
|
||||
else
|
||||
printf("\t%s\t$5C\t\t\t; RET\n", DB);
|
||||
}
|
||||
|
@ -190,6 +190,7 @@ def emit_leave#0
|
||||
emit_pending_seq
|
||||
if framesize
|
||||
emit_byte($5A)
|
||||
emit_byte(framesize)
|
||||
else
|
||||
emit_byte($5C)
|
||||
fin
|
||||
@ -805,7 +806,7 @@ def writeheader(refnum)
|
||||
len = moddep - 1 - @header
|
||||
modfix = len + RELADDR - codebuff // Convert generated address into module adress
|
||||
header:0 = len + codeptr - codebuff // sizeof header+data+bytecode
|
||||
header:2 = $DA7F // Magic #
|
||||
header:2 = $6502 // Magic #
|
||||
header:4 = modsysflags // Module SYSFLAGS
|
||||
header:6 = len + RELADDR + datasize // Byte code offset
|
||||
header:8 = def_cnt // DEFinition count
|
||||
|
@ -938,7 +938,7 @@ def loadmod(mod)#1
|
||||
moddep = @header.1
|
||||
defofst = modsize + RELADDR
|
||||
init = 0
|
||||
if rdlen > 4 and header:2 == $DA7F // DAVE+1 = magic number :-)
|
||||
if rdlen > 4 and header:2 == $6502 // DAVE+1 = magic number :-)
|
||||
//
|
||||
// This is an EXTended RELocatable (data+bytecode) module.
|
||||
//
|
||||
@ -951,7 +951,7 @@ def loadmod(mod)#1
|
||||
// Load module dependencies.
|
||||
//
|
||||
while ^moddep
|
||||
if !lookuptbl(moddep, symtbl)//lookupmod(moddep)
|
||||
if !lookuptbl(moddep, symtbl)
|
||||
close(refnum)
|
||||
refnum = 0
|
||||
if loadmod(moddep) < 0
|
||||
@ -995,7 +995,7 @@ def loadmod(mod)#1
|
||||
//
|
||||
// Add module to symbol table.
|
||||
//
|
||||
addsym(mod, modaddr)//addmod(mod, modaddr)
|
||||
addsym(mod, modaddr)
|
||||
//
|
||||
// Apply all fixups and symbol import/export.
|
||||
//
|
||||
|
@ -1528,7 +1528,7 @@ JMPTMP JMP (TMP)
|
||||
;*
|
||||
ENTER INY
|
||||
LDA (IP),Y
|
||||
PHA ; SAVE ON STACK FOR LEAVE
|
||||
; PHA ; SAVE ON STACK FOR LEAVE
|
||||
EOR #$FF ; ALLOCATE FRAME
|
||||
SEC
|
||||
ADC PPL
|
||||
@ -1560,7 +1560,9 @@ LEAVEX STA ALTRDOFF
|
||||
LDA PSR
|
||||
PHA
|
||||
PLP
|
||||
LEAVE PLA ; DEALLOCATE POOL + FRAME
|
||||
LEAVE ;PLA ; DEALLOCATE POOL + FRAME
|
||||
+INC_IP
|
||||
LDA (IP),Y
|
||||
CLC
|
||||
ADC IFPL
|
||||
STA PPL
|
||||
|
@ -1517,8 +1517,8 @@ ENTER INY
|
||||
STA $7D0+31
|
||||
PLA
|
||||
}
|
||||
PHA ; SAVE ON STACK FOR LEAVE
|
||||
DEC HWSP ; UPDATE HWSP TO SKIP FRAME SIZE
|
||||
;PHA ; SAVE ON STACK FOR LEAVE
|
||||
;DEC HWSP ; UPDATE HWSP TO SKIP FRAME SIZE
|
||||
+ACCMEM16 ; 16 BIT A/M
|
||||
; AND #$00FF
|
||||
EOR #$FFFF ; ALLOCATE FRAME
|
||||
@ -1549,7 +1549,16 @@ ENTER INY
|
||||
;* LEAVE FUNCTION
|
||||
;*
|
||||
LEAVEX STX ALTRDOFF
|
||||
LEAVE +ACCMEM8 ; 8 BIT A/M
|
||||
LEAVE ;PLA ; DEALLOCATE POOL + FRAME
|
||||
+INC_IP
|
||||
LDA (IP),Y
|
||||
AND #$00FF
|
||||
CLC
|
||||
ADC IFP
|
||||
STA PP
|
||||
PLA ; RESTORE PREVIOUS FRAME
|
||||
STA IFP
|
||||
+ACCMEM8 ; 8 BIT A/M
|
||||
TSC ; MOVE HW EVAL STACK TO ZP EVAL STACK
|
||||
EOR #$FF
|
||||
SEC
|
||||
@ -1587,15 +1596,7 @@ LEAVE +ACCMEM8 ; 8 BIT A/M
|
||||
LDX $C010
|
||||
+ LDX TMPL
|
||||
}
|
||||
TYX ; RESTORE NEW ESP
|
||||
PLA ; DEALLOCATE POOL + FRAME
|
||||
+ACCMEM16 ; 16 BIT A/M
|
||||
AND #$00FF
|
||||
CLC
|
||||
ADC IFP
|
||||
STA PP
|
||||
PLA ; RESTORE PREVIOUS FRAME
|
||||
STA IFP
|
||||
TYX ; RESTORE NEW ESP
|
||||
SEC ; SWITCH TO EMULATED MODE
|
||||
XCE
|
||||
!AS
|
||||
|
Loading…
Reference in New Issue
Block a user