Professional Documents
Culture Documents
VHDL PROGRAMMING
FILE
Abhinav Malhotra
03/EC/07
INDEX
1. To find out the largest number from a given unordered array of 8- bit numbers,
stored in locations starting from a known address.
2. To find out the number of even and odd numbers from a given series of 16-bit
hexadecimal numbers.
3. To find out the number of positive and negative numbers from a given series of
signed hexadecimal numbers.
4. To move a string of data words from offset 2000H to 3000H, when length is 0FH.
5. To arrange a given series of hexadecimal bytes in ascending order.
6. To perform one byte BCD addition.
7. To perform addition, subtraction, multiplication and division of numbers.
8. To decide whether the parity of a given number is even or odd. If even, set DL to
00, else 01. The given number may be a multi byte number.
9. To convert a BCD number to an equivalent binary number.
10. To find out the square root of a given number, assuming it to be a perfect square.
Experiment No:1
AIM: To find out the largest number from a given unordered array of 8- bit numbers,
stored in locations starting from a known address.
Logic: The 1st number of the array is taken in a register, say AL. The 2nd number of
array is then compared with the 1st one. If the 1st one is greater than 2nd one, it is left
unchanged. However, if the 2nd one is greater than 1st, 2nd number replaces the 1st one
in the AL register. The procedure is repeated for every number in array and thus requires
15 iterations.
AIM: To find out the number of even and odd numbers from a given series of 16-bit
hexadecimal numbers.
MOV AX,1000H
MOV DS,AX
MOV BX,0000H
MOV DX,0000H
MOV CX,13H
MOV SI,100H
L2: MOV AX,[SI]
RCR AX,01H
JNC L1
JMP L5
L1: INC BL
L5: INC SI
INC SI
LOOP L2
MOV CX,13H
MOV SI,100H
L3: MOV AX,[SI]
RCL AX,01H
JNC L4
JMP L6
L4: INC DL
L6: INC SI
INC SI
LOOP L3
MOV AL,14H
SUB AL,DL
MOV DH,AL
MOV AL,14H
SUB AL,BL
MOV BH,AL
HLT
Experiment No: 3
AIM: To find out the number of positive and negative numbers from a given series of
signed hexadecimal numbers.
Logic: Take a number and rotate it left through carry. The status of carry flag will give
the sign of the number. If CF=1, the number is negative, otherwise positive.
AIM: To move a string of data words from offset 2000H to 3000H, when length is 0FH.
MOV SI,2000H
MOV DI,3000H
MOV CX,0FH
AGAIN: MOV AX,[SI]
MOV [DI],AX
ADD SI,02H
ADD DI,02H
DEC CX
JNZ AGAIN
HLT
Experiment No: 5
AIM: .To decide whether the parity of a given number is even or odd. If even, set DL to
00, else 01. The given number may be a multi byte number.
MOV CX,08H
MOV AX,2000H
MOV DS,AX
MOV SI,100H
MOV AX,35H
L1: SHR AX,01H
RCR BX,01H
LOOP L1
HLT
Experiment No: 10
AIM: To find out the square root of a given number, assuming it to be a perfect square.