flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > .

Author
Thread Post new topic Reply to topic
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta 11 Dec 2008, 17:19
[ Post removed by author. ]


Last edited by mikegonta on 28 Jan 2009, 09:03; edited 1 time in total
Post 11 Dec 2008, 17:19
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 11 Dec 2008, 19:06
no sane way to do it. that's one of FASM's main limitations: no nice string manipulation. you have to use 'file', 'txt', or something like that.
Post 11 Dec 2008, 19:06
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 12 Dec 2008, 12:13
vid,

Let's go insane!
Code:
macro get_last_dot_position pos*, [str*] {
common
local c
    virtual at 0
        db str
        repeat $
            load c from $-%
            if c = '.'
                pos = $-%
                break
            end if
        end repeat
    end virtual
}

macro db_to pos*, [str*] {
common
local c
    repeat pos
        virtual at 0
            db str
            load c from %-1
        end virtual
        db c
    end repeat
}

macro db_from pos*, [str*] {
common
local c, len
    virtual at 0
        db str
        len = $
    end virtual
    repeat len-(pos)
        virtual at 0
            db str
            load c from pos+%-1
        end virtual
        db c
    end repeat
}

macro upcase pstr*, len* {
local c
    repeat len
        load c from pstr+%-1
        if c >= 'a' & c <= 'z'
            store c-'a'+'A' at pstr+%-1
        end if
    end repeat
}

macro build_8.3_name [name*] {
local pos, off
    get_last_dot_position pos, name
    off = $
    db_to pos, name
    upcase off, $-off
    if off+8>$
        db off+8-$ dup ' '
    end if
    off = $
    db_from pos+1, name
    upcase off, $-off
    if off+3>$
        db off+3-$ dup ' '
    end if
}


build_8.3_name "io.sys", "msdos.sys", "command.com"
    
I love fasm for that kind of dirty hacks… Barely tested though, almost no error checking, but works. Wink
Post 12 Dec 2008, 12:13
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 12 Dec 2008, 16:26
Well done, baldr. Could use rept to shift more to the preprocessor - doesn't seem to be a reason to though.
Post 12 Dec 2008, 16:26
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Dec 2008, 16:49
yep, that's exactly what i meant by "no sane way" and by "nice way" Wink

Btw, you didn't solve the original problem. Problem was how to set symbolic constant to substring up to '.' character. You didn't do that.
Post 12 Dec 2008, 16:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 12 Dec 2008, 17:26
vid,

Yes, but my wild guess at db ??? was about using parts of file name in data definitions… As I said already somewhere, I'm considering fasm interpretive layer Turing-complete (opposed to preprocessing, it should be simple yet useful).

bitRAKE,

fasm preprocessing is almost of no use here, let alone unnecessary source size increase (after preprocession Wink). However, irpc-style preprocessing directive will be useful (upcase macro can benefit from it, e.g.)
Post 12 Dec 2008, 17:26
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.