DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T p

⟦4a8d96a77⟧ TextFile

    Length: 21566 (0x543e)
    Types: TextFile
    Names: »prims.h«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/gnu-31mar87/scheme/microcode/prims.h« 

TextFile

/*          Hey EMACS, this is -*- C -*- code!                 */

/****************************************************************
*                                                               *
*                         Copyright (c) 1984                    *
*               Massachusetts Institute of Technology           *
*                                                               *
* This material was developed by the Scheme project at the      *
* Massachusetts Institute of Technology, Department of          *
* Electrical Engineering and Computer Science.  Permission to   *
* copy this software, to redistribute it, and to use it for any *
* purpose is granted, subject to the following restrictions and *
* understandings.                                               *
*                                                               *
* 1. Any copy made of this software must include this copyright *
* notice in full.                                               *
*                                                               *
* 2. Users of this software agree to make their best efforts (a)*
* to return to the MIT Scheme project any improvements or       *
* extensions that they make, so that these may be included in   *
* future releases; and (b) to inform MIT of noteworthy uses of  *
* this software.                                                *
*                                                               *
* 3.  All materials developed as a consequence of the use of    *
* this software shall duly acknowledge such use, in accordance  *
* with the usual standards of acknowledging credit in academic  *
* research.                                                     *
*                                                               *
* 4. MIT has made no warrantee or representation that the       *
* operation of this software will be error-free, and MIT is     *
* under no obligation to provide any services, by way of        *
* maintenance, update, or otherwise.                            *
*                                                               *
* 5.  In conjunction with products arising from the use of this *
* material, there shall be no use of the name of the            *
* Massachusetts Institute of Technology nor of any adaptation   *
* thereof in any advertising, promotional, or sales literature  *
* without prior written consent from MIT in each case.          *
*                                                               *
****************************************************************/

/* File: PRIMS.H
 * This file contains the information needed for the basic primitives.
 */
\f


/* Information on primitives:
 *
 * Primitives are routines written in the interpreter implementation
 * language (C in this case) which accept Scheme objects as arguments
 * and return a Scheme object as their value.  Some of them (APPLY,
 * SCODE-EVAL, CATCH) are really entry points into the interpreter,
 * and in other languages or implementations would be special forms.
 * These depend on the way the interpreter works and should not be
 * modified.  Most (all?) of these "interpreter hooks" live in the
 * file HOOKS.C
 *
 * Most primitives are basic in some sense.  Their functionality
 * cannot easily be achieved with a Scheme procedure unless they are
 * defined (eg, CAR, PRIMITIVE-TYPE, GET-CHARACTER, etc).  Some exist
 * only for efficiency, they are very common and easily written in
 * the interpreter implementation language, and this extra work is
 * worth the speed that they provide (eg LENGTH, MEMQ, etc).
 *
 * The runtime system depends on many primitives (the others are
 * fossils or used by specialized subsystems only).  Users may,
 * however, add new primitives to suit their applications (graphics,
 * matrix multiplication, etc.), and are encouraged to do so.
 *
 * The system provides some facilities for declaring new primitives,
 * which can then be accessed from Scheme.  The linking of the C code
 * which implements these user-supplied (we call them "external")
 * primitives is done at system (microcode) generation time (e.g.
 * when you use "make" to link a new version of scheme under Unix).
 * These externals are handled in such a way that Scheme programs
 * which use them can be loaded on any system, including
 * systems that do not have those primitives.  If you run a program
 * which tries to apply one of these undefined externals to arguments,
 * you will, of course, get an error.

\f



 * The original primitives (provided with Cscheme) are not linked in
 * the same way for historical reasons, and must always exist.  They
 * will eventually be linked in the same or similar way that user
 * defined primitives are linked, and then there will be no difference
 * between both kinds.  Currently, there are tables in STORAGE.C with
 * information on these original, or "built in" primitives.  These
 * tables are needed for the old linking mechanism, but need not be
 * extended when adding user defined primitives, since the equivalent
 * tables are constructed at microcode generation time.  If you are
 * curious, look at the files USRDEF.C, created at microcode generation
 * time, and FINDPRIM.C, the program which creates it.
 *
 * Primitives have 2 fixed names: The C name (the name of the C
 * routine that implements them), and the Scheme linking name.  The
 * latter is the name which when given to MAKE-PRIMITIVE-PROCEDURE
 * will return the appropriate procedure object.  Note that this name
 * is not usually initially bound in Scheme, and it may be bound to
 * anything at all, though for some of the most common primitives it
 * is bound to the primitive object.  In other words, you must choose
 * names for your primitives so that neither the C name nor the
 * linking name have conflicts with other linked primitives, but you
 * need not worry about name conflicts with the Scheme environment.
 * Note also that this name is currently ignored for "built in",
 * required primitives.
 *
 * Define_Primitive is a macro used to declare a primitive to the
 * linking mechanism.  It is both a C macro (defined in primitive.h)
 * and a special name used by the program Findprim to generate a
 * special file used when a new scheme microcode is linked together.
 * Notice that you must be sure to run Findprim ONLY on the files
 * containing user defined primitives, and NOT the system supplied
 * primitives.  For UNIX users, you should look at the top few lines
 * of the Makefile and add the names of your files.  In particular,
 * this means that you cannot have both kinds of primitives in one
 * file.  Don't add primitives to "system" files, add your own files
 * instead.
 *
 * Define_Primitive expects 3 arguments which are the C name, the
 * number of arguments that the primitive expects (currently
 * primitives cannot receive variable numbers of arguments), and the
 * Scheme linking name.  Original primitives make use of
 * Built_In_Primitive and the primitive numbers defined below for
 * linking purposes instead of using this symbolic linking mechanism.
 *
 * One last note: Unless very special care is taken (and we do not
 * recommend it), primitives cannot call other primitives.  If you
 * want to share code between two primitives, write a third procedure
 * which implements the common work, and have both primitives call it
 * as appropriate.  The reason for this is that the primitive calling
 * convention may change without notice, and the way arguments
 * are accessed may therefore change.  As long as you only use
 * Primitive_N_Args to access them, your code will continue to work.
 * In particular, if you write primitives which do not expect any
 * arguments, make sure to invoke Primitive_0_Args anyway since it will
 * take care of any initialization needed.  Define_Primitive,
 * Built_In_Primitive, Primitive_N_Args, and other utilities for
 * primitives are defined in the file PRIMITIVE.H.
 *
 * For examples of user defined primitives, look at the files SAMPLE.C
 * and XDEBUG.C.  For an example on how to access these primitives
 * from scheme look at sample.scm and xdebug.scm.
 */
\f


                      /************************/
                      /* PRIMITIVE OPERATIONS */
                      /************************/

