# Programming Assignment | Homework Help Websites

Regis University CC&IS
CS370 Assembly Language
Programming Assignment 4
Due by: midnight Sunday of Week 4
Introduction
For this assignment you will create a combination lock simulation. The combination lock has
four buttons, numbered 1, 2, 3 and 4. The lock will open if the buttons are pressed in a correct
sequence.
The rules for the combination lock are: The combination lock starts in a state where its 2s count is zero.
Pressing the 1 button causes the lock to decrement the 2s count. The 2s count cannot be
less than zero. For example:
If the 2s count was three, then the 2s count is now two.
If the 2s count was two, then the 2s count is now one.
If the 2s count was one, then the 2s count is now zero.
If the 2s count was zero, then the 2s count remains 0.
Pressing the 2 button causes the lock to increment its 2s count by one.
Pressing the 3 button causes the lock to open if 2s count is exactly two. If that is not the
case, the lock remains locked and the 2s count is set to zero.
Pressing the 4 button is the same as pressing the 2 button twice in that pressing the 4
button will increment the 2s count by two.
The lock s memory can only store three 2s. If a button press will cause the 2s count to be
greater than three, then the 2s count will be equal to three.
Requirements
Design a finite state machine (FSM) for the combination lock. The FSM design will be included
in the problem document and will consist of:
All states of the FSM, labeled (the label being an integer stating how far the current state
is from the start state). This also includes:

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.

The start state.
The terminal state(s).
All possible transitions (arrows) from one state to another, labeled (the label being the
button press that triggers that particular transition).
For every possible state and every valid button press, there must be a transition.
Create a program that: Has three user-defined procedures (UDPs):
GetButtonPress this UDP shall:
Prompt the user to enter an integer in the range of 1 to 4.
Validate that the integer is actually in the range of 1 to 4.
If valid, print the integer to the screen.
If not valid, do not prompt the user, but wait for another button
press. Keep waiting until a valid value is entered.
Return the validated value in the AL register.
DisplayMessage this UDP shall:
Accept an integer that is passed in the AL register.
Based on the integer value, displays a message about the state of the
combination lock.
Divides the main procedure into sections with labels describing the combination l
state. For example, State0 for no 2s count, State1, for a 2s count of 1, etc.
Accepts button presses from the user using the GetButtonPress procedure.
Displays a message, using the DisplayMessage procedure, after each button press, that
describes t
Enters a termination state once the lock is opened.
Is formatted and commented as required by the CS370 Coding and Documentation
Standards. Does not use the .IF, .REPEAT, or .WHILE directives of MASM. Allowed Irvine Procedure Calls:
WriteChar
WriteString

Sample Program Input and Output:
Program Documentation
Create your program document which contains:
Algorithms as pseudo-code (C++ structure, but does not have to strictly adhere to the
syntax of the language).
A test plan and results. Input values Expected Result Actual Result
2
1
2
3
4
2
1
3
The lock 2s count = 0
The lock 2s count = 1
The lock 2s count = 0
The lock 2s count = 1
The lock 2s count = 0
The lock 2s count = 2
The lock 2s count = 3
The lock 2s count = 2
The lock is open!
A test plan should be created before running the program in order to have tests that will
determine whether the program works correctly or not.
Program Submission
Submit each of program documents to the Assignment 4 Dropbox.
Before submitting your program deliverables, you MUST name them as follows:
Lastname-Assn4-Program.asm
Lastname-Assn4-ProgramDocument.docx
For example:
Jones-Assn4-Program.asm
Jones-Assn4-ProgramDocument.docx

The following rubric will be used to grade your program. Rating Category Exemplary Partially Proficient Basic
(needs work)
Not Demonstrated
Documentation is
well written, clearly
explains what the
code is
accomplishing.
Includes complete
and accurate file and
detailed in the CS370
all appropriate and
necessary locations.
Documentation
may lack clarity or
details in some
instances, OR may
have violated some
minor details of the
CS370 coding
standards. Documentation is
incomplete and/or
incorrect and/or
formatted incorrectly.
Violated significant
details of the CS370
coding standards or
the underlying
program intent. Only a few (or no)
program. Constants used where
appropriate, correct
data types used for
variables. Constant, variables defined
within correct
program scope.
Followed CS370
coding standards
naming conventions
and used descriptive
names for all
identifiers.
A few minor errors in
data declaration
scope, data typing or
assignment, or may
have violated some
minor details of the
CS370 coding
standards. One or more major
errors, or may have violated
significant details of
the CS370 coding
standards. Constants not used,
identifier names are
not descriptive,
and/or there are
multiple errors in the
data types assigned.
correctly handling
multiple records per
line. Recognizes end
of line correctly.
Recognizes end of
file correctly,
whether the file
contains a newline on
the last line or not.
Last data line is
duplicated or not
are handled correctly
OR other minor
processing data.
Does not correctly
handle multiple
records per line, OR
major/many issues in
processing data.
data from the file.
Individual
calculations and
summations
performed correctly.
Keeps track of counts
correctly.
All if statements
written correctly and
efficiently.
Problems with ONE
of the program
calculations and/or if
statement not written
correctly and
efficiently.
Multiple problems
with program
calculations or if
statements. All calculations
incorrect.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.

