HW4: Assembly Beyond NetRun

CS 301 Project, Dr. Lawlor

I'd like you to figure out and document how to compile a file full of x86 assembly code, and link it with some C++ code, on any machine other than NetRun.

Feel free to pick any assembler you like:

Instead of source code, I'd like you to prepare me a nicely formatted PDF document, including at least the following contents:
  1. A brief header describing your name, date, and what exact hardware and software platform you'll be using here.  For example, I might say "Dr. Lawlor's 2012 directions for how to useYASM from the command line on an x86-64 Ubuntu Linux 12.04 machine."
  2. Clear, concise, easy to follow directions for how to call assembly from C++ on that platform.  Be sure to include:
  3. A well-designed screenshot (for a GUI) or text capture (for terminal commands) of you actually compiling and running some assembly.  Artfully arranging the windows prior to capture is highly recommended, but no photoshop allowed!
For example, I just made a text capture like this (note you can still copy and paste this text, unlike an image):
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$ sudo apt-get install yasm make g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++ is already the newest version.
make is already the newest version.
yasm is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$ cat > demo.cpp
#include <iostream>
extern "C" int diggit(void);
int main() {
std::cout<<"Diggit="<<diggit()<<"\n";
return 0;
}
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$ cat > diggit.S
section .text
global diggit ; note no underscore on Linux
diggit:
mov eax,1234
ret
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$ yasm -f elf64 diggit.S
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$ g++ diggit.o demo.cpp
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$ ./a.out
Diggit=1234
olawlor@ozzy:/me/olawlor/tmp/yasm_demo$

Turn your PDF document in via BlackBoard by midnight Monday, October 8.