flat assembler
Message board for the users of flat assembler.

Index > DOS > TASM -> FASM syntax question.

Author
Thread Post new topic Reply to topic
FASMresearcher



Joined: 28 May 2008
Posts: 24
FASMresearcher
Hi all!
Is it possible to use in FASM the following syntax, which is allowable in TASM:
Code:
table_1     equ offset tables
table_2    equ offset tables + 300h
table_3     equ offset tables + 400h

begin:
........

tables:
end begin    

I want to generate tables during code execution and append them to the end.
How I can do it?
Post 02 Jun 2008, 08:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
Sure you can, just remove the word "offset".
Post 02 Jun 2008, 09:15
View user's profile Send private message Visit poster's website Reply with quote
FASMresearcher



Joined: 28 May 2008
Posts: 24
FASMresearcher
Great thanks! Smile
Post 02 Jun 2008, 10:06
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> want to generate tables during code execution and append them to the end

Of what ? Confused

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 02 Jun 2008, 23:29
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
Location: Severodvinsk, Russia
SFeLi
Code:
begin:
........

;end begin
table_1 rb 0x0300
table_2 rb 0x0100
table_3 rb 0x????
    
Post 03 Jun 2008, 05:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Good evening,

I would like to ask a question.
How such TASM declarations translated in fasm syntax.
Code:
mystruc struc
     string db 20 dup (0h)
     n db 0h
mystruc ends

table   mystruc <'One',const1>
        mystruc <'Two',const2>
        mystruc <'Three',const3>           
        mystruc <0>                              
    


Is it like this? (un-elegant)
Code:
table    db 'One' 
         db 17 dup 0, const1
         db 'Two'
         db 17 dup 0, const2 
         db 'Three'
         db 16 dup 0, const3
         db 0   
    
Post 10 Apr 2010, 20:15
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
I think there is an error.
Three has 5 characters so your constant should be 15 instead of 16.
Better to use a macro I think.

Code:
macro myTASMmacro data,constx
{
  local cnt1,cnt2
cnt1:
  db data
cnt2:
  db count-(cnt2-cnt1) dup 0
  db constx
} 

; and then use

table myTASMmacro 'One',const1
        myTASMmacro 'Two',const2
        myTASMmacro 'Three',const3
        db 0
    
Post 10 Apr 2010, 20:58
View user's profile Send private message Send e-mail Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop
revolution wrote:
Sure you can, just remove the word "offset".

or keep the TASM syntax but add
Code:
offset equ    
Post 10 Apr 2010, 21:37
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
shutdownall wrote:
Better to use a macro I think.

Yes, a macro can do the job easy.

Fasm syntax is very close to Tasm ideal mode, that is a feature i always like in fasm. Razz
Post 11 Apr 2010, 00:26
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
shutdownall,

That won't compile.

myTASMmacro macro name would not be recognized as its invocation if it is second token on the line (not counting label_name: definitions), because it's macro macro Wink. Use struc macro and make macro thunk:
Code:
struc mystruc string, n {
.string db string
        db .string+20-$ dup 0
.n      db n+0
}

macro mystruc string, n {
  local .
  . mystruc string, n
}

table   mystruc 'One',const1
        mystruc 'Two',const2
        mystruc 'Three',const3
        mystruc 0    


----------
Picnic,

Basic headers contain struct macro:
Code:
        include "Win32A.Inc"

struct mystruct
string  db 20 dup 0
n       db 0
ends

table2  mystruct 'One',const1
        mystruct 'Two',const2
        mystruct 'Three',const3
        mystruct 0    
Hope this helps.
Post 11 Apr 2010, 01:42
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
It does baldr, and this way it declares sizeof. automatically, i omit that.
Post 11 Apr 2010, 13:17
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
baldr wrote:
shutdownall,

That won't compile.



You are right, i forgot ":" after table and count has to be replaced by constant 20.
But your solution is more elegant, I think.
Wink
Post 11 Apr 2010, 21:17
View user's profile Send private message Send e-mail Reply with quote
monk



Joined: 09 Mar 2011
Posts: 2
monk
I've a question how to translate that code[tasm] in fasm:
MOV AH,0AH
LEA DX,NAMEPAR
INT 21H
mov ah,9
mov dx, NAMEFLD
int 21h
;-------------------------------------------------------
NAMEPAR LABEL BYTE
MAXLEN DB 20
ACTLEN DB ?
NAMEFLD DB 20 DUP (?)
Post 15 Mar 2011, 06:34
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Hi,

Try this, and also check daluca's post here
Code:
ORG 100H
MOV AH,0AH
MOV DX,NAMEPAR
INT 21H

MOV AH,9
MOV DX, NAMEFLD
INT 21H
RET

NAMEPAR:
MAXLEN DB 20
ACTLEN DB ?
NAMEFLD DB 20 DUP ("$")
    
Post 15 Mar 2011, 14:06
View user's profile Send private message Reply with quote
monk



Joined: 09 Mar 2011
Posts: 2
monk
Thank you very much !
Post 16 Mar 2011, 05:59
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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.