9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: Re: [9fans] 5l bug
Date: Mon, 29 Apr 2013 21:06:01 +0200	[thread overview]
Message-ID: <4ef8328033f37e9bcc5980b3eebb9636@rei2.9hal> (raw)
In-Reply-To: <55d863d12c769379ce2cbf372d2f5160@coraid.com>

term% cat foo.c
#include <u.h>
#include <libc.h>

void
main(void)
{
	int i, j, k;

	i = 1;
	j = 0;
	k = j <= 0 ? 1 : 2/i;
	print("%d\n", k);
	exits(nil);
}

term% 5c -S foo.c
	TEXT	main+0(SB),0,$20
	MOVW	$1,R1
	MOVW	$0,R2
	CMP	$0,R2,
	MOVW.LE	R1,R3
	BLE	,3(PC)
	MOVW	$2,R3
	DIV	R1,R3,R3
	MOVW	$.string<>+0(SB),R0
	MOVW	R3,8(R13)
	BL	,print+0(SB)
	MOVW	$0,R0
	BL	,exits+0(SB)
	RET	,
	DATA	.string<>+0(SB)/8,$"%d\n\z\z\z\z\z"
	GLOBL	.string<>+0(SB),$8
	END	,

5.out:arm plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/arm
acid: asm(main)
main 0x00001020	MOVW.W	R14,#-0x18(R13)
main+0x4 0x00001024	MOVW	$#0x1,R1
main+0x8 0x00001028	MOVW	$#0x0,R2
main+0xc 0x0000102c	CMP.S	$#0x0,R2
main+0x10 0x00001030	MOVW.LE	R1,R3
main+0x14 0x00001034	B.LE	main+0x34
main+0x18 0x00001038	MOVW	$#0x2,R3
main+0x1c 0x0000103c	SUB	$#0x8,R13,R13
main+0x20 0x00001040	MOVW	R1,#0x4(R13)
main+0x24 0x00001044	MOVW	R3,R11
main+0x28 0x00001048	BL	_div
main+0x2c 0x0000104c	MOVW	R11,R3
main+0x30 0x00001050	ADD	$#0x8,R13,R13
main+0x34 0x00001054	MOVW	$#0x7084,R0
main+0x38 0x00001058	MOVW	R3,#0x8(R13)
main+0x3c 0x0000105c	BL	print
main+0x40 0x00001060	MOVW	$#0x0,R0
main+0x44 0x00001064	BL	exits
main+0x48 0x00001068	RET.P	#0x18(R13)
_main 0x0000106c	MOVW.W	R14,#-0x54(R13)
acid:

--
cinap



  reply	other threads:[~2013-04-29 19:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29  5:54 Paul Patience
2013-04-29 18:53 ` cinap_lenrek
2013-04-29 18:57   ` erik quanstrom
2013-04-29 19:06     ` cinap_lenrek [this message]
2013-04-29 19:08       ` erik quanstrom
2013-04-29 19:34   ` Richard Miller
2013-04-30 10:15     ` kernel panic
2013-04-30  9:07 ` zephyr.pellerin
2013-04-30 10:58   ` kernel panic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ef8328033f37e9bcc5980b3eebb9636@rei2.9hal \
    --to=cinap_lenrek@gmx.de \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).