Due to the non-portability of assembly language, it’s not possible to do the assignments for this course on Windows or Mac OS X. Instead, I’ll tell you how to setup a virtual machine that emulates the environment on the server, and then how to transfer files to/from the VM to the server.

Note that if you’re already running an Ubuntu-flavored Linux on your machine, you can skip down to step (3) and just install the required software.

Virtual machine hosts

You’ll need a virtual machine host software; popular choices are VMWare and VirtualBox. I’ll be using VirtualBox but either should work. In order to run 64-bit Ubuntu inside VirtualBox, you will need to be running a 64-bit version of Windows (Mac OS X is always 64-bit) and you will need to have virtualization extensions enabled in your BIOS. This is not a requirement if you are using VMWare, although the VM will run slower if your host OS is 32-bit, or if virtualization extensions are not enabled.

Step 1: Installing Ubuntu

We’re going to create a virtual machine, and then install Ubuntu on it. (Other Linux distributions will of course work, with some modifications.)

First, download the Ubuntu minimal install ISO and save it somewhere where you can find it.

Next, create a new virtual machine, named “CSci 241” or something. In VirtualBox, you can set its type to “Linux” and its version to “Ubuntu 64-bit”. Set the machine up to use 1GB of RAM, and create a virtual hard disk of size 5GB or so. (Most VM hosts won’t allocate the entire disk, so the actual amount of space used will be less.)

Mount the Ubuntu ISO in your machine’s virtual CD/DVD drive and the start the machine. It should boot into the Ubuntu installer. Most of the installer options can be left at their defaults. You can set the machine’s hostname to csci241, or you can get creative. The installer may sometimes ask scary-looking questions about formatting the hard drive and such; remember that it’s only operating on a virtual machine and has no access to your actual hardware.

When you setup your user account, be sure to pick a user name and password you can remember. You might want to modify the description of your virtual machine to include your user account details.

At some point, the installer will give you a choice of software to installer. You should select “OpenSSH server” from the list to enable SSH access to your VM. (Unfortunately, there isn’t an option to install the development tools, so we’ll have to do that manually.) While the base Ubuntu install includes the SSH client (i.e., you could connect to the FCCSCI server from the virtual machine), it does not include a SSH server. We want to allow you to SSH in to your virtual machine, so that you can use the SSH client (PuTTY, OS X Terminal, etc.) you are already familiar with.

When the installation is finished, you should shut down the virtual machine and unmount the virtual CD/DVD.

Step 2: Enabling network access

This step will vary depending on whether you are using VMWare or VirtualBox. We need to modify a few network settings to allow us to access (via SSH) the virtual server from your computer. Typically, the default network settings for new machines will be to use “NAT” (network address translation). This is the same technique that allows your cable modem (which has a single network address) to server all the different devices in your house (multiple network addresses). The NAT device maintains a list of active internet connections, so that when it receives a response to a request, it can map that back to the particular device which initiated the request. This technique works well as long as all network requests initiate at machines behind the NAT; if we want to allow unsolicited requests into our server, we have to tell the system how to handle them.

We need to setup port forwarding so that port 5150 externally will be forwarded to port 22 (the default SSH port) internally. Thus, we will SSH into port 5150 as usual, but our virtual server will see SSH requests coming in on port 22, as it expects. (Otherwise we’d have to modify the sshd server config. and that’s just a pain.)

In VirtualBox, these can be found in the machine settings, Network tab, expand Advanced and then click Port Forwarding. Add a new entry named “SSH”, type “TCP”, with a host port of 5150 and a guest port of 22.

Step 3: Installing software

You should now be able to start up your virtual machine, without the Ubuntu ISO mounted, so that it will boot from the virtual hard drive. After running through the boot process, you will be left at a login prompt. At this point, you can either:

The latter is probably the better option, as it gives you more control. Either way, use the username and password you setup during installation.

At this point, you are logged into your machine, but none of the development software we need is installed. Run each of the following commands as a single line; after the first one, you’ll have to enter your password, but as long as you type the rest without stopping, you should only have to enter it once.

General packages

First, we’ll install some general packages that just make things easier:

sudo apt install unp 

Compiler and assembler

This will install GCC and its related tools (a lot of packages):

sudo apt install build-essential

The assembler we want to use is not part of the above package, so run

sudo apt install yasm

to install it.

Finally, you can download the asm script into ~/bin with

mkdir ~/bin
cd ~/bin
wget https://staffwww.fullcoll.edu/aclifton/files/asm.txt
mv asm.txt asm
chmod +x asm

Editor

Here you can install whatever editor(s) you like. Most can be installed via apt:

To install Micro, you’ll have to download it manually:

mkdir ~/bin
cd ~/bin
wget https://github.com/zyedidia/micro/releases/download/v1.4.1/micro-1.4.1-linux64.tar.gz
unp micro-1.4.1-linux64.tar.gz
cp micro-1.4.1/micro .

Due to the way the ~/bin directory works, you’ll have to log out and then back in for micro to be available as a command.

x86-64 emulator

Later in the semester we will (hopefully) experiment with writing a boot loader and running our assembly without an operating system. In order to test it, we will need the Bochs x86 emulator. The version of Bochs that would be installed by apt expects a GUI, so we’re going to compile it ourselves.

mkdir ~/work
cd ~/work
wget -O bochs-2.6.9.tar.gz "https://downloads.sourceforge.net/project/bochs/bochs/2.6.9/bochs-2.6.9.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fbochs%2Ffiles%2Fbochs%2F2.6.9%2Fbochs-2.6.9.tar.gz%2Fdownload&ts=1546454589"
unp bochs-2.6.9.tar.gz
cd bochs-2.6.9/
sudo apt install libncurses5-dev
./configure --with-nogui --with-term --enable-x86-64 --enable-debugger --enable-disasm --disable-debugger-gui
make
sudo make install

If the install went correctly, you should be able to run

bochs --help

to get a bit of help.

Moving files to/from the VM

To transfer files to the server from the VM, you can use scp:

scp -P 5150 ~/path/to/file "username@fccsci.fullcoll.edu:~/path/to/dest"

You can use a similar technique to transfer files to/from your host computer. Because scp actually runs over SSH, you can use it to move files onto the VM. E.g., on Windows, you can use WinSCP, connected to localhost port 5150, to view the files you have on the VM. On a Mac, you can run scp in the Terminal app to transfer files to the VM:

scp -P 5150 ~/path/to/file "username@localhost:~/path/to/dest"

Note that username here is the user name you set up for the VM, not your fccsci user name, or your user name on your host computer.

It’s also possible to setup guest extensions in the virtual machine, which will allow you to “share” folders between your host computer and the VM.