Instruction Set Architecture

Summary

The following table summarizes the ISA of the AS2650-2. Hover over table entries for more detailed description and affected flags.

Base Instructions

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 lodz,r0 lodz,r1 lodz,r2 lodz,r3 lodi,r0 lodi,r1 lodi,r2 lodi,r3 lodr,r0 lodr,r1 lodr,r2 lodr,r3 loda,r0 loda,r1 loda,r2 loda,r3
1 push pop spsu spsl retc,eq retc,gt retc,lt retc,un bctr,eq bctr,gt bctr,lt bctr,un bcta,eq bcta,gt bcta,lt bcta,un
2 eorz,r0 eorz,r1 eorz,r2 eorz,r3 eori,r0 eori,r1 eori,r2 eori,r3 eorr,r0 eorr,r1 eorr,r2 eorr,r3 eora,r0 eora,r1 eora,r2 eora,r3
3 redc,r0 redc,r1 redc,r2 redc,r3 rete,eq rete,gt rete,lt rete,un bstr,eq bstr,gt bstr,lt bstr,un bsta,eq bsta,gt bsta,lt bsta,un
4 halt andz,r1 andz,r2 andz,r3 andi,r0 andi,r1 andi,r2 andi,r3 andr,r0 andr,r1 andr,r2 andr,r3 anda,r0 anda,r1 anda,r2 anda,r3
5 rrr,r0 rrr,r1 rrr,r2 rrr,r3 rede,r0 rede,r1 rede,r2 rede,r3 brnr,r0 brnr,r1 brnr,r2 brnr,r3 brna,r0 brna,r1 brna,r2 brna,r3
6 iorz,r0 iorz,r1 iorz,r2 iorz,r3 iori,r0 iori,r1 iori,r2 iori,r3 iorr,r0 iorr,r1 iorr,r2 iorr,r3 iora,r0 iora,r1 iora,r2 iora,r3
7 redd,r0 redd,r1 redd,r2 redd,r3 cpsu cpsl ppsu ppsl bsnr,r0 bsnr,r1 bsnr,r2 bsnr,r3 bsna,r0 bsna,r1 bsna,r2 bsna,r3
8 addz,r0 addz,r1 addz,r2 addz,r3 addi,r0 addi,r1 addi,r2 addi,r3 addr,r0 addr,r1 addr,r2 addr,r3 adda,r0 adda,r1 adda,r2 adda,r3
9 mul xchg lpsu lpsl dar,r0 dar,r1 dar,r2 dar,r3 bcfr,eq bcfr,gt bcfr,lt zbrr bcfa,eq bcfa,gt bcfa,lt bxa
A subz,r0 subz,r1 subz,r2 subz,r3 subi,r0 subi,r1 subi,r2 subi,r3 subr,r0 subr,r1 subr,r2 subr,r3 suba,r0 suba,r1 suba,r2 suba,r3
B wrtc,r0 wrtc,r1 wrtc,r2 wrtc,r3 tpsu tpsl EXTD bsfr,eq bsfr,gt bsfr,lt zbsr bsfa,eq bsfa,gt bsfa,lt bsxa
C nop strz,r1 strz,r2 strz,r3 clr r0 clr r1 clr r2 clr r3 strr,r0 strr,r1 strr,r2 strr,r3 stra,r0 stra,r1 stra,r2 stra,r3
D rrl,r0 rrl,r1 rrl,r2 rrl,r3 wrte,r0 wrte,r1 wrte,r2 wrte,r3 birr,r0 birr,r1 birr,r2 birr,r3 bira,r0 bira,r1 bira,r2 bira,r3
E comz,r0 comz,r1 comz,r2 comz,r3 comi,r0 comi,r1 comi,r2 comi,r3 comr,r0 comr,r1 comr,r2 comr,r3 coma,r0 coma,r1 coma,r2 coma,r3
F wrtd,r0 wrtd,r1 wrtd,r2 wrtd,r3 tmi,r0 tmi,r1 tmi,r2 tmi,r3 bdrr,r0 bdrr,r1 bdrr,r2 bdrr,r3 bdra,r0 bdra,r1 bdra,r2 bdra,r3

Table colorization:


