linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* jump_code
@ 2002-09-06 17:14 ssams
  2002-09-06 19:59 ` jump_code Maciej Hrebien
  0 siblings, 1 reply; 2+ messages in thread
From: ssams @ 2002-09-06 17:14 UTC (permalink / raw)
  To: linux-assembly

I build this code , iget output but i little bug ithink.
i hope some body be correct it..

.data
 msg1: .ascii "Mencetak Saya\n"
msg2: .ascii "\nKok saya dilompati sih\n"
msg2_len: .long .-msg2
msg3: .ascii "Hai ini pesen ketiga "
msg3_len: .long .-msg3

.text
	.globl _start
_start:
	mov $4,%eax
	mov $1,%ebx
	mov $msg1,%ecx
	mov $14,%edx
	int $0x80

	jmp pesan3
pesan2:
	mov $4,%eax
	mov $1,%ebx
	mov $msg2,%ecx
	sub $24,%edx
	int $0x80

	mov $1,%eax
	xor %edx,%edx
	xor %ecx,%ecx
	int $0x80
pesan3:
	mov $3,%ecx
   ulang:
	  push %ecx

	mov $4,%eax
	mov $1,%ebx
	mov $msg3,%ecx
	sub $21,%edx
	int $0x80
	pop %ecx
	dec %ecx
	jnz ulang
	jmp pesan2

Output
	Mencetak Saya
	Hai ini pesen ketiga
	Hai ini pesen ketiga
	Hai ini pesen ketiga
	Kok saya dilompati sih
	Hai ini pesen ketiga

my questio is ..
why the third message is printing for one again in the end
of output
althought no instruction point it..?
---------------------  Yang Mudah dan Menghibur ----------------------------

 

Hosting menjadi mudah dan murah hanya di PlasaCom. Klik http://idc.plasa.com

F1 Mania!! Ikuti F1 Game di Obelix Game Corner di http://www.plasa.com/infotel/f1.html

 

---------------------------------------------------------------------------------------


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

* Re: jump_code
  2002-09-06 17:14 jump_code ssams
@ 2002-09-06 19:59 ` Maciej Hrebien
  0 siblings, 0 replies; 2+ messages in thread
From: Maciej Hrebien @ 2002-09-06 19:59 UTC (permalink / raw)
  To: linux-assembly

You have wrong value in edx register when calling kernel's write
routine!

> I build this code , iget output but i little bug ithink.
> i hope some body be correct it..
> 
> .data
>  msg1: .ascii "Mencetak Saya\n"
> msg2: .ascii "\nKok saya dilompati sih\n"
> msg2_len: .long .-msg2
> msg3: .ascii "Hai ini pesen ketiga "
> msg3_len: .long .-msg3
> 
> .text
>         .globl _start
> _start:
>         mov $4,%eax
>         mov $1,%ebx
>         mov $msg1,%ecx
>         mov $14,%edx
>         int $0x80
> 
>         jmp pesan3
> pesan2:
>         mov $4,%eax
>         mov $1,%ebx
>         mov $msg2,%ecx
>         sub $24,%edx

Change "sub $24,%edx" to "mov msg2_len,%edx".

>         int $0x80
> 
>         mov $1,%eax
>         xor %edx,%edx
>         xor %ecx,%ecx
>         int $0x80
> pesan3:
>         mov $3,%ecx
>    ulang:
>           push %ecx
> 
>         mov $4,%eax
>         mov $1,%ebx
>         mov $msg3,%ecx
>         sub $21,%edx

Change "sub $21,%edx" to "mov msg3_len,%edx".

>         int $0x80
>         pop %ecx
>         dec %ecx
>         jnz ulang
>         jmp pesan2
> 
> Output
>         Mencetak Saya
>         Hai ini pesen ketiga
>         Hai ini pesen ketiga
>         Hai ini pesen ketiga
>         Kok saya dilompati sih
>         Hai ini pesen ketiga
> 
> my questio is ..
> why the third message is printing for one again in the end
> of output
> althought no instruction point it..?

Regards,

-- 
Maciej Hrebien


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

end of thread, other threads:[~2002-09-06 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-06 17:14 jump_code ssams
2002-09-06 19:59 ` jump_code Maciej Hrebien

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