flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Unix > asm4BSD - FreeBSD,OpenBSD,NetBSD,DragonflyBSD fasm headers

Author
Thread Post new topic Reply to topic
killasmurf86



Joined: 29 Sep 2010
Posts: 36
asm4BSD - FreeBSD,OpenBSD,NetBSD,DragonflyBSD fasm headers
FreeBSD, OpenBSD, NetBSD, DragonflyBSD syscalls for fasm and nasm

https://github.com/graudeejs/asm4BSD

I will add data structures as I progress.
Also Maybe I will write some perl script that will convert c headers for asm.

There are also FreeBSD native Hello World in fasm Smile


Last edited by killasmurf86 on 29 Sep 2011, 17:21; edited 10 times in total
Post 29 Sep 2010, 15:24
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
have you seen LSCR? What are differences?
Post 29 Sep 2010, 21:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
Yup i've seen it, In fact I have it on my HDD Very Happy
some (probably many) syscall numbers differ (argument count might differ as well for some syscalls)

but the biggest difference is how arguments are passed to kernel
Linux pass arguments with registers and fallback to stack, if it runs out of free regs

FreeBSD push all args to stack except syscall number (which is stored in eax as well)
after that it can call function that will call int 80h

Or you can simply push some dummy arg (I prefer push eax, because it's smaller than push 0x0)
then call int 0x80.
After you called int 0x80 you need to clear stack (for example with lea esp, 4*(arg_count))

Also some data structures might be different

After all FreeBSD != Linux


for info how to code asm in FreeBSD
http://int80h.org/
Also this month there was article in BSDmag [Free journal] about asm in Linux and FreeBSD
http://bsdmag.org/magazine/1502-bsd-and-linux


Last edited by killasmurf86 on 23 Feb 2011, 06:54; edited 4 times in total
Post 29 Sep 2010, 22:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14924
Location: 6EQUJ5

killasmurf86 wrote:

You might want to consider using "=" instead of "equ". Using equ can have unintended consequences when using things like match and doing parameter comparisons.
Post 29 Sep 2010, 22:45
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7113
Location: Slovakia
stickied
Post 29 Sep 2010, 22:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
Forgot to mention that in FreeBSD you pass sysargs from right to left


revolution wrote:

killasmurf86 wrote:

You might want to consider using "=" instead of "equ". Using equ can have unintended consequences when using things like match and doing parameter comparisons.



ye, I was wondering about that.... Thanks for hint


Last edited by killasmurf86 on 23 Feb 2011, 06:54; edited 2 times in total
Post 30 Sep 2010, 05:58
View user's profile Send private message Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
Added awk script to convert C/C++ headers to asm
You still will have to edit resulted file manually (edit structures, remove some bloat and remove C macro definitions [Don't know why they are still there, I tried to remove them])
However I think this can be HUGE time-saver

Any thoughts appreciated.
Also I'd be glad if someone could test if it works on Linux (FreeBSD and Linux Use different awk implementation)

http://aldis.git.bsdroot.lv/asm4FreeBSD/tree/scripts/h2fasm.awk


Code:

$ awk -f h2fasm.awk /usr/include/limits.h > limits.fasm





EDIT:
Just wrote nice script to convert /usr/src/sys/kern/syscalls.master to fasm readable format:
http://aldis.git.bsdroot.lv/asm4FreeBSD/tree/scripts/FreeBSD_syscalls4fasm.pl
Post 30 Sep 2010, 10:54
View user's profile Send private message Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
Added support OpenBSD and NetBSD
renamed project to asm4BSD
http://git.bsdroot.lv/aldis/asm4BSD.git/

Renamed this thread

EDIT:
Added DragonflyBSD


Last edited by killasmurf86 on 09 Nov 2010, 06:28; edited 1 time in total
Post 12 Oct 2010, 22:44
View user's profile Send private message Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
Figured out how to get rid of subdomain....
Changed url:

http://git.bsdroot.lv/aldis/asm4BSD.git/

also hg repo is available (I will probably later switch to hg completely)
http://hg.bsdroot.lv/pub/aldis/asm4BSD/
Post 09 Nov 2010, 06:28
View user's profile Send private message Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
I will shutdown my server permanently.
My repositories are moved to github under graudeejs nick

asm4BSD: https://github.com/graudeejs/asm4BSD
Post 29 Sep 2011, 17:23
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.