1 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
---|
2 | Running the O'Caml 8051/8052 emulator. |
---|
3 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
---|
4 | |
---|
5 | * Compile the C source file with SDCC. SDCC will generate a number of files, |
---|
6 | including two files in the standard Intel Hex format (extensions .hex and |
---|
7 | .ihx). These files (both are the same, just with differing extensions) are |
---|
8 | understood by the O'Caml emulator. |
---|
9 | * Build the emulator by running: |
---|
10 | $ ocamlbuild test.native |
---|
11 | * The emulator outputs on stderr. As all 8051 programs loop infinitely, you |
---|
12 | must manually terminate the emulator process after a few seconds, in order |
---|
13 | to view the execution trace. To execute the emulator, run: |
---|
14 | $ ./test.native HEX_FILE 2> /tmp/log |
---|
15 | (assuming you are using the Bash shell, where 2> /tmp/log is a pipe from |
---|
16 | stderr to a temporary log file). |
---|
17 | * Open /tmp/log. The first section, above the dotted lines, is a sequential |
---|
18 | readout from the emulator's code memory. You can turn this off by editing |
---|
19 | test.ml. The number of code memory cells that are printed is hard coded in |
---|
20 | test.ml, also, so if loading a large program, you may need to change this |
---|
21 | hard coding (alternatively, the hard coded limit may be too large, in which |
---|
22 | case NOP is printed). |
---|
23 | |
---|
24 | Following the dotted lines, the execution trace begins. Usually, you have |
---|
25 | to scroll down quite some way until you see the `interesting' part of the |
---|
26 | execution (i.e. after the standard preamble). |
---|
27 | |
---|
28 | NOTE: the emulator does not replace fixed memory locations with their |
---|
29 | mnenomics. For instance, DPL and DPH are memory locations 0x81 and 0x82, |
---|
30 | respectively, and the B register is 0xFF (if I remember correctly). |
---|
31 | |
---|
32 | NOTE: although most of the opcodes are debugged and tested, you may still |
---|
33 | come across bugs in the ones we have not reached yet. If you do find a bug, |
---|
34 | please let us know! |
---|