Extended Instructions

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 lodf,r0 lodf,r1 lodf,r2 lodf,r3 ldfi,r0 ldfi,r0 ldfi,r0 ldfi,r0
1 pshs pops svb chrp bctf,eq bctf,gt bctf,lt bctf,un
2
3 bstf,eq bstf,gt bstf,lt bstf,un
4
5 brnf,r0 brnf,r1 brnf,r2 brnf,r3
6
7 bsnf,r0 bsnf,r1 bsnf,r2 bsnf,r3
8
9 trap clrt bcff,eq bcff,gt bcff,lt bxf
A
B bsff,eq bsff,gt bsff,lt bsxf
C strf,r0 strf,r1 strf,r2 strf,r3 stfi,r0 stfi,r0 stfi,r0 stfi,r0
D birf,r0 birf,r1 birf,r2 birf,r3
E cpl r0 cpl r1 cpl r2 cpl r3
F bdrf,r0 bdrf,r1 bdrf,r2 bdrf,r3

Programming Model

The AS2650v2 CPU is an 8-bit CPU core that can directly address 65,536 bytes of memory organized in 8,192 byte large pages. It contains 7 total general-purpose registers, of which 4 are accessible at any time. R0, or the accumulator, is always the same, while R1 - R3 can be instantly banked with a second set of registers, R1’ - R3’.

There is also an internal 16x16-bit large stack memory that can be used to store program variables, but is intended to be used as the subroutine and interrupt call stack.

There is also a register to hold processor status and flags, the Program Status Word (PSW). As it is 16-bits wide, it is split into the PSL (Program Status Lower) and PSU (Program Status Upper).

Lastly, there is a 16-bit Instruction Pointer which is split into the Page Control and Program Counter registers.

The Interrupt Vector Base (IVB) register is used as part of the interrupt configuration.

2¹⁵ 2⁸ 2⁷ 2⁰
General-Purpose
R3'
R2'
R1'
R3
R2
R1
R0
Stack
S[15]
[...]
S[0]
Instruction Pointer
Page ControlProgram Counter
Program Status
PSUPSL
Interrupts
IVB

Program Status Word

Program Status Upper

The PSU primarily contains the Stack Pointer SP for the internal stack as well as the global Interrupt Inhibit II. The pointer increments when values are pushed onto the stack and decrements when values are popped. It always points to where the next value will go, so the TOS is actually at SP - 1.

This register also contains the bits that control the two digital input/output lines Sense and Flag. The F bit sets the state (high or low) of Flag and the current state of the Sense input can be read out of the F bit.

Bit 4 of the PSU is not wired up to any hardware functionality, but is physically present and can be read and writen by a user program.

The PSU is reset to 20h on reset, meaning the II bit is set.

Program Status Lower

The PSL contains all processor flags and settings.

C is the carry flag defined by arithmatic operations.

COM is a processor setting that modifies the behavior of the compare instructions. If clear, they will compare values as two’s-complement signed bytes. If set, they will compare values as unsigned bytes.

OVF if set, indicates that the last addition or subtraction operation resulted in an arithmatic overflow, meaning the result could not be represented by a signed byte.

WC is a processor setting that modifies the behavior of addition and subtraction instructions, as well as left- and right-rotate.

IDC is the Interdigit Carry, that is the carry from bit 3 to bit 4 during an addition, subtraction of bitshift operation. It is used in combination with the dar instruction to perform arithmatic on packed BCD values.

CC is the Condition Code. This code is set either by any instruction that modifies a general purpose register (unless otherwise specified) and compare and bit-test instructions. This code can be tested by software or conditional branch instructions.

This PSL is initialized to 0 on reset.

Unless otherwise specified, any instruction listed in this documentation that is described as affecting CC will do according to the new value in whichever register it modifies as listed in this table:

Table 6 Condition Codes

Register Contents

CC

Positive

01

Zero

00

Negative

10

The value 11 will never be generated in the CC by any instruction.

Memory Model

The AS2650v2 segments its view of the 65,536 byte memory space into 8,192 pages. There is always one “current” page set by the 3 bit Page Control. This is combined with the 13 bit Program Counter to form the address of the next instruction to be executed. The Page Control can only be changed by a far branch or indirect addressed branch changing the Instruction Pointer to a different page.

All absolute and relative addressed instructions can only directly reach memory within the current page, essentially allowing faster access to local data. Indirect addressing and far addressing can access bytes anywhere within the complete 65,536 byte memory space.

Notably, the Program Counter reaching its maximum value and wrapping to 0 does not cause the Instruction Pointer to be advanced into the following page. Only branch instructions can change the current page.