All required screen
output is displayed
neatly in columns
under correct
long files. Problems with
display formatting or
pausing,
OR does not satisfy
one of the
requirements. Multiple problems
with display output. No display output
produced.
Demonstrates
understanding of
program structure,
control structures, and file structure.
Appropriate use of
language with correct
parameter passing
and no global
variable usage.
Follows all of the
coding standards for
code usage.
Most parameters are
defined and passed
correctly with no
global variable
usage, but there are
minor errors (e.g.
parameter passed by
reference when it
should be passed by
value).
Multiple problems
with parameter
definition and/or
usage,
OR global variables
were used
OR
several major errors. Does not demonstrate
any understanding or
program or
control/data
structures. Most parameters
incorrectly defined or
passed.
Major coding
standard violations. Program is modular
in design (if
applicable, functions
with arguments, not
including main) and
all are logically
organized with
prototyping.
Each module
performs ONE well- defined task and is
defined and called
correctly.
Program uses code
efficiently. The
program modules can
be easily modified
and/or reused with
minimal work.
Program is modular
in design and is
mostly logically
organized.
Most of program has
efficient use of code.
May be missing one
required function,
contain a module that
performs too many
function that is
incorrectly defined or
called.
Some of the program
modules can be
easily modified
and/or reused with
minimal work.
Program is modular
in design and some
parts are logically
organized.
Multiple problems
with parameter
definition and/or
usage.
Program has little
efficient use of code.
More than one
required function
missing, or multiple
problems with
module
definitions/calls. Modules could not be
modified and/or
reused, without
substantial work.
Program is not
modular in design
and is not logically
organized.
Program has little
efficient use of code
and program
compactness. The program
modules cannot be
easily modified
and/or debugged.
Code is exceptionally
well organized and
very easy to follow
and has no issues. Code is fairly easy to
some spacing,
indentation, and/or
other issues. Code is readable only
by someone who
it is supposed to be
doing and/or there
are substantial
spacing, indentation,
and/or other issues. The code is poorly
organized and very
and/or
has other major
issues.

Test plan includes
rationale and tests that
validate ALL logic.
Missing parts of
rationale or missing
tests of some logic.
Missing all rationale
and/or missing many
tests of the logic.
No test plan submitted.
Submitted on time Submitted 1-3 days
late
(3% deducted per
day late)
Submitted 4-7 days
late
Not submitted within
1 week of due date

; Finite State Machine (Finite.asm)

; This program implements a finite state machine that
; accepts an integer with an optional leading sign.

INCLUDE Irvine32.inc

.data

WriteInt proto
WriteString proto

prompt BYTE “Please press a button (1,2,3, or 4): “,0
DisplayMsg1 BYTE “The lock 2s count = “,0
;DisplayMsg11 BYTE “The lock is open!”,0

.code
main PROC

call clrscr

StateA:
call GetButtonPress
cmp al, 4-1
je StateB
;loop StateA

StateB:
cmp al, ‘1’
je State1

cmp al, 2
je State2

State1:
cmp al, ‘1’
mov bl, al
call Count1
loop StateA

State2:
cmp al,2
mov bl, al
call Count2
loop StateA

Quit:
call Crlf
exit
main ENDP

;———————————————–
GetButtonPress PROC
;
; Reads a character from standard input.
; Returns: AL contains the character
;———————————————–
mov edx, OFFSET prompt
call WriteString ; input from keyboard
call ReadInt ; echo on screen
ret
GetButtonPress ENDP

;———————————————–
Count1 PROC
; with the user integer stored in al
; subtract 1 from the al register
;———————————————–

sub bl,1
call DisplayMessage1
call WriteInt
call crlf
ret
Count1 ENDP

;———————————————–
Count2 PROC
;
;
;———————————————–
call DisplayMessage1
call WriteInt
call crlf

ret
Count2 ENDP

;———————————————–
DisplayMessage1 PROC
;
;
;———————————————–
push edx
mov edx,OFFSET DisplayMsg1
call WriteString
pop edx
ret
DisplayMessage1 ENDP

END main

Calculate the price
Pages (550 words)
\$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works

## Here is how simple it is to make use of our essay writing services

step 1

### Submit a "write my essay for me" request

Fill out a quick order form and provide detailed requirements as to the paper, its format, etc. You can even attach screenshots or add additional instructions later. If something has to be clarified or added, the writer will contact you directly.
Pro service tips
How to get the most out of your experience with Homework Writing Services
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Human Resources Management (HRM)
Good work.
Customer 463125, July 4th, 2022
Nursing
Thanks for the amazing PPT!!!!
Customer 454007, June 8th, 2020
English 101
Good work.
Customer 453625, May 25th, 2022
Military
Very good job.
Customer 456821, April 8th, 2022
Retail
Good
Customer 463469, October 18th, 2022
Commendable.
Customer 452441, April 6th, 2022
Military
good job
Customer 456821, October 24th, 2022
Thank you for following all instructions. Good piece
Customer 463337, March 1st, 2023
Other
Customer 459155, April 7th, 2022
Technology
Thank you for doing a great job. I really am glad that you did not use someones else work like the first person who did this did. Awesome job. Because of this I will continue to use this site!
Customer 454345, June 2nd, 2020
Always capitalize in AP style.
Customer 452441, April 1st, 2022
Military
Good job
Customer 456821, November 28th, 2022
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend