News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

a mathematical demo

Started by litwr, 19:31, 24 December 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

litwr

#25
Quote from: ZbyniuR on 21:06, 09 January 16
Did you see this?    Search for prime numbers in Basic, here compare CPC and C64:

https://www.youtube.com/watch?v=pxye-RbKFpY

My friends from speccy.pl made more tests:

BBC Master        - 0'25 - here is little bit optimised but I suppose it safe maximum 2 sec.
Amiga Basic   - 0'30
...
These are tests of Basics - they show mostly the performance of ROM Basic.  They are also a bit superficial, for example, Commodore +4 fast mode (just blank screen for it) gives 50% speed boost. Locomotive Basic is much faster than Commodore...
The π-number calculator is not benchmark - it is namely the mathematical demo - it realized the computation by the fastest known way using all CPU power.  BTW Commodore +4 PAL can make 800 digits of π for only 98 seconds.  It uses the same ML-program as C64 or C128.

Urusergi

#26
Quote from: ZbyniuR on 22:02, 10 January 16But method of the ACU is realy much faster.
Program from film after optimizing is need less than 53 sec to find prime numbers from 2 to 997, and method of ACU after a small amendments does it in 15.6 sec.
Or around ten seconds  ;D
10 DEFINT a-z
20 pri=3:ma=1000
30 DIM sieve(ma+1)
40 ZONE 8
50 PRINT pri-1,
60 WHILE sieve(pri)
70 pri=pri+2
80 WEND
90 FOR i=pri TO ma STEP pri*2
100 sieve(i)=-1
110 NEXT
120 IF pri<ma THEN PRINT pri,:GOTO 60

litwr

IMHO it will be the best to start a new topic "The benchmark of Basics".  I am still curios about some of them, e.g., Warsaw Basic, ... My measurements show that Locomotive Basic interpreter may be even faster that p-code compilers for Commodore.  :o

ZbyniuR

Urusergi - Your way need 7.7sek. Genius!  My small improve take 7.2 (on 6128), and with XD-DOS (FastPrint) only 5.8sec. :)

10 DEFINT a-y:ZONE 8:MODE 2:z=TIME:p=3:m=1000:DIM s(m+1):PRINT 2,
20 WHILE s(p):p=p+2:WEND:FOR i=p TO m STEP p*2:s(i)=-1:NEXT:IF p<m THEN PRINT p,:GOTO 20 ELSE z2=TIME:PRINT(z2-z)/300

Since months I try find time to find and compare the different ways of sorting in Basic.

Is Typhoon is the only compiler for CPC which uses floating point numbers?
In STARS, TREK is better than WARS.

AMSDOS

#29
Quote from: ZbyniuR on 00:13, 13 January 16
Is Typhoon is the only compiler for CPC which uses floating point numbers?


I only know Typhoon the Game, so I curious regarding where the Compiler is.


EDIT: Okay I found it, a French BASIC Compiler called Typhon, the page I found it on mentions it after the Laser BASIC Compiler, so I'm presuming their separate programs. The Fabacom (Fast Basic Compiler) also supports Floating Point Numbers.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Urusergi

Quote from: ZbyniuR on 00:13, 13 January 16
Urusergi - Your way need 7.7sek. Genius!  My small improve take 7.2 (on 6128), and with XD-DOS (FastPrint) only 5.8sec. :)

10 DEFINT a-y:ZONE 8:MODE 2:z=TIME:p=3:m=1000:DIM s(m+1):PRINT 2,
20 WHILE s(p):p=p+2:WEND:FOR i=p TO m STEP p*2:s(i)=-1:NEXT:IF p<m THEN PRINT p,:GOTO 20 ELSE z2=TIME:PRINT(z2-z)/300

