Date: Wed, 14 Nov 2001 11:59:12 +0100 From: Bernd Walter <ticso@cicely8.cicely.de> To: Khaled Daham <khaled@w-arts.com> Cc: freebsd-alpha@FreeBSD.ORG Subject: Re: Alpha assembler programming. Message-ID: <20011114115912.A42331@cicely8.cicely.de> In-Reply-To: <20011113231429.W97694-100000@fantasy.telia.net>
index | next in thread | previous in thread | raw e-mail
On Tue, Nov 13, 2001 at 11:30:20PM +0100, Khaled Daham wrote:
> Hello!
>
> I have convinced myself to do some assembly coding on alpha for some
> reason. I have almost managed to do a simple hello world involving
> write(2).
>
> main:
> lda $16, 1
> lda $17, msg
> lda $18, len
> jsr write
> lda $16, 0
> jsr exit
>
> which bombs out on
>
> 45328 a.out CALL write(0x1,0x1200107a0,0xc)
> 45328 a.out GIO fd 1 wrote 12 bytes
> "Hello World!"
> 45328 a.out RET write 12/0xc
> 45328 a.out PSIG SIGSEGV SIG_DFL
>
> I am note sure why I get the SIGSEGV, anyone ?
>
> Another thing I noted in /usr/src/sys/alpha/alpha/support.s
> is the line
>
> lda a0, longjmp_botchmsg
>
> where longjmp_botchmsg is a string just like my
> lda $16, msg
> ( $16 == a0 ) but I cannot get gcc to compile if I use
> lda a0, msg
> gcc returns "Error: inappropriate arguments for opcode `lda'"
> I cannot really see why it does not accept it, except that in the
> alpha assembler guide's I have seen a0-a5 is used for passing integers,
> but howcome the mapping between $16-$21 to a0-a5.
>
> Does anyone know a good site with some alpha assembly examples using C
> calling convention ?
>
> 680x0 was alot easier :)
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 */
--
B.Walter COSMO-Project http://www.cosmo-project.de
ticso@cicely.de Usergroup info@cosmo-project.de
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011114115912.A42331>