#define PC_LEXICAL_ASSIGNMENT           0x00
#define PC_LOCAL_REFERENCE              0x01
#define PC_LOCAL_ASSIGNMENT             0x02
#define PC_CATCH                        0x03
#define PC_SCODE_EVAL                   0x04
#define PC_APPLY                        0x05
#define PC_SET_INTERRUPT_ENABLES        0x06
/*      UNUSED (will be STRING->SYMBOL) 0x07 */
#define PC_GET_WORK                     0x08	/* Futures only */
/*	UNUSED			        0x09 */
/*	UNUSED			        0x0A */
/*	UNUSED				0x0B */
#define PC_NOT                          0x0C
#define PC_EQ                           0x0D
#define PC_STRING_EQUAL                 0x0E
#define PC_PRIM_TYPE_QM                 0x0F
#define PC_PRIM_TYPE                    0x10
#define PC_PRIMITIVE_SET_TYPE           0x11
#define PC_LEXICAL_REFERENCE            0x12
#define PC_UNREFERENCEABLE_TEST         0x13
/*	UNUSED				0x14 */
/*	UNUSED				0x15 */
#define PC_NON_RESTARTABLE_EXIT         0x16
/*	UNUSED				0x17 */
#define PC_UNASSIGNED_TEST              0x18
#define PC_INSERT_NON_MARKED_VECTOR     0x19
#define PC_RESTARTABLE_EXIT             0x1A
/*	UNUSED				0x1B */
#define PC_MEMQ                         0x1C
#define PC_INSERT_STRING                0x1D
#define PC_ENABLE_INTERRUPTS            0x1E
#define PC_MAKE_EMPTY_STRING            0x1F
#define PC_CONS                         0x20
#define PC_CAR                          0x21
#define PC_CDR                          0x22
#define PC_SET_CAR                      0x23
#define PC_SET_CDR                      0x24

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_PRINT_STRING                 0x25
#define PC_GET_CURSOR                   0x26
#define PC_GENERAL_CAR_CDR              0x27
#define PC_HUNK3_CONS                   0x28
#define PC_HUNK3_CXR                    0x29
#define PC_HUNK3_SET_CXR                0x2A
#define PC_OVERWRITE_STRING             0x2B
#define PC_VECTOR_CONS                  0x2C
#define PC_VECTOR_SIZE                  0x2D
#define PC_VECTOR_REF                   0x2E
#define PC_SET_CURRENT_HISTORY          0x2F
#define PC_VECTOR_SET                   0x30
#define PC_NON_MARKED_VECTOR_CONS       0x31
#define PC_GET_CHAR                     0x32
#define PC_UNBOUND_TEST                 0x33
/*	UNUSED				0x34 */
/*	UNUSED				0x35 */
/*	UNUSED				0x36 */
/*	UNUSED				0x37 */
/*	UNUSED				0x38 */
/*	UNUSED				0x39 */
#define PC_GARBAGE_COLLECT              0x3A
#define PC_PLUS_FIXNUM                  0x3B
#define PC_MINUS_FIXNUM                 0x3C
#define PC_MULTIPLY_FIXNUM              0x3D
#define PC_DIVIDE_FIXNUM                0x3E
#define PC_EQUAL_FIXNUM                 0x3F
#define PC_LESS_FIXNUM                  0x40
#define PC_POSITIVE_FIXNUM              0x41
#define PC_ONE_PLUS_FIXNUM              0x42
#define PC_M_ONE_PLUS_FIXNUM	        0x43
#define PC_TRUNCATE_STRING              0x44
#define PC_SUBSTRING                    0x45
#define PC_ZERO_FIXNUM                  0x46
#define PC_UNDANGERIZE                  0x47
#define PC_DANGERIZE                    0x48
#define PC_DANGEROUS_QM                 0x49
#define PC_SUBSTRING_TO_LIST            0x4A
#define PC_MAKE_FILLED_STRING           0x4B
#define PC_PLUS_BIGNUM                  0x4C
#define PC_MINUS_BIGNUM                 0x4D
#define PC_MULTIPLY_BIGNUM              0x4E
#define PC_DIVIDE_BIGNUM                0x4F

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_LISTIFY_BIGNUM               0x50
#define PC_EQUAL_BIGNUM                 0x51
#define PC_LESS_BIGNUM                  0x52
#define PC_POSITIVE_BIGNUM              0x53
/* Unused                               0x54 */
/* Unused                               0x55 */
#define PC_PRIMITIVE_FASDUMP            0x56
#define PC_FASLOAD               0x57
#define PC_STRING_POSITION              0x58
#define PC_STRING_LESS                  0x59
#define PC_OBJECT_HASH                  0x5A
#define PC_OBJECT_UNHASH                0x5B
#define PC_REHASH_GC_DAEMON             0x5C
#define PC_LENGTH                       0x5D
#define PC_ASSQ                         0x5E
#define PC_BUILD_STRING_FROM_LIST       0x5F
#define PC_EQUAL_STRING_TO_LIST         0x60
#define PC_MAKE_CELL                    0x61
#define PC_CELL_CONTENTS                0x62
#define PC_CELL 	                0x63
#define PC_RAISE_CHAR                   0x64
#define PC_CHARACTER_LIST_HASH          0x65
#define PC_GCD_FIXNUM                   0x66
#define PC_FIX_TO_BIG                   0x67
#define PC_BIG_TO_FIX                   0x68
#define PC_PLUS_FLONUM                  0x69
#define PC_MINUS_FLONUM                 0x6A
#define PC_MULTIPLY_FLONUM              0x6B
#define PC_DIVIDE_FLONUM                0x6C
#define PC_EQUAL_FLONUM                 0x6D
#define PC_LESS_FLONUM                  0x6E
#define PC_ZERO_BIGNUM                  0x6F
#define PC_TRUNCATE_FLONUM              0x70
#define PC_ROUND_FLONUM                 0x71
#define PC_INT_TO_FLOAT                 0x72
#define PC_SINE_FLONUM                  0x73
#define PC_COSINE_FLONUM                0x74
#define PC_ARCTAN_FLONUM                0x75
#define PC_EXP_FLONUM                   0x76
#define PC_LN_FLONUM                    0x77

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_SQRT_FLONUM                  0x78
#define PC_ASCII_FASLOAD                0x79
#define PC_GET_FIXED_OBJECTS_VECTOR     0x7A
#define PC_SET_FIXED_OBJECTS_VECTOR     0x7B
#define PC_LIST_TO_VECTOR               0x7C
#define PC_SUBVECTOR_TO_LIST            0x7D
#define PC_PAIR                         0x7E
#define PC_NEGATIVE_FIXNUM              0x7F
#define PC_NEGATIVE_BIGNUM              0x80
#define PC_GREATER_FIXNUM               0x81
#define PC_GREATER_BIGNUM               0x82
#define PC_STRING_HASH                  0x83
#define PC_SYS_PAIR_CONS                0x84
#define PC_SYS_PAIR                     0x85
#define PC_SYS_PAIR_CAR                 0x86
#define PC_SYS_PAIR_CDR                 0x87
#define PC_SYS_SET_CAR                  0x88
#define PC_SYS_SET_CDR                  0x89
#define PC_INITIALIZE_OBJECT_HASH       0x8A
#define PC_GET_CHAR_IMMEDIATE           0x8B
#define PC_SET_CELL_CONTENTS            0x8C
#define PC_EQUAL_BIT_STRING		0x8D
#define PC_SYS_H3_0                     0x8E
#define PC_SYS_H3_SET_0                 0x8F
#define PC_MAP_ADDRESS_TO_CODE          0x90
#define PC_SYS_H3_1                     0x91
#define PC_SYS_H3_SET_1                 0x92
#define PC_MAP_CODE_TO_ADDRESS          0x93
#define PC_SYS_H3_2                     0x94
#define PC_SYS_H3_SET_2                 0x95
#define PC_MAP_PRIM_ADDRESS_TO_ARITY    0x96
#define PC_SYS_LIST_TO_VECTOR           0x97
#define PC_SYS_SUBVECTOR_TO_LIST        0x98
#define PC_SYS_VECTOR                   0x99
#define PC_SYS_VECTOR_REF               0x9A
#define PC_SYS_VECTOR_SET               0x9B
#define PC_WITH_HISTORY_DISABLED        0x9C

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_VECTOR_1B_CONS               0x9D
#define PC_VECTOR_1B                    0x9E
#define PC_VECTOR_1B_REF                0x9F
#define PC_VECTOR_1B_SET                0xA0
#define PC_VEC_1B_SET_FALSE             0xA1
#define PC_VEC_1B_SET_TRUE              0xA2
#define PC_VECTOR_8B_CONS               0xA3
#define PC_VECTOR_8B                    0xA4
#define PC_VECTOR_8B_REF                0xA5
#define PC_VECTOR_8B_SET                0xA6
#define PC_ZERO_FLONUM                  0xA7
#define PC_POSITIVE_FLONUM              0xA8
#define PC_NEGATIVE_FLONUM              0xA9
#define PC_GREATER_FLONUM               0xAA
#define PC_INTERN_CHARACTER_LIST        0xAB
#define PC_VECTOR_1B_SIZE               0xAC
#define PC_VECTOR_8B_SIZE               0xAD
#define PC_SYS_VECTOR_SIZE              0xAE
#define PC_FORCE                        0xAF
#define PC_PRIMITIVE_DATUM              0xB0
#define PC_MAKE_NON_POINTER             0xB1
#define PC_TEMP_PRINTER                 0xB2
#define PC_RAISE_STRING                 0xB3
#define PC_PRIMITIVE_PURIFY             0xB4
/*	UNUSED				0xB5 */
#define PC_COMPLETE_GARBAGE_COLLECT     0xB6
#define PC_BAND_DUMP                    0xB7
#define PC_SUBSTRING_SEARCH             0xB8
#define PC_BAND_LOAD                    0xB9
#define PC_CONSTANT_P                   0xBA
#define PC_PURE_P                       0xBB
#define PC_GC_TYPE                      0xBC
#define PC_IMPURIFY                     0xBD
#define PC_WITH_THREADED_STACK          0xBE
#define PC_WITHIN_CONTROL_POINT         0xBF
#define PC_SET_RUN_LIGHT                0xC0
/*	UNUSED				0xC1 */
/*	UNUSED				0xC2 */
/*	UNUSED				0xC3 */
/*	UNUSED				0xC4 */
/*	UNUSED				0xC5 */
/*	UNUSED				0xC6 */

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_CLOSE_LOST_OPEN_FILES        0xC7
#define PC_PUT_CHAR_TO_OUTPUT_CHANNEL   0xC8
#define PC_MASK_INTERRUPT_ENABLES       0xC9
#define PC_EVAL_STEP                    0xCA
#define PC_APPLY_STEP                   0xCB
#define PC_RETURN_STEP                  0xCC
/*	UNUSED				0xCD */
/*	UNUSED				0xCE */
/*	UNUSED				0xCF */
/*	UNUSED				0xD0 */
#define PC_MAKE_UNFILLED_BIT_STRING     0xD1
#define PC_MAKE_FILLED_BIT_STRING       0xD2
#define PC_BIT_STRING_QM                0xD3
#define PC_BIT_STRING_SIZE              0xD4
#define PC_BIT_STRING_REF               0xD5
#define PC_BIT_STR_SET		        0xD6
#define PC_BIT_STR_SET_TRUE      	0xD7
#define PC_BIT_STR_SET_FALSE            0xD8
#define PC_BIT_SUBSTRING                0xD9
#define PC_INST_BIT_STR                 0xDA
#define PC_INST_BIT_STR_EXCL	        0xDB
#define PC_INTEGER_TO_BIT_STRING        0xDC
#define PC_BIT_STRING_TO_INTEGER        0xDD
#define PC_REVERSE_BIT_STRING           0xDE
#define PC_READ_BITS                    0xDF
#define PC_WRITE_BITS                   0xE0
#define PC_MAKE_STATE_SPACE             0xE1
#define PC_EXECUTE_AT_NEW_POINT         0xE2
#define PC_TRANSLATE_TO_POINT           0xE3
#define PC_GET_NEXT_CONSTANT		0xE4

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_MICROCODE_IDENTIFY		0xE5
#define PC_ZERO                         0xE6
#define PC_POSITIVE                     0xE7
#define PC_NEGATIVE                     0xE8
#define PC_EQUAL_NUMBER			0xE9
#define PC_LESS       			0xEA
#define PC_GREATER    		        0xEB
#define PC_PLUS			        0xEC
#define PC_MINUS		        0xED
#define PC_MULTIPLY			0xEE
#define PC_DIVIDE		       	0xEF
#define PC_INTEGER_DIVIDE           	0xF0
#define PC_ONE_PLUS			0xF1
#define PC_M_ONE_PLUS			0xF2
#define PC_TRUNCATE		        0xF3
#define PC_ROUND		        0xF4
#define PC_FLOOR		        0xF5
#define PC_CEILING		        0xF6
#define PC_SQRT			        0xF7
#define PC_EXP				0xF8
#define PC_LN				0xF9
#define PC_SINE				0xFA
#define PC_COSINE			0xFB
#define PC_ARCTAN		        0xFC
/*	UNUSED				0xFD */
/*	UNUSED				0xFE */
/*	UNUSED				0xFF */
/*	UNUSED				0x100 */
#define PC_GET_EXTERNAL_COUNTS		0x101
#define PC_GET_EXT_NAME			0x102
#define PC_GET_EXT_NUMBER		0x103
#define PC_OPEN_CHANNEL			0x104
#define PC_CLOSE_PHYSICAL_CHANNEL	0x105
#define PC_GET_NEXT_INTERRUPT_CHAR	0x106
#define PC_CHK_AND_CLN_INPUT_CHANNEL	0x107
#define PC_INITIALIZE_MICROCODE_DEBUG	0x108
#define PC_SYSTEM_CLOCK			0x109
#define PC_FILE_EXISTS			0x10A
#define PC_DELETE_FILE			0x10B
#define PC_MOVE_CURSOR			0x10C
#define PC_INTERNAL_PHOTO		0x10D
#define PC_CURRENT_DATE			0x10E

