Set letterj j mov r0 letterj this is a contrived

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: constant "J" (alternative syntax) –5– Of course, a good programmer will define a symbol with the appropriate value and use that instead: .set letter_J, 'J' mov r0, #letter_J ; This is a contrived example! Character constants can also contain certain backslash escape sequences, similar to the C programming language. See section 3.6.1 of the GNU Assembler Reference for more details. Apart from simple integer numbers, expressions can also look like standard mathematical and logical expressions expressed in the C language. These are described in detail in Chapter 6 of the GNU Assembler Reference. Some examples are: .set .set .set .set ROM_size, start_ROM, end_ROM, bm1, 128 * 1024 ; 131072 bytes (128KB) 0xE0000000 start_ROM + ROMsize ; 0xE0020000 0b11001101 ; Binary bit-mask (hex 0xCD) .set .set .set val1, -2 * 4 + (45 / (5 << 2)) ; -6 (in two's complement) val2, ROM_size >> 10 ; 128 (131072 shifted right by 10) val3, bm1 | 0b11110000 ; bm1 OR 0b11110000 = 0b11111101 Expressions can, of course, contain previously-defined labels, as illustrated above. Such expressions can yield absolute values or relative values. Absolute values don’t depend on their position in the final executable (ie, they are position-independent); they are a simple numeric constant, such as those in the examples above. Relative values, on the other hand, are relative to some address, such as the start of the .data section. These values are only fixed into place (ie, assigned a value) by the linker when the final executable is created, not by the assembler. Relative values are mainly used for offset calculations, and can only use the “+” and “-” operators. For example: .text code_start: XXX code_end: .set .set .set .set .set ; Many assembly language instructions... instr_size, code_length, first_instr, instr_11th, instr_10th, 4 ; instructions are all 4 bytes long on ARM code_end - code_start code_start code_start + 10 * instr_size instr_11th - instr_size The symbol code_length is set to an abs...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online