File tree 1 file changed +5
-15
lines changed
1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -22,24 +22,14 @@ along with evm-esp32. If not, see <http://www.gnu.org/licenses/>.
22
22
23
23
void vm_init (struct vm *VM, String program)
24
24
{
25
- uint16_t i = 0 ;
26
- int size = program.length ();
27
-
28
25
memset (VM, ' \0 ' , sizeof (struct vm ));
29
26
VM->registers .pc = 0x200 ;
27
+ int size = program.length ();
30
28
31
- while (i < size && i < 0xFFF - 0x200 ) {
32
- int fH , fL ;
33
-
34
- fH = program[i];
35
- if (fH == -1 ) break ;
36
- VM->memory [VM->registers .pc + i] = fH ;
37
-
38
- fL = program[i+1 ];
39
- if (fL == -1 ) break ;
40
- VM->memory [VM->registers .pc + i + 1 ] = fL ;
41
-
42
- i += 2 ;
29
+ // 1 opcode per iteration
30
+ for (uint16_t i = 0 ; i < size && i < 0xFFF - 0x200 ; i += 2 ) {
31
+ VM->memory [VM->registers .pc + i] = program[i];
32
+ VM->memory [VM->registers .pc + i + 1 ] = program[i+1 ];
43
33
}
44
34
}
45
35
You can’t perform that action at this time.
0 commit comments