/* Primitive operations continue on the next page */
\f


/* Primitive operations, continued */

#define PC_CURRENT_TIME			0x10F
#define PC_TRANSLATE_FILE		0x110
#define PC_COPY_FILE			0x111
#define PC_RENAME_FILE			0x112
#define PC_REMOVE_FILE			0x113
#define PC_LINK_FILE			0x114
#define PC_MAKE_DIRECTORY		0x115
#define PC_VOLUME_NAME			0x116
#define PC_PREFIX_VOLUME		0x117
#define PC_OPEN_CATALOG			0x118
#define PC_CLOSE_CATALOG		0x119
#define PC_NEXT_FILE			0x11A
#define PC_CAT_NAME			0x11B
#define PC_CAT_KIND			0x11C
#define PC_CAT_PSIZE			0x11D
#define PC_CAT_LSIZE			0x11E
#define PC_CAT_INFO			0x11F
#define PC_CAT_BLOCK			0x120
#define PC_CAT_CREATE_DATE		0x121
#define PC_CAT_CREATE_TIME		0x122
#define PC_CAT_LAST_DATE		0x123
#define PC_CAT_LAST_TIME		0x124
#define PC_ERROR_MESSAGE		0x125
#define PC_CURRENT_YEAR			0x126
#define PC_CURRENT_MONTH		0x127
#define PC_CURRENT_DAY			0x128
#define PC_CURRENT_HOUR			0x129
#define PC_CURRENT_MINUTE		0x12A
#define PC_CURRENT_SECOND		0x12B
#define PC_INIT_FLOPPY			0x12C
#define PC_ZERO_FLOPPY			0x12D
#define PC_PACK_VOLUME			0x12E
#define PC_LOAD_PICTURE			0x12F
#define PC_STORE_PICTURE		0x130
#define PC_LOOKUP_SYSTEM_SYMBOL		0x131

/* Unix specialized primitives start here */

/* Unused		       		0x132 */
#define PC_CLEAR_SCREEN			0x133
#define PC_CLEAR_TO_END_OF_LINE		0x134
#define PC_NUMBER_OF_COLUMNS		0x135
#define PC_NUMBER_OF_LINES		0x136

/* And a new primitive ... */
#define PC_WITH_INTERRUPT_MASK		0x137
\f



/* Be sure to change MAX_PRIMITIVE_NUMBER, below,
 * and the tables in STORAGE.
 */

#define MAX_PRIMITIVE_NUMBER                   0x137