简体   繁体   English

比较Motorolla 68k中的两个地址寄存器

[英]Compare two Address Registers in Motorolla 68k

I have a simple program, where I'm trying to understand how to compare two address registers, and branch if A1 is less than or equal to A2 我有一个简单的程序,我试图理解如何比较两个地址寄存器,如果A1小于或等于A2则分支

As such: 因此:

    ORG    $8000
START:                  ; first instruction of program

    CMP A2,A1
    BLE LOOP ;if A1 is less then or equal to A2, BRANCH

LOOP: 

* Put variables and constants here

    END    START        ; last line of source

Is this the correct way of doing it? 这是正确的做法吗? What if I used the macro CMPA here instead, would it make a difference? 如果我在这里使用宏CMPA会有什么不同呢?

You have to use cmpa to compare with an addressregister on 68K. 您必须使用cmpa与68K上的地址cmpa进行比较。 You don't have a choice. 你没有选择。

Also it's best to include the size suffix .L to make sure the full 32 bits are compared as opposed to a sign-extended version of the low 16 bits. 此外,最好包括大小后缀.L以确保比较完整的32位而不是低16位的符号扩展版本。

CMPA.L A2,A1
BLE.S  LOOP

I'd use cmp.L for sure, since many 68k assemblers default to .w when no size is set and then you'd end up with CPU sign-extending lower 16 bit contents of addresses and then comparing them as 32-bit quantities (68k does so only for address arithmetics). 我肯定会使用cmp.L ,因为当没有设置大小时,许多68k汇编器默认为.w,然后你最终会使用CPU符号扩展低16位的地址内容,然后将它们作为32位数量进行比较(68k仅适用于地址算术)。

In contrary, most assemblers (at least known to me) will automatically select cmp a when destination of cmp is an address register. 相反,当cmp 目的地是地址寄存器时,大多数汇编程序(至少我已知)将自动选择cmp a

Also, I see no reason in signed comparison of addresses with ble . 此外,我认为没有理由与ble签署地址比较。 Unsigned comparisons are more appropriate here, for example: 这里的无符号比较更合适,例如:

     lea   Start,a0
     lea   Start+size,a1
loop:clr.l (a0)+
     cmp.l a0,a1
     bhi.s loop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM