Archelon Ischyros Archelon Inc.

Programming tools for your new processor

Compiler Generated Tree Sort assembly code

; Archelon URCC C 3.17 2003/08/11 MCSYS = ucode
; - tree.c at Wed Aug 13 13:14:07 2003
; struct node {
;         struct node *left,*right;
;         int val;
;     };
; struct node *tree;
; int    sortlist[ 5000 +1],
;     biggest, littlest,
;     top;
;     void
;     tInitarr()
	.segment tree_code,memtype=0,locinc=1,rom
	.global _tInitarr
_tInitarr:
	addi_l	R31,0x4,R31
	strri_l	R30,R31,-0x4
	mov_l	R31,R30
	addi_l	R31,0x4,R31
	strri_l	R0,R30,0x0
; ENTRY
; i in reg  size 2
; temp in reg  size 2
;     {
;         int i, temp;
;         Initrand();
	call	_Initrand
;         biggest = 0; littlest = 0;
	movi_w	0x0,R24
	stizi_w	0x0,_biggest
	stizi_w	0x0,_littlest
;         for ( i = 1; i <= 5000 ; i++ )
	movi_w	0x1,R0
tInitarr_L1:
;         {
;             temp = Rand();
	call	_Rand
;             sortlist[i] = temp - (temp/100000)*100000 - 50000;
	cvtswl	R24,R24
	ldzi_l	__lcons1,R25
	div_l	R24,R25,R25
	ldzi_l	__lcons1,R26
	mul_l	R25,R26,R25
	sub_l	R24,R25,R25
	ldzi_l	__lcons2,R24
	sub_l	R25,R24,R24
	cvtlw	R24,R25
	cvtswl	R0,R24
	llsi_l	R24,0x1,R24
	ldzi_l	__pcons3,R26
	add_l	R24,R26,R24
	strri_w	R25,R24,0x0
;             if ( sortlist[i] > biggest )
	ldzi_w	_biggest,R24
	cmp_w	R25,R24
	ble	tInitarr_L2
;                 biggest = sortlist[i];
	strzi_w	R25,_biggest
	br	tInitarr_L3
tInitarr_L2:
;             else if ( sortlist[i] < littlest )
	ldzi_w	_littlest,R24
	cmp_w	R25,R24
	bge	tInitarr_L4
;                 littlest = sortlist[i];
	strzi_w	R25,_littlest
tInitarr_L4:
tInitarr_L3:
	addi_w	R0,0x1,R0
	cmpi_w	R0,0x1388
	ble	tInitarr_L1
;         };
; EXIT
; .temp0 at stkloc 0 (0x0) size 4
	ldri_l	R30,0x0,R0
	mov_l	R30,R31
	ldri_l	R31,-0x4,R30
	subi_l	R31,0x4,R31
	ret	
;     }
;         void
;         CreateNode (t,n) struct node **t; int n;
	.global _CreateNode
_CreateNode:
	addi_l	R31,0x4,R31
	strri_l	R30,R31,-0x4
	mov_l	R31,R30
	addi_l	R31,0x8,R31
	strri_l	R0,R30,0x0
	strri_l	R1,R30,0x4
; ENTRY
	mov_l	R24,R1
; t at argloc 0 (0x0) in reg  size 4
	mov_w	R25,R0
; n at argloc 0 (0x0) in reg  size 2
;         {
;             *t = (struct node *)malloc(sizeof(struct node));
	movi_l	0xa,R24
	call	_malloc
	cvtuwl	R24,R24
	strri_l	R24,R1,0x0
;             (*t) ->left = 0 ; (*t) ->right = 0 ;
	movi_l	0x0,R25
	stiri_l	0x0,R24,0x0
	ldri_l	R1,0x0,R24
	stiri_l	0x0,R24,0x4
;             (*t) ->val = n;
	ldri_l	R1,0x0,R24
	strri_w	R0,R24,0x8
; EXIT
; .temp1 at stkloc 0 (0x0) size 8
	ldri_l	R30,0x0,R0
	ldri_l	R30,0x4,R1
	mov_l	R30,R31
	ldri_l	R31,-0x4,R30
	subi_l	R31,0x4,R31
	ret	
;         }
;     void
;     Insert(n, t) int n; struct node *t;
	.global _Insert
