flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > fasm macro for html.

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
LOL Laughing.

i was playing with fasmw to write html code when i had an idea:

use fasm syntax, and macro system to write html code.

simple idea, really, simple... the original editor higlighting is very good for html reading

the main challenge is to be able to do recursive macro.

just don't be too much hurry to find the solution and it will be cool.

first, the <> chars are really cool in my opinion.
the absence of easy coding of html is a brake to the creativity.
the bloat is really huge in html.

then, solution is to do a macro to create html code... it will let you use any solution.

i think about a macro with large associed library, using directives in macro for the large bloat or the easy coding.

Code:
        format binary as 'html'
        org 0
crlf    equ 10,13
macro   header title,color
{
db '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',crlf
db '<HTML>',crlf
db '<HEAD>',crlf
db '  <TITLE>',title,'</TITLE>',crlf
db ' </HEAD>',crlf
db ' <BODY bgcolor="',color,'">',crlf
}
macro   headerend
{
db '</BODY></HTML>',0
}
macro   § text
{
db '<br>'
db text
}
    

and how it would be used
Code:
include 'html.inc'

        header ' - test - ','112233'
      § 'hello world'
      § 'how are you today?'
      § 'fine and you how are you?'
        headerend                         
    

compile it, and browse it.
it gives that

and why not... using fasm optimized for cgi scripting, is it fast enough?

i jut wonder how to do the implementation of a db text redefinition macro, with the crlf and formating of the editor, in order to don't have to enter chars like:
<br> <nbsp>
and all specail chars too.
i wonder if fasm macro can use text from the source and convert bytes from a string in a string of strings, generating the special chars and items directlly from text.

an idea can be to use bbcode to implement tags and advanced macro (quote, table, list, code, etc...)

i think fasm can be only made with the macro system.
if you delete all the mnemonic parts relative to X86 opcodes, etc, and using only the macro and directive system (db, align, include) to implement opcodes (mov, ret, etc...), it is possible to make an interresting fork of fasm.

Smile


Last edited by edfed on 26 Sep 2011, 22:00; edited 1 time in total
Post 28 Apr 2011, 11:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7737
Location: Kraków, Poland
Tomasz Grysztar
Back in 2001 there was an article about CGI programming with fasm published in the issue 9 of Assembly Programming Journal (look for the title "Common Gateway Interface using PE console apps"). So the idea is not new. Wink
Post 28 Apr 2011, 11:44
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
After some hacking I got it working, but the strange thing is (with Windows 7) that it doesn't like the 'std' in some places. Maybe it thinks its a disease Razz
Anyway, it works at the beginning of Format_Time, but not at the beginning of .ascii. It also doesn't work just before movsb.

This is something I haven't used, EVER, before:
Code:
    cld                                          ;Copy Left to Right
    rep                                          ;    (esi++, edi++)
    movsb
    

Smile just a rep...
Post 28 Apr 2011, 13:39
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7737
Location: Kraków, Poland
Tomasz Grysztar
I now think that CGI, being really a nice and simple idea in general, is not really so great when you consider performance. For each request the application has to be loaded and executed - this gives some considerable overhead. Ideally the web server would just call some code already residing in memory, like a function imported from some external library. This would of course mean that the web application would have to be "deployed" into server - which would be nothing else than LoadLibrary or something like that - just like in modern application servers the Java classes implementing servlet interfaces are loaded in memory upon startup.
So... what about writing some simple HTTP server with a high-performance binary interface for web applications written in assembly? Wink
Post 28 Apr 2011, 21:13
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Tomasz Grysztar wrote:
So... what about writing some simple HTTP server with a high-performance binary interface for web applications written in assembly? Wink

If that is an idea, I second it.
That would be one hell of a milestone though . Very Happy
Post 28 Apr 2011, 23:53
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Tomasz Grysztar wrote:
Ideally the web server would just call some code already residing in memory, like a function imported from some external library.


Of course these functions should be dynamically loaded and unloaded. And also, there should be some die-hard exception handling in order to not give the imported function to crash the server.
Another important issue is the security - the imported functions should not be able to access the same files as the whole server, but only the files of the web site it belongs. This can be implemented as different thread security attributes. But I am not very sure how exactly it should appear in Windows and Unixes.
Post 29 Apr 2011, 06:12
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
typedef wrote:
Tomasz Grysztar wrote:
So... what about writing some simple HTTP server with a high-performance binary interface for web applications written in assembly? Wink

If that is an idea, I second it.
That would be one hell of a milestone though . Very Happy


it is not a bad idea, will increase a lot the servicing.

