Computer Organization Assembly Language University of Sargodha Lahore
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed
LOOP Instruction �Loop instruction is use to repeat group of statements a particular number of times �CX register is use for this purpose �Initialize CX � use label �Body �LOOP label
JCXZ Instruction �Jmp if CX is 0 �This statement may be use before loop �You may loop instruction is executed at least once �If CX contain 0 when loop enter it will become FFFFh. �And loop run 65535 more times �To prevent this we use above instruction
Logic instructions �AND destination, source �OR destination, source �XOR destination, source (same 0 different 1) �The result of the operation store in destination register
Logic instruction �Effect on Flag �SF, ZF, PF reflect the result �AF is undefined �CF, OF =0 �One use of AND , OR and XOR is to selective modify the bits of the registers or to make the mask
Logic register �AND is use for clear. 0 mask is use to clear the bits of destination register �OR is use to set the particular bit of destination register. 1 is use for this purpose �XOR is use to compliment the bit of destination register. 1 use for bit compliment and 0 is to preserves the bits
Not instruction �This instruction is use for 1 s compliment of the operand �Syntax: �NOT Destination
TEST instruction �This instruction performs the AND instruction but it does not change the content of destination register. �TEST destination, source �Effect on Flag �SF, ZF, PF �AF is undefined �CF, OF is 0
Usage of TEST �It can be use to examine the individual bit of operand �Example �Jump on the label BELOW if AL contain even number �TEST AL, 1 �JZ BELOW
Shift Instruction �Shift and Rotate instruction shift the bits in destination operands �For one or more positions in left or right position �For shift instruction the bits shifted out are lost �For rotate bits shifted out are again enter form the other end
Shift Instruction �The instruction have two possible format �Opcode �For destination, 1 rotate n bits �Opcode destination, cl �Cl contain the value of N �Destination can be a register or memory
SHL Instruction � Shift Left instruction shift the bits to the lefts � Example � SHL Al, 1 � OR � SHL Al, Cl � The value of CL remain the same after execution � This instruction multiply the operand by 2 � Most Significant bit go to the Carry Flag � 0 is appended at the start
�Problem �Write a program multiply the value of AX by 8 �Assume that overflow will not occurs.
SHR Instruction � Shift Right instruction shift the bits to the right � Example � SHR Al, 1 � OR � SHR Al, Cl � The value of CL remain the same after execution � This instruction divide the operand by 2 � Least Significant bit go to the Carry Flag � 0 is appended at the End
Rotate Left �Rotate Left instruction shift the bits to the lefts �Example �ROL Al, 1 �OR �ROL Al, Cl �The value of CL remain the same after execution �Most Significant bit go to the Carry Flag and at the start of operands
Rotate Right �Rotate right Right instruction shift the bits to the �Example �ROR Al, 1 �OR �ROR Al, Cl �The value of CL remain the same after execution �least Significant bit go to the Carry Flag and at the end of operands
Rotate Carry Left �Rotate Left instruction shift the bits to the lefts �Example �RCL Al, 1 �OR �RCL Al, Cl �The value of CL remain the same after execution �Most Significant bit go to the Carry Flag (CF) and CF go at the start of operands
Rotate Carry Right �Rotate lefts Right instruction shift the bits to the �Example �RCR Al, 1 �OR �RCR Al, Cl �The value of CL remain the same after execution �Least Significant bit go to the Carry Flag (CF) and CF go at the start of operands
�Thanks
- Slides: 19