flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Customizing FASM

Author
Thread Post new topic Reply to topic
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 01 Jul 2003, 08:13
Hi Privalov!

Thanks once again for your excellent work!

A little question...:
How am I going to add an instruction or a directive which declares a symbol/label?? For instance if I'm going to make a directive with name "makelabel" which does as following:
Code:
makelabel a_name
 |
 V
a_name:
push eax
    

How am I going to write these sources in the FASM core??

Do you understand what I mean?? (Sorry my English)

Well, so long! Take care!
Regards,
Tommy
Post 01 Jul 2003, 08:13
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 01 Jul 2003, 12:56
Why do you want an instruction/directive to make a label?
in fasm.txt privalov wrote:
The last and the most flexible way to define labels is to use "label"
directive. This directive should be followed by the name of label, then
optionally size operator (it can be preceded by a colon) and then - also
optionally "at" operator and the numerical expression defining the address at
which this label should be defined. For example "label wchar word at char"
will define a new label for the 16-bit data at the address of "char". Now the
instruction "mov ax,[wchar]" will be after compilation the same as
"mov ax,word [char]". If no address is specified, "label" directive defines
the label at current offset. Thus "mov [wchar],57568" will copy two bytes
while "mov [char],224" will copy one byte to the same address.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 01 Jul 2003, 12:56
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 01 Jul 2003, 13:40
That was only an example... I want an instruction in which declares a label and output some bytes to the output file... (Please don't suggest macros) I only want to know how to do it, you'll probably see what it will be used for later.... Wink So, do you know how?

Thanks for your reply anyway.... So long!
Tommy
Post 01 Jul 2003, 13:40
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 02 Jul 2003, 11:19
Tommy wrote:
That was only an example... I want an instruction in which declares a label and output some bytes to the output file...

Ok, sorry I miss understood you. Embarassed

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 02 Jul 2003, 11:19
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 02 Jul 2003, 12:00
You'll probably have a good reference when I finish the internals documentation, but currently I can only provide you with a small example. You'll have to make three modifications, I give line numbers for the 1.47 version of core. First you have to put two new lines into the X86.INC file, between the lines 7730 and 7731 (after the definition of cvttss2si instruction handler):
Code:
 db 'makelabel',0
 dw makelabel_directive-assembler    

The you have to put two new lines into the PARSER.INC file, in line, after the line 178 add:
Code:
        cmp     bx,makelabel_directive-assembler
        je      parse_label_directive    

And finally you have to put the handler for newly defined directive into ASSEMBLE.INC file, you can put it anywhere:
Code:
makelabel_directive:
        lods    byte [esi]
        cmp     al,2
        jne     invalid_argument
        lods    dword [esi]
        cmp     eax,0Fh
        jb      invalid_use_of_symbol
        je      reserved_word_used_as_symbol
        inc     esi
        mov     ebx,eax
        xor     cl,cl
        mov     eax,edi
        sub     eax,[org_origin]
        cdq
        mov     ebp,[org_sib]
        call    operand_32bit_prefix
        mov     byte [edi],50h
        inc     edi
        jmp     define_free_label    

Directive defined this way should work exactly as in your example above.
Post 02 Jul 2003, 12:00
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 03 Jul 2003, 09:08
I understand scientica.... Smile
Thank you Privalov! Exactly what I needed.... Thanks again!

So long!
Tommy
Post 03 Jul 2003, 09:08
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 04 Jul 2003, 08:49
When we're talking about custom instructions etc., what about adding your old tutorial on how to customize FASM instructions etc. to the documentation??

Regards,
Tommy
Post 04 Jul 2003, 08:49
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.