COSC2406T – 21SS – Assembly Language Programming Assign 5
Assignment 5 – Covers up to Chapter 5
Due: Monday Jul 12th, 2021 by 11:55pm
Complete the following Programming Exercises USING ONLY MATERIAL UP TO CHAPTER 5:
FOR EACH QUESTION: It does help to write pseudo-code to identify the steps necessary to solve these problems. Transfer the refined algorithms to your program as comments and then write the Assembly code to perform the necessary steps. It is recommended that this step is done first, and coding second.
A) [40] Special Linking Array Items
You are provided with a file called secret1.dat which contains a secret message. The first byte of file will indicate how many letters are in the message. This will be followed by all the letters, one byte for each, and all the indexes – one byte for each and one extra as the starting index value. Your job is to follow the letters from the starting position until all the letters have been printed. You will need two BYTE arrays – both of size 256. The first one will be named letters, and a second array will be named index. You will write your program to follow the links, traversing them to locate and print the letters in the correct order. You must read the initial data from the test file – hard coding the data is not allowed.
This program will perform the following steps:
a) Ask the user for the name of the data file. (use ReadString)
b) Open the file using the OpenInputFile library function. Make sure you save the file handle returned in EAX because you will need it later
c) Using the ReadFromFile library function, read the first byte into a msgLength variable.
d) Using the ReadFromFile library function, read the next msgLength bytes into the letters array.
e) Using the ReadFromFile library function, read the next (msgLength+1) bytes from the file into the index array.
f) Close the file connection using the file handle and the CloseFile library function.
Copyright © 2020-21 by Michael Lajoie, Sault Ste Marie, Ontario
All rights reserved. No part of this work may be reproduced or used in any form or by any means – graphic, electronic, or mechanical – without the prior written permission of the author.
Good formatting and commenting are essential for assembly program. A penalty of up to 25% will be
applied if the programs are not properly formatted and commented.
If you have any issue with the questions or unclear about the requirements, please email me
immediately.
COSC2406T – 21SS – Assembly Language Programming Assign 5
g) The initial index value will be found at index[msgLength] in the index array. Get this value and then print the message by following the index. For example, if the start index is 10, then you would first print the character at letters[10] and get the next index value from index[10]. Use the next index to find and print the next letter and find the index value of the 3rd letter. Repeat this process until (msgLength) letters have been printed.
DO NOT WORRY ABOUT ERROR CHECKING – you don’t know IF statements yet.
B) [10] MyRandomRange Procedure
Create a procedure called MyRandomRange that accepts two parameters using the registers EAX and EBX where EAX is the high number of the range and EBX is the low number of the range. The procedure must generate a random number between EAX and EBX inclusive (means the value in EAX must be a possibility). The result will be returned in the EAX register.
Then create a main procedure to test your version of MyRandomRange. The test program will first call the Randomize library procedure to set the seed for random numbers. Inside a loop which will repeat 5 times:
a) ask the user for a lower number and an upper number
b) Use your MyRandomNumber procedure to generate the number
c) Print the random number returned by your procedure with an appropriate
message.
Your MyRandomNumber procedure must be independent of any other code so that it can be copied and pasted into other assignments without modification.
HINT: You will be using this proedure again in future assignments. If you don’t do it here, you will need to do it later (only without any grade component).
Copyright © 2020-21 by Michael Lajoie, Sault Ste Marie, Ontario
All rights reserved. No part of this work may be reproduced or used in any form or by any means – graphic, electronic, or mechanical – without the prior written permission of the author.
COSC2406T – 21SS – Assembly Language Programming Assign 5 Submission, demonstrating, and grading:
For each of the programs, make sure there is a header showing the TITLE, description, your name, assignment & problem number, and the date you wrote the program.
For each of the programs:
i. The Java/pseudocode programs can be used as the comments for the assembly code
along with other descriptions as required.
ii. The header must include your name, assignment number, question number, and program
description.
Upload all of your .asm files for each of the programs to CMS.
All programs must be fully commented using the two-column approach discussed in class and shown
throughout the textbook in the code examples. Failure to comment the code properly or to format like
the code in the textbook will result in a penalty of up to 25%.
If you are selected to demonstrate and explain your working programs to the TA, Duc Tran, be sure to
do so by Friday July 16th. The demonstration and explanation of your code will represent 25% of the
assignment grade – the other 75% of the grade will come from grading the code and how well the
programs meet the specification and requirements of the question.
IMPORTANT:
a) b)
If you do not demonstrate your programs to the TA by the end of the demonstration date, you
will receive a grade of zero.
If you are unable to explain most or all of your code and the logic of your programs, then the
maximum grade possible will be 50%.
Copyright © 2020-21 by Michael Lajoie, Sault Ste Marie, Ontario
All rights reserved. No part of this work may be reproduced or used in any form or by any means – graphic, electronic, or mechanical – without the prior written permission of the author.