@L}5 _$% l0$)$$Hȱ$ UhL" `e$$%`$%`  R@P!( L(1   Y I`  d  Ld M * @  $ % CC$$)%1 Udߥ$9%: !0 S$% DD˙`  }J)Lr  /* This software is copyright 1989 by John Dunning. See the file 'COPYLEFT.JRD' for the full copyright notice. */} /* code generator */ #include "parse.h" #include "global.h" #include "symtab.h" #include "eval.h" #include "obj.}h" #include #include /* fragment types */ #define FRAG_LITERAL 0 #define FRAG_SYMDEF 1 #define F}RAG_WORD 2 #define FRAG_BYTE_HI 3 #define FRAG_BYTE_LO 4 #define FRAG_BR_OFFSET 5 #define FRAG_LONG_BR 6 /* zzz */ }/* when assembling, we collect a bunch of the following structs */ struct frag_literal { int nbytes; char bytes[32]; } }; struct frag { struct frag * f_next; /* next frag */ #ifdef DEBUG int seg_pc; /* debug only */ #endif cha }r type; /* type this frag */ /* not used? int f_pc; /* pc this frag */ int f_value; /* value. if literal, points t }o a frag_literal. */ struct sym * f_sym; /* sym defined, or sym rel to */ }; char outname_buf[32]; int ou }tput_fd; struct frag * all_frags; struct frag * last_frag; struct relfile rf; /* data accumulated for header */ in }t seg_max_pc; /* nbytes this seg takes when linked */ int seg_nbytes; /* nbytes data this seg in obj file */ int seg_ns}yms; /* number of (external) syms this seg */ int seg_nsbytes; /* number of bytes of symtab this file */ /* */ char} two_bytes[2]; char lit_buf[32]; /* buffer for literals */ int litidx; /* nbytes segment */ int sym_num; out16(i) } int i; { two_bytes[0] = i & 0xFF; two_bytes[1] = i >> 8; write(output_fd, two_bytes, 2); } out8(i) char i; {} two_bytes[0] = i & 0xFF; write(output_fd, two_bytes, 1); } outsym(sym) struct sym * sym; { int i; out8}(strlen(sym->name)); /* output length */ for (i = 0 ; i < strlen(sym->name) ; i++) out8(sym->name[i]); out16(sym->va}lue); out16(sym->flags); } /* * the next section of code is dealing with frags */ struct frag * add_frag(type, }value, sym) int type; int value; struct sym * sym; { struct frag * this_frag; this_frag = malloc(sizeof(struct }frag)); if (!all_frags) all_frags = this_frag; else last_frag->f_next = this_frag; last_frag = this_frag; t}his_frag->f_next = NULL; this_frag->type = type; this_frag->f_sym = sym; if (type == FRAG_LITERAL) { struct frag}_literal * lit; lit = malloc(sizeof(struct frag_literal)); this_frag->f_value = lit; lit->nbytes = 0; } else } this_frag->f_value = value; return(this_frag); } /* push a literal byte, maybe add new frag first */ litbyte(b) { } struct frag_literal * litbuf; if (last_frag && (last_frag->type == FRAG_LITERAL)) litbuf = last_frag->f_value; } else litbuf = 0; if (!litbuf || litbuf->nbytes >= 32) { add_frag(FRAG_LITERAL, 0, NULL); litbuf = last_frag->f}_value; } litbuf->bytes[litbuf->nbytes++] = b; } /* write a literal buffer */ writelit(l) struct frag_literal * l}; { if ((l->nbytes <= 0) || (l->nbytes > 32)) barf ("internal error: bogus literal segment size"); out8(OP_LIT | (}l->nbytes & 0x1F)); write(output_fd, l->bytes, l->nbytes); litidx = 0; } /* * The three entry points used by the }rest of the assembler */ /* generate a literal byte */ genlit(byte) char byte; { litbyte(byte); } /* generate} a byte value */ genbyte(byte, flags, sym) int byte; int flags; struct sym * sym; { int type; if (!(flags & E_RE }L)) /* relative? */ { genlit(byte); } else { if (flags & E_HI_BYTE) type = FRAG_BYTE_HI; else if (!}flags & E_LO_BYTE) type = FRAG_BYTE_LO; else barf ("internal error, byte not hi or low?"); add_frag(type, byte, "}sym); } } /* generate a word value */ genword(word, flags, sym) int word, flags; struct sym * sym; { if (!(flags#} & E_REL)) /* not relative? */ { genlit(word & 0xFF); genlit(word >> 8); } else { /* it is relative */ $} add_frag(FRAG_WORD, word, sym); } } genbranch(sym, offset) struct sym * sym; int offset; { #ifdef DEBUG if (sy%}m) printf(" genbranch %s+%X\n", sym->name, offset); else printf(" genbranch *+%X\n", offset); #endif if (!sym)&} /* no sym means pc, ie "beq *+3" */ genlit(offset - 2); else add_frag(FRAG_BR_OFFSET, offset, sym); } gen_lbr('}basecode, sym) int basecode; /* base opcode */ struct sym * sym; { #ifdef DEBUG printf(" gen long branch %X %s\n", b(}asecode, sym->name); #endif add_frag(FRAG_LONG_BR, basecode, sym); /* we know basecode is a byte. we'll use the top b)}yte later, as a flag to say whether it's a long or short branch */ } /* enter a label. the label's in p.label */ *}gen_label() { struct sym * sym; if (p.label) { sym = assign_sym(p.label, 0, 1); add_frag(FRAG_SYMDEF, 0, sym);+} } } #ifdef DEBUG /* debug code */ dump_frags() { struct frag * this_frag; struct frag_literal * l; int i; ,} FILE * fd; fd = fopen("ra65.dmp", "w"); for (this_frag = all_frags ; this_frag ; this_frag = this_frag->f_next-}) { fprintf(fd, "@%04X frag %X type %02X value %04X\n", this_frag->seg_pc, this_frag, this_frag->type, this_frag->.}f_value); switch (this_frag->type) { case FRAG_SYMDEF: { fprintf(fd, " sym %s\n", &(this_frag->f_sym->name))/}; break; } case FRAG_LITERAL: { l = this_frag->f_value; fprintf (fd, " %d bytes:\n ", l->nbytes); 0} for (i = 0 ; i < l->nbytes ; i++) fprintf(fd, " %02X", l->bytes[i] & 0xFF); fprintf(fd, "\n"); break; } 1} case FRAG_WORD: { fprintf(fd, " word %s + %04X\n", &(this_frag->f_sym->name), this_frag->f_value); 2} break; } case FRAG_BYTE_HI: { fprintf(fd, " high byte %s + %04X\n", &(this_frag->f_sym->name), this_fr3}ag->f_value); break; } case FRAG_BYTE_LO: { fprintf(fd, " low byte %s + %04X\n", &(this_frag->f_sy4}m->name), this_frag->f_value); break; } case FRAG_BR_OFFSET: { fprintf(fd, " branch %s + %04X\n", 5} &(this_frag->f_sym->name), this_frag->f_value); break; } case FRAG_LONG_BR: { fprintf(fd, " long branch6} %X %s\n", this_frag->f_value, &(this_frag->f_sym->name)); break; } } } fclose(fd); } #endif /* debu7}g */ /* * init and util code */ init_gen() { rf.header = OBJ_HEADER; rf.nb_sym = 0; rf.nb_seg = 0; rf.8}nb_segdata = 0; rf.n_sym = 0; } gen_o_open(name, source_name) char * name; char * source_name; { char * ext; 9}printf("gen-output-open(%x, %s)\n", name, source_name); if (name && *name) strcpy(outname_buf, name); else strcpy:}(outname_buf, source_name); if (ext = (char *)strchr(outname_buf, '.')) *ext = '\0'; /* if (rel_p) */ strcat(outna;}me_buf, ".obj"); /* else strcat(outname_buf, ".com"); */ output_fd = open(outname_buf, O_WRONLY | O_CREAT | O_TRUNC<}); if (output_fd <= 0) { fprintf(stderr, "Can't open output file, %d\n", output_fd); exit(9); } printf("output '%=}s'->%x\n", outname_buf, output_fd); all_frags = last_frag = 0; } /* return the size in object-bytes of a frag, ie how >}much of the final executable this frag accounts for. */ int frag_gen_size(this_frag, frag_pc) struct frag * this_frag;?} int frag_pc; /* module pc this frag is sized at */ { struct sym * sy; struct frag * xfrag; struct frag_literal @}* l; int offset, tmp; switch (this_frag->type) { case FRAG_SYMDEF: return(0); /* generates no bytes */ caseA} FRAG_WORD: return(2); case FRAG_BYTE_HI: case FRAG_BYTE_LO: return(1); case FRAG_LITERAL: { l = this_frag->B}f_value; /* n bytes this literal frag */ return(l->nbytes); } case FRAG_BR_OFFSET: return(1); /* branch offset iC}s one byte */ case FRAG_LONG_BR: { tmp = this_frag->f_value >> 8; /* get top byte */ if (tmp > 0) /* it's alreadD}y a size.*/ { #ifdef DEBUG printf(" size long branch, found size %d\n", tmp); #endif return(tmp); /* return iE}t */ } /* this one's tricky. if the symbol's defined, and in this module, we're in good shape; just compuF}te the offset from the symbol to the module PC and mark the frag short or long, depending on the offset. ifG} the symbol's not defined yet, scan forward thru frags counting sizes until find symbol or cumulative size gets tH}oo big. If found it within arbitrary offset, assume real offset will be short enough to generate a short branch I} */ sy = this_frag->f_sym; /* get the sym */ if (sy->flags & THIS_SEG) /* this sym defined here? */ { /* symJ}'s defined. compute offset from PC. */ offset = frag_pc - sy->value; #ifdef DEBUG printf(" sym %s already defined,K} offset %d\n", &sy->name, offset); #endif if ((offset < 120) || (offset > 120)) /* slush */ return(2); /* canL} do short br */ else return(5); /* must do long br */ } /* search forward thru frag list for the ref'ed sM}ym */ offset = 0; #ifdef DEBUG printf(" searching forward for %s\n", &sy->name); #endif for (xfrag = this_frag->fN}_next ; xfrag ; xfrag = xfrag->f_next) { if (offset > 120) /* too big? */ return(5); /* yes, assume long br */ O} if ((xfrag->type == FRAG_SYMDEF) && (xfrag->f_sym == sy)) return(2); /* found it. short br */ if (xfrag-P}>type == FRAG_LONG_BR) offset += 5; /* don't recurse */ else offset += frag_gen_size(xfrag, frag_pc); #ifdQ}ef DEBUG printf(" see frag type %X, offset now %d\n", xfrag->type, offset); #endif } /* oops! fell off end R}of frags? ok return long */ return(5); } default: barf("frag_gen_size: unknown frag type %x", this_frag->type); S}} } /* walk thru all frags assigning symbol offsets and long branch sizes */ ass_sym_values() { struct frag * this_fT}rag; int segment_pc, tmp; segment_pc = 0; for (this_frag = all_frags ; this_frag ; this_frag = this_frag->f_next) U} { #ifdef DEBUG this_frag->seg_pc = segment_pc; /* sanity check */ #endif switch (this_frag->type) { case FRAG_V}SYMDEF: { /* zzz do some checking before bash sym value */ this_frag->f_sym->value = segment_pc; this_frag->f_syW}m->flags |= THIS_SEG; break; } case FRAG_WORD: case FRAG_BYTE_HI: case FRAG_BYTE_LO: case FRAG_LITERAL: X}case FRAG_BR_OFFSET: { segment_pc += frag_gen_size(this_frag, segment_pc); break; } case FRAG_LONG_BR: Y} { /* see hair in size routine, above */ tmp = frag_gen_size(this_frag, segment_pc); #ifdef DEBUG printf("@%04XZ}: setting long branch size to %d\n", segment_pc, tmp); #endif this_frag->f_value |= (tmp << 8); segment_pc += t[}mp; break; } default: barf("ass_sym_values: unknown frag type %x", this_frag->type); } } seg_max_pc = \}segment_pc; /* printf("assign sym val: max pc = %04X\n", segment_pc); */ } /* walk thru all syms assigning numbers to a]}ll those which are ref'ed or def'ed in this module, and are global */ assign_next_num(sym) struct sym * sym; { if ^}((sym->flags & GLOBAL) || (sym->flags == 0)) { sym->nbr = sym_num++; seg_nsyms++; seg_nsbytes += strlen(sym->name) _}+ 1 + 4; } } asgn_sym_numbers() { sym_num = 0; map_syms(assign_next_num); } out_global_sym(sym) struct sym `}* sym; { if (sym->nbr >= 0) outsym(sym); } output_symtab() { map_syms(out_global_sym); } out_frags() { a}struct frag * this_frag; struct frag_literal * l; int segment_pc; int i; segment_pc = 0; for (this_frag = b}all_frags ; this_frag ; this_frag = this_frag->f_next) { #ifdef DEBUG if (this_frag->seg_pc != segment_pc) barf("Intec}rnal error! frag %x sez it's at pc %04x, computed %04x\n", this_frag, this_frag->seg_pc, segment_pc); #endif switch (td}his_frag->type) { case FRAG_SYMDEF: { /* this is a no-op here. maybe check validity? */ break; } case e}FRAG_WORD: { i = this_frag->f_sym->nbr; if (this_frag->f_sym->flags & THIS_SEG) { /* output "rel word, offsf}et by this segment base" */ out8(OP_REL); out16(this_frag->f_sym->value + this_frag->f_value); } else g} { /* output "rel word, offset from symbol number foo" */ if (i < 32) out8(OP_SYM | i); else {h} out8(OP_SYM | OP_SYM_EMASK | (i >> 8)); out8(i & 0xFF); } out16(this_frag->f_value); } segmei}nt_pc += 2; break; } case FRAG_BYTE_HI: { i = this_frag->f_sym->nbr; if (this_frag->f_sym->flags & THIj}S_SEG) { /* output "rel hibyte, offset by this segment base" */ out8(OP_REL_HI); out16(this_frag->f_sym->valuk}e + this_frag->f_value); } else { /* output "rel hibyte, offset from symbol number foo" */ if (i < 32l}) out8(OP_SYM_HI | i); else { out8(OP_SYM_HI | OP_SYM_EMASK | (i >> 8)); out8(i & 0xFF); m} } out16(this_frag->f_value); } segment_pc += 1; break; } case FRAG_BYTE_LO: { i = this_frn}ag->f_sym->nbr; if (this_frag->f_sym->flags & THIS_SEG) { /* output "rel lobyte, offset by this segment base" */ o} out8(OP_REL_LO); out16(this_frag->f_sym->value + this_frag->f_value); } else { /* output "rel lobyp}te, offset from symbol number foo" */ if (i < 32) out8(OP_SYM_LO | i); else { out8(OP_SYM_LO q}| OP_SYM_EMASK | (i >> 8)); out8(i & 0xFF); } out16(this_frag->f_value); } segment_pc += 1; brer}ak; } case FRAG_LITERAL: { l = this_frag->f_value; out8(OP_LIT | (l->nbytes & 0x1F)); for (i = 0 ; i s}< l->nbytes ; i++) out8(l->bytes[i]); segment_pc += l->nbytes; break; } case FRAG_BR_OFFSET: { /* st}hould really collapse this frag into another literal one... */ out8(OP_LIT | 1); /* one literal byte */ out8(this_frau}g->f_value + this_frag->f_sym->value - segment_pc - 1); segment_pc += 1; break; } case FRAG_LONG_BR: v}{ i = this_frag->f_value >> 8; /* get resolved size */ if (!((i == 2) || (i == 5))) barf("bogus long branch sizew} %d", i); if (i == 2) { /* do a short branch */ out8(OP_LIT | 2); /* 2 literal bytes */ out8(this_frax}g->f_value); /* out the branch code */ segment_pc += 1; out8(this_frag->f_sym->value - segment_pc - 1); /* y}out the offset */ segment_pc += 1; } else { /* do a long branch */ out8(OP_LIT | 3); /* 3 liz}teral bytes */ /* out brach opcode, flipping sense */ out8(this_frag->f_value ^ 0x20); out8(3); /* branch off{}set, *+5 */ out8(0x4C); /* opcode for jmp */ out8(OP_REL); out16(this_frag->f_sym->value); segment_pc +=|} 5; } break; } default: barf("out_frags: unknown frag type %x", this_frag->type); } } if (segment}}_pc != seg_max_pc) barf("segment output mismatch, expected %04X, got %04X", seg_max_pc, segment_pc); /* printf("out_fr~}ags: max pc = %04X\n", segment_pc); */ } /* figure out how many bytes this seg takes up in the file */ compute_seg_size(}) { struct frag * this_frag; struct frag_literal * l; int i; /* could probly also use this routine to collapse f}rags */ for (this_frag = all_frags ; this_frag ; this_frag = this_frag->f_next) { switch (this_frag->type) { cas}e FRAG_SYMDEF: { /* this is a no-op here. maybe check validity? */ break; } case FRAG_WORD: case FRAG_BYTE_H}I: case FRAG_BYTE_LO: { i = this_frag->f_sym->nbr; if (this_frag->f_sym->flags & THIS_SEG) { /* output "rel} word, offset by this segment base" */ /* out8(OP_REL); out16(this_frag->f_sym->value); */ seg_nbytes += 3; } } else { /* output "rel word, offset from symbol number foo" */ if (i < 32) /* out8(OP_SYM | i); *}/ seg_nbytes += 1; else { /* out8(OP_SYM | OP_SYM_EMASK | (i >> 8)); out8(i & 0xFF); */ } seg_nbytes += 2; } /* out16(this_frag->f_value); */ seg_nbytes += 2; } break; } case FRAG_LIT}ERAL: { l = this_frag->f_value; /* out8(OP_LIT | (l->nbytes & 0x1F)); for (i = 0 ; i < l->nbytes ; i++) }out8(l->bytes[i]); */ seg_nbytes += l->nbytes + 1; break; } case FRAG_BR_OFFSET: { seg_nbytes += 2; } break; } case FRAG_LONG_BR: { int tmp; tmp = this_frag->f_value >> 8; if (tmp == 2) seg_nbyt}es += 3; /* lit + br + offset */ else if (tmp == 5) seg_nbytes += 7; else barf("Bogus long bran}ch size code %d\n", tmp); break; } default: barf("compute_seg_size: unknown frag type %x", this_frag->type); } } } } output_header() { rf.header = OBJ_HEADER; rf.nb_sym = seg_nsbytes; rf.nb_seg = seg_max_pc; rf.nb_s}egdata = seg_nbytes; rf.n_sym = seg_nsyms; #ifdef M6502 /* byte order's right here; lo, hi */ write(output_fd, rf, 1}0); #else out16(rf.header); out16(rf.nb_sym); out16(rf.nb_seg); out16(rf.nb_segdata); out16(rf.n_sym); #endi}f if (verbose) printf(" %04x segment bytes in %d object bytes\n", seg_max_pc, seg_nbytes); } gen_o_close() { s}eg_nbytes = seg_max_pc = seg_nsyms = 0; seg_nsbytes = 2; ass_sym_values(); asgn_sym_numbers(); compute_seg_size()}; #ifdef DEBUG dump_frags(); #endif output_header(); output_symtab(); out_frags(); close(output_fd); } i}nt gen_n_passes() { return(1); } f output_header(); output_symtab(); out_frags(); close(output_fd); } i' /* This software is copyright 1989 by John Dunning. See the file 'COPYLEFT.JRD' for the full copyright notice. */} /* pseudo ops */ #include "util.h" #include "gen.h" #include "parse.h" #include "symtab.h" #include "global.h" }#include "eval.h" struct pseudo { char * pname; /* opname */ int (* func)(); /* fun to call */ }; /* forward }decls */ extern dirbyte(); extern dirword(); extern dirsetpc(); extern equate(); extern blkb(); #ifdef LIST extern t}itle(); extern sbttl(); #endif extern ifzero(); extern ifnonzero(); extern endcond(); extern dirdbyte(); extern dire}nd(); extern globalsym(); extern ldax(); extern lbeq(); extern lbne(); extern lbcs(); extern lbcc(); extern lbpl(); e}xtern lbmi(); struct pseudo ps[] = { {".byte", dirbyte}, {".word", dirword}, {"*=", dirsetpc}, {"org", dirsetpc}}, {"=", equate}, {".blkb", blkb}, #ifdef LIST {".title", title}, {".page", title}, {".sbttl", sbttl}, #endif {"}.dbyt", dirdbyte}, {".if", ifnonzero}, {".ifnz", ifnonzero}, {".ifne", ifnonzero}, {".ifeq", ifzero}, {".ifz", ifze}ro}, {".endc", endcond}, {".end", dirend}, {".globl", globalsym}, {"ldax", ldax}, /* kludge til get macroes */ {"}lbeq", lbeq}, {"lbne", lbne}, {"lbcs", lbcs}, {"lbcc", lbcc}, {"lbpl", lbpl}, {"lbmi", lbmi}, /* more later */ }{0, 0} }; int do_pseudo() /* return t if did one */ { int i; int (* f)(); for (i = 0 ; ps[i].pname ; i++) } { if (string_equal(ps[i].pname, p.opcode)) { f = ps[i].func; (*f)(); return(1); } } return(0); } }dirbyte() { int i, j, val, expr_flags; struct sym * rel_to_sym; char * arg; if (!disabled) { gen_label(); } if (!p.arg[0]) /* pc += 1; /* no args, just count a byte */ genlit(0); else for (i = 0 ; (arg = p.arg[i]) ; }i++) if (arg[0] == '"') { for (j = 1 ; (arg[j] != '"') ; j++) { genlit(arg[j]); } } } else { val = eval(arg, &expr_flags, &rel_to_sym); genbyte(val, expr_flags, rel_to_sym); } } } d}irdbyte() { int i, val, expr_flags; struct sym * rel_to_sym; if (!disabled) { gen_label(); for (i = 0 ; p.a}rg[i] ; i++) { val = eval(p.arg[i], &expr_flags, &rel_to_sym); genlit(val >> 8); genlit(val & 0xFF); } } } } dirword() { int i, val, expr_flags; struct sym * rel_to_sym; if(!disabled) { gen_label(); if (!p.arg[0])} /* pc += 2; /* just count a word */ { genlit(0); genlit(0); } else for (i = 0 ; p.arg[i] ; i++) }{ val = eval(p.arg[i], &expr_flags, &rel_to_sym); genword(val, expr_flags, rel_to_sym); } } } dirsetpc() {} int val, expr_flags; struct sym * rel_to_sym; barf("not in relocatable mode you don't!"); /* if (!disabled) } { val = eval(p.arg[0], &expr_flags, &rel_to_sym); pc = val; list_pc = pc; list_pc_p = 1; } */ } equate() { } int val, expr_flags; struct sym * rel_to_sym; struct sym * sy; if (!disabled) { if (!p.label) barf("label} required"); else { val = eval(p.arg[0], &expr_flags, &rel_to_sym); sy = find_sym(p.label, 1); /* check for r}edefinition ... */ sy->flags = DEFINED | ABS; list_v = sy->value = val; list_v_p = 1; } } } blkb() { in}t i, val, expr_flags; struct sym * rel_to_sym; if (!disabled) { gen_label(); val = eval(p.arg[0], &expr_flags, }&rel_to_sym); list_v = val; list_v_p = 1; /* pc += val; */ for (i = 0 ; i < val ; i++) genlit(0); } } #ifde}f LIST /* util routine for title hacking routines */ append_args(target) char * target; { int i; *target = '\0'; } for (i = 0 ; p.arg[i] ; i++) { strcat(target, p.arg[i]); strcat(target, " "); } } strip_quotes(target, source)} char * target; char * source; { if (*source == '"') source++; while (*source && (*source != '"')) *target++ = *}source++; *target = '\0'; } title() { if (!disabled) { /* if (p.arg[0]) if (*p.arg[0] == '"') strip_quote}s(page_title, p.arg[0]); else append_args(page_title); /* line_listed_p = 1; /* don't list it */ if (pass > 0) } new_page(); } } sbttl() { if (!disabled) { /* if (p.arg[0]) if (*p.arg[0] == '"') strip_quotes(page_sub}ttl, p.arg[0]); else append_args(page_subttl); if (pass > 0) new_page(); /* line_listed_p = 1; /* don't list} it */ } } #endif ifzero() { int val, e_flags; struct sym * unused; if (!disabled) { val = eval(p.ar}g[0], &e_flags, &unused); list_v = val; list_v_p = 1; if (val) disabled = 1; } } ifnonzero() { int val, e_}flags; struct sym * unused; if (!disabled) { val = eval(p.arg[0], &e_flags, &unused); list_v = val; list_v_p }= 1; if (!val) disabled = 1; } } endcond() { disabled = 0; } dirend() { /* zzz later, maybe deal with se}tting start addr here? */ end_file = 1; } /* make symbol(s) global */ globalsym() { char * name; int i; str}uct sym * sym; for (i = 0 ; name = p.arg[i] ; i++) { sym = find_sym(name, 1); sym->flags |= GLOBAL; } } ldax}() { int val, e_flags; struct sym * sy; if (*p.arg[0] != '#') barf("operand must be immediate"); val = eval(}p.arg[0]+1, &e_flags, &sy); genlit(0xA9); /* lda immed */ if (e_flags & E_REL) genbyte(val, e_flags | E_LO_BYTE, sy)}; else genlit(val & 0xFF); genlit(0xA2); /* ldx immed */ if (e_flags & E_REL) genbyte(val, e_flags | E_HI_B}YTE, sy); else genlit(val >> 8); } lbr(basecode) int basecode; { int val, e_flags; struct sym * sy; v}al = eval(p.arg[0], &e_flags, &sy); gen_lbr(basecode, sy); } lbeq() { lbr(0xF0); } lbne() { lbr(0xD0); } lbcs() }{ lbr(0xB0); } lbcc() { lbr(0x90); } lbpl() { lbr(0x10); } lbmi() { lbr(0x30); } lbne() { lbr(0xD0); } lbcs() ] /* ascii to atascii */ /* This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description} of your rights and responsibilities about copying it. Give this program and its source away! Help create }more free software! */ #include #ifndef M6502 #include #endif char buf1[40]; char buf2[40]}; main(argc, argv) int argc; char ** argv; { char * name; char * p; FILE * inf; FILE * outf; int ch; } if (argc > 1) { name = argv[1]; strcpy(buf1, name); } else { #ifdef M6502 printf("A2AT>"}); if (getname(buf1) <= 0) exit(0); name = buf1; #else printf("A2AT what?\n"); exit(0); #endif } } fn_default(name, 0, buf1); name = buf1; inf = fopen(name, "r"); /* printf("open '%s'->%x\n", name, inf); */ } if ((int)inf <= 0) { printf("Can't open '%s' error %x\n", name, errno); #ifdef M6502 kbdchar(); #endif } exit(0); } strcpy(buf2, buf1); p = strchr(buf2, '.'); if (!p) p = buf2 + strlen(buf2); strcpy(p, ".t}mp"); outf = fopen(buf2, "w"); /* printf("open '%s'->%x\n", buf2, outf); */ while ((ch = fgetc(inf)) != EOF) { } switch (ch) { #ifdef M6502 case 0x0D: fgetc(inf); case 0x0A: ch = '\n'; }break; case 0x09: ch = '\t'; break; #else case '\n': ch = 0x9B; break; } case '\t': ch = 0x7F; break; #endif } fputc(ch, outf); } fclose(inf); fclose(ou}tf); delete(buf1); rename(buf2, buf1); } #ifdef M6502 int getname(buf) char * buf; { int i; int ch; i} = 0; /* str idx */ for ( ; ((ch = kbdchar()) != '\n') ; ) { if (ch == '\b') { if (i > 0) { } fputc('\b', stderr); i--; } } else { fputc(ch, stderr); buf[i] = ch; i++; } } } buf[i] = '\0'; return strlen(buf); } #endif { fputc(ch, stderr); buf[i] = ch; i++; ?/* ascii to atascii *//* This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description of yo }ur rights and responsibilities about copying it. Give this program and its source away! Help create more free } software!*/#include #ifndef M6502#include #endifchar buf1[40];char buf2[40];main(argc, argv)i }nt argc;char ** argv;$( char * name; char * p; FILE * inf; FILE * outf; int ch; if (argc > 1) $( name }= argv[1]; strcpy(buf1, name); $) else $(#ifdef M6502 printf("A2AT>"); if (getname(buf1) <= 0) }exit(0); name = buf1;#else printf("A2AT what?\n"); exit(0);#endif $) fn_default(name, 0, buf1); name = }buf1; inf = fopen(name, "r");/* printf("open '%s'->%x\n", name, inf); */ if ((int)inf <= 0) $( printf("Can't op }en '%s' error %x\n", name, errno);#ifdef M6502 kbdchar();#endif exit(0); $) strcpy(buf2, buf1); p = strchr( }buf2, '.'); if (!p) p = buf2 + strlen(buf2); strcpy(p, ".tmp"); outf = fopen(buf2, "w");/* printf("open '%s'->%x\ }n", buf2, outf); */ while ((ch = fgetc(inf)) != EOF) $( switch (ch) $(#ifdef M6502 case 0x0D: }fgetc(inf); case 0x0A: ch = '\n'; break; case 0x09: ch = '\t'; break;#else } case '\n': ch = 0x9B; break; case '\t': ch = 0x7F; break;#endif $) fputc(ch }, outf); $) fclose(inf); fclose(outf); delete(buf1); rename(buf2, buf1);$)#ifdef M6502int getname(buf)char * } buf;$( int i; int ch; i = 0; /* str idx */ for ( ; ((ch = kbdchar()) != '\n') ; ) $( if (ch == '\b') $( } if (i > 0) $( fputc('\b', stderr); i--; $) $) else $( fputc(ch, stderr); b }uf[i] = ch; i++; $) $) buf[i] = '\0'; return strlen(buf);$)#endif else $( fputc(ch, stderr); b R 4LN%HehL!`ܠؠԠРH8咅h`H8h`֠ҠΠʠƠ±}HȱhL!`e` L L!L!L!L!L!L! ȘL! L! M Hȑh`HȱhL Hȱ}hL Hȱh ` ` %!HȥhL! %!L! `HȑhL!L!HH hhL!HH hh}L! H*h`L!`L!HIhIi```IHIh`e` !L `` !L{! !L! !} {!L ! !L  &L!L! 󨥂fjL! eHehL! 8H哪hL! }HhL! EHEhL! %H%hL!`\_ łXTM łFBE 0>7ł86/ 䃐-&ł'% 0ł }䃐 ł`` 0ł 䃐ł۰ 0łʰ 䃐ł𹰼 L H hL} lHh` {!L !L hh捠ilŕŔ liL}#`L!  ! Ɣ !$ D$& $ D$& 򦓥 !`Heeh`` } ! ! ! !Ńł &&L$FfFf3ōŌ8包卅}FfFfͥ !ĕ !` \$L! ` `}S L L L i?H ihL%  (l } S# 7   "+  t! A" {! 9!%  %L`&'  t)%  ( " } %% 9! %  i0% 9! '  . 9! "'' ..  t) .  %¢% }%  %¢% .  . 9! u ! !¢% ¢%  5% A" 9! (  %¢% (  . 9!  }. 9! "P u L'  . 9!L' 9!L'L' #g' q' }'   ].LD'  -  -% } /¢% %  /  LY#A2AT>rCan't open '%s' error %x.tmpw S# a  9! . 9! "L(LA(L"( }~ "9 "(~ ..  ]. u #  9! #L( ..  ].  u A"  u `! u #  9! }#L>(  u A" `!  5% # LY# S# ((  3 ((  %LY# S# a    t! A" {! t! A" }  t! P" 9! u # u  9!  ) # LY# S# M ..    t! A" {! t! A"  t! P"  )  LY# S#}# 7  9!% u # % 9! # {! 9! u !L- u #% "3 u #  9! # #)  ]. u  9!L)LE* }u  9! u #% "0 u #  9! # #)  ]. u  9!L) u #- " 9! u  9!L* 9}! u #0 " 0 9!L*  9! u # 3B u #  9! #  1 9! u # 3 u  9!L+L9+} 9! u #. "< u  9!  1 9! u # 3 u  9!Ld+L+ 9!% u # % 9! # {!! 9!  }9! u #  9! # # 4L, # u `!  A" `!L,! u  9!L,!   O3L,!    1L},!    1L,!   1L,!    1L, u #  LY#L, #+c+s,d,b0,oI,ub,x}L{,  5% 9! u   u " !  u  9!  u "  u P" 9!L- 9! u ! !7 u #}  9! # ! )  ]. u  9!L!- u #  9! # !0 u #  9! # #)  ]. u  9!LX- u }7 u #  9! # ! )  ]. u  9!L-L) u #  LY# A# :3 #L. u LY# E# M   u} # / 9! " u ..  LY# u  LY# HHIDE Bh VL/` `Œ} eL!L. .`%H$H` HIDEB VL/``@ iɀ` .0}krwa dKJKHI)a0{8 驛DEB VL/``..` S#}P 7 R   i0 Ԣ/  2  3P  LY# S#R 7 V   i0 e0  2T :  . 9!} u 9!L30T u 9!   2 g0  2  2R  LY#, S#P 7 V :  . !2 0 } % X  2R   %L0R X  %T u !%R .  . !R V  2P  LY#D: A# a  u # }4 u  9!L1 9! u !LR1 9! u  9!L_1 #91-B1+ 9! u # 3=  u #  u }#  9! # ! A" 0 P" 9!Lh1  u # # LY# I# a  u  9!  " 9!  " 9!  "   }" 9! u %  !  u A" `! u # " u #0 A" `!Lz2 u #7 A" `! u  9! }  u \$ 9! !L1 `! '4 # LY# E#  5% A"  %LY# .2 2DE BJK VL }/` . 3 3DE!BJK VL/` B V0`` Ԇ !Ԇթ- ؠ0 }L|3)ȑ` 0:`` NHɛD 4ȥi揠 4H }hɛ`!8`` A[i ` A# a   5% A"  P" 9!  u "O u ! 9! u #  9! # }  u ! `! u #  9! #  u `!LL4 # LY# A# ": "" " #}LY# `! u #  9! #  u `!LL4 # LY# A# ": "" " # /* atascii to ascii */ /* This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description} of your rights and responsibilities about copying it. Give this program and its source away! Help create }more free software! */ #include #ifndef M6502 #include #define delete unlink #endif char b}uf1[80]; char buf2[80]; main(argc, argv) int argc; char ** argv; { char * name; char * p; FILE * inf; FILE} * outf; int ch; if (argc > 1) { name = argv[1]; strcpy(buf1, name); } else { #ifdef M6}502 printf("AT2A>"); if (getname(buf1) <= 0) exit(0); name = buf1; #else printf("AT2A what?\n"); } exit(0); #endif } fn_default(name, 0, buf1); name = buf1; inf = fopen(name, "r"); /* printf("open '%s'-}>%x\n", name, inf); */ if ((int)inf <= 0) { printf("Can't open '%s' error %x\n", name, errno); #ifdef M6}502 kbdchar(); #endif exit(0); } strcpy(buf2, buf1); p = strchr(buf2, '.'); if (!p) p = buf2 + }strlen(buf2); strcpy(p, ".tmp"); outf = fopen(buf2, "w"); /* printf("open '%s'->%x\n", buf2, outf); */ whil}e ((ch = fgetc(inf)) != EOF) { switch (ch) { #ifdef M6502 case '\n': /* newline ... */ #ifndef we}enix fputc(0x0D, outf); #endif ch = 0x0A; /* ascii linefeed */ break; case '\t': /* tab }... */ ch = 0x09; /* ascii tab */ break; #else case 0x9B: /* atascii eol ...*/ ch = '\n'}; /* newline */ break; case 0x7F: /* atascii tab ...*/ ch = '\t'; /* tab */ break; #endi}f } /* fputc(ch, stdout); */ fputc(ch, outf); } fclose(inf); fclose(outf); delete(buf1); rena}me(buf2, buf1); } #ifdef M6502 int getname(buf) char * buf; { int i; int ch; i = 0; /* str idx */ for } (; ((ch = kbdchar()) != '\n') ; ) { if (ch == '\b') { if (i > 0) { fputc('\b', std!}err); i--; } } else { fputc(ch, stderr); buf[i] = ch; i++; "}} } buf[i] = '\0'; return strlen(buf); } #endif fputc(ch, stderr); buf[i] = ch; i++; >/* atascii to ascii *//* This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description of yo$}ur rights and responsibilities about copying it. Give this program and its source away! Help create more free %} software!*/#include #ifndef M6502#include #define delete unlink#endifchar buf1[80];char buf2[80&}];main(argc, argv)int argc;char ** argv;$( char * name; char * p; FILE * inf; FILE * outf; int ch; if (argc'} > 1) $( name = argv[1]; strcpy(buf1, name); $) else $(#ifdef M6502 printf("AT2A>"); if (getn(}ame(buf1) <= 0) exit(0); name = buf1;#else printf("AT2A what?\n"); exit(0);#endif $) fn_default(nam)}e, 0, buf1); name = buf1; inf = fopen(name, "r");/* printf("open '%s'->%x\n", name, inf); */ if ((int)inf <= 0)*} $( printf("Can't open '%s' error %x\n", name, errno);#ifdef M6502 kbdchar();#endif exit(0); $) strcp+}y(buf2, buf1); p = strchr(buf2, '.'); if (!p) p = buf2 + strlen(buf2); strcpy(p, ".tmp"); outf = fopen(buf2, "w"),};/* printf("open '%s'->%x\n", buf2, outf); */ while ((ch = fgetc(inf)) != EOF) $( switch (ch) $(#ifd-}ef M6502 case '\n': /* newline ... */#ifndef weenix fputc(0x0D, outf);#endif ch = 0x0A; /* ascii li.}nefeed */ break; case '\t': /* tab ... */ ch = 0x09; /* ascii tab */ break;#else case /}0x9B: /* atascii eol ...*/ ch = '\n'; /* newline */ break; case 0x7F: /* atascii tab ...*/ 0}ch = '\t'; /* tab */ break;#endif $)/* fputc(ch, stdout); */ fputc(ch, outf); $) fclose(inf); f1}close(outf); delete(buf1); rename(buf2, buf1);$)#ifdef M6502int getname(buf)char * buf;$( int i; int ch; i =2} 0; /* str idx */ for (; ((ch = kbdchar()) != '\n') ; ) $( if (ch == '\b') $( if (i > 0) $(3} fputc('\b', stderr); i--; $) $) else $( fputc(ch, stderr); buf[i] = ch;4} i++; $) $) buf[i] = '\0'; return strlen(buf);$)#endif $( fputc(ch, stderr); buf[i] = ch;L P5LN%HehL!`ܠؠԠРH8咅h`H8h`֠ҠΠʠƠ±6}HȱhL!`e` L L!L!L!L!L!L! ȘL! L! M Hȑh`HȱhL Hȱ7}hL Hȱh ` ` %!HȥhL! %!L! `HȑhL!L!HH hhL!HH hh8}L! H*h`L!`L!HIhIi```IHIh`e` !L `` !L{! !L! !9} {!L ! !L  &L!L! 󨥂fjL! eHehL! 8H哪hL! :}HhL! EHEhL! %H%hL!`\_ łXTM łFBE 0>7ł86/ 䃐-&ł'% 0ł ;}䃐 ł`` 0ł 䃐ł۰ 0łʰ 䃐ł𹰼 L H hL<} lHh` {!L !L hh捠ilŕŔ liL=}#`L!  ! Ɣ !$ D$& $ D$& 򦓥 !`Heeh`` >} ! ! ! !Ńł &&L$FfFf3ōŌ8包卅?}FfFfͥ !ĕ !` \$L! ` `@}S L L L i?H ihL%  E)l A} S# 7   "+ B}  t! A" {! 9!%  %L&=(  )%  f( "  %% 9! %  0% 9! C} C(  g. 9! "'E( I/J/  ) /  %% %  %% .  . 9! u ! D}!% %  5% A" 9! _(  %% d(  g. 9!  / 9! "S u L'   . E} 9!L' 9!L'L' #''   .L'  A.  A.%  /% %  )0  LY#AT2A>rCaF}n't open '%s' error %x.tmpw S# a  9! / 9! "L)L(Lu( ~ "9 "(~ G/H/  G}. u #  9! #L) G/H/  .  u A"  u `! u #  9! #L(  u A" `!  5% # LH}Y# S# C)D)  3 C)D)  :&LY# S# a    t! A" {! t! A"  t! P" 9! u # u  9! I} * # LY# S# M E/F/    t! A" {! t! A"  t! P"  *  LY# S## 7  9!% u # % 9! # {! 9!J} u !L4. u #% "3 u #  9! # #)  . u  9!L:*L* u  9! u #% "0 u #  9K}! # #)  . u  9!L:* u #- " 9! u  9!L + 9! u #0 " 0 9!L2+  9! L}u # 3B u #  9! #  U1 9! u # 3 u  9!La+L+ 9! u #. "< u  9!  U1M} 9! u # 3 u  9!L+L+ 9!% u # % 9! # {!! 9!  9! u #  9! # # l4L, # u N} `!  A" `!L-! u  9!L-!   3L-!    2L-!    2L-!  O}  2L-!    2L- u #  LY#L- #%,cK,sX,dj,b,o,u,xL,  5% 9! u   u "P} !  u  9!  u "  u P" 9!Lg- 9! u ! !7 u #  9! # ! )  . u  Q}9!Lt- u #  9! # !0 u #  9! # #)  . u  9!L- u 7 u #  9! # ! )  .R} u  9!L-L:* u #  LY# A# 3 #Ld. u LY# E# M   u # `/ 9! " u I/J/ S} LY# u  LY# HHIDE Bh VL/` `Œ eL!L. /`%H$H` T}HIDEB VL/``@ iɀ` K/0krwa dKJU}KHI)a0{8 驛DEB VL/``I/J/` S#P 7 R   0 '0  3V}  _3P  LY# S#R 7 V   0 0  3T :  . 9! u 9!L0T u 9!   W}3 0  3  03R  LY#, S#P 7 V :  . !2 R1  % X  3R   %L1R X}X  %T u !%R .  . !R V  3P  LY#D: A# a  u # 5 u  9!L[1 9! u !L1Y} 9! u  9!L1 #1-1+ 9! u # 3=  u #  u #  9! # ! A" 0 P" 9!L1 Z} u # # LY# I# a  u  9!  " 9!  " 9!  "  " 9! u %  !  u[} A" `! u # " u #0 A" `!L2 u #7 A" `! u  9!  u \$ 9! !L92 `! \} z4 # LY# E#  5% A"  %LY# K//3 /3DE BJK VL/` K/^3 ^3DE!BJK ]}VL/` B V0`` Ԇ !Ԇթ- ؠ0L3)ȑ` 0:`` ^} NHɛD `4ȥi揠 `4Hhɛ`!8`` A[i ` A_}# a   5% A"  P" 9!  u "O u ! 9! u #  9! #  u ! `! u #  9! #  u ``}!L4 # LY# A# ": "" " #LY# `! u #  9! #  u `^x cc65 -O %1.Cx a:ra65 %1.M65DEL %1.M65x a:link65 -o %1.com runtime.obj %1.obj c.olbDEL %1.OBJu #  9! #  u ` c CC65 ---- This is the (c) copyright notice for RA65, LINK65, LIBR65, and other Atari 8-bit programs. Said programs a%c}re Copyright 1989, by John R. Dunning. All rights reserved, with the following exceptions: Anyone may copy or redistrib%d}ute these programs, provided that: 1: You don't charge anything for the copy. It is permissable to charge a no%e}minal fee for media, etc. 2: All source code and documentation for the programs is made available as part o%f}f the distribution. 3: This copyright notice is preserved verbatim, and included in the distribution. You%g} are allowed to modify these programs, and redistribute the modified versions, provided that the modifications are clearly%q}BXGEN C B0XPSEUDO C BA2AT ASCBA2AT C B,A2AT COMBAT2A ASCB#AT2A C B,5AT2A COMBaCOMPILE BATB bCOPYLEFTDOCBuREADME DOCBSANITIZEASCBSANITIZEC B-SANITIZECOMBUNSAN ASCBUNSAN C B-UNSAN COM noted. There is NO WARRANTY with this software, it comes as is, and is distributed in the hope that it may be useful.%r} This copyright notice is based on the one published by the Free Software Foundation, sometimes known as the GNU project.%s} The idea is the same as theirs, ie the software is free, and is intended to stay that way. Everybody has the right to c%t}opy, modify, and redistribute this software. Nobody has the right to prevent anyone else from copying, modifying or redis&%}-*- Mode: Text -*-This is the README for UTILS.ARC,which is part of the CC65 distrib-ution.UTILS.ARC contains a bunch o)v}f randomutility programs. Currently theseare all things to aid in convertingtext files and C source programsto and from )w}Atari formats. Theseprograms are:AT2A Converts a file from Atascii to AsciiA2AT C)x}onverts a file from Ascii to AtasciiSANITIZE Convert tabs and C-style braces to )y} spaces and $( $)UNSAN Convert $( $) to C- style braces.COMPILE.BAT A Spartados)z} command file, suitable for compiling any of these programs.All these progr){}ams are written in C,and source is included. All arecovered by COPYLEFT.JRD; ie they'refree, and are freely distributable)|},and may not be sold. To aid in get-ting things set up, both ascii andatascii versions of the source areincluded. The .)}}C versions are atascii, the .ASC ones are ascii.All these programs can run eitheras a command, from DOS XL or Sparta-Dos)~}, or as an ordinary load file,under DOS 2.5 or similar DOS'es.Using a command line: (this exampleuses SpartaDos, but it )}should workthe same in DOS XL)At the prompt, simply type:AT2A is the file to convert. That's it!All t)}he programs work the same way;AT2A is just an example.Using these programs from DOS'esthat don't hack command lines:Ty)}pe 'L' at your command menu. Whenthe program loads, it will prompt,as AT2A>type in the name of the file to convert, a)}nd hit return. That's it! oads, it will prompt,as AT2A>type in the name of the file to convert, a(0/* SANITIZE.C flush tabs and convert ascii braces to two { }. Aids conversion of C code from ascii to -}atascii. This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description of your rights -}and responsibilities about copying it. Give this program and its source away! Help create more free softwa-}re! */ #include #ifndef M6502 #include #define delete unlink #endif char buf1[80]; char buf2[-}80]; main(argc, argv) int argc; char ** argv; { char * name; char * p; FILE * inf; FILE * outf; int ch; -} if (argc > 1) { name = argv[1]; strcpy(buf1, name); } else { #ifdef M6502 printf("SAN-}ITIZE>"); if (getname(buf1) <= 0) exit(0); name = buf1; #else printf("Sanitize what?\n"); exit(0)-}; #endif } fn_default(name, 0, buf1); name = buf1; inf = fopen(name, "r"); /* printf("open '%s'->%x\n", name-}, inf); */ if ((int)inf <= 0) { printf("Can't open '%s' error %x\n", name, errno); #ifdef M6502 kbdchar()-}; #endif exit(0); } strcpy(buf2, buf1); p = strchr(buf2, '.'); if (!p) p = buf2 + strlen(buf2); s-}trcpy(p, ".tmp"); outf = fopen(buf2, "w"); /* printf("open '%s'->%x\n", buf2, outf); */ while ((ch = fgetc(inf-})) != EOF) { switch (ch) { case 0x7B: fputc('$', outf); fputc('(', outf); -}break; case 0x7D: fputc('$', outf); fputc(')', outf); break; case '\t': fpu-}tc(' ', outf); fputc(' ', outf); break; default: fputc(ch, outf); } } fclose(-}inf); fclose(outf); delete(buf1); rename(buf2, buf1); } #ifdef M6502 int getname(buf) char * buf; { int i; -} int ch; i = 0; /* str idx */ for (; ((ch = kbdchar()) != '\n') ; ) { if (ch == '\b') { if-} (i > 0) { fputc('\b', stderr); i--; } } else { fputc(ch, stde-}rr); buf[i] = ch; i++; } } buf[i] = '\0'; return strlen(buf); } #endif fputc(ch, stde,j/* SANITIZE.C flush tabs and convert ascii braces to two $( $). Aids conversion of C code from ascii to atas1}cii. This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description of your rights and respo1}nsibilities about copying it. Give this program and its source away! Help create more free software!*/#inclu1}de #ifndef M6502#include #define delete unlink#endifchar buf1[80];char buf2[80];main(argc, argv)i1}nt argc;char ** argv;$( char * name; char * p; FILE * inf; FILE * outf; int ch; if (argc > 1) $( name 1}= argv[1]; strcpy(buf1, name); $) else $(#ifdef M6502 printf("SANITIZE>"); if (getname(buf1) <= 0) 1} exit(0); name = buf1;#else printf("Sanitize what?\n"); exit(0);#endif $) fn_default(name, 0, buf1); 1} name = buf1; inf = fopen(name, "r");/* printf("open '%s'->%x\n", name, inf); */ if ((int)inf <= 0) $( printf(1}"Can't open '%s' error %x\n", name, errno);#ifdef M6502 kbdchar();#endif exit(0); $) strcpy(buf2, buf1); p 1}= strchr(buf2, '.'); if (!p) p = buf2 + strlen(buf2); strcpy(p, ".tmp"); outf = fopen(buf2, "w");/* printf("open 1}'%s'->%x\n", buf2, outf); */ while ((ch = fgetc(inf)) != EOF) $( switch (ch) $( case 0x7B: 1} fputc('$', outf); fputc('(', outf); break; case 0x7D: fputc('$', outf); fputc(')', ou1}tf); break; case '\t': fputc(' ', outf); fputc(' ', outf); break; default: 1} fputc(ch, outf); $) $) fclose(inf); fclose(outf); delete(buf1); rename(buf2, buf1);$)#ifdef M6502int getn1}ame(buf)char * buf;$( int i; int ch; i = 0; /* str idx */ for (; ((ch = kbdchar()) != '\n') ; ) $( if (1}ch == '\b') $( if (i > 0) $( fputc('\b', stderr); i--; $) $) else 1} $( fputc(ch, stderr); buf[i] = ch; i++; $) $) buf[i] = '\0'; return strlen(buf);$)#endif0} 5LN%HehL!`ܠؠԠРH8咅h`H8h`֠ҠΠʠƠ±5}HȱhL!`e` L L!L!L!L!L!L! ȘL! L! M Hȑh`HȱhL Hȱ5}hL Hȱh ` ` %!HȥhL! %!L! `HȑhL!L!HH hhL!HH hh5}L! H*h`L!`L!HIhIi```IHIh`e` !L `` !L{! !L! !5} {!L ! !L  &L!L! 󨥂fjL! eHehL! 8H哪hL! 5}HhL! EHEhL! %H%hL!`\_ łXTM łFBE 0>7ł86/ 䃐-&ł'% 0ł 5}䃐 ł`` 0ł 䃐ł۰ 0łʰ 䃐ł𹰼 L H hL5} lHh` {!L !L hh捠ilŕŔ liL5}#`L!  ! Ɣ !$ D$& $ D$& 򦓥 !`Heeh`` 5} ! ! ! !Ńł &&L$FfFf3ōŌ8包卅5}FfFfͥ !ĕ !` \$L! ` `5}S L L L i?H ihL%  )l 5} S# 7   "+ 5}  t! A" {! 9!%  %L&(  *%  ( "  %% 9! %  1% 9! 5} (  . 9! "'( //  * \/  %% %  %% .  // 9! u ! 5}!% %  5% A" 9! (  %% (  . 9!  m/ 9! "LR( u L;($   5}/(   /LO($   /)   /LO(   /   /LO(   /LO( #'{'}5}(L)(L'  .  .%  >0% %  }0  LY#SANITIZE>rCan't open '%s' error %x.tmpw S# a 5} 9! \/ 9! "Lp)L(L( ~ "9 "(~ //  / u #  9! #Lm) //  5}/  u A"  u `! u #  9! #L(  u A" `!  5% # LY# S# ))  G4 ))  5}:&LY# S# a    t! A" {! t! A"  t! P" 9! u # u  9!  b* # LY# S# M //    t!5} A" {! t! A"  t! P"  b*  LY# S## 7  9!% u # % 9! # {! 9! u !L. u #% "3 u # 5} 9! # #)  / u  9!L*L* u  9! u #% "0 u #  9! # #)  / u  9!L* u #5}- " 9! u  9!L`+ 9! u #0 " 0 9!L+  9! u # 74B u #  9! #  15} 9! u # 74 u  9!L+L+ 9! u #. "< u  9!  1 9! u # 74 u  9!L ,L6,5} 9!% u # % 9! # {!! 9!  9! u #  9! # # 4L2- # u `!  A" `!LV-! u  9!LV-5}!   3LV-!    l2LV-!    l2LV-!   l2LV-!    l2LV- u #5}  LY#LV- #y,c,s,d,b,o,u -xL"-  5% 9! u   u " !  u  9!  u "  u5} P" 9!L- 9! u ! !7 u #  9! # ! )  / u  9!L- u #  9! # !0 u # 5} 9! # #)  / u  9!L- u 7 u #  9! # ! )  / u  9!LN.L* u #  LY# A# 35} #L. u LY# E# M   u # / 9! " u //  LY# u  LY# HHIDE5} Bh VL40` `Œ eL!L=/ d/`%H$H` HIDEB VL40``5}@ iɀ` /0krwa dKJKHI)a0{8 驛5}DEB VL40``//` S#P 7 R   1 {0  b3  3P  LY# S#R 7 V  5} 1 1  b3T :  // 9! u 9!L0T u 9!   b3 1  b3  3R  LY#, 5}S#P 7 V :  // !2 1  % X  b3R   %Lo1R X  %T u !%R .  // !5}R V  b3P  LY#D: A# a  u # W5 u  9!L1 9! u !L1 9! u  9!L2 #1-1+5} 9! u # 74=  u #  u #  9! # ! A" 0 P" 9!L2  u # # LY# I# a  u  9!  "5} 9!  " 9!  "  " 9! u %  !  u A" `! u # " u #0 A5}" `!L!3 u #7 A" `! u  9!  u \$ 9! !L2 `! 4 # LY# E#  5% A"  %LY5}# /3 3DE BJK VL40` /3 3DE!BJK VL40` B V0`` 5} Ԇ !Ԇթ- ؠ0L#4)ȑ` 0:`` NHɛD 45}ȥi揠 4Hhɛ`!8`` A[i ` A# a   5% A"  P" 9! 5} u "O u ! 9! u #  9! #  u ! `! u #  9! #  u `!L4 # LY# A# ": ""5} " #LY# `! u #  9! #  u `!L4 # LY# A# ": ""45/* UNSANITIZE.C Opposite of sanitize. turn { } to c-style braces. Aids conversion of C code from atascii 9} to ascii. This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description of your rig9}hts and responsibilities about copying it. Give this program and its source away! Help create more free so9}ftware! */ #include #ifndef M6502 #include #define delete unlink #endif char buf1[80]; char b9}uf2[80]; main(argc, argv) int argc; char ** argv; { char * name; char * p; FILE * inf; FILE * outf; int 9}ch, other_ch; if (argc > 1) { name = argv[1]; strcpy(buf1, name); } else { #ifdef M6502 9} printf("UNSANITIZE>"); if (getname(buf1) <= 0) exit(0); name = buf1; #else printf("Unsanitize what?9}\n"); exit(0); #endif } fn_default(name, 0, buf1); name = buf1; inf = fopen(name, "r"); /* printf("open9} '%s'->%x\n", name, inf); */ if ((int)inf <= 0) { printf("Can't open '%s' error %x\n", name, errno); #ifdef M69}502 kbdchar(); #endif exit(0); } strcpy(buf2, buf1); p = strchr(buf2, '.'); if (!p) p = buf2 + 9}strlen(buf2); strcpy(p, ".tmp"); outf = fopen(buf2, "w"); /* printf("open '%s'->%x\n", buf2, outf); */ whil9}e ((ch = fgetc(inf)) != EOF) { switch (ch) { case '$': other_ch = fgetc(inf); switc9}h(other_ch) { case '(': other_ch = 0x7B; break; case ')': 9} other_ch = 0x7D; break; default: fputc(ch, outf); } fputc(other9}_ch, outf); break; default: fputc(ch, outf); } } fclose(inf); fclose(outf); delete9}(buf1); rename(buf2, buf1); } #ifdef M6502 int getname(buf) char * buf; { int i; int ch; i = 0; /* str9} idx */ for (; ((ch = kbdchar()) != '\n') ; ) { if (ch == '\b') { if (i > 0) { f9}putc('\b', stderr); i--; } } else { fputc(ch, stderr); buf[i] = ch; 9} i++; } } buf[i] = '\0'; return strlen(buf); } #endif fputc(ch, stderr); buf[i] = ch; 8L/* UNSANITIZE.C Opposite of sanitize. turn $( $) to c-style braces. Aids conversion of C code from atascii t=}o ascii. This program is copyleft 1989 by JRD. See COPYLEFT.JRD for a detailed description of your rights and r=}esponsibilities about copying it. Give this program and its source away! Help create more free software!*/#i=}nclude #ifndef M6502#include #define delete unlink#endifchar buf1[80];char buf2[80];main(argc, arg=}v)int argc;char ** argv;$( char * name; char * p; FILE * inf; FILE * outf; int ch, other_ch; if (argc > 1) =} $( name = argv[1]; strcpy(buf1, name); $) else $(#ifdef M6502 printf("UNSANITIZE>"); if (getnam=}e(buf1) <= 0) exit(0); name = buf1;#else printf("Unsanitize what?\n"); exit(0);#endif $) fn_default=}(name, 0, buf1); name = buf1; inf = fopen(name, "r");/* printf("open '%s'->%x\n", name, inf); */ if ((int)inf <= 0)=} $( printf("Can't open '%s' error %x\n", name, errno);#ifdef M6502 kbdchar();#endif exit(0); $) strcpy=}(buf2, buf1); p = strchr(buf2, '.'); if (!p) p = buf2 + strlen(buf2); strcpy(p, ".tmp"); outf = fopen(buf2, "w");=}/* printf("open '%s'->%x\n", buf2, outf); */ while ((ch = fgetc(inf)) != EOF) $( switch (ch) $( =} case '$': other_ch = fgetc(inf); switch(other_ch) $( case '(': other_ch = 0x=}7B; break; case ')': other_ch = 0x7D; break; default: fpu=}tc(ch, outf); $) fputc(other_ch, outf); break; default: fputc(ch, outf); $) =} $) fclose(inf); fclose(outf); delete(buf1); rename(buf2, buf1);$)#ifdef M6502int getname(buf)char * buf;$( int i=}; int ch; i = 0; /* str idx */ for (; ((ch = kbdchar()) != '\n') ; ) $( if (ch == '\b') $( if (=}i > 0) $( fputc('\b', stderr); i--; $) $) else $( fputc(ch, stderr); =} buf[i] = ch; i++; $) $) buf[i] = '\0'; return strlen(buf);$)#endif $( fputc(ch, stderr); <^ 5LN%HehL!`ܠؠԠРH8咅h`H8h`֠ҠΠʠƠ±A}HȱhL!`e` L L!L!L!L!L!L! ȘL! L! M Hȑh`HȱhL HȱA}hL Hȱh ` ` %!HȥhL! %!L! `HȑhL!L!HH hhL!HH hhA}L! H*h`L!`L!HIhIi```IHIh`e` !L `` !L{! !L! !A} {!L ! !L  &L!L! 󨥂fjL! eHehL! 8H哪hL! A}HhL! EHEhL! %H%hL!`\_ łXTM łFBE 0>7ł86/ 䃐-&ł'% 0ł A}䃐 ł`` 0ł 䃐ł۰ 0łʰ 䃐ł𹰼 L H hLA} lHh` {!L !L hh捠ilŕŔ liLB}#`L!  ! Ɣ !$ D$& $ D$& 򦓥 !`Heeh`` B} ! ! ! !Ńł &&L$FfFf3ōŌ8包卅B}FfFfͥ !ĕ !` \$L! ` `B}S L L L i?H ihL%  )l B} S# 7   "+ B}  t! A" {! 9!%  %L&y(  *%  ( "  %% 9! %  0% 9! B} (  . 9! "'( //  * J/  %% %  %% .  / 9! u ! B}!% %  5% A" 9! (  %% (  . 9!  [/ 9! "L>( u L/(  [/ 9!B} u L'{ 9!L (} 9!L (   .L ( #'(')L'   .L;(   .L;( #'$L(L'  B }.  .%  ,0% %  k0  LY#UNSANITIZE>rCan't open '%s' error %x.tmpw S# a  9! J/ 9! B } "L^)L(L( ~ "9 "(~ //  . u #  9! #L[) //  .  u A" B } u `! u #  9! #L(  u A" `!  5% # LY# S# ))  54 ))  :&LY# S# a  B }  t! A" {! t! A"  t! P" 9! u # u  9!  P* # LY# S# M //    t! A" {! t! A" B } t! P"  P*  LY# S## 7  9!% u # % 9! # {! 9! u !Lv. u #% "3 u #  9! # #)  B}. u  9!L|*L* u  9! u #% "0 u #  9! # #)  . u  9!L|* u #- " 9!B} u  9!LN+ 9! u #0 " 0 9!Lt+  9! u # %4B u #  9! #  1 9! u # %4B} u  9!L+L+ 9! u #. "< u  9!  1 9! u # %4 u  9!L+L$, 9!% u # B}% 9! # {!! 9!  9! u #  9! # # 4L - # u `!  A" `!LD-! u  9!LD-!   3LD-B}!    Z2LD-!    Z2LD-!   Z2LD-!    Z2LD- u #  LY#LD- #g,c,B}s,d,b,o,u,xL-  5% 9! u   u " !  u  9!  u "  u P" 9!L-B} 9! u ! !7 u #  9! # ! )  . u  9!L- u #  9! # !0 u #  9! # #)  B}. u  9!L- u 7 u #  9! # ! )  . u  9!L<.L|* u #  LY# A# 3 #LB}. u LY# E# M   u # / 9! " u //  LY# u  LY# HHIDE Bh VL"0`B} `Œ eL!L+/ R/`%H$H` HIDEB VL"0``@ iB}ɀ` /0krwa dKJKHI)a0{8 驛DEB VB}L"0``//` S#P 7 R   0 i0  P3  3P  LY# S#R 7 V   0 0  B}P3T :  / 9! u 9!L0T u 9!   P3 0  P3  r3R  LY#, S#P 7 V : B}  / !2 1  % X  P3R   %L]1R X  %T u !%R .  / !R V  P3PB}  LY#D: A# a  u # E5 u  9!L1 9! u !L1 9! u  9!L1 #1-1+ 9! u # %4=B}  u #  u #  9! # ! A" 0 P" 9!L1  u # # LY# I# a  u  9!  " 9!  "B} 9!  "  " 9! u %  !  u A" `! u # " u #0 A" `!L3 u #B}7 A" `! u  9!  u \$ 9! !L{2 `! 4 # LY# E#  5% A"  %LY# /q3 q3DB }E BJK VL"0` /3 3DE!BJK VL"0` B V0`` Ԇ !Ԇթ-B!} ؠ0L4)ȑ` 0:`` NHɛD 4ȥiB"}揠 4Hhɛ`!8`` A[i ` A# a   5% A"  P" 9!  u "O u !B#} 9! u #  9! #  u ! `! u #  9! #  u `!L4 # LY# A# ": "" " B$} #LY# `! u #  9! #  u `!L4 # LY# A# ": "" " @#tributing it.d redistribute this software. Nobody has the right to prevent anyone else from copying, modifying or redis$