~ubuntu-branches/ubuntu/utopic/vice/utopic-proposed

« back to all changes in this revision

Viewing changes to src/monitor/mon_assembleR65C02.c

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2014-05-10 21:08:23 UTC
  • mfrom: (17.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140510210823-v5aojvy1pv1sg132
Tags: 2.4.dfsg+2.4.6-1ubuntu1
Use autotools-dev to update config.{sub,guess} for new arches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "mon_util.h"
39
39
#include "types.h"
40
40
#include "uimon.h"
41
 
 
 
41
#include "util.h"
42
42
 
43
43
static int mon_assemble_instr(const char *opcode_name, asm_mode_addr_info_t operand)
44
44
{
59
59
 
60
60
        opinfo = (monitor_cpu_for_memspace[mem]->asm_opcode_info_get)(i, 0, 0);
61
61
        if (!strcasecmp(opinfo->mnemonic, opcode_name)) {
62
 
 
63
62
            /* Special case: ZERO PAGE RELATIVE mode needs special handling. */
64
63
            if (opinfo->addr_mode == ASM_ADDR_MODE_ZERO_PAGE_RELATIVE
65
64
                && operand_mode == ASM_ADDR_MODE_DOUBLE) {
66
 
                branch_offset = operand_value - loc - 3;
67
 
                if (branch_offset > 127 || branch_offset < -128) {
 
65
                branch_offset = (operand_value - loc - 3) & 0xffff;
 
66
                if (branch_offset > 0x7f && branch_offset < 0xff80) {
68
67
                    mon_out("Branch offset too large.\n");
69
68
                    return -1;
70
69
                }
93
92
            /* Special case: RELATIVE mode looks like ZERO_PAGE or ABSOLUTE
94
93
               modes.  */
95
94
            if ((operand_mode == ASM_ADDR_MODE_ZERO_PAGE
96
 
                || operand_mode == ASM_ADDR_MODE_ABSOLUTE)
 
95
                 || operand_mode == ASM_ADDR_MODE_ABSOLUTE)
97
96
                && opinfo->addr_mode == ASM_ADDR_MODE_RELATIVE) {
98
 
                branch_offset = operand_value - loc - 2;
99
 
                if (branch_offset > 127 || branch_offset < -128) {
 
97
                branch_offset = (operand_value - loc - 2) & 0xffff;
 
98
                if (branch_offset > 0x7f && branch_offset < 0xff80) {
100
99
                    mon_out("Branch offset too large.\n");
101
100
                    return -1;
102
101
                }
152
151
    }
153
152
 
154
153
    len = (monitor_cpu_for_memspace[mem]->asm_addr_mode_get_size)
155
 
          ((unsigned int)(operand_mode), 0, 0, 0);
 
154
              ((unsigned int)(operand_mode), 0, 0, 0);
156
155
 
157
156
    /* EP 98.08.23 use correct memspace for assembling.  */
158
157
    mon_set_mem_val(mem, loc, opcode);