Data Types and Encoding
In assembler, various data types, such as bytes, words, and double words, are used. Bytes are the smallest data unit and have 8 bits. Words have 16 bits, and double words have 32 bits. Data types are used to store integers, floating-point numbers, and characters. Data encoding involves representing information in binary form. Data can be encoded in binary, decimal, or hexadecimal format. Character encoding is done using standards such as ASCII. Understanding data types and encoding is crucial for effective programming in assembler. This course will discuss various data types and encoding techniques. Practical examples will demonstrate how to encode and decode data in assembly language.
AVR microcontrollers are classified as 8-bit devices, but the instruction word is 16-bit.
Data Types in AVR Assembler
Single bits: Can be used for logical operations and control, e.g., setting or clearing bits in registers.
Bytes, 8-bit values: The basic data type in AVR, used to store small integers,
ASCII characters, etc.
Words, 16-bit values: Consist of two bytes, used to store larger integers or memory addresses.
Double Words, 32-bit values: Consist of four bytes, used to store even larger integers or addresses.
For additional libraries, such as those used in the C language, 64-bit data can be utilized. These data require extra handling.
Encoding
Binary Encoding: Data is stored in binary format, the most fundamental form of data representation in microcontrollers.
ASCII Encoding: Characters are often stored using
ASCII encoding, where a unique 7-bit or 8-bit code represents each character.
BCD (Binary-Coded Decimal): Sometimes used for applications requiring precise decimal representation, such as digital clocks or calculators. Each decimal digit is represented by its binary equivalent.
Endianness: AVR microcontrollers typically use little-endian format, where the least significant byte is stored at the lowest memory address.