|
Post by C128Man on Aug 21, 2017 19:38:08 GMT
Hi, I'm trying to test the CBASIC-80 from Digital Research. This is a compiled version of BASIC. The Z-80 is the C-128 runs more or less at 2Mhz, just like the 8502 in fast mode. Here is the C-128 program: 10 fast:t=ti 20 for a=1 to 1000:b=a*a:f=99 30 e=int(b/10):e=b-e*10:b=int(b/10) 40 if e>f then 70 50 if b=0 then print a;"=";a*a:goto 70 60 f=e:goto 30 70 next a 80 print (ti-t)/60 It calculate the square of 1000 first numbers and test if the result is in ascending order. In fact, the program doesn't matter. Here is the same program in CBASIC: 20 FOR A=1 TO 1000:B=A*A:F=99 30 E=INT(B/10):E=B-E*10:B=INT(B/10) 40 IF E>F THEN 70 50 IF B=0 THEN PRINT A;"=";A*A:GOTO 70 60 F=E:GOTO 30 70 NEXT A The two program are exactly the same, except for the time calculation. In C-128 mode, the program runs in 57 sec. While the CP/M version runs in 4 min 56 sec. Almost 5 time slower than the C-128!! This is because of the C-128 or a compile switch? I don't know exactly. But the precision is very good. Do you remember the little Test program? The program calculate: 1.9999999837. It's much better than the C-128 C128Man
|
|
|
Post by bjonte on Aug 22, 2017 5:03:02 GMT
One difference is that BASIC 7.0 used 40-bit floating point numbers while CBASIC used 64-bit ones, like you noted. That slows down. Otherwise it's hard to say without taking it apart to see what it is actually doing. Maybe it is calling kernal routines that switches to 8502 mode and back. You could try removing the print to see if it makes a big difference.
|
|
|
Post by C128Man on Aug 22, 2017 15:32:47 GMT
I think, it will be more interesting to try this program on a C64 with the CP/M cartridge or on an other CP/M machine
I can put everything on a .D71 file
|
|
|
Post by remark on Aug 28, 2017 19:52:06 GMT
I think it is generally agreed that a 1 MHz 6502 is in the same speed range as a 4 MHz Z80. So the Z80 in the C128 is actually a bit "underpowered".
|
|
geneb
Windows User
Posts: 2
|
Post by geneb on Aug 28, 2017 21:35:08 GMT
Couple of things to keep in mind... C-BASIC is compiled down to p-code, not native Z-80 assembly. It's similar to Blitz! or UCSD Pascal.
You'll get (or should get) better performance out of BASCOM, which is the Microsoft BASIC compiler. It uses identical syntax as MS BASIC-80 that's shipped with most distributions of CP/M. It's v5.21 I think.
g.
|
|
|
Post by C128Man on Sept 8, 2017 18:15:44 GMT
Oups, this is "only" a p-code objet. The runtime is include in the .com?
|
|