#define SOFTX86_H
/* get the Softx86 configuration defines */
-#include <softx86cfg.h>
+#include <softx86/softx86cfg.h>
#ifdef __cplusplus
extern "C" {
#define SEGMENT_OFFSET_TO_LINEAR(s,o) (SEGMENT_TO_LINEAR(x)+o)
/* force a given value to fit within the specified size */
-#define MASK_BYTE_SIZE(x) (x &= 0xFF)
-#define MASK_WORD_SIZE(x) (x &= 0xFFFF)
-#define MASK_DWORD_SIZE(x) (x &= 0xFFFFFFFFL)
-#define FORCE_BYTE_SIZE(x) (x & 0xFF)
-#define FORCE_WORD_SIZE(x) (x & 0xFFFF)
-#define FORCE_DWORD_SIZE(x) (x & 0xFFFFFFFFL)
+#define MASK_BYTE_SIZE(x) ((x) &= 0xFF)
+#define MASK_WORD_SIZE(x) ((x) &= 0xFFFF)
+#define MASK_DWORD_SIZE(x) ((x) &= 0xFFFFFFFFL)
+#define FORCE_BYTE_SIZE(x) ((x) & 0xFF)
+#define FORCE_WORD_SIZE(x) ((x) & 0xFFFF)
+#define FORCE_DWORD_SIZE(x) ((x) & 0xFFFFFFFFL)
/* sign-extending macros */
-#define SGNEXT8(x) (x | ((x & 0x80) ? 0xFFFFFF00 : 0))
-#define SGNEXT16(x) (x | ((x & 0x8000) ? 0xFFFF0000 : 0))
+#define SGNEXT8(x) ((x) | (((x) & 0x80) ? 0xFFFFFF00 : 0))
+#define SGNEXT16(x) ((x) | (((x) & 0x8000) ? 0xFFFF0000 : 0))
/*=====================================================================================
Softx86 bug structure
imm16 = softx86_fetch_dec_byte(ctx);
if (w16)
+ {
if (sx)
imm16 |= (imm16&0x80) ? 0xFF80 : 0;
else
imm16 |= softx86_fetch_dec_byte(ctx)<<8;
+ }
if (reg == 0) sprintf(buf,"ADD %s,%04Xh",op1_tmp,imm16);
else if (reg == 1) sprintf(buf,"OR %s,%04Xh",op1_tmp,imm16);
if (mod == 3) { /* immediate <-> register */
imm = softx86_fetch_exec_byte(ctx);
if (w16)
+ {
if (sx) imm |= (imm&0x80) ? 0xFF80 : 0;
else imm |= softx86_fetch_exec_byte(ctx)<<8;
+ }
// TODO: For 386+ 32-bit instructions... if (d32) {...}
if (w16) {
imm = softx86_fetch_exec_byte(ctx);
if (w16)
+ {
if (sx) imm |= (imm&0x80) ? 0xFF80 : 0;
else imm |= softx86_fetch_exec_byte(ctx)<<8;
+ }
// TODO: For 386+ 32-bit instructions... if (d32) {...}
if (w16) {
if (mod == 3) { /* immediate <-> register */
imm = softx86_fetch_exec_byte(ctx);
if (w16)
+ {
if (sx) imm |= (imm&0x80) ? 0xFF80 : 0;
else imm |= softx86_fetch_exec_byte(ctx)<<8;
+ }
// TODO: For 386+ 32-bit instructions... if (d32) {...}
if (w16) {
imm = softx86_fetch_exec_byte(ctx);
if (w16)
+ {
if (sx) imm |= (imm&0x80) ? 0xFF80 : 0;
else imm |= softx86_fetch_exec_byte(ctx)<<8;
+ }
// TODO: For 386+ 32-bit instructions... if (d32) {...}
if (w16) {
lo = sx86_far_to_linear(ctx,seg,ofs);
softx86_fetch(ctx,NULL,lo,tmp,sz);
- op64(ctx,tmp,sz);
+ op64(ctx,(char*)tmp,sz);
}
}
}
lo = sx86_far_to_linear(ctx,seg,ofs);
softx86_fetch(ctx,NULL,lo,tmp,sz);
- op64(ctx,tmp,sz);
+ op64(ctx,(char*)tmp,sz);
softx86_write(ctx,NULL,lo,tmp,sz);
}
}