I caught a cold, my head was heavy, and my mind was slow, but I barely understood it. I will look back later.
The offset adjustment involves three pseudo commands: Even, align, org, and an offset counter value "$ ".
First, you must understand what the offset is. The offset mainly refers to the distance from the starting address of a data segment to the memory unit we define.
The purpose of adjusting the offset is to quickly obtain the content of a word.
The even is an even-alignment pseudocommand.
This command is used to allocate the memory variables defined in the next definition starting from the next even address unit. If the next offset is an even address, this command does not take effect. Otherwise, the AssemblyProgramOne byte is left blank and memory variables are allocated from the next even address.
Why is it faster to access words at even locations?
For example, access the words at the 5 h location
16-bit CPU reads two bytes each time
0 h 1 h
2 H 3 H
4 H 5 h
6 H 7 h,
In this case, the CPU needs to read 4 h, 5 h, 6 h, and 7 h, and then splice the content on the 5 h and the content on the 6 h, which is equivalent to reading twice and splicing once, therefore, it is faster to access a word at an even number.
Align is alignment pseudocommandThe role of algin is similar to that of the even-alignment command to improve efficiency. However, algin is more flexible in its pseudo-Directive, instead of specifying the next variable to be allocated from the even address unit, instead, it is allocated from the memory unit that can be divisible by the next operand.
For example
Align 8
If the current memory unit is allocated to 13 H, the next memory unit will be allocated from 16 h, and leave no space between 13-16 h.
Org is a pseudo command to adjust the offset., Format bit
Org numeric expression
The function is to tell the assembler compiler that the following memory variables are allocated from the address specified by the value expression.
If org is used to specify an address to be allocated, the variable may overlap.
Offset counter value
The preceding three pseudo commands are used to change the offset counter value. But how can we reference the offset counter value in the program? assembly language provides a symbol $ to reference the offset counter value.
For example:
W1 DW $, $
Org $ + 3
B1 dB 43 H
Shows the memory unit distribution.