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. |