From c4912583dec3df04d6f8ec056b67755f0ff10902 Mon Sep 17 00:00:00 2001 From: dschmenk Date: Thu, 27 Jul 2017 19:15:57 -0700 Subject: [PATCH] Add CFFB to portable VM with test case --- src/samplesrc/test.pla | 1 + src/toolsrc/codegen.c | 8 ++++---- src/vmsrc/plvm.c | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/samplesrc/test.pla b/src/samplesrc/test.pla index 92fedc7..01b94d5 100755 --- a/src/samplesrc/test.pla +++ b/src/samplesrc/test.pla @@ -143,5 +143,6 @@ putln puti(mystruc) putln puts(@constr); puti(constval); putln +puts("Signed byte constant:"); puti(-3); putln puts("Hello from in-line string!\$7F\n") done diff --git a/src/toolsrc/codegen.c b/src/toolsrc/codegen.c index b51ca6b..942a4e3 100755 --- a/src/toolsrc/codegen.c +++ b/src/toolsrc/codegen.c @@ -540,12 +540,12 @@ void emit_codetag(int tag) } void emit_const(int cval) { - if (cval == 0) + if (cval == 0x0000) printf("\t%s\t$00\t\t\t; ZERO\n", DB); - else if (cval > 0 && cval < 256) + else if ((cval & 0xFF00) == 0x0000) printf("\t%s\t$2A,$%02X\t\t\t; CB\t%d\n", DB, cval, cval); - else if ((cval&0xFF00) >= 0xFF00) - printf("\t%s\t$5E,$%02X\t\t\t; CFFB\t%d\n", DB, cval&0xFF, cval&0xFF); + else if ((cval & 0xFF00) == 0xFF00) + printf("\t%s\t$5E,$%02X\t\t\t; CFFB\t%d\n", DB, cval&0xFF, cval); else printf("\t%s\t$2C,$%02X,$%02X\t\t; CW\t%d\n", DB, cval&0xFF,(cval>>8)&0xFF, cval); } diff --git a/src/vmsrc/plvm.c b/src/vmsrc/plvm.c index f05e305..62356d6 100755 --- a/src/vmsrc/plvm.c +++ b/src/vmsrc/plvm.c @@ -776,7 +776,9 @@ void interp(code *ip) fp += PLA; case 0x5C: // RET : IP = TOFP return; - case 0x5E: // ??? + case 0x5E: // CFFB : TOS = CONSTANTBYTE(IP) | 0xFF00 + PUSH(BYTE_PTR(ip) | 0xFF00); + ip++; break; /* * 0x60-0x6F