DUE DATE:
| FRI, OCT 24 2008 BY 5:00 PM (EST)
| Computer Architecture
Exercise #13
(Friday, October 24, 2008)
You must work as a Team of 2. No more than 2 students per team.
|
You should save/rename this document using the naming convention MUid_MUid.doc using the MU IDs of the team members. The objective of this exercise to get started with typing, compiling, linking, and running assembly language programs under the Linux operating system. Fill in answers to all of the questions. For almost all the questions you can simply copy-paste appropriate text from the shell window into this document. You are free to refer to Blackboard contents as well. You may discuss the questions with your neighbors or with the lab instructor. You must upload hello.s to Blackboard to earn points for this exercise.
|
Names of team Members:
Follow the directions provided by your instructor (and available off Blackboard in handouts folder) to:
R un the X-Server Xming from →EAS Applications → Communications → XMing → XMing
U se PuTTY ( → EAS Applications → Communications → PuTTY) to log into the Linux server easlnx01.eas.muohio.edu.
When you log onto the server, you will be presented with a shell ($) prompt. You need to perform various tasks by typing commands at the shell prompt and pressing the enter () key.
When you log onto the Linux server, you will start off in a default directory called your home directory. You should create all your files and save your work off your home directory or sub-directories under your home directory. To figure out what your home directory is, you need to use the pwd (present working directory) command (that is, type pwd at the shell ($) prompt and press enter key) as shown below:
What is your home directory:
| /home/raodm
| Note: The home directory will be similar to /home/raodm. The home directory changes for every user.
To organize your files better, create a subdirectory in your home directory using the following (make directory) command:
Change your present working directory to the newly created csa278 directory using the (change directory) command:
Double check your present working directory has changed using the pwd command.
Now launch the text editor emacs from the command line to edit a new assembly program in a file called hello.s using the following command line:
The above command should run emacs in the background (due to trailing &) and free up the shell for accepting further commands.
Copy-paste the following assembly program into your emacs buffer. The assembly program prints the message “Hello World\n” on the console using a Linux system call.
-
.text
.global _start _start:
mov $4, %eax /* System call to write to a file handle */
mov $1, %ebx /* File handle=1 implies standard output */
mov $msg, %ecx /* Address of message to be displayed */
mov $len, %edx /* Number of bytes to be displayed */
int $0x80 /* Call OS to display the characters. */ mov $1,%eax /* The system call for exit (sys_exit) */
mov $0,%ebx /* Exit with return code of 0 (no error) */
int $0x80 .data
/* The data to be displayed */
msg: .string "Hello World\n"
.equ len, . - msg
|
Save your emacs buffer (to save hello.s) and run the following commands at the shell prompt to compile and link your assembly program.
as –-gdwarf2 hello.s –o hello.o
ld hello.o –o hello
You may have to fix any errors (syntax or semantic) that are reported during the assembly or linking steps and repeat the above process.
Once you have successfully assembled and linked your program try running it from the shell prompt as shown below:
You should see the message “Hello World” displayed on your console.
O nce you have tested your program use WinSCP2 ( → EAS Applications → Communications → WinSCP2) to copy the assembly source file hello.s from easlnx01.eas.muohio.edu to your local Windows machine. See LinuxEnvironment.pdf in the handouts folder for details on how to use WinSCP2.
Use Internet Explorer to upload the file to Blackboard using the appropriate exercise link (we could have uploaded the file from Linux if Blackboard was compatible with FireFox).
Ensure you include both your name and your partner’s name in the submission notes
Don’t forget to click the Submit button. If you don’t click the Submit button, I cannot view your submissions and you will get a 0 (zero) score for this exercise.
|