The 4KiB of on-die SRAM lie entirely within the first half of page 0.

Instruction Addressing Modes

Implied

The instruction consists only of a 8-bit opcode. All operands are implied.

Register Addressing

All instructions that operate on a single register in-place are encoded in a single byte with a 6-bit opcode and 2-bit register index.

Zero Addressing

This is a special form of Register Addressing that is identical in encoding but operates on a pair of registers, the second of which is always implied to be R0.

With the exception of strz or unless otherwise specified, R0 is also the destination for the instruction result with the specified register index only used as a source.

Immediate Addressing

Immediate addressed instructions operate on a register and immediate value. The operation and register are encoded as in Register Addressing and followed by a second byte containing the immediate value.

Relative Addressing

Relative addressed instructions are either branch instructions or memory reference instructions, in which case they load or store one byte in memory as part of their operation. Relative instructions reference a memory location relative to the current Program Counter value. The second byte contains a signed 7-bit displacement value that is added to the Program Counter to obtain the effective address.

Indirect addressing may additionally be specified.

There are some exceptions (zbsr, zbrr) where the effective address is computed not as relative to the Program Counter, but as relative to address 0, page 0.

This mode applies the same to branch or memory reference instructions.

Absolute Addressing for non-branch instructions

Absolute addressed instructions encode a complete 13-bit page-relative address in the two bytes following the opcode and register index. This immediate address is the effective address.

Indirect and/or indexed addressing may additionally be specified.

Absolute Addressing for branch instructions

Absolute addressing for branch instructions differs from regular absolute addressing, not allowing for indexed addressing (but still allowing indirect addressing).

These instructions encode a 15-bit address as the branch target, corresponding to the entire PC and the 2 least-significant bits of Page Control. The most significant bit of Page Control is unchanged.

Additionally, the register index may instead be a Condition Code Mask for conditional branches.

Far / Far Indirect addressing

Far and Far Indirect addressing modes were added in the AS2650v2 to extend the available total address space to 65,536 bytes, as well as make working with the paged memory layout easier.

These instructions encode a full 16-bit address. Unlike the other addressing modes, wether indirect addressing is specified is encoded in the opcode.

This mode applies the same to branch or memory reference instructions.

Indirect Addressing

Indirect Addressing may be specified on top of another addressing mode, when supported, by setting the I bit. When specified, the original effective address of the instruction is no longer the true memory reference. Instead, two successive bytes are read from this location which become the new effective address for the memory reference.

Essentially, this mode implements a pointer dereference. The pointer is stored in big endian format.

Indexed Addressing

Indexed Addressing may be specified on top of another addressing mode, when supported, by setting the Index Control bits to a value other than zero. Once enabled, the register index in the first instruction byte instead specifies which register to use for indexing. The operation’s actual register index implicitly becomes R0.

The current value of the register chosen for indexing is added onto the original effective address to obtain the new effective address.

If autoincrement or autodecrement are specified, the index register’s value is incremented or decremented before the address calculation.

Table 7 Index Control

Bit 6

Bit 5

Meaning

0

0

No indexing

0

1

Indexed with auto-increment

1

0

Indexed with auto-decrement

1

1

Indexed only

Indexed and Indirect Addressing may both be supported on the same instruction. They are not mutually exclusive. If both are specified, the Indirect Addressing takes precedence and the pointer is read from memory and the index added onto it.

Extended Instructions

The AS2650v2 contains a series of extended instructions marked by a prefix, B7h. If the processor encounters this opcode, it will skip it and interpret the following byte(s) as an extended instruction. Besides this prefix, extended instructions follow the same rules for their addressing modes.

Instructions

Note: for most (but not all) non-extended instructions, the addressing mode is encoded within the least significant two bits of the opcode. This will be refered to as m from here on out, and is defined as follows:

Table 8 Adressing mode encodings

m

Mode

00

Zero Addressing

01

Immediate Addressing

10

Relative Addressing

11

Absolute Addressing

Additionally, in these cases, the addressing mode is represented as part of the instruction mnemonic, either as a z, i, r, a or f character at the end of the mnemonic.

lodz/lodi/lodr/loda - Load Register value

These instructions transfer a byte of data into one of the general purpose registers. The source of the value may be another register, an immediate or a memory reference.

Affected flags: CC

