jshoward
5/31/2013 - 3:35 PM

Template for assembly language module for Solaris x86

Template for assembly language module for Solaris x86

/ This is a template for creating assembly language
/ programs or modules for Solaris x86.
/
/ Before coding, replace all instances of "main" with
/ the name of your function.
/
/ Build using cc
  
.section	.text			/ code section
.globl	main
  .type	main, @function
  .align	16
main:                      / start of the function
preamble:                  / the preamble sets up the
                           / stack frame
  pushl	%ebp
  movl	%esp,%ebp
  pushl	%ebx
  pushl	%esi
  pushl	%edi

/ Function code goes here
	

finale:                    / the finale restores the
                           / stack
  popl	%edi               / and returns to the caller.
  popl	%esi
  popl	%ebx
  movl	%ebp,%esp
  popl	%ebp
  ret
  .size	main,.-main


.section	.data      / contains initialized data
Ddata.data:
  .type	Ddata.data,@object
  .size	Ddata.data,0

.section	.bss       / contains uninitialized
                           / data
Bbss.bss:
  .type	Bbss.bss,@object
  .size	Bbss.bss,0