using first a project in fasm that supports some basic server function, and add one by one every single function we will need to generate html from a very short describing code like i posted in first. something like that.

as dexos still have the server part, it can be interresting to focus on it for the start.

but as we don't really need the real internet connection management to test the idea, we can certainly try it as a little program that takes parameters from a file or ram, and convert it in a file or in ram...

a specialized server like a phpbb board don't need a lot of funcitons i think, and it needs every functions in permanence, then, it is some job for us as we can make fit very big librairies in less than 64k.

to be continued then.
Post 30 Apr 2011, 21:25
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
added some little macros just to test, it works.
Code:
        format binary as 'html'
        org 0
crlf    equ 10,13
macro   header title,color
{
db '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',crlf
db '<HTML>',crlf
db '<HEAD>',crlf
db '  <TITLE>',title,'</TITLE>',crlf
db ' </HEAD>',crlf
db ' <BODY bgcolor="',color,'">',crlf
}
macro   headerend
{
db '</BODY></HTML>',0
}
macro   § text
{
db '<br>'
db text
}
macro img i
{
db '<IMG SRC="',i,'" ALT="',i,'">'
}
macro link l,t
{
db '<a href="',l,'">'
t
db '</a>'
}
macro anchor l,t
{
db '<a name="',l,'">'
t
db '</a>'
}
                             


link.t takes any line of code, even a macro, and that is fine.

now, the problem is how to put a long string of macro inside link.t, because if i want to create a <a href> with an image, a text, and maybe something else like formating, it will be longer than just one line of code... and will use more than just one macro...

Code:
include 'mhtml.inc'
        header ' - test - ','112233'
      § 'hello world'
      § 'how are you today?'
      § 'fine and you how are you?'
      § ''
      § ''
      § ''
      § ''
   link 'http://fool.asm4u.net', img 'fool-icon-80.png'
      § ''
        headerend      
    


it works, i like it!
Post 01 May 2011, 11:24
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
I don't know how about France, but the "paragraph" character is missing from my keyboard.
Post 01 May 2011, 12:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17350
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
I don't know how about France, but the "paragraph" character is missing from my keyboard.
Wikipedia shows it as SHIFT-;

http://en.wikipedia.org/wiki/File:Bulgarian_BDS_layout.svg

OMG Shocked is Wikipedia wrong!
Post 01 May 2011, 12:45
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
[offtopic]
No, it is not wrong, but BDS (Bulgarian state standard) keyboard is only for Cyrillic and is not so popular here. Particularly, for Cyrillic, I use phonetic layout, that is based on standard QWERTY keyboard.

BDS is actually better for Bulgarian language and even for english, because it loads both wrists equally and the most words are typed using both hands consequently.
Unfortunately I never managed to learn to use it. Smile
[/offtopic]
Post 01 May 2011, 14:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
This would be great. I have aways want to do this with simple games, as any body got any ideas of a way to implement this ?.
Post 01 May 2011, 18:42
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
if § is not on the common layout of all keyboard, it might be good to find another char for this...

for me, this is the shifted key of !, on the left of the right shift key, that's why i feel it very good for this purpose, because it is very fast to type §

Smile

but finally, what i'd like is to just input text with db (or file, or include), and replace all crlf occurences (or 10,13) by <br> tag... and more, it should be able to take multiple ' ' (20h) and replace them by the <nbsp> special char.

then, db should be redefined by a macro...

it would be not so complex to do, forward directive is the main part of the solution, with some if =20h and if =crlf.

html is really bloated, but will never be replaced by something better, as all the public internet is build on...
Post 02 May 2011, 11:25
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
...and what is HTML 3.2??? Because of this kind of code in 2011 we won't ever hit HTML5. Why would anyone use anything less than 4.01 or XHTML 1 in 2011? Because of IE6?
http://www.ie6countdown.com/
http://whencaniuse.com/

Sad sad
Post 03 May 2011, 07:47
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
for the html3.2, the explanation is simple, i just took the header from a random html page.

but effectivelly, the finality is to comply with the last html revision.

for that, i think an axtra parameter for the macro 'header' will be needed, with a default value predefined, and if header.v equ, ver = default.

but it is just a little, a very little detail in this html macro project.

at term, it will be exatlly as the macro for pic i made, just use fasm to compile your html pages, and then, bring fasmw the ability to be a suiss knife instead of a hammer, without modifiing its internal code Very Happy

modifing the fasm code is something too much advanced for me, and have nothing to do with html or pic compilation, as it is the internal of the fasm engine. Smile

one day, i will learn polish and russian. Smile
Post 03 May 2011, 09:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.