y86-Assembly exercises¶
The exercises here are returned to Lovelace as with C programming exercises. Please follow the instructions below.
Computer classrooms¶
We have installed y86 assembly programming environment into the faculty computer classrooms in to the same virtual machine TKJ_harjoitukset. The virtual machine runs both y86-compiler and simulators.
Installing y86¶
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 VMWare Workstation Player, free version for teaching
- You also need a 'Ubuntu iso image from the official Ubuntu Web pages
- Installation modifications
- You need the library flex that can be installed with
sudo apt-get install flex
- You need also the TCL/TK-libraries, install with
sudo apt-get install tk8.5-dev
- Modify the simulator Makefile to change the library names (tk and tcl) to tk8.5 and tcl8.5 in the line
TKLIBS=-L/usr/lib -ltk8.5 -ltcl8.5
- Then follow the simulator manual
Compiling assembly programs¶
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. Sequential simulator is used with the command
ssim__
. The command ssim
or the command line parameter -g
opens the GUI. ubuntu:~$ ./ssim__ program.yo ubuntu:~$ ./ssim program.yo
There is also pipeline-version of the simulator:
ubuntu:~$ ./psim program.yo ubuntu:~$ ./psim -g program.yo
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.
1. The code first line must be main: code block:
main:
...
- Do not give memory position directives
.pos
nor any other initializations before the main label!
2. Each exercise has its own input and output registers, which you muset use.
3. Of course follow any other exercise instructions
4. Always end your program with the instruction
5. y86 compiles requires each code line to end with next line character.
3. Of course follow any other exercise instructions
4. Always end your program with the instruction
halt
.5. y86 compiles requires each code line to end with next line character.
yas
compilers 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..
Anna palautetta
Kommentteja harjoituksista?