sd:isa
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sd:isa [2026/06/16 08:13] – appledog | sd:isa [2026/06/18 04:53] (current) – appledog | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| == ISA Overview | == ISA Overview | ||
| The SD-8516 instruction set is organized into four tiers. Numbering is canonical | The SD-8516 instruction set is organized into four tiers. Numbering is canonical | ||
| - | in decimal (as defined in '' | + | in decimal (as defined in '' |
| * **Tier 1 - Core** behaves like a RISC instruction set: small, orthogonal, and complete on its own. Target this first. Everything above it can be synthesized from the core if you have to. | * **Tier 1 - Core** behaves like a RISC instruction set: small, orthogonal, and complete on its own. Target this first. Everything above it can be synthesized from the core if you have to. | ||
| * **Tier 2 - Extended** are quality-of-life instructions for hand assemblers. '' | * **Tier 2 - Extended** are quality-of-life instructions for hand assemblers. '' | ||
| * **Tier 3 - CISC** are heavier, mostly VAX- and 680x0-flavored instructions: | * **Tier 3 - CISC** are heavier, mostly VAX- and 680x0-flavored instructions: | ||
| - | * **Tier 4 - Acceleration** are instructions added primarily to speed up a specific consumer: the LLVM backend ('' | + | * **Tier 4 - Acceleration** are instructions added primarily to speed up a specific consumer: the LLVM backend ('' |
| A handful of opcodes carry aliases (e.g. '' | A handful of opcodes carry aliases (e.g. '' | ||
| Line 57: | Line 57: | ||
| | 254 | $FE | [[# | | 254 | $FE | [[# | ||
| | 255 | $FF | [[# | | 255 | $FF | [[# | ||
| + | |||
| + | Although this is intended as a RISC core, there are some extras here, primarily LD-8bit hot path, which is done to speed up execution of 8 bit loads by about 30%. Additionally, | ||
| + | |||
| + | POPF however, is a strong canidate for removal. It would really only be needed for a kind of protected mode, interrupt mode or kernal mode, and we dont use it currently. | ||
| + | |||
| + | Finally, it may be interesting to fuse CMP and JZ. Imagine, any CMP and conditional jump could be a CJMP. ex. '' | ||
| + | |||
| + | Consider: | ||
| + | * No CMP exists in isolation | ||
| + | * No JZ exists without responding to a change in the Z flag. | ||
| + | * CJZ A, A can test for zero after a load if we really need one. | ||
| + | |||
| + | Further investigate: | ||
| + | * Does the cost of flag calculation outweight dispatch for how often a CMP occurrs? | ||
| === Tier 2: Extended (Quality of Life) | === Tier 2: Extended (Quality of Life) | ||
| Line 164: | Line 178: | ||
| === Tier 4: Acceleration (LLVM / Forth / Hardware) | === Tier 4: Acceleration (LLVM / Forth / Hardware) | ||
| - | Instructions added to remove work from a specific hot path rather than to add | + | Instructions added to remove work from a specific hot path rather than to add expressiveness. Each one has a primary consumer noted below. |
| - | expressiveness. Each one has a primary consumer noted below. | + | |
| + | Canidates for inclusion: LEA, fused CMP-Bcc and CMP-Jcc, conditional move, LD_IDX16 | ||
| | # | hex | Mnemonic | Example | | # | hex | Mnemonic | Example | ||
| Line 374: | Line 389: | ||
| <wrap #cmpc /> | <wrap #cmpc /> | ||
| **''# | **''# | ||
| - | Non-zero byte compare, useful for strings. Compares up to C characters; C returns | + | Non-zero byte compare, useful for strings. Compares up to C characters; C returns either the index of the first mismatch or the matched length. Sets ZERO on a full match; otherwise CARRY distinguishes the -1 / +1 ordering. |
| - | either the index of the first mismatch or the matched length. Sets ZERO on a full | + | |
| - | match; otherwise CARRY distinguishes the -1 / +1 ordering. | + | |
| - | CMPC allows early termination when '' | + | CMPC allows early termination when '' |
| - | semantics. If both strings reach a terminator at the same position with all prior | + | |
| - | bytes equal, the loop exits matched (Z=1, C=1). Only '' | + | |
| - | that point '' | + | |
| - | '' | + | |
| - | null-terminated strcmp in one instruction. | + | |
| <wrap #skpc /> | <wrap #skpc /> | ||
| Line 479: | Line 487: | ||
| <wrap #casetab /> | <wrap #casetab /> | ||
| **''# | **''# | ||
| - | Jump table held at a base address rather than inline. Indexes an address from the | + | Jump table held at a base address rather than inline. Indexes an address from the table at '' |
| - | table at '' | + | |
| - | //The precise indexing and out-of-bounds policy should be confirmed against the | + | |
| - | current emulator handler: the older CASE3 (computed table at base) and CASEB | + | |
| - | (scanned '' | + | |
| - | table-at-base form.// | + | |
| <wrap #cvtan /> | <wrap #cvtan /> | ||
| **''# | **''# | ||
| - | Convert ASCII to number. Maps ' | + | Convert ASCII to number. Maps ' |
| - | a decimal digit (0-9) and Carry if it is not a hex digit (0-15). Also a fast digit | + | |
| - | test: '' | + | |
| - | Designed for zoned decimal, and works for zoned hex. | + | |
| <wrap #cvtna /> | <wrap #cvtna /> | ||
| Line 499: | Line 499: | ||
| <wrap #idx /> | <wrap #idx /> | ||
| - | **''# | + | **''# |
| - | Indexed load/store: a 24-bit pointer register plus a displacement. The '' | + | |
| - | take a signed byte immediate (-128..+127); | + | |
| - | These back the compiler' | + | |
| - | pointer base must be a 24-bit register; the effective address reads the base at its | + | |
| true width before applying the offset. | true width before applying the offset. | ||
| Line 521: | Line 517: | ||
| <codify armasm> | <codify armasm> | ||
| - | LDFLX $F000 ; loop start | + | LDFLX $F000 ; |
| - | LDA #1 | + | LDA #1 ; start at 1 |
| - | STA [FLX] | + | STA [FLX] ; write starting counter at first four bytes |
| - | LDA #1000 | + | LDA #1000 ; go until 1000 |
| - | STA [FLX+4] | + | STA [FLX+4] |
| loop: | loop: | ||
| - | LSTEPM | + | LSTEPM |
| JNZ @loop | JNZ @loop | ||
| </ | </ | ||
| - | Unlike a DEC loop it counts upward and supports an arbitrary start. | + | Unlike a DEC loop it counts upward and supports an arbitrary start. |
| - | for Forth and has been generalized by [[# | + | |
| - | LSTEPM | + | Only used by Forth. It is recommended to use LSTEP instead; this instruction |
| <wrap #ttos /> | <wrap #ttos /> | ||
sd/isa.1781597626.txt.gz · Last modified: by appledog
