From 97c3ecad7369759ea39edfcc84665e5c5d3b4b8e Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 18 Feb 2020 23:29:40 -0600 Subject: [PATCH] ORCALib changes for GNO. This is a reconstruction of the ORCALib source changes for the version of ORCALib distributed with GNO 2.0.6. The library built with this code should be identical to the original GNO one, apart from insignificant junk bytes at the ends of segments and the build date in the resource fork. --- Makefile | 17 ++++++++ assert.asm | 2 +- cc.asm | 21 ++++++---- ctype.asm | 35 ++++++++++++++-- equates.asm | 1 + liborca.rez | 20 +++++++++ signal2.c | 10 +++++ string.asm | 28 ------------- vars.asm | 118 +--------------------------------------------------- 9 files changed, 94 insertions(+), 158 deletions(-) create mode 100644 Makefile create mode 100644 liborca.rez create mode 100644 signal2.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4ea57e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +# +# Makefile for GNO version of ORCALib +# +# To use this, you need a GNO system with the GNO source code in /src. +# +# This currently builds the library as "liborca". +# You will have to manually copy it to /lib/ORCALib. +# +# The assert.o file is not included in ORCALib but is used in libc. + +LIB = orca +SRCS = cc.asm ctype.asm orca.asm signal2.c stdlib.asm string.asm \ + time.asm toolglue.asm vars.asm + +buildall .PHONY: build assert.o + +.INCLUDE: /src/gno/lib/lib.mk diff --git a/assert.asm b/assert.asm index 454def3..529a9bf 100644 --- a/assert.asm +++ b/assert.asm @@ -38,7 +38,7 @@ __assert start ph2 l ph4 f ph4 #msg - ph4 >stderr + ph4 >__assertfp jsl fprintf jsl abort diff --git a/cc.asm b/cc.asm index 907e1db..5d200d2 100644 --- a/cc.asm +++ b/cc.asm @@ -184,9 +184,6 @@ TAB equ 9 TAB key code stz ~ExitList no exit routines, yet stz ~ExitList+2 - case on - jsl ~InitIO reset standard I/O - case off lda cLine if cLine == 0 then ora cLine+2 @@ -401,13 +398,19 @@ lb2 ldy #2 dereference the pointer ; Close (and flush) any open files ; case on -lb3 lda >stderr+6 while there is a next file - ora >stderr+4 +lb3 lda >__cleanup+2 + ora >__cleanup beq lb4 - ph4 >stderr+4 close it - dc h'22' (jsl fclose, soft reference) - dc s3'fclose' - bra lb3 + phk + pea lb4-1 + short I,M + lda >__cleanup+2 + pha + long I,M + lda >__cleanup + dec A + pha + rtl case off ; ; return diff --git a/ctype.asm b/ctype.asm index a3d1365..5cdce57 100644 --- a/ctype.asm +++ b/ctype.asm @@ -103,7 +103,7 @@ yes lda #1 **************************************************************** * -* int isctrl (int c) +* int isblank (int c) * * Inputs: * 4,S - digit to test @@ -113,7 +113,34 @@ yes lda #1 * **************************************************************** * -isctrl start +isblank start + + lda 4,S fetch the operand + tax + lda 2,S remove parm from stack + sta 4,S + pla + sta 1,S + inx form the result + lda >__ctype2,X + and #_blank + rtl + end + +**************************************************************** +* +* int iscntrl (int c) +* +* Inputs: +* 4,S - digit to test +* +* Outputs: +* A - result +* +**************************************************************** +* +iscntrl start +isctrl entry lda 4,S fetch the operand tax @@ -840,7 +867,7 @@ __ctype2 start dc i1'0' $06 dc i1'0' $07 dc i1'0' $08 - dc i1'0' $09 + dc i1'_blank' $09 dc i1'0' $0A dc i1'0' $0B dc i1'0' $0C @@ -863,7 +890,7 @@ __ctype2 start dc i1'0' $1D dc i1'0' $1E dc i1'0' $1F - dc i1'0' ' ' + dc i1'_blank' ' ' dc i1'0' ! dc i1'0' " dc i1'0' # diff --git a/equates.asm b/equates.asm index 0659d15..7bc865b 100644 --- a/equates.asm +++ b/equates.asm @@ -36,6 +36,7 @@ _print gequ $80 [' '..'~'] _csym gequ $01 ['0'..'9','A'..'Z','a'..'z','_'] _csymf gequ $02 ['A'..'Z','a'..'z'.'_'] _octal gequ $04 ['0'..'7'] +_blank gequ $08 ['\t', ' '] ; ; signal numbers ; diff --git a/liborca.rez b/liborca.rez new file mode 100644 index 0000000..d83f683 --- /dev/null +++ b/liborca.rez @@ -0,0 +1,20 @@ +#include "Types.rez" + +resource rVersion (0x1, purgeable3) { + { + 2,0,6,beta,4 + }, + verUS, + "ORCALib (GNO Version)", + "Byte Works' General Purpose Library.\n" + "This library is only for use with GNO.\n" + "Build Date: " $$DATE +}; + +resource rComment (0x1, purgeable3) { + "ORCALib (GNO Version)\n" + "Byte Works' General Purpose Library.\n" + "This library is only for use with GNO.\n" + "Build Date: " $$DATE +}; + diff --git a/signal2.c b/signal2.c new file mode 100644 index 0000000..d89cc07 --- /dev/null +++ b/signal2.c @@ -0,0 +1,10 @@ +#ifdef __ORCAC__ +segment "libc_sys__"; +#endif + +#include +#include + +int raise(int sig) { + return Kkill(Kgetpid(), sig, &errno); +} diff --git a/string.asm b/string.asm index 397ad05..f7bf717 100644 --- a/string.asm +++ b/string.asm @@ -878,34 +878,6 @@ lb2 sty set set the disp past the current disp rtl end -**************************************************************** -* -* strerror - return the addr of an error message -* -* Inputs: -* err - error number to return the error for -* -**************************************************************** -* -strerror start - - phb get the error number - plx - ply - pla - phy - phx - phk use local data bank - plb - asl A compute the index - asl A - tay - ldx sys_errlist+2,Y load the address - lda sys_errlist,Y - plb restore caller's data bank - rtl - end - **************************************************************** * * strlen - find the length of a string diff --git a/vars.asm b/vars.asm index 4fba53c..4395493 100644 --- a/vars.asm +++ b/vars.asm @@ -30,123 +30,9 @@ errno entry library error number _ownerid entry user ID (C) ~USER_ID entry user ID (Pascal, libraries) ds 2 -sys_nerr entry # of error messages - dc i'6' +__cleanup entry function to clean up files at exit + dc i4'0' _toolErr entry last error in a tool call (C) ~TOOLERROR entry last error in a tool call (Pascal) ds 2 end - -**************************************************************** -* -* ~InitIO - initialize the standad I/O files -* -**************************************************************** -* -~InitIO start - - ldx #24 set up the file records -lb1 lda stderr+34,X - sta stderr+8,X - lda stdin+34,X - sta stdin+8,X - lda stdout+34,X - sta stdout+8,X - dex - dex - bpl lb1 - lla stderr,stderr+4 set up the file pointers - lla stdin,stdin+4 - lla stdout,stdout+4 - rtl - end - -**************************************************************** -* -* stderr - error out file -* -**************************************************************** -* -stderr start - - dc a4'lb1' - -lb1 dc a4'0' next file - dc a4'0' next location to write to - dc a4'0' first byte of buffer - dc a4'0' end of the file buffer - dc i4'0' size of the file buffer - dc i4'0' count - dc i'EOF' putback buffer - dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file - dc i'stderrID' error out - - dc a4'0' next location to write to - dc a4'0' first byte of buffer - dc a4'0' end of the file buffer - dc i4'0' size of the file buffer - dc i4'0' count - dc i'EOF' putback buffer - dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file - dc i'stderrID' error out - end - -**************************************************************** -* -* stdin - standard in file -* -**************************************************************** -* -stdin start - - dc a4'lb1' - -lb1 dc a4'stdout+4' next file - dc a4'0' next location to write to - dc a4'0' first byte of buffer - dc a4'0' end of the file buffer - dc i4'0' size of the file buffer - dc i4'0' count - dc i'EOF' putback buffer - dc i'_IONBF+_IOREAD+_IOTEXT' no buffering; allow reads; text file - dc i'stdinID' standard in - - dc a4'0' next location to write to - dc a4'0' first byte of buffer - dc a4'0' end of the file buffer - dc i4'0' size of the file buffer - dc i4'0' count - dc i'EOF' putback buffer - dc i'_IONBF+_IOREAD+_IOTEXT' no buffering; allow reads; text file - dc i'stdinID' standard in - end - -**************************************************************** -* -* stdout - standard out file -* -**************************************************************** -* -stdout start - - dc a4'lb1' - -lb1 dc a4'stderr+4' next file - dc a4'0' next location to write to - dc a4'0' first byte of buffer - dc a4'0' end of the file buffer - dc i4'0' size of the file buffer - dc i4'0' count - dc i'EOF' putback buffer - dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file - dc i'stdoutID' standard out - - dc a4'0' next location to write to - dc a4'0' first byte of buffer - dc a4'0' end of the file buffer - dc i4'0' size of the file buffer - dc i4'0' count - dc i'EOF' putback buffer - dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file - dc i'stdoutID' standard out - end