forked from shhyou/rubi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasm.h
More file actions
30 lines (25 loc) · 680 Bytes
/
asm.h
File metadata and controls
30 lines (25 loc) · 680 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
#ifndef RUBI_ASM_INCLUDED
#define RUBI_ASM_INCLUDED
#include <stdint.h>
unsigned char ntvCode[0x10000] __attribute__((aligned(4)));
int ntvCount;
enum { EAX = 0, ECX, EDX, EBX, ESP, EBP, ESI, EDI };
static inline void emit(unsigned char val)
{
ntvCode[ntvCount++] = (val);
}
static inline void emitI32(unsigned int val)
{
emit(val << 24 >> 24);
emit(val << 16 >> 24);
emit(val << 8 >> 24);
emit(val << 0 >> 24);
}
static inline void emitI32Insert(unsigned int val, int pos)
{
ntvCode[pos + 0] = (val << 24 >> 24);
ntvCode[pos + 1] = (val << 16 >> 24);
ntvCode[pos + 2] = (val << 8 >> 24);
ntvCode[pos + 3] = (val << 0 >> 24);
}
#endif