Serving the Quantitative Finance Community

  • 1
  • 4
  • 5
  • 6
  • 7
  • 8
  • 10
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Programming Education

May 14th, 2014, 9:06 am

Maybe a source of requirements? Visual Studio debugger
 
User avatar
rmax
Topic Author
Posts: 374
Joined: December 8th, 2005, 9:31 am

Programming Education

May 15th, 2014, 6:36 am

QuoteOriginally posted by: CuchulainnMaybe a source of requirements? Visual Studio debuggerIndeed. It has some good features. Ideally it would be best if what ever your compiled always allowed you to enter debug mode. Although perhaps wth Open software just the ability to set breakpoints/watches, step and see the disassembly would be enough.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Programming Education

May 21st, 2014, 1:05 pm

Will there be support for different number systems, arithmetic and conversions etc.? Can I write e.g. a loop in octal?
Last edited by Cuchulainn on May 20th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
rmax
Topic Author
Posts: 374
Joined: December 8th, 2005, 9:31 am

Programming Education

May 21st, 2014, 1:36 pm

QuoteOriginally posted by: CuchulainnWill there be support for different number systems, arithmetic and conversions etc.? Can I write e.g. a loop in octal?If there is a good reason that I will include! As the memory and instructions are contained in 32 bit words, octal might be painful.At the moment the rewrite of the VM is taking longer as it is (hopefully) better structured that v0.01. I have finished most of the opcode programming for Register and Immediate addressing. I am still debating about how the Load, Save and Transfer Opcodes will work in reality (just a single MOV, or separate statements). I have been going around this circle for some weeks now and still have not settled on a final design. I had played around with the idea of using a single instruction for everything (OISC) but that I don't think would be good pedagogical example.The next two tasks (once the CPU is completed) is build the ROM layer and the Perphial Bus. The ROM is relatively easy, however the Perpherial bus is much more complex as I don't want to limit what can be plugged in. The I/O is still an issue to be solved as well. No neat way to do this at the moment so need to explore different options. Likewise I have not settled on how the debug will provide anything more than just a simple disassembler. Clearly for it to be useful I want more than that.And when all of that is done it will be time to write the assembler and then build a simple programme. The OS I will leave until another time for the moment, but would probably need a compiler for a 3rd gen language to do that. Writing a C compliler to compile would be interesting, but bastard hard (like all of the above problems I am trying to solve).It is going to be a hobby project at the end of the day, but hopefully with enough documentation people can take it and play with it in a safe environment. (I did go down a kind of Harvard Architecture with a switch that changes it between von Neumann and Harvard).Oh, and I need to complete the Interrupts, finish buliding the VM cradle and...and ...and....
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Programming Education

May 22nd, 2014, 12:48 am

Nice work, rmax! Have you ever looked at old programmable calculators (e.g. HP-65, HP-25, etc.)? They use a stack and register load/store system with op-codes linked to keyboard coordinates that's simple but pretty complete for doing algorithms.What would a prime number generator look like in your language?
 
User avatar
rmax
Topic Author
Posts: 374
Joined: December 8th, 2005, 9:31 am

Programming Education

May 22nd, 2014, 7:06 am

QuoteOriginally posted by: Traden4AlphaNice work, rmax! Have you ever looked at old programmable calculators (e.g. HP-65, HP-25, etc.)? They use a stack and register load/store system with op-codes linked to keyboard coordinates that's simple but pretty complete for doing algorithms.What would a prime number generator look like in your language?Thanks for the support! It is as I said above bastard hard, but then again if it was easy I wouldn't have bothered, or learnt as much.I went against the stack register implementation as I want the VM to represent hardware architectures that exist today - notably ARM and x86 (and there are others of course). I am also firmly of the belief that we should run all machines virtually (either locally or hosted in a cloud) as the abstraction given has many many more benefits (although of course slower). The opcodes are complex as I wanted to aim for as many instructions as possible to be executed in a single instruction. Hence apart from absolute Jumps, and Load all opcodes are single instructions.A prime number generator is actually a pretty good test. At the moment it would have to consist of assembler as there is no language at present but it should be possible - however much easier if I implement something called Offset Addressing (although thinking out-loud actually it might not be necessary due to how the addressing modes use in general registers rather than immediate modes).I will publish something here once there is something to view that of "reasonable" quality.
 
User avatar
rmax
Topic Author
Posts: 374
Joined: December 8th, 2005, 9:31 am

Programming Education

May 22nd, 2014, 7:11 am

A set of high-level objectives:The Virtual Machine is designed primarily as an educational tool for use by anyone who is interested in building software and wants to understand how computers operate. The key principle is that The Virtual Machine is open and users can follow execution from a high-level piece of software, through the various system calls to the fundamental instructions that are operated by a virtual Central Processing Unit (CPU).To this end a number of key design principle have been enacted to support this overarching goal. These are listed below:a. Users of Virtual Machine must be able to drill through the numerous layers of software until they reach the virtual hardware where the user can see how the CPU operates and interacts with memory and other devicesb. The implementation of the Virtual Machine is independent of the specification. Components of the Virtual Machine can be added, or if someone wishes they can remove elements of the implementation and replace it, as long as it complies with this specification and the source code is available to all under GPL if republished c. It should be possible to extend the Virtual Machine to work with multiple processors and CPUs if that is the direction the project takesd. The design must be simple enough that students can understand what is happening at a fundamental level. In other words the design must be elegant and by elegant the design must allow for users to understande. The design must mimic real world processors and silicon. The Virtual Machine specification does not specify interactions at a silicon level, however it must be of similar type to common processors that already existf. The Virtual Machine implementation must be safe in design. I.e. users can restore from a prior point etc.g. The Virtual Machine must be Turing Complete and be able to emulate any other machine (without a criteria of speed)h. Speed of the Virtual Machine will be sacrificed for understandingi. Tools must exist for the Virtual Machine before being published widely in the public domain (at the very least an assembler)j. The Virtual Machine will support disassembly and tracing from ground up. I.e. it should be possible to view both the machine code, the assembler and the source code to understand how a program has been compiled and ideally step through each line of code
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Programming Education

