-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbitwise.c
More file actions
37 lines (33 loc) · 702 Bytes
/
bitwise.c
File metadata and controls
37 lines (33 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "instruction.h"
#include "cpu.h"
#include "bitwise.h"
void xor(cpu_t* cpu)
{
switch(cpu->memory[cpu->ip])
{
case 0x31:
xor_modrm_reg16(cpu,cpu->memory[cpu->ip+1],cpu->memory[cpu->ip+2]);
cpu->ip += instruction_length(0x31);
break;
}
}
void xor_modrm_reg16(cpu_t* cpu,uint8_t modrm,uint16_t src)
{
switch(modrm)
{
case 0xC0:
// 0x31C0 is XOR ax,ax. I think the 0x31 opcode is XOR reg,self
// ie "clear reg", so I'm going to write a function that does exactly that.
clear_reg(&cpu->ax);
break;
}
}
void clear_reg(uint16_t* dest)
{
// equivalent to *dest ^= *dest but clearer
*dest = 0x0;
}
void xor_reg16_reg16(uint16_t* dest,uint16_t src)
{
*dest ^= src;
}