Question

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

Write a program 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. PLEASE WRITE IN MASM!

Starter file:

; Assignment 5.3
; Prepare for output!(Challenge Assignment) - MASM(32 - bit)
; Copyright(c) 2017 Hall & Slonka

; Solution must use system call information from Chapter 10
; Use the CONSOLE subsystem(in project properties)
; Build, then run in a console window

.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
        val DWORD 0FFFFh                                                                        ; 65, 535 of possible 4, 294, 967, 295
        valArr BYTE 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0Ah, 0        ; 12 bytes
                                                                                                                ; 10 = max digits for 32 - bit number
                                                                                                                ; pre - load to 0 (non - print NULL)

        .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
                push 12                                         ; bytes to write
                push OFFSET valArr                      ; valArr address
                push stdHandle                          ; STD_OUPUT_HANDLE
                call WriteConsoleA                      ; call win api to write text to console

INVOKE ExitProcess, 0
_main ENDP
END
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Write a program that turns a 32-bit numeric value (e.g., 0xFFFFh) and converts it to a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code...

    X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code INCLUDE Irvine32.inc         .data       KeyPrompt BYTE "Enter the passphrase: ",0       TextPrompt BYTE "Enter the plaintest: ",0           str1 BYTE "The passphrase has length:",0           str2 BYTE "The plaintest has length:",0       KeyIs BYTE "The passphrase: ",0       PlainTextIs BYTE "The plaintext: ",0       CipherTextIs BYTE "The ciphertext: ",0       KMAX = 64                        ; passphrase buffer maximum size       BMAX = 128                       ; test...

  • Write a Python program which defines a function named "divide_two_numbers" that accepts two numeric parameters and...

    Write a Python program which defines a function named "divide_two_numbers" that accepts two numeric parameters and divides the first parameter by the second. Your divide_two_numbers function must check the second parameter before dividing; if it is zero, raise an ZeroDivisionError exception which includes the string "second parameter was zero!" as a parameter instead of processing the division. Your main function must call your divide_two_numbers function at least twice; one call must use two normal parameters to verify normal operation, the...

  • Part 3.  Write a program to dynamically allocate some char buffers, use memset to fill them, and...

    Part 3.  Write a program to dynamically allocate some char buffers, use memset to fill them, and use memcpy and memmove to move the data around. I suggest you do part 3a, test and verify it’s working as expected, then add part b, test & verify, then do part 3c.  You only need to turn in the complete program, but doing it in steps will help both with understanding and if you have bugs along the way. Part 3a. a.Allocate 2 char...

  • ASSEMBLY LANGUAGE Write a program using author's routine, WriteString, to print "Hello World". This routine will...

    ASSEMBLY LANGUAGE Write a program using author's routine, WriteString, to print "Hello World". This routine will output to the screen any character data pointed to by the EDX register. It will continue to print until it runs into the null character (zero). We need only to move the address into the EDX register and calll his routine. Lookup in the ASCII code chart the value reqresented by CR and LF. In the program I will define these values using the...

  • Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers

    Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...

  • User Profiles Write a program that reads in a series of customer information -- including name,...

    User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...

  • For this computer assignment, you are to write a C++ program to implement a class for...

    For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • How to write the insert, search, and remove functions for this hash table program? I'm stuck......

    How to write the insert, search, and remove functions for this hash table program? I'm stuck... This program is written in C++ Hash Tables Hash Table Header File Copy and paste the following code into a header file named HashTable.h Please do not alter this file in any way or you may not receive credit for this lab For this lab, you will implement each of the hash table functions whose prototypes are in HashTable.h. Write these functions in a...

  • /*************************************************** Name: Date: Homework #7 Program name: HexUtilitySOLUTION Program description: Accepts hexadecimal numbers as input. Valid...

    /*************************************************** Name: Date: Homework #7 Program name: HexUtilitySOLUTION Program description: Accepts hexadecimal numbers as input. Valid input examples: F00D, 000a, 1010, FFFF, Goodbye, BYE Enter BYE (case insensitive) to exit the program. ****************************************************/ import java.util.Scanner; public class HexUtilitySOLUTION { public static void main(String[] args) { // Maximum length of input string final byte INPUT_LENGTH = 4; String userInput = ""; // Initialize to null string Scanner input = new Scanner(System.in); // Process the inputs until BYE is entered do {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT