<<< Portability Concerns | Index | >>> |
Modify the original add_16_bytes.asm program as follows:
Change the type of "values" array to a 32-bit doubleword.
While making changes,
Every CPU instruction in your program must have a brief comment.
Use .CONST memory segment to define necessary constants.
Use LENGTHOF and TYPE operators to refer to the number of elements in the array and size of each array element, respectively.
Replace LEA instructions by MOV instructions with OFFSET operators.
Add console I/O to prompt for the user input, and then have the user input a certain number of values.
Instead of calculating the sum, write assembly code to generate tones on the system speaker by calling Beep. Interpret array of integers as pairs of duration and frequency values.
Note : the Beep function modifies all general purpose registers EAX, EDX, ECX, and so on. If you rely on values in those registers to control your loops, memory addresses, offsets, etc., etc., please be sure to preserve your registers before the Beep call and restore the registers upon return from the call. One way to preserve the values is to push them on the stack, and restore them by popping in the reversed order. However, this needs to happen before duration and frequency parameters are pushed on the stack. Alternatively, you can have dedicated memory locations to temporarily preserve your registers.
Add logic to handle potential Beep error codes:
If the function fails, the return value in EAX register is zero and no additional action is required.
If the Beep function succeeds, the return value in EAX is nonzero. In that case, to get extended error information, call GetLastError API function.
The GetLastError returns the error code in EAX. Program should print this error code on the screen.
As the sound is produced, display the tone frequency and duration on the console screen.
Ask the user if they wish to retry, and if so, start over. Exit the program otherwise.
Optional (15 xtra pts.) The original size of "values" array is 16 elements. However, the program could ask the user how many sample values they wish to enter.
Optional (5 xtra pts.) Modify program to use the at least one LOOP instruction.
Optional (10 xtra pts.) Modify program and add a 200-millisecond delay before each beep. (Hint: lookup kernel32 Sleep API documentation.)
What to submit:
Submit only your ASM source file (not the EXE or project.)
<<< Portability Concerns | Index | >>> |