|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
i have written a SML code(below) which ask the user to input positive number and print out the total sum. the program will jump out of the input if user enter negative number. But don't really know how to write a simulator with C++ to test the code. hope somebody can help me with it.
Location Number -------- ------ 00 +1009 (10=read,09=location of A) 01 +2009 (20=load, 09=location of A) 02 +4108 (41=branch negative, 08=write to screen) 03 +2010 (20=load,10=location of B) 04 +3009 (30=add,09=location of A) 05 +2110 (21=store,10=location of B 06 +4000 (40=branch,00=read A) 07 +1110 (11=write,10=location of B) 08 +4300 (halt) 09 +0000 variable of a 10 +0000 variable of b |
| Sponsored Links |
|
|
|
|||||
|
Do you know how to dynamically allocate memory? Do you know how to create a linked list? Do you have any compiler theory in your background? Depending on your answers to those questions, we may be able to help. In general, writing a simulator is a non-trivial project.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
I would do something like the following:
Create a map between instruction numbers and instructions. Load the instructions into the map. Create another map between "memory" locations and text representations of their values. Have a variable to store the current instruction. Have an instruction processor based on what counts as a valid statement.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic Calculator | AfTriX | VB Tutorials | 3 | 02-29-2008 08:53 AM |
| How to write such code??? | stephen0606 | C and C++ | 5 | 10-10-2007 08:24 PM |
| Please Help With A C Program!! | siren | C and C++ | 7 | 04-17-2007 08:45 AM |
| Where to Put PHP Code | clookid | PHP Tutorials | 1 | 01-11-2007 08:44 PM |
| Xav | ........ | 1322.18 |
| MeTh0Dz|Reb0rn | ........ | 1053.7 |
| morefood2001 | ........ | 879.43 |
| John | ........ | 877.37 |
| marwex89 | ........ | 869.98 |
| WingedPanther | ........ | 830.24 |
| Brandon W | ........ | 735.07 |
| chili5 | ........ | 309.39 |
| Steve.L | ........ | 236.23 |
| dcs | ........ | 216.02 |
Goal: 100,000 Posts
Complete: 82%