MegaProcessor

Artifact [c7d9fa489f]
Login

Artifact c7d9fa489faa12669634bde342852fb9d2f61364:

Wiki page [Generating test data] by jos 2015-10-09 10:25:14.
D 2015-10-09T10:25:14.786
L Generating\stest\sdata
P c970879df8f82e1dc8f03ac4ebc05eeec4a71436
U jos
W 1653
<h2>Intro</h2>

Aside from processing assembly source, it can be quite handy to directly generate data for the MegaProcessor simulator.

Categories:

  *  Rotate/shift and bit test/change instructions
  *  Intel Hex format

<h3>Rotate/shift and bit test/change instructions</h3>

File `tools/gen_bitops.lua` generates all the 1088 bit-oriented instructions in mnemonic format.

<h3>Intel Hex format</h3>

Once a library such as [/artifact/b71f8a7265c8d867|ihex.lua] is available,<br>
we can simply fill a table with byte-values, and emit intel-hex records to stdout.<br>
( or use the shell redirect '>' )

<pre>
---------------------------------------------
-- All bytes from 0x00 .. 0xff
require('ihex');

local data = {};

for i=0,255 do
    table.insert(data,i)
end

ihex_reset()

for i=0,7 do
    ihex_datarecord(data,32,(i*32+1) );
end

ihex_endrecord();

-- EOF --
---------------------------------------------
</pre>

A somewhat more complicated example...

<pre>
---------------------------------------------
-- All 2-byte combinations starting from d8 00; d8 01; ... 
-- up to (and including) ... df fe; df ff;
-- (To test disassembly of the bitwise shift/rotate/change/test operations)
require('ihex');

local data = {};

for instr = 0xd8,0xdf do
        for postb = 0x00,0xff do
                table.insert(data,instr);
                table.insert(data,postb);
        end
end

ihex_reset();
for i=0,15 do
    for j=0,15 do
        ihex_datarecord(data,16,i*256+j*16+1);
    end
end
ihex_endrecord();


-- EOF --
---------------------------------------------
</pre>


Z 9d5f0e586211e151450bc54f5499f753