Question: In this lab, you are given a character string in memory, and you must search through the character string to find the ASCII characters HELP

In this lab, you are given a character string in memory, and you must search through the character string to find the ASCII characters HELP in order, though not necessarily sequentially. You may refer to the ASCII table at the bottom of this assignment or here: https://simple.wikipedia.org/wiki/ASCII. The address of the first time each character is found should be stored in registers r4, r5, r6, and r7 (the first H instance in r4, the first E instance in r5, etc.). If and only if all the letters are found in order, the string is considered valid, and the address of the first instance of H should also be stored in r0. If the letters are not found in order, 0x00 should be stored in r0 instead. To make life easier for you, the character string of all letters will be null terminated (will end with a value of 0, which is the default value of memory beyond the DCB). The program will terminate when the P is found or when the null terminator is reached, whichever comes first.

Example: If the searched string started at 0x800 and read: HQEQLQPQ, 0x800 should be stored in r0 at the end of the program. However, if the string read PLEHEL, nothing will be stored in r0.

Code Given:

For this lab, you are given an outline (that you may choose not to use) of the entire program. The program utilizes branches, which you should be familiar enough with to utilize the given code:

ENTRY

FindH

BEQ FindE ;if H is found, branch to the E finder

BNE FindH ;if 0 terminator not found, keep searching for H

BEQ STOP ;if 0 terminator found, branch to stop

FindE

BEQ FindL ;if E is found, branch to the L finder

BNE FindE ;if 0 terminator not found, keep searching for E

BEQ STOP ;if 0 terminator found, branch to stop

FindL

BEQ FindP ;if L is found, branch to the P finder

BNE FindL ;if 0 terminator not found, keep searching for L

BEQ STOP ;if 0 terminator found, branch to stop

FindP

BEQ STOP ;if P is found, branch to the stop

BNE FindP ;if 0 terminator not found, keep searching for P

BEQ STOP ;if 0 terminator found, branch to stop

B STOP

TEST_DATA DCB 'p','s','d','f','n','O','L','H','H','N','O','H','D','P','[','[','H','E','L','k','h','j','x','v','c','p','h','e','l','H','E','L','L','p','p','p','H','E','L','P'

STOP END

; HINT: Be careful that Microsoft Word does not change the apostrophe to an

; unrecognizable character for VisUAL. You may want to type this line in manually

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!