|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1620 (0x654)
Types: TextFile
Notes: UNIX file
Names: »try.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦0a3c255ba⟧ UNIX Filesystem
└─⟦this⟧ »assm/try.c«
#include <stdio.h>
/* #include "opcode.c" */
char line_buf[255];
unsigned int pc;
FILE *fopen();
int def_lbl, udef_lbl;
main()
{
register int i;
char file[32];
FILE *fp0, *fp1;
printf("\033[E");
printf("8085 Cross Assembler\n\n\n\n");
printf("Source file: ");
scanf("%s", file);
if((fp0 = fopen(file, "r")) == NULL) {
panic("\nFile not found\n\n");
}
pass1(fp0);
pass2(fp0);
printf("Assembly complete.\n");
fclose(fp0);
}
/*
* Pass 1 code
*/
pass1(fp0)
FILE *fp0;
{
pc = 0; /* initial PC counter */
def_lbl = 0; /* no defined labels */
udef_lbl = 0; /* no undefined labels */
for(;;) {
get_line(fp0);
printf("%s\n", line_buf);
}
}
/*
* Pass 2 code
*/
pass2(fp0)
FILE *fp0;
{
}
/*
* get a line from the file.
*/
get_line(fp0)
FILE *fp0;
{
char c, *tmp;
register int cnt;
tmp = &line_buf[0]; /* point tmp @ buffer */
cnt = 0;
printf("Here!\n");
while (( c=getc(fp0)) != EOF) {
if(((c == 0x3B) || (c == 0x0A)) && (cnt == 0)) {
if(c == 0x3B)
while((c=getc(fp0)) != EOF) {
if(c == 0x0A)
return(1);
}
return(1);
}
if(c == 0x3B ) { /* chuck rest of line */
while ((c = getc(fp0)) != EOF) {
if(c == 0x0A) {
*tmp++ = 0;
return(0);
}
}
panic("Pass1: Unexpected EOF\n");
}
*tmp++ = c; /* c into buf & inc pointer */
/* bump counter */
if (cnt++ == 255)
panic("Pass1: Bogus source file!\n");
if ( c == 0x0A ) {
*tmp++ = 0;
return(0); /* got line - return */
}
}
panic("Pass1: Unexpected EOF\n");
}
/*
* Error exit.
*/
panic(msg)
char *msg;
{
printf("%s", msg);
exit(1);
}