/******************************************************** * Program to make ascii file into .com file via * * an assembly language output. Use by typing note * * followed by the ascii input file then >outfile * * (use .asm as a filetype, natch), then assemble with * * asm.com and load to a .com file and you have an easy * * way to generate messages with only a small amount of * * overhead. i.e. error messages on rbbs/rcpm systems * * for non-used commands--user under zcpr2 for example. * * Freely stole txt23.asm for assembly lang. output * * Written by Tom Burnett 05/01/84 ver 2.0 * ********************************************************/ #define CPMEOF 26 #include "qstdio.h" main(argc,argv) int argc; char *argv[]; { int fd1; int c; int count; int maxcount; fprintf(stderr,"\nNOTE Ver 2.0 makes .com file\n"); fprintf(stderr,"out of ascii text source. Tom Burnett 05/01/84\n"); fprintf(stderr,"Written for Q/C compiler 3.2\n"); fprintf(stderr,"Based on TXT23.ASM\n\n\n"); if (argc < 2) { fprintf(stderr,"Usage: A>NOTE INFILE [ >OUTFILE ] \n"); fprintf(stderr,"Make outfile use .asm as filetype\n"); fprintf(stderr,"Then assemble with asm.com and load\n"); exit(1); } fd1 = fopen(argv[1],"rb"); /* note--"rb" is the binary read funcion of qc and it insures no cr/lf * * tampering is done. It may be neccesary to change with different * * C compilers to get all chars of file. To paraphrase Chuck Forsberg * * This cr/lf stuff is a pain..... -T.B. */ if (fd1 == NULL) { fprintf(stderr,"Open failure on input --> %s <--\n",argv[1]); exit(1); } fprintf(stderr,"\nworking.....\n"); prmsg1(); prmsg2(); prmsg3(); maxcount = 10; count = 0; printf("\tdb\t"); while (((c = getc(fd1)) != EOF) && c != CPMEOF) { printf("%d",c); count++; if (count > maxcount) { printf("\n\tdb\t"); count = 0; } else printf(","); } printf("0\nEND\n%c",CPMEOF); exit(0); } prmsg1() { printf(";program generated by note 2.0 by Tom Burnett\n"); printf(";Bob Schultz contributed this change to txt.asm because of the fact\n"); printf(";that bdos handles the ^S in a strange way: if the first character\n"); printf(";entered is not a ^S then it ignore the first and subsequent valid\n"); printf(";^S entries.\n"); printf(";\n"); printf(";--------------------------\n"); printf(" ;\n"); printf("BDOS EQU 5 ;system call entry point\n"); printf("BELL EQU 7 ;a bell if you whant one\n"); printf("CONDIR EQU 6 ;direct console I/O\n"); printf("CR EQU 13 ;carriage return\n"); printf("LF EQU 10 ;line feed\n"); printf(" ;\n"); printf(";--------------------------------------\n"); printf("; ---- START OF PGM ----\n"); printf(";\n"); } prmsg2() { printf(" ORG 100H ;\n"); printf(";\n"); printf("START: LXI H,BUFFER ;point to text\n"); printf("LOOP: PUSH H ;save pointer\n"); printf(" MOV A,M ;get character\n"); printf(" CPI 0 ;at end?\n"); printf(" JZ EXIT ;yes, so quit\n"); printf(" MOV E,A ;move character to e\n"); printf(" MVI C,CONDIR ;console out\n"); printf(" CALL BDOS ;bdos\n"); printf(" CALL CONIN ;check for key pressed\n"); printf(" JZ LOOP2 ;if no key then continue\n"); printf(" CPI 'S'-40H ;is it ^S?\n"); printf(" JNZ CHECKC ; if not check ^C\n"); printf("LOOP1: CALL CONIN ;check for key pressed\n"); printf(" JZ LOOP1 ;loop until key pressed\n"); printf("CHECKC: CPI 'C'-40H ;is it ^C?\n"); printf(" JZ EXIT ; if so exit\n"); printf("LOOP2: POP H ;get pointer\n"); printf(" INX H ;and bump to next char\n"); printf(" JMP LOOP ;go on doing it\n"); printf(" ;\n"); } prmsg3() { printf("EXIT: POP H ;clean up the stack\n"); printf(" RET ;return to CCP\n"); printf(";\n"); printf("CONIN: MVI E,0FFH ;direct input\n"); printf(" MVI C,CONDIR\n"); printf(" CALL BDOS\n"); printf(" ORA A ;set flags\n"); printf(" RET\n"); printf(";\n"); printf(" DB '?',CR,LF ;start of buffer marker\n"); printf(";-----------------------------------\n"); printf("; Message space starts here, and is as large as your TPA -512 bytes\n"); printf(";-----------------------------------\n"); printf("BUFFER:\n"); }