Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
This is a short program to practice assembly language loops and if/else statements. You will use various jump commands and the cmp instruction.The program will generate a random number in the range 0-9 using the Randomize and RandomRange functions and the user will try and guess the number generated. The numbers entered are in base 10.You should use ReadDec to read a decimal number from the keyboard (the user's guess). ReadDec stores the number read into the eax register.This program must can be run in Visual Studio 2008 Professional editionThis program MUST ONLY use Irvine library functions INCLUDELIB /Irvine/Irvine32.libConstants (using "equ")You should define a constant, LF, for ASCII code for a linefeed (0Ah).PrototypesDeclare the following prototypes in the Prototype section of your code.ExitProcess PROTO,dwExitCode:DWORD;from Win32 api not Irvine to exit to dos with exit codeReadChar PROTO;Irvine code for getting a single char from keyboard;Character is stored in the al register.;Can be used to pause program execution until key is hit.ReadDec PROTO;Irvine code to read 32 bit decimal number from console;and store it into eaxWriteString PROTO ; Irvine code to write null-terminated string to output; EDX points to stringRandomRange PROTO ; Returns an unsigned pseudo-random 32-bit integer; in EAX, between 0 and n-1. If n = 10 a random number; in the range 0-9 is generated;; Input parameter: EAX = n.Randomize PROTO ; Re-seeds the random number generator with the current time; in seconds.Variables (.data)You should declare zero terminated strings for the prompts.You should embed in the string enough CR,LF as necessary to generate the correct output.See output example below for how the output should be formatted. You should use WriteString to print out the messages and the output.The messages should be as follows (substitute your name for my name):"Program 3 by Fred Kennedy""Guess a number in the range 0 - 9.""Guess: ""High!""Low!""Correct!!""Do another?('y' or 'Y' to continue. Any other character to exit)"You may declare any other variables you think you need but use variables sparingly since moving data to and from memory is not as efficient as using registers which are on the CPU.mPrtStr Macro(See Irvine 10.2)(see macro_mPrtStr.asm on the class web site)To print a string you should use the mPrtStr macro defined at the top of ifElse.asmInstead of the following code to print a string named message:pushedx ;save edxmovedx, offset message ;address of str to display should be in dxcallWriteString;display 0 terminated stringpopedx;restore edxyou can use a macro:mPrtStr messageWherever mPrtStr appears in the code it will be replaced with the macro definitionmPrtStr MACRO arg1 ;arg1 is replaced by the name of string to be displayedpushedx ;save edxmovedx, offset arg1 ;address of str to display should be in dxcallWriteString ;display 0 terminated stringpopedx ;restore edxENDMDo not copy the above macro from this PDF file. It may not operate properly if you do. If you wish to copy the mPrtStr macro copy it from the top of ifElse.asm on the class web site or copy it from macro_mPrtStr.asmDuring assembling wherever "mPrtStr message" appears in the code it will be replaced with:pushedxmovedx, offset messagecallWriteStringpopedxarg1 is replaced with message if that is the name of the string passed in.Before you can use a macro you must first define it in your code.You can place the macro definition section of your code just above the prototype section.Please do not use any other macros in your code unless directed otherwise or unless you ask first.Program specification:The list of steps below just gives the basic flow of the program. You should read the details of this entire document to get all the requirements for writing the program.You are to write a program with an outer and inner loop. The outer loop is the equivalent of a doWhile loop.1. display opening message2. seed the random number generator by calling Randomize3. enter outer loop (loop1:)4. display "guess a number" message"5. get the random number (RandomRange)6. enter inner loop (loop2:)7. display "guess" message8. get guess from user (ReadDec)9. You should code a series of if/else statements that compares the user's guess to the random number generated and takes appropriate action depending on whether the guess was high (print "High!" and repeat loop2), low (print "Low!" and repeat loop2) or correct(print "Correct!!" and ask the user to input 'y' to continue (ReadChar)).You should arrange the series of if/else for step 9 in the most efficient order that requires the least amount of jumps.You should also determine the best timing for exiting loop 2 and in which loop (loop1 or loop2) the "High!", "Low!" and "Correct!!" messages should be printed.The series of if/else should take the following form:if(condition);codeelse if (condition);codeelse (no condition needed since only option left);code10.If the user enters 'Y' or 'y', repeat loop1 (step 3) else quit (exit to dos with ExitProcess).Warning: "Invoke ExitProcess" should remain at the bottom of the main proc even if it seems inefficient.Since loop2 is contained in loop1, if loop1 is repeated loop2 will be repeated.Use the appropriate jump instruction: JB, JA, JE, JBE, JAE, JNE or JMP. You should use the cmp instruction to compare 2 numbers.Do not use any directives like .IF, .WHILE etc. You should code a loop and if/else statements using cmp, labels and jumps.Remember that efficiency counts. Points will be taken off for inefficient code, convoluted code or code that has no effect. You should use the least amount of jumps you need to get the job done.Organization of codeIn general code should flow from top to bottom.You should only jump back towards the top to repeat a loop. Loops should flow from top to bottom. If you have nested loops, the code for the outer loop should flow from top of outer loop to bottom of outer loop and the code for the inner loop should flow from top of inner loop to bottom of inner loop.Outer Loop top:-outer loop codeinnerLoopTop-inner loop code-bottom of inner loop: code to jump back to innerLoopTop to repeat inner loop-you may also have code to cut the loop short to repeat the loop like the C++ continue-bottom of outer loop: code in outer loop that comes after inner loop including code to jump back to outerLoopTop to repeat outer loop. If your code does not flow from top to bottom as described above, points will be taken off.
Explain the basic method for implementing paging
Tabular comparison for µ PS' Parameters Tables (a) and (b) list the characteristic of Intel microprocessor. Table(a): Table(b): It has a 64 bit da
given a sentence, find the number of times a particular character or word appear. the sentence is to be entered by the user
SHL/SAL : Shift logical/Arithmetic Left: These instructions shift the operand byte or word bit by bit to the left and insert 0 in the newly introduced least significant bits. In c
what is sahf nstrucions
assempbly language routine that takes an array named A containing n bytes of postive numebrs and fills two arranys, array B containing n words and array C containing n long words
1. Write a program that will generate an array of ten random 32-bit integers, and that will display on the monitor the numbers followed by either the words " has the fourth bit se
How is bob different from johnny in the outsiders
Write a MIPS/SPIM assembly language program that prints the smallest and largest values found in a non-empty table of N word-sized integers. The address of the first entry in your
How to define procedures?
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd