flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 01 Apr 2009, 22:15
equ is textual replacement.
|
|||
![]() |
|
Tomasz Grysztar 01 Apr 2009, 22:19
If I understand correctly, what you are trying to do, you can try something like this:
Code: struc revdb [data] { common . db data repeat ($-.)/2 load b1 byte from .+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at .+%-1 end repeat } example revdb 'bar' |
|||
![]() |
|
revolution 01 Apr 2009, 22:22
Oh, you mean you want to reverse the byte stream? Was that your question? Sorry, looks like my question parser is not working very well
![]() |
|||
![]() |
|
Azu 01 Apr 2009, 22:23
Tomasz Grysztar wrote: If I understand correctly, what you are trying to do, you can try something like this: I need to know how to reverse string in equate. So it will be like I put "foo equ 'rab'".. |
|||
![]() |
|
revolution 01 Apr 2009, 22:26
Azu wrote: I need to know how to reverse string in equate. So it will be like I put "foo equ 'rab'".. |
|||
![]() |
|
Azu 01 Apr 2009, 22:34
revolution wrote:
I'm guessing it is done basically the same way adding ror and rol was? What file should I look in to find the equ code so I can make a revequ? Last edited by Azu on 01 Apr 2009, 22:36; edited 1 time in total |
|||
![]() |
|
revolution 01 Apr 2009, 22:36
PREPROCE.INC
|
|||
![]() |
|
Azu 01 Apr 2009, 22:37
Thank you again ^.^
|
|||
![]() |
|
revolution 01 Apr 2009, 22:40
I'm not sure what you refer to when you say "the same way adding ror and rol was" but it looks to me like those would be assembler-stage operators? Whereas equ is preprocessor-stage so maybe not the same thing.
|
|||
![]() |
|
Azu 01 Apr 2009, 23:02
Meant in preprocessor (I think that's what you call it.. whatever it is that shl and shr are done in). You know like so you can do "mov [port],80 ror 8" for defining ports for winsock. You helped me add them to FASM before.
Edit: Whoops that was LocoDelAssembly sorry. ![]() |
|||
![]() |
|
Azu 02 Apr 2009, 00:25
Ugh the PREPROCE.INC code looks a lot harder to add to. Please isn't there some way to do it in a macro or something instead?
Or if can't reverse in equ then at least some way to pass to my struct that that one should be reversed? Something like Code: Blah equ 1 moo equ 'ooooom' struc edb[data]{ common .len dd .lenn if reverse . reverse db data else . db data endif .lenn=$-. woof edb Blah,reverse moo,"hello",5 FASM source is scary to me I don't want to mess with it again ![]() |
|||
![]() |
|
LocoDelAssembly 02 Apr 2009, 00:44
Code: struc edb [data] { forward done equ match =reverse op, data \{ done equ 1 ; Tomasz's code . db op repeat ($-.)/2 load b1 byte from .+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at .+%-1 end repeat \} match , done\{ . db data \} } Or something near (I haven't tested it) |
|||
![]() |
|
Azu 02 Apr 2009, 02:14
LocoDelAssembly wrote:
Thank you! But no matter how much I change it it always fails to compile, with either "symbol already defined" or "extra character on line".. and I've tried literally EVERYTHING I could think of so far.. ![]() Starting to think maybe it would be easier to change FASM itself for this afterall.. |
|||
![]() |
|
LocoDelAssembly 02 Apr 2009, 02:40
Oh right sorry, the symbol is defined several times (at least once for each parameter).
This (I hope) will work OK: Code: struc edb [data] { common label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code l db op repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat \} match , done \{ db data \} } |
|||
![]() |
|
Azu 02 Apr 2009, 03:04
Sweet thanks. I hate to keep bugging you, but.. no matter how I try it, it doesn't compile, or gives the wrong data.. help please.. :/
Code: struc edb [data] { common .lenn dd .len label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code l db op repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat \} match , done \{ db data \} .len = $-. } Code: struc edb [data] { common label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code dd ..temp2-l l db op ..temp2: .len = $-. repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat \} match , done \{ common ..temp1: db data .len = $-..temp1 \} } Code: struc edb [data] { common label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code dd ..temp2-l l db op ..temp2: repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat \} match , done \{ dd blah2b-blah2a blah2a: db data blah2b: \} .len = $-. } Code: struc edb [data] { common label .lenn dword label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code dd .len l db op repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat .len = $-. \} match , done \{ dd .len db data .len = $-. \} } Code: struc edb [data] { common label .lenn dword label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code dd .len @@: l db op repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat .len equ $-@b \} match , done \{ dd .len @@: db data .len equ $-@b \} } Nothing works.... |
|||
![]() |
|
revolution 02 Apr 2009, 03:08
Works fine for me. How are you trying to use it?
Code: struc edb [data] { common label . byte forward local l done equ match =reverse op, data \{ done equ 1 ; Tomasz's code l db op repeat ($-l)/2 load b1 byte from l+%-1 load b2 byte from $-% store byte b1 at $-% store byte b2 at l+%-1 end repeat \} match , done \{ db data \} } x_norm edb 'abcd' x_reverse edb reverse 'abcd' |
|||
![]() |
|
Azu 02 Apr 2009, 03:26
All the examples I posted fail to compile, or crash on startup due to putting in the wrong length E.G. 0
![]() Your example won't compile because you deleted the .len definition.. so there are "undefined symbol X.len" errors.. and it would crash anyways, since you also took the part that embeds the length.. basically you removed everything except the db.. |
|||
![]() |
|
LocoDelAssembly 02 Apr 2009, 03:28
revolution, he added this to my code:
Code: .len = $-. That is located under the forward block so it fails because it is defined several times which is OK for assembly-time variables but very bad for forward referencing (he also added a size field at the common block). Fix:Just add a second common block after the forward block, i.e. replace the last line with: Code: common .len = $-. |
|||
![]() |
|
Azu 02 Apr 2009, 03:32
Ah, got it working perfect now. Thank you. I forgot about the "common". Shouldn't have been in such a hurry lol sorry.
![]() |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.