Asmusr Posted April 5, 2015 Share Posted April 5, 2015 10 FOR A=1 TO 1000 20 PRINT A 30 NEXT A I have often used the program above as a simple benchmark for testing the speed of home computers. In TI BASIC it finishes in about 3 mins. In XB in about 1 min 38 secs. This was intended as a April's fool joke, but I got sidetracked and didn't finish on time: It's pure machine code, of course, but apart from that there's no cheating - the whole screen is scrolling. It takes about 12 s to finish. If you use the version on the disk, ABSCS, where it syncs with the VDP it takes exactly 1000/60 = 16.66 secs. Sending 768 bytes to the VDP within a 60 Hz frame is not a problem, but if you also need to scroll the 768 bytes in CPU RAM first it becomes very close. So I'm using a screen buffer 2 screens tall, which allows me to 'scroll' simply by changing the start address of the viewport to send to the VDP. When the viewport reaches the end of the buffer it's set back to the start. In order for this to work I have to write each line to the buffer twice, one screen apart, in a circular wrapping fashion as I have tried to explain on this figure: ______________________________ | | | | |FOR A=1 to 1000 | |PRINT A | |----------------------------| |NEXT A (added next) | | | | | | Viewport | | | | | |FOR A=1 to 1000 | |PRINT A | |----------------------------| |NEXT A (added next) | | | | | |____________________________| APRBASIC.dsk April BASIC.a99 5 Quote Link to comment Share on other sites More sharing options...
+mizapf Posted April 5, 2015 Share Posted April 5, 2015 Could definitely not resist ... in Geneve's ABASIC this loop takes 29 seconds (of course, in the same graphics mode). 1 Quote Link to comment Share on other sites More sharing options...
+Ksarul Posted April 5, 2015 Share Posted April 5, 2015 That was fun! Thanks, Rasmus! Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted April 5, 2015 Share Posted April 5, 2015 fbForth 2.0: 76 seconds in graphics mode TurboForth 1.2.1: 43 seconds in graphics mode Program==>> : NUMS 1001 1 DO I . CR LOOP ; ...lee Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted April 5, 2015 Share Posted April 5, 2015 Rasmus... That is indeed a very nice program! It might be a good tutorial for those trying to learn ALC on this forum. ...lee Quote Link to comment Share on other sites More sharing options...
+InsaneMultitasker Posted April 6, 2015 Share Posted April 6, 2015 Another similar method is to use a circular ram buffer the same size as the screen. This variation works because your top line is 'trashed' during the scroll anyway, meaning you can use it as your next line's buffer. The method does require testing the buffer boundaries and updating the pointer during the loop that prints from memory to VDP. (and you might need a 2nd pointer). On the other hand, the double buffering is not longer needed. As usual, neat example and nice, easy to follow code. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted April 6, 2015 Share Posted April 6, 2015 It takes about 35 seconds to run when compiled. I use my own scroll routine in the compiler which is quite a bit faster than the console scroll routines. Quote Link to comment Share on other sites More sharing options...
RXB Posted April 6, 2015 Share Posted April 6, 2015 XB has a SCROLL routine in the ROM's that is faster than the TI BASIC routine. [0816] 64DA D5,30,32 SZRUN0 DCEQ @ENLN,@STLN Refuse without program [0817] 64DD 64,EF BS ILLST [0818] 64DF BD,A3,72 DST @ENLN,V@START Defualt to beginning 64E2 32 [0819] 64E3 A7,A3,72 DSUB 3,V@START Offset into the table 64E6 00,03 [0820] 64E8 45,02 BR SZRUN1 Merge in below [0821] * Jump always [0822] 64EA D5,30,32 SZRUN2 DCEQ @ENLN,@STLN Refuse without program [0823] 64ED 44,F9 BR G64F9 [0824] 64EF 0F,83 ILLST XML SCROLL Scroll the screen for message [0825] 64F1 86,44 CLR @PRGFLG Prevent line # printing [0826] 64F3 06,6A,82 WRNNPP CALL G6A82 [0827] 64F6 1D BYTE 29 * NO PROGRAM PRESENT [0828] 64F7 43,DD BR TOPL15 [0829] * Condition can never be set since line 0 is prohibited [0830] 64F9 0F,7E G64F9 XML SPEED [0831] 64FB 03 BYTE SEETWO * Find the line in the program [0832] 64FC 49,8C BR ERRLNF * LINE NOT FOUND [0833] 64FE BD,A3,72 DST @EXTRAM,V@START Program run starts here 6501 2E [0834] * GKXB RUN code for color change. [0835] 6502 57,74 SZRUN1 BR RUNPAT Change colors. [0836] 6504 06,80,12 G6504 CALL CLSALL Close any open files [0837] 6507 92,44 DEC @PRGFLG Put it back in execution [0838] 6509 BC,80,89 ST @RAMTOP+1,@RAMFLG Set/reset RAMFLG flag -- when 650C 80,85 [0839] 650E 87,A3,86 DCLR V@SEXTRM in program mode & ERAM exist [0840] 6511 87,A3,8A DCLR V@ERRLN Disallow CONTINUE after RUN [0841] 6514 06,68,DC CALL KILSYM Reset ERR handling to defualt [0842] 6517 BE,73,88 ST RSTK,@SUBSTK Set the stack empty [0843] 651A 05,6A,70 B G6A70 [0844] 651D 05,D0,0D EDTZ05 B EDTZ00 Quote Link to comment Share on other sites More sharing options...
Willsy Posted April 6, 2015 Share Posted April 6, 2015 fbForth 2.0: 76 seconds in graphics mode TurboForth 1.2.1: 43 seconds in graphics mode Program==>> : NUMS 1001 1 DO I . CR LOOP ; ...lee Cool This version of the code (in TF) runs in ~14 seconds. But it is cheating! : nums 0 0 4 24 panel \ define scroll window false sscroll ! \ disable default upwards screen scroll 1001 1 do 0 23 gotoxy i . 4 scroll loop \ 4=scroll up true sscroll ! \ re-enable auto screen-scroll 0 0 gotoxy ; I also tried this in TF: : NUMS 1001 1 do i n>s type cr loop ; Which appeared to be a little bit faster. Either way, it just goes to show that probably >80% (I haven't done any figures) of the time is "wasted" scrolling the screen. In fact, let's time it. I'll use TF because it's simple to turn off the screen scrolling when the print position hits the bottom of the screen: Lee's original code, above: 43 seconds. Here's the same code without any scrolling: : NUMS false sscroll ! 1001 1 do i . cr loop true sscroll ! ; 3 seconds. So, if I've done my math right ((3/43)*100)-100, this demonstrates that TurboForth spends 93% of the total run time (of the example program, above) scrolling the screen! OMG! It's possible to make the 3 second program above slightly faster: : NUMS false sscroll ! 1001 1 do i . loop true sscroll ! ; Takes about 2.5 seconds (as far as I can measure it). The CR runs a not-inconsiderable amount of machine code. Not executing it is obviously going to make a difference. Anway... as you were! Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted April 6, 2015 Share Posted April 6, 2015 XB has a SCROLL routine in the ROM's that is faster than the TI BASIC routine. I knew about that routine but did not want the compiled code be dependent on having the XB cartridge in the slot. I think my scroll is faster, but don't know how to test just the speed of the XB scroll routine. If I was interested enough I guess an assembly routine that did nothing but call the XB scroll routine 1000 times would work. 1 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 6, 2015 Share Posted April 6, 2015 (edited) So, straight logic (no scrolling) TF smokes at 3 seconds! How about this code? LOOP LI R2,1000 DEC R2 JNE LOOP END I assembled it, but can't get it to run for some reason. I'm pretty rusty on using the EA cart, I guess. Edited April 6, 2015 by Opry99er Quote Link to comment Share on other sites More sharing options...
Willsy Posted April 6, 2015 Share Posted April 6, 2015 You need a space in front of END otherwise it's seen as a label. Also the label loop should point to the DEC instruction, not the load instruction! Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 6, 2015 Share Posted April 6, 2015 Ahhhh yep.... Duh. The END is indented in my source... Just didnt translate in the code box. Thanks Willsy Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 6, 2015 Share Posted April 6, 2015 I'll retest Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.