Computer Science Works

Computer Science Works

In this session you will find my computer science works, including programming languages, website creation and a few home made games.

Pocket C - An Interpreter for the C language

 

I have always loved programming languages, compilers, interpreters and low level design and interaction. This project consists of an interpreter for a subset of the C language and some of its standard libraries, along with an IDE that I developed in Delphi for writing programs and running them. The actual interpreter is written in C itself. An interpreter is different to a compiler in that no code is ever translated into binary format, instead, the code is directly run by the interpreter itself. I worked this purely for fun and pleasure and I learned a lot during the process.

 

The subset of the C language that it runs includes matrices, pointer arithmetic with multiple indirection and many of the C standard library's functions. It also has some original functions that I created like evaluation of mathematical expressions. I still have the original source files for this and you can download them by clicking here.

A city simulation game

 

This is an old game that I made using Delphi (Object Pascal). I used to be a fan of the game Sim City, and being a programmer, I had to try and make my own city simulation game. The game interface is actually written in Portuguese (My native language), because I made this while still very young and still living in Brazil (some 10 years ago). You can download the source code for this game here.

Space Travellers II

 

This is a more recent game. It is also made in object Pascal. This could be used as an introduction to the applications of trigonometry. There are different types of enemies, some of them are good at shooting at you (they know trigonometry), and some are not so good. Ah, and the final enemy is very smart and desperate to win. There are also auto-targetting missiles. You can download the source code for this project here.

 

CTRL: Shoots; ARROWS: Moves

 

 

Mario Delphi

 

This is an unfinished project. There are no enemies. There is a full stage editor that allows the creation and integration of stages one after another in order to create a complete world. There are also animated tiles and different kinds of interactions, ie. swimming and sinking in quicksand.

 

You can download the source code for this project here.

 

Z: Jumps; ARROWS: Moves; A: Runs

Andromeda Virtual Machine

 

I started working on this project as soon as I finished Pocket C interpreter. Inspired by the non ideal speed in which an interpreter runs, I started working on the idea of a virtual machine, that instead of interpreting strings of commands, only interprets integers. This improves speed dramatically. This was the perfect project for me because what I love the most is low level design, and hence why I am drawn to electronics and embedded systems. This project consists of a compiler that translates an assembly language into binary code, together with the virtual machine itself, which interprets and runs the binary code. The assembly language was inspired by x86 assembly, and supports a whole collection of instructions working with integers, floats and doubles:

 

HLT,

LDA,

LDO,

NOP,

JT,

JF,

JMP,

CALL,

INT,

RET,

 

MOV,

LBI,

LWI,

LDI,

LB,

LW,

LD,

SB,

SW,

SD,

ADD,

SUB,

MUL,

DIV,

INC,

DEC,

FTI,

DTI,

PUSH,

POP,

AND,

OR,

XOR,

NOT,

SHR,

SHL,

CMPE,

CMPG,

CMPGE,

CMPL,

CMPLE,

 

FMOV,

LFI,

LF,

SF,

FADD,

FSUB,

FMUL,

FDIV,

ITF,

DTF,

FPUSH,

FPOP,

FCMPL,

 

DMOV,

LDBLI,

LDBL,

SDBL,

DADD,

DSUB,

DMUL,

DDIV,

ITD,

FTD,

DPUSH,

DPOP,

DCMPL

 

Please have a look at the example code below, during the writing process, the compilation process and the running process.

 

You can download the source code for this project here.