Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- // --------------------------------------------------------------
- /* stores the value at the specified register. Success/fail -
- * if the address is illegal or the value is illegal (>8, >4)
- * it will fail.
- */
- int storeRegister(int address, const unsigned char value);
- // --------------------------------------------------------------
- /* gets the value from register specified by "address" and places it
- * into the value. It is success/fail - it will fail if
- * the address is illegal (>8)
- */
- int fetchRegister(int address, unsigned char value);
- // --------------------------------------------------------------
- /* dumps contents of registers to specified file, in decimal and hex.
- * Each register is printer per line following decimal and hex value.
- * Primarily for debugging use and to view the contents of memory
- * after the "simulator" has terminated.
- */
- void registersDump(FILE *f);
- ----------------header end
- #include <stdlib.h>
- #include <stdio.h>
- #include "Memory.h"
- static unsigned char registers[9];
- static char regNames[9] = {"%eax","%ebp","%ebx",
- "%ecx","%edi","%edx",
- "%esi","%esp","PC" };
- // --------------------------------------------------------------
- /* stores the value at the specified register. Success/fail -
- * if the address is illegal or the value is illegal (>8, >4)
- * it will fail.
- */
- int storeRegister(int address, const unsigned char value){
- registers[address] = value;
- }
- // --------------------------------------------------------------
- /* gets the value from register specified by "address" and places it
- * into the value. It is success/fail - it will fail if
- * the address is illegal (>8)
- */
- int fetchRegister(int address, unsigned char value){
- value = registers[address];
- }
- // --------------------------------------------------------------
- /* dumps contents of registers to specified file, in decimal and hex.
- * Each register is printer per line following decimal and hex value.
- * Primarily for debugging use and to view the contents of memory
- * after the "simulator" has terminated.
- */
- void registersDump(FILE *f){
- int i;
- for(i = 0; i<8; i++){
- fprintf(f, "
Add Comment
Please, Sign In to add comment