_Insert:
	addi_l	R31,0x4,R31
	strri_l	R30,R31,-0x4
	mov_l	R31,R30
; ENTRY
	mov_w	R24,R26
; n at argloc 0 (0x0) in reg  size 2
; t at argloc 0 (0x0) in reg  size 4
;     {
;            if ( n > t->val )
	ldri_w	R25,0x8,R24
	cmp_w	R24,R26
	bge	Insert_L1
;                 if ( t->left == 0  ) CreateNode(&t->left,n);
	ldri_l	R25,0x0,R24
	cmpui_l	R24,0x0
	bne	Insert_L2
	mov_l	R25,R24
	mov_w	R26,R25
	call	_CreateNode
	br	Insert_L4
Insert_L2:
;                 else Insert(n,t->left);
	mov_w	R26,R24
	ldri_l	R25,0x0,R25
	call	_Insert
Insert_L3:
	br	Insert_LL1
Insert_L1:
;            else if ( n < t->val )
	ldri_w	R25,0x8,R24
	cmp_w	R24,R26
	ble	Insert_L5
;                 if ( t->right == 0  ) CreateNode(&t->right,n);
	ldri_l	R25,0x4,R24
	cmpui_l	R24,0x0
	bne	Insert_L6
	addi_l	R25,0x4,R24
	mov_w	R26,R25
	call	_CreateNode
	br	Insert_LL1
Insert_L6:
;                 else Insert(n,t->right);
	mov_w	R26,R24
	ldri_l	R25,0x4,R25
	call	_Insert
Insert_L7:
Insert_L5:
Insert_L4:
Insert_LL1:
; EXIT
	mov_l	R30,R31
	ldri_l	R31,-0x4,R30
	subi_l	R31,0x4,R31
	ret	
;     }
;     int Checktree(p) struct node *p;
	.global _Checktree
_Checktree:
	addi_l	R31,0x4,R31
	strri_l	R30,R31,-0x4
	mov_l	R31,R30
	addi_l	R31,0x8,R31
	strri_l	R0,R30,0x0
	strri_l	R1,R30,0x4
; ENTRY
	mov_l	R24,R1
; p at argloc 0 (0x0) in reg  size 4
; result in reg  size 2
;     {
;     int result;
;         result = 1 ;
	movi_w	0x1,R0
;         if ( p->left != 0  )
	ldri_l	R1,0x0,R24
	movi_l	0x0,R25
	cmpui_l	R24,0x0
	beq	Checktree_L1
;            if ( p->left->val <= p->val )
	ldri_w	R1,0x8,R25
	ldri_w	R24,0x8,R26
	cmp_w	R26,R25
	bgt	Checktree_L2
;                result= 0 ;
	movi_w	0x0,R0
	br	Checktree_L3
Checktree_L2:
;            else
;                result = Checktree(p->left) && result;
	call	_Checktree
	cmpi_w	R24,0x0
	beq	Checktree_LL3
	cmpi_w	R0,0x0
	bne	Checktree_LL1
Checktree_LL3:
	movi_w	0x0,R0
	br	Checktree_LL2
Checktree_LL1:
	movi_w	0x1,R0
Checktree_LL2:
Checktree_L3:
Checktree_L1:
;         if ( p->right != 0  )
	ldri_l	R1,0x4,R26
	cmpui_l	R26,0x0
	mov_l	R0,R24
	beq	Checktree_L4
;            if ( p->right->val >= p->val )
	ldri_w	R1,0x8,R25
	ldri_w	R26,0x8,R24
	cmp_w	R24,R25
	blt	Checktree_L5
;                result = 0 ;
	movi_w	0x0,R24
	br	Checktree_L6
Checktree_L5:
;            else
;                result = Checktree(p->right) && result;
	mov_l	R26,R24
	call	_Checktree
	cmpi_w	R24,0x0
	beq	Checktree_LL6
	cmpi_w	R0,0x0
	bne	Checktree_LL4
Checktree_LL6:
	movi_w	0x0,R24
	br	Checktree_LL5
Checktree_LL4:
	movi_w	0x1,R24
Checktree_LL5:
Checktree_L6:
Checktree_L4:
;         return( result);
; EXIT
; .temp2 at stkloc 0 (0x0) size 8
	ldri_l	R30,0x0,R0
	ldri_l	R30,0x4,R1
	mov_l	R30,R31
	ldri_l	R31,-0x4,R30
	subi_l	R31,0x4,R31
	ret	
;     }  
; void
; Trees()
	.global _Trees
