EdouardBERGE / rasm

RASM powerful Z80 assembler
129 stars 16 forks source link

Suggestion: add a `duration` function that returns the execution time of the given opcode #3

Closed rgiot closed 3 years ago

rgiot commented 4 years ago

The following sample file illustrates a simple example that works properly with my toy assembler: https://github.com/cpcsdk/rust.cpclib/blob/master/cpclib-asm/tests/duration.asm and deserves to be available with rasm.

To add this function will allow people that write stable code to not search the execution time of an opcode.

Example:

defs 64 - duration(out (c), a) + duration(inc l) + duration(ld a, (hl))

Note that most complex cases would better fit with the TIMER-like directives.

Maybe a function that takes a single line listing would be better:

defs 64 - duration(out (c), a : inc l : ld a, (hl))
EdouardBERGE commented 4 years ago

There is an incomplete math function called GETNOP doing this

Usage is GETNOP('out (c),a') with quotes inside parenthesis

DURATION will be an alias for GETNOP when in CPC mode and an alias for GETTICK (in the future) to get Z80 ticks instead of CPC nop duration

WIP!

EdouardBERGE commented 3 years ago

with last commit, all opcodes are supported avoid using variables in duration code because parsing is very simple for data or label, use 0 or $ or (ix+0) it should be fine