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.
Creating a program from scratch
- Find the skeleton program on the class Web page
- Login to beowulf with your new 231a-xx account
- 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
- 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!