Tuesday, 17 July 2012

C version of CPU Core

To get the system into an Arduino, I need a C version. This also can be used for simulating, running programs in a command line and for testing.

The first version of this is now available. It has three modes of use controlled by a single parameter.

nri832 run - runs the simulator for the Arduino system which isn't implemented yet.

nri832 test - runs the unit test of the CPU core, running 1,000,000 simulated instructions which takes about 7 seconds on my PC.

nri832 ???? - runs the binary file and dumps the processor status to the console as it goes along.

The code is for Code::Blocks and the provided binary is for 64 bit Linux, though it should compile on any version of gcc or more or less any other 'C' compiler.

The picture shows the result of a run of the 'divide' code.  It is dividing $86 (134) by $0C (12) giving a result of $0D (13) remainder $02 (2).

These values are store in the data memory except for the result which is in the Accumulator.

This version also supports the subroutine extensions and 512 bytes of memory.

No comments:

Post a Comment