SPRUI03E June 2015 – January 2023
Reserve Space
[label] .space size in bytes
[label] .bes size in bytes
The .spaceand .bes directives reserve the number of bytes given by size in bytes in the current section and fill them with 0s. The section program counter is incremented to point to the word following the reserved space.
When you use a label with the .space directive, it points to the first byte reserved. When you use a label with the .bes directive, it points to the last byte reserved.
This example shows how memory is reserved with the .space and .bes directives .
1 *****************************************************
2 ** Begin assembling into the .text section. **
3 **************************************************
4 00000000 .text
5 **************************************************
6 ** Reserve 0F0 bytes (60 words in .text) **
7 **************************************************
8 00000000 .space 0F0h
9 000000f0 00000100 .word 100h, 200h
000000f4 00000200
10 **************************************************
11 ** Begin assembling into the .data section. **
12 **************************************************
13 00000000 .data
14 00000000 00000049 .string "In .data"
00000001 0000006E
00000002 00000020
00000003 0000002E
00000004 00000064
00000005 00000061
00000006 00000074
00000007 00000061
15 **************************************************
16 ** Reserve 100 bytes in the .data section; **
17 ** RES_1 points to the first word **
18 ** that contains reserved bytes. **
19 **************************************************
20 00000008 RES_1: .space 100
21 0000006c 0000000F .word 15
22 00000070 00000008" .word RES_1
23 **************************************************
24 ** Reserve 20 bytes in the .data section; **
25 ** RES_2 points to the last word **
26 ** that contains reserved bytes. **
27 **************************************************
28 00000087 RES_2: .bes 20
29 00000088 00000036 .word 36h
30 0000008c 00000087" .word RES_2