NED - Simulator
A simulator, assembler, disassembler and graphical front panel implementing NED v1. Browse the source code.
Status
The assembler, disassembler, and front panel are fully functional. The CPU
simulator only supports a single CPU and does not implement the CMPSWP
instruction but is otherwise functional.
The calculator included as an example of NED assembly is also fully functional.
Getting Started
Obtain a snapshot of the repository.
wget -O ned.tgz "http://gitweb.subgeniuskitty.com/?p=ned-v1-simulator/.git;a=snapshot;h=HEAD;sf=tgz"
tar xzf ned.tgz
cd ned-v1-simulator-HEAD*
Build all the tools by executing make
in the top-level directory or use
make
in individual project subfolders. Note that nedfp
requires SDL2 and
SDL2_ttf but is not required for simulation.
No install
targets are supplied for make
. Instead, manually copy the
binaries wherever you want or adjust your $PATH
to use them in place. For example:
export PATH=/home/username/ned/nedasm:/home/username/ned/nedsim:$PATH
Once the NED binaries are accessible from your $PATH
, the calculator example
can be run with make sim
. Exit with Ctrl-C
.
cd software/4func_calculator
make sim
<calculator starts up and takes control of the screen>
To use nedfp
as a graphical front panel for debugging, first start nedfp
with no arguments. Then, execute nedsim
with flags for IP address and port.
The -s
flag can be useful in slowing the simulation down enough to understand
nedfp
’s output.
nedfp/nedfp &
nedasm/nedasm -i software/4func_calculator/calc/asm -o /tmp/calc.bin
nedsim/nedsim -i /tmp/calc.bin -a 127.0.0.1 -p 4999 -s 10000
Binaries can be disassembled with neddis
. Using the calculator as an example:
% ./neddis/neddis -i ./calc.bin -s -l
Summary
=====================================
Magic: 0x00000107
Machine ID: 0x000000d7
Flags: 0x00000000
Text Size: 0x00000600 bytes
Data Size: 0x00000000 bytes
BSS Size: 0x00000000 bytes
Symbol Table Size: 0x00000514 bytes
Entry Point: 0x20000000
Text Reloc. Size: 0x00000000 bytes
Data Reloc. Size: 0x00000000 bytes
Offset || Hex || Binary || Description
===========================================================================================================================================
0x20000000 0x01041041 00 000001 000001 000001 000001 000001 NOP NOP NOP NOP NOP
calc:
0x20000004 0x90000044 1 00100000 00000000 00000000 1000100 WORD =====> 0x20000088 04000000210 536871048
0x20000008 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
calcloop:
0x2000000c 0x900000d6 1 00100000 00000000 00000001 1010110 WORD =====> 0x200001ac 04000000654 536871340
0x20000010 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000014 0x900002b8 1 00100000 00000000 00000101 0111000 WORD =====> 0x20000570 04000002560 536872304
0x20000018 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x2000001c 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x20000020 0x900000ec 1 00100000 00000000 00000001 1101100 WORD =====> 0x200001d8 04000000730 536871384
0x20000024 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000028 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x2000002c 0x90000122 1 00100000 00000000 00000010 0100010 WORD =====> 0x20000244 04000001104 536871492
0x20000030 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000034 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x20000038 0x900000fc 1 00100000 00000000 00000001 1111100 WORD =====> 0x200001f8 04000000770 536871416
0x2000003c 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000040 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x20000044 0x90000196 1 00100000 00000000 00000011 0010110 WORD =====> 0x2000032c 04000001454 536871724
0x20000048 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x2000004c 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x20000050 0x90000136 1 00100000 00000000 00000010 0110110 WORD =====> 0x2000026c 04000001154 536871532
0x20000054 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000058 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x2000005c 0x9000014a 1 00100000 00000000 00000010 1001010 WORD =====> 0x20000294 04000001224 536871572
0x20000060 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000064 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x20000068 0x90000160 1 00100000 00000000 00000010 1100000 WORD =====> 0x200002c0 04000001300 536871616
0x2000006c 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000070 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x20000074 0x90000176 1 00100000 00000000 00000010 1110110 WORD =====> 0x200002ec 04000001354 536871660
0x20000078 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x2000007c 0x06041041 00 000110 000001 000001 000001 000001 TEST NOP NOP NOP NOP
0x20000080 0x90000006 1 00100000 00000000 00000000 0000110 WORD =====> 0x2000000c 04000000014 536870924
0x20000084 0x0e001041 00 001110 000000 000001 000001 000001 JMP HALT NOP NOP NOP
calcinit:
0x20000088 0xa0000000 1 01000000 00000000 00000000 0000000 WORD =====> 0x40000000 010000000000 1073741824
0x2000008c 0x0d80d69a 00 001101 100000 001101 011010 011010 SWAP IM_0 SWAP LDSP+2 LDSP+2
calcinitzeroloop:
0x20000090 0x9000005a 1 00100000 00000000 00000000 1011010 WORD =====> 0x200000b4 04000000264 536871092
0x20000094 0x2808d381 00 101000 000010 001101 001110 000001 IM_8 LOAD SWAP JMP NOP
0x20000098 0x2069a303 00 100000 011010 011010 001100 000011 IM_0 LDSP+2 LDSP+2 ADD STORE
0x2000009c 0x18041041 00 011000 000001 000001 000001 000001 LDSP+0 NOP NOP NOP NOP
0x200000a0 0x90000058 1 00100000 00000000 00000000 1011000 WORD =====> 0x200000b0 04000000260 536871088
0x200000a4 0x07041041 00 000111 000001 000001 000001 000001 BRZ NOP NOP NOP NOP
0x200000a8 0x90000048 1 00100000 00000000 00000000 1001000 WORD =====> 0x20000090 04000000220 536871056
0x200000ac 0x0e041041 00 001110 000001 000001 000001 000001 JMP NOP NOP NOP NOP
calcinitzeroloopend:
0x200000b0 0x0618e041 00 000110 000110 001110 000001 000001 TEST TEST JMP NOP NOP
incrementstackindex:
0x200000b4 0x0d90c62c 00 001101 100100 001100 011000 101100 SWAP IM_4 ADD LDSP+0 IM_12
0x200000b8 0x90000066 1 00100000 00000000 00000000 1100110 WORD =====> 0x200000cc 04000000314 536871116
0x200000bc 0x1a3522a1 00 011010 001101 010010 001010 100001 LDSP+2 SWAP STSP+2 NOT IM_1
0x200000c0 0x0c306b02 00 001100 001100 000110 101100 000010 ADD ADD TEST IM_12 LOAD
0x200000c4 0x2220d1c6 00 100010 001000 001101 000111 000110 IM_2 AND SWAP BRZ TEST
0x200000c8 0x20041041 00 100000 000001 000001 000001 000001 IM_0 NOP NOP NOP NOP
<snip>