microcontroller-vtu-4th-sem-lab-programs

microcontroller-vtu-4th-sem-lab-programs

2nd program

AREA MYCODE, CODE, READONLY
	 ENTRY
	 LDR R1, Numb1
	 LDR R2, Numb2
	 ADD R3,R1,R2
	 LDR R4, Numb3
	 LDR R5, Numb4
	 SUB R6,R4,R5
	 LDR R7, Numb5
	 LDR R8, Numb6
	 AND R9,R7,R8
	 LDR R10, Numb7
	 LDR R11, Numb8
	 ORR R12,R10,R11
SS B SS
Numb1 DCD 0X00000001
Numb2 DCD 0X00000002
Numb3 DCD 0X00000003
Numb4 DCD 0X00000004
Numb5 DCD 0X00000005
Numb6 DCD 0X00000006
Numb7 DCD 0X00000007
Numb8 DCD 0X00000008
END

1st program

	AREA MYCODE, CODE, READONLY
	ENTRY
	MOV R1, #04
	MOV R2, #06
	ADD R3, R2, R1
SS B SS
	END	

2nd program

	 AREA MYCODE, CODE, READONLY
	 ENTRY
	 LDR R1, NUM1
	 LDR R2, NUM2
	 ADD R3, R1, R2
	 SUB R4, R1, R2
	 AND R5, R1, R2
	 ORR R6, R1, R2
SS B SS
NUM1 DCD 0X00000001
NUM2 DCD 0X00000000
	END

3rd program

	 AREA MYCODE, CODE, READONLY
	 ENTRY
	 LDR R0, =ARR
	 LDRH R1, [R0]
	 ADD R0, #2
	 LDRH R2, [R0]
	 MUL R3, R2, R1
	 LDR R4, =RES
	 STR R3, [R4]
SS B SS
ARR DCW 2_0101, 2_0010
	AREA DATA1, DATA, READWRITE
RES DCD 0X0
	END

4th program

	AREA MYCODE, CODE, READONLY
	ENTRY
	MOV R1, #10
	LDR R2, =ARR
	MOV R4, #0
NEXT LDR R3, [R2], #4
	ADD R4, R3
	SUBS R1, #1
	BNE NEXT
SS B SS
ARR DCD 1,2,3,4,5,6,7,8,9,10
	END

5th (highest) program

	AREA MYCODE, CODE, READONLY
	ENTRY
	MOV R5, #5
	LDR R1, =ARR
	LDR R2, [R1], #4
LOOP LDR R4, [R1], #4
	CMP R2, R4
	BHI NEXT
	MOV R2, R4
NEXT SUBS R5, R5, #1
	BNE LOOP
SS B SS
ARR DCD 0X23, 0X45, 0X65, 0X76, 0X12, 0X99
	END

5th (lowest0 Program

	AREA MYCODE, CODE, READONLY
	ENTRY
	MOV R5, #5
	LDR R1, =ARR
	LDR R2, [R1], #4
LOOP LDR R4, [R1], #4
	CMP R2, R4
	BLS NEXT
	MOV R2, R4
NEXT SUBS R5, R5, #1
	BNE LOOP
SS B SS
ARR DCD 0X23, 0X45, 0X65, 0X76, 0X12, 0X99
	END

6th program

	AREA MYCODE,CODE, READONLY
	ENTRY
	MOV R2, #0
	MOV R3, #0
	MOV R7, #2
	LDR R6, =VAL
LOOP MOV R1, #32
	LDR R0, [R6], #4
LOOP0 MOVS R0, R0, ROR #1
	BHI ONES
ZEROS ADD R3, R3, #1
	B LOOP1
ONES ADD R2, R2, #1
	B LOOP1
LOOP1 SUBS R1, R1, #1
	BNE LOOP0
	SUBS R7, R7, #1
	CMP R7, #0
	BNE LOOP
SS B SS
VAL DCD 0X11111111, 0XAA55AA55
	END

10th program

	AREA IRQ_FIQ_control, CODE, READONLY
	ENTRY
START
	BL EnableIRQ
	BL DisableIRQ
	BL EnableFIQ
	BL DisableFIQ
	B START
EnableIRQ
	MRS R0, CPSR
	BIC R0, R0, #0X80
	MSR CPSR_c, R0
	MOV PC,LR
DisableIRQ
	MRS R0, CPSR
	ORR R0, R0, #0X80
	MSR CPSR_c, R0
	MOV PC,LR
EnableFIQ
	MRS R0, CPSR
	BIC R0, R0, #0X40
	MSR CPSR_c, R0
	MOV PC,LR
DisableFIQ
	MRS R0, CPSR
	ORR R0, R0, #0X40
	MSR CPSR_c, R0
	MOV PC,LR	 
END

10 th program ( short version )

	AREA IRQ_FIQ_control, CODE, READONLY
	ENTRY
START
	BL EnableIRQ_FIQ
	BL DisableIRQ_FIQ
	 B START
EnableIRQ_FIQ
	MRS R0, CPSR
	BIC R0, R0, #0XC0
	MSR CPSR_c, R0
	MOV PC,LR
DisableIRQ_FIQ
	MRS R0, CPSR
	ORR R0, R0, #0XC0
	MSR CPSR_c, R0
	MOV PC,LR	 
END