eorz/eori/eorr/eora - Logical Exclusive OR

These instructions perform an exclusive OR logic operation on the bits of both operands.

Affected flags: CC

andz/andi/andr/anda - Logical AND

These instructions perform a AND logic operation on the bits of both operands.

Affected flags: CC

Note: the combination of r == 0 and m == 0 (andz,r0) is invalid. This opcode is used for a different instruction.

iorz/iori/iorr/iora - Logical Inclusive OR

These instructions perform a OR logic operation on the bits of both operands.

Affected flags: CC

addz/addi/addr/adda - Addition

These instructions perform an arithmatic addition on both operands. If the WC bit in the PSL is set, the carry flag C is also added onto the result.

The carry flag will be set to the carry out of the addition. The interdigit carry will be set to the carry from bit 3 to bit 4. The overflow flag is set if a signed overflow occured.

Affected flags: CC, C, IDC, OVF

subz/subi/subr/suba - Subtraction

These instructions perform an arithmatic subtraction of one operand from the other. If the WC bit in the PSL is set, the inverse of the carry flag C is also subtracted from the result.

In the case of Zero Addressing, the subtrahend is the value of the register determined by the register index. In the case of Immediate Addressing or a memory reference addressing, the subtrahend is the immediate or value from memory.

Internally, this operation forms the binary complement subtrahend and adds it onto the minuend, and also adds either one (WC == 0) or the carry flag (WC == 1).

The carry flag will be set to the carry out of this addition. The interdigit carry will be set to the carry from bit 3 to bit 4. The overflow flag is set if a signed overflow occured.

Affected flags: CC, C, IDC, OVF

strz/strr/stra - Store Register Value

These instructions store a register value to another register or memory. Immediate Addressing or a combination of r == 0 and m == 0 may not be specified. These opcodes are used for other instructions.

The CC is not affected unless m == 0 (Zero Addressing), in which case it is affected as normal based on the stored value. In Zero Addressing, the value of R0 is copied into another register.

comz/comi/comr/coma - Compare Values

These instructions compare two values from registers or memory and set the Condition Code according to the following tables. No registers or memory values are modified, only the comparison takes place.

If Zero Addressing is used:

Table 9 Condition Codes (Zero Addressing)

Meaning

CC

R0 > r

01

R0 == r

00

R0 < r

10

Otherwise, where V is the byte loaded by the memory reference:

Table 10 Condition Codes

Meaning

CC

r > V

01

r == V

00

r < V

10

The comparison can be either signed or unsigned as set by the COM bit in PSL (signed if COM == 0, unsigned if COM == 1).

Affected flags: CC

bctr/bcta - Branch on Condition True

These instructions affect a relative or absolute branch only if the Condition Code matches the mask in the opcode, or the mask is equal to 11, which always affects an unconditional branch.

In the instruction mnemonic, the mask value can either be defined explicitely, eg. bcta,2 [target] or according to the following syntax:

Table 11 Branch condition syntax

Syntax

Mask value

eq (equal)

00

gt (greater-than)

01

lt (less-than)

10

un (unconditional)

11

eg. bctr,eq [target]

Affected flags: none

bstr/bsta - Branch to Subroutine on Condition True

These instructions behave identically to bctr/bcta explained above, except that they additionally push a return address onto the internal stack if the branch is taken. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

Affected flags: none

brnr/brna - Branch if Not Zero

These instructions test the specified general purpose register’s value and only affect a branch if it is not zero. The register value is not modified.

Affected flags: none

bsnr/bsna - Branch to Subroutine if Not Zero

These instructions behave identically to brnr/brna explained above, except that they additionally push a return address onto the internal stack if the branch is taken. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

Affected flags: none

bcfr/bcfa - Branch on Condition False

These instructions affect a relative or absolute branch only if the Condition Code does not match the mask in the opcode.

In the instruction mnemonic, the mask value can either be defined explicitely, eg. bcfa,2 [target] or according to the following syntax:

Table 12 Branch condition syntax

Syntax

Mask value

eq (equal)

00

gt (greater-than)

01

lt (less-than)

10

Illegal

11

eg. bcfr,eq [target]

The CC mask may not be equal to 3. Those opcodes are used by other instructions.

Affected flags: none

bsfr/bsfa - Branch to Subroutine on Condition False

These instructions behave identically to bcfr/bcfa explained above, except that they additionally push a return address onto the internal stack if the branch is taken. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

