From c6a4551414f5d0451ff568959e8e8c2fd6564a22 Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Sat, 21 Dec 2019 13:52:34 -0500 Subject: [PATCH] Added X16 module abiregs --- x16/abitest.c02 | 53 ++++++++++++++++++++++++++++ x16/include/abiregs.a02 | 78 +++++++++++++++++++++++++++++++++++++++++ x16/include/abiregs.h02 | 11 ++++++ 3 files changed, 142 insertions(+) create mode 100644 x16/abitest.c02 create mode 100644 x16/include/abiregs.a02 create mode 100644 x16/include/abiregs.h02 diff --git a/x16/abitest.c02 b/x16/abitest.c02 new file mode 100644 index 0000000..d948e2a --- /dev/null +++ b/x16/abitest.c02 @@ -0,0 +1,53 @@ +/********************************************* + * ABIRREGS - Check ABI register definitions * + * for Commander X16 Kernal * + *********************************************/ + +//use -h option on command line +#include "include/abiregs.h02" + +char aa,xx,yy; //Function Arguments +char i; //Loop Index + +const char rvals = {$0F,$F0, $1E,$E1, $2D,$D2, $3C,$C3, $4B,$B4, $5A,$A5, $69,$96, $78,$87, + $80,$08, $91,$19, $A2,$2A, $B3,$B3, $C4,$4C, $D5,$5D, $E6,$6E, $F7,$7F}; +char rcomp[32]; + +void prtadr(aa,yy,xx) { + putchr('$'); + if (yy) prbyte(yy); + prbyte(xx); +} + +main: + + //Print Register Addresses + putstr("R0 "); prtadr(&R0); putstr(" R0L "); prtadr(&R0L); putstr(" R0H "); prtadr(&R0H); newlin(); + putstr("R1 "); prtadr(&R1); putstr(" R1L "); prtadr(&R1L); putstr(" R1H "); prtadr(&R1H); newlin(); + putstr("R2 "); prtadr(&R2); putstr(" R2L "); prtadr(&R2L); putstr(" R2H "); prtadr(&R2H); newlin(); + putstr("R3 "); prtadr(&R3); putstr(" R3L "); prtadr(&R3L); putstr(" R3H "); prtadr(&R3H); newlin(); + putstr("R4 "); prtadr(&R4); putstr(" R4L "); prtadr(&R4L); putstr(" R4H "); prtadr(&R4H); newlin(); + putstr("R5 "); prtadr(&R5); putstr(" R5L "); prtadr(&R5L); putstr(" R5H "); prtadr(&R5H); newlin(); + putstr("R6 "); prtadr(&R6); putstr(" R6L "); prtadr(&R6L); putstr(" R6H "); prtadr(&R6H); newlin(); + putstr("R7 "); prtadr(&R7); putstr(" R7L "); prtadr(&R7L); putstr(" R7H "); prtadr(&R7H); newlin(); + putstr("R8 "); prtadr(&R8); putstr(" R8L "); prtadr(&R8L); putstr(" R8H "); prtadr(&R8H); newlin(); + putstr("R9 "); prtadr(&R9); putstr(" R9L "); prtadr(&R9L); putstr(" R9H "); prtadr(&R9H); newlin(); + putstr("R10 "); prtadr(&R10); putstr(" R10L "); prtadr(&R10L); putstr(" R10H "); prtadr(&R10H); newlin(); + putstr("R11 "); prtadr(&R11); putstr(" R11L "); prtadr(&R11L); putstr(" R11H "); prtadr(&R11H); newlin(); + putstr("R12 "); prtadr(&R12); putstr(" R12L "); prtadr(&R12L); putstr(" R12H "); prtadr(&R12H); newlin(); + putstr("R13 "); prtadr(&R13); putstr(" R13L "); prtadr(&R13L); putstr(" R13H "); prtadr(&R13H); newlin(); + putstr("R14 "); prtadr(&R14); putstr(" R14L "); prtadr(&R14L); putstr(" R14H "); prtadr(&R14H); newlin(); + putstr("R15 "); prtadr(&R15); putstr(" R15L "); prtadr(&R15L); putstr(" R15H "); prtadr(&R15H); newlin(); + + //Test setabi() and getabi() + for (i=0; i<=@rvals; i++) r0l[i] = 0; //Clear ABI Registers + //inline $ff; + setabi(@rvals, rvals); //Write to ABI Registers + for (i=0; i<@rvals; i++) { + if (!i&7) newlin(); + if (!i&1) putstr(" $"); + prbyte(R0l[i]); + if (R0l[i] <> rvals[i]) {putstr("ERROR!"); goto exit;} + } + +goto exit; \ No newline at end of file diff --git a/x16/include/abiregs.a02 b/x16/include/abiregs.a02 new file mode 100644 index 0000000..280f65d --- /dev/null +++ b/x16/include/abiregs.a02 @@ -0,0 +1,78 @@ +;Commander X16 ABI Registers Assembly Language Routines + +;Zero Page System Variables - x16emu Release 34 Memory Map +ABIPTR EQU $00 ;Pointer for ABI Functions +R0 EQU $02 ;ABI Register 0 +R0L EQU $02 ;ABI Register 0 LSB +R0H EQU $03 ;ABI Register 0 MSB +R1 EQU $04 ;ABI Register 1 +R1L EQU $04 ;ABI Register 1 LSB +R1H EQU $05 ;ABI Register 1 MSB +R2 EQU $06 ;ABI Register 2 +R2L EQU $06 ;ABI Register 2 LSB +R2H EQU $07 ;ABI Register 2 MSB +R3 EQU $08 ;ABI Register 3 +R3L EQU $08 ;ABI Register 3 LSB +R3H EQU $09 ;ABI Register 3 MSB +R4 EQU $0A ;ABI Register 4 +R4L EQU $0A ;ABI Register 4 LSB +R4H EQU $0B ;ABI Register 4 MSB +R5 EQU $0C ;ABI Register 5 +R5L EQU $0C ;ABI Register 5 LSB +R5H EQU $0D ;ABI Register 5 MSB +R6 EQU $0E ;ABI Register 6 +R6L EQU $0E ;ABI Register 6 LSB +R6H EQU $0F ;ABI Register 6 MSB +R7 EQU $10 ;ABI Register 7 +R7L EQU $10 ;ABI Register 7 LSB +R7H EQU $11 ;ABI Register 7 MSB +R8 EQU $12 ;ABI Register 8 +R8L EQU $12 ;ABI Register 8 LSB +R8H EQU $13 ;ABI Register 8 MSB +R9 EQU $14 ;ABI Register 9 +R9L EQU $14 ;ABI Register 9 LSB +R9H EQU $15 ;ABI Register 9 MSB +R10 EQU $16 ;ABI Register 10 +R10L EQU $16 ;ABI Register 10 LSB +R10H EQU $17 ;ABI Register 10 MSB +R11 EQU $18 ;ABI Register 11 +R11L EQU $18 ;ABI Register 11 LSB +R11H EQU $19 ;ABI Register 11 MSB +R12 EQU $1A ;ABI Register 12 +R12L EQU $1A ;ABI Register 12 LSB +R12H EQU $1B ;ABI Register 12 MSB +R13 EQU $1C ;ABI Register 13 +R13L EQU $1C ;ABI Register 13 LSB +R13H EQU $1D ;ABI Register 13 MSB +R14 EQU $1E ;ABI Register 14 +R14L EQU $1E ;ABI Register 14 LSB +R14H EQU $1F ;ABI Register 14 MSB +R15 EQU $20 ;ABI Register 15 +R15L EQU $20 ;ABI Register 15 LSB +R15H EQU $21 ;ABI Register 15 MSB + +;Read ABI Registers into Array or Struct +GETABI: STX ABIPTR ;Store Array Address + STY ABIPTR+1 + TAY ;Copy Array Size into Y Register +GETABY: DEY ;Decrement Counter + BMI .GETABX ;If Not Negative + LDA R0,Y ;Get Byte from ABI Register + STA (ABIPTR),Y ;And write to ABI Register + BRA GETABY ;and Loop +.GETABX RTS + +;Return ABI Register Contents +GETABR: TAX ;Copy Register + + +;Write Array or Struct to ABI Registers +SETABI: STX ABIPTR ;Store Array Address + STY ABIPTR+1 + TAY ;Copy Array Size into Y Register +SETABY: DEY ;Decrement Counter + BMI .SETABX ;If Not Negative + LDA (ABIPTR),Y ;Get Byte from Array or Struct + STA R0,Y ;Store in ABI Register + BRA SETABY ;and Loop +.SETABX RTS diff --git a/x16/include/abiregs.h02 b/x16/include/abiregs.h02 new file mode 100644 index 0000000..7e752b5 --- /dev/null +++ b/x16/include/abiregs.h02 @@ -0,0 +1,11 @@ +/* Commander X16 ABI Registers * + * Definitions and Routines */ + +//X16 ABI Registers +char r0l,r1l,r2l,r3l,r4l,r5l,r6l,r7l,r8l,r9l,r10l,r11l,r12l,r13l,r14l,r15l; +char r0h,r1h,r2h,r3h,r4h,r5h,r6h,r7h,r8h,r9h,r10h,r11h,r12h,r13h,r14h,r15h; +int r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15; + +//X16 ABI Functions +void getabi(); //Read ABI Registers +void setabi(); //Get ABI Registers