Commit 7bd13a38fcd10b9f31961c79e7d91220329884a2
1 parent
f240a33b
Made changes to make linter happy
Showing
4 changed files
with
14 additions
and
13 deletions
cpu.c
@@ -50,7 +50,7 @@ void teq(uint16_t dst, uint16_t a, uint16_t b) | @@ -50,7 +50,7 @@ void teq(uint16_t dst, uint16_t a, uint16_t b) | ||
50 | { | 50 | { |
51 | b = regs[b % (MAX_INT+1)]; | 51 | b = regs[b % (MAX_INT+1)]; |
52 | } | 52 | } |
53 | - regs[dst % (MAX_INT+1)] = (a == b); | 53 | + regs[dst % (MAX_INT+1)] = (uint16_t)(a == b); |
54 | } | 54 | } |
55 | 55 | ||
56 | void tgt(uint16_t dst, uint16_t a, uint16_t b) | 56 | void tgt(uint16_t dst, uint16_t a, uint16_t b) |
@@ -63,7 +63,7 @@ void tgt(uint16_t dst, uint16_t a, uint16_t b) | @@ -63,7 +63,7 @@ void tgt(uint16_t dst, uint16_t a, uint16_t b) | ||
63 | { | 63 | { |
64 | b = regs[b % (MAX_INT+1)]; | 64 | b = regs[b % (MAX_INT+1)]; |
65 | } | 65 | } |
66 | - regs[dst % (MAX_INT+1)] = (a > b); | 66 | + regs[dst % (MAX_INT+1)] = (uint16_t)(a > b); |
67 | } | 67 | } |
68 | 68 | ||
69 | void jmp(uint16_t dst) | 69 | void jmp(uint16_t dst) |
@@ -112,7 +112,7 @@ void add(uint16_t dst, uint16_t a, uint16_t b) | @@ -112,7 +112,7 @@ void add(uint16_t dst, uint16_t a, uint16_t b) | ||
112 | { | 112 | { |
113 | b = regs[b % (MAX_INT+1)]; | 113 | b = regs[b % (MAX_INT+1)]; |
114 | } | 114 | } |
115 | - regs[dst % (MAX_INT+1)] = (a + b) % (MAX_INT+1); | 115 | + regs[dst % (MAX_INT+1)] = (uint16_t)((a + b) % (MAX_INT+1)); |
116 | } | 116 | } |
117 | 117 | ||
118 | void mul(uint16_t dst, uint16_t a, uint16_t b) | 118 | void mul(uint16_t dst, uint16_t a, uint16_t b) |
@@ -125,7 +125,7 @@ void mul(uint16_t dst, uint16_t a, uint16_t b) | @@ -125,7 +125,7 @@ void mul(uint16_t dst, uint16_t a, uint16_t b) | ||
125 | { | 125 | { |
126 | b = regs[b % (MAX_INT+1)]; | 126 | b = regs[b % (MAX_INT+1)]; |
127 | } | 127 | } |
128 | - regs[dst % (MAX_INT+1)] = (a * b) % (MAX_INT+1); | 128 | + regs[dst % (MAX_INT+1)] = (uint16_t)((a * b) % (MAX_INT+1)); |
129 | } | 129 | } |
130 | 130 | ||
131 | void mod(uint16_t dst, uint16_t a, uint16_t b) | 131 | void mod(uint16_t dst, uint16_t a, uint16_t b) |
@@ -173,7 +173,7 @@ void not(uint16_t dst, uint16_t src) | @@ -173,7 +173,7 @@ void not(uint16_t dst, uint16_t src) | ||
173 | { | 173 | { |
174 | src = regs[src % (MAX_INT+1)]; | 174 | src = regs[src % (MAX_INT+1)]; |
175 | } | 175 | } |
176 | - regs[dst % (MAX_INT+1)] = ~src & 0x7FFF; | 176 | + regs[dst % (MAX_INT+1)] = (uint16_t)(~src & 0x7FFF); |
177 | } | 177 | } |
178 | 178 | ||
179 | void load(uint16_t dst, uint16_t src) | 179 | void load(uint16_t dst, uint16_t src) |
debug.c
@@ -30,7 +30,8 @@ void load_state(char *filename) | @@ -30,7 +30,8 @@ void load_state(char *filename) | ||
30 | uint16_t regsdump[NUM_REGISTERS+1]; | 30 | uint16_t regsdump[NUM_REGISTERS+1]; |
31 | uint16_t memdump[MEMSIZE]; | 31 | uint16_t memdump[MEMSIZE]; |
32 | uint16_t *stackdump; | 32 | uint16_t *stackdump; |
33 | - uint32_t stacksize, stackpos; | 33 | + uint32_t stacksize; |
34 | + long stackpos; | ||
34 | 35 | ||
35 | fread(regsdump,sizeof(uint16_t),NUM_REGISTERS+1,state); | 36 | fread(regsdump,sizeof(uint16_t),NUM_REGISTERS+1,state); |
36 | fread(memdump,sizeof(uint16_t),MEMSIZE,state); | 37 | fread(memdump,sizeof(uint16_t),MEMSIZE,state); |
@@ -99,7 +100,7 @@ void query() | @@ -99,7 +100,7 @@ void query() | ||
99 | sscanf(input,"b %hu\n",&bpoint); | 100 | sscanf(input,"b %hu\n",&bpoint); |
100 | fprintf(stderr,"Set breakpoint %hu to %hu",nbpoints,bpoint); | 101 | fprintf(stderr,"Set breakpoint %hu to %hu",nbpoints,bpoint); |
101 | breakpoints[nbpoints] = bpoint; | 102 | breakpoints[nbpoints] = bpoint; |
102 | - nbpoints = nbpoints + 1 % 0xFF; | 103 | + nbpoints = (uint16_t)(nbpoints + 1 % 0xFF); |
103 | break; | 104 | break; |
104 | case 'd': | 105 | case 'd': |
105 | sscanf(input,"d %hu\n",&bpoint); | 106 | sscanf(input,"d %hu\n",&bpoint); |
main.c
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | #include "mem.h" | 4 | #include "mem.h" |
5 | #include "stack.h" | 5 | #include "stack.h" |
6 | #include "disasm.h" | 6 | #include "disasm.h" |
7 | -#include "debug.h" | ||
8 | 7 | ||
9 | uint32_t load_program(const char* path) | 8 | uint32_t load_program(const char* path) |
10 | { | 9 | { |
@@ -14,7 +13,7 @@ uint32_t load_program(const char* path) | @@ -14,7 +13,7 @@ uint32_t load_program(const char* path) | ||
14 | rewind(fp); | 13 | rewind(fp); |
15 | fread(mem,1,(size_t)file_size,fp); | 14 | fread(mem,1,(size_t)file_size,fp); |
16 | fclose(fp); | 15 | fclose(fp); |
17 | - return file_size/2; | 16 | + return (uint32_t)file_size/2; |
18 | } | 17 | } |
19 | 18 | ||
20 | void initializevm(char *program) | 19 | void initializevm(char *program) |
@@ -51,8 +50,8 @@ int main(int argc, char** argv) | @@ -51,8 +50,8 @@ int main(int argc, char** argv) | ||
51 | uint8_t disasm_flag = 0; | 50 | uint8_t disasm_flag = 0; |
52 | uint8_t err = 0; | 51 | uint8_t err = 0; |
53 | char c; | 52 | char c; |
54 | - char *program; | ||
55 | - while ((c = getopt(argc, argv, "s:d:")) != -1) | 53 | + char *program = NULL; |
54 | + while ((c = (char)getopt(argc, argv, "s:d:")) != -1) | ||
56 | { | 55 | { |
57 | switch(c) | 56 | switch(c) |
58 | { | 57 | { |
@@ -65,6 +64,7 @@ int main(int argc, char** argv) | @@ -65,6 +64,7 @@ int main(int argc, char** argv) | ||
65 | program = optarg; | 64 | program = optarg; |
66 | break; | 65 | break; |
67 | case '?': | 66 | case '?': |
67 | + default: | ||
68 | err = 1; | 68 | err = 1; |
69 | break; | 69 | break; |
70 | } | 70 | } |
stack.c
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | 9 | ||
10 | uint8_t STACK_FAULT = 0; | 10 | uint8_t STACK_FAULT = 0; |
11 | uint32_t stack_size = EXTEND_SIZE; | 11 | uint32_t stack_size = EXTEND_SIZE; |
12 | -uint32_t stack_pos = -1; | 12 | +uint32_t stack_pos = 0xFFFF; |
13 | uint32_t stack_elems = 0; | 13 | uint32_t stack_elems = 0; |
14 | uint16_t *stack; | 14 | uint16_t *stack; |
15 | 15 | ||
@@ -64,7 +64,7 @@ uint16_t stack_pop() | @@ -64,7 +64,7 @@ uint16_t stack_pop() | ||
64 | if(!stack_elems) | 64 | if(!stack_elems) |
65 | { | 65 | { |
66 | STACK_FAULT = 1; | 66 | STACK_FAULT = 1; |
67 | - return -1; | 67 | + return 0xFFFF; |
68 | } | 68 | } |
69 | uint16_t value = stack[stack_pos--]; | 69 | uint16_t value = stack[stack_pos--]; |
70 | if(stack_size - --stack_elems == 2*EXTEND_SIZE) | 70 | if(stack_size - --stack_elems == 2*EXTEND_SIZE) |