├── 6800 ├── Makefile ├── README.md ├── a │ ├── 6801.asm │ ├── asm-indent.py │ ├── ccc.h │ ├── ccint.asm │ ├── ccint.bin │ ├── ccint.txt │ ├── end.asm │ ├── flexptrs.txt │ ├── h.c │ ├── hell0.asm │ ├── hell0.c │ ├── hello.c │ ├── p.c │ ├── t-h2.asm │ ├── t-h2.c │ ├── t-hello.asm │ ├── t-hello.c │ ├── t.c │ ├── x.S │ ├── x.c │ ├── x.s │ ├── x.t │ ├── x.tmp │ ├── x.x │ ├── xe.asm │ ├── xe.c │ ├── z.asm │ └── z.c ├── ask.c ├── heir.c ├── io.c ├── io9.c ├── notes.txt ├── options.c ├── prtlib.asm ├── prtlib.c ├── prtlib.lib ├── run0.asm ├── run0.c ├── run1.asm ├── run1.c ├── run9.asm ├── run9.c ├── smallc.c └── smallc.h ├── LICENSE ├── Makefile ├── README.md ├── ccint.txt ├── silifen ├── LIB51 │ ├── man1.txt │ ├── man10.txt │ ├── man2.txt │ ├── man3.txt │ ├── man4a.txt │ ├── man4b.txt │ ├── man5.txt │ ├── man6a.txt │ ├── man6b.txt │ ├── man7.txt │ ├── man8.txt │ ├── man9.txt │ ├── manc.txt │ └── mani.txt ├── LIB52 │ ├── man6801.txt │ └── mang.txt ├── LIB53 │ ├── ctype.h │ ├── get01.txt │ ├── get09.txt │ ├── goto1.txt │ ├── goto9.txt │ ├── goto91.txt │ ├── hardware.h │ ├── liba09.txt │ ├── libc01.txt │ ├── libc09.txt │ ├── libdef.txt │ ├── libdef01.txt │ ├── libdef09.txt │ ├── libdef91.txt │ ├── libf01.txt │ ├── libf09.txt │ ├── libh.txt │ ├── libld91.txt │ ├── libload.txt │ ├── libload1.txt │ ├── libload9.txt │ ├── libm01.txt │ ├── libm09.txt │ ├── libp.txt │ ├── libs01.txt │ ├── libs09.txt │ └── stdio.h ├── LIB54 │ ├── cc.cmd │ ├── grep.c │ ├── grep.cmd │ ├── opt.c │ ├── opt.cmd │ ├── readme.txt │ ├── sieve.c │ ├── sieve.cmd │ ├── tr.c │ ├── tr.cmd │ └── tst01.txt ├── LIB55 │ ├── cc1.c9 │ ├── cc2.c9 │ ├── cc3.c9 │ ├── cc4.c9 │ ├── cc5.c9 │ ├── cc6.c9 │ ├── cc7.c9 │ ├── cc8.c9 │ ├── cc9.c9 │ ├── grep.c │ ├── hello.c │ ├── itob.c │ ├── opt.c │ ├── printf.c │ ├── readme.txt │ ├── sieve.c │ ├── strip.c │ ├── tr.c │ └── tst01.txt ├── Makefile ├── README.md ├── ask.c ├── cc.h ├── cc2.c ├── cc3.c ├── cc4.c ├── cc8.c ├── cc9.c ├── dump.c ├── heir.c ├── io9.c ├── itob.c ├── opt.c ├── readme.txt ├── run9.c ├── scc ├── scc.c ├── scc.h └── t-hello.c └── v22 ├── README.md ├── ar.c ├── cc.h ├── cc2.c ├── cc3.c ├── cc4.c ├── mystdio.h ├── notice.h └── smallcv22.c /6800/Makefile: -------------------------------------------------------------------------------- 1 | # https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#zz-2.3 2 | CC = gcc 3 | COPT = -g -O3 -D FDEBUG -D ASL 4 | 5 | OBJS = smallc.o io.o heir.o ask.o options.o 6 | 7 | # smallc.c smallc.h # smallc.c -o smallc 8 | smallc: $(OBJS) 9 | $(CC) $(COPT) -o $@ $^ 10 | 11 | %.o: %.c smallc.h 12 | $(CC) $(COPT) -o $@ -c $< 13 | 14 | .PHONY: clean 15 | 16 | clean: 17 | rm -rf *~ *.ihx *.lst *.map *.mem *.rel *.rst \ 18 | *.sym foo bar *.d51 *.hex *.a51 *.lnk \ 19 | smallc smallcv22 *.o zap 20 | 21 | # for i in AR.C CC1.C CC2.C CC3.C CC4.C CC.H NOTICE.H; do 22 | # nom=$(tr '[:upper:]' '[:lower:]' <<< $i); cp $i ~/dev/git/SmallC68/${nom}; done 23 | 24 | # gdb -q --args ./smallcv22 ar.c 25 | -------------------------------------------------------------------------------- /6800/README.md: -------------------------------------------------------------------------------- 1 | # Small C v1.1 for the Motorola 68XX processor 2 | 3 | Small C v1.1 to pseudo code compiler. 4 | 5 | # Status 6 | 7 | Currently this compiles under 64bit Linux (with a huge number of warnings). When done this will be a cross compiler under Linux/Windows. You won't be able to compile this under Flex. And if done correctly you should be able to use it with Motorola 68XX embedded boards with no OS. 8 | 9 | Interesting note, this compiler outputs psuedo code which gets assembled with an interpreter in assembler code appropriate to the processor. Currently I have run1.c (6801/6803) and run9.c (6809). I have mow attempted to create a 6800 version but it remains untested. One additional note, I lack documentions on how the pseudo code works. I will come back to this at a later date as it's an interesting approach and may be useful for future projects on more than the 68XX processors. 10 | 11 | Remember this is the limited compiler so it's annoying but it's simple so debugging is less of a chore. Once this is somewhat stable I'll more on to more advanced versions and take what I've learned here to those. 12 | 13 | And one more point, just because it compiles doesn't mean it actually works or works well. I willkeep hacking at it until it works reasonably. I do want to test this out and see what it can do. The interpreter is an interesting idea. 14 | -------------------------------------------------------------------------------- /6800/a/6801.asm: -------------------------------------------------------------------------------- 1 | MACEXP on 2 | 3 | CPU 6801 4 | 5 | org $1000 6 | 7 | lds $FF 8 | ldaa #$01 9 | ldab #$80 10 | ldx #$20 11 | abx 12 | stab 0,X 13 | nop 14 | nop 15 | 16 | end 17 | -------------------------------------------------------------------------------- /6800/a/ccc.h: -------------------------------------------------------------------------------- 1 | ** SMALL-C HEADER FILE 2 | 3 | ORG $800 4 | OPT NOG 5 | 6 | WARMS EQU $AD03 7 | exit EQU $AD03 8 | fclose EQU $4 9 | fopen EQU $8 10 | getc EQU $C 11 | getchar EQU $10 12 | gets EQU $14 13 | putc EQU $18 14 | putchar EQU $1C 15 | puts EQU $20 16 | RTSC EQU $24 17 | isalpha EQU $28 18 | isdigit EQU $2C 19 | isalnum EQU $30 20 | islower EQU $34 21 | isupper EQU $38 22 | isspace EQU $3C 23 | toupper EQU $40 24 | tolower EQU $44 25 | strclr EQU $48 26 | strlen EQU $4C 27 | strcpy EQU $50 28 | strcat EQU $54 29 | strcmp EQU $58 30 | EOF EQU -1 31 | 32 | * This stuff has been added to implement command line 33 | * parameter passing ( argc, argv stuff ). 34 | 35 | FCB 86 SWITCH TO INLINE CODE 36 | BRA zzSTRT BRANCH AROUND LOCAL STORAGE 37 | 38 | zzARGC RMB 2 39 | zzXTMP RMB 2 TEMP STORE FOR X REG 40 | zzARGV RMB 20 ARRAY OF POINTERS 41 | 42 | NXTCH EQU $AD27 NEXT CHARACTER ROUTINE 43 | 44 | zzSTRT CLR zzARGC 45 | CLR zzARGC+1 46 | INC zzARGC+1 SET TO AT LEAST 1 PARAMETER 47 | LDX #$A080 POINT TO LINE BUFFER 48 | STX zzARGV 49 | LDX $AC14 GET LINE POINTER 50 | DEX FIX UP 51 | CLR 0,X MARK END OF STRING 52 | LDX #zzARGV+2 NEXT ADDRESS POINTER 53 | LDA B #9 MAX # OF ARG'S - 1 54 | 55 | * now get the rest of arguments 56 | 57 | zzNEXT JSR NXTCH GET NEXT CHAR FROM LINE BUFFER 58 | CMP A #$0D IS IT A CR ? 59 | BEQ zzDONE YES -- FINISHED 60 | CMP A $AC02 COMPARE TO E.O.L. 61 | BEQ zzDONE 62 | 63 | INC zzARGC+1 BUMP ARGUMENT COUNTER 64 | LDA A $AC14 LINE BUFFER POINTER MSB 65 | STA A 0,X SAVE IN POINTER ARRAY 66 | INX 67 | LDA A $AC15 LINE BUFFER POINTER LSB 68 | DEC A FIX ADDRESS 69 | STA A 0,X 70 | INX 71 | 72 | zzAGAIN JSR NXTCH LETS GET TO END OF PARAMETER STRING 73 | CMP A #$0D 74 | BEQ zzDONE 75 | CMP A $AC02 76 | BEQ zzDONE 77 | CMP A #$20 BLANK ? 78 | BEQ zzMARK 79 | CMP A #', 80 | BNE zzAGAIN 81 | zzMARK STX zzXTMP SAVE POINTER 82 | LDX $AC14 83 | DEX 84 | CLR 0,X 85 | LDX zzXTMP 86 | DEC B DECREMENT MAX PARAM. COUNT 87 | BEQ zzDONE 88 | BRA zzNEXT 89 | 90 | zzDONE LDX $AC14 91 | CLR 0,X MARK THE FINAL STRING 92 | * 93 | *------------------------------------------------------- 94 | * 95 | JSR RTSC RETURN TO INTERPRETED CODE 96 | 97 | FCB 2*2 LOAD VALUE 98 | FDB zzARGC 99 | FCB 2*10 PUSH ON STACK 100 | FCB 2*0 LOAD ADDRESS 101 | FDB zzARGV 102 | FCB 2*10 PUSH ON STACK 103 | * 104 | *------------------------------------------------------ 105 | * 106 | 107 | *;/* ASMB c_source.a +SY # Asm. suppressing symbol table, listing */ 108 | *;/* Local Variables: */ 109 | *;/* mode:asm */ 110 | *;/* End: */ 111 | -------------------------------------------------------------------------------- /6800/a/ccint.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxha/SmallC68/4e1c4171e6585ed1ced90e62372d0debd10089d2/6800/a/ccint.bin -------------------------------------------------------------------------------- /6800/a/end.asm: -------------------------------------------------------------------------------- 1 | ;/* Local Variables: */ 2 | ;/* mode: asm */ 3 | ;/* End: */ 4 | -------------------------------------------------------------------------------- /6800/a/flexptrs.txt: -------------------------------------------------------------------------------- 1 | *** 2 | * POINTERS TO FLEX SUBROUTINES 3 | * 4 | WARMS EQU $AD03 ;* DOS WARM START ENTRY 5 | RENTER EQU $AD06 ;* MAIN LOOP RE-ENTRY 6 | INCH EQU $AD09 ;* INPUT CHAR 7 | OUTCH EQU $AD0F ;* OUTPUT CHAR 8 | GETCHR EQU $AD15 ;* PREFERRED GET CHAR 9 | PUTCHR EQU $AD18 ;* PREFFERED OUTPUT CHAR 10 | INBUFF EQU $AD1B ;* INPUT TO LINE BUFFER 11 | PSTRNG EQU $AD1E ;* PRINT STRING 12 | CLASS EQU $AD21 ;* CLASSIFY CHARACTER 13 | PCRLF EQU $AD24 ;* PRINT C/R, L/F 14 | NXTCH EQU $AD27 ;* NEXT CHARACTER 15 | RSTRIO EQU $AD2A ;* RESTORE I/O VECTORS 16 | GETFIL EQU $AD2D ;* PARSE FILE SPEC 17 | LOAD EQU $AD30 ;* FILE LOADER 18 | SETEXT EQU $AD33 ;* SET EXTENSION 19 | ADDBX EQU $AD36 ;* ADD ACC-B TO X 20 | OUTDEC EQU $AD39 ;* OUTPUT DECIMAL NUMBER 21 | OUTHEX EQU $AD3C ;* OUTPUT HEX NUMBER 22 | RPTERR EQU $AD3F ;* REPORT ERROR 23 | GETHEX EQU $AD42 ;* GET HEX NUMBER 24 | OUTADR EQU $AD45 ;* OUTPUT HEXADECIMAL ADDRESS 25 | INDEC EQU $AD48 ;* INPUT DECIMAL NUMBER 26 | DOCMND EQU $AD4B ;* CALL DOS 27 | 28 | FMSCLS EQU $B403 ;* CLOSE ALL FILES 29 | FMS EQU $B406 ;* FMS CALL 30 | 31 | FCB EQU $A840 ;* SYSTEM FCB 32 | 33 | * ------------------------------------------ 34 | 35 | ;/* Local Variables: */ 36 | ;/* mode: asm */ 37 | ;/* End: */ 38 | -------------------------------------------------------------------------------- /6800/a/hell0.c: -------------------------------------------------------------------------------- 1 | /* C Demo Program */ 2 | 3 | #include run0.c 4 | 5 | /* Small-C Input-Output Library for sim6800 */ 6 | 7 | main() { 8 | nl(); 9 | puts ("Hello World"); 10 | nl(); 11 | } 12 | 13 | nl() { 14 | putchar (13); 15 | } 16 | 17 | putchar(c) 18 | char c; 19 | { 20 | #asm 21 | FCB 86 22 | nop 23 | nop ;* Check to see where the char c is 24 | nop 25 | nop 26 | tsx 27 | ldaa 0,X ;* Char goes into A 28 | staa $F001 ;* ACIADA 29 | JMP RTSC 30 | #endasm 31 | } 32 | 33 | puts(s) 34 | char s[]; 35 | { 36 | int k; 37 | k=0; 38 | while(putchar(s[k++])); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /6800/a/t-h2.c: -------------------------------------------------------------------------------- 1 | /* Small C Demo Program */ 2 | 3 | #include run0.c /* This is a very broken compiler */ 4 | 5 | main() { 6 | nl(); 7 | } 8 | 9 | nl() { 10 | #asm 11 | FCB 86 12 | nop 13 | ldaa #13 ;* NL 14 | staa $F001 ;* ACIADA 15 | jmp RTSC 16 | #endasm 17 | } 18 | 19 | putchar(c) 20 | char c; 21 | { 22 | #asm 23 | FCB 86 24 | nop 25 | nop 26 | nop 27 | nop 28 | tsx 29 | ldaa 0,X 30 | ; Char goes into A 31 | staa $F001 ;* ACIADA 32 | jmp RTSC 33 | #endasm 34 | } 35 | -------------------------------------------------------------------------------- /6800/a/t-hello.c: -------------------------------------------------------------------------------- 1 | /* Small C Demo Program */ 2 | 3 | /* 4 | No include in simpliest Small C compiler 5 | 6 | #include "run9.c" /* Must use double quotes not <> * / 7 | #include "io9.c" 8 | */ 9 | #include run0.c 10 | 11 | main() { 12 | nl(); 13 | /* 14 | xputs ("Hello World"); 15 | nl(); 16 | */ 17 | } 18 | 19 | nl() { 20 | #asm 21 | ldaa #13 22 | staa $F001 23 | #endasm 24 | } 25 | 26 | #ifdef NOPE 27 | putchar(i) 28 | char i; 29 | { 30 | #asm 31 | ldaa zREG 32 | staa $F001 33 | #endasm 34 | } 35 | 36 | xnl() { 37 | putchar (13); 38 | } 39 | 40 | xputs(s) 41 | char *s; 42 | { 43 | /* int k; */ 44 | /* k = 0; */ 45 | /* while(putchar(s[k++])); */ 46 | while(putchar(s++)); 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /6800/a/t.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | int sub(int c) { 10 | return(isalpha(c)); 11 | } 12 | 13 | void 14 | main() { 15 | int c = 'a', c1 = 0; 16 | 17 | printf("C is = 0x%x\n", isalpha(c)); 18 | printf("C1 is = 0x%x\n", isalpha(c1)); 19 | if(sub(c)) { 20 | printf("true\n"); 21 | } else { 22 | printf("false\n"); 23 | } 24 | 25 | if(sub(c1)) { 26 | printf("true\n"); 27 | } else { 28 | printf("false\n"); 29 | } 30 | 31 | printf("sizeof(Char *) = %d\n", sizeof(char *)); 32 | printf("sizeof(Int) = %d\n", sizeof(int)); 33 | printf("sizeof(Int *) = %d\n", sizeof(int *)); 34 | printf("sizeof(long) = %d\n", sizeof(long)); 35 | printf("sizeof(long *) = %d\n", sizeof(long *)); 36 | 37 | printf("sizeof(uint8_t) = %d\n", sizeof(uint8_t)); 38 | printf("sizeof(uint8_t *) = %d\n", sizeof(uint8_t *)); 39 | printf("sizeof(uint16_t) = %d\n", sizeof(uint16_t)); 40 | printf("sizeof(uint16_t *) = %d\n", sizeof(uint16_t *)); 41 | printf("sizeof(uint32_t) = %d\n", sizeof(uint32_t)); 42 | printf("sizeof(uint32_t *) = %d\n", sizeof(uint32_t *)); 43 | printf("sizeof(uint64_t) = %d\n", sizeof(uint64_t)); 44 | printf("sizeof(uint64_t *) = %d\n", sizeof(uint64_t *)); 45 | } 46 | -------------------------------------------------------------------------------- /6800/a/x.c: -------------------------------------------------------------------------------- 1 | xputs(s) 2 | char *s; 3 | { 4 | int *ACIADA; 5 | &ACIADA = 0xF001; 6 | 7 | while(*s) { 8 | ACIADA = *s; 9 | s++; 10 | } 11 | } 12 | 13 | main() { 14 | /* char c; */ 15 | /* int i; */ 16 | char *str; 17 | 18 | str = "A long string"; 19 | 20 | puts(str); 21 | exit(0); 22 | } 23 | -------------------------------------------------------------------------------- /6800/a/xe.c: -------------------------------------------------------------------------------- 1 | /* FLEX: Simply echo calling line arguments */ 2 | /* #include */ 3 | print(s) 4 | char *s; 5 | { 6 | char c; 7 | 8 | while (*s) { 9 | if ( 0x5C == *s ) { 10 | s = s + 1; 11 | c = *s & 0x1F; 12 | putchar(c); 13 | } else { 14 | putchar(*s); 15 | } 16 | 17 | s++; 18 | } 19 | } 20 | 21 | nl() { 22 | putchar(13); 23 | } 24 | 25 | main(carg, varg) 26 | int carg; 27 | char *varg[]; 28 | { 29 | /* Let's cheat, @ thru DEL get 0110 knocked off */ 30 | /* so \@ (x40) becomes NULL (x00), A (x41) or a (x61) becomes ^A (x01), etc. */ 31 | while (--carg > 0) { 32 | ++varg; 33 | print(*varg); /* print the 'word' */ 34 | putchar(' '); 35 | } 36 | 37 | /* nl(); */ 38 | } 39 | 40 | /* 41 | -*- mode: c-mode; -*- 42 | */ 43 | -------------------------------------------------------------------------------- /6800/a/z.asm: -------------------------------------------------------------------------------- 1 | *main() { 2 | 3 | ;* ====== main() 4 | main 5 | * char c; 6 | 7 | ;* modstk(17) 8 | ;* pseudoins(17) 9 | FCB 34 10 | FDB -1 11 | * c = 32; 12 | Line 3, main + 2: illegal symbol name 13 | c = 32; 14 | ^ 15 | Line 3, main + 2: already defined 16 | c = 32; 17 | ^ 18 | *c 19 | 20 | ;* modstk(17) 21 | ;* pseudoins(17) 22 | FCB 34 23 | FDB -1 24 | Line 3, main + 2: missing semicolon 25 | c = 32; 26 | ^ 27 | 28 | ;* imediate(0) 29 | ;* pseudoins(0) 30 | FCB 0 31 | FDB 32 32 | * putc(c); 33 | 34 | ;* getmem(2) 35 | ;* pseudoins(2) 36 | FCB 4 37 | FDB putc 38 | 39 | ;* zpush(10) 40 | ;* pseudoins(10) 41 | FCB 20 42 | 43 | ;* getloc(1) 44 | ;* pseudoins(1) 45 | FCB 2 46 | FDB 65539 47 | 48 | ;* indirect(5) 49 | ;* pseudoins(5) 50 | FCB 10 51 | 52 | ;* swapstk(11) 53 | ;* pseudoins(11) 54 | FCB 22 55 | 56 | ;* zpush(10) 57 | ;* pseudoins(10) 58 | FCB 20 59 | 60 | ;* callstk(15) 61 | ;* pseudoins(15) 62 | FCB 30 63 | 64 | ;* modstk(17) 65 | ;* pseudoins(17) 66 | FCB 34 67 | FDB 2 68 | *} 69 | 70 | ;* modstk(17) 71 | ;* pseudoins(17) 72 | FCB 34 73 | FDB 6 74 | 75 | ;* zret(16) 76 | ;* pseudoins(16) 77 | FCB 32 78 | *putc(c) 79 | 80 | ;* ====== putc() 81 | putc 82 | *char c; 83 | *{ 84 | *#asm 85 | ACIA equ 0xC000 86 | ldab c ;* 87 | stab ACIA ;* 88 | *} 89 | 90 | ;* zret(16) 91 | ;* pseudoins(16) 92 | FCB 32 93 | -------------------------------------------------------------------------------- /6800/a/z.c: -------------------------------------------------------------------------------- 1 | main() { 2 | char c; 3 | c = 32; 4 | putc(c); 5 | } 6 | 7 | putc(c) 8 | char c; 9 | { 10 | #asm 11 | ACIA equ 0xC000 12 | 13 | ldab c ;* 14 | stab ACIA ;* 15 | #endasm 16 | } 17 | -------------------------------------------------------------------------------- /6800/ask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "smallc.h" 7 | 8 | #ifndef __linux 9 | /* */ 10 | /* Get options from user */ 11 | /* */ 12 | void 13 | ask() { 14 | int k,num[1]; 15 | kill(); /* clear input line */ 16 | 17 | outbyte(CLS); /* clear the screen */ 18 | nl();nl(); /* print banner */ 19 | pl(BANNER); 20 | nl();nl(); 21 | pl(VERSION); 22 | nl(); 23 | pl(AUTHOR); 24 | nl(); 25 | nl(); 26 | 27 | /* see if user wants to interleave the c-text */ 28 | /* in form of comments (for clarity) */ 29 | pl("Do you want the c-text to appear (y,N) ? "); 30 | myGets(line); /* get answer */ 31 | ctext=0; /* assume no */ 32 | if((ch()=='Y') || (ch()=='y')) 33 | ctext=1; /* user said yes */ 34 | 35 | /* see if the user is compiling everything at once */ 36 | /* (as is usually the case) */ 37 | pl("Are you compiling the whole program at once (Y,n) ? "); 38 | myGets(line); 39 | if((ch()!='N') && (ch()!='n')) { /* single file - assume... */ 40 | glbflag=1; /* define globals */ 41 | mainflg=1; /* first file to assembler */ 42 | nxtlab =0; /* start numbers at lowest possible */ 43 | } else { /* one of many - ask everything */ 44 | /* see if user wants us to allocate static */ 45 | /* variables by name in this module */ 46 | /* (pseudo external capability) */ 47 | pl("Do you want the globals to be defined (y,N) ? "); 48 | myGets(line); 49 | glbflag=0; 50 | if((ch()=='Y') || (ch()=='y')) 51 | glbflag=1; /* user said yes */ 52 | /* see if we should put out the stuff */ 53 | /* needed for the first assembler */ 54 | /* file. */ 55 | pl("Is the output file the first one the assembler "); 56 | pl("will see (y,N) ? "); 57 | myGets(line); 58 | mainflg=0; 59 | if((ch()=='Y') || (ch()=='y')) 60 | mainflg=1; /* indeed it is */ 61 | /* get first allowable number for compiler-generated */ 62 | /* labels (in case user will append modules) */ 63 | while(1) { 64 | pl("Starting number for labels (0) ? "); 65 | myGets(line); 66 | if(ch()==0){num[0]=0;break;} 67 | if(k=number(num))break; 68 | } 69 | nxtlab=num[0]; 70 | } 71 | 72 | /* see if user wants to be sure to see all errors */ 73 | pl("Should I pause after an error (y,N) ? "); 74 | myGets(line); 75 | errstop=0; 76 | if((ch()=='Y') || (ch()=='y')) 77 | errstop=1; 78 | 79 | litlab=getlabel(); /* first label=literal pool */ 80 | kill(); /* erase line */ 81 | } 82 | 83 | /* */ 84 | /* Get output filename */ 85 | /* */ 86 | void 87 | openout() { 88 | kill(); /* erase line */ 89 | output=0; /* start with none */ 90 | pl("Output filename? "); /* ask...*/ 91 | myGets(line); /* get a filename */ 92 | if(ch()==0) return; /* none given... */ 93 | if((output=fopen((char *) line,"w"))==NULL) { /* if given, open */ 94 | output=0; /* can't open */ 95 | printf("Opps %x\n", output); 96 | error("Open failure!"); 97 | } 98 | printf("0x%x\n", output); 99 | kill(); /* erase line */ 100 | } 101 | 102 | /* */ 103 | /* Get (next) input file */ 104 | /* */ 105 | void 106 | openin() { 107 | input=0; /* none to start with */ 108 | 109 | while(input==0) { /* any above 1 allowed */ 110 | kill(); /* clear line */ 111 | if(eof) break; /* if user said none */ 112 | pl("Input filename? "); 113 | myGets(line); /* get a name */ 114 | if(ch() == 0) { 115 | eof=1; 116 | break; 117 | } /* none given... */ 118 | 119 | if((input=fopen(line,"r"))!=NULL) { 120 | newfile(); 121 | } else { 122 | input = stdin; /* can't open it */ 123 | pl("An Open failure"); 124 | } 125 | } 126 | kill(); /* erase line */ 127 | } 128 | #else 129 | // Flex version 130 | 131 | /* */ 132 | /* Get options from user */ 133 | /* */ 134 | /* 135 | 1. Output intro ( -q to quiet) 136 | 2. Whole program or individuals (-c) (.p) 137 | 3. Do you want globals to be defined? 138 | 4. Is this main()? 139 | 5. Starting number for labels? 140 | 6. ask for output file 141 | 7. ask for input file 142 | */ 143 | void 144 | ask() { 145 | ctext=1; /* user said yes */ 146 | 147 | glbflag=1; /* define globals */ 148 | mainflg=1; /* first file to assembler */ 149 | nxtlab =0; /* start numbers at lowest possible */ 150 | 151 | /* see if user wants to be sure to see all errors */ 152 | errstop=0; 153 | 154 | litlab = getlabel(); /* first label=literal pool */ 155 | } 156 | 157 | /* */ 158 | /* Get output filename */ 159 | /* */ 160 | void 161 | openout() { 162 | return ; 163 | } 164 | 165 | /* */ 166 | /* Get (next) input file */ 167 | /* */ 168 | void 169 | openin(char *filename) { 170 | exit(0); 171 | /* 172 | if(filename != NULL) { 173 | if((input=fopen(filename,"r"))!=NULL) { 174 | newfile(); 175 | } else { 176 | fprintf(stderr, "File not found: %s\n", filename); 177 | exit(2); 178 | } 179 | } 180 | */ 181 | } 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /6800/io.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "smallc.h" 6 | 7 | /* Print a carriage return and a string only to console */ 8 | void 9 | pl(char *str) { 10 | int k; 11 | 12 | k=0; 13 | putchar(EOL); 14 | while(str[k]) putchar(str[k++]); 15 | fflush(stderr); 16 | fflush(stdout); 17 | } 18 | 19 | long 20 | outbyte(char c) { 21 | if(c==0) return (0); 22 | if(output) { 23 | int i = (int) c; 24 | if((fputc(i, output)) == EOF) { 25 | closeout(); 26 | error("Output file error"); 27 | myAbort(); 28 | } 29 | } 30 | else putchar(c); 31 | /* 32 | fflush(output); 33 | fflush(stderr); 34 | fflush(stdout); 35 | */ 36 | return (c); 37 | } 38 | 39 | /* direct output to console */ 40 | void 41 | toconsole() { 42 | saveout=output; 43 | output=stdout; 44 | } 45 | 46 | /* direct output back to file */ 47 | void 48 | tofile() { 49 | if(saveout) 50 | output=saveout; 51 | saveout=stdout; 52 | } 53 | 54 | /* */ 55 | /* Close the output file */ 56 | /* */ 57 | void 58 | closeout() { 59 | tofile(); /* if diverted, return to file */ 60 | if(output) fclose(output); /* if open, close it */ 61 | output=0; /* mark as closed */ 62 | } 63 | 64 | long 65 | myFclose(FILE *fp) { 66 | return(fclose(fp)); 67 | } 68 | -------------------------------------------------------------------------------- /6800/io9.c: -------------------------------------------------------------------------------- 1 | /* Small-C Input-Output Library for FLEX9 */ 2 | 3 | putchar(c) 4 | char c; 5 | { 6 | #asm 7 | FCB 86 8 | LDA 3,S 9 | CMPA #13 10 | BNE :1 11 | JSR $CD24 12 | BRA :2 13 | :1 JSR $CD18 14 | :2 LDD 2,S 15 | JMP RTSC 16 | #endasm 17 | } 18 | 19 | getchar() 20 | { 21 | #asm 22 | FCB 86 23 | JSR $CD15 24 | CMPA #13 25 | BNE :1 26 | JSR $CD24 27 | LDA #13 28 | :1 TFR A,B 29 | CLRA 30 | JMP RTSC 31 | #endasm 32 | } 33 | 34 | puts(s) 35 | char *s; 36 | { 37 | int k; 38 | k=0; 39 | /* while(putchar(s[k++])); */ 40 | while(putchar(s++)); 41 | } 42 | -------------------------------------------------------------------------------- /6800/options.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Author: Neil Cherry 4 | ** Date: 2023/02/03 5 | ** Version: 1.1 (sub alpha) 6 | ** 7 | ** 8 | */ 9 | 10 | #include /* as referenced in the getop man page */ 11 | #include /* used by atoi */ 12 | #include 13 | #include 14 | #include 15 | 16 | #include "smallc.h" 17 | 18 | extern void openFile(char *filename); 19 | 20 | void 21 | clihelp() { 22 | fprintf(stderr,"smallc filename.c\n"); 23 | } 24 | 25 | void 26 | options(int argc, char **argv) { 27 | int c, option_index = 0; 28 | 29 | static struct option long_options[] = { 30 | {"help", 0, 0, '?'}, 31 | {"help", 0, 0, 'h'}, 32 | {0, 0, 0, 0} 33 | }; 34 | 35 | ctext=1; /* user said yes */ 36 | 37 | glbflag=1; /* define globals */ 38 | mainflg=1; /* first file to assembler */ 39 | nxtlab =0; /* start numbers at lowest possible */ 40 | 41 | /* see if user wants to be sure to see all errors */ 42 | errstop=0; 43 | 44 | litlab = getlabel(); /* first label=literal pool */ 45 | 46 | /* 47 | ** handle options here before we fork 48 | ** 49 | ** The following options should be available: 50 | ** --help -h -? Issues help 51 | */ 52 | 53 | while(1) { /* Forever loop */ 54 | c = getopt_long (argc, argv, "?", long_options, &option_index); 55 | if(c == (-1)) { 56 | openFile(argv[optind]); 57 | return; 58 | } 59 | 60 | switch(c) { 61 | default: /* Bad option */ 62 | fprintf(stderr,"Bad option '%c'\n",**argv); 63 | case 'h': /* Help screen */ 64 | case '?': 65 | clihelp(); 66 | exit(1); 67 | break; 68 | } 69 | } 70 | } 71 | 72 | /* */ 73 | /* Get (next) input file */ 74 | /* */ 75 | void 76 | openFile(char *filename) { 77 | //fprintf("* filename '%s'\n) 78 | if(!filename) return; 79 | 80 | // input is global 81 | if((input = fopen(filename,"r")) == NULL) { 82 | fprintf(stderr, "X File not found: %s\n", filename); 83 | exit(2); 84 | } else { 85 | newfile(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /6800/prtlib.lib: -------------------------------------------------------------------------------- 1 | #asm 2 | LIB PRTLIB.ASM 3 | #endasm 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#zz-2.3 2 | COPT = -g -O3 3 | OBJS = smallcv22.o cc2.o cc3.o cc4.o 4 | 5 | #mallcv22: %.o cc2.o cc3.o cc4.o 6 | smallcv22: ${OBJS} 7 | $(CC) $(LOPT) -o $@ $^ 8 | 9 | %.o: %.c cc.h notice.h 10 | $(CC) $(COPT) -o $@ -c $< 11 | 12 | cc2.c: cc.h 13 | cc3.c: cc.h 14 | cc4.c: cc.h 15 | 16 | smallc: smallc.c smallc.h 17 | gcc -g -O3 smallc.c -o smallc 18 | 19 | .PHONY: clean 20 | 21 | clean: 22 | rm -rf *~ *.ihx *.lst *.map *.mem *.rel *.rst \ 23 | *.sym foo bar *.d51 *.hex *.a51 *.lnk \ 24 | smallc *.o 25 | 26 | # for i in AR.C CC1.C CC2.C CC3.C CC4.C CC.H NOTICE.H; do 27 | # nom=$(tr '[:upper:]' '[:lower:]' <<< $i); cp $i ~/dev/git/SmallC68/${nom}; done 28 | 29 | # gdb -q --args ./smallcv22 ar.c 30 | -------------------------------------------------------------------------------- /silifen/LIB51/man1.txt: -------------------------------------------------------------------------------- 1 | ,pn 1 2 | ,pl 66 3 | ,lm 8 4 | ,ll 64 5 | ,ju 6 | ,ppsi 4 7 | ,ppsp 1 8 | ,pc ` 9 | ,hd 10 | ,ll 64 11 | `$1B,'!,24` 12 | ,ce 1 13 | Introduction 14 | 15 | `$1B,'!,8` 16 | ,, 17 | ,ft 18 | ,ll 64 19 | `$1B,'!,24` 20 | ,ce 3 21 | ### 22 | 23 | Silicon Fen Software 24 | `$1B,'!,0` 25 | ,, 26 | 27 | 28 | 29 | 30 | `$1B,'!,24` 31 | ,ce 1 32 | 1. Introduction 33 | 34 | `$1B,'!,8` 35 | ,pp 36 | C is a compiled language. This means that C programs are written as text files (known as source files) and then a C compiler is used to read the program text and output a file which can be assembled to produce an executable command. Pascal is another compiled language that was designed for teaching computer science while Basic is an interpreted language designed for newcomers to computing. Most people know Basic but it is hard to write programs of any size in Basic because the language is unstructured and programs run slowly. Pascal is a structured language that runs much faster than Basic but because of deficiencies in the original language specification there are many incompatible versions of the language available. Pascal was not designed to be used to write large programs and problems occur when it would be desirable to split a program into several source files so that they can be edited and compiled more easily. Assembly language (sometimes called machine code) programs are difficult to write but run fastest. Programs written in C run faster than Pascal programs because C includes many of the features of assembly language in a structured way. C was also designed to cope with large programs and most versions of the language are compatible. 37 | ,pp 38 | The C language is becoming more widely known in the computer industry for two main reasons. The first reason is that it combines most of the speed and efficiency of assembler with the benefits of a high level language. It is available for almost every type of computer from 8 bit microprocessors through 16 and 32 bit micros and minicomputers to large mainframes. Programs can be written in C much more quickly and easily than in assembler and they do not need to be completely rewritten to run on another computer. For example, the programs written by the software house Psion for the Sinclair QL were written in C and the same programs are available for the IBM PC. These two computers have completely different operating systems and processors but the C language is the same for both of them. 39 | ,pp 40 | The second reason for the popularity of C is that the Unix operating system has become an industry standard. This operating system was originally written in the late 1960's using assembler but the designers then defined the language C and rewrote Unix in C. The very first C compiler was the Unix C compiler and the language was designed to match the requirements of a large and complex project. Unix is a good operating system for many reasons but the main reason that it has become an industry standard is that it is written in C and can in principle be run on any computer that has a C compiler available for it. It is obviously much easier to write a compiler for a new computer and then recompile the whole operating system than it is to rewrite the whole operating system from scratch in assembler. 41 | ,pp 42 | The facilities of an operating system (input/output and file handling) are available to users of the C language via a library of subroutines. These routines have standard names and parameters for all implementations of C under the Unix operating system and most other implementations of C follow the same standard where possible. Silicon Fen Software has followed the standard where possible and programs written using this compiler and its subroutine libraries can be compiled and run with no changes to the program on any Unix based computer. (Or any other computer with a Unix standard C compiler). Extra subroutines have been written which use special features of FLEX-9 but for each subroutine described in section 6 of this manual the extent of Unix compatibility is noted. 43 | ,pp 44 | This C compiler accepts as input text files containing a subset of the C language and generates an output text file in a processor independent macro assembly language. Macros and library routines are provided for 6809, FLEX-9 operation using the standard FLEX macro assembler. Compilation for the 6801 and 6301 ranges of single chip microcomputers is available as an option and requires a special assembler (see your dealer for details). Compilation for the 68000 is under development and the compiler will eventually be available on 68000 based computers. The compiler is based on the original 8080 small-C compiler by Ron Cain, published in Doctor Dobbs Journal. It has been extensively modified to generate code for the Motorola family of processors however and 8080, Z80 support is not available. 45 | ,pp 46 | This manual contains a tutorial introduction to C as well as a small-C language definition. This should be sufficient for most users but the standard text book on C is 'The C Programming Language' by B.W.Kernighan and D.M.Ritchie (Prentice Hall). This costs over 20 pounds. A much cheaper and easier introduction, which also includes listings of an 8080 small-C compiler, is 'A Book on C' by Berry and Meekins (Macmillan) which is only 7.50. The differences between small-C and standard C are listed in section 5 of this manual and it is recommended that section 5 is read before trying the text book. The main omissions are floating point maths and data structure definitions. 47 | ,pp 48 | This compiler is intended to be used as a substitute for assembler in systems programming and real time control applications. It is substantially cheaper than other FLEX C-compilers and is upwards compatible, i.e. programs written in small-C can be recompiled without any changes using a more expensive compiler (as long as the compiler uses the unix standard runtime library). The small-C compiler itself is written in the small-C subset and compiles and runs with no changes to the code on both FLEX-9 and PDP-11 Xenix (same as Unix) systems. 49 | ,pp 50 | Copyright exists on the small-C compiler and covers the manual, the executable compiler command, the source code of the runtime libraries and the example C programs. Programs written using the compiler and runtime library are not covered by any restrictions or copyright as long as the source code for the runtime libraries is not resold. Silicon Fen Software cannot be held liable for any loss or misfortune caused by a failure of this product. 51 | ,pp 52 | If any problems or queries arise concerning the compiler or its runtime libraries then Silicon Fen Software should be notified in writing; telephone support is not available. 53 | ,pp 54 | New releases of this compiler will be available to existing users for a nominal charge to cover media and delivery costs. 55 | 56 | 57 | -------------------------------------------------------------------------------- /silifen/LIB51/man5.txt: -------------------------------------------------------------------------------- 1 | ,pn 37 2 | ,pl 66 3 | ,lm 8 4 | ,ll 64 5 | ,ju 6 | ,ppsi 4 7 | ,ppsp 1 8 | ,pc ` 9 | ,hd 10 | ,ll 64 11 | `$1B,'!,24` 12 | ,ce 2 13 | Differences from Standard C 14 | 15 | `$1B,'!,8` 16 | ,, 17 | ,ft 18 | ,ll 64 19 | `$1B,'!,24` 20 | ,ce 3 21 | ### 22 | 23 | Silicon Fen Software 24 | `$1B,'!,0` 25 | ,, 26 | 27 | 28 | `$1B,'!,24` 29 | ,ce 2 30 | 5. Differences from Standard C 31 | 32 | `$1B,'!,8` 33 | ,pp 34 | The differences from standard C fall into two classes. The first is extensions to standard C and implementation differences, the second is the sections of standard C which do not exist for small-C. 35 | ,pp 36 | The main extension from standard C is the #asm and #endasm directives. Because these allow native assembler to be included in C programs use of this directive means that small-C programs may not be ported to other processors. Some of the runtime library routines are FLEX specific and the graphics library is Microbox ][ specific so use of these routines will prevent programs from being ported. 37 | ,pp 38 | The runtime library contains the essential standard C routines but some of them are implemented differently from the original Unix implementation. In particular, the low level file handling routines "open", "write" etc are not provided. Some of the higher level routines are used instead, e.g. "fopen". The compatibility of each routine is noted in section 6. 39 | ,pp 40 | Function parameters are pushed on the stack from left to right in small-C and from right to left in Unix C. This affects functions like printf which use the first parameter to determine how many other parameters there are. In Unix C the last thing pushed was the first parameter so it is at a known stack offset. For small-C this parameter is an unknown number of bytes up the stack! This is fixed by passing the number of bytes that were pushed on the stack in a register. This is wasteful for most functions so the number is only put in the register for function calls to printf or to a pointer to function. This is handled by the CALL macro, see the file LIBM09.TXT for details. If another function needs the byte count then LIBM09.TXT must be modified. 41 | ,pp 42 | The missing features from standard C are partially detailed in the small-C language definition but a summary follows: 43 | ,in 8 44 | 45 | Missing keywords: 46 | float extern unsigned 47 | double register auto 48 | struct typedef switch 49 | union static case 50 | long goto default 51 | short sizeof entry 52 | enum 53 | 54 | Missing constants: 55 | Long constants (32 bit) 56 | Floating point constants 57 | 58 | Missing storage classes: 59 | static 60 | register 61 | 62 | 63 | Missing types: 64 | short integers (same as int) 65 | unsigned integers 66 | long (32 bit) integers 67 | float (32 bit) floating point 68 | double (64 bit) floating point 69 | structures of types 70 | unions of types 71 | 72 | 73 | Missing derived types: 74 | Functions that don't return integers 75 | Pointers to pointers 76 | Arrays of arrays (multiple dimensions) 77 | 78 | 79 | Missing operators: 80 | sizeof(type) 81 | ! boolean not. 82 | && boolean and 83 | || boolean or 84 | op= assignment operators 85 | 86 | 87 | Missing statements: 88 | switch(expr) case const: ; default: ; 89 | goto label; 90 | label: 91 | 92 | 93 | Missing preprocessor directives: 94 | #define with parameter substitution 95 | #undef 96 | #ifdef (next release) 97 | #ifndef (next release) 98 | #else (next release) 99 | #endif (next release) 100 | #line 101 | #include <> (use "" instead) 102 | ,in 0 103 | 104 | ,pp 105 | The missing statements can be simulated using constructs given in section 4 of this manual. Floating point will not be added to 16 bit versions of this compiler but may be added to the 32 bit 68000 version which is under development. If a more complete version of C is needed then James McCosh C is recommended. JMC's C costs a lot more, only targets to the 6809, takes a lot longer to compile a program and has a much bigger minimum size of program than small-C but it includes almost all the missing features and generates faster code than small-C. 106 | ,pp 107 | C is still an evolving language and new features are added to the most advanced C compilers every few years. Some features that have been added since the Kernighan and Ritchie book in 1978 are: enumerated types ( a la pascal ), functions returning structures and assignment of structures. These features are present in most Unix C compilers. 108 | -------------------------------------------------------------------------------- /silifen/LIB51/man8.txt: -------------------------------------------------------------------------------- 1 | ,pn 76 2 | ,pl 66 3 | ,lm 8 4 | ,ll 64 5 | ,ju 6 | ,ppsi 4 7 | ,ppsp 1 8 | ,pc ` 9 | ,hd 10 | ,ll 64 11 | `$1B,'!,24` 12 | ,ce 2 13 | Output Macros and Optimisation 14 | 15 | `$1B,'!,8` 16 | ,, 17 | ,ft 18 | ,ll 64 19 | `$1B,'!,24` 20 | ,ce 3 21 | ### 22 | 23 | Silicon Fen Software 24 | `$1B,'!,0` 25 | ,, 26 | 27 | 28 | `$1B,'!,24` 29 | ,ce 2 30 | 8. Output Macros and Optimisation 31 | 32 | `$1B,'!,8` 33 | ,pp 34 | The output from the compiler is in a processor independent macro language which can be used to generate machine code for several different microprocessors by simply redefining the macro's. Macro's are currently available for 6809 and 6801 use and macro sets for the 68000 is under development. It is possible to develop a small-C program on a 6809 FLEX machine and when it has been tested, the macro's can be reassembled (without being recompiled) for a 6801 using 6801 macro definitions and runtime library. This code can then be put into EPROM or whatever and then run on the target machine. 35 | ,pp 36 | The macros are defined in LIBM09.TXT for the 6809 and they will not be described any further here. Users are welcome to redefine the macro's for new processors using the 6809 versions as a guide and Silicon Fen Software would like to know if anyone succeeds in this. 37 | ,pp 38 | Section 7 describes the special method used to pass the number of parameters to a function. Some extra information is also available when a function is defined. The FUNC macro is passed the number of arguments that were declared with the function. This is not the number of bytes, it is the number of words. This is used by the FUNC macro to see how many arguments the function "main" was defined with. This number is saved as _MARGS and later on the code that parses the FLEX command line is only present if it is needed. This saves a few hundred bytes. 39 | ,pp 40 | When generating code the compiler always assumes the worst so that for simple constructs the code generated may be inefficient. For example when a constant array index is used the compiler still calculates the resulting array element address at runtime rather than at compile time. This applies even if the constant is zero. The code for accessing stack based variables is also inefficient. The optimiser program opt.cmd is provided to remove some of the redundant code sequences. The optimiser is a small-C program (the source code is provided in OPT.C) which works on the macros output from the compiler, looking for sequences of macros which can be replaced by a more efficient macro. Some of the defined macros in LIBM09.TXT are never generated by the compiler but are inserted by the optimiser. The optimiser is currently very simple in operation and is coded as a nest of if() else statements. The current version saves about 10-15% on the size of the code segment for a program. The current optimiser doesnt optimise constant array indexes but the user can modify OPT.C to increase the range of optimisations it performs. A lot of testing is needed to verify that an optimisation is valid in all situations. 41 | ,pp 42 | One extra advantage of using processor independent macros is that a single version of the optimiser will optimise code for any target processor. The current optimisations are set up to take advantage of the 6809 instruction set so the savings may not be as good for other processors but there should always be some savings 43 | -------------------------------------------------------------------------------- /silifen/LIB51/man9.txt: -------------------------------------------------------------------------------- 1 | ,pn 77 2 | ,pl 66 3 | ,lm 8 4 | ,ll 64 5 | ,ju 6 | ,ppsi 4 7 | ,ppsp 1 8 | ,pc ` 9 | ,hd 10 | ,ll 64 11 | `$1B,'!,24` 12 | ,ce 2 13 | The Image in Memory 14 | 15 | `$1B,'!,8` 16 | ,, 17 | ,ft 18 | ,ll 64 19 | `$1B,'!,24` 20 | ,ce 3 21 | ### 22 | 23 | Silicon Fen Software 24 | `$1B,'!,0` 25 | ,, 26 | 27 | 28 | `$1B,'!,24` 29 | ,ce 2 30 | 9. The Image in Memory 31 | 32 | `$1B,'!,8` 33 | ,pp 34 | A small-C program occupies memory as shown below. The program sections are shown in order but their sizes are not to scale. 35 | 36 | FFFF------------------------- 37 | | Vectors | 38 | ------------------------- 39 | | Monitor Rom | 40 | ------------------------- 41 | | I/O Space | 42 | ------------------------- 43 | | | 44 | | FLEX | 45 | | | 46 | C080------------------------- 47 | | FLEX stack | 48 | BFFF------------------------- <----- default MEMEND 49 | | | 50 | | C Stack | 51 | | | 52 | ------------------------- 53 | | | 54 | | Free RAM | 55 | | | 56 | ------------------------- 57 | | | 58 | | File Control Blocks | 59 | | | 60 | ------------------------- end 61 | | | 62 | | Global Data | 63 | | | 64 | ------------------------- edata 65 | | | 66 | | String Literals | 67 | | | 68 | ------------------------- etext 69 | | | 70 | | Runtime Library Code | 71 | | | 72 | ------------------------- 73 | | | 74 | | C Program Code | 75 | | | 76 | 0000------------------------- 77 | 78 | ,pp 79 | By default, small-C programs start at address 0000. This can be changed using #asm, org XXXX, #endasm at the start of the program. 80 | ,pp 81 | The stack starts at the address given in the FLEX MEMEND location and proceeds downwards. This is usually set to BFFF. 82 | ,pp 83 | The code generated from the users C program starts at 0000. After this comes the machine library routines (multiply, divide, shift etc) followed by the program startup code at the transfer address. The startup code deals with the FLEX command line and then calls the function main in the users program. A few bytes of ram exist at this point to store the flex command line and the argc and argv values. If it is required to ROM a small-C program for use in a standalone system the startup routine will need to be replaced and the ram will not be required. Following the startup code comes the runtime library routines that were called by the program. 84 | ,pp 85 | The label etext marks the end of the code segment. This label is available to assembler but the true external storage class is needed to use it from C (the label name and useage is unix compatible). 86 | ,pp 87 | The next segment is the initialised data segment. In small-C it consists only of the string literals used by the program. The end of this segment is marked by the label edata. (Available like etext). 88 | ,pp 89 | The uninitialised data segment follows containing all global variables. Its end is marked by the end label and as part of the startup code the block of RAM from edata to end is filled with zero's. This is standard C compatable and means that all global variables are guaranteed to be zero at the start of program execution. 90 | ,pp 91 | If any files are opened by the program they will be allocated file control blocks automatically just above the end label. These FCB's form a heap of 320 byte blocks and are reused if a file is closed and another is opened. The chain of open files maintained by FLEX is used to determine which FCB's are in use. 92 | ,pp 93 | The gap between the FCB's and the stack is free RAM. Heavily recursive programs or programs which have a lot of local variables may cause the stack to overwrite the top FCB with possibly fatal results. This has never yet occurred in practice and it is possible to fit the TSC Debug program into the free RAM even when running the compiler itself. The compiler starts at 0000 and end for the compiler is somewhere between 8000 and 9000 depending on the exact version in use. The compiler is heavily recursive and exceedingly complicated expressions with lots of parentheses consume large quantities of stack. 94 | -------------------------------------------------------------------------------- /silifen/LIB51/manc.txt: -------------------------------------------------------------------------------- 1 | ,pl 66 2 | ,lm 8 3 | ,ll 64 4 | ,ju 5 | ,ppsi 4 6 | ,ppsp 1 7 | ,pc ` 8 | ,hd 9 | ,ll 64 10 | `$1B,'!,24` 11 | ,ce 2 12 | Small-C Compiler R1.1 13 | 14 | `$1B,'!,8` 15 | ,, 16 | ,ft 17 | ,ll 64 18 | `$1B,'!,24` 19 | ,ce 3 20 | 21 | 22 | Silicon Fen Software 23 | `$1B,'!,0` 24 | ,, 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | `$1B,'!,56` 45 | Small-C Compiler 46 | `$1B,'!,8` 47 | 48 | ,PG 49 | 50 | 51 | 52 | 53 | 54 | ,CE 1 55 | Contents 56 | ,rj 57 | Page 58 | ,IN 16 59 | Index 60 | 61 | 1. Introduction 1 62 | 63 | 2. Tutorial 4 64 | 65 | 3. Compiler Operation 12 66 | 67 | 4. Small-C Language Definition 17 68 | 69 | 5. Differences from Standard C 37 70 | 71 | 6. The Runtime Libraries 39 72 | 73 | 7. Assembler Interfacing 70 74 | 75 | 8. The Output Macros and Optimisation 76 76 | 77 | 9. The Image in Memory 77 78 | 79 | 10. Error Messages and Debugging 79 80 | 81 | 82 | Appendix A. Graphics Library Option 83 | 84 | Appendix B. 6801 Cross Support Option 85 | 86 | 87 | ,in 0 88 | ,pg 89 | 90 | 91 | 92 | 93 | ,ce 94 | Acknowledgments 95 | 96 | ,in 8 97 | Thanks to: 98 | 99 | Ron Cain for starting something. 100 | 101 | Colin Tapp for typing it in. 102 | 103 | Andy Biggs for proofreading the manual. 104 | 105 | CCL for Xenix. 106 | 107 | Dave Rumball for the Microbox ][. 108 | 109 | Chris Lindsay for help and encouragement. 110 | 111 | Linda for putting up with it. 112 | 113 | ,in 0 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | ,pp 126 | The small-C compiler, runtime libraries and manual are copyright Silicon Fen Software, Adrian Cockcroft 1984, 1985. 127 | 128 | Silicon Fen Software 129 | 39, Mason Road 130 | Burwell 131 | Cambridgeshire 132 | CB5 0BG 133 | England 134 | 135 | 136 | 137 | NOTE: 138 | FLEX is a trademark of Technical Systems Consultants Inc. 139 | Unix is a trademark of AT&T. 140 | Xenix is a trademark of Microsoft. 141 | 142 | -------------------------------------------------------------------------------- /silifen/LIB51/mani.txt: -------------------------------------------------------------------------------- 1 | ,pl 66 2 | ,lm 8 3 | ,ll 64 4 | ,ju 5 | ,ppsi 4 6 | ,ppsp 1 7 | ,pc ` 8 | ,hd 9 | ,ll 64 10 | `$1B,'!,24` 11 | ,ce 2 12 | Index 13 | 14 | `$1B,'!,8` 15 | ,, 16 | ,ft 17 | ,ll 64 18 | `$1B,'!,24` 19 | ,ce 3 20 | 21 | 22 | Silicon Fen Software 23 | `$1B,'!,0` 24 | ,, 25 | 26 | 27 | `$1B,'!,24` 28 | ,ce 2 29 | Index 30 | 31 | `$1B,'!,8` 32 | ,pp 33 | This index covers the appendices on Microbox Graphics and 6801 code generation although they may not be supplied with the compiler. Appendices have a letter after the page number which indicates which appendix the reference is in. 34 | 35 | 6801 Article 7 B 36 | 6801 C Library 4 B 37 | 6801 C Notes 4 B 38 | 6801 Code Generation 1 B 39 | abs 55 40 | Additive operators 23 41 | Assembler Interface 7. 70 42 | Assignment operators 25 43 | Bitwise operators 24 44 | Break statement 32 45 | Books on C 2 46 | btoi 52 47 | C callable assembler 70 48 | clearerr 60 49 | Comments 17 50 | Comparison operators 24 51 | Compiler Operation 3. 12 52 | Compound statements 28 53 | Conditional compilation 35 54 | Conditional statement 30 55 | Constants 17 56 | Continue statement 32 57 | Conversions 19 58 | Copyright Restrictions 2 59 | Debugging check list 84 60 | Declarations 25 61 | Differences from C 5. 37 62 | Do statement 30 63 | Editors 4 64 | Error messages 10. 79 65 | exit 40 66 | Expression statements 28 67 | Expressions 20 68 | FCB allocation 78 69 | fclose 59 70 | feof 60 71 | ferror 60 72 | fgetc 66 73 | fgets 68 74 | File I/O routines 56 75 | File inclusion 35 76 | fill 46 77 | FLEX setup 4 78 | fopen 57 79 | For statement 31 80 | fputc 67 81 | fputs 69 82 | frdchk 62 83 | Function definitions 33 84 | gcircle 15 A 85 | getc 66 86 | getchar 49 87 | gets 48 88 | gfill 16 A 89 | ginit 11 A 90 | gline 14 A 91 | gmove 14 A 92 | Goto statement 32 93 | gpoint 15 A 94 | gputs 17 A 95 | Graphics 1 A 96 | grect 16 A 97 | greet.c 7 98 | greets.c 10 99 | gwindow 12 A 100 | gwtrans 13 A 101 | hello.c 5 102 | Identifiers 17 103 | Image in memory 9. 77 104 | Implicit declarations 36 105 | index 45 106 | Inline assembler 35,74 107 | isalpha 54 108 | isdigit 54 109 | islower 54 110 | isupper 54 111 | itob 51 112 | I/O routines 47 113 | Keywords 17 114 | Label statement 33 115 | Language Definition 4. 17 116 | Library recipe 72 117 | Lvalues 19 118 | Macros 76 119 | mbbchk 7 A 120 | mbcchk 6 A 121 | mbcirc 6 A 122 | mbclrg 3 A 123 | mbdelay 9 A 124 | mbfill 7 A 125 | mbgetgc 5 A 126 | mbgraph 3 A 127 | mbline 5 A 128 | mbpchk 5 A 129 | mbpoint 6 A 130 | mbputc 10 A 131 | mbrand 9 A 132 | mbrect 7 A 133 | mbsetgc 5 A 134 | mbsetp 4 A 135 | mbsetz 10 A 136 | mbspat 7 A 137 | mbsync 9 A 138 | mbtext 3 A 139 | MEMEND 77 140 | Memory useage 77 141 | Multiplicative oper's 22 142 | Objects 19 143 | Optimisation 76 144 | Output macros 8. 76 145 | perror 50 146 | polyline 18 A 147 | Preprocessor lines 34 148 | Primary Expressions 20 149 | printf 63 150 | Processor Selection 3 B 151 | putc 67 152 | putchar 49 153 | putdec 53 154 | puthex 53 155 | puts 48 156 | restore 3 A 157 | Return statement 32 158 | rewind 61 159 | rindex 45 160 | Runtime library 6. 39 161 | Shift operators 23 162 | sign 55 163 | Statements 28 164 | Storage classes 18 165 | strcat 42 166 | strcmp 43 167 | strcpy 43 168 | String routines 42 169 | String constants 18 170 | strlen 44 171 | strncat 42 172 | strncmp 43 173 | strncpy 43 174 | Styles 29 175 | Switch statement 31 176 | system 41 177 | Token replacement 34 178 | tolower 54 179 | toupper 54 180 | Tutorial 2. 4 181 | Types 18 182 | Unary Operators 21 183 | While statement 30 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /silifen/LIB53/ctype.h: -------------------------------------------------------------------------------- 1 | /* ctype.h - include file for character classification and transformation 2 | routines in liba.txt. 3 | Copyright Silicon Fen Software October 1984. 4 | */ 5 | #asm 6 | LIBA SET 1 7 | TOUPPER SET 0 8 | TOLOWER SET 0 9 | ISALPHA SET 0 10 | ISUPPER SET 0 11 | ISLOWER SET 0 12 | ISDIGIT SET 0 13 | #endasm 14 | 15 | -------------------------------------------------------------------------------- /silifen/LIB53/get01.txt: -------------------------------------------------------------------------------- 1 | echo get files onto ramdisk (drive 1) from floppy (drive 2) for 6801 compilation 2 | contin 3 | echo get standard files 4 | echo get exec files for get09 goto1 goto9 goto91 5 | y copy 2.get09.txt 1 6 | y copy 2.goto1.txt 1 7 | y copy 2.goto9.txt 1 8 | y copy 2.goto91.txt 1 9 | echo copying stdio.h 10 | y copy 2.stdio.h 1 11 | echo copying ctype.h 12 | y copy 2.ctype.h 1 13 | echo copying libdef01.txt 14 | y copy 2.libdef01.txt 1 15 | echo copying libdef91.txt 16 | y copy 2.libdef91.txt 1 17 | echo copying libload1.txt 18 | y copy 2.libload1.txt 1 19 | echo copying libld91.txt 20 | y copy 2.libld91.txt 1 21 | echo switch to 6801 code generation 22 | y copy libdef01.txt libdef.txt 23 | y copy libload1.txt libload.txt 24 | echo copying libc01.txt 25 | y copy 2.libc01.txt 1 26 | echo copying libf01.txt 27 | y copy 2.libf01.txt 1 28 | echo copying libm01.txt 29 | y copy 2.libm01.txt 1 30 | echo copying libs01.txt 31 | y copy 2.libs01.txt 1 32 | echo copying liba01.txt 33 | y copy 2.liba01.txt 1 34 | echo copying libp.txt 35 | y copy 2.libp.txt 1 36 | echo get hardware access library if required 37 | contin 38 | echo copying hardware.h 39 | y copy 2.hardware.h 1 40 | echo copying libh.txt 41 | y copy 2.libh.txt 1 42 | echo now setup for 6801 use 43 | -------------------------------------------------------------------------------- /silifen/LIB53/get09.txt: -------------------------------------------------------------------------------- 1 | echo get files onto ramdisk (drive 1) from floppy (drive 2) for 6809 compilation 2 | contin 3 | echo get exec files for get01 goto1 goto9 goto91 4 | y copy 2.get01.txt 1 5 | y copy 2.goto1.txt 1 6 | y copy 2.goto9.txt 1 7 | y copy 2.goto91.txt 1 8 | echo get standard files 9 | echo copying stdio.h 10 | y copy 2.stdio.h 1 11 | echo copying ctype.h 12 | y copy 2.ctype.h 1 13 | echo copying libdef09.txt 14 | y copy 2.libdef09.txt 1 15 | echo copying libload9.txt 16 | y copy 2.libload9.txt 1 17 | echo switch to 6809 code generation 18 | y copy libdef09.txt libdef.txt 19 | y copy libload9.txt libload.txt 20 | echo copying libc09.txt 21 | y copy 2.libc09.txt 1 22 | echo copying libf09.txt 23 | y copy 2.libf09.txt 1 24 | echo copying libm09.txt 25 | y copy 2.libm09.txt 1 26 | echo copying libs09.txt 27 | y copy 2.libs09.txt 1 28 | echo copying liba09.txt 29 | y copy 2.liba09.txt 1 30 | echo copying libp.txt 31 | y copy 2.libp.txt 1 32 | echo get graphics if required 33 | contin 34 | echo copying plot.h 35 | y copy 2.plot.h 1 36 | echo copying libg09.txt 37 | y copy 2.libg09.txt 1 38 | echo now setup for 6809 use 39 | -------------------------------------------------------------------------------- /silifen/LIB53/goto1.txt: -------------------------------------------------------------------------------- 1 | echo change to 6801 code generation 2 | y copy libdef01.txt libdef.txt 3 | y copy libload1.txt libload.txt 4 | -------------------------------------------------------------------------------- /silifen/LIB53/goto9.txt: -------------------------------------------------------------------------------- 1 | echo change to 6809 code generation 2 | y copy libdef09.txt libdef.txt 3 | y copy libload9.txt libload.txt 4 | -------------------------------------------------------------------------------- /silifen/LIB53/goto91.txt: -------------------------------------------------------------------------------- 1 | echo change to 6801 code generation with 6809 flex I/O libraries 2 | y copy libdef91.txt libdef.txt 3 | y copy libld91.txt libload.txt 4 | -------------------------------------------------------------------------------- /silifen/LIB53/hardware.h: -------------------------------------------------------------------------------- 1 | /* hardware.h header file for 6801 hardware definitions */ 2 | 3 | /* no default definitions */ 4 | 5 | -------------------------------------------------------------------------------- /silifen/LIB53/liba09.txt: -------------------------------------------------------------------------------- 1 | * liba - ascii character classification and transformation routines 2 | * 3 | * Unix C compatible but implemented as assembler subroutines for speed 4 | * on unix these are C macro's. 5 | * 6 | * Copyright October 1984 by Silicon Fen Software 7 | * 8 | * use #include "ctype.h" in a C program to use these routines 9 | * 10 | IF TOUPPER 11 | * char toupper(c) convert character to upper case 12 | * char c; 13 | toupper ldb 3,s 14 | sex 15 | cmpb #'a 16 | blt TOUP1 17 | cmpb #'z 18 | bgt TOUP1 19 | subb #'a-'A 20 | TOUP1 rts 21 | ENDIF 22 | * 23 | * 24 | IF TOLOWER 25 | * char tolower(c) convert character to lower case 26 | * char c; 27 | tolower ldb 3,s 28 | sex 29 | cmpb #'A 30 | blt TOLO1 31 | cmpb #'Z 32 | bgt TOLO1 33 | addb #'a-'A 34 | TOLO1 rts 35 | ENDIF 36 | * 37 | * IF TOASCII 38 | * ENDIF 39 | * 40 | IF ISALPHA 41 | * int isalpha(c) return non-zero if character is alphabetic 42 | * char c; 43 | isalpha ldb 3,s 44 | sex 45 | cmpb #'A 46 | blt ISALP1 47 | cmpb #'z 48 | bgt ISALP1 49 | cmpb #'a 50 | bge ISALP2 51 | cmpb #'Z 52 | bgt ISALP1 53 | ISALP2 ldd #1 54 | rts 55 | ISALP1 ldd #0 56 | rts 57 | ENDIF 58 | * 59 | * 60 | IF ISDIGIT 61 | * int isdigit(c) return non-zero if character is a digit 62 | * char c; 63 | isdigit ldb 3,s 64 | sex 65 | cmpb #'0 66 | blt ISDIG1 67 | cmpb #'9 68 | bgt ISDIG1 69 | ldd #1 70 | rts 71 | ISDIG1 ldd #0 72 | rts 73 | ENDIF 74 | * 75 | * 76 | IF ISUPPER 77 | * int isupper(c) return non-zero if character is upper case 78 | * char c; 79 | isupper ldb 3,s 80 | cmpb #'A 81 | blt ISUPP1 82 | cmpb #'Z 83 | bgt ISUPP1 84 | ldd #1 85 | rts 86 | ISUPP1 ldd #0 87 | rts 88 | ENDIF 89 | * 90 | * 91 | IF ISLOWER 92 | * int islower(c) return non-zero if character is lower case 93 | * char c; 94 | islower ldb 3,s 95 | cmpb #'a 96 | blt ISLOW1 97 | cmpb #'z 98 | bgt ISLOW1 99 | ldd #1 100 | rts 101 | ISLOW1 ldd #0 102 | rts 103 | ENDIF 104 | * 105 | * IF ISXDIGIT 106 | * ENDIF 107 | * 108 | * IF ISALNUM 109 | * ENDIF 110 | * 111 | * IF ISSPACE 112 | * ENDIF 113 | * 114 | * IF ISPUNCT 115 | * ENDIF 116 | * 117 | * IF ISPRINT 118 | * ENDIF 119 | * 120 | * IF ISCNTRL 121 | * ENDIF 122 | * 123 | * IF ISASCII 124 | * ENDIF 125 | -------------------------------------------------------------------------------- /silifen/LIB53/libdef.txt: -------------------------------------------------------------------------------- 1 | * libdef09 R1.1 19/8/85 Define runtime library for FLEX9 6809 small-C compiler 2 | * 3 | * copyright 1985 by Silicon Fen Software 4 | * 5 | C6809 set 1 6 | C6801 set 0 7 | C68091 set 0 8 | * 9 | * macro's and FLEX constants 10 | lib libm09 machine library and macros 11 | lib libf09 flex equates for i/o etc 12 | * 13 | * set library files for libload 14 | LIBC EQU 1 default library always loaded 15 | LIBS SET 0 stdio.h file i/o library 16 | LIBG SET 0 plot.h graphics library 17 | LIBH SET 0 hardware.h hardware access library (not used) 18 | LIBA SET 0 ctype.h ascii tests and conversions library 19 | LIBP SET 0 printf etc library auto loaded if printf used 20 | * enable required library functions 21 | * the following routines are in libc - default library 22 | FILL SET 0 23 | EXIT SET 0 24 | SYSTEM SET 0 25 | STRCAT SET 0 26 | STRNCAT SET 0 27 | STRCMP SET 0 28 | STRNCMP SET 0 29 | STRCPY SET 0 30 | STRNCPY SET 0 31 | STRLEN SET 0 32 | INDEX SET 0 33 | RINDEX SET 0 34 | SIGN SET 0 35 | ABS SET 0 36 | BTOI SET 0 37 | ITOB SET 0 38 | * the following routines are in libs - file i/o using stdio. 39 | FOPEN SET 0 40 | FCLOSE SET 0 41 | FEOF SET 0 42 | FERROR SET 0 43 | CLEARERR SET 0 44 | REWIND SET 0 45 | FRDCHK SET 0 46 | GETS SET 0 47 | PUTS SET 0 48 | PERROR SET 0 49 | PUTDEC SET 0 50 | PUTHEX SET 0 51 | FPUTC SET 0 52 | FGETC SET 0 53 | FPUTS SET 0 54 | FGETS SET 0 55 | * in libp 56 | PRINTF SET 0 57 | * machine library routines, not C callable 58 | _CCMUL SET 0 59 | _CCDIV SET 0 60 | _CCASR SET 0 61 | _CCASL SET 0 62 | * end of libdef09 63 | -------------------------------------------------------------------------------- /silifen/LIB53/libdef01.txt: -------------------------------------------------------------------------------- 1 | * libdef01 R1.1b 18/11/85 - Define runtime library for 6801 small-C compiler 2 | * 3 | * copyright 1985 by Silicon Fen Software 4 | * 5 | opt exp 6 | * 7 | * The CRASMB assembler can be used with R1.1b, set to 1 if it is used 8 | CRASMB set 1 9 | * 10 | if CRASMB 11 | OPT NOU 12 | endif 13 | * 14 | C6809 set 0 15 | C6801 set 1 16 | C68091 set 0 17 | * 18 | * macro's and FLEX constants 19 | lib libm01 machine library and macros 20 | lib libf01 equates for i/o etc 21 | * 22 | * set library files for libload 23 | LIBC EQU 1 default library always loaded 24 | LIBS EQU 0 stdio.h terminal I/O library 25 | LIBP EQU 0 printf library routine 26 | LIBH SET 0 hardware.h hardware access library 27 | LIBA SET 0 ctype.h ascii tests and conversions library 28 | * enable required library functions 29 | * the following routines are in libc01 - default library 30 | STRCAT SET 0 31 | STRNCAT SET 0 32 | STRCMP SET 0 33 | STRNCMP SET 0 34 | STRCPY SET 0 35 | STRNCPY SET 0 36 | STRLEN SET 0 37 | FILL SET 0 38 | INDEX SET 0 39 | RINDEX SET 0 40 | SIGN SET 0 41 | ABS SET 0 42 | BTOI SET 0 43 | ITOB SET 0 44 | * the following routines are in libs01 - terminal i/o using stdio.h 45 | FRDCHK SET 0 46 | PUTCHAR SET 0 47 | GETCHAR SET 0 48 | PUTS SET 0 49 | GETS SET 0 50 | * machine library routines, not C callable 51 | CC_MUL SET 0 52 | CC_DIV SET 0 53 | CC_ASR SET 0 54 | CC_ASL SET 0 55 | * end of libdef01 56 | -------------------------------------------------------------------------------- /silifen/LIB53/libdef09.txt: -------------------------------------------------------------------------------- 1 | * libdef09 R1.1b 18/11/85 Define library for FLEX 6809 small-C compiler 2 | * 3 | * copyright 1985 by Silicon Fen Software 4 | * 5 | opt exp expand macros in listing 6 | * 7 | * The CRASM assembler can be used with R1.1b, set to 1 if it is used 8 | CRASMB set 1 9 | * 10 | if CRASMB 11 | OPT NOU 12 | endif 13 | * 14 | C6809 set 1 15 | C6801 set 0 16 | C68091 set 0 17 | * 18 | * macro's and FLEX constants 19 | lib libm09 machine library and macros 20 | lib libf09 flex equates for i/o etc 21 | * 22 | * set library files for libload 23 | LIBC EQU 1 default library always loaded 24 | LIBS SET 0 stdio.h file i/o library 25 | LIBG SET 0 plot.h graphics library 26 | LIBH SET 0 hardware.h hardware access library (not used) 27 | LIBA SET 0 ctype.h ascii tests and conversions library 28 | LIBP SET 0 printf etc library auto loaded if printf used 29 | * enable required library functions 30 | * the following routines are in libc - default library 31 | FILL SET 0 32 | EXIT SET 0 33 | SYSTEM SET 0 34 | STRCAT SET 0 35 | STRNCAT SET 0 36 | STRCMP SET 0 37 | STRNCMP SET 0 38 | STRCPY SET 0 39 | STRNCPY SET 0 40 | STRLEN SET 0 41 | INDEX SET 0 42 | RINDEX SET 0 43 | SIGN SET 0 44 | ABS SET 0 45 | BTOI SET 0 46 | ITOB SET 0 47 | * the following routines are in libs - file i/o using stdio. 48 | FOPEN SET 0 49 | FCLOSE SET 0 50 | FEOF SET 0 51 | FERROR SET 0 52 | CLEARERR SET 0 53 | REWIND SET 0 54 | FRDCHK SET 0 55 | GETS SET 0 56 | PUTS SET 0 57 | PERROR SET 0 58 | PUTDEC SET 0 59 | PUTHEX SET 0 60 | FPUTC SET 0 61 | FGETC SET 0 62 | FPUTS SET 0 63 | FGETS SET 0 64 | * in libp 65 | PRINTF SET 0 66 | * machine library routines, not C callable 67 | CC_MUL SET 0 68 | CC_DIV SET 0 69 | CC_ASR SET 0 70 | CC_ASL SET 0 71 | * end of libdef09 72 | -------------------------------------------------------------------------------- /silifen/LIB53/libdef91.txt: -------------------------------------------------------------------------------- 1 | * libdef91 R1.1b 18/11/85 Define library for FLEX9 6809 small-C compiler 2 | * using 6801 macro definitions 3 | * 4 | * copyright 1985 by Silicon Fen Software 5 | * 6 | opt exp 7 | * 8 | * The CRASMB assembler can be used with R1.1b, set to 1 if it is used 9 | CRASMB set 1 10 | * 11 | if CRASMB 12 | OPT NOU 13 | * special CRASMB macros for 6801 code using I6809 14 | pshx macro 15 | pshs x 16 | endm 17 | * 18 | pulx macro 19 | puls x 20 | endm 21 | * 22 | stad macro 23 | if &&2 24 | std &1,&2 25 | else 26 | std &1 27 | endif 28 | endm 29 | * 30 | ldad macro 31 | if &&2 32 | ldd &1,&2 33 | else 34 | ldd &1 35 | endif 36 | endm 37 | * 38 | asld macro 39 | aslb 40 | rola 41 | endm 42 | * 43 | lsrd macro 44 | lsra 45 | rorb 46 | endm 47 | * 48 | endif 49 | * 50 | C6809 set 0 define the processor libraries in use 51 | C6801 set 0 52 | C68091 set 1 53 | * 54 | * macro's and FLEX constants 55 | lib libm01 macros for 6801 56 | lib libf09 flex equates for i/o etc 57 | * 58 | * set library files for libload 59 | LIBC EQU 1 default library always loaded 60 | LIBS SET 0 stdio.h file i/o library 61 | LIBG SET 0 plot.h graphics library 62 | LIBH SET 0 hardware.h hardware access library (not used) 63 | LIBA SET 0 ctype.h ascii tests and conversions library 64 | LIBP SET 0 printf etc library auto loaded if printf used 65 | * enable required library functions 66 | * the following routines are in libc - default library 67 | FILL SET 0 68 | EXIT SET 0 69 | SYSTEM SET 0 70 | STRCAT SET 0 71 | STRNCAT SET 0 72 | STRCMP SET 0 73 | STRNCMP SET 0 74 | STRCPY SET 0 75 | STRNCPY SET 0 76 | STRLEN SET 0 77 | INDEX SET 0 78 | RINDEX SET 0 79 | SIGN SET 0 80 | ABS SET 0 81 | BTOI SET 0 82 | ITOB SET 0 83 | * the following routines are in libs - file i/o using stdio. 84 | FOPEN SET 0 85 | FCLOSE SET 0 86 | FEOF SET 0 87 | FERROR SET 0 88 | CLEARERR SET 0 89 | REWIND SET 0 90 | FRDCHK SET 0 91 | GETS SET 0 92 | PUTS SET 0 93 | PERROR SET 0 94 | PUTDEC SET 0 95 | PUTHEX SET 0 96 | FPUTC SET 0 97 | FGETC SET 0 98 | FPUTS SET 0 99 | FGETS SET 0 100 | * in libp 101 | PRINTF SET 0 102 | * machine library routines, not C callable 103 | CC_MUL SET 0 104 | CC_DIV SET 0 105 | CC_ASR SET 0 106 | CC_ASL SET 0 107 | * end of libdef09 108 | -------------------------------------------------------------------------------- /silifen/LIB53/libf01.txt: -------------------------------------------------------------------------------- 1 | * Small-C R1.1 27/7/85 Silicon Fen Software 2 | * 3 | * equates for use with 6801 4 | * 5 | opt exp expand macro's in assembly listing 6 | * 7 | * memory map for very basic 68701 with 128bytes RAM and 2k EPROM 8 | *CCODE equ $F800 start code at base of EPROM 9 | *CDATA equ $0080 start data after I/O locations 10 | *CSTACK equ $00FF place stack at highest RAM location 11 | * 12 | * memory map for testing on 6809 FLEX 13 | CCODE equ $0000 14 | CDATA equ $8000 15 | CSTACK equ $BFFF 16 | -------------------------------------------------------------------------------- /silifen/LIB53/libf09.txt: -------------------------------------------------------------------------------- 1 | * 2 | * libf - flex equates for small-C compiler 3 | * 4 | * Storage locations. 5 | LINBUF EQU $C080 Line buffer start. 6 | LINPTR EQU $CC14 Line buffer pointer 7 | FMSBASE EQU $D409 FCB base pointer 8 | TTYBS EQU $CC00 TTYSET backspace character. 9 | SYSDRV EQU $CC0B System drive number. 10 | WRKDRV EQU $CC0C Working drive number. 11 | MONTH EQU $CC0E FLEX system date. 12 | DAY EQU $CC0F 13 | YEAR EQU $CC10 14 | MEMEND EQU $CC2B Memory end pointer. 15 | * 16 | * User callable routines. 17 | COLDS EQU $CD00 Cold start. 18 | WARMS EQU $CD03 Warm start. 19 | RENTER EQU $CD06 Main loop entry point. 20 | DOCMND EQU $CD4B Call dos as a subroutine. 21 | STAT EQU $CD4E Check terminal status. 22 | INCH EQU $CD09 Input character. 23 | INCH2 EQU $CD0C Input character. 24 | OUTCH EQU $CD0F Output character. 25 | OUTCH2 EQU $CD12 Output character. 26 | GETCHR EQU $CD15 Get a char (main routine). 27 | PUTCHR EQU $CD18 Put a char (main routine). 28 | INBUFF EQU $CD1B Input into line buffer. 29 | PSTRNG EQU $CD1E Print a char string. 30 | CLASS EQU $CD21 Classify a char. 31 | PCRLF EQU $CD24 Print a crlf. 32 | NXTCH EQU $CD27 Get next buffer char. 33 | RSTRIO EQU $CD2A Restore i/o vectors. 34 | GETFIL EQU $CD2D Get file spec. 35 | LOAD EQU $CD30 File loader. 36 | SETEXT EQU $CD33 Set file extension. 37 | OUTDEC EQU $CD39 Output decimal number. 38 | OUTHEX EQU $CD3C Output hexadecimal number. 39 | OUTADR EQU $CD45 Output hex address. 40 | RPTERR EQU $CD3F Report error. 41 | GETHEX EQU $CD42 Get hexadecimal number. 42 | INDEC EQU $CD48 Input decimal number. 43 | FMSCLR EQU $D400 Close all open files. 44 | FMS EQU $D406 FMS entry point. 45 | -------------------------------------------------------------------------------- /silifen/LIB53/libh.txt: -------------------------------------------------------------------------------- 1 | * libh.txt R1.1 31/8/85 hardware access library 2 | * 3 | * bottom level terminal I/O routines based on FLEX entry points 4 | * 5 | * must be defined by the user for a hardware configuration 6 | * remove "err" lines when defined. 7 | * 8 | * get a character into the A reg. 9 | GETCHR 10 | err GETCHR not defined 11 | rts 12 | * 13 | * output char in A reg to terminal 14 | PUTCHR 15 | err PUTCHR not defined 16 | rts 17 | * 18 | * output return and linefeed 19 | PCRLF 20 | err PCRLF not defined 21 | rts 22 | * 23 | * see if character can be read by GETCHR, return clear Z (not equal) 24 | * if one is ready else return set Z (equal) in CC register. 25 | STAT 26 | err STAT not defined 27 | rts 28 | * 29 | * end of libh 30 | -------------------------------------------------------------------------------- /silifen/LIB53/libld91.txt: -------------------------------------------------------------------------------- 1 | * libld91 R1.1 26/8/85 Load runtime library for FLEX9 6809 small-C compiler 2 | * copyright 1985 by Silicon Fen Software 3 | * 4 | IF LIBP printf library common to 6801 and 6809 5 | lib libp 6 | ENDIF 7 | * 8 | IF LIBC default library is 6801 version 9 | lib libc01 10 | ENDIF 11 | * 12 | IF LIBS stdio.h i/o library 6809, flex for testing 13 | lib libs09 14 | ENDIF 15 | * 16 | IF LIBG plot.h graphics library 17 | lib libg09 18 | ENDIF 19 | * 20 | IF LIBH hardware.h hardware access library (unused) 21 | lib libh09 22 | ENDIF 23 | * 24 | IF LIBA ctype.h ascii tests and conversions library 25 | lib liba09 26 | ENDIF 27 | * end of libload9 28 | -------------------------------------------------------------------------------- /silifen/LIB53/libload.txt: -------------------------------------------------------------------------------- 1 | * libload R1.1 19/8/85 Load runtime library for FLEX9 6809 small-C compiler 2 | * copyright 1985 by Silicon Fen Software 3 | * 4 | IF LIBP printf library common to 6801 and 6809 5 | lib libp 6 | ENDIF 7 | * 8 | IF LIBC default library 9 | lib libc09 10 | ENDIF 11 | * 12 | IF LIBS stdio.h i/o library 13 | lib libs09 14 | ENDIF 15 | * 16 | IF LIBG plot.h graphics library 17 | lib libg09 18 | ENDIF 19 | * 20 | IF LIBH hardware.h hardware access library (unused) 21 | lib libh09 22 | ENDIF 23 | * 24 | IF LIBA ctype.h ascii tests and conversions library 25 | lib liba09 26 | ENDIF 27 | * end of libload9 28 | -------------------------------------------------------------------------------- /silifen/LIB53/libload1.txt: -------------------------------------------------------------------------------- 1 | * libload1 - Load runtime library for 6801 small-C compiler 2 | * 3 | * copyright July 1985 by Silicon Fen Software 4 | * 5 | * load library files 6 | * 7 | IF LIBP printf library 8 | lib libp same for 6809 and 6801 9 | ENDIF 10 | * 11 | IF LIBC default library 12 | lib libc01 13 | ENDIF 14 | * 15 | IF LIBS stdio.h file i/o library 16 | lib libs01 17 | ENDIF 18 | * 19 | IF LIBH hardware.h hardware access library 20 | lib libh01 21 | ENDIF 22 | * 23 | IF LIBA ctype.h ascii tests and conversions library 24 | lib liba01 25 | ENDIF 26 | * 27 | -------------------------------------------------------------------------------- /silifen/LIB53/libload9.txt: -------------------------------------------------------------------------------- 1 | * libload R1.1 19/8/85 Load runtime library for FLEX9 6809 small-C compiler 2 | * copyright 1985 by Silicon Fen Software 3 | * 4 | IF LIBP printf library common to 6801 and 6809 5 | lib libp 6 | ENDIF 7 | * 8 | IF LIBC default library 9 | lib libc09 10 | ENDIF 11 | * 12 | IF LIBS stdio.h i/o library 13 | lib libs09 14 | ENDIF 15 | * 16 | IF LIBG plot.h graphics library 17 | lib libg09 18 | ENDIF 19 | * 20 | IF LIBH hardware.h hardware access library (unused) 21 | lib libh09 22 | ENDIF 23 | * 24 | IF LIBA ctype.h ascii tests and conversions library 25 | lib liba09 26 | ENDIF 27 | * end of libload9 28 | -------------------------------------------------------------------------------- /silifen/LIB53/libm09.txt: -------------------------------------------------------------------------------- 1 | * libm09 R1.1b 16/11/85 - 6809 codegen macros 2 | * 3 | * Silicon Fen Software 6809 macro's for small-C compiler 4 | * 5 | POS_IND set 0 default not pos indep 6 | * 7 | * start a new function 8 | FUNC macro 9 | if CRASMB 10 | M_ARGS set 1 11 | else 12 | ifc &0,main 13 | if &1 14 | M_ARGS set 1 15 | else 16 | M_ARGS set 0 17 | endif 18 | endif 19 | endif 20 | endm 21 | 22 | * get a byte from a global variable 23 | GETB macro 24 | if POS_IND 25 | ldb &1,pcr 26 | else 27 | ldb &1 28 | endif 29 | sex 30 | endm 31 | 32 | * get a word from a global variable 33 | GETW macro 34 | if POS_IND 35 | ldd &1,pcr 36 | else 37 | ldd &1 38 | endif 39 | endm 40 | 41 | * get the address of a stack variable 42 | GETLOC macro 43 | leay &1,s 44 | tfr y,d 45 | endm 46 | 47 | * get the address of a global variable 48 | GETGLB macro 49 | if POS_IND 50 | leay &1,pcr 51 | tfr y,d 52 | else 53 | ldd #&1 54 | endif 55 | endm 56 | 57 | * store a byte in a global 58 | PUTB macro 59 | if POS_IND 60 | stb &1,pcr 61 | else 62 | stb &1 63 | endif 64 | endm 65 | 66 | * store a word in a global 67 | PUTW macro 68 | if POS_IND 69 | std &1,pcr 70 | else 71 | std &1 72 | endif 73 | endm 74 | 75 | * store byte at address on stack and pull 76 | PUTSB macro 77 | stb [,s++] 78 | endm 79 | 80 | * store word at address on stack and pull 81 | PUTSW macro 82 | std [,s++] 83 | endm 84 | 85 | * get byte from address in reg 86 | GETBI macro 87 | tfr d,y 88 | ldb ,y 89 | sex 90 | endm 91 | 92 | * get word indirect 93 | GETWI macro 94 | tfr d,y 95 | ldd ,y 96 | endm 97 | 98 | * push reg 99 | PUSH macro 100 | pshs a,b 101 | endm 102 | 103 | * swap TOS and reg 104 | SWAPS macro 105 | puls y 106 | PUSH 107 | tfr y,d 108 | endm 109 | 110 | * swap 1st and 2nd reg 111 | SWAP macro 112 | exg d,x 113 | endm 114 | 115 | * get word from global pointer 116 | GWWI macro 117 | if POS_IND 118 | ldd [&1,pcr] 119 | else 120 | ldd [&1] 121 | endif 122 | endm 123 | 124 | * get byte from global pointer 125 | GWBI macro 126 | if POS_IND 127 | ldb [&1,pcr] 128 | else 129 | ldb [&1] 130 | endif 131 | sex 132 | endm 133 | 134 | * get byte from stack 135 | GETBS macro 136 | ldb &1,s 137 | sex 138 | endm 139 | 140 | * put byte in stack 141 | PUTBS macro 142 | stb &1,s 143 | endm 144 | 145 | * get word from stack 146 | GETWS macro 147 | ldd &1,s 148 | endm 149 | 150 | * put word in stack 151 | PUTWS macro 152 | std &1,s 153 | endm 154 | 155 | * get word from pointer on stack 156 | GETWSI macro 157 | ldd [&1,s] 158 | endm 159 | 160 | * get byte from pointer on stack 161 | GETBSI macro 162 | ldb [&1,s] 163 | sex 164 | endm 165 | 166 | * check the name of a called fn 167 | CALLCHK macro 168 | ifc &1,&2 169 | ldd #&3 load arg count in bytes 170 | LIBP set 1 load printf library 171 | endif 172 | endm 173 | 174 | * call subroutine 175 | CALL macro 176 | CALLCHK &1,printf,&2 177 | if POS_IND 178 | lbsr &1 179 | else 180 | jsr &1 181 | endif 182 | endm 183 | 184 | * return 185 | RET macro 186 | rts 187 | endm 188 | 189 | * jump 190 | GOTO macro 191 | if POS_IND 192 | lbra &1 193 | else 194 | jmp &1 195 | endif 196 | endm 197 | 198 | * test and jump if zero 199 | TEST macro 200 | cmpd #0 201 | lbeq &1 202 | endm 203 | 204 | * jump if zero, assuming test is already in cc 205 | NTST macro 206 | lbeq &1 207 | endm 208 | 209 | * immediate load 210 | IMMED macro 211 | ldd #&1 212 | endm 213 | 214 | * call stack 215 | CALLS macro 216 | ldd #&1 always load arg count in bytes 217 | jsr [&1,s] 218 | endm 219 | 220 | * increment stack 221 | INCS macro 222 | leas &1,s 223 | endm 224 | 225 | * scale reg 226 | SCALE macro 227 | if &1=2 228 | aslb 229 | rola 230 | else 231 | asra 232 | rorb 233 | endif 234 | endm 235 | 236 | * add to stack 237 | ADDS macro 238 | addd ,s++ 239 | endm 240 | 241 | * sub from stack 242 | SUBS macro 243 | PUSH 244 | GETWS 2 245 | subd ,s++ 246 | INCS 2 247 | endm 248 | 249 | * mult stack by reg 250 | MULS macro 251 | CC_MUL SET 1 252 | PUSH 253 | CALL CCMUL 254 | INCS 4 255 | endm 256 | 257 | * divide ,s by reg 258 | DIVS macro 259 | CC_DIV SET 1 260 | PUSH 261 | CALL CCDIV 262 | INCS 4 263 | endm 264 | 265 | * modulus (remainder) of ,s divided by reg 266 | MODS macro 267 | CC_DIV SET 1 268 | PUSH 269 | CALL CCDIV 270 | INCS 4 271 | SWAP 272 | endm 273 | 274 | * or with stack 275 | ORS macro 276 | ora ,s+ 277 | orb ,s+ 278 | endm 279 | 280 | * exclusive or with stack 281 | EORS macro 282 | eora ,s+ 283 | eorb ,s+ 284 | endm 285 | 286 | * and with stack 287 | ANDS macro 288 | anda ,s+ 289 | andb ,s+ 290 | endm 291 | 292 | * shift right ,s by reg 293 | ASRS macro 294 | CC_ASR SET 1 295 | PUSH 296 | CALL CCASR 297 | INCS 4 298 | endm 299 | 300 | * shift left ,s by reg 301 | ASLS macro 302 | CC_ASL SET 1 303 | PUSH 304 | CALL CCASL 305 | INCS 4 306 | endm 307 | 308 | * increment reg 309 | INCD macro 310 | addd #&1 311 | endm 312 | 313 | * decrement reg 314 | DECD macro 315 | subd #&1 316 | endm 317 | 318 | * complement reg 319 | COMD macro 320 | coma 321 | comb 322 | endm 323 | 324 | * negate reg 325 | NEGD macro 326 | COMD 327 | INCD 1 328 | endm 329 | 330 | * test ,s against reg and set reg to 1 if true or 0 if false 331 | * problem with non commutative operators is that comparison is inverted 332 | CCTST macro 333 | cmpd ,s++ 334 | &1 *+5 335 | clrb 336 | bra *+4 337 | ldb #1 338 | sex this sets cc z flag correctly 339 | endm 340 | 341 | CCEQ macro 342 | CCTST beq 343 | endm 344 | 345 | CCNE macro 346 | CCTST bne 347 | endm 348 | 349 | CCLT macro 350 | CCTST bgt 351 | endm 352 | 353 | CCGT macro 354 | CCTST blt 355 | endm 356 | 357 | CCLE macro 358 | CCTST bge 359 | endm 360 | 361 | CCGE macro 362 | CCTST ble 363 | endm 364 | 365 | CCULT macro 366 | CCTST bhi 367 | endm 368 | 369 | CCULE macro 370 | CCTST bhs 371 | endm 372 | 373 | CCUGT macro 374 | CCTST blo 375 | endm 376 | 377 | CCUGE macro 378 | CCTST bls 379 | endm 380 | 381 | * declare code segment 382 | CSEG macro 383 | endm 384 | 385 | * declare literal segment 386 | LSEG macro 387 | endm 388 | 389 | * declare data segment 390 | DSEG macro 391 | endm 392 | 393 | * external function reference 394 | EXTF macro 395 | &2 SET 1 396 | endm 397 | 398 | * external variable reference 399 | EXTV macro 400 | endm 401 | 402 | * public reference 403 | PUB macro 404 | endm 405 | 406 | * end of libm 407 | -------------------------------------------------------------------------------- /silifen/LIB53/libp.txt: -------------------------------------------------------------------------------- 1 | * libp.txt R1.1 28/4/85 2 | * 3 | IF PRINTF 4 | * Silicon Fen Software - small-C compiler R1.0 5 | printf FUNC 1 6 | INCS -2-2-2-2-2-2-2-1-1-20-2-1-2 7 | std ,s save argument bytecount in i 8 | GETLOC 31 9 | PUSH 10 | GETLOC 45 11 | PUSH 12 | GETWS 4 13 | PUSH 14 | IMMED 2 15 | SUBS 16 | ADDS 17 | PUTSW 18 | GETLOC 29 19 | PUSH 20 | GETWSI 33 21 | PUTSW 22 | CCPF02 23 | GETLOC 26 24 | PUSH 25 | GETLOC 31 26 | PUSH 27 | GETWI 28 | INCD 1 29 | PUTSW 30 | DECD 1 31 | GETBI 32 | PUTSB 33 | TEST CCPF03 34 | GETBS 26 35 | PUSH 36 | IMMED 37 37 | CCNE 38 | NTST CCPF04 39 | GETBS 26 40 | PUSH 41 | CALL putchar,2 42 | INCS 2 43 | GOTO CCPF02 44 | CCPF04 45 | GETBSI 29 46 | PUSH 47 | IMMED 37 48 | CCEQ 49 | NTST CCPF05 50 | GETLOC 29 51 | PUSH 52 | GETWI 53 | INCD 1 54 | PUTSW 55 | DECD 1 56 | GETBI 57 | PUSH 58 | CALL putchar,2 59 | INCS 2 60 | GOTO CCPF02 61 | CCPF05 62 | GETLOC 27 63 | PUSH 64 | GETWS 31 65 | PUTSW 66 | GETBSI 27 67 | PUSH 68 | IMMED 45 69 | CCEQ 70 | NTST CCPF06 71 | GETLOC 25 72 | PUSH 73 | IMMED 0 74 | PUTSB 75 | GETLOC 27 76 | PUSH 77 | GETWI 78 | INCD 1 79 | PUTSW 80 | GOTO CCPF07 81 | CCPF06 82 | GETLOC 25 83 | PUSH 84 | IMMED 1 85 | PUTSB 86 | CCPF07 87 | GETBSI 27 88 | PUSH 89 | IMMED 48 90 | CCEQ 91 | NTST CCPF08 92 | GETLOC 2 93 | PUSH 94 | IMMED 48 95 | PUTSB 96 | GETLOC 27 97 | PUSH 98 | GETWI 99 | INCD 1 100 | PUTSW 101 | GOTO CCPF09 102 | CCPF08 103 | GETLOC 2 104 | PUSH 105 | IMMED 32 106 | PUTSB 107 | CCPF09 108 | GETLOC 37 109 | PUSH 110 | GETLOC 37 111 | PUSH 112 | GETLOC 43 113 | PUSH 114 | IMMED 0 115 | PUTSW 116 | PUTSW 117 | PUTSW 118 | GETLOC 27 119 | PUSH 120 | GETWS 29 121 | PUSH 122 | GETWS 31 123 | PUSH 124 | IMMED 8 125 | PUSH 126 | GETLOC 47 127 | PUSH 128 | IMMED 10 129 | PUSH 130 | CALL btoi,8 131 | INCS 8 132 | ADDS 133 | PUTSW 134 | GETLOC 39 135 | PUSH 136 | GETWS 41 137 | PUSH 138 | CALL abs,2 139 | INCS 2 140 | PUTSW 141 | GETBSI 27 142 | PUSH 143 | IMMED 46 144 | CCEQ 145 | NTST CCPF10 146 | GETLOC 35 147 | PUSH 148 | GETLOC 29 149 | PUSH 150 | GETWI 151 | INCD 1 152 | PUTSW 153 | PUSH 154 | IMMED 8 155 | PUSH 156 | GETLOC 43 157 | PUSH 158 | IMMED 10 159 | PUSH 160 | CALL btoi,8 161 | INCS 8 162 | PUTSW 163 | GETLOC 27 164 | PUSH 165 | GETWS 29 166 | PUSH 167 | GETWS 39 168 | ADDS 169 | PUTSW 170 | CCPF10 171 | GETLOC 37 172 | PUSH 173 | GETWS 39 174 | PUSH 175 | CALL abs,2 176 | INCS 2 177 | PUTSW 178 | GETLOC 3 179 | PUSH 180 | GETLOC 7 181 | PUTSW 182 | GETLOC 26 183 | PUSH 184 | GETLOC 29 185 | PUSH 186 | GETWI 187 | INCD 1 188 | PUTSW 189 | DECD 1 190 | GETBI 191 | PUTSB 192 | GETLOC 0 193 | PUSH 194 | GETLOC 33 195 | PUSH 196 | GETWI 197 | DECD 2 198 | PUTSW 199 | GETWI 200 | PUTSW 201 | GETBS 26 202 | PUSH 203 | IMMED 100 204 | CCEQ 205 | NTST CCPF11 206 | GETLOC 5 207 | PUSH 208 | GETLOC 7 209 | PUSH 210 | GETWS 4 211 | PUSH 212 | IMMED 10 213 | NEGD 214 | PUSH 215 | CALL itob,6 216 | INCS 6 217 | ADDS 218 | PUSH 219 | IMMED 0 220 | PUTSB 221 | GOTO CCPF12 222 | CCPF11 223 | GETBS 26 224 | PUSH 225 | IMMED 120 226 | CCEQ 227 | NTST CCPF13 228 | GETLOC 5 229 | PUSH 230 | GETLOC 7 231 | PUSH 232 | GETWS 4 233 | PUSH 234 | IMMED 16 235 | PUSH 236 | CALL itob,6 237 | INCS 6 238 | ADDS 239 | PUSH 240 | IMMED 0 241 | PUTSB 242 | GOTO CCPF14 243 | CCPF13 244 | GETBS 26 245 | PUSH 246 | IMMED 99 247 | CCEQ 248 | NTST CCPF15 249 | GETLOC 5 250 | PUSH 251 | IMMED 0 252 | ADDS 253 | PUSH 254 | GETWS 2 255 | PUTSB 256 | GETLOC 5 257 | PUSH 258 | IMMED 1 259 | ADDS 260 | PUSH 261 | IMMED 0 262 | PUTSB 263 | GOTO CCPF16 264 | CCPF15 265 | GETBS 26 266 | PUSH 267 | IMMED 115 268 | CCEQ 269 | NTST CCPF17 270 | GETLOC 3 271 | PUSH 272 | GETWS 2 273 | PUTSW 274 | GOTO CCPF18 275 | CCPF17 276 | GETBS 26 277 | PUSH 278 | IMMED 117 279 | CCEQ 280 | NTST CCPF19 281 | GETLOC 5 282 | PUSH 283 | GETLOC 7 284 | PUSH 285 | GETWS 4 286 | PUSH 287 | IMMED 10 288 | PUSH 289 | CALL itob,6 290 | INCS 6 291 | ADDS 292 | PUSH 293 | IMMED 0 294 | PUTSB 295 | GOTO CCPF20 296 | CCPF19 297 | GETBS 26 298 | PUSH 299 | CALL putchar,2 300 | INCS 2 301 | GOTO CCPF02 302 | CCPF20 303 | CCPF18 304 | CCPF16 305 | CCPF14 306 | CCPF12 307 | GETLOC 29 308 | PUSH 309 | GETWS 29 310 | PUTSW 311 | GETLOC 33 312 | PUSH 313 | GETWS 5 314 | PUSH 315 | CALL strlen,2 316 | INCS 2 317 | PUTSW 318 | GETBS 26 319 | PUSH 320 | IMMED 115 321 | CCEQ 322 | PUSH 323 | GETWS 35 324 | PUSH 325 | GETWS 41 326 | CCGT 327 | ANDS 328 | PUSH 329 | GETWS 37 330 | PUSH 331 | IMMED 0 332 | CCGT 333 | ANDS 334 | TEST CCPF21 335 | GETLOC 33 336 | PUSH 337 | GETWS 39 338 | PUTSW 339 | CCPF21 340 | GETBS 25 341 | TEST CCPF22 342 | CCPF23 343 | GETLOC 39 344 | PUSH 345 | GETWI 346 | DECD 1 347 | PUTSW 348 | INCD 1 349 | PUSH 350 | GETWS 35 351 | SUBS 352 | PUSH 353 | IMMED 0 354 | CCGT 355 | NTST CCPF24 356 | GETBS 2 357 | PUSH 358 | CALL putchar,2 359 | INCS 2 360 | GOTO CCPF23 361 | CCPF24 362 | CCPF22 363 | CCPF25 364 | GETWS 33 365 | TEST CCPF26 366 | GETLOC 3 367 | PUSH 368 | GETWI 369 | INCD 1 370 | PUTSW 371 | DECD 1 372 | GETBI 373 | PUSH 374 | CALL putchar,2 375 | INCS 2 376 | GETLOC 33 377 | PUSH 378 | GETWI 379 | DECD 1 380 | PUTSW 381 | GETLOC 39 382 | PUSH 383 | GETWI 384 | DECD 1 385 | PUTSW 386 | GOTO CCPF25 387 | CCPF26 388 | CCPF27 389 | GETLOC 39 390 | PUSH 391 | GETWI 392 | DECD 1 393 | PUTSW 394 | INCD 1 395 | PUSH 396 | GETWS 35 397 | SUBS 398 | PUSH 399 | IMMED 0 400 | CCGT 401 | NTST CCPF28 402 | GETBS 2 403 | PUSH 404 | CALL putchar,2 405 | INCS 2 406 | GOTO CCPF27 407 | CCPF28 408 | GOTO CCPF02 409 | CCPF03 410 | INCS 41 411 | RET 412 | EXTF putchar,PUTCHAR 413 | EXTF btoi,BTOI 414 | EXTF abs,ABS 415 | EXTF itob,ITOB 416 | EXTF strlen,STRLEN 417 | ENDIF 418 | -------------------------------------------------------------------------------- /silifen/LIB53/libs01.txt: -------------------------------------------------------------------------------- 1 | * libs01 R1.1 29/8/85 2 | * 3 | * Copyright Silicon Fen Software 1985 4 | * 5 | * This file is automatically loaded when stdio.h is used 6 | * 7 | * Unix compatible standard (not file) i/o functions 8 | * 9 | IF GETS 10 | * read a newline terminated string into s, replace the newline 11 | * with a null and return s. 12 | * char *gets(s) 13 | * char *s; 14 | gets tsx 15 | ldx 2,x 16 | pshx 17 | GETS1 jsr getchar 18 | cmpb #13 19 | beq GETS2 20 | pulx 21 | stab ,x 22 | inx 23 | pshx 24 | bra GETS1 25 | GETS2 pulx 26 | clr ,x 27 | tsx 28 | ldad 2,x 29 | rts 30 | ENDIF 31 | * 32 | IF PUTS 33 | * output string s, add a newline 34 | * puts(s) 35 | * char *s; 36 | puts tsx 37 | ldx 2,x 38 | clra 39 | PUTS1 ldb ,x 40 | beq PUTS2 41 | pshx 42 | pshd 43 | jsr putchar 44 | pulx 45 | pulx 46 | inx 47 | bra PUTS1 48 | PUTS2 ldb #13 49 | pshd 50 | jsr putchar 51 | pulx 52 | rts 53 | ENDIF 54 | * 55 | * output a character 56 | * putchar(c) 57 | * char c; 58 | putchar tsx 59 | ldaa 3,x 60 | cmpa #$D 61 | beq PUTCH1 62 | jsr PUTCHR 63 | rts 64 | PUTCH1 jsr PCRLF 65 | rts 66 | * 67 | * input a character 68 | * int getchar() 69 | getchar jsr GETCHR 70 | tab 71 | clra 72 | cmpb #4 control-D 73 | beq GETCH1 74 | rts 75 | GETCH1 ldad #-1 EOF 76 | rts 77 | * 78 | IF PUTDEC 79 | * output in decimal as in flex with f as space suppression flag 80 | * putdec(n,f) int n,f; 81 | putdec 82 | * CUSTOM ROUTINE FITS HERE 83 | err CUSTOM putdec NOT SUPPLIED 84 | rts 85 | ENDIF 86 | * 87 | if PUTHEX 88 | * output integer in hex 89 | *puthex(n) 90 | * int n; 91 | puthex FUNC 1 92 | INCS -1-2 93 | GETLOC 0 94 | PUSH 95 | IMMED 12 96 | PUTSW 97 | CCLS04 98 | GETWS 0 99 | PUSH 100 | IMMED 0 101 | CCGE 102 | NTST CCLS03 103 | GOTO CCLS05 104 | CCLS02 105 | GETLOC 0 106 | PUSH 107 | GETWS 2 108 | PUSH 109 | IMMED 4 110 | SUBS 111 | PUTSW 112 | GOTO CCLS04 113 | CCLS05 114 | GETLOC 2 115 | PUSH 116 | GETWS 7 117 | PUSH 118 | GETWS 4 119 | ASRS 120 | PUSH 121 | IMMED 15 122 | ANDS 123 | PUTSB 124 | PUSH 125 | IMMED 9 126 | CCGT 127 | NTST CCLS06 128 | GETBS 2 129 | PUSH 130 | IMMED 10 131 | SUBS 132 | PUSH 133 | IMMED 65 134 | ADDS 135 | PUSH 136 | CALL putchar,2 137 | INCS 2 138 | GOTO CCLS07 139 | CCLS06 140 | GETBS 2 141 | PUSH 142 | IMMED 48 143 | ADDS 144 | PUSH 145 | CALL putchar,2 146 | INCS 2 147 | CCLS07 148 | GOTO CCLS02 149 | CCLS03 150 | INCS 3 151 | RET 152 | endif 153 | * 154 | * simulated file routines for use with stdin and stdout only 155 | * 156 | IF FGETC|FGETS 157 | * get a character from a file, return EOF (integer -1) if fail 158 | * 6801 version only works with stdin 159 | * int fgetc(stream) 160 | * FILE *stream; 161 | fgetc tsx 162 | ldad 2,x 163 | cmpd #1 stdin 164 | bne FGETC1 165 | jsr getchar 166 | rts 167 | FGETC1 168 | ldad #-1 169 | rts 170 | ENDIF 171 | * 172 | IF FRDCHK 173 | * return 1 if a char can be read from the stream else 0 or EOF on error 174 | * 6801 version only works with stdin, stdout 175 | * int frdchk(stream) 176 | * FILE *stream; 177 | frdchk tsx 178 | ldad 2,x 179 | cmpd #1 stdin 180 | beq FRDCH1 181 | ldad #-1 EOF for anything else 182 | rts 183 | FRDCH1 jsr STAT 184 | beq FRDCH3 185 | ldad #1 char ready 186 | rts 187 | FRDCH3 ldd #0 no char 188 | rts 189 | endif 190 | * 191 | IF FPUTC|FPUTS 192 | * put a character in a file, return the character or EOF if error 193 | * 6801 version only works for stdout 194 | * int fputc(c,stream) 195 | * char c; 196 | * FILE *stream; 197 | fputc tsx 198 | ldad 2,x 199 | cmpd #2 200 | bne FPUTC1 201 | ldad 4,x 202 | pshd 203 | jsr putchar 204 | ins 205 | ins 206 | tsx 207 | ldad 4,x 208 | rts 209 | FPUTC1 ldad #-1 210 | rts 211 | ENDIF 212 | * 213 | if FGETS 214 | * get up to n-1 chars into s. return s if ok. return NULL if problems. 215 | * stop on newline and put newline in s. 6801 stdin only 216 | *fgets(s,n,stream) 217 | * char *s; 218 | * int n; 219 | * FILE *stream; 220 | fgets FUNC 3 221 | INCS -2-2 222 | GETLOC 0 223 | PUSH 224 | GETWS 12 225 | PUTSW 226 | GETWS 6 227 | PUSH 228 | IMMED 1 229 | CCNE 230 | NTST CCLS08 231 | IMMED 0 232 | INCS 4 233 | RET 234 | CCLS08 235 | CCLS09 236 | GETLOC 8 237 | PUSH 238 | GETWI 239 | DECD 1 240 | PUTSW 241 | PUSH 242 | IMMED 0 243 | CCGT 244 | NTST CCLS10 245 | GETLOC 2 246 | PUSH 247 | GETWS 8 248 | PUSH 249 | CALL fgetc,2 250 | INCS 2 251 | PUTSW 252 | PUSH 253 | IMMED 1 254 | NEGD 255 | CCEQ 256 | NTST CCLS11 257 | IMMED 0 258 | INCS 4 259 | RET 260 | CCLS11 261 | GETLOC 0 262 | PUSH 263 | GETWI 264 | INCD 1 265 | PUTSW 266 | DECD 1 267 | PUSH 268 | GETWS 4 269 | PUTSB 270 | PUSH 271 | IMMED 13 272 | CCEQ 273 | NTST CCLS12 274 | GOTO CCLS10 275 | CCLS12 276 | GOTO CCLS09 277 | CCLS10 278 | GETWS 0 279 | PUSH 280 | IMMED 0 281 | PUTSB 282 | GETWS 10 283 | INCS 4 284 | RET 285 | endif 286 | * 287 | IF FPUTS 288 | * output a string to a stream 289 | * fputs(s,stream) 290 | * char *s; 291 | * FILE *stream; 292 | fputs tsx 293 | ldx 4,x 294 | pshx 295 | FPUTS1 pulx 296 | clra 297 | ldab ,x 298 | beq FPUTS2 299 | bpl FPUTS3 300 | coma 301 | FPUTS3 inx 302 | pshx 303 | pshd 304 | tsx 305 | ldad 6,x 306 | pshd 307 | jsr fputc 308 | ins 309 | ins 310 | ins 311 | ins 312 | cmpd #-1 313 | bne FPUTS1 314 | pulx 315 | FPUTS2 rts 316 | ENDIF 317 | * end of libs01 318 | -------------------------------------------------------------------------------- /silifen/LIB53/libs09.txt: -------------------------------------------------------------------------------- 1 | * libs.txt R1.0 24/3/85 2 | * fopen for update bug fixed R1.1 12/6/88 3 | * Copyright Silicon Fen Software July 1984 4 | * 5 | * This file is automatically loaded when stdio.h is used 6 | * 7 | * Unix compatable standard (not file) i/o functions 8 | * 9 | IF GETS 10 | * read a newline terminated string into s, replace the newline 11 | * with a null and return s. 12 | * char *gets(s) 13 | * char *s; 14 | gets jsr INBUFF 15 | ldd #LINBUF 16 | pshs a,b 17 | ldb #13 18 | sex 19 | pshs a,b 20 | lbsr index 21 | leas 4,s 22 | tfr d,x 23 | clr ,x 24 | ldd 2,s 25 | pshs a,b 26 | ldd #LINBUF 27 | pshs a,b 28 | lbsr strcpy 29 | leas 4,s 30 | rts 31 | ENDIF 32 | * 33 | IF PUTS 34 | * output string s, redirectable but allows use of escape to 35 | * halt output and return to abort program. 36 | * puts(s) 37 | * char *s; 38 | puts ldx 2,s 39 | PUTS1 lda ,x+ 40 | beq PUTS2 41 | jsr PUTCHR 42 | bra PUTS1 43 | PUTS2 jsr PCRLF 44 | rts 45 | ENDIF 46 | * 47 | * output a character 48 | * putchar(c) 49 | * char c; 50 | putchar lda 3,s 51 | cmpa #$D 52 | beq PUTCH1 53 | jsr PUTCHR 54 | rts 55 | PUTCH1 jsr PCRLF 56 | rts 57 | * 58 | * input a character 59 | * int getchar() 60 | getchar jsr GETCHR 61 | tfr a,b 62 | clra 63 | cmpb #4 control-D 64 | beq GETCH1 65 | rts 66 | GETCH1 ldd #-1 EOF 67 | rts 68 | * 69 | IF PERROR 70 | * print a string to the error stream - not redirectable 71 | * perror(s) 72 | * char *s; 73 | perror lda #$D 74 | jsr OUTCH2 75 | lda #$A 76 | jsr OUTCH2 77 | ldy 2,s 78 | PERR1 lda ,y+ 79 | beq PERR2 80 | jsr OUTCH2 81 | bra PERR1 82 | PERR2 lda #$D 83 | jsr OUTCH2 84 | lda #$A 85 | jsr OUTCH2 86 | rts 87 | ENDIF 88 | * 89 | IF PUTDEC 90 | * output in decimal via flex with f as space suppression flag 91 | * putdec(n,f) int n,f; 92 | putdec ldd 2,s 93 | leax 4,s 94 | jsr $CD39 95 | rts 96 | ENDIF 97 | * 98 | IF PUTHEX 99 | * output in hex via flex 100 | * puthex(n) int n; 101 | puthex leax 2,s 102 | jsr $CD45 103 | rts 104 | ENDIF 105 | * 106 | * file i/o routines 107 | * 108 | IF FOPEN 109 | * open file 110 | * first find an fcb 111 | * FILE *findfcb() 112 | findfcb ldx #end+28 113 | FINDF2 ldy #FMSBASE 114 | FINDF3 cmpx ,y 115 | beq FINDF4 116 | ldy ,y 117 | bne FINDF3 118 | leax -28,x 119 | tfr x,d 120 | rts 121 | FINDF4 leax 320,x 122 | bra FINDF2 123 | * 124 | * FILE *fopen(name,type) - return 0 if can't open 125 | * char *name,*type; type = "r" read, "w" write, "u" update 126 | * type = "rb" binary read etc 127 | CONSDEV fcc "console.dev",0 128 | fopen ldd 4,s 129 | pshs a,b 130 | ldd #CONSDEV 131 | pshs a,b 132 | jsr strcmp 133 | leas 4,s 134 | bne FOPE7 135 | ldb [2,s] 136 | cmpb #'w 137 | bne FOPE6 138 | ldd #2 stdout 139 | rts 140 | FOPE6 cmpb #'r 141 | bne FOPE5 142 | ldd #1 stdin 143 | rts 144 | FOPE5 ldd #0 145 | rts 146 | FOPE7 jsr findfcb 147 | pshs a,b 148 | * *index( LINPTR=strcpy(LINBUF,name), 0 ) = '\n'; !! 149 | * loop back to this point if deleting existing file 150 | * because delete destroys the filename in the FCB. 151 | FOPE8 ldd #LINBUF strcpy(LINBUF,name) 152 | pshs a,b 153 | ldd 8,s 154 | pshs a,b 155 | jsr strcpy 156 | leas 4,s 157 | std LINPTR 158 | pshs a,b 159 | ldd #0 160 | pshs a,b 161 | jsr index 162 | leas 4,s 163 | pshs a,b 164 | ldb #$D 165 | stb [,s++] 166 | ldx ,s 167 | jsr GETFIL 168 | bcs FOPE99 169 | lda #1 170 | jsr SETEXT 171 | ldy 4,s 172 | ldb ,y 173 | cmpb #'r 174 | bne FOPE1 175 | lda #1 176 | sta ,x 177 | jsr FMS 178 | bne FOPE99 179 | bra FOPE9 180 | FOPE1 cmpb #'u 181 | bne FOPE2 182 | lda #3 183 | sta ,x 184 | jsr FMS 185 | bne FOPE99 186 | bra FOPE9 187 | FOPE2 cmpb #'w 188 | bne FOPE99 189 | lda #2 190 | sta ,x 191 | jsr FMS 192 | beq FOPE9 193 | lda 1,x 194 | cmpa #3 195 | bne FOPE99 196 | lda #12 197 | sta ,x 198 | jsr FMS 199 | bne FOPE99 200 | bra FOPE8 201 | FOPE99 clra 202 | clrb 203 | leas 2,s 204 | rts 205 | FOPE9 ldb 1,y 206 | cmpb #'b 207 | bne FOPE91 208 | lda #$FF 209 | sta 59,x 210 | FOPE91 puls a,b 211 | rts 212 | ENDIF 213 | * 214 | * 215 | IF FCLOSE 216 | * close a file 217 | * fclose(stream) 218 | * FILE *stream; 219 | fclose ldx 2,s 220 | cmpx #3 221 | bls FCLO1 222 | lda #4 223 | sta ,x 224 | jsr FMS 225 | FCLO1 rts 226 | ENDIF 227 | * 228 | IF FEOF 229 | * return true (non-zero) if end of file on stream 230 | * int feof(stream) 231 | * FILE *stream; 232 | feof ldx 2,s 233 | cmpx #3 234 | bls FEOF1 235 | lda 1,x 236 | cmpa #8 237 | bne FEOF1 238 | ldd #1 239 | rts 240 | FEOF1 ldd #0 241 | rts 242 | ENDIF 243 | * 244 | IF FERROR 245 | * return the error code for a stream 246 | * int ferror(stream) 247 | * FILE *stream; 248 | ferror ldx 2,s 249 | cmpx #3 250 | bls FERR1 251 | ldb 1,x 252 | sex 253 | rts 254 | FERR1 ldd #0 255 | rts 256 | ENDIF 257 | * 258 | IF CLEARERR 259 | * clear the error code on a stream 260 | * clearerr(stream) 261 | * FILE *stream; 262 | clearerr ldx 2,s 263 | cmpx #3 264 | bls CLER1 265 | clr 1,x 266 | CLER1 rts 267 | ENDIF 268 | * 269 | IF REWIND 270 | * rewind a stream that is open for read (FLEX restriction) 271 | * rewind(stream) 272 | * FILE *stream; 273 | rewind ldx 2,s 274 | cmpx #3 275 | bls REWI1 276 | lda #5 277 | sta ,x 278 | jsr FMS 279 | REWI1 rts 280 | ENDIF 281 | * 282 | IF FGETC|FGETS 283 | * get a character from a file, return EOF (integer -1) if fail 284 | * int fgetc(stream) 285 | * FILE *stream; 286 | fgetc ldx 2,s 287 | cmpx #3 288 | bhi FGETC2 289 | cmpx #1 stdin 290 | bne FGETC1 291 | jsr getchar 292 | rts 293 | FGETC2 lda 2,x 294 | cmpa #1 295 | bne FGETC1 296 | clr ,x 297 | jsr FMS 298 | bne FGETC1 299 | tfr a,b 300 | sex 301 | rts 302 | FGETC1 ldd #-1 303 | rts 304 | ENDIF 305 | * 306 | IF FRDCHK 307 | * return 1 if a char can be read from the stream else 0 308 | * int frdchk(stream) 309 | * FILE *stream; 310 | frdchk ldx 2,s 311 | cmpx #1 stdin 312 | beq FRDCH1 313 | cmpx #3 314 | bhi FRDCH2 315 | FRDCH4 ldd #-1 EOF for output file 316 | rts 317 | FRDCH1 jsr STAT 318 | beq FRDCH3 319 | ldd #1 char ready 320 | rts 321 | FRDCH3 ldd #0 no char 322 | rts 323 | FRDCH2 lda #1 read? 324 | cmpa 2,x 325 | bne FRDCH4 326 | tst 1,x error? 327 | bne FRDCH4 328 | ldd #1 329 | rts 330 | endif 331 | * 332 | IF FPUTC|FPUTS 333 | * put a character in a file, return the character or EOF if error 334 | * int fputc(c,stream) 335 | * char c; 336 | * FILE *stream; 337 | fputc ldx 2,s get FCB 338 | cmpx #3 339 | bhi FPUTC2 340 | beq FPUTC3 341 | cmpx #2 342 | bne FPUTC1 343 | ldd 4,s 344 | pshs a,b 345 | jsr putchar 346 | leas 2,s 347 | ldd 4,s 348 | rts 349 | FPUTC3 lda 5,s 350 | jsr OUTCH2 351 | cmpa #$D 352 | bne FPUTC4 353 | lda #$A 354 | jsr OUTCH2 355 | FPUTC4 356 | ldd 4,s 357 | rts 358 | FPUTC2 lda 2,x 359 | cmpa #2 360 | bne FPUTC1 361 | lda 5,s 362 | jsr FMS 363 | bne FPUTC1 364 | ldd 4,s 365 | rts 366 | FPUTC1 ldd #-1 367 | rts 368 | ENDIF 369 | * 370 | IF FGETS 371 | * char *fgets(s,n,stream) 372 | * char *s; 373 | * int n; 374 | * FILE *stream; 375 | fgets ldd 6,s 376 | pshs a,b 377 | FGETS3 ldd 6,s 378 | subd #1 379 | std 6,s 380 | beq FGETS1 381 | ldd 4,s 382 | pshs a,b 383 | jsr fgetc 384 | leas 2,s 385 | ldy 8,s 386 | stb ,y 387 | cmpd #-1 388 | bne FGETS2 389 | clr ,y 390 | ldd #0 391 | leas 2,s 392 | rts 393 | FGETS2 ldb ,y+ 394 | sty 8,s 395 | cmpb #$D end of line 396 | bne FGETS3 397 | FGETS1 ldy 8,s 398 | clr ,y 399 | puls a,b 400 | rts 401 | ENDIF 402 | * 403 | IF FPUTS 404 | * output a string to a stream 405 | * fputs(s,stream) 406 | * char *s; 407 | * FILE *stream; 408 | fputs 409 | FPUTS1 ldx 4,s 410 | ldb ,x+ 411 | beq FPUTS2 412 | sex 413 | pshs a,b 414 | stx 6,s 415 | ldd 4,s 416 | pshs a,b 417 | jsr fputc 418 | leas 4,s 419 | cmpd #-1 420 | bne FPUTS1 421 | FPUTS2 rts 422 | ENDIF 423 | -------------------------------------------------------------------------------- /silifen/LIB53/stdio.h: -------------------------------------------------------------------------------- 1 | /* standard i/o header file for small-C with FLEX-9 */ 2 | /* Silicon Fen Software August 1984 */ 3 | /* get FILE i/o routines for assembler */ 4 | #asm 5 | LIBS SET 1 6 | #endasm 7 | #define stdin 1 8 | #define stdout 2 9 | #define stderr 3 10 | #define putc fputc 11 | #define getc fgetc 12 | #define YES 1 13 | #define NO 0 14 | #define NULL 0 15 | #define BUFSIZE 256 16 | #define EOF -1 17 | /* EOL = cr for FLEX lf for unix */ 18 | #define EOL 13 19 | #define BYTMASK 255 20 | #define FILE char 21 | #define extern 22 | -------------------------------------------------------------------------------- /silifen/LIB54/grep.c: -------------------------------------------------------------------------------- 1 | /* grep.c - print lines from a file that contain a pattern */ 2 | 3 | #include "stdio.h" 4 | 5 | char buf[132], *str, *p; 6 | 7 | main(argc,argv) 8 | int argc; 9 | char *argv[]; 10 | { 11 | FILE *input,*output; 12 | if (argc<3) 13 | perror("useage: grep pattern infile [outfile]"); 14 | else 15 | { 16 | if (argc > 3) 17 | { 18 | if ((output=fopen(argv[3],"w"))==0) 19 | { 20 | perror("can't open output file"); 21 | exit(1); 22 | } 23 | } 24 | else 25 | { 26 | output = stdout; 27 | putchar(EOL); 28 | } 29 | if ((input=fopen(argv[2],"r"))==0) 30 | { 31 | perror("can't open input file"); 32 | exit(1); 33 | } 34 | p = argv[1]; 35 | while(fgets(buf,132,input)) 36 | { 37 | str = buf; 38 | while(str=index(str,*p)) 39 | { 40 | if (strncmp(str,p,strlen(p))==0) 41 | fputs(buf,output); 42 | ++str; 43 | } 44 | } 45 | } 46 | fclose(input); 47 | if (output != stdout) 48 | fclose(output); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /silifen/LIB54/grep.cmd: -------------------------------------------------------------------------------- 1 | 2|h4._ ' 2 | M42b~h4-_ 'N1 4h4XI4s42d4'_ 'u42b42b~1 4 3 | 4r2b1b 4h4XI442d4'_ '42b42bf4XI*44f42f'm((4*4[2d('I(4*@4*4N2b42f4'_ '4b422d((~b42b4&_ ' 42b2d9+01r4 $o 2b1Z&04 4 | 4{w2do0g 'm'4O 4G2d'- &o m'XI1' 404~b~db-. &_999fdb/b- M&999db&d9bm&0b9db'm&99c 5 | '9$9O'99 6 | 7 | b' 8 | 9 | 9H '&090@ console.devd442d&w&9r&9944h4@2d44[2d4 10 | -%D3dr&<&- 0u& &w&'&& O_2b9!b&;59b#9b" &9&o&99b"$'&-d4r2bd9e 11 | & 12 | d9& 13 | e&d99f4ff'%d42bh&o2b9h 14 | &ho59d'4fd42d&9useage: grep pattern infile [outfile]wcan't open% output filercan't open input file -------------------------------------------------------------------------------- /silifen/LIB54/opt.c: -------------------------------------------------------------------------------- 1 | /* optimiser for small-C */ 2 | /* macro version 12/7/84 */ 3 | /* uppercase macros 22/8/84 R0.1 */ 4 | /* multiple INCS 17/1/85 R0.3 */ 5 | /* "getw" to "getw " so that it doesnt match getwi by mistake R0.4 */ 6 | /* NTEST from CCEQ, TEST etc R1.0 28/5/85 */ 7 | /* bug in CC?? TEST fixed R1.1 3/7/85 */ 8 | 9 | /* transformations : 10 | getloc n = getws n use ldd n,s 11 | getwi 12 | 13 | getloc n = getbs n use ldb n,s 14 | getbi sex 15 | 16 | getloc n = getwsi n use ldd [n,s] 17 | getwi 18 | getwi 19 | 20 | getloc n = getbsi n use ldb [n,s] 21 | getwi sex 22 | getbi 23 | 24 | getw label = gwwi label use ldd [label] 25 | getwi 26 | 27 | getw label = gwbi label use ldb [label] 28 | getbi sex 29 | 30 | INCS n = INCS n+m+... use single leas n,s 31 | INCS m ... 32 | 33 | CCEQ = CCEQ use result in cc rather than cmpd 34 | TEST label NTEST label 35 | */ 36 | 37 | #include "stdio.h" 38 | 39 | #define LINELEN 132 40 | 41 | char line[LINELEN], save[LINELEN], save2[LINELEN], save3[LINELEN]; 42 | int i; 43 | char *match1,*match2,*match3,*match4,*match5,*match6,*matchcc,*matchtst; 44 | 45 | #define LENMAT1 7 46 | #define LENMAT2 6 47 | #define LENMAT3 6 48 | #define LENMAT4 6 49 | #define LENMAT5 5 50 | #define LENMAT6 5 51 | #define LENMATCC 3 52 | #define LENMATTST 5 53 | 54 | main(argc,argv) 55 | int argc; 56 | char *argv[]; 57 | { 58 | FILE *input,*output; 59 | match1 = " GETLOC"; 60 | match2 = " GETWI"; 61 | match3 = " GETBI"; 62 | match4 = " GETW "; 63 | match5 = " PUSH"; 64 | match6 = " INCS"; 65 | matchcc = " CC"; 66 | matchtst = " TEST "; 67 | /* open files specified on command line */ 68 | if (argc < 2 ) 69 | { /* not enough arguments */ 70 | perror("Optimiser R1.1 3/7/85 useage: opt infile [outfile]"); 71 | exit(1); 72 | } 73 | else 74 | { 75 | if ((input=fopen(argv[1],"r")) == 0) 76 | { 77 | perror("can't open input file"); 78 | exit(1); 79 | } 80 | if (argc == 2) 81 | output = stdout; /* output to screen */ 82 | else 83 | { 84 | if ((output=fopen(argv[2],"w")) == 0) 85 | { 86 | perror("can't open output file"); 87 | exit(1); 88 | } 89 | } 90 | } 91 | /* process input file a line at a time */ 92 | while( fgets(line,LINELEN,input) ) /* read till end of file */ 93 | { 94 | if ( strncmp( line, match6, LENMAT6 ) == 0 ) 95 | { /* matched an INCS */ 96 | strcpy( save, line); 97 | fgets( line, LINELEN, input ); 98 | while( strncmp( line, match6, LENMAT6 ) == 0 ) 99 | { /* keep accumulating INCS n's onto save */ 100 | save[strlen(save)-1] = NULL; /* remove return */ 101 | if ( line[6] == '-' ) 102 | strcat( save, line+6 ); /* copy number and - */ 103 | else 104 | { 105 | strcat( save, "+" ); /* need a plus */ 106 | strcat( save, line+6 ); /* and number */ 107 | } 108 | fgets( line, LINELEN, input ); /* get another line */ 109 | } 110 | fputs( save, output ); /* output INCS n+m+k-j... */ 111 | } /* leave line for other matches */ 112 | if( strncmp( line, match1, LENMAT1 ) == 0 ) 113 | { /* it matched a getloc */ 114 | strcpy( save, line ); 115 | fgets(line,LINELEN,input); 116 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) 117 | { /* it matched getloc, getwi */ 118 | /* can junk line so */ 119 | fgets(line,LINELEN,input); 120 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) 121 | { /* matched getloc,getwi,getwi */ 122 | /* edit getloc -> getwsi */ 123 | save[4] = 'W'; 124 | save[5] = 'S'; 125 | save[6] = 'I'; 126 | fputs(save,output); 127 | continue; 128 | } 129 | else if ( strncmp( line, match3, LENMAT3 ) == 0 ) 130 | { /* matched getloc,getwi,getbi */ 131 | /* edit getloc -> getbsi */ 132 | save[4] = 'B'; 133 | save[5] = 'S'; 134 | save[6] = 'I'; 135 | fputs(save,output); 136 | continue; 137 | } 138 | else /* no extra match */ 139 | { 140 | /* edit saved line */ 141 | save[4] = 'W'; /* getloc -> getws */ 142 | save[5] = 'S'; 143 | save[6] = ' '; 144 | fputs( save, output ); 145 | } 146 | } 147 | else if ( strncmp( line, match3, LENMAT3 ) == 0 ) 148 | { /* it matched getloc, getbi */ 149 | /* edit saved line */ 150 | save[4] = 'B'; /* getloc -> getbs */ 151 | save[5] = 'S'; 152 | save[6] = ' '; 153 | fputs( save ,output); 154 | continue; /* try another line */ 155 | } 156 | else /* second line didnt match so */ 157 | fputs( save ,output); 158 | } 159 | else if ( strncmp( line, match4, LENMAT4 ) == 0 ) 160 | { /* it matched a getw */ 161 | strcpy( save, line ); 162 | fgets(line,LINELEN,input); 163 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) 164 | { /* it matched getw, getwi */ 165 | /* edit getw -> gwwi */ 166 | save[2] = 'W'; 167 | save[3] = 'W'; 168 | save[4] = 'I'; 169 | fputs(save,output); 170 | continue; 171 | } 172 | if ( strncmp( line, match3, LENMAT3 ) == 0 ) 173 | { /* matched getw, getbi */ 174 | /* edit getw -> gwbi */ 175 | save[2] = 'W'; 176 | save[3] = 'B'; 177 | save[4] = 'I'; 178 | fputs(save,output); 179 | continue; 180 | } 181 | /* second line didnt match so */ 182 | fputs( save ,output); 183 | } 184 | if ( strncmp( line, matchcc, LENMATCC ) == 0 ) 185 | { /* matched " CC??" */ 186 | fputs( line, output ); /* keep CC?? */ 187 | fgets( line, LINELEN, input ); /* get next line */ 188 | if ( strncmp( line, matchtst, LENMATTST ) == 0 ) 189 | { /* matched TEST */ 190 | line[1] = 'N'; /* TEST to NTST */ 191 | line[2] = 'T'; 192 | } 193 | fputs( line, output ); /* save result, modified or not */ 194 | } 195 | else 196 | fputs( line ,output); /* no matches at all */ 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /silifen/LIB54/opt.cmd: -------------------------------------------------------------------------------- 1 | 2| 2 | 3 | ( 4 | / 5 | 6 6 | = 7 | C 8 | I 9 | Mh4._ ' 10 | T4q2b42b~1b 4h4XI4 11 | 42d4'_ ' 12 | 4q2b42bh4'_ '1 4~1 4h4XI4 13 | 42d4'_ ' 14 | 4q2b42b 15 | 44f4 2f'( 16 | 4442f4'_ '>4 17 | 42d 18 | 44f4 2f 19 | 4442f4'_ '>4>42b44b2b4 20 | 44-'_ '>4 21 | 442d~,>4 22 | 42d>4 23 | 442d 24 | 44f4 2f~~>4b4L 25 | 2d 26 | 4442f4'_ '>4 27 | 42d 28 | 44f4 2f 29 | 4442f4'_ '5 30 | 44f4 2f 31 | 4442f4'_ 'G>44W>44S>44I>4b4 32 | 2d~~ 33 | 4442f4'_ 'G>44B>44S>44I>4b4 34 | 2d~~>44W>44S>44 >4b4 35 | 2d~t 36 | 4442f4'_ 'G>44B>44S>44 >4b4 37 | 2d~~t>4b4 38 | 2d~ 39 | 4442f4'_ '>4 40 | 42d 41 | 44f4 2f 42 | 4442f4'_ 'D>44W>44W>44I>4b4 43 | 2d~ 44 | 4442f4'_ 'D>4\4W>44B>44I>4b4 45 | 2d~>4b4 46 | 2d 47 | 4442f4'_ '| 48 | 4b4 49 | 2d 50 | 44f4 2f 51 | 4442f4'_ '" 52 | 4 4N 53 | 44T 54 | 4b4 55 | 2d~Y 56 | 4b4 57 | 2d~2d9+0S44"42f1Z&04 58 | 42do0g 'm'4O 4`2d'- &o m'XI1*' 404~b~d4_2bd4d4D2dd9db-. &_999fdb/b- M&999db&d9bm&0b9db'm&99fb4hg$ 2bf9c 59 | '9$9O'99r 60 | 61 | b' 62 | 63 | 9 '&090@ console.devd442d&w&9r&9944h42d44&2d4 64 | -%D3dr&&- 0u& & w&'&& O_2b9!b&;59b" &b9&o&99b"$'&-d4T2bd9e 65 | & 66 | d9& 67 | e&d99f4ff'%d4 2bh&o2b9h 68 | &ho59d'4fd4 2d&9 GETLOC GETWI GETBI GETW PUSH INCS CC TEST Optimiser R1.1 3/7/85 useage: opt infile [outfile]rcan't open input filewcan't open output file+_ -------------------------------------------------------------------------------- /silifen/LIB54/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Notes for use of CRASMB with SFS small-C R1.1b 4 | ---------------------------------------------- 5 | 6 | For 6809 use to generate a FLEX command. 7 | 8 | Make sure that LIBDEF09.TXT has CRASMB set 1 in it. 9 | 10 | +++exec goto9 11 | 12 | +++cc sieve.c -o sieve.m -d normal useage 13 | 14 | +++opt sieve.m sieve.om normal useage 15 | 16 | +++crasmb sieve.om,sieve.cmd,i6809+ls 17 | 18 | +++sieve 19 | 20 | 21 | See Manual Appendix B for details of 6801 code generation, this 22 | appendix does not cover CRASMB use, it assumes Compusense XASM6801. 23 | 24 | To generate 6801 code but assemble into 6809 FLEX command for testing. 25 | 26 | Make sure that LIBDEF91.TXT has CRASMB set 1 in it. 27 | 28 | +++exec goto91 29 | 30 | If sieve.om is still around from 6809 use then it can be used, 31 | otherwise make it as above. 32 | 33 | +++cc sieve.c -o sieve.m -d no difference from 6809 34 | 35 | +++opt sieve.om sieve.cmd no difference from 6809 36 | 37 | +++crasmb sieve.om,sieve91.cmd,i6809+ls 38 | 39 | +++sieve91 40 | 41 | The above version of sieve, sieve91, uses 6801 assembly language 42 | definitions of the macro's used to generate code but the 6809 43 | assembler turns these into a subset of the 6809 instruction set. 44 | The code is larger and slower than pure 6809 and is a bit larger 45 | and slower than it would be on a real 6801. 46 | 47 | 48 | To generate code for a 6801/6811/6301 49 | 50 | Make sure that LIBDEF01.TXT has CRASMB set 1 in it. 51 | 52 | Check that LIBM01.TXT has the processor type set up. One of 53 | M6801, M6811 or H6301 should be SET 1. 54 | 55 | Check that LIBF01.TXT has the correct memory map set up using 56 | CCODE, CDATA and CSTACK for the target system. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | The program starts at the label START in LIBC01.TXT, this needs 73 | to be jumped to in some way on the target system. To set up the 74 | reset vector the CSEG macro in LIBM01.TXT could be changed to: 75 | 76 | CSEG macro 77 | org $FFFE 78 | fdb START 79 | org CCODE 80 | endm 81 | 82 | Terminal I/O primitives need to be put into LIBH.TXT 83 | if any character based I/O is required. Any other hardware 84 | access routines can be placed in LIBH.TXT. A C header file 85 | is provided, HARDWARE.H and this should be #included or 86 | compiled in with the program otherwise LIBH.TXT will not 87 | be loaded in by the assembler. Alternatively LIBLOAD1.TXT could 88 | be modified to always load LIBH.TXT. 89 | 90 | 91 | Finally - 92 | 93 | +++exec goto1 94 | 95 | If the .om file is note left over from above then recompile, 96 | there is no change as far as the compiler is concerned for 6801. 97 | 98 | +++cc sieve.c -o sieve.m -d normal compile 99 | 100 | +++opt sieve.m sieve.om normal opt 101 | 102 | +++crasmb sieve.om,sieve1.bin,i6801+ls (or use i6811,i6301 as required) 103 | 104 | Then get sieve1.bin into the target processor somehow. 105 | 106 | 107 | A word of warning 108 | ----------------- 109 | This compiler is tested and believed bug free for 6809 use, the 6801 110 | use has been tested using a 6809 and has been assembled into 6801 binaries 111 | successfully. The 6801 binaries have never been tested on a real 6801 112 | (to the authors knowledge) although some users have had the 6801 product 113 | since september 1985 and have not complained yet. Please report problems 114 | to 115 | 116 | Silicon Fen Software 117 | 39, Mason Road, 118 | Burwell, 119 | Cambs, 120 | CB5 OBG 121 | 122 | -------------------------------------------------------------------------------- /silifen/LIB54/sieve.c: -------------------------------------------------------------------------------- 1 | /* eratosthenes sieve benchmark, Silicon Fen Software 30/1/85 */ 2 | /* approx 30 seconds on 1MHz 6809 for 10 iterations */ 3 | 4 | 5 | #include "stdio.h" 6 | 7 | char flags[8191]; /* globals zeroed automatically */ 8 | int i,prime,k,count,iter; 9 | 10 | main() 11 | { 12 | printf("\n10 iterations\n"); 13 | while(iter++ < 10) 14 | { 15 | count = 0; 16 | fill(flags,1,8191); 17 | for(i = 0;i<8191;++i) 18 | { 19 | if (flags[i]) 20 | { 21 | k = i + ( prime = i + i + 3 ); 22 | while(k<8191) 23 | { 24 | flags[k] = 0; 25 | k = k + prime; 26 | } 27 | ++count; 28 | } 29 | } 30 | } 31 | printf("%d primes found\n", count); 32 | } 33 | -------------------------------------------------------------------------------- /silifen/LIB54/sieve.cmd: -------------------------------------------------------------------------------- 1 | 2 | G42b-o-o4 3 | ._ '-m 4 | h444#2f-g-g4._ '~r-g-gM 5 | h4-g'^-g4-g4-g4-i-k-k4._ ' 6 | h4-k4-k4-i-k-m-mg 7 | 8 | W4-m42d921 41- 4d44b2b1 4!1 41 4B'4%&_ '4 9 | *2b~04%'_ '"1 44 10 | *2b~01 44-'_ '1 41 4~1 440'_ '1b 401 4~I1b 4 1% 41% 41+ 41 44441/ 4 11 | 4 2h1' 4)4:2b4.'_ 'D1# 41 4441+ 4 12 | 4 2h1 44'1% 4'4:2b1c 41g 1# 41 41 41! 44d'_ '+1e 41g 4d4 13 | CS4E2f4~4x'_ '&1e 41g 4d44E2f4~4c'_ '&1e 44b1e 44~4s'_ ' 14 | 1c 4b~4u'_ '&1e 41g 4ed4 15 | 4E2f4~4 16 | *2b~01 41! 4e42b4s'_ 4#4)-_ 4%4-_ '1! 4''A1' 44#4b2b4-_ ' 17 | b4 18 | *2b~!'A1c 44 19 | *2b1! 41' 4~R1' 44#4b2b4-_ ' 20 | b4 21 | *2b~~02)9+0z1'4 $o 2b1Z&04 22 | 42do0g 'm'4OEO 42d'- &o m'XI1' 404o~4bM+ 23 | &md&e=9CS1!4f*CS1!42d&CS9ec=eb='_0dc='_09oc*CSe*cCSme*CSm*CS94@0'3o4Phaild%$ffa%icibjd&cccbb2f55bm&0b9db'm&99fb4hg$ 2bf9b+9CS92|1 4lh4._ 4h4,_ t'+1b 4jCS1 44-~1b 4jf4'_ '1f 4 24 | ~ f4._ '1f 4hCSb4h/_ '* 1 4b4d4h4n42d4n4E2f4d4j42d4049-_ '444l4b2b42d92v1 41h 41f 4 4-_ 44 '_ '#1 41 4~ 4-_ '~4-'_ '.1d 41 4 25 | Y1 4~ 26 | 4+'_ ' 1 41 4l4'_ 44/_ '40'_ 44 27 | 4x'_ 444X'_ ',1 441 444b2b4-_ 't1b 4b40/_ 4d49,_ '01f 4d404b2b4n/_ '~~b4A/_ 4d4Z,_ '01f 4d474b2b4;n/_ '~~b4a/_ 4d4z,_ '01f 4d4W4b2b4n/_ '~~~1h 4j4442d4j1 41 4~kd'n4jCS~ 28 | n4j4b4b2b2j9c 29 | '9$9O'99 30 | 10 iterations 31 | %d primes found 32 | -------------------------------------------------------------------------------- /silifen/LIB54/tr.cmd: -------------------------------------------------------------------------------- 1 | 2 4._ ' 2 | 422b1b 44XI442d4'_ ' 3 | 422b4-_ 'F1 44XI4-42d4'_ ' 4 | /422b~1 41n 44XI4~'_ 'I1j 4n441 44j2f4'_ ' 5 | HB422b~1j 4n41 44j2f4'_ ' 6 | Z422b4XI4l442d4'_ '1 44~4XI41 44j2f4'_ ' 7 | n422b1d 41 4\2b1 4\2b4f-_ 4l4'_ '1h 4~}1h 41d 4~41 41 4 8 | .2f'z1f 41 41 4h4b2b44l4 2hh4'_ 4h4h/_ 4f4/_ $'k1 4f4b42d1f 41 41 4h4b2b44l4 2h1f 4f/_ '~Il4CS'_ '~-f4/_ 4f4/_ '1 4h4b42d~*f4._ ' 9 | l4b42d~29'!1b 44p2b~24dd2b92~1 44j4j41f 4l42j4h41d 4j42j94d/_ '9~f44jd44992z1d 41b 41 44&_ 44&_ '-4\'_ '!1n 4v2b4n4n4n42h~a4-&_ '4n4n4n42h~a 10 | 4,_ 444'_ '-4n4n4n42h~ad4n444b2b4i2d4-_ '11nF 4d41 44442j~ab4n444b2b4i2d4-_ '11n 4b41 44442j~a4n444b2b4i2d4-_ '11n 441 44442j~a-4n4n4n42h1n 4~2f92~1 44\&_ ' 2b9~44'_ ' \2b9~d41b 44n'_ ' 11 | 2b9~4t'_ ' b9~&4f'_ ' 2b9~4b'_ ' 2b9~4l'_ ' 12 | 2b9~4r'_ ' 13 | 2b9~4s'_ ' 2b9~2b92b92|h41 444v2b4i2d1b 44n44i2db4b$_ '/~ 1b 4~ 4l4l4l42h~ 2d92~h 4CS'_ 'CS2b9~ 14 | +f4'_ 'M1 4l4l4i2d4'_ 'CS2b9~ 4l4b2b2b9~ 15 | +j4j4i2d4- 16 | _ 'CS2b9~ 17 | +d42b92b921 41- 4d44b2b1 4!1 41 4'4%&_ '4 18 | p2b~ 19 | `4%'_ '"1 44p2b~ 20 | `1 44-'_ '1 41 4~81 440'_G '1b 401 4~y1b 4 1% 41% 41+ 41 44441/ 4 21 | 42h1' 4)42b4.'_ 'D1# 41 4441+ 4 22 | 42h1 44'1% 4'42b1c 41g 1 41 41 41! 44d'_ '+1e 41g 4d4 23 | CS42f4~ 24 | 4x'_ '&1e 41g 4d442f4~ 25 | 4c'_ '&1e 26 | *44b1e 44~ 27 | 4s'_ ' 28 | 1c 4b~ 29 | 4u'_ '&1e 41g 4d4 30 | 42f4~ 31 | 4p2b~ 32 | `1 41! 33 | 4e4\2b4s'_ 4#4)-_ 4%4-_ '1! 4''A1' 44#4b2b4-_l ' 34 | b4p2b~A!'A1c 44p2b1! 41' 4~1' 44#4b2b4-_ ' 35 | b4p2b~~ 36 | `2)9+0 1 4 $o 2b1Z&04 37 | 42do0g 'm'4O 42d'- &o m'XI1' 404?~db~bM+ 38 | &md&e=9CS1!4f*CS1!42d&CS9ec=eb='_0dc='_09oc*CSe*cCSme*CSm*CS94@0'3o4Phaild%$ffa%icibjd&cccbb2f55db-. &_999db&d9bm&0b9db'm&99b+9CS92|1 4lh4._ 4h4,_ '+1b 4jCS1 44-~1b 4jf4'_ '1f 4 39 | ~Gf4._ '1f 4hCSGb4h/_ '*1 4b4d4h4n42d4n42f4d4j42d4049-_ '444l4b2b42d92v1 41h 41f 44-_ 44 '_ '#1 41 4~4-_ '~4-'_ '.1d 41 41 4~4+'_ ' 1 41 4l4'_ 44/_ '40('_ 444x'_ 444X'_ ',1 441 444b2b4-_ 't1b 4b40/_ 4d49,_ '01f 4d404b2b4n/_ '~<~b4A/_ 4d4Z,_ '0h1f 4d474b2b4n/_ '~<~b4a/_ 4d4z,_ '01f 4d4W4b2b4n/_ '~<~~<1h 4j4 40 | 4i2d4j1 41 4~d'n4jCS~^n4j4b4b2b2j9c 41 | '9$9O'99 '&090@ console.devd4442d&w&9r&9944h4N2d44i2d4 42 | -%D3dr&&- 0u& &w&'&& O_2b9!Vb&;59b" &~9&o&99b"$'&-d4p2bd9e 43 | & 44 | d9& 45 | e&d99 46 | Transliterate characters V0.7 4/7/85 - useage: tr from to infile [outfile] 47 | r 48 | Can't open input file 49 | w 50 | Can't open output file 51 | 52 | from: too large 53 | 54 | from: too large 55 | ~ 56 | to: too large 57 | From: %s 58 | To: %s 59 | 0123456:789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -------------------------------------------------------------------------------- /silifen/LIB54/tst01.txt: -------------------------------------------------------------------------------- 1 | opt exp,con 2 | lib libdef 3 | * 4 | CSEG 5 | 6 | puld 7 | 8 | pshd 9 | 10 | main FUNC 0 11 | 12 | GETB varb 13 | 14 | GETW varw 15 | 16 | GETLOC 0 17 | 18 | GETLOC 10 19 | 20 | GETLOC 300 21 | 22 | PUTB varb 23 | 24 | PUTW varw 25 | 26 | PUTSB 27 | 28 | PUTSW 29 | 30 | GETBI 31 | 32 | GETWI 33 | 34 | PUSH 35 | 36 | SWAPS 37 | 38 | SWAP 39 | 40 | GWWI varw 41 | 42 | GWBI varw 43 | 44 | GETBS 0 45 | 46 | GETBS 100 47 | 48 | GETBS 200 49 | 50 | GETBS 1000 51 | 52 | PUTBS 0 53 | 54 | PUTBS 100 55 | 56 | PUTBS 1000 57 | 58 | GETWS 0 59 | 60 | GETWS 100 61 | 62 | GETWS 1000 63 | 64 | PUTWS 0 65 | 66 | PUTWS 100 67 | 68 | PUTWS 1000 69 | 70 | GETWSI 0 71 | 72 | GETWSI 100 73 | 74 | GETWSI 1000 75 | 76 | GETBSI 0 77 | 78 | GETBSI 100 79 | 80 | GETBSI 1000 81 | 82 | CALL main,2 83 | 84 | RET 85 | 86 | GOTO main 87 | 88 | TEST main 89 | 90 | GETGLB varw 91 | 92 | IMMED 1234 93 | 94 | CALLS 2 95 | 96 | PULL 97 | 98 | INCS 0 99 | 100 | INCS 4 101 | 102 | INCS -4 103 | 104 | INCS 100 105 | 106 | INCS 1000 107 | 108 | INCS -1000 109 | 110 | SCALE 1 111 | 112 | SCALE -1 113 | 114 | ADDS 115 | 116 | SUBS 117 | 118 | MULS 119 | 120 | DIVS 121 | 122 | MODS 123 | 124 | ORS 125 | 126 | EORS 127 | 128 | ANDS 129 | 130 | ASRS 131 | 132 | ASLS 133 | 134 | INCD 10 135 | 136 | DECD 10 137 | 138 | COMD 139 | 140 | NEGD 141 | 142 | CCEQ 143 | 144 | CCNE 145 | 146 | CCLT 147 | 148 | CCGT 149 | 150 | CCLE 151 | 152 | CCGE 153 | 154 | CCULT 155 | 156 | CCULE 157 | 158 | CCUGT 159 | 160 | CCULE 161 | 162 | CCUGT 163 | 164 | CCUGE 165 | 166 | RET 167 | 168 | EXTF start,START 169 | 170 | EXTV bert 171 | PUB main 172 | lib libload 173 | etext 174 | LSEG 175 | cc1 fcb 50,50,50,0 176 | edata 177 | DSEG 178 | varb rmb 1 179 | varw rmb 2 180 | end 181 | end START 182 | 183 | -------------------------------------------------------------------------------- /silifen/LIB55/cc5.c9: -------------------------------------------------------------------------------- 1 | /* cc5.c9 R1.0 10/3/85 recursive descent expression evaluator */ 2 | 3 | /* lval[0] - symbol table address - 0 for constant */ 4 | /* lval[1] - type of indirect obj to fetch - 0 for static */ 5 | /* this file contains assignment, logical operators and comparisons */ 6 | 7 | expression() 8 | { 9 | int lval[2]; 10 | if ( heir1(lval) ) 11 | rvalue(lval); 12 | } 13 | 14 | heir1(lval) 15 | int lval[]; 16 | { 17 | int k; 18 | int lval2[2]; 19 | k = heir2(lval); 20 | if ( match("=") ) /* need an lvalue to put result in */ 21 | { 22 | if ( k == 0 ) 23 | { 24 | needlval(); 25 | return 0; 26 | } 27 | if ( lval[1] ) 28 | push(); 29 | if ( heir1(lval2) ) 30 | rvalue(lval2); 31 | store(lval); 32 | return 0; 33 | } 34 | else return k; 35 | } 36 | 37 | heir2(lval) 38 | int lval[]; 39 | { 40 | int k; 41 | int lval2[2]; 42 | k = heir3(lval); 43 | blanks(); 44 | if ( ch != '|' ) 45 | return k; 46 | if ( k ) 47 | rvalue(lval); 48 | while ( 1 ) 49 | { 50 | if ( match("|") ) 51 | { 52 | push(); 53 | if ( heir3(lval2) ) 54 | rvalue(lval2); 55 | or(); /* auto pop in or */ 56 | } 57 | else return 0; 58 | } 59 | } 60 | 61 | heir3(lval) 62 | int lval[]; 63 | { 64 | int k; 65 | int lval2[2]; 66 | k = heir4(lval); 67 | blanks(); 68 | if ( ch != '^' ) 69 | return k; 70 | if ( k ) 71 | rvalue(lval); 72 | while ( 1 ) 73 | { 74 | if ( match("^") ) 75 | { 76 | push(); 77 | if ( heir4(lval2) ) 78 | rvalue(lval2); 79 | xor(); /* auto pop in xor */ 80 | } 81 | else return 0; 82 | } 83 | } 84 | 85 | heir4(lval) 86 | int lval[]; 87 | { 88 | int k; 89 | int lval2[2]; 90 | k = heir5(lval); 91 | blanks(); 92 | if ( ch != '&' ) 93 | return k; 94 | if ( k ) 95 | rvalue(lval); 96 | while ( 1 ) 97 | { 98 | if ( match("&") ) 99 | { 100 | push(); 101 | if ( heir5(lval2) ) 102 | rvalue(lval2); 103 | and(); /* auto pop in and */ 104 | } 105 | else return 0; 106 | } 107 | } 108 | 109 | heir5(lval) 110 | int lval[]; 111 | { 112 | int k; 113 | int lval2[2]; 114 | k = heir6(lval); 115 | blanks(); 116 | if((streq(line+lptr,"==")==0) & (streq(line+lptr,"!=") == 0 )) 117 | return k; 118 | if ( k ) 119 | rvalue(lval); 120 | while ( 1 ) 121 | { 122 | if ( match("==") ) 123 | { 124 | push(); 125 | if ( heir6(lval2)) 126 | rvalue(lval2); 127 | eq(); /* takes one param in D and other on stack */ 128 | } 129 | else if ( match("!=") ) 130 | { 131 | push(); 132 | if ( heir6(lval2) ) 133 | rvalue(lval2); 134 | ne(); 135 | } 136 | else return 0; 137 | } 138 | } 139 | 140 | heir6(lval) 141 | int lval[]; 142 | { 143 | int k; 144 | int lval2[2]; 145 | k = heir7(lval); 146 | blanks(); 147 | if ( (streq(line + lptr,"<") == 0 ) & 148 | (streq(line + lptr,">" ) == 0 ) & 149 | (streq(line + lptr , "<=" ) == 0 ) & 150 | (streq(line + lptr , ">=" ) == 0 ) ) 151 | return k; 152 | if ( streq( line + lptr , ">>" ) ) 153 | return k; 154 | if ( streq( line + lptr , "<<" ) ) 155 | return k; 156 | if ( k ) 157 | rvalue(lval); 158 | while(1) 159 | { 160 | if ( match("<=") ) 161 | { 162 | push(); 163 | if ( heir7(lval2) ) 164 | rvalue(lval2); 165 | if ( cptr = *lval ) 166 | if (cptr[IDENT] == POINTER ) 167 | { 168 | ule(); 169 | continue; 170 | } 171 | if ( cptr = *lval2 ) 172 | if ( cptr[IDENT] == POINTER ) 173 | { 174 | ule(); 175 | continue; 176 | } 177 | le(); 178 | } 179 | else if ( match(">=") ) 180 | { 181 | push(); 182 | if ( heir7(lval2) ) 183 | rvalue(lval2); 184 | if ( cptr = *lval ) 185 | if ( cptr[IDENT] == POINTER ) 186 | { 187 | uge(); 188 | continue; 189 | } 190 | if ( cptr = *lval2 ) 191 | if ( cptr[IDENT] == POINTER ) 192 | { 193 | uge(); 194 | continue; 195 | } 196 | ge(); 197 | } 198 | else if((streq(line+lptr,"<"))&(streq(line+lptr,"<<")==0)) 199 | { 200 | inbyte(); 201 | push(); 202 | if ( heir7(lval2) ) 203 | rvalue(lval2); 204 | if ( cptr = *lval ) 205 | if ( cptr[IDENT] == POINTER ) 206 | { 207 | ult(); 208 | continue; 209 | } 210 | if ( cptr = *lval2 ) 211 | if ( cptr[IDENT] == POINTER ) 212 | { 213 | ult(); 214 | continue; 215 | } 216 | lt(); 217 | } 218 | else if((streq(line+lptr,">"))&(streq(line+lptr,">>")==0)) 219 | { 220 | inbyte(); 221 | push(); 222 | if ( heir7(lval2) ) 223 | rvalue(lval2); 224 | if ( cptr = *lval ) 225 | if ( cptr[IDENT] == POINTER ) 226 | { 227 | ugt(); 228 | continue; 229 | } 230 | if ( cptr = *lval2 ) 231 | if ( cptr[IDENT] == POINTER ) 232 | { 233 | ugt(); 234 | continue; 235 | } 236 | gt(); 237 | } 238 | else return 0; 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /silifen/LIB55/cc6.c9: -------------------------------------------------------------------------------- 1 | /* cc6.c9 R1.1 24/4/85 */ 2 | 3 | heir7(lval) 4 | int lval[]; 5 | { 6 | int k,lval2[2]; 7 | k = heir8(lval); 8 | blanks(); 9 | if ((streq(line+lptr,">>")== 0)&(streq(line+lptr,"<")==0 )) 10 | return k; 11 | if ( k ) 12 | rvalue(lval); 13 | while(1) 14 | { 15 | if ( match(">>") ) 16 | { 17 | push(); 18 | if ( heir8(lval2) ) 19 | rvalue(lval2); 20 | casr(); /* auto stack pop */ 21 | } 22 | else if ( match("<<") ) 23 | { 24 | push(); 25 | if ( heir8(lval2) ) 26 | rvalue(lval2); 27 | casl(); 28 | } 29 | else return 0; 30 | } 31 | } 32 | 33 | heir8(lval) 34 | int lval[]; 35 | { 36 | int k,lval2[2]; 37 | k = heir9(lval); 38 | blanks(); 39 | if ( (ch != '-') & (ch != '+') ) 40 | return k; 41 | if ( k ) 42 | rvalue(lval); 43 | while(1) 44 | { 45 | if ( match("+") ) 46 | { 47 | push(); 48 | if ( heir9(lval2) ) 49 | rvalue(lval2); 50 | if ( cptr = *lval ) 51 | if((cptr[IDENT]==POINTER)&(cptr[TYPE]==CINT)) 52 | scale(intwidth); 53 | cadd(); /* auto pull in add */ 54 | } 55 | else if ( match("-") ) 56 | { 57 | push(); 58 | if ( heir9(lval2) ) 59 | rvalue(lval2); 60 | if ( cptr = *lval ) 61 | if((cptr[IDENT]==POINTER)&(cptr[TYPE]==CINT)) 62 | scale(intwidth); 63 | csub(); /* auto pull in sub */ 64 | } 65 | else return 0; 66 | } 67 | } 68 | 69 | heir9(lval) 70 | int lval[]; 71 | { 72 | int k; 73 | int lval2[2]; 74 | k = heir10(lval); 75 | blanks(); 76 | if ( (ch != '*') & (ch != '/') & (ch != '%') ) 77 | return k; 78 | if ( k ) 79 | rvalue(lval); 80 | while(1) 81 | { 82 | if ( match("*") ) 83 | { 84 | push(); 85 | if ( heir9(lval2) ) /**should it be heir10?**/ 86 | rvalue(lval2); 87 | mult(); /* cleans up its own stack */ 88 | } 89 | else if ( match("/") ) 90 | { 91 | push(); 92 | if ( heir10(lval2) ) 93 | rvalue(lval2); 94 | div(); 95 | } 96 | else if ( match("%") ) 97 | { 98 | push(); 99 | if ( heir10(lval2) ) 100 | rvalue(lval2); 101 | mod(); 102 | } 103 | else return 0; 104 | } 105 | } 106 | 107 | heir10(lval) 108 | int lval[]; 109 | { 110 | int k; 111 | char *ptr; 112 | if (match("++") ) 113 | { 114 | if ((k=heir10(lval)) == 0 ) 115 | { 116 | needlval(); 117 | return 0; 118 | } 119 | if ( lval[1] ) 120 | push(); 121 | rvalue(lval); 122 | ptr = *lval; 123 | if ( (ptr[IDENT] == POINTER ) & (ptr[TYPE] == CINT )) 124 | cinc( intwidth ); 125 | else 126 | cinc( 1 ); 127 | store(lval); 128 | return 0; 129 | } 130 | if (match("--") ) 131 | { 132 | if ((k=heir10(lval)) == 0 ) 133 | { 134 | needlval(); 135 | return 0; 136 | } 137 | if ( lval[1] ) 138 | push(); 139 | rvalue(lval); 140 | ptr = *lval; 141 | if ( (ptr[IDENT] == POINTER ) & (ptr[TYPE] == CINT )) 142 | cdec( intwidth ); 143 | else 144 | cdec( 1 ); 145 | store(lval); 146 | return 0; 147 | } 148 | if (match("-") ) 149 | { 150 | k = heir10(lval); 151 | if ( k ) 152 | rvalue(lval); 153 | cneg(); 154 | return 0; 155 | } 156 | else if ( match("*") ) /* take contents of pointer */ 157 | { 158 | k = heir10(lval); 159 | if ( k ) 160 | rvalue(lval); 161 | lval[1] = CINT; 162 | if ( ptr = *lval ) 163 | lval[1] = ptr[TYPE]; 164 | *lval = 0; 165 | return 1; 166 | } 167 | else if ( match("&") ) /* take address of variable */ 168 | { 169 | k = heir10(lval); 170 | if ( k == 0 ) 171 | { 172 | error("illegal address"); 173 | return 0; 174 | } 175 | else if ( lval[1] ) 176 | return 0; 177 | else 178 | { 179 | getglb(); 180 | outstr(ptr = *lval ); 181 | nl(); 182 | lval[1] = ptr[TYPE]; 183 | return 0; 184 | } 185 | } 186 | else 187 | { 188 | k = heir11(lval); 189 | if ( match("++") ) /* post increment */ 190 | { 191 | if ( k == 0 ) 192 | { 193 | needlval(); 194 | return 0; 195 | } 196 | if ( lval[1] ) 197 | push(); 198 | rvalue(lval); 199 | ptr = *lval; 200 | if((ptr[IDENT]==POINTER)&(ptr[TYPE]==CINT)) 201 | { 202 | cinc( intwidth ); 203 | store(lval); 204 | cdec( intwidth ); 205 | } 206 | else 207 | { 208 | cinc( 1 ); 209 | store(lval); 210 | cdec( 1 ); 211 | } 212 | /* the value is incremented and stored then decremented before use */ 213 | return 0; 214 | } 215 | else if (match("--") ) /* post decrement */ 216 | { 217 | if ( k == 0 ) 218 | { 219 | needlval(); 220 | return 0; 221 | } 222 | if ( lval[1] ) 223 | push(); 224 | rvalue(lval); 225 | ptr = *lval; 226 | if((ptr[IDENT]==POINTER)&(ptr[TYPE]==CINT)) 227 | { 228 | cdec( intwidth ); 229 | store(lval); 230 | cinc( intwidth ); 231 | } 232 | else 233 | { 234 | cdec( 1 ); 235 | store(lval); 236 | cinc( 1 ); 237 | } 238 | return 0; 239 | } 240 | else return k; 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /silifen/LIB55/cc7.c9: -------------------------------------------------------------------------------- 1 | /* cc7.c9 R1.1 24/4/85 */ 2 | 3 | heir11(lval) 4 | int *lval; 5 | { 6 | int k; 7 | char *ptr; 8 | k = primary(lval); 9 | ptr = *lval; 10 | blanks(); 11 | if ( (ch == '[' ) | ( ch == '(' ) ) 12 | while(1) 13 | { 14 | if ( match("[") ) 15 | { 16 | if (ptr) 17 | { 18 | if ( ptr[IDENT] == POINTER ) 19 | rvalue(lval); 20 | } 21 | push(); 22 | expression(); 23 | needbrack("]"); 24 | if (ptr) 25 | if ( ptr[TYPE] == CINT ) 26 | scale(intwidth); 27 | cadd(); /* auto pull */ 28 | *lval = 0; 29 | if (ptr) 30 | lval[1] = ptr[TYPE]; 31 | else 32 | lval[1] = 0; 33 | k = 1; 34 | } 35 | else if ( match("(") ) 36 | { 37 | if ( ptr == 0 ) 38 | { 39 | callfunction(0); 40 | } 41 | else if ( ptr[IDENT] != FUNCTION ) 42 | { 43 | rvalue(lval); 44 | callfunction(0); 45 | } 46 | else callfunction(ptr); 47 | k = *lval =0; 48 | } 49 | else return k; 50 | } 51 | if ( ptr == 0 ) 52 | return k; 53 | if ( ptr[IDENT] == FUNCTION ) 54 | { 55 | getglb(); 56 | outstr(ptr); 57 | nl(); 58 | return 0; 59 | } 60 | return k; 61 | } 62 | 63 | primary(lval) 64 | int *lval; 65 | { 66 | char *ptr; 67 | char sname[NAMESIZE]; 68 | int num; 69 | int k; 70 | if ( match("(") ) 71 | { 72 | k = heir1(lval); 73 | needbrack(")"); 74 | return k; 75 | } 76 | if ( symname(sname) ) 77 | { 78 | if ( ptr = findloc(sname) ) 79 | { 80 | getloc(ptr); 81 | *lval = ptr; 82 | lval[1] = ptr[TYPE]; 83 | if ( ptr[IDENT] == POINTER ) 84 | lval[1] = CINT; 85 | if ( ptr[IDENT] ==ARRAY ) 86 | return 0; 87 | else return 1; 88 | } 89 | if ( ptr = findglb(sname) ) 90 | if ( ptr[IDENT] != FUNCTION ) 91 | { 92 | *lval = ptr; 93 | lval[1] = 0; 94 | if ( ptr[IDENT] != ARRAY ) 95 | return 1; 96 | getglb(); 97 | outstr(ptr); 98 | nl(); 99 | lval[1]= ptr[TYPE]; 100 | return 0; 101 | } 102 | ptr = addglb( sname , FUNCTION , CINT , 0 ); 103 | *lval =ptr; 104 | lval[1] = 0; 105 | return 0; 106 | } 107 | if ( constant(&num) ) 108 | return ( *lval = lval[1] = 0 ); 109 | else 110 | { 111 | error("invalid expression"); 112 | immed(); 113 | outdec(0); 114 | nl(); 115 | junk(); 116 | return 0; 117 | } 118 | } 119 | 120 | store(lval) 121 | int *lval; 122 | { 123 | if ( lval[1] == 0 ) 124 | putmem(*lval); 125 | else putstk(lval[1]); 126 | } 127 | 128 | rvalue(lval) 129 | int *lval; 130 | { 131 | if ( ( *lval != 0 ) & ( lval[1] == 0 ) ) 132 | getmem(*lval); 133 | else indirect(lval[1]); 134 | } 135 | 136 | test(label) 137 | int label; 138 | { 139 | needbrack("("); 140 | expression(); 141 | needbrack(")"); 142 | testjump(label); 143 | } 144 | 145 | constant(val) 146 | int *val; 147 | { 148 | if ( number(val) ) 149 | { 150 | immed(); 151 | outdec( *val ); 152 | nl(); 153 | } 154 | else if ( pstr(val) ) 155 | { 156 | immed(); 157 | outdec(*val); 158 | nl(); 159 | } 160 | else if ( qstr(val) ) 161 | { 162 | getglb(); 163 | printlabel(litlab); 164 | outbyte('+'); 165 | outdec(*val); 166 | nl(); 167 | } 168 | else return 0; 169 | return 1; 170 | } 171 | 172 | number(val) 173 | int *val; 174 | { 175 | int k; 176 | int minus,i,base; 177 | char buf[20],c; 178 | k = 1; 179 | i = minus = 0; 180 | while ( k ) 181 | { 182 | k = 0; 183 | if ( match("+") ) 184 | k = 1; 185 | if ( match("-") ) 186 | { 187 | minus = 1; 188 | k = 1; 189 | } 190 | } 191 | if ( numeric(ch) == 0 ) 192 | return 0; 193 | while ( an(ch)&(i<19) ) 194 | { 195 | buf[i++] = inbyte(); 196 | } 197 | buf[i] = 0; 198 | if (i==19) 199 | { 200 | error("number truncated"); 201 | while(an(ch)) inbyte(); 202 | } 203 | if (*buf=='0') /* work out base */ 204 | { 205 | base = 8; 206 | if (toupper(buf[1])=='X') 207 | base = 16; 208 | } 209 | else 210 | base = 10; 211 | if (i != btoi(buf,i,&k,base)) 212 | error("invalid number"); 213 | if ( minus ) 214 | k = ( - k ); 215 | *val = k; 216 | return 1; 217 | } 218 | 219 | pstr(val) 220 | int val[]; 221 | { 222 | int k; 223 | char c; 224 | k = 0; 225 | if ( match("'") == 0 ) 226 | return 0; 227 | while (( ch) != 39 ) /* ' */ 228 | k = ( ( k & 255 ) << 8 ) + ( litchar() & 255 ); 229 | gch(); /* clear trailing ' */ 230 | *val = k; 231 | return 1; 232 | } 233 | 234 | qstr(val) 235 | int val[]; 236 | { 237 | if ( match(quote) == 0 ) 238 | return 0; 239 | *val = litptr; 240 | while ( ch != '"' ) 241 | { 242 | if ( ch == 0 ) 243 | break; 244 | if ( litptr >= LITMAX ) 245 | { 246 | error("string space exhausted"); 247 | while ( match(quote) == 0 ) 248 | if ( gch() == 0 ) 249 | break; 250 | return 1; 251 | } 252 | litq[litptr++] = litchar(); 253 | } 254 | gch(); 255 | litq[litptr++] = 0; 256 | return 1; 257 | } 258 | 259 | litchar() 260 | /* sort out backslash sequences */ 261 | { 262 | int i,oct; 263 | if ((ch!=92)|(nch==0)) 264 | return gch(); 265 | gch(); 266 | if (ch=='n') {gch(); return EOL;} 267 | if (ch=='f') {gch(); return 12;} 268 | if (ch=='t') {gch(); return 9;} 269 | if (ch=='b') {gch(); return 8;} 270 | if (ch=='l') {gch(); return 10;} 271 | if (ch=='r') {gch(); return 13;} 272 | if (ch==92) {gch(); return 92;} /* '\\' for \ */ 273 | if (ch=='"') {gch(); return '"';} /* "\"" for " */ 274 | if (ch==39) {gch(); return 39;} /* '\'' for ' */ 275 | i = 3; 276 | oct = 0; 277 | while(((i--)>0)&(ch>='0')&(ch<='7')) 278 | oct = (oct<<3) + gch() - '0'; 279 | if (i==2) 280 | return gch(); 281 | else 282 | return oct; 283 | } 284 | 285 | -------------------------------------------------------------------------------- /silifen/LIB55/cc9.c9: -------------------------------------------------------------------------------- 1 | /* cc9.c9 R1.1 24/4/85 */ 2 | 3 | /* get output file name */ 4 | openout() 5 | { 6 | char *p; 7 | int i; 8 | kill(); 9 | if (gargc>1) /* command line parameters in use */ 10 | { 11 | i = 1; 12 | while(i1) /* take from command line */ 66 | { 67 | while(curr_arg 3) 17 | { 18 | if ((output=fopen(argv[3],"w"))==0) 19 | { 20 | perror("can't open output file"); 21 | exit(1); 22 | } 23 | } 24 | else 25 | { 26 | output = stdout; 27 | putchar(EOL); 28 | } 29 | if ((input=fopen(argv[2],"r"))==0) 30 | { 31 | perror("can't open input file"); 32 | exit(1); 33 | } 34 | p = argv[1]; 35 | while(fgets(buf,132,input)) 36 | { 37 | str = buf; 38 | while(str=index(str,*p)) 39 | { 40 | if (strncmp(str,p,strlen(p))==0) 41 | fputs(buf,output); 42 | ++str; 43 | } 44 | } 45 | } 46 | fclose(input); 47 | if (output != stdout) 48 | fclose(output); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /silifen/LIB55/hello.c: -------------------------------------------------------------------------------- 1 | 2 | #include "stdio.h" 3 | 4 | main(argc,argv) 5 | int argc; 6 | char *argv[]; 7 | { 8 | if (argc==1) printf("\nfilename %s\n",*argv); 9 | if (argc==2) printf(argv[1],100,0x6ABC,'c',"string",-32000); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /silifen/LIB55/itob.c: -------------------------------------------------------------------------------- 1 | /* itob and btoi derived from WANB's discompiled versions of itob and btoi */ 2 | 3 | /* ANC 22/8/84 */ 4 | #asm 5 | IF ITOB 6 | *itob(s,i,base) 7 | * integer to ascii, s=buffer, i=integer, base is -36..36, -ve for signed 8 | * char *s; 9 | * int i,base; 10 | #endasm 11 | itob(s,i,base) 12 | /* integer to ascii, s=buffer, i=integer, base is -36..36, -ve for signed */ 13 | char *s; 14 | int i,base; 15 | { 16 | int val; 17 | char *qbuf; 18 | qbuf = s; 19 | /* correct for sign of i */ 20 | if ( (i < 0) & (base <= 0) ) 21 | { 22 | val = -i; 23 | *qbuf++ = '-'; 24 | } 25 | else 26 | val = i; 27 | /* check base */ 28 | if (base == 0) 29 | base = 10; 30 | else 31 | if (base < 0) 32 | base = -base; 33 | /* pick digits off recursively */ 34 | if ( val >= base ) 35 | qbuf = qbuf + itob(qbuf,val/base,base); 36 | if ((*qbuf = (val % base) + '0') > '9' ) 37 | *qbuf = *qbuf + 7; /* ( 'A'-'9'-1 ) */ 38 | /* return number of digits converted */ 39 | return (qbuf - s + 1); 40 | } 41 | #asm 42 | ENDIF 43 | 44 | IF BTOI 45 | * btoi(s,n,pinum,base) 46 | * ascii to integer, s=buffer,n=field width,pinum=*int for result,base to 36 47 | * char *s; 48 | * int n, *pinum, base; 49 | #endasm 50 | btoi(s,n,pinum,base) 51 | /* ascii to integer, s=buffer,n=field width,pinum=*int for result,base to 36 */ 52 | char *s; 53 | int n, *pinum, base; 54 | { 55 | int answer, digit, minus, c; 56 | char *p; 57 | p = s; 58 | answer = minus = 0; /* assume positive */ 59 | /* skip white */ 60 | while( (n > 0) & ( *s == ' ') ) 61 | { 62 | --n; 63 | ++s; 64 | } 65 | /* look for + or - */ 66 | if (n > 0) 67 | { 68 | if (*s == '-') 69 | { 70 | minus = 1; 71 | ++s; 72 | --n; 73 | } 74 | else 75 | { 76 | if (*s == '+') 77 | { 78 | ++s; 79 | --n; 80 | } 81 | } 82 | } 83 | /* check for 0x or 0X */ 84 | if ((base==16)&(n>=2)) 85 | if ((*s=='0')&((s[1]=='x')|(s[1]=='X'))) 86 | { 87 | s = s+2; 88 | n = n-2; 89 | } 90 | /* convert chars */ 91 | while( n > 0 ) 92 | { 93 | c = *s; 94 | if ((c >= '0')&(c <= '9')) 95 | { 96 | if ( (digit = c - '0') >= base) 97 | break; 98 | } 99 | else if ((c >= 'A')&(c <= 'Z')) 100 | { /* 55 == 'A' - 10 */ 101 | if ( (digit = c - 55 ) >= base) 102 | break; 103 | } 104 | else if ((c >= 'a')&(c <= 'z')) 105 | { /* 87 == 'a' - 10 */ 106 | if ( (digit = c - 87) >= base) 107 | break; 108 | } 109 | else break; 110 | answer = answer*base + digit; 111 | --n; 112 | ++s; 113 | } 114 | /* store answer */ 115 | if (minus) 116 | *pinum = -answer; 117 | else 118 | *pinum = answer; 119 | /* return number of chars converted */ 120 | return (s-p); 121 | } 122 | #asm 123 | ENDIF 124 | #endasm 125 | 126 | -------------------------------------------------------------------------------- /silifen/LIB55/opt.c: -------------------------------------------------------------------------------- 1 | /* optimiser for small-C */ 2 | /* macro version 12/7/84 */ 3 | /* uppercase macros 22/8/84 R0.1 */ 4 | /* multiple INCS 17/1/85 R0.3 */ 5 | /* "getw" to "getw " so that it doesnt match getwi by mistake R0.4 */ 6 | /* NTEST from CCEQ, TEST etc R1.0 28/5/85 */ 7 | 8 | /* transformations : 9 | getloc n = getws n use ldd n,s 10 | getwi 11 | 12 | getloc n = getbs n use ldb n,s 13 | getbi sex 14 | 15 | getloc n = getwsi n use ldd [n,s] 16 | getwi 17 | getwi 18 | 19 | getloc n = getbsi n use ldb [n,s] 20 | getwi sex 21 | getbi 22 | 23 | getw label = gwwi label use ldd [label] 24 | getwi 25 | 26 | getw label = gwbi label use ldb [label] 27 | getbi sex 28 | 29 | INCS n = INCS n+m+... use single leas n,s 30 | INCS m ... 31 | 32 | CCEQ = CCEQ use result in cc rather than cmpd 33 | TEST label NTEST label 34 | */ 35 | 36 | #include "stdio.h" 37 | 38 | #define LINELEN 132 39 | 40 | char line[LINELEN], save[LINELEN], save2[LINELEN], save3[LINELEN]; 41 | int i; 42 | char *match1,*match2,*match3,*match4,*match5,*match6,*matchcc,*matchtst; 43 | 44 | #define LENMAT1 7 45 | #define LENMAT2 6 46 | #define LENMAT3 6 47 | #define LENMAT4 6 48 | #define LENMAT5 5 49 | #define LENMAT6 5 50 | #define LENMATCC 3 51 | #define LENMATTST 5 52 | 53 | main(argc,argv) 54 | int argc; 55 | char *argv[]; 56 | { 57 | FILE *input,*output; 58 | match1 = " GETLOC"; 59 | match2 = " GETWI"; 60 | match3 = " GETBI"; 61 | match4 = " GETW "; 62 | match5 = " PUSH"; 63 | match6 = " INCS"; 64 | matchcc = " CC"; 65 | matchtst = " TEST "; 66 | /* open files specified on command line */ 67 | if (argc < 2 ) 68 | { /* not enough arguments */ 69 | perror("Optimiser R1.0 28/5/85 useage: opt infile [outfile]"); 70 | exit(1); 71 | } 72 | else 73 | { 74 | if ((input=fopen(argv[1],"r")) == 0) 75 | { 76 | perror("can't open input file"); 77 | exit(1); 78 | } 79 | if (argc == 2) 80 | output = stdout; /* output to screen */ 81 | else 82 | { 83 | if ((output=fopen(argv[2],"w")) == 0) 84 | { 85 | perror("can't open output file"); 86 | exit(1); 87 | } 88 | } 89 | } 90 | /* process input file a line at a time */ 91 | while( fgets(line,LINELEN,input) ) /* read till end of file */ 92 | { 93 | if ( strncmp( line, match6, LENMAT6 ) == 0 ) 94 | { /* matched an INCS */ 95 | strcpy( save, line); 96 | fgets( line, LINELEN, input ); 97 | while( strncmp( line, match6, LENMAT6 ) == 0 ) 98 | { /* keep accumulating INCS n's onto save */ 99 | save[strlen(save)-1] = NULL; /* remove return */ 100 | if ( line[6] == '-' ) 101 | strcat( save, line+6 ); /* copy number and - */ 102 | else 103 | { 104 | strcat( save, "+" ); /* need a plus */ 105 | strcat( save, line+6 ); /* and number */ 106 | } 107 | fgets( line, LINELEN, input ); /* get another line */ 108 | } 109 | fputs( save, output ); /* output INCS n+m+k-j... */ 110 | } /* leave line for other matches */ 111 | if( strncmp( line, match1, LENMAT1 ) == 0 ) 112 | { /* it matched a getloc */ 113 | strcpy( save, line ); 114 | fgets(line,LINELEN,input); 115 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) 116 | { /* it matched getloc, getwi */ 117 | /* can junk line so */ 118 | fgets(line,LINELEN,input); 119 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) 120 | { /* matched getloc,getwi,getwi */ 121 | /* edit getloc -> getwsi */ 122 | save[4] = 'W'; 123 | save[5] = 'S'; 124 | save[6] = 'I'; 125 | fputs(save,output); 126 | continue; 127 | } 128 | else if ( strncmp( line, match3, LENMAT3 ) == 0 ) 129 | { /* matched getloc,getwi,getbi */ 130 | /* edit getloc -> getbsi */ 131 | save[4] = 'B'; 132 | save[5] = 'S'; 133 | save[6] = 'I'; 134 | fputs(save,output); 135 | continue; 136 | } 137 | else /* no extra match */ 138 | { 139 | /* edit saved line */ 140 | save[4] = 'W'; /* getloc -> getws */ 141 | save[5] = 'S'; 142 | save[6] = ' '; 143 | fputs( save, output ); 144 | } 145 | } 146 | else if ( strncmp( line, match3, LENMAT3 ) == 0 ) 147 | { /* it matched getloc, getbi */ 148 | /* edit saved line */ 149 | save[4] = 'B'; /* getloc -> getbs */ 150 | save[5] = 'S'; 151 | save[6] = ' '; 152 | fputs( save ,output); 153 | continue; /* try another line */ 154 | } 155 | else /* second line didnt match so */ 156 | fputs( save ,output); 157 | } 158 | else if ( strncmp( line, match4, LENMAT4 ) == 0 ) 159 | { /* it matched a getw */ 160 | strcpy( save, line ); 161 | fgets(line,LINELEN,input); 162 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) 163 | { /* it matched getw, getwi */ 164 | /* edit getw -> gwwi */ 165 | save[2] = 'W'; 166 | save[3] = 'W'; 167 | save[4] = 'I'; 168 | fputs(save,output); 169 | continue; 170 | } 171 | if ( strncmp( line, match3, LENMAT3 ) == 0 ) 172 | { /* matched getw, getbi */ 173 | /* edit getw -> gwbi */ 174 | save[2] = 'W'; 175 | save[3] = 'B'; 176 | save[4] = 'I'; 177 | fputs(save,output); 178 | continue; 179 | } 180 | /* second line didnt match so */ 181 | fputs( save ,output); 182 | } 183 | if ( strncmp( line, matchcc, LENMATCC ) == 0 ) 184 | { 185 | while( strncmp( line, matchcc, LENMATCC ) == 0 ) 186 | { /* strip off multiple CCEQ's */ 187 | fputs( line, output ); 188 | fgets( line, LINELEN, input ); 189 | } 190 | if ( strncmp( line, matchtst, LENMATTST ) == 0 ) 191 | { /* matched TEST */ 192 | line[1] = 'N'; /* TEST to NTST */ 193 | line[2] = 'T'; 194 | fputs( line, output ); 195 | } 196 | } 197 | 198 | else 199 | fputs( line ,output); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /silifen/LIB55/printf.c: -------------------------------------------------------------------------------- 1 | /* printf.c R0.2 30/6/85 Silicon Fen Software */ 2 | 3 | printf(args) 4 | /* formatted output */ 5 | int args; 6 | { 7 | int width,prec,preclen,len,*nxtarg; 8 | char *ctl,*cx,c,right,str[20],*sptr,pad; 9 | int i; 10 | #asm 11 | std ,s save argument bytecount in i 12 | #endasm 13 | nxtarg = &args + (i - 2); 14 | ctl = *nxtarg; 15 | while(c = *ctl++) 16 | { 17 | if (c != '%') { putchar(c); continue; } /* chars */ 18 | if (*ctl == '%'){ putchar(*ctl++);continue;} /* %'s */ 19 | cx = ctl; 20 | if (*cx == '-') { right=0; ++cx; } else right = 1; 21 | if (*cx == '0') { pad='0'; ++cx; } else pad = ' '; 22 | prec = preclen = width = 0; 23 | cx = cx + btoi(cx,8,&width,10); 24 | /* putdec(width,1);puts(" width"); */ 25 | width = abs(width); 26 | if (*cx == '.') 27 | { 28 | preclen = btoi(++cx,8,&prec,10); 29 | cx = cx + preclen; 30 | } 31 | /* putdec(prec,1);putdec(preclen,1);puts(" prec preclen"); */ 32 | prec = abs(prec); 33 | sptr = str; 34 | c = *cx++; 35 | i = *(--nxtarg); 36 | if (c == 'd') str[itob(str,i,-10)]=0; 37 | else if (c == 'x') str[itob(str,i,16)]=0; 38 | else if (c == 'c') {str[0] = i; str[1] = 0;} 39 | else if (c == 's') sptr = i; 40 | else if (c == 'u') str[itob(str,i,10)]=0; 41 | else { putchar(c); continue; } 42 | ctl = cx; 43 | len = strlen(sptr); 44 | if ((c == 's')&(len>prec)&(preclen>0)) len = prec; 45 | /* putdec(len,1);puts(" len"); */ 46 | if (right) while(((width--)-len)>0) putchar(pad); 47 | while(len) { putchar(*sptr++); --len; --width; } 48 | while(((width--)-len)>0) putchar(pad); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /silifen/LIB55/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Notes for use of CRASMB with SFS small-C R1.1b 4 | ---------------------------------------------- 5 | 6 | For 6809 use to generate a FLEX command. 7 | 8 | Make sure that LIBDEF09.TXT has CRASMB set 1 in it. 9 | 10 | +++exec goto9 11 | 12 | +++cc sieve.c -o sieve.m -d normal useage 13 | 14 | +++opt sieve.m sieve.om normal useage 15 | 16 | +++crasmb sieve.om,sieve.cmd,i6809+ls 17 | 18 | +++sieve 19 | 20 | 21 | See Manual Appendix B for details of 6801 code generation, this 22 | appendix does not cover CRASMB use, it assumes Compusense XASM6801. 23 | 24 | To generate 6801 code but assemble into 6809 FLEX command for testing. 25 | 26 | Make sure that LIBDEF91.TXT has CRASMB set 1 in it. 27 | 28 | +++exec goto91 29 | 30 | If sieve.om is still around from 6809 use then it can be used, 31 | otherwise make it as above. 32 | 33 | +++cc sieve.c -o sieve.m -d no difference from 6809 34 | 35 | +++opt sieve.om sieve.cmd no difference from 6809 36 | 37 | +++crasmb sieve.om,sieve91.cmd,i6809+ls 38 | 39 | +++sieve91 40 | 41 | The above version of sieve, sieve91, uses 6801 assembly language 42 | definitions of the macro's used to generate code but the 6809 43 | assembler turns these into a subset of the 6809 instruction set. 44 | The code is larger and slower than pure 6809 and is a bit larger 45 | and slower than it would be on a real 6801. 46 | 47 | 48 | To generate code for a 6801/6811/6301 49 | 50 | Make sure that LIBDEF01.TXT has CRASMB set 1 in it. 51 | 52 | Check that LIBM01.TXT has the processor type set up. One of 53 | M6801, M6811 or H6301 should be SET 1. 54 | 55 | Check that LIBF01.TXT has the correct memory map set up using 56 | CCODE, CDATA and CSTACK for the target system. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | The program starts at the label START in LIBC01.TXT, this needs 73 | to be jumped to in some way on the target system. To set up the 74 | reset vector the CSEG macro in LIBM01.TXT could be changed to: 75 | 76 | CSEG macro 77 | org $FFFE 78 | fdb START 79 | org CCODE 80 | endm 81 | 82 | Terminal I/O primitives need to be put into LIBH.TXT 83 | if any character based I/O is required. Any other hardware 84 | access routines can be placed in LIBH.TXT. A C header file 85 | is provided, HARDWARE.H and this should be #included or 86 | compiled in with the program otherwise LIBH.TXT will not 87 | be loaded in by the assembler. Alternatively LIBLOAD1.TXT could 88 | be modified to always load LIBH.TXT. 89 | 90 | 91 | Finally - 92 | 93 | +++exec goto1 94 | 95 | If the .om file is note left over from above then recompile, 96 | there is no change as far as the compiler is concerned for 6801. 97 | 98 | +++cc sieve.c -o sieve.m -d normal compile 99 | 100 | +++opt sieve.m sieve.om normal opt 101 | 102 | +++crasmb sieve.om,sieve1.bin,i6801+ls (or use i6811,i6301 as required) 103 | 104 | Then get sieve1.bin into the target processor in the same way you would 105 | for an assembler program that used crasmb. 106 | 107 | 108 | -------------------------------------------------------------------------------- /silifen/LIB55/sieve.c: -------------------------------------------------------------------------------- 1 | /* eratosthenes sieve benchmark, Silicon Fen Software 30/1/85 */ 2 | /* approx 30 seconds on 1MHz 6809 for 10 iterations */ 3 | 4 | 5 | #include "stdio.h" 6 | 7 | char flags[8191]; /* globals zeroed automatically */ 8 | int i,prime,k,count,iter; 9 | 10 | main() 11 | { 12 | printf("\n10 iterations\n"); 13 | while(iter++ < 10) 14 | { 15 | count = 0; 16 | fill(flags,1,8191); 17 | for(i = 0;i<8191;++i) 18 | { 19 | if (flags[i]) 20 | { 21 | k = i + ( prime = i + i + 3 ); 22 | while(k<8191) 23 | { 24 | flags[k] = 0; 25 | k = k + prime; 26 | } 27 | ++count; 28 | } 29 | } 30 | } 31 | printf("%d primes found\n", count); 32 | } 33 | -------------------------------------------------------------------------------- /silifen/LIB55/strip.c: -------------------------------------------------------------------------------- 1 | /* strip.c, R0.1 strip out spaces */ 2 | 3 | #include "stdio.h" 4 | 5 | main(argc,argv) 6 | int argc; 7 | char *argv[]; 8 | { 9 | FILE *input,*output; 10 | int c,nospace; 11 | if (argc<3) 12 | { 13 | perror("useage: strip infile outfile"); 14 | exit(1); 15 | } 16 | if ((input=fopen(argv[1],"r"))==0) 17 | { 18 | perror("input file not found"); 19 | exit(1); 20 | } 21 | if ((output=fopen(argv[2],"w"))==0) 22 | { 23 | perror("output file not found"); 24 | exit(1); 25 | } 26 | nospace = YES; 27 | while((c=fgetc(input))!=EOF) 28 | { 29 | if (c==' ') 30 | { 31 | if (nospace) 32 | { 33 | fputc(c,output); 34 | nospace = NO; 35 | } 36 | } 37 | else 38 | { 39 | nospace = YES; 40 | fputc(c,output); 41 | } 42 | } 43 | fclose(input); 44 | fclose(output); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /silifen/LIB55/tst01.txt: -------------------------------------------------------------------------------- 1 | opt exp,con 2 | lib libdef 3 | * 4 | CSEG 5 | 6 | puld 7 | 8 | pshd 9 | 10 | main FUNC 0 11 | 12 | GETB varb 13 | 14 | GETW varw 15 | 16 | GETLOC 0 17 | 18 | GETLOC 10 19 | 20 | GETLOC 300 21 | 22 | PUTB varb 23 | 24 | PUTW varw 25 | 26 | PUTSB 27 | 28 | PUTSW 29 | 30 | GETBI 31 | 32 | GETWI 33 | 34 | PUSH 35 | 36 | SWAPS 37 | 38 | SWAP 39 | 40 | GWWI varw 41 | 42 | GWBI varw 43 | 44 | GETBS 0 45 | 46 | GETBS 100 47 | 48 | GETBS 200 49 | 50 | GETBS 1000 51 | 52 | PUTBS 0 53 | 54 | PUTBS 100 55 | 56 | PUTBS 1000 57 | 58 | GETWS 0 59 | 60 | GETWS 100 61 | 62 | GETWS 1000 63 | 64 | PUTWS 0 65 | 66 | PUTWS 100 67 | 68 | PUTWS 1000 69 | 70 | GETWSI 0 71 | 72 | GETWSI 100 73 | 74 | GETWSI 1000 75 | 76 | GETBSI 0 77 | 78 | GETBSI 100 79 | 80 | GETBSI 1000 81 | 82 | CALL main,2 83 | 84 | RET 85 | 86 | GOTO main 87 | 88 | TEST main 89 | 90 | GETGLB varw 91 | 92 | IMMED 1234 93 | 94 | CALLS 2 95 | 96 | PULL 97 | 98 | INCS 0 99 | 100 | INCS 4 101 | 102 | INCS -4 103 | 104 | INCS 100 105 | 106 | INCS 1000 107 | 108 | INCS -1000 109 | 110 | SCALE 1 111 | 112 | SCALE -1 113 | 114 | ADDS 115 | 116 | SUBS 117 | 118 | MULS 119 | 120 | DIVS 121 | 122 | MODS 123 | 124 | ORS 125 | 126 | EORS 127 | 128 | ANDS 129 | 130 | ASRS 131 | 132 | ASLS 133 | 134 | INCD 10 135 | 136 | DECD 10 137 | 138 | COMD 139 | 140 | NEGD 141 | 142 | CCEQ 143 | 144 | CCNE 145 | 146 | CCLT 147 | 148 | CCGT 149 | 150 | CCLE 151 | 152 | CCGE 153 | 154 | CCULT 155 | 156 | CCULE 157 | 158 | CCUGT 159 | 160 | CCULE 161 | 162 | CCUGT 163 | 164 | CCUGE 165 | 166 | RET 167 | 168 | EXTF start,START 169 | 170 | EXTV bert 171 | PUB main 172 | lib libload 173 | etext 174 | LSEG 175 | cc1 fcb 50,50,50,0 176 | edata 177 | DSEG 178 | varb rmb 1 179 | varw rmb 2 180 | end 181 | end START 182 | 183 | -------------------------------------------------------------------------------- /silifen/Makefile: -------------------------------------------------------------------------------- 1 | # https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#zz-2.3 2 | CC = gcc 3 | COPT = -g -O3 -D FDEBUG 4 | OBJS = scc.o itob.o ask.o heir.o cc2.o cc3.o cc4.o cc8.o cc9.o dump.o 5 | OOBJS = opt.c 6 | 7 | scc: $(OBJS) 8 | $(CC) $(COPT) -o $@ $^ 9 | 10 | %.o: %.c 11 | $(CC) $(COPT) -o $@ -c $< 12 | 13 | scc.o: scc.c scc.h cc.h 14 | ask.o: ask.c cc.h 15 | heir.o: heir.c cc.h 16 | cc2.o: cc2.c cc.h 17 | cc3.o: cc3.c cc.h 18 | cc4.o: cc4.c cc.h 19 | cc8.o: cc8.c cc.h 20 | cc9.o: cc9.c cc.h 21 | dump.o: dump.c cc.h 22 | 23 | opt: $(OOBJS) 24 | $(CC) $(COPT) -o $@ $^ 25 | 26 | .PHONY: clean 27 | 28 | clean: 29 | rm -rf *~ *.ihx *.lst *.map *.mem *.rel *.rst \ 30 | *.sym foo bar *.d51 *.hex *.a51 *.lnk \ 31 | a.out scc smallc smallcv22 *.o zap 32 | 33 | # for i in AR.C CC1.C CC2.C CC3.C CC4.C CC.H NOTICE.H; do 34 | # nom=$(tr '[:upper:]' '[:lower:]' <<< $i); cp $i ~/dev/git/SmallC68/${nom}; done 35 | 36 | # gdb -q --args ./smallcv22 ar.c 37 | -------------------------------------------------------------------------------- /silifen/README.md: -------------------------------------------------------------------------------- 1 | # Silicon Fen Software Small C for V2.1 the Motorola 68XX Processor 2 | 3 | I'm busy reading the Small-C Handbook by James E. Hendrix and from what I can tell this version by "Silicon Fen Software: Small-C Compiler R1.1.0 4/7/85". Despite the r1.1 it support the the for loop which is part of James E. Hendrix v2.1. At the moment I'm having to fix the char */int usage because 64 bit linux char pointers occupy the same size as a lone (8 bytes) and the same size as int (4 bytes). For those not familiar with the various CPUs, porting C and address size. The 8 bit machines typically had 16bit char pointers and ints. But as we moved to 16/32/64 bit machines the size of the char * matched the machine address width. Hense 64 bits wide on 64 bits Linux/Windows. This is also what we now have stdint.h and the unit8_t, uint16_t, ... etc. This helps avoid some of the confusing. 4 | 5 | Nee to a copy of the Microbox II (from Micro Concepts in Chelteham UK) 6 | 7 | # Description 8 | 9 | Note that the LIB5X directories appear to be the original Flex disks for this compiler. 10 | The current file structure: 11 | 12 | ``` 13 | ask.c 14 | cc2.c 15 | cc3.c 16 | cc4.c 17 | cc8.c 18 | cc9.c 19 | cc.h 20 | dump.c 21 | heir.c 22 | io9.c 23 | itob.c 24 | LIB51 25 | LIB52 26 | LIB53 27 | LIB54 28 | LIB55 29 | Makefile 30 | opt.c 31 | README.md 32 | readme.txt 33 | run9.c 34 | scc.c 35 | scc.h 36 | t-hello.c 37 | ``` 38 | 39 | # Original readme.txt 40 | 41 | Note: '+++' is the Flex OS command prompt. 42 | 43 | ``` 44 | Notes for use of CRASMB with SFS small-C R1.1b 45 | ---------------------------------------------- 46 | 47 | For 6809 use to generate a FLEX command. 48 | 49 | Make sure that LIBDEF09.TXT has CRASMB set 1 in it. 50 | 51 | +++exec goto9 52 | 53 | +++cc sieve.c -o sieve.m -d normal useage 54 | 55 | +++opt sieve.m sieve.om normal useage 56 | 57 | +++crasmb sieve.om,sieve.cmd,i6809+ls 58 | 59 | +++sieve 60 | 61 | 62 | See Manual Appendix B for details of 6801 code generation, this 63 | appendix does not cover CRASMB use, it assumes Compusense XASM6801. 64 | 65 | To generate 6801 code but assemble into 6809 FLEX command for testing. 66 | 67 | Make sure that LIBDEF91.TXT has CRASMB set 1 in it. 68 | 69 | +++exec goto91 70 | 71 | If sieve.om is still around from 6809 use then it can be used, 72 | otherwise make it as above. 73 | 74 | +++cc sieve.c -o sieve.m -d no difference from 6809 75 | 76 | +++opt sieve.om sieve.cmd no difference from 6809 77 | 78 | +++crasmb sieve.om,sieve91.cmd,i6809+ls 79 | 80 | +++sieve91 81 | 82 | The above version of sieve, sieve91, uses 6801 assembly language 83 | definitions of the macro's used to generate code but the 6809 84 | assembler turns these into a subset of the 6809 instruction set. 85 | The code is larger and slower than pure 6809 and is a bit larger 86 | and slower than it would be on a real 6801. 87 | 88 | To generate code for a 6801/6811/6301 89 | 90 | Make sure that LIBDEF01.TXT has CRASMB set 1 in it. 91 | 92 | Check that LIBM01.TXT has the processor type set up. One of 93 | M6801, M6811 or H6301 should be SET 1. 94 | 95 | Check that LIBF01.TXT has the correct memory map set up using 96 | CCODE, CDATA and CSTACK for the target system. 97 | 98 | The program starts at the label START in LIBC01.TXT, this needs 99 | to be jumped to in some way on the target system. To set up the 100 | reset vector the CSEG macro in LIBM01.TXT could be changed to: 101 | 102 | CSEG macro 103 | org $FFFE 104 | fdb START 105 | org CCODE 106 | endm 107 | 108 | Terminal I/O primitives need to be put into LIBH.TXT 109 | if any character based I/O is required. Any other hardware 110 | access routines can be placed in LIBH.TXT. A C header file 111 | is provided, HARDWARE.H and this should be #included or 112 | compiled in with the program otherwise LIBH.TXT will not 113 | be loaded in by the assembler. Alternatively LIBLOAD1.TXT could 114 | be modified to always load LIBH.TXT. 115 | 116 | Finally - 117 | 118 | +++exec goto1 119 | 120 | If the .om file is note left over from above then recompile, 121 | there is no change as far as the compiler is concerned for 6801. 122 | 123 | +++cc sieve.c -o sieve.m -d normal compile 124 | 125 | +++opt sieve.m sieve.om normal opt 126 | 127 | +++crasmb sieve.om,sieve1.bin,i6801+ls (or use i6811,i6301 as required) 128 | 129 | Then get sieve1.bin into the target processor in the same way you would 130 | for an assembler program that used crasmb. 131 | ``` 132 | 133 | # Status 134 | 135 | Currently in the process of being modernized. When done this will be a cross compiler under Linux/Windows. You won't be able to compile this under Flex. And if done correctly you should be able to use it with Motorola 68XX embedded boards with no OS. 136 | -------------------------------------------------------------------------------- /silifen/ask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "cc.h" 9 | 10 | #if 1 11 | void 12 | ask() { 13 | //return(); 14 | } 15 | #else 16 | /* */ 17 | /* get options from user */ 18 | /* */ 19 | void 20 | ask() { 21 | int k; 22 | int num; 23 | 24 | kill(); /*clear input line*/ 25 | nl(); 26 | pl(version); /* version string defined above */ 27 | nl(); 28 | 29 | pl("Interleave source as comments (y/*n): "); 30 | getl(line); /*get answer*/ 31 | if (toupper(*line) == 'Y') 32 | ctext = 1; /*user said yes*/ 33 | else 34 | ctext = 0; 35 | 36 | /* check for module compilation */ 37 | pl("Declare global variables (*y/n) : "); 38 | getl(line); /*get answer*/ 39 | if ( toupper(*line) == 'N' ) 40 | glbflag = 0; /*user said no*/ 41 | else 42 | glbflag = 1; 43 | 44 | /* check for 32 bit integers */ 45 | pl("Generate 32 bit macro code (y/*n) : "); 46 | getl(line); 47 | if ( toupper(*line) == 'Y' ) 48 | intwidth = 4; /* 32 bit for 68000 */ 49 | else 50 | intwidth = 2; /* 16 bit for 6809, 6801 */ 51 | 52 | /*get first allowable number of compiler generated labels 53 | in case user will append modules*/ 54 | while ( 1 ) { 55 | pl("Starting number for labels (*0) : "); 56 | getl(line); 57 | if ( *line == 0 ) { 58 | num = 0; 59 | break; 60 | } 61 | if ( btoi(line,4,&num,10) ) 62 | break; 63 | } 64 | 65 | nxtlab = num; /*first label = literal pool*/ 66 | litlab = getlabel(); /*first label = literal pool*/ 67 | kill(); /*erase line*/ 68 | } 69 | #endif 70 | 71 | /* fix options from command line */ 72 | void 73 | cl_ask() { 74 | int i, t; 75 | char *p; 76 | 77 | ctext = 0; 78 | i = glbflag = 1; 79 | intwidth = 2; /* assume 16 bit */ 80 | 81 | while(i 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "cc.h" 10 | 11 | /* get output file name */ 12 | void 13 | openout() { 14 | char *p; 15 | int i; 16 | kill(); 17 | if (gargc>1) { /* command line parameters in use */ 18 | i = 1; 19 | while(i1) { /* take from command line */ 66 | while(curr_arg 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "cc.h" 9 | 10 | /* print out compiler statistics */ 11 | dumpstats() { 12 | if (dump) { 13 | pl("compilation errors "); 14 | outdec(errcnt); 15 | pl("global symbols "); 16 | outdec((glbptr-STARTGLB)/SYMSIZ); 17 | pl("literal characters "); 18 | outdec(litptr); 19 | pl("define characters "); 20 | outdec(macptr); 21 | nl(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /silifen/io9.c: -------------------------------------------------------------------------------- 1 | /* Small-C Input-Output Library for FLEX9 */ 2 | 3 | putchar(c) 4 | char c; 5 | { 6 | #asm 7 | FCB 86 8 | LDA 3,S 9 | CMPA #13 10 | BNE :1 11 | JSR $CD24 12 | BRA :2 13 | :1 JSR $CD18 14 | :2 LDD 2,S 15 | JMP RTSC 16 | #endasm 17 | } 18 | 19 | getchar() 20 | { 21 | #asm 22 | FCB 86 23 | JSR $CD15 24 | CMPA #13 25 | BNE :1 26 | JSR $CD24 27 | LDA #13 28 | :1 TFR A,B 29 | CLRA 30 | JMP RTSC 31 | #endasm 32 | } 33 | 34 | puts(s) 35 | char *s; 36 | { 37 | int k; 38 | k=0; 39 | /* while(putchar(s[k++])); */ 40 | while(putchar(s++)); 41 | } 42 | -------------------------------------------------------------------------------- /silifen/itob.c: -------------------------------------------------------------------------------- 1 | /* itob and btoi derived from WANB's discompiled versions of itob and btoi */ 2 | 3 | /* ANC 22/8/84 */ 4 | /* 5 | #asm 6 | IF ITOB 7 | *itob(s,i,base) 8 | * integer to ascii, s=buffer, i=integer, base is -36..36, -ve for signed 9 | * char *s; 10 | * int i,base; 11 | #endasm 12 | */ 13 | /* integer to ascii, s=buffer, i=integer, base is -36..36, -ve for signed */ 14 | char * 15 | itob(char *s, int i, int base) { 16 | int val, t; 17 | char *qbuf; 18 | 19 | qbuf = s; 20 | 21 | /* correct for sign of i */ 22 | if ( (i < 0) & (base <= 0) ) { 23 | val = -i; 24 | *qbuf++ = '-'; 25 | } else { 26 | val = i; 27 | } 28 | /* check base */ 29 | if (base == 0) { 30 | base = 10; 31 | } else { 32 | if (base < 0) { 33 | base = -base; 34 | } 35 | } 36 | /* pick digits off recursively */ 37 | if ( val >= base ) { 38 | t = itob(qbuf,val/base,base); 39 | qbuf = qbuf[t]; 40 | //qbuf = qbuf + itob(qbuf,val/base,base); 41 | } 42 | 43 | if ((*qbuf = (val % base) + '0') > '9' ) 44 | *qbuf = *qbuf + 7; /* ( 'A'-'9'-1 ) */ 45 | 46 | /* return number of digits converted */ 47 | return (qbuf - s + 1); 48 | } 49 | /* 50 | #asm 51 | ENDIF 52 | 53 | IF BTOI 54 | * btoi(s,n,pinum,base) 55 | * ascii to integer, s=buffer,n=field width,pinum=*int for result,base to 36 56 | * char *s; 57 | * int n, *pinum, base; 58 | #endasm 59 | */ 60 | /* ascii to integer, s=buffer,n=field width,pinum=*int for result,base to 36 */ 61 | char * 62 | btoi(char *s, int n, int *pinum, int base) { 63 | int answer, digit, minus, c; 64 | char *p; 65 | 66 | p = s; 67 | answer = minus = 0; /* assume positive */ 68 | /* skip white */ 69 | while( (n > 0) & ( *s == ' ') ) { 70 | --n; 71 | ++s; 72 | } 73 | 74 | /* look for + or - */ 75 | if (n > 0) { 76 | if (*s == '-') { 77 | minus = 1; 78 | ++s; 79 | --n; 80 | } else { 81 | if (*s == '+') { 82 | ++s; 83 | --n; 84 | } 85 | } 86 | } 87 | 88 | /* check for 0x or 0X */ 89 | if ((base==16) && (n>=2)) { 90 | if ((*s=='0') && ((s[1]=='x') || (s[1]=='X'))) { 91 | s = s+2; 92 | n = n-2; 93 | } 94 | } 95 | 96 | /* convert chars */ 97 | while( n > 0 ) { 98 | c = *s; 99 | if ((c >= '0')&(c <= '9')) { 100 | if ( (digit = c - '0') >= base) 101 | break; 102 | } else if ((c >= 'A')&(c <= 'Z')) { /* 55 == 'A' - 10 */ 103 | if ( (digit = c - 55 ) >= base) { 104 | break; 105 | } 106 | } else if ((c >= 'a')&(c <= 'z')) { /* 87 == 'a' - 10 */ 107 | if ( (digit = c - 87) >= base) { 108 | break; 109 | } 110 | } else { 111 | break; 112 | } 113 | 114 | answer = answer*base + digit; 115 | --n; 116 | ++s; 117 | } 118 | /* store answer */ 119 | if (minus) 120 | *pinum = -answer; 121 | else 122 | *pinum = answer; 123 | 124 | /* return number of chars converted */ 125 | return (s-p); 126 | } 127 | /* 128 | #asm 129 | ENDIF 130 | #endasm 131 | */ 132 | -------------------------------------------------------------------------------- /silifen/opt.c: -------------------------------------------------------------------------------- 1 | /* optimiser for small-C */ 2 | /* macro version 12/7/84 */ 3 | /* uppercase macros 22/8/84 R0.1 */ 4 | /* multiple INCS 17/1/85 R0.3 */ 5 | /* "getw" to "getw " so that it doesnt match getwi by mistake R0.4 */ 6 | /* NTEST from CCEQ, TEST etc R1.0 28/5/85 */ 7 | 8 | /* transformations : 9 | getloc n = getws n use ldd n,s 10 | getwi 11 | 12 | getloc n = getbs n use ldb n,s 13 | getbi sex 14 | 15 | getloc n = getwsi n use ldd [n,s] 16 | getwi 17 | getwi 18 | 19 | getloc n = getbsi n use ldb [n,s] 20 | getwi sex 21 | getbi 22 | 23 | getw label = gwwi label use ldd [label] 24 | getwi 25 | 26 | getw label = gwbi label use ldb [label] 27 | getbi sex 28 | 29 | INCS n = INCS n+m+... use single leas n,s 30 | INCS m ... 31 | 32 | CCEQ = CCEQ use result in cc rather than cmpd 33 | TEST label NTEST label 34 | */ 35 | 36 | #include "stdio.h" 37 | 38 | #define LINELEN 132 39 | 40 | char line[LINELEN], save[LINELEN], save2[LINELEN], save3[LINELEN]; 41 | int i; 42 | char *match1,*match2,*match3,*match4,*match5,*match6,*matchcc,*matchtst; 43 | 44 | #define LENMAT1 7 45 | #define LENMAT2 6 46 | #define LENMAT3 6 47 | #define LENMAT4 6 48 | #define LENMAT5 5 49 | #define LENMAT6 5 50 | #define LENMATCC 3 51 | #define LENMATTST 5 52 | 53 | main(int argc, char *argv) { 54 | FILE *input,*output; 55 | 56 | match1 = " GETLOC"; 57 | match2 = " GETWI"; 58 | match3 = " GETBI"; 59 | match4 = " GETW "; 60 | match5 = " PUSH"; 61 | match6 = " INCS"; 62 | matchcc = " CC"; 63 | matchtst = " TEST "; 64 | 65 | /* open files specified on command line */ 66 | if (argc < 2 ) { /* not enough arguments */ 67 | perror("Optimiser R1.0 28/5/85 useage: opt infile [outfile]"); 68 | exit(1); 69 | } else { 70 | if ((input=fopen(argv[1],"r")) == 0) { 71 | perror("can't open input file"); 72 | exit(1); 73 | } 74 | if (argc == 2) 75 | output = stdout; /* output to screen */ 76 | else { 77 | if ((output=fopen(argv[2],"w")) == 0) { 78 | perror("can't open output file"); 79 | exit(1); 80 | } 81 | } 82 | } 83 | 84 | /* process input file a line at a time */ 85 | while( fgets(line,LINELEN,input) ) { /* read till end of file */ 86 | if ( strncmp( line, match6, LENMAT6 ) == 0 ) { /* matched an INCS */ 87 | strcpy( save, line); 88 | fgets( line, LINELEN, input ); 89 | while( strncmp( line, match6, LENMAT6 ) == 0 ) { /* keep accumulating INCS n's onto save */ 90 | save[strlen(save)-1] = NULL; /* remove return */ 91 | if ( line[6] == '-' ) 92 | strcat( save, line+6 ); /* copy number and - */ 93 | else { 94 | strcat( save, "+" ); /* need a plus */ 95 | strcat( save, line+6 ); /* and number */ 96 | } 97 | fgets( line, LINELEN, input ); /* get another line */ 98 | } 99 | fputs( save, output ); /* output INCS n+m+k-j... */ 100 | } /* leave line for other matches */ 101 | if( strncmp( line, match1, LENMAT1 ) == 0 ) { /* it matched a getloc */ 102 | strcpy( save, line ); 103 | fgets(line,LINELEN,input); 104 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) { /* it matched getloc, getwi */ 105 | /* can junk line so */ 106 | fgets(line,LINELEN,input); 107 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) { /* matched getloc,getwi,getwi */ 108 | /* edit getloc -> getwsi */ 109 | save[4] = 'W'; 110 | save[5] = 'S'; 111 | save[6] = 'I'; 112 | fputs(save,output); 113 | continue; 114 | } else if ( strncmp( line, match3, LENMAT3 ) == 0 ) { /* matched getloc,getwi,getbi */ 115 | /* edit getloc -> getbsi */ 116 | save[4] = 'B'; 117 | save[5] = 'S'; 118 | save[6] = 'I'; 119 | fputs(save,output); 120 | continue; 121 | } else { /* no extra match */ 122 | /* edit saved line */ 123 | save[4] = 'W'; /* getloc -> getws */ 124 | save[5] = 'S'; 125 | save[6] = ' '; 126 | fputs( save, output ); 127 | } 128 | } else if ( strncmp( line, match3, LENMAT3 ) == 0 ) { /* it matched getloc, getbi */ 129 | /* edit saved line */ 130 | save[4] = 'B'; /* getloc -> getbs */ 131 | save[5] = 'S'; 132 | save[6] = ' '; 133 | fputs( save ,output); 134 | continue; /* try another line */ 135 | } else { /* second line didnt match so */ 136 | fputs( save ,output); 137 | } 138 | } else if ( strncmp( line, match4, LENMAT4 ) == 0 ) { /* it matched a getw */ 139 | strcpy( save, line ); 140 | fgets(line,LINELEN,input); 141 | if ( strncmp( line, match2, LENMAT2 ) == 0 ) { /* it matched getw, getwi */ 142 | /* edit getw -> gwwi */ 143 | save[2] = 'W'; 144 | save[3] = 'W'; 145 | save[4] = 'I'; 146 | fputs(save,output); 147 | continue; 148 | } 149 | if ( strncmp( line, match3, LENMAT3 ) == 0 ) { /* matched getw, getbi */ 150 | /* edit getw -> gwbi */ 151 | save[2] = 'W'; 152 | save[3] = 'B'; 153 | save[4] = 'I'; 154 | fputs(save,output); 155 | continue; 156 | } 157 | /* second line didnt match so */ 158 | fputs( save ,output); 159 | } 160 | 161 | if ( strncmp( line, matchcc, LENMATCC ) == 0 ) { 162 | while( strncmp( line, matchcc, LENMATCC ) == 0 ) { /* strip off multiple CCEQ's */ 163 | fputs( line, output ); 164 | fgets( line, LINELEN, input ); 165 | } 166 | if ( strncmp( line, matchtst, LENMATTST ) == 0 ) { /* matched TEST */ 167 | line[1] = 'N'; /* TEST to NTST */ 168 | line[2] = 'T'; 169 | fputs( line, output ); 170 | } 171 | } else { 172 | fputs( line ,output); 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /silifen/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Notes for use of CRASMB with SFS small-C R1.1b 4 | ---------------------------------------------- 5 | 6 | For 6809 use to generate a FLEX command. 7 | 8 | Make sure that LIBDEF09.TXT has CRASMB set 1 in it. 9 | 10 | +++exec goto9 11 | 12 | +++cc sieve.c -o sieve.m -d normal useage 13 | 14 | +++opt sieve.m sieve.om normal useage 15 | 16 | +++crasmb sieve.om,sieve.cmd,i6809+ls 17 | 18 | +++sieve 19 | 20 | 21 | See Manual Appendix B for details of 6801 code generation, this 22 | appendix does not cover CRASMB use, it assumes Compusense XASM6801. 23 | 24 | To generate 6801 code but assemble into 6809 FLEX command for testing. 25 | 26 | Make sure that LIBDEF91.TXT has CRASMB set 1 in it. 27 | 28 | +++exec goto91 29 | 30 | If sieve.om is still around from 6809 use then it can be used, 31 | otherwise make it as above. 32 | 33 | +++cc sieve.c -o sieve.m -d no difference from 6809 34 | 35 | +++opt sieve.om sieve.cmd no difference from 6809 36 | 37 | +++crasmb sieve.om,sieve91.cmd,i6809+ls 38 | 39 | +++sieve91 40 | 41 | The above version of sieve, sieve91, uses 6801 assembly language 42 | definitions of the macro's used to generate code but the 6809 43 | assembler turns these into a subset of the 6809 instruction set. 44 | The code is larger and slower than pure 6809 and is a bit larger 45 | and slower than it would be on a real 6801. 46 | 47 | 48 | To generate code for a 6801/6811/6301 49 | 50 | Make sure that LIBDEF01.TXT has CRASMB set 1 in it. 51 | 52 | Check that LIBM01.TXT has the processor type set up. One of 53 | M6801, M6811 or H6301 should be SET 1. 54 | 55 | Check that LIBF01.TXT has the correct memory map set up using 56 | CCODE, CDATA and CSTACK for the target system. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | The program starts at the label START in LIBC01.TXT, this needs 73 | to be jumped to in some way on the target system. To set up the 74 | reset vector the CSEG macro in LIBM01.TXT could be changed to: 75 | 76 | CSEG macro 77 | org $FFFE 78 | fdb START 79 | org CCODE 80 | endm 81 | 82 | Terminal I/O primitives need to be put into LIBH.TXT 83 | if any character based I/O is required. Any other hardware 84 | access routines can be placed in LIBH.TXT. A C header file 85 | is provided, HARDWARE.H and this should be #included or 86 | compiled in with the program otherwise LIBH.TXT will not 87 | be loaded in by the assembler. Alternatively LIBLOAD1.TXT could 88 | be modified to always load LIBH.TXT. 89 | 90 | 91 | Finally - 92 | 93 | +++exec goto1 94 | 95 | If the .om file is note left over from above then recompile, 96 | there is no change as far as the compiler is concerned for 6801. 97 | 98 | +++cc sieve.c -o sieve.m -d normal compile 99 | 100 | +++opt sieve.m sieve.om normal opt 101 | 102 | +++crasmb sieve.om,sieve1.bin,i6801+ls (or use i6811,i6301 as required) 103 | 104 | Then get sieve1.bin into the target processor in the same way you would 105 | for an assembler program that used crasmb. 106 | 107 | 108 | -------------------------------------------------------------------------------- /silifen/scc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxha/SmallC68/4e1c4171e6585ed1ced90e62372d0debd10089d2/silifen/scc -------------------------------------------------------------------------------- /silifen/scc.h: -------------------------------------------------------------------------------- 1 | #ifndef SCC_H 2 | #define SCC_H 3 | /* now reserve some storage words */ 4 | 5 | char symtab[SYMTBSZ]; /*symbol table*/ 6 | char *glbptr; 7 | char *locptr; /*pointers to next entry*/ 8 | long wq[WQTABSZ]; /*while queue*/ 9 | long *wqptr; /*pointer to next entry*/ 10 | char litq[LITABSZ]; /*literal pool*/ 11 | long litptr; /*pointer to next entry*/ 12 | char macq[MACQSIZE]; /*macro string buffer*/ 13 | long macptr; /*and its index*/ 14 | char line[LINESIZE]; /*parsing buffer*/ 15 | char mline[LINESIZE]; /*temp macro buffer*/ 16 | long iflevel; /* #if.. nest level */ 17 | long skiplevel; /* level at which #if.. skipping started */ 18 | long lptr; 19 | long mptr; /*pointers into each*/ 20 | 21 | /* misc storage */ 22 | 23 | char *version; /*pointer to version string */ 24 | int intwidth; /*integer width in bytes 2 or 4*/ 25 | int nxtlab; /*next available label*/ 26 | int litlab; /*label # assigned by literal pool*/ 27 | int sp; /*compiler relative stack pointer*/ 28 | int argstk; /*function arg sp*/ 29 | int ncmp; /*# open compound statements*/ 30 | int errcnt; /*# errors in compilation*/ 31 | int eof; /*set non zero on final input eof*/ 32 | int glbflag; /*non-zero if internal globals*/ 33 | int ctext; /*non-zero to intermix c-source*/ 34 | int cmode; 35 | /*non-zero while parsing c-code zero when parsing assembly code*/ 36 | int lastst; /*last executed statement type*/ 37 | char quote[2]; /*literal string for '"' */ 38 | char *cptr; /*work pointer to any char buffer*/ 39 | long *iptr; /*work pointer to any int buffer*/ 40 | int ch,nch; /*current and next characters as ints*/ 41 | char infnam[FNAMSIZ]; /*buffer for current filename*/ 42 | char incfnam[FNAMSIZ]; /*buffer for include filename*/ 43 | int infline; /*line number for input file*/ 44 | int incfline; /*line number for include file*/ 45 | int curr_arg; /*current place in argument list*/ 46 | int dump; /*dump statistics flag*/ 47 | 48 | int gargc; /*global copy of arg count*/ 49 | char **gargv; /*pointer to argument array*/ 50 | 51 | FILE *output; /*output fcb pointer*/ 52 | FILE *input; /*input file fcb pointer*/ 53 | FILE *input2; /*include file fcb pointer */ 54 | 55 | #endif /* SCC_H */ 56 | 57 | -------------------------------------------------------------------------------- /silifen/t-hello.c: -------------------------------------------------------------------------------- 1 | /* Small C Demo Program */ 2 | 3 | #include "run9.c" /* Must use double quotes not <> */ 4 | #include "io9.c" 5 | 6 | main() { 7 | nl(); 8 | puts ("Hello World"); 9 | nl(); 10 | } 11 | 12 | nl() { 13 | putchar (13); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /v22/README.md: -------------------------------------------------------------------------------- 1 | # Small C V2.2 for the Intel 8086 and MSDOS 2 | 3 | James E. Hendrix v2.2 Small C Compiler for MSDOS. I'm hoping to learn about the differences and port them back the the SmallC68 version. 4 | 5 | # Status 6 | 7 | This is currently a mess. I've put it aside while I work on the 68XX versions. 8 | -------------------------------------------------------------------------------- /v22/ar.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxha/SmallC68/4e1c4171e6585ed1ced90e62372d0debd10089d2/v22/ar.c -------------------------------------------------------------------------------- /v22/mystdio.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSTDIO.H 2 | #define MYSTDIO.h 3 | /* 4 | ** STDIO.H -- Standard Small C Definitions. 5 | */ 6 | #define stdin 0 /* file descriptor for standard input file */ 7 | #define stdout 1 /* file descriptor for standard output file */ 8 | #define stderr 2 /* file descriptor for standard error file */ 9 | #define stdaux 3 /* file descriptor for standard auxiliary port */ 10 | #define stdprn 4 /* file descriptor for standard printer */ 11 | #define FILE char /* supports "FILE *fp;" declarations */ 12 | #define ERR (-2) /* return value for errors */ 13 | #define EOF (-1) /* return value for end-of-file */ 14 | #define YES 1 /* true */ 15 | #define NO 0 /* false */ 16 | #define NULL 0 /* zero */ 17 | #define CR 13 /* ASCII carriage return */ 18 | #define LF 10 /* ASCII line feed */ 19 | #define BELL 7 /* ASCII bell */ 20 | #define SPACE ' ' /* ASCII space */ 21 | #define NEWLINE LF /* Small C newline character */ 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /v22/notice.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** NOTICE.H -- Small C Signon Notice. 3 | */ 4 | #define VERSION "Small C, Version 2.2.0\n" 5 | #define CRIGHT1 "Copyright 1982, 1983, 1985, 1988 J. E. Hendrix\n\n" 6 | --------------------------------------------------------------------------------