Assembler directives - Assembler directives • Examples...

Info icon This 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
Image of page 1

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

View Full Document Right Arrow Icon
Examples of Assembler directives:
Image of page 2
Image of page 3

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern