[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-alpha
Subject:    Re: Alpha assembler programming.
From:       Khaled Daham <khaled () w-arts ! com>
Date:       2001-11-14 12:06:39
[Download RAW message or body]

On Wed, 14 Nov 2001, Bernd Walter wrote:

> I did this "Hello World!" a long time ago.
> IIRC it was based on the hello world in the FreeBSD programmers guide
> for i386.
>
> cc -c -g -x assembler-with-cpp -ffixed-8 hello-world2.s
> ld -o hello-world2 hello-world2.o
>
>
> #include <machine/asm.h>
>         .text
>         .globl _start                           /* must be declared for linker (ld) */
>
> textseq:
> msg:    .ascii          "Hello, world!\n"       /* our dear string */
>         .equ            t12diff, _start-textseq
>         .equ            len, . - msg            /* length of our dear string */
>
> _start:                                         /* tell linker entry point */
>         subq            t12,t12diff,gp          /* get address of .text */
>         addq            zero,1,a0               /* file descriptor (stdout) */
>         addq            gp,textseq-msg,a1       /* message to write */
>         addq            zero,len,a2             /* message length */
>         addq            zero,0x4,v0             /* system call number (sys_write) */
>         call_pal        PAL_OSF1_callsys        /* call kernel - errors returned in a3 */
>         addq            zero,0x0,v0             /* system call number (sys_exit) */
>         call_pal        PAL_OSF1_callsys        /* exit */

I got it all working by including machine/asm.h and using CALL(write)
instead of just jsr write ( which resulted in a SIGSEGV ).

/Khaled Daham, w.arts
Mail:    khaled@w-arts.com
Cell:    +46-70-6785492
FreeBSD: The Power to Serve! http://www.FreeBSD.org/

This isn't rocket science -- but it _is_ computer science.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic