Tabrez Coa 1
Tabrez Coa 1
School of Engineering
Assignment 1
USN: ENG23CS0451
Section: G
Semester: 4th
Assignment No: 1
Date: 21-05-2025
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
MOV R6, #0x00000000
loop B loop
END
OutPut
Q.2
Write a program that takes character data “a” through “z” and
returns the character in uppercase.
</> Code
__main
MOV R1, #'a'
loop B loop
END
OutPut
C\Users\dewi\OneDrive\Documents\CoA Assignments\Coa.uvproj - µVision4
File Edit View Project Flash Debug Peripherals Tools SVCS Window Help
0 0 =
Registers Disassembly
8:
Register Value
9: Subtract 0x20 to convert to uppercase
Current
0x00000000 E3A01061 MOV R1,#0x00000061
RO 0x00000000
10: SUB R2, R1, #0x20 : R2- Rl 0x20 ? should be Ox41 ('A')
R1 0x00000061
11:
R2 0x00000041
0x00000004 E2412020 SUB R2, R1, #0x00000020
R3 0x00000000
12: loop B 10op
R4 0x00000000
0x00000008 EAFFFFFE B 0x00000008
R5 0x00000000
0x00000000 00000000 ANDEO RO.RO.RO
R6
R7 0x00000000
R8 0x00000000
00000000%0 main.s
R9
AREA RESET, CODE, READONLY
R10 0x00000000
ENTRY
R11 0x00000000
EXPORT main
R12 0x00000000
R13 (SP) 0x00000000
00000000*0 main
R14 (LR)
Let's assume Rl has lowercase character 'a' 0x61
R15 (PC) 0x00000008
MOV Rl, #'a RI- 0x61
7890)
:
CPSR 0x00000003
00000000*0
F SPSR
Subtract 0x20 to convert to uppercase
User/System SUB R2, R1. #0x20 R2 R1- 0x20 ? should be 0x41 ('A')
Fast Interrupt
Intermrupt
12 loop B 1oop
Supervisor END
13
Abort 14
Undefined
Ε Intemal
PC $ 0x00000008
Project Registers
ASSIGN BreakDisable BreakEnable BreakKill BreakList BreakSet BreakAccess COVERAGE DEFINE DIR Call Stack + Locals Memory 1
Real-Time Agent: Target Stopped Simulation t1: 22.65265467 sec L:12 C:1 CAP NUM SCRL OVR
Q.4
Write a program to count the number of ones and zeros in two
consecutive memory locations.
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
MOV R0, #0xF0
ORR R0, R0, R0, LSL #8
ORR R0, R0, R0, LSL #16
MOV R1, #0
MOV R2, #0
MOV R3, #32
check_bit
TST R0, #1
ADDNE R1, R1, #1
ADDEQ R2, R2, #1
LSR R0, R0, #1
SUBS R3, R3, #1
BNE check_bit
loop B loop
END
OutPut
Write a program to arrange a series of 32-bit number in
ascending and descending order.
</>Code
Q.6
__main
LDR R0, =array MOV R1, #5
sort_outer
MOV R2, #0
sort_inner
CMP R2, R1 BGE sort_done
skip_swap
ADD R2, R2, #1
SUB R6, R1, #1
CMP R2, R6 BLT sort_inner
OutPut
Q.5 Write a program to find the largest and smallest number in an array
of 32 numbers.
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
LDR R0, =array MOV R1, #5
loop
CMP R2, R1 BGE done
CMP R5, R3
BLS check_min
MOV R3, R5
check_min
CMP R5, R4
BGE next
MOV R4, R5 next
ADD R2, R2, #1
B loop
done
B done
AREA data, DATA, READWRITE
array DCD 45, 11, 23, 90, 3
END
OutPut
Q.6 Write a program to add an array of 16-bit numbers and store the
32bit result in internal RAM.
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
LDR R0, =array
MOV R1, #5
MOV R2, #0 MOV R3, #0
loop
CMP R3, R1 BGE done
done
LDR R5, =result STR R2, [R5]
B done
OutPut
Q.7 Write a program to search a key element in a list of ‘n’ elements.
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
LDR R0, =array
MOV R1, #6
LDR R2, =key
LDR R3, [R2]
MOV R4, #0 MOV R5, #-1
search_loop
CMP R4, R1 BGE not_found
found
LDR R7, =result
STR R4, [R7]
B end
not_found
LDR R7, =result STR R5, [R7]
end
B end
AREA data, DATA, READWRITE
array DCD 22, 45, 67, 90, 12, 88 key
DCD 90
result DCD 0
END
OutPut
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
LDR R0, =string
LDR R1, =result
MOV R2, #0 find_len
LDRB R3, [R0, R2]
CMP R3, #0
BEQ check_palindrome
ADD R2, R2, #1 B find_len
check_palindrome
MOV R4, #0
SUB R5, R2, #1 MOV R6, #1
compare_loop
CMP R4, R5 BGE done_check
not_palindrome
MOV R6, #0
done_check
STR R6, [R1]
end
B end
AREA data, DATA,
READWRITE string DCB "madam",
0 result DCD 0
END
Output
Q.9 Write a program to count the number of ones and zeros in two
consecutive memory locations.
</> Code
AREA RESET, CODE, READONLY
ENTRY
EXPORT __main
__main
LDR R0, =data
LDR R1, [R0]
LDR R2, [R0, #4]
MOV R3, #0
MOV R4, #0
END
OutPut