1.
Assembly level language program to find ODD/EVEN number in an array
ORG 0000h //Clear
MOV R0, #50H // Array starting address copy to R0 register
MOV R1, #05H // Count = total no of datas in the array, copy to r1 register
HERE: MOV A, @R0 // Accumulator (A – Register) directly fetching datas from array memory locations
RRC A // Rotate right with carry (If ODD number carry bit SET else RESET)
JC LOOP // If carry bit SET, jump to loop else data pointer move to next line
INC R4 // If the number is ODD or carry bit SET, increase R4 register value by 01, (Initially R4=0)
INC R0 // Move to next memory location in the array
DJNZ R1, HERE //Decrement R1 register value (Count) by 01 and check R1 is not zero
SJMP LABEL1 //Unconditionally jump to HERE
LOOP: INC R3 // If the number is EVEN or carry bit is 0, increase R3 register value by 01, (Initially R3=0)
INC R0 // Move to next memory location in the array
DJNZ R1, HERE //Decrement R1 register value (Count) by 01 and check R1 is not zero
LABEL1: MOV 40H, R3 //Copy R3 value to the location 40H
MOV 41H,R4 //Copy R4 value to the location 41H
END // Stop
2. Assembly-level language program to sort array elements in ascending order
ORG 0000H //Clear
MOV R3, #05H // Count = total no of datas in the array, copy to R3 register for outer loop operation
HERE: MOV R0, #50H // Array starting address copy to R0 register
MOV R1, #05H // Count = total no of datas in the array, copy to R1 register for inner loop operation
LABEL2: MOV A, @R0 // Accumulator (A – Register) directly fetching datas from array memory locations
INC R0 // Move to next memory location in the array
MOV B, @R0 // B – Register directly fetching datas from incremented array memory locations
CJNE A, B, LABEL // Compare the values of A and B registers if not equal jump to label
LABEL: JC LABEL1 //From previous instruction comparision if Carry bit set, jump to LABEL1 else move to next line
MOV @R0,A // Accumulator (A – Register) directly fetching datas from array memory locations
DEC R0 //Decrease count value by 01
MOV @R0,B // B – Register directly fetching datas from incremented array memory locations
INC R0 // Move to next memory location in the array
LABEL1: DJNZ R1, LABEL2 //Decrement R1 register value (Count) by 01 and check R1 is not zero
DJNZ R3, HERE //Decrement R3 register value (Count) by 01 and check R1 is not zero
END // Stop
3. Assembly-level language program for sum of n natural numbers (n=10)
ORG 00H // Clear
MOV A, #00H //Starting natural number zero copy to A register
MOV R0,#0AH // N = 10
MOV B, #01H //Second natural number zero copy to A register
REPEAT: ADD A, B // A + B = A
INC B // Increase natural number by 01
DJNZ R0, REPEAT HERE //Decrement R0 register value (Count) by 01 and check R1 is not zero
MOV 40H, A //Copy A register final value to the location 40H
END //Stop
4. Assembly-level language program for finding largest number in an array
ORG 00H // Clear
MOV R0,#05H // Count = total no of datas in the array, copy to R0 register
MOV R1,#30H // Array starting address copy to R1 register
MOV 40H, @R1 // Copy Array first data from the location 30 H to 40H
UP: INC R1 // Move to next memory location in the array
MOV A,@R1 // Accumulator (A – Register) directly fetching datas from array memory locations
CJNE A,40H,D1 //Compare the value of A register and value from the location 40H, if not equal jump to D1
D1: JC D2 // From previous comparison if carry bit set, jump to D2 else data pointer move to next line
MOV 40H,@R1 //Copy largest number value from the R1 register to the location 40H
D2: DJNZ R0,UP //Decrement R0 register value (Count) by 01 and check R0 is not zero
END //Stop
5. Assembly-level language program for Arithmetic calculator
ORG OOH
MOV A, #05H
MOV B,A
MOV A, #08H
ADD A,B
MOV R0,A
END
ORG OOH
MOV A, #05H
MOV B,A
MOV A, #08H
SUB A,B
MOV R1,A
END
ORG OOH
MOV A, #05H
MOV B,A
MOV A, #08H
MUL AB
MOV R2,A
END
ORG OOH
MOV A, #05H
MOV B,A
MOV A, #08H
DIV AB
MOV R3,A
END