Question

I am currently in a class called "Computer Architecture and Organization." My professor wrote a mini operating system in the Sparc Assembler Language. My professor now wants us to write a recursive function and print the results to a console.

My question is, how do I compile and test my program? I really do not understand. Last semester I took a class called "Assembly Language." In that class, I never learned about the "Sparc" architecture. I would always use Assembly Language with inline C, and use Visual Basic to compile the programs. Now I am just lost.

Was it helpful?

Solution

Here is a good tutorial for SPARC Assembly Language including compiling and running code with gcc. See also SPARC Assembly Language.

OTHER TIPS

You write the assembler code in vi(1), then use as(1), the assembler, to assemble it into a machine code object file, .o. Then you'd use the link editor, ld(1), to add the relevant executable and linking format (ELF) information to the .o file, resolve any external symbols (functions calls into shared object libraries), thereby turning it into an executable which the runtime linker, ld.so.1, could execute.

as hello.s -o hello.o && ld hello.o -o hello && ./hello

Hello, world!

You could also use the C or C++ compiler's front end to link the assembler code you wrote into an executable:

cc hello.o -o hello && ./hello

gcc hello.o -o hello && ./hello

the above invocation will call the link editor, ld(1) for you with the correct options, behind the scenes.

Let's presume that your assembler code makes function calls into libc. Then you'd have an additional step:

; generates hello.o

as hello.s && ld hello.o -lc -o hello && ./hello

-lc option tells the linker that you want to link with libc. "lib" is prepended automatically by the linker.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top