We want to measure the exact time taken by a routine (microsecond precision, aka NOP time unit).

Clockwall profiling from the monitor.


(Documentation as it would be written once the feature is implemented.)


  • No overhead
  • Handle real routines with auto-modifications, I/O access (e.g. FDC).


  • Routine musn't crash. (Oh, maybe that's a pro).
  • Routine must be self-sufficient (you can CALL it, and it will return or BRK).

If the routine is less than 310 rasters lines. (*)

Introduced in FF alpha 10.

Assemble your source, and in monogams type either:

profile Projection3D
pr Projection3D
pr ; Shortcut to profile the same routine as previously.

It will execute the code as-is until BRK or final RET is reached.

(*) It would also work if you know your routine takes between N and N+1 * 52 raster lines ("HALTs"),
and are just interested by the time in the last portion.

See 64nops torus asm profiling section for more details.
Here for now.

If the routine takes more than 310 rasters lines.

Not available yet.

Here the tool uses (non-firmware) interruptions to measure the gross part of the elapsed time.
This implies more constraint on the routine:
At each interruption, 2 words would be pushed on the stack (PC and HL).
You must stay aware of that if you use the stack for other purposes.
(Reminder: in some context, it's perfectly fine to use the stack to read of write data, while leaving the interruptions on).
You can actually protect critical sections with DI, given that:
- You put back EI.
- The section doesn't last more than 84 raster lines.

Open questions:

- Which command to use for no-int vs int version?

In the future

- What if we want to run the runtime x times to mesure variation taken?
- For <52 lines, we could do that automatically.
- Introduce directive (e.g. PROFILE START) so that CONTROL-2 would launch the profiling automatically.

Routine specification

; Return # of NOPs taken by the routine, without counting CALL/RET.
;in: HL = address of routine to execute/profile.
    ; For now, the routine is expected to RET.
;out: HL = time elapsed in microseconds (max = 104 * 64 - 2).

; Must DI before calling the routine (that's a given guarantee).

; Exemple:
   ld hl,.rout
   call profile_di

   ld hl,.rout
   call profile_di
    ld b,&7f:out (c),0
; Profile a routine of arbitrary duration.
; Same in/out than profile_di.

In-editor gross measurement.

ld b,4:djnz $ wouldn't be


  • Inaccurate (well)

In the future

Fast-trace profiling.

This would allows in-editor exact duration counting, and


  • 30x slower than normal execution.


chunk: Copy on Write routines

Stack trace profiling.

Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License