Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Little Man Computer - Simulator Applet  (Read 17753 times)
0 Members and 1 Guest are viewing this topic.
Offline johnkershaw

Senior Newbie





« Reply #30 - Posted 2012-09-02 21:48:09 »

The students have to use LMC - not even 100% sure yet whether I'm even allowed to suggest a *different* implementation of LMC than the one they've suggested in the materials, but I'd at least like to have a standalone exemplar page I can direct the exam board to.

Regards HOW it runs, I'm happy either in-browser or as a standalone app. Currently I can't figure out how to make either of them work. I've now downloaded the NetBeans environment too, but although I can make Hello World work there, the LMC code still chokes with the same error.

John.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #31 - Posted 2012-09-03 02:05:44 »

Thanks for your interest in this project!

So I went looking for an alternative LMC app... and there aren't any! The *idea* is well documented, but implementations are thin on the ground. Yours is excellent, especially the syntax colouring and single-stepping with line highlight. Unfortunately, I'm new to Java and can't figure out how to get this to be a standalone app, even though you kindly posted the source.

Download the JAR file: here and double-click it. It will immediately launch the application.


So I went looking for an alternative LMC app... and there aren't any! The *idea* is well documented, but implementations are thin on the ground. Yours is excellent, especially the syntax colouring and single-stepping with line highlight.
That's exactly the reason I coded this LMC simulator: existing implementations were crap, often to the point of being unusable. Teaching students LMC without a parser & compiler is just cruel.


Unfortunately, I'm new to Java and can't figure out how to get this to be a standalone app, even though you kindly posted the source. I downloaded Eclipse, did the intro-tutorials, then pasted your code as a new project, but both 'checkAddress' and 'execute' are marked with red crosses, I *think* because 'EmulatorCrash cannot be resolved to a type'. Do I need to load a library/module/something to make this work? I did google 'EmulatorFeedback' and 'EmulatorCrash' but the only results point back to your page, which makes me think this is something specific to your code that I'm missing.
The posted sourcecode was the core of the simulator, and didn't contain any user-interface code, or code to parse and compile input.


PS No offence, but the anti-spam sign-up requirements for this BB are mighty steep for someone just wanting to ask a casual question!
I agree with your observation, but our experience is that anything less hard will cause a huge influx of (human!) spammers. Sorry for the inconvenience!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline johnkershaw

Senior Newbie





« Reply #32 - Posted 2012-09-03 07:44:51 »

