CSE 2312 - Brief Linux Guide
Topics:
Creating and Changing Directories
Creating/Changing Text Files with Copy-and-Paste
Suppose that you have a text file open on the host machine (i.e., your regular machine, not the virtual machine), and you want to copy that text file to your virtual machine. You can do that by following these steps:
- Copy the entire text on the text file (for example, by doing "select all" and then "copy").
- On the virtual machine, on the terminal, assuming that you want to call the new file "test1.s", enter this command:
cat > test1.s
- Right-click on the terminal window and select "paste".
- Press control-D.
Creating/Changing Text Files with Emacs
An alternative to copying and pasting text from the host machine to the virtual machine is to use directly a text editor on the virtual machine. You have several choices, including vi, pico, nano, and emacs. Emacs is probably the easiest to get started with. To start Emacs all you have to do is enter this command:
emacs &
After executing that command you should see the Emacs window pop up. Using the top menu on that window you should be able to open an existing file, save the file, and so on.
To create a new file, just start typing on the window, and then go to File->Save As to specify where to save the file.
Emacs has a lot of shortcuts, and many of them are listed next to the menu commands. You may find it useful to learn some of the shortcuts. Have in mind that if you press Control-Z on the Emacs window, it gets minimized. To open the window again, just find the corresponding icon on the left side of the virtual machine window, and click on it.
Copying and Renaming Files
Compiling and Executing a Program
The instructions here describes how to compile and execute a assembly program that consists of a SINGLE source file. More complicated instructions will be given later in the course.
- Create a file, that you should call test1.s (note that names are case-sensitive), that contains the program that you want to execute. You can create this file using either of the two methods mentioned above (cut-and-paste text from the host machine, or Emacs).
- In the same directory as the previous file, create a file, that you should call Makefile (note that names are case-sensitive), whose contents should be exactly what you see in this file. Again, you can create this file using either cut-and-paste or Emacs.
- In the same directory as the previous file, create a file, that you should call hw07_memmap (note that names are case-sensitive), whose contents should be exactly what you see in this file.
- From the terminal, make sure that you are in the same directory where you created test1.s and Makefile. Enter this command to compile:
make
- If compilation gave error messages, go back to your test1.s file and make changes as needed to fix the errors. If you are compiling code that was posted on the slides, you should not be getting any errors, so you should e-mail the instructor usually have problems compiling those files. After making the changes that you need, go back to the previous step to compile again.
- If compilation was successful, execute this command on the terminal:
qemu-system-arm -s -M versatilepb -daemonize -m 128M -d in_asm,cpu,exec -kernel test1.bin
- This should open a QEMU console window. Once started, press ctrl+alt+3 to change to QEMU's UART (serial) display output, which will display the output of your program.
Note that if you want to save the assembly code on the file that is NOT called test1.s, you can do that, but you should also change Makefile to replace all occurrences of the string "test1" with the name that you want to use.
Back to the resources page.
Back to the CSE 2312 home page.