SBTCVM / SBTCVM-Mark-2

[no longer supported, please see SBTCVM-Gen2-9] Simple Balanced Ternary Computer Virtual Machine: Mark 2 is a simple Balanced Ternary VM programmed in python and Pygame.
https://sbtcvm.blogspot.com/
GNU General Public License v3.0
14 stars 5 forks source link

My program crashed the VM #8

Closed eekee closed 6 years ago

eekee commented 6 years ago

I broke it with my first program!

Hahahaha oh dear! Github "doesn't support" attaching .tasm or .trom... or seemingly any source code. What is this I don't even! Aaaanyway, pasting the tasm since it's so short:

setreg1|--------+|overloop
# label could go on next statement, but if it loops wrong i want to see it.

setreg2|+--------
dumpreg1|0|leftloop
multiply|3
wait|-
gotodataif|>nextloop
gotodata|>leftloop

setreg2|--------+|nextloop
dumpreg1|0|rightloop
divide|3
wait|-
gotodataif|>overloop
gotodata|>rightloop

It assembled with no errors, reporting 4 gotorefs, 13 instructions, and extra space: 19670.

On running it, the VM window opens, then soon closes. Here is the console output: image

Since I laughed at Github earlier, I'll say I'm happy to see I can attach a screenshot with print screen and ctrl-V.

They say you don't really find the bugs in your code until someone else uses it. :)

ThomasTheSpaceFox commented 6 years ago

ah. yea the assembler doesn't exactly tell you when the syntax is wrong. (known bug) you may want to take a look at the assembly section of the users manual. the basic arithmetic operations are add, sub, mul, and div. and they work on the values in Registers 1 and 2. and populate register 1 with the result. second, the wait instruction supports a decimal syntax. like so: wait|:6.2 The actual operation takes a ternary-encoded fixed point number with a range from 0 to 19.683

The assembler is a bit, well dumb. most instructions will treat whats between the first and second separators as 9-trit wide ternary data... what happens is the trom winds up having lines that are too short and contain invalid characters that the VM simply doesn't know what to do with.

ThomasTheSpaceFox commented 6 years ago

if what is in the users manual doesn't work or doesn't help, check some of the dozen-or-so test roms and accompanying source code. a good algorithm example would be fib.tasm (in VMSYSTEM/ROMS)

eekee commented 6 years ago

Ah I see! Thank you.

Not promising anything, but I'll see what I can do to improve SBTCVM-asm.txt.

eekee commented 6 years ago

All sorted, thanks!

I'm adding little extra bits of info to SBTCVM-asm.txt, as I said. I'll see about getting familiar with git so you can pull it when you want.