Lab 1 – Hello World… Your first “lab”
Overview
It is finally time for your first lab,
Anyway, it is a long-standing tradition in computer science that your first program displays “Hello World” to the screen. This dates back to the first message sent over ARPANET – the predecessor to the Internet.
This week, you will basically get your feet wet with assembly programming. On the next page of this handout, there is a very basic “Hello World” program. Essentially, your only task for this lab is to print the traditional “Hello World!” to the screen followed by some other information.
Connecting to the Server
To do your labs, you need to use your ECS Account. If you don’t have one yet, then I will show you how to create one. Unfortunately, you probably won’t be able to work on your lab today, but you have a week to finish it.
Step 1 – Windows
The three servers that we use to do our labs cannot be accessed from off campus – at least directly. To connect these computers, first connect to Athena using Putty.
Step 1 – Macintosh
Open the Terminal program. This is the same UNIX prompt that you get when you connect to Athena. Mac-OS X is a version of UNIX. Neat! Once at the prompt, type the following where username is your ECS username.
Step 2 – Secure Shell to SP1, SP2, or SP3
Once you are connected, you need to Secure Shell (SSH) to one of the SP computers. Basically, you will connect to Athena and it will connect you to the SP computer. This example uses SP2. You will have to enter your password again and (maybe) have to manually type “yes”.
athena.csus.edu
ssh sp2
Creating a new file
To run nano, type “nano” following by the name of the file you either want to create or edit:
nano lab1.s
Hints
- First type in the program at the end of this handout verbatim. Then see if you can it to assemble, link, and execute. You don’t have to type the comments, but I recommend it.
- Now work on each of the requirements below one at a time. You will turn in the final program, but incremental design is best for labs.Hello World On x86 Linux
Pressley the Lab was helpful enough to write the following program for you! She’s a good doggy!
2
Requirements
3
You must think of a solution on your own. The requirements are as follows:
1. Print “hello world” to the screen. You can make it “howdy” or any type of greeting you like. This is pretty much done for you already in the sample code.
2. Print the text “My name is” and your full name to the screen.
Do not use the same string as in #1. Create a new label and ASCII text. 3. Print a quote from someone. It can be funny or inspirational.
Do not use the same string as in #1 or #2. Create a new label and ASCII text.
4. Print off the text “I will graduate in year from Sacramento State!” The year must be printed using the PrintInt
subroutine.
Submitting Your Lab
To submit your lab, you must use Alpine – an easy-to-use application much like Nano. However, if your ECS account existed before Fall 2017, you need to configure it to work on SP1, SP2, and SP3. To do this, please type the following verbatim and hit enter. You will only need to do this once.
No space before the period. There is a space before the tilde.
Afterwards, run Alpine by typing the following and, then, enter your username and password.
Please send an e-mail to yourself (on your Outlook, Google account) to check if Alpine is working. To submit your lab, send the assembly file (not a.out or the object file) to:
UNIX Commands
Editing
cp /netdisk/skel/.pinerc ~
alpine
|
Action |
Command |
Notes |
|
Edit File |
nano filename |
“Nano” is an easy to use text editor. |
|
|
alpine |
“Alpine” is text-based e-mail application. You will e-mail your assignments it. |
|
Assemble File |
as -o object source |
Don’t mix up the objectfile and asmfile fields. It will destroy your program! |
|
Link File |
ld -o exe object(s) |
Link and create an executable file from one (or more) object files |
Folder Navigation
4
|
Action |
Command |
Description |
|
Change current folder |
cd foldername |
“Changes Directory” |
|
Go to parent folder |
cd .. |
Think of it as the “back button”. |
|
Show current folder |
pwd |
Gives a file path |
|
List files |
ls |
Lists the files in current directory. |
File Organization
|
Action |
Command |
Description |
|
Create folder |
mkdir foldername |
Folders are called directories in UNIX. |
|
Copy file |
cp oldfile newfile |
Make a copy of an existing file |
|
Move file |
mv filename foldername |
Moves a file to a destination folder |
|
Rename file |
mv oldname newname |
Note: same command as “move”. |
|
Delete file |
rm filename |
Remove (delete) a file. There is no undo. |






