9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Hello Assembly
@ 2008-02-09  9:44 Anant Narayanan
  2008-02-09  9:58 ` Charles Forsyth
  2008-02-09 14:37 ` Eris Discordia
  0 siblings, 2 replies; 37+ messages in thread
From: Anant Narayanan @ 2008-02-09  9:44 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2181 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread
[parent not found: <ead6208b996760a9eb2eeccb8c431b12@plan9.bell-labs.com>]

end of thread, other threads:[~2008-02-11 19:49 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-09  9:44 [9fans] Hello Assembly Anant Narayanan
2008-02-09  9:58 ` Charles Forsyth
2008-02-09 10:09   ` Anant Narayanan
2008-02-09 10:15     ` erik quanstrom
2008-02-09 10:32   ` Charles Forsyth
2008-02-09 10:34     ` erik quanstrom
2008-02-09 10:36       ` erik quanstrom
2008-02-09 20:15       ` Anant Narayanan
2008-02-09 20:17     ` Anant Narayanan
2008-02-09 14:37 ` Eris Discordia
2008-02-09 16:17   ` Brantley Coile
2008-02-09 16:27     ` ron minnich
2008-02-09 16:38       ` erik quanstrom
2008-02-09 16:51       ` Brantley Coile
2008-02-10  8:04       ` maht
2008-02-11 16:39       ` john
2008-02-09 17:32     ` Charles Forsyth
2008-02-10  8:18       ` Eris Discordia
2008-02-10  8:56         ` Martin Neubauer
2008-02-10 14:38           ` Pietro Gagliardi
2008-02-10 16:55             ` Anant Narayanan
2008-02-10 18:01               ` erik quanstrom
2008-02-10 18:11                 ` Pietro Gagliardi
2008-02-11  2:36               ` Adrian Tritschler
2008-02-11  2:36                 ` Pietro Gagliardi
2008-02-11  2:39                 ` Pietro Gagliardi
2008-02-11  6:26                   ` maht
2008-02-11  2:40                 ` Pietro Gagliardi
2008-02-11  2:55                   ` erik quanstrom
     [not found] <ead6208b996760a9eb2eeccb8c431b12@plan9.bell-labs.com>
2008-02-09 21:15 ` Anant Narayanan
2008-02-09 21:27   ` Pietro Gagliardi
2008-02-10  8:30     ` Anant Narayanan
2008-02-11 16:36   ` john
2008-02-11 16:43     ` erik quanstrom
2008-02-11 16:45       ` john
2008-02-11 19:41       ` Jon Snader
2008-02-11 19:49         ` Pietro Gagliardi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).