A simple esolang interpreter
-
Hmm, how do I do subtraction and comparisons with ">" or "<"?
-
@vinicity You subtract by adding 255 to the said number. Example: (I 5 : A 255) This makes Acc become 4. Since Acc when it has reached the highest amount of bits within the range of 0x00 to 0xFF. resets itself to 0.
Comparisons are done using the C instruction. So the capital C compares an immediate value with Acc. There are no negative numbers in this VM. So if you are for example at 0 and want to loop until you reach 5. You'll need to store the amount of loops in RAM or in register X and then compare if that number has reached 0, since you will be subtracting RAM/ register X after each loop.
-
Thought I'd try writing a BrainF interpreter in my esolang. Wrote this on the windows version. It should work for the FUZE4 version as it's the same VM and same code.
;Register X => Stack Pointer
;RAM[253] => Program Counter
;RAM[252] => Scanner Pointer
;RAM[251] => Internal RAM for BrainF Interpreter
;Setup X register and RAM address 253,252,251 and 250
I49 U I50 S253 S252 I150 S251 I149 S250 C0 j210(20)
;if token is 60 = '<'
L251 C150 J197 A255 S251 C0 j197(40)
;if token is 62 = '>'
L251 C249 J197 A1 S251 C0 j197(60)
;if token is 44 = ','
I0 i L254 C0 J60 s251 C0 j197(80)
;if token is 46 = '.'
l251 P C0 J197 j197(90)
;if token is 43 = '+'
l251 A1 s251 C0 j197(100)
;if token is 45 = '-'
l251 C0 J197 A255 s251 C0 j197(120)
;if token is 91 = '['
L253 u G A255 U C0 j197(140)
;if token is 93 = ']'
G A1 U l251 C0 J197 g S253 C0 j120(180)
;Scan the tokens <>,.[]+- line 88
l253 C60 J20 C62 J40 C44 J60 C46 J80 C43 J90 C45 J100 C91 J120 C93 J140
L253 C150 J225 A1 S253 C0 j180(210)
;Get keyboard input and execute code when ENTER is pressed line 112
I0 i L254 C0 J210 P C10 J180 s252 L252 A1 S252 C0 j210(225) ;Reset Program Counter and erase old data from scanner
I50 S253 I0 s252 L252 A255 S252 C50 j225 I10 P J210 -
the most I could make was a simple calculator for addition o.o
-
@JMM161437 interesting. Would love to see your code for that! Also the BrainF interpreter code above is very buggy. This is mostly how it would be if you were to build a compiler/interpreter in Assembly. There's a lot more at play here than learning the language.
-
well I never saved it but once I reprogram it i'll definitely share and wow I'll still check it out buggy or not... also kinda confused a little... how do i get back to editing code?...i may have missed something XD but I love this little language, I have work very little with assembly(ARM/Raspberry pi) and the most I made was a square bounce aroung the screen lol
-
So the editing is done using the input() command in FUZE4. If the program doesn't go back to the input() command then most likely you've reached an infinite loop or the program has ended. Mostly you'll have to back out of the program and go back in if you're not seeing the input prompt.
-
oh... makes sense... I first instinct is to make a loop in my coding lol I'll try maybe finding a way to break the loop
-
Good idea. Though, I'm actually currently updating the language in C currently. I'm thinking of adding labels to the langage. I decided this due to the realization that it's hard to keep track of which line you're code is on when you want to jump to a specific instruction.
-
Ok managed to get somewhere. I'll be updating the FUZE4 version of this language by Sunday. The new language will have labels like this:
ex:
(5)
;Testing keyboard keys
I0 i L254 C0 J0 P C10 J20 j0(20) ;prints End
I69 P I78 P I68 PWhatever number you write in between the (). the code after that label will be written on that line number.
-
genus! that will make it a little more easy to use... so I did look at the code and I'm curious... Are you emulating a computer?... I plan to create a fuze program to simulate electronics where you can edit truce tables and create things based off of discrete logic... got the Idea when playing around with the ATMEGA328-PU micro controller(yes with the arduino bootloader... don't have a programmer fit for it)
-
@JMM161437 you have a good eye. Yes i am emulating a computer. Though this computer doesn't actually exist. So it's basically a fantasy console. That's all my studies have been focused on, emulation, compiler design, and reverse engineering software/hardware. Though I'm still a beginner in all three.
-
@LucasJG25 well fantasy or not it's amazing that you implemented such a thing. As for me I have never emulation anything of the sorts but I do understand how the hardward works... instruction register pulls instruction from memory... Instruction decoder coverts that to single the component the data tells it to and puts the result on the bus... I'm sure it's way more complex than that, but that's the fun thing about it is discovering more. not sure if you have seen it but ever heard of the visual 6502... it's a website that emulates the 6502 8-bit processor and has the circuitry with a hex editor and assember for it... if understanding how computing works is your thing you should google it!
-
@JMM161437 I actually code in 6502 Assembly. I use a VICE C64 emulator and a Turbo assembler which I use to code with. In fact my first assembler I made was the 6502. I call it a fan made assembler due to it not having all the instructions that the 6502 has.
As for hardware, everything I learned was from the Nand2Tetris course which you can google up. Plus it's free. If you're interested in building a computer from nothing but a Nand Gate.
-
@LucasJG25 That sounds like a fun thing for me to check out!... as for now all I have is a breadboard and a bunch of transistors... not enough to create a full on computer but I did make an sr latch and that was fun. blew my own mind once I got that working lol. as for vice c64 well... I never owned a real C64 so I never worked with the keyboard to know what was what and which graphic character belonged to which key to even work with the emulator properly... all my knowledge of the c64 came from the 8-bit guy
-
@JMM161437 Very nice! I'd love to actually build a computer with transisters and breadboards. But, as of right now I'm focused on virtual machines and emulation.
Also, if you'd like to know more abou the C64. There's a wiki page dedicated to that. You'll find everything there.
-
Ok so I've done some updates to the FUZE version of the language.
UPDATES:
I'm not a big fan of how you edit code in this interpreter. I prefer to see all my code. Thanks to Fuze allowing strings to be used on multiple lines you can now edit the esolang code within the text editor provided by Fuze itself.
Example:
code = "
(5) ;test
I69 P I78 P I68 P
"
This will write the esolang code within ROM(5)/line 5.Labels are now usable as shown above.
The ':' is no longer needed. You can if you want to but it doesn't change the syntax. So if using ':' helps to make the code more readable then go ahead and use it.
The esolang is now updated and is pending.
-
sweet! thats awesome! I'll definitely download this update!
-
@JMM161437 It will be a lot more easier to edit your code now. Enjoy! :D
-
:D... have no other reply ideas lol