Starting from:
$30

$24

Homework #01 8080 CPU Emulation and Simple OS Solution

In this homework, you will run processes on a simulated Intel8080 CPU emulator. The emulator is provided as a C++ class. Your job in this homework will be to write a few assembly programs to run on this emulator. However since you will need some OS systems calls and we do not have any OS available, you will also have to write some simple OS system calls mainly for screen input and output. Here are the files that we provide with this homework:




8080Book.pdf : Good book on 8080 Assembly programming

8080_Z80 Instruction Set.pdf : reference for 8080 assembly programming




8080emu.cpp : Emulator implementation for 8080. You will not change this file

8080emuCPP.h: Emulator interface for 8080. You will not change this file

gtuos.h : sample header for GTUOS. You will rewrite this file

gtuos.cpp : sample implementation for GTUOS. You will rewrite this file

main.cpp : sample main function for this HW. You will rewrite this file




sum.asm: Adds numbers from 0 to 10 and prints the results on screeen.




sum2.asm : Adds numbers from 0 to 10 and prints the results on screeen using a different system call.




printstr.asm : 8080 Assembly file that prints "Hello world" on screen.




You need to use an assembler to produce the executable machine code for your emulator. Use the simple assembler at , http://asdasd.rpg.fi/~svo/i8080/ which helps a lot in writing the assembly code. You can directly download the executable .com file from this site.




There are two main tasks for you to do in this homework.

First, you need to implement a number of GTUOS systems calls as descibed below

Call
Params to pass
Function
How many






cycles








PRINT_B
Register A = 1,
Prints the contents of register B on
10


Register B holds the
the screen as a decimal number.




value to be printed












PRINT_MEM
Register A = 2,
Prints the contents of the memory
10


Register BC = adress
pointed by registers B and C as a






decimal number.










READ_B
Register A = 3,
Reads an integer from the keyboard
10


Register B will hold the
and puts it in register B.




value












READ_MEM
Register A = 4,
Reads an integer from the keyboard
10


Register BC = adress
and puts it in the memory location






pointed by registers B and C










PRINT_STR
Register A = 5,
Prints the null terminated string at
100


Register BC = adress
the memory location pointed by B






and C










READ_STR
Register A = 6,
Reads the null terminated string
100


Register BC = adress
from the keyboard and puts the






result at the memory location






pointed by B and C













You will rewrite the two files (gtuos.h, gtuos.cpp) to implement the above system calls and you will write another file (main.cpp) to use your OS with the 8080 CPU. Use the sample main file as a guide.




You will also write and test the following assembly files. Use the provided sample assebly files to learn about how to use the assembler and how we call the OS.




PrintNumbers.asm: file that prints integers from 0 to 50 on the screen. Each number will be printed on a new line.



PrintNumbersRev.asm: file that prints integers from 100 down to 50 on the screen. Each number will be printed on a new line.



Sort.asm: file that sorts the numbers 12, 34, 53, 2A, 5B, 6F, 33, 21, 7C, FF, BA, CB, A1, 1A, 3B, C3, 4A, 5D, 62, A3, B1, 5C, 7F, CC, AA, 34 in increasing order and prints the results on the screen. Use DW assembler directive to give the initial numbers.



Search.asm: reads an integer from the keyboard and makes a linear search on the integer list above. If found prints the memory address else prints "error"



test.asm: a file that tests each of the system calls one by one.



Your program should work

sim8080 exe.com debugFlag




There should be parameters for the program name and debug flag. Sim8080 is your program, exe.com will be produced by the assembler, and the debug will work as follows




sim8080 exe.com 1 : will read the program from exe.com. In debug mode 1, the status of the CPU will be printed to the screen after each instruction execution. At the end of the simulation, the whole memory will be saved to exe.mem as a text file of hexedecimal numbers. Each line of the file will start with the memory addres, then it will show 16 bytes of hexadecimal numbers separated with spaces.



In Debug mode 0, the program will be run and the contents of the memory will be saved as in Debug mode 1.



In Debug mode 2, after each instruction execution, the CPU state will be displayed. Your



simulation will wait for an from the keyboard and it will continue for the next tick. The contents of the memory will be saved as in Debug mode 1.




All three modes will display the total number of cycles used by the program at the end of the executions.




We will provide the submissin instructions in a separate document. You should strictly follow these instructions otherwise your submission may not get graded.

More products