Assembler directives

Assembler directives - Assembler directives • Examples...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Assembler Directives (instead of Chapter 4) Assembly language programs contain the following: 1)Machine instructions – mnemonics of executable instructions example: ADD r1,r2,r5 2)Assembler directives – instructions to the assembler that define program structure, symbols, data, constants, etc. example: .equ number, 10 3)Comments – enhance readability of programs example: @ r1=r2+r5 General format of Machine Instructions: Label: mnemonic operand1, operand2 … @comment Examples: _start: ADD r1,r2,r5 @ r1=r2+r5 SUB r2,r2,r5 @ r2=r2-r5 ADDS r0,r2,#23 @ r0=r2+23 and CPSR is set Loop: SUB r4,r5,#0x17 @ r4=r5-23 (23 = 17 16 ) SUBS r5,r5,r2 @ r5=r5-r3 and CPSR is set
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Examples of
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Assembler directives: • Examples converted to GNU Assembler directives: Program 1 from section 3.2 of text (page 38): .section .text, "prog1" .global _start _start: MOV R0, #0x11 @ immediate constant fits in 8 bits MOV R1, R0, LSL #1 MOV R2, R1, LSL #1 stop: B stop .end A more complete example including data (Sample program from “The ARM Assembly language – A Short Introduction”: .text .global _start _start: LDR R1,=SIZE LDR R1,[R1] LDR R2,=VEC MOV R0, #0 LOOP: LDR R3,[R2] ADD R0,R0,R3 ADD R2,R2 ,#4 SUB R1,R1, #1 CMP R1, #0 BNE LOOP LDR R1,=TOT STR R0, [R1] stop: B stop .data .align SIZE: .word 3 VEC: .word 3, -1, 2 TOT: .skip 4 .end This table of assembler directives will be included with he test....
View Full Document

This note was uploaded on 12/20/2010 for the course CSC CSCC85 taught by Professor Lorincz during the Spring '10 term at University of Toronto.

Page1 / 4

Assembler directives - Assembler directives • Examples...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online