Commit 7bd13a38fcd10b9f31961c79e7d91220329884a2

Authored by Imanol-Mikel Barba Sabariego
1 parent f240a33b

Made changes to make linter happy

... ... @@ -50,7 +50,7 @@ void teq(uint16_t dst, uint16_t a, uint16_t b)
50 50 {
51 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 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 63 {
64 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 69 void jmp(uint16_t dst)
... ... @@ -112,7 +112,7 @@ void add(uint16_t dst, uint16_t a, uint16_t b)
112 112 {
113 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 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 125 {
126 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 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 173 {
174 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 179 void load(uint16_t dst, uint16_t src)
... ...
... ... @@ -30,7 +30,8 @@ void load_state(char *filename)
30 30 uint16_t regsdump[NUM_REGISTERS+1];
31 31 uint16_t memdump[MEMSIZE];
32 32 uint16_t *stackdump;
33   - uint32_t stacksize, stackpos;
  33 + uint32_t stacksize;
  34 + long stackpos;
34 35  
35 36 fread(regsdump,sizeof(uint16_t),NUM_REGISTERS+1,state);
36 37 fread(memdump,sizeof(uint16_t),MEMSIZE,state);
... ... @@ -99,7 +100,7 @@ void query()
99 100 sscanf(input,"b %hu\n",&bpoint);
100 101 fprintf(stderr,"Set breakpoint %hu to %hu",nbpoints,bpoint);
101 102 breakpoints[nbpoints] = bpoint;
102   - nbpoints = nbpoints + 1 % 0xFF;
  103 + nbpoints = (uint16_t)(nbpoints + 1 % 0xFF);
103 104 break;
104 105 case 'd':
105 106 sscanf(input,"d %hu\n",&bpoint);
... ...
... ... @@ -4,7 +4,6 @@
4 4 #include "mem.h"
5 5 #include "stack.h"
6 6 #include "disasm.h"
7   -#include "debug.h"
8 7  
9 8 uint32_t load_program(const char* path)
10 9 {
... ... @@ -14,7 +13,7 @@ uint32_t load_program(const char* path)
14 13 rewind(fp);
15 14 fread(mem,1,(size_t)file_size,fp);
16 15 fclose(fp);
17   - return file_size/2;
  16 + return (uint32_t)file_size/2;
18 17 }
19 18  
20 19 void initializevm(char *program)
... ... @@ -51,8 +50,8 @@ int main(int argc, char** argv)
51 50 uint8_t disasm_flag = 0;
52 51 uint8_t err = 0;
53 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 56 switch(c)
58 57 {
... ... @@ -65,6 +64,7 @@ int main(int argc, char** argv)
65 64 program = optarg;
66 65 break;
67 66 case '?':
  67 + default:
68 68 err = 1;
69 69 break;
70 70 }
... ...
... ... @@ -9,7 +9,7 @@
9 9  
10 10 uint8_t STACK_FAULT = 0;
11 11 uint32_t stack_size = EXTEND_SIZE;
12   -uint32_t stack_pos = -1;
  12 +uint32_t stack_pos = 0xFFFF;
13 13 uint32_t stack_elems = 0;
14 14 uint16_t *stack;
15 15  
... ... @@ -64,7 +64,7 @@ uint16_t stack_pop()
64 64 if(!stack_elems)
65 65 {
66 66 STACK_FAULT = 1;
67   - return -1;
  67 + return 0xFFFF;
68 68 }
69 69 uint16_t value = stack[stack_pos--];
70 70 if(stack_size - --stack_elems == 2*EXTEND_SIZE)
... ...