flat assembler
Message board for the users of flat assembler.

Index > Linux > Any GTK2.0 /2.1 examples with FASM

Author
Thread Post new topic Reply to topic
surgeon



Joined: 04 Apr 2011
Posts: 2
Location: Biafra.
surgeon
I and lots of friends are starting a project to write small applications for a complete Linux OS, We picked GTK as the GUI toolkit we are going to use, the only problem is that there is no examples to use as a starting point to code with FASM, all the gtk examples i saw so far are really old and even after soo much tweaks there are still issues creeping out somewhere.
the project is simply to build a linux distro with very small apps written entirely with assembly and GTK, kinda anti-bloat distro. so my needs are just the GTK stuffs.
Any help guys ? or do i drop FASM for NASM...i really like FASM.

_________________
“It is not sufficient that I succeed - all others must fail.”Genghis Khan.
Post 04 Apr 2011, 17:18
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
This is a template for GTK generic application.

It's intended for multiplatform development. The same sources must work in supported platforms (currently Linux and Win32).

I have abandoned the project because FreshLib provides a more comfortable solution for my needs and without the bulk of GTK libraries


Description: Template for GTK application. Working in Linux and Win32
Download
Filename: fasm-gtk.zip
Filesize: 3.46 KB
Downloaded: 230 Time(s)

Post 04 Apr 2011, 18:18
View user's profile Send private message Yahoo Messenger Reply with quote
surgeon



Joined: 04 Apr 2011
Posts: 2
Location: Biafra.
surgeon
I have GTK 2.1 installed on my CentOS linux box but the above file refused to work. i am really green on mixing assemly and other languages , can someone direct me to a link or a pointer on how to translate C header files to work with Assembly, or importing DLLs and all that .
Post 08 Apr 2011, 04:25
View user's profile Send private message Reply with quote
ProphetOfDoom



Joined: 08 Aug 2008
Posts: 120
Location: UK
ProphetOfDoom
Hi. I don't actually use gtk much at present but I had a book on the subject lying around so I translated the hello world application for you. I'd be very surprised if it doesn't work - it's about the simplest gtk app you can write.

Code:
format ELF

extrn exit
extrn gtk_init
extrn gtk_window_new
extrn gtk_window_set_title
extrn gtk_widget_show
extrn gtk_main
extrn printf

public main

GTK_WINDOW_TOPLEVEL = 0

section '.data' writeable

window dd 0
hello db "Hello world.",0

section '.text' executable

main:

push ebp
mov ebp, esp

lea eax, [ebp + 12]
push eax
lea eax, [ebp + 8]
push eax
call gtk_init
add esp, 8

push GTK_WINDOW_TOPLEVEL
call gtk_window_new
add esp, 4
mov [window], eax

push hello
push [window]
call gtk_window_set_title
add esp, 8

push [window]
call gtk_widget_show
add esp, 4

call gtk_main

push 0
call exit


    


To assemble:

Code:
fasm gtk.asm
    


Link:

Code:
gcc gtk.o `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
    


Execute:

Code:
./a.out
    


I'm basing the arguments of the first call (to gtk_init) on the assumption that argc and argv are located at ebp + 8. I discovered that from looking at the assembly output from a C program. Hopefully it's the same across distros. The only other possible problems i can forsee are that you may need to install the program pkg-config, and you may need to change gtk+-2.0 to gtk+-2.1. Also you have to kill the resulting program with CTRL-C because it doesn't handle messages. Hope that helps.
Post 09 Apr 2011, 19:46
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.