_Trees:
	addi_l	R31,0x4,R31
	strri_l	R30,R31,-0x4
	mov_l	R31,R30
	addi_l	R31,0x4,R31
	strri_l	R0,R30,0x0
; ENTRY
; i in reg  size 2
; {
;     int i;
;     tInitarr();
	call	_tInitarr
;     tree = (struct node *)malloc(sizeof(struct node));
	movi_l	0xa,R24
	call	_malloc
	cvtuwl	R24,R24
	strzi_l	R24,_tree
;     tree->left = 0 ; tree->right= 0 ; tree->val=sortlist[1];
	movi_l	0x0,R25
	stiri_l	0x0,R24,0x0
	stiri_l	0x0,R24,0x4
	ldzi_w	_sortlist+2,R25
	strri_w	R25,R24,0x8
;     for ( i = 2; i <= 5000 ; i++ )
	movi_w	0x2,R0
Trees_L1:
;         Insert(sortlist[i],tree);
	movi_w	0x1,R24
	cvtswl	R0,R24
	llsi_l	R24,0x1,R25
	ldzi_l	__pcons3,R24
	add_l	R25,R24,R24
	ldri_w	R24,0x0,R24
	ldzi_l	_tree,R25
	call	_Insert
	addi_w	R0,0x1,R0
	cmpi_w	R0,0x1388
	ble	Trees_L1
;     if ( ! Checktree(tree) ) printf ( " Error in Tree.\n");
	ldzi_l	_tree,R24
	call	_Checktree
	cmpi_w	R24,0x0
	bne	Trees_L2
	ldzi_l	__pcons4,R24
	call	_printf
Trees_L2:
; EXIT
; .temp3 at stkloc 0 (0x0) size 4
	ldri_l	R30,0x0,R0
	mov_l	R30,R31
	ldri_l	R31,-0x4,R30
	subi_l	R31,0x4,R31
	ret	
; }
	.segment tree_bss,memtype=1,locinc=1,wordsize=8
tree_V6:
	.global _sortlist
_sortlist:
	.bss 10002
; sortlist size 10002
	.global _biggest
_biggest:
	.bss 2
; biggest size 2
	.global _tree
_tree:
	.bss 4
; tree size 4
	.global _top
_top:
	.bss 2
; top size 2
	.global _littlest
_littlest:
	.bss 2
; littlest size 2
	.extern _Rand
	.extern _printf
	.extern _malloc
	.extern _Initrand
	.segment tree_data_const,memtype=1,locinc=1,wordsize=8,rom
__pcons4:
	.data .byte3(tree_V4)
	.data .byte2(tree_V4)
	.data .byte1(tree_V4)
	.data .byte0(tree_V4)
__pcons3:
	.data .byte3(_sortlist)
	.data .byte2(_sortlist)
	.data .byte1(_sortlist)
	.data .byte0(_sortlist)
__lcons2:
	.data 0x0
	.data 0x0
	.data 0xc3
	.data 0x50
__lcons1:
	.data 0x0
	.data 0x1
	.data 0x86
	.data 0xa0
	.segment tree_istrings_const,memtype=1,locinc=1,wordsize=8,rom
tree_V4:
	.data 0x20
	.data 0x45
	.data 0x72
	.data 0x72
	.data 0x6f
	.data 0x72
	.data 0x20
	.data 0x69
	.data 0x6e
	.data 0x20
	.data 0x54
	.data 0x72
	.data 0x65
	.data 0x65
	.data 0x2e
	.data 0xa
	.data 0x0
	.segment _idesc,memtype=1,locinc=1,wordsize=8,rom
	.data 0x0
	.data 0x0
	.data 0x0
	.data 0x0
	.data .byte3(tree_V6)
	.data .byte2(tree_V6)
	.data .byte1(tree_V6)
	.data .byte0(tree_V6)
	.data 0x0
	.data 0x0
	.data 0x27
	.data 0x1c


Back to Archelon's Home Page