Mercurial > hg > Members > kono > nitros9-code
changeset 2474:7d70b7e1cb21
Moved net and alib files into here
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/alib.docs Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,1013 @@ +.s="",ss=0,p="",n="",sn=80, * normal (pica) characters, 80 per 8 inch line +.lm=5, rm=75, tm=5, bm=60 +.lh=5,rh=75,p="" +.he0="Assembler Library Documentation", he1="Page ##" +.he2="String Handlers" +.hf0=r,hf1=l,hf2=r +.hl0=2,hl1=2,hl2=3 +.lf=c +.tf=_ +===================== +== String Handlers == +===================== +.lf=l + + +.nl=7 +\t66\ + +STIMESTR: Get current system time as an ascii string. + +OTHER MODULES NEEDED: DATESTR + +ENTRY: X=buffer for ascii + +EXIT: all registers preserved (except cc) + + +.nl=7 +\t66\ + +DATESTR: Convert a date to a string. This can be used + for converting the system time as well as + modify/create dates from files. The date must + be 6 bytes -- null pad file dates. + +OTHER MODULES NEEDED: BIN_ASC + +ENTRY: X=binary date + Y=buffer for ascii + +EXIT: all registers preserved (except cc) + + +.nl=7 +\t66\ + +TO_NON_SP: Advance X to 1st non-space character + +OTHER MODULES NEEDED: none + +ENTRY: X=somewhere in a string + +EXIT: X=1st non-space character in string + B=char at X + + +.nl=7 +\t66\ + +PRINT_DEC: Print decimal number to standard out. + +ENTRY: D=value to print + +EXIT: CC carry set if error (from I$WritLn) + B error code, if any + + +.nl=7 +\t66\ + +PRINT_HEX: Print hex number to standard out. + +ENTRY: D=value to print + +EXIT: CC carry set if error (from I$WritLn) + B error code, if any + + +.nl=7 +\t66\ + +PRINT_ASC: Print binary number to standard out. + +ENTRY: D=value to print + +EXIT: CC carry set if error (from I$WritLn) + B error code, if any + + +.nl=7 +\t66\ + +STRCMP: compare two null terminated strings. + +NOTE: This routine first finds the length of both + strings and passes the length of the longer + one to strncmp. + +OTHER MODULES NEEDED: STRNCMP, STRLEN + +ENTRY: X=start of 1st string + Y=start of 2nd string + +EXIT: CC zero set if equal (beq) + carry + zero clear if 1>2 (bhi) + carry set if 1<2 (blo) + + +.nl=7 +\t66\ + +STRNCMP: compare 2 null terminated strings + maximum number of bytes to compare in D + +OTHER MODULES NEEDED: COMPARE + +ENTRY: X=start of 1st string + Y=start of 2nd string + D=number of bytes to compare + CASEMTCH:(a global variable in COMPARE) + 0=match for case + -1=ignore case differences + +EXIT: CC zero set if equal (beq) + carry + zero clear if 1>2 (bhi) + carry set if 1<2 (blo) + + +.nl=7 +\t66\ + +STRLEN: String Length: find length of null terminated string. + note:null NOT included in count. + +ENTRY: X=start of string + +EXIT: D=length + all other regs (except cc) preserved + + +.nl=7 +\t66\ + +STRHLEN: find length of sign-bit terminated string. + note: sign-bit set byte IS included in count. + +OTHER MODULES NEEDED: none + +ENTRY: X=start of string + +EXIT: D=length + all other regs (except cc) preserved + + +.nl=7 +\t66\ + +B09STRLEN: Find the length of a BASIC09 string. + +OTHER MODULES NEEDED: none + +ENTRY: X=start of string + D=max possible length (size passed to subroutine) + +EXIT: D=actual length (either at $FF or max size) + all other regs (except cc) preserved + +.nl=7 +\t66\ + +STRCAT: append 2 null terminated strings + User must ensure there is room in buffer!!! + +OTHER MODULES NEEDED: STRCPY, STRLEN + +ENTRY: X=start of string to move + Y=start of string to append to + +EXIT: all regs preserved (except cc) + + +.nl=7 +\t66\ + +STRNCPY: copy N bytes of a null terminated string + User must ensure there is room in buffer!!! + If N>string length only N bytes will be moved + +OTHER MODULES NEEDED: STRLEN, MEMMOVE + +ENTRY: X=start of string to move + Y=buffer for copy of string + +EXIT: D = actual number of bytes moved + all other regs preserved (except cc) + + +.nl=7 +\t66\ + +STRCPY: copy a null terminated string + User must ensure there is room in buffer!!! + +OTHER MODULES NEEDED: STRNCPY + +ENTRY: X=start of string to move + Y=buffer for copy of string + +EXIT: all regs preserved (except cc) + +.nl=7 +\t66\ + +STRNCPY: copy N bytes of a null terminated string + User must ensure there is room in buffer!!! + If N>string length only N bytes will be moved + +OTHER MODULES NEEDED: STRLEN, MEMMOVE + +ENTRY: X=start of string to move + Y=buffer for copy of string + +EXIT: D = actual number of bytes moved + all other regs preserved (except cc) + + +.nl=7 +\t66\ + +STRHCPY: copy sign-bit terminated string + User must ensure there is room in buffer!!! + See also PARSNSTR, this routine does not change + sign-bit termination. + +OTHER MODULES NEEDED: strhlen,memmove + +ENTRY: X=start of string to move + Y=buffer for copy of string + + +.nl=7 +\t66\ + +TO_UPPRS: convert a null terminated string to all uppercase + +OTHER MODULES NEEDED: TO_UPPER + +ENTRY: X=start of string + +EXIT: all registers (except CC) preserved + + +.nl=7 +\t66\ + +TO_UPPER: Convert character in "B" to uppercase + +OTHER MODULES NEEDED: IS_LOWER + +ENTRY: B=ascii value of character to convert + +EXIT: B=ascii value of character in uppercase + +Note: control codes, etc. are not effected. + + +.nl=7 +\t66\ + +TO_LOWRS: convert a null terminated string to all lowercase + +OTHER MODULES NEEDED: TO_LOWER + +ENTRY: X=start of string + +EXIT: all registers (except CC) preserved + + +.nl=7 +\t66\ + +TO_LOWER: Convert character in "B" to lowercase + +OTHER MODULES NEEDED: IS_UPPER + +ENTRY: B=ascii value of character to convert + +EXIT: B=ascii value of character in lowercase + +Note: control codes, etc. are not effected. + + +.nl=7 +\t66\ + +PARSNSTR: Parse sign bit terminated string to convert it to a + null terminated string. Note: if X and Y are the same + the existing string will be overwritten -- don't do this + with psects... + +OTHER MODULES NEEDED: none + +ENTRY: X=start of sign bit terminated string + Y=buffer for null terminated string + +EXIT: D=string size (not including null) + All other regs (except cc) preserved + + +.lf=c, he2="I/O Routines",pg +================== +== I/O Routines == +================== +.lf=l + +.nl=7 +\t66\ + +PRINTS: Print a program embedded, null terminated string to std out. + +OTHER MODULES NEEDED: puts + +ENTRY: Null terminated string must follow PRINTS call + eg: LBSR PRINTS + fcc /this is a string to print/ + fcb $0d + fcc /a second string/ + fcb $0d,0 + lbsr morestuff... + +EXIT: CC carry set if error + B error code (if any) + +.nl=7 +\t66\ + +PUTS: Print a null terminated string to standard out. + +OTHER MODULES NEEDED: fputs + +ENTRY: X=string to print + +EXIT: CC carry set if error + B error code (if any) + + +.nl=7 +\t66\ + +FPUTS: print null terminated string to "A". + +OTHER MODULES REQUIRED: none + +ENTRY: X=start of string + A=path + +EXIT: CC carry set if error + B = OS9 error if any (from I$WritLn) + +NOTE: string is feed through I$WritLn for editing (adding LF, etc.) + + +.nl=7 +\t66\ + +PUTCR: Subroutine to print a carriage return to std. out. + +OTHER MODULES REQUIRED: FPUTCR + +ENTRY: none + +EXIT: CC carry set if error (from I$WritLn) + B error code if any. + + +.nl=7 +\t66\ + +FPUTCR: Subroutine to print a carriage return + +OTHER MODULES REQUIRED: FPUTC + +ENTRY: A=path + +EXIT: CC carry set if error (from I$WritLn) + B error code if any. + + +.nl=7 +\t66\ + +PUTSPACE: Subroutine to print a space to std. out + +OTHER MODULES REQUIRED: FPUTSPACE + +ENTRY: none + +EXIT: CC carry set if error (from I$WritLn) + B error code if any. + + +.nl=7 +\t66\ + +FPUTSPACE: Subroutine to print a space + +OTHER MODULES REQUIRED: FPUTC + +ENTRY: A=path + +EXIT: CC carry set if error (from I$WritLn) + B error code if any. + + +.nl=7 +\t66\ + +PUTC: Put single character to standard out. + +OTHER MODULES NEEDED: FPUTC + +ENTRY: B=character to print + +EXIT: CC carry set if error + B=error code if any + + +.nl=7 +\t66\ + +FPUTC: Subroutine to print one character. + +OTHER MODULES NEEDED: none + +ENTRY: A=path + B=char to print + +EXIT: CC carry set if error (from I$WritLn) + B error code if any + + +.nl=7 +\t66\ + +GETC: Subroutine to input one character from std in. + +OTHER MODULES NEEDED: FGETC + +ENTRY: none + +EXIT: A character + CC carry set if error (from I$Read) + B error code if any + + +.nl=7 +\t66\ + +FGETC: Subroutine to input one character. + +OTHER MODULES NEEDED: none + +ENTRY: A=path + +EXIT: A character + CC carry set if error (from I$Read) + B error code if any + + +.nl=7 +\t66\ + +GETS: Subroutine to input a null terminated string from Std. In + +OTHER MODULES NEEDED: FGETS + +ENTRY: X=buffer for string + Y=max buffer size (leave room for null!!) + +EXIT: CC carry set if error (from I$ReadLn) + B error code if any + +NOTE: The string entered must end with an end-of-record char + (usually a $0D), the null is appended for ease in string + handling. + + +.nl=7 +\t66\ + +FGETS: Subroutine to input a null terminated string. + +OTHER MODULES NEEDED: none + +ENTRY: A=path + X=buffer for string + Y=max buffer size (leave room for null!!) + +EXIT: CC carry set if error (from I$ReadLn) + B error code if any + + +NOTE: The string entered must end with an end-of-record char + (usually a $0D), the null is appended for ease in string + handling. + +.nl=7 +\t66\ + +INKEY: Checks STDIN for a keypress and returns it if avail. + +ENTRY: none + +EXIT: A=character, 0=no character + B=error code (if any) + CC=carry set if error (from I$Read) + +NOTE: NULLs entered from the keyboard are returned as "no keypress". + + +.he2="Integer Math",pg,lf=c +================== +== Integer Math == +================== +.lf=l + + +.nl=7 +\t66\ + +MULT168: 16 x 8 Multiply (24 bit result) + +OTHER MODULES NEEDED: none + +ENTRY: A = multiplier + X = multiplicand + +EXIT: A = product byte 1 + X = product bytes 2 & 3 + B modified + + +.nl=7 +\t66\ + +MULT16: 16 x 16 Multiply + +ENTRY: D = multiplier + X = multiplicand + +EXIT: Y = product 2 msbs + U = " 2 lsbs + D & X preserved + + +.nl=7 +\t66\ + +DIV168: 16 x 8 bit integer divide + +Result must be an 8 bit value + +ENTRY: A = divisor + X = dividend + +EXIT: A = remainder + B = quotient + all other registers (except CC) preserved + + +.nl=7 +\t66\ + +DIV16: 16 x 16 bit integer divide + +OTHER MODULES NEEDED: none + +ENTRY: D = divisor + X = dividend + +EXIT: X = quotient + D = remainder + + +.nl=7 +\t66\ + +DIV88: 8 x 8 Divide + +OTHER MODULES NEEDED: none + +ENTRY: A = divisor + B = dividend + +EXIT: A = remainder + B = quotient + + +.he2="Number Conversions",pg,lf=c +======================== +== Number Conversions == +======================== +.lf=l + + +.nl=7 +\t66\ + +DEC_BIN: DECIMAL to BINARY conversion routine + +OTHER MODULES NEEDED: DECTAB$, IS_TERMIN + +ENTRY: X = start of asci decimal string terminated by + a space, comma, CR or null. + +EXIT: D = binary value + CC carry set if error (too large, not numeric) + Y = terminator or error char. + + +.nl=7 +\t66\ + +BIN_DEC: Binary to decimal conversion + +OTHER MODULES NEEDED: DECTAB$ + +ENTRY: X=buffer for ascii string + D=binary value to convert + +EXIT: all registers (except cc) preserved + + +.nl=7 +\t66\ + +ASC_BIN: ASCII String to binary byte conversion + +OTHER MODULES NEEDED: IS_TERMIN + +ENTRY: X = start of string of binary digits (001101) + terminated by space, comma, CR or null. + +EXIT: D = value + CC carry set if error (string too long, not binary digits) + Y = terminator or error pos. + + +.nl=7 +\t66\ + +BIN_ASC: Binary word to ASCII string conversion + +OTHER MODULES NEEDED: none + +ENTRY: D = binary value + X = buffer for 16 bit number + +EXIT: all registers (except cc) preserved + + +.nl=7 +\t66\ + +HEX_BIN: Hexadecimal string to BINARY conversion + +OTHER MODULES REQUIRED: TO_UPPER, IS_TERMIN, IS_XDIGIT + +ENTRY: X=start of a hex string terminated by a space, + comma, CR, or NULL. + +EXIT: D=binary number + CC carry set iferror (too large, non-numeric) + Y=terminator position or error char. + + +.nl=7 +\t66\ + +BIN_HEX: Binary to hexadecimal convertor + +This subroutine will convert the binary value in +'D' to a 4 digit hexadecimal ascii string. + +OTHER MODULES NEEDED: BIN2HEX + +ENTRY: D=value to convert + X=buffer for hex string-null terminated + +EXIT all registers (except CC) preserved. + + +.nl=7 +\t66\ + +HEX2BIN: Convert hex byte to 2 hex digits + +OTHER MODULES REQUIRED: none + +ENTRY: B= value to convert + +EXIT: D=2 byte hex digits + + +.nl=7 +\t66\ + +DECTAB: table of decimal numbers for use by binary/decimal conversion +routines. + + +.he2="What's IT??",pg,lf=c +================= +== What's IT?? == +================= +.lf=l + + +.nl=7 +\t66\ + +IS_PUNCT: See if character in "B" is a punctuation character + +OTHER MODULES NEEDED: IS_ALNUM, IS_CNTRL + +ENTRY: B=character to test + +EXIT: CC zero=1 if punct., 0 if not + + +.nl=7 +\t66\ + +IS_PRINT: See if character in "B" is a printable character +controls are defined as $00..$1F and $7F+ -- all others are printable + +OTHER MODULES NEEDED: IS_CNTRL + +ENTRY: B=character to test + +EXIT: CC zero=1 if printable, 0 if not + + +.nl=7 +\t66\ + +IS_CNTRL: See if character in "B" is a control character +controls are defined as $00..$1F and $7F+ + +OTHER MODULES NEEDED: none + +ENTRY: B=character to test + +EXIT: CC zero=1 if control, 0 if not + + +.nl=7 +\t66\ + +IS_SPACE: See if character in "B" is a space ($20) + +NOTE: This module is included for completeness only, + it is much more efficient to do an inline test. + +OTHER MODULES NEEDED: none + +ENTRY: B=character to test + +EXIT: CC zero=1 if space, 0 if not + + +.nl=7 +\t66\ + +IS_XDIGIT: See if character in "B" is a hexdigit 0..9, A..F or a..f + +OTHER MODULES NEEDED: IS_DIGIT + +ENTRY: B=character to test + +EXIT: CC zero=1 if hex digit, 0 if not + + +.nl=7 +\t66\ + +IS_ALNUM: See if character in "B" is a + alpha letter a..z or A..Z or digit 0..9 + +OTHER MODULES NEEDED: IS_ALPHA, IS_DIGIT + +ENTRY: B=character to test + +EXIT: CC zero=1 if alphanumeric, 0 if not + + +.nl=7 +\t66\ + +IS_ALPHA: See if character in "B" is a alpha letter a..z or A..Z + +OTHER MODULES NEEDED: IS_LOWER, IS_UPPER + +ENTRY: B=character to test + +EXIT: CC zero=1 if alpha, 0 if not + + +.nl=7 +\t66\ + +IS_DIGIT: See if character in "B" is a digit 0..9 + +OTHER MODULES NEEDED: none + +ENTRY: B=character to test + +EXIT: CC zero=1 if digit, 0 if not + + +.nl=7 +\t66\ + +IS_LOWER: See if character in "B" is a lowercase letter + +OTHER MODULES NEEDED: none + +ENTRY: B=character to test + +EXIT: CC zero=1 if lowercase, 0 if not + + +.nl=7 +\t66\ + +IS_UPPER: See if character in "B" is a uppercase letter + +OTHER MODULES NEEDED: none + +ENTRY: B=character to test + +EXIT: CC zero=1 if uppercase, 0 if not + + +.nl=7 +\t66\ + +IS_TERMIN: See if character in "B" is a valid string terminator. + +NOTE: This module is used by HEX_BIN, DEC_BIN, etc. It permits + SPACE, CR, COMMA and NULL to be used as a delimiter -- useful + for paramater and list processing.... + +OTHER MODULES NEEDED: none + +ENTRY: B=character to test + +EXIT: CC zero=1 if space, 0 if not + + +.he2="OS9 File Specific",lf=c +======================= +== OS9 File Specific == +======================= +.lf=l + + +.nl=7 +\t66\ + +GETFMD: Get the "last modified" date of an open file + +NOTE: Even though OS9 does not save seconds in its + files this routine stores a zero in this position. + This is done to make the routine compatible with + DATESTR. + +OTHER MODULES NEEDED: none + +ENTRY: X=buffer for 6 byte date + A=path of open file + +EXIT: CC carry set if error + B error code (if any) from SS.FD + + +.nl=7 +\t66\ + +MKTEMP: This subroutine creates a temorary filename +by adding a "." and a 2digit hex value based +on the process id. +IMPORTANT: there must be room after the filename +for at least 6 bytes!! Filename must be variable +area, not parameter or program sections!!! + +OTHER MODULES NEEDED: BIN_HEX + +ENTRY: X= filename + +EXIT: no registers (expect cc) modified + filename ends in ".processid",$0d + + +.he2="Miscellaneous Routines",pg,lf=c +============================ +== Miscellaneous Routines == +============================ +.lf=l + + +.nl=7 +\t66\ + +LINEDIT: Edit/input line. + +This routine does not use cursor positioning, +instead it uses backspacing, etc. This means it +can be used without a GOTOXY module, however it +is a bit slow, especially when lines get longer than +one line. If the buffer contains data, you will be +able to edit; to enter new data pass a buffer of +blanks. + +OTHER MODULES NEEDED: STRLEN,IS_PRINT, FPUTS, FPUTC, FGETC, MEMMOVE + +ENTRY: X=null terminated string to edit + A=input path (normally 0) + B=output path (normally 1) + +EXIT: CC carry set if error (GetStt, Setstt, Write, Read, etc.) + B=error code, if any + + +.nl=7 +\t66\ + +SHO_REGS: Display the 6809 registers to standard error. + +OTHER MODULES NEEDED: BIN2HEX, BIN_HEX, PUTS + +ENTRY: none + +EXIT: none + + +NOTE: The value used for PC is that of the calling routine + S is assumed to be 2 greater than actual to comp for + the subroutine call... + + +.nl=7 +\t66\ + +MEMMOVE: Memory move + +NOTE: This routine properly moves overlapping areas of memory. + Uses fast move algorithm + +ENTRY: X=source data + Y=destination + D=count + +EXIT: all registers (except CC) preserved + + +.nl=7 +\t66\ + +PTSEARCH: Pattern Search + +OTHER MODULES REQUIRED: COMPARE + +ENTRY: X=start of memory to search + U=end of memory + Y=start of pattern + D=size of pattern + CASEMTCH (a global variable in COMPARE) =0 if A<>a, -1 if A=a + +EXIT: X=address of match if found, unchanged if no match + CC zero set if match, clear for no-match + A,B,U,Y preserved + + +.nl=7 +\t66\ + +MEMSET: Set bytes in memory to specified value + +OTHER MODULES NEEDED: none + +ENTRY: X=start of memory + Y=number of bytes to set + B=character to set + +EXIT: all registers (except cc) preserved + + +.nl=7 +\t66\ + +COMPARE: Subroutine for string comparsion routines. + Compares chars in A/B, will convert both to + uppercase first if CASEMTCH is set (negative) + +OTHER MODULES NEEDED: TO_UPPER + +ENTRY: A/B=characters to compare + CASEMTCH=0 (or positive value) if A<>a + -1 (or neg value) if A=a + +EXIT: CC zero set if characters match. + All other registers preserved.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/alib.intro Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,56 @@ + RMA Library + + by + + Bob van der Poel + + +WARNING: The entire contents of this file including the documentation and +the actual binary library code are protected by copyright and is the sole +property of Bob van der Poel. You are given permission to use this +software and to post it on other information systems, etc. However, you +may not sell it, or claim it as your own. Any commercial expoltation will +be prosectuted to the full extent of the law. + + Bob van der Poel Software + + P.O. Box 57 P.O. Box 355 + Wynndel, B.C. Porthill, ID + Canada V0B 2N0 USA 83853 + + +To use the routines in this library, just include calls to them in your +programs with a "lbsr". For example, the following code segment calls a +library routine to print a number via standard out: + + ldd number + lbsr PRINT_DEC + +To use a routine make sure you have set up all the registers properly. +None of the routines use any memory other than stated. Since the hardware +stack is used for all temporary variables all the routines are re-entrant +and shareable. It is up to the user to ensure an adequate stack area. +Note that most of the routines have all uppercase names. It is hoped that +this will make your code more readable since you can tell at a glance +which routines are external. + +To compile an assembler program using the library first use RMA to +generate a ".r" file, then use RLINK to compile. A sample command line +would be: + + rlink yourprog.a -o=yourprog -l=/d0/lib/alib.l + +The file alib.doc is a formatted listing of all the commands available in +the library. Just list it to your printer. + +Included in the SRC directory is the file "makefile" which can be used +with MAKE to create a new library file. List "makefile" first to see +which directories, etc. you'll need. + +Also included on the disk is the file "LIB/alib.l". This is the complied +version of the library, ready for you to link with. + +If you have any comments or suggestions for future improvement--or even +if you want to send money (yes, I take contributions!)--please write me +at the above address or email bvdp@uniserve.com. +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/asc_bin.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,60 @@ +****************************************** +* +* ASCII String to binary byte conversion + +* OTHER MODULES NEEDED: IS_TERMIN + +* ENTRY: X = start of string of binary digits (001101) +* terminated by space, comma, CR or null. + +* EXIT: D = value +* CC carry set if error (string too long, not binary digits) +* Y = terminator or error pos. + + + nam ASCII String to Binary Conversion + ttl Assembler Library Module + + + psect ASC_BIN,0,0,0,0,0 + +ASC_BIN: + clra msb/lsb=0 + clrb + pshs a,b,x + +ascbn1 + ldb ,x+ get a digit + lbsr IS_TERMIN see if space/comma/null/cr + beq ascbn2 + subb #$30 strip off ASCII + bmi error less than "0".. + cmpb #1 + BHI error geater than "1" + rorb get bit into carry + ROL 1,S into LSB + ROL ,S into MSB + inca bump string length + cmpa #16 + BLS ascbn1 length ok, loop + BRA error + +ascbn2 + clrb = no errors + tsta len = 0? + bne done no, skip + +* error -- too long or null + +error + CLR ,S force data to 0 + CLR 1,S + ORCC #1 set carry flag + +done + leay -1,x end of string/error char + PULS A,B,X,PC get data; restore & return + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/b09strlen.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,37 @@ +********************************** + +* BASIC09 String Length: find length of a BASIC09 string +* which can be terminated by a $ff +* =or= allocated storage size + +* ENTRY: X=start of string +* D=max allocated + +* EXIT: D=actual length +* all other regs (except cc) preserved + + nam Find Basic09 String Length + ttl Assembler Library Module + + + psect B09STRLEN,0,0,0,0,0 + +B09STRLEN: + pshs d,x,y + tfr d,y max. possible size to Y + +loop + lda ,x+ get char from string + inca this effects a cmpa #$ff + beq exit reached terminator + leay -1,y if string max leng, no terminator + bne loop no yet, check more + +exit + puls d get max possible size + pshs y unused size in memory + subd ,s++ find actual length + puls x,y,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/bin2hex.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,37 @@ +**************************************** + +* Convert hex byte to 2 hex digits + +* OTHER MODULES REQUIRED: none + +* ENTRY: B= value to convert + +* EXIT: D=2 byte hex digits + + + nam Convert Byte to Hex + ttl Assembler Library Module + + psect BIN2HEX,0,0,0,0,0 + +BIN2HEX: + pshs b + lsrb get msn + lsrb + lsrb + lsrb fall through to convert msn and return + bsr ToHex + tfr b,a 1st digit in A + puls b get lsn + andb #%00001111 keep msn + +ToHex + addb #'0 convert to ascii + cmpb #'9 + bls ToHex1 + addb #7 convert plus 9 to A..F +ToHex1 + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/bin_asc.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,40 @@ +****************************************** + +* Binary word to ASCII string conversion + +* OTHER MODULES NEEDED: none + +* ENTRY: D = binary value +* X = buffer for 16 bit number + +* EXIT: all registers (except cc) preserved + + nam Convert # to Ascii String + ttl Assembler Library Module + + + psect BIN_ASC,0,0,0,0,0 + +BIN_ASC: + pshs a,b,x save registers + pshs a,b save data again + ldb #16 total bits to convert + andcc #%11111110 clear CARRY to start + +binas1 + lda #'0 get ASCII 0 + rol 1,S get hi bit in LSB to carry + rol ,S and into MSB; is it 1 or 0? + bcc binas2 0, skip + inca get ASCII 1 + +binas2 + sta ,x+ put it in the buffer + decb done all bits? + bne binas1 no, loop + clr ,x mark end of string + leas 2,s clean up + puls a,b,x,pc restore & return + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/bin_dec.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,97 @@ +************************************************ +* +* Binary to decimal conversion + +* OTHER MODULES NEEDED: DECTAB$ + +* ENTRY: X=buffer for ascii string +* D=binary value to convert + +* EXIT: all registers (except cc) preserved + +* BGP - 04/11/2009 - Fixed issue where BIN_DEC was printing negative +* sign in certain cases. Cleared nega flag to fix issue. + + nam Binary to Decimal Conversion + ttl Assembler Library Module + + + psect BIN_DEC,0,0,0,0,0 + + vsect +nega rmb 1 + endsect + +BIN_SDEC: + clr nega,u + tsta + bpl BIN_DEC + sta nega,u + comb + coma + addd #$0001 + bra BIN_DEC_COMMON +++ added BGP + +BIN_DEC: + clr nega,u +++ added BGP +BIN_DEC_COMMON + pshs a,b,x,y + lda #7 clear out 7 bytes in buffer + +bindc1 + clr ,x+ + deca + bne bindc1 + ldx 2,s restore buffer start address + ldd ,s get data + bne bindc2 not 0, do convert + lda #'0 + sta ,x + bra bindc8 exit + +bindc2 + tst nega,u + beq bindc25 + pshs a + lda #'- + sta ,x+ + puls a +bindc25 + leay DECTAB$,pcr point to conversion table + clr ,--s temps, flag 1st dgt not placed + +bindc3 + clr 1,s current digit=0 + +bindc4 + subd ,y sub table element + bcs bindc5 too far, correct + inc 1,s bump digit + bra bindc4 loop til done + +bindc5 + addd ,y restore, 1 too many subtracts + pshs a,b save rest of number + lda 3,s get the digit + adda #$30 make it ascii + cmpa #'0 is it zero? + bne bindc6 no, skip + tst 2,s is it 1st digit in string? + beq bindc7 yes, don't do leading 0s + +bindc6 + inc 2,s indidicate at least 1 digit + sta ,x+ save in buffer + +bindc7 + leay 2,y next table entry + tst 1,y end of table + puls a,b restore data + bne bindc3 no..loop + leas 2,s + +bindc8 + puls a,b,x,y,pc restore and return + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/bin_hex.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,35 @@ +******************************************** +* +* Binary to hexadecimal convertor +* +* This subroutine will convert the binary value in +* 'D' to a 4 digit hexadecimal ascii string. + + +* OTHER MODULES NEEDED: BIN2HEX + +* ENTRY: D=value to convert +* X=buffer for hex string-null terminated + +* EXIT all registers (except CC) preserved. + + nam Convert # to Hex String + ttl Assembler Library Module + + + psect BIN_HEX,0,0,0,0,0 + +BIN_HEX: + pshs d,x + ldb ,s + lbsr BIN2HEX convert 1 byte + std ,x++ + ldb 1,s + lbsr BIN2HEX convert 2nd byte + std ,x++ + clr ,x term with null + puls d,x + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/bin_rom.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,94 @@ +*************************************** + +* Subroutine to convert binary number to roman numerals + +* OTHER MODULES NEEDED: none + +* ENTRY: D=number to convert +* X=start of buffer (20 bytes) + + +* EXIT: all registers preserved + +* Note: the buffer should be set to 20 bytes. This permits the +* longest possible number to be converted without a buffer overflow. +* This routine trunates any numbers >8191 to ensure that no number +* is longer than 19 characters (plus null terminator). +* The number 7888 converts to a 19 character string. To permit larger +* number conversions one could delete the anda #%00011111 statement. + +* This routine has been converted from the BASIC09 sample in +* the Basic09 Reference Manual (Microware) page a-3. + + nam Binary to Roman numberal conversion + ttl Assembler Library Module + + + psect BINROM,0,0,0,0,0 + + +BIN_ROM: + pshs d,x,y,u + + leau nums,pcr number conversion table + clr ,-s counter on stack + lda 1,s restore value + anda #%00011111 ensure no value>8191 permitted + +roman1 + cmpd ,u + blo roman2 + leay chars,pcr + bsr addchar + subd ,u + bra roman1 + +roman2 + pshs d + ldd ,u + subd 2,u + cmpd ,s + puls d + bhi roman3 + + leay subs,pcr + bsr addchar + leay chars,pcr + bsr addchar + subd ,u + addd 2,u + +roman3 + leau 4,u next pair of values + pshs d + inc 2,s counter + lda 2,s + cmpa #7 done? + puls d + bne roman1 no, do more + + puls a + clr ,x null terminator + + puls d,x,y,u,pc + +addchar + pshs d + lda 4,s get loop count + lda a,y get char + sta ,x+ + puls d,pc + +nums fdb 1000,100 + fdb 500,100 + fdb 100,10 + fdb 50,10 + fdb 10,1 + fdb 5,1 + fdb 1,0 + +chars fcc /MDCLXVI/ +subs fcc /CCXXII/ + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/compare.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,43 @@ +************************************** + +* COMPARE: Subroutine for string comparsion routines. +* Compares chars in A/B, will convert both to +* uppercase first if CASEMTCH is set (negative) + + +* OTHER MODULES NEEDED: TO_UPPER + +* ENTRY: A/B=characters to compare +* CASEMTCH=0 (or positive value) if A<>a +* -1 (or neg value) if A=a + + +* EXIT: CC zero set if characters match. +* All other registers preserved. + + + nam Compare 2 Chars + ttl Assembler Library Module + + + Psect COMPARE,0,0,0,0,0 + + vsect dp + +CASEMTCH: rmb 1 + + endsect + +COMPARE: + pshs d + tst CASEMTCH need to covert to upper? + bpl no + lbsr TO_UPPER + exg a,b + lbsr TO_UPPER +no + pshs a somewhere to compare it + cmpb ,s+ do compare, set zero + puls d,pc go home + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/datestr.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,56 @@ +***************************************** + +* Convert a date to a string. This can be used +* for converting the system time as well as +* modify/create dates from files. The date must +* be 6 bytes -- null pad file dates. + + +* OTHER MODULES NEEDED: BIN_ASC + +* ENTRY: X=binary date +* Y=buffer for ascii + +* EXIT: all registers preserved (except cc) + + nam Get ASCII Date + ttl Assembler Library Module + + + psect DATESTR,0,0,0,0,0 + +DATESTR: + pshs d,x,y,u + leau delims,pcr + +loop + bsr get1 convert a byte + lda ,u+ get next delimiter + sta ,y+ add to ascii buffer + bne loop not end yet + puls d,x,y,u,pc + +get1 + ldb ,x+ get next byte to convert + clra only doing one byte value + pshs x save ptr to date packet + leas -8,s buffer for ascii number + tfr s,x + lbsr BIN_DEC convert + ldd ,x get ascii + tstb 1byte number? + bne get2 no + tfr a,b + lda #'0 leading "0" + +get2 + std ,y++ to buffer + leas 8,s + puls x,pc + +delims + fcc '// ::' + fcb 0 + + endsect +t
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/dec_bin.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,110 @@ +**************************************** + +* DECIMAL to BINARY conversion routine + +* OTHER MODULES NEEDED: DECTAB$, IS_TERMIN + +* ENTRY: X = start of asci decimal string terminated by +* a space, comma, CR or null. + +* EXIT: D = binary value +* CC carry set if error (too large, not numeric) +* Y = terminator or error char. + + nam Convert Decimal String to Binary + ttl Assembler Library Module + + + psect DEC_BIN,0,0,0,0,0 + + vsect +nega rmb 1 + endsect + +DEC_BIN: + clra set result to 0 + clrb + pshs a,b,x + leas -1,s temp variable + + clr nega,u + ldb ,x+ + cmpb #'- + bne decbn15 + stb nega,u +decbn1 + LDB ,X+ get a digit +decbn15 + LBSR IS_DIGIT + bne decbn3 end of string... + INCA bump string len + BRA decbn1 loop for whole string + +decbn3 + lbsr IS_TERMIN valid terminator? + bne error + +ok + TSTA length = 0? + BEQ error yes, error + CMPA #6 more than 6 chars? + BHI error yes, error + + ldx 3,s get start of string again + + PSHS A + lda ,x + cmpa #'- + bne decbn35 + leax 1,x +decbn35 + LDA #5 max length + SUBA ,S+ adjust for offset + ASLA 2 bytes per table entry + LEAY DECTAB$,PCR addr of conversion table + LEAY A,Y add in offset for actual len + +decbn4 + LDA ,X+ get a digit + SUBA #$30 strip off ASCII + BEQ decbn6 zero, skip + sta ,s save digit=# of adds + LDD 1,S get binary data + +decbn5 + ADDD ,Y add in table value + BCS error past 0, too big + DEC ,S count down digit size + BNE decbn5 loop til 0 + STD 1,S save binary data + + +decbn6 + LEAY 2,Y next entry + tst 1,y end of table? + BNE decbn4 loop til done + clr ,s+ clean up and clear carry + bra exit + + +error + clr 0,s force data = 0 + clr 1,s + com ,s+ clean up and set carry + +exit + tfr x,y end of string/error char + puls a,b,x + bcs leave + tst nega,u + beq leave + subd #$0001 + coma + comb + andcc #$FE +leave + rts + + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/dectab.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,17 @@ +********************************************************************* + +* table of decimal numbers for use by binary/decimal conversion +* routines. + + + nam Decimal Number Table + ttl Assembler Library Module + + + psect DECTAB$,0,0,0,0,0 + +DECTAB$: + fdb 10000,1000,100,10,1,0 + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/div16x16.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,90 @@ +********************************************* +* 16 x 16 bit integer divide + +* OTHER MODULES NEEDED: none + +* ENTRY: D = divisor +* X = dividend + +* EXIT: X = quotient +* D = remainder + + nam 16x16 bit Divide + ttl Assembler Library Module + + + psect DIV16,0,0,0,0,0 + + vsect +negcount rmb 1 + endsect + +* Signed Divide +SDIV16: + clr negcount,u + PSHS D,X + tst ,s + bpl testquo + ldd ,s + comb + coma + addd #$0001 + std ,s + inc negcount,u +testquo + tst 2,s + bpl ok + ldd 2,s + comb + coma + addd #$0001 + std 2,s + inc negcount,u +ok + puls d,x + bsr DIV16 + dec negcount,u + bne goforit + pshs d,x + ldd ,s + coma + comb + addd #$0001 + std ,s + ldd 2,s + coma + comb + addd #$0001 + std 2,s + puls d,x +goforit + rts + + +* Unsigned Divide +DIV16: + PSHS D,X save divisor & dividend + LDA #16 bit counter + PSHS A + CLRA initialize remainder + CLRB + +div1 + ASL 4,S shift dividend & quotient + ROL 3,S + ROLB shift dividend into B + ROLA + CMPD 1,S trial subtraction reqd? + BLO div2 + SUBD 1,S yes, do subtraction + INC 4,S increment quotient + +div2 + DEC ,S count down another bit + BNE div1 + LDX 3,S get quotient + LEAS 5,S clean stack + RTS + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/div16x8.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,83 @@ +**************************************** +* 16 x 8 bit integer divide + +* Result must be an 8 bit value + +* ENTRY: A = divisor +* X = dividend + +* EXIT: A = remainder +* B = quotient +* all other registers (except CC) preserved + + nam 16x8 bit Divide + ttl Assembler Library Module + + + psect DIV168,0,0,0,0,0 + + vsect +negcount rmb 1 + endsect + +* Signed Divide +SDIV168: + clr negcount,u + PSHS A,X + tst ,s + bpl testquo + lda ,s + coma + inca + sta ,s + inc negcount,u +testquo + tst 1,s + bpl ok + ldd 1,s + comb + coma + addd #$0001 + std 1,s + inc negcount,u +ok + puls a,x + bsr DIV168 + dec negcount,u + bne goforit + pshs a,x + lda ,s + coma + inca + sta ,s + ldd 1,s + coma + comb + addd #$0001 + std 1,s + puls a,x +goforit + rts + + +DIV168: + LDB #8 bit counter + PSHS A,B,X save count and divisor and value + TFR X,D put dividend in D + +div1 + ASLB shift dividend and quotient + ROLA + CMPA 0,S is trial subtraction successful? + BCS div2 + SUBA 0,S yes, subtract and set bit + INCB in quotient + +div2 + DEC 1,S count down bits + BNE div1 loop till done + LEAS 2,S clean stack + PULS X,PC return + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/div8x8.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,81 @@ +********************************* +* 8 x 8 Divide + +* OTHER MODULES NEEDED: none + +* ENTRY: A = divisor +* B = dividend + +* EXIT: A = remainder +* B = quotient + + nam 8x8 bit Divide + ttl Assembler Library Module + + + psect DIV88,0,0,0,0,0 + + vsect +negcount rmb 1 + endsect + +* Signed Divide +SDIV88: + clr negcount,u + PSHS D + tst ,s + bpl testquo + lda ,s + coma + inca + sta ,s + inc negcount,u +testquo + tst 1,s + bpl ok + ldd 1,s + coma + adda #$01 + std 1,s + inc negcount,u +ok + puls d + bsr DIV88 + dec negcount,u + bne goforit + pshs d + lda ,s + coma + inca + sta ,s + lda 1,s + coma + inca + sta 1,s + puls d +goforit + rts + + +DIV88: + PSHS A save divisor + LDA #8 bit counter + PSHS A + CLRA initialize remainder + +div1 + ASLB shift dividend & quotient + ROLA + CMPA 1,S trial subtraction needed + BLO div2 + SUBA 1,S + INCB + +div2 + DEC 0,S count down # of bits + BNE div1 + LEAS 2,S clean up stack + RTS + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fgetc.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,28 @@ +*************************************** + +* Subroutine to input one character. + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path + + +* EXIT: A character +* CC carry set if error (from I$Read) +* B error code if any + + nam Input Single Character + ttl Assembler Library Module + + + psect FGETC,0,0,0,0,0 + +FGETC: + pshs a,x,y + ldy #1 number of char to print + tfr s,x point x at 1 char buffer + os9 I$Read + puls a,x,y,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fgets.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,47 @@ +*************************************** + +* Subroutine to input a null terminated string. + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path +* X=buffer for string +* Y=max buffer size (leave room for null!!) + +* EXIT: CC carry set if error (from I$ReadLn) +* B error code if any + + +* NOTE: The string entered must end with an end-of-record char +* (usually a $0D), the null is appended for ease in string +* handling. + + + nam Input Null Terminated String + ttl Assembler Library Module + + + psect FGETS,0,0,0,0,0 + +FGETS_NOCR: + pshs d,x + bsr FGETS + bcs bye + tfr y,d + leax -1,x + clr d,x +bye puls d,x,pc + +FGETS: + pshs a,x + os9 I$ReadLn get line + bcs exit return error code + tfr y,d + clr d,x add null + clrb no error.. + +exit + puls a,x,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fgety.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,27 @@ +*************************************** + +* Subroutine to input one word in Y. + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path + + +* EXIT: Y value +* CC carry set if error (from I$Read) +* B error code if any + + nam Input word + ttl Assembler Library Module + + + psect FGETY,0,0,0,0,0 + +FGETY: + pshs x,y + ldy #2 number of char to read + leax 2,s point x at 2 char buffer + os9 I$Read + puls x,y,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fputc.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,28 @@ +*************************************** + +* Subroutine to print one character. + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path +* B=char to print + +* EXIT: CC carry set if error (from I$WritLn) +* B error code if any + + nam Output Single Char. + ttl Assembler Library Module + + + psect FPUTC,0,0,0,0,0 + +FPUTC: + pshs b,x,y + ldy #1 number of char to print + tfr s,x point x at char to print + os9 I$WritLn + leas 1,s don't care about char anymore (B now = error) + puls x,y,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fputcr.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,23 @@ +**************************************** + +* Subroutine to print a carriage return + +* OTHER MODULES REQUIRED: FPUTC + +* ENTRY: A=path + +* EXIT: CC carry set if error (from I$WritLn) +* B error code if any. + + + nam Output Carriage Return + ttl Assembler Library Module + + + psect FPUTCR,0,0,0,0,0 + +FPUTCR: + ldb #$0d + lbra FPUTC + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fputs.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,47 @@ +************************************** + +* FPUTS: print null terminated string to "A". + +* OTHER MODULES REQUIRED: none + +* ENTRY: X=start of string +* A=path + +* EXIT: CC carry set if error +* B = OS9 error if any (from I$WritLn) + +* NOTE: string is feed through I$WritLn for editing (adding LF, etc.) + + nam Output String + ttl Assembler Library Module + + + psect FPUTS,0,0,0,0,0 + +FPUTS: + pshs a,x,y,u + tfr x,u start of 1st segment to print + +loop + pshs u start of this segment + ldy #-1 size of this seg. + +l1 + leay 1,y count size + ldb ,u+ check for null/cr + beq doit null=do last seg. + cmpb #$0d cr=do this seg. + bne l1 + leay 1,y count CR as one of the ones to print + +doit + puls x get start of this segment + OS9 I$WritLn + bcs exit + tst -1,u at end? + bne loop + +exit + puls a,x,y,u,pc return with status in CC,error code in B + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fputspace.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,22 @@ +**************************************** + +* Subroutine to print a space + +* OTHER MODULES REQUIRED: FPUTC + +* ENTRY: A=path + +* EXIT: CC carry set if error (from I$WritLn) +* B error code if any. + + nam Output One Space Char. + ttl Assembler Library Module + + + psect FPUTSPACE,0,0,0,0,0 + +FPUTSPACE: + ldb #$20 + lbra FPUTC + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/fputy.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,27 @@ +*************************************** + +* Subroutine to save word in Y to file + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path +* Y=value to save + +* EXIT: CC carry set if error (from I$Write) +* B error code if any + + nam Save word to file + ttl Assembler Library Module + + + psect FPUTY,0,0,0,0,0 + +FPUTY: + pshs x,y + ldy #2 number of chars to write + leax 2,s point X at value + os9 I$Write + puls x,y,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/frewind.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,27 @@ +*************************************** + +* Subroutine rewind file + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path + + +* EXIT: CC carry set if error (from I$Seek) +* B error code if any + + nam Rewind open RBF file + ttl Assembler Library Module + + + psect FREWIND,0,0,0,0,0 + +FREWIND: + pshs x,u + ldx #0 + tfr x,u + os9 I$Seek seek to pos 0 + puls x,u,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/ftoeof.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,28 @@ +*************************************** + +* Subroutine seek to end of file + +* OTHER MODULES NEEDED: none + +* ENTRY: A=path + + +* EXIT: CC carry set if error (from I$Seek) +* B error code if any + + nam Seek EOF of open RBF file + ttl Assembler Library Module + + + psect FTOEOF,0,0,0,0,0 + +FTOEOF: + pshs x,u + ldb #SS.Size first get filesize + os9 I$GetStt + bcs exit + os9 I$Seek seek to end of file +exit + puls x,u,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/ftrans.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,75 @@ +*************************************** + +* Subroutine to transfer data for one file to another + +* OTHER MODULES NEEDED: none + +* ENTRY: A=source path +* B=destination path +* Y=number of bytes to transfer +* X=buffer for this routine +* U=buffer size + + +* EXIT: CC carry set if error (from I$Read or I$Write) +* B error code if any + + nam File data transfer + ttl Assembler Library Module + + csect + +* this sets up a stack frame used for variable references + +count rmb 2 number of bytes to transfer (2nd Y) +inpath rmb 1 source file (A) +Breg rmb 1 copy of B register +outpath equ Breg dest file +buffer rmb 2 buffer memory (X) + rmb 2 copy of Y +bufsize rmb 2 buffer size (U) + + endsect + + psect FTRANS,0,0,0,0,0 + +FTRANS: + pshs a,b,x,y,u + pshs y + +loop + ldy count,s bytes left to send + beq exit all done? + + lda inpath,s source file + ldx buffer,s buffer area + cmpy bufsize,s is remainder > buffer size + blo get no, get all of remainder + ldy bufsize,s use buffer size + +get + os9 I$Read get data + bcs error + lda outpath,s + os9 I$Write + bcs error + + pshs y number of bytes got/sent + ldd count+2,s adjust count remaining + subd ,s++ + std count,s + bra loop + +exit + clra no error + bra exit2 + +error + coma signal error + stb Breg,s set B + +exit2 + puls y + puls a,b,x,y,u,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/getc.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,25 @@ +*************************************** + +* Subroutine to input one character from std in. + +* OTHER MODULES NEEDED: FGETC + +* ENTRY: none + + +* EXIT: A character +* CC carry set if error (from I$Read) +* B error code if any + + nam Input Single Character + ttl Assembler Library Module + + + psect GETC,0,0,0,0,0 + +GETC: + clra std in + lbra FGETC + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/getfmd.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,48 @@ +************************************ + +* Get the "last modified" date of an open file + +* NOTE: Even though OS9 does not save seconds in its +* files this routine stores a zero in this position. +* This is done to make the routine compatible with +* DATESTR. + +* OTHER MODULES NEEDED: none + +* ENTRY: X=buffer for 6 byte date +* A=path of open file + +* EXIT: CC carry set if error +* B error code (if any) from SS.FD + + + nam Get Last Modified Date + ttl Assembler Library Module + + psect GETFMD,0,0,0,0,0 + +BUFSIZ equ 8 + +GETFMD: + pshs x,y + leas -BUFSIZ,s where to put FD sector info + tfr s,x pointer for FD sector info + ldy #BUFSIZ bytes to read from FD sector + ldb #$0F SS.FD + os9 I$GetStt + bcs exit + ldy BUFSIZ,s get back orig X + ldx 3,s get 2 bytes + stx ,y++ move year,month + ldx 5,s + stx ,y++ move date,hour + lda 7,s + sta ,y+ move minutes + clr ,y null for seconds + +exit + leas BUFSIZ,s + puls x,y,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/gets.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,30 @@ +*************************************** + +* Subroutine to input a null terminated string from Std. In + +* OTHER MODULES NEEDED: GETS + +* ENTRY: X=buffer for string +* Y=max buffer size (leave room for null!!) + +* EXIT: CC carry set if error (from I$ReadLn) +* B error code if any + +* NOTE: The string entered must end with an end-of-record char +* (usually a $0D), the null is appended for ease in string +* handling. + + nam Input Null Terminated String from Std. In + ttl Assembler Library Module + + + psect GETS,0,0,0,0,0 + +GETS: + pshs a + clra std in. + lbsr FGETS + puls a,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/gety.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,26 @@ +*************************************** + +* Subroutine to input a word in Y + +* OTHER MODULES NEEDED: FGETY + +* ENTRY: none + + +* EXIT: Y value +* CC carry set if error (from I$Read) +* B error code if any + + nam Input Word for stdin + ttl Assembler Library Module + + + psect GETY,0,0,0,0,0 + +GETY: + pshs a + clra std in + lbsr FGETY + puls a,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/hex_bin.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,79 @@ +***************************************** + +* Hexadecimal string to BINARY conversion + +* OTHER MODULES REQUIRED: TO_UPPER, IS_TERMIN, IS_XDIGIT + +* ENTRY: X=start of a hex string terminated by a space, +* comma, CR, or NULL. + +* EXIT: D=binary number +* CC carry set iferror (too large, non-numeric) +* Y=terminator position or error char. + + + nam Convert Hex String to Binary + ttl Assembler Library Module + + psect HEX_BIN,0,0,0,0,0 + + +HEX_BIN: + clra init number + clrb + pshs d,x + tfr d,y digit counter + +loop + ldb ,x+ get next digit + lbsr TO_UPPER convert to uppercase + lbsr IS_TERMIN end of string? + beq exit yes, go home + lbsr IS_XDIGIT make sure it's valid digit + bne error not 0..9, a..f + cmpb #'9 convert to binary value + bls notAtoF + subb #7 fix a..f +notAtoF + subb #'0 convert to binary 0..15 + +* now shift the digit to bits 7..4 + + lslb + lslb + lslb + lslb + +* now shift the value in to the result + + lda #4 number of bits +l1 + lslb digit bit to carry + rol 1,s carry bit to result + rol 0,s + deca done 4? + bne l1 no, loop + + leay 1,y number of digits done + cmpy #4 + bhi error more than 4 + bra loop keep going + + +exit + clrb clear carry=no error + sty -2,s test y (count) + bne done no digits? + +error + clr 0,s + clr 1,s + orcc #1 set carry + +done + leay -1,x terminator/error pos + puls d,x,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/inkey.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,43 @@ +*************************************** + +* Subroutine to input one character from std in. if ready +* like an INKEY$... + +* OTHER MODULES NEEDED: FGETC + +* ENTRY: none + + +* EXIT: A character, 0=no char +* CC carry set if error (from I$Read) +* B error code if any + + nam Inkey + ttl Assembler Library Module + + + psect INKEY,0,0,0,0,0 + +INKEY: + clra std in + ldb #SS.Ready + os9 I$GetStt see if key ready + bcc getit + cmpb #E$NotRdy no keys ready=no error + bne exit other error, report it + clra no error + bra exit + +getit + lbsr FGETC go get the key + +* this inst. needed since ctrl/: sometimes returns a null +* usually callers are not expecting a null.... + + tsta + +exit + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_alnum.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,29 @@ +***************************************** + +* See if character in "B" is a alpha letter a..z or A..Z or digit 0..9 + +* OTHER MODULES NEEDED: IS_ALPHA, IS_DIGIT + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if alphanumeric, 0 if not + + + nam Is Char AlphaNumeric? + ttl Assembler Library Module + + + psect IS_ALNUM,0,0,0,0,0 + + +IS_ALNUM: + lbsr IS_ALPHA + BEQ yes upper/lowercase letters are alphanumeric + lbsr IS_DIGIT last chance to set flags. + +yes + rts + + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_alpha.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,28 @@ +***************************************** + +* See if character in "B" is a alpha letter a..z or A..Z + +* OTHER MODULES NEEDED: IS_LOWER, IS_UPPER + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if alpha, 0 if not + + nam Is Char Alphabetic? + ttl Assembler Library Module + + + psect IS_ALPHA,0,0,0,0,0 + + +IS_ALPHA: + lbsr IS_UPPER + BEQ yes uppercase letters are alpha + lbsr IS_LOWER last chance to set flags. + +yes + rts + + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_cntrl.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,32 @@ +***************************************** + +* See if character in "B" is a control character +* controls are defined as $00..$1F and $7F+ + +* OTHER MODULES NEEDED: none + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if control, 0 if not + + nam Is Char a Control? + ttl Assembler Library Module + + + psect IS_CNTRL,0,0,0,0,0 + + +IS_CNTRL: + cmpb #$7f + bhs yes + cmpb #$1f + bhi exit not control, zero cleared + +yes + orcc #%00000100 set zero + +exit + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_digit.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,29 @@ +***************************************** + +* See if character in "B" is a digit 0..9 + +* OTHER MODULES NEEDED: none + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if digit, 0 if not + + nam Is Char a Digit? + ttl Assembler Library Module + + + psect IS_DIGIT,0,0,0,0,0 + + +IS_DIGIT: + cmpb #'0 + blo no not digit, zero cleared + cmpb #'9 if equal, zero set + bhi no not digit, zero cleared + orcc #%00000100 set zero + +no + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_lower.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,29 @@ +***************************************** + +* See if character in "B" is a lowercase letter + +* OTHER MODULES NEEDED: none + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if lowercase, 0 if not + + nam Is Char. Lowercase? + ttl Assembler Library Module + + + psect IS_LOWER,0,0,0,0,0 + + +IS_LOWER: + cmpb #'a + blo no not lowercase, zero cleared + cmpb #'z if equal, zero set + bhi no not lowc, zero cleared + orcc #%00000100 set zero + +no + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_print.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,30 @@ +***************************************** + +* See if character in "B" is a printable character +* controls are defined as $00..$1F and $7F+ -- all others are printable + +* OTHER MODULES NEEDED: IS_CNTRL + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if printable, 0 if not + + + nam Is Char Printable? + ttl Assembler Library Module + + + psect IS_PRINT,0,0,0,0,0 + +IS_PRINT: + lbsr IS_CNTRL + beq no + orcc #%00000100 set zero + rts + +no + andcc #%11111011 clear zero + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_punct.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,33 @@ +***************************************** + +* See if character in "B" is a punctuation character + +* OTHER MODULES NEEDED: IS_ALNUM, IS_CNTRL + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if punct., 0 if not + + + nam Is Char Punctuation? + ttl Assembler Library Module + + + psect IS_PUNCT,0,0,0,0,0 + + +IS_PUNCT: + lbsr IS_ALNUM + BEQ no if its a.z,A.Z or 0.9 not punct + lbsr IS_CNTRL + BEQ no controls not punct. + orcc #%00000100 set carry + rts + +no + andcc #%11111011 clear zero + rts + + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_space.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,27 @@ +***************************************** + +* See if character in "B" is a space ($20) + +* NOTE: This module is included for completeness only, +* it is much more efficient to do an inline test. + +* OTHER MODULES NEEDED: none + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if space, 0 if not + + + nam Is Char a Space? + ttl Assembler Library Module + + + psect IS_SPACE,0,0,0,0,0 + + +IS_SPACE: + cmpb #$20 + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_termin.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,36 @@ +***************************************** + +* See if character in "B" is a valid string terminator. + +* NOTE: This module is used by HEX_BIN, DEC_BIN, etc. It permits +* SPACE, CR, COMMA and NULL to be used as a delimiter -- useful +* for paramater and list processing.... + +* OTHER MODULES NEEDED: none + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if space, 0 if not + + + nam Is Char a Terminator? + ttl Assembler Library Module + + + psect IS_TERMIN,0,0,0,0,0 + + +IS_TERMIN: + tstb null? + beq exit + cmpb #$20 space + beq exit + cmpb #$0d carriage return + beq exit + cmpb #', comma? + +exit + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_upper.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,29 @@ +***************************************** + +* See if character in "B" is a uppercase letter + +* OTHER MODULES NEEDED: none + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if uppercase, 0 if not + + nam Is Char Uppercase? + ttl Assembler Library Module + + + psect IS_UPPER,0,0,0,0,0 + + +IS_UPPER: + cmpb #'A + blo no not uppercase, zero cleared + cmpb #'Z if equal, zero set + bhi no not upperc, zero cleared + orcc #%00000100 set zero + +no + rts + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/is_xdigit.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,38 @@ +***************************************** + +* See if character in "B" is a hexdigit 0..9, A..F or a..f + +* OTHER MODULES NEEDED: IS_DIGIT + +* ENTRY: B=character to test + +* EXIT: CC zero=1 if hex digit, 0 if not + + nam Is Char a Hex Digit? + ttl Assembler Library Module + + + psect IS_XDIGIT,0,0,0,0,0 + + +IS_XDIGIT: + pshs b + lbsr IS_DIGIT + beq exit digits are okay + cmpb #'A + blo exit exit, zero not set + cmpb #'f + bhi exit zero not set + cmpb #'a + bhs yes + cmpb #'F + bhi exit + +yes + orcc #%00000100 set zero + +exit + puls b,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/jsr_cmd.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,57 @@ +*************************************** + +* Subroutine to jsr to subroutine from 1 character command table + +* OTHER MODULES NEEDED: none + +* ENTRY: A=1 char command +* X=start of jump table + +* EXIT: CC carry set if entry not found +* all other regs can be modified by subs + +* Note format of table: each entry is three bytes +* 0-match character (command) +* 1..2-offset to routine + +* It is the user's job to set commands to proper case for matching... + +* end of table=NULL + +* sample table: fcc /A/ +* fdb routineA-* +* fcc /B/ +* fdb routineB-* +* fcb 0 + + + nam Jsr to 1 char Command + ttl Assembler Library Module + + psect JSR_CMD,0,0,0,0,0 + +JSR_CMD: + tst ,x end of table? + beq jsrerr + + cmpa ,x+ found match? + beq docmd yes, go do it + + leax 2,x next entry + bra JSR_CMD + +* no match found, return with carry set + +jsrerr + coma set error flag + rts + +* command found, do call and return + +docmd + ldd ,x get offset to routine + jsr d,x + andcc #%11111110 clear carry + rts + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/jsr_cmd2.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,58 @@ +*************************************** + +* Subroutine to jsr to subroutine from 2 character command table + +* OTHER MODULES NEEDED: none + +* ENTRY: D=2 char command +* X=start of jump table + +* EXIT: CC carry set if entry not found +* all other regs can be modified by subs +* D and X always modified + +* Note format of table: each entry is four bytes +* 0..1-match characters (command) +* 2..3-offset to routine + +* It is the user's job to set commands to proper case for matching... + +* end of table=NULL + +* sample table: fcc /A1/ +* fdb routineA-* +* fcc /B1/ +* fdb routineB-* +* fcb 0 + + + nam Jsr to 2 char Command + ttl Assembler Library Module + + psect JSR_CMD2,0,0,0,0,0 + +JSR_CMD2: + tst ,x end of table? + beq jsrerr + + cmpd ,x++ found match? + beq docmd yes, go do it + + leax 2,x next entry + bra JSR_CMD2 + +* no match found, return with carry set + +jsrerr + coma set error flag + rts + +* command found, do call and return + +docmd + ldd ,x get offset to routine + jsr d,x + andcc #%11111110 clear carry + rts + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/linedit.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,259 @@ +*************************************** + +* Edit/input line. + +* This routine does not use cursor positioning, +* instead it uses backspacing, etc. This means it +* can be used without a GOTOXY module, however it +* is a bit slow, especially when lines get longer than +* one line. If the buffer contains data, you will be +* able to edit; to enter new data pass a buffer of +* blanks. + +* OTHER MODULES NEEDED: STRLEN,IS_PRINT, FPUTS, FPUTC, FGETC, MEMMOVE + +* ENTRY: X=null terminated string to edit +* A=input path (normally 0) +* B=output path (normally 1) + +* EXIT: B=key used to end editing +* CC carry set if error (GetStt, Setstt, Write, Read, etc.) +* B=error code, if any + + nam Edit/Input Line + ttl Assembler Library Module + + + psect LINEDIT,0,0,0,0,0 + +* these variable are all referenced via the +* U stack pointer. + +modPD equ 0 first buffer of copy of path descriptor +echo equ $04 echo mode +bso equ $02 backspace mode +bse equ $12 backspace echo char +bsp equ $09 backspace char +int equ $10 interupt char +qut equ $11 quit char +bell equ $13 line-overflow char + +maxsize equ 35 temp variable +dupPD equ 38 2nd path desc. + +vsize equ dupPD+32 variable stack size +strptr equ vsize+2 x on stack +inpath equ vsize+0 a on stack +outpath equ inpath+1 b on stack + +LINEDIT: + pshs a,b,x,y,u + leas -vsize,s variable storage area + tfr s,u point U to var. area + lbsr STRLEN + std maxsize,u save max leng. + lbeq exit + +* get 2 copies of path descriptor, one to restore with, one to modify + + lda outpath,u + leax dupPD,u + clrb SS.OPT + OS9 I$GetStt + bcs err1 + leax modPD,u + clrb + OS9 I$GetStt + bcs err1 + + clrb + clr echo,u turn off echo + clr int,u ignore keyboard interupt + clr qut,u ignore quit + clr bso,u backspace overstrike + os9 I$SetStt +err1 + lbcs exit + +* parse string and change all controls to space + +fixloop + lda ,x+ + beq fixx + lbsr IS_PRINT is it printable? + beq fixloop yes, test next + lda #$20 change control to space + sta -1,x + bra fixloop +fixx + +* print string at current cursor pos.... + + lda outpath,u + ldy maxsize,u + ldx strptr,u get string start + lbsr FPUTS print string + bra shiftl1 go to line start + +loop + pshs a save outpath + lda inpath,u + lbsr FGETC get one char + tfr a,b keypress to B + puls a restore outpath + lbcs out + cmpb bsp,u backspace? + bne delete no, try next + +* backspace one position + + sty -2,s test y + beq loop ignore if already at start + lbsr bs do a backspace + leax -1,x + bra loop + +* Delete char at cursor + +delete + cmpb #$10 delete char? + bne inspace no, try next + pshs d,x,y + ldd maxsize,u max leng + subd 4,s -current pos + tfr x,y destination + leax 1,x source + lbsr MEMMOVE + leax d,y end of string + lda #$20 put space at end of string + sta -1,x + tfr y,x + +del1 + puls d get outpath and char + lbsr FPUTS reprint string + ldy maxsize,u + +del2 + cmpy 2,s back up to current cur pos + beq del3 + lbsr bs + bra del2 + +del3 + puls x,y clean up and loop + +del4 + bra loop + + +inspace + cmpb #$11 insert space? + bne shiftl no, try next + pshs d,x,y + ldd maxsize,u + subd 4,s + subd #1 + leay 1,x X=source, Y=dest + lbsr MEMMOVE + ldb #$20 insert space in hole + stb ,x + bra del1 go reprint and loop + +* move cursor to start of line + +shiftl + cmpb #$18 shift left? + bne shiftr no, try next + +shiftl1 + bsr startln backup to start of line + ldx strptr,u reset x to start of line + bra asciix go loop + +* move cursor to end of line + +shiftr + cmpb #$19 shift right? + bne right + +shiftr1 + cmpy maxsize,u + bhs del4 back to loop + ldb ,x+ move to end by printing string + lbsr FPUTC + leay 1,y + bra shiftr1 + +* move 1 pos right + +right + cmpb #$09 + bne maybasci + ldb ,x get current char and insert it + lbeq loop at end, don't move + +* insert ascii char into buffer + +maybasci + tstb insert ascii into buffer + lbmi out not ascii + cmpb #$20 + lblo out + cmpy maxsize,u room for this? + blo ascii yes, insert it + ldb bell,u + lbsr FPUTC + bra asciix to main loop + +ascii + stb ,x+ + lbsr FPUTC + leay 1,y +asciix + lbra loop + +out + pshs b save keypress + bsr startln + ldx strptr,u + lbsr FPUTS + + + leax dupPD,u get original pd + lda outpath,u + clrb + os9 I$SetStt + puls a get keypress + bcc out1 + tfr b,a set error to A +out1 + sta outpath,s set B to error/keypress + +* when exiting CARRY will be set if error. B will contain +* either the keypress or the error code. + +exit + leas vsize,s + puls a,b,x,y,u,pc + +* move cursor to start of line + +startln + sty -2,s + beq startlnx exit if at start +startln1 + bsr bs + bne startln1 + +startlnx + rts + +bs + pshs b + ldb bse,u + lbsr FPUTC + leay -1,y + puls b,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/memmove.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,66 @@ +************************************** + +* Memory move + +* NOTE: This routine properly moves overlapping areas of memory. +* Uses fast move algorithm + +* ENTRY: X=source data +* Y=destination +* D=count + +* EXIT: all registers (except CC) preserved + + nam Move Memory + ttl Assembler Library Module + + + + psect MEMMOVE,0,0,0,0,0 + +MEMMOVE: + pshs d,x,y,u + std -2,s test u + beq exit zero count, exit + tfr y,u use u for dest + tfr d,y count in y + cmpu 2,s compare dest. to source (x) + beq exit same, no need to move + bhi down u>x + +up + bitb #1 see if odd number to move + beq up1 + lda ,x+ move odd byte + sta ,u+ + leay -1,y could be only one + beq exit + +up1 + ldd ,x++ move 2 bytes + std ,u++ + leay -2,y count down + bne up1 + bra exit + +down + leau d,u u=dest end (count in D) + leax d,x x=source end + + bitb #1 + beq down2 + lda ,-x move odd byte + sta ,-u + leay -1,y could be only one to do + beq exit + +down2 + ldd ,--x get 2 bytes + std ,--u move them + leay -2,y count down + bne down2 + +exit + puls d,x,y,u,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/memset.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,29 @@ +************************************ + +* MEMSET: Set bytes in memory to specified value + +* OTHER MODULES NEEDED: none + +* ENTRY: X=start of memory +* Y=number of bytes to set +* B=character to set + +* EXIT: all registers (except cc) preserved + + nam Set memory + ttl Assembler Library Module + + + psect MEMSET,0,0,0,0,0 + +MEMSET: + pshs x,y + +loop + stb ,x+ + leay -1,y dec count + bne loop till zero + + puls x,y,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/mktemp.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,40 @@ +****************************************** +* +* This subroutine creates a temorary filename +* by adding a "." and a 2digit hex value based +* on the process id. +* IMPORTANT: there must be room after the filename +* for at least 6 bytes!! Filename must be variable +* area, not parameter or program sections!!! + +* OTHER MODULES NEEDED: BIN_HEX + +* ENTRY: X= filename + +* EXIT: no registers (expect cc) modified +* filename ends in ".processid",$0d + + nam Make Unique Filename + ttl Assembler Library Module + + + psect MKTEMP,0,0,0,0,0 + +MKTEMP: + pshs d,x,y + + OS9 F$PrsNam find end of name + tfr y,x + + lda #'. + sta ,x+ put "." in name + + OS9 F$ID + tfr a,b convert to 4 digit hex + lbsr BIN2HEX + std ,x++ + lda #$0d end name with cr + sta ,x + puls d,x,y,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/mult16x16.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,47 @@ +************************************ + +* 16 x 16 Multiply + +* ENTRY: D = multiplier +* X = multiplicand + +* EXIT: Y = product 2 msbs +* U = " 2 lsbs +* D & X preserved + + nam 16x16 bit Multiply + ttl Assembler Library Module + + + psect MULT16,0,0,0,0,0 + +MULT16: + PSHS D,X,Y,U save #s and make stack room + CLR 4,S reset overflow flag + LDA 3,S get byte + MUL + STD 6,S save B x Xl + LDD 1,S + MUL B x Xh + ADDB 6,S + ADCA #0 + STD 5,S add 1st 2 mult. + LDB 0,S + LDA 3,S + MUL A x Xl + ADDD 5,S + STD 5,S add result to previous + BCC no.ov branch if no overflow + INC 4,S set overflow flag + +no.ov + LDA 0,S + LDB 2,S + MUL A x Xh + ADDD 4,S + STD 4,S + PULS D,X,Y,U,PC return + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/mult16x8.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,35 @@ +*********************************** + +* 16 x 8 Multiply (24 bit result) + +* OTHER MODULES NEEDED: none + +* ENTRY: A = multiplier +* X = multiplicand + +* EXIT: A = product byte 1 +* X = product bytes 2 & 3 + + nam 16x8 bit Multiply + ttl Assembler Library Module + + + psect MULT168,0,0,0,0,0 + +MULT168: + PSHS A,X save numbers + LEAS -3,S room for product + LDB 5,S get lsb of multiplicand + MUL + STD 1,S save partial product + LDD 3,S get mupltiplier & msb of multp. + MUL + ADDB 1,S add lsb to msb + ADCA #0 add carry + STD 0,S save sum of partial products + LDX 1,S get 2 lsb's + LEAS 6,S clean stack + RTS + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/parsnstr.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,37 @@ +* Parse sign bit terminated string to convert it to a +* null terminated string. Note: if X and Y are the same +* the existing string will be overwritten -- don't do this +* with psects... + +* OTHER MODULES NEEDED: none + +* ENTRY: X=start of sign bit terminated string +* Y=buffer for null terminated string + +* EXIT: D=string size (not including null) +* All other regs (except cc) preserved + + + nam Parse sign-bit terminated string + ttl Assembler Library Module + + + psect PARSNSTR,0,0,0,0,0 + + +PARSNSTR: + pshs x + lbsr STRHCPY copy string + tfr y,x point to moved string + lbsr STRHLEN find length of string + pshs d size + leax d,x + lda ,-x get final byte + anda #%01111111 clear sign bit + clrb add null terminator + std ,x + puls d,x,pc + + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/print_asc.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,26 @@ +*************************************** + +* Print binary number to standard out. + +* ENTRY: D=value to print + +* EXIT: CC carry set if error (from I$WritLn) +* B error code, if any + + nam Print # as ASCII String to Std. Out + ttl Assembler Library Module + + + psect PRINT_ASC,0,0,0,0,0 + +PRINT_ASC: + pshs a,x + leas -18,s buffer + tfr s,x + lbsr BIN_ASC convert to ascii + lbsr PUTS print to standard out + leas 18,s clean stack + puls a,x,pc return with error in B + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/print_dec.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,27 @@ +*************************************** + +* Print decimal number to standard out. + +* ENTRY: D=value to print + +* EXIT: CC carry set if error (from I$WritLn) +* B error code, if any + + + nam Print # as Decimal String to Std Out + ttl Assembler Library Module + + + psect PRINT_DEC,0,0,0,0,0 + +PRINT_DEC: + pshs a,x + leas -8,s buffer + tfr s,x + lbsr BIN_DEC convert to decimal + lbsr PUTS print to standard out + leas 8,s clean stack + puls a,x,pc return with error in B + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/print_hex.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,27 @@ +*************************************** + +* Print hex number to standard out. + +* ENTRY: D=value to print + +* EXIT: CC carry set if error (from I$WritLn) +* B error code, if any + + + nam Print # as Hex String to Std Out + ttl Assembler Library Module + + + psect PRINT_HEX,0,0,0,0,0 + +PRINT_HEX: + pshs a,x + leas -6,s buffer + tfr s,x + lbsr BIN_HEX convert to hex + lbsr PUTS print to standard out + leas 6,s clean stack + puls a,x,pc return with error in B + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/prints.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,40 @@ +*********************************** + +* Print a program-embedded, null terminated string to standard out. + +* OTHER MODULES NEEDED: puts + +* ENTRY: Null terminated string must follow PRINTS call +* eg: LBSR PRINTS +* fcc /this is stuff to print/ +* fcb $0d * a new line +* fcc /more stuff to print/ +* fcb $0d,0 the end +* lda #xx or whatever.. +* * the rest of the program.... + +* EXIT: CC carry set if error +* B error code (if any) + + + nam Print Embedded String to Std. Out + ttl Assembler Library Module + + + psect PRINTS,0,0,0,0,0 + +PRINTS: + pshs x,u + ldx 4,s get start of string (old return address) + tfr x,u copy it + +loop + tst ,u+ advance U to end of string + bne loop + + stu 4,s one past null=return address + lbsr PUTS print from orig pos. + puls x,u,pc return to caller + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/ptsearch.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,90 @@ +*************************************** + +* Pattern Search + +* OTHER MODULES REQUIRED: COMPARE + +* ENTRY: X=start of memory to search +* U=end of memory +* Y=start of pattern +* D=size of pattern +* CASEMTCH (a global variable in COMPARE) =0 if A<>a, -1 if A=a + +* EXIT: X=address of match if found, unchanged if no match +* CC zero set if match, clear for no-match +* A,B,U,Y preserved + + + nam Pattern Search + ttl Assembler Library Module + + + psect PTSEARCH,0,0,0,0,0 + +* set up stack frame for variables + + csect + +pattend rmb 2 end of pattern in memory +memend rmb 2 realend-pattern size +patsize rmb 2 saved <D> +memstrt rmb 2 saved <X> +patstrt rmb 2 saved <Y> +realend rmb 2 saved <U> + + endsect + +PTSEARCH: + pshs d,x,y,u + leas -4,s room for temps + tfr u,d end of memory to check + subd patsize,s end-pattern size + std memend,s where we stop looking + ldd patstrt,s + addd patsize,s + std pattend,s + +* loop here looking for a match of the first characters + +inmatch + cmpx memend,s raeched end of memory + bhs nomatch + lda ,x+ get char from memory + ldb ,y compare to pattern + lbsr COMPARE compare them + bne inmatch keep looking for inital match + +* see if rest of pattern matches + +more + tfr x,u save pointer + leay 1,y already matched that one + +more1 + cmpy pattend,s all chars matched, go home happy + beq match + lda ,x+ + ldb ,y+ + lbsr COMPARE + beq more1 keep matching + tfr u,x match fails, backup and do more + ldy patstrt,s start of pattern + bra inmatch + + +nomatch + lda #1 clear zero + bra exit + +match + leau -1,u start of match + stu memstrt,s where pattern starts + clra set zero flag=found + +exit + leas 4,s clean stack + puls d,x,y,u,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/putc.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,25 @@ +********************************** + +* Put single character to standard out. + +* OTHER MODULES NEEDED: FPUTC + +* ENTRY: B=character to print + +* EXIT: CC carry set if error +* B=error code if any + + nam Print Char to Std. Out + ttl Assembler Library Module + + + psect PUTC,0,0,0,0,0 + +PUTC: + pshs a + lda #1 stn out + bsr FPUTC + puls a,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/putcr.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,25 @@ +**************************************** + +* Subroutine to print a carriage return to std. out. + +* OTHER MODULES REQUIRED: FPUTCR + +* ENTRY: none + +* EXIT: CC carry set if error (from I$WritLn) +* B error code if any. + + + nam Output Carriage Return to Std. Out + ttl Assembler Library Module + + + psect PUTCR,0,0,0,0,0 + +PUTCR: + pshs a + lda #1 std out + lbsr FPUTCR + puls a,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/puts.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,26 @@ +*********************************** + +* Print a null terminated string to standard out. + +* OTHER MODULES NEEDED: fputs + +* ENTRY: X=string to print + +* EXIT: CC carry set if error +* B error code (if any) + + + nam Print String to Std. Out + ttl Assembler Library Module + + + psect PUTS,0,0,0,0,0 + +PUTS: + pshs a + lda #1 std out + lbsr FPUTS + puls a,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/putspace.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,24 @@ +**************************************** + +* Subroutine to print a space to std. out + +* OTHER MODULES REQUIRED: FPUTSPACE + +* ENTRY: none + +* EXIT: CC carry set if error (from I$WritLn) +* B error code if any. + + nam Output One Space Char. to Std. Out + ttl Assembler Library Module + + + psect PUTSPACE,0,0,0,0,0 + +PUTSPACE: + pshs a + lda #1 + lbsr FPUTSPACE + puls a,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/puty.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,24 @@ +********************************** + +* Put the word in Y to std out + +* OTHER MODULES NEEDED: FPUTY + +* ENTRY: Y=value to save + +* EXIT: CC carry set if error +* B=error code if any + + nam Save word to std out + ttl Assembler Library Module + + + psect PUTY,0,0,0,0,0 + +PUTY: + pshs a + lda #1 stn out + bsr FPUTY + puls a,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/rnd.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,85 @@ +*************************************** + +* Subroutine to calc. a random number +* Based on routine by L.A. Middaugh +* The Rainbow Jan/85 p. 277 + +* Value truncated so that it is =>0 and <=passed value in D. + +* OTHER MODULES NEEDED: none + +* ENTRY: D=max value of number to be returned +* EXIT: D = value + + + nam Rnd + ttl Assembler Library Module + + + psect Rnd,0,0,0,0,0 + + vsect dp + +SEED rmb 4 + + endsect + +RND: + pshs d,x,u + +rnd0 + ldx #SEED point to seed + ldb #8 number of shifts +loop + lda 3,x exclusive or bit 28 with 31 + rora + rora + rora + eora 3,x + rora result in carry + rora + ror 0,x rotate carry into bit0 + ror 1,x + ror 2,x + ror 3,x + decb do 8 times + bne loop + ldd 1,x get rnd value + bne trunc ensure we never return a 0 + inc 1,x fudge it so we get a non-zero + inc 3,x + bra rnd0 + +trunc + cmpd ,s in range specified? + bls exit yes + subd ,s + bra trunc + +exit + leas 2,s forget original D + puls x,u,pc + + +********************************************** +* +* Subroutine to seed the random number buffer +* with the current system date + +* ENTRY: none +* EXIT: none + +SEEDRND: + pshs d,x + leas -6,s make room for date + tfr s,x point X to buffer + os9 F$Time + addd 4,x add min/secs to value in D + addd <SEED add to orig value + std <SEED set msb of seed + addd <SEED+2 add lsb of seed to new msb + std <SEED+2 + leas 6,s + puls d,x,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/sho_regs.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,103 @@ +************************************ + +* Display the 6809 registers to standard error + +* OTHER MODULES NEEDED: BIN2HEX, BIN_HEX, PUTS + + +* ENTRY: none +* EXIT: none + + +* NOTE: The value used for PC is that of the calling routine +* S is assumed to be 2 greater than actual to comp for +* the subroutine call... + + + nam Show Register Values + ttl Assembler Library Module + + + psect SHO_REGS,0,0,0,0,0 + + csect + +count rmb 1 counter for 9 regs. +buffer rmb 8 buffer for ascii strings +cc.r rmb 1 offsets to access values +a.r rmb 1 +b.r rmb 1 +dp.r rmb 1 +x.r rmb 2 +y.r rmb 2 +u.r rmb 2 +s.r rmb 2 +pc.r rmb 2 + + endsect + +SHO_REGS: + leas -2,s room for copy of <S> + pshs cc,a,b,dp,x,y,u save rest + leas -cc.r,s room for ascii strings + tfr s,x + leax pc.r,x get old <S> + stx s.r,s stick on stack + leay cc.r,s point to regs + leau text,pcr register names + clr count,s int. counter + +* now we loop and display all the registers + +loop1 + leax buffer,s point to ascii buffer + ldd ,u++ get reg. name + std ,x++ + lda #'= add a "=" + sta ,x+ + lda count,s 1st 4 are 1 byte + cmpa #4 + bhs loop2 no, do a 2byte + ldb ,y+ get single value + lbsr BIN2HEX + std ,x save ascii number + clr 2,x + bra report go report +loop2 + cmpa #9 done all? + bhs exit yes, go home + ldd ,y++ get reg value + lbsr BIN_HEX convert it + +* report reg. value + +report + leax buffer,s start of buffer + lda #2 std err + lbsr FPUTS print it + ldb #$20 space + lbsr FPUTC + inc count,s do next reg + bra loop1 + +exit + ldb #$0d + lda #2 + lbsr FPUTC start new line + leas cc.r,s clear up stack + puls cc,a,b,dp,x,y,u + leas 2,s + rts go home + +text + fcc /cc/ + fcc / a/ + fcc / b/ + fcc /dp/ + fcc / x/ + fcc / y/ + fcc / u/ + fcc / s/ + fcc /pc/ + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/stimestr.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,29 @@ +***************************************** + +* Get current system time as an ascii string. + + +* OTHER MODULES NEEDED: DATESTR + +* ENTRY: X=buffer for ascii + +* EXIT: all registers preserved (except cc) + + nam Get System Time String + ttl Assembler Library Module + + + psect STIMESTR,0,0,0,0,0 + +STIMESTR: + pshs x,y + tfr x,y ascii buffer to Y + leas -7,s buffer for time packet + tfr s,x + os9 F$Time get system time + lbsr DATESTR convert to ascii in Y buffer + leas 7,s + puls x,y,pc + + endsect +t \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strcat.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,31 @@ +********************************** + +* STRCAT: append 2 null terminated strings +* User must ensure there is room in buffer!!! + +* OTHER MODULES NEEDED: STRCPY, STRLEN + +* ENTRY: X=start of string to move +* Y=start of string to append to + +* EXIT: all regs preserved (except cc) + + + nam Append 2 null terminated strings + ttl Assembler Library Module + + + psect STRCAT,0,0,0,0,0 + +STRCAT: + pshs d,x,y + exg x,y + lbsr STRLEN find end of appended string + leax d,x point to end of "buffer" + exg x,y + lbsr STRCPY copy string + puls d,x,y,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strcmp.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,43 @@ +************************************** + +* STRCMP: compare two null terminated strings. + +* NOTE: This routine first finds the length of both +* strings and passes the length of the longer +* one to strncmp. + +* OTHER MODULES NEEDED: STRNCMP, STRLEN + + +* ENTRY: X=start of 1st string +* Y=start of 2nd string + +* EXIT: CC zero set if equal (beq) +* carry + zero clear if 1>2 (bhi) +* carry set if 1<2 (blo) + + + nam Compare Strings + ttl Assembler Library Module + + + psect STRCMP,0,0,0,0,0 + +STRCMP: + pshs d + lbsr STRLEN find len of str1 + pshs d + exg y,x find len of str2 + lbsr STRLEN + exg y,x restore ptrs + cmpd ,s + bhi ok + ldd ,s get bigger value + +ok + leas 2,s clean stack + lbsr STRNCMP go compare + puls d,pc go home + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strcpy.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,28 @@ +********************************** + +* STRCPY: copy a null terminated string +* User must ensure there is room in buffer!!! + +* OTHER MODULES NEEDED: STRNCPY + +* ENTRY: X=start of string to move +* Y=buffer for copy of string + +* EXIT: all regs preserved (except cc) + + + nam Copy Null Term. String + ttl Assembler Library Module + + + psect STRCPY,0,0,0,0,0 + +STRCPY: + pshs d + ldd #$ffff pass very long value to STRNCPY + lbsr STRNCPY move it + puls d,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strhcpy.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,32 @@ +********************************** + +* STRHCPY: copy sign-bit terminated string +* User must ensure there is room in buffer!!! +* See also PARSNSTR, this routine does not change +* sign-bit termination. + +* OTHER MODULES NEEDED: strhlen,memmove + + +* ENTRY: X=start of string to move +* Y=buffer for copy of string + + +* EXIT: all regs preserved (except cc) + + + nam Copy sign-bit terminated String + ttl Assembler Library Module + + + psect STRHCPY,0,0,0,0,0 + +STRHCPY: + pshs d + lbsr STRHLEN find length of string + lbsr MEMMOVE move it + puls d,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strhlen.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,36 @@ +********************************** + +* String Length: find length of sign-bit terminated string. +* note: sign-bit set byte IS included in count. + +* OTHER MODULES NEEDED: none + + +* ENTRY: X=start of string + + +* EXIT: D=length +* all other regs (except cc) preserved + + + nam Find sign-bit term. String Length + ttl Assembler Library Module + + + psect STRHLEN,0,0,0,0,0 + +STRHLEN: + pshs x + clra it'll be at least one byte long + clrb + +loop + addd #1 bump count + tst ,x+ end? + bpl loop + + puls x,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strlen.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,30 @@ +********************************** + +* String Length: find length of null terminated string. +* note:null NOT included in count. + +* ENTRY: X=start of string + +* EXIT: D=length +* all other regs (except cc) preserved + + nam Find String Length + ttl Assembler Library Module + + + psect STRLEN,0,0,0,0,0 + +STRLEN: + pshs x + ldd #-1 comp for inital inc + +loop + addd #1 bump count + tst ,x+ end? + bne loop + + puls x,pc + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strncmp.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,47 @@ +************************************* + +* STRNCMP: compare 2 null terminated strings +* maximum number of bytes to compare in D +* +* OTHER MODULES NEEDED: COMPARE + +* ENTRY: X=start of 1st string +* Y=start of 2nd string +* D=number of bytes to compare +* CASEMTCH:(a global variable in COMPARE) +* 0=match for case +* -1=ignore case differences + +* EXIT: CC zero set if equal (beq) +* carry + zero clear if 1>2 (bhi) +* carry set if 1<2 (blo) + + nam Compare 2 Strings + ttl Assembler Library Module + + + psect STRNCMP,0,0,0,0,0 + + +STRNCMP: + pshs d,x,y,u + + tfr y,u U=string2 + tfr d,y use Y for counter + leay 1,y comp for initial dec. + +loop + leay -1,y count down + beq exit no miss-matches + lda ,x+ get 2 to compare + ldb ,u+ + lbsr COMPARE go compare chars. + beq loop chars match, do more + +* exit with flags set. Do a beq, bhi or blo to correct +* routines.... + +exit + puls d,x,y,u,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/strncpy.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,36 @@ +********************************** + +* STRNCPY: copy N bytes of a null terminated string +* User must ensure there is room in buffer!!! +* If N>string length only N bytes will be moved + +* OTHER MODULES NEEDED: STRLEN, MEMMOVE + +* ENTRY: X=start of string to move +* Y=buffer for copy of string + +* EXIT: D = actual number of bytes moved +* all other regs preserved (except cc) + + + nam Copy partial String + ttl Assembler Library Module + + + psect STRNCPY,0,0,0,0,0 + +STRNCPY: + pshs d bytes wanted to move + lbsr STRLEN find length of string + addd #1 move NULL also + cmpd ,s get smaller of passed/actual size + bls skip use actual leng + ldd ,s use passed leng²² +skip + lbsr MEMMOVE move it + leas 2,s + rts + + endsect + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/to_lower.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,30 @@ +*************************************************** + +* Convert character in "B" to lowercase + +* OTHER MODULES NEEDED: IS_UPPER + +* ENTRY: B=ascii value of character to convert + +* EXIT: B=ascii value of character in lowercase + +* Note: control codes, etc. are not effected. + + + nam Convert Char to Lowercase + ttl Assembler Library Module + + + psect TO_LOWER,0,0,0,0,0 + +TO_LOWER: + pshs cc + lbsr IS_UPPER only uppercase can be converted + bne tolox no upper, exit + addb #$20 make lowercase + +tolox + puls cc,pc + + endsect + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/to_lowrs.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,30 @@ +******************************* + +* convert a null terminated string to all lowercase + +* OTHER MODULES NEEDED: TO_LOWER + +* ENTRY: X=start of string + +* EXIT: all registers preserved + + nam Convert String to Lowercase + ttl Assembler Library Module + + psect TO_LOWRS,0,0,0,0,0 + +TO_LOWRS: + pshs cc,b,x + +loop + ldb ,x get char to check + beq exit exit if all done + bsr TO_LOWER convert to upper + stb ,x+ put back in string + bra loop loop till done + +exit + puls cc,b,x,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/to_non_sp.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,25 @@ +********************************** + +* Advance X to 1st non-space character + +* OTHER MODULES NEEDED: none + +* ENTRY: X=somewhere in a string + +* EXIT: X=1st non-space character in string +* B=char at X + + + nam Advance to non-space + ttl Assembler Library Module + + psect TO_NON_SP,0,0,0,0,0 + +TO_NON_SP: + ldb ,x+ + cmpb #$20 is it space? + beq TO_NON_SP yes, loop + leax -1,x point to non-space + rts + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/to_sp.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,26 @@ +********************************** + +* Advance X to 1st space character + +* OTHER MODULES NEEDED: none + +* ENTRY: X=somewhere in a string + +* EXIT: X=1st space character in string + + + nam Advance to space + ttl Assembler Library Module + + psect TO_SP,0,0,0,0,0 + +TO_SP: + pshs b +spl + ldb ,x+ + cmpb #$20 is it space? + bne spl no, loop + leax -1,x point to space + puls b,pc + + endsect
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/to_upper.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,30 @@ +*************************************************** + +* Convert character in "B" to uppercase + +* OTHER MODULES NEEDED: IS_LOWER + +* ENTRY: B=ascii value of character to convert + +* EXIT: B=ascii value of character in uppercase + +* Note: control codes, etc. are not effected. + + + nam Convert Char to Uppercase + ttl Assembler Library Module + + + psect TO_UPPER,0,0,0,0,0 + +TO_UPPER: + pshs cc + lbsr IS_LOWER only lowercase can be converted to upper + bne toupx + subb #$20 make uppercase + +toupx + puls cc,pc + + endsect + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/to_upprs.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,32 @@ +******************************* + +* convert a null terminated string to all uppercase + +* OTHER MODULES NEEDED: TO_UPPER + +* ENTRY: X=start of string + +* EXIT: all registers (except CC) preserved + + + nam Convert String to Uppercase + ttl Assembler Library Module + + + psect TO_UPPRS,0,0,0,0,0 + +TO_UPPRS: + pshs cc,b,x + +loop + ldb ,x get char to check + beq exit exit if all done + bsr TO_UPPER convert to upper + stb ,x+ put back in string + bra loop + +exit + puls cc,b,x,pc + + endsect +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/alib/windefs.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,93 @@ +************************************ +* +* This file contains the names for the various window +* commands avail for CoCo3 Level 2 OS9. + +* History: File created 88/04/24 - Bob van der Poel + +* Note that all these constants begin with a "W" + + ttl Window Definitions + + psect Windefs,0,0,0,0,0 + +WBColor: equ $1b33 background color +WBoldSw: equ $1b3d bold switch +WBorder: equ $1b34 border color +WCWArea: equ $1b25 change working area +WDefColr: equ $1b30 set default color +WDfnGPBuf: equ $1b28 define get/put buffer +WDWEnd: equ $1b24 device window end +WDWProtSw: equ $1b36 device window protect +WDWSet: equ $1b20 device window set +WFColor: equ $1b32 foreground color +WFont: equ $1b3a select font +WGCSet: equ $1b39 graphics cursor set +WGetBlk: equ $1b2c get block +WGPLoad: equ $1b2b get/put buffer load +WKilBuf: equ $1b2a kill get/put buffer +WLSet: equ $1b2f logic set +WOWEnd: equ $1b23 overlay window end +WOWSet: equ $1b22 overlay window set +WPalette: equ $1b31 change palette +WPropSw: equ $1b3f proportional switch +WPSet: equ $1b2e Pattern set +WPutBlk: equ $1b2d put block +WScaleSw: equ $1b35 scale switch +WSelect: equ $1b21 select window +WTCharSw: equ $1b3c transparent char switch + +* drawing commands + +WArc3P: equ $1b52 draw arc +WBar: equ $1b4a draw bar +WRBar: equ $1b4b draw bar relative +WBox: equ $1b48 draw box +WRBox: equ $1b49 draw box relative +WCircle: equ $1b50 draw circle +WEllipse: equ $1b51 draw ellipse +WFFill: equ $1b4f flood fill +WLine: equ $1b44 draw line +WRLine: equ $1b45 draw line relative +WLineM: equ $1b46 draw line and move +WRLineM: equ $1b47 draw line relative and move +WPoint: equ $1b42 set point +WRPoint: equ $1b43 set point relative +WPutGC: equ $1b4e put graphics cursor +WSetDPtr: equ $1b40 set draw pointer +WRSetDPtr: equ $1b41 set draw pointer relative + +* Text commands + +* these are one byte codes... + +WHomeCur: equ $01 home cursor +WPosCur: equ $02 position cursor +WErasLn: equ $03 erase line +WErasEOL: equ $04 erase to end of line +WErasEOS: equ $0b erase to end of screen +WErase: equ $0c erase screen and home cursor +WCurR: equ $06 move cursor right one pos +WCurL: equ $08 move cursor left one pos +WCurUp: equ $09 move cursor up one line +WCurDn: equ $0a move cursor down one line +WBell: equ $07 rings terminal bell +WCr: equ $0d sends a carriage return + +* two byte codes... + +WCurOff: equ $0520 turn off cursor +WCurOn: equ $0521 turn on cursor +WRvOn: equ $1f20 reverse video on +WRvOff: equ $1f21 reverse video off +WUlOn: equ $1f22 underlining on +WUlOff: equ $1f23 underlineing off +WBlnkOn: equ $1f24 blinking on +WBlnkOff: equ $1f25 blinking off +WInsLn: equ $1f30 insert line at cursor +WDelLn: equ $1f31 delete current line + + + endsect + +
--- a/lib/makefile Wed Mar 17 13:17:38 2010 +0000 +++ b/lib/makefile Tue Mar 30 02:44:42 2010 +0000 @@ -1,6 +1,6 @@ include $(NITROS9DIR)/rules.mak -all: sys6809l1.l sys6809l2.l sys6309l2.l +all: sys6809l1.l sys6809l2.l sys6309l2.l net.l alib.l sys6809l1.l: sys6809l1.a @@ -8,5 +8,11 @@ sys6309l2.l: sys6309l2.a +net.l: net.a + +alib.l: + cd alib; make; cp alib.l .. + clean: $(RM) *.l *.r + $(RM) alib/*.r
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/net.a Tue Mar 30 02:44:42 2010 +0000 @@ -0,0 +1,226 @@ +******************************************************************** +* net - network routines +* +* $Id$ +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 1 2010/01/08 Boisy G. Pitre +* Started. + + nam net.a + ttl network routines + + psect net_a,0,0,0,0,0 + + vsect +nbufferl equ 128 +nbuffer rmb nbufferl + endsect + +space fcb C$SPAC + +devnam fcs "/N" + + +getopts leax nbuffer,u + ldb #SS.Opt + os9 I$GetStt + rts + +setopts leax nbuffer,u + ldb #SS.Opt + os9 I$SetStt + rts + +* Set Echo +* +* Entry: A = path to network device +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +SetEcho: pshs a,x + bsr getopts + bcs rawex + ldb #1 + stb PD.EKO-PD.OPT,x + bsr setopts + puls a,x,pc + + +* Set Auto Linefeed +* +* Entry: A = path to network device +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +SetAutoLF: pshs a,x + bsr getopts + bcs rawex + ldb #1 + stb PD.ALF-PD.OPT,x + bsr setopts + puls a,x,pc + + +* Put the path passed in A in raw mode +* +* Entry: A = path to network device +* +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +RawPath: pshs a,x + bsr getopts + bcs rawex + leax PD.UPC-PD.OPT,x + ldb #PD.QUT-PD.UPC +rawloop clr ,x+ + decb + bpl rawloop + bsr setopts +rawex puls a,x,pc + + +* Attempts to open and setup a path to the TCP server +* +* Exit: +* Success: A = path to network device, CC carry clear +* Failure: B = error code, CC carry set +TCPOpen: pshs x,y + lda #UPDAT. + leax devnam,pcr + os9 I$Open + puls x,y,pc + + +* Informs the server that we are killing a session +* +* Entry: A = path to network device +* Y = pointer to token string (nul terminated) +* +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +TCPKill: pshs a,x,y + leax tcpkill,pcr + ldy #tcpkilll + os9 I$Write + lbcs connectex + bra writeport + +* Informs the server that we are joining a session +* +* Entry: A = path to network device +* Y = pointer to token string (nul terminated) +* +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +TCPJoin: pshs a,x,y + leax tcpjoin,pcr + ldy #tcpjoinl + os9 I$Write + lbcs connectex + bra writeport + +* Attempts to connect to a TCP/IP host via the server +* +* Entry: A = path to network device +* X = pointer to host name string (nul terminated) +* Y = pointer to port string (nul terminated) +* +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +TCPConnectToHost: + pshs a,x,y + leax tcpconnect,pcr + ldy #tcpconnectl + os9 I$Write + bcs connectex + ldx 1,s + lbsr STRLEN + tfr d,y + lda ,s + os9 I$Write +* write space + leax space,pcr + ldy #1 + os9 I$Write +* write port (we worry about response later) +writeport ldx 3,s get original Y on stack + pshs a + lbsr STRLEN + tfr d,y + puls a + os9 I$Write + leax acr,pcr + ldy #1 + os9 I$WritLn + +* read response from server +* Entry: A = path +readresponse + leax nbuffer,u + ldy #nbufferl + os9 I$ReadLn + bcs connectex + lda ,x + cmpa #'F + bne connectex +* failure case: read number and return it with carry set + leax 5,x skip over "FAIL " + lbsr DEC_BIN error will fit in B + coma set carry +connectex puls a,x,y,pc + +acr fcb C$CR + +* Requests to listen on a port +* +* Entry: A = path to network device +* X = pointer to parameter string (nul terminated) +* +* Exit: +* Success: CC carry clear +* Failure: CC carry set, B = error code +TCPListen: pshs a,x,y + leax tcplisten,pcr + ldy #tcplistenl + os9 I$Write + bcs connectex + ldx 1,s + lbsr STRLEN + tfr d,y + lda ,s + os9 I$Write + leax acr,pcr + ldy #1 + os9 I$WritLn + bra readresponse + +* Disconnects the TCP/IP host via the server +* +* Entry: A = path to network device +* +* Exit: +* Success: CC carry clear +* Failure: B = error code, CC carry set +TCPDisconnect: os9 I$Close + rts + +tcpconnect fcc 'tcp connect ' +tcpconnectl equ *-tcpconnect + +tcplisten fcc 'tcp listen ' +tcplistenl equ *-tcplisten + +tcpjoin fcc 'tcp join ' +tcpjoinl equ *-tcpjoin + +tcpkill fcc 'tcp kill ' +tcpkilll equ *-tcpkill + + endsect