| Modification (1/95, B. Boigelot) de la definition des macros
| `WORD' et `LONG'.

| This is where the S-machine instruction encoding is defined. 

.macro WORD(x) (x)%256 (x)/256          | Low-byte followed by high-byte.
.macro LONG(x) WORD(x) WORD((x) >> 16)  | Low-word followed by high-word.

| S opcode macros:
.macro slla(n)   0x00+1 WORD(n) | slla(n)   - Push local address n.
.macro slaa(n)   0x00+2 WORD(n) | slaa(n)   - Push argument address n.
.macro salloc(n) 0x00+3 WORD(n) | salloc(n) - Allocate/deallocate +/- n bytes.

.macro sc1(C) 0x04   C          | sc@(C) - Push @-byte constant onto stack.
.macro sc2(C) 0x04+1 WORD(C)
.macro sc4(C) 0x04+2 LONG(C)

.macro slr1(n) 0x08   n         | slr@   - Push PC-relative adr, @-byte offset.
.macro slr2(n) 0x08+1 WORD(n)
.macro slr4(n) 0x08+2 LONG(n)

| S Opcode remaining instructions
sl1     = 0x0C          | sl@ - @-byte fetch from user memory (|.e., DRA)
sl2     = 0x0C+1
sl4     = 0x0C+2

ss1     = 0x10          | ss@ - @-byte store into user memory (|.e., DRA)
ss2     = 0x10+1
ss4     = 0x10+2

sadd1   = 0x14          | sadd@ - @-byte addition.
sadd2   = 0x14+1
sadd4   = 0x14+2

ssub1   = 0x18          | ssub@ - @-byte subtraction.
ssub2   = 0x18+1
ssub4   = 0x18+2

sneg1   = 0x1C          | sneg@ - @-byte negation (2's complement).
sneg2   = 0x1C+1
sneg4   = 0x1C+2

scmp1   = 0x20          | scmp@ - @-byte comparison.
scmp2   = 0x20+1
scmp4   = 0x20+2

sjmp    = 0x24          | Unconditional jump.
sje     = 0x24+2        | =     Jump iff equal.
sjne    = 0x24+3        | ~=    Jump iff not equal.

sjle    = 0x28          | <=    Jump iff less or equal    (signed).
sjgt    = 0x28+1        | >     Jump iff greater than     (signed).
sjlt    = 0x28+2        | <     Jump iff less than        (signed).
sjge    = 0x28+3        | >=    Jump iff greater or equal (signed).

sjlos   = 0x2C          | LS    Jump iff lower or same    (unsigned).
sjhi    = 0x2C+1        | H     Jump iff higher           (unsigned).
sjlo    = 0x2C+2        | L     Jump iff lower            (unsigned).
sjhis   = 0x2C+3        | HS    Jump iff higher or same   (unsigned).

| Alternate conditional jump mnemonics for use with siostat:

sjda    = sjlt          | Jump if data available (S bit set).
sjnda   = sjge          | Jump if data not available (S bit reset).

sjp1    = sjlo          | Jump if P1 pressed (C bit set).
sjnp1   = sjhis         | Jump if P1 not pressed (C bit reset).

sjp0    = sje           | Jump if PO pressed (Z bit set).
sjnp0   = sjne          | Jump if PO not pressed (Z bit reset).

.macro scall(n) 0x30 WORD(n)
                        | scall(n) - Call subr with n arguments.
.macro spdcall(n) 0x31 WORD(n)
                        | Procedure call (through descriptor) with n args.
spdcons = 0x32          | Procedure-descriptor constructor.

srtn0   = 0x34          | Valueless return.
.macro sla(d,n) 0x35 d WORD(n)  | Address of local n at lexical depth d.
.macro saa(d,n) 0x36 d WORD(n)  | Address of argument n at lexical depth d.

srtn1   = 0x38          | srtn@ - Return @-byte value.
srtn2   = 0x38+1
srtn4   = 0x38+2

| Encodings 3C-43 left blank for sarraysize@ and sarray@. 

sdiv1   = 0x44          | sdiv@ - @-bit division uith @-bit quotient.
sdiv2   = 0x45
sdiv4   = 0x46

srem1   = 0x48          | srem@ - @-bit modulo with @-bit remainder.
srem2   = 0x49
srem4   = 0x4A

sediv1  = 0x4C          | sediv@ - @-bit division with @-bit quotient
sediv2  = 0x4D          | and @-bit remainder
sediv4  = 0x4E

sand1   = 0x50          | sand@ - @-bit bitwise-logical AND function.
sand2   = 0x51
sand4   = 0x52

sor1    = 0x54             | sor@ - @-bit bitwise-logical OR function.
sor2    = 0x55
sor4    = 0x56

sxor1   = 0x58            | sxor@ - @-bit bitwise-logical XOR function.
sxor2   = 0x59
sxor4   = 0x5A

scom1   = 0x5C            | scom@ - @-bit bitwise complement.
scom2   = 0x5D
scom4   = 0x5E

sash1   = 0x60            | sash@ - @-bit arithmetic shift (+ left, - right).
sash2   = 0x61
sash4   = 0x62

slsh1   = 0x64            | slsh@ - @-bit logical shift (+ left, - right).
slsh2   = 0x65
slsh4   = 0x66

ssext1  = 0x68           | ssext@ - 2@-bit result of sign-extension.
ssext2  = 0x69
ssext4  = 0x6A

szext1  = 0x6C           | szext@ - 2@-bit result of zero-extend.
szext2  = 0x6D
szext4  = 0x6E

slow1   = 0x70            | slow@ - low @-bits of a 2@-bit number.
slow2   = 0x71
slow4   = 0x72

shigh1  = 0x74           | shigh@ - high @-bits of a 2@-bit number.
shigh2  = 0x75
shigh4  = 0x76

stest1  = 0x78           | stest@ - @-bit compare with zero (see scmp@).
stest2  = 0x79
stest4  = 0x7A

sdup1   = 0x7C           | sdup@ - Duplicate top @ bits on stack.
sdup2   = 0x7D
sdup4   = 0x7E

smult1  = 0x80           | smult@ - @-bit multiplication with @-bit product.
smult2  = 0x81
smult4  = 0x82

semul1  = 0x84          | semul@ - @-bit multiplication with 2@-bit prouct.
semul2  = 0x85
semul4  = 0x86

| I/O instructions:

siostat = 0x88          | Get SIO, PO, P1 status.
sioget  = 0x89          | Read a byte.
sioput  = 0x8A          | Send a byte.

.macro ssvc(C)  0x8C C  | ssvc(C) - Supervisor call with code C.
strtn   = 0x8D          | Return from trap or interrupt.
ssetclk4 = 0x8E         | Set alarm-clock timer.

| DO NOT REASSIGN THESE ENCODINGS: They are "hard-wired" into the simulator.

shalt   = 0x00          | Stop machine (flash: 111..111 <=> ...11...).
sbpt    = 0xFF          | Breakpoint (for debugging using simulator).
