Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-29-2007, 07:24 AM
debug debug is offline
Newbie
 
Join Date: Aug 2007
Posts: 17
Rep Power: 5
debug is on a distinguished road
Default How to write a Simulator for SML code

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-29-2007, 12:11 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,418
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default

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
Programming is a branch of mathematics.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-29-2007, 12:17 PM
debug debug is offline
Newbie
 
Join Date: Aug 2007
Posts: 17
Rep Power: 5
debug is on a distinguished road
Default

yup i have learn about creating a link list and allocating memory but i dun have any complier theory background.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-30-2007, 12:14 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,418
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default

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
Programming is a branch of mathematics.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Calculator AfTriX VB Tutorials 3 02-29-2008 09:53 AM
How to write such code??? stephen0606 C and C++ 5 10-10-2007 09:24 PM
Please Help With A C Program!! siren C and C++ 7 04-17-2007 09:45 AM
Where to Put PHP Code clookid PHP Tutorials 1 01-11-2007 09:44 PM


All times are GMT -5. The time now is 02:57 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads