linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* problem with printchar
@ 2002-04-24  7:18 ssams
  2002-04-24  7:26 ` Scott Lanning
  2002-04-24  7:27 ` Rudolf Marek
  0 siblings, 2 replies; 3+ messages in thread
From: ssams @ 2002-04-24  7:18 UTC (permalink / raw)
  To: linux-assembly

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..?

 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with printchar
  2002-04-24  7:18 problem with printchar ssams
@ 2002-04-24  7:26 ` Scott Lanning
  2002-04-24  7:27 ` Rudolf Marek
  1 sibling, 0 replies; 3+ messages in thread
From: Scott Lanning @ 2002-04-24  7:26 UTC (permalink / raw)
  To: ssams; +Cc: linux-assembly

On Wed, 24 Apr 2002, ssams wrote:
>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.

>   movl $1,%edx
>   int   $0x80
>   xorl  %eax,%eax
>   movl  $1,%eax

ITYM 'incl %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..?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with printchar
  2002-04-24  7:18 problem with printchar ssams
  2002-04-24  7:26 ` Scott Lanning
@ 2002-04-24  7:27 ` Rudolf Marek
  1 sibling, 0 replies; 3+ messages in thread
From: Rudolf Marek @ 2002-04-24  7:27 UTC (permalink / raw)
  To: ssams; +Cc: linux-assembly


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 error
0x61, 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"

.....

DATASEG
my_char DB 'b' 

Happy assembling,
    
      Regards

		Rudolf


On Wed, 24 Apr 2002, ssams wrote:

> Date: Wed, 24 Apr 2002 14:18:57 +0700
> From: ssams <ssams@telkom.net>
> To: linux-assembly@vger.kernel.org
> Subject: 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..?
> 
>  
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-24  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-24  7:18 problem with printchar ssams
2002-04-24  7:26 ` Scott Lanning
2002-04-24  7:27 ` Rudolf Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).