You may work with one other person on this lab.
If you do, please submit only one version (from either account), but be sure
to put both your names on your assignment.
If you develop you code on your own machine, make sure it works on a CS Lab
machine before you submit your final version.
A palendromic number is a positive integer whose digits read the same forwards and backwards. For example, 1, 454, and 94649 are palendromic numbers.
Your assignment is to write an assembly language program that inputs an integer and finds the smallest number greater than the number entered that is a palendromic number. However, because integers are stored in two's complement binary in 32 bits, it is possible that the first such number will not fit (i.e., overflow). In this case, print the word "overflow" instead of the number.
For example, if your program read the integer 1, then it should output 2, if your program read the integer 50, then it should output 55, or if your program read the integer 2147483647, then it should output overflow.
You can assume that the input integer will always be greater than or equal to 1 and will fit in 32 bits (signed).
Your program should read one number and print one number. DO NOT write a loop that repeatedly reads numbers and prints results.
I suggest you write this first in Java/C/C++ so you can focus on the algorithm. Efficiency is not important, correctness is, so you don't have to find the most efficient algorithm.
Use any assembly language instructions you want, including pseudo-instructions. If fact I encourage you to use pseudo-instructions when possible to make the code easier to understand.
Hint - if N is an integer value, then N % 10 is the low order (rightmost) digit value of N (e.g., 349 % 10 = 9). Also, N / 10 (integer division!) is a new value that no longer contains the lower order digit (e.g., 349 / 10 = 34).
Here is an example of a properly appearing program:
# Sue Percoder # Seth Lesthan # CS3421 Fall 2005 # Lab Assignment 1 # # This program computes the ... # this code does something interesting main: sub $s1,$s2,$s2 # this does something add $s1,$s2,$s2 # this does something too # this code does something even more interesting here: lw $t0,8($s1) # so does this addi $t0,$t0,5 # as does this sub $t0,$s4,$s7 # and this # terminate jr $ra # exit
Test your program as completely as you can. Then use the submit command to electronically submit your "lab1.s" file to "cs3421", assignment "lab1" by the due date.
You must submit your program by the due date/time in order to receive credit.