1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-11 23:43:19 +00:00

Combine three small arithmetic opcode implementation files into one

Combines arith2.c ... arith4.c files and their associated header files
into new arithops.c/arithopsdefs.h files, and adjusts the CMakeLists.txt,
and old-style makefile-tail.  Also updates  makefile-dos,
inlnPS2.h, and inlndos.h to reflect these changes, though these are not
used.
This commit is contained in:
Nick Briggs 2022-08-10 20:16:59 -07:00
parent 601d6e9142
commit b94cb8809b
13 changed files with 275 additions and 345 deletions

View File

@ -121,9 +121,7 @@ SET(BAD_SRCS
SET(MAIKO_SRCS
src/allocmds.c
src/arith2.c
src/arith3.c
src/arith4.c
src/arithops.c
src/arrayops.c
src/asmbbt.c
src/bbtsub.c
@ -218,9 +216,7 @@ SET(MAIKO_HDRS
inc/address.h
inc/adr68k.h
inc/allocmdsdefs.h
inc/arith2defs.h
inc/arith3defs.h
inc/arith4defs.h
inc/arithopsdefs.h
inc/arith.h
inc/arrayopsdefs.h
inc/array.h

View File

@ -13,12 +13,12 @@ LDFLAGS = -g graphics.lib binmode.lib mouse.lib
RM = del
SRCFILES = conspage.c gcoflow.c shift.c dbgtool.c gcr.c gcrcell.c llstk.c gcscan.c loopsops.c storage.c allocmds.c dir.c gvar2.c lowlev1.c subr.c arith2.c lowlev2.c subr0374.c arith3.c doscomm.c hardrtn.c lsthandl.c sxhash.c arith4.c draw.c main.c testtool.c array.c dsk.c inet.c misc7.c timer.c array2.c dspif.c initdsp.c miscn.c typeof.c array3.c initkbd.c ubf1.c array4.c dspsubrs.c initsout.c mkatom.c ubf2.c array5.c eqf.c intcall.c mkcell.c ubf3.c array6.c ether.c mkvdate.c ufn.c atom.c findkey.c kbdsubrs.c mouseif.c ufs.c bbtsub.c foreign.c keyevent.c unixcomm.c bin.c fp.c binds.c asmbbt.c fvar.c mvs.c unwind.c bitblt.c gc.c uraid.c blt.c gc2.c kprint.c osmsg.c usrsubr.c byteswap.c gcarray.c perrno.c ldeboot.c ldeether.c uutils.c carcdr.c gccode.c rawcolor.c vars3.c gcfinal.c ldsout.c return.c vmemsave.c chardev.c gchtfind.c lineblt8.c rpc.c xc.c common.c gcmain3.c lisp2c.c rplcons.c z2.c xmkicon.c xbbt.c xinit.c xscroll.c xcursor.c xlspwin.c xrdopt.c xwinman.c dosmouse.c vesafns.asm vesainit.c vgainit.c kbdif.c dspsparc.il copyright launch.asm lpread.c lpsolve.c lpmain.c lpwrite.c lpdual.c lptran.c
SRCFILES = conspage.c gcoflow.c shift.c dbgtool.c gcr.c gcrcell.c llstk.c gcscan.c loopsops.c storage.c allocmds.c dir.c gvar2.c lowlev1.c subr.c arithops.c lowlev2.c subr0374.c doscomm.c hardrtn.c lsthandl.c sxhash.c draw.c main.c testtool.c array.c dsk.c inet.c misc7.c timer.c array2.c dspif.c initdsp.c miscn.c typeof.c array3.c initkbd.c ubf1.c array4.c dspsubrs.c initsout.c mkatom.c ubf2.c array5.c eqf.c intcall.c mkcell.c ubf3.c array6.c ether.c mkvdate.c ufn.c atom.c findkey.c kbdsubrs.c mouseif.c ufs.c bbtsub.c foreign.c keyevent.c unixcomm.c bin.c fp.c binds.c asmbbt.c fvar.c mvs.c unwind.c bitblt.c gc.c uraid.c blt.c gc2.c kprint.c osmsg.c usrsubr.c byteswap.c gcarray.c perrno.c ldeboot.c ldeether.c uutils.c carcdr.c gccode.c rawcolor.c vars3.c gcfinal.c ldsout.c return.c vmemsave.c chardev.c gchtfind.c lineblt8.c rpc.c xc.c common.c gcmain3.c lisp2c.c rplcons.c z2.c xmkicon.c xbbt.c xinit.c xscroll.c xcursor.c xlspwin.c xrdopt.c xwinman.c dosmouse.c vesafns.asm vesainit.c vgainit.c kbdif.c dspsparc.il copyright launch.asm lpread.c lpsolve.c lpmain.c lpwrite.c lpdual.c lptran.c
OFILES = conspage.obj gcoflow.obj shift.obj dbgtool.obj gcr.obj gcrcell.obj llstk.obj gcscan.obj loopsops.obj storage.obj allocmds.obj dir.obj gvar2.obj lowlev1.obj subr.obj arith2.obj lowlev2.obj subr0374.obj arith3.obj doscomm.obj hardrtn.obj lsthandl.obj sxhash.obj arith4.obj draw.obj main.obj testtool.obj array.obj dsk.obj inet.obj misc7.obj timer.obj array2.obj dspif.obj initdsp.obj miscn.obj typeof.obj array3.obj initkbd.obj ubf1.obj array4.obj dspsubrs.obj initsout.obj mkatom.obj ubf2.obj array5.obj eqf.obj intcall.obj mkcell.obj ubf3.obj array6.obj ether.obj ufn.obj atom.obj findkey.obj kbdsubrs.obj mouseif.obj ufs.obj bbtsub.obj foreign.obj keyevent.obj unixcomm.obj bin.obj fp.obj binds.obj fvar.obj mvs.obj unwind.obj bitblt.obj gc.obj uraid.obj blt.obj gc2.obj kprint.obj osmsg.obj usrsubr.obj byteswap.obj gcarray.obj perrno.obj uutils.obj carcdr.obj asmbbt.obj gccode.obj vars3.obj gcfinal.obj ldsout.obj return.obj vmemsave.obj chardev.obj gchtfind.obj lineblt8.obj rpc.obj xc.obj common.obj gcmain3.obj lisp2c.obj rplcons.obj z2.obj vdate.obj $(COLORFILES) $(ARCHFILES) $(LPFILES)
OFILES = conspage.obj gcoflow.obj shift.obj dbgtool.obj gcr.obj gcrcell.obj llstk.obj gcscan.obj loopsops.obj storage.obj allocmds.obj dir.obj gvar2.obj lowlev1.obj subr.obj arithops.obj lowlev2.obj subr0374.obj doscomm.obj hardrtn.obj lsthandl.obj sxhash.obj draw.obj main.obj testtool.obj array.obj dsk.obj inet.obj misc7.obj timer.obj array2.obj dspif.obj initdsp.obj miscn.obj typeof.obj array3.obj initkbd.obj ubf1.obj array4.obj dspsubrs.obj initsout.obj mkatom.obj ubf2.obj array5.obj eqf.obj intcall.obj mkcell.obj ubf3.obj array6.obj ether.obj ufn.obj atom.obj findkey.obj kbdsubrs.obj mouseif.obj ufs.obj bbtsub.obj foreign.obj keyevent.obj unixcomm.obj bin.obj fp.obj binds.obj fvar.obj mvs.obj unwind.obj bitblt.obj gc.obj uraid.obj blt.obj gc2.obj kprint.obj osmsg.obj usrsubr.obj byteswap.obj gcarray.obj perrno.obj uutils.obj carcdr.obj asmbbt.obj gccode.obj vars3.obj gcfinal.obj ldsout.obj return.obj vmemsave.obj chardev.obj gchtfind.obj lineblt8.obj rpc.obj xc.obj common.obj gcmain3.obj lisp2c.obj rplcons.obj z2.obj vdate.obj $(COLORFILES) $(ARCHFILES) $(LPFILES)
HFILES = address.h adr68k.h arith.h cell.h dbprint.h display.h dspif.h ifpage.h iopage.h lispemul.h lispmap.h lsptypes.h miscstat.h lspglob.h array.h bb.h bitblt.h debug.h devconf.h dspdata.h ether.h fast_dsp.h gcdata.h hdw_conf.h initatms.h inlinec.h keyboard.h lispver1.h lispver2.h lldsp.h locfile.h medleyfp.h mouseif.h my.h opcodes.h osmsg.h pilotbbt.h print.h return.h stack.h stream.h subrs.h timeout.h tos1defs.h tosfns.h tosret.h vmemsave.h xdefs.h xbitmaps.h xkeymap.h
HFILES = address.h adr68k.h arithopsdefs.h arith.h cell.h dbprint.h display.h dspif.h ifpage.h iopage.h lispemul.h lispmap.h lsptypes.h miscstat.h lspglob.h array.h bb.h bitblt.h debug.h devconf.h dspdata.h ether.h fast_dsp.h gcdata.h hdw_conf.h initatms.h inlinec.h keyboard.h lispver1.h lispver2.h lldsp.h locfile.h medleyfp.h mouseif.h my.h opcodes.h osmsg.h pilotbbt.h print.h return.h stack.h stream.h subrs.h timeout.h tos1defs.h tosfns.h tosret.h vmemsave.h xdefs.h xbitmaps.h xkeymap.h
@ -202,9 +202,9 @@ subr.obj : ../src/subr.c
$(CC) @copts ../src/subr.c -I ../inc -c $@
del copts
arith2.obj : ../src/arith2.c
arithops.obj : ../src/arithops.c
@ echo $(CFLAGS) > copts
$(CC) @copts ../src/arith2.c -I ../inc -c $@
$(CC) @copts ../src/arithops.c -I ../inc -c $@
del copts
lowlev2.obj : ../src/lowlev2.c
@ -217,11 +217,6 @@ subr0374.obj : ../src/subr0374.c
$(CC) @copts ../src/subr0374.c -I ../inc -c $@
del copts
arith3.obj : ../src/arith3.c
@ echo $(CFLAGS) > copts
$(CC) @copts ../src/arith3.c -I ../inc -c $@
del copts
doscomm.obj : ../src/doscomm.c
@ echo $(CFLAGS) > copts
$(CC) @copts ../src/doscomm.c -I ../inc -c $@
@ -242,11 +237,6 @@ sxhash.obj : ../src/sxhash.c
$(CC) @copts ../src/sxhash.c -I ../inc -c $@
del copts
arith4.obj : ../src/arith4.c
@ echo $(CFLAGS) > copts
$(CC) @copts ../src/arith4.c -I ../inc -c $@
del copts
draw.obj : ../src/draw.c
@ echo $(CFLAGS) > copts
$(CC) @copts ../src/draw.c -I ../inc -c $@

View File

@ -38,9 +38,7 @@ REQUIRED-INCS = $(INCDIR)version.h $(INCDIR)maiko/platform.h
CFLAGS = $(OPTFLAGS) $(DFLAGS)
RFLAGS = -c $(CFLAGS) -I$(INCDIR) -I$(INCLUDEDIR)
OFILES = $(OBJECTDIR)arith2.o \
$(OBJECTDIR)arith3.o \
$(OBJECTDIR)arith4.o \
OFILES = $(OBJECTDIR)arithops.o \
$(OBJECTDIR)arrayops.o \
$(OBJECTDIR)bin.o \
$(OBJECTDIR)binds.o \
@ -240,27 +238,21 @@ $(OBJECTDIR)allocmds.o: $(SRCDIR)allocmds.c $(REQUIRED-INCS) \
$(INCDIR)timerdefs.h
$(CC) $(RFLAGS) $(SRCDIR)allocmds.c -o $(OBJECTDIR)allocmds.o
$(OBJECTDIR)arith2.o: $(SRCDIR)arith2.c $(REQUIRED-INCS) \
$(INCDIR)lispemul.h $(INCDIR)lspglob.h \
$(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)miscstat.h $(INCDIR)adr68k.h \
$(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)medleyfp.h $(INCDIR)arith.h \
$(INCDIR)arith2defs.h $(INCDIR)fpdefs.h $(INCDIR)mkcelldefs.h
$(CC) $(RFLAGS) $(SRCDIR)arith2.c -o $(OBJECTDIR)arith2.o
$(OBJECTDIR)arith3.o: $(SRCDIR)arith3.c $(REQUIRED-INCS) \
$(INCDIR)lispemul.h $(INCDIR)lispmap.h \
$(INCDIR)lspglob.h $(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)miscstat.h \
$(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)cell.h \
$(INCDIR)arith.h $(INCDIR)arith3defs.h $(INCDIR)mkcelldefs.h
$(CC) $(RFLAGS) $(SRCDIR)arith3.c -o $(OBJECTDIR)arith3.o
$(OBJECTDIR)arith4.o: $(SRCDIR)arith4.c $(REQUIRED-INCS) \
$(INCDIR)lispemul.h $(INCDIR)lispmap.h \
$(INCDIR)lspglob.h $(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)miscstat.h \
$(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)cell.h \
$(INCDIR)medleyfp.h $(INCDIR)arith.h $(INCDIR)arith4defs.h $(INCDIR)fpdefs.h \
$(INCDIR)mkcelldefs.h
$(CC) $(RFLAGS) $(SRCDIR)arith4.c -o $(OBJECTDIR)arith4.o
$(OBJECTDIR)arithops.o: $(SRCDIR)arithops.c $(REQUIRED-INCS) \
$(INCDIR)adr68k.h \
$(INCDIR)arith.h \
$(INCDIR)commondefs.h \
$(INCDIR)lispemul.h \
$(INCDIR)lispmap.h \
$(INCDIR)lsptypes.h \
$(INCDIR)mkcelldefs.h \
$(INCDIR)arithopsdefs.h \
$(INCDIR)fpdefs.h \
$(INCDIR)lspglob.h \
$(INCDIR)ifpage.h \
$(INCDIR)iopage.h \
$(INCDIR)miscstat.h
$(CC) $(RFLAGS) $(SRCDIR)arithops.c -o $(OBJECTDIR)arithops.o
$(OBJECTDIR)arrayops.o: $(SRCDIR)arrayops.c $(REQUIRED-INCS) \
$(INCDIR)adr68k.h \
@ -926,8 +918,7 @@ $(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(REQUIRED-INCS) \
$(INCDIR)miscstat.h $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \
$(INCDIR)initatms.h $(INCDIR)gcdata.h $(INCDIR)arith.h $(INCDIR)stream.h \
$(INCDIR)tos1defs.h $(INCDIR)tosret.h $(INCDIR)tosfns.h $(INCDIR)inlineC.h \
$(INCDIR)xcdefs.h $(INCDIR)arith2defs.h $(INCDIR)arith3defs.h \
$(INCDIR)arith4defs.h $(INCDIR)arrayopsdefs.h \
$(INCDIR)xcdefs.h $(INCDIR)arithopsdefs.h $(INCDIR)arrayopsdefs.h \
$(INCDIR)bitbltdefs.h $(INCDIR)bltdefs.h \
$(INCDIR)byteswapdefs.h $(INCDIR)car-cdrdefs.h $(INCDIR)commondefs.h \
$(INCDIR)conspagedefs.h $(INCDIR)drawdefs.h $(INCDIR)eqfdefs.h \

View File

@ -126,19 +126,4 @@
} \
} while (0)
#define N_IARITH_BODY_2(a, tos, op) \
do { \
register int arg1, arg2; \
\
N_IGETNUMBER(a, arg1, do_ufn); \
N_IGETNUMBER(tos, arg2, do_ufn); \
\
arg1 = arg1 op arg2; \
\
N_ARITH_SWITCH(arg1); \
\
do_ufn: \
ERROR_EXIT(tos); \
} while (0)
#endif /* ARITH_H */

View File

@ -1,7 +0,0 @@
#ifndef ARITH3DEFS_H
#define ARITH3DEFS_H 1
#include "lispemul.h" /* for LispPTR */
LispPTR N_OP_makenumber(int tosm1, int tos);
LispPTR N_OP_boxiplus(register int a, int tos);
LispPTR N_OP_boxidiff(register int a, int tos);
#endif

View File

@ -1,9 +0,0 @@
#ifndef ARITH4DEFS_H
#define ARITH4DEFS_H 1
#include "lispemul.h" /* for LispPTR */
LispPTR N_OP_times2(int tosm1, int tos);
LispPTR N_OP_itimes2(int tosm1, int tos);
LispPTR N_OP_quot(int tosm1, int tos);
LispPTR N_OP_iquot(int tosm1, int tos);
LispPTR N_OP_iremainder(int tosm1, int tos);
#endif

View File

@ -1,5 +1,5 @@
#ifndef ARITH2DEFS_H
#define ARITH2DEFS_H 1
#ifndef ARITHOPSDEFS_H
#define ARITHOPSDEFS_H 1
#include "lispemul.h" /* for LispPTR */
LispPTR N_OP_plus2(int tosm1, int tos);
LispPTR N_OP_iplus2(int tosm1, int tos);
@ -12,4 +12,12 @@ LispPTR N_OP_greaterp(int tosm1, int tos);
LispPTR N_OP_igreaterp(int tosm1, int tos);
LispPTR N_OP_iplusn(int tos, int n);
LispPTR N_OP_idifferencen(int tos, int n);
LispPTR N_OP_makenumber(int tosm1, int tos);
LispPTR N_OP_boxiplus(int a, int tos);
LispPTR N_OP_boxidiff(int a, int tos);
LispPTR N_OP_times2(int tosm1, int tos);
LispPTR N_OP_itimes2(int tosm1, int tos);
LispPTR N_OP_quot(int tosm1, int tos);
LispPTR N_OP_iquot(int tosm1, int tos);
LispPTR N_OP_iremainder(int tosm1, int tos);
#endif

View File

@ -48,7 +48,7 @@
/* */
/* */
/* Register conventions within arithmetic functions in the files */
/* arith2.c - arith4.c, etc.: */
/* arithops.c, etc.: */
/* */
/* esi first argument to the function */
/* edi second argument to the function */

View File

@ -48,7 +48,7 @@
/* */
/* */
/* Register conventions within arithmetic functions in the files */
/* arith2.c - arith4.c, etc.: */
/* arithops.c etc.: */
/* */
/* esi first argument to the function */
/* edi second argument to the function */

View File

@ -1,93 +0,0 @@
/* $Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* A R I T H 3 . C */
/* */
/* Including : OP_makenumber */
/* OP_boxiplus */
/* OP_boxidiff */
/* */
/* */
/************************************************************************/
#include "version.h"
#include "adr68k.h" // for Addr68k_from_LADDR
#include "arith.h" // for N_GETNUMBER, N_ARITH_SWITCH
#include "arith3defs.h" // for N_OP_boxidiff, N_OP_boxiplus, N_OP_makenumber
#include "lispemul.h" // for state, LispPTR, ERROR_EXIT
#include "lispmap.h" // for S_POSITIVE
#include "lspglob.h"
#include "lsptypes.h" // for GetTypeNumber, TYPE_FIXP
/************************************************************************/
/* */
/* N _ O P _ m a k e n u m b e r */
/* */
/* Given the 2 halves of a FIXP as SMALLP's, create a number */
/* box for the number, and fill it in. */
/* */
/************************************************************************/
LispPTR N_OP_makenumber(int tosm1, int tos) {
register int result;
if (((tosm1 & 0xFFFF0000) != S_POSITIVE) || ((tos & 0xFFFF0000) != S_POSITIVE)) ERROR_EXIT(tos);
/* UB: left shift of 49152 by 16 places cannot be represented in type 'int' */
result = ((tosm1 & 0xffff) << 16) | (tos & 0xffff);
N_ARITH_SWITCH(result);
} /* end OP_makenumber */
/************************************************************************/
/* */
/* N _ O P _ b o x i p l u s */
/* */
/* Given a FIXP box and a number to add to it, add the number, */
/* leaving the result in the box given. Used to avoid garbaging. */
/* */
/************************************************************************/
LispPTR N_OP_boxiplus(register int a, int tos) {
register int arg2;
if (GetTypeNumber(a) == TYPE_FIXP) {
N_GETNUMBER(tos, arg2, bad);
*((LispPTR *)Addr68k_from_LADDR(a)) += arg2;
return (a);
}
bad:
ERROR_EXIT(tos);
} /* OP_boxiplus */
/************************************************************************/
/* */
/* O P _ b o x i d i f f */
/* */
/* Given a FIXP box and a number to subtract from it, do the */
/* subtraction, and leave the result in the box given. */
/* Used to avoid allocating storage in low-level routines. */
/* */
/************************************************************************/
LispPTR N_OP_boxidiff(register int a, int tos) {
register int arg2;
if (GetTypeNumber(a) == TYPE_FIXP) {
N_GETNUMBER(tos, arg2, bad);
*((LispPTR *)Addr68k_from_LADDR(a)) -= arg2;
return (a);
}
bad:
ERROR_EXIT(tos);
} /* end OP_boxidiff */

View File

@ -1,157 +0,0 @@
/* $Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
/***********************************************************************/
/*
File Name : arith4.c
Including : OP_times2 326Q(OP_itimes2 332Q)
OP_quot 327Q(OP_iquot 333Q)
OP_reminder 334Q
*/
/**********************************************************************/
#include "version.h"
#include "arith.h" // for N_IGETNUMBER, N_ARITH_SWITCH, N_GETNUMBER
#include "arith4defs.h" // for N_OP_iquot, N_OP_iremainder, N_OP_itimes2
#include "fpdefs.h" // for N_OP_fquotient, N_OP_ftimes2
#include "lispemul.h" // for state, ERROR_EXIT, LispPTR
#include "lspglob.h"
#include "lsptypes.h"
/**********************************************************************/
/*
Func name : N_OP_times2(itimes2)
*/
/**********************************************************************/
LispPTR N_OP_times2(int tosm1, int tos) {
int arg1, arg2;
int result;
N_GETNUMBER(tosm1, arg1, doufn);
N_GETNUMBER(tos, arg2, doufn);
#ifdef USE_OVERFLOW_BUILTINS
if (__builtin_smul_overflow(arg1, arg2, &result)) {
goto doufn2;
}
N_ARITH_SWITCH(result);
#else
result = arg1 * arg2;
if ((arg2 != 0) && ((result / arg2) != arg1)) goto doufn2;
N_ARITH_SWITCH(result);
#endif
doufn2:
ERROR_EXIT(tos);
doufn:
return (N_OP_ftimes2(tosm1, tos));
} /* end N_OP_times2 */
LispPTR N_OP_itimes2(int tosm1, int tos) {
int arg1, arg2;
int result;
N_IGETNUMBER(tosm1, arg1, doufn);
N_IGETNUMBER(tos, arg2, doufn);
#ifdef USE_OVERFLOW_BUILTINS
if (__builtin_smul_overflow(arg1, arg2, &result)) {
goto doufn;
}
N_ARITH_SWITCH(result);
#else
/* UB: signed integer overflow: 1073741824 * 32768 cannot be represented in type 'int' */
result = arg1 * arg2;
if ((arg2 != 0) && ((result / arg2) != arg1)) { goto doufn; }
N_ARITH_SWITCH(result);
#endif
doufn:
ERROR_EXIT(tos);
} /* end N_OP_itimes2 */
/**********************************************************************/
/*
Func name : N_OP_quot(iquot)
*/
/**********************************************************************/
LispPTR N_OP_quot(int tosm1, int tos) {
int arg1, arg2;
int result;
N_GETNUMBER(tosm1, arg1, doufn);
N_GETNUMBER(tos, arg2, doufn);
if (arg2 == 0) goto doufn2;
result = arg1 / arg2; /* lmm: note: no error case!! */
N_ARITH_SWITCH(result);
doufn2:
ERROR_EXIT(tos);
doufn:
return (N_OP_fquotient(tosm1, tos));
} /* end N_OP_quot */
LispPTR N_OP_iquot(int tosm1, int tos) {
register int arg1, arg2;
register int result;
N_IGETNUMBER(tosm1, arg1, doufn);
N_IGETNUMBER(tos, arg2, doufn);
if (arg2 == 0) goto doufn;
result = arg1 / arg2;
N_ARITH_SWITCH(result);
doufn:
ERROR_EXIT(tos);
} /* end N_OP_quot */
/**********************************************************************/
/*
Func name : N_OP_iremainder
*/
/**********************************************************************/
LispPTR N_OP_iremainder(int tosm1, int tos) {
register int arg1, arg2;
register int result;
N_IGETNUMBER(tosm1, arg1, doufn);
N_IGETNUMBER(tos, arg2, doufn);
if (arg2 == 0) goto doufn;
result = arg1 % arg2;
N_ARITH_SWITCH(result);
doufn:
ERROR_EXIT(tos);
} /* end N_OP_iremainder */

View File

@ -1,18 +1,18 @@
/* $Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-99 Venue. All Rights Reserved. */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include "adr68k.h" // for Addr68k_from_LADDR
#include "arith.h" // for N_IGETNUMBER, N_ARITH_SWITCH, N_GETNUMBER
#include "arith2defs.h" // for N_OP_difference, N_OP_greaterp, N_OP_idiffer...
#include "arithopsdefs.h" // for N_OP_difference, N_OP_greaterp, N_OP_idiffer...
#include "fpdefs.h" // for N_OP_fdifference, N_OP_fgreaterp, N_OP_fplus2
#include "lispemul.h" // for state, ERROR_EXIT, LispPTR, ATOM_T, NIL_PTR
#include "lispmap.h" // for S_POSITIVE
#include "lspglob.h"
#include "lsptypes.h"
@ -150,21 +150,57 @@ N_OP_logxor
return(tosm1 ^ tos)
************************************************************/
LispPTR N_OP_logxor(int tosm1, int tos) { N_IARITH_BODY_2(tosm1, tos, ^); }
LispPTR N_OP_logxor(int tosm1, int tos) {
int arg1, arg2;
N_IGETNUMBER(tosm1, arg1, do_ufn);
N_IGETNUMBER(tos, arg2, do_ufn);
arg1 = arg1 ^ arg2;
N_ARITH_SWITCH(arg1);
do_ufn:
ERROR_EXIT(tos);
}
/************************************************************
N_OP_logand
entry LOGAND2 OPCODE[0345]
return(tosm1 & tos)
************************************************************/
LispPTR N_OP_logand(int tosm1, int tos) { N_IARITH_BODY_2(tosm1, tos, &); }
LispPTR N_OP_logand(int tosm1, int tos) {
int arg1, arg2;
N_IGETNUMBER(tosm1, arg1, do_ufn);
N_IGETNUMBER(tos, arg2, do_ufn);
arg1 = arg1 & arg2;
N_ARITH_SWITCH(arg1);
do_ufn:
ERROR_EXIT(tos);
}
/************************************************************
N_OP_logor
entry LOGOR2 OPCODE[0344]
return(tosm1 | tos)
************************************************************/
LispPTR N_OP_logor(int tosm1, int tos) { N_IARITH_BODY_2(tosm1, tos, |); }
LispPTR N_OP_logor(int tosm1, int tos) {
int arg1, arg2;
N_IGETNUMBER(tosm1, arg1, do_ufn);
N_IGETNUMBER(tos, arg2, do_ufn);
arg1 = arg1 | arg2;
N_ARITH_SWITCH(arg1);
do_ufn:
ERROR_EXIT(tos);
}
/************************************************************
N_OP_greaterp
@ -174,7 +210,7 @@ N_OP_greaterp
************************************************************/
LispPTR N_OP_greaterp(int tosm1, int tos) {
register int arg1, arg2;
int arg1, arg2;
N_GETNUMBER(tosm1, arg1, do_ufn);
N_GETNUMBER(tos, arg2, do_ufn);
@ -189,7 +225,7 @@ do_ufn:
}
LispPTR N_OP_igreaterp(int tosm1, int tos) {
register int arg1, arg2;
int arg1, arg2;
N_IGETNUMBER(tosm1, arg1, do_ufn);
N_IGETNUMBER(tos, arg2, do_ufn);
@ -262,3 +298,195 @@ LispPTR N_OP_idifferencen(int tos, int n) {
do_ufn:
ERROR_EXIT(tos);
}
/************************************************************************/
/* */
/* N _ O P _ m a k e n u m b e r */
/* */
/* Given the 2 halves of a FIXP as SMALLP's, create a number */
/* box for the number, and fill it in. */
/* */
/************************************************************************/
LispPTR N_OP_makenumber(int tosm1, int tos) {
int result;
if (((tosm1 & 0xFFFF0000) != S_POSITIVE) || ((tos & 0xFFFF0000) != S_POSITIVE)) ERROR_EXIT(tos);
/* UB: left shift of 49152 by 16 places cannot be represented in type 'int' */
result = ((tosm1 & 0xffff) << 16) | (tos & 0xffff);
N_ARITH_SWITCH(result);
} /* end OP_makenumber */
/************************************************************************/
/* */
/* N _ O P _ b o x i p l u s */
/* */
/* Given a FIXP box and a number to add to it, add the number, */
/* leaving the result in the box given. Used to avoid garbaging. */
/* */
/************************************************************************/
LispPTR N_OP_boxiplus(int a, int tos) {
int arg2;
if (GetTypeNumber(a) == TYPE_FIXP) {
N_GETNUMBER(tos, arg2, bad);
*((LispPTR *)Addr68k_from_LADDR(a)) += arg2;
return (a);
}
bad:
ERROR_EXIT(tos);
} /* OP_boxiplus */
/************************************************************************/
/* */
/* O P _ b o x i d i f f */
/* */
/* Given a FIXP box and a number to subtract from it, do the */
/* subtraction, and leave the result in the box given. */
/* Used to avoid allocating storage in low-level routines. */
/* */
/************************************************************************/
LispPTR N_OP_boxidiff(int a, int tos) {
int arg2;
if (GetTypeNumber(a) == TYPE_FIXP) {
N_GETNUMBER(tos, arg2, bad);
*((LispPTR *)Addr68k_from_LADDR(a)) -= arg2;
return (a);
}
bad:
ERROR_EXIT(tos);
} /* end OP_boxidiff */
/**********************************************************************/
/*
Func name : N_OP_times2
*/
/**********************************************************************/
LispPTR N_OP_times2(int tosm1, int tos) {
int arg1, arg2;
int result;
N_GETNUMBER(tosm1, arg1, doufn);
N_GETNUMBER(tos, arg2, doufn);
#ifdef USE_OVERFLOW_BUILTINS
if (__builtin_smul_overflow(arg1, arg2, &result)) {
goto doufn2;
}
N_ARITH_SWITCH(result);
#else
result = arg1 * arg2;
if ((arg2 != 0) && ((result / arg2) != arg1)) goto doufn2;
N_ARITH_SWITCH(result);
#endif
doufn2:
ERROR_EXIT(tos);
doufn:
return (N_OP_ftimes2(tosm1, tos));
} /* end N_OP_times2 */
LispPTR N_OP_itimes2(int tosm1, int tos) {
int arg1, arg2;
int result;
N_IGETNUMBER(tosm1, arg1, doufn);
N_IGETNUMBER(tos, arg2, doufn);
#ifdef USE_OVERFLOW_BUILTINS
if (__builtin_smul_overflow(arg1, arg2, &result)) {
goto doufn;
}
N_ARITH_SWITCH(result);
#else
/* UB: signed integer overflow: 1073741824 * 32768 cannot be represented in type 'int' */
result = arg1 * arg2;
if ((arg2 != 0) && ((result / arg2) != arg1)) { goto doufn; }
N_ARITH_SWITCH(result);
#endif
doufn:
ERROR_EXIT(tos);
} /* end N_OP_itimes2 */
/**********************************************************************/
/*
Func name : N_OP_quot(iquot)
*/
/**********************************************************************/
LispPTR N_OP_quot(int tosm1, int tos) {
int arg1, arg2;
int result;
N_GETNUMBER(tosm1, arg1, doufn);
N_GETNUMBER(tos, arg2, doufn);
if (arg2 == 0) goto doufn2;
result = arg1 / arg2; /* lmm: note: no error case!! */
N_ARITH_SWITCH(result);
doufn2:
ERROR_EXIT(tos);
doufn:
return (N_OP_fquotient(tosm1, tos));
} /* end N_OP_quot */
LispPTR N_OP_iquot(int tosm1, int tos) {
int arg1, arg2;
int result;
N_IGETNUMBER(tosm1, arg1, doufn);
N_IGETNUMBER(tos, arg2, doufn);
if (arg2 == 0) goto doufn;
result = arg1 / arg2;
N_ARITH_SWITCH(result);
doufn:
ERROR_EXIT(tos);
} /* end N_OP_quot */
/**********************************************************************/
/*
Func name : N_OP_iremainder
*/
/**********************************************************************/
LispPTR N_OP_iremainder(int tosm1, int tos) {
int arg1, arg2;
int result;
N_IGETNUMBER(tosm1, arg1, doufn);
N_IGETNUMBER(tos, arg2, doufn);
if (arg2 == 0) goto doufn;
result = arg1 % arg2;
N_ARITH_SWITCH(result);
doufn:
ERROR_EXIT(tos);
} /* end N_OP_iremainder */

View File

@ -57,9 +57,7 @@
#include "inlineC.h"
#include "xcdefs.h"
#include "arith2defs.h"
#include "arith3defs.h"
#include "arith4defs.h"
#include "arithopsdefs.h"
#include "arrayopsdefs.h"
#include "bitbltdefs.h"
#include "bltdefs.h"