[FEAT] Implemented 'if' support

[BUG] Variables inside blocks couldn't shadow those outside
[FEAT] Decompiler shows address of each opcode
This commit is contained in:
2021-05-05 15:16:57 +02:00
parent 8b101e4d3c
commit 287bf565bd
6 changed files with 108 additions and 114 deletions

View File

@@ -4,10 +4,22 @@
#include <string.h>
#include "parser.h"
#define SIMPLE(X) f << X << std::endl; pos++; break
#define SIMPLE(X) f << get_address(pos) << ": " << X << std::endl; pos++; break
// [RZC 05/05/2021] To solve alignment problems on ARM architectures we have to first copy the 4 bytes to an aligned byte array, then cast it to float
#define FVAR(X) memcpy(data, &code[pos+1], 4); f << X << " " << *((float*)data) << std::endl; pos += 5; break
#define IVAR(X) memcpy(data, &code[pos+1], 4); f << X << " " << *((uint32_t*)data) << std::endl; pos += 5; break
#define FVAR(X) memcpy(data, &code[pos+1], 4); f << get_address(pos) << ": " << X << " " << *((float*)data) << std::endl; pos += 5; break
#define IVAR(X) memcpy(data, &code[pos+1], 4); f << get_address(pos) << ": " << X << " " << *((uint32_t*)data) << std::endl; pos += 5; break
static std::string get_address(const int pos) {
std::string label = "0000";
int value = pos;
int i = 3;
while (value > 0) {
label[i] = 48 + (value % 10);
value = value / 10;
i--;
}
return label;
}
void decompiler_save(const uint8_t *code, const int size) {
uint8_t data[4];