From e0d1c62907032ba74b533762d9dcc5cd591cc840 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 7 Mar 2025 17:33:14 -0500 Subject: listamsb: tweak -D option some more. --- listamsb.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/listamsb.c b/listamsb.c index a9f6505..bd92aa0 100644 --- a/listamsb.c +++ b/listamsb.c @@ -480,8 +480,13 @@ void unlock_program(void) { exit(0); } -void write_code(int ptr, int lineno, const char *code) { - /* TODO */ +void write_code(int addr, int lineno, const unsigned char *code) { + fputc(addr & 0xff, outfile); + fputc((addr >> 8) & 0xff, outfile); + fputc(lineno & 0xff, outfile); + fputc((lineno >> 8) & 0xff, outfile); + fputs((char *)code, outfile); + fputc(0x00, outfile); } int crunch_line(void) { @@ -538,12 +543,7 @@ int crunch_line(void) { codelen += 4; /* account for ptr and lineno */ addr += codelen; - fputc(addr & 0xff, outfile); - fputc((addr >> 8) & 0xff, outfile); - fputc(lineno & 0xff, outfile); - fputc((lineno >> 8) & 0xff, outfile); - fputs((char *)code, outfile); - fputc(0x00, outfile); + write_code(addr, lineno, code); return codelen; } @@ -588,7 +588,8 @@ int need_space_between(unsigned char t1, unsigned char t2) { a keyword, but put it in for neatness. examples: OPEN #1,"D:X" INPUT IF A$="FOO" THEN 10 - these look weird with the space before INPUT or THEN. */ + PRINT "YOUR IQ IS" IQ + these look weird without the space after the " */ if(t1last == '|' && isalnum(t2first)) return 1; return(isalnum(t1last) && isalnum(t2first)); @@ -641,12 +642,7 @@ int decrunch_line(void) { codelen += 4; /* account for ptr and lineno */ addr += codelen; - fputc(addr & 0xff, outfile); - fputc((addr >> 8) & 0xff, outfile); - fputc(lineno & 0xff, outfile); - fputc((lineno >> 8) & 0xff, outfile); - fputs((char *)code, outfile); - fputc(0x00, outfile); + write_code(addr, lineno, code); return codelen; } -- cgit v1.2.3