Question

In: Computer Science

Write a program in NASM that turns a 32-bit numeric value (e.g., 0xFFFFh) and converts it...

Write a program in NASM that turns a 32-bit numeric value (e.g., 0xFFFFh) and converts it to a byte array such that it can be printed to the screen using a system call method. A loop is necessary for converting the numeric value to ASCII for output. Again, use a system call (e.g., int 80h) to print the value to the console. Calling external functions (e.g. printf) is not allowed. You may use the starter file attached to this assignment.

Solutions

Expert Solution

The program is written below,


The program is written below,

.386

.MODEL FLAT, stdcall

.STACK 4096

GetStdHandle PROTO, nStdHandle:DWORD

WriteConsoleA PROTO,

hConsoleOutput:DWORD, ; output handle

lpBuffer:PTR BYTE, ; pointer to buffer

nNumberOfCharsToWrite:DWORD, ; size of buffer

lpNumberOfCharsWritten:PTR DWORD, ; num bytes written

lpReserved:DWORD ; not used (NULL)

ExitProcess PROTO, dwExitCode:DWORD

.data

bytesWritten DWORD 0 ; for WriteConsoleA

stdHandle DWORD 0 ; for WriteConsoleA

s1 BYTE "Hello Universe", 13, 10, 0

lenS1 = ($ - s1)

.code

_main PROC

print:

; get STDOUT handle

push -11 ; request STD_OUTPUT_HANDLE (-11)

call GetStdHandle ; call WinAPI to get console handle

mov stdHandle, eax ; save stdHandle

push 0 ; reserved, push NULL

push OFFSET bytesWritten ; bytes written

mov eax, lenS1

push eax ; bytes to write

push OFFSET s1 ; string address

push stdHandle ; STD_OUPUT_HANDLE

call WriteConsoleA ; call win api to write text to console

done:

INVOKE ExitProcess, 0

_main ENDP

END

Related Solutions

Write a C function str_to_float() that takes a numeric string as input and converts it to...
Write a C function str_to_float() that takes a numeric string as input and converts it to a floating point number. The function should return the floating point number by reference. If the conversion is successful, the function should return 0, and -1 otherwise (e.g. the string does not contain a valid number). The prototype of the function is given below int str_to_float(char * str, float * number);
Write a program that converts a given floating point binary number with a 24-bit normalized mantissa...
Write a program that converts a given floating point binary number with a 24-bit normalized mantissa and an 8-bit exponent to its decimal (i.e. base 10) equivalent. For the mantissa, use the representation that has a hidden bit, and for the exponent use a bias of 127 instead of a sign bit. Of course, you need to take care of negative numbers in the mantissa also. Use your program to answer the following questions: (a) Mantissa: 11110010 11000101 01101010, exponent:...
using Windows 32 bit framework , Write an assembly language program to find the second minimum...
using Windows 32 bit framework , Write an assembly language program to find the second minimum element (formally, second minimum is larger than the minimum but smaller than all the other elements in the array) of an array of size 100. Note: You can define the array as nbrArray DWORD 23 45 21 67 78 95 dup(?) and show that your program works for the first five elements. Display the second minimum in a message box using Input output macro
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Write a MIPS assembly language program that inputs a floating-point number and shows its internal 32-bit...
Write a MIPS assembly language program that inputs a floating-point number and shows its internal 32-bit representation as a 8-digit hexadecimal representation. For example: 2.5 decimal is 10.1 binary, which normalized is 1.01x21 and would be stored in the IEEE format as 0100 0000 0010 0000 0000 0000 0000 0000 which is 0x40200000
Write a program that accepts a number of minutes and converts it both to hours and...
Write a program that accepts a number of minutes and converts it both to hours and days. For example, 6000 minutes is 100.0 hours or 4.166666666666667 days. (I currently have what is below) import java.util.Scanner; public class MinutesConversion { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numOfMinutes = sc.nextInt(); double hour = numOfMinutes/60.00; double days = (hour/24); System.out.println(numOfMinutes + " minutes is " + hour + " hours or " + days + " days.");...
Write a program that accepts a number of minutes and converts it to days and hours....
Write a program that accepts a number of minutes and converts it to days and hours. For example, 6000 minutes represents 4 days and 4 hours. Be sure to provide proper exception handling for non-numeric values and for negative values. Save the file as  MinuteConversionWithExceptionHandling.java
Write a program that prompts the user to enter a person’s date of birth in numeric...
Write a program that prompts the user to enter a person’s date of birth in numeric form such as 8-27-1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Follow similar conventions for the invalid values of month and year. (Note that your program...
Write the following in C language for Arduino: Write a program that turns on the LED...
Write the following in C language for Arduino: Write a program that turns on the LED at 25%, 50%, 75%, 100%, and then 0% brightness with a one second delay in between each change. Remember you are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine the values for...
Write a program that converts the user's number into the desired unit of measurement. The user...
Write a program that converts the user's number into the desired unit of measurement. The user will pick the desired unit from a menu shown below. Ask the follow-up question (the number to convert) and do the math ONLY if the user picks a valid choice from the menu. You can see the conversions / multipliers needed for this program in the output section below. Menu/Prompt: Enter the number that corresponds to your desired unit conversion from the choices below:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT