* code_for_integer_printing
@ 2002-09-06 17:06 ssams
2002-09-06 18:50 ` code_for_integer_printing lx
0 siblings, 1 reply; 3+ messages in thread
From: ssams @ 2002-09-06 17:06 UTC (permalink / raw)
To: linux-assembly
i want to ask about a little code bellow...
i build this code for print some integer value..
i think is easy for doing but after i do some fungtion
below
i did not find ionteger output.
so how is function to do it..?
this is my code, i hope you help me..?
thank's before..
.macro cetak # macro for printing
xor %eax,%eax
mov $1,%ebx
mov $4,%eax
int $0x80
.endm
.data
promt1:
.byte 65
.text
.globl _start
_start:
mov $promt1,%eax #eax will divided
mov $10,%ebx #ebx is divident
xor %ecx,%ecx
ulangi:
xor %edx,%edx
div %ebx #eax : ebx
push %edx # save remainder
inc %ecx
cmp $0 ,%eax
jne ulangi
mov $3,%ecx
ulang_cetak:
push %ecx
pop %edx #take point
add $0 ,%dl #convert to ascii
mov %edx,%ecx #for printing
mov $1,%edx
cetak #print
pop %ecx
dec %ecx
jnz ulang_cetak
movl $1,%eax #exit
movl $0,%ebx
int $0x80
--------------------- 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] 3+ messages in thread
* Re: code_for_integer_printing
2002-09-06 17:06 code_for_integer_printing ssams
@ 2002-09-06 18:50 ` lx
[not found] ` <web-49325170@m1.plasa.com>
0 siblings, 1 reply; 3+ messages in thread
From: lx @ 2002-09-06 18:50 UTC (permalink / raw)
To: ssams; +Cc: linux-assembly
On Sat, 07 Sep 2002 00:06:03 +0700
"ssams" <ssams@telkom.net> wrote:
[...]
> ulang_cetak:
> push %ecx
> pop %edx #take point
> add $0 ,%dl #convert to ascii
add $'0,dl
or
add $48,dl
> mov %edx,%ecx #for printing
> mov $1,%edx
> cetak #print
> pop %ecx
> dec %ecx
> jnz ulang_cetak
>
regards,
hp
--
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de
software patents http://petition.eurolinux.org/pr/pr17.html
-
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
* Re: code_for_integer_printing
[not found] ` <web-49325170@m1.plasa.com>
@ 2002-09-19 20:07 ` lx
0 siblings, 0 replies; 3+ messages in thread
From: lx @ 2002-09-19 20:07 UTC (permalink / raw)
To: ssams; +Cc: linux-assembly
On Mon, 16 Sep 2002 12:31:26 +0700
"ssams" <ssams@telkom.net> wrote:
i do not re-write the code for you:) but, i hope that my annotations
will help. i'd suggest you try getting through my syscalls intro at
http://www.lxhp.in-berlin.de/lhpsyscal.html
but, those syscalls aren't all that simple; try verifying what happens
by following the rsp. source files. could aid a lot to understanding.
if you find it difficult to connect to the syscalls pages i could send
you the complete colletion as an archive, by email or, you might get
it yourself by
http://www.lxhp.in-berlin.de/lhpsysc-html.tar.bz2
best,
hp
> .macro cetak # macro for printing
> xor %eax,%eax
> mov $1,%ebx
> mov $4,%eax
> int $0x80
> .endm
essential: syscalls read/write (and many others) always use
an address of where the data are which you want to operate on
and a count of bytes of the length of that sequence of data.
which for 'read' and 'write' means that with ECX you pass the
#address# of your text and, with EDX the number of bytes to
receive or send.
so, for instance, you could modify the macro to
.macro cetak # all regs but EAX, EBX preserved
pushl %ecx # print the register value itself,
movl %esp,%ecx # this is your temporary buffer address
movl $1,%ebx # Linux "stdout"
movl $4,%eax # sys_write
int $0x80 # execute...
cmpl $0xffff0001,%eax # optional: NC in EFLAGS if EAX error code
popl %ecx # remove temp buffer = restore stack, and restore ECX
.endm
# or, restore stack, e.g. w. "addl $4,%esp" which modifies EFLAGS
# or, preserve error flags w. "leal 4(%esp),%esp"
# note that the above error test is valid for #all# syscalls.
btw, you could save typing those "%"s (they are often required if AS used
for the GCC backend, though) with:
.att_syntax no_prefix
at top of your assembly text.
> .data
> promt1:
> .byte 65
> .text
> .globl _start
> _start:
> mov $promt1,%eax #eax will divided
> mov $10,%ebx #ebx is divident
> xor %ecx,%ecx
>
> ulangi:
> xor %edx,%edx
> div %ebx #eax : ebx
> push %edx # save remainder
> inc %ecx
> cmp $0 ,%eax
> jne ulangi
>
> mov $3,%ecx
> ulang_cetak:
> push %ecx
> pop %edx #take point
> add $48 ,%dl #convert to ascii i've try add with $'0' to
> #but it same no output with it
> mov %edx,%ecx #for printing
> mov $1,%edx
> cetak #print
> pop %ecx
> dec %ecx
> jnz ulang_cetak
>
> movl $1,%eax #exit
> movl $0,%ebx
> int $0x80
>
> regards,
> ssams
>
> =========================================================================
> Khusus Pelanggan Telepon DIVRE 2, Tekan 166 untuk mendengarkan pesan Anda.
> =========================================================================
--
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-19 20:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-06 17:06 code_for_integer_printing ssams
2002-09-06 18:50 ` code_for_integer_printing lx
[not found] ` <web-49325170@m1.plasa.com>
2002-09-19 20:07 ` code_for_integer_printing lx
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.