Skip to contentSkip to conversation

'defines.h' file not found

DISCUSSION Paul Irofti 1 participant 3 messages Jun 22, 2005 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

ofcourse, i need a header that has define directives as:

;output control
%define NL 10
%define STDIN 0
%define STDOUT 1
...
;syscalls
%define SYS_EXIT 1
%define SYS_READ 3
%define SYS_WRITE 4
%define SYS_IOCTL 54

....

and a sample code that can be found at www.linuxassembly.org is:

.include "defines.h"
.data
hello:
.string "hello world\n"

.globl main
main:

	movl	$SYS_write,%eax
	movl	$STDOUT,%ebx
	movl	$hello,%ecx
	movl	$12,%edx
	int	$0x80

	ret

that's about it, i need this for an easier code writting. i can use interrupts and numbers but a 'defines.h' would be nicer. thanks.

#1 lore raw
Quoted 34 lines · Paul Irofti

ofcourse, i need a header that has define directives as:

;output control
%define NL 10
%define STDIN 0
%define STDOUT 1
...
;syscalls
%define SYS_EXIT 1
%define SYS_READ 3
%define SYS_WRITE 4
%define SYS_IOCTL 54

....

and a sample code that can be found at www.linuxassembly.org is:

.include "defines.h"
.data
hello:
.string "hello world\n"

.globl main
main:

    movl    $SYS_write,%eax
    movl    $STDOUT,%ebx
    movl    $hello,%ecx
    movl    $12,%edx
    int    $0x80

    ret
Quoted 3 lines

that's about it, i need this for an easier code writting. i can use interrupts and numbers but a 'defines.h' would be nicer. thanks.

oh yeah, and the header snapshot that i gave is written in NASM syntax which is Intel syntax similar. i need an AT&T syntax one...

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 20 lines · Robert G.Plantz
Quoted 1 line · Paul Irofti

Paul Irofti wrote:

The AT&T equivalent of this file:

Quoted 11 lines
Quoted 11 lines

;output control
%define NL 10
%define STDIN 0
%define STDOUT 1
...
;syscalls
%define SYS_EXIT 1
%define SYS_READ 3
%define SYS_WRITE 4
%define SYS_IOCTL 54

is:

Quoted 12 lines
# output control
NL = 10
STDIN = 0
STDOUT = 1
...
# syscalls
SYS_EXIT = 1
SYS_READ = 3
SYS_WRITE = 4
SYS_IOCTL = 54

i knew that, it only came in handly in a copy-paste kindda way. thanks.

Quoted 31 lines
Quoted 7 lines
Quoted 7 lines

and a sample code that can be found at www.linuxassembly.org is:

.include "defines.h"
.data
hello:
.string "hello world\n"

Also, you'll have a problem here unless you use the
.text
directive so the following code goes into the text segment.

Quoted 8 lines
Quoted 7 lines

.globl main
main:

    movl    $SYS_write,%eax
    movl    $STDOUT,%ebx
    movl    $hello,%ecx
    movl    $12,%edx
    int    $0x80

Your shell will be happier if you return zero:

       movl   $0, $eax
Quoted 6 lines
Quoted 6 lines

ret

that's about it, i need this for an easier code writting. i can use interrupts and numbers but a 'defines.h' would be nicer. thanks.

Quoted 6 lines

I use the assembler to assemble this

     as --gstabs helloWorld.s -o helloWorld.o

and then gcc to link/load it
gcc helloworld.o -o helloworld

thanks for the info, it seems simpler this way for i used a gcc-ld-wc session for making the executable.

Quoted 6 lines

If you just use ld, you need to explicitly specify the system libraries. But gcc recognizes that helloworld.o is an object file and goes directly to the ld phase and automatically links all the necessary libraries.

You can do something like
gcc helloworld.o -o helloworld -Wl,-M
to see the libraries.

Quoted 10 lines

--Bob

-----------------------------------------------------
Mac on Intel:
Gotta stick to your principles -- until they get in your way.

Bob Plantz
[email protected]

the sample helloWorld code was meant to see one of the code snipets where i found the defines.h included.

it's not a bigdeal, i wanted the general defines.h file because i think it contains alot of goodies that i'd like to take a look at, and use in future apps.

thanks again Bob!