Assembler Optimizer

Página 57/57
50 | 51 | 52 | 53 | 54 | 55 | 56 |

Por Metalion

Paragon (1557)

imagem de Metalion

31-05-2022, 08:49

Hello santiontanon,

I don't know if your optimizer uses this (time and size) optimization:

ld a,r  ;  5
neg     ; 10

transformed into:

xor a   ; 5
sub a,r ; 5

Just a suggestion, if it's not already taken into account.

Por theNestruo

Champion (360)

imagem de theNestruo

31-05-2022, 12:05

Metalion wrote:

Hello santiontanon,

I don't know if your optimizer uses this (time and size) optimization:

ld a,r  ;  5
neg     ; 10

transformed into:

xor a   ; 5
sub a,r ; 5

Just a suggestion, if it's not already taken into account.

Yup, it is there already: https://github.com/santiontanon/mdlz80optimizer/blob/master/...

Por santiontanon

Paragon (1653)

imagem de santiontanon

06-09-2022, 16:48

It had been a while since I made a new release, so, I just released version 2.5 in GitHub: https://github.com/santiontanon/mdlz80optimizer/releases/tag...

The new version contains many many small improvements and fixes here and there (things that I needed), but the two main new additions are:
- support for the WLA-DX assembler (common in the console development world)
- a new "code execution" functionality which is useful to optimize code without having to get it into an emulator/system to measure its execution.

I find this last functionality very useful, and I have been using it a lot in a project I am working on that is not for MSX, and hence all the fancy features of openMSX are not available. For example, imagine you have this simple code:

    org #4000

start:
    ld hl,table
    ld de,#c000
    ld bc,4
    ldir
end:

table:
    db 0,1,2,3

You can call mdl like this (telling MDL to start executing at "start", and stop once the PC reaches "end"):

java -jar mdl.jar test.asm -e:u start end

And you will get this as output:

INFO: Execution result:
INFO:   f: 32 (#20)
INFO:   d: 192 (#c0)
INFO:   e: 4 (#04)
INFO:   h: 64 (#40)
INFO:   l: 15 (#0f)
INFO:   r: 4 (#04)
INFO:   (#c000) = 0 (#00)
INFO:   (#c001) = 1 (#01)
INFO:   (#c002) = 2 (#02)
INFO:   (#c003) = 3 (#03)
INFO:   4 instructions executed.
INFO:   execution time: 120 t-states

As you can see if shows everything that changed (registers and memory). Perhaps, I should also add which flags changed?

Naturally, you can change the z80 type. By default it uses an MSX-configured z80, but if you use "-cpu z80", then executio only takes 109 t-states (e.g., on a Spectrum), and if you say "-cpu z80cpc", you get "32 nops" (As time in the Amstrad CMC is measured in "nops").

Anyway, I find it very useful to check small routines :)

Por thegeps

Paragon (1062)

imagem de thegeps

06-09-2022, 23:02

Oh this is a really cool update! It can be used as debugger for specific program zones! Thank you Santi!

Por ro

Scribe (4745)

imagem de ro

07-09-2022, 12:53

but, "END" is an assembler command that tells it to shove it. I would expect "label table not found" error or something.

Por santiontanon

Paragon (1653)

imagem de santiontanon

07-09-2022, 15:06

Ah yes! some assemblers reserve the "end" label for internal purposes, such as for finishing the assembly process. MDL does not make any assumptions about that, since not all assemblers reserve the "end" label for that, so, it'll not complain about it.

But I used "start" and "end" just for the example. You can use any two labels in your code, of course. Alternatively, with the "-e:s" flag, you can also tell it a start label, and a predefined number of t-states instead of specifying a target label to reach Smile

Página 57/57
50 | 51 | 52 | 53 | 54 | 55 | 56 |