From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <6FB2CC30-C95E-4C51-830D-FEE61A889161@kix.in> From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Content-Type: multipart/alternative; boundary=Apple-Mail-1-904761903 Mime-Version: 1.0 (Apple Message framework v915) Date: Sat, 9 Feb 2008 15:14:21 +0530 Subject: [9fans] Hello Assembly Topicbox-Message-UUID: 4d6cb78a-ead3-11e9-9d60-3106f5b1d025 --Apple-Mail-1-904761903 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi, I'm trying to make a Hello World program in assembly without depending on libc. Here's what I have so far: DATA string+0(SB)/7, $"Hello\n\z" GLOBL string+0(SB), $7 TEXT _main+0(SB), 1, $0 // first arg; $1 = stdout MOVL $1, (SP) // second arg, address of string MOVL $string+0(SB), 4(SP) // third arg, $7 = length of string MOVL $7, 8(SP) // fourth argument, -1LL (vlong offset) MOVL $-1, 12(SP) MOVL $-1, 16(SP) // use pwrite syscall MOVL $51, AX INT $64 RET The program assembles and links fine - but executing it gives me: 8.out 1183: suicide: invalid address 0x7 in sys call pc=0x104e It's probably something silly - I'll be extremely grateful if someone could point out what I'm doing wrong. Thanks! -- Anant --Apple-Mail-1-904761903 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi,

I'm trying to make a Hello = World program in assembly without depending on libc. Here's what I have = so far:

DATA string+0(SB)/7, = $"Hello\n\z"
GLOBL string+0(SB), $7

TEXT = _main+0(SB), 1, $0

// first arg; $1 =3D = stdout
MOVL $1, (SP)
// second arg, address of = string
MOVL $string+0(SB), 4(SP)
// third arg, $7 =3D = length of string
MOVL $7, 8(SP)
// fourth = argument, -1LL (vlong offset)
MOVL $-1, 12(SP)
MOVL $-1, = 16(SP)

// = use pwrite syscall
MOVL $51, AX
INT = $64
RET

The program assembles and = links fine - but executing it gives me:

8.out 1183: suicide: = invalid address 0x7 in sys call pc=3D0x104e

It's probably something = silly - I'll be extremely grateful if someone could point out what I'm = doing wrong.

Thanks!

--
Anant
= --Apple-Mail-1-904761903--