Help Logs Database

Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Ircnet  |  Dalnet
Page: 1 2

<looth> AHA!
<Cupu> When you have a statement like "myVar db ?" (in nasm) what does the "?" mean?
<froztbyte> dunno
<froztbyte> i'm here to listen to what you guys say to learn
<Cupu> :)
<libero_> Cupu, it means it isn't initialised
<Cupu> so why do that in a data segment and not in bss?
<libero_> why not?
<libero_> :)
<froztbyte> my answer: ?
<Cupu> I see .. so you can do it either way .. it's the same .. thanks libero_
<Cupu> I mean .. either "myVar db ?" or "myvar resd 1" .. same thing?
<libero_> well, u can have "db" inside code :)
<Cupu> actualy not the same thing .. but I got it
<Cupu> Indeed
<blumber> is this the channel for ***embly language ?
<libero_> yes mate
<libero_> are you good in plumbing?
<blumber> okay..
<libero_> i need something to get fixed in my bathroom
<blumber> you need a strong snake wire?
<libero_> no, in uk. they only wipe
<libero_> while i wash
<Cupu> :))
<libero_> so need to fit a little tupe to get water near the ****ter
<libero_> tube
<blumber> anyhow...how do I include a header file in the source code? using as (gas) ?
<libero_> #include "filename"
<blumber> Im still getting a : undefined reference to `SYS_write' after I have #include "sys/syscall.h"
<blumber> been searching for a tutorial on how to include this header file and not in luck today
<libero_> blumber, uh, have u tried <sys/syscall.h>??
<libero_> i thought you're including your own library
<blumber> same way as in C when doing an include?
<libero_> i thought u were talking about C :|
<blumber> nope
<libero_> syscall.h is a C library, ain't?
<blumber> yes its in /usr/include/sys/
<libero_> and are u allowed to include C lib?
<Cupu> good question
<blumber> im trying to use system calls in C
<Cupu> so it is c after all
<Cupu> use <> not ""
<Cupu> or are you trying to use c system calls in asm? .. it's confusing :)
<blumber> its .s ***embly code, trying to save some time, using printf, read, write, ... c system calls
<Cupu> in that case .. just pay attention to the calling conventions ... declare them as extern .. and add whatever you need to the linker
<Cupu> sys_write .. if it's c .. should be declared as _sys_write in asm
<Cupu> so the .h files won't do any good .. I might be wrong though
<blumber> i was calling it for example, movl $SYS_write, %eax
<blumber> the way im doing it is wrong?
<Cupu> also you have to include them by the full path or add an extra path to the ***embler .. I'm not sure
<libero_> i think it should be done in a different way
<libero_> i had a link for some docs :S
<libero_> don't have it now
<blumber> you guys dont happen to have a link to a good tutorial on AS ***embler?
<Cupu> what ***embler do you use .. what linker?
<blumber> AS and gnu ld linker
<blumber> whatever comes with linux
<Cupu> I see
<Cupu> http://www.angelcode.com/dev/callconv/callconv.html
<blumber> thank you, i'll peruse that link...
<Cupu> read this .. then remember that c functions should be referenced in asm with an _ (underscore)
<Cupu> if you have printf in c .. it will be _printf here .. basicly (in nasm) you declare in your file "EXTERN _printf" so the ***embler knows you'll link this file with the one that actually contains the code for printf
<Cupu> Someone please correct me if I am wrong
<blumber> when I do an nm of a file.o it does show SYS_exit as U U i believed meant external as oppose to T
<Cupu> after that you'll have to p*** the linker some extra parameters so it finds and links your program with the lib's that actually contain code for printf and whatever you use there
<Cupu> I can't comment on that because I have no idea :)
<blumber> I have this book from wrox, it does not have much on using a header files
<Cupu> I think header files won't do it for you
<Cupu> what I mean is .. c header files are good for c .. that's all
<Cupu> a declaration like void myfunction(int param) .. will make no sense in an asm file right?
<blumber> i see
<Cupu> there are 2 steps .. see what calling conventions you have to use (how to p*** parameters, how to get return values) .. declare the functions you want to use as external (don't forget to prepend them with an _) and look out for the parameters you have to give the linker
<Cupu> ok .. that's more then 2 steps
<Cupu> blumber .. my bad .. I just read somewhere that linux C doesn't put underscore before funtion names .. sorry about that
<Cupu> In win it does.. sorry again
<blumber> its okay, am learning
<blumber> I may have mistated earlier anyways, what I wanted is to use the macros defined on those header files like SYS_exit
<Cupu> I am not familiar with those .. one second
<Cupu> I'm still not familiar with it .. haha :)
<Cupu> If it's a macro I'm not sure you can use it .. unless .. you write your own function that usess the macro in c I guess
<blumber> I use .include "/usr/include/sys/syscall.h" in file.s but it fails at the linker
<blumber> so I may not be giving ld with the correct option to find syscall.h
<Cupu> I never tried this .. so it's off the top of my head .. but syscall.h contains c definitions .. why include that in an ***embler file?
<Cupu> there is code that a c compiler understands .. but not the ***embler .. I gues
<Cupu> you say it fails at the linker step? are you able to compile your file? I mean ***emble?
<blumber> the macros on that syscall.h are the system call codes for example for write its 5
<blumber> yeah it compiles to an object code like so.. as -o file.o file.s
<blumber> and I link like so, ld -o file file.o
<blumber> and this is where it says it cant find the SYS_exit
<Cupu> I'm a little lost here ... so you file.s contains ***embly code (or inline ***embly understood by gcc) ?
<blumber> file.s is all ***embly code not inline
<Cupu> is the syscall.h file in your path? .. have you tried doing the same in c code and it worked?
<blumber> syscall.h is not in path, I tried to link like so too, ld -o file file.o -I/usr/include/sys/
<blumber> and this fails too
<blumber> the equivalent c code does work, its the simple "hello world"
<Cupu> I'm so furious I deleted my fedora core installation last week
<Cupu> try looking at how your c compiler links that code ..
<blumber> just curious, what OS do you use?
<Cupu> Windows xp right now .. I deleted fedora to make room for fifa 2006 and doom 3 :)
<blumber> hehe, you're a futbol fan eh?
<Cupu> Actually .. so and so .. fifa 2005 was nice but this one is too difficult so I spent the last hour editing savegames to give me more money .. so I'm a lousy cheater
<blumber> :)
<Cupu> anyway .. back on topic :) .. do you use and ide for your code? or did you compile and link "by hand" ,so to speak, your c program?
<blumber> link by hand, vim is my ide..lol
<Cupu> so gcc (or what you're using) finds syscall.h in your path and the other one doesn't
<Cupu> If I didn't tell you before .. i have no idea what I am talking about .. I 'm just throwing opinions here
<blumber> somehow, with the ***embly code, I have to provide the full path as in.. .include "/usr/include/sys/sysinstall.h"
<Cupu> isn't this syscall like a library so you can use a -l<syscall_lib_name> in oyur linker?
<blumber> but upon using the linker, it fails to find SYS_exit
<blumber> yeah I tried it with that -I option hoping it finds it ...somehow it still does not
<blumber> maybe I just cant use the macros defined in the header files within ***embly
<Cupu> well I would tend to think so ... but you said it compiled
<Cupu> one seccond .. let me find a syscall.h file :)
<blumber> btw, how to I check what the default path the ld linker is seeing?
<blumber> yeah it compiled, this command as -o file.o file.s generated the object file
<Cupu> I've been going at this all wrong
<Cupu> I kept thinking of functions when you said macros .. maybe it compiles because your ***embler uses similar syntax for definesx with c
<Cupu> still syscall.h has clear c definitions at the end ..
<blumber> let me check syscall.h again
<Cupu> why don't you just define SYS_exit as 1 in your asm code and that's that?
<blumber> actually its all macros, and includes the asm/unistd.h
<Cupu> maybe we looked at different files :)
<Cupu> is your syscall.h file anyway like http://cvs.opensolaris.org/source/xref/usr/src/uts/common/sys/syscall.h ?
<blumber> well Im hoping that whatever system call I used thats already defined in the header, I dont need to redefine it, also Im hoping it was a shortcut, I cant remember if 5 was a write or a read
<Cupu> open :)
<blumber> well it doesnt look exactly the same, my syscall.h includes bits/syscall.h where it looks very similar to what you posted
<Cupu> My opinion (wich I stick to) is that syscall.h is part of the GNU C library .. so it should only be used with c ... on the otherhand I have never used the ***embler you're using so I can't say
<Cupu> The quick and dirty way I would do it (wich is BAD) is create a couple of c functions wich make the system calls and use them in your ***embly program
<blumber> I was following some guide by Phillip, its one of the tutorials at linux***embly.org dated 2001 so may its dated
<Cupu> sorry you said you wanted the macros .. I was thinking of any functions again .. sorry I think I shuld shut up :)
<blumber> its okay, i thank you for enlightening me though
<Cupu> Your very welcome .. I just hoped I helped you in any way
<blumber> oh my time flies...have to pick up the kids..laters...mucho gracias
<shark2> hi. i want to make a computer controllable switch. what port would be simplest to use for this on x86?
<froztbyte> if i would to take a guess 'd say serial port
<froztbyte> but i'm not an asm programmer, i'm here to listen to these guys & learn stuff
<froztbyte> but i know serial isn't too difficult
<Robert> shark2: What exactly do you mean by "switch"?
<Robert> er
<Robert> "port"
<Robert> I guess your use of "x86" in connection to it confuses me.
<shark2> let's say that i want to turn diode (getting power of somewhere other than port) on and off
<Robert> Will you be using a PC computer, or just an x86 processor connected directly to your hardware?
<shark2> computer
<Robert> Ah. I think the parallell port is the easiest way then.
<Robert> Serial port in case the parallell port is busy.
<shark2> it's not
<Robert> Want a document about it?
<shark2> sure
<Robert> http://www.ee.washington.edu/circuit_archive/text/para-port.html
<shark2> cheers


Return to asm
or
Go to some related logs:


Copyright © 2005 www.irclogs.ws. All rights reserved. » disclaimer » contact