0

我正在尝试编译此代码片段,但我一生都无法理解汇编程序错误:

[...]
.macro collflag flags
    RW_forced a8i16
    lda EXRAM, x
    and flags
    RW_forced a16i16
.endmac

[...]

col_r:
    RW_forced a16i16
    lda lamus_vx
    bmi col_l
    beq col_d
    lda lamus_tile
    inc a
    tax
    collflag #PROPS_WALL_LEFT
    beq :+
    jmp r_detected  ; Collision detected - right
:   lda lamus_y
    and #$0300
    beq col_d
    txa
    add #32
    tax
    collflag #PROPS_WALL_LEFT
    beq col_d
    ; Collision detected - right

在这段代码提取中,我得到了这个汇编错误:

metroix.s(264): Error: Range error (130 not in [-128..127])

第 264 行将指:

    beq col_d

RW_forced 是在一个库中实现的,实际上他们应该做的就是输出应该可以工作的 sep/rep 指令和 .a8/.a16 宏。但这是他们的实现,对我来说看起来不错:

/**
  Macro: RW_assume
  Assume known accumulator/index register widths without emitting any instructions

  Parameter:
  >:in:    widths    Register widths         a8/a16/i8/i16/a8i8/a16i16/a8i16/a16i8
*/
.macro RW_assume widths
.if .blank({widths})
  SFX_error "RW_assume: Missing required parameter"
.else
  RW_init
  .if .xmatch({widths},{a8})
    SFX_RW_a_size .set 1
    .a8
  .elseif .xmatch({widths},{a16})
    SFX_RW_a_size .set 0
    .a16
  .elseif .xmatch({widths},{i8})
    SFX_RW_i_size .set 1
    .i8
  .elseif .xmatch({widths},{i16})
    SFX_RW_i_size .set 0
    .i16
  .elseif .xmatch({widths},{a8i8})
    RW_assume a8
    RW_assume i8
  .elseif .xmatch({widths},{a16i16})
    RW_assume a16
    RW_assume i16
  .elseif .xmatch({widths},{a8i16})
    RW_assume a8
    RW_assume i16
  .elseif .xmatch({widths},{a16i8})
    RW_assume a16
    RW_assume i8
  .else
    SFX_error "RW_assume: Illegal parameter"
  .endif
.endif
.endmac

/**
  Macro: RW_forced
  Force set accumulator/index register widths (ie. always emit rep/sep instructions)

  Parameter:
  >:in:    widths    Register widths         a8/a16/i8/i16/a8i8/a16i16/a8i16/a16i8
*/
.macro RW_forced widths
.if .blank({widths})
  SFX_error "RW_forced: Missing required parameter"
.else
  .if .xmatch({widths},{a8i8})
    sep #$30
  .elseif .xmatch({widths},{a16i16})
    rep #$30
  .elseif .xmatch({widths},{a8i16})
    sep #$20
    rep #$10
  .elseif .xmatch({widths},{a16i8})
    rep #$20
    sep #$10
  .else
    SFX_error "RW_forced: Illegal parameter"
  .endif
  RW_assume widths
.endif
.endmac

我的问题是,到底是怎么回事,beq col_d或者它周围的任何东西超出了范围?130在哪里?这是汇编程序中的错误吗?

作为参考,如果我将 EITHER callflag 调用更改为没有 RW_forced 调用的另一个版本,则代码会组装(但错误)。

4

0 回答 0