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
You might also like to view...
The Windows utility program that removes unnecessary files from the hard drive is called ________
Fill in the blank(s) with correct word
In order to add and join tables in a select query, depending on how a table is created, the primary key fields:
A) must be defined. B) may or may not be defined. C) must be defined as a single field primary key. D) must not be defined.