Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

y86-Lab

A sequential simulator for the Y86-64 instruction set, written in C. It loads a program into memory and runs it one instruction at a time through the six classic processor stages.

What this demonstrates

Y86-64 is a teaching subset of x86-64 used to show how a CPU actually executes machine code. This simulator implements the sequential (SEQ) processor: every instruction flows through fetch, decode, execute, memory, write-back, and PC update, exactly as a hardware datapath would. Reading it is a concrete way to understand instruction encoding, register files, condition codes, and how a program counter advances.

Concepts demonstrated

  • The six-stage sequential processor cycle: fetch, decode, execute, memory, write-back, PC update
  • Instruction decoding: splitting an opcode byte into icode and ifun, reading register bytes and immediate words
  • The full Y86-64 instruction set: irmovq, rmmovq, mrmovq, rrmovq, OPq, push/pop, jXX, call, ret, conditional moves, nop, and halt
  • Condition codes and conditional branch/move evaluation
  • A register file and a byte-addressable memory model
  • Variable-length instruction encoding and PC math per instruction
  • A step mode that prints machine state stage by stage

What's implemented

  • y86-64.c: the complete SEQ simulator. stepMachine runs one instruction through all six stages; main initializes memory and registers, loads a program, and runs until HALT.
  • Optional DEBUG build that dumps machine state after every cycle.

Stack

  • C
  • Y86-64 instruction set architecture

Usage

Compile and run against a Y86 object file:

gcc -o y86 y86-64.c utils.c
./y86 program.yo

Pass a step flag (handled in parseCommandLine) to print the machine state after each stage instead of only the final result.

Note: this file depends on a utils.h/utils.c support module (memory, register, and opcode helpers) provided by the course framework.

About

Sequential Y86-64 processor simulator in C running the full fetch-decode-execute-memory-writeback-PC cycle

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages