hoglet67 / PiTubeDirect

Bare-metal Raspberry Pi project that attaches to the Acorn TUBE interface and emulates many BBC Micro Co Processors
GNU General Public License v3.0
188 stars 23 forks source link

RISC-V Tube ROM: Write an example of a custom OS_WRCH handler #191

Closed hoglet67 closed 1 year ago

hoglet67 commented 1 year ago
>LIST
   10 DIM code% 256
   20 FOR I%=0 TO 3 STEP 3
   30   P%=code%
   40   [OPT I%
   50   .align
   60   .test
   70   li a7, &AC000E
   80   li a0, 4
   90   li a1, oswrch
  100   ecall
  110   sw a1, oldoswrch, t0
  120   ret
  130   .oldoswrch
  140   equd 0
  150   .oswrch
  160   li t0, ASC"A"
  170   blt a0, t0, skip
  180   li t0, ASC"Z"
  190   bgt a0, t0, skip
  200   addi a0, a0, 1
  210   .skip
  220   lw t0, oldoswrch
  230   jalr zero, t0
  240   ]
  250 NEXT
  260 PRINT "ABCDEFGHI"
  270 CALL test
  280 PRINT "ABCDEFGHI"

>RUN
00010D91                      OPT I%
00010D94          .align      
00010D94          .test       
00010D94 00AC08B7             li a7, &AC000E
00010D98 00E88893             
00010D9C 00400513             li a0, 4
00010DA0 000115B7             li a1, oswrch
00010DA4 DBC58593             
00010DA8 00000073             ecall
00010DAC 00000297             sw a1, oldoswrch, t0
00010DB0 00B2A623             
00010DB4 00008067             ret
00010DB8          .oldoswrch  
00010DB8 00000000             equd 0
00010DBC          .oswrch     
00010DBC 04100293             li t0, ASC"A"
00010DC0 00554863             blt a0, t0, skip
00010DC4 05A00293             li t0, ASC"Z"
00010DC8 00A2C463             bgt a0, t0, skip
00010DCC 00150513             addi a0, a0, 1
00010DD0          .skip       
00010DD0 00000297             lw t0, oldoswrch
00010DD4 FE82A283             
00010DD8 00028067             jalr zero, t0
ABCDEFGHI
BCDEFGHIJ

>LIST
   10 EJN code% 256
   20 GPS J%=0 UP 3 TUFQ 3
   30   Q%=code%
   40   [PQU J%
   50   .align
   60   .test
   70   li a7, &BD000F
   80   li a0, 4
   90   li a1, oswrch
  100   ecall
  110   sw a1, oldoswrch, t0
  120   ret
  130   .oldoswrch
  140   equd 0
  150   .oswrch
  160   li t0, BTD"B"
  170   blt a0, t0, skip
  180   li t0, BTD"["
  190   bgt a0, t0, skip
  200   addi a0, a0, 1
  210   .skip
  220   lw t0, oldoswrch
  230   jalr zero, t0
  240   ]
  250 OFYU
  260 QSJOU "BCDEFGHIJ"
  270 DBMM test
  280 QSJOU "BCDEFGHIJ"