flat assembler
Message board for the users of flat assembler.

Index > Heap > Fun Code...(valid FASM syntax)

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
Code:
\.O._   db 90h
  !     db 90h
  M     db 90h    

_________________
¯\(°_o)/¯ unlicense.org
Post 21 Aug 2008, 07:05
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
...slip on banana peel:
Code:
\O_     db 90h
 !_     db 90h
  \^    db 90h    

_________________
¯\(°_o)/¯ unlicense.org
Post 21 Aug 2008, 21:55
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
I find the last line surprising!
Code:
  \^    db 90h    
Wouldn't have expected that to assemble, but it does.
Post 21 Aug 2008, 22:22
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
bitRAKE: you're mad - and I love it Very Happy
Post 22 Aug 2008, 04:02
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
I've been working on configuring this editor (awesome tool, btw) for use with FASM. Several hours work, but it now generates a tree view for rapid navigation of generic sources (no PROC/ENDP stuff). Still have control structures and the preprocessor stuff to work on. I imagine they'll be easier because block endings are well defined.

Really makes reading sources easier, imho.

_________________
¯\(°_o)/¯ unlicense.org
Post 22 Aug 2008, 07:55
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
And you were ASCII-arting with this editor because...?
Post 22 Aug 2008, 08:11
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
Madis731 wrote:
And you were ASCII-arting with this editor because...?
...I needed a break from the learning curve and thought I'd play with label names for testing my regular expressions. Not to mention it is just a little funny.

