go to previous page   go to home page   go to next page


A zero byte (also called a null byte).

Null-terminated String

A null-terminated string is a sequence of ASCII characters, one to a byte, followed by a zero byte (a null byte). null-terminated strings are common in C and C++. Here is how a string is declared in assembly language:

str:    .asciiz "Time is the ghost of space."

The characters are placed in memory in order, starting with the 'T'. The picture shows this. The blank bytes are filled with ASCII space (0x20). The last byte is filled with 0x00, represented with a slash.

Time is the ghost of space

Here is what it looks like in the data display of SPIM running on a Windows PC. The characters are placed in memory in sequential order beginning with 'T' (at address 0x10000000). This is hard to see in the display.

SPIM display

The display is aimed at displaying 32-bit little-endian integers. Every group of four bytes is displayed from right to left. (For 32-bit integers, this puts the most significant byte of the integers on the left, where you would expect it when integers are printed.) Unfortunately, this makes the display hard to read for data other than integers.

'T' is at address 0x10000000.
'i' is at address 0x10000001.
'm' is at address 0x10000002.
'e' is at address 0x10000003.

In the red text, space (0x20) is shown as '_'. The null byte is at address 0x1000001B.


What character is at 0x10000005     ?