Thanks a million - that's fantastic! Would you be okay with me approaching the exam board to offer this as an alternative LMC for project work? As I said, they are currently basing an entire chunk of the curriculum on a single implementation from a guy at York University, which doesn't offer the source code and could disappear at any moment! On that note (and because I'd still like to have a crack at compiling some 'real' Java source) would you be happy to post the complete source?

Thanks again for an excellent resource.

John.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #33 - Posted 2012-09-03 15:20:16 »

Thanks a million - that's fantastic! Would you be okay with me approaching the exam board to offer this as an alternative LMC for project work?
Sure.

I didn't quite 'agree' with the proposed syntax on wikipedia (which is just one of the proposed versions on the web). Therefore, there are a few bits you need to know:
  • There is no support for the DAT mnemonic
  • I added a way to directly assign a value to any value in memory: @96 145 (put 145 in mailbox 96)
  • labels are defined using: label: ...
  • labels are refered to using: ... :label (you can use and refer to a label on 1 line)
  • mnemonics and raw opcodes/values can be used interchangeably (which is why we don't need the DAT mnemonic)



On that note (and because I'd still like to have a crack at compiling some 'real' Java source) would you be happy to post the complete source?
The source code is not really worth it, really. For the UI it's poor code quality all the way down, the syntax highlighter, parser & compiler are a bunch of regex, and the 'core' that's properly written is already posted in this thread Smiley It'd rather keep it closed source, for the simple reason that it wouldn't end up in the hands of those novice students Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline johnkershaw

Senior Newbie





« Reply #34 - Posted 2012-09-08 23:29:13 »

Hi,

I've created a page for my students to use this week:
https://sites.google.com/a/bxs.org.uk/mrkershaw/lmc

Let me know if you're unhappy about any of it or if I've mis-representated anything. If you're happy I'd like to email a link to the page to the OCR exam board to check they're happy with my students submitting their work on your emulator.

Thanks again,

John.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #35 - Posted 2012-09-09 00:42:53 »

I'd say for the sake of clarity, your examples of 'my syntax' would be a little clearer if you didn't write uninitialized variables as label definitions only, but adding a 0 after it:

1  
2  
3  
4  
5  
var1 DAT   // wikipedia syntax
var1 DAT 0 // wikipedia syntax (explicit)

var1:   // my syntax #1 (might raise a few eyebrows)
var1: 0 // my syntax #2 (which I think is clearer)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #36 - Posted 2012-09-09 00:45:31 »

If you're happy I'd like to email a link to the page to the OCR exam board to check they're happy with my students submitting their work on your emulator.
Sounds great. If there are any showstoppers, notify me, and I'll see what I can do.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #37 - Posted 2012-09-09 00:53:15 »

Goddamn, I'm now addicted to this thing again. There goes the next few hours......

Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #38 - Posted 2012-09-09 00:55:53 »

Share the code you came up with. The nastier the tricks the better. Self modifying code is mandatory.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline johnkershaw

Senior Newbie





« Reply #39 - Posted 2012-09-09 01:09:49 »

I agree, but I was trying to make as few changes to the original code as possible. Possibly it's making the point that all memory 'starts off' with a default value of zero and therefore doesn't need initialising explicitly, though that approach doesn't hold water after the first run after the machine boots up (or even partway through the first run!).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #40 - Posted 2012-09-09 01:28:08 »

Squaring input:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
INP
STA :input
STA :count
sqr: LDA :accum
ADD :input
STA :accum
LDA :count
SUB :one
STA :count
BRZ :end
BRA :sqr
input:
accum:
count:
one: 1
end: LDA :accum
OUT
HLT


@Riven, you should put an option to choose what kind of syntax highlighting in the 'code' tag and then add LMC syntax highlighting option! Smiley

Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #41 - Posted 2012-09-09 01:32:34 »

No.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #42 - Posted 2012-09-09 01:33:42 »


Offline johnkershaw

Senior Newbie





« Reply #43 - Posted 2012-10-23 22:14:43 »

Riven,

Working with the simulator the other day I noticed a small error. Under 'Print Instructionset' you have STA and LDA reversed, ie they are correctly compiled to 3xx (STA) and 5xx (LDA), but listed the wrong way round in the print string.

Could you fix it and upload a new .jar file?

John.
Offline johnkershaw

Senior Newbie





« Reply #44 - Posted 2012-10-23 22:31:19 »

Also there's no Program Counter field. This is necessary to help kids see how the computer can perform a branch instruction by copying whatever is at location xx into the Program Counter.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #45 - Posted 2012-10-23 23:11:41 »

Also there's no Program Counter field.
The Program Counter is the memory cell with the red border.

This is necessary to help kids see how the computer can perform a branch instruction by copying whatever is at location xx into the Program Counter.


look at this code:
1  
2  
3  
4  
5  
6  
LDA :var // load 55 into register
OUT // show 55 to the user
BRP :end // branch if positive (we'll branch in this case)
OUT // show 55 to the user (never happens)
end: HLT // quit program
var: 55
and compile it

hit [step]:
  • memory cell 00 is the current program counter (red), memory cell 05 is refered to as a source (green), register now holds 55

hit [step]:
  • user is prompted with '55'

hit [step]:
  • BRP is executed... memory cell 03 is the current program counter (red), the potential jump to memory cell 04 is refered to (green), register holds 55, so branching occurs
  • what else is there to display to the students - there is nothing more to show persecutioncomplex

hit [step]:
  • program halted due to earlier conditional jump (never reaches 2nd OUT)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline johnkershaw

Senior Newbie





« Reply #46 - Posted 2012-10-24 00:21:03 »

What I'm trying to convey to the kids is that there's a no-thinking link between the branch statement and where execution then moves to.

For example, tomorrow afternoon I'm going to have them 'run' a paper-based LMC. I'll draw 100 boxes on the board (maybe less!) and write some compiled instructions in there. They get the hang of looking fetching whichever instruction is 'pointed to' by the Program Counter, looking it up in the 'Decode' list of mnemonics/instructions, then performing the required task (looking in the 'IN' mailbox and writing it's contents into the accumulator, putting stuff from the accumulator into the 'OUT' mailbox, etc...) and after each instruction executes they add one to the number in the program counter box (also on the board), having started it at zero.

Then we come to branching. They hit a statement that says '804' (ignoring labels for now). Looking in the 'decode' table they find 8xx, where '8' means copy the '04' into the program counter, then carry on with the next fetch/execute cycle as normal, only now execution has 'jumped' to memory location 04. The computer doesn't need to think, or even know/care that's there's been a 'jump', only the programmer knows. I'm trying to convey the utter dumbness of the computer, that any cleverness ONLY comes from the programmer. For me, that's what LMC is all about, pulling back the curtain on the 'magic box' and discovering it's just a clockwork machine that moves numbers around according to a small set of instructions which it follows slavishly.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #47 - Posted 2012-10-24 00:35:27 »

Think of the red cell as the current PC and the green cell as the potential next PC, if not current+1. Adding a textfield solely to hold the last two digits of the current cell and also the address of the green cell is a bit redundant: three visualisations of one number! Last but not least, there is not really any room in the UI for another textfield.

I think the concept of the PC and how branching works is so trivial, that you can get that well in their heads during the board-demo, after which the LMC app will show them the same information in two (more) ways.

This applet is a simulator, not quite a way to teach new concepts. It's more a tool to apply what you learned, in the easiest way possible.



By the way; I think it's best if you'd start off with a 10x1 or 1x10 'grid' on the board, as memory is conceptually one dimensional, so it's no use to visualize it in two dimensions during the introduction, especially as you want to emphasize the simplicity of the computer: doing a 2D lookup is not trivial in hardware.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline johnkershaw

Senior Newbie





« Reply #48 - Posted 2012-10-24 10:11:31 »

Using just 00-09 for starters is a great idea, and is just enough for a few short examples (IN/OUT, add, double, etc).
Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (5 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!