flat assembler
Message board for the users of flat assembler.

Index > Windows > Multiple .ASM files

Author
Thread Post new topic Reply to topic
roland



Joined: 09 Nov 2008
Posts: 10
roland 09 Nov 2008, 07:03
Hi I'm new to FASM and im not sure how to do this:

like have a main asm file eg main.asm then have an include file like main.inc
then another asm file called proc.asm

what i want to do is have a procedure in proc.asm and somehow call it in main.asm

eg in proc .asm


proc dosomething

;do something

endp

and in main.asm

call dosomething



sorry if this is confusing, thanks
Post 09 Nov 2008, 07:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 09 Nov 2008, 08:28
I think you are talking about including one file from another. This is known as the "include" directive.
Code:
include "somefile.inc"    
It is explained in the fasm manual.
Post 09 Nov 2008, 08:28
View user's profile Send private message Visit poster's website Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 09 Nov 2008, 08:31
so its ok to put whole procedures in the includes? ah ok thanks Very Happy
Post 09 Nov 2008, 08:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 09 Nov 2008, 08:33
Sure, just put anything in there, it is as though you have copy-pasted the whole file into that position within the main source. You can even include files from the included file to any desired depth.
Post 09 Nov 2008, 08:33
View user's profile Send private message Visit poster's website Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 09 Nov 2008, 08:42
thanks. is there a way to put sections in .inc files?
Post 09 Nov 2008, 08:42
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 09 Nov 2008, 09:27
roland,

Definitely is. Just don't expect fasm to combine them… Wink
Post 09 Nov 2008, 09:27
View user's profile Send private message Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 10 Nov 2008, 02:53
Thanks so much for the info and quick replies! Very Happy just one more question im not sure you can do this but, can you close a window without ending a program? eg if you wanted to open a new window in your program can you close the old one without ending the program? thanks!
Post 10 Nov 2008, 02:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 10 Nov 2008, 03:00
roland wrote:
Thanks so much for the info and quick replies! Very Happy just one more question im not sure you can do this but, can you close a window without ending a program? eg if you wanted to open a new window in your program can you close the old one without ending the program? thanks!
Yes, you can create and destroy windows at your leisure without ever ending the process. Many programs do this and put an icon in the system tray so that you can activate it again later. Although, just hiding a window may also achieve the same effect for you, it depends upon your requirement.
Post 10 Nov 2008, 03:00
View user's profile Send private message Visit poster's website Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 10 Nov 2008, 08:08
i was just thinking of going from windowed screen to full screen by pressing f1. when i press f1 i create a new window which is either full screen or windowed but i need to destroy the old window at the same time.
Post 10 Nov 2008, 08:08
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 10 Nov 2008, 09:48
There is no need to trash the window just to change its style.

First hide it via ShowWindow(hwnd,SW_HIDE)
Then set new styles via SetWindowLong(...)
Then update and show it via SetWindowPos(...)
Post 10 Nov 2008, 09:48
View user's profile Send private message Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 11 Nov 2008, 05:50
AH! thats how you do it! Very Happy thanks!
Post 11 Nov 2008, 05:50
View user's profile Send private message Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 12 Nov 2008, 00:50
can i have just one more question?


I want to set a D3D9 line using a procedure so I can change the line position when i want.

Code:
struct Vertex
       x dd ?
       y dd ?
       z dd ?
       colour dd ?
ends 

proc SetLine x1, y1, colour1, x2, y2, colour2

lineList     Vertex [x1],[y1], 0.0, [colour1]
               Vertex [x2],[y2], 0.0, [colour2]
ret
endp    



then I Set it using:

Code:
invoke SetLine, 0, 0, $ff0000, 100, 100, $00ff00 ;Set the line at 0, 0 to 100,100, first point red and second is green.    


then i just draw it.

its just that this comes up with errors

Error: invalid argument Linelist.x dd[..arg?2fN] -what ever that means???
Post 12 Nov 2008, 00:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 12 Nov 2008, 01:13
You need to show us the lineList macro, the error is occurring somewhere in there.

BTW: You shouldn't use invoke to call SetLine, use stdcall.
Post 12 Nov 2008, 01:13
View user's profile Send private message Visit poster's website Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 12 Nov 2008, 03:32
lineList is an array from the struct Vertex.

But when i try to declare linelist inside a procedure it doesn't work. And i can't declare it twice. So in the Struct Vertex, there is X, Y, Z and Colour. Is there a way to move a number into the x, y, z and colour like in c++?

