flat assembler
Message board for the users of flat assembler.

Index > Heap > PHP fasm codehightlighting needed

Author
Thread Post new topic Reply to topic
sylwek32



Joined: 27 Apr 2006
Posts: 339
sylwek32
Hello,
need a fasm code highlighting script written in php for
www.fasm.info
Post 15 Oct 2006, 23:23
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
write one then Smile
it's simple
Post 15 Oct 2006, 23:39
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
I got one with line numbers option as well I'll upload for you...
Post 16 Oct 2006, 12:47
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
OK here you go:

FASM Syntax PHP

I'm still working on my rewrite for extra functionality, this one does the actual syntax colouring and does line numbers, any problems just ask Cool

HTH
Post 16 Oct 2006, 12:57
View user's profile Send private message Reply with quote
orbital_fox



Joined: 08 Sep 2006
Posts: 14
orbital_fox
All u need it a good set of

str_replace("code","<font color=\"code_color\">code</font>");
str_replace("code1","<font color=\"code1_color\">code1</font>");

Where code, code1 are various mnemonics..
Post 17 Oct 2006, 10:02
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
That won't work, it also produces needless HTML for consecutive special characters.

The PHP I posted divides the syntax into types: normal, text 1 (for '') and text 2 (for ""), comments, numbers and special. It starts on normal, when a specific character is recognised to be another type a new colour format is used until a character which is not valid occurs, then the current format is stopped and the new format used and so on. Comments are only termined by new line and text is only termined by the character that started it. I'm also using CSS so that if you want to change the syntax colours/text/etc you only have to edit the css file, which looks much nicer than the PHP source Very Happy

My rewrite will (hopefully) process the code line by line (instead of character by character) to add funcitonality to enumerate all macros, procs, variables, labels etc so that a viewer can jump to a point in the source. I'm also going to output to a table so that line numbers, code and comments can be separated out...or at least thats the plan Cool. This is the version I was planning on posting for the people of FASM, but hey you got a sneak preview Very Happy
Post 17 Oct 2006, 10:28
View user's profile Send private message Reply with quote
orbital_fox



Joined: 08 Sep 2006
Posts: 14
orbital_fox
I just addes a quick way to colorise the mnemonics.. just a quick kick off, which should really work fine..

It wouldnt colorise/shouldnt be used to colorise, any arguments, and strings, as apparently it wont work..

Since u got something working, i suppose no more comments are needed..

_________________
http://section-9.co.nr
Post 17 Oct 2006, 23:21
View user's profile Send private message Visit poster's website Reply with quote
sylwek32



Joined: 27 Apr 2006
Posts: 339
sylwek32
It cannot process this code
Code:
; Program in FASM, which is an example of HTML/EXE 'dual nature' program.
; After changing its extension from '.bin' to '.exe' it becomes normal
; Win application. If its extension has been modified to '.htm' or '.html',
; it may be viewed in WWW browser as a normal HTML page.
;
; (C) Mikolaj Hajduk, 18.08.2006.
; based on babyboy10777's 'Manual .EXE template'.
;
macro align n { db ((n-1)-($+n-1) mod n) dup(0) }

use32

exe_begin:
        dw 'MZ'                   ; Useless...
        db '<!--'                 ; Begin of HTML comment.
        db 36h dup(0)
        dd 40h
        db 'PE', 0, 0             ; Signature,
        dd 1014Ch, 0, 0, 0        ; cpu (.I386+). # sections, etc,
        dd 10F00E0h, 10Bh         ; n/a,
        dd 0, 0, 0                ; .code/.idata/.data sizes,
        dd 1000h, 0, 0, 400000h   ; entry, .code/.data offsets, base address,
        dd 1000h, 200h            ; section alignment in memory and file: 1K/512,
        dd 1, 0, 4, 0             ; versions,
        dd (((1000h +\            ; image size = (rva + section size) aligned to 1000h,
           prg_core_end-prg_core)\
           shr 12) + 1) shl 12
        dd 200h, 0                ; section 1 offset,
        dw 2, 0                   ; subsystem,
        dd 1000h, 1000h, 1000h, 0 ; stack/heap reserve/commit,
        dd 0, 16                  ; flags, # directories,
        dq 0                      ; "data directory" structures,
        dd it+0E00h               ; import table rva, size...
        dd prg_core_end-it
        dq 14 dup(0)

        dq '.core'                ; Section header. File offset = 138h.
        dd prg_core_end-prg_core  ; Size,
        dd 1000h                  ; rva,
        dd exe_end-prg_core       ; size rounded to 200h,
        dd 200h, 0, 0, 0          ; file offset, skip relocations, etc,
        dd 0E0000020h             ; attributes: readable, writable, executable, etc,
        db 200h-$ dup(0)          ; proceed to 200h/1000h.

; 'Core' of the program.
;
prg_core:
        push 0 msgbox_caption+400E00h msgbox_message+400E00h 0
        call dword [MessageBox+400E00h]
        push 0
        call dword [ExitProcess+400E00h]

; Program data.
;
msgbox_caption db 'Boss', 0
msgbox_message db 'Zmien rozszerzenie na HTML!', 0

; Import table.
;
it:
        dd 0, 0, 0, kernel_name+0E00h, kernel_table+0E00h
        dd 0, 0, 0, user_name+0E00h, user_table+0E00h
        dd 0, 0, 0, 0, 0

kernel_name db 'KERNEL32.DLL', 0

kernel_table:
        ExitProcess dd _ExitProcess+0E00h
        dd 0
        _ExitProcess db 0, 0, 'ExitProcess', 0

user_name db 'USER32.DLL', 0

user_table:
        MessageBox dd _MessageBox+0E00h
        dd 0
        _MessageBox db 0, 0, 'MessageBoxA', 0

; End of the main part of application.
;
prg_core_end:
        ; End of HTML comment.
        ;
        db '-->'

        ; Content of HTML page.
        ;
       file 'includes/include.html'

align 512

exe_end:
    




it only shows a snippet:

Code:
; Program in FASM, which is an example of HTML/EXE 'dual nature' program.
; After changing its extension from '.bin' to '.exe' it becomes normal
; Win application. If its extension has been modified to '.htm' or '.html',
; it may be viewed in WWW browser as a normal HTML page.
;
; (C) Mikolaj Hajduk, 18.08.2006.
; based on babyboy10777's 'Manual .EXE template'.
;
macro align n { db ((n-1)-($+n-1) mod n) dup(0) }

use32

exe_begin:
         dw 'MZ'                      ; Useless...
         db ''

         ; Content of HTML page.
         ;
       file 'includes/include.html'

align 512

exe_end:

    
Post 18 Oct 2006, 08:22
View user's profile Send private message Reply with quote
sylwek32



Joined: 27 Apr 2006
Posts: 339
sylwek32
sorry. now i see why..
there are <!--- and ---!>
Post 18 Oct 2006, 08:41
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Shocked uh oh I hadn't anticipated HTML, but I have managed to find a way to counter it (phew!) this is something that will go into the rewrite as it will need line by line processing.

Thanks, sylwek32! Hope the others are working fine too!
Post 18 Oct 2006, 11:55
View user's profile Send private message 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 can 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.