Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Sep 2011 17:43:14 -0400
From:      Nate Dobbs <misconfiguration@gmail.com>
To:        Colin Barnabas <axel@ucs.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Hello World assembly language
Message-ID:  <CAGjvUo7F2kZ69sQW-NVfK8zdTM3mMqRS=LVY-8By-joMFXRdbw@mail.gmail.com>
In-Reply-To: <20110928202647.GA8284@hs1.VERBENA>
References:  <20110928202647.GA8284@hs1.VERBENA>

next in thread | previous in thread | raw e-mail | index | archive | help
Alter the stuff in red, the message will print irrespective of your
`message' length.

Change 13 to 14.



section .data

message:
db      'hello, world!', 0x0a

message_len equ $-message


section .text

global _start
_start:
mov     rax, 4
mov     rdi, 1
mov     rsi, message
mov     rdx, *message_len*
syscall

mov     rax, 1
xor     rdi, rdi
syscall



On Wed, Sep 28, 2011 at 4:26 PM, Colin Barnabas <axel@ucs.com> wrote:

> I found a hello world program written in assembly language which
> runs on my amd64 8.2 stable box. However, I can not seem to get
> it to print a new line. Any suggestions on how to print a line
> feed in assembly?
>
> Here is the code-
>
> section .data
>
> message:
> db      'hello, world!', 0x0a
>
> section .text
>
> global _start
> _start:
> mov     rax, 4
> mov     rdi, 1
> mov     rsi, message
> mov     rdx, 13
> syscall
>
> mov     rax, 1
> xor     rdi, rdi
> syscall
>
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>



-- 
Cheers,

Nate Dobbs RHCE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGjvUo7F2kZ69sQW-NVfK8zdTM3mMqRS=LVY-8By-joMFXRdbw>