More on Assembly Language (Shift and Rotate Instructions (SHL and SHR…
More on Assembly Language
Data Exchange and Translate Instructions
This instruction exchanges the 8, 16, or 32 bit source and destination operands. It is very usefull since we do not need a third register to hold a temporary value to perform the exchange.
It can be used to perform character translation. The EBX must be loaded with the address of the translation table and AL and hines value to the table.
Shift and Rotate Instructions
SHL and SHR
This are used to shift left or right from 1 to 31 times. It has two different formats. --shl(or shr) destination, count-- or --shl(or shr) destination, CL--. The last bit that is shifted out of the number is placed on the carry flag(CF).
ROL and ROR
The rol and ror instrucciones word very similar to the shifting. The only difference is that the bit rotated out of the number if the one that is inserted to create the new number, the bit shifted out is also copied to the CF. This happens on rotation without carry.
RCR and RCL
In the rotación through carry the bit rotated out is transfered to the CF and the bit on the CF is inserted in the new number. Rotation through carry is written RCL or RCR. They have the same format as shifts.
It has a format of --name EQU expression--.
With this format expression is assigned to name. It is recommended to use capital letters when choosing the name used to avoid confusion with variables names.
When applied --STUDENTS EQU 20 -- the instruction --mov ECX, 90-- is the same as --mov ECX, STUDENTS--.
It can be used to assign constant such as EQU but this instructor allows redefinition. It is case sensitive so names as b or B are treated different. For unsensitive instructor %iassign is used.
--%assign i j+1-- then later in the program it can be redefine to --%assign i j+3--.
It works similar to #define in C language. This directive is case sensitive. For insensitive instruction use %idefine. It can be used very similar to assing but it can be used to define string constants too. It allows redefinition.
--%define X1 [EBP + 4]-- and it can be redefined later in the program.