SLAU131Y October 2004 – June 2021
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 reserved.
This example shows how memory is reserved with the .space and .bes directives .
1 **************************************************
2 ** Begin assembling into the .text section. **
3 **************************************************
4 0000 .text
5
6 **************************************************
7 ** Reserve 0F0 bytes in the .text section. **
8 **************************************************
9 0000 .space 0F0h
10 00f0 0100 .word 100h, 200h
00f2 0200
11 **************************************************
12 ** Begin assembling into the .data section. **
13 **************************************************
14 0000 .data
15 0000 0049 .string "In .data"
0001 006E
0002 0020
0003 002E
0004 0064
0005 0061
0006 0074
0007 0061
16 ***************************************************
17 ** Reserve 100 bytes in the .data section; RES_1 **
18 ** points to the first byte that contains **
19 ** reserved bytes. **
20 ***************************************************
21 0008 RES_1: .space 100
22 006c 000F .word 15
23 006e 0008! .word RES_1
24 ***************************************************
25 ** Reserve 20 bits in the .data section; RES_2 **
26 ** points to the last byte that contains **
27 ** reserved bytes. **
28 ***************************************************
29 0083 RES_2: .bes 20
30 0084 0036 .word 36h
31 0086 0083! .word RES_2