diff --git a/src/toolsrc/codegen.c b/src/toolsrc/codegen.c index 7471bcb..f8dd98a 100755 --- a/src/toolsrc/codegen.c +++ b/src/toolsrc/codegen.c @@ -1233,7 +1233,7 @@ int crunch_seq(t_opseq **seq, int pass) if (opnext->code == BINARY_CODE(SHL_TOKEN)) { op->code = DUP_CODE; - opnext->code == BINARY_CODE(ADD_TOKEN); + opnext->code = BINARY_CODE(ADD_TOKEN); break; } if (opnext->code == BINARY_CODE(MUL_TOKEN) || opnext->code == BINARY_CODE(DIV_TOKEN)) @@ -1465,7 +1465,10 @@ int crunch_seq(t_opseq **seq, int pass) } else { - for (shiftcnt = 0; shiftcnt < 16; shiftcnt++) + // + // Constants 0, 1 and 2 handled above + // + for (shiftcnt = 2; shiftcnt < 16; shiftcnt++) { if (op->val == (1 << shiftcnt)) { @@ -1477,7 +1480,10 @@ int crunch_seq(t_opseq **seq, int pass) } break; case BINARY_CODE(DIV_TOKEN): - for (shiftcnt = 0; shiftcnt < 16; shiftcnt++) + // + // Constant 1 handled above + // + for (shiftcnt = 1; shiftcnt < 16; shiftcnt++) { if (op->val == (1 << shiftcnt)) { diff --git a/src/toolsrc/codeopt.pla b/src/toolsrc/codeopt.pla index 66e97e4..6e49f7c 100644 --- a/src/toolsrc/codeopt.pla +++ b/src/toolsrc/codeopt.pla @@ -288,7 +288,7 @@ def crunch_seq(seq, pass) fin break is DIV_CODE - for shiftcnt = 0 to 15 + for shiftcnt = 1 to 15 if op=>opval == 1 << shiftcnt op=>opval = shiftcnt nextop->opcode = SHR_CODE diff --git a/src/vmsrc/apple/plvm01.s b/src/vmsrc/apple/plvm01.s index 73645fe..de74557 100644 --- a/src/vmsrc/apple/plvm01.s +++ b/src/vmsrc/apple/plvm01.s @@ -109,7 +109,7 @@ COMP LDA #$FF ;* OPCODE TABLE ;* !ALIGN 255,0 -OPTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -388,13 +388,17 @@ LNOT LDA ESTKL,X STA ESTKH,X JMP NEXTOP ;* -;* CONSTANT -1, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) +;* CONSTANT -1, ZERO, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) ;* MINUS1 DEX + LDA #$FF STA ESTKL,X STA ESTKH,X JMP NEXTOP +ZERO DEX + STA ESTKL,X + STA ESTKH,X + JMP NEXTOP CN DEX LSR ; A = CONST * 2 STA ESTKL,X diff --git a/src/vmsrc/apple/plvm02.s b/src/vmsrc/apple/plvm02.s index 9781c0f..3cca995 100755 --- a/src/vmsrc/apple/plvm02.s +++ b/src/vmsrc/apple/plvm02.s @@ -132,7 +132,7 @@ VMCORE = * ;* * ;**************** !ALIGN 255,0 -OPTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -633,13 +633,17 @@ LNOT LDA ESTKL,X STA ESTKH,X JMP NEXTOP ;* -;* CONSTANT -1, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) +;* CONSTANT -1, ZERO, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) ;* MINUS1 DEX + LDA #$FF STA ESTKL,X STA ESTKH,X JMP NEXTOP +ZERO DEX + STA ESTKL,X + STA ESTKH,X + JMP NEXTOP CN DEX LSR ; A = CONST * 2 STA ESTKL,X diff --git a/src/vmsrc/apple/plvm03.s b/src/vmsrc/apple/plvm03.s index d00c54e..db24f80 100755 --- a/src/vmsrc/apple/plvm03.s +++ b/src/vmsrc/apple/plvm03.s @@ -143,7 +143,7 @@ JENTRY !WORD JITINTRP ; $A0FA ;* OPCODE TABLE ;* !ALIGN 255,0 -OPTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -551,13 +551,17 @@ LNOT LDA ESTKL,X STA ESTKH,X JMP NEXTOP ;* -;* CONSTANT -1, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) +;* CONSTANT -1, ZERO, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) ;* MINUS1 DEX + LDA #$FF STA ESTKL,X STA ESTKH,X JMP NEXTOP +ZERO DEX + STA ESTKL,X + STA ESTKH,X + JMP NEXTOP CN DEX LSR ; A = CONST * 2 STA ESTKL,X diff --git a/src/vmsrc/apple/plvm802.s b/src/vmsrc/apple/plvm802.s index baf41b6..6015ebc 100644 --- a/src/vmsrc/apple/plvm802.s +++ b/src/vmsrc/apple/plvm802.s @@ -258,7 +258,7 @@ VMCORE = * ;* * ;**************** !ALIGN 255,0 -OPTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -491,7 +491,7 @@ LCDEFCMD = *-28 ; DEFCMD IN LC MEMORY ;* * ;***************** !ALIGN 255,0 -OPXTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPXTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CSX ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -849,14 +849,14 @@ ORI INY ;+INC_IP ;* LOGICAL NOT ;* LNOT PLA - BEQ MINUS1 - PEA $0000 - JMP NEXTOP + BNE ZERO ;* -;* CONSTANT -1, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) +;* CONSTANT -1, ZERO, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) ;* MINUS1 PEA $FFFF JMP NEXTOP +ZERO PEA $0000 + JMP NEXTOP CN TXA LSR ; A = CONST * 2 PHA diff --git a/src/vmsrc/apple/plvmjit02.s b/src/vmsrc/apple/plvmjit02.s index 54c2820..8dc1396 100755 --- a/src/vmsrc/apple/plvmjit02.s +++ b/src/vmsrc/apple/plvmjit02.s @@ -206,7 +206,7 @@ VMCORE = * ;* * ;**************** !ALIGN 255,0 -OPTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -397,7 +397,7 @@ LCDEFCMD = * ;*-28 ; DEFCMD IN LC MEMORY ;* * ;***************** !ALIGN 255,0 -OPXTBL !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E +OPXTBL !WORD ZERO,CN,CN,CN,CN,CN,CN,CN ; 00 02 04 06 08 0A 0C 0E !WORD CN,CN,CN,CN,CN,CN,CN,CN ; 10 12 14 16 18 1A 1C 1E !WORD MINUS1,BREQ,BRNE,LA,LLA,CB,CW,CSX ; 20 22 24 26 28 2A 2C 2E !WORD DROP,DROP2,DUP,DIVMOD,ADDI,SUBI,ANDI,ORI ; 30 32 34 36 38 3A 3C 3E @@ -797,13 +797,17 @@ LNOT LDA ESTKL,X STA ESTKH,X JMP NEXTOP ;* -;* CONSTANT -1, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) +;* CONSTANT -1, ZERO, NYBBLE, BYTE, $FF BYTE, WORD (BELOW) ;* MINUS1 DEX + LDA #$FF STA ESTKL,X STA ESTKH,X JMP NEXTOP +ZERO DEX + STA ESTKL,X + STA ESTKH,X + JMP NEXTOP CN DEX LSR ; A = CONST * 2 STA ESTKL,X