-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriteOps.c
49 lines (40 loc) · 1000 Bytes
/
writeOps.c
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
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include "error.h"
// OP,OP_RA,OP_RA_IMM,OP_RA_RB,OP_RA_RB_IMM,OP_RA_RB_RC
void write_OP(uint8_t opcode,FILE* bin){
fputc(opcode,bin);
fputc(0,bin);
fputc(0,bin);
fputc(0,bin);
}
void write_OP_RA(uint8_t opcode,uint8_t rA,FILE* bin){
fputc(opcode,bin);
fputc(rA,bin);
fputc(0,bin);
fputc(0,bin);
}
void write_OP_RA_IMM(uint8_t opcode,uint8_t rA,uint16_t imm16,FILE* bin){
fputc(opcode,bin);
fputc(rA,bin);
fwrite(&imm16,2,1,bin);
}
void write_OP_RA_RB(uint8_t opcode,uint rA,uint8_t rB,FILE* bin){
fputc(opcode,bin);
fputc(rA,bin);
fputc(rB,bin);
fputc(0,bin);
}
void write_OP_RA_RB_IMM(uint8_t opcode,uint8_t rA,uint8_t rB,uint8_t imm8,FILE * bin){
fputc(opcode,bin);
fputc(rA,bin);
fputc(rB,bin);
fputc(imm8,bin);
}
void write_OP_RA_RB_RC(uint8_t opcode,uint8_t rA,uint8_t rB,uint8_t rC,FILE * bin){
fputc(opcode,bin);
fputc(rA,bin);
fputc(rB,bin);
fputc(rC,bin);
}