CPCWiki forum

General Category => Technical Support - Software related => Topic started by: Wawavoun on 12:28, 12 June 23

Title: CPC6128 CPM 2.2 or Plus time measurement
Post by: Wawavoun on 12:28, 12 June 23
Hello,

I try to measure the execution time of cpm programs.

Into Locomotive Basic there is native functions to do that.
Also it is possible to read HB8B4 --> HB8B7 and get how many 1/300th second are elapsed since last reset.

I believe these addresses are feeded by a basic routine into the rom.

Run CPM and they stop to move on.

Is there something equivalent onto CPM ?

I see on some documentations that there a bios TIME function so probably somewhere an equivalent information is stored but where.
If yes how to call this function from eg basic ?

The language I use (Basic80, Bascom, Fortran80) looks to not have any function related to time management...

Regards.
Philippe


Title: Re: CPC6128 CPM 2.2 or Plus time measurement
Post by: McArti0 on 18:03, 12 June 23
CPM plus works the same like BASIC, B8B4-B8B7 and CALL BD0D return time in DE,HL registers.
Title: Re: CPC6128 CPM 2.2 or Plus time measurement
Post by: Wawavoun on 19:50, 12 June 23
You mean that I should be able to read HB8B4 --> HB8B7 under CPM and get the same information than with Locomotive Basic ?
Title: Re: CPC6128 CPM 2.2 or Plus time measurement
Post by: McArti0 on 22:04, 12 June 23
YES!

In CPM 2.2 Interrupt is identical like Rom Firmware. 0038 JP B941

In CPM plus 

0038   JP &FDAE

.LFD96
PUSH AF
PUSH HL
EXX
LD A,#C1
OUT (C),A
EXX
LD HL,(#FEDF) ; in HL is B941
CALL LFDAD
LD A,(#FE58)
CALL #FD04
POP HL
POP AF
RET
.LFDAD
JP (HL)    ;  Jump to default Int procedure.
.LFDAE
JR LFD96 ; from 0038

Title: Re: CPC6128 CPM 2.2 or Plus time measurement
Post by: McArti0 on 19:50, 13 June 23
BUT in CPM plus ....

User program work in C2 setting of RAM. (OUT 7F00,C2) Bank 4,5,6,7

Timer memory is in C1 setting. Bank 0,1,2,7.

Your procedure to read Timer memory must have an absolute addres above C0A0, jump to C1, read memory and back to C2.

ps. Maybe there is some elegant solution by calling system function. I don't know that.
Title: Re: CPC6128 CPM 2.2 or Plus time measurement
Post by: ajcasado on 09:58, 14 June 23
In CPM+ there are bdos functions to manage the system time (104 & 105): https://www.seasip.info/Cpm/bdosfunc.html

You will only have a resolution of seconds, not 1/300th of a second as when using the CPC firmware.

Using a Basic dialect you should be able to use the CALL statement to reach the BDOS. For example, look at the pages 2-3 and C-5 of the BASIC-80 reference document:
https://ia800708.us.archive.org/8/items/BASIC-80_MBASIC_Reference_Manual/BASIC-80_MBASIC_Reference_Manual_text.pdf

EDIT:
Using Fortran you can use a subprogram call, see apendix C on page 102 of this Fortran manual:
https://ia902904.us.archive.org/31/items/bitsavers_microsoftc03.0ReferenceManual1977_4603160/Microsoft_FORTRAN-80_3.0_Reference_Manual_1977.pdf
Title: Re: CPC6128 CPM 2.2 or Plus time measurement SOLVED
Post by: McArti0 on 16:51, 24 June 23
YES YES YES!!!  ;D

In CPM plus

CALL &FC5A  ; For CPM 2.2 &BE9B

DW &BD0D ; - Addres Firmware Procedure

in register DE,HL is time counter.

Its work!  :-*

Inspired by  turpas3.angelfire.com/unifirm.pas (https://turpas3.angelfire.com/unifirm.pas)



175   &BD0D   KL TIME PLEASE
      Action: Returns the time that  has  elapsed  since the computer
              was switched on or reset (in 1/300ths of a second)
      Entry:  No entry conditions
      Exit:   DEHL contains the four byte  count of the time elapsed,
              and all other registers are preserved
      Notes:  D holds the most signifilcant byte of the time elapsed,
              and L holds the least  significant; the four byte count
              overflows after approximately l66 days have elapsed.
Powered by SMFPacks Menu Editor Mod