flat assembler
Message board for the users of flat assembler.
Index
> Projects and Ideas > Befunge Interpreter Goto page 1, 2 Next |
Author |
|
Pinecone_ 26 Aug 2009, 13:34
Lately I've been interested in befunge, and made a simple interpreter for in in FASM.
This was originally just a side-note from a topic i posted in the Heap section - Esoteric Programming Challenges! and a new topic here was created mainly because MHajduk suggested i post it here, and the topic was being lead off-topic in talks about improvement for the interpreter, instead of the challenges. List of updates: Code: 10-10-09: Major update: Complete rewrite, is now 100% bug free as far as I know. The core is separated from OS-specific stuff. 08-09-09: Bug fix: The "." command now prints a space after the number it pops off the stack. Thanks to windwakr for finding out that the specifications say to do this. Bug fix: Revolution noticed the bounds checking of g and p instructions wasn't quite right and provided a fix. 07-09-09: Bug fix: The fungespace is now stored in 32 bit cells instead of 8 bit. This means values > 255 can now be stored on the fungespace. 06-09-09: Update : A small help message is now displayed if the executable is run with no paramaters. Bug fix: Division by zero now works as per the language specifications. Bug fix: Stack overflow now shows an error and quits the script instead of crashing. Bug fix: Greater than instruction didnt work correctly with negative values. Thanks to windwakr for helping find this. Bug fix: modulus and division of negative numbers. Found and fixed by windwakr. 31-08-09: Bug fix: ? instruction wasn't really random and didn't go up at all. 26-08-09: Initial release. Known bugs: No known bugs currently! Please test and find some for me to fix! Planned updates (No idea when I will do these, others are welcome to do so and provide the code):
Comments, constructive criticism and discussion about the befunge language and this interpreter are all welcome.
Last edited by Pinecone_ on 09 Oct 2009, 15:45; edited 60 times in total |
|||||||||||
26 Aug 2009, 13:34 |
|
Pinecone_ 26 Aug 2009, 13:50
(No more discussions about this interpreter should be continued in the Befunge Programming Challenge thread now. Please use this thread instead.)
From the previous thread: MHajduk wrote:
Yes, but then nothing could be compiled without the whole package. With the /c compile option, all that would be needed is the interpreter itself, which would be better for people who are interested in befunge, but not FASM. |
|||
26 Aug 2009, 13:50 |
|
Pinecone_ 01 Sep 2009, 13:38
That would work, but the process could not be automated entirely by doing that.
|
|||
01 Sep 2009, 13:38 |
|
windwakr 05 Sep 2009, 16:58
All you have to do for the negative divide(AND modulus!) is change 3 instructions.
In "InstructionHandlers.asm" in the "Proc Instruction_Division" Change: Code:
xor edx,edx
div ecx Code: cdq idiv ecx In "Proc Instruction_Modulus" all you need to do is change "xor edx,edx" to "cdq" Pinecone_ wrote:
It seems to work right if you change "Mov [ScriptLines], ecx" to "Mov [ScriptLines], 25" in "Proc ParseFile uses Esi Edi", But it probably breaks something somewhere. Also, where is "ScriptSize" used? I don't see it referenced anywhere, yet you set it up. |
|||
05 Sep 2009, 16:58 |
|
Pinecone_ 05 Sep 2009, 18:18
Thanks a heap windwakr. It's now updated.
Yay I learned a new instruction cdq. |
|||
05 Sep 2009, 18:18 |
|
Pinecone_ 06 Sep 2009, 01:42
Fixed a bug where negative values did not work right with the greater than command (`).
Previously the following happened: Code: <v5p009 <v" is greater than 2"0 >1-::.2`|>:#,_$00g1-:00p!#@_91+, <^" is lower than or equal to 2"0 Code: 4 is greater than 2 3 is greater than 2 2 is lower than or equal to 2 1 is lower than or equal to 2 0 is lower than or equal to 2 -1 is greater than 2 -2 is greater than 2 -3 is greater than 2 -4 is greater than 2 First post has been updated with new version, which has been fixed. Thanks to windwakr for making me check this. If you have the source and can't be bothered re-downloading, in InstructionHandlers.asm, look for "Proc Instruction_GreaterThan" and change Code: Jbe @F Code: Jle @F |
|||
06 Sep 2009, 01:42 |
|
Pinecone_ 06 Sep 2009, 07:45
I've done a few more updates:
All avaliable for download in the first post. |
|||
06 Sep 2009, 07:45 |
|
Pinecone_ 07 Sep 2009, 07:14
Another update.
Previously the entire fungespace was stored as 8 bit cells. It didn't occur to me until today that the p and g instructions should be able to store/get much greater values from the fungespace because the stack is 32 bit. The fungespace is now stored in 32 bit cells, so that wont be a problem anymore (even though we never noticed it before). Chess still doesn't work... |
|||
07 Sep 2009, 07:14 |
|
Pinecone_ 07 Sep 2009, 16:56
Yet another update!! Sorry everyone.
revolution wrote: I assume you want to use jle and jge for proper bounds checking? Thanks revolution. Updated now and available for download in the first post.. |
|||
07 Sep 2009, 16:56 |
|
windwakr 07 Sep 2009, 18:14
Are you sure you uploaded the right version? If you did indeed fix it at 2:56A.M. Sept. 8(in your time) like you say, then why does the edit date on the files read Sept. 7 and Sept. 6? And I can't find the fix that revolution suggested in the files.
|
|||
07 Sep 2009, 18:14 |
|
Pinecone_ 07 Sep 2009, 21:37
Thank you windwakr. The right one has been uploaded this now. (I don't know how that happened.....)
|
|||
07 Sep 2009, 21:37 |
|
windwakr 07 Sep 2009, 23:22
There's an error in your interpreter....
Befunge Documentation wrote:
Original post below, ignore it. I didn't do any research before posting it, but it did lead me to discover this bug: The chess code obviously relies on some sort of exploit in the official interpreter. The second line prints "8 |R|....." in the official one(Note the space.), but in yours it prints "8|R|". If you trace through it yourself you see no reason why there is a space printed in the official one after the number. Look at the part of code responsible for the "8 |". It enters from the top right going left. v9. >"|", It shows the number, and puts 9 and "|" on the stack, then prints the "|". NO SPACE IN THERE! So why does the official one insert a space? Befunge-93 Interpreter/Debugger v2.21 +-+-+-+-+-+-+-+-+ 8 |R|N|B|Q|K|B|N|R| 7 |P|P|P|P|P|P|P|P| 6 |.|.|.|.|.|.|.|.| 5 |.|.|.|.|.|.|.|.| 4 |.|.|.|.|.|.|.|.| 3 |.|.|.|.|.|.|.|.| 2 |p|p|p|p|p|p|p|p| 1 |r|n|b|q|k|b|n|r| +-+-+-+-+-+-+-+-+ A B C D E F G H Who knows what other bugs the chess game uses. When I make a mistake, I don't kohlrak my posts....nope. I just make it small and acknowledge that I was wrong. |
|||
07 Sep 2009, 23:22 |
|
Pinecone_ 08 Sep 2009, 10:08
Thanks windwakr. Updated version in first post now prints a space after "." command.
|
|||
08 Sep 2009, 10:08 |
|
revolution 08 Sep 2009, 10:26
Pinecone_ wrote: Thanks windwakr. Updated version in first post now prints a space after "." command. windwakr wrote: When I make a mistake, I don't kohlrak my posts....nope. I just make it small and acknowledge that I was wrong. |
|||
08 Sep 2009, 10:26 |
|
Pinecone_ 10 Sep 2009, 02:09
windwakr wrote: When I make a mistake, I don't kohlrak my posts....nope. I just make it small and acknowledge that I was wrong. |
|||
10 Sep 2009, 02:09 |
|
windwakr 10 Sep 2009, 02:11
kohlrak is a member here who got mad and deleted all his posts. So when I say I didn't "kohlrak" my post, I'm using his name as a verb meaning deleting the post.
He seems to have grown up(A LITTLE) and has started posting again. I could have also use "mikegonta" or "asmcoder" in place of kohlrak. Mikegonta and asmcoder both also deleted their posts. |
|||
10 Sep 2009, 02:11 |
|
Pinecone_ 10 Sep 2009, 15:14
I noticed asmcoder did that. It seems so stupid and makes it really annoying when one of his posts turn up in a search and people haven't quoted what he said that they're referring to, so you have no idea what they're talking about...
What could possibly have happened to make them take so much time to delete everything? |
|||
10 Sep 2009, 15:14 |
|
windwakr 10 Sep 2009, 15:17
Well, asmcoder was just an asshole, and I didn't help the situation much. Mikegonta, who knows why he did it. And I think kohlrak did it because he got pissed off.
|
|||
10 Sep 2009, 15:17 |
|
rugxulo 10 Sep 2009, 23:37
To be fair, I'll blindly guess that kohlrak and asmcoder are just young and immature (no offense intended by that) and can't handle criticism very well. We all remember how awkward it is to be that young. Sure, maybe? it could've been handled better, but that's life, mistakes are made, and nobody's (!) perfect.
Some people just easily annoy other people, and I'm one of 'em. Fortunately, it's only (mostly?) offline people (e.g. my bro), heh. |
|||
10 Sep 2009, 23:37 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.