eg

mov lineList.x, [number]

i tried this but it doesnt work. Is there any FASM tutorials that someone can point me to?
Post 12 Nov 2008, 03:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 12 Nov 2008, 04:29
It is confusing the way you have coded it. It is not normal to put data variables into a procedure without a local directive. What did you think would be executed as the first instruction within the SetLine procedure?
Post 12 Nov 2008, 04:29
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: 20363
Location: In your JS exploiting you and your system
revolution 12 Nov 2008, 05:08
roland: What is it that you are trying to achieve? If we had some idea of what you want to do then perhaps someone can suggest the proper method to do it.
Post 12 Nov 2008, 05:08
View user's profile Send private message Visit poster's website Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 12 Nov 2008, 05:54
i want to make an easy procedure to set where to put a line, so i can change the lines position and colour quickly and easily. heres the code, hope it helps. sorry for being confusing before.


heres how i set up and draw the line


Code:
proc DrawLineInit

     D3DCALL pd3dDevice, CreateVertexBuffer, sizeof.Vertex * 2, 0, CustomFVF, D3DPOOL_DEFAULT, LineVB, NULL
     cmp eax, D3D_OK
     jne Error

     mov     [pVertices], NULL

     D3DCALL LineVB, Lock, 0, sizeof.Vertex * 2, pVertices, 0
     cmp eax, D3D_OK
     jne Error

     cinvoke memcpy, [pVertices], lineList, sizeof.Vertex * 2
     D3DCALL LineVB, Unlock
ret
endp

proc DrawLine
     D3DCALL pd3dDevice, SetStreamSource, 0, [LineVB], 0, sizeof.Vertex
     D3DCALL pd3dDevice, DrawPrimitive, D3DPT_LINELIST, 0, 1
ret
endp       



heres how I want to set the lines position and colour, but its not working
Code:
proc SetLine x1, y1, colour1, x2, y2, colour2

lineList       Vertex  [x1],[y1], 0.0,1.0, [colour1]
               Vertex  [x2],[y2], 0.0,1.0, [colour2]
ret
endp     




and heres my D3DRender procedure where i do the drawing
Look at:

stdcall SetLine, 0, 0, $ff0000, 100, 200, $00ff00
call DrawLine



Code:
proc Draw
     D3DCALL pd3dDevice, Clear, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, $000000, 1.0, 0
     D3DCALL pd3dDevice, BeginScene
     ;Render geometry here...

     stdcall SetLine, 0, 0, $ff0000, 100, 200, $00ff00
     call DrawLine

     D3DCALL pd3dDevice, EndScene
     D3DCALL pd3dDevice, Present, NULL, NULL, NULL, NULL
     return
endp     
Post 12 Nov 2008, 05:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 12 Nov 2008, 06:21
You should declare lineList in your data section. Putting it in the code section is not a good idea.
Code:
;somewhere in your data section
lineList       Vertex
               rb sizeof.Vertex

;somewhere in your code section
proc SetLine x1, y1, colour1, x2, y2, colour2
       ;the first vertex
   mov     eax,[x1]
    mov     [sizeof.Vertex*0+lineList.x],eax
    mov     eax,[y1]
    mov     [sizeof.Vertex*0+lineList.y],eax
    mov     eax,dword 0.0
       mov     [sizeof.Vertex*0+lineList.z],eax
    mov     eax,[colour1]
       mov     [sizeof.Vertex*0+lineList.colour],eax
       ;the second vertex
  mov     eax,[x2]
    mov     [sizeof.Vertex*1+lineList.x],eax
    mov     eax,[y2]
    mov     [sizeof.Vertex*1+lineList.y],eax
    mov     eax,dword 0.0
       mov     [sizeof.Vertex*1+lineList.z],eax
    mov     eax,[colour2]
       mov     [sizeof.Vertex*1+lineList.colour],eax
       ret
endp    
Post 12 Nov 2008, 06:21
View user's profile Send private message Visit poster's website Reply with quote
roland



Joined: 09 Nov 2008
Posts: 10
roland 12 Nov 2008, 07:57
WOW! Thanks revolution!!!


Code:
lineList       Vertex
               rb sizeof.Vertex ; could you explain to me what this does?    



i get the rest though, cool!


also, are there any tutorials anywhere that cover arrays?
Post 12 Nov 2008, 07:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 12 Nov 2008, 08:11
rb is reserve bytes. Read the fasm manual for description.
Post 12 Nov 2008, 08:11
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.