Omnimaga
Calculator Community => Other Calculators => Topic started by: harold on July 31, 2011, 09:49:28 am
-
I did a primitive order-1 frequency analysis of z80 opcodes as used in TIOS.
It's pretty useless really, but it shows some interesting things.
For example, it's clear that control flow instructions are particularly popular.
Also, there's a general bias towards low values. This bias is much higher for immediate values (as in ld a,imm8 and cp imm8)
Perhaps something to keep in mind when writing a compressor for programs.
-
:o O.O :o
And what can we learn from this pic?
looks funny!
-
Is there a key? What do the colors represent?
-
Hotter colours are more common.
In order, black, gray, green, yellow, red, purple
One of the things I noticed is that the ED prefix isn't rare in itself, but doesn't have one of those "lines" across the map - it's only common in combination with a few select bytes following it.
-
Interesting Harold. :) One thing to keep in mind, however, is that TI apparently hardly optimized their OS code (judging by the reactions from BrandonW while he was examinating the code during a video livestream last year), so I wouldn't be surprised if the average ASM source by people on this forum gave different results. :P
By the way how did you generate this pic?
-
I wrote a small C# program, barely a dozen lines of code..
Then I took a look at it and marked some lines.
My guess is that optimized assembly has a higher arithmetic/control-flow ratio (and also less cp's, by using the flags from other instructions better), but I couldn't quickly gather enough proper material to analyze.
In the upper left part of the lower right quadrant (so, just off the middle), there are a couple of intriguing diagonal lines - does anyone have any thoughts on that?
-
Lol, look at the NOPs at the top.
I thought TI's most common instruction was ld a,a. :P