summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asmmon.h446
-rw-r--r--disasm.c6
-rw-r--r--disasm.h3
-rw-r--r--enums.h5
-rw-r--r--opcode.h2
-rw-r--r--programs/subasm.s76
-rw-r--r--programs/subeditor.s241
-rw-r--r--sux.c3
-rw-r--r--tables.h5
-rw-r--r--test/add-sub.s2
-rw-r--r--test/fib2.s14
-rw-r--r--test/hello-world.s22
-rw-r--r--test/input-2.s412
-rw-r--r--test/input-3.s900
-rw-r--r--test/input.s338
-rw-r--r--test/subroutine.s4
-rw-r--r--test/test.s17
17 files changed, 414 insertions, 2082 deletions
diff --git a/asmmon.h b/asmmon.h
index 52315a9..059d801 100644
--- a/asmmon.h
+++ b/asmmon.h
@@ -138,82 +138,80 @@ static const uint8_t opcodes[OPNUM][9] = {
[11] = {0x19, 0x3D, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, 0x4C, 0xFF},
[12] = {0x1A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
[13] = {0xFF, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0xF5},
- [14] = {0xFF, 0x1E, 0xFF, 0xFF, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF},
- [15] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0xFF},
- [16] = {0x21, 0x26, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0xFF},
- [17] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x22},
- [18] = {0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [19] = {0x29, 0x4D, 0xFF, 0xFF, 0xB5, 0xFF, 0xFF, 0x3C, 0xFF},
- [20] = {0x2A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [21] = {0xFF, 0x2E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0xFF},
- [22] = {0x31, 0x36, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x34, 0xFF},
- [23] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x32},
- [24] = {0x38, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [25] = {0x3A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [26] = {0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0xFF},
- [27] = {0x41, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x44, 0xFF},
- [28] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x42},
- [29] = {0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [30] = {0x4A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [31] = {0xFF, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0xFF},
- [32] = {0x51, 0x56, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x54, 0xFF},
- [33] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x52},
- [34] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x58},
- [35] = {0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [36] = {0xFF, 0x5E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xFF},
- [37] = {0x61, 0x66, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x64, 0xFF},
- [38] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62},
- [39] = {0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- [40] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6A},
- [41] = {0xFF, 0x6E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xFF},
- [42] = {0x71, 0x76, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x74, 0xFF},
- [43] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x72},
- [44] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78},
- [45] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7A},
- [46] = {0xFF, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xFF},
- [47] = {0x81, 0x86, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x84, 0xFF},
- [48] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82},
- [49] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x88},
- [50] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8A},
- [51] = {0xFF, 0x8E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x90, 0xFF},
- [52] = {0x91, 0x96, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF},
- [53] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x92},
- [54] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x98},
- [55] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x9A},
- [56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F, 0xFF, 0xEC, 0xFF},
+ [83] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEE},
+ [84] = {0xF1, 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xFF},
+ [85] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2},
+ [86] = {0xFF, 0xFD, 0xFF, 0xD9, 0xA5, 0xFF, 0xFF, 0xFC, 0xFF},
+ [87] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE}
};
static const char *dir_t[6] = {
@@ -278,81 +276,79 @@ static const char *mne[OPNUM] = {
[12] = "PLB",
[13] = "INC",
[14] = "JSR",
- [15] = "JSL",
- [16] = "AND",
- [17] = "ABA",
- [18] = "PLP",
- [19] = "CPX",
- [20] = "PHY",
- [21] = "BPO",
- [22] = "ORA",
- [23] = "OAB",
- [24] = "STT",
- [25] = "PLY",
- [26] = "BNG",
- [27] = "XOR",
- [28] = "XAB",
- [29] = "PHA",
- [30] = "PHX",
- [31] = "BCS",
- [32] = "LSL",
- [33] = "LLB",
- [34] = "CLC",
- [35] = "PLX",
- [36] = "BCC",
- [37] = "LSR",
- [38] = "LRB",
- [39] = "PLA",
- [40] = "TAB",
- [41] = "BEQ",
- [42] = "ROL",
- [43] = "RLB",
- [44] = "SEC",
- [45] = "TBA",
- [46] = "BNE",
- [47] = "ROR",
- [48] = "RRB",
- [49] = "DEY",
- [50] = "TAY",
- [51] = "BVS",
- [52] = "MUL",
- [53] = "MAB",
- [54] = "CLI",
- [55] = "TYA",
- [56] = "BVC",
- [57] = "DIV",
- [58] = "DAB",
- [59] = "INY",
- [60] = "TAX",
- [61] = "RTS",
- [62] = "RTL",
- [63] = "CMP",
- [64] = "CAB",
- [65] = "SEI",
- [66] = "LDX",
- [67] = "TXA",
- [68] = "RTI",
- [69] = "LDA",
- [70] = "DEX",
- [71] = "CLV",
- [72] = "TYX",
- [73] = "STA",
- [74] = "TSX",
- [75] = "LDB",
- [76] = "INX",
- [77] = "WAI",
- [78] = "TXY",
- [79] = "STB",
- [80] = "TXS",
- [81] = "LDY",
- [82] = "BRK",
- [83] = "NOP",
- [84] = "STY",
- [85] = "DEB",
- [86] = "ASR",
- [87] = "ARB",
- [88] = "STX",
- [89] = "INB"
+ [15] = "AND",
+ [16] = "ABA",
+ [17] = "PLP",
+ [18] = "CPX",
+ [19] = "PHY",
+ [20] = "BPO",
+ [21] = "ORA",
+ [22] = "OAB",
+ [23] = "STT",
+ [24] = "PLY",
+ [25] = "BNG",
+ [26] = "XOR",
+ [27] = "XAB",
+ [28] = "PHA",
+ [29] = "PHX",
+ [30] = "BCS",
+ [31] = "LSL",
+ [32] = "LLB",
+ [33] = "CLC",
+ [34] = "PLX",
+ [35] = "BCC",
+ [36] = "LSR",
+ [37] = "LRB",
+ [38] = "PLA",
+ [39] = "TAB",
+ [40] = "BEQ",
+ [41] = "ROL",
+ [42] = "RLB",
+ [43] = "SEC",
+ [44] = "TBA",
+ [45] = "BNE",
+ [46] = "ROR",
+ [47] = "RRB",
+ [48] = "DEY",
+ [49] = "TAY",
+ [50] = "BVS",
+ [51] = "MUL",
+ [52] = "MAB",
+ [53] = "CLI",
+ [54] = "TYA",
+ [55] = "BVC",
+ [56] = "DIV",
+ [57] = "DAB",
+ [58] = "INY",
+ [59] = "TAX",
+ [60] = "RTS",
+ [61] = "CMP",
+ [62] = "CAB",
+ [63] = "SEI",
+ [64] = "LDX",
+ [65] = "TXA",
+ [66] = "RTI",
+ [67] = "LDA",
+ [68] = "DEX",
+ [69] = "CLV",
+ [70] = "TYX",
+ [71] = "STA",
+ [72] = "TSX",
+ [73] = "LDB",
+ [74] = "INX",
+ [75] = "WAI",
+ [76] = "TXY",
+ [77] = "STB",
+ [78] = "TXS",
+ [79] = "LDY",
+ [80] = "BRK",
+ [81] = "NOP",
+ [82] = "STY",
+ [83] = "DEB",
+ [84] = "ASR",
+ [85] = "ARB",
+ [86] = "STX",
+ [87] = "INB"
};
static const char *instdesc[OPNUM] = {
@@ -371,81 +367,79 @@ static const char *instdesc[OPNUM] = {
[12] = "PuLl the number of bytes specified, from the stack, to the B register.",
[13] = "INCrement accumulator, or memory.",
[14] = "Jump to a SubRoutine.",
- [15] = "Jump to a Subroutine, Long address.",
- [16] = "Bitwise AND accumulator, with operand.",
- [17] = "Bitwise AND Accumulator, with B.",
- [18] = "PuLl the number of bytes specified, from the stack, to the Processor status register.",
- [19] = "ComPare the X register, with operand.",
- [20] = "PusH the number of bytes specified, from the Y register to the stack.",
- [21] = "Branch if POsitive.",
- [22] = "Bitwise OR Accumulator, with operand.",
- [23] = "Bitwise OR Accumulator, with B.",
- [24] = "STart a Thread.",
- [25] = "PuLl the number of bytes specified, from the stack, to the Y register.",
- [26] = "Branch if NeGative.",
- [27] = "Bitwise XOR Accumulator, with operand.",
- [28] = "Bitwise XOR Accumulator, with B.",
- [29] = "PusH the number of bytes specified, from the Accumulator to the stack.",
- [30] = "PusH the number of bytes specified, from the X register to the stack.",
- [31] = "Branch if the Carry flag is Set.",
- [32] = "Logical Shift Left accumulator, with operand.",
- [33] = "Logical Shift Left accumulator, with B.",
- [34] = "CLear the Carry flag.",
- [35] = "PuLl the number of bytes specified, from the stack, to the X register.",
- [36] = "Branch if the Carry flag has been Cleared.",
- [37] = "Logical Shift Right accumulator, with operand.",
- [38] = "Logical Shift Right accumulator, with B.",
- [39] = "PuLl the number of bytes specified, from the stack, to the Accumulator.",
- [40] = "Transfer the value from the Accumulator, to the B register.",
- [41] = "Branch if EQual (the zero flag has been set).",
- [42] = "ROtate Left accumulator, with operand.",
- [43] = "Rotate Left accumulator, with B.",
- [44] = "SEt the Carry flag.",
- [45] = "Transfer the value from the Y register, to the Accumulator.",
- [46] = "Branch if Not Equal (the zero flag has been cleared)",
- [47] = "ROtate Right accumulator, with operand.",
- [48] = "Rotate Right accumulator, with B.",
- [49] = "DEcrement the Y register.",
- [50] = "Transfer the value from the Accumulator, to the Y register.",
- [51] = "Branch if the oVerflow flag is Set.",
- [52] = "MULtiply accumulator, with operand.",
- [53] = "Multiply Accumulator, with B.",
- [54] = "CLear the Interrupt flag.",
- [55] = "Transfer the value from the Y register, to the Accumulator.",
- [56] = "Branch if the oVerflow flag has been Cleared.",
- [57] = "DIVide accumulator, with operand, and put the remainder into the B register.",
- [58] = "Divide Accumulator, with B, and put the remainder into the X register.",
- [59] = "INcrement the Y register.",
- [60] = "Transfer the value from the Accumulator, to the X register.",
- [61] = "ReTurn from a Subroutine.",
- [62] = "ReTurn from subroutine, Long address.",
- [63] = "CoMPare acumulator, with operand.",
- [64] = "Compare Accumulator, with B.",
- [65] = "SEt the Interrupt flag.",
- [66] = "LoaD the value from the operand, to the X register.",
- [67] = "Transfer the value from the X register, to the Accumulator.",
- [68] = "ReTurn from an Interrupt.",
- [69] = "LoaD the value from the operand, to the Accumulator.",
- [70] = "DEcrement the X register.",
- [71] = "CLear the oVerflow flag.",
- [72] = "Transfer the value from the Y register, to the X register.",
- [73] = "STore the value from the Accumulator, in memory.",
- [74] = "Transfer the value from the Stack pointer, to the X register.",
- [75] = "LoaD the value from the operand, to the B register.",
- [76] = "INcrement the X register.",
- [77] = "WAIt for an interrupt",
- [78] = "Transfer the value from the X register, to the Y register.",
- [79] = "STore the value from the B register, in memory.",
- [80] = "Transfer the value from the X register, to the Stack pointer.",
- [81] = "LoaD the value from the operand, to the Y register.",
- [82] = "BReaKpoint",
- [83] = "NO oPeration",
- [84] = "STore the value from the Y register, in memory.",
- [85] = "DEcrement the B register.",
- [86] = "Arithmetic Shift Right accumulator, with operand.",
- [87] = "Arithmetic shift Right accumulator, with B.",
- [88] = "STore the value from the X register, in memory.",
- [89] = "INcrement the B register."
+ [15] = "Bitwise AND accumulator, with operand.",
+ [16] = "Bitwise AND Accumulator, with B.",
+ [17] = "PuLl the number of bytes specified, from the stack, to the Processor status register.",
+ [18] = "ComPare the X register, with operand.",
+ [19] = "PusH the number of bytes specified, from the Y register to the stack.",
+ [20] = "Branch if POsitive.",
+ [21] = "Bitwise OR Accumulator, with operand.",
+ [22] = "Bitwise OR Accumulator, with B.",
+ [23] = "STart a Thread.",
+ [24] = "PuLl the number of bytes specified, from the stack, to the Y register.",
+ [25] = "Branch if NeGative.",
+ [26] = "Bitwise XOR Accumulator, with operand.",
+ [27] = "Bitwise XOR Accumulator, with B.",
+ [28] = "PusH the number of bytes specified, from the Accumulator to the stack.",
+ [29] = "PusH the number of bytes specified, from the X register to the stack.",
+ [30] = "Branch if the Carry flag is Set.",
+ [31] = "Logical Shift Left accumulator, with operand.",
+ [32] = "Logical Shift Left accumulator, with B.",
+ [33] = "CLear the Carry flag.",
+ [34] = "PuLl the number of bytes specified, from the stack, to the X register.",
+ [35] = "Branch if the Carry flag has been Cleared.",
+ [36] = "Logical Shift Right accumulator, with operand.",
+ [37] = "Logical Shift Right accumulator, with B.",
+ [38] = "PuLl the number of bytes specified, from the stack, to the Accumulator.",
+ [39] = "Transfer the value from the Accumulator, to the B register.",
+ [40] = "Branch if EQual (the zero flag has been set).",
+ [41] = "ROtate Left accumulator, with operand.",
+ [42] = "Rotate Left accumulator, with B.",
+ [43] = "SEt the Carry flag.",
+ [44] = "Transfer the value from the Y register, to the Accumulator.",
+ [45] = "Branch if Not Equal (the zero flag has been cleared)",
+ [46] = "ROtate Right accumulator, with operand.",
+ [47] = "Rotate Right accumulator, with B.",
+ [48] = "DEcrement the Y register.",
+ [49] = "Transfer the value from the Accumulator, to the Y register.",
+ [50] = "Branch if the oVerflow flag is Set.",
+ [51] = "MULtiply accumulator, with operand.",
+ [52] = "Multiply Accumulator, with B.",
+ [53] = "CLear the Interrupt flag.",
+ [54] = "Transfer the value from the Y register, to the Accumulator.",
+ [55] = "Branch if the oVerflow flag has been Cleared.",
+ [56] = "DIVide accumulator, with operand, and put the remainder into the B register.",
+ [57] = "Divide Accumulator, with B, and put the remainder into the X register.",
+ [58] = "INcrement the Y register.",
+ [59] = "Transfer the value from the Accumulator, to the X register.",
+ [60] = "ReTurn from a Subroutine.",
+ [61] = "CoMPare acumulator, with operand.",
+ [62] = "Compare Accumulator, with B.",
+ [63] = "SEt the Interrupt flag.",
+ [64] = "LoaD the value from the operand, to the X register.",
+ [65] = "Transfer the value from the X register, to the Accumulator.",
+ [66] = "ReTurn from an Interrupt.",
+ [67] = "LoaD the value from the operand, to the Accumulator.",
+ [68] = "DEcrement the X register.",
+ [69] = "CLear the oVerflow flag.",
+ [70] = "Transfer the value from the Y register, to the X register.",
+ [71] = "STore the value from the Accumulator, in memory.",
+ [72] = "Transfer the value from the Stack pointer, to the X register.",
+ [73] = "LoaD the value from the operand, to the B register.",
+ [74] = "INcrement the X register.",
+ [75] = "WAIt for an interrupt",
+ [76] = "Transfer the value from the X register, to the Y register.",
+ [77] = "STore the value from the B register, in memory.",
+ [78] = "Transfer the value from the X register, to the Stack pointer.",
+ [79] = "LoaD the value from the operand, to the Y register.",
+ [80] = "BReaKpoint",
+ [81] = "NO oPeration",
+ [82] = "STore the value from the Y register, in memory.",
+ [83] = "DEcrement the B register.",
+ [84] = "Arithmetic Shift Right accumulator, with operand.",
+ [85] = "Arithmetic shift Right accumulator, with B.",
+ [86] = "STore the value from the X register, in memory.",
+ [87] = "INcrement the B register."
};
static const uint8_t bitsize[4] = {
diff --git a/disasm.c b/disasm.c
index 0a4b6ef..befb93b 100644
--- a/disasm.c
+++ b/disasm.c
@@ -101,8 +101,8 @@ void disasm(struct sux *cpu, uint64_t *operands, uint8_t lines, uint8_t opcode,
ptr.u8[6] = addr[adr+6]; ptr.u8[7] = addr[adr+7];
wprintw(scr, ", idx0: $%04"PRIX64, ptr.u64);
if (address == CTRL_ADDR || addr[STEP_ADDR]) {
- mvwprintw(scr, 29, 0, "address: $%04"PRIX64", scr_row: %02u, scr_col: %02u, scr_str: %02u, scr_end: %02u\r", address, addr[0], addr[1], addr[0x1C], addr[0x1D]);
- adr = 0x300000;
+ mvwprintw(scr, 29, 0, "address: $%04"PRIX64", scr_row: %02u, scr_col: %02u, scr_str: %02u, scr_end: %02u\r", address, addr[0], addr[1], addr[0x22], addr[0x23]);
+ adr = 0x30000;
wmove(scr, 32, 0);
wprintw(scr, "bitabl: ");
for (uint8_t i = 0; i < 16; i++) {
@@ -114,7 +114,7 @@ void disasm(struct sux *cpu, uint64_t *operands, uint8_t lines, uint8_t opcode,
line_idx = (i << 6) + (i << 4);
for (uint8_t j = 0; j < 0x50; j++) {
wprintw(scr, "%02X", addr[tmpad+j+line_idx]);
- if ((addr[0]+addr[0x1C]) == i && addr[1] == j) {
+ if ((addr[0]+addr[0x22]) == i && addr[1] == j) {
iscursor=1;
getyx(scr,row, col);
wmove(scr, ln++, 0);
diff --git a/disasm.h b/disasm.h
index 8fe2b4c..ce35ad3 100644
--- a/disasm.h
+++ b/disasm.h
@@ -23,7 +23,7 @@ static const char *opname[0x100] = {
[0x1C] = "INC a",
[0x1D] = "INC zm",
[0x1E] = "JSR zm",
- [0x20] = "JSL a",
+ [0x20] = "JSR a",
[0x21] = "AND #",
[0x22] = "ABA",
[0x24] = "AND a",
@@ -131,7 +131,6 @@ static const char *opname[0x100] = {
[0xAC] = "CPB iny",
[0xAD] = "CPB inx",
[0xAE] = "RTS",
- [0xB0] = "RTL",
[0xB1] = "CMP #",
[0xB2] = "CAB",
[0xB4] = "CMP a",
diff --git a/enums.h b/enums.h
index f5d30a8..451f5c2 100644
--- a/enums.h
+++ b/enums.h
@@ -23,8 +23,8 @@ enum base_isa {
PLB = 0x1A, /* PuLl B register to stack. */
INC_AB = 0x1C, /* INC Absolute. */
INC_Z = 0x1D, /* INC Zero Matrix. */
- JSR = 0x1E, /* Jump to SubRoutine. */
- JSL = 0x20, /* Jump to Subroutine Long. */
+ JSR_Z = 0x1E, /* Jump to SubRoutine. */
+ JSR = 0x20, /* JSR Absolute. */
AND = 0x21, /* bitwise AND with accumulator. */
ABA = 0x22, /* bitwise And with Accumulator, and B register. */
AND_AB = 0x24, /* AND Absolute. */
@@ -132,7 +132,6 @@ enum base_isa {
CPB_IY = 0xAC, /* CPB Indirect Indexed. */
CPB_IX = 0xAD, /* CPB Indexed Indirect. */
RTS = 0xAE, /* ReTurn from Subroutine. */
- RTL = 0xB0, /* ReTurn from subroutine Long. */
CMP = 0xB1, /* CoMPare accumulator. */
CAB = 0xB2, /* Compare Accumulator, and B. */
CMP_AB = 0xB4, /* CMP Absolute. */
diff --git a/opcode.h b/opcode.h
index 1fb06ff..c36daf8 100644
--- a/opcode.h
+++ b/opcode.h
@@ -10,7 +10,7 @@
#define getclk 0
#define keypoll 0
-#define OPNUM 90
+#define OPNUM 88
#define C (1 << 0) /* Carry flag. */
#define Z (1 << 1) /* Zero flag. */
diff --git a/programs/subasm.s b/programs/subasm.s
index 350e105..e5d620f 100644
--- a/programs/subasm.s
+++ b/programs/subasm.s
@@ -65,8 +65,7 @@ mne:
.byte "CPY", $19, $3D, $FF, $FF, $85, $FF, $FF, $4C, $FF
.byte "PLB", $1A, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte "INC", $FF, $1D, $FF, $FF, $FF, $FF, $FF, $1C, $F5
- .byte "JSR", $FF, $1E, $FF, $FF, $BE, $FF, $FF, $FF, $FF
- .byte "JSL", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $20, $FF
+ .byte "JSR", $FF, $1E, $FF, $FF, $BE, $FF, $FF, $20, $FF
.byte "AND", $21, $26, $FF, $FF, $FF, $FF, $FF, $24, $FF
.byte "ABA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $22
.byte "PLP", $28, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
@@ -113,7 +112,6 @@ mne:
.byte "INY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A8
.byte "TAX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $AA
.byte "RTS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $AE
- .byte "RTL", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B0
.byte "CMP", $B1, $B6, $FF, $FF, $25, $7D, $7C, $B4, $FF
.byte "CAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B2
.byte "SEI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B8
@@ -214,22 +212,22 @@ fix_val:
subasm:
ldb #0 ; Set the first pointer
lda.d #cmd_buf ; to the command buffer.
- jsl set_ptr ;
+ jsr set_ptr ;
tba ; Reset A.
tax ; Reset X.
- jsl chk_shcmd ; Did we get a shortend command?
+ jsr chk_shcmd ; Did we get a shortend command?
bne parse_cmd ; Yes, so skip everything else.
jmp subasm_end ;
- jsl chk_cmd ; No, but did we get a full command?
+ jsr chk_cmd ; No, but did we get a full command?
bne parse_cmd ; Yes, so skip everything else.
- jsl lexer ; No, so start lexing this line.
+ jsr lexer ; No, so start lexing this line.
subasm_end:
- rtl ; End of subasm.
+ rts ; End of subasm.
parse_cmd:
ldb #1 ; Set the second pointer
lda.d #cmd_srt ; to the command subroutine table.
- jsl set_ptr ;
+ jsr set_ptr ;
deb ; Reset B.
tba ; Reset A.
lda f ; Get the command ID.
@@ -241,7 +239,7 @@ parse_cmd:
lda.w (ptr2), y ; Get the command subroutine, from the command subroutine table.
ply #2 ; Get back the screen buffer position.
ldb #2 ; Save it in the third pointer.
- jsl set_ptr ;
+ jsr set_ptr ;
ldb #0 ; Reset B.
jsr (ptr3) ; Run the command's subroutine.
jmp subasm_end ; We are done.
@@ -250,7 +248,7 @@ chk_shcmd:
tba ; Reset A.
inb ; Set the second pointer
lda.w #sh_cmds ; to the shortend command table.
- jsl set_ptr ;
+ jsr set_ptr ;
deb ; Reset B.
tba ; Reset A.
phy #2 ; Preserve the screen buffer position.
@@ -283,19 +281,19 @@ shcmd_fail:
tax ; Reset X.
shcmd_end:
ply #2 ; Get back the screen buffer position.
- rtl ; End of chk_shcmd.
+ rts ; End of chk_shcmd.
print_hex:
pha #8 ; Preserve the hex value.
and #0 ; Reset A.
ldb #1 ; Set the second pointer
lda.w #hex_char ; to the start of hex character table.
- jsl set_ptr ;
+ jsr set_ptr ;
inb ; Set the third pointer
lda.d #hex_str ; to the end of hex string buffer.
clc ; Do a non carrying add.
adc #$10 ;
- jsl set_ptr ;
+ jsr set_ptr ;
ldb #0 ; Reset B.
pla #8 ; Get the hex value back.
pnthex_lp:
@@ -325,22 +323,22 @@ pnthex_lp4:
beq pnthex_end ; Yes, so we're done.
jmp pnthex_lp ; No, so keep printing more digits.
pnthex_end:
- rtl ; End of print_hex.
+ rts ; End of print_hex.
charcpy:
ldx idx3 ; Get the string index.
sta strbuf, x ; Save it in the string buffer.
inc idx3 ; Increment the string index.
- rtl ; End of charcpy.
+ rts ; End of charcpy.
print_hi:
and #0 ; Reset A.
sta idx3 ; Clear the string index.
lda #'$' ; Print the hex delimiter.
- jsl charcpy ;
+ jsr charcpy ;
lda.q idx0 ; Get the masked address.
ldx #$10 ; Set digit count to 16.
- jsl print_hex ; Print the address.
+ jsr print_hex ; Print the address.
lda.q hex_str ; Get the lower half of the string.
sta.q strbuf+1 ; Save it in the string buffer.
lda.q hex_str+8 ; Get the upper half of the string.
@@ -348,10 +346,10 @@ print_hi:
ldx #$11 ; Add 16 to the index.
stx idx3 ;
lda #':' ; Print a colon.
- jsl charcpy ;
+ jsr charcpy ;
lda # ' ' ; Print a space.
- jsl charcpy ;
- rtl ; End of print_hi.
+ jsr charcpy ;
+ rts ; End of print_hi.
print_lo:
lda #0 ; Reset A.
@@ -359,11 +357,11 @@ print_lo:
pntlo_lp:
ldx #2 ; Set digit count to 2.
pha #1 ; Preserve the nibble offset.
- jsl print_hex ; Print the low nibble offset.
+ jsr print_hex ; Print the low nibble offset.
lda.w (ptr3) ; Get the two digits.
- jsl charcpy ; Copy the first digit.
+ jsr charcpy ; Copy the first digit.
lsr #8 ; Copy the next digit.
- jsl charcpy ;
+ jsr charcpy ;
pla #1 ; Get the nibble offset back.
inc ; Increment the offset.
cmp #$10 ; Are we at the last offset?
@@ -371,7 +369,7 @@ pntlo_lp:
pntlo_lp1:
pha #1 ; No, so preserve the nibble offset.
lda #' ' ; Add a space to the string buffer.
- jsl charcpy ;
+ jsr charcpy ;
pla #1 ; Get the nibble offset back.
jmp pntlo_lp ; Keep looping.
pntlo_end:
@@ -380,8 +378,8 @@ pntlo_end:
sta strbuf, x ;
tax ; Reset X.
lda.d #strbuf ; Print the string buffer.
- jsl print_str ;
- rtl ; End of print_lo.
+ jsr print_str ;
+ rts ; End of print_lo.
print_chunk:
ldx #0 ; Reset X.
@@ -391,16 +389,16 @@ pntchnk_lp:
and #0 ; Reset A.
ldx #2 ; Set the digit count to 2.
lda (idx0), y ; Get the byte at that address.
- jsl print_hex ; Print the byte.
+ jsr print_hex ; Print the byte.
lda.w (ptr3) ; Get the two digits.
- jsl charcpy ; Copy the first digit.
+ jsr charcpy ; Copy the first digit.
lsr #8 ; Copy the next digit.
- jsl charcpy ;
+ jsr charcpy ;
iny ; Increment the byte index.
cpy #$10 ; Have we read 16 bytes?
beq pntchnk_end ; Yes, so we're done.
lda #' ' ; No, so add a soace to the string buffer.
- jsl charcpy ;
+ jsr charcpy ;
jmp pntchnk_lp ; Keep looping.
pntchnk_end:
ply #2 ; Get the screen buffer index back.
@@ -409,7 +407,7 @@ pntchnk_end:
sta strbuf, x ;
tax ; Reset X.
sta idx3 ; Clear the string index.
- rtl ; End of print_chunk.
+ rts ; End of print_chunk.
viewmem:
lda.q prg_cnt ; Get the program counter.
@@ -418,18 +416,18 @@ viewmem:
sta idx0 ; Overwrite the first byte, with the masked byte.
lda #19 ; Move the cursor to the right, by 19 columns.
sta scr_col ;
- jsl update_pos ;
- jsl print_lo ; Print the low nibble offsets.
+ jsr update_pos ;
+ jsr print_lo ; Print the low nibble offsets.
ldx #0 ; Reset X.
ldb #0 ; Reset B.
stb idx1 ; Reset the byte count.
vmem_lp0:
lda #'\n' ; Print a newline.
- jsl print_char ;
- jsl print_hi ; Place the address in the string buffer.
- jsl print_chunk ; Place the next 16 bytes in the string buffer.
+ jsr print_char ;
+ jsr print_hi ; Place the address in the string buffer.
+ jsr print_chunk ; Place the next 16 bytes in the string buffer.
lda.d #strbuf ; Print the string buffer.
- jsl print_str ;
+ jsr print_str ;
inc idx1 ; Increment the chunk count.
ldb idx1 ; Get the chunk count.
cpb #$10 ; Did we print 16 chunks?
@@ -442,7 +440,7 @@ vmem_lp0:
jmp vmem_lp0 ; Keep looping.
vmem_end:
lda #'\n' ; Print a newline.
- jsl print_char ;
+ jsr print_char ;
and #0 ; Reset A.
rts ; End of viewmem.
diff --git a/programs/subeditor.s b/programs/subeditor.s
index e344588..0a42c32 100644
--- a/programs/subeditor.s
+++ b/programs/subeditor.s
@@ -38,11 +38,6 @@ made:
author:
.byte "mr b0nk 500"
-;sub_name:
-; .byte "SuB Suite"
-;sub_ver:
-; .byte "0.9"
-
string2:
.byte "You typed, "
@@ -143,17 +138,17 @@ reset:
lda.w #$1FFF ; Set the clear count to $1FFF.
sta.w scr_ptr ;
lda.d #buffer ; Set the array to be cleared to the screen buffer.
- jsl clr_arr ; Clear the screen buffer.
- jsl pnt_strt ; Print the starting message.
+ jsr clr_arr ; Clear the screen buffer.
+ jsr pnt_strt ; Print the starting message.
jmp start ; Goto the start of the main program.
clr_arr:
phb #1 ; Preserve whatever was in B.
ldb #0 ; Clear B.
- jsl set_ptr ; Set the first pointer to the parameter.
+ jsr set_ptr ; Set the first pointer to the parameter.
adc #8 ; Set the second pointer to the parameter, plus eight.
inb ; Tell set_ptr to set the second pointer.
- jsl set_ptr ;
+ jsr set_ptr ;
deb ; Set B back to zero.
tba ;
clr_arr_st:
@@ -175,26 +170,26 @@ clr_arr_st:
clr_arr_end:
ldy.w zero ; Set the index back to zero.
plb #1 ; Get whatever was in the B register, back.
- rtl ; End of clr_arr.
+ rts ; End of clr_arr.
pnt_strt:
lda.w #ed_name ; Print the name of the editor.
- jsl print_str ;
+ jsr print_str ;
lda.w #ver_str ; Print the version text.
- jsl print_str ;
+ jsr print_str ;
lda.w #ed_ver ; Print the version number.
- jsl print_str ;
+ jsr print_str ;
lda.w #ed_sver ; Print the sub version number.
- jsl print_str ;
+ jsr print_str ;
lda #'\n' ; Print a newline.
- jsl print_char ;
+ jsr print_char ;
lda.w #made ; Print the "Created by" text.
- jsl print_str ;
+ jsr print_str ;
lda.w #author ; Print the name of the author.
- jsl print_str ;
+ jsr print_str ;
lda #'\n' ; Print a newline.
- jsl print_char ;
- rtl ; End of pnt_strt.
+ jsr print_char ;
+ rts ; End of pnt_strt.
start:
lda #0 ; TODO: Update this for the Super VIA.
@@ -205,7 +200,7 @@ start:
lda.w #$3FF ; Set the clear count to $3FF.
sta.w scr_ptr ;
lda.d #cmd_buf ; Set the array to be cleared to the command buffer.
- jsl clr_arr ; Clear the command buffer.
+ jsr clr_arr ; Clear the command buffer.
ply #2 ; Get back the cursor index.
and #0 ; Reset the Accumulator.
sta end ;
@@ -217,7 +212,7 @@ read:
inc end ; Enable the dummy flag.
lda status ; Did we get a key?
beq read ; No, so try again.
- jsl getchar ; Yes, and was it a newline?
+ jsr getchar ; Yes, and was it a newline?
beq parse ; Yes, so start parsing the line.
jmp read ; No, so keep looping.
@@ -227,7 +222,7 @@ print_str:
print_str2:
lda.q end ; Get the parameter.
ldb #0 ; Clear the B register.
- jsl set_ptr ; Set the first pointer to the parameter.
+ jsr set_ptr ; Set the first pointer to the parameter.
tba ; Clear the Accumulator.
pntstr_lp:
ldb #1 ; Enable replace mode.
@@ -242,12 +237,12 @@ pntstr_lp:
ply #2 ; Get the cursor index back.
beq pntstr_end ; Yes, so we're done.
inx ; No, so increment the string index.
- jsl print_char ; Print the character.
+ jsr print_char ; Print the character.
jmp pntstr_lp ; Keep looping.
pntstr_end:
ldb #0 ; Enable insert mode.
stb b ;
- rtl ; End of print_str.
+ rts ; End of print_str.
getbit:
clc ; Clear the carry flag.
@@ -263,10 +258,10 @@ getbt1:
pha #1 ; Save the parameter.
ldb #1 ; Make sure that set_ptr sets the second pointer.
lda.d #bitabl ; Set the second pointer to the linewrap table.
- jsl set_ptr ;
+ jsr set_ptr ;
lsr #$10 ; Clear the Accumulator.
pla #1 ; Get the return byte back.
- jsl bitpos ; Get the bit, and byte position.
+ jsr bitpos ; Get the bit, and byte position.
phy #2 ; Save the screen index.
txy ; Get the byte position.
ldb (ptr2), y ; Get one byte of the wrap table.
@@ -279,10 +274,10 @@ clrbit:
pha #1 ; Save the parameter.
ldb #1 ; Make sure that set_ptr sets the second pointer.
lda.d #bitabl ; Set the second pointer to the linewrap table.
- jsl set_ptr ;
+ jsr set_ptr ;
and #0 ; Clear the Accumulator.
pla #1 ; Get the return byte back.
- jsl bitpos ; Get the bit, and byte position.
+ jsr bitpos ; Get the bit, and byte position.
xor #$FF ; Invert the bitmask.
phy #2 ; Save the screen index.
txy ; Get the byte position.
@@ -293,16 +288,16 @@ bitsav:
ply #2 ; Get the screen index back.
bitout:
ldx bitmask ; Return the bitmask.
- rtl ; We are done.
+ rts ; We are done.
setbit:
pha #1 ; Save the parameter.
ldb #1 ; Make sure that set_ptr sets the second pointer.
lda.d #bitabl ; Set the second pointer to the linewrap table.
- jsl set_ptr ;
+ jsr set_ptr ;
and #0 ; Clear the Accumulator.
pla #1 ; Get the return byte back.
- jsl bitpos ; Get the bit, and byte position.
+ jsr bitpos ; Get the bit, and byte position.
phy #2 ; Save the screen index.
txy ; Get the byte position.
ldb (ptr2), y ; Get one byte of the wrap table.
@@ -313,7 +308,7 @@ bitpos:
pha #1 ; Save the parameter.
ldb #0 ; Make sure that set_ptr sets the first pointer.
lda.w #bits ; Set the first pointer to the bitmask table.
- jsl set_ptr ;
+ jsr set_ptr ;
and #0 ; Clear the Accumulator.
pla #1 ; Get the parameter back.
stx bitmask ; Make the line number the bitmask.
@@ -329,7 +324,7 @@ bitpos:
lsr #3 ; Get the byte position.
tax ; Copy it into X.
pla #1 ; Get back the bitmask.
- rtl ; End of bitpos.
+ rts ; End of bitpos.
getchar:
lda kbd ; Get the character that was typed from the keyboard.
@@ -340,14 +335,14 @@ getchar:
phy #2 ; Save the cursor index.
cmp #'\n' ; Was the character that was typed, a newline?
bne getchar_pnt ; No, so just print the character.
- jsl cmd_cpy ; Yes, so start copying the line to the command buffer.
+ jsr cmd_cpy ; Yes, so start copying the line to the command buffer.
getchar_pnt:
ply #2 ; Get back the cursor index.
pla #1 ; Get back the character.
ldb e ; Is the temporary row position non zero?
bne reset_row ; Yes, so reset the row positon.
getchar_pt1:
- jsl print_char ; No, so print the character.
+ jsr print_char ; No, so print the character.
lda a ; Get the return value.
cmp #'\n' ; Is the return value, a newline?
beq getchar_ln ; Yes, so return 0.
@@ -369,13 +364,13 @@ getchar_ln:
getchar_chr:
lda #1 ; Return one.
getchar_end:
- rtl ; End of get char.
+ rts ; End of get char.
cmd_cpy:
lda scr_row ; Get the row position.
sta scr_trow ; Save it for later.
- jsl findend ; Find the end of the line.
+ jsr findend ; Find the end of the line.
ldb scr_str ; Has the screen been scrolled?
beq cmd_cpy3 ; No, so don't subtract the screen's starting point from the line number.
cmd_cpy2:
@@ -385,7 +380,7 @@ cmd_cpy2:
cmd_cpy3:
sta scr_row ; Set the row position to the end of the line.
sta e ; Save it into the temporary row posiition.
- jsl findst ; Find the start of the line.
+ jsr findst ; Find the start of the line.
clc ; Clear the carry flag.
lda scr_row ; Get the row position.
adc scr_str ; Add it with the screen's starting row.
@@ -394,10 +389,10 @@ cmd_cpy3:
ldx.w #0 ; Reset the X register.
ldb #0 ; Make sure that set_ptr sets the first pointer.
lda.d #buffer ; Set the first pointer to the start of the screen buffer.
- jsl set_ptr ;
+ jsr set_ptr ;
inb ; Make sure that set_ptr sets the second pointer.
lda.d #cmd_buf ; Set the second pointer to the start of the command buffer.
- jsl set_ptr ;
+ jsr set_ptr ;
deb ; Set B back to zero.
tba ; Set the accumulator to zero.
cmd_cpy_lp:
@@ -431,14 +426,14 @@ cmd_cpy_nd0:
ply #2 ; Get back the screen index.
cmd_cpy_nd:
tab ; The B register is zero, so clear the Accumulator.
- rtl ; End of cmd_cpy.
+ rts ; End of cmd_cpy.
findst:
lda #0 ; Reset A.
findst_lp:
pha #1 ; Save the current line number.
- jsl getbit ; Is this the start of the line?
+ jsr getbit ; Is this the start of the line?
pla #1 ; Get the current line number back.
bcc findst_done ; Yes, so we're done.
inc ; No, so check the next physical line.
@@ -448,14 +443,14 @@ findst_lp:
inc scr_row ; Put the row postiion back to zero.
findst_done:
cmp #0 ; Update all the flags.
- rtl ; End of findst.
+ rts ; End of findst.
fndend:
phb #1 ; Save the contents of the B register.
ldb #0 ; Make sure that set_ptr sets the first pointer.
lda.d #buffer ; Set the first pointer to the start of the screen buffer.
- jsl set_ptr ;
+ jsr set_ptr ;
tba ; Set the Accumulator to zero.
plb #1 ; Restore the contents of the B register.
phy #2 ;
@@ -467,25 +462,25 @@ fndend_lp:
fndend_done:
sty.w scr_ptr3 ;
ply #2 ;
- rtl ; End of fndend.
+ rts ; End of fndend.
findend:
- jsl fndend ;
+ jsr fndend ;
lda.w scr_ptr3 ;
div #maxcol+1 ;
- rtl ;
+ rts ;
parse:
lda #0 ;
tax ;
- jsl subasm ;
+ jsr subasm ;
jmp start ;
print_char:
sta a ; Save the typed character for now.
ldb #2 ; Make sure that set_ptr sets the third pointer.
lda.d #buffer ; Set the third pointer to the start of the screen buffer.
- jsl set_ptr ;
+ jsr set_ptr ;
ldb #0 ; Set B to zero.
tba ; Set the Accumulator to zero.
lda a ; Get back the character.
@@ -511,25 +506,25 @@ printc:
lda b ; No, but was the flag set?
bne printc_save ; Yes, so don't shift the line.
sty.w scr_ptr ; No, so save the cursor index for later.
- jsl fndend ; Find the end of the line.
+ jsr fndend ; Find the end of the line.
jmp prntc_movln ; Start shifting the line right.
prntc_updt:
lda scr_col ; Save the current column position for later.
sta scr_tcol ;
prntc_updt2:
- jsl findend ; Find the end of the line.
+ jsr findend ; Find the end of the line.
sta e ; Use it for redrawing the line.
sta scr_row ; Set the row position to to the end of the line.
- jsl findst ; Find the start of the line.
+ jsr findst ; Find the start of the line.
lda scr_row ; Get the start of the line.
prntc_updt3:
sta f ; Set the starting line, to the start of the line.
- jsl rdrw_ln ; Redraw the line.
+ jsr rdrw_ln ; Redraw the line.
lda scr_trow ; Get the real row position back.
sta scr_row ;
lda scr_tcol ; Get the real column position back.
sta scr_col ;
- jsl update_pos ; Update the cursor's position.
+ jsr update_pos ; Update the cursor's position.
dec d ;
jmp printc_sav1 ;
prntc_movln:
@@ -539,7 +534,7 @@ prntc_movln:
dey ;
ldb #1 ;
stb d ;
- jsl shftln ;
+ jsr shftln ;
ldb #1 ;
stb d ;
lda a ;
@@ -580,7 +575,7 @@ printc_scrl:
clc ;
lda #1 ;
sta wrapped ;
- jsl scrl_down ;
+ jsr scrl_down ;
jmp printc_wrap ;
printc_wrap:
ldb #0
@@ -596,11 +591,11 @@ printc_wrp2:
lda scr_row ;
adc scr_str ;
tax ;
- jsl setbit ;
+ jsr setbit ;
plx #2 ;
- jsl update_pos ;
+ jsr update_pos ;
printc_end:
- rtl ;
+ rts ;
nl:
lda #0 ; Reset A.
@@ -612,11 +607,11 @@ nl1:
lda scr_row ; Get the row position.
cmp #maxrow ; Are we at the bottom of the screen?
bcc nl_inc ; No, so move down one line.
- jsl scrl_down ; Yes, so scroll down one line.
+ jsr scrl_down ; Yes, so scroll down one line.
jmp nl_end ; We are done.
nl_inc:
inc scr_row ; Move the cursor down by one line.
- jsl update_pos ; Update the cursor's position.
+ jsr update_pos ; Update the cursor's position.
nl_end:
lda #'\n' ; Print the newline.
sta a ;
@@ -633,15 +628,15 @@ clr_scr:
lda.w #$1FFF ; Set the clear count to $1FFF.
sta.w scr_ptr ;
lda.d #buffer ; Set the array to be cleared to the screen buffer.
- jsl clr_arr ; Clear the screen buffer.
+ jsr clr_arr ; Clear the screen buffer.
tay ;
lda.w #$3FF ; Set the clear count to $3FF.
sta.w scr_ptr ;
lda.d #cmd_buf ; Set the array to be cleared to the command buffer.
- jsl clr_arr ; Clear the screen buffer.
+ jsr clr_arr ; Clear the screen buffer.
sta scr_col ;
sta scr_row ;
- jsl update_pos ;
+ jsr update_pos ;
lda #$C ;
sta scr ;
jmp printc_end ;
@@ -670,10 +665,10 @@ back:
stb f ;
lda scr_row ; Save the current row position for later.
sta scr_trow ;
- jsl findend ; Find the end of the line.
+ jsr findend ; Find the end of the line.
sta scr_row ; Set our row position to the end of the line.
back0:
- jsl findst ; Does this line take up more than one real line?
+ jsr findst ; Does this line take up more than one real line?
beq back1 ; No, so skip updating any other lines.
bcs back_updt ; Yes, so update the other lines.
lda scr_trow ; Get the real row position back.
@@ -686,24 +681,24 @@ back1:
iny ; Increment cursor index.
ldb #0 ; Set shifting direction to left.
stb d ;
- jsl shftln ; Shift line back by one character.
+ jsr shftln ; Shift line back by one character.
lda #$7F ; Print a backspace to the screen.
sta scr ;
lda e ; Are we updating more than one line?
beq back3 ; No, so skip to the next step.
back2:
- jsl findend ; Yes, so find the end of the line.
+ jsr findend ; Yes, so find the end of the line.
sta e ; Set the end parameter to it.
lda scr_col ; Save the current column position for now.
sta scr_tcol ;
- jsl rdrw_ln ; Start redrawing the line.
+ jsr rdrw_ln ; Start redrawing the line.
lda scr_tcol ; Get the real column position back.
sta scr_col ;
back3:
lda scr_trow ; Get the real row position bac.
sta scr_row ;
dec scr_col ; Move the cursor back by one column,
- jsl update_pos ; and update it's position.
+ jsr update_pos ; and update it's position.
jmp printc_end ; We are done.
back_updt:
lda scr_row ; Set the line to start redrawing, to the start of the line.
@@ -716,7 +711,7 @@ bs:
beq back_wrap ; Yes, so check for a wrapped line.
jmp back ; No, so add the backspace to the buffer.
back_wrap:
- jsl getbit ; Is this line, a wrapped line?
+ jsr getbit ; Is this line, a wrapped line?
bcs back_wrap1 ; Yes, so check if the cursor is at the top.
jmp printc_end ; No, so we're done.
back_wrap1:
@@ -729,7 +724,7 @@ back_wrap2:
jmp printc_end ; No, so we're done.
back_scrl:
clc ; Clear the carry flag, so that we don't get odd behaviour.
- jsl scrl_up ; Scroll up.
+ jsr scrl_up ; Scroll up.
inc scr_row ; Move down by one row.
backwrp:
clc ; Clear the carry flag.
@@ -740,7 +735,7 @@ backwrp2:
dec scr_row ; Move up by one row.
ldb #maxcol+1 ; Move the cursor to the absolute right of the screen.
stb scr_col ;
- jsl update_pos ; Update the cursor's position.
+ jsr update_pos ; Update the cursor's position.
jmp back ; Delete the previous character.
shftln:
@@ -784,11 +779,11 @@ shftln_lp1:
jmp shftln_lp1 ; Keep looping.
shftln_wrap:
tax ; Use the ending line as a parameter for setbit.
- jsl setbit ; Set the wrap bit of the ending line.
+ jsr setbit ; Set the wrap bit of the ending line.
jmp shftln_end2 ; We are done.
shftln_wrp1:
tax ; Use the ending line as a parameter for clrbit.
- jsl clrbit ; Clear the wrap bit of the ending line.
+ jsr clrbit ; Clear the wrap bit of the ending line.
jmp shftln_end2 ; We are done.
shftln_end:
lda (ptr3), y ; Is this character a null terminator?
@@ -796,7 +791,7 @@ shftln_end:
lda #$20 ; Yes, so convert it to a space for now.
sta (ptr3), y ;
shftln_nd0:
- jsl findend ; Find the ending line.
+ jsr findend ; Find the ending line.
sta d ; Save ending line for later.
lda (ptr3), y ; Is this character a space?
cmp #$20 ;
@@ -810,7 +805,7 @@ shftln_nd1:
bcs shftln_wrap ; Yes, so set the wrap bit.
jmp shftln_end2 ; No, so we're done.
shftln_end1:
- jsl findend ; Find the ending line.
+ jsr findend ; Find the ending line.
cpb #0 ; Is the remainder zero?
beq shftln_nd2 ; Yes, so check if the ending line is greater than the starting line.
jmp shftln_end2 ; No, so we're done.
@@ -819,7 +814,7 @@ shftln_nd2:
beq shftln_end2 ; No, so we're done.
bcs shftln_wrp1 ; Yes, so clear the wrap bit.
shftln_end2:
- rtl ; End of shftln.
+ rts ; End of shftln.
esc:
lda status ; Get the next character.
@@ -832,17 +827,17 @@ esc:
sta c ; Store the escape code, until we need it.
lda #0 ; Set the D pseudo register to zero.
sta d ;
- jsl isup ; Check if the user pressed up.
+ jsr isup ; Check if the user pressed up.
lda d ; Did the user press up?
bne esc_end ; Yes, so we're done.
- jsl isdown ; No, so check if the user pressed down.
+ jsr isdown ; No, so check if the user pressed down.
lda d ; Did the user press down?
bne esc_end ; Yes, so we're done.
lda #0 ; No, so check if the user pressed left.
- jsl isleft ;
+ jsr isleft ;
lda d ; Did the user press left?
bne esc_end ; Yes, so we're done.
- jsl isright ; No, so check if the user pressed right.
+ jsr isright ; No, so check if the user pressed right.
esc_end:
lda #0 ; Clear the D pseudo register.
sta d ;
@@ -857,10 +852,10 @@ shftesc:
sta c ; Store the escape code, until we need it.
lda #0 ; Use the D pseudo register as a skip flag.
sta d ;
- jsl isshftup ; Check if the user pressed shift+up.
+ jsr isshftup ; Check if the user pressed shift+up.
lda d ; Was it successful?
bne shftesc_end ; Yes, so we're done.
- jsl isshftdown ; No, so check if the user pressed shift+down.
+ jsr isshftdown ; No, so check if the user pressed shift+down.
shftesc_end:
lda #0 ; Clear the D pseudo register.
sta d ;
@@ -880,11 +875,11 @@ isup_2:
isup_scrl:
lda scr_str ; Are we at the top of the screen buffer?
beq isup_done ; Yes, so we're done.
- jsl scrl_up ; No, so scroll up.
+ jsr scrl_up ; No, so scroll up.
lda #1 ; Tell the escape routine that we were successful.
sta d ;
isup_done:
- rtl ; End of isup.
+ rts ; End of isup.
isdown:
lda c ; Load the escape code into the accumulator.
@@ -902,7 +897,7 @@ isdown_scrl:
sta scr_trow ;
lda scr_col ; Save the cursor's column number.
sta scr_tcol ;
- jsl scrl_down ; Scroll down.
+ jsr scrl_down ; Scroll down.
lda scr_trow ; Load the cursor's row number.
sta scr_row ;
lda scr_tcol ; Load the cursor's column number.
@@ -910,7 +905,7 @@ isdown_scrl:
lda #1 ; Tell the escape routine that we were successful.
sta d ;
isdown_done:
- rtl ; End of isdown.
+ rts ; End of isdown.
isright:
lda c ; Load the escape code into the accumulator.
@@ -922,7 +917,7 @@ isright:
jmp right ; No, so move the cursor right, like normal.
isright_wrp:
inc scr_row ; Move down a row.
- jsl getbit ; Is the current line, a wrapped line?
+ jsr getbit ; Is the current line, a wrapped line?
bcs wrap_inc ; Yes, so leave the cursor where it is.
dec scr_row ; No, so move the cursor back up a row.
jmp isright_dne ; We are done.
@@ -931,7 +926,7 @@ isright_scr:
beq isright_end ; Yes, so we're done.
lda #1 ; No, so scroll down.
sta wrapped ; Set the wrapped flag.
- jsl scrl_down ; Scroll down.
+ jsr scrl_down ; Scroll down.
jmp isright_end ; We are done.
wrap_inc:
lda #0 ; Set the cursor to the far left of the screen.
@@ -944,11 +939,11 @@ wrap_inc:
isright_end:
dec scr_row ; Move back up a row.
isright_nd2:
- jsl update_pos ; Update the cursor position.
+ jsr update_pos ; Update the cursor position.
isright_dne:
lda #0 ; Unset the wrapped flag.
sta wrapped ;
- rtl ; End of isright.
+ rts ; End of isright.
isleft:
lda c ; Load the escape code into the accumulator.
@@ -961,7 +956,7 @@ isleft:
beq left ; Yes, so move the cursor left.
jmp isleft_done ; No, so we're done.
isleft_wrp:
- jsl getbit ; Is the current line, a wrapped line?
+ jsr getbit ; Is the current line, a wrapped line?
bcs wrap_dec ; Yes, so wrap back up a line.
jmp isleft_done ; No, so we're done.
wrap_dec:
@@ -983,34 +978,34 @@ isleft_scrl:
bne isleft_end ; Yes so we're done.
lda scr_str ; No, but are we actually at the top of the screen buffer?
beq isleft_done ; Yes, so we're done.
- jsl scrl_up ; No, so scroll up.
+ jsr scrl_up ; No, so scroll up.
jmp isleft_done ; We are done.
isleft_end:
- jsl update_pos ; Update the cursor position.
+ jsr update_pos ; Update the cursor position.
isleft_done:
lda #0 ; Unset the wrapped flag.
sta wrapped ;
- rtl ; End of isleft.
+ rts ; End of isleft.
up:
dec scr_row ; Move the cursor up a line.
- jsl update_pos ; Update it's position.
+ jsr update_pos ; Update it's position.
lda #1 ; Tell the escape routine that we succeded.
sta d ;
jmp isup_done ; We are done.
down:
inc scr_row ; Move the cursor down a line.
- jsl update_pos ; Update it's position.
+ jsr update_pos ; Update it's position.
lda #1 ; Tell the escape routine that we succeded.
sta d ;
jmp isdown_done ; We are done.
right:
inc scr_col ; Move the cursor right by one character.
- jsl update_pos ; Update it's position.
+ jsr update_pos ; Update it's position.
jmp isright_dne ; We are done.
left:
dec scr_col ; Move the cursor left a character.
- jsl update_pos ; Update it's position.
+ jsr update_pos ; Update it's position.
lda #1 ; Tell the escape routine that we succeded.
sta d ;
jmp isleft_done ; We are done
@@ -1025,7 +1020,7 @@ isshftup:
beq shftup_done ;
jmp shftup ;
shftup_done:
- rtl ;
+ rts ;
isshftdown:
lda c ; Load the escape code back into the accumulator.
@@ -1038,16 +1033,16 @@ isshftdown:
bcs shftdn_done ;
jmp shftdown ;
shftdn_done:
- rtl ;
+ rts ;
shftup:
- jsl scrl_up ;
+ jsr scrl_up ;
lda #1 ;
sta d ;
jmp shftup_done ;
shftdown:
- jsl scrl_down ;
+ jsr scrl_down ;
lda #1 ;
sta d ;
jmp shftdn_done ;
@@ -1066,11 +1061,11 @@ update_pos:
sta scr ; to the screen.
lda #'[' ; Print '['
sta scr ; to the screen, and start the escape sequence.
- jsl getrow ; Start printing the row number to the screen.
- jsl getcol ; Start printing the column number to the screen.
+ jsr getrow ; Start printing the row number to the screen.
+ jsr getcol ; Start printing the column number to the screen.
lda #'H' ; Print 'H'
sta scr ; to the screen.
- rtl ; End of update_pos.
+ rts ; End of update_pos.
getrow:
lda scr_row ; Get the cursor's y coordinate.
@@ -1080,7 +1075,7 @@ getrow:
tba ; Get the remainder.
adc #'0' ; Convert it to ascii, and
sta scr ; print to the screen.
- rtl ; End of getrow.
+ rts ; End of getrow.
getcol:
lda #';' ; Print ';'
@@ -1094,7 +1089,7 @@ getcol:
clc
adc #'0' ; Convert it to ascii, and
sta scr ; print to the screen.
- rtl ; End of getrow.
+ rts ; End of getrow.
scrl_down:
inc scr_str ; Increment the starting line of the screen.
@@ -1110,7 +1105,7 @@ scrl_down:
lda wrapped ; Was the wrapped flag set?
beq scrldn_save ; Yes, so save the cursor position.
scrldn1:
- jsl rdrw_row ; Redraw this row.
+ jsr rdrw_row ; Redraw this row.
lda wrapped ; Was the wrapped flag set?
beq scrldn_load ; Yes, so load the previous cursor position back.
jmp scrldn_end ; No, so we're done.
@@ -1124,11 +1119,11 @@ scrldn_load:
scrldn_end:
pla #1 ; Get the cursor's previous line number back.
sta scr_row ;
- jsl update_pos ; Update the cursor's position.
+ jsr update_pos ; Update the cursor's position.
lda #0 ; Clear the wrapped flag.
sta wrapped ;
scrldn_done:
- rtl ; End of scrl_down.
+ rts ; End of scrl_down.
scrl_up:
dec scr_str ;
@@ -1145,19 +1140,19 @@ scrl_up:
pha #1 ;
lda #0 ;
sta scr_row ;
- jsl rdrw_row ;
+ jsr rdrw_row ;
pla #1 ;
sta scr_col ;
pla #1 ;
sta scr_row ;
- jsl update_pos ;
+ jsr update_pos ;
scrlup_done:
- rtl ;
+ rts ;
rdrw_row:
lda #0 ;
sta scr_col ;
- jsl update_pos ;
+ jsr update_pos ;
rdrow_st:
lda (ptr3), y ;
beq rdrow_inc ;
@@ -1180,9 +1175,9 @@ rdrow_skip:
rdrow_end:
lda #0 ;
sta scr_col ;
- jsl update_pos ;
+ jsr update_pos ;
rdrow_done:
- rtl ;
+ rts ;
rdrw_ln:
lda scr_row ;
@@ -1191,14 +1186,14 @@ rdrw_ln:
sta scr_row ;
lda scr_col ;
pha #1 ;
- jsl update_pos ;
+ jsr update_pos ;
rdrwln_lp:
lda scr_row ;
cmp e ;
beq rdrwln_lp1 ;
bcs rdrwln_done ;
rdrwln_lp1:
- jsl rdrw_row ;
+ jsr rdrw_row ;
rdrwln_inc:
inc scr_row ;
jmp rdrwln_lp ;
@@ -1207,11 +1202,11 @@ rdrwln_done:
sta scr_col ;
pla #1 ;
sta scr_row ;
- jsl update_pos ;
+ jsr update_pos ;
lda #0 ;
sta e ;
sta f ;
- rtl ;
+ rts ;
set_ptr:
cpb #1 ; Are we setting the second pointer?
@@ -1230,7 +1225,7 @@ set_ptr3:
stb.q ptr3 ; Reset the third pointer.
sta.q ptr3 ; Set the third pointer.
setptr_end:
- rtl ; End of set_ptr.
+ rts ; End of set_ptr.
; Entry point for SuBAsm.
parser:
diff --git a/sux.c b/sux.c
index 75577d2..dcdd79b 100644
--- a/sux.c
+++ b/sux.c
@@ -457,7 +457,7 @@ void *run(void *args) {
break;
case JSR_IN: /* JSR Indirect. */
case JSR: /* Jump to SubRoutine. */
- case JSL: /* Jump to Subroutine Long. */
+ case JSR_Z: /* JSR Zero Matrix. */
value.u64 = cpu->pc[thread];
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]-0] = value.u8[7];
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]-1] = value.u8[6];
@@ -481,7 +481,6 @@ void *run(void *args) {
cpu->sp[thread] += 1;
cpu->ps.u8[thread] = addr[(cpu->stk_st[thread] << 16)+(cpu->sp[thread])]; /* Falls through. */
case RTS: /* ReTurn from Subroutine. */
- case RTL: /* ReTurn from subroutine Long. */
cpu->sp[thread] += 8;
value.u8[0] = addr[(cpu->stk_st[thread] << 16)+(cpu->sp[thread]-7)];
value.u8[1] = addr[(cpu->stk_st[thread] << 16)+(cpu->sp[thread]-6)];
diff --git a/tables.h b/tables.h
index 6a95887..45c0910 100644
--- a/tables.h
+++ b/tables.h
@@ -24,8 +24,8 @@ static const uint8_t optype[0x100] = {
[PLB ] = IMM,
[INC_AB ] = ABS,
[INC_Z ] = ZM,
- [JSR ] = ZM,
- [JSL ] = ABS,
+ [JSR_Z ] = ZM,
+ [JSR ] = ABS,
[AND ] = IMM,
[ABA ] = IMPL,
[AND_AB ] = ABS,
@@ -133,7 +133,6 @@ static const uint8_t optype[0x100] = {
[CPB_IY ] = INDY,
[CPB_IX ] = INDX,
[RTS ] = IMPL,
- [RTL ] = IMPL,
[CMP ] = IMM,
[CAB ] = IMPL,
[CMP_AB ] = ABS,
diff --git a/test/add-sub.s b/test/add-sub.s
index 694931d..3dfdca4 100644
--- a/test/add-sub.s
+++ b/test/add-sub.s
@@ -8,7 +8,7 @@ reset:
cps ; Clear the processor status register.
ldx.w #$FFFF ; Reset the stack pointer.
txs ;
- lsr #16 ; Reset A.
+ and #0 ; Reset A.
tab ; Reset B.
tax ; Reset X.
up:
diff --git a/test/fib2.s b/test/fib2.s
index 59830a2..9bb2406 100644
--- a/test/fib2.s
+++ b/test/fib2.s
@@ -1,19 +1,9 @@
-; Variables for thread 0.
-.org $1000
-x:
- .qword 0
-y:
- .qword 1
-z:
- .qword 0
-zero:
- .qword 0
.org 0
init:
cps ; Clear the Processor Status register.
start:
- lsr #63 ; Reset the accumulator.
+ and #0 ; Reset the accumulator.
tab ;
tax ;
tay ;
@@ -30,4 +20,4 @@ fib:
tay ;
jmp fib ; No, so keep looping.
a
-done
+d
diff --git a/test/hello-world.s b/test/hello-world.s
index 9138bc7..f3b540a 100644
--- a/test/hello-world.s
+++ b/test/hello-world.s
@@ -1,8 +1,12 @@
; Hello world.
; Writen in Sux assembly by mr b0nk 500 <b0nk@b0nk.xyz>
+status = $100 ; Status.
+scr = $101 ; Screen output.
+
+
; Initialize, and declare variables.
-.org $8000
+.org $A000
string:
.byte "Hello, world!\n"
@@ -12,7 +16,7 @@ buffer:
; Get CPU into a known state.
-.org $0
+.org $8000
reset:
cps ; Reset the processor status.
ldx.w #$FFFF ; Set up the stack pointer.
@@ -25,21 +29,22 @@ start:
line_count:
iny ; Increment the line count.
- cpy #$32
- beq spin ; Have we printed 50 lines?
- jmp start ; Keep looping until we have printed 50 lines.
+ cpy #50 ; Have we printed 50 lines?
+ beq disp ; Yes, so we're done.
+ jmp start ; No, so keep looping.
; Printing sub routine.
print:
lda string, x ; Get character at offset x.
beq line_count ; Did we find a null terminator?
- sta $C001 ; Print character.
+ sta scr ; Print character.
inx ; Increment offset.
jmp print ; Keep printing more characters.
; The other threads would clash, if we're running the same code.
; So, have them spin instead, please?
-.org $1000
+disp:
+ lda status
spin:
nop
nop
@@ -58,5 +63,6 @@ spin:
.qword spin
.qword spin
.qword spin
-done
+a
+d
diff --git a/test/input-2.s b/test/input-2.s
deleted file mode 100644
index f5cb49e..0000000
--- a/test/input-2.s
+++ /dev/null
@@ -1,412 +0,0 @@
-; Testing input.
-;
-; Writen in Sux assembly by
-; mr b0nk 500 <b0nk@b0nk.xyz>
-
-; Instruction mnemonics,
-; and opcodes.
-.org $1000
-tok:
- .byte "dab"
-msg:
- .byte "oof, you divided a, and b on me.\n"
-
-; Input buffer.
-.org $2000
-buffer:
-
-.org $2800
-cmd_buf:
-
-; Initalize some variables.
-.org $0
-scr_row:
- .byte $0
-scr_col:
- .byte $0
-a:
- .byte $0
-b:
- .byte $0
-c:
- .byte $0
-d:
- .byte $0
-e:
- .byte $0
-string:
- .byte "Please, type something.\n"
-string2:
- .byte "You typed, "
-end:
- .byte $0
-
-; String Pointer
-ptr:
- .qword buffer
-cptr:
- .qword cmd_buf
-tptr:
- .qword tok
-mptr:
- .qword msg
-
-
-; Main program
-.org $8000
-reset:
- cps
- ldx.w #$FFFF
- txs
- ldy #0
- lda #0
-clr_buf:
- cpy.w #$7FF
- beq start
- sta (ptr), y
- iny
- jmp clr_buf
-
-start:
- lda #0
- sta $C000
- tax ; Reset x.
- tay ; Reset y.
- jsl clr_cbuf
- jmp print
-
-clr_cbuf:
- cpy.w #$3FF
- beq clr_cbuf_end
- sta (cptr), y
- iny
- jmp clr_cbuf
-clr_cbuf_end:
- ldy #0
- rtl
-
-rset_a:
- lda #1
-read:
- lda $C000 ; Get control register.
- beq rset_a ; Loop until we get a character.
- jmp getchar ; We got a key.
-sleep:
- lda end
- bne spin ; Are we done with getting input?
-
-print:
- lda string, x ; Get character at offset x.
- beq rset_a ; Did we find a null terminator?
- sta $C001 ; Print character.
- inx ; Increment offset.
- cmp #$A
- beq inc_row
- inc scr_col
- jmp print
-inc_row:
- lda #0
- sta scr_col
- lda #$42
- sta c
- jsl isdown
- jmp print ; Keep printing more characters.
-
-getchar:
- lda $C002 ; Get typed character.
- cmp #$1B
- beq esc
- cmp #$A
- beq nl ; Did the user type a newline?
- cmp #8
- beq bs ; Did the user type a backspace?
- cmp #$7F
- beq bs ; Did the user type a backspace?
-echo:
- sta a
- ldx scr_col
- cpx #79
- bne echo_print
-linewrap:
- inc scr_row
- ldx #0
- stx scr_col
- lda scr_row
- jsl update_pos
-echo_print:
- lda a
- sta $C001 ; Echo typed character.
- inc scr_col ; Increment the cursor's x coordinate.
- sta (ptr), y ; Store typed character into the input buffer.
- iny
- jmp rset_a ; Start getting user input.
-
-esc:
- lda $C000 ; Skip the '['.
- lda $C000 ; Get the next character.
- beq read ; We have an error, so discard it, and go back to getting user input.
- lda $C002 ; Get the escape code.
- sta c ; Store the escape code, until we need it.
- jsl isup ; Check if the user pressed up.
- lda d
- bne esc_end
- jsl isdown ; Check if the user pressed down.
- lda d
- bne esc_end
- lda #0
- jsl isleft ; Check if the user pressed left.
- lda d
- bne esc_end
- jsl isright ; Check if the user pressed right.
-esc_end:
- lda #0
- sta d
- jmp rset_a ; Go back to getting user input.
-
-isup:
- lda scr_row ; Is the cursor at the top of the screen?
- beq isup_done ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$41 ; Did the user press the up arrow key?
- beq up ; Yes, so move the cursor up.
-isup_done:
- rtl ; End of isup.
-
-isdown:
- lda scr_row ; Start checking the y coordinate of the cursor.
- cmp #23 ; Is the cursor at the bottom of the screen?
- beq isdown_done ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$42 ; Did the user press the down arrow key?
- beq down ; Yes, so move the cursor down.
-isdown_done:
- rtl ; End of isdown.
-
-isright:
- lda scr_col ; Start checking the x coordinate of the cursor.
- cmp #79 ; Is the cursor at the far right of the screen?
- beq isright_end ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$43 ; Did the user press the right arrow key?
- beq right ; Yes, so move the cursor right.
-isright_end:
- rtl ; End of isright.
-
-isleft:
- lda scr_col ; Is the cursor at the far left of the screen?
- beq isleft_done ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$44 ; Did the user press the left arrow key?
- beq left ; Yes, so move the cursor left.
-isleft_done:
- rtl ; End of isleft.
-
-up:
- dec scr_row
- jsl update_pos
- lda #1
- sta d
- jmp isup_done
-down:
- inc scr_row
- jsl update_pos
- lda #1
- sta d
- jmp isdown_done
-right:
- inc scr_col
- jsl update_pos
- jmp isright_end
-left:
- dec scr_col
- jsl update_pos
- lda #1
- sta d
- jmp isleft_done
-
-update_pos:
- lda #$1B ; Print an escape character
- sta $C001 ; to the screen.
- lda #$5B ; Print '['
- sta $C001 ; to the screen, and start the escape sequence.
- jsl getrow ; Start printing the row number to the screen.
- jsl getcol ; Start printing the column number to the screen.
- lda #$48 ; Print 'H'
- sta $C001 ; to the screen.
- rtl ; End of update_pos.
-getrow:
- lda scr_row ; Get the cursor's y coordinate.
- div #10 ; Divide A by 10.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- tba ; Get the remainder.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- rtl ; End of getrow.
-getcol:
- lda #$3B ; Print ';'
- sta $C001 ; to the screen.
- lda scr_col ; Get the cursor's x coordinate.
- div #10 ; Divide A by 10.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- tba ; Get the remainder.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- rtl ; End of getrow.
-
-nl:
- lda #0
- sta scr_col
- sta (ptr), y ; Store said terminator into the input buffer.
- lda #$42
- sta c
- jsl isdown
- ldy.w #0 ; Reset y, to print the result.
- jsl dabbed
- beq start
- ldy #0
- jmp result
-
-back:
- sta $C001 ; Print backspace.
- lda #0 ; Put a null terminator, in place of the backspace.
- sta (ptr), y ; Place it into the input buffer.
- dey ; Decrement buffer offset.
- dec scr_col
- jmp read ; Get next character.
-
-bs:
- cpy #0 ; Are we at the start of the buffer?
- beq rset_a ; We are, so do not store the backspace into the buffer.
- jmp back ; We are not, so add the backspace to the buffer.
-
-result:
- ldx scr_col
- cpx #79
- bne result_print
-linewrap2:
- inc scr_row
- ldx #$0
- stx scr_col
- jsl update_pos
-result_print:
- lda string2, y
- beq rset_y ; Reset y, if we hit the null terminator.
- sta $C001 ; Print 'You have typed, '
- inc scr_col ; Increment the cursor's x coordinate.
- iny ; Increment offset.
- jmp result ; Keep printing.
-
-rset_y:
- ldy.w #0 ; Reset y.
- ldx.w #0 ; Reset x.
- lda.w #0 ; Reset a.
- jmp print_buf ; Print the input buffer.
-dabbed:
- lda (ptr), y ; Get a character from the input buffer.
- beq dab_nend ; Are we done with printing the buffer?
- cmp (tptr), y
- bcs dab_nend
- beq chk_str
- bcc dab_nend
-chk_str:
- iny
- cpy #3
- bne dabbed
- ldy #0
-pnt_msg:
- ldx scr_col
- cpx #79
- bne msg_pnt
-linewrap3:
- inc scr_row
- ldx #0
- stx scr_col
- jsl update_pos
-msg_pnt:
- lda (mptr), y ; Get a character from the input buffer.
- beq dab_eqnd ; Are we done with printing the buffer?
- sta $C001 ; Print said character.
- inc scr_col ; Increment the cursor's x coordinate.
- iny
- jmp pnt_msg ; Keep printing the buffer.
-dab_nend:
- lda #1
- jmp dab_end
-dab_eqnd:
- lda #0
- jmp dab_end
-dab_end:
- rtl
-
-
-
-print_buf:
- ldx scr_col
- cpx #79
- bne buf_print
-linewrap4:
- inc scr_row
- ldx #0
- stx scr_col
- jsl update_pos
-buf_print:
- lda (ptr), y ; Get a character from the input buffer.
- beq cmd_clr ; Are we done with printing the buffer?
- sta $C001 ; Print said character.
- inc scr_col ; Increment the cursor's x coordinate.
- iny
- jmp print_buf ; Keep printing the buffer.
-
-cmd_clr:
- lda #0
- sta scr_col
- lda #$42
- sta c
- jsl isdown
- jmp start
-
-scr_to_buf:
- tax
- mul #80
- adc scr_col
- tay
- txa
- rtl
-
-spin:
- nop
- nop
- nop
- jmp spin
-
-.org $1000
-v
-.org $1100
-v
-.org $1200
-v
-.org $8000
-v
-.org $8100
-v
-.org $8200
-v
-.org $8300
-v
-.org $FFC0
-.qword reset
-
-.org $FF50
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.org $FF50
-v
-done
-
diff --git a/test/input-3.s b/test/input-3.s
deleted file mode 100644
index 35547a7..0000000
--- a/test/input-3.s
+++ /dev/null
@@ -1,900 +0,0 @@
-; Testing input.
-;
-; Writen in Sux assembly by
-; mr b0nk 500 <b0nk@b0nk.xyz>
-
-; Instruction mnemonics,
-; and opcodes.
-.org $1000
-tok:
- .byte "dab"
-msg:
- .byte "oof, you divided a, and b on me.\n"
-
-; Input buffer.
-.org $2000
-buffer:
-
-.org $4000
-cmd_buf:
-
-
-; Initalize some variables.
-.org $0
-scr_row:
- .byte $0
-scr_col:
- .byte $0
-scr_trow:
- .byte $0
-scr_tcol:
- .byte $0
-scr_ptr:
- .word $0
-a:
- .byte $0
-b:
- .byte $0
-c:
- .byte $0
-d:
- .byte $0
-e:
- .byte $0
-f:
- .byte $0
-string:
- .byte "Please, type something.\n"
-string2:
- .byte "You typed, "
-end:
- .byte $0
-bits:
- .byte $80
- .byte $40
- .byte $20
- .byte $10
- .byte $08
- .byte $04
- .byte $02
- .byte $01
-bitmask:
- .byte $0
-bitabl:
- .qword $0
- .qword $0
-scr_str:
-.byte $0
-scr_end:
-.byte $0
-wrapped:
-.byte $0
-
-; Pointers
-ptr:
- .qword buffer
-cptr:
- .qword cmd_buf
-tptr:
- .qword tok
-mptr:
- .qword msg
-
-; Main program
-.org $8000
-reset:
- cps
- ldx.w #$FFFF
- txs
- ldy #0
- lda #23
- sta scr_end
- lda #0
- sta scr_str
- ldx #8
- sta.q bitabl
- sta.q bitabl, x
- tax
- jsl clr_buf
- jmp start
-clr_buf:
- lda #0
- cpy.w #$1FFF
- beq clr_buf_end
- sta (ptr), y
- iny
- jmp clr_buf
-clr_buf_end:
- ldy.w #0
- rtl
-
-start:
- lda #0
- tax
- sta $C000
- phy #2
- ldy.w #0
- jsl clr_cbuf
- ply #2
- jmp print
-
-clr_cbuf:
- cpy.w #$3FF
- beq clr_cbuf_end
- sta (cptr), y
- iny
- jmp clr_cbuf
-clr_cbuf_end:
- rtl
-
-pull_y:
- ply #2
-rset_a:
- lda #0
- sta $C000
- inc
-read:
- lda $C000 ; Get control register.
- beq rset_a ; Loop until we get a character.
- jsl getchar ; We got a key.
- beq parse ; We got a newline, so start parsing the line.
- jmp rset_a ; We didn't get a newline, so keep getting more characters.
-
-print:
- phy #2
- txy
- lda string, y ; Get character at offset x.
- beq pull_y ; Did we find a null terminator?
- ply #2
- inx
- jsl print_char
- jmp print
-
-getbit:
- clc
- lda scr_str
- bne getbt0
- ldx scr_row
- jmp getbt1
-getbt0:
- lda scr_row
- adc scr_str
- tax
-getbt1:
- jsl bitpos
- ldb bitabl, x
- aba
- cmp #1
- jmp bitout
-
-;putbit:
-; ldx scr_row
-;putbt1:
-; bcc setbit
-
-
-clrbit:
- jsl bitpos
- xor #$FF
- ldb bitabl, x
- aba
-bitsav:
- sta bitabl, x
-bitout:
- ldx bitmask
- rtl
-
-setbit:
- jsl bitpos
- ldb bitabl, x
- oab
- jmp bitsav
-
-bitpos:
- stx bitmask
- txa
- and #7
- tax
- lda bits, x
- pha #1
- lda bitmask
- lsr #3
- tax
- pla #1
- rtl
-
-
-getchar:
- lda $C002 ; Get typed character.
- ldb #0
- stb e
- pha #1
- phy #2
- cmp #10
- beq cmd_cpy
-getchar_pnt:
- ply #2
- pla #1
- ldb e
- bne reset_row
-getchar_pnt1:
- jsl print_char
- lda a
- cmp #10
- beq getchar_line
- jmp getchar_char
-reset_row:
- ldb e
- stb scr_row
- jmp getchar_pnt1
-
-
-cmd_cpy:
- ldb scr_row
- stb e
- jsl findst
- clc
- lda scr_row
- adc scr_str
- mul #80
- tay
- ldx.w #$0
-cmd_cpy_strt:
- lda (ptr), y
- beq getchar_pnt
- phy #2
- txy
- sta (cptr), y
- inx
- ply #2
- iny
- jmp cmd_cpy_strt
-getchar_line:
- lda #0
- jmp getchar_end
-getchar_char:
- lda #1
-getchar_end:
- rtl
-
-findst:
- jsl getbit
- bcc findst_done
- dec scr_row
- bpo findst
- inc scr_row
-findst_done:
- rtl
-
-parse:
- lda #0
- tax
- jsl dabbed
- beq start
- lda #0
- tax
- jmp result
-
-print_char:
- sta a
- cmp #$1B
- beq esc
- cmp #$A
- beq nl ; Did the user type a newline?
- cmp #$C
- beq clr_scr
- cmp #19
- beq en_step
- cmp #18
- beq dis_step
- cmp #8
- beq bs ; Did the user type a backspace?
- cmp #$7F
- beq bs ; Did the user type a backspace?
- sta a
-printc:
- lda a
- sta (ptr), y ; Store typed character into the input buffer.
- inc scr_col ; Increment the cursor's x coordinate.
- iny
-printc_2:
- ldb #1
- stb f
- ldb scr_col
- cpb #80
- bcs printc_4
-printc_3:
- sta $C001 ; Echo typed character.
- ldb f
- beq printc_wrap
- jmp printc_end
-printc_4:
- ldb scr_row
- cpb #23
- bcs printc_scrl
-printc_5:
- ldb #0
- stb f
- jmp printc_3
-printc_scrl:
- sta $C001 ; Echo typed character.
- clc
- lda #1
- sta wrapped
- jsl scrl_down
-printc_wrap:
- ldb #0
- stb scr_col
- ldb scr_row
- cpb #23
- bcs printc_wrap2
-printc_wrap1:
- inc scr_row
-printc_wrap2:
- phx #2
- clc
- lda scr_row
- adc scr_str
- tax
- jsl setbit
- plx #2
- jsl update_pos
-printc_end:
- rtl
-
-nl:
- lda #0
- sta (ptr), y ; Store said terminator into the input buffer.
- sta scr_col
- lda scr_row
- cmp #23
- bne nl_inc
- jsl scrl_down
- lda #10
- sta a
- jmp printc_end
-nl_inc:
- inc scr_row
- jsl update_pos
- lda #10
- sta a
- jmp printc_end
-
-clr_scr:
- lda #23
- sta scr_end
- lda #0
- sta scr_str
- ldx #8
- sta.q bitabl
- sta.q bitabl, x
- tay
- jsl clr_buf
- sta scr_col
- sta scr_row
- jsl update_pos
- lda #$C
- sta $C001
- jmp printc_end
-
-en_step:
- lda $C010
- beq step_en
- jmp stp_end
-step_en:
- lda #1
- sta $C010
- jmp stp_end
-
-dis_step:
- lda $C010
- bne step_dis
- jmp stp_end
-step_dis:
- lda #0
- sta $C010
-stp_end:
- jmp printc_end
-
-back:
- lda #$7F
- sta $C001
- dey ; Decrement buffer offset.
- lda #0 ; Put a null terminator, in place of the backspace.
- sta (ptr), y ; Place it into the input buffer.
- dec scr_col
- jsl update_pos
- jmp printc_end ; Get next character.
-
-bs:
- lda scr_col ; Are we at the start of the buffer?
- beq back_wrap
- jmp back ; We are not, so add the backspace to the buffer.
-back_wrap:
- jsl getbit
- bcs back_wrap1
- jmp printc_end
-back_wrap1:
- lda scr_row
- beq back_wrap2
- jmp backwrp
-back_wrap2:
- lda scr_str
- bne back_scrl
- jmp printc_end
-back_scrl:
- clc
- jsl scrl_up
- inc scr_row
-backwrp:
- clc
- lda scr_row
- adc scr_str
- tax
-backwrp2:
- dec scr_row
- jsl clrbit
- ldb #80
- stb scr_col
- jsl update_pos
- jmp back
-
-esc:
- lda $C000 ; Skip the '['.
- lda $C002
- cmp #$1B
- beq shftesc
- lda $C000 ; Get the next character.
- beq printc_end ; We have an error, so discard it, and go back to getting user input.
- lda $C002 ; Get the escape code.
- sta c ; Store the escape code, until we need it.
- lda #0
- sta d
- jsl isup ; Check if the user pressed up.
- lda d
- bne esc_end
- jsl isdown ; Check if the user pressed down.
- lda d
- bne esc_end
- lda #0
- jsl isleft ; Check if the user pressed left.
- lda d
- bne esc_end
- jsl isright ; Check if the user pressed right.
-esc_end:
- lda #0
- sta d
- jmp printc_end ; Go back to getting user input.
-
-shftesc:
- lda $C000 ; Skip the '['.
- lda $C000 ; Get the next character.
- beq printc_end ; We have an error, so discard it, and go back to getting user input.
- lda $C002 ; Get the escape code.
- sta c ; Store the escape code, until we need it.
- lda #0
- sta d
- jsl isshftup ; Check if the user pressed shift+up.
- lda d
- bne shftesc_end
- jsl isshftdown ; Check if the user pressed shift+down.
-shftesc_end:
- lda #0
- sta d
- jmp printc_end ; Go back to getting user input.
-
-isup:
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$41 ; Did the user press the up arrow key?
- bne isup_done ; Yes, so return.
- lda #1
- sta d
- lda scr_row ; Is the cursor at the top of the screen?
- beq isup_scrl ; Yes, so return.
-isup_2:
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$41 ; Did the user press the up arrow key?
- beq up ; Yes, so move the cursor up.
- jmp isup_done
-isup_scrl:
- lda scr_str
- beq isup_done
- jsl scrl_up
-isup_done:
- rtl ; End of isup.
-
-isdown:
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$42 ; Did the user press the down arrow key?
- bne isdown_done
- lda scr_row ; Start checking the y coordinate of the cursor.
- cmp #23 ; Is the cursor at the bottom of the screen?
- beq isdown_scrl ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$42 ; Did the user press the down arrow key?
- beq down ; Yes, so move the cursor down.
- jmp isdown_done
-isdown_scrl:
- lda scr_row
- sta scr_trow
- lda scr_col
- sta scr_tcol
- jsl scrl_down
- lda scr_trow
- sta scr_row
- lda scr_tcol
- sta scr_col
-isdown_done:
- rtl ; End of isdown.
-
-isright:
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$43 ; Did the user press the right arrow key?
- bne isright_done
- lda scr_col ; Start checking the x coordinate of the cursor.
- cmp #79 ; Is the cursor at the far right of the screen?
- beq isright_wrp ; Yes, so check if this is a wrapped line.
- jmp right ; No, so move the cursor right, like normal.
-isright_wrp:
- inc scr_row
- jsl getbit
- bcs wrap_inc
- dec scr_row
- jmp isright_done
-isright_scrl:
- lda scr_str
- beq isright_end
- lda #1
- sta wrapped
- jsl scrl_down
- dec scr_row
- jmp isright_end
-wrap_inc:
- lda #0
- sta scr_col
- lda scr_row
- cmp #23
- bcs isright_scrl
-isright_end:
- jsl update_pos
-isright_done:
- lda #0
- sta wrapped
- rtl ; End of isright.
-
-isleft:
- lda c
- cmp #$43
- beq isleft_done
- lda scr_col ; Is the cursor at the far left of the screen?
- beq isleft_wrp ; Yes, so start checking if this is a wrapped line.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$44 ; Did the user press the left arrow key?
- beq left ; Yes, so move the cursor left.
- jmp isleft_done
-isleft_wrp:
- jsl getbit
- bcs wrap_dec
- jmp isleft_done
-wrap_dec:
- lda scr_row
- beq wrap_dec1
- lda #1
- sta wrapped
- dec scr_row
-wrap_dec1:
- lda #79
- sta scr_col
- lda #1
- sta d
- lda scr_row
- beq isleft_scrl
- jmp isleft_end
-isleft_scrl:
- lda wrapped
- bne isleft_end
- lda scr_str
- beq isleft_done
- jsl scrl_up
- jmp isleft_done
-isleft_end:
- jsl update_pos
-isleft_done:
- lda #0
- sta wrapped
- rtl ; End of isleft.
-
-up:
- dec scr_row
- jsl update_pos
- lda #1
- sta d
- jmp isup_done
-down:
- inc scr_row
- jsl update_pos
- lda #1
- sta d
- jmp isdown_done
-right:
- inc scr_col
- jsl update_pos
- jmp isright_done
-left:
- dec scr_col
- jsl update_pos
- lda #1
- sta d
- jmp isleft_done
-
-isshftup:
- lda c ; Load the escape code back into the accumulator.
- cmp #$41 ; Did the user press the up arrow key?
- bne isshftup_done
- lda #1
- sta d
- lda scr_str
- beq isshftup_done
- jmp shftup
-isshftup_done:
- rtl
-
-isshftdown:
- lda c ; Load the escape code back into the accumulator.
- cmp #$42 ; Did the user press the down arrow key?
- bne isshftdown_done
- lda #1
- sta d
- lda scr_end
- cmp #71
- bcs isshftdown_done
- jmp shftdown
-isshftdown_done:
- rtl
-
-shftup:
- jsl scrl_up
- lda #1
- sta d
- jmp isshftup_done
-
-shftdown:
- jsl scrl_down
- lda #1
- sta d
- jmp isshftdown_done
-
-update_pos:
- ldb #1
- stb f
- clc
- lda scr_row
- adc scr_str
- clc
- mul #80
- clc
- adc scr_col
- tay
- lda #$1B ; Print an escape character
- sta $C001 ; to the screen.
- lda #$5B ; Print '['
- sta $C001 ; to the screen, and start the escape sequence.
- jsl getrow ; Start printing the row number to the screen.
- jsl getcol ; Start printing the column number to the screen.
- lda #$48 ; Print 'H'
- sta $C001 ; to the screen.
- rtl ; End of update_pos.
-
-getrow:
- lda scr_row ; Get the cursor's y coordinate.
- div #10 ; Divide A by 10.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- tba ; Get the remainder.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- rtl ; End of getrow.
-
-getcol:
- lda #$3B ; Print ';'
- sta $C001 ; to the screen.
- lda scr_col ; Get the cursor's x coordinate.
- div #10 ; Divide A by 10.
- clc
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- tba ; Get the remainder.
- clc
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- rtl ; End of getrow.
-
-scrl_down:
-
- inc scr_str
- inc scr_end
- lda #$1B ; Print an escape character
- sta $C001 ; to the screen.
- lda #$5B ; Print '['
- sta $C001 ; to the screen, and start the escape sequence.
- lda #$54 ; Print 'T'
- sta $C001 ; to the screen, and end the escape sequence.
- lda wrapped
- beq scrldn_save
-scrldn1:
- jsl rdrw_row
- lda wrapped
- beq scrldn_load
- jmp scrldn_end
-scrldn_save:
- lda scr_row
- pha #1
- lda scr_col
- pha #1
- jmp scrldn1
-scrldn_load:
- pla #1
- sta scr_col
- pla #1
- sta scr_row
- jsl update_pos
-scrldn_end:
- lda #0
- sta wrapped
-scrldn_done:
- rtl
-
-scrl_up:
- dec scr_str
- dec scr_end
- lda #$1B ; Print an escape character
- sta $C001 ; to the screen.
- lda #$5B ; Print '['
- sta $C001 ; to the screen, and start the escape sequence.
- lda #$53 ; Print 'S'
- sta $C001 ; to the screen, and end the escape sequence.
- lda scr_row
- pha #1
- lda scr_col
- pha #1
- lda #0
- sta scr_row
- jsl rdrw_row
- pla #1
- sta scr_col
- pla #1
- sta scr_row
- jsl update_pos
-scrlup_done:
- rtl
-
-rdrw_row:
- lda #0
- sta scr_col
- jsl update_pos
-rdrow_st:
- lda (ptr), y
- beq rdrow_inc
- sta $C001
-rdrow_inc:
- inc scr_col
- lda (ptr), y
- beq rdrow_skip
- iny
-rdrow_inc1:
- lda scr_col
- cmp #80
- bcs rdrow_end
- jmp rdrow_st
-rdrow_skip:
- jsl update_pos
- jmp rdrow_inc1
-rdrow_end:
- lda #0
- sta scr_col
- jsl update_pos
-rdrow_done:
- rtl
-
-
-;rdrw_scr:
-; lda #$C
-; sta $C001
-; lda scr_col
-; sta scr_tcol
-; lda scr_row
-; sta scr_trow
-; lda #0
-; sta scr_col
-; sta scr_row
-; phy #2
-; jsl update_pos
-; ply #2
-; ldx scr_ptr
-; phy #2
-; txy
-; lda (ptr), y
-; sta $C001
-; ply #2
-; rtl
-
-result:
- phy #2
- txy
- lda string2, y
- beq rset_y ; Reset y, if we hit the null terminator.
- ply #2
- jsl print_char ; Print 'You have typed, '
- inx
- jmp result ; Keep printing.
-
-rset_y:
- ply #2
- lda #0 ; Reset a.
- tax ; Reset y.
- jmp print_buf ; Print the input buffer.
-
-dabbed:
- phy #2
- txy
- lda (cptr), y ; Get a character from the input buffer.
- beq dab_pend ; Are we done with printing the buffer?
- cmp (tptr), y
- bcc dab_pend
- beq chk_str
- bcs dab_pend
-chk_str:
- ply #2
- inx
- cpx #3
- bne dabbed
- ldx #0
-pnt_msg:
- phy #2
- txy
- lda (mptr), y ; Get a character from the input buffer.
- beq dab_peqnd ; Are we done with printing the buffer?
- ply #2
- jsl print_char
- inx
- jmp pnt_msg ; Keep printing the buffer.
-dab_pend:
- ply #2
- lda #1
- jmp dab_end
-dab_peqnd:
- ply #2
- lda #0
- jmp dab_end
-dab_end:
- rtl
-
-print_buf:
- phy #2
- txy
- lda (cptr), y ; Get a character from the input buffer.
- beq cmd_clr ; Are we done with printing the buffer?
- ply #2
- jsl print_char
- inx
- jmp print_buf ; Keep printing the buffer.
-
-cmd_clr:
- ply #2
- lda #10
- jsl print_char
- jmp start
-
-.org $FFC0
-.qword reset
-
-.org $FF50
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-done
-
diff --git a/test/input.s b/test/input.s
deleted file mode 100644
index a8b0830..0000000
--- a/test/input.s
+++ /dev/null
@@ -1,338 +0,0 @@
-; Testing input.
-;
-; Writen in Sux assembly by
-; mr b0nk 500 <b0nk@b0nk.xyz>
-
-
-; Input buffer.
-.org $4000
-buffer:
-
-; Initalize some variables.
-.org $0
-scr_row:
- .byte $0
-scr_col:
- .byte $0
-a:
- .byte $0
-b:
- .byte $0
-c:
- .byte $0
-d:
- .byte $0
-e:
- .byte $0
-string:
- .byte "Please, type something.\n"
-string2:
- .byte "You typed, "
-end:
- .byte $0
-
-; String Pointer
-ptr:
- .qword buffer
-
-; Main program
-.org $8000
-reset:
- cps
- ldx.w #$FFFF
- txs
- ldy #0
- lda #0
-clr_buf:
- cpy.w #$FFF
- beq start
- sta (ptr), y
- iny
- jmp clr_buf
-
-start:
- tax ; Reset x.
- tay ; Reset y.
- jmp print
-
-rset_a:
- lda #1
-
-read:
- lda $C000 ; Get control register.
- beq rset_a ; Loop until we get a character.
- lda #0
- sta $C000
- jmp getchar ; We got a key.
-sleep:
- lda end
- bne spin ; Are we done with getting input?
-
-print:
- lda string, x ; Get character at offset x.
- beq rset_a ; Did we find a null terminator?
- sta $C001 ; Print character.
- inx ; Increment offset.
- cmp #$A
- beq inc_row
- inc scr_col
- jmp print
-inc_row:
- inc scr_row
- lda #0
- sta scr_col
- jmp print ; Keep printing more characters.
-
-getchar:
- lda $C002 ; Get typed character.
- cmp #$1B
- beq esc
- cmp #$A
- beq nl ; Did the user type a newline?
- cmp #8
- beq bs ; Did the user type a backspace?
- cmp #$7F
- beq bs ; Did the user type a backspace?
-echo:
- sta a
- ldx scr_col
- cpx #79
- bne echo_print
-linewrap:
- inc scr_row
- ldx #0
- stx scr_col
- lda scr_row
- jsl update_pos
-echo_print:
- lda a
- sta $C001 ; Echo typed character.
- inc scr_col ; Increment the cursor's x coordinate.
- sta (ptr), y ; Store typed character into the input buffer.
- iny
- jmp rset_a ; Start getting user input.
-
-esc:
- lda $C000 ; Skip the '['.
- lda $C000 ; Get the next character.
- beq read ; We have an error, so discard it, and go back to getting user input.
- lda $C002 ; Get the escape code.
- sta c ; Store the escape code, until we need it.
- jsl isup ; Check if the user pressed up.
- lda d
- cmp #0
- bne esc_end
- jsl isdown ; Check if the user pressed down.
- lda d
- cmp #0
- bne esc_end
- lda #0
- jsl isleft ; Check if the user pressed left.
- lda d
- cmp #0
- bne esc_end
- jsl isright ; Check if the user pressed right.
-esc_end:
- lda #0
- sta d
- jmp rset_a ; Go back to getting user input.
-
-isup:
- lda scr_row ; Is the cursor at the top of the screen?
- beq isup_done ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$41 ; Did the user press the up arrow key?
- beq up ; Yes, so move the cursor up.
-isup_done:
- rtl ; End of isup.
-
-isdown:
- lda scr_row ; Start checking the y coordinate of the cursor.
- cmp #23 ; Is the cursor at the bottom of the screen?
- beq isdown_done ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$42 ; Did the user press the down arrow key?
- beq down ; Yes, so move the cursor down.
-isdown_done:
- rtl ; End of isdown.
-
-isright:
- lda scr_col ; Start checking the x coordinate of the cursor.
- cmp #79 ; Is the cursor at the far right of the screen?
- beq isright_end ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$43 ; Did the user press the right arrow key?
- beq right ; Yes, so move the cursor right.
-isright_end:
- rtl ; End of isright.
-
-isleft:
- lda scr_col ; Is the cursor at the far left of the screen?
- beq isleft_done ; Yes, so return.
- lda c ; No, so load the escape code back into the accumulator.
- cmp #$44 ; Did the user press the left arrow key?
- beq left ; Yes, so move the cursor left.
-isleft_done:
- rtl ; End of isleft.
-
-up:
- dec scr_row
- jsl update_pos
- lda #1
- sta d
- jmp isup_done
-down:
- inc scr_row
- jsl update_pos
- lda #1
- sta d
- jmp isdown_done
-right:
- inc scr_col
- jsl update_pos
- jmp isright_end
-left:
- dec scr_col
- jsl update_pos
- lda #1
- sta d
- jmp isleft_done
-
-update_pos:
- lda #$1B ; Print an escape character
- sta $C001 ; to the screen.
- lda #$5B ; Print '['
- sta $C001 ; to the screen, and start the escape sequence.
- jsl getrow ; Start printing the row number to the screen.
- jsl getcol ; Start printing the column number to the screen.
- lda #$48 ; Print 'H'
- sta $C001 ; to the screen.
- rtl ; End of update_pos.
-getrow:
- lda scr_row ; Get the cursor's y coordinate.
- div #10 ; Divide A by 10.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- tba ; Get the remainder.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- rtl ; End of getrow.
-getcol:
- lda #$3B ; Print ';'
- sta $C001 ; to the screen.
- lda scr_col ; Get the cursor's x coordinate.
- div #10 ; Divide A by 10.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- tba ; Get the remainder.
- adc #$30 ; Convert it to ascii, and
- sta $C001 ; print to the screen.
- rtl ; End of getrow.
-
-
-nl:
- lda #$A
- sta $C001
- inc scr_row
- lda #0 ; Replace newline with a null terminator.
- sta (ptr), y ; Store said terminator into the input buffer.
- sta scr_col
- ldy.w #0 ; Reset y, to print the result.
- jmp result
-
-back:
- sta $C001 ; Print backspace.
- lda #0 ; Put a null terminator, in place of the backspace.
- sta (ptr), y ; Place it into the input buffer.
- dey ; Decrement buffer offset.
- dec scr_col
- jmp read ; Get next character.
-
-bs:
- cpy #0 ; Are we at the start of the buffer?
- beq rset_a ; We are, so do not store the backspace into the buffer.
- jmp back ; We are not, so add the backspace to the buffer.
-
-result:
- ldx scr_col
- cpx #79
- bne result_print
-linewrap2:
- inc scr_row
- ldx #$0
- stx scr_col
- jsl update_pos
-result_print:
- lda string2, y
- beq rset_y ; Reset y, if we hit the null terminator.
- sta $C001 ; Print 'You have typed, '
- inc scr_col ; Increment the cursor's x coordinate.
- iny ; Increment offset.
- jmp result ; Keep printing.
-
-
-rset_y:
- ldy.w #0 ; Reset y.
- jmp print_buf ; Print the input buffer.
-
-print_buf:
- ldx scr_col
- cpx #79
- bne buf_print
-linewrap3:
- inc scr_row
- ldx #0
- stx scr_col
- jsl update_pos
-buf_print:
- lda (ptr), y ; Get a character from the input buffer.
- beq spin ; Are we done with printing the buffer?
- sta $C001 ; Print said character.
- inc scr_col ; Increment the cursor's x coordinate.
- iny
- jmp print_buf ; Keep printing the buffer.
-
-scr_to_buf:
- tax
- mul #80
- adc scr_col
- tay
- txa
- rtl
-
-spin:
- nop
- nop
- nop
- jmp spin
-
-.org $1000
-v
-.org $1100
-v
-.org $1200
-v
-.org $8000
-v
-.org $8100
-v
-.org $8200
-v
-.org $8300
-v
-.org $FFC0
-.qword reset
-
-.org $FF50
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.qword spin
-.org $FF50
-v
-;done
-q
-
diff --git a/test/subroutine.s b/test/subroutine.s
index 7db1b87..d39fc15 100644
--- a/test/subroutine.s
+++ b/test/subroutine.s
@@ -24,7 +24,7 @@ start:
;stb $C010
;deb
bench:
- jsl clr_buf
+ jsr clr_buf
jmp bench
clr_buf:
@@ -39,7 +39,7 @@ clr_buf:
jmp clr_buf ; Keep looping.
clr_buf_end:
tay ; Set the index back to zero.
- rtl ; End of clr_buf.
+ rts ; End of clr_buf.
;.org $C010
;.byte $1
diff --git a/test/test.s b/test/test.s
index 7c36579..14b9798 100644
--- a/test/test.s
+++ b/test/test.s
@@ -2,12 +2,15 @@
;
; Writen by mr b0nk 500 <b0nk@b0nk.xyz>
.org $8000
-cps ; Clear the processor status register.
-lda.w #$1000 ; Load 0x1000 into the accumulator.
-rol #$1 ; Then rotate the accumulator left by 1 bit.
-jmp $8005 ; And then loop.
+entry:
+ cps ; Clear the processor status register.
+ lda.w #$1000 ; Load 0x1000 into the accumulator.
+loop:
+ rol #$1 ; Then rotate the accumulator left by 1 bit.
+ jmp loop ; And then loop.
-.org $FFC0 ; Reset vector.
-.qword $8000
-done
+.org $FFC0 ; Reset vector.
+.qword entry
+a
+d