May 22nd, 2014, 12:23 pm

Interesting and impressive! So you seem to be designing for teaching low-level computation as implemented in current processors instead of teaching the concepts of algorithms as an abstract machine.I assume you have or plan to have some kind of visual representation of the program, program counter, register values, and animated state transitions (e.g., showing registers A and B feeding the ALU and the result going to register C)?
 
User avatar
rmax
Topic Author
Posts: 374
Joined: December 8th, 2005, 9:31 am

Programming Education

May 22nd, 2014, 1:22 pm

QuoteOriginally posted by: Traden4AlphaInteresting and impressive! It might be if I can get to finish it ! (I have my little Fun with Mr Bensford project also on the boil).QuoteSo you seem to be designing for teaching low-level computation as implemented in current processors instead of teaching the concepts of algorithms as an abstract machine.Yes. Really because sometimes abstraction can be helpful, however sometimes it can be so abstract that it does not help. Again this is the reason I went against OISC, and stack based machines etc. The temptation is go down an abstract route, but I am not sure it teaches as much as something that is more realistic.QuoteI assume you have or plan to have some kind of visual representation of the program, program counter, register values, and animated state transitions (e.g., showing registers A and B feeding the ALU and the result going to register C)?This is the tricky bit. I have gone against going down to the ALU level. It was very very tempting, but feel I have bitten off more than I can chew already. I have stubbed out interfaces for attaching monitors. I.e. it should be possible to access the VM and see each register, the contents of memory locations etc. This is the plan at least....
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Programming Education

May 22nd, 2014, 4:49 pm

QuoteOriginally posted by: rmaxQuoteOriginally posted by: Traden4AlphaInteresting and impressive! It might be if I can get to finish it ! (I have my little Fun with Mr Bensford project also on the boil).If you analyze financial documents, I'd bet that 1's are even more prevalent in revenue and profit figures than expected as companies with 999 million in sales try to push to 1,000 million (second digit zeros would also be more common). In cost and loss data, the 9's would be slightly overrepresented.QuoteOriginally posted by: rmaxQuoteSo you seem to be designing for teaching low-level computation as implemented in current processors instead of teaching the concepts of algorithms as an abstract machine.Yes. Really because sometimes abstraction can be helpful, however sometimes it can be so abstract that it does not help. Again this is the reason I went against OISC, and stack based machines etc. The temptation is go down an abstract route, but I am not sure it teaches as much as something that is more realistic.Indeed. Yet perhaps we have two different definitions of abstraction. If the goal is to teach the minimum language features of computing (vs. the basics of processor design) then it becomes an issue of representing a series of steps of an algorithm including some simple categories of control statement (IF/THEN, loop). Things such as binary, octal, registers, and op codes are irrelevant implementation details. An abstraction of a computer might be some analogical physical system such as a train track in which each type of track segment "does something" to the cars of the train.QuoteOriginally posted by: rmaxQuoteI assume you have or plan to have some kind of visual representation of the program, program counter, register values, and animated state transitions (e.g., showing registers A and B feeding the ALU and the result going to register C)?This is the tricky bit. I have gone against going down to the ALU level. It was very very tempting, but feel I have bitten off more than I can chew already. I have stubbed out interfaces for attaching monitors. I.e. it should be possible to access the VM and see each register, the contents of memory locations etc. This is the plan at least....I would think that a visual representation of the processor would really help students/children see what was happening. For better or worse, very few young people have ever seen a command line and the trend toward touch screens is taking computing ever farther from CLI. I suppose it depends on the prerequisite skills of the students.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Programming Education

May 22nd, 2014, 8:06 pm

Excel Student $69.99 (the price of a few Kwoks).
Last edited by Cuchulainn on May 21st, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
rmax
Topic Author
Posts: 374
Joined: December 8th, 2005, 9:31 am

Programming Education

May 23rd, 2014, 7:02 am

I have been playing around with VMs for a while. I wrote some basic ones in Excel and VBA initially. It grow up out of writing a Turing Machine in VBA. This started years ago, but never really had a purpose. It was only recently that I felt that the purpose was educational (when I started this thread in fact).It is a long, long time since I coded in anger. So I picked C#: partly as I didn't know it as I could learn it and, partly because a friend of mine worked at Microsoft and told me how much better than Java is was I avoided Python (I cannot get on with it). My concern with C++ is that I think I would have spent a long time doing the plumbing where C# it comes out of the box for free. The other choice was C, but I am so used to OO now that I think I would find it tricky to think functionally again.Some people have done amazing things in Javascript (hence my post about Linux in a browser the other day) and there is another guy that has written BBC Model B (6502) in javascript. The issue with Javascript is that there are no bit-level operations (I had the same problem in Excel and had to write a number of functions that executed Rotate Bits etc).However, the implementation langauge should be separate from the concept - I have specified interfaces however, the idea being that if you did want to rewrite the CPU to be faster then you could, and still plug it into the overall VM framework.