Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: It is a question down below and i put my code and answer with my output so can someone told me please what should

Question: It is a question down below and i put my code and answer with my output so can someone told me please what should I add?

Scatter Names

Practice with: Input validation, loops, branching, and selection.

Write a Pep 9 assembly language program that satisfies the following requirements:

1) Get user input

a. FirstName - Read in a character from the user. You can a assume the user will type in a character. However, enforce the user to type in one of the following valid capital letters {G, D, R, A}. If they type an invalid letter, display an error message and prompt them again for this first letter. Do this until they type in a correct CAPTIAL letter. Anything other than {G, D, R, A} is considered invalid.

b. Last Name- Read in another character from the user {S, K, M, B}. Use the same process in step a to ensure a valid character is typed in.

c. n -Use DECI to get a number from the user. Assume that the user will type in a number between -32768 and 32767. If the user types in a number less than or equal to 0, display a message telling them to re-enter their number before moving on. Continue to display errors and prompting them with DECI until they type in a positive integer.

d. Ascending/Descending- Read in a character from the user with a capital letter {A,D}. Use the same processes in step a to ensure a valid character is typed.

2) You are going to display the First Name LastName n times with either ascending or descending numbers next to each name as defined in step d. Be sure to display ONE NAME PER LINE.

a. Note the first name is only an abbreviation. You will display a complete first name and complete last name. The first names are: G - Gerald, D - Dave, R - Ryan, A - Adam. The last names are S - Sitchards, K - Kinyeck, M - Murry, B - Bonoughe

. Note that the user can pick ANY first name with ANY last name.

Sample Input g W G s S -12 4 a 3 D

Sample Output Invalid character, try again {G, D, R, A}. Invalid character, try again {G, D, R, A}. Invalid character, try again {S, K, M, B} Number must be positive Invalid character, try again {A,D} Invalid character, try again {A,D} 4 Gerald Sitchards 3 Gerald Sitchards 2 Gerald Sitchards 1 Gerald Sitchards

My Code and it's Input and Output:

BR main,i

char1: .BLOCK 1

char2: .BLOCK 1

char3: .BLOCK 1

num1: .BLOCK 2

num2: .BLOCK 2

error1: .ASCII "Invalid Input, try again \x00"

error2: .ASCII "{G,D,R,A).\x0A\x00"

error3: .ASCII "{S,K,M,B}.\x0A\x00"

error4: .ASCII "{A,D}.\x0A\x00"

error5: .ASCII "Number must be positive\x0A\x00"

adam: .ASCII "Adam \x00"

dave: .ASCII "Dave \x00"

gerald: .ASCII "Gerald \x00"

ryan: .ASCII "Ryan \x00"

stichard: .ASCII "Stichards\x0A\x00"

kinyeck: .ASCII "Kinyeck\x0A\x00"

murry: .ASCII "Murry\x0A\x00"

bonoguhe: .ASCII "Bonoguhe\x0A\x00"

main: LDWA 0,i ;for clear the register

LDWX 0,i

LDBX 0x0A,i

LDBA 0xFC15,d

STBA char1,d

CPWA 0x0A,i

BREQ main,i

CPWA 0x41,i ;memory cell number for A

BREQ lastName,i

CPWA 0x44,i ;memory cell number for D

BREQ lastName,i

CPWA 0x47,i ;memory cell number for G

BREQ lastName,i

CPWA 0x52,i ;memory cell number for R

BREQ lastName,i

BRNE fNameErr,i

BR endIf,i

fNameErr: STRO error1,d

STRO error2,d

BR main,i

lastName: LDBA 0xFC15,d

STBX 0xFC16,d

STBA char2,d

CPWA 0x0A,i

BREQ lastName,i

CPWA 0x53,i ;memory cell number for S

BREQ numLName,i

CPWA 0x4B,i ;memory cell number for K

BREQ numLName,i

CPWA 0x4D,i ;memory cell number for M

BREQ numLName,i

CPWA 0x42,i ;memory cell number for B

