flat assembler
Message board for the users of flat assembler.

Index > Main > can fasm do this?

Author
Thread Post new topic Reply to topic
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 30 Oct 2009, 07:49
I know the irp macro can be used to loop over a given set of values, but it is possible to do something like this:
Code:
rept 10 i:0 {
 mov eax,[[table+4*i^2]]
}
table: dd 0,1,2,3,4,5,6,7,8,...    

and have the code generated be:
Code:
 mov eax,0
 mov eax,1
 mov eax,4
 mov eax,9
...    

Essentialy fasm need to find the value from the address and substitue it in instead of encoding it as a memory access.
Post 30 Oct 2009, 07:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Oct 2009, 08:09
Read up about the load directive.
Code:
table: dd 0,1,2,whatever,...
rept 10 i:0 {
  load x dword from table+4*i*i
  mov eax,x
}    
Post 30 Oct 2009, 08:09
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Oct 2009, 08:12
But if all you want to do is generate squares then:
Code:
rept 10 i:0 {
  mov eax,i*i
}    
Post 30 Oct 2009, 08:12
View user's profile Send private message Visit poster's website Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 19 Nov 2009, 06:24
How about this one:
How can you get fasm to compile something like this:
Code:
.ifc
x1
.nz
y1
.elseif
x2
.nz
y2
.elseif
x3
.nz
y3
.else
y4
.endif    

into:
Code:
x1
jnz .1
x2
jnz .2
x3
jnz .3
y4
jmp .end
.3:
y3
jmp .end
.2:
y2
jmp .end
.1:
y1
.end:    


It essentially involves movinf the intruction blocks y1,y2,.. around but keeping the condition checking block x1,x2 in the same order.
Post 19 Nov 2009, 06:24
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.