problem with printchar
i have this code
.globl mulai
mulai:
movl $4,%eax
movl $1,%ebx
movl $'a',%ecx
movl $1,%edx
int $0x80 xorl %eax,%eax movl $1,%eax xorl %ebx,%ebx int $0x80
then i compile with
as program1.s -o program1.o
ld program1.o -o program1
by this code i want print one char but there is no output. can anybody help me why..?
Quoted 6 lines · ssams
i have this code
.globl mulai
mulai:
movl $4,%eax
movl $1,%ebx
movl $'a',%ecx
Wow, is that valid?
Anyway, %ecx should not be the value of 'a'
but rather a pointer to a buffer.
Quoted 4 lines
movl $1,%edx
int $0x80 xorl %eax,%eax movl $1,%eax
ITYM 'incl %eax'.
Quoted 8 lines
xorl %ebx,%ebx
int $0x80
then i compile with
as program1.s -o program1.o
ld program1.o -o program1by this code i want print one char but there is no output. can anybody help me why..?
Yes...
Because in ecx should be address (pointer) to char. Kernel silently ignores bad address so there is no output. You can use strace utility to watch whats going on
$strace ./program1
execve("./program1", ["./program1"], [/* 30 vars */]) = 0 write(1, ptrace: un: Input/output error0x61, 1) = -1 EFAULT (Bad
addreexit(0) = ?
uh... the solution: you have to declare somewhere in memory a byte where you will store that char.
This is not "as" syntax but hope you will get an idea
mov ecx,my_char
mov [ecx],'a' ;you can cachnge it "on-line"
.....
DATASEGmy_char DB 'b'
Happy assembling,
Regards
Rudolf
Quoted 32 lines · ssams
Date: Wed, 24 Apr 2002 14:18:57 +0700
From: ssams <[email protected]>
To: [email protected]
Subject: problem with printchari have this code
.globl mulai
mulai:movl $4,%eax movl $1,%ebx movl $'a',%ecx movl $1,%edx int $0x80 xorl %eax,%eax movl $1,%eax xorl %ebx,%ebx int $0x80then i compile with
as program1.s -o program1.o
ld program1.o -o program1by this code i want print one char but there is no output. can anybody help me why..?
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html