CSC231 Lab 1 2014
This lab is a first lab to get you started with the process of assembling, linking, and running assembly programs for the Intel processor.
Contents
Creating a program from scratch
- Find the skeleton program on the class Web page
- Login to beowulf with your new 231a-xx account (see Troubleshooting section at bottom of this page in case of trouble)
- Create a file called skel.asm in your account, and save the skeleton program in it.
- Make a copy of skel.asm and call it lab1.asm
- Add a string variable in your data section:
msg db "Welcome to csc231", 10 MSGLEN equ $-msg
- Add some code to output the string in the text (code) section
mov eax, WRITE mov ebx, STDOUT mov ecx, msg ; use the same name as the string in the data section mov edx, MSGLEN ; # of chars in string int 0x80
- Save your file
Assembly and Linking steps
- Assemble your program
nasm -f elf -F stabs lab1.asm
- Fix any errors you may get
- Link your program
ld -o lab1 lab1.o
You shouldn't get any errors at this stage.
Execution
- Run your program:
./lab1
Playing around with the program
- Make your program output look like this:
Welcome to CSC111 Home of the Assembly Language
- If your first solution uses two strings, modify your program so that it uses only 1 string. If your first solution uses one string, modify your program so that it uses two.
- Modify your program so that its output looks like this:
********************************* * Welcome to CSC111 * * Home of the Assembly Language * *********************************
The lines of stars contain 33 *-characters. Each line is thus 34-character long (to account for the line-feed character). Can you find a solution where the number of characters in your data section is not 4 x 34 = 136 characters, but 3 x 34 = 102, instead?
Test it out!
Troubleshooting
It is possible that if you are using ssh to connect to Beowulf the first time, and if you are using a Mac, you get a message of this form:
ssh 231a-xx@beowulf.csc.smith.edu ================================================== WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! ================================================== IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is bf:db:14:e6:a4:e0:f3:3d:d8:87:35:66:a9:35:68:fb. Please contact your system administrator. Add correct host key in /Users/alex/.ssh/known_hosts to get rid of this message. Offending key in /Users/xxxxx/.ssh/known_hosts:1 RSA host key for beowulf.csc.smith.edu has changed and you have requested strict checking. Host key verification failed.
In this case, use the editor of your choice and edit the file ~/.ssh/known_hosts and remove the lines that contains the word beowulf. Be careful, the lines are very long and wrap around to form blocks of 4 or 5 lines on your screen, so deleting one line will require a big block to disappear.