MPMC Assignment-1
MPMC Assignment-1
MPMC Assignment-1
31/08/2020
AAA converts the result of the addition of two valid unpacked BCD digits to a valid 2-
digit BCD number and takes the AL register as its implicit operand. Two operands of the
addition must have its lower 4 bits contain a number in the range from 0- 9.The AAA instruction
then adjust AL so that it contains a correct BCD digit. If the addition produce carry (AF=1), the
AH register is incremented and the carry CF and auxiliary carry AF flags are set to 1. If the
addition did not produce a decimal carry, CF and AF are cleared to 0 and AH is not altered. In
both cases the higher 4 bits of AL are cleared to 0. AAA will adjust the result of the two ASCII
characters that were in the range from 30h (“0”) to 39h(“9”).This is because the lower 4 bits of
those character fall in the range of 0-9.The result of addition is not a ASCII character but it is a
BCD digit.
Example:
CWD Instruction:
CWD converts the 16 bit signed value in the AX register into an equivalent 32 bit signed
value in DX: AX register pair by duplicating the sign bit to the left.
The CWD instruction sets all the bits in the DX register to the same sign bit of the AX
register. The effect is to create a 32- bit signed result that has same integer value as the original
16 bit operand.
Example:
Assume AX contains C435h. If the CWD instruction is executed, DX will contain FFFFh
since bit 15 (MSB) of AX was 1. Both the original value of AX (C435h) and resulting value of
DX: AX (FFFFC435h) represents the same signed number.
LAHF Instruction:
LAHF instruction copies the value of SF, ZF, AF, PF, and CF into bits of 7, 6, 4, 2 and 0
respectively of AH register. This LAHF instruction was provided to make conversion of
assembly language programs written for 8080 and 8085 to 8086 easier.
MOVS/MOVSB/MOVSW Instruction:
Example:
RCL Instruction:
RCL instruction rotates the bits in the operand specified by op1 towards left by the count
specified in op2.The operation is circular, the MSB of operand is rotated into a carry flag and the
bit in the CF is rotated around into the LSB of operand.
Example:
CLC ; put 0 in CF
ROL Instruction:
ROL instruction rotates the bits in the operand specified by op1 towards left by the count
specified in op2. ROL moves each bit in the operand to next higher bit position. The higher order
bit is moved to lower order position. Last bit rotated is copied into carry flag.
Example:
SAHF Instruction:
SAHF copies the value of bits 7, 6, 4, 2, 0 of the AH register into the SF, ZF, AF, PF, and
CF respectively. This instruction was provided to make easier conversion of assembly language
program written for 8080 and 8085 to 8086.
2. Analyze an 8086 ALP to find the sum of numbers in an array of 10 elements.
DATA SEGMENT
ARR DB 5, 3, 7, 1, 9, 2, 6, 8, 4, 10
LEN DW $ -ARR
SUM DW?
DATA ENDS
CODE SEGMENT
START:
MOV DS, AX
MOV AX, 0
REPEAT:
MOV BH,0
ADD AX, BX
INC SI
LOOP REPEAT
MOV SUM, AX
INT 21H
CODE ENDS
END SRART
DATA SEGMENT
BLOCK1 DB ‘MALAYALAM’
PAL DB 00H
DATA ENDS
INT 21H
INT 3H
ENDM
EXTRA SEGMENT
EXTRA ENDS
CODE SEGMENT
MOV DS, AX
MOV ES, AX
CLD
REPZ CMPSB
JNZ SKIP
PRINT MSG1
CODE ENDS
END START