The CC mask may not be equal to 3. Those opcodes are used by other instructions.

Affected flags: none

birr/bira - Branch on Incrementing Register Not Zero

These instructions first increment the specified register, then affect a branch only if the new register value is not equal to zero.

Affected flags: none

bdrr/bdra - Branch on Decrementing Register Not Zero

These instructions first decrement the specified register, then affect a branch only if the new register value is not equal to zero.

Affected flags: none

retc - Return on Condition True

These instructions affect a subroutine return if the Condition Code matches the mask in the opcode. When true, a value is popped off of the internal stack and used to load the Page Control and Program Counter to become the new Instruction Pointer.

Affected flags: none

rete - Return on Condition True and Enable Interrupts

These instructions affect a subroutine return if the Condition Code matches the mask in the opcode. When true, a value is popped off of the internal stack and used to load the Page Control and Program Counter to become the new Instruction Pointer.

Additionally, the Interrupt Inhibit bit in the PSU is cleared, enabling interrupts globally.

Affected flags: II

rrr - Rotate Register Right

These instructions perform a right-rotate on the specified register in-place. The exact operation depends on the state of the WC flag in the PSL.

If WC is clear, the register is right-rotated and the Carry and Interdigit Carry are not changed. Bit 7 of the new register value is set from Bit 0 of the previous value.

If WC is set, the register is right-rotated through the Carry. The previous Carry is shifted into bit 7 of the result and the previous bit 0 becomes the next Carry. Additionally, the Interdigit Carry is loaded from bit 6 of the old register value.

Affected flags: CC, C (if WC), IDC (if WC)

rrl - Rotate Register Left

These instructions perform a left-rotate on the specified register in-place. The exact operation depends on the state of the WC flag in the PSL.

If WC is clear, the register is left-rotated and the Carry and Interdigit Carry are not changed. Bit 0 of the new register value is set from Bit 7 of the previous value.

If WC is set, the register is left-rotated through the Carry. The previous Carry is shifted into bi t 0 of the result and the previous bit 7 becomes the next Carry. Additionally, the Interdigit Carry is loaded from bit 4 of the old register value.

Affected flags: CC, C (if WC), IDC (if WC)

dar - Decimal Adjust Register

These instructions perform a decimal adjust based on the states of the Carry and Interdigit Carry to help perform arithmatic on packed BCD values.

If the Carry is clear, a value of A0h is added to the register’s value.

If the Interdigit Carry is clear, a value of 0Ah is added to the register’s value.

If both are clear, a value of AAh is added to the register’s value.

Packed BCD operations may then be performed according to these algorithms:

To perform addition, add 66h to either term, then add both terms. This instruction will then adjust the sum to its correct BCD value.

To perform subtraction, perform subtraction as normal, then execute this instruction to get the correct BCD result.

Affected flags: none

wrtc - Write Command

This instruction triggers a external IO Write transaction using the value of the specified register as the value written. The IOC and WE lines are asserted as part of the transaction.

Affected flags: none

wrtd - Write Data

This instruction triggers a external IO Write transaction using the value of the specified register as the value written. The IOD and WE lines are asserted as part of the transaction.

Affected flags: none

redc - Read Command

This instruction triggers a external IO Read transaction and saves the received value into the specified register. The IOC and OE lines are asserted as part of the transaction.

Affected flags: CC

redd - Read Data

This instruction triggers a external IO Read transaction and saves the received value into the specified register. The IOD and OE lines are asserted as part of the transaction.

Affected flags: CC

wrte - Write Extended IO

This instruction triggers a write to an on-die IO device using the value of the specified register. A immediate 8-bit address follows the opcode which is decoded to address one of the on-die peripheral registers.

Affected flags: none

rede - Read Extended IO

This instruction triggers a read from an on-die IO device and writes the received value into the specified register. A immediate 8-bit address follows the opcode which is decoded to address one of the on-die perhipheral registers.

Affected flags: CC

spsu - Store Program Status Upper

This instruction copies the value of the PSU into R0. Flags are not affected until after the copy.

Affected flags: CC

spsl - Store Program Status Lower

This instruction copies the value of the PSL into R0. Flags are not affected until after the copy.

Affected flags: CC

lpsu - Load Program Status Upper

This instruction copies the value in R0 into the PSU.

Affected flags: S, F, II, SP

lpsl - Load Program Status Lower

