retro-compiler: fix bugs preventing compilation, causing hangs on startup

FossilOrigin-Name: 78afb7f951d46489c15c6db1b84720753fae72e141b0afedb88a56853a5500f5
This commit is contained in:
crc 2023-11-08 02:38:06 +00:00
parent e975c4acd0
commit 11418661d8
3 changed files with 9 additions and 5 deletions

View file

@ -36,5 +36,8 @@
- retro-describe small reductions in call/return overhead
- nga-x11: Retro on X11
- add (termina) vocabulary from ilo [console position, colors]
- fix bugs in retro-compiler(1) preventing compilation
- fix bug in retro-compiler(1) causing compiled programs to
hang on startup
================================================================

View file

@ -70,7 +70,7 @@ Handler IO_queryHandlers[NUM_DEVICES + 1];
CELL ngaLoadImage(char *imageFile);
void ngaPrepare();
void ngaProcessOpcode(CELL opcode);
void ngaProcessPackedOpcodes(int opcode);
void ngaProcessPackedOpcodes(CELL opcode);
int ngaValidatePackedOpcodes(CELL opcode);
CELL stack_pop();
@ -106,9 +106,9 @@ void dump_stack() {
printf("\nStack: ");
for (i = 1; i <= sp; i++) {
if (i == sp)
printf("[ TOS: %d ]", data[i]);
printf("[ TOS: %lld ]", (long long)data[i]);
else
printf("%d ", data[i]);
printf("%lld ", (long long)data[i]);
}
printf("\n");
}
@ -190,6 +190,7 @@ void write_image() {
void patch_entry(CELL a) {
memory[1] = a;
printf("Entry set to %lld\n", (long long)a);
}
int main(int argc, char **argv) {
@ -209,7 +210,7 @@ int main(int argc, char **argv) {
generate_turnkey();
unlink("__ngaImage");
printf("\nFinal image is %d cells\n", memory[3]);
printf("\nFinal image is %lld cells\n", (long long)memory[3]);
return validate_image(tokens);
}

View file

@ -2109,7 +2109,7 @@ void load_embedded_image(char *arg) {
if (strcmp(name, ".ngaImage") == 0) {
fseek(ElfFile, sectHdr.sh_offset, SEEK_SET);
for (int i = 0; i < (int)sectHdr.sh_size; i++) {
fread(&a, 1, sizeof(int), ElfFile);
fread(&a, 1, sizeof(CELL), ElfFile);
memory[i] = a;
}
}