mirror of
https://github.com/bobbimanners/EightBall.git
synced 2024-05-29 03:41:32 +00:00
v0.62: Fixed function call bug in compiled code
- The compiler was not pushing the SENTINEL value to the operator stack and popping it afterwards, so the expression parsing was getting messed up. Now fixed. - Also added targets to the Makefile to allow the emulators to be run directly (make xvic, make x64, make mame).
This commit is contained in:
parent
7cdaccab52
commit
d9532c8f71
BIN
8ball20.prg
BIN
8ball20.prg
Binary file not shown.
BIN
8ball64.prg
BIN
8ball64.prg
Binary file not shown.
BIN
8ballvm20.prg
BIN
8ballvm20.prg
Binary file not shown.
BIN
8ballvm64.prg
BIN
8ballvm64.prg
Binary file not shown.
8
Makefile
8
Makefile
|
@ -112,3 +112,11 @@ test.dsk: eightball.system ebvm.system sieve4.8b
|
|||
java -jar $(APPLECMDR) -p test.dsk ebvm.system sys <ebvm.system
|
||||
java -jar $(APPLECMDR) -p test.dsk sieve4.8b txt <sieve4.8b
|
||||
|
||||
xvic: test.d64
|
||||
xvic -mem all -drive8type 1541 -8 test.d64
|
||||
|
||||
x64: test.d64
|
||||
x64 -8 test.d64
|
||||
|
||||
mame: test.dsk
|
||||
mame -w apple2ee -sl6 diskii -floppydisk1 test.dsk
|
||||
|
|
BIN
ebvm.system
BIN
ebvm.system
Binary file not shown.
|
@ -952,7 +952,7 @@ unsigned char E()
|
|||
*/
|
||||
unsigned char subscript(int *idx)
|
||||
{
|
||||
/* Start a new subexpression */
|
||||
/* Start a new subexpression */
|
||||
push_operator_stack(SENTINEL);
|
||||
|
||||
if (expect('[')) {
|
||||
|
@ -1078,9 +1078,11 @@ unsigned char P()
|
|||
}
|
||||
|
||||
if (compile) {
|
||||
push_operator_stack(SENTINEL);
|
||||
if (docall()) {
|
||||
return 1;
|
||||
}
|
||||
pop_operator_stack();
|
||||
goto skip_var; // MESSY!!
|
||||
} else {
|
||||
|
||||
|
@ -2931,6 +2933,7 @@ unsigned char doendfor()
|
|||
emit(VM_GTE);
|
||||
emitldi(return_stack[returnSP + 3]);
|
||||
emit(VM_BRNCH);
|
||||
emit(VM_DROP);
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
|
|
BIN
eightball.system
BIN
eightball.system
Binary file not shown.
|
@ -37,7 +37,7 @@
|
|||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#define VERSIONSTR "0.61"
|
||||
#define VERSIONSTR "0.62"
|
||||
|
||||
void print(char *str);
|
||||
|
||||
|
|
BIN
eightballvm
BIN
eightballvm
Binary file not shown.
|
@ -209,7 +209,7 @@ void execute_instruction()
|
|||
unsigned int delay;
|
||||
#endif
|
||||
|
||||
// print("--->PC "); printhex(pc); print(" eval stk: "); printhex(evalptr); print("\n");
|
||||
//print("--->PC "); printhex(pc); print(" eval stk: "); printhex(evalptr); print("\n");
|
||||
#ifdef DEBUGREGS
|
||||
unsigned int i;
|
||||
print("\n");
|
||||
|
@ -279,10 +279,14 @@ void execute_instruction()
|
|||
* Miscellaneous
|
||||
*/
|
||||
case VM_END: /* Terminate execution */
|
||||
if (evalptr > 0) {
|
||||
print("WARNING: evalptr ");
|
||||
printdec(evalptr);
|
||||
printchar('\n');
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
exit(0);
|
||||
#else
|
||||
/* Spin forever */
|
||||
for (delay = 0; delay < 25000; ++delay);
|
||||
exit(0);
|
||||
#endif
|
||||
|
|
4
fact.8b
4
fact.8b
|
@ -10,8 +10,8 @@ sub fact(word val)
|
|||
if val == 0
|
||||
return 1
|
||||
else
|
||||
' return val * fact(val-1) ; ' THIS DOES NOT WORK
|
||||
return fact(val-1) * val ; ' BUT THIS DOES!!!
|
||||
return val * fact(val-1) ; ' THIS DOES NOT WORK
|
||||
' return fact(val-1) * val ; ' BUT THIS DOES!!!
|
||||
endif
|
||||
endsub
|
||||
|
||||
|
|
20
unittest.8b
20
unittest.8b
|
@ -251,6 +251,8 @@ call expect(iw==45)
|
|||
call pbrfirstlevel(AA)
|
||||
call expect(AA[3]==123)
|
||||
|
||||
call wrapper()
|
||||
|
||||
'------------------
|
||||
' Invoke func
|
||||
'------------------
|
||||
|
@ -258,13 +260,11 @@ pr.msg "Invoke func:"; pr.nl
|
|||
call expect(sqr(10)==100)
|
||||
|
||||
pr.msg " Recursive:"; pr.nl
|
||||
iw=recurse2(4)
|
||||
call expect(iw==24)
|
||||
iw=recurse2(5)
|
||||
call expect(iw==5*4*3*2)
|
||||
|
||||
' TODO: This is failing in the compiler where it returns 1
|
||||
' But it is okay in interpreter where it returns 24 as it should.
|
||||
iw=recurse3(4)
|
||||
call expect(iw==24)
|
||||
iw=recurse3(5)
|
||||
call expect(iw==5*4*3*2)
|
||||
|
||||
'------------------
|
||||
' Locals
|
||||
|
@ -431,6 +431,12 @@ sub pbrsecondlevel(word XX[])
|
|||
endfor
|
||||
endsub
|
||||
|
||||
sub wrapper()
|
||||
word xyz[10]=0
|
||||
call pbrfirstlevel(xyz)
|
||||
call expect(xyz[3]==123)
|
||||
endsub
|
||||
|
||||
sub recurse2(word x)
|
||||
if x==0
|
||||
return 1;
|
||||
|
@ -445,7 +451,7 @@ sub recurse3(word x)
|
|||
if x==0
|
||||
return 1;
|
||||
else
|
||||
return x*recurse2(x-1)
|
||||
return x*recurse3(x-1)
|
||||
endif
|
||||
endsub
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user