Repeat problem 39, but when you transfer the string, remove any occurrences of the word “the”; for example, “and the man said” would become “and man said”.

What will be an ideal response?


There are several ways of dealing with this. One general technique would be to copy characters until you find a ‘t’ and then call a string matching algorithm to look for ‘the’. If you find ‘the’ continue copying after ‘the’. If not, continue copying at the initial ‘t’. This solution works with any string you are trying to remove.

If you don’t want a general solution, you could copy until a ‘t’ is found and then look ahead for ‘h’ and ‘e’. If you find them then continue from that point.


AREA RemoveThe, CODE, READWRITE
ADR r0,String1 ;r0 points to the source string
ADR r1,String2 ;r1 points to the dest string
Copy LDRB r2,[r0] ;read a byte (don't update the pointer)
CMP r2,#"t" ;is it a "t'?
BNE NotThe ;if not "t" then continue
LDRB r3,[r0,#1] ;get next char
CMP r3,#"h" ;is it an "h"?
BNE NotThe ;if not "h" then continue
LDRB r3,[r0,#2] ;get next char
CMP r3,#"e" ;is it an "e"?
BNE NotThe ;if not "e" then continue
ADD r0,r0,#3 ;"the" found, move source pointer on 3 bytes
B Copy ; continue with "the" removed
NotThe STRB r2,[r1,#1]! ;store char at destination and inc pointer
ADD r0,r0,#1 ;increment r0 pointer
CMP r2,#0x00 ;test for terminator(i.e., 0x00)
BNE Copy ;repeat until terminator found
SVC #0x123456 ;stop
AREA RemoveThe, code, READWRITE
String1 DCB "AB theABthe the ABthetheAB", 0x00 ;dummy string
String2 SPACE 40 ;reserve 40 bytes for copy
END

Computer Science & Information Technology

You might also like to view...

What username was sent to the FTP server?

What will be an ideal response?

Computer Science & Information Technology

To use the RPM utility in removing mode, you must be a(n) ____.

A. owner B. administrator C. supervisor D. root user

Computer Science & Information Technology

After you install the SNMP service, make sure that it is started, is set to start automatically, and is set up to have a(n) ____________________ of hosts that share use of the service.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Why is it always best to run the latest version of Mac system software?

What will be an ideal response?

Computer Science & Information Technology