Cond is one of the two-letter condition codes listed above. The parts in curly brackets are optional. If the numbers being compared are n1 and n2, the conditions are n1>=n2, n1n2 and n1=n2, n1n2, n1,, The next four conditions are often used after comparisons of two unsigned numbers. This is the opposite to the MI condition and instructions with the PL condition will only execute if the N flag is cleared. (All data operations work on 32-bit numbers.) That is, the N flag reflects the state of bit 31 of the result. Such a condition would occur when the last data operation gave a result which was negative.
Instructions with this condition only execute if the N (negative) flag is set. Add, subtract and compare instructions affect the V flag. This condition is true if the result flag V (overflow) is set. If Z is set, and instruction with the NE condition will not be executed. This is clearly the opposite of EQ, and is true if the Z flag is cleared. This might arise after a compare instruction where the operands were equal, or in any data instruction which received a zero result into the destination. This condition is true if the result flag Z (zero) is set. Such instructions might be used for 'padding' or perhaps to use up a (very) small amount of time in a program. Any instruction with this condition will be ignored. Thus ADDAL and ADD mean the same thing: add unconditionally.Īll ARM conditions also have their inverse, so this is the inverse of always. To save having to type ' AL' after the majority of instructions which are unconditional, the suffix may be omitted in this case. The suffixes, and their meanings, are listed below.Īn instruction with this suffix is always executed. To make an instruction conditional, a two-letter suffix is added to the mnemonic. The way in which each instruction affects the flags is described below. However, the MOVS (move with Set) instruction additionally causes the result flags to be set. For example, a MOV instruction which copies the contents of one register to another.
These instructions only affect the flags if you explicitly tell them to.
The result flags are altered mainly by the data manipulation instructions. If the condition does not hold, the instruction is ignored and the next one executed. If the condition for the current instruction is true, the execution goes ahead. The property of conditional execution is common to all ARM instructions, so its representation in assembler is described before the syntax of the actual instructions.Īs mentioned in chapter two, there are four bits of condition encoded into an instruction word. Chapter Four covers the use of the BASIC assembler. The former method is more convenient for testing short programs, the latter for developing large scale projects. There are two main ways of assembling ARM programs - using the assembler built-in to BBC BASIC, or using a dedicated assembler.
CX PROGRAMMER SETTING CANNOT AFFECTED TO DATA MEMORY HOW TO
At this stage, we don't explain how to create programs, assemble and run them. The mnemonics and operand formats for all of the ARM's instructions are described in detail in the sections below. Certain 'optional extras' may be added to slightly alter the affect of the instruction, leading to mnemonics such as ADCNES and SWINE. Most ARM mnemonics consist of three letters, e.g. Thus the complete add instruction, in assembler format, would be: If the left and right hand side of the addition are R1 and R2 respectively, and the result is to go in R0, the operand part would be written R0,R1,R2. This alone doesn't tell the assembler which registers to add and where to put the result. Usually, mnemonics are followed by one or more operands which are used to completely describe the instruction.Īn example mnemonic is ADD, for 'add two registers'. We saw at the end of Chapter One a few typical ARM mnemonics. Here is a typical one:įortunately, we don't have to write ARM programs using such codes. We now know what the ARM provides by way of memory and registers, and the sort of instructions to manipulate them.This chapter describes those instructions in great detail.Īs explained in the previous chapter, all ARM instructions are 32 bits long. ARM Assembly Language Programming - Chapter 3 - The Instruction Set