![]() ![]() ![]() Instructions are the first base 10 digit and the second 2 base 10 digits for instructions that take an argument specify the RAM address of the argument. LMC code is numerical but unlike normal assembly, it's in base 10. ![]() It's a virtual machine for running LMC code, not just any assembly. That doesn't answer my question I guess chooper100's implementation doesn't compile the Assembly and run the machine code but rather interprets the Assembly (so I don't think that qualifies as a Virtual Machine). ![]() For those who don't know LMC (like me about 2 hours ago), it is basically a very simple machine language with its own assembly language. MartinBraendli created a great implementation of the Little Man Computer. Jonathan50 wrote:Wait so made a Virtual Machine in Scratch!? Or does it just interpret the Assembly? Can you actually run binary on it? But, it works in chooper100's interpreter so I'm going to assume it's valid -– If printing unnecessary output is allowed, here's a 17 16 line version that uses the same dirty hack Now the hacky case is where input is 1, because the interpreter has to go over a bunch of unknown commands. For all other valid input cases, the program loops as necessary until COUNTER is 0 and then uses COUNTER as a HLT. Then, it halts For the input case 1, the program goes over the entire thing and prints 1, then it goes over the DAT space for COUNTER which is 0 at this point, so it halts. Let me explain: For the input case 1, the program goes through the entire thing and prints 1, then goes over the DAT spaces which are all 1 until it reaches space 19 which is a 0 since the program doesn't use it. INP SUB ONE SUB ONE START STA COUNTER LDA CURRENT ADD OLD STA CURRENT SUB OLD STA OLD LDA COUNTER SUB ONE BRP START LDA CURRENT OUT COUNTER DAT OLD DAT 0 CURRENT DAT 1 ONE DAT 1 19 18 lines This uses a dirty hack that probably isn't portable (add a HLT after OUT to make it valid). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |