redirection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have the following program:

	SECTION .data		; data section
msg1:	db "Hello World -- 1",10,0 ; the string to print, 10=cr
msg:	db "Hello World",10	; the string to print, 10=cr
len:	equ $-msg		; "$" means "here"
				; len is a value, not an address

	SECTION .text		; code section
        global main		; make label available to linker 
        extern printf
main:				; standard  gcc  entry point
	
	mov	edx,len		; arg3, length of string to print
	mov	ecx,msg		; arg2, pointer to string
	mov	ebx,1		; arg1, where to write, screen
	mov	eax,4		; write command to int 80 hex
	int	0x80		; interrupt 80 hex, call kernel
	
        push    msg1
        call    printf
        add	esp, 4

        mov	ebx,0		; exit code, 0=normal
	mov	eax,1		; exit command to kernel
	int	0x80		; interrupt 80 hex, call kernel


When I assembled/linked it, I used:

nasm -f elf burtp1.asm
gcc burtp1.o

when i ran it, I got two lines of output.:

[burt@linux2 ~]$ ./a.out
Hello World
Hello World -- 1


When I redirected it, I got:

[burt@linux2 ~]$ ./a.out > foo
[burt@linux2 ~]$ cat foo
Hello World

Why was the output from using printf not redirected?
-
: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies]     [Security]     [Linux C Programming]     [Linux for Hams]     [DCCP]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux