Code in Java/C/C++:
============================================================
main(...) ----> int printf(....)
{ / {
... / ...
... / ...
printf("Hello") return;
^ } |
| |
+--------------------------------+
...
}
Assembler code for calling a subroutine/function
============================================================
main: ...
...
...
Pass parameters in output registers
call printf
nop
...
...
str1: .ascii "Hello World!\n\0"
str1: .ascii "Hello World!\n\0"defines a string in memory. What it actually does is to reserve (enough) space in memory and store the ASCII codes of the characters 'H', 'o', etc. in that space.
sethi str1, %o0
add %o0, %lo(str1), %o0
Compile it using:
cc sparc-example1.s
Run it using:
a.out
There you have your first "real" program in assembler....