Keith Carolus and Dr. Alphonce Smallpond Simulator Keith Carolus and Dr. Alphonce
Keith Carolus Senior computer engineering student keithcarolus.com linkedin.com/in/keithcarolus Previous CSE115/116, CSE341 TA Current CSE379 TA
Simulator Developed as a framework for simulating RISC, non-pipelined ISAs Targeting Smallpond ISA, providing assembler and simulator ~2000 lines of code Verbose assembly error reporting Front end interface with view of memory, registers, and current instruction
Smallpond Simulator From Linux terminal (Bash): Notes: > java -jar SmallpondSimulator.jar input_assembly.s mem_cap output_exec Notes: mem_cap: memory capacity in bytes (optional, default 500) output_exec: output executable (optional) May run jar in Eclipse, demo to come
Smallpond Assembly Syntax C/Java-like single line comments, i.e., prefaced by “//” Mnemonics, operands separated by whitespace and/or commas Registers, mnemonics, flags, condition codes all uppercase Labels expected on line of assembly Instructions described in reference manual
Registers and Register Aliases 32 registers, R0-R31 Aliases: A0-A3 T0-T7 S0-S5 + and - C+ and C- HP, FP, SP LR0-LR3 PC CPSR
Structure of Assembly File DATA block, optional MAIN subroutine, required e.g. DATA my_block BLOCK 50 MAIN ADDI T0, T0, #1 Demo later
Data Section For defining constants 6 types: BLOCK INT HEX BINARY REAL STRING *** all constants are padded to multiple of 4 bytes
Data Section Example my_block BLOCK 50 // a block of memory 50 bytes in size my_block INT 2 // a 32 bit integer of value 2 my_block HEX 0xF // a 32 bit integer of value 15 my_block BINARY 0b1 // a 32 bit integer of value 1 my_block REAL 2.5 // a 64 IEEE-754 standard floating point number of value 2.5 my_block STRING “this is a string” // a variable length string // STRING prefaced by 32 bit integer length in memory
How to Load a Data’s Address 2 instructions, ADDI and LUI e.g. ADDI T0, T0, my_data LUI T0, my_data This is very RISC-like
End of Execution Denoted by a “NOP” instruction Reason: We have no operating system to return to :) Suggested: Place NOP at end of MAIN subroutine and always return back to the MAIN subroutine at the end of your program
Layout in Memory Low addresses Set SP (end of code segment) Set HP (end of memory, grows backwards) Set CPSR (jump to code segment) Data segment Code segment (starting with MAIN) Stack ↓ High addresses Heap ↑
Beta Release This simulator is ~2000 lines of code Many moving parts Let me know if you encounter an issue or have any later questions Piazza kmcarolu@buffalo.edu
Questions?
Importing JAR as Eclipse project https://www.albany.edu/faculty/jmower/geog/gog692/ImportExportJARFiles.htm Main method located in package model.driver, class Driver.java Arguments may be set in “Run configurations...”
Immediates Immediate values are prefaced by ‘#’ and may be: Integer, e.g., #1 Hexadecimal (prefaced by 0x), e.g., #0xF Binary (prefaced by 0b), e.g., #0b1010 Example of usage: ADDI T0, 0, #0xAB
STRING Data Type Note that strings are interpretted literally i.e. there are no escaped characters