y86 Basic Assembly exercises¶
The exercises here are returned to Lovelace as with C programming exercises. Please follow the instructions below.
Simulator in Internet¶
You can find in internet the network version of the assembly simulator for y86-64.
The network version offers all the necessary functionality for implementign the course exercises and the final project work.
Installing y86¶
Option 1 Using official program (NOT RECOMMENDED -> NECESSARY MODIFY AND COMPILE)¶
You can of course install the programming environment into your own computer. The source code is available from here (Menu Student site and Chapter 4: Processor Architecture).
Simulator manual can be found from here.
The simulator works best with linux, e.g. with Ubuntu
- If you use Windows/MAC, its best to install Ubuntu in a virtual machine
- You need VirtualBox'
- You also need a 'Ubuntu iso image from the official Ubuntu Web pages, version >16.04 LTS.
- Installation instructions
- Instructions are compiled here
- Then follow the simulator manual
Option 2: Using a modified version by course staff (only tested in Lubuntu)¶
You can
To make your life easier create a new folder inside your home directory named
sim. Clone the repo there.The The README.md file contains information on how to install in your system.
You can find further information for execution in the README.md file of the repo
Option 3: Using VM¶
VM can be found at Virtual Machine Download and Historial
The installed file is under
student/y86 folderYou can find further information for execution here
Compiling assembly programs¶
More detailed instructions can be found from this README.md file.
The compiler works with command
yas.ubuntu:~$ ./yas program.ys
The compiler creates an object file
program.yo that is given to the simulator. You can actually take a look inside the object file to see how the program was compiled to machine language. Sequential simulator is used with the command
ssim, where the command line parameter -g opens the GUI. However, GUI components are not installed into the course virtual machine. ubuntu:~$ ./ssim program.yo
If you program uses more than 10.000 instructions, which is the default limit for the simulator, you can adjust the max number of instructions with command line parameter
-l n, where n is the new maximum. Exercises¶
You need to return your exercise answers in a particular form as described below. This is needed that your answers can be automatically checked.
- The code must be returned using
.ysextension - The code first line must be main: code block:
main:
...
- Do not give memory position directives
.posnor any other initializations before the main label!
- Each exercise has its own input and output registers, which you must use.
- Of course follow any other exercise instructions
- Always end your program with the instruction
halt. - y86 compiles requires each code line to end with next line character.
yascompilers gives an error of this, but not the Lovelace exercise output.
An example. Sum up the registers %rax ja %rbx and return the sum in %rbx-register:
.pos 0
irmovq $2,%rax
irmovq $3,%rbx
main:
addq %rax,%rbx
halt
You need to eliminate the first three lines of code and only return the following:
main:
addq %rax,%rbx
halt
This enables Lovelace to correctly interpret and test your answer.
Please note that Lovelace exercises can only handle programs with less than 10.000 executed instructions.
Ok, so here we go..
Give feedback on this content
Comments about these exercises