MightyPirates / TIS-3D

TIS-100 inspired low-tech computing in Minecraft.
https://www.curseforge.com/minecraft/mc-mods/tis-3d
Other
105 stars 35 forks source link

A lot (plot twist: small amount) of questions about 6507 Assembly and TIS-3D. #141

Closed fl215 closed 2 years ago

fl215 commented 2 years ago

Okay, now, I got a lot of questions but I will shorten them. Let's start with my most "question-ed" questions.

  1. How do I print numbers to the terminal without getting an empty space? All it currently prints is just blank, I defined a variable set to 15 and it will never print it, just a character from cp437 that isn't even supported on the terminal.
  2. How do I randomise a number without using random modules?
  3. How do I use the port module? And the last one, how do I use the queue module?

Someone please answer these questions.

fl215 commented 2 years ago

WTF! I found so much about execution modules in the reference manual, tho I still have 1 unanswered question: writing numbers without the cp437 characters appearing.

fnuecke commented 2 years ago

Glad the manual helped :)

Re 1.: what do you mean, exactly? Do you send the value 15 to the terminal and expect the text 15 to appear? You'll have to convert the digits to cp437 codes first. Otherwise, could you please try to reword the issue?

fl215 commented 2 years ago

I would like to write a number to the screen, but because you quite literally have to use numbers to type into the terminal, they just appear as cp437 characters, and those are lower than 31 which means they will not appear. I want to put in a number after you type in the beats (since I am making a music program) which will represent how many times they used it. That key value is also used to modify the pitch in the other terminal, (setting it to 0 will result in pitch 1, etc) and I want the users to see what pitch they currently have. I will, of course change the pitch value to it's own value, for now it's the key for debugging purposes wink wink.

fnuecke commented 2 years ago

Still not quite sure I follow, but it sounds like you want to display values as readable text on the terminal module? In that case, as mentioned, you'll have to convert them (kinda like how in Java you'd have to do String.valueOf). For example (note: untested, but should get the idea accross):

mov up acc # read value to convert, assuming it comes from the top
jez end: # ignore invalid input
mov 0 left # assuming there's a stack module on the left side

# convert digits to codepage 437 one by one
convert_loop:
sav
mod 10 # extract lowest base 10 digit
add 48 # digit to codepage 437
mov left # push to stack
swp
div 10 # move on to next digit
jnz convert_loop

# read back from stack, inverting order for printing
output_loop:
mov left acc
jez end # check for the 0 we pushed at the start, it marks the end
mov acc right
jmp convert_loop

end: