在SWI条件位(ARM指令) [英] Condition bits in SWI (ARM Instruction)

查看:626
本文介绍了在SWI条件位(ARM指令)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ARM SWI指令32位被分成3组:0点23(系统呼叫码),24:27(0b1111)和28:31(条件)。 什么条件?

In ARM SWI instruction 32 bits are divided into 3 sets: 0:23 (System Call Number), 24:27 (0b1111), and 28:31 (Condition). What is the condition?

这本书的ARM SoC架构中提到,如果条件通过指令进入的管理方式。当我检查样本code,则该示例具有SWI前一CMP条件但我仍然无法理解为条件的原因。此外,在几个presentations'SWI ARM的'互联网上的present没有SWI之前的任何CMP条件。所以,我很困惑的我们是否需要与否,如果是,那么有什么必要?

The book 'ARM SoC Architecture' mentions that 'If condition is passed the instruction enters supervisor mode.' When i check the sample code then the example has one CMP condition before the SWI but I am still not able to understand the reason for the condition. Moreover, several presentations on 'SWI for ARM' present on the Internet don't have any CMP condition before SWI. So I am confused that whether we need it or not and if yes, then what is the need?

请帮忙,并在此先感谢。

Please help and Thanks in advance.

推荐答案

这是一个基本的ARM概念。尝试谷歌ARM条件执行或说明。例如,今天戴维的空间帖子提供了良好的这个概念的概述。同时,从的://计算器的.com /标签/ ARM /信息> ARM#1维基对这一主题的信息。

This is a fundamental ARM concept. Try to google ARM conditional execution OR instructions. For instance, today the Dave's space post gives a good overview of this concept. As well, the Wikipedia article referenced from the Stackoverflow ARM wiki has information on this topic.

在简单地说,ARM有四个条件位或标记的 NZCV 注意;这些都是标准的概念,任何汇编/机器语言。他们是,

In brief, ARM has four condition bits or flags NZCVnote; these are standard concepts to any assembler/machine language. They are,


  1. N 的负。

  2. 以Z 的零。

  3. C 的适合随身携带。

  4. V 的溢出。

  1. N for negative.
  2. Z for zero.
  3. C for carry.
  4. V for overflow.

ARM已经16条件执行prefixes重新在四位字段psented $ P $的条件位的是测试版本,

ARM has 16 conditional execution prefixes represented in a four bit field that test variations of the condition bits,


  • 0000 - EQ 意思的等于的用的的标志集

  • 0001 - NE 意思的不等于的用的的清晰

  • 0010 - CS 意思的设置进 HS 意思的符号更高或同一的用的执行的设置。

  • 0011 - CC 意思的执行清除 LO 意思的无符号低的用的执行的清晰。

  • 0100 - MI 意思的减去的或的的用的的标志设置。

  • 0101 - PL 意思的加上的(包括零)与的的标志清晰

  • 0110 - VS 意思的溢出的用的溢出的标志集

  • 0111 - VC 意思的无溢出的用的溢出的清晰

  • 1000 - HI 意味着一个的无符号大于的用的执行的设置 的清晰。

  • 1001 - LS 意思的无符号小于或相同的用的执行的清晰 的设置。

  • 1010 - GE 意思的符号大于或等于的用的的相等的溢出

  • 1011 - LT 意思的签名小于的用的的不等于的溢出

  • 1100 - GT 意思的签名不是的用的的清晰 负的等于溢出。

  • 1101 - LE 意思的符号小于或等于的用的的设置的不等于的溢出

  • 1110 - AL 意思的总是的。如果在没有汇编条件部分使用这种编码。

  • 1111 - NV ;这是历史和德precated,但ARMv3它意味着的从不的。即 NOP 。对于新的ARM(+的ARMv5),这扩展了选购code范围内。

  • 0000 - EQ meaning Equal with Zero flag set.
  • 0001 - NE meaning Not equal with the Zero clear.
  • 0010 - CS meaning Carry set or HS meaning unsigned higher or same with Carry set.
  • 0011 - CC meaning Carry clear or LO meaning unsigned lower with Carry clear.
  • 0100 - MI meaning Minus or negative with the Negative flag set.
  • 0101 - PL meaning Plus (including zero) with the Negative flag clear.
  • 0110 - VS meaning Overflow with the Overflow flag set.
  • 0111 - VC meaning No overflow with the Overflow clear.
  • 1000 - HI meaning an Unsigned higher with Carry set AND Zero clear.
  • 1001 - LS meaning Unsigned lower or same with Carry clear AND Zero set.
  • 1010 - GE meaning Signed greater than or equal with Negative equal to Overflow.
  • 1011 - LT meaning Signed less than with Negative not equal to Overflow.
  • 1100 - GT meaning Signed greater than with Zero clear AND Negative equal to Overflow.
  • 1101 - LE meaning Signed less than or equal with Zero set AND Negative not equal to Overflow.
  • 1110 - AL meaning Always. If there is no conditional part in assembler this encoding is used.
  • 1111 - NV; this is historical and deprecated, but for ARMv3 it meant never. Ie a nop. For newer ARMs (ARMv5+), this extends the op-code range.

几乎所有的 ARM 的说明与此四位字段pfixed $ P $。这并不适用于拇指 Thumb2 的说明。统一汇编(组装用于任何 Thumb2 ARM )时,的 IT preFIX 被使用。

Almost all ARM instructions are prefixed with this four bit field. This does not apply to Thumb or Thumb2 instructions. In unified assembler (assembles for either Thumb2 or ARM), the IT prefix is used.

一个例子可能是如下。你有这样的'C'code,

An example might be as follows. You have this 'C' code,

 if(size > 0)
    write(fd, buffer, size);

呼叫的write()是一个操作系统调用。下面是一些示例汇编,

The call write() is an OS call. The following is some sample assembler,

 ; fd is in r0, buffer in r1, size in r2

 cmp  r2, #0         ; if(size > 0)
 movgt r7, #NR_write ; OS constant for write().
 swigt #0            ; call OS write() if(size > 0)

 ; code resumes here whether or not the OS was called.

有很多其他用途,在ARM条件语句。

There are many other uses for the ARM conditionals.

注意:所有现代化的ARM CPU有一个问:(饱和)标志。它的行为以不同的方式,因为它是一个扩展指令集。

Note: All modern ARM CPUs have a Q (saturation) flag. It behaves in a different way as it is an extension to the instruction set.

这篇关于在SWI条件位(ARM指令)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