Hacker News new | ask | show | jobs
by RichWalton 4012 days ago
This is a nice implementation.

I made something similar [1], based on the Post Room Computer [2].

Basically it is a two address (operand) modification of the LMC. It was used to as a teaching tool for undergrad students at my local university.

It's a bit more fully featured - It supports absolute and register based address modes, macros, programs spanning multiple files. The computer is accessible via command line or using the in-built Java Swing UI.

If anyone is bored and wanted to run it, heres a sample program:

  ;; A simple multiplication program

  INP :x:		; Input value and store at location :x:
  INP :y:		; Input value and store at location :y:
  MOV :result: :x:	; Copy the value at :x: into :result:

  ; Multiplication loop
  :loop:		
	  SUB :y: :one:	; Substract 1 from the the value at :y:
	  JMP EQZ :end:	; If result of subtraction was 0, stop looping
	  ADD :result: :x:	; Add the value at :x: to the result
	
  ; If the program reaches this stage multiplication is not complete
  ; So jump back to start of loop
  JMP LWY :loop:

  :end:		; Label to exit the loop
  OUT :result:	; Output the result
  HLT		; Stop execution

  ; Data Stores
  :x: (0)
  :y: (0)
  :result: (0)
  :one: (1)
[1] https://github.com/Richard-Walton/The-Post-Room-Computer

[2] http://eprints.hud.ac.uk/2518/

1 comments

> Post Room Computer

Given that your link spells this "Postroom Computer" and is British, I'm guessing it has to do with mail (as in, the post; as in, what there is none of on Sundays) as opposed to any of the work of Emil Post, who formalized computation similarly to, independently of, but less famously than, Turing.

https://en.wikipedia.org/wiki/Emil_Leon_Post

Yes, correct :).

In the "Post Room Computer" analogy, the little man works in a post (mail) room.

The mailboxes are memory, in/out trays are IO, etc etc.