









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Development processor Target processor
Instruction Set Simulator For A Simple
Processor
typedef struct { unsigned char first_byte, second_byte; } instruction;
instruction program[1024]; //instruction memory unsigned char memory[256]; //data memory
int run_program(int num_bytes) {
int pc = -1; unsigned char reg[16], fb, sb;
while( ++pc < (num_bytes / 2) ) { fb = program[pc].first_byte; sb = program[pc].second_byte; switch( fb >> 4 ) { case 0: reg[fb & 0x0f] = memory[sb]; break; case 1: memory[sb] = reg[fb & 0x0f]; break; case 2: memory[reg[fb & 0x0f]] = reg[sb >> 4]; break; case 3: reg[fb & 0x0f] = sb; break; case 4: reg[fb & 0x0f] += reg[sb >> 4]; break; case 5: reg[fb & 0x0f] -= reg[sb >> 4]; break; case 6: pc += sb; break; default: return – 1;
return 0; }
int main(int argc, char *argv[]) {
FILE* ifs;
If( argc != 2 || (ifs = fopen(argv[1], “rb”) == NULL ) { return – 1; } if (run_program(fread(ifs,program, sizeof(program)) == 0) { print_memory_contents(); return(0); } else return(-1); }
Verification Phase
Emulator
Development processor
(a) (b)
External tools
Change Full chip simulation to
HCS12 Serial Monitor