BREQ numLName,i

BRNE lNameErr,i

BR endIf,i

lNameErr: STRO error1,d

STRO error3,d

BR lastName,i

numLName: DECI num1,d

LDWA num1,d

CPWA 0,i

BRLT numError,i

CPWA 0x0A,i

BREQ numLName,i

BR AOrD,i

numError: STRO error5,d

BR numLName

AOrD: LDBA 0xFC15,d

STBX 0xFC16,d

STBA char3,d

LDWX 0,i

CPWA 0x41,i

BREQ ascendOr,i

CPWA 0x44,i

BREQ dscendOr,i

CPWA 0x0A,i

BREQ AOrD,i

BRNE AOrDEror,i

BR endIf,i

AOrDEror: STRO error1,d

STRO error4,d

BR AOrD,i

ascendOr: ADDX 1,i

STWX num2,d

DECO num2,d

LDBA char1,d

CPWA 0x41,i

BREQ fstNameA,i

CPWA 0x44,i

BREQ fstNameD,i

CPWA 0x47,i

BREQ fstNameG,i

CPWA 0x52,i

BREQ fstNameR,i

CPWX num1,d

BREQ endIf,i

dscendOr: LDWX num1,d

SUBX 1,i

STWX num2,d

DECO num2,d

LDBA char1,d

CPWA 0x41,i

BREQ fstNameA,i

CPWA 0x44,i

BREQ fstNameD,i

CPWA 0x47,i

BREQ fstNameG,i

CPWA 0x52,i

BREQ fstNameR,i

CPWA 0,i

BREQ endIf,i

fstNameA: STRO adam,d

LDBA char2,d

CPWA 0x53,i

BREQ lstNameS,i

CPWA 0x4B,i

BREQ lstNameK,i

CPWA 0x4D,i

BREQ lstNameM,i

CPWA 0x42,i

BREQ lstNameB,i

fstNameD: STRO dave,d

LDBA char2,d

CPWA 0x53,i

BREQ lstNameS,i

CPWA 0x4B,i

BREQ lstNameK,i

CPWA 0x4D,i

BREQ lstNameM,i

CPWA 0x42,i

BREQ lstNameB,i

fstNameG: STRO gerald,d

LDBA char2,d

CPWA 0x53,i

BREQ lstNameS,i

CPWA 0x4B,i

BREQ lstNameK,i

CPWA 0x4D,i

BREQ lstNameM,i

CPWA 0x42,i

BREQ lstNameB,i

fstNameR: STRO ryan,d

LDBA char2,d

CPWA 0x53,i

BREQ lstNameS,i

CPWA 0x4B,i

BREQ lstNameK,i

CPWA 0x4D,i

BREQ lstNameM,i

CPWA 0x42,i

BREQ lstNameB,i

lstNameS: STRO stichard,d

LDBA char3,d

CPWA 0x41,d

BREQ ascendOr,i

CPWA 0x44,d

BREQ dscendOr,i

lstNameK: STRO kinyeck,d

LDBA char3,d

CPWA 0x41,d

BREQ ascendOr,i

CPWA 0x44,d

BREQ dscendOr,i

lstNameM: STRO murry,d

LDBA char3,d

CPWA 0x41,d

BREQ ascendOr,i

CPWA 0x44,d

BREQ dscendOr,i

lstNameB: STRO bonoguhe,d

LDBA char3,d

CPWA 0x41,d

BREQ ascendOr,i

CPWA 0x44,d

BREQ dscendOr,i

endIf: STOP

.end

--------------------------------------------------------------------

Input: Simliar as in the question

---------------------------------------------------------------------

output:

Invalid Input, try again {G,D,R,A).

Invalid Input, try again {G,D,R,A).

Invalid Input, try again {S,K,M,B}.

Number must be positive

Invalid Input, try again {A,D}.

Invalid Input, try again {A,D}.

3Gerald Stichards

Kinyeck

Murry

Bonoguhe

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago

Question

=+Are there shop stewards?

Answered: 1 week ago