flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > Linux & OpenGL

Author
Thread Post new topic Reply to topic
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
Yesterday i tried to write a simple program in linux using some gl and glut function, but when i execute it, it shows the "Segmentation Error"

i used theese for assembling and linking:
fasm ./OGL.asm
ld -s -o GL ./OGL.o /lib/ld-linux.so.2

Can someone help me understand what's wrong?
(sorry for my english Smile )


Description:
Download
Filename: OGL.asm
Filesize: 2.38 KB
Downloaded: 133 Time(s)


_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 07 Mar 2008, 14:46
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16128
Location: Hyperborea
Maybe here:
Code:
keyboard: ;(tasto,x,y)
 mov eax,dword [ebp+8]
       cmp al,'q'
        je _exit
    ret ;<--- do you need a ret 12?    
And perhaps also for the disegna/ret function.
Post 07 Mar 2008, 15:23
View user's profile Send private message Visit poster's website Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
@revolution: thanks, but the problem still remain Sad
I used IDA and i discovered that the segmentation error happen inside the first function call (glutInit). mmmmm

ps. Are the ld's parameters right?
Post 07 Mar 2008, 16:11
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16128
Location: Hyperborea
You need to pass a proper command line string to glutInit.

The first few lines of glutInit show that it does not allow null parameters:
Code:
void glutInit(int *argcp, char **argv) {
  char *str, *geometry = NULL;
  int i;

  if (gState.display) {
    __glutWarning("glutInit being called a second time.");
    return;
  }
  /* Determine temporary program name. */
  str = strrchr(argv[0], '/');         <--- here cannot be null!
  if (str == NULL) {
    gState.programName = argv[0];
  } else {
    gState.programName = str + 1;
  }
...    
Post 07 Mar 2008, 16:59
View user's profile Send private message Visit poster's website Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
thanks! SmileSmile
2° problem: Is there some methods in linux to get the current command line quickly (like GetCommandLine in windows)?
Post 07 Mar 2008, 17:33
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16128
Location: Hyperborea
The entry point to your program will have the command line passed to you from the loader. As for getting it after that I am not sure, so to make your task easier just save the values upon entry.
Post 07 Mar 2008, 17:39
View user's profile Send private message Visit poster's website Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
§-Death_Reaver-§ wrote:
thanks! SmileSmile
2° problem: Is there some methods in linux to get the current command line quickly (like GetCommandLine in windows)?


You may simply get them on the stack, like in C. The first parameter of the entry-point function is the number of words in the the command-line, and the second is a pointer to an array of pointers to the words.

_________________
(French only) http://dap.developpez.com
Post 07 Mar 2008, 20:37
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-2018, Tomasz Grysztar.

Powered by rwasa.