Beebug Crtsys LIBRARYDASM specialdasm librarylibdef dirops commit string stdlib stdio stddef stdarg setjmp math limits float ctype call assert rtlib welcomecompasccomparelist CSP RUNC 1.50 1.50 1.50 1.5 2]%%%7%%{ )-ve 1 &ve 1x*ve=LzwsJoJh e0/&>ve.w`@=ve.ch:ve.c7ve.l.@4%%0%%@* * * ȱ > ȱ 3  %%%% &&1& ۩c%/&% % & & ,& q pq pݜ%`>&LBeebug CK.0 ompile/nolist |Mlink |Mrun |M K.1compile/nolist |M K.2link |M K.3run |M K.4 . |M C '' ' &  &second processor online'' ' '''Uȩ**'% &-' '' '-' '' ' &Ls L* +& &already resident g& L >& '''`hh & & & ,'` (-( 0' ά'ੴ b'`''`'H hLhh ' & ' & &L '`' "cInternal ErrorB')C'0'`No Beebug C compiler language romSP v1.0 orinstalledThe words were on the ceilingHJJJJ 'h) ' L ii0L#`CSP V1.0 Copyright (c) 1987 by MGP L LL. ? <ޘޅީ o   ܩ (`ɏ  <Lܩ Š `HJJJJ h) L ii0LELSEZQUERYdINCLUDEENDRADIXDEFS ,)+-*/=>< $-(RADIX pages0zpcr ostubechan3osbyteoswrchosnewlosasci ErrorSpace RomSearch=% RomSearch2T% RomSearch3a% RomOfflinek% RomOffline1% RomOffline2% RomOffline3% RomOffline4% RomsError% Rom1Online% InstallCSP% IsItMinLLIBeebug CV1.2(C) 1987 Beebug LtdLLqLAuthor: David AllisonH) ɻLlh(`HH Beebug C 1.2 L˜HH \C(ȱ  ȱ0 3/L©Lhhh(` X `Xˍ$ LW Ʃ#Å$ Ɛ Lµ*ÒCOMPILE P1 File 9LIST J0LSPACE [OBJECT n@PORTABLE @WARNINGS DEFINE @OPTIMISE @DEBUG "LINK P File 0ORIGIN @ STANDALONE LIBRARY EXECUTABLE C1MODE P1 Mode QbRUN P File v@ TRACEBACK OUTPUT INPUT ERROR CLOSE REPORT 1COMMAND @   L` :ȱ .`H ű .h`h.  L)H ű .a{)_`0:`8` /, =`8` sŰ.`,,`, 8``, Ű \ŝ Ő.,  8`, " \ŝ sŐ  8` ŝ Lc",ʰ۠Hȱh`h8`-ȥ.ȩȑi,`!! ȥ !ȥ !`Too many values  8e` `,  ,` -`8`No command `,0 * Őԥ#$ e-i. ưi $Ɛ0H&' e(-)i. 88`, ƩC(ą)L$ǠLBad commandAmbiguous command()0Ћ`()  ư,3 e-i./Lp ȥHH 8h!h" WƩ, Ő? ͥL  :Υ>? ̐ ! L` z υ υ `>? ̐ `) @ȱ ȱ ȥ ȥ  8ieeLyԥ>?ȱ )@ bLΠHȱhLh>?0ȱ)?HȱhLh` Liͩ `@ 8` File not found  LLink aborted` %ϐ   ͥi8`  %ϤL89 `7 2  `< LNo room 77 LError limit exceeded ** Link Error - h*h+*+* L3Х+H*H` ** Fatal Link Error - h*h+*+* Lw@0 ЅL`c$gfa c$gna c$g2a c$put qc$get Cfgetc fputc ungetc 'c$print 7c$scan F stdin V"stdout f$stderr RTLIB RTSYS u: Bad byte ҩ#  h˩ @ 9 h˥8 h vх`􀃊Ӂc퇚 M@B in *+* ` "   " LZ[ Z @L E P M˩E Kť 02 1  ͩ7 :; < OR : ; LIB  =,i х  LLibrary not found L %  LIB @ STA @=4 DE z =L- Υ% A] 12J:H;H HH h hhh 7 12L`3 h֩89%L L_ P LөO  k3 yԩ L4ԥLW` q ϰ ѥ0& ԥ i ψ) L LϥLϥBY҅ p҅ Lyl LB  L`= ԥ3 ` `= B L Lϥ= L B e  (eL υ υ   ԥ 8 Lm`  LB LB LB LB  e  (eL υ υ   ϥ 8 L`Beebug C Linker V1.1 main o х  LRTSYS not found ͥABLL֥AB ϩ ϩ y yԩL@0 4 ϥ5 ϥ6 ϩ ϩ Ϡ֙ ̰ No main function  ȱ ϩLϠ ϰ4L/ %=%44 ϑ ƥ8  8`& Bad object file  LZ`5643  Ϥ%`Beebug C Librarian V1.1 ϰs ` LBad libraryHHHHveHHhh` ץL ץlm ؊LWتLl  L8`  L/ L8``G ץlm qؐܤL8L#include file not found ?#endif @#else CEOF in #if DEOF in comment E#ifs F#include file G local symbol Hmember I  Jline no. Kfew  LTag Division by 0 N expression Static i O label PUn label Qers S M No literal space No room Error limit exceeded Preprocessed line too long Stack full Function prototypes are T specifier is Symbol name Input line !Struct p converted to pointer Unionation is expected required dentifier defined initialis Unmatched Multiply constant declared acro ype arameter function already non portable truncated name arguments Too many Must be default value Bad ** Error - ** Warning - ** Fatal error - ߩ"ޅ# ީ"م# KLߩ آ "+"e""#$LKޭ L at line in ީ"ޅ# ޥ}"~# ੊"ޅ# ޭ@"A#8""# Lߠ"  `H#H"H4"݅# " "  h"h#hLީ H@$ Qh `h` ߩ"ޅ# ީT"܅# KL߭ L LL$ከh(` HHXL/8QL ư ߩ "ޅ# ީ"܅# KLL­  +L hhh(` L߹L߹I%LLOPDWlopdwК ˍ(SK  ߩ"# ޥ Ӆ"# ޥ څ"# ޭT "# ޭT ߩ $\] Ġ hLCompilation completed with error and warning sL`"#"&#*  "i0H"#h `ZBE[CFGHD ZH:Zh8eZZ[ZH.ZheZZ[Z ZZ[Z[.ZZ[LBBC TSUs OB  P1 M˩O Kť 0 Ĥ ] \ )߅ P1 M˩C Ŧ @ A@ File not found LIST @ 6 P1 L K Ĥ Q @L La) DEB 0) PO  Z[ LS Z [ WA 0) OPT 0)NmZZZOm[[[ u DEF  u mL c m$Ș @ A qԩLBeebug C Compiler V1.2 $p8`` cLs ZT[ULZrȥ[rsZrr r  r8eZZ[8Hrhrr``8`` L` ȱ ȱ ȱ `Hȱh` `8`͠` L     W`  [àȱ 8HH hh  ! )  ȱ Lv` [L#HH hh H H W `ȱ vhhL) 4))))@)ɀȱ``իv(5AUhr~,W `  W` :L ΍WLHH hh H HHH  hh  h h eLwl8 `  , 8` 8 ` :F f eeffff  LfW` :H & *&&  ޅhLf e e `8   `   ` % % `   ` E E ` & `F f ` `   ` U I ` 0 HH  h h Lu I I` rLk ~Lk I I `HH HH  hhhh Lhhhh L H  W W 0 h ` HHHHHHH  W LW   hhhhhhh `LH) hH h`\ ɊL0`\ȱ\ e\ ȱ\ (e]  i  \i ]i  \Hȱ\]h\Lh`\ ȱ\ L \ ȱ\   襉 襊  ȱ Lo  \ ȱ\ L H$h`hɁ #include #define MINLINE 1 #define MAXLINE 65535 #define MAXLEN 255 main(argc, argv) int argc; char *argv[]; { unsigned int line = 0, start, end; char string[MAXLEN]; FILE *instr; start = (argc > 2) ? strtol(argv[2], NULL, 0) : MINLINE; end = (argc > 3) ? strtol(argv[3], NULL, 0) : MAXLINE; if ((instr = fopen(argv[1], "r")) != NULL) { while (fgets(string, MAXLEN, instr) != NULL && line < end) if (++line >= start) printf("%5d %s", line, string); } else printf("File '%s' not found\n", argv[1]); } /* Compare Utility */ #include #include main(argc, argv) char *argv[]; { int c1, c2; FILE *file1, *file2; unsigned long byte = 0; file1 = fopen(argv[1], "r"); file2 = fopen(argv[2], "r"); if (file1 == NULL || file2 == NULL) printf("File not found\n"); else { do { c1 = fgetc(file1); c2 = fgetc(file2); ++byte; } while(c1 == c2 && c1 != EOF); if ((c1 == EOF && c2 != EOF) || (c1 != EOF && c2 == EOF)) printf("Files are different lengths\n");else if (c1 != c2) printf("Compare failed at 0x%x\n", --byte); } } /* ASCII Compare Utility */ #define MAXLEN 255 #include #include main(argc, argv) char *argv[]; { int charnum; FILE *file1, *file2; char string1[MAXLEN], string2[MAXLEN]; unsigned long linenum; file1 = fopen(argv[1], "r"); file2 = fopen(argv[2], "r"); if (file1 == NULL || file2 == NULL) printf("File not found\n"); else { for (linenum = 0; (fgets(string1, MAXLEN, file1) != NULL) && (fgets(string2, MAXLEN, file2) != NULL); ++linenum) if (strcmp(string1, string2) != NULL) { printf("%10s %5d %s", argv[1], linenum, string1); printf("%10s %5d %s\n\n", argv[2], linenum, string2); } } } /* Beebug C Welcome Program */ #include main() { printf("Welcome to Beebug C\n"); } Beebug C Librarian V1.1 RTLIB - Version 1.3 This is the main run-time library for the Beebug C system. This library was designed and written by David Allison Library contents are copyright (C) Beebug Limited 1987. All rights reserved. No part of this library may be reproduced in whole or part by any means without written permission of the copyright holder. While every care is taken, the copyright holder cannot be held responsible for any errors in this library, or for the loss of any data or consequential effects from the use of this library. fgetpos time ~ c$ctype strcmp strcat strcpy strncat Nstrlen strchr ?strncmp bstrncpy tolower toupper islower iscntrl  isalnum isalpha isdigit \ isgraph isspace isprint ( ispunct l isupper isxdigit 8 malloc .envelope rand settime srand 4 sound g oscli {osbyte osword =abort call gets fclose free ;fopen fputs fgets ivdu puts hmode bget bput @_nf tfprintf feof $fseek ftell fsetpos rewind scanf va_count vprintf sprintf sscanf strtol Bfflush fscanf calloc (freopen strtod Aatoi Dfread Qfwrite atol Datof ^setjmp strspn texit |_f xatexit strcspn memset strpbrk strrchr 3remove rename strtok "_assert !longjmp plot O!point !strstr H"memcmp J%memmove #realloc ?$memcpy %memchr %strcpy strcpy  c$g2a `strcat strcat  c$g2a 5e恠`strncat strncat  c$g2a HH c$gna =hhe恠Ć 󥈅`strlen strlen  c$gfa `strcmp strcmp  c$g2a )ф`8񄅄00strncmp strncmp  c$g2a HH c$gna 7hhĆ ф`8񄅄00strncpy strncpy  c$g2a HH c$gna *hhĆ 󥀅`strchr strchr  c$g2a -ń`ei`tolower tolower  c$gfa A[ `toupper toupper  c$gfa a{)߅`@@@@@@@@@@@@@@@$$$$$$$$$$@@@@@@@000000@@@@@@((((((@@@@isalnum isalnum  c$gfa )c$ctype )`isalpha isalpha  c$gfa )c$ctype )`iscntrl iscntrl  c$gfa )c$ctype )`isdigit isdigit  c$gfa )c$ctype )`isgraph isgraph  c$gfa )c$ctype )\`islower islower  c$gfa )c$ctype )`isprint isprint  c$gfa )c$ctype )܅`ispunct ispunct  c$gfa )c$ctype )@`isspace isspace  c$gfa )c$ctype )`isupper isupper  c$gfa )c$ctype )`isxdigit isxdigit  c$gfa )c$ctype ) `time time Lsettime settime  c$gfa Lrand rand B30]408.0.1.2.3ܭ3ƀϥ)`srand srand  c$gfa 0`sound sound H c$gna @ȥ@@Lenvelope envelope H c$gna @@Losbyte osbyte  c$g2a H c$gna h h`osword osword  c$g2a  h`oscli oscli  c$gfa  Lcall call  c$g2a "HevwiH( c$call h`c$call lmalloc malloc  c$gfa i慦568E8刅剅儅充)Ŏ台Bȱ)no椏0CƎeeȱȱ ii`nenȥoeovnwono`free free  c$gfa 8ƅ568ȱ)Ņnoߩ`)noȱ08no`fopen fopen  c$g2a  @a r ȱ+%!wIllegal file access mode 9HPhPHaK  hiP`fclose fclose  c$gfa 4#P  HPh `fputs fputs  c$g2a lm c$put `0fgets fgets  c$g2a M c$gna lmM c$get .!L 8呀 ȩ``gets gets  c$gfa  l!m c$get 9,L  8呀``puts puts  c$gfa "l#m c$put  c$put `0mode mode  c$gfa H) Bad mode o橄 ąJvw8倅偅vwvw恥Ň hL h 88wܥvֱvvw`vdu vdu Hy c$gna `bget bget  c$gfa * ` 8`bput bput  c$g2a ! ` 8fgetpos fgetpos  c$g2a # `ftell ftell  c$gfa Lfseek fseek  c$g2a  c$gna I2 u ` 8fsetpos fsetpos  c$g2a # `rewind rewind  c$gfa Lfeof feof  c$gfa  c$eof `c$eof lva_count va_count y`stdout c$print stdin c$scan c$print c$scan c$print c$scan calloc  malloc fflush fflush  c$gfa 6!&H hP p`Yfclose fopen strtod  sscanf isspace isdigit .+-eE      %fstrtol ord isalpha 70valid isalnum ord strtol isspace   +  -      0toupper X  toupper valid ord չ  fread  fgetc fwrite  fputc  strtol strtod @exit _nf _f _nf printf abort  exit status: %d atexit _f _nf strcspn strcspn  c$g2a )LņLL`strspn strspn  c$g2a 1L ņLޥL`strpbrk strpbrk  c$g2a 8L(ņLLei`strrchr strrchr  c$g2a &ń8ei`memset memset  c$g2a  c$gna `remove remove  c$gfa & iLrename rename  c$g2a c$ren 4 ʠ  Lc$ren RENAME setjmp setjmp  c$gfa .yȽȽȽȥvȥw`longjmp longjmp  c$g2a ,愠yȱȱȱȱvȱw`plot plot  c$gfa  c$gna c$gna L_assert _assert  c$gfa `Assertion failedpoint point  c$g2a +@ABC @ D`strstr strlen   strncmp strtok strspn strlen strcspn memmove    realloc   malloc  malloc    memmove free memcmp memcpy  memchr # pragma l /* list off */ # pragma p /* non portable code */ /*************************************************************************** H.ASSERT - diagnostics ---------------------- Author : David Allison Date : 20 July 1987 Issue : 1.0 (C) 1987 Beebug Limited ******************************************************************************/ # ifdef NDEBUG # define assert(exp) # else extern void _assert(int) ; # define assert(exp) _assert(exp) # endif # pragma l /* list off */ # pragma p /* non portable */ /************************************************************************** H.CALL - Acorn OS call definitions ---------------------------------- Author : David Allison Date : 2 August 1987 Issue : 1.0 (C) 1987 Beebug Limited *************************************************************************/ typedef struct { unsigned short A ; unsigned short P ; unsigned short Y ; unsigned short X ; } call_buf ; /* holds registers to pass to called routine */ extern long call (char *addr,call_buf *regs,...) ; /* calls machine code subroutine. Takes as the first parameter the address of the routine to call. The optional second parameter is the address of a call_buf struct containing the register values to pass. The rest of the parameters are arguments to be passed. returns a long (4 bytes) containing the contents of the registers at the execution of the RTS. The order is : APYX (hi to lo) */ /* MOS calls */ # define OSBYTE 0xfff4U # define OSWORD 0xfff1U # define OSCLI 0xfff7U # define OSNEWL 0xffe7U # define OSWRCH 0xffeeU # define OSASCI 0xffe3U # define OSRDCH 0xffe0U # define NVRDCH 0xffcbU # define NVWRCH 0xffc8U # define GSREAD 0xffc5U # define GSINIT 0xffc2U # define OSEVEN 0xffbfU # define OSRDRM 0xffb9U # define OSRDSC 0xffb9U # define OSWRSC 0xffb3U /* filing system calls */ # define OSFILE 0xffddU # define OSARGS 0xffdaU # define OSBGET 0xffd7U # define OSBPUT 0xffd4U # define OSGBPB 0xffd1U # define OSFIND 0xffceU # pragma l # pragma p /************************************************************************** H.CTYPE - character handling functions -------------------------------------- Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited **************************************************************************/ /* character handling macros and functions */ extern int isalnum (int c) ; extern int isalpha (int c) ; extern int iscntrl (int c) ; extern int isdigit (int c) ; extern int isgraph (int c) ; extern int islower (int c) ; extern int isprint (int c) ; extern int ispunct (int c) ; extern int isspace (int c) ; extern int isupper (int c) ; extern int isxdigit (int c) ; extern int tolower (int c) ; extern int toupper (int c) ; # define isascii(c) ((c)<=0x7f) # pragma l /* list off */ # pragma p /* non portable */ /************************************************************************** H.FLOAT - Floating point limits ------------------------------- Author : David Allison Date : 2 August 1987 Issue : 1.0 (C) 1987 Beebug Limited *************************************************************************/ # define FLT_RADIX 2 # define FLT_ROUNDS # define FLT_MANT_DIGS 24 # define FLT_EPSILON 1.192093e-7 # define FLT_DIG 7 # define FLT_MIN 1.469368e-39 # define FLT_MIN_10_EXP -39 # define FLT_MAX 1.701412e38 # define FLT_MAX_10_EXP 38 # define DBL_MANT_DIGS 24 # define DBL_EPSILON 1.192093e-7 # define DBL_DIG 7 # define DBL_MIN 1.469368e-39 # define DBL_MIN_10_EXP -39 # define DBL_MAX 1.701412e38 # define DBL_MAX_10_EXP 38 # pragma l /* list off */ /***************************************************************************** H.LIMITS - arithmetic limits ---------------------------- Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited ******************************************************************************/ # define CHAR_BIT 8 # define SCHAR_MIN -127 # define SCHAR_MAX 127 # define UCHAR_MAX 255U # define CHAR_MIN -127 # define CHAR_MAX 127 # define SHRT_MIN -127 # define SHRT_MAX 127 # define USHRT_MAX 255U # define INT_MIN -32767 # define INT_MAX 32767 # define UINT_MAX 65535U # define LONG_MIN -2147483647 # define LONG_MAX 2147473647 # define ULONG_MAX 4294967295U # pragma l /* list off */ # pragma p /* non portable */ /************************************************************************** H.MATH - Standard maths definitions ------------------------------------- Author : David Allison Date : 6 October 1987 Issue : 2.0 (C) 1987 Beebug Limited **************************************************************************/ # define PI 3.1415927 # define HUGE_VAL 1.7014118E38 extern double cos (double x) ; extern double sin (double x) ; extern double tan (double x) ; extern double exp (double x) ; extern double frexp (double value, int *exp) ; extern double ldexp (double x, int exp) ; extern double log (double x) ; extern double log10 (double x) ; extern double modf (double value, double *iptr) ; extern double pow (double x, double y) ; extern double sqrt (double x) ; extern double ceil (double x) ; extern double fabs (double x) ; extern double floor (double x) ; extern double fmod (double x) ; /* extensions to ISO */ extern double ipow (double x, int y) ; /* double to power of int */ extern double itof (int i) ; /* int to float */ extern int ftoi (double x) ; /* float to int */ extern double rad (double angle) ; /* degress to radians */ extern double deg (double angle) ; /* radians to degrees */ # pragma l # pragma p /*************************************************************************** H.SETJMP - non-local jump handler --------------------------------- Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited ***************************************************************************/ /* non local jumps */ typedef char jmp_buf[6] ; extern int setjmp (jmp_buf env) ; extern void longjmp (jmp_buf env, int val) ; # pragma l # pragma p /**************************************************************************** H.STDARG - variable argument handler ------------------------------------ Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited ****************************************************************************/ typedef char *va_list ; # define va_start(list,pn) list = &pn # define va_arg(list,mode) (mode)*((mode*)((list+=4)-4)) # define va_end(list) extern unsigned short va_count(void) ; # pragma l /* list off */ # pragma p /*non portable code */ /************************************************************************** H.STDDEF - standard definitions ------------------------------- Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited ***************************************************************************/ typedef int bool ; /* boolean type */ typedef unsigned short int byte ; /* a byte */ # redef ptrdiff_t int /* ptr subtraction type */ # redef size_t int /* sizeof type */ # redef NULL 0 # redef TRUE 1 # redef FALSE 0 # define offsetof(type,id) ((char*)(&type.id) - (char *)&type) /* member offset in struct */ # pragma l /* list off */ # pragma p /* non portable */ /************************************************************************** H.STDIO - standard input/output ------------------------------- Author : David Allison Date : 30 October 1987 Issue : 1.1 (C) 1987 Beebug Limited *************************************************************************/ /* standard input/output macros and functions */ # redef NULL 0 # redef TRUE 1 # redef FALSE 0 # define EOF (-1) # define FILE short # define fpos_t long # redef size_t int # define SEEK_SET 0 # define SEEK_CUR 1 # define SEEK_END 2 extern int printf (char *format,...) ; extern int scanf (char *format,...) ; extern int sprintf (char *s,char *format,...) ; extern int sscanf (char *s,char *format,...) ; extern int fprintf (FILE *stream,char *format,...) ; extern int fscanf (FILE *stream,char *format,...) ; extern int fclose (FILE *fp) ; extern FILE *fopen (char *filename,char *mode) ; extern FILE *freopen (char *s, char *mode, FILE *stream) ; extern int fputc (int c,FILE *stream); extern int fputs (char *s,FILE *stream) ; extern int puts (char *s) ; extern int fgetc (FILE *stream) ; extern int ungetc (int c, FILE *stream) ; extern char *fgets (char *s,int n,FILE *stream) ; extern char *gets (char *s); extern int fgetpos (FILE *stream, fpos_t *pos) ; extern int fseek (FILE *stream, long offset, int whence) ; extern int fsetpos (FILE *stream, fpos_t *pos); extern fpos_t ftell (FILE *stream) ; extern void rewind (FILE *stream) ; extern int feof (FILE *stream) ; extern int bget (FILE *stream) ; extern int bput (FILE *stream, char c) ; extern int remove (char *name) ; extern int rename (char *old, char *new) ; extern int fflush (FILE *stream) ; extern int fread (char *ptr, size_t size, size_t num, FILE *stream) ; extern int fwrite (char *ptr, size_t size, size_t num, FILE *stream) ; extern FILE *stdin, *stdout, *stderr; # define putc(_c,_s) fputc (_c,_s) # define getc(_s) fgetc (_s) # define putchar(_c) fputc ((_c),stdout) # define getchar() fgetc (stdin) # define clearerr(stream) # define ferror(stream) 0 # pragma l /* list off */ # pragma p /* non portable */ /************************************************************************** H.STDLIB - Standard library functions ------------------------------------- Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited **************************************************************************/ /* standard operating system functions */ # define RAND_MAX 32767 # redef size_t int extern int rand (void) ; extern void srand (unsigned seed) ; extern double atof (char *str) ; extern int atoi (char *str) ; extern long atol (char *str) ; extern double strtod (char *str, char **endptr) ; extern long strtol (char *str, char **endptr, int base); extern char *calloc (size_t num, size_t size) ; extern void free (char *ptr) ; extern char *malloc (size_t size) ; extern char *realloc (char *ptr, size_t size) ; extern void abort (void) ; extern int atexit (int (*func)(void)) ; extern void exit (int status) ; # define system(s) oscli (s) # define abs(j) j < 0 ? -j : j # define labs(j) abs(j) /* Acorn OS functions */ extern void vdu () ; /* variable argument list */ extern long osbyte (short A,short X,short Y) ; extern long osword (short A,char *para_block) ; extern void oscli (char *str) ; extern void mode (short num) ; extern long time (void) ; extern void settime (long t) ; extern void sound (int,int,int,int) ; extern void envelope (short,short,short,short,short,short,short,short,short,short,short,short,short,short) ; extern void plot (short k,int x, int y) ; extern int point (int x, int y) ; /* BASIC-like macro definitions */ # define draw(x,y) plot (5,x,y) # define move(x,y) plot (4,x,y) # define gcol(a,b) vdu (18,a,b) # define colour(x) vdu (17,x) # define cls() vdu (12) # define clg() vdu (16) # define page() (osbyte (131,0,0) &0xffffU ) # define himem() (osbyte (132,0,0) &0xffffU ) # define inkey(k) (osbyte (129,k,(k)>>8) &0xffffU) # define adval(c) (osbyte (128,c,0) &0xffffU) # define tab(x,y) vdu(31,x,y) # pragma l # pragma p /************************************************************************* H.STRING - string handling functions ------------------------------------ Author : David Allison Date : 10 July 1987 Issue : 1.0 (C) 1987 Beebug Limited **************************************************************************/ # redef size_t int /* string handling functions */ extern char *strcpy (char *s1, char*s2) ; extern char *strncpy (char *s1, char *s2, size_t n) ; extern char *strcat (char *s1, char *s2) ; extern char *strncat (char *s1, char *s2, size_t n) ; extern int strcmp (char *s1, char *s2) ; extern int strncmp (char *s1, char *s2, size_t n) ; extern char *strchr (char *s, int c) ; extern int strcspn (char *s1, char *s2) ; extern int strspn (char *s1,char *s2) ; extern char *strpbrk (char *s1, char *s2) ; extern char *strrchr (char *s, int c); extern int strlen (char *s) ; extern char *strstr (char *s1,char *s2) ; extern char *strtok (char *s1, char *s2) ; /* memory handling functions */ extern char *memcpy (char *s1,char *s2,size_t n) ; extern int memcmp (char *s1, char *s2, size_t n) ; extern char *memchr (char *s, int c, size_t n) ; extern char *memset (char *s, int c, size_t n) ; extern char *memmove (char *s1, char *s2, size_t n); # include # include "c.libdef" extern tree_ptr tree ; /* the tree */ extern FILE *fp,*new_fp ; extern char filename[] ; extern int modified, amount_to_add ; extern void add_amount(tree_ptr) ; int next_dir_entry, first_dir_entry, current_ptr ; static int module_number ; /* traverse the tree in 'pre-order'. This ensures the new directory is not sorted 'in-order' to create a better balanced tree */ traverse_pre_order (tree_ptr cursor, int (*function)()) { if (cursor == NULL) return ; (*function)(cursor) ; traverse_pre_order (cursor->right,function) ; traverse_pre_order (cursor->left,function) ; } copy_header(void) { char ch, ans[10], library_id[255] ; do fputc (ch=fgetc(fp),new_fp) ; while (ch != '\n') ; printf ("Change identification text ? ") ; scanf ("%s",ans) ; if (toupper(ans[0]) == 'Y') { fflush (stdin) ; printf ("Enter new identification text:") ; gets (library_id) ; fprintf (new_fp,"%s",library_id) ; fputc (0,new_fp) ; while (bget(fp)) ; } else do bput (new_fp,ch=bget(fp)) ; while (ch) ; do bput (new_fp,ch=bget(fp)) ; /* copy copyright text */ while (ch) ; amount_to_add = first_dir_entry = (int)ftell(new_fp) ; traverse_tree (tree,add_amount) ; /* adjust to proper offset */ } create_dir_entry(tree_ptr cursor) { if (!cursor->deleted) { fputc (0,new_fp) ; fprintf (new_fp,"%s\r",cursor->name) ; bput (new_fp,cursor->new_offset &0xff); bput (new_fp,cursor->new_offset >> 8) ; next_dir_entry = (int)ftell (new_fp) ; } } copy_module (tree_ptr cursor) { int loop ; if (cursor->deleted == FALSE && cursor->new == FALSE) { printf ("Committing...%d\r",++module_number) ; fseek (fp,cursor->old_offset,SEEK_SET) ; /* set ptr to old module */ for (loop = 0 ; loop < cursor->length ; loop++) /* copy module */ bput (new_fp,bget(fp)) ; } } skip_to_cr(FILE *obj_fp) { while (fgetc(obj_fp) != '\n') ; } insert_new_module(tree_ptr cursor) { FILE *obj_fp ; int ch ; int length ; fseek (new_fp,next_dir_entry,SEEK_SET) ; /* set ptr# to next dir entry */ create_dir_entry (cursor) ; /* rewrite directory entry */ if (!cursor->new) /* new ? */ return ; if ((obj_fp = fopen (cursor->filename,"r")) == NULL) { fprintf (stderr,"Unable to reopen object file %s\n",cursor->filename) ; return ; } printf ("Inserting...%d\r",++module_number) ; skip_to_cr(obj_fp) ; /* skip header */ skip_to_cr(obj_fp) ; /* skip debug flag + filename */ fseek (new_fp,-2,SEEK_CUR) ; /* point to offset for entry */ bput (new_fp,current_ptr &0xff) ; /* write new offset */ bput (new_fp,current_ptr >> 8) ; fseek (new_fp,current_ptr,SEEK_SET) ; /* reset ptr# */ length = 1 ; while ((ch=bget(obj_fp)) != EOF) /* copy object file */ { bput (new_fp,ch) ; length ++ ; } fputc (0xff,new_fp) ; /* terminate module */ fclose (obj_fp) ; cursor->length = length ; /* set length */ cursor->new = FALSE ; /* is committed now */ cursor->old_offset = cursor->new_offset = current_ptr ; /* set offsets */ current_ptr = (int)ftell(new_fp) ; /* save ptr# */ } build_temp_name(char *temp) { int i ; for (i=strlen(filename); filename[i] != '.' && i > 0 ; i--) ; if (i) /* directory found */ strncpy (temp,filename,i+1) ; /* include the . */ else temp[0] = '\0' ; strcat (temp,"!!!!!!!") ; } commit_changes(void) { char temp_name [100] ; module_number = 0 ; build_temp_name (temp_name) ; /* build the temp name */ new_fp = fopen (temp_name,"w") ; /* open temp file */ rewind (fp) ; copy_header() ; /* copy the library header */ traverse_pre_order (tree,create_dir_entry) ; /* create the directory */ fputc (0xff,new_fp) ; /* terminate directory */ traverse_tree (tree,copy_module) ; /* copy all non-new modules */ current_ptr = (int) ftell (new_fp) ; next_dir_entry = first_dir_entry ; if (module_number) putchar ('\n'); module_number = 0 ; traverse_pre_order (tree,insert_new_module) ; /* insert new modules at end*/ if (module_number) putchar ('\n') ; fclose (new_fp) ; fclose (fp) ; remove (filename) ; rename (temp_name,filename) ; } # include # include # include "c.libdef" # define SYMBOL_ADMIN_SIZE 4 tree_ptr tree ; /* the tree */ int num_modules, amount_to_add, deleted_offset ; tree_ptr last_node ; char *compiler_header = "Beebug C Compiler V1.5\n", buffer [32] ; extern unsigned short get_byte(void) ; extern void read_symbol(void) ; extern char filename[] ; extern int offset, modified ; extern FILE *fp,*new_fp ; free_node (tree_ptr cursor) { free (cursor->name) ; free (cursor->filename) ; free (cursor) ; } free_tree(void) { traverse_tree (tree,free_node) ; init_tree() ; } no_room(void) { fprintf (stderr,"Insufficient memory\n") ; exit (0) ; } tree_ptr new_node (record *data) { tree_ptr node ; if ((node = malloc (sizeof (struct tree_node))) == NULL) no_room() ; node->left = node->right = NULL ; if ((node->name = malloc (strlen(data->name)+1)) == NULL) no_room() ; strcpy (node->name,data->name) ; node->old_offset = node->new_offset = data->offset ; node->deleted = node->new = FALSE ; return node ; } tree_ptr insert_right (tree_ptr cursor, record *data) { return cursor->right = new_node (data) ; } tree_ptr insert_left (tree_ptr cursor, record *data) { return cursor->left = new_node (data) ; } tree_ptr insert_at_root (record *data) { return tree = new_node (data) ; } init_tree(void) { tree = NULL ; } int right_empty (tree_ptr cursor) { return cursor->right == NULL ; } int left_empty (tree_ptr cursor) { return cursor->left == NULL ; } tree_ptr insert_tree (tree_ptr cursor, record *data) { if (tree == NULL) return insert_at_root (data) ; if (data->offset < cursor->old_offset) return left_empty(cursor) ? insert_left(cursor,data) : insert_tree (cursor->left,data) ; return right_empty(cursor) ? insert_right(cursor,data) : insert_tree (cursor->right,data) ; } tree_ptr search_tree (tree_ptr cursor, char *name) { tree_ptr ptr ; if (cursor == NULL) return NULL ; if (!strcmp(cursor->name,name)) return cursor ; if ((ptr=search_tree(cursor->left,name)) != NULL) return ptr ; return search_tree (cursor->right,name) ; } add_amount (tree_ptr cursor) { if (!cursor->new) cursor->new_offset += amount_to_add ; } calculate_length (tree_ptr cursor) { if (last_node != NULL) last_node->length = cursor->old_offset - last_node->old_offset ; last_node = cursor ; } read_directory(void) { record data ; int record_number = 0; int last_offset, file_length ; putchar ('\n') ; amount_to_add = -(int)ftell (fp) ; /* record start of dir */ for (;;) { if (get_byte() == 0xff) break ; read_symbol() ; printf ("Reading... %d\r",++record_number) ; strcpy (data.name,buffer) ; data.offset = offset ; insert_tree (tree,&data) ; } putchar ('\n') ; last_node = NULL ; traverse_tree (tree,calculate_length) ; fseek (fp,0,SEEK_END) ; file_length = (int)ftell (fp) ; last_offset = last_node->old_offset ; last_node->length = file_length - last_offset ; traverse_tree (tree,add_amount) ; /* subtract length of header */ modified = FALSE ; } traverse_tree(tree_ptr cursor,int (*function)() ) { if (cursor == NULL) return ; traverse_tree (cursor->left,function) ; (*function) (cursor) ; traverse_tree (cursor->right,function) ; } list_node(tree_ptr cursor) { printf ("%-20.20s ",cursor->name) ; if (cursor->deleted) printf ("Deleted\n") ; else if (cursor->new) printf ("New (%s)\n",cursor->filename) ; else printf ("%X\n",cursor->length) ; num_modules++ ; } int check_using(void) { if (filename[0] == '\0') { fprintf (stderr,"No working library has been defined\n"); return FALSE; } return TRUE ; } list_directory(void) { if (!check_using()) return ; printf ("\nContents of library: %s\n\n",filename) ; num_modules = 0 ; traverse_tree (tree,list_node) ; if (num_modules) printf ("\nTotal of %d modules\n",num_modules) ; else printf ("No modules found\n") ; } insert_module(void) { char name[MAX_NAME],filename[100] ; tree_ptr ptr ; record data ; char *filename_ptr ; if (!check_using()) return ; strcpy (name,get_string (NULL,"Name of module to insert")) ; if (strlen(name) > MAX_NAME) { fprintf (stderr,"Name too long\n") ; return ; } if ((ptr=search_tree(tree,name)) != NULL) fprintf (stderr,"Module \"%s\" already exists in library\n",name) ; else { strcpy (filename,get_string(NULL,"Name of object file")); if (!valid_obj_file(filename)) return ; strcpy (data.name,name) ; data.offset = INT_MAX ; /* ensure end of list */ ptr = insert_tree (tree,&data) ; ptr->new = modified = TRUE ; if ((ptr->filename = malloc (strlen(filename)+1)) == NULL) no_room() ; strcpy (ptr->filename,filename) ; modify_offsets (name,INSERT,tree) ; } } valid_obj_file (char *name) { char *ch = compiler_header ; FILE *obj_fp ; if ((obj_fp=fopen(name,"r")) == NULL) { fprintf (stderr,"Object file not found\n") ; return FALSE ; } while (*ch == (unsigned short)fgetc(obj_fp)) if (*ch++ == '\n') break ; fclose (obj_fp) ; if (*--ch != '\n') { fprintf (stderr,"Invalid object file\n") ; return FALSE ; } return TRUE ; } add_deleted_amount (tree_ptr cursor) { if (cursor->new_offset > deleted_offset) add_amount (cursor) ; } no_module (char *name) { fprintf (stderr,"Module \"%s\" does not exist in library\n",name) ; } delete_module(void) { char name[MAX_NAME] ; tree_ptr ptr ; record data ; if (!check_using()) return ; strcpy (name,get_string(NULL,"Name of module to delete")) ; if ((ptr=search_tree(tree,name)) == NULL) no_module (name) ; else { ptr->deleted = modified = TRUE ; modify_offsets (name,DELETE,tree) ; amount_to_add = -ptr->length ; deleted_offset = ptr->new_offset ; traverse_tree (tree,add_deleted_amount) ; } } modify_offsets(char *name, int op,tree_ptr cursor) { amount_to_add = strlen (name) + SYMBOL_ADMIN_SIZE ; if (op==DELETE) amount_to_add = -amount_to_add ; traverse_tree (cursor,add_amount) ; } extract_module(void) { char name[MAX_NAME], filename[100] ; FILE *file_fp ; int loop ; tree_ptr ptr ; if (!check_using()) return ; strcpy (name,get_string(NULL,"Name of module to extract")) ; if ((ptr=search_tree(tree,name)) == NULL) no_module (name) ; else { if (ptr->new || ptr->deleted) { fprintf (stderr,"Cannot extract module\n") ; return ; } printf ("Name of file:") ; scanf ("%s",filename) ; file_fp = fopen (filename,"w") ; put_header (compiler_header,file_fp) ; fputc (0,file_fp) ; put_header (name,file_fp) ; bput (file_fp,'\r') ; printf ("Extracting...\n") ; fseek (fp,ptr->old_offset,SEEK_SET) ; for (loop = 1; loop < ptr->length ; loop++) bput (file_fp,bget(fp)) ; fclose(file_fp) ; } } # define NUM_COMMANDS 11 # define LIST 0 # define INSERT 1 # define EXIT 2 # define USE 3 # define CREATE 4 # define DELETE 5 # define QUIT 6 # define COMMIT 7 # define NEW 8 # define EXTRACT 9 # define HELP 10 # define MAX_NAME 32 typedef struct tree_node { struct tree_node *left,*right ; /* left and right children */ char *name, *filename ; /* module name + file name */ int old_offset ; /* offset into old file */ int new_offset ; /* offset into new file */ int length ; /* length of module */ unsigned deleted : 1 ; /* deleted flag */ unsigned new : 1 ; /* new flag */ } *tree_ptr ; typedef struct data_node { char name[MAX_NAME] ; int offset ; } record ; /************************************************************************ Beebug C Library Facility ------------------------- Author : David Allison Issue : 1.0 Date : 13 August 1987 (C) 1987 Beebug Limited This is the main driver module for the facility. *************************************************************************/ # include # include # include # include # include "c.libdef" struct { char *comm ; int token ; char *description ; } commands [] = { { "LIST",LIST,"List contents of library" }, { "INSERT",INSERT,"Insert module into library" }, { "EXIT",EXIT,"Exit, committing changes"} , { "USE",USE,"Establish working library"}, { "CREATE",CREATE,"Create new library"}, { "DELETE",DELETE,"Delete module from library"}, { "QUIT",QUIT,"Quit from facility"}, { "COMMIT",COMMIT,"Commit changes to disk"}, { "NEW",NEW,"Establish new working library"}, { "EXTRACT",EXTRACT,"Extract module into file"}, { "HELP",HELP,"This command"} } ; # define MAX_COMMAND 50 char command_line[MAX_COMMAND], filename[100] ; FILE *fp,*new_fp ; int offset, modified ; char header[] = "Beebug C Librarian V1.1\n" ; extern char buffer [] ; /* in c.dirops */ unsigned short get_byte(void) { return getc(fp) &0xff ; } void read_symbol_name(void) { char *ch = buffer ; while ((*ch++ = get_byte()) != '\n') ; *--ch = '\0' ; } void read_offset(void) { offset = bget(fp) &0xff ; offset += ((bget(fp) &0xff)*256) ; } void read_symbol(void) { read_symbol_name() ; read_offset() ; } int skip_header(void) { char *ch = header ; while (*ch == get_byte()) if (*ch++ == '\n') return TRUE ; return FALSE ; } void upper_case (char *string) { while (*string) { *string = toupper (*string) ; string++ ; } } char *get_string (char *buf, char *prompt) { char *result ; if ((result=strtok(buf," ")) != NULL) return result ; fflush (stdin) ; printf ("%s:",prompt) ; gets (command_line) ; return get_string (command_line,prompt) ; } int get_command(void) { char command[255] ; int loop, command_count, command_num ; for (;;) { memset (command_line,0,MAX_COMMAND) ; /* reset command buffer */ osbyte (200,1,0xfe) ; /* disable escape key */ printf ("LIBRARY> ") ; /* display prompt */ fflush (stdin) ; gets (command_line) ; /* get command */ osbyte (200,0,0xfe) ; /* reenable escape */ if (command_line[0] == '\0') /* return pressed */ continue ; if (command_line[0] == '*') /* star command */ { system (command_line) ; continue ; } strcpy (command,strtok (command_line," .")) ; /* get first word */ upper_case (command) ; command_count = 0 ; for (loop = 0 ; loop < NUM_COMMANDS ; loop ++) if (strncmp (commands[loop].comm,command,strlen(command)) == 0) { command_count ++ ; /* increment command count */ command_num = loop ; /* save command */ } if (command_count > 1) fprintf (stderr,"Ambiguous command\n") ; /* more than one */ else if (command_count == 0) fprintf (stderr,"Bad command\n") ; /* bad command */ else return commands[command_num].token ; /* command ok */ } } int check_valid (void) { if (filename[0] == '\0') { fprintf (stderr,"No working library\n") ; return FALSE ; } return TRUE ; } void handle_command(int command) { switch (command) { case CREATE : create_library() ; break ; case USE : use_library() ; break ; case LIST : list_directory() ; break ; case INSERT : insert_module() ; break ; case DELETE : delete_module() ; break ; case COMMIT : if (modified) { commit_changes() ; fp = fopen (filename,"r") ; free_tree() ; skip_header() ; print_lib_id() ; read_directory() ; } break ; case NEW : new_library() ; break ; case EXTRACT : extract_module() ; break ; case HELP : give_help() ; } } void print_lib_id (void) { char ch ; while (ch=get_byte()) /* library id text */ putchar (ch) ; putchar ('\n') ; while (ch=get_byte()) /* copyright info */ putchar (ch) ; putchar ('\n') ; } void use_library (void) { if (filename[0] != '\0') { fprintf (stderr,"Already using a library\n") ; return ; } strcpy (filename,get_string (NULL,"Name of library to use")) ; upper_case (filename) ; if ((fp=fopen(filename,"r")) == NULL) { fprintf (stderr,"Library %s not found\n",filename) ; filename[0] = '\0' ; return ; } if (skip_header() == FALSE) { fprintf (stderr,"Bad library\n") ; close_library() ; ; filename[0] = '\0' ; return ; } print_lib_id() ; read_directory() ; } void put_header (char *ch, FILE *file) { while (*ch) { if (*ch == '\n') bput (file,'\r') ; else bput (file,*ch) ; ch ++ ; } } void create_library (void) { char library_id[255] ; if (filename[0] != '\0') { fprintf (stderr,"There is a library in use\n") ; return ; } strcpy (filename,get_string(NULL,"Name of library to create")) ; upper_case (filename) ; fp = fopen (filename,"w") ; put_header (header,fp) ; fflush (stdin) ; printf ("Enter the library identification text:") ; gets (library_id) ; fprintf (fp,"%s",library_id) ; fputc (0,fp) ; printf ("Enter copyright text:") ; gets (library_id) ; fprintf (fp,"%s",library_id) ; fputc (0,fp) ; fputc (0xff,fp) ; fclose(fp) ; fp = fopen (filename,"r") ; skip_header() ; print_lib_id() ; read_directory() ; } void ask_commit (void) { char answer[10] ; printf ("Commit changes ? ") ; scanf ("%s",answer) ; if (toupper(answer[0]) == 'Y') commit_changes() ; else close_library() ; } void new_library(void) /* establish new library */ { if (modified) ask_commit() ; else close_library() ; filename[0] = '\0' ; free_tree () ; modified = FALSE ; init_tree() ; } void give_help(void) { int loop = 0; printf ("\nThe commands available are:\n\n") ; for (; loop < NUM_COMMANDS; loop++) printf ("%-8s %s\n",commands[loop].comm,commands[loop].description) ; putchar ('\n') ; } void close_library (void) { fclose (fp) ; } void main(void) { int command ; printf ("\nBeebug C Library Facility\nVersion 1.0\n") ; printf ("Author : David Allison\n") ; printf ("(C) 1987 Beebug Limited\n\n") ; atexit (close_library) ; /* close library on exit */ filename[0] ='\0' ; /* no working library yet */ modified = FALSE ; /* no modifications yet */ init_tree() ; /* initialise the binary tree */ for (;;) { command = get_command() ; /* get a command */ if (command == EXIT || command == QUIT) /* EXIT or QUIT? */ break ; handle_command (command) ; /* execute command */ } if (modified) if (command == QUIT) ask_commit() ; else commit_changes() ; /* commit changes on EXIT */ else close_library() ; } /* c'est fini */ /************************************************************************* Linkable D-code Disassembler ---------------------------- Author : David Allison Issue : 1.0 Date : 11 August 1987 (C) 1987 Beebug Limited This file is the main driving software for the disassembler. It should be linked with SPECIAL, the special opcode handler. ***************************************************************************/ # include /* standard input/output definitions */ # include /* standard library definitions */ # include /* standard definitions */ # define NUM_OPCODES 67 /* number of opcodes */ /* these are the types */ # define INT 0 /* int */ # define UINT 1 /* unsigned int */ # define LONG 2 /* long int */ # define ULONG 3 /* unsigned long */ # define CHAR 4 /* char (signed) */ # define UCHAR 5 /* unsigned char */ # define BIT_FIELD 6 /* bit field */ # define FLOAT 7 /* float/double */ int address ; /* address of current opcode */ FILE *file_ptr ; /* file ptr for file */ /* the opcodes are held in the following structure. The num_bytes member holds various info about the opcode. The bits in this member are: bit 7 - clear indicates that a type may follow the opcode bit6 ..0 - the number of bytes all set - this is a special opcode requiring special treatment */ struct op_list { byte opcode ; /* the opcode */ char *string ; /* the name of the opcode */ byte num_bytes ; /* number of bytes following opcode */ } list[NUM_OPCODES] = { { 0xa0,"pre-inc",255 }, { 0xa2,"add",0 }, { 0xa3,"pre-dec",255 }, { 0xa5,"sub",0 }, { 0xa7,"mult",1 }, { 0xaa,"and",0 }, { 0xab,"onescomp",0 }, { 0xac,"noteq",0 }, { 0xad,"not",0 }, { 0xaf,"mod",1 }, { 0xb0,"gteq",1 }, { 0xb2,"greater",1 }, { 0xb3,"rshift",0 }, { 0xb4,"lesseq",1 }, { 0xb6,"less",1 }, { 0xb7,"lshift",0 }, { 0xb8,"equal",0 }, { 0xb9,"store",1 }, { 0xbb,"exor",0 }, { 0xbe,"or",0 }, { 0xc0,"div",1 }, { 0xd0,"post-inc",255 }, { 0xd3,"post-dec",255 }, { 0xd7,"contents",1 }, { 0xd5,"neg",0 }, { 0xdd,"float-s",0 }, { 0xe1,"defbytes",255 }, { 0xe2,"defsym",255 }, { 0xe3,"decsp",130 }, { 0xe4,"jf",255 }, { 0xe5,"jt",255 }, { 0xe6,"jmp",255 }, { 0xe7,"rts",0 }, { 0xe8,"switch",0 }, { 0xe9,"switch-list",255 }, { 0xea,"end-list",255 }, { 0xeb,"ldmem",255 }, { 0xec,"ldaddrmem",255 }, { 0xed,"ldstk",3 }, { 0xee,"ldimm4",132 }, { 0xef,"ldlitaddr",130 }, { 0xf0,"ldind",1 }, { 0xf1,"pop-as",0 }, { 0xf2,"ldind-np",1 }, { 0xf3,"incsp",130 }, { 0xf4,"defspace",130 }, { 0xf5,"deflitoff",130}, { 0xf6,"trunc",0 }, { 0xf7,"ldaddrstk",130 }, { 0xf8,"call",255 }, { 0xf9,"callind",129 }, { 0xfa,"push-vs",0 }, { 0xfb,"def-list",255 }, { 0xfc,"push-as",0 }, { 0x80,"func-name",255 }, { 0x81,"line-number",130 }, { 0x83,"reset-line-func",255 }, { 0x82,"addf",0 }, { 0x85,"subf",0 }, { 0xb5,"negf",0 }, { 0x86,"ldimm2",130 }, { 0x87,"ldimm1",129 }, { 0x88,"ldimm0",0 }, { 0x89,"ldimm3",131 }, { 0x8a,"defstatoff",255 }, { 0xfd,"float-us",0 }, { 0x8b,"sym-ref",255} } ; /* this function returns the address of the opcode record (see above) associated with the opcode passed as a parameter */ struct op_list *opcode_record(byte opcode) { int i ; for (i=0 ; istring) ; num_bytes = code->num_bytes ; /* get number of bytes */ if (num_bytes == 0xff) disassemble_special(code) ; /* special opcode */ else if (num_bytes) /* do any bytes follow */ { type = get_byte() ; /* get the type */ if ((num_bytes & 0x80) == 0) /* type allowed ? */ { if (type==BIT_FIELD) /* for bitfield need */ num_bytes += 2 ; /* 2 more */ print_type (type) ; /* print the type */ } else printf ("%02X ",type) ; /* no type */ --num_bytes ; /* already have one byte */ num_bytes &= 0x7f ; /* mask off top bit */ for (i=0 ; i /* only need unsigned int and bitfield */ # define UINT 1 # define BIT_FIELD 6 extern int get_byte (void) ; /* is c.dasm, get a byte */ struct op_list { unsigned short opcode ; char *string ; unsigned short num_bytes ; } ; /* this is the main function. It disassembles one opcode. All those opcodes whose 'num_bytes' field is 255 are handled here */ disassemble_special(struct op_list *code) { switch (code -> opcode) { case 0xe4 : case 0xe5 : case 0xe6 : case 0xec : case 0xea : case 0xfb : case 0xe2 : read_symbol() ; break ; case 0xe1 : def_bytes() ; break ; case 0x80 : read_name() ; break ; case 0x83 : reset_line_func() ; break ; case 0xeb : load_mem() ; break ; case 0xa0 : case 0xa3 : case 0xd0 : case 0xd3 : inc_dec() ; break ; case 0xf8 : dasm_call() ; break ; case 0xe9 : switch_list() ; break ; case 0x8a : def_stat_offset() ; break ; case 0x8b : read_symbol() ; } } /* read a symbol from the input file */ read_symbol(void) { int type ; switch (type=get_byte()) /* get the symbol type */ { case 2 : read_external() ; /* external */ break ; case 1 : read_static() ; /* static symbol */ break ; case 4 : read_internal() ; /* internal */ break ; case 3 : read_func_stat() ; /* funcion static symbol */ break ; case 0xd8 : read_label() ; /* label */ break ; default : fprintf (stderr,"\nUnknown symbol type %d\n",type) ; } } /* output the next byte from the file in hex */ out_byte(void) { unsigned short i ; i = get_byte() ; printf ("%02X ",i & 0xff) ; } read_name(void) { int i ; putchar ('"') ; while ((i=get_byte()) != '\r') putchar (i) ; putchar ('"') ; } read_external(void) { printf ("external ") ; read_name() ; } read_static(void) { printf ("static ") ; read_name() ; } read_internal(void) { int lo,hi ; printf ("internal ") ; lo = get_byte() ; hi = get_byte() ; printf (" %X",hi * 256 + lo) ; } read_label(void) { int lo,hi ; printf ("label ") ; lo = get_byte() ; hi = get_byte() ; printf (" %X",hi * 256 + lo) ; read_name() ; } read_func_stat(void) { int lo,hi ; printf ("int-static ") ; lo = get_byte() ; hi = get_byte() ; printf (" %X",hi * 256 + lo) ; putchar (' ') ; out_byte() ; out_byte() ; } def_bytes(void) { int lo,hi,num ; lo = get_byte() ; hi = get_byte() ; num = hi*256+lo ; for (lo=0 ; lo < num ; lo++) out_byte() ; } reset_line_func(void) { read_symbol() ; putchar (' ') ; out_byte() ; out_byte(); } load_mem(void) { unsigned short i ; print_type (i = get_byte()) ; if (i==BIT_FIELD) { out_byte() ; out_byte(); } read_symbol() ; } inc_dec(void) { unsigned short i ; print_type (i = get_byte()) ; if (i==UINT) { out_byte() ; out_byte(); } } dasm_call(void) { out_byte() ; read_symbol() ; } switch_list(void) { out_byte() ; out_byte() ; read_symbol() ; } def_stat_offset(void) { read_symbol() ; putchar (' ') ; out_byte() ; out_byte() ; } Beebug C Linker V1.1 {20))))** ****!*%***2*9*@*E*L*R*X*]*`*d*m*v**݃*******************+++!+'+1+6+>+F+O+W+a+m+}++++++++++Cv&!%m&!%7&g(&-&&+$11'%+1#',''g(f'X''v'+1'g(+1'" ɕ(((((5(B(O(\(f(+1f(+1f(,1f(,1f(,1f(,1f(,1f(%,1%%1%%,,0(.,$11) ()g(((g(g(g( ))Beebug C Compiler V1.5 dD,1f,1~,1d),1,1" ɕ),p1y((),$1)&))%0dpre-incaddpre-decsubmultandonescompnoteqnotmodgteqgreaterrshiftlesseqlesslshiftequalstoreexorordivpost-incpost-deccontentsnegfloat-sdefbytesdefsymdecspjfjtjmprtsswitchswitch-listend-listldmemldaddrmemldstkldimm4ldlitaddrldindpop-asldind-npincspdefspacedeflitofftruncldaddrstkcallcallindpush-vsdef-listpush-asfunc-nameline-numberreset-line-funcaddfsubfnegfldimm2ldimm1ldimm0ldimm3defstatofffloat-ussym-ref Unknown opcode : %X %04X %-20s%02X %02X int uint long ulong char uchar bitfield float rCan't open file "%s" D-code Disassembler Version 1.0 Author : David Allison (C) 1987 Beebug Ltd Filename:%s%sBad object file !-!-!-!-!-!-!-)-1-9-A-I-I-I-I-Q-Y-a-i-n-o-n-F/n-.n-/n-/n-/n-0n-0n-/0n-o-g(-------K.-[.-k.-.-.-N0$1g(g01""ɕg( 8."ɕ.""ɕm01.x01.01g(g(0101g(g(01.01g(g(01" ɕ--g(g(/-x/o-" ɕ--g('/--o-g('0---o---o-o-" ɕ-- Unknown symbol type %d %02X external static internal %Xlabel %Xint-static %X0 #P  HPh `0  @a r ȱ+%!wIllegal file access mode 9HPhPHaK  hiP`1  ` 8` "922;2921 2&2182 exit status: %d `1  ` 8` "922;292Beebug C Linker V1.1 J,-------- ..#.*.E.J.].d.{... .. .Beebug C Librarian V1.1 %0& H&1&%%sF%%sF%&W&%&& &&&hC&.H' G.wG_%D_%&2_%jHD.wG G_%DD_%'(_%*'_%hD(._%H B& _(B % BV((~(.$F((.$F(%`'%(/$F))!)))1)9)q) y) ))*)))k5)5)7)%n)@%/%E0&)3)G,)8)w,&)"ɕ)" ɕ&)"ɕ)" ɕ% */$F2/&%B%&%I/%Ef*%K/$F%&*a/$F,%)3* * F*F*%+n/$F/&%B%&%/%E%%* G/wGD/%F%ɕ/wGD/%F%ɕ%ɕ%D%/%E&)3 /wG/gGhCY>,@C,, %W,,\,,%0%1/wG ,%%0wG," ɕ%D'0wGO0wGg0wG,UH%%1Z'K-S-a-(.-%-|-,-@-,LISTList contents of libraryINSERTInsert module into libraryEXITExit, committing changesUSEEstablish working libraryCREATECreate new libraryDELETEDelete module from libraryQUITQuit from facilityCOMMITCommit changes to diskNEWEstablish new working libraryEXTRACTExtract module into fileHELPThis command %s:LIBRARY> .Ambiguous command Bad command No working library rAlready using a library Name of library to userLibrary %s not found Bad library There is a library in use Name of library to createwEnter the library identification text:%sEnter copyright text:%srCommit changes ? %s The commands available are: %-8s %s Beebug C Library Facility Version 1.0 Author : David Allison (C) 1987 Beebug Limited 4:9E9E9E0041L:$FG~C#10B~C_10B  110100(21 z22b21w22121222?B2232Q3 00y30 00" ɕ0%9Gչ&3 4&a:wG0 B %023" ɕ0R304%F%9G00 0304%444p:wG5z:wG@5+5:wG@5 :wG0%g5:$FG5u5%:wG0404050:wG5:wGG55 :&BB 6;$F 02I6!;$F7H;&B 7s6 B 02%B~C60B08 0\;EK7^;$Fv7 s7v7K7D 7u;$F 0703;$F G57;&B02<878%080 չ0 7040B800չ03 4G58;&nBj02(9j70:C9\9;$F;wG <gG < E0*ɕn* F<wG%F %:%sFF9DBeebug C Compiler V1.5 Insufficient memory Reading... %d %-20.20s Deleted New (%s) %X No working library has been defined Contents of library: %s Total of %d modules No modules found Name of module to insertName too long Module "%s" already exists in library Name of object filerObject file not found Invalid object file Module "%s" does not exist in library Name of module to deleteName of module to extractCannot extract module Name of file:%swExtracting... 0<%<%< % %ɕ  m%ɕA%F %F %F<%9G&>>#<AwG%F >%sF%F\> >><%F=>B E"?B$F#<%BwG>>%F!<%F!<%F!<%FsF?%F?%ɕD  !<!<%9G%B%.a@o@H@@% .C@5BoBd#<6@%=BE%LGj<=0%<%ɕ>04!<%9G<<#0%<# eEUZ U ]PTi \ T . T nZ T +8厢- T  0 T 0LTfb 8U厪 ]TeT 0  T'. T `0 TT. T8厨 T` 0LTs> j ]TT ]# T T3 TB`CcLT j TdehiX vde`j lelm`w {&&&*  0 `RSS0- Tƌ PSS 8PS _ T-ƌ T`]TT8TU j  0  `  &8f  ') L/'k  J L/P Lw] 5j #轂0`w :0`ƎȢ     ` 授#  *0 `c$scan  bX jlm j pq\cg I n c%LL  _[Ȅ^ I*[ I% &Sl^ I: bD oNx/V b PŎd P y PŎ\L~L dh\^ b - Sƌ y \   P   y \ \ e [ j^L ehL ^ h   b G  _ƌ D L D ! P   Dh7  DL7C 5% y +-ƍX y \  e ePLXp L \e0    L  fLs4 e cQ[ j [ yc n\[Lc y[c jLP bPL\  XcL\Q ]4 g`<._D yG_ƏL\P a A\80P`b e y n`n   x`y S\ `S\\XG6l.Yʽ L QȄY fY Q`  Qc` lQclm`\Q`Z ~ȱz Ȅtz|{}` |ȱz}ȱz ~ȱzȄt@x``a~ jkxP:`Px jlkm  4Ox0G@G  at line ~   in function '   ' in file ' ' ? EF`  A = _   B = [   PC = {   ASP = u !   FSP = y !   VSP = w   File   Function"   Line xZ   " ~  tyʽ{ʽzʆyLz  zɃ |l}mL|tClDmtllm  l  `t  t t L u H h 0L !ʈ`!HJJJJ ,h), i2i0L7 zL{A oL{G L{Mu   L{^u   L{o ) e z L?   &8f FLe `8阨IȐ$ &&&&`  &&&` ffff`  Ffff` ffff`  Ffff` `  ` ` `&*:00 e e IH`I ppqU`V j ^`bvVwWjgnVViVW` pȱzqȄtlp