[英]Understanding the “S[cc]” instructions of 68000 assembly
I'm trying to understand the "S[cc]" set of instructions in 68000 assembly. 我试图了解68000汇编中的“ S [cc]”指令集。
The format of the instruction is this: 指令的格式为:
S[cc] reg
[cc]
is a condition code (for example, SEQ
means "set if equals"). [cc]
是条件代码(例如, SEQ
意思是“等于则设置”)。 If the condition specified by [cc]
is true, the register is set to all 1
s. 如果
[cc]
指定的条件为true,则将寄存器设置为全1
s。 Otherwise, the register is set to all 0
s. 否则,寄存器设置为全
0
s。
There's one thing I don't understand: where does the S[cc]
operation look to check if the condition is true? 我不了解一件事:
S[cc]
操作在哪里检查条件是否成立? Does it check the flags? 它会检查标志吗?
If so, than if I want register D0
to hold the result of the expression D0 = D1
, this is what I need to do: 如果是这样,则比我要让寄存器
D0
保留表达式D0 = D1
的结果要多,这是我需要做的:
CMP D0,D1 ; this sets the flags according to the result
SEQ D0 ; sets D0 to true if the flags indicate the condition is true. else, sets it to false.
Is this correct? 这个对吗? Or do I not understand this operation correctly?
还是我不能正确理解此操作?
Yes, it checks the flags, which should become apparent when looking at the mnemonics: 是的,它会检查标志,当查看助记符时,这些标志应显而易见:
SCC set on carry clear (!C)
SCS set on carry set (C)
SEQ set on equal (Z)
SGE set on greater than or equal (N.V + !N.!V)
SGT set on greater than (N.V.!Z + !N.!V.!Z)
SHI set on higher than (!C.!Z)
SLE set on less than or equal (Z + N.!V + !N.V)
SLS set on lower than or same (C + Z)
SLT set on less than (N.!V + !N.V)
SMI set on minus (i.e., negative) (N)
SNE set on not equal (!Z)
SPL set on plus (i.e., positive) (!N)
SVC set on overflow clear (!V)
SVS set on overflow set (V)
SF set on false (i.e., set never) (0)
ST set on true (i.e., set always) (1)
Taken from http://de.scribd.com/doc/418461/Easy-Motorola-68k-Reference page 51. I don't know the first thing about 68k ASM. 取自http://de.scribd.com/doc/418461/Easy-Motorola-68k-参考第51页。我不了解68k ASM的第一件事。 ;-)
;-)
Take a look at Motorola's 68K Programmer's Reference Manual (1992) 看看Motorola的68K程序员参考手册 (1992)
Table 3-23
gives you the answer: The condition code checks for the bits in the status register. 表
3-23
为您提供了答案:条件代码检查状态寄存器中的位。 The status register is set not only by compare operations. 状态寄存器不仅可以通过比较操作进行设置。 See the other mnemonics for details on how they influence the status register.
有关它们如何影响状态寄存器的详细信息,请参见其他助记符。
S<cc>
does check the condition flags. S<cc>
确实检查条件标志。 You might appreciate this simple guide into how you can set the flags to your liking with the CMP
instruction: 您可能会喜欢此简单指南,了解如何使用
CMP
指令根据自己的喜好设置标志:
CMP src, dest
dest < src LT CS src >= dest ; CS = LO
dest <= src LE LS src >= dest
dest == src EQ EQ src == dest
dest != src NE NE src != dest
dest > src GT HI src <= dest
dest >= src GE CC src <= dest ; CC = HE
signed ---^ ^--- unsigned
For example, if you want to check that the unsigned value src
is more than or equal to dest
, use CMP src,dest
then SCS
. 例如,如果要检查无符号值
src
大于或等于dest
,请使用CMP src,dest
然后使用SCS
。 If the values were signed, but you wanted the same test (that src >= dest
), use SLT
如果值是带符号的,但是您想要相同的测试(
src >= dest
),请使用SLT
You can use the TST
instruction for comparing a value to zero, although in many cases this is done automatically (eg MOVE
will also do a test at the same time) 您可以使用
TST
指令将值与零进行比较,尽管在很多情况下,此操作是自动完成的(例如, MOVE
也将同时进行测试)
TST dest
dest == 0 EQ
dest != 0 NE
dest < 0 MI
dest >= 0 PL
I also want to point out that s[cc]
only affects least significant byte (eg if you do st d0
, d0
will be $xxxxxxFF
, xx
meaning this will be whatever used to be on the register). 我还要指出,
s[cc]
仅影响最低有效字节(例如,如果您执行st d0
,则d0
将为$xxxxxxFF
, xx
表示这将是寄存器上的所有内容)。 Furthermore on situations where the condition is true, the byte will be set to $FF
rather than 1
. 此外,在条件为真的情况下,字节将设置为
$FF
而不是1
。 On false situations it will be cleared. 在错误的情况下,它将被清除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.