1 / 11

Important Irvine Library Procedures

Important Irvine Library Procedures. Randomize Initializes the seed of the random-number formula by both the Random32 and the RandomRange procedures. The seed equals the time of day, accurate to 1/100 th of a second. Only call it once at the beginning of a program

anka
Télécharger la présentation

Important Irvine Library Procedures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Important Irvine Library Procedures • Randomize • Initializes the seed of the random-number formula by both the Random32 and the RandomRange procedures. • The seed equals the time of day, accurate to 1/100th of a second. • Only call it once at the beginning of a program • This ensures that each time you run a program, the starting random integer will be different, and any sequence of random integers will also be unique.

  2. RandomRange • Produces a random integer within the range of 0 to (n-1) • N is passed in the EAX register. • The random integer is returned in EAX.

  3. How to choose a random number between 0 and 4999 .data Randval DWORD ? .code Call Randomize Mov eax, 5000 Call RandomRange Mov randval, eax

  4. SetTextColor • Sets the current foreground and background colors for text output. The color constants are predefined and can be used for both the foreground and background.

  5. SetTextColor • Not available in Irvine16.inc • (only Irvine32.inc) • The background color must by multiplied by 16 before being added to the foreground color. • Example • Mov eax, yellow + (blue * 16) • Call SetTextColor ;yellow on blue

  6. GoToXY • Locates the cursor at a given row and column on the screen. Using a console screen, the x-coordinate range is 0-79, and the y-coordinate range is 0-24. • Inputs: • DH = Y-coordinate (row value) • DL = X-coordinate (column value)

  7. ReadChar • Reads a single character from standard input and returns the character in the AL register. The character is not echoed to the screen.

  8. Clrscr • Clears the console and locates the cursor at the upper left corner.

  9. Programming Assignment • Draw Text Colors Write a program that clears the screen, generates and displays 50 random numbers (0-9), in 50 random colors (only use the 16 different colors available to you, but call the random number generator each time a number is generated).  Use the Irvine library functions (Randomize, RandomRange, and SetTextColors) to generate and display the results.  Wait for a keyboard input before exitting the program. You may use the library function (Readchar, ReadInt, or ReadString) to read the character.

  10. Programming Assignment (cont) • In class, we discussed the evaluation of the expression (-3)*VALUE using only shifts, adds and subtracts.  Will this same code work to evaluate the expression (+5)*VALUE?  If not, create a program to implement this.  Will this same code work to evaluate the expression (-5)*VALUE?  If not, add this to your program.  Display on the screen a message allowing the user to input an 8-bit input(values between 0 and 255, evaluate each of the above expressions and display 16-bit results in binary, hex and in decimal. You do not have to provide error checking for the input data.  You may use the Irvine library functions for I/O.

  11. What to turn in for the Programming Assignment • Structure Chart or detailed outline • Listing File • Executable on Diskette

More Related