Skip to content

Commit

Permalink
Small changes to hde
Browse files Browse the repository at this point in the history
  • Loading branch information
m417z committed Nov 13, 2020
1 parent 8fda4f5 commit 7819161
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/hde/hde32.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#if defined(_M_IX86) || defined(__i386__)

#include <string.h>
#include "hde32.h"
#include "table32.h"

Expand All @@ -15,12 +16,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0;
uint8_t *ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0;

// Avoid using memset to reduce the footprint.
#ifndef _MSC_VER
memset((LPBYTE)hs, 0, sizeof(hde32s));
#else
__stosb((LPBYTE)hs, 0, sizeof(hde32s));
#endif
memset(hs, 0, sizeof(hde32s));

for (x = 16; x; x--)
switch (c = *p++) {
Expand Down Expand Up @@ -183,7 +179,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
}
for (; ht != table_end; ht += 2)
if (*ht++ == opcode) {
if (*ht++ & pref && !((*ht << m_reg) & 0x80))
if ((*ht++ & pref) && !((*ht << m_reg) & 0x80))
goto error_operand;
else
break;
Expand Down Expand Up @@ -234,6 +230,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
disp_size = 2;
if (!(pref & PRE_67))
disp_size <<= 1;
break;
}

if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) {
Expand All @@ -259,6 +256,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
case 4:
hs->flags |= F_DISP32;
hs->disp.disp32 = *(uint32_t *)p;
break;
}
p += disp_size;
} else if (pref & PRE_LOCK)
Expand Down
8 changes: 2 additions & 6 deletions src/hde/hde64.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#if defined(_M_X64) || defined(__x86_64__)

#include <string.h>
#include "hde64.h"
#include "table64.h"

Expand All @@ -16,12 +17,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
uint8_t *ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0;
uint8_t op64 = 0;

// Avoid using memset to reduce the footprint.
#ifndef _MSC_VER
memset((LPBYTE)hs, 0, sizeof(hde64s));
#else
__stosb((LPBYTE)hs, 0, sizeof(hde64s));
#endif
memset(hs, 0, sizeof(hde64s));

for (x = 16; x; x--)
switch (c = *p++) {
Expand Down

0 comments on commit 7819161

Please sign in to comment.