// Template for assignment 2
// Your assignment submission needs to be based on this template.
// Carefully read the instructions.
// You need to complete the subroutines and the test cases below.
Copyright By PowCoder代写 加微信 powcoder
// Make sure all code is your own, and don’t share any code
// or code fragments with other students.
/ Execute all the test cases
/ (You can comment the next line if you don’t want to
/ run the test cases)
JnS TestAll
/ Execute the main wordle game
JnS Wordle
/ Finish execution
////////////////////////////////
/ Task 2.2: ToUpper subroutine
////////////////////////////////
/ … insert your code here
///////////////////////////////////////
/ Task 2.3: StringContains subroutine
///////////////////////////////////////
/ … insert your code here
///////////////////////////////////
/ Task 2.4: CheckGuess subroutine
///////////////////////////////////
/ … insert your code here
/////////////////////////////////////////
/ Task 2.5: Main Wordle game subroutine
/////////////////////////////////////////
Wordle, HEX 0 / Return address
/ … insert your code here
JumpI Wordle / return
/ Task 2.1: Your name as a string
Name, HEX 0
//////////////////////////
/ Pre-defined Subroutines
//////////////////////////
/ InputString subroutine
/ Expects the starting address of an area in memory
/ where the string can be stored in argument InputTo.
/ Requests a string character by character from the user.
/ When the user enters value 0 (not the character “0” but
/ the integer 0), the input is finished and the
/ subroutine returns.
/ Careful: the subroutine will overwrite any memory
/ starting from the InputTo address.
InputTo, HEX 0 / Start address where to store the string
InputString, HEX 0 / Return address placeholder
InputLoop, Input
StoreI InputTo
Skipcond 800
JumpI InputString / Return if entered value is 0
Load InputTo
Store InputTo
Jump InputLoop
/ PrintString subroutine
/ Expects the start address of a string to be printed
/ in argument PrintFrom.
/ Will print the string character by character until
/ a 0 is encountered, and then return.
PrintFrom, HEX 0 / Address to start printing from
PrintString, HEX 0 / Return address placeholder
PrintLoop, LoadI PrintFrom
Skipcond 800
JumpI PrintString / Return if character is 0
Load PrintFrom
Store PrintFrom
Jump PrintLoop
One, Dec 1
/////////////////
/ Test cases
/////////////////
/ Each test case is a subroutine that requires no arguments.
/ The TestAll subroutine calls all the test cases in a row.
/ Add your own test cases as subroutines, and add the necessary
/ calls to the TestAll subroutine.
/ You can then execute individual test cases by calling them
/ (at the top of the file), or execute all of them by calling
/ TestAll (see top of the file).
TestAll, HEX 0 / Return address
JnS TestToUpper1 / Run first test case
JnS TestStringContains1 / Run second test case
JnS TestCheckGuess1 / Run another test case
JumpI TestAll / Return
/ Test case 1 for ToUpper
/ Expected output: your name in upper case
NameAdr, ADR Name
TestToUpper1, HEX 0 / Return address
Load NameAdr
Store ToUpperWord
JnS ToUpper
Load NameAdr
Store PrintFrom
Jns PrintString
JumpI TestToUpper1
/ Test case 1 for StringContains
/ Expected output: 1 if your name contains the letter F, 0 otherwise
TestStringContains1Char, HEX 46
TestStringContains1, HEX 0 / Return address
Load NameAdr
Store StringContainsStart
Load TestStringContains1Char
Store StringContainsChar
JnS StringContains
Load StringContainsResult
JumpI TestStringContains1 / Return
GreatAdr, ADR Great
Great, HEX 47
WordsAdr, ADR Words
Words, HEX 57
SelectedWord, Adr Words
/ Test case 1 for CheckGuess
/ Expected output: _r___
TestCheckGuess1, HEX 0 / Return address
Load GreatAdr
Store CheckGuessedWord
Load WordsAdr
Store CheckSelectedWord
JnS CheckGuess
JumpI TestCheckGuess1 / Return
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com