Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are ARM instructuons SWI and SVC exactly same thing?

ARM assembly has SWI and SVC instructions for entering into 'supervisor mode'.

What confuses me is, why there are two of them? Here it is said that SVC was formerly SWI. Does it mean that basically they changed the mnemonic? Are they the same thing? Can I use them interchangeably? Does one of them exist before an architecture, and other after?

like image 577
Hayri Uğur Koltuk Avatar asked Dec 10 '11 19:12

Hayri Uğur Koltuk


People also ask

What is SVC in ARM assembly?

The Cortex-M cores support the SuperVisor Call (SVC) instruction, with that the user can trigger an exception. This can become handy if e. g. the core is in unprivileged mode and the program needs to access special registers, that only can be accessed in privileged mode.

What is SWI in arm?

The Software Interrupt instruction (SWI) is used to enter Supervisor mode, usually to request a particular supervisor function. The SWI handler reads the opcode to extract the SWI function number.

What does SWI mean in assembly?

Software Interrupt (SWI) functions are functions that run in Supervisor Mode of ARM7™ and ARM9™ core and are interrupt protected. SWI functions can accept arguments and can return values. They are used in the same way as other functions.

What is the use of SWI?

SWI is particularly useful in the setting of trauma and acute neurologic presentations suggestive of stroke, but can also characterize occult low-flow vascular malformations, cerebral microbleeds, intracranial calcifications, neurodegenerative diseases and brain tumors.


2 Answers

Yes, SWI and SVC are same thing, it is just a name change. Previously, the SVC instruction was called SWI, Software Interrupt.

The opcode for SVC (and SWI) is partially user defined (bit 0-23 is user defined and is like a parameter to SVC handler). Bits 24-27 are b1111 and these 4 bits makes CPU to realize that the opcode is SVC (or SWI). see ARM Information Center for more details.

like image 135
Kamyar Souri Avatar answered Jan 14 '23 14:01

Kamyar Souri


There is a good UAL vs pre-UAL mnemonic table on ARMv8 Appendix K6 "Legacy Instruction Syntax for AArch32 Instruction Sets"

One of the entries of that table is:

Pre-UAL syntax    UAL equivalent
SWI               SVC

which explicitly states that they are equivalent.

On GNU GAS, you can select the UAL syntax with .syntax unified.

From GCC, you can use the option -masm-syntax-unified for inline assembly, although it wasn't working in 8.2.0 due to a then fixed bug: How to write .syntax unified UAL ARMv7 inline assembly in GCC?

UAL vs pre-UAL also has further implications besides the names of certain instructions, e.g. the requirement for # or not in certain integer literals: Is the hash required for immediate values in ARM assembly?

like image 24
Ciro Santilli Avatar answered Jan 14 '23 14:01

Ciro Santilli