Since months I try find time to find and compare the different ways of sorting in Basic.
Thanks  :-[ Don´t hesitate to ask me if you need help with that.

litwr

I've just made a few updates - http://litwr2.atspace.eu/pi/pi-spigot-benchmark.html
I can't reach C128, CPC6128 with mathematics shows speed of 1.8 MHz 6502... However it is the open project - anybody may try to write a better z80-code.  But beware it will be not easy.  ;)

Fessor

The Benchmarks are "unclean" as they did not take into account how much time is needed to printout a digit.
Computers with a real Text-Mode have a speed advantage about Computers with bitmapped screens and due to this are slower at printing.

Docent

Quote from: litwr on 16:01, 06 March 16
I've just made a few updates - http://litwr2.atspace.eu/pi/pi-spigot-benchmark.html
I can't reach C128, CPC6128 with mathematics shows speed of 1.8 MHz 6502... However it is the open project - anybody may try to write a better z80-code.  But beware it will be not easy.  ;)
"mul10000.s" for Amstrad is missing from the archive.


litwr

#34
Quote from: Fessor on 17:35, 06 March 16
The Benchmarks are "unclean" as they did not take into account how much time is needed to printout a digit.
Computers with a real Text-Mode have a speed advantage about Computers with bitmapped screens and due to this are slower at printing.
This is a nature of this combined demo-benchmark.  The screen output time makes difference for 100 digits result but it means very little for 3000 digits calculation.  My point - the program should print the results in the natural for OS way.  For example, PUT CONSOLE OUTPUT TO FILE should continue to work with CP/M.  Console output is very slow at CP/M but it is possible to use other operating systems.
Quote from: Docent on 18:06, 06 March 16
"mul10000.s" for Amstrad is missing from the archive.
I am very sorry.  :(  it is fixed!

litwr

#35
The things are updated - π  :D  The z80 code has become a bit faster.  I've added MSX (even turbo R) systems and Commodore 128 in z80 mode.  I thought that MSX maybe faster than Amstrad due to separate video memory but CPC showed 18% better speed.  :)  Commodore 128 is the shame.  How was it possible to do so monstrous, expensive and slow computer in 1985?  :o The number of C128 units sold is bigger than CPC6128's.  :o  This shows that it was kind of manipulation of the customers.  :( However it is a bit curious why z80 programmers lost the opportunity to work with C128.  It is about 90% slower than CP6128 but it has the advanced custom chips.  The VIC's sprites should be much faster than the software sprites.  So C128 games or demos in z80 mode maybe faster than their analogies for CPC... VIC has also very smooth scrolling...
I tried also to make PCW version but it looks almost impossible.  PCW has a good emulator but it is the one only and without debugger. :( I couldn't find a way to use timer under PCW.  There is almost complete absence of the programming documentation for PCW.  It looks like a big oddity for so mass produced computer.  I used PCW during 3 years (1989-1991)... Could anybody provide any help with information about timer?

TMR

Quote from: litwr on 21:02, 14 May 16However it is a bit curious why z80 programmers lost the opportunity to work with C128.  It is about 90% slower than CP6128 but it has the advanced custom chips.  The VIC's sprites should be much faster than the software sprites.  So C128 games or demos in z80 mode maybe faster than their analogies for CPC... VIC has also very smooth scrolling...

When you use the Z80 you don't really get the C128; the MMU gets shut down so it's a 64K machine which in turn takes C128-specific features like double buffered colour RAM off the table, interrupt handling is [ahem] quirky to the point i never got my head around it, the VIC-IIe seems to get royally messed with if commands like LDIR are used during the display and the testbit "features" don't appear to work at all, I/O registers including the colour RAM should be written to with OUT commands rather than directly... you get the idea.

Tl;DR version; for most things at least, it's easier and probably more efficient to use the 8502. =-)

Singaja

In terms of π generation algorithm used , isn't the Ramanujan algorithm a viable approach? It might be too much for the Z80 to handle though.
The formula is:

It's modern form formulated by Chudnovsky brothers is used for current record braking.

ZbyniuR

As I know C128 have 3 modes of work:
VIC-II + MOS 1MHz - the same colors, sprites and resolutions as C64.

VDC  + MOS 2MHz - with different RGBI 16 colors, max 640x400 in 64K VRAM, with faster processor and some kind blitter but without sprites at all.

VDC  + Z80 2MHz - graphics as above but because Zilog must be twice as fast as MOS to have equal power, and as you see in that case IS NOT, so default mode in CPM is semigraphic text mode. 4K for screen. Half for characters and half for colors for each sign. So forget about something spectacular in Zilog mode.

C128 with FDD cost as 6128 with monitor. But Commodore was sold in more countries then CPC and had traditions to selling popular computers for games (C64), and computers for small business (CBM series) with more popular 5.25" floppy. Adverts was fantastic. ;)  Amstrad was new on market and was know local in part of Europe only. To buy big FDD for CPC was cheeper than buy monitor for C128, but who knew about it?
In STARS, TREK is better than WARS.

FloppySoftware

Quote from: litwr on 21:02, 14 May 16
I tried also to make PCW version but it looks almost impossible.  PCW has a good emulator but it is the one only and without debugger. :( I couldn't find a way to use timer under PCW.  There is almost complete absence of the programming documentation for PCW.  It looks like a big oddity for so mass produced computer.  I used PCW during 3 years (1989-1991)... Could anybody provide any help with information about timer?

The Amstrad PCW runs under CP/M Plus, then, you could use the time fields stored in the SCB; this is valid for the CPC when running CP/M Plus too.

The SCB parts you are interested in are the clock minutes and seconds.

So, there is a lot of information about PCW programming at CP/M level (tons of books out there).

Regarding PCW emulators, there are two of them:

  1. Joyce from John Elliott: JOYCE for UNIX
  2. CP/M Box from Habi: CP/M Box

Joyce was the first one, with a LocoScript-like GUI, and CP/M Box is more recent, with a nowadays GUI.

Good luck.
floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

mahlemiut

MAME emulates the PCW also.
- Barry Rodewald

TMR

Quote from: ZbyniuR on 17:41, 15 May 16
As I know C128 have 3 modes of work:
VIC-II + MOS 1MHz - the same colors, sprites and resolutions as C64.

Sort of... the 8502 can be run at 2MHz in the upper and lower borders which means 2MHz for about a third of the display on a PAL machine. Resolutions and sprites are the same, but the MMU means it's possible to double buffer the colour RAM and, because it's a VIC-IIe rather than just a VIC-II, the test bit can be (ab)used to either swap the R and G values of the standard palette or desaturate it completely - these aren't documented and only work on a CRT it seems.

Quote from: ZbyniuR on 17:41, 15 May 16VDC  + MOS 2MHz - with different RGBI 16 colors, max 640x400 in 64K VRAM, with faster processor and some kind blitter but without sprites at all.

It's not a blitter, there's a DMA for moving data around within the VDC RAM, and getting data back and forth between there and the system RAM where the CPU can deal with it isn't very efficient. There are hardware smooth and coarse scrolling options for the VDC as well.

And there's a fourth mode you missed by the way, VIC-IIe and Z80 does work even though there are those caveats  mentioned previously.

litwr

#42
Quote from: FloppySoftware on 22:37, 15 May 16
The SCB parts you are interested in are the clock minutes and seconds.
So, there is a lot of information about PCW programming at CP/M level (tons of books out there).
Thanks but could you point to the information about 300 Hz timer?  How to use this interrupt?  The seconds level is too crude for the demo, it requires at least 0.1 second.
Quote from: mahlemiut on 23:30, 15 May 16
MAME emulates the PCW also.
Did you run PCW with MAME?  MAME is very difficult to use and it doesn't work in a lot of cases. :(

mahlemiut

Quote from: litwr on 14:47, 16 May 16Did you run PCW with MAME?  MAME is very difficult to use and it doesn't work in a lot of cases. :(
Uh yes, I've worked on MAME's PCW driver a bit (although arnoldemu is the original author of the driver).
- Barry Rodewald

arnoldemu

Quote from: mahlemiut on 23:25, 16 May 16
Uh yes, I've worked on MAME's PCW driver a bit (although arnoldemu is the original author of the driver).
Yes, many years ago....

@litwr: You said "MAME is very difficult to use and it doesn't work in a lot of cases.".

Are you referring to the emulation of the PCW, or the MAME emulator itself?

When you say it doesn't work in a lot of cases is this PCW, CPC, or MAME not working with your hardware?

The PCW emulation was based off the official documents. I didn't have a PCW to test things on so the emulation is likely to be inaccurate.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

#45
Quote from: litwr on 14:47, 16 May 16
 
Thanks but could you point to the information about 300 Hz timer?  How to use this interrupt? 
Notes on PCW I/O ports

Amstrad "Joyce" software interface specification

I don't know how the timer is connected in the cpm system, so you may need to hit the hardware directly.

It is probably similar to the CPC in it's operation.

I would say that to determine if the interrupt is from fdc or the timer you should read the timer counter register and see if it changed.

Something a bit like this (totally untested):



di
ld a,&c3
ld hl,int_handler
ld (&0038),a
ld (&0039),hl
;; initialise base-line timer count
in a,(&f4)
ld (timer_count),a
ei

loop:
jp loop

int_handler:
push bc
push af
in a,(&f4) ;; read current
ld c,a
ld a,(timer_count) ;; different to previous read?
cp c
jr z,int_handler2
;; timer changed, assume int is from timer.
ld a,c
ld (timer_count),a

;; do timer based int stuff.

int_handler2:
pop af
pop bc
ei
reti



timer_count:
defb 0


The code will not work well if a fdc int happens at the same time as a timer int. It's difficult to know which caused the int. So it's best if floppy uses nmi. If you disable int sources from fdc, then the int will be the timer one.

It's also not clear if im 2 and vectored interrupts can be used, the document doesn't mention it at all. It also doesn't mention how to differentiate the two.

EDIT: Now I read the document you *can* tell if it's timer or not.




di
ld a,&c3
ld hl,int_handler
ld (&0038),a
ld (&0039),hl
ei

loop:
jp loop

int_handler:
push bc
push af
in a,(&f8) ;; read system status
bit 5,a ;; fdc interrupted?
jr nz,int_handler2 ;; ignore

;; do timer based int stuff.

int_handler2:
pop af
pop bc
ei
reti





My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

litwr

#46
Thanks for the code.  :)  IMHO it will not work because the interrupt may occur during the system call when CPU is in other bank of memory. So we need a kind of RSX but can this RSX work with interrupt is a question.  So absence of documentation indirectly confirms that this is impossible.  :(
There is other problem.  I tried ZSID 1.4 with PCW CP/M.  It worked fine with Amstrad CPC CP/M 2.2 or Commodore C128 CP/M 3 but it doesn't work with PCW CP/M or Amstrad CP/M 3. :( Is there version of ZSID for Amstrad CP/M 3?  I can't even find word ZSID in the AMSTRAD wikipedia. :(
[MAME,MESS] It asks for two ROMs... BTW the newer MAME's become very odd it may even demand non-existed firmware. :(

*EDIT* I've just found a patch for ZSID at Digital Research Binary Files which fixed ZSID.  :)

mahlemiut

Quote from: litwr on 16:57, 17 May 16[MAME,MESS] It asks for two ROMs... BTW the newer MAME's become very odd it may even demand non-existed firmware. :(
You mean the printer MCU and keyboard MCU dumps?  I'm sure they're around here somewhere.
The keyboard MCU is used for keyboard handling, the printer MCU is used for printing and booting (this is where the bootstrap code comes from, although MAME doesn't yet do the proper boot sequence as it requires the Z80 being able to stop mid-instruction).
- Barry Rodewald

arnoldemu

Quote from: mahlemiut on 23:47, 17 May 16
You mean the printer MCU and keyboard MCU dumps?  I'm sure they're around here somewhere.
The keyboard MCU is used for keyboard handling, the printer MCU is used for printing and booting (this is where the bootstrap code comes from, although MAME doesn't yet do the proper boot sequence as it requires the Z80 being able to stop mid-instruction).
@litwr: MAME is correct here.The PCW boots from the printer, it forces the bytes to the z80 which runs them.
The keyboard MCU is also required for correct emulation because the keyboard and PCW communicate keyboard codes.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

litwr

This MESS became a total mess.  :o I'd found ROMs, ran MESS and got "THIS SYSTEM DOESN'T WORK"  :( It is MESS 0.154
MESS has no debugger too... So I prefer to try CPM-box under VirtualBox.  I remember PCW as friendly computer but I was in error.  It couldn't even read CPC disks.  iDSK and CPCXFS utilities do not work with PCW disk images.  I am almost ready to cease to do anything with all this mess. :(

Powered by SMFPacks Menu Editor Mod