This instruction copies the value in R0 into the PSL.

Affected flags: CC, IDC, RS, WC, OVF, COM, C

halt - Halt

This instruction pauses program execution until an interrupt occurs. The Program Counter will become stuck in place until the servicing of an interrupt routine. Once the interrupt routine returns, execution resumes from the first instruction following the halt.

Affected flags: none

cpsu - Clear bits in Program Status Upper

This immediate-addressed instruction clears specific bits in the PSU according to the mask in its immediate argument. All bits in the PSU for which the corresponding bit in the mask is a one will be cleared to zero.

Affected flags: S, F, II, SP

cpsl - Clear bits in Program Status Lower

This immediate-addressed instruction clears specific bits in the PSL according to the mask in its immediate argument. All bits in the PSL for which the corresponding bit in the mask is a one will be cleared to zero.

Affected flags: CC, IDC, RS, WC, OVF, COM, C

ppsu - Preset bits in Program Status Upper

This immediate-addressed instruction sets specific bits in the PSU according to the mask in its immediate argument. The mask is simply inclusive-OR’d onto the PSU.

Affected flags: S, F, II, SP

ppsl - Preset bits in Program Status Lower

This immediate-addressed instruction sets specific bits in the PSL according to the mask in its immediate argument. The mask is simply inclusive-OR’d onto the PSL.

Affected flags: CC, IDC, RS, WC, OVF, COM, C

tpsu - Test Program Status Upper

This immediate-addressed instruction tests bits in the PSU according to the mask in its immediate argument. Every bit in the PSU for which there is a one in the mask is checked. The test succeeds if all checked bits are one.

Table 13 Condition Codes

Meaning

CC

All of the selected bits are one

00

Not all of the selected bits are one

10

Affected flags: CC

tpsl - Test Program Status Lower

This immediate-addressed instruction tests bits in the PSL according to the mask in its immediate argument. Every bit in the PSL for which there is a one in the mask is checked. The test succeeds if all checked bits are one.

Table 14 Condition Codes

Meaning

CC

All of the selected bits are one

00

Not all of the selected bits are one

10

Affected flags: CC

nop - No Operation

No operation is performed and the following instruction executed.

Affected flags: none

tmi - Test Under Mask Immediate

This immediate-addressed instruction tests bits in the value of the specified register according to the mask in its immediate argument. Every bit in the register value for which there is a one in the mask is checked. The test succeeds if all checked bits are ones.

Table 15 Condition Codes

Meaning

CC

All of the selected bits are one

00

Not all of the selected bits are one

10

Affected flags: CC

zbrr - Zero-Branch Relative

This relative-addressed instruction performs a unconditional branch to a location relative to page 0, byte 0. The displacement in the argument is interpreted as being relative to this address and negative values cause a wrap-around to page 0, byte 8191 - 8128.

Affected flags: CC

zbsr - Zero-Branch to Subroutine Relative

This instruction behaves identically to zbrr explained above, except that it additionally pushes a return address onto the internal stack. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

Affected flags: CC

bxa - Branch Indexed, Absolute

This absolute-addressed instruction is encoded the same as an unconditionally, absolute branch instruction but has indexing implicitely enabled. The index register is always R3, however.

Affected flags: CC

bsxa - Branch to Subroutine Indexed, Absolute

This instruction behaves identically to bxa explained above, except that it additionally pushes a return address onto the internal stack. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

Affected flags: CC

Extended Instructions

Extended Instructions, in this case, refers to all instructions that were added in the AS2650v2 on top of the original 2650’s instruction set. Not all of these use the extension prefix. Some use opcodes that went unused in the 2650. Which instructions use the prefix will be indicated as part of their opcode.

push - Push to Internal Stack

This instruction pushes a 16-bit wide value pair onto the internal stack. These values are taken from registers R0 (LSB, bits 0 - 7) and R1 (MSB, bits 8 - 15).

Affected flags: none

pop - Pop from Internal Stack

This instruction pops a 16-bit wide value pair from the internal stack into registers R0 (LSB, bits 0 - 7) and R1 (MSB, bits 8 - 15). No flags are affected despite the register writes.

push and pop are intended to allow the call stack to be spilled over into memory if necesarry and are not meant to be used to store program data.

Affected flags: none

mul - Unsigned multiply of R0 and R1

