Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

These are all 1 question, please write code in LC-3 Assembly language. Please provide the code, not explanation. Thank you so much Random numbers are

image text in transcribedimage text in transcribedimage text in transcribedThese are all 1 question, please write code in LC-3 Assembly language. Please provide the code, not explanation. Thank you so much

Random numbers are an important concept in computer science. However, computers can't just randomly generate numbers. They can make use of events of nature that appear to be random (or at least, infeasibly hard to trace a pattern), but what also happens regularly is that so-called pseudorandom number generators are used. An example of such a pseudo-random number generator where 3 each number can be defined from the previous number can be seen in Equation 1, given the three parameters a,b, and m (where a,b and m are non-negative integer numbers with m=0 ). Xn=(aXn1+b)modm Lastly, we need to define the initial number, X0. For this, computers usually take some noise, like the current time, but for your case, we will provide you with some artificial noise in the form of a few random characters (or maybe a few dozen). Another name for this initial number X0 is the seed. Input details The first line of the input consists of three non-negative integer numbers a,b and m ( m is strictly positive); these are represented using the normal decimal system. Note that these numbers are separated (and possibly preceded) by spaces or new lines, therefore the inputs are all valid, equivalent inputs. Notice that there can also be spacesewlines in front of the number a. Immediately after the three numbers a,b, and m have been read, there will be one line break followed by any number of characters, which will represent the seed X0. For each character, treat letters as their index in the alphabet (starting from 0 ), and digits like numbers. All other characters can (and should) be ignored. Thus, the seed b29*3] ] ] corresponds to the number X0=1+2+9+3+2=17. Notice that for the seed, we read characters individually, thus we interpret the substring 29 as 2+9. The sequence of characters ends with a newline. Note that there is no newline within the seed line. The seed X0 is then obtained by taking the sum of all the valid characters. Example noise could be: abbH23sa651d or 5663a The final line of the input will contain a non-negative integer n, which is again represented using decimal notation, which you should use to print X1,X2,X3, up till and including Xn. Notice that you must not print X0. So if the input is, for example 3 you should print X1X2X3 These numbers must be printed in hexadecimal form, and they must start with an x. Use capital letters and print the shortest form (no leading zeroes). Thus, print for example xD03 instead of x0D03. x3 These numbers must be printed in hexadecimal form, and they must start with an x. Use capital letters and print the shortest form (no leading zeroes). Thus, print for example xD03 instead of x0D03. After every of these numbers, you should print exactly one newline (ASCII \#10). This means that your full output also ends with a newline. Input / Output Example Input 2325 aaabbbccc -11 4 should print the output x17x18x1x5 In this case, we see that a=2,b=3,m=25, and the seed is X0=0+0+0+1+1+1+2+2+2+1= 10. Since n=4 we print X1,X2,X3 and X4, with a newline after all of them. In a real application, the user likes to see what they type. Therefore, you must also print every inputted character while the user types. This is easily accomplished by using an OUT command after every GETC. Notice that you must not use the IN command because then you get a Input a character> message each time which is undesirable. Another important fact to know is that due to apparent limitations of Themis, your program must always begin at .ORIG x3000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions