Write a program to reverse a character string with an odd number of characters pointed at by r0. Assume the string you are copying is non?null (it contains at least one character) and that it is terminated by 0x0D (the number of characters included the terminator). You must not use an additional memory buffer (i.e., you can use only registers and the string storage itself).

What will be an ideal response?


AREA ReverseString2, CODE, READWRITE


ADR r0,Source ;r0 points to source
MOV r3,r0 ;keep a copy of the start of the source
FindEnd LDRB r2,[r0],#1 ;read a byte and update pointer
CMP r2,#0x0D ;test for end
BNE FindEnd ;continue until terminator found
Reverse LDRB r2,[r3],#1 ;REVERSE Repeat (Pick up char from front)
LDRB r4,[r0,#-1]! ; Pick up char from end
STRB r2,[r0,#0] ; Do the swap ? note offsets
STRB r4,[r3,#-1] ;
CMP r3,r0 ;have we finished
BLE Reverse
MOV r0, #0x18 ;angel_SWIreason_ReportException
LDR r1, =0x20026 ;ADP_Stopped_ApplicationExit
SVC #0x123456 ;ARM semihosting (formerly SWI)
AREA ReverseString2, DATA, READWRITE
DCD 0xFFFFFFFF ;this is just a marker to help me read the code
Source DCB "12345",0x0D
END

Computer Science & Information Technology

You might also like to view...

Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?"

a. Alpha. b. Beta. c. Release candidate. d. Continuous beta.

Computer Science & Information Technology

Which of the following is a tunneling protocol used to make VPN connections?

A. PPP B. SLIP C. PPTP D. STP

Computer Science & Information Technology

When you set a VLAN switch to the "client" state, it will not update but will hold onto its manual settings.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

When you query a database, there is a defined order in which the results are displayed.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology