Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please create in Assembly language programming. Intel x86 based Write a program (in either protected or real mode; your choice) similar to the one described
Please create in Assembly language programming. Intel x86 based
Write a program (in either protected or real mode; your choice) similar to the one described in Exercise 5 on page 138, that generates a Fibonacci-like series of integers. Instead of 1 and 1, make your series start with the values 1 and 4; then let each successive number be the sum of the two previous numbers. Modify the original directions as follows: generate the first twenty-four (rather than seven) numbers in the series; also define an uninitialized array of 24 doublewords in memory and fill it with the 32-bit values in the series as you compute them. Call Irvine's DumpRegs procedure after each value is generated so the registers will be displayed to the screen; in addition, after the last number is generated, call Irvine's DumpMem procedure to display the final contents of the twenty-four doubleword values in your array. (See pages 159-160 for descriptions of these two procedures and how to call them.) Use MAKE16, MAKE32, or a Visual Studio project as appropriate to assemble your program and link its object code to the Irvine library procedures. Run your program and test it to make sure it generates correct output (hint: counting 1 and 4 as the first and second values, the 24th value in the series is 132,339 decimal or 000204F3h). Capture and print out a screen shot(s) showing the results of the program (you may have to scroll up/down to see all the output) into an unsigned uou 5, Fibonacci Numbers number seq 7-2). Write a program that uses a loop to calculate the first seven values of the Fibonacci described by the following formular Fib(1): 1,Fb(2-1, Fib(n): Fib(n-1) +Fibomb Es 5.4 lht lavNE 32 Libiowy 179 Ci rscr The Clrser procedure clears the console window. This procedure is typically called at ginning and end of a program. If you call it at other times, you may need to pause the p m by first calling WaitMsg. Doing this allows the user to view information already on the o- screen before it is erased. Sample call: call WaitMsg call Cirscr : "Press any key" CreateOutputFile The CreatcOutputFile procedure creates a new disk file and opens it for wr When you call the procedure, place the offset of a filename in EDX. When the procedure returns, EAX will contain a valid file handle (32-bit integer) if the file was created successfully therwise , EAX equals INVALID_HANDLE VALUE (a predefined constant). Sample call: .data filename BYTE "newfile.txt",0 .code mov edx, OFFSET filename call createoutputFile The following pscudocode describes the possible outcomes after calling CreateOutputFile: if EAX INVALID HANDLE VAUE the file was not created successfuiy else EAX handle for the open file endi f If procedure advances the cursor to the beginning of the next line in the console window. It writes a string containing the ASCII character codes 0Dh and 0Ah. Sample call: call Crlf Delay The Delay procedure pauses the program for a specified number of milliseconds. Before calling Delay, set EAX to the desired interval. Sample call: mov eax, 1000 call Delay i 1 second DumpMem The DumpMem procedure writes a range of memory to the console window in hexa- decimal, Pass it the starting address in ESI, the number of units in ECX, and the unit size in EBX ( 1 byte, 2-word, 4-double word). The following sample call displays an array of 1 1 doublewords in hexadecimal: .data array DWORD 1,2,3,4,5,6,7,8,9,0Ah, 0Bh .code main PROC mov esi,OFFSET array mov ecx, LENGTHOF array mov ebx, TYPE array call DumpMem ; starting OFFSET ; number of units ; doubleword format PTER 1 60 4 00000001 00000002 00000003 00000004 00000007 00000008 00000009 00000 00000005 000oo The following output is produced 00A 0000000B Dump Regs The DumpRegs procedure displays the FAX, EBX, ECX, EDX ESP, EIP and EFL (EFLAGS) registers in hexadecimal. It also displays the vt ign, Zero, Overflow, Auxiliary Carry, and Parity flags. Sample cal , ESI, EDI,E the call DumpRegs Ge Sample output Dx-00000000 EAX 00000613 EBX-00000000 C 000000FF E gr in Ge ZF-0 OF-0 AF O SP-1 ESI 00000000 EDI-00000100 0000091E ESP 000000F6 CF- EFL-00000286 E: EIP 00401026 DumpRegs can be useful when debugging programs because it displays a snapshot It has no input parameters and no return value The displayed value of EIP is the offset of the instruction following the call to of the GetCommandTail The GetCommand Tail procedure copies the program's command line a null-terminated string. If the command line was found to be empty, the Carry flag is e wise, the Carry flag is cleared. This procedure is useful because it permits the user of a pro to pass parameters on the command line. Suppose a program named Encrypt.exe reads ar ile named filel.txt and produces an output file named file2.txt. The user can pass both filen on the command line when running the program: Encrypt filel.txt file2.txt When it startls up, the Encrypt program can call GetCommandTail and retrieve the two hi names. When calling GetCommand Tail, EDX must contain the offset of an array of at least 129 bytes. Sample call Ll data cmdTail BYTE 129 DUP (0) ; empty buffer mov edx, OFFSET cmdTail call GetCommandTail ; fills the buffer There is a way to pass command-line arguments when running an application in Visua From the Project menu, select
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started