comparison src/cpu.c @ 6:74a6d629b78f

Added assembler. Removed hand-assembled version of hello world example
author Michael Pavone <pavone@retrodev.com>
date Sat, 26 Mar 2016 23:31:08 -0700
parents 6204c81e2933
children d8ae30286d17
comparison
equal deleted inserted replaced
5:18b66690ae13 6:74a6d629b78f
20 #define STATUS_INT0_ENABLE 1 20 #define STATUS_INT0_ENABLE 1
21 #define STATUS_INT1_ENABLE 2 21 #define STATUS_INT1_ENABLE 2
22 #define FLAG_Z 4 22 #define FLAG_Z 4
23 #define FLAG_C 8 23 #define FLAG_C 8
24 #define FLAG_N 16 24 #define FLAG_N 16
25
26 #define REG_PC 14
27 #define REG_SR 15
28 25
29 cpu* alloc_cpu(uint32_t clock_divider, uint32_t num_regions, memory_region *regions) 26 cpu* alloc_cpu(uint32_t clock_divider, uint32_t num_regions, memory_region *regions)
30 { 27 {
31 size_t alloc_size = sizeof(cpu) + sizeof(memory_region) * num_regions; 28 size_t alloc_size = sizeof(cpu) + sizeof(memory_region) * num_regions;
32 cpu *context = malloc(alloc_size); 29 cpu *context = malloc(alloc_size);
371 } 368 }
372 } 369 }
373 370
374 char * mnemonics[] = { 371 char * mnemonics[] = {
375 "ldim", "ldimh", "ld8", "ld16", "str8", "str16", "add", "adc", "and", "or", "xor", "lsl", "lsr", "asr", "bcc", "single" 372 "ldim", "ldimh", "ld8", "ld16", "str8", "str16", "add", "adc", "and", "or", "xor", "lsl", "lsr", "asr", "bcc", "single"
373 };
374
375 char * mnemonics_single_src[] = {
376 "mov", "neg", "not", "cmp", "call", "swap", "in", "out", "ini", "outi", "addi", "andi", "ori", "lsi", "cmpi", "single reg"
377 };
378
379 char * mnemonics_single_reg[] = {
380 "reti", "trap", "trapi", "getepc", "setepc", "getesr", "setesr", "getenum", "setenum", "setuer", "getuer"
376 }; 381 };
377 382
378 void run_instruction(cpu *context) 383 void run_instruction(cpu *context)
379 { 384 {
380 uint16_t instruction = context->prefetch; 385 uint16_t instruction = context->prefetch;