# 2.4: Data types

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$$$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

While an assembly language has no explicit data types, there are rules for how the data is accessed and stored. This section defines the rules for data access.

In this CPU, a word is 16 bits. All memory locations are 16 bits wide, and words, not bytes, are addressable. Thus the value at the address 0 is contained in bits 0...15, the value at address 1 is contained in the bits 16...31, etc.

Each address refers to a 2-byte quantity or word. If that memory location is in data memory the value is an integer number; if the address is in text memory it is a 2-byte instruction.

There are a total of 256 memory locations (addressable words) in both the data memory and the text (program) memory. The addresses for both of these memories start at 0 and run to 255, which corresponds to an 8-bit unsigned value. Though the memory addresses overlap, the context of the request will determine which memory to use. Only the \$pc will be used to access text memory, and all other addresses will refer to data memory.

When referencing values in instructions (immediate values and addresses) an 8 bit value is used. This 8-bit value can either be given as a numeric value, or as a valid label to an address somewhere in the program. When used as an address, this 8-bit value will be is unsigned, and refers to a number between 0...255. For the instructions add, sub, and stor, this is an addresses in the data segment. For branch instructions, beqz, the 8-bit address refers to the text segment.

For immediate instructions, addi and subi, the value of the operand is an 8-bit integer value, and has a value from -128...127.

This page titled 2.4: Data types is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Charles W. Kann III via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.