Homework 3: Basic Arithmetic Operations (continued)
Analysis/Design/Implementation
Overview
Assembly language programmers benefit greatly from program analysis and
design methods such as those studied in C201 and C202. It consists of:
-
Analysis of problem (determination of input and output, decomposition of
problem into module structure chart).
-
Design of algorithm (pseudo code and variables of algorithm for each module
of structure chart).
-
Implementation (translation to target language).
Recall that the target language influences the algorithm's design only
slightly. It is STRONGLY urged that you practice this design method as
test questions will often provide pseudo code/C++ algorithms for implementation
in Assembler language.
Assignment
Design and implement a high-level algorithm to convert a time from seconds
to hours, minutes, and seconds. After verification of the high-level algorithm
operation, translate your algorithm into assembler. Your input should be
the time in seconds entered via the keyboard. The input value will be in
the range 0 to 4,294,967,295. Do not use commas in input. The output should be the equivalent time in the form HH:MM:SS. For example, an input of 7272 seconds would yield output of
02:01:12.
Test using the values of:
0; 59; 60; 3599; 3600; 7272; 32000; 32072; 65535; 4,294,967,295; 4,294,967,296
AND also enter four more test values that provide additional credibility to your
program.
Turn in
-
Cover sheet with your name, date, and Homework 3.
-
High-level language solution (C++, Java, etc.). Give program listing
of solution and test output using values given above. Comment your code.
-
Assembly language solution. Give program listing of solution and test output
using values given above. For documentation and as helpful reminder of algorithm
when debugging assembly code, include pseudo code comments to the right of
assembly instructions, using the ";" character to begin a comment.
-
Extra credit will be awarded for padding a zero when the result in a field is a
single digit. e.g. 2:1:12 would be ok, 02:01:12 would receive bonus points.
Hints
-
Use the following example program as a guide for program structure.
-
The input should be an unsigned 32-bit number. Use ReadDec (why not
ReadInt?) from the
Irvine32.lib to read a signed integer from the keyboard into the eAx register.
-
You will need to divide the input number to determine the number of hours,
minutes, seconds. Remember that division produces a quotient and
a remainder.
-
Remember the rules for division, a 32-bit divisor automatically uses eDx:eAx
as the dividend, producing eAx as the quotient and eDx as the remainder.
Make certain that eDx:eAx have been properly initialized before the division
(i.e. XOR eDX, eDX for unsigned; CDQ for signed division).
Q: eAx
32-bit divisor/ eDx:eAx
R: eDx
Document last modified: