emu48-mirror/LST2C.C
Gwenhael Le Moine c3ab4004ad
1996-02-01: Historic version 0.37
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
2024-03-19 22:11:59 +01:00

65 lines
No EOL
1.3 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (C) 1995 Sebastien Carlier
*/
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 256
#define NEXTFIELD {s=p; while ((p<BUFSIZE)&&(ptr[p]!='\t')) p++; ptr[p] = 0; p++;}
char buffer[BUFSIZE];
int icnt, lcnt;
int main() {
char *ptr, array;
int s, p, ticks;
while (!feof(stdin)) {
lcnt++;
if (gets(buffer)==NULL) break;
if (buffer[0]==0) break;
if (buffer[0]=='#') {
if (buffer[1])
printf("/* %s */\n", buffer+1);
else
putchar('\n');
continue;
}
ptr = buffer; p = 0;
NEXTFIELD;
printf("o%s: ", ptr+s);
NEXTFIELD;
if (ptr[s+3]) {
array = ptr[s+3];
ptr[s+3] = 0;
ticks = atoi(ptr+s);
ptr[s+3] = array;
array = ptr[s+6];
ptr[s+6] = 0;
if (ticks)
printf("ticks-=%i+%s[(int)I[%i]];", ticks, ptr+s+3, array-'0');
else
printf("ticks-=%s[(int)I[%i]];", ptr+s+3, array-'0');
ptr[s+6] = array;
} else {
ticks = atoi(ptr+s);
printf("ticks-=%i; ", ticks);
}
NEXTFIELD;
NEXTFIELD;
NEXTFIELD;
printf("%s goto o_done;\n", ptr+s);
icnt++;
}
if (feof(stdin))
printf("/* %i lines, %i instructions */\n", lcnt, icnt);
else
fprintf(stderr, "Error at line %i\n", lcnt+1);
return 0;
}