Maybe I missed something?
Code:
# backslashes can lead other characters
# dollar sign or number cannot be first character
# symbol characters divide names
\\*
[^/,:=<>`~&\+\-\*\(\)\[\]\{\}\|\#\\\s\$\d]
[^/,:=<>`~&\+\-\*\(\)\[\]\{\}\|\#\\\s]*    
...seems to cover all labels.

_________________
¯\(°_o)/¯ unlicense.org
Post 22 Aug 2008, 14:34
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
Nah, I screwed up - it doesn't cover \$... or \8... type labels. Confused

_________________
¯\(°_o)/¯ unlicense.org
Post 23 Aug 2008, 02:25
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
Code:
\\+
[^/,:=<>`~&\+\-\*\(\)\[\]\{\}\|\#\\\s]+
|
[^/,:=<>`~&\+\-\*\(\)\[\]\{\}\|\#\\\s\$\d]
[^/,:=<>`~&\+\-\*\(\)\[\]\{\}\|\#\\\s]*    
...there must be a more compact way?

(it is important to note backslashes cannot be a label by itself:
\\\\\: ; invalid label)

_________________
¯\(°_o)/¯ unlicense.org
Post 23 Aug 2008, 06:06
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
The cool thing about this editor is the nested lexers: define a language with FASM macros then define the lexer and nest FASM lexer. It's truely a match for FASM's expressive power, imho.

_________________
¯\(°_o)/¯ unlicense.org
Post 23 Aug 2008, 06:11
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Oh, that sounds pretty cool - don't think I've seen (lightweight) editors supporting nested lexers. But there must be at least a few out there - I imagine it's a must if you work with things like html with embedded scripting.
Post 23 Aug 2008, 07:08
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
f0dder wrote:
...editors supporting nested lexers
In the improbable event that someone else on the forum is unfamiliar with the word, "lexer", here is what I have learned today:
A lexer (as opposed to the more familiar (at least to me who imbibes same daily!) ELIXIR) is a program, or component of a program, to perform lexical analysis, i.e. the first stage in processing a language. The lexer assigns each "token" (aka lexeme) to a category, for example, identifier, or literal, or punctuation, and so on. Upon completion, the lexer passes all of this data, or at least, the starting address of all this data, to the parser, which, dumb as I am, I thought performed this assignment into category. Hurrah, I think I understand what a Lexer is, but alas, now I am again lost, trying to explain what function awaits the parser. In brief, there appear to be two tasks here, lexing and parsing, but my brain, reduced to only half the size of normal, and bolstered only slightly by daily elixir therapy, can comprehend only one travail. What does the parser do, after the lexer has assigned all characters their roles?
Confused
Post 23 Aug 2008, 13:27
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
tom tobias wrote:
What does the parser do, after the lexer has assigned all characters their roles? Confused
Parser performs syntactic analysis of the given data.

Lexer checks if the given tokens are "words" of the chosen (formal) language, parser checks if these words form properly build "sentences" of this language.
Post 23 Aug 2008, 15:13
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
f0dder wrote:
Oh, that sounds pretty cool - don't think I've seen (lightweight) editors supporting nested lexers. But there must be at least a few out there - I imagine it's a must if you work with things like html with embedded scripting.
Yeah, that is fairly common these days. The difference is the degree of customization. Most editors have parts of the lexer internalized - exposing only the bare essentials for colorization. Because this editor is actually a demo of his lexer the whole thing is exposed.

tom, the parser takes action based on the type information. Although it can get rather blurred unless an explicit division between parts is made. For example, the parser could change the type returned by the lexer, or the order of the tokens.

_________________
¯\(°_o)/¯ unlicense.org
Post 23 Aug 2008, 15:17
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Yeah, good ol' times, when I was still in school, all I heard was lexers (especially in one class) and we had to play around that word for at least a year or so. At that time I learned to grasp a bit of flex

I guess when bitRake finishes testing his new toy, he will tell us all about it and know-how when someone else wants to try it Smile Thank you in advance!
Post 23 Aug 2008, 23:10
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro
bitRAKE could you post your lexer for fasm? I have played a bit with that editor also and would like to see what you have done, maybe i could learn something. Below is my lexer and screenshot of Kuemmels Mandelbrot Benchmark source analyzed.
http://sites.google.com/site/aaro314/econtrol/fasm.lcf
Image
Post 03 Jul 2009, 14:13
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
I'm very sorry, but I lost all my work with this program. Grabbed the wrong USB stick. I'll take a look at your work...
Post 03 Jul 2009, 14:41
View user's profile Send private message Visit poster's website Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro
Ok, hope it's useful for someone. This was my first time playing with lexers and regular expressions. Didn't play with nested lexers and grammar rules maybe some tasks would be easier with them..
Post 03 Jul 2009, 15:55
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
A line like "extrn '__imp_SetCursor' as SetCursor:QWORD" will get picked up incorrectly as a label "SetCursor". At first I thought this was by design then a STRUC showed up as a child of SetCursor. Very Happy
Code:
struc RECT {
       .:
      .left   rd 1
        .top    rd 1
        .right  rd 1
        .bottom rd 1
        .. = $ - .
}    
...is handled incorrect due to ".:".

Also, labels inside a virtual which have a colon appear - yet, others do not.

You've done a wonderful job. My approach was just at the assembler level figuring to later add the preprocessor and nest the assembler; but I didn't get that far.

Edit: I've been going through just the include files for the latest FASM version and making note of needed changes. For example, "@" is definitely needed in Identifier.

Your approach seems to be top-down. Which will provide a good initial experience, but fail to adapt to alternate uses of valid syntax. A bottom-up approach would mirror what FASM itself does.
Post 04 Jul 2009, 02:06
View user's profile Send private message Visit poster's website Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro
bitRAKE wrote:
A line like "extrn '__imp_SetCursor' as SetCursor:QWORD" will get picked up incorrectly as a label "SetCursor". At first I thought this was by design then a STRUC showed up as a child of SetCursor. Very Happy
Code:
struc RECT {
   .:
      .left   rd 1
        .top    rd 1
        .right  rd 1
        .bottom rd 1
        .. = $ - .
}    
...is handled incorrect due to ".:".

Also, labels inside a virtual which have a colon appear - yet, others do not.

I saw similar errors when opened some OS source where segments and selectors were handled as labels. I'm thinking of doing more work in lexer so i could use regex to identify labels etc. this would also simplify some of the parser statements.
Quote:

Edit: I've been going through just the include files for the latest FASM version and making note of needed changes. For example, "@" is definitely needed in Identifier.

Thanks for pointing that out, if you got more please tell.
Quote:

Your approach seems to be top-down. Which will provide a good initial experience, but fail to adapt to alternate uses of valid syntax. A bottom-up approach would mirror what FASM itself does.

Found wikipedia articles about top-down and bottom-up parsing. Didn't have time to read them yet so don't know what you mean but i'll take a look soon. After that i'm trying to improve the whole thing.
Post 24 Jul 2009, 10:29
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.