It is a most primitive machine level language is used to make efficient code that consumes less number of clock cycles and takes less memory as compared to the high-level programming language. It is a complete hardware oriented programing language to write a program the programmer must be aware of embedded hardware. Here, we are providing basics of assembly level programming The assembly programming language is a low-level language which is developed by using mnemonics.
Before writing the program the embedded designers must have sufficient knowledge on particular hardware of the controller or processor, so first we required to know hardware of processor. The microprocessor requires a program to perform the operations that require a memory for read and save the functions. The assembly level programming is based on the memory registers.
A Register is the main part of the microprocessors and controllers which are located in the memory that provides a faster way of collecting and storing the data. If we want to manipulate data to a processor or controller by performing multiplication, addition, etc.
The microprocessor contains various kinds of registers that can be classified according to their instructions such as;. The IP register point to the current executing instruction and always works to gather with the CS segment register.
The main function of flag registers is to modify the CPU operations after mechanical functions are completed and we cannot access directly Segment registers: The CPU has consisted 4- segment registers such as CS, DS, ES, SS which is mainly used for possible to store any data in the segment registers and we can access a block of memory using segment registers.
Op-code: A single instruction is called as an op-code that can be executed by the CPU. Operands: A single piece data are called operands that can be operated by the op-code. Example, subtraction operation is performed by the operands that are subtracted by the operand. Syntax: SUB b, c. The CMP cannot directly compare the data of two memory addresses.
It checks the contents of AX and BX. In this example, BX is greater than AX. Both instructions are explained below. SHR is a logical shift right instruction used for unsigned operands. It shifts the bits of operand one by one to the right. In every shift, the least significant bit goes to the carry flag and insert zeros in the higher bit. The operand to be shifted can be a register or a memory location. Specify the number of shifts by loading the value into CL register. If the bits are to be shifted once, then specify it in the instruction.
The destination operand can be a register, or a memory location and count indicate the number of shifts. So the least significant bit which is 1 goes to carry flag and all others bits are shifted by 1. Insert 0 at the most significant bit. So, the final result obtained after shifting is whose hexadecimal value is This instruction is arithmetic right shift which deals with signed operands.
The operation of this instruction is similar to the SHR instruction. The only difference is when the bits are shifted to the right, the empty bits at MSB are filled with sign bit instead of zeros. This instruction can also be used for division of signed number by 2 if the count is 1.
There are two shift left instructions. One is used for signed operands and the other one is used for unsigned operands. Both instructions are explained in this section. The SHL is the logical left shift for unsigned operands. It shifts the operand bits to the left. The destination can be a register or a memory location. The number of shifts are stored in CL register which is then loaded in the count operand. If the number of shifts are 1, then you can directly specify it in the instructions like SHL Destination, 1.
The most significant bit of operand remains unchanged as it is a signed bit while remaining bits are shifted to the left and the empty bits at LSB are filled with zeros.
Enter your email address to subscribe to this blog and receive notifications of new posts by email. Email Address. Notify me of follow-up comments by email. Notify me of new posts by email.
0コメント