Haru
Haru

Reputation: 91

ARM Cortex-M3: Store digits/string in memory

I'm studying ARM Cortex-M3 with Thumb-2 instruction. I found some code that declares some data areas.

AREA RESET, DATA, READONLY
DULIEU  DCB &0F,&0D,&7,&0A

The first code is for declaring hexa number: FD7A. What does the'&' mean before each byte?

AREA Data1, DATA, READONLY
xau DCB "Hello, World", CR

So how can the string "Hello, World" be stored in a byte? And what is CR?

Upvotes: 0

Views: 279

Answers (1)

Nate Eldredge
Nate Eldredge

Reputation: 58142

The ARM assembler reference says that & is used as a prefix for hexadecimal numbers, just like 0x. So &0F is equivalent to 0x0F, the number fifteen.

The DCB directive can be used to assemble multiple bytes, not just one. So DCB "Hello, World" assembles the bytes H, e, l, l, o, etc, in sequence.

I don't think CR is defined by the assembler, but it is almost certainly a macro or equate for the number 10, the ASCII carriage return character, aka \r. You'll probably find it defined higher up in your program, or in some include file.

Upvotes: 1

Related Questions