This instruction multiplies the value of R0 by the value of R1. This produces a 16-bit result that is written back into R0 (LSB, bits 0 - 7) and R1 (MSB, bits 8 - 15). The Condition Code is set according to the full 16-bit value.

Affected flags: CC

xchg - Exchange R0 and R1

This instruction exchanges the values in R0 and R1 in-place without affecting flags.

Affected flags: none

clr - Clear Register

This instruction sets the value of the specified register to zero. No flags are affected despite the register change.

Affected flags: none

trap - Software Trap

This instruction sets the trap interrupt (priority 4) as pending. This does not mean that the interrupt is immediately served as any incoming higher-priority interrupts will be served first. Additionally, the instruction has no effect if the global Interrupt Inhibit flag is set. The trap will remain pending until the flag is cleared.

Affected flags: none

clrt - Clear Trap Pending Flag

This instruction serves as the pending interrupt clear for the software trap. It will always clear any pending trap interrupt even if that interrupt hasn’t been served yet.

Affected flags: none

cpl - Complement Register

This instruction complements all the bits of the specified register’s value. Notably, this operation does not affect any flags.

Affected flags: none

pshs - Push Program Status

This instruction pushes the whole PSW onto the internal stack. It is meant to only be used at the start of interrupt routines.

Affected flags: none

pops - Pop Program Status

This instruction pops a value from the internal stack and loads it into the PSW. It is meant to only be used at the end of interrupt routines.

Affected flags: S, F, II, SP, CC, IDC, RS, WC, OVF, COM, C

svb - Set Interrupt Vector Base

This instruction sets the value of the IVB register by copying the combined value of R0 (LSB, bits 4 - 7) and R1 (MSB, bits 8 - 15). Bits 0 - 3 are always zero.

Affected flags: none

lodf - Load Register value, Far

This instruction performs a register load from memory same as lodr/loda, but using Far Addressing.

Affected flags: CC

ldfi - Load Register value, Far Indirect

This instruction performs a register load from memory same as lodr/loda but using Far Addressing plus Indirect Addressing.

Affected flags: CC

strf - Store Register value, Far

This instruction performs a register store to memory same as strr/stra, but using Far Addressing.

Affected flags: none

stfi - Store Register value, Far Indirect

This instruction performs a register store to memory same as strr/stra, but using Far Addressing plus Indirect Addressing.

Affected flags: none

bctf - Branch on Condition True, Far

This instruction behaves the same as bcta, branching only if the Condition Code value matches the Mask in the opcode, but using Far Addressing. This sets all 3 bits of Page Control as well as all 13 bits of the Program Counter.

Affected flags: none

bstf - Branch to Subroutine on Condition True, Far

This instruction behaves the same as bctf, except that it additionally pushes a return address onto the internal stack if the branch is taken. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

Affected flags: none

brnf - Branch on Not Zero, Far

This instruction behaves the same as brna, branching only if the specified register’s value is not zero, but using Far Addressing. This sets all 3 bits of Page Control as well as all 13 bits of the Program Counter.

Affected flags: none

bsnf - Branch to Subroutine on Not Zero, Far

This instruction behaves the same as brnf, except that it additionally pushes a return address onto the internal stack if the branch is taken. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

Affected flags: none

bcff - Branch on Condition False, Far

This instruction behaves the same as bcfa, branching only if the Condition Code does not match the Mask in the opcode, but using Far Addressing. This sets all 3 bits of Page Control as well as all 13 bits of the Program Counter.

The CC mask may not be equal to 3. This opcode is used by another instruction.

Affected flags: none

bsff - Branch to Subroutine on Condition False, Far

This instruction behaves the same as bcff, except that it additionally pushes a return address onto the internal stack if the branch is taken. This address is a complete Instruction Pointer and will always point to the instruction immediatly following the branch.

The CC mask may not be equal to 3. This opcode is used by another instruction.

Affected flags: none

birf - Branch on Incrementing Register Not Zero, Far

This instruction behaves the same as bira, branching only if the value of the specified register after it is incremented is not zero, but using Far Addressing. This sets all 3 bits of Page Control as well as all 13 bits of the Program Counter.

Affected flags: none

bdrf - Branch on Decrementing Register Not Zero, Far

This instruction behaves the same as bira, branching only if the value of the specified register after it is decremented is not zero, but using Far Addressing. This sets all 3 bits of Page Control as well as all 13 bits of the Program Counter.

Affected flags: none