ARM A32 ASSEMBLY LANGUAGE: 32-BIT ARM, NEON, VFP, THUMB by Bruce Smith

ARM A32 ASSEMBLY LANGUAGE: 32-BIT ARM, NEON, VFP, THUMB by Bruce Smith

Author:Bruce Smith [Smith, Bruce]
Language: eng
Format: azw3, epub
Tags: A32, 32-bit, Thumb, machine code, A64, single boiard computers, computers, programming, ARM Assembler, T32
ISBN: 9780992391690
Publisher: Bruce Smith Books
Published: 2017-05-20T04:00:00+00:00


Program 18a. Use of .byte and .equ directives.

/* Use of byte and equ to sum a set of numbers */

.global _start

_start:

LDR R1, =values

LDR R2, =endvalues

MOV R0, #0

_loop:

LDRB R3, [R1], #increment

ADD R0, R0, R3

CMP R1, R2

BNE _loop

_exit:

MOV R7, #1

SWI 0

.data

.equ increment, 1

values:

.byte 1,2,3,4,5,6,7,8,9

endvalues:

The .byte directive allows for a sequence of values separated by commas to be stored sequentially in memory. As the directive suggests these values must be in the range 0-255.

The .equ directive allows an immediate value to be assigned to a name. The name can then be used in your source files. This is handy in that if you need to change the value at any point you just have to change the .equ definition and not any and every reference to it in the source.

If you look at the .data section of Program 18a you can see that the constant ‘increment’ has been assigned the value 1. You can see how this is used as the post-indexing counter at the start of the _loop routine.

The label values: is used to mark the start of the .byte definition. A second label called endvalues: is used to mark the end of the .byte sequence. This is a handy technique to use when dealing with tables or arrays of data as a simple CMP test sees if the end of the sequence has been reached. The program illustrates this.

If you assemble, link and run Program 18a and then enter:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.