Saturday, 16 January 2016

Expressions in MINOL

So, having been tinkering for a bit, I’ve written the functions to calculate expressions for MINOL. 

This is considerably simpler than BASIC , because there is no order of precedence, and only five possible terms:
  • integer constant
  • variable A-Z
  • a random number - ! (e.g. !*2)
  • quoted character value (‘a’) 
  • memory access (4,1) (which reads $0401). 

Plus, they are all one byte which means I can return them easily in E rather than use the stack.


The code is actually just the expression and the test code, which is python generated expressions which are then run and compared with the calculated answer – this kind of thing for example 

(4,(2,(((7,'O'),Z),70)))-6-90+D-4/50+D 

which is, incidentally, 23 (on the current version of the monitor, which is used for memory reads).

Obviously I don't use random numbers in a unit test but this is the Galoisian LFSR again, which is quite a decent random number generator.

No comments:

Post a Comment