diff options
author | Robert de Bath <rdebath@poboxes.com> | 2002-02-17 23:02:29 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:46 +0200 |
commit | df538463687d768b6ee8247ff4412b78850e7404 (patch) | |
tree | 52f42c02ef8139e5d73a8504e1bb3e896f3c0bc9 | |
parent | d91fa39567f5659e3931cf61517d62fddcd87570 (diff) | |
download | dev86-df538463687d768b6ee8247ff4412b78850e7404.tar.gz |
Import Dev86src-0.16.2.tar.gzv0.16.2
69 files changed, 587 insertions, 3460 deletions
@@ -1,3 +1,38 @@ +For version 0.16.*. + +> General clean out of some files that are no longer needed. + +> as86 modified to use normal malloc routines - no longer has limited + input file size. + +> as6809 repaired, appears to work. + +> as86 error display adjusted, some errors demoted to warnings. + +> Complete re-write of bcc.c driver program. Should now be easier to + modify, does have more versatility so that things that were formerly + compile time options are all run time. + +> #asm and #endasm now interact with statment processing inside functions. + If statments and case labels no longer need special layout however #asm + must be placed between statments now. + +> The __heap_top virtual constant added, allows the -H option to be used + with the -d option in the linker. + +> Conio routines added, merged with bios_getc/bios_putc routines which + now no longer exist under those names. + +> monitor.out now copes with very old zimages, like the memtest86 program, + and has 'Retry' prompt for disk errors. + +> msdos.s and tarboot.s loading of non-a.out executables adjusted for + dos BIN like files. + +> Standalone library startup adjusted to allow execution of a '-d' + executable from DOS, if __argr.x.cflag is set this is running under + DOS. + For version 0.16.0. > As major bugs seem to be absent 0.16.0 is escaping. diff --git a/Contributors b/Contributors index 0a821aa..ad6c92c 100644 --- a/Contributors +++ b/Contributors @@ -5,10 +5,10 @@ Bruce Evans <bde@FreeBSD.org> Then there's me, I'm controlling the releases of Dev86 and have the master files. -Robert de Bath <robert@mayday.cix.co.uk> +Robert de Bath <robert$@mayday.cix.co.uk> The files are available at linux.mit.edu with the source and yesterday's -patch file available via http://poboxes.com/rdebath +patch file available via http://cix.co.uk/~mayday/ We're all available through the Linux-8086 mailing list at: linux-8086@vger.rutgers.edu @@ -33,3 +33,4 @@ Wietse Venema <wietse@wzv.win.tue.nl> Joel Weber II <nemo@koa.iolani.honolulu.hi.us> Claudio Matsuoka <claudio@helllabs.org> Andrew Chittenden <achitten@madge.com> +John Coffman <johninsd@san.rr.com> diff --git a/Libc_version b/Libc_version index 2a0970c..201a22c 100644 --- a/Libc_version +++ b/Libc_version @@ -1 +1 @@ -0.16.1 +0.16.2 @@ -67,12 +67,15 @@ needed for the linux-i386 kernel and can replace them, versions before I _strongly_ suggest you install the kernel patch or load the module to allow transparent execution of elks executables. If you're using -a post 2.1.43 or 2.0.36 kernel the module you need is the binfmt_misc +a post 2.1.43 or 2.0.36 kernel the only module you need is the binfmt_misc driver configured like this: echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \ > /proc/sys/fs/binfmt_misc/register +The elksemu executable must be stored in /lib/elksemu or the above +line adjusted. + Previous versions need a special module or patch described in elksemu/README (All the options need the elksemu executable installed correctly) @@ -23,6 +23,7 @@ #include <unistd.h> #include <string.h> #include <utime.h> +#include <sys/time.h> #endif #include <fcntl.h> #include <time.h> @@ -234,7 +235,7 @@ void print_contents (); void write_symdef_member (); void read_old_symdefs (); void two_operations (); -void usage (), fatal (), error (), error_with_file (); +void usage (), fatal (), error (), error3(), error_with_file (); void perror_with_name (), pfatal_with_name (); void write_archive (); void touch_symdef_member (); @@ -245,14 +246,17 @@ char *basename (); void print_modes (); char *make_tempname (); void copy_out_member (); +#define const #else /* Grrr. */ -extern void error (); -extern void fatal (); -extern void extract_members (); +extern void error (char * s1, char * s2); +extern void error3 (char * s1, char * s2, char * s3); +extern void fatal (char * s1, char * s2); +extern void extract_members (void (*function) (struct member_desc member, FILE *istream)); +extern void scan (void (*function) (struct member_desc member, FILE *istream), int crflag); extern char *basename (char *path); -extern char *concat (char *s1, char *s2, char *s3); +extern char *concat (const char *s1, const char *s2, const char *s3); extern char *make_tempname (char *name); extern char *xmalloc (unsigned int size); extern char *xrealloc (char *ptr, unsigned int size); @@ -266,7 +270,7 @@ extern struct mapelt *find_mapelt_noerror (struct mapelt *map, register char *na extern struct mapelt *last_mapelt (struct mapelt *map); extern struct mapelt *make_map (int nonexistent_ok); extern struct mapelt *prev_mapelt (struct mapelt *map, struct mapelt *elt); -extern void add_to_map (struct member_desc member); +extern void add_to_map (struct member_desc member, FILE * istream); extern void close_archive (void); extern void copy_out_member (struct mapelt *mapelt, int archive_indesc, int outdesc, char *outname); extern void delete_from_map (char *name, struct mapelt *map); @@ -277,11 +281,11 @@ extern void header_from_map (struct ar_hdr *header, struct mapelt *mapelt); extern void lock_for_update (void); extern void make_new_symdefs (struct mapelt *mapelt, int archive_indesc); extern void move_members (void); -extern void mywrite (int desc, char *buf, int bytes, char *file); +extern void mywrite (int desc, void *buf, int bytes, char *file); extern void perror_with_name (char *name); extern void pfatal_with_name (char *name); extern void print_contents (struct member_desc member, FILE *istream); -extern void print_descr (struct member_desc member); +extern void print_descr (struct member_desc member, FILE * instream); extern void print_modes (int modes); extern void quick_append (void); extern void read_old_symdefs (struct mapelt *map, int archive_indesc); @@ -298,13 +302,14 @@ extern void write_symdef_member (struct mapelt *mapelt, struct mapelt *map, int FILE is the name of the file (for error messages). */ void -mywrite (desc, buf, bytes, file) +mywrite (desc, pbuf, bytes, file) int desc; - char *buf; + void *pbuf; int bytes; char *file; { register int val; + register char * buf = pbuf; while (bytes > 0) { @@ -349,7 +354,7 @@ main (argc, argv) if (*p == '-') p++; - while (c = *p++) + while ((c = *p++)) { switch (c) { @@ -445,10 +450,12 @@ main (argc, argv) i = 2; if (postype != POS_DEFAULT) + { if (i < argc) posname = argv[i++]; else usage ("no position operand", 0); + } if (i >= argc) usage ("no archive specified", 0); @@ -500,7 +507,7 @@ main (argc, argv) break; default: - usage ("invalid operation %d", operation); + usage ("invalid operation %d", (void*)operation); } exit (0); @@ -514,7 +521,11 @@ two_operations () void scan (function, crflag) +#ifdef __STDC__ + void (*function) (struct member_desc member, FILE *istream); +#else void (*function) (); +#endif int crflag; { FILE *arcstream = fopen (archive, "r"); @@ -597,8 +608,9 @@ scan (function, crflag) } void -print_descr (member) +print_descr (member, instream) struct member_desc member; + FILE * instream; { char *timestring; if (!verbose) @@ -673,7 +685,7 @@ extract_member (member, istream) if (preserve_dates) { -#if defined(USG) || defined(linux) || defined(__BCC__) +#if defined(USG) || defined(__BCC__) long tv[2]; tv[0] = member.date; tv[1] = member.date; @@ -735,8 +747,9 @@ make_map (nonexistent_ok) } void -add_to_map (member) +add_to_map (member, istream) struct member_desc member; + FILE * istream; { struct mapelt *mapelt = (struct mapelt *) xmalloc (sizeof (struct mapelt)); mapelt->info = member; @@ -1075,7 +1088,7 @@ header_from_map (header, mapelt) header->ar_name[sizeof (header->ar_name) - 2] = 'o'; } header->ar_name[sizeof (header->ar_name) - 1] = '\0'; - error ("member name `%s' truncated to `%s'", + error3 ("member name `%s' truncated to `%s'", mapelt->info.name, header->ar_name); } #if defined(USG) || defined(HAVE_TRAILING_SLASH_IN_NAME) @@ -1275,7 +1288,7 @@ move_members () { struct mapelt *map = make_map (0); char **p; - struct mapelt *after_mapelt; + struct mapelt *after_mapelt = 0; struct mapelt mapstart; struct mapelt *change_map; @@ -1337,7 +1350,7 @@ replace_members () { struct mapelt *map = make_map (1); struct mapelt mapstart; - struct mapelt *after_mapelt; + struct mapelt *after_mapelt = 0; struct mapelt *change_map; char **p; int changed; @@ -1469,7 +1482,11 @@ insert_in_map (name, map, after) void extract_members (function) +#ifdef __STDC__ + void (*function) (struct member_desc member, FILE *istream); +#else void (*function) (); +#endif { struct mapelt *map; FILE *arcstream; @@ -1954,7 +1971,7 @@ update_symdefs (map, archive_indesc) } else if (pos > old_strings_size) fatal ("Old archive's string size was %u too small.", - pos - old_strings_size); + (void*)(pos - old_strings_size)); for (tail = map; tail != 0; tail = tail->next) if (tail->info.symdefs) @@ -2000,11 +2017,20 @@ fatal (s1, s2) /* Print error message. `s1' is printf control string, the rest are args. */ void -error (s1, s2, s3, s4, s5) - char *s1, *s2, *s3, *s4, *s5; +error (s1, s2) + char *s1, *s2; +{ + fprintf (stderr, "%s: ", program_name); + fprintf (stderr, s1, s2); + fprintf (stderr, "\n"); +} + +void +error3 (s1, s2, s3) + char *s1, *s2, *s3; { fprintf (stderr, "%s: ", program_name); - fprintf (stderr, s1, s2, s3, s4, s5); + fprintf (stderr, s1, s2, s3); fprintf (stderr, "\n"); } @@ -2053,7 +2079,7 @@ pfatal_with_name (name) char * concat (s1, s2, s3) - char *s1, *s2, *s3; + const char *s1, *s2, *s3; { int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); char *result = (char *) xmalloc (len1 + len2 + len3 + 1); @@ -2089,7 +2115,7 @@ xrealloc (ptr, size) { char *result = realloc (ptr, size); if (result == 0) - fatal ("virtual memory exhausted"); + fatal ("virtual memory exhausted", 0); return result; } diff --git a/as/TODO b/as/TODO deleted file mode 100644 index 4cf413d..0000000 --- a/as/TODO +++ /dev/null @@ -1,13 +0,0 @@ -Update 6809/const.h. - -Produce bsd symbol tables. - -Accept gas format. - -Decide how to choose between 8-bit and 32-bit branches. 16-bit branches in -32-bit mode are unusable because top 16 bits of PC are messed up. - -Buffer for printing of listing. - -Need to make assembler remember the code it generated in the penultimate -pass and regenerate code of exactly the same length in the last pass. diff --git a/as/as.doc b/as/as.doc deleted file mode 100644 index cb6a649..0000000 --- a/as/as.doc +++ /dev/null @@ -1,169 +0,0 @@ -as options ----------- - -as [-03agjuw] [-b [bin]] [-lm [list]] [-n name] [-o obj] [-s sym] src - -The 6809 version does not support -0, -3, -a or -j. - -The 'src' file can be '-' for stdin but ONLY on 'big' machines. - -defaults (off or none except for these; no output is produced without a flag): --03 native -list stdout (beware of clobbering next arg) -name basename of the source name - --0 start with 16-bit code segment --3 start with 32-bit code segment --a enable partial compatibility with asld --g only put global symbols in object or symbol file --j force all jumps to be long --l produce list file, filename may follow --m print macro expansions in listing --n name of module follows (goes in object instead of source name) --o produce object file, filename follows --b produce a raw binary file, filename may follow --s produce an ASCII symbol file, filename follows --u take undefined symbols as imported-with-unspecified segment --w don't print warnings - -The -u and -w options are perhaps back to front because they are needed for -cc1 output and Minix's make does the wrong thing with .s files left around. -However, all assembler code not written by compilers should assemble with -them turned off. - -The -b flag produces a 'raw' binary file with no header, if there's no --s flag the file starts at location 0. The -s generates an ASCII symbol -table, if a binary file doesn't start at location zero the first two items -are the start and end addresses of the binary file. - -BCC is classed as a 'small' compiler, with this there is a maximum line -length of 256 characters. - -Using GASP ----------- - -The Gnu assembler preprocessor provides some reasonable implementations -of user biased pseudo operations. - -It can be invoked as: - gasp [-a] ... file.s [file2.s ...] | as86 [...] - [-o obj] [-b bin] - -Notes: -Gasp generates an error for '.org' commands if you're not using -'alternate' syntax you can use 'org' instead, otherwise use 'block'. - -Export is translated in .global, if you are making a 'bin' file use -'public' or '.define' instead. - -The GASP list options have no support in as86. - -as source ---------- - -Conditionals: - IF, ELSE, ELSEIF, ENDIF Numeric condition - IFC, ELSEIFC String compare (str1,str2) - FAIL .FAIL Generate user error. - -Segments: - .TEXT .ROM .DATA .BSS - .SECT Follow with one of above - LOC Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 15=MAX - -Lable type definition: - Export label defined in this object: EXPORT PUBLIC .DEFINE - Force linker to include label in a.out: ENTRY - - Define label as external or imported: .GLOBL .GLOBAL - Import list of externally defined labels: EXTRN EXTERN IMPORT .EXTERN - NB: Can't use imports in 'bin' files. - - Mark entry for old binary file (obs) .ENTER - -Data init - 1 byte: DB .DATA1 .BYTE FCB - 2 byte: DW .DATA2 .SHORT FDB .WORD - 4 byte: DD .DATA4 .LONG - String: .ASCII FCC - String+Zero: .ASCIZ - -Data uninit - byte count: .BLKB RMB .SPACE - word count: .BLKW .ZEROW - -Data Common - COMM .COMM LCOMM .LCOMM - -Alignment - .ALIGN .EVEN - -Misc - EQU Define label - SET Define re-definable label - ORG .ORG Set assemble location - BLOCK Set assemble location and stack old one - ENDB Return to stacked assemble location - GET INCLUDE Insert new file (no quotes on name) - USE16 Define default operand size as 16 bit - USE32 Define default operand size as 32 bit - END End of compilation for this file. - .WARN Switch warnings - .LIST Listings on/off (1,-1) - .MACLIST Macro listings on/off (1,-1) - -Macros - MACRO sax - mov ax,#?1 - MEND - sax(1) - -Unimplemented/unused. - IDENT Define object identity string. - SETDP Set DP value on 6809 - .MAP Set binary symbol table map number. - -Registers - BP BX DI SI - EAX EBP EBX ECX EDI EDX ESI ESP - AX CX DX SP - AH AL BH BL CH CL DH DL - CS DS ES FS GS SS - CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7 - TR3 TR4 TR5 TR6 TR7 ST - -Operand type specifiers - BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR - - -Instructions - -AAA AAD AAM AAS ADC ADD AND ARPL BCC BCS BEQ BGE BGT BHI BHIS BLE BLO -BLOS BLT BMI BNE BOUND BPC BPL BPS BR BVC BVS CALL CALLF CALLI CBW CLC -CLD CLI CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CSEG CWD CWDE CDQ DAA DAS -DSEG DEC DIV ENTER ESEG FSEG GSEG HLT IDIV IMUL IN INC INS INSB INSD -INSW INT INTO INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JECXE JECXZ JE -JG JGE JL JLE JMP JMPF JMPI JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE -JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LEAVE LES LOCK LODB -LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVS -MOVSB MOVSD MOVSW MOVW MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW -OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR -ROL ROR REP REPE REPNE REPNZ REPZ RET RETF RETI SAHF SAL SAR SBB SCAB -SCAS SCASB SCASD SCASW SCAW SEG SHL SHR SSEG STC STD STI STOB STOS STOSB -STOSD STOSW STOW SUB TEST WAIT XCHG XLAT XLATB XOR - -F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS -FDECSTP FDISI FDIV FDIVP FDIVR FDIVRP FENI FFREE FIADD FICOM FICOMP -FIDIV FIDIVR FILD FIMUL FINCSTP FINIT FIST FISTP FISUB FISUBR FLD FLD1 -FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX -FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM -FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT FST -FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP -FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1 - -BSF BSR BSWAP BT BTC BTR BTS CLTS CMPXCHG INVD INVLPG LAR LFS LGDT LGS -LIDT LLDT LMSW LSL LSS LTR MOVSX MOVZX SETA SETAE SETB SETBE SETC SETE -SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE -SETNL SETNLE SETNO SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ -SGDT SIDT SHLD SHRD SLDT SMSW STR VERR VERW WBINVD XADD ADCB ADDB ANDB -CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB -RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB @@ -17,8 +17,10 @@ #include <stdio.h> #ifdef __STDC__ #include <stdlib.h> +#ifndef MSDOS #include <unistd.h> #endif +#endif #include <string.h> #include <memory.h> #include <malloc.h> @@ -1106,6 +1108,11 @@ static char ** minienviron[] = { case -1: fatal("Forking failure"); case 0: + (void) signal(SIGQUIT, SIG_DFL); + (void) signal(SIGINT, SIG_DFL); + (void) signal(SIGTERM, SIG_DFL); + (void) signal(SIGCHLD, SIG_DFL); + #ifdef __BCC__ execve(command.fullpath, command.arglist, minienviron); #else @@ -1117,7 +1124,8 @@ static char ** minienviron[] = { wait(&status); if (status&0xFF) { - fprintf(stderr, "%s: killed by signal %d\n", command.fullpath, (status&0xFF)); + fprintf(stderr, "%s: killed by signal %d\n", + command.fullpath, (status&0xFF)); } } @@ -1126,7 +1134,7 @@ static char ** minienviron[] = { (void) signal(SIGTERM, otsig); (void) signal(SIGCHLD, ocsig); #endif - if (status) + if (status && file) file->filetype = '~'; } diff --git a/bcc/misc/sformat b/bcc/misc/sformat deleted file mode 100644 index 3dcb0c4..0000000 --- a/bcc/misc/sformat +++ /dev/null @@ -1,56 +0,0 @@ -int x; -.comm _x,2 - -int x = 1; -.global _x -.data -_x: -1 - -static int x; -.bss -_x: -.=.+2 - -static int x = 1; -.bss | implicit -.data -_x: -1 - -char x[10]; -.comm _x,12 - -char x[10] = "1"; -.globl _x -.data -_x: -.byte 61,0 -.=.+10 - -static char x[10]; -.bss; -_cc: -.=.+12 - -static char x[10] = "1"; -.data -_x: -.byte 61,0 -.=.+10 - -test() -.globl _test -.text -_test: - -{ -static int x; -.bss -L3: -.=.+2 - -static int x = 1; -.bss -.data -L5:1 diff --git a/bcc/misc/test/8queens.pas b/bcc/misc/test/8queens.pas deleted file mode 100644 index f4f1b47..0000000 --- a/bcc/misc/test/8queens.pas +++ /dev/null @@ -1,33 +0,0 @@ -program eightqueens; - -var i: integer; - a: array[ 1..8 ] of boolean; - b: array[ 2..16] of boolean; - c: array[-7..7 ] of boolean; - x: array[ 1..8 ] of integer; - -procedure print; -var k: integer; -begin - for k:= 1 to 8 do write(x[k]:4); - writeln; -end; - -procedure try(i: integer); -var j: integer; -begin - for j:= 1 to 8 do if a[j] and b[i+j] and c[i-j] then - begin - x[i]:= j; - a[j]:= false; b[i+j]:= false; c[i-j]:= false; - if i < 8 then try(i+1) else print; - a[j]:= true; b[i+j]:= true; c[i-j]:= true; - end; -end; - -begin - for i:= 1 to 8 do a[i]:= true; - for i:= 2 to 16 do b[i]:= true; - for i:= -7 to 7 do c[i]:= true; - try(1); -end. diff --git a/bcc/misc/test/8queens.t b/bcc/misc/test/8queens.t deleted file mode 100644 index 8d20a4d..0000000 --- a/bcc/misc/test/8queens.t +++ /dev/null @@ -1,74 +0,0 @@ -/* 8queens - straightforward translation of pascal version */ - -#define TRUE 1 -#define FALSE 0 - -int i; -char a[8],b[15],c[15],x[8]; - -main() -{ - for (i=0;i<8;i++) - a[i]=TRUE; - for (i=0;i<15;i++) - b[i]=TRUE; - for (i=0;i<15;i++) - c[i]=TRUE; - try(0); -} - -print() -{ - int k; - - for (k=0;k<8;k++) - write(x[k]); - writeln(); -} - -write(i) -int i; -{ - { -#asm - LDA #$20 - JSR $E820 - LDD .i,S - JSR $C682 -#endasm - } -} - -writeln() -{ - { -#asm - LDA #13 - JSR $E820 - LDA #10 - JSR $E820 -#endasm - } -} - -try(i) -int i; -{ - int j; - - for(j=0;j<8;j++) - if (a[j] && b[i+j] && c[7+i-j]) - { - x[i]=j; - a[j]=FALSE; - b[i+j]=FALSE; - c[7+i-j]=FALSE; - if (i<7) - try(i+1); - else - print(); - a[j]=TRUE; - b[i+j]=TRUE; - c[7+i-j]=TRUE; - } -} diff --git a/bcc/misc/test/atol.t b/bcc/misc/test/atol.t deleted file mode 100644 index 79c78b7..0000000 --- a/bcc/misc/test/atol.t +++ /dev/null @@ -1,29 +0,0 @@ -/* atol.c - long atol( char *s ) */ - -/* atol converts s to a long */ -/* leading spaces and tabs are ignored, an optional sign is recognised, */ -/* and the digits (0 to 9) following determine the long */ - -long atol( s ) -register char *s; -{ - char signflag; - long number; - - while ( *s == ' ' || *s == '\t') - s++; - signflag = 0; - if ( *s == '+' ) - s++; - else if ( *s == '-' ) - { - signflag = 1; - s++; - } - number = 0; - while ( *s >= '0' && *s <= '9' ) - number = 10 * number + *s++ - '0'; - if ( signflag ) - return -number; - return number; -} diff --git a/bcc/misc/test/bigsievec.t b/bcc/misc/test/bigsievec.t deleted file mode 100644 index f3f76b2..0000000 --- a/bcc/misc/test/bigsievec.t +++ /dev/null @@ -1,29 +0,0 @@ -#define TRUE 1 -#define FALSE 0 -#define NITER 10 -#define SIZE 100000 - -char flags[SIZE+1]; - -main() -{ - int i,prime,k,count,iter; - - for (iter=0;iter<NITER;iter++) - { - count=0; - for (i=0;i<=SIZE;i++) - flags[i]=TRUE; - for (i=0;i<=SIZE;i++) - { - if (flags[i]) - { - prime=i+i+3; - for (k=i+prime;k<=SIZE;k=k+prime) - flags[k]=FALSE; - count++; - } - } - } - printf( "%d primes\n", count ); -} diff --git a/bcc/misc/test/bt.t b/bcc/misc/test/bt.t deleted file mode 100644 index b88836c..0000000 --- a/bcc/misc/test/bt.t +++ /dev/null @@ -1,373 +0,0 @@ -/* bt.t - bug tests */ - -test1() -{ - char *p, *q; - - q += *p++; -} - -test2() -{ - int i,j,k,a[2],b[2],c[2]; - - i = a[i] + b[j] + c[k]; -} - -test3() -{ - int *p, *q; - int i; - - i = p - q; -} - -test4() -{ - int a[2]; - int *p; - - p = a; - test4(a); -} - -test5() -{ - char c; - - test4(c); -} - -test6(a,b) -int b,a; -{ - int i; - - i = b; - i = a; -} - -test7() -{ - int a[2]; - int *p; - - p = a + 1; -} - -int *test8(); - -int *test8() -{ - int i; - - if ( test8() == i ) - ; - i = *test8(); -} - -test9() -{ - int i,j,k,n; - - if ((i < 0 || j > 100) && (k < 0 || n > 50)) - i = 1; -} - -struct complex -{ - int re; - int im; -} - znum, *zptr, zarr[10], *zptrarr[10]; - -test10() -{ - int i; - - znum.re = i; - znum.im = 1; - zptr -> re = 1; - zptr -> im = i; - zarr[3].im = i; - zptrarr[4] -> im = 1; -} - -test11() -{ - char symtab[100]; - - char *p; - - if (p > symtab) - ; -} - -test12() -{ -char symtab[100]; - - char *p; - - p = symtab - 21; -} - -test13() -{ - char a[10]; - int i; - - i = a - 1; -} - -test14() -{ - int i, **pi; - - **pi = i; -} - -test15() -{ - int i, j; - - if ( (i = j ) == 2 ) - test(); -} - -test16() -{ - struct cx3 - { - int re3; - char im3; - } - z[10], *pz, *pz1; - int i; - - i = z[i].re3; - i = pz1 - pz; -} - -test17() -{ - int i; - char c; - - c &= ~i; -} - -test18() -{ - typedef int (*PFI)(); - PFI h(); - - (*h())( 0 ); -} - -test19() -{ - register int *p, *q; - int ***z,i,a[10]; - - test(***z + a[i]); -} - -char a[2][3][5]; - -char *p = a; -char *q = a[1]; -char *r = a[1][2]; - -char test20(); -char (*test21)(); - -test22() -{ - char i,k; - char *p; - - p = a; - p = a[1]; - p = a[1][2]; - p = a[k]; - p = a[k][k]; - i = sizeof a; - i = sizeof a[k]; - i = sizeof a[k][k]; - i = sizeof test20; - i = sizeof test21; - i = sizeof test20(); - i = sizeof (*test21)(); -} - -test23() -{ - long *pl; - int i; - char *s; - - *pl += i; - *s += *pl; -} - -test24() -{ - float f; - double *dp1(), *dp2(); - - f = *dp1()++; /* illegal */ - f = *++dp1(); /* illegal */ - f = *dp1() + *dp2(); /* bad code (pushes ptr to doubly indirect) */ -} - -test25() -{ - test25( "2"[1] ); /* added 1 to label number, not label address */ -} - -struct stat -{ - int st_dev; -}; - -test26( buf ) -struct stat buf; /* wrong declare, s.b. struct stat *buf */ -{ - buf->st_dev = 1; /* error caused null pointer to be dereferenced */ -} - -union -{ - long l; -} - test27; - -test28() -{ - test27.l = test27.l + 1; /* produced poor code */ -} - -int test29 = (char) 1; /* cast was clobbering the global symptr */ - -struct { int i; } test30; - -test31() -{ - return test30; /* a structure cannot be returned (yet) */ -} - -int *test32, test33() {} /* this is illegal */ - -test35() -{ - char a[1]; - char b[1]; - int i; - - i = i == 1 ? a : b; /* arrays were not converted to ptrs */ -} - -test36() -{ - struct fp - { - struct filp *fp_filp[1]; - }; - struct filp - { - int filp_int; - long filp_long; - }; - int i; - register char *junk; - register struct fp *cp; - - cp->fp_filp[i]->filp_int++; /* used to push lvalue */ - cp->fp_filp[i]->filp_long++; /* used to push lvalue */ - cp->fp_filp[i]->filp_int += 1; /* was OK */ - cp->fp_filp[i]->filp_long += 1; /* used to load long into DREG:DREG */ -} - -test37() -{ - unsigned u; - - u = -u; /* used to give botched nodetype */ -} - -test38() -{ - char c; - int i; - - i = -c; /* did i = (char) -c for a time */ -} - -test39() -{ - int i; - - i = (char) 1000; /* the constant wasn't being truncated */ -} - -#define test40(x) (x) - -test41() -{ - int i; - int j; - int k; - - i = test40( j + /* was confused by EOL in macro argument */ - k ); -} - -test42() -{ - register char *junk1; - register char *junk2; - long *longptr; - long longfn(); - - *longptr = longfn(); /* used to run out of index regs */ -} - -test43() -{ - register char *jnk1, *junk2; - unsigned char *bp; - struct FILE_BUF - { - char *bufp; - } *op; - - *op->bufp++ = *bp; /* used to push lvalue */ -} - -test44() -{ - register char *x, *y; - int i; - char a[2]; - char **p; - - a[**p] = **p; /* used to push lvalue */ -} - -struct test45 -{ - int i; - int j; -} test45[10]; - -test46() -{ - register char *p, *q; - int i; - int j; - - test45[i] = test45[j]; /* used to push lvalue */ -} - -int (*test100( x )() {} /* this is legal, keep last avoid swallowing */ diff --git a/bcc/misc/test/cast.t b/bcc/misc/test/cast.t deleted file mode 100644 index 554cb93..0000000 --- a/bcc/misc/test/cast.t +++ /dev/null @@ -1,144 +0,0 @@ -/* cast.t */ - -char c; -unsigned char uc; -short s; -unsigned short us; -int i; -unsigned int ui; -long l; -unsigned long ul; -float f; -double d; -int *p; - -cast() -{ - c = (char) c; - uc = (unsigned char) c; - s = (short) c; - us = (unsigned short) c; - i = (int) c; - ui = (unsigned int) c; - l = (long) c; - ul = (unsigned long) c; - f = (float) c; - d = (double) c; - p = (int *) c; - - c = (char) uc; - uc = (unsigned char) uc; - s = (short) uc; - us = (unsigned short) uc; - i = (int) uc; - ui = (unsigned int) uc; - l = (long) uc; - ul = (unsigned long) uc; - f = (float) uc; - d = (double) uc; - p = (int *) uc; - - c = (char) s; - uc = (unsigned char) s; - s = (short) s; - us = (unsigned short) s; - i = (int) s; - ui = (unsigned int) s; - l = (long) s; - ul = (unsigned long) s; - f = (float) s; - d = (double) s; - p = (int *) s; - - c = (char) us; - uc = (unsigned char) us; - s = (short) us; - us = (unsigned short) us; - i = (int) us; - ui = (unsigned int) us; - l = (long) us; - ul = (unsigned long) us; - f = (float) us; - d = (double) us; - p = (int *) us; - - c = (char) i; - uc = (unsigned char) i; - s = (short) i; - us = (unsigned short) i; - i = (int) i; - ui = (unsigned int) i; - l = (long) i; - ul = (unsigned long) i; - f = (float) i; - d = (double) i; - p = (int *) i; - - c = (char) ui; - uc = (unsigned char) ui; - s = (short) ui; - us = (unsigned short) ui; - i = (int) ui; - ui = (unsigned int) ui; - l = (long) ui; - ul = (unsigned long) ui; - f = (float) ui; - d = (double) ui; - p = (int *) ui; - - c = (char) l; - uc = (unsigned char) l; - s = (short) l; - us = (unsigned short) l; - i = (int) l; - ui = (unsigned int) l; - l = (long) l; - ul = (unsigned long) l; - f = (float) l; - d = (double) l; - p = (int *) l; - - c = (char) ul; - uc = (unsigned char) ul; - s = (short) ul; - us = (unsigned short) ul; - i = (int) ul; - ui = (unsigned int) ul; - l = (long) ul; - ul = (unsigned long) ul; - f = (float) ul; - d = (double) ul; - p = (int *) ul; - - c = (char) f; - uc = (unsigned char) f; - s = (short) f; - us = (unsigned short) f; - i = (int) f; - ui = (unsigned int) f; - l = (long) f; - ul = (unsigned long) f; - f = (float) f; - d = (double) f; - - c = (char) d; - uc = (unsigned char) d; - s = (short) d; - us = (unsigned short) d; - i = (int) d; - ui = (unsigned int) d; - l = (long) d; - ul = (unsigned long) d; - f = (float) d; - d = (double) d; - - c = (char) p; - uc = (unsigned char) p; - s = (short) p; - us = (unsigned short) p; - i = (int) p; - ui = (unsigned int) p; - l = (long) p; - ul = (unsigned long) p; - p = (int *) p; -} diff --git a/bcc/misc/test/cast1.t b/bcc/misc/test/cast1.t deleted file mode 100644 index a4c15d5..0000000 --- a/bcc/misc/test/cast1.t +++ /dev/null @@ -1,144 +0,0 @@ -/* cast1.t */ - -char c; -unsigned char uc; -short s; -unsigned short us; -int i; -unsigned int ui; -long l; -unsigned long ul; -float f; -double d; -int *p; - -cast() -{ - c = c; - uc = c; - s = c; - us = c; - i = c; - ui = c; - l = c; - ul = c; - f = c; - d = c; - p = c; - - c = uc; - uc = uc; - s = uc; - us = uc; - i = uc; - ui = uc; - l = uc; - ul = uc; - f = uc; - d = uc; - p = uc; - - c = s; - uc = s; - s = s; - us = s; - i = s; - ui = s; - l = s; - ul = s; - f = s; - d = s; - p = s; - - c = us; - uc = us; - s = us; - us = us; - i = us; - ui = us; - l = us; - ul = us; - f = us; - d = us; - p = us; - - c = i; - uc = i; - s = i; - us = i; - i = i; - ui = i; - l = i; - ul = i; - f = i; - d = i; - p = i; - - c = ui; - uc = ui; - s = ui; - us = ui; - i = ui; - ui = ui; - l = ui; - ul = ui; - f = ui; - d = ui; - p = ui; - - c = l; - uc = l; - s = l; - us = l; - i = l; - ui = l; - l = l; - ul = l; - f = l; - d = l; - p = l; - - c = ul; - uc = ul; - s = ul; - us = ul; - i = ul; - ui = ul; - l = ul; - ul = ul; - f = ul; - d = ul; - p = ul; - - c = f; - uc = f; - s = f; - us = f; - i = f; - ui = f; - l = f; - ul = f; - f = f; - d = f; - - c = d; - uc = d; - s = d; - us = d; - i = d; - ui = d; - l = d; - ul = d; - f = d; - d = d; - - c = p; - uc = p; - s = p; - us = p; - i = p; - ui = p; - l = p; - ul = p; - p = p; -} diff --git a/bcc/misc/test/castest.t b/bcc/misc/test/castest.t deleted file mode 100644 index ae27f7b..0000000 --- a/bcc/misc/test/castest.t +++ /dev/null @@ -1,74 +0,0 @@ -/* castest.c */ - -/* -#define signedchar -#define bigints -*/ -#define unsigchar -#define unsigshort -#define unsiglong - -#define TEST(u,c) if ( (u) != (c) )\ - { printf( "u != c\n" ); ++bad; } ++possible - -main() -{ - int bad; - int possible; - char c; -#ifdef signedchar - signed char sc; -#endif -#ifdef unsigchar - unsigned char uc; -#endif - short s; -#ifdef unsigshort - unsigned short us; -#endif - int i; - unsigned u; - long l; -#ifdef unsiglong - unsigned long ul; -#endif - - bad = possible = 0; - u = 0x1ff; - c = (char) u; - if ( c < 0 ) - printf( "characters are signed\n" ); - TEST((char)u,c); - i = (int)(char) u; - TEST(i,(int)c); - TEST((int)(char)u,i); - -#ifdef signedchar - sc = (signed char) u; - if ( sc >= 0 ) - printf( "??? signed char not signed\n" ); - TEST((signed char)u,sc); - TEST((int)(signed char)u,(int)sc); - i = (int) sc; - TEST((int)(signed char)u,i); -#endif - -#ifdef bigints - u = 0x1ffff; - s = (short) u; - TEST((short)u,s); - TEST((int)(short)u,(int)s); - i = (int) s; - TEST((int)(short)u,i); - -#ifdef unsigshort - us = (unsigned short) u; - TEST((unsigned short)u,us); - TEST((int)(unsigned short)u,(int)us); - i = (int) us; - TEST((int)(unsigned short)u,i); -#endif -#endif - - printf( "%d bad out of a possible %d\n", bad, possible ); -} diff --git a/bcc/misc/test/ctype.t b/bcc/misc/test/ctype.t deleted file mode 100644 index 93b3e4f..0000000 --- a/bcc/misc/test/ctype.t +++ /dev/null @@ -1,38 +0,0 @@ -/* ctype.h */ - -#define _C 1 /* control */ -#define _D 2 /* digit */ -#define _L 4 /* lower */ -#define _P 8 /* punctuation */ -#define _S 16 /* space */ -#define _U 32 /* upper */ -#define _UN 64 /* underline */ -#define _X '\200' /* hex digit, not digit */ - -extern char _ctype_[]; - -#define _ct1_ (_ctype_+1) - -#define isalnum(c) (_ct1_[c]&(_U|_L|_D)) -#define isalpha(c) (_ct1_[c]&(_U|_L)) -#define isascii(i) ((unsigned)(i)<=0x7f) -#define isalpha(c) (_ct1_[c]&(_U|_L)) -#define iscntrl(c) (_ct1_[c]&_C) -#define iscsym(c) (_ct1_[c]&(_U|_L|_D|_UN)) -#define iscsymf(c) (_ct1_[c]&(_U|_L|_UN)) -#define isdigit(c) (_ct1_[c]&_D) -#define isgraph(c) (_ct1_[c]&(_U|_L|_D|_P)) -#define islower(c) (_ct1_[c]&_L) -/* isodigit(i) is a function */ -/* isprint(i) is a function */ -#define ispunct(c) (_ct1_[c]&_P) -#define isspace(c) (_ct1_[c]&_S) -#define isupper(c) (_ct1_[c]&_U) -#define isxdigit(c) (_ct1_[c]&(_D|_X)) - -#define toascii(i) ((i)&0x7f) -/* toint(i) is a function */ -/* tolower(i) is a function */ -#define _tolower(c) ((c)+('a'-'A')) -/* toupper(i) is a function */ -#define _toupper(c) ((c)+('A'-'a')) diff --git a/bcc/misc/test/error.t b/bcc/misc/test/error.t deleted file mode 100644 index 24e302a..0000000 --- a/bcc/misc/test/error.t +++ /dev/null @@ -1,78 +0,0 @@ -static char *errorstring[] = -{ - "# in a macro: not preprocessed", - "already declared", - "array of functions is illegal", - "bad address", - "bad case label", - "bad character constant", - "bad character", - "bad control", - "bad default label", - "bad expression", - "bad file name", - "bad indirection count", - "bad initializer address", - "bad register store", - "call of non-function", - "can't continue in switch", - "can't index", - "can't load char to index reg", - "can't open", - "can't open input", - "can't open output", - "case can't be reached with char switch", - "constant expression expected", - "else without if", - "end of file in #asm", - "end of file in #define", - "end of file in comment", - "end of file in failed #if", - "end of file in macro parameter expansion", - "end of file in string constant", - "end of line in string constant", - "endif without if", - "function returning array is illegal", - "function returning function is illegal", - "function returning structure is illegal", - "if stack overflow", - "illegal indirection", - "illegal macro name", - "illegal non-external function", - "illegal symbol name", - "illegal type conversion", - "illegal type name", - "initializer too complicated", - "input error", - "load of long constants not implemented", - "loading direct long with offset not implemented", - "local symbol table overflow", - "macro stack overflow", - "missing '('", - "missing while at end of do-while", - "need '", - "need int or char", - "need lvalue", - "need scalar or ptr type", - "need structure", - "no active fors, switches or whiles", - "not in a compound statement", - "null dimension", - "out of index registers", - "redefined macro", - "repeated argument", - "repeated default label", - "repeated parameter", - "table full", - "too few macro parameters", - "too many active whiles", - "too many cases", - "too many macro parameters", - "too many open compound statements", - "too many parameters", - "undeclared variable", - "undefined structure element", - "undefined structure", - "unsigned ints only", - "variable not in argument list" -}; diff --git a/bcc/misc/test/extern.t b/bcc/misc/test/extern.t deleted file mode 100644 index dac5f5c..0000000 --- a/bcc/misc/test/extern.t +++ /dev/null @@ -1,236 +0,0 @@ -/* extern.c - external declarations (K & R p218-9) */ - -#include "def.h" -#include "globvar.h" -#include "symbol.h" - -struct typestruct *declarator(); -struct typestruct *extypespec(); -int paramlist(); -struct typestruct *typespec(); - -/*============================================================================= - -- notation is 1st attempt at EBNF (see Modula-2 book) - program = { type-definition | function-or-data-definition }. - type-definition = "typedef" type-definition-list. -=============================================================================*/ - -program() -{ - nextsym(); - while ( sym != EOFSYM ) - { - if ( sym = TYPEDEFDECL ) - deftypes(); - else - functordata(); - } -} - -/*============================================================================= - type-definition-list. -- not implemented -=============================================================================*/ - -deftypes() -{} - -/*============================================================================= - function-or-data-definition = external-type-specification - ( function-definition | init-declarators ). - function-definition = "(" parameter-list ")" arg-list compound-statement. - -- this is different from K & R who omit typedefs and static functions -=============================================================================*/ - -functordata() -{ - struct typestruct *type; - int nargs; - - type = extypespec(); - if ( sym == LPAREN ) - { - nextsym(); - nargs = paramlist(); - need( RPAREN ); - arglist( nargs ); - need( LBRACE ); - compound( 1 + locptr-pstartloc );/* 1 = function flag, rest = nargs */ - oldlevel(); - } - else - initdecl( type ); -} - -/*============================================================================= - external-type-specification = extern-sc type-specifier declarator. - extern-sc = [ extern | static ]. -=============================================================================*/ - -struct typestruct *extypespec() -{ - int sc; - - switch( sym ) - { - case EXTERNDECL: - case STATICDECL: - sc = sym; nextsym(); break; - default: - sc = EXTERNDECL; break; - } - return declarator( typespec() ); -} - -/*============================================================================= - parameter-list = [identifier { "," identifier }]. -=============================================================================*/ - -int paramlist() -{ - int nargs; - - locptr = pstartloc; - newlevel(); - nargs = 0; - while ( sym == IDENT ) - { - addloc( gsname, itype, 0 ); /* fix up types and offsets later */ - nextsym(); - ++nargs; - if ( sym != COMMA ) - break; - nextsym(); - } - return nargs; -} - -/*============================================================================= - arg-list = -=============================================================================*/ - -arglist( nargs ) -int nargs; -{ - struct symstruct *symptr; - int argsize, argsp; - int lastsym; - struct typestruct *basetype; - char declflag; - - declflag = TRUE; - do - { - switch( sym ) - { - case TYPEDECL: - basetype = gsymptr->type; - nextsym(); - getarg1( basetype ); - break; - case STRUCTDECL: - case UNIONDECL: - lastsym = sym; - nextsym(); - getarg( declsu( lastsym ) ); - break; - case AUTODECL: - case EXTERNDECL: - case REGDECL: - case STATICDECL: - case SEMICOLON: - nextsym(); - break; - default: - declflag = FALSE; - break; - } - } - while ( declflag ); - argsp = -2; - symptr = pstartloc; - while ( nargs && symptr < locptr ) /* convert arg sizes to offsets */ - { - argsize = symptr->offset; - if ( symptr->type == ctype ) - { - ++argsp; - --argsize; - } - symptr->offset = argsp; - argsp += argsize; - if ( symptr == pstartloc ) - argsp += 2; - --nargs; - ++symptr; - } - if ( nargs ) - error( "arguments not all declared" ); -} - -/* getarg( basetype ) - fill in argument types and sizes */ - -getarg1( basetype ) -struct typestruct *basetype; -{ - char sname[NAMESIZE]; - struct typestruct *type; - int size; - struct symstruct *symptr; - - if ( sym != SEMICOLON ) - while ( TRUE ) - { - type = basetype; - size = getvar( sname, &type ); - if ( (symptr = findlorg( sname )) == NULL || symptr->level != ARGLEVEL ) - error( "variable not in argument list" ); - else if ( symptr->offset != 0 ) /* already in arg list */ - multidecl( sname, type, symptr ); - else - { - if ( size < 2 || type->typeop == ATYPEOP ) - size = 2; - symptr->offset = size; - symptr->type = type; - } - if ( sym == COMMA ) - nextsym(); - else - break; - } - ns(); -} - -struct typestruct *declarator( basetype ) -struct typestruct *basetype; -{ - char sname[NAMESIZE]; - int size; - struct symstruct *multi; - - size = getvar( sname, &type ); - if ( multi = findlorg( sname ) ) - multidecl( sname, type, multi ); - else - addglb( sname, type, size ); - nextsym(); -} - -struct typestruct *typespec() -{ - int lastsym; - - switch( sym ) - { - case TYPEDECL: - nextsym(); - return gsymptr->type; - case STRUCTDECL: - case UNIONDECL: - lastsym = sym; - nextsym(); - return declsu( lastsym ); - default: - return itype; - } -} diff --git a/bcc/misc/test/hilbert.t b/bcc/misc/test/hilbert.t deleted file mode 100644 index e18dc63..0000000 --- a/bcc/misc/test/hilbert.t +++ /dev/null @@ -1,169 +0,0 @@ -/* hilbert.c */ - -/* S1 stuff - -#define PIFBUF ( *(struct IFBUF **) 0xf010 ) -#define PSET 2 - -struct IFBUF -{ - char ERR; - char COMMAND; - char COLOR; - char PLOTOPTION; - int LINESTYLE; - int X1; - int Y1; - int X2; - int Y2; - char BFFLAG; -}; -end of S1 stuff */ - -/* L3 stuff */ - -#define PIFBUF ( (struct IFBUF *) 0xa1 ) -#define PSET 1 - -struct IFBUF -{ - char PLOTOPTION; - char junk1[0xa8-0xa2]; - int X1; - int Y1; - int X2; - int Y2; - char junk2[0xf0-0xb0]; - char ERR; /* this to BFFLAG are dummies to keep S1 code */ - char COMMAND; - int LINESTYLE; - char BFFLAG; - char junk3[0x3ea-0xf5]; - char COLOR; -}; - -#define H0 512 /* square size */ -#define XOFFS 80 /* offset to centre square */ -#define XNUM 15 /* scale 512 * 15/16 = 480 */ -#define XDENOM 16 -#define YNUM 25 /* scale 512 * 25/64 = 200 */ -#define YDENOM 64 /* to give max height, dot ratio 480/200 = 2.4 */ - -int h, x, y; - -main() -{ - int i, x0, y0; - char color; - - PIFBUF->PLOTOPTION = PSET; - PIFBUF->LINESTYLE = /* normal */ - PIFBUF->COMMAND = /* ?? */ - PIFBUF->BFFLAG = 0; /* not a box */ - color = i = 0; - x0 = y0 = (h = H0)/2; - while ( h > 1 ) - { - ++i; - h = h/2; - if ( ++color > 7 ) - color = 1; - gcolor( color ); - x = x0 += h/2; - y = y0 += h/2; - glocate(); - a( i ); - } -} - -a( i ) -int i; -{ - if ( --i >= 0 ) - { - d( i ); x -= h; plot(); - a( i ); y -= h; plot(); - a( i ); x += h; plot(); - b( i ); - } -} - -b( i ) -int i; -{ - if ( --i >= 0 ) - { - c( i ); y += h; plot(); - b( i ); x += h; plot(); - b( i ); y -= h; plot(); - a( i ); - } -} - -c( i ) -int i; -{ - if ( --i >= 0 ) - { - b( i ); x += h; plot(); - c( i ); y += h; plot(); - c( i ); x -= h; plot(); - d( i ); - } -} - -d( i ) -int i; -{ - if ( --i >= 0 ) - { - a( i ); y -= h; plot(); - d( i ); x -= h; plot(); - d( i ); y += h; plot(); - c( i ); - } -} - -glocate() -{ - PIFBUF->X2 = x - x * (XDENOM - XNUM) / XDENOM + XOFFS; - PIFBUF->Y2 = (y * YNUM) / YDENOM; -} - -/* S1 gcolor and plot - -gcolor( color ) -int color; -{ - PIFBUF->COLOR = color; -} - -plot() -{ - PIFBUF->X1 = PIFBUF->X2; - PIFBUF->Y1 = PIFBUF->Y2; - glocate(); -#asm - SWI2 - FDB $4201 call LINEMA -#endasm -} - -end S1 plot */ - -gcolor( color ) -int color; -{ - PIFBUF->COLOR = color | 0x10; -} - -plot() -{ - PIFBUF->X1 = PIFBUF->X2; - PIFBUF->Y1 = PIFBUF->Y2; - glocate(); -#asm - JSR $D709 - JSR $D79A -#endasm -} diff --git a/bcc/misc/test/longtest.c b/bcc/misc/test/longtest.c deleted file mode 100644 index 0c0bfe0..0000000 --- a/bcc/misc/test/longtest.c +++ /dev/null @@ -1,24 +0,0 @@ -int i,j; -long m,n; - -main() -{ - while ( 1 ) - { - if ( scanf( "%ld %ld", &m, &n ) <= 0 ) - exit( 0 ); - printf( "m = %ld n = %ld m + n = %ld m - n = %ld m * n = %ld\n", - m, n, m + n, m - n, m * n ); - printf( "m = %ld n = %ld m / n = %ld m %% n = %ld\n", - m, n, m / n, m % n ); - printf( "m = %ld n = %ld m&n = %ld m | n = %ld m^n = %ld\n", - m, n, m & n, m | n, m ^ n ); - printf( "m = %ld n = %ld m << n = %ld m >> n = %ld\n", - m, n, m << (int) n, m >> (int) n ); - printf( - "m = %ld n = %ld m < n is %d m == n is %d m > n is %d m == 0 is %d\n", - m, n, m < n, m == n, m > n, m == 0 ); - printf( "m = %ld n = %ld -m = %ld ~m = %ld ++m = %ld --n = %ld\n", - m, n, -m, ~m, ++m, --n ); - } -} diff --git a/bcc/misc/test/longtest.dat b/bcc/misc/test/longtest.dat deleted file mode 100644 index a1c7998..0000000 --- a/bcc/misc/test/longtest.dat +++ /dev/null @@ -1,15 +0,0 @@ -1 1 --1 1 -1 -1 --1 -1 -2 3 -4 5 -234234 34554 -4534534 34535 -345324523 3245325 -345435345 319755 -34534 345 --352351235 23535 -533512351 -3535345 --351351313 -12235 -123456789 987654321 diff --git a/bcc/misc/test/longtest.mak b/bcc/misc/test/longtest.mak deleted file mode 100755 index 454a4e8..0000000 --- a/bcc/misc/test/longtest.mak +++ /dev/null @@ -1,3 +0,0 @@ -cc -o cclongtest longtest.c -sc longtest.c sclongtest.s -cc -o sclongtest sclongtest.s $HOME/lib/libcb.a $HOME/lib/liblb.a diff --git a/bcc/misc/test/longtest.sh b/bcc/misc/test/longtest.sh deleted file mode 100755 index e76f98a..0000000 --- a/bcc/misc/test/longtest.sh +++ /dev/null @@ -1,4 +0,0 @@ -./sclongtest < longtest.dat >scl.out -./cclongtest < longtest.dat >ccl.out -diff scl.out ccl.out >longtest.diff -cat longtest.diff diff --git a/bcc/misc/test/miniltest.t b/bcc/misc/test/miniltest.t deleted file mode 100644 index 78097d4..0000000 --- a/bcc/misc/test/miniltest.t +++ /dev/null @@ -1,72 +0,0 @@ -long x; -int i; -unsigned u; - -long test1(x) -long x; -{ - return x; -} - -long test2(x) -int x; -{ - return x; -} - -main() -{ - printlong( "x=1 is ", x = 1 ); - printlong( "test1(x) is ", test1(x) ); - printlong( "test1(1L) is ", test1(1L) ); - printlong( "x = test1(1L) is ", x = test1(1L) ); - printlong( "x = test1(x=1) is ", x = test1(x=1) ); - printlong( "i=1 is ", (long) (i = 1) ); - printlong( "test2(i) is ", test2(i) ); - printlong( "test2(1) is ", test2(1) ); - printlong( "i = test2(1) is ", (long) (i = test2(1)) ); - printlong( "i = test2(i=1) is ", (long) (i = test2(i=1)) ); - printlong( "(long) (i = -1) is ", (long) (i=-1) ); - printlong( "(long) (u = -1) is ", (long) (u=-1) ); - printlong( "x = -1 is ", x = -1 ); -} - -printlong( s, x ) -char *s; -long x; -{ - printf( "%s", s ); - if ( x & 0x80000000 ) - { - putchar( '-' ); - x = -x; - } - printf( "%08lx", (x >> 16) + (x << 16) ); - putchar( '\n' ); -} - -outulhex( pnum ) -char *pnum; -{ - int i; - - for ( i = 3; i >=0; --i ) - p2( pnum[i] ); -} - -p2(i) -int i; -{ - p1(i>>4); - p1(i); -} - -p1(num) -int num; -{ - int digit; - - if ( (digit = num & 0xf) >= 10 ) - digit += 'A' - ('9' + 1); - putchar( digit + '0' ); -} diff --git a/bcc/misc/test/op1.t b/bcc/misc/test/op1.t deleted file mode 100644 index 614e093..0000000 --- a/bcc/misc/test/op1.t +++ /dev/null @@ -1,120 +0,0 @@ -/* op1.t - test and, or (eor same as or ) */ - -char cfn(); -int ifn(); - -char *op1() -{ - char c, *pc, **ppc; - int i, *pi, **ppi; - - i = c & 1; - i = 1 & c; - i = i & 1; - i = 1 & i; - - i = c & 500; - i = 500 & c; - i = i & 500; - i = 500 & i; - - i = c | 1; - i = 1 | c; - i = i | 1; - i = 1 | i; - - i = c | 500; - i = 500 | c; - i = i | 500; - i = 500 | i; - - i = c & c; - i = c & i; - i = i & c; - i = i & i; - - i = c | c; - i = c | i; - i = i | c; - i = i | i; - - i = c & c++; - i = c & i++; - i = i & c++; - i = i & i++; - - i = c++ & c; - i = i++ & c; - i = c++ & i; - i = i++ & i; - - i = c | c++; - i = c | i++; - i = i | c++; - i = i | i++; - - i = c++ | c; - i = i++ | c; - i = c++ | i; - i = i++ | i; - - i = c & cfn(); - i = c & ifn(); - i = i & cfn(); - i = i & ifn(); - - i = cfn() & c; - i = ifn() & c; - i = cfn() & i; - i = ifn() & i; - - i = c | cfn(); - i = c | ifn(); - i = i | cfn(); - i = i | ifn(); - - i = cfn() | c; - i = ifn() | c; - i = cfn() | i; - i = ifn() | i; - - i = *pc & c++; - i = *pc & i++; - i = *pi & c++; - i = *pi & i++; - - i = c++ & *pc; - i = i++ & *pc; - i = c++ & *pi; - i = i++ & *pi; - - i = *pc | c++; - i = *pc | i++; - i = *pi | c++; - i = *pi | i++; - - i = c++ | *pc; - i = i++ | *pc; - i = c++ | *pi; - i = i++ | *pi; - - i = **ppc & c++; - i = **ppc & i++; - i = **ppi & c++; - i = **ppi & i++; - - i = c++ & **ppc; - i = i++ & **ppc; - i = c++ & **ppi; - i = i++ & **ppi; - - i = **ppc | c++; - i = **ppc | i++; - i = **ppi | c++; - i = **ppi | i++; - - i = c++ | **ppc; - i = i++ | **ppc; - i = c++ | **ppi; - i = i++ | **ppi; -} diff --git a/bcc/misc/test/opcmp.t b/bcc/misc/test/opcmp.t deleted file mode 100644 index 28bd1a2..0000000 --- a/bcc/misc/test/opcmp.t +++ /dev/null @@ -1,106 +0,0 @@ -/* opcmp.t - test logical compare operations */ - -/* only doing chars, shorts, ints and unsigneds */ -/* not doing longs, floats or doubles */ - -/* short = int, so only a few examples */ -/* unsigned like int, so only a few examples */ -/* all examples < */ - -op1() -{ - char c, *pc, **ppc, cfn(); - short s, *ps, **pps, sfn(); - int i, *pi, **ppi, ifn(); - unsigned u, *pu, **ppu, ufn(); - - c < 0; - 0 < c; - i < 0; - 0 < i; - - s < 0; - 0 < s; - - 0 < u; - u < 0; - 1 < u; - u < 1; - - c < 1; - 1 < c; - c < 500; - 500 < c; - - c < c; - c < i; - i < c; - i < i; - - s < c; - i < u; - - c < c++; - c < i++; - i < c++; - i < i++; - - s < i++; - c < u++; - - c++ < c; - i++ < c; - c++ < i; - i++ < i; - - s++ < c; - i++ < u; - - c < cfn(); - c < ifn(); - i < cfn(); - i < ifn(); - - s < cfn(); - c < ufn(); - - cfn() < c; - ifn() < c; - cfn() < i; - ifn() < i; - - sfn() < c; - ifn() < u; - - *pc < c++; - *pc < i++; - *pi < c++; - *pi < i++; - - *ps < c++; - *pi < u++; - - c++ < *pc; - i++ < *pc; - c++ < *pi; - i++ < *pi; - - s++ < *pc; - i++ < *pu; - - **ppc < c++; - **ppc < i++; - **ppi < c++; - **ppi < i++; - - **pps < c++; - **ppi < u++; - - c++ < **ppc; - i++ < **ppc; - c++ < **ppi; - i++ < **ppi; - - s++ < **ppc; - i++ < **ppu; -} diff --git a/bcc/misc/test/oplong.t b/bcc/misc/test/oplong.t deleted file mode 100644 index b452243..0000000 --- a/bcc/misc/test/oplong.t +++ /dev/null @@ -1,264 +0,0 @@ -/* oplong.t - test long operations */ - -/* this is just opsoft.t with int defined as long */ - -#define int long -#define UNSIGNED unsigned long - -/* only doing chars, shorts, ints and unsigneds */ -/* not doing longs, floats or doubles */ - -/* short = int, so only a few examples */ -/* unsigned like int, so only a few examples */ -/* most examples for DIVOP */ -/* only (all) special cases of MULOP, MODOP, SLOP and SROP are tried */ - -op1() -{ - char c, *pc, **ppc, cfn(); - short s, *ps, **pps, sfn(); - int i, *pi, **ppi, ifn(); - UNSIGNED u, *pu, **ppu, ufn(); - - i = c / 0; - i = 0 / c; - i = i / 0; - i = 0 / i; - - i = s / 0; - i = 0 / u; - - i = c / 1; - i = 1 / c; - i = i / 1; - i = 1 / i; - - i = s / 1; - i = 1 / u; - - i = c / 2; - i = 2 / c; - i = i / 2; - i = 2 / i; - - i = s / 2; - i = 2 / u; - - i = c / 500; - i = 500 / c; - i = i / 500; - i = 500 / i; - - i = s / 500; - i = 500 / u; - - i = c / c; - i = c / i; - i = i / c; - i = i / i; - - i = s / c; - i = i / u; - - i = c / c++; - i = c / i++; - i = i / c++; - i = i / i++; - - i = s / i++; - i = c / u++; - - i = c++ / c; - i = i++ / c; - i = c++ / i; - i = i++ / i; - - i = s++ / c; - i = i++ / u; - - i = c / cfn(); - i = c / ifn(); - i = i / cfn(); - i = i / ifn(); - - i = s / cfn(); - i = c / ufn(); - - i = cfn() / c; - i = ifn() / c; - i = cfn() / i; - i = ifn() / i; - - i = sfn() / c; - i = ifn() / u; - - i = *pc / c++; - i = *pc / i++; - i = *pi / c++; - i = *pi / i++; - - i = *ps / c++; - i = *pi / u++; - - i = c++ / *pc; - i = i++ / *pc; - i = c++ / *pi; - i = i++ / *pi; - - i = s++ / *pc; - i = i++ / *pu; - - i = **ppc / c++; - i = **ppc / i++; - i = **ppi / c++; - i = **ppi / i++; - - i = **pps / c++; - i = **ppi / u++; - - i = c++ / **ppc; - i = i++ / **ppc; - i = c++ / **ppi; - i = i++ / **ppi; - - i = s++ / **ppc; - i = i++ / **ppu; - - i = c * 0; - i = 0 * c; - i = i * 0; - i = 0 * i; - - i = s * 0; - i = 0 * u; - - i = c * 1; - i = 1 * c; - i = i * 1; - i = 1 * i; - - i = s * 1; - i = 1 * u; - - i = c * 2; - i = 2 * c; - i = i * 2; - i = 2 * i; - - i = s * 2; - i = 2 * u; - - i = c * 500; - i = 500 * c; - i = i * 500; - i = 500 * i; - - i = s * 500; - i = 500 * u; - - i = c * c; - i = c * c++; - i = c++ * c; - i = c * cfn(); - i = cfn() * c; - i = *pc * c++; - i = c++ * *pc; - i = **ppc * c++; - i = c++ * **ppc; - - i = c % 0; - i = 0 % c; - i = i % 0; - i = 0 % i; - - i = s % 0; - i = 0 % u; - - i = c % 1; - i = 1 % c; - i = i % 1; - i = 1 % i; - - i = s % 1; - i = 1 % u; - - i = c % 2; - i = 2 % c; - i = i % 2; - i = 2 % i; - - i = s % 2; - i = 2 % u; - - i = c % 500; - i = 500 % c; - i = i % 500; - i = 500 % i; - - i = s % 500; - i = 500 % u; - - i = c << 0; - i = 0 << c; - i = i << 0; - i = 0 << i; - - i = s << 0; - i = 0 << u; - - i = c << 1; - i = 1 << c; - i = i << 1; - i = 1 << i; - - i = s << 1; - i = 1 << u; - - i = c << 8; - i = 8 << c; - i = i << 8; - i = 8 << i; - - i = s << 8; - i = 8 << u; - - i = c << 9; - i = 9 << c; - i = i << 9; - i = 9 << i; - - i = s << 9; - i = 9 << u; - - i = c >> 0; - i = 0 >> c; - i = i >> 0; - i = 0 >> i; - - i = s >> 0; - i = 0 >> u; - - i = c >> 1; - i = 1 >> c; - i = i >> 1; - i = 1 >> i; - - i = s >> 1; - i = 1 >> u; - - i = c >> 8; - i = 8 >> c; - i = i >> 8; - i = 8 >> i; - - i = s >> 8; - i = 8 >> u; - - i = c >> 9; - i = 9 >> c; - i = i >> 9; - i = 9 >> i; - - i = s >> 9; - i = 9 >> u; -} diff --git a/bcc/misc/test/opplus.t b/bcc/misc/test/opplus.t deleted file mode 100644 index 88e31e9..0000000 --- a/bcc/misc/test/opplus.t +++ /dev/null @@ -1,122 +0,0 @@ -/* op+-.t - test plus, minus operators */ - -/* only doing chars and ints, not shorts, longs, floats, doubles */ -/* not doing pointer arithmetic */ - -op1() -{ - char cfn(); - int ifn(); - char c, *pc, **ppc; - int i, *pi, **ppi; - - i = c + 1; - i = 1 + c; - i = i + 1; - i = 1 + i; - - i = c + 500; - i = 500 + c; - i = i + 500; - i = 500 + i; - - i = c - 1; - i = 1 - c; - i = i - 1; - i = 1 - i; - - i = c - 500; - i = 500 - c; - i = i - 500; - i = 500 - i; - - i = c + c; - i = c + i; - i = i + c; /* -2 cycles, +1 byte different from c + i, lhs loaded 1st */ - i = i + i; - - i = c - c; - i = c - i; - i = i - c; - i = i - i; - - i = c + c++; - i = c + i++; - i = i + c++; - i = i + i++; - - i = c++ + c; - i = i++ + c; - i = c++ + i; - i = i++ + i; - - i = c - c++; - i = c - i++; - i = i - c++; - i = i - i++; - - i = c++ - c; - i = i++ - c; - i = c++ - i; - i = i++ - i; - - i = c + cfn(); - i = c + ifn(); - i = i + cfn(); - i = i + ifn(); - - i = cfn() + c; - i = ifn() + c; - i = cfn() + i; - i = ifn() + i; - - i = c - cfn(); - i = c - ifn(); - i = i - cfn(); - i = i - ifn(); - - i = cfn() - c; - i = ifn() - c; - i = cfn() - i; - i = ifn() - i; - - i = *pc + c++; - i = *pc + i++; - i = *pi + c++; - i = *pi + i++; - - i = c++ + *pc; - i = i++ + *pc; - i = c++ + *pi; - i = i++ + *pi; - - i = *pc - c++; - i = *pc - i++; - i = *pi - c++; - i = *pi - i++; - - i = c++ - *pc; - i = i++ - *pc; - i = c++ - *pi; - i = i++ - *pi; - - i = **ppc + c++; - i = **ppc + i++; - i = **ppi + c++; - i = **ppi + i++; - - i = c++ + **ppc; - i = i++ + **ppc; - i = c++ + **ppi; - i = i++ + **ppi; - - i = **ppc - c++; - i = **ppc - i++; - i = **ppi - c++; - i = **ppi - i++; - - i = c++ - **ppc; - i = i++ - **ppc; - i = c++ - **ppi; - i = i++ - **ppi; -} diff --git a/bcc/misc/test/opsoft.t b/bcc/misc/test/opsoft.t deleted file mode 100644 index 346df4d..0000000 --- a/bcc/misc/test/opsoft.t +++ /dev/null @@ -1,259 +0,0 @@ -/* opsoft.t - test software operations */ - -/* only doing chars, shorts, ints and unsigneds */ -/* not doing longs, floats or doubles */ - -/* short = int, so only a few examples */ -/* unsigned like int, so only a few examples */ -/* most examples for DIVOP */ -/* only (all) special cases of MULOP, MODOP, SLOP and SROP are tried */ - -op1() -{ - char c, *pc, **ppc, cfn(); - short s, *ps, **pps, sfn(); - int i, *pi, **ppi, ifn(); - unsigned u, *pu, **ppu, ufn(); - - i = c / 0; - i = 0 / c; - i = i / 0; - i = 0 / i; - - i = s / 0; - i = 0 / u; - - i = c / 1; - i = 1 / c; - i = i / 1; - i = 1 / i; - - i = s / 1; - i = 1 / u; - - i = c / 2; - i = 2 / c; - i = i / 2; - i = 2 / i; - - i = s / 2; - i = 2 / u; - - i = c / 500; - i = 500 / c; - i = i / 500; - i = 500 / i; - - i = s / 500; - i = 500 / u; - - i = c / c; - i = c / i; - i = i / c; - i = i / i; - - i = s / c; - i = i / u; - - i = c / c++; - i = c / i++; - i = i / c++; - i = i / i++; - - i = s / i++; - i = c / u++; - - i = c++ / c; - i = i++ / c; - i = c++ / i; - i = i++ / i; - - i = s++ / c; - i = i++ / u; - - i = c / cfn(); - i = c / ifn(); - i = i / cfn(); - i = i / ifn(); - - i = s / cfn(); - i = c / ufn(); - - i = cfn() / c; - i = ifn() / c; - i = cfn() / i; - i = ifn() / i; - - i = sfn() / c; - i = ifn() / u; - - i = *pc / c++; - i = *pc / i++; - i = *pi / c++; - i = *pi / i++; - - i = *ps / c++; - i = *pi / u++; - - i = c++ / *pc; - i = i++ / *pc; - i = c++ / *pi; - i = i++ / *pi; - - i = s++ / *pc; - i = i++ / *pu; - - i = **ppc / c++; - i = **ppc / i++; - i = **ppi / c++; - i = **ppi / i++; - - i = **pps / c++; - i = **ppi / u++; - - i = c++ / **ppc; - i = i++ / **ppc; - i = c++ / **ppi; - i = i++ / **ppi; - - i = s++ / **ppc; - i = i++ / **ppu; - - i = c * 0; - i = 0 * c; - i = i * 0; - i = 0 * i; - - i = s * 0; - i = 0 * u; - - i = c * 1; - i = 1 * c; - i = i * 1; - i = 1 * i; - - i = s * 1; - i = 1 * u; - - i = c * 2; - i = 2 * c; - i = i * 2; - i = 2 * i; - - i = s * 2; - i = 2 * u; - - i = c * 500; - i = 500 * c; - i = i * 500; - i = 500 * i; - - i = s * 500; - i = 500 * u; - - i = c * c; - i = c * c++; - i = c++ * c; - i = c * cfn(); - i = cfn() * c; - i = *pc * c++; - i = c++ * *pc; - i = **ppc * c++; - i = c++ * **ppc; - - i = c % 0; - i = 0 % c; - i = i % 0; - i = 0 % i; - - i = s % 0; - i = 0 % u; - - i = c % 1; - i = 1 % c; - i = i % 1; - i = 1 % i; - - i = s % 1; - i = 1 % u; - - i = c % 2; - i = 2 % c; - i = i % 2; - i = 2 % i; - - i = s % 2; - i = 2 % u; - - i = c % 500; - i = 500 % c; - i = i % 500; - i = 500 % i; - - i = s % 500; - i = 500 % u; - - i = c << 0; - i = 0 << c; - i = i << 0; - i = 0 << i; - - i = s << 0; - i = 0 << u; - - i = c << 1; - i = 1 << c; - i = i << 1; - i = 1 << i; - - i = s << 1; - i = 1 << u; - - i = c << 8; - i = 8 << c; - i = i << 8; - i = 8 << i; - - i = s << 8; - i = 8 << u; - - i = c << 9; - i = 9 << c; - i = i << 9; - i = 9 << i; - - i = s << 9; - i = 9 << u; - - i = c >> 0; - i = 0 >> c; - i = i >> 0; - i = 0 >> i; - - i = s >> 0; - i = 0 >> u; - - i = c >> 1; - i = 1 >> c; - i = i >> 1; - i = 1 >> i; - - i = s >> 1; - i = 1 >> u; - - i = c >> 8; - i = 8 >> c; - i = i >> 8; - i = 8 >> i; - - i = s >> 8; - i = 8 >> u; - - i = c >> 9; - i = 9 >> c; - i = i >> 9; - i = 9 >> i; - - i = s >> 9; - i = 9 >> u; -} diff --git a/bcc/misc/test/puzzle.t b/bcc/misc/test/puzzle.t deleted file mode 100644 index 9d2c4ab..0000000 --- a/bcc/misc/test/puzzle.t +++ /dev/null @@ -1,178 +0,0 @@ -/* puzzle.t - from C puzzle book */ - -#define puzzle(which) ( puts( "-----which-----\n" ), which() ) - -main() -{ - puzzle( op1 ); - puzzle( op2 ); - puzzle( op3 ); - puzzle( op4 ); - puzzle( op5 ); - puzzle( op6 ); - puzzle( prep1 ); - puzzle( prep2 ); -} - -op1() -{ - int x; - - x = - 3 + 4 * 5 - 6; printf("%d\n",x); - x = 3 + 4 % 5 - 6; printf("%d\n",x); - x = - 3 * 4 % - 6 / 5; printf("%d\n",x); - x = ( 7 + 6 ) % 5 /2; printf("%d\n",x); -} - -#define PRINTX printf( "%d\n", x ) - -op2() -{ - int x, y, z; - - x = 2; - x *= 3 + 2; PRINTX; - x *= y = z = 4; PRINTX; - x = y == z; PRINTX; - x == (y == z); PRINTX; -} - -#define PRINT(int) printf( "int = %d\n", int ) - -op3() -{ - int x, y, z; - - x = 2; y = 1; z = 0; - x = x && y || z; PRINT(x); - PRINT( x || ! y && z ); - - x = y = 1; - z = x ++ - 1; PRINT(x); PRINT(z); - z += - x ++ + ++ y;PRINT(x);PRINT(z); - z = x / ++ x; PRINT(z); -} - -op4() -{ - int x, y, z; - - x = 03; y = 02; z = 01; - PRINT( x | y & z ); - PRINT( x | y & ~ z ); - PRINT( x ^ y & ~ z ); - PRINT( x & y && z ); - - x = 1; y = -1; - PRINT( ! x | x ); - PRINT( ~ x | x ); - PRINT( x ^ x ); - x <<= 3; PRINT(x); - y <<= 3; PRINT(y); - y >>= 3; PRINT(y); -} - -op5() -{ - int x, y, z; - - x = 1; y = 1; z = 1; - - x += y += z; - PRINT( x < y ? y : x ); - - PRINT( x < y ? x ++ : y ++ ); - PRINT(x); PRINT(y); - - PRINT( z += x < y ? x ++ : y ++ ); - PRINT(y); PRINT(z); - - x = 3; y=z=4; - PRINT( (z >= y >= x) ? 1 : 0 ); - PRINT( z >= y && y >= x ); -} - -#define PRINT3(x,y,z) printf("x=%d\ty=%d\tz=%d\n",x,y,z) - -op6() -{ - int x, y, z; - - x = y = z = 1; - ++x || ++y && ++z; PRINT3(x,y,z); - - x = y = z = 1; - ++x && ++y || ++z; PRINT3(x,y,z); - - x = y = z = 1; - ++x && ++y && ++z; PRINT3(x,y,z); - - x = y = z = -1; - ++x && ++y || ++z; PRINT3(x,y,z); - - x = y = z = -1; - ++x || ++y && ++z; PRINT3(x,y,z); - - x = y = z = -1; - ++x && ++y && ++z; PRINT3(x,y,z); -} - -#define FUDGE(k) k+3 -#define PR(a) printf("a= %d\t",(int)(a)) -#define PRINTNEW(a) PR(a); putchar( '\n' ); -#define PRINT2(a,b) PR(a); PRINT(b) -#define PRINT3NEW(a,b,c) PR(a); PRINT2(b,c) -#define MAX(a,b) (a<b ? b : a ) - -prep1() -{ - { - int x; - x = 2; - PRINTNEW( x*FUDGE(2) ); - } - { - int cel; - for( cel=0; cel<=100; cel+=50 ) - PRINT2( cel, 9/5*cel+32 ); - } - { - int x, y; - x=1; y=2; - PRINT3NEW( MAX(x++,y),x,y ); - PRINT3NEW( MAX(x++,y),x,y ); - } -} - -#define NEG(a)-a -#define weeks(mins) (days(mins)/7) -#define days(mins) (hours(mins)/24) -#define hours(mins) (mins/60) -#define mins(secs) (secs/60) -#define TAB(c,i,oi,tx) if(c=='\t')\ - for(tx=8-(i-oi-1)%8,oi=i; tx; tx--)\ - putchar(' ') - -static char *input = "\twhich\tif?"; - -prep2() -{ - { - int x; - x=1; - PRINT( -NEG(x) ); - } - { - PRINT( weeks(10080) ); - PRINT( days(mins(86400)) ); - } - { - char c; - int i, oldi, temp; - - for( oldi= -1,i=0; (c=input[i])!='\0'; i++ ) - if( c<' ' ) TAB(c,i,oldi,temp); - else putchar(c); - putchar('\n'); - } -} diff --git a/bcc/misc/test/sierpin.t b/bcc/misc/test/sierpin.t deleted file mode 100644 index 79016f7..0000000 --- a/bcc/misc/test/sierpin.t +++ /dev/null @@ -1,123 +0,0 @@ -/* sierpin.t */ - -#define PPIFBUF 0xf010 /* address of ptr to IFBUF */ -#define PSET 2 /* use this plot option */ - -struct IFBUF -{ - char ERR; - char COMMAND; - char COLOR; - char PLOTOPTION; - int LINESTYLE; - int X1; - int Y1; - int X2; - int Y2; - char BFFLAG; -}; - -#define H0 512 /* square size */ -#define XOFFS 80 /* offset to centre square */ -#define XNUM 15 /* scale 512 * 15/16 = 480 */ -#define XDENOM 16 -#define YNUM 25 /* scale 512 * 25/64 = 200 */ -#define YDENOM 64 /* to give max height, dot ratio 480/200 = 2.4 */ - -struct IFBUF *pifbuf; -int h, x, y; - -main() -{ - struct IFBUF **ppifbuf; /* required since no casts */ - int i, x0, y0; - char color; - - pifbuf = *(ppifbuf = PPIFBUF); /* pifbuf = *(struct IFBUF **)PPIFBUF; */ - pifbuf->PLOTOPTION = PSET; - pifbuf->LINESTYLE = /* normal */ - pifbuf->COMMAND = /* ?? */ - pifbuf->BFFLAG = 0; /* not a box */ - color = i = 0; - x0 = 2 * (h = H0/4); - y0 = 3 * (H0/4); - while ( h > 1 ) - { - ++i; - if ( ++color > 7 ) - color = 1; - pifbuf->COLOR = color; - x = x0 -= h; - y = y0 += h /= 2; - glocate(); - a( i ); x += h; y -= h; plot(); - b( i ); x -= h; y -= h; plot(); - c( i ); x -= h; y += h; plot(); - d( i ); x += h; y += h; plot(); - } -} - -a( i ) -int i; -{ - if ( --i >= 0 ) - { - a( i ); x += h; y -=h; plot(); - b( i ); x += 2*h; plot(); - d( i ); x += h; y += h; plot(); - a( i ); - } -} - -b( i ) -int i; -{ - if ( --i >= 0 ) - { - b( i ); x -= h; y -=h; plot(); - c( i ); y -= 2*h; plot(); - a( i ); x += h; y -= h; plot(); - b( i ); - } -} - -c( i ) -int i; -{ - if ( --i >= 0 ) - { - c( i ); x -= h; y +=h; plot(); - d( i ); x -= 2*h; plot(); - b( i ); x -= h; y -= h; plot(); - c( i ); - } -} - -d( i ) -int i; -{ - if ( --i >= 0 ) - { - d( i ); x += h; y +=h; plot(); - a( i ); y += 2*h; plot(); - c( i ); x -= h; y += h; plot(); - d( i ); - } -} - -glocate() -{ - pifbuf->X2 = x - x * (XDENOM - XNUM) / XDENOM + XOFFS; - pifbuf->Y2 = (y * YNUM) / YDENOM; -} - -plot() -{ - pifbuf->X1 = pifbuf->X2; - pifbuf->Y1 = pifbuf->Y2; - glocate(); -#asm - SWI2 - FDB $4201 call LINEMA -#endasm -} diff --git a/bcc/misc/test/sievec.t b/bcc/misc/test/sievec.t deleted file mode 100644 index 1b51fdb..0000000 --- a/bcc/misc/test/sievec.t +++ /dev/null @@ -1,28 +0,0 @@ -#define TRUE 1 -#define FALSE 0 -#define SIZE 8190 - -char flags[SIZE+1]; - -main() -{ - int i,prime,k,count,iter; - - for (iter=0;iter<10;iter++) - { - count=0; - for (i=0;i<=SIZE;i++) - flags[i]=TRUE; - for (i=0;i<=SIZE;i++) - { - if (flags[i]) - { - prime=i+i+3; - for (k=i+prime;k<=SIZE;k=k+prime) - flags[k]=FALSE; - count++; - } - } - } - printf( "%d primes\n", count ); -} diff --git a/bcc/misc/test/sievecp.t b/bcc/misc/test/sievecp.t deleted file mode 100644 index 185b031..0000000 --- a/bcc/misc/test/sievecp.t +++ /dev/null @@ -1,45 +0,0 @@ -/* sieve using pointers */ - -#define TRUE 1 -#define FALSE 0 -#define NITER 100 -#define SIZE 8191 /* last prime <= 2*this+3 */ -#define SQRSIZE 63 /* last divisor tested = 2*this+3 */ - -char flags[SIZE+2*SQRSIZE+3]; /* avoid ptr+=prime overflowing */ - -main() -{ - int i,count,iter; - register char *ptr; - char *endptr; - int prime; - - for (iter=0;iter<NITER;iter++) - { - count=0; - ptr=flags; - endptr=flags+SIZE; - while (ptr<endptr) - *ptr++=TRUE; - for (i=0;i<SQRSIZE;i++) - { - if (flags[i]) - { - prime=i+i+3; - ptr=flags+i+prime; /* ptr<endptr since i<SQRSIZE */ - while (ptr<endptr) - { - *ptr=FALSE; - ptr+=prime; /* does not overflow since in flags */ - } - count++; - } - } - ptr=flags+SQRSIZE; - while (ptr<endptr) - if (*ptr++) - count++; - } - printf( "%d primes\n", count ); -} diff --git a/bcc/misc/test/sievei.t b/bcc/misc/test/sievei.t deleted file mode 100644 index d4910dc..0000000 --- a/bcc/misc/test/sievei.t +++ /dev/null @@ -1,28 +0,0 @@ -#define TRUE 1 -#define FALSE 0 -#define SIZE 8190 - -int flags[SIZE+1]; - -main() -{ - int i,prime,k,count,iter; - - for (iter=0;iter<10;iter++) - { - count=0; - for (i=0;i<=SIZE;i++) - flags[i]=TRUE; - for (i=0;i<=SIZE;i++) - { - if (flags[i]) - { - prime=i+i+3; - for (k=i+prime;k<=SIZE;k=k+prime) - flags[k]=FALSE; - count++; - } - } - } - printf( "%d primes\n", count ); -} diff --git a/bcc/misc/test/sort.t b/bcc/misc/test/sort.t deleted file mode 100644 index 34bcb9e..0000000 --- a/bcc/misc/test/sort.t +++ /dev/null @@ -1,104 +0,0 @@ -unsigned t[10000]; -unsigned s[10000]; -unsigned size,repet; -unsigned comp=0,swap=0; /* s.b. long */ - -main(argc) -{ - int i,zz; - -/* - printf("size?"); - scanf("%d",&size); - printf("repet?"); - scanf("%d",&repet); -*/ - if ( argc > 20 ) - { - printf( "usage: sort [args], where 500*argc is the array size\n" ); - exit( 1 ); - } - size = 500 * argc; - repet = 1; - for (i = 0; i < size; i++) - s[i] = size-i; - printf("\npress key to begin shell sorting\n"); - getchar(); - for (zz=0;zz<repet;zz++) - { - comp=swap=0; - for (i=0;i<size;i++) - t[i]=s[i]; - sort(); - } - printf("\nsorted\n"); - printf("\ncompares = %d, swaps = %d\n",comp,swap); - printf("\npress key to begin quick sorting\n"); - getchar(); - for (zz=0;zz<repet;zz++) - { - comp=swap=0; - for (i=0;i<size;i++) - t[i]=s[i]; - qqsort(); - } - printf("\nsorted\n"); - printf("\ncompares = %d, swaps = %d\n",comp,swap); -} - -sort() -{ - int i,j,h,temp; - - h=1; - while (9*h+4<size) - h=3*h+1; - while (h>0) - { - for (j=h; j<size; j++) - for (i=j-h; i>=0; i-=h) - { - ++comp; - if (t[i]<=t[i+h]) - break; - ++swap; - temp=t[i]; - t[i]=t[i+h]; - t[i+h]=temp; - } - h=(h-1)/3; - } -} - -qqsort() -{ - qsort(0,size-1); -} - -qsort(l,r) -int l,r; -{ - int i,j; - unsigned x,w; - - i=l;j=r; - x=t[(l+r)>>1]; - do - { - while (t[i] < x) - { - ++comp; - i++; - } - while (x < t[j]) {--j;} - if (i<=j) - { - ++swap; - w=t[i];t[i]=t[j];t[j]=w; - i++;j--; - } - } - while (i<=j); - if (l<j) qsort(l,j); - if (i<r) qsort(i,r); -} diff --git a/bcc/misc/test/stdio.t b/bcc/misc/test/stdio.t deleted file mode 100644 index e7e174d..0000000 --- a/bcc/misc/test/stdio.t +++ /dev/null @@ -1,87 +0,0 @@ -/* stdio.h */ - -#asm - -#define BUFSIZ 512 -#define _NFILE 20 - -#define _IOREAD 1 -#define _IOWRITE 2 -#define _IODIRTY 4 -#define _IOEOF 8 -#define _IOERR 16 -#define _IOMYBUF 32 /* says if stream routines allocated buffer */ -#define _IOUNBUF 64 - -#define EOF (-1) -#define NULL 0 - -#endasm - -#define stdin (&_iob[0]) -#define stdout (&_iob[1]) -#define stderr (&_iob[2]) - -#define FILE struct _iobuf - -struct _iobuf -{ - char *_ptr; - char *_base; - char *_rtop; - char *_wtop; - char _flags; - char _fd; -} - _iob[_NFILE]; - -#define clearerr(fp) ((fp)->flags&=~_IOERR) -#define getchar() getc(stdin) -#define feof(fp) ((fp)->_flags&_IOEOF) -#define ferror(fp) ((fp)->_flags&_IOERR) -#define fileno(fp) ((fp)->_fd) -#define putchar(c) putc((c),stdout) - -#define void int - -FILE *fdopen(); -char *fgets(); -FILE *fopen(); -FILE *freopen(); -long ftell(); - -long lseek(); -unsigned read(); -unsigned write(); - -char *malloc(); -char *realloc(); -char *sbrk(); - -char *index(); -char *rindex(); -char *strcat(); -char *strcpy(); -char *strncat(); -char *strncpy(); - -#asm - -BLANK EQU 32 -COEOL EQU 10 -EOL EQU 13 -MAXCONTROL EQU 31 - -* struct _iobuf translated into offsets - - BLOCK 0 -PTR RMB 2 -BASE RMB 2 -RTOP RMB 2 -WTOP RMB 2 -FLAGS RMB 1 -FD RMB 1 -IOB.SIZE - ENDB - -#endasm diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 66a87c4..6efa75b 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -19,7 +19,8 @@ all: bootbin bootsys default tgz bootsys: bootfile.sys boottar.sys bootminix.sys CSRC=minix.c -SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s +SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s \ + boot_fpy.s encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v msdos16.v bootbin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin minix_elks.bin @@ -46,7 +47,7 @@ fs_min.o: minix.h bootfile.sys: $(MSRC) $(MINC) @rm -f $(MOBJ) - make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY -i' monitor.out + make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY -i -d' monitor.out mv monitor.out bootfile.sys @rm -f $(MOBJ) diff --git a/bootblocks/README b/bootblocks/README index 80a447e..81fc634 100644 --- a/bootblocks/README +++ b/bootblocks/README @@ -54,8 +54,8 @@ Contents as my testing has gone this is only significant on 8086 machines, all others (286 8Mhz +) are fast enough to keep up at a 1-1 interleve. - But beware some older versions of superformat defeat this because - they do not correctly calculate intersector gaps. + But some older versions of superformat defeat this because they do + not correctly calculate intersector gaps. 1.3 ) Minixfs boot block @@ -146,8 +146,7 @@ Contents at the prompt '>' where 'linux' is the name of the bzImage file. Escape or ^C will interrupt the boot and drop you to the '>' prompt. - Esacpe or ^C at the '>' prompt will reboot - (This may be a little too sensitive :-) + ^C at the '>' prompt will reboot A file called 'help.txt' will be displayed upto the first line that starts with a '%', chunks after that (seperated by '%'s) will be displayed when diff --git a/bootblocks/boot_fpy.s b/bootblocks/boot_fpy.s new file mode 100644 index 0000000..ef1f21a --- /dev/null +++ b/bootblocks/boot_fpy.s @@ -0,0 +1,203 @@ +! This binary is for loading a dev86 a.out file from a floppy without +! a filesystem; to make a bootable disk just do: +! +! cat boot_fpy.bin monitor.out > /dev/fd0 +! +! Warning: Disk errors currently cause a hang. +! The boot sector does not end with $AA55 this is not a problem +! with the BIOS but many boot managers will not boot it. + +ORGADDR=0x0600 +EXEADDR=0x06E0 +LOADSEG=0x0080 ! Must be 512b aligned for DMA + +.org EXEADDR-1 +.byte 0xFF ! Marker + +.org ORGADDR +entry start +public start +start: + mov ax,#$07C0 ! Relocate to ORGADDR + mov ds,ax + xor ax,ax + mov es,ax + mov cx,#256 + mov si,ax + mov di,#ORGADDR + cld + rep + movsw + jmpi go,#0 +go: + mov ds,ax ! Setup SP & S-regs + mov ss,ax + mov sp,#ORGADDR + mov ax,[a_text] ! How many sectors to load + mov cl,#4 + shr ax,cl + mov bx,ax + mov ax,[a_data] + mov cl,#4 + shr ax,cl + add ax,bx + add ax,#$1F + mov cl,#5 + shr ax,cl ! ax = sectors to read + + ! This routine starts by loading one sector at a time, with most + ! modern PCs the processor is fast enough to keep up with single + ! sector reads, in reality an 8Mhz 286 can keep up! + ! But occasionally some older machines have really poor BIOSes + ! (Some modern ones too) so once we know how many sectors to read + ! we switch to reading a track at a time. But we only try it once + ! for each track, normally, as long as the load address is sector + ! aligned, this will work every time but with some BIOSes we can't + ! read a track without messing with the BPB so if the track read + ! fails it's one try we fall back to sector reads. + ! + ! Overall this usually gives good performance, and with a BIOS that + ! isn't completely broken and correctly formatted floppies will run + ! at about 2.5 rotations per cylinder (1.25 per track). If you find + ! your BIOS is one of the bad ones you'll have to format your disks + ! to a 2:1 interleave. + ! + ! BTW: There are some versions of superformat that incorrectly + ! calculate the inter-sector gaps and end up squeezing the sectors + ! to the start of the track. This means that only a full track read + ! is fast enough. + + ! AX = count of sectors + mov cx,#2 ! CX = First sector + mov bx,#LOADSEG ! ES:BX = Where to load + mov es,bx + xor bx,bx ! Initial offset + + xor dx,dx ! DX = Drive 0 + + ! ax=cnt, dl=drv, ch=*, dh=*, cl=sec, es:bx=buffer. + +read_data: + mov si,ax ! Save big count. + xor ch,ch + xor dh,dh + + mov maxsect,cl ! Save first sector. + +load_loop: + mov di,#5 ! Error retry. + +sect_retry: + mov ax,#$0201 + ! ah=2, al=1, dl=drv, ch=cyl, dh=head, cl=sec, es:bx=buffer. + int $13 + jnc next_sect + + dec di ! Retry counter + jz sect_error + + cmp cl,maxsect ! If this is first sector or previously ok sector + jle sect_retry ! number then retry. + + mov maxsect,cl + j inc_trk + +next_sect: + mov ax,es ! Inc load address. + add ax,#32 + mov es,ax + + dec si ! Had enough ? + jz all_loaded + +inc_sect: + inc cl + cmp cl,maxsect + jnz load_loop +inc_trk: ! Reached end of track, seek to next. + mov cl,#1 + xor dh,cl + jnz load_track + inc ch +load_track: + cmp si,maxsect ! Is the whole track needed ? + jb load_loop ! no, goto load_loop for 1 by 1 + + ! Try to load the track _once_ only, if it fails go 1 by 1 again. + + mov ax,maxsect + dec ax + mov ah,#$02 + ! ah=2, al=*, dl=drv, ch=cyl, dh=head, cl=sec, es:bx=buffer. + int $13 + jc load_loop + + mov ax,maxsect ! Ok that worked, update the pointers + dec ax + mov cl,#5 + shl ax,cl + mov di,es + add ax,di + mov es,ax + + inc si + sub si,maxsect + jnz inc_trk + +all_loaded: + + xor dx,dx ! DX=0 => floppy drive + push dx ! CX=0 => partition offset = 0 + mov si,dx ! Sect/track = 0 + + mov bx,#EXEADDR>>4 + mov ds,bx ! DS = loadaddress + xor di,di ! Zero + mov ax,[di+2] + and ax,#$20 ! Is it split I/D ? + jz impure ! No ... + mov cl,#4 + mov ax,[di+8] + shr ax,cl +impure: + pop cx ! Partition offset. + inc bx + inc bx ! bx = initial CS + add ax,bx + mov ss,ax + mov sp,[di+24] ! Chmem value + mov ds,ax + + ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=* + +bad_magic: + push bx ! jmpi 0,#LOADSEG+2 + push di + retf + +sect_error: + ! TODO Error. + j sect_error + +maxsect: + .word 0 + +! Check for overlap +end_of_code: + if end_of_code>hitme + fail! Overlap at end_of_code + endif + +.org EXEADDR +hitme: + +magic: .space 2 ! A.out header +btype: .space 2 +headerlen: .space 4 +a_text: .space 4 +a_data: .space 4 +a_bss: .space 4 +a_entry: .space 4 +a_total: .space 4 +a_syms: .space 4 + diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c index fac9017..8540cd6 100644 --- a/bootblocks/bzimage.c +++ b/bootblocks/bzimage.c @@ -113,6 +113,7 @@ char * command_line; #endif low_sects = buffer[497] + 1; /* setup sects + boot sector */ + if (low_sects == 1) low_sects = 5; image_length = (file_length()+511)/512 - low_sects; address = 0x900; @@ -154,11 +155,11 @@ char * command_line; printf("%dk to go \r", (int)(len/1024)); fflush(stdout); #ifndef NOCOMMAND - v = (bios_khit()&0x7F); + v = (kbhit()&0x7F); if( v == 3 || v == 27 ) { printf("User interrupt!\n"); - bios_getc(); + getch(); return -1; } #endif @@ -332,36 +333,42 @@ register char * image_buf; { is_zimage = 0; - /* Boot sector magic number */ + /* Boot sector magic numbers */ if( *(unsigned short*)(image_buf+510) != 0xAA55 || - - /* Setup start */ - memcmp(image_buf+0x202, "HdrS", 4) != 0 || - - /* Setup version */ - *(unsigned short*)(image_buf+0x206) < 0x200 ) + memcmp(image_buf, "\270\300\007\216") != 0 ) { printf("File %s is not a linux Image file\n", fname); return -1; } - /* Code 32 start address for zImage */ - if( *(unsigned long*)(image_buf+0x214) == 0x1000 ) - { - printf("File %s is a zImage file\n", fname); - is_zimage = 1; - return 0; - } - else - /* Code 32 start address bzImage */ - if( *(unsigned long*)(image_buf+0x214) != 0x100000 ) + /* Setup start */ + if ( memcmp(image_buf+0x202, "HdrS", 4) == 0 && + /* Setup version */ + *(unsigned short*)(image_buf+0x206) >= 0x200 ) { - printf("File %s is a strange Image file\n", fname); - return -1; + /* Code 32 start address for zImage */ + if( *(unsigned long*)(image_buf+0x214) == 0x1000 ) + { + printf("File %s is a zImage file\n", fname); + is_zimage = 1; + return 0; + } + else + /* Code 32 start address bzImage */ + if( *(unsigned long*)(image_buf+0x214) == 0x100000 ) + { + printf("File %s is a bzImage file\n", fname); + return 0; + } } - printf("File %s is a bzImage file\n", fname); + is_zimage = 1; + printf("File %s is an old Image file\n", fname); +#if ZIMAGE_LOAD_SEG == 0x10000 return 0; +#else + return -1; +#endif } #ifndef __ELKS__ @@ -516,7 +523,14 @@ static char * image_str = "BOOT_IMAGE="; free(ptr); } else if( inp == 0 ) + { inp = free_inp = input_cmd(image); + if( inp == 0 ) + { + printf("\nAborted\n"); + return -1; + } + } if( auto_flag ) len += strlen(auto_str) + 1; if( image ) len += strlen(image_str) + strlen(image) + 1; @@ -685,11 +699,11 @@ unsigned int k_top; for( ; rd_len>0 ; rd_len--) { #ifndef NOCOMMAND - int v = (bios_khit()&0x7F); + int v = (kbhit()&0x7F); if( v == 3 || v == 27 ) { printf("User interrupt!\n"); - bios_getc(); + getch(); return -1; } #endif @@ -727,6 +741,7 @@ check_crc() __movedata(address*16, 0, __get_ds(), buffer, 512); low_sects = buffer[497] + 1; /* setup sects + boot sector */ + if (low_sects == 1) low_sects = 5; for(len=image_size; len>0; len-=512) { diff --git a/bootblocks/commands.c b/bootblocks/commands.c index 9720cfe..d39aa60 100644 --- a/bootblocks/commands.c +++ b/bootblocks/commands.c @@ -155,6 +155,7 @@ cmd_regs() printf(": AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x", __argr.x.ax, __argr.x.bx, __argr.x.cx, __argr.x.dx, __argr.x.si, __argr.x.di); + printf(" CF=%x", __argr.x.cflag); printf(" CS=%04x DS=%04x ES=%04x\n", __get_cs(), __get_ds(), __get_es()); #else printf("Only in standalone\n"); diff --git a/bootblocks/fs.c b/bootblocks/fs.c index 47faffc..ec3e0a6 100644 --- a/bootblocks/fs.c +++ b/bootblocks/fs.c @@ -13,6 +13,9 @@ char * fname; #endif if( fs_type ) close_file(); + /* If we can't read the boot sector there is a _real_ problem */ + if (read_sector(0) == 0) return -1; + if( tar_open_file(fname) >= 0 ) { fs_type = 1; return 0; } if( min_open_file(fname) >= 0 ) { fs_type = 2; return 0; } if( dos_open_file(fname) >= 0 ) { fs_type = 3; return 0; } diff --git a/bootblocks/fs_tar.c b/bootblocks/fs_tar.c index ccab3b5..6a5c6ca 100644 --- a/bootblocks/fs_tar.c +++ b/bootblocks/fs_tar.c @@ -168,7 +168,7 @@ char * buffer; { printf("Please insert next disk and press return:"); fflush(stdout); - while( (k=(bios_getc() & 0x7F)) != '\r' && k != '\n') + while( (k=(getch() & 0x7F)) != '\r' && k != '\n') if( k == 27 || k == 3 ) { printf("... Aborting\n"); diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c index 7b88da2..dd9ec33 100644 --- a/bootblocks/i86_funcs.c +++ b/bootblocks/i86_funcs.c @@ -109,6 +109,8 @@ void cpu_check() #ifdef __STANDALONE__ x86_test = x86_emu; + if (__argr.x.cflag) + x86_test = 1; #else x86_test = 1; #endif diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s index d071a8b..e633c87 100644 --- a/bootblocks/mbr.s +++ b/bootblocks/mbr.s @@ -327,9 +327,9 @@ more_boot: jz load_done mov bx,ax ! word 1 address lodsw - mov cx,ax ! word 2 CX, head/sector + mov cx,ax ! word 2 CX, cylinder/sector lodsw - mov dx,ax ! word 3 DX, drive, cylinder + mov dx,ax ! word 3 DX, drive, head lodsw ! word 4 AX, $02, sector count int $13 jnc more_boot ! This doesn't retry, with a HD it shouldn't be bad. @@ -353,19 +353,16 @@ pre_boot_table: ! .word <execute address> ! Then repeat .. ! .word <BX>, <CX>, <DX>, <AX> + ! Or. + ! .word <Load Address> + ! .byte <sector> + (<cyl> & $300)>>2), <cyl> & $FF, <Drive>, <Head>, <cnt>, 2 ! Finally ! .word 0 ! Example: Load rest of H0,C0 into mem at $7C00 (8k). - ! .word $7C00, $7C00,$0002,$8000,$0210, $0000 - - ! Example: Use single LBA call - ! .word <execute address> - ! .word 0,0,$8000,$4200, $0010 - ! .word <number of blocks> - ! .long <transfer buffer> - ! .long <start block number> - ! .long <start block number high 4 bytes> + ! .word $7C00 + ! .word $7C00,$0002,$8000,$0210 + ! .word $0000 endif !-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c index 2e47da8..27f25ea 100644 --- a/bootblocks/monitor.c +++ b/bootblocks/monitor.c @@ -32,29 +32,33 @@ static char minibuf[2] = " "; #endif init_prog(); + + if (!x86_test) + { #ifdef __STANDALONE__ #ifndef NOCOMMAND - if( __get_ds() != 0x1000 ) - { - /* First to top of RAM */ - relocator(-1); - /* Then align DS to 64k boundry -> DMA is simple. */ - relocator(0x1000-__get_ds()+__get_cs()); - - /* Oops, relocate down didn't work, try a little higher. */ - if( __get_ds() > 0x1000 ) relocator(2); - printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds()); - } + if( __get_ds() != 0x1000 ) + { + /* First to top of RAM */ + relocator(-1); + /* Then align DS to 64k boundry -> DMA is simple. */ + relocator(0x1000-__get_ds()+__get_cs()); + + /* Oops, relocate down didn't work, try a little higher. */ + if( __get_ds() > 0x1000 ) relocator(2); + printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds()); + } #endif - disk_drive = __argr.h.dl; + disk_drive = __argr.h.dl; #endif #ifdef NOCOMMAND - cmd_type("help.txt"); + cmd_type("help.txt"); #else - display_help(0); + display_help(0); #endif - cmd_bzimage((void*)0); + cmd_bzimage((void*)0); + } #ifdef NOCOMMAND printf("Unable to boot, sorry\nreboot:"); diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s index b9f02a9..4e9eb1a 100644 --- a/bootblocks/msdos.s +++ b/bootblocks/msdos.s @@ -356,8 +356,6 @@ maincode: mov bx,#LOADSEG mov ds,bx ! DS = loadaddress - inc bx - inc bx ! bx = initial CS xor di,di ! Zero mov ax,[di] cmp ax,#0x0301 ! Right magic ? @@ -370,19 +368,19 @@ maincode: shr ax,cl impure: pop cx ! Partition offset. + inc bx + inc bx ! bx = initial CS add ax,bx mov ss,ax mov sp,[di+24] ! Chmem value mov ds,ax + ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=* + +bad_magic: push bx ! jmpi 0,#LOADSEG+2 push di - - ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=* retf -bad_magic: - pop cx - jmpi LOADSEG<<4,0 ! No magics, just go. !--------------------------------------------------------------------------- ! initilised data diff --git a/bootblocks/relocate.c b/bootblocks/relocate.c index 5e14d0e..2e31ea8 100644 --- a/bootblocks/relocate.c +++ b/bootblocks/relocate.c @@ -23,6 +23,9 @@ unsigned newseg; unsigned moved, codelen; unsigned es = __get_es(); + /* If running under DOS don't relocate */ + if (__argr.x.cflag) return; + /* Where do we start */ if(memseg == 0) { diff --git a/bootblocks/tarboot.s b/bootblocks/tarboot.s index a8e56fa..a21d9eb 100644 --- a/bootblocks/tarboot.s +++ b/bootblocks/tarboot.s @@ -97,7 +97,7 @@ endif jz nogood ! If it`s zero .. Hmm if STACK = 0 - mov sp,#bad_magic ! Real bad magic :-) + mov sp,#overstack ! Real bad magic :-) endif call load_sectors @@ -262,9 +262,10 @@ div_loop: loop div_loop mov di,bx -bad_magic: ret +overstack: + !-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ! ! This is good so far, is it an 8086 a.out file ? @@ -277,8 +278,6 @@ go_go_go: mov bx,#LOADSEG mov ds,bx ! DS = loadaddress - inc bx - inc bx ! bx = initial CS xor di,di ! Zero mov ax,[di] cmp ax,#0x0301 ! Right magic ? @@ -291,15 +290,18 @@ go_go_go: shr ax,cl impure: pop cx ! Partition offset. + inc bx + inc bx ! bx = initial CS add ax,bx mov ss,ax mov sp,[di+24] ! Chmem value mov ds,ax + ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=* + +bad_magic: push bx ! jmpi 0,#LOADSEG+2 push di - - ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=* retf !-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- diff --git a/bootblocks/tich.s b/bootblocks/tich.s index 15bc238..ce21e4a 100644 --- a/bootblocks/tich.s +++ b/bootblocks/tich.s @@ -34,5 +34,6 @@ mesg: .ascii "Hello world" emesg: +! Floppies aren't supposed to need this, oh well. org 510 - .word 0 + .word $AA55 diff --git a/bootblocks/trk_buf.c b/bootblocks/trk_buf.c index 86a6721..cfa1e93 100644 --- a/bootblocks/trk_buf.c +++ b/bootblocks/trk_buf.c @@ -92,7 +92,6 @@ void reset_disk() char * read_lsector(sectno) long sectno; { - int tries = 6; int rv; int phy_s = 1; @@ -147,12 +146,26 @@ long sectno; do { - rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); - tries--; + int v,tries = 6; + do + { + rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); + tries--; + } + while(rv && tries > 0); + if( rv ) + { + printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\nRetry:", + rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); + fflush(stdout); + + v = phy_reset(disk_drive); + v = (getch()&0x7F); + printf("\n"); + if( v == 3 || v == 27 ) break; + } } - while(rv && tries > 0); - if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n", - rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1); + while(rv); check_motor = motor_running(); @@ -334,6 +347,31 @@ func_ok: #endasm } +phy_reset(drive) +{ +#asm + push bp + mov bp,sp + + push di + push es + + mov dl,[bp+2+_phy_reset.drive] + + mov ah,#$08 + int $13 + jnc reset_ok + mov cx,ax + mov dx,#-1 +reset_ok: + mov ax,cx + + pop es + pop di + pop bp +#endasm +} + motor_running() { #asm diff --git a/bootblocks/unix.c b/bootblocks/unix.c index 455d9b1..e7f07a0 100644 --- a/bootblocks/unix.c +++ b/bootblocks/unix.c @@ -3,11 +3,11 @@ #ifdef __ELKS__ -bios_khit() { +kbhit() { return 0; } -bios_getc() { +getch() { return 0; } @@ -61,6 +61,15 @@ extern int disk_spt; return 0; } +phy_reset() +{ +} + +motor_running() +{ + return 1; +} + putsect(buffer, address) char * buffer; int address; diff --git a/ld/include/fcntl.h b/ld/include/fcntl.h deleted file mode 100644 index 8c1ec8b..0000000 --- a/ld/include/fcntl.h +++ /dev/null @@ -1,2 +0,0 @@ -#define O_RDONLY 0 -#define O_WRONLY 1 diff --git a/ld/typeconv.c b/ld/typeconv.c index 708d92b..d8c0c89 100644 --- a/ld/typeconv.c +++ b/ld/typeconv.c @@ -15,8 +15,8 @@ void xxerr(x) char * x; { write(2, x, strlen(x)); } static int no_swap = 1; -static long_off[4] = {0,1,2,3}; -static int_off[2] = {0,1}; +static int long_off[4] = {0,1,2,3}; +static int int_off[2] = {0,1}; PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) bool_pt big_endian; diff --git a/ld/writex86.c b/ld/writex86.c index 86c3157..70ecdde 100644 --- a/ld/writex86.c +++ b/ld/writex86.c @@ -146,6 +146,7 @@ bool_pt argxsym; curseg = 0; /* text seg, s.b. variable */ symres("__etext"); symres("__segoff"); + symres("__heap_top"); /* calculate segment and common sizes (sum over loaded modules) */ /* use zero init of segsz[] */ @@ -315,6 +316,11 @@ bool_pt argxsym; fatalerror("data segment too large for 16bit"); } + if( heap_top_value < 0x100 || endoffset > heap_top_value-0x100) + heap_top_value = endoffset + 0x8000; + if( heap_top_value > 0x10000 && !bits32 ) heap_top_value = 0x10000; + setsym("__heap_top", (bin_off_t)heap_top_value); + openout(outfilename); writeheader(); for (modptr = modfirst; modptr != NUL_PTR; modptr = modptr->modnext) @@ -614,9 +620,6 @@ PRIVATE void writeheader() if (uzp) offtocn((char *) &header.a_entry, page_size(), sizeof header.a_entry); - if( heap_top_value < 0x100 || endoffset > heap_top_value-0x100) - heap_top_value = endoffset + 0x8000; - if( heap_top_value > 0x10000 && !bits32 ) heap_top_value = 0x10000; offtocn((char *) &header.a_total, (bin_off_t) heap_top_value, sizeof header.a_total); diff --git a/libbsd/Makefile b/libbsd/Makefile index 618c668..2b29f72 100644 --- a/libbsd/Makefile +++ b/libbsd/Makefile @@ -32,7 +32,7 @@ tests: dummy make -C tests $(LIBBSD): $(OBJS) - $(AR) rcs $(LIBBSD) $(OBJS) + $(AR) rc $(LIBBSD) $(OBJS) realclean: clean clean: dummy diff --git a/libc/Makefile b/libc/Makefile index 6d6c5bb..01e05d7 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -11,7 +11,7 @@ endif VERMAJOR=0 VERMINOR=16 -VERPATCH=1 +VERPATCH=2 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) CC=bcc diff --git a/libc/README b/libc/README index 653ed06..89e0188 100644 --- a/libc/README +++ b/libc/README @@ -25,12 +25,11 @@ gtermcap GNU termcap i386fp BCC's floating point routines for 386 code. include Some include files, some new others Glib or Glib hacked. kinclude Kernel include files, here for now. -malloc1 Robert's malloc routines -malloc2 Joel's malloc routines +malloc Malloc routines misc Various larger functions msdos This is the syscall directory for msdos. regexp Standard regular expression parser -stdio2 Robert's standard I/O +stdio Robert's standard I/O string The functions for string.h syscall All the system call functions, and some tied lib ones. termios Termimal mode control. diff --git a/libc/bios/Makefile b/libc/bios/Makefile index 116776e..3b01e77 100644 --- a/libc/bios/Makefile +++ b/libc/bios/Makefile @@ -8,7 +8,7 @@ AOBJ=bios_start.o bios_isatty.o bios_nofiles.o \ bios_read.o bios_write.o bios_lseek.o bios_close.o BSRC=bios_vid.c -BOBJ=bios_putc.o bios_getc.o bios_khit.o bios_rdline.o +BOBJ=bios_putc.o bios_getc.o bios_getce.o bios_khit.o bios_rdline.o OBJ=$(AOBJ) $(BOBJ) time.o fileops.o fs_dos.o rawio.o diff --git a/libc/bios/bios.c b/libc/bios/bios.c index e0e5c23..ab592a0 100644 --- a/libc/bios/bios.c +++ b/libc/bios/bios.c @@ -3,6 +3,8 @@ * under the GNU Library General Public License. */ +#undef AOUT_STANDALONE + #if !__FIRST_ARG_IN_AX__ #ifdef __AS386_16__ #ifdef __STANDALONE__ @@ -22,7 +24,7 @@ void (*__cleanup)() = 0; .data export ___argr ___argr: - .word 0,0,0,0,0,0,0 ! A struct REGS + .word 0,0,0,0,0,0,0,0 ! A struct REGS: ax, bx, cx, dx, si, di, cflag, flags defarg: .word boot_str, 0 boot_str: @@ -34,20 +36,49 @@ loop_save: export ___cstartup ! Crt0 startup ___cstartup: cli +#ifndef AOUT_STANDALONE + seg cs + cmp word ptr [0],#$20CD ! "int 20h" at psp: CS:0000 + jne not_dos + + ! DOS - only AX has a defined value. + ! All the segment registers are pointing at the PSP + ! SP points to the top of the segment so is probably useable. + + push ax ! Save AX + mov ax,cs + add ax,#$10 ! bump CS by 0x10 + push ax + mov ax,#is_dos ! resume address + push ax + retf ! continue at next instruction +dos_flag: + .word 0 ! Set to 1 if DOS +is_dos: + seg cs + inc dos_flag + pop ax ! restore saved AX + +not_dos: mov sp,cs add sp,#__segoff mov ds,sp mov ss,sp + mov bp,#__heap_top + mov sp,#___argr+14 + seg cs + push [dos_flag] ! Set the carry flag if we're under DOS. +#else + mov bp,sp mov sp,#___argr+12 +#endif push di push si push dx push cx push bx push ax - xor bp,bp mov sp,bp - push bp sti zap_bss: ! Clear the BSS @@ -61,6 +92,7 @@ zap_bss: ! Clear the BSS rep stosb + !mov bp,ax ! Top frame pointer, only needed if we get a debugger push [_environ] mov ax,#defarg ! Don`t define __mkargv, standalone programs don`t push ax ! get any arguments. @@ -107,12 +139,19 @@ no_clean: export __exit __exit: +#ifndef AOUT_STANDALONE + seg cs + cmp [dos_flag],#0 ! Should we do a DOS exit + je do_reboot + int #$20 +do_reboot: +#endif xor ax,ax mov es,ax mov ax,cs seg es mov [$E6*4+2],ax - mov ax,#reti_ins + mov ax,#iret_ins seg es mov [$E6*4],ax mov ax,#$FFFF @@ -121,8 +160,8 @@ __exit: seg es mov [$472],#$1234 ! Warm reboot. jmpi $0000,$FFFF -reti_ins: - reti +iret_ins: + iret #endasm @@ -141,8 +180,7 @@ char * buf; for(v=len; v>0; v--) { c= *buf++; - if( c == '\n') bios_putc('\r'); - bios_putc(c); + putch(c); } return len; } diff --git a/libc/bios/bios_vid.c b/libc/bios/bios_vid.c index 8bf375a..bbe7545 100644 --- a/libc/bios/bios_vid.c +++ b/libc/bios/bios_vid.c @@ -7,7 +7,6 @@ #define VT52_CON /* IMO the best, no clear to EOS/EOL tho */ #define XANSI_CON /* Largest but still not complete */ #define XDUMB_CON /* Can't do much */ -#define XSPEC_CON /* Incomplete, best for slow links */ #if !__FIRST_ARG_IN_AX__ #ifdef __AS386_16__ @@ -27,7 +26,7 @@ static int con_colour = 0; static unsigned char con_row, con_col; #ifdef VT52_CON -bios_putc(c) +putch(c) int c; { static int ctrl = 0; @@ -85,7 +84,9 @@ static int ctrl = 0; asm_putc(c); break; case CTRL('I'): - asm_putc(' '); /* Only some BIOS's have this, so play safe */ + asm_gpos(); + con_col = ((con_col+8)& -8); + asm_cpos(con_row, con_col); break; case CTRL('L'): asm_cpos(0,0); @@ -110,7 +111,7 @@ static int ansi_argc = 0; static int ansi_argv[MAX_ARGS]; static void do_ansi(); -bios_putc(c) +putch(c) int c; { if( con_mode==0 ) asm_coninit(); @@ -123,6 +124,11 @@ int c; asm_colour(last_attr); asm_putc(c); break; + case CTRL('I'): + asm_gpos(); + con_col = ((con_col+8)& -8); + asm_cpos(con_row, con_col); + break; case CTRL('L'): asm_cpos(0,0); asm_cls(); @@ -233,68 +239,12 @@ int ctrl, argc, *argv; } #endif -#ifdef SPEC_CON -static char vidbuf[3]; -static int vidcnt=0; - -bios_putc(c) -int c; -{ - if( con_mode==0 ) asm_coninit(); - if( vidcnt == 0 ) - { - if( c & 0xE0 ) - { asm_colour(last_attr) ; asm_putc(c); } - else switch(c) - { - default: - asm_putc(c); - break; - case CTRL('L'): - asm_cpos(0,0); - asm_cls(); - break; - case CTRL('P'): - case CTRL(']'): - vidbuf[vidcnt++] = c; - break; - } - } - else - { - vidbuf[vidcnt++] = c; - if( vidcnt < 3 && - (vidbuf[0] != CTRL(']') || vidbuf[1] < '`' || vidbuf[1] > 'p')) - return; - - if( vidbuf[0] == CTRL('P') ) - { - if( vidbuf[1] >= 32 && vidbuf[1] <= 56 - && vidbuf[2] >= 32 && vidbuf[2] <= 111 ) - asm_cpos((vidbuf[1]-32), (vidbuf[2]-32)); - } - else - { - if( vidbuf[1] >= '`' ) - last_attr = ( (vidbuf[1]&0xF) | (last_attr&0xF0)); - else - last_attr = ( (vidbuf[2]&0xF) | ((vidbuf[1]&0xF)<<4)); - - if( !con_colour ) - last_attr = (last_attr&0x88) + ((last_attr&7)?0x07:0x70); - } - vidcnt=0; - } -} -#endif - #ifdef DUMB_CON -bios_putc(c) +putch(c) int c; { if( con_mode==0 ) asm_coninit(); - if( c & 0xE0 ) asm_putc(c); - else switch(c) + switch(c) { default: asm_putc(c); @@ -327,6 +277,13 @@ static asm_putc(c) mov bx,sp mov ax,[bx+2] #endif + cmp al,#$0A + jne not_nl + mov ax,#$0E0D + mov bx,#7 + int $10 + mov al,#$0A +not_nl: mov ah,#$0E mov bx,#7 int $10 @@ -404,6 +361,25 @@ static asm_gpos() /****************************************************************************/ +#ifdef L_bios_getce +getche() +{ + static char linebuf[80]; + static int nextc = 0, endc=0; + int rv; + + if (nextc >= endc) + { + endc = bios_readline(linebuf, sizeof(linebuf)); + nextc= 0; + } + if (endc <= nextc) return 3; + rv = linebuf[endc++]; + if (endc == nextc) return '\r'; + return rv; +} +#endif + #ifdef L_bios_rdline bios_rdline(buf, len) char * buf; @@ -415,13 +391,13 @@ int len; if( len < 0 ) { errno = EINVAL; return -1; } if( len == 0 ) { - if( bios_khit() == 0 ) return 0; + if( kbhit() == 0 ) return 0; errno = EINTR; return -1; } if( len == 1 ) { - buf[0]=((ch=bios_getc())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80)); + buf[0]=((ch=getch())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80)); return 1; } @@ -429,32 +405,31 @@ int len; { if(ch != '\003') { - ch = bios_getc(); + ch = getch(); if( pos == 0 && (ch&0xFF) == 0 ) { buf[0] = ((ch>>8)|0x80); return 1; } ch &= 0x7F; - if( ch == '\033' ) ch=3; /* ESC= Interrupt too */ } if( ch == '\r' ) { - bios_putc('\r'); bios_putc('\n'); + putch('\n'); buf[pos++] = '\n'; return pos; } if( ch >= ' ' && ch != 0x7F && pos < len-1) - bios_putc(buf[pos++] = ch); + putch(buf[pos++] = ch); else if( (ch == '\003' || ch == '\b') && pos > 0 ) { - bios_putc('\b'); bios_putc(' '); bios_putc('\b'); + putch('\b'); putch(' '); putch('\b'); pos--; } else if( ch == '\003' ) return 0; else - bios_putc('\007'); + putch('\007'); } } #endif @@ -462,7 +437,7 @@ int len; /****************************************************************************/ #ifdef L_bios_getc -bios_getc() +getch() { #asm xor ax,ax @@ -474,7 +449,7 @@ bios_getc() /****************************************************************************/ #ifdef L_bios_khit -bios_khit() +kbhit() { #asm mov ah,#1 diff --git a/libc/conio/Makefile b/libc/conio/Makefile index bd86b2c..662b0ec 100644 --- a/libc/conio/Makefile +++ b/libc/conio/Makefile @@ -3,19 +3,23 @@ # under the GNU Library General Public License. ASRC=conio.c -AOBJ=getch.o getche.o kbhit.o putch.o cputs.o +AOBJ=getch.o getche.o kbhit.o putch.o -OBJ=$(AOBJ) cprintf.o +BSRC=conio.c +BOBJ=cputs.o + +BIOSOBJ=$(BOBJ) cprintf.o +DOSOBJ=$(AOBJ) $(BOBJ) cprintf.o CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) ifeq ($(LIB_CPU)-$(LIB_OS),i86-BIOS) -all: $(LIBC)($(OBJ)) - @$(RM) $(OBJ) +all: $(LIBC)($(BIOSOBJ)) + @$(RM) $(BIOSOBJ) else ifeq ($(LIB_CPU)-$(LIB_OS),i86-DOS) -all: $(LIBC)($(OBJ)) - @$(RM) $(OBJ) +all: $(LIBC)($(DOSOBJ)) + @$(RM) $(DOSOBJ) else all: @: @@ -26,11 +30,13 @@ $(LIBC)($(AOBJ)): $(ASRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o +$(LIBC)($(BOBJ)): $(BSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + $(LIBC)(cprintf.o): cprintf.c $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c $(AR) $(ARFLAGS) $@ $*.o - - clean: rm -f *.o libc.a diff --git a/libc/conio/conio.c b/libc/conio/conio.c index c0e9cbb..ee311a5 100644 --- a/libc/conio/conio.c +++ b/libc/conio/conio.c @@ -58,13 +58,6 @@ putch() mov bx,sp mov ax,[bx+2] #endif - cmp al,#$0A - jne not_nl - mov ax,#$0E0D - mov bx,#7 - int $10 - mov al,#$0A -not_nl: mov ah,#$0E mov bx,#7 int $10 diff --git a/libc/conio/cprintf.c b/libc/conio/cprintf.c index 4bc3bac..5194376 100644 --- a/libc/conio/cprintf.c +++ b/libc/conio/cprintf.c @@ -1,3 +1,8 @@ +/* Copyright (C) 1999-2002 Robert de Bath <rdebath@cix.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + #include <stdarg.h> #include <conio.h> diff --git a/libc/include/a.out.h b/libc/include/a.out.h index bd58346..677d73e 100644 --- a/libc/include/a.out.h +++ b/libc/include/a.out.h @@ -48,6 +48,7 @@ struct exec { /* a.out header */ #define A_UZP 0x01 /* unmapped zero page (pages) */ #define A_PAL 0x02 /* page aligned executable */ #define A_NSYM 0x04 /* new style symbol table */ +#define A_STAND 0x08 /* standalone executable */ #define A_EXEC 0x10 /* executable */ #define A_SEP 0x20 /* separate I/D */ #define A_PURE 0x40 /* pure text */ @@ -5,8 +5,9 @@ SRC_CC1='bcc-cc1.c assign.c codefrag.c debug.c declare.c express.c exptree.c floatop.c function.c gencode.c genloads.c glogcode.c hardop.c input.c label.c loadexp.c longop.c output.c preproc.c preserve.c scan.c softop.c state.c table.c type.c' -SRC_AS=' as.c assemble.c error.c express.c genbin.c genlist.c genobj.c gensym.c - keywords.c macro.c mops.c pops.c readsrc.c scan.c table.c typeconv.c' +SRC_AS=' alloc.c as.c assemble.c errors.c express.c genbin.c genlist.c genobj.c + gensym.c keywords.c macro.c mops.c pops.c readsrc.c scan.c table.c + typeconv.c' SRC_LD=' ld.c dumps.c io.c linksyms.c readobj.c table.c typeconv.c writebin.c writex86.c' |