OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:29 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Xlib and assembly?
PostPosted: Fri Dec 26, 2014 2:09 am 
Offline

Joined: Wed Dec 17, 2014 12:43 pm
Posts: 11
Anyone got experience with Xlib/xcb for linux and assembly? basically i would like to start "hacking" http://incise.org/tinywm.html but dont know how to link / compile to the lib

re
skid


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Fri Dec 26, 2014 2:39 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
I'm not quite sure that I understand what your problem is. You call Xlib functions just like you would any other library. Or am I missing something?


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sat Dec 27, 2014 6:25 am 
Offline

Joined: Wed Dec 17, 2014 12:43 pm
Posts: 11
care to give an example, i've been out of the game for quite som time and become literally stupid ;)


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sat Dec 27, 2014 8:07 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
Asking for the solution is not something that makes you look good. It makes you look like a complete idiot. As someone has in his sig, computer science is all about problem solving. By asking for the solution, you're basically defeating the purpose. Even if this does not reflect this case, it shows you one thing: we only provide help that helps you to find the solution by yourself.

Take a look at the System V ABI. It tells you how to call a function. If you're not familiar with gcc or ld, there's nothing for you to do here. Go learn to use it first (e.g. by taking a look at the man pages ...). I'm sorry if it sounds very rude, but that's the truth.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sat Dec 27, 2014 8:11 am 
Offline
Member
Member

Joined: Thu Jul 05, 2012 5:12 am
Posts: 923
Location: Finland
In general, if I were interested in using X11, I would start studying the X Window System Protocol.
Code:
ChangeWindowAttributes
     1     2                               opcode
     1                                     unused
     2     3+n                             request length
     4     WINDOW                          window
     4     BITMASK                         value-mask (has n bits set to 1)
          encodings are the same as for CreateWindow
     4n     LISTofVALUE                    value-list
          encodings are the same as for CreateWindow



I am not interested using it (and I am no familiar with it) but I kind of like these kind of interfaces. There are no specific programming languages involved. Send an opcode and then parameters into some messaging system...

_________________
Undefined behavior since 2012


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sat Dec 27, 2014 9:27 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
skid wrote:
care to give an example, i've been out of the game for quite som time and become literally stupid ;)

TBH, if you are not up to reading and understanding the X Window and Xlib documentation then you are not going to have much success "hacking" a window manager. Start with something simpler and practise calling C libraries from assembler. When you are confident with that you can come back to using this particular library.


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sun Dec 28, 2014 2:10 am 
Offline

Joined: Wed Dec 17, 2014 12:43 pm
Posts: 11
i get the picture and i think i understand but could someone please give me an idea howto build the structure for Display for example, guess one way would be to put extern Display * dpy in a c file and link, but i want to learn but i dont understand. i'm not asking for anyone to write me an entire program here, only minor guidance, and explain in a language i can understand or begin to understand. i used to do dos assembly years ago, i'm sorry i have blown my brains on dope...

http://www.x.org/releases/current/doc/x ... tion_Setup
what am i supposed to to with this, a snippet is all i ask.


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sun Dec 28, 2014 3:20 am 
Offline
Member
Member

Joined: Mon Jan 03, 2011 6:58 pm
Posts: 283
skid wrote:
i get the picture and i think i understand but could someone please give me an idea howto build the structure for Display for example, guess one way would be to put extern Display * dpy in a c file and link, but i want to learn but i dont understand. i'm not asking for anyone to write me an entire program here, only minor guidance, and explain in a language i can understand or begin to understand. i used to do dos assembly years ago, i'm sorry i have blown my brains on dope...

http://www.x.org/releases/current/doc/x ... tion_Setup
what am i supposed to to with this, a snippet is all i ask.


Everything you need to know is at http://www.cprogramming.com/

- Monk


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sun Dec 28, 2014 3:47 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
skid wrote:
i get the picture and i think i understand but could someone please give me an idea howto build the structure for Display for example, guess one way would be to put extern Display * dpy in a c file and link, but i want to learn but i dont understand. i'm not asking for anyone to write me an entire program here, only minor guidance, and explain in a language i can understand or begin to understand. i used to do dos assembly years ago, i'm sorry i have blown my brains on dope...

http://www.x.org/releases/current/doc/x ... tion_Setup
what am i supposed to to with this, a snippet is all i ask.

You are not asking how to use Xlib or how to do XWindow programming. You are asking how to use any external C function or library from assembler (in this case how to build the assembler equivalent of a C struct). This is not really the level that this forum is aimed at.

I repeat my previous advice - before being so ambitious learn and practise the basics with simpler C libraries. Once you understand them you can return to this more advanced project. There are plenty of web sites and/or books that will provide help with these basics of assembler programming.


Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sun Dec 28, 2014 6:36 am 
Offline

Joined: Wed Dec 17, 2014 12:43 pm
Posts: 11
am i on the right path atleast?

Code:
extern XOpenDisplay
extern DefaultRootWindow

   push 0
   call XOpenDisplay
   or eax, eax
   je fail
   ;add esp, 4
   mov [display], eax

   push display
   call DefaultRootWindow
   ;add esp, 8
   mov [root], eax

fail:
   ; print something

display       dd 0
root    dd 0



Top
 Profile  
 
 Post subject: Re: Xlib and assembly?
PostPosted: Sun Dec 28, 2014 7:02 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
A good way to check what you need to do in assembler is to create a simple program in C and compile it. Look at the assembler output produced.

A better way is just to use C in the first place. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 45 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group