mirror of
https://github.com/digarok/gsplus.git
synced 2024-05-28 13:41:31 +00:00
fix relative calculation.
This commit is contained in:
parent
79df8bf62e
commit
c22c517214
|
@ -663,8 +663,7 @@ static int parse_line(const char *cp, uint32_t *pc) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* address ... */
|
cookie.pc = addr;
|
||||||
cookie.pc = *pc;
|
|
||||||
|
|
||||||
|
|
||||||
cp = parse_opcode(cp, &cookie);
|
cp = parse_opcode(cp, &cookie);
|
||||||
|
@ -673,7 +672,7 @@ static int parse_line(const char *cp, uint32_t *pc) {
|
||||||
|
|
||||||
|
|
||||||
if (*cp) {
|
if (*cp) {
|
||||||
parse_operand(cp, &cookie);
|
cp = parse_operand(cp, &cookie);
|
||||||
if (!cp) return error(offset, "bad operand");
|
if (!cp) return error(offset, "bad operand");
|
||||||
//offset = cp - start;
|
//offset = cp - start;
|
||||||
}
|
}
|
||||||
|
@ -684,29 +683,29 @@ static int parse_line(const char *cp, uint32_t *pc) {
|
||||||
|
|
||||||
/* clean up relative */
|
/* clean up relative */
|
||||||
if (cookie.mode == RELATIVE) {
|
if (cookie.mode == RELATIVE) {
|
||||||
int pc = (cookie.pc + 1 + cookie.size) & 0xffff;
|
int pc = (addr + 1 + cookie.size) & 0xffff;
|
||||||
int tmp = (int16_t)(cookie.operand & 0xffff);
|
int tmp = cookie.operand & 0xffff;
|
||||||
int offset = tmp - pc;
|
int offset = tmp - pc;
|
||||||
if (cookie.size == 1) {
|
if (cookie.size == 1) {
|
||||||
if (tmp < -128 || tmp > 127) return error(offset, "out of range");
|
if (offset < -128 || offset > 127) return error(offset, "out of range");
|
||||||
tmp &= 0xff;
|
offset &= 0xff;
|
||||||
}
|
}
|
||||||
else tmp &= 0xffff;
|
else offset &= 0xffff;
|
||||||
cookie.operand = tmp;
|
cookie.operand = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
set_memory_c(addr, cookie.opcode, 0);
|
set_memory_c(addr++, cookie.opcode, 0);
|
||||||
unsigned operand = cookie.operand;
|
unsigned operand = cookie.operand;
|
||||||
for (i = 0; i < cookie.size; ++i) {
|
for (i = 0; i < cookie.size; ++i) {
|
||||||
set_memory_c(addr, operand & 0xff, 0);
|
set_memory_c(addr++, operand & 0xff, 0);
|
||||||
operand >>= 8;
|
operand >>= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fputs("\r\x1b[A\x1b[K", stdout);
|
fputs("\r\x1b[A\x1b[K", stdout);
|
||||||
do_list(addr, 1);
|
do_list(cookie.pc, 1);
|
||||||
*pc = addr + 1 + cookie.size;
|
*pc = addr;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user