Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

In the Solutions Explorer window on the right, choose the file windows32/Source Files/ha.asm and look at its text in the left window. Change this program completely into one that prompts the user for...

1 answer below »
  1. In theSolutions Explorerwindow on the right, choose the filewindows32/Source Files/ha.asmand look at its text in the left window.
  2. Change this program completely into one that prompts the user for integersa,b, andc, and displays thequotientandremainderof the fraction:((a * b) + (5 * c)) / 13. Create your own sensible pop-up window titles.

An example execution of your program could result in the following five I/O windows:

Please enter a: 10
Please enter b: 6
Please enter c: -3
Quotient is 3
Remainder is 6


Submit your modifiedha.asmfile

Textbook:Introduction to 80x86 Assembly Language and Computer Architecture (3rd Edition), by Richard C. Detmer, Jones and Bartlett Publishers, 2015. ISBN: XXXXXXXXXX.

Answered Same Day Sep 25, 2021

Solution

Gaurav answered on Sep 26 2021
150 Votes
ha3-2/.vs/windows32/v14/.suo
ha3-2/.vs/windows32/v16/.suo
ha3-2/.vs/windows32/v16/Browse.VC.d
ha3-2/.vs/windows32/v16/Browse.VC.db-shm
ha3-2/.vs/windows32/v16/Browse.VC.db-wal
ha3-2/.vs/windows32/v16/Browse.VC.opend
ha3-2/windows32.sln
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "windows32", "windows32\windows32.vcxproj", "{6B479473-FF1D-447F-9B62-0693B729278A}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Win32 = Debug|Win32
        Release|Win32 = Release|Win32
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {6B479473-FF1D-447F-9B62-0693B729278A}.Debug|Win32.ActiveCfg = Debug|Win32
        {6B479473-FF1D-447F-9B62-0693B729278A}.Debug|Win32.Build.0 = Debug|Win32
        {6B479473-FF1D-447F-9B62-0693B729278A}.Release|Win32.ActiveCfg = Release|Win32
        {6B479473-FF1D-447F-9B62-0693B729278A}.Release|Win32.Build.0 = Release|Win32
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
EndGlobal
ha3-2/windows32.VC.d
ha3-2/windows32/Debug/windows32.Build.CppClean.log
c:\users\ganapathy\desktop\ha3-2\windows32\debug\vc140.pd
c:\users\ganapathy\desktop\ha3-2\windows32\debug\vc140.id
c:\users\ganapathy\desktop\ha3-2\windows32\debug\framework.obj
c:\users\ganapathy\desktop\ha3-2\windows32\debug\framework.cod
c:\users\ganapathy\desktop\ha3-2\debug\windows32.ilk
c:\users\ganapathy\desktop\ha3-2\debug\windows32.exe
c:\users\ganapathy\desktop\ha3-2\debug\windows32.map
c:\users\ganapathy\desktop\ha3-2\debug\windows32.pd
c:\users\ganapathy\desktop\ha3-2\windows32\debug\framework.res
c:\users\ganapathy\desktop\ha3-2\windows32\debug\ha.obj
c:\users\ganapathy\desktop\ha3-2\windows32\debug\io.obj
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\cl.command.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\cl.read.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\cl.write.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\link.command.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\link.read.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\link.write.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\rc.command.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\rc.read.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\rc.write.1.tlog
c:\users\ganapathy\desktop\ha3-2\windows32\debug\windows32.tlog\windows32.write.1u.tlog
ha3-2/windows32/Debug/windows32.exe.recipe

C:\Users\user\Desktop\CS238\ha3-2\Debug\windows32.exe



ha3-2/windows32/Debug/windows32.log
ha3-2/windows32/framework.c
#include #include "resource.h"
static char buf[255];
static char inputLabel[255];
HINSTANCE _hInstance;
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
            
set up the dialog box
            SetDlgItemText(hwnd, IDC_LABEL, inputLabel);
            SetDlgItemText(hwnd, IDC_TEXT, "");
        
eak;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDC_OK:
                {
                    
When somebody clicks OK, get the number of characters entered
                    int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT));
                    if(len > 0)
                    {
                        
get the string into our buffer and exit
                        GetDlgItemText(hwnd, IDC_TEXT, buf, len + 1);
                        EndDialog(hwnd, 0);
                    }
                    else
                    {
                        MessageBox(hwnd, "Nothing entered", "Warning", MB_OK);
                    }
                }
                
eak;
            }
        
eak;
        case WM_CLOSE:
            EndDialog(hwnd, 0);
        
eak;
        default:
            return FALSE;
    }
    return TRUE;
}
#pragma warning(disable : 4996)
disables warning for strcpy use
void getInput(char* inputPrompt, char* result, int maxChars)
generate an input dialog with prompt as a label
and a text box to input a string of up to maxChars characters,
returned in result
{
    strcpy(inputLabel, inputPrompt);
    DialogBox(_hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
    buf[maxChars-1] = '\0';
in case too many characters, terminate string at maxChars
    strcpy(result, buf);
    return;
}
void showOutput(char* outputLabel, char* outputString)
display a message box with outputLabel in the title ba
and outputString in the main area
{
    MessageBox(NULL, outputString, outputLabel, MB_OK);
}
int MainProc(void);
prototype for user's main program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    _hInstance = hInstance;
    return MainProc();
}
ha3-2/windows32/framework.rc
Microsoft Visual C++ generated resource script.
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
Generated from the TEXTINCLUDE 2 resource.
#ifndef __BORLANDC__
#include "winresrc.h"
#endif
#undef APSTUDIO_READONLY_SYMBOLS
English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif
_WIN32
#ifdef APSTUDIO_INVOKED
TEXTINCLUDE
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef __BORLANDC__\r\n"
"#include ""winres.h""\r\n"
"#endif\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif
APSTUDIO_INVOKED
Dialog
IDD_MAIN DIALOGEX 0, 0, 207, 63
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOPMOST
FONT 10, "MS Sans Serif", 400, 0, 0x0
BEGIN
EDITTEXT IDC_TEXT,7,21,193,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDC_OK,156,40,44,14
EDITTEXT IDC_LABEL,7,6,165,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
END
DESIGNINFO
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 200
TOPMARGIN, 6
BOTTOMMARGIN, 56
END
END
#endif
APSTUDIO_INVOKED
#endif
English (U.S.) resources
ha3-2/windows32/ha.asm
; Example assembly language program -- perimeter numbers
; Author: Hassan
; Date: 9/21/20
.586
.MODEL FLAT
INCLUDE io.h                ; header file for input/output
.STACK 4096
.DATA
a_value    DWORD ?
_value    DWORD ?
quotient    DWORD ?
emainder    DWORD ?
prompt1 BYTE "Please enter a: ", 0
prompt2 BYTE "Please enter b: ", 0
prompt3 BYTE    "Please enter c: ", 0
output1 BYTE    "Quotient is ", 0
output2 BYTE    10, 13, "Remainder is ", 0
string BYTE 40 DUP (?)
esultLbl BYTE        "Division", 0
outputString BYTE    64 DUP (0)
.CODE
_MainProc PROC
    input prompt1, string, 40            ; read ASCII characters for a
    atod string                        ; convert to intege
    mov a_value, eax                ; store in memory
    input prompt2, string, 40            ; repeat for
    atod string
    mov b_value, eax
    input prompt3, string, 40            ; repeat for c
    atod string
    mov        ecx, 5                        ; eax = c, ecx = 5
    mul        ecx                            ; c * 5
    mov        ecx, eax                    ; ecx = c * 5
    mov        eax, a_value                ; eax = a
    mov        ebx, b_value                ; ebx =
    mul        ebx                            ; eax = a *
    add        eax, ecx                    ; eax = eax + ecx i.e. ((a * b) + (c * 5))
    mov        edx, 0
    mov        ebx, 13                        ; ebx = 13
    idiv ebx                            ; eax = eax / 13, edx = eax % 13
    mov        quotient, eax                ; save quotient
    mov        remainder, edx                ; save remainde
    
    cld                                    ; increment esi, edi
    mov        ecx, -1                        ; maximum value, since 0 is tested for end of the string
    mov        esi, OFFSET output1            ; address of quotient string
    mov        edi, OFFSET outputString    ; address of output string buffe
loop_1:
    lodsb                                ; copy quotient string into output string buffe
    stos
    cmp        al, 0
    loopne loop_1
    dec        edi                            ; since the 0 at the end, also increment the edi, decrement it to the position of null characte
    dtoa string, quotient            ; convert the quotient to ASCII characters
    mov        esi, OFFSET string            ; concatenate the value of quotient to output string
loop_2:
    lodsb    
    cmp    al, 20h
    je    loop_2
    stos
    cmp        al, 0
    loopne loop_2
    dec        edi    
    mov        esi, OFFSET output2            ; remainder string
loop_3:
    lods
    stos
    cmp        al, 0
    loopne loop_3
    dec        edi    
    dtoa    string, remainder            ; convert the remainder to ASCII characters
    mov        esi, OFFSET string            ; concatenate the value of remainder to output string
loop_4:
    lods
    cmp    al, 20h
    je    loop_4
    stos
    cmp        al, 0
    loopne loop_4
    dec        edi    
    
    output resultLbl, outputString        ; output label and sum
    mov eax, 0                        ; exit with return code 0
    ret
_MainProc ENDP
END                                        ; end of source code
ha3-2/windows32/ha.lst
Microsoft (R) Macro Assembler Version 14.00.24210.0     09/26/20 00:58:42
ha.asm                             Page 1 - 1
                ; Example assembly language program -- perimeter numbers
                ; Author: Hassan
                ; Date: 9/21/20
                .586
                .MODEL FLAT
                INCLUDE io.h                ; header file for input/output
             C ; IO.H -- header file for I/O macros (listing suppressed)
             C .NOLIST ; turn off listing
             C .LIST ; begin listing
             C
                .STACK 4096
00000000            .DATA
00000000 00000000        a_value    DWORD ?
00000004 00000000        b_value    DWORD ?
00000008 00000000        quotient    DWORD ?
0000000C 00000000        remainder    DWORD ?
00000010 50 6C 65 61 73    prompt1 BYTE "Please enter a: ", 0
     65 20 65 6E 74
     65 72 20 61 3A
     20 00
00000021 50 6C 65 61 73    prompt2 BYTE "Please enter b: ", 0
     65 20 65 6E 74
     65 72 20 62 3A
     20 00
00000032 50 6C 65 61 73    prompt3 BYTE    "Please enter c: ", 0
     65 20 65 6E 74
     65 72 20 63 3A
     20 00
00000043 51 75 6F 74 69    output1 BYTE    "Quotient is ", 0
     65 6E 74 20 69
     73 20 00
00000050 0A 0D 52 65 6D    output2 BYTE    10, 13, "Remainder is ", 0
     61 69 6E 64 65
     72 20 69 73 20
     00
00000060            string BYTE 40 DUP (?)
00000088 44 69 76 69 73    resultLbl BYTE        "Division", 0
     69 6F 6E 00
00000091            outputString BYTE    64 DUP (0)
00000000            .CODE
00000000            _MainProc PROC
                    input prompt1, string, 40            ; read ASCII characters for a
                    atod string                        ; convert to intege
0000002D A3 00000000 R        mov a_value, eax                ; store in memory
                    input prompt2, string, 40            ; repeat for
                    atod string
0000005F A3 00000004 R        mov b_value, eax
                    input prompt3, string, 40            ; repeat for c
                    atod string
00000091 B9 00000005            mov        ecx, 5                        ; eax = c, ecx = 5
00000096 F7 E1            mul        ecx                            ; c * 5
00000098 8B C8            mov        ecx, eax                    ; ecx = c * 5
0000009A A1 00000000 R        mov        eax, a_value                ; eax = a
0000009F 8B 1D 00000004 R        mov        ebx, b_value                ; ebx =
000000A5 F7 E3            mul        ebx                            ; eax = a *
000000A7 03 C1            add        eax, ecx                    ; eax = eax + ecx i.e. ((a * b) + (c * 5))
000000A9 BA 00000000            mov        edx, 0
000000AE BB 0000000D            mov        ebx, 13                        ; ebx = 13
000000B3 F7 FB            idiv ebx                            ; eax = eax / 13, edx = eax % 13
000000B5 A3 00000008 R        mov        quotient, eax                ; save quotient
000000BA 89 15 0000000C R        mov        remainder, edx                ; save remainde
                    
000000C0 FC                cld                                    ; increment esi, edi
000000C1 B9 FFFFFFFF            mov        ecx, -1                        ; maximum value, since 0 is tested for end of the string
000000C6 BE 00000043 R        mov        esi, OFFSET output1            ; address of quotient string
000000CB BF 00000091 R        mov        edi, OFFSET outputString    ; address of output string buffe
000000D0            loop_1:
000000D0 AC                lodsb                                ; copy quotient string into output string buffe
000000D1 AA                stos
000000D2 3C 00            cmp        al, 0
000000D4 E0 FA            loopne loop_1
000000D6 4F                dec        edi                            ; since the 0 at the end, also increment the edi, decrement it to the position of null characte
                    dtoa string, quotient            ; convert the quotient to ASCII characters
000000F3 BE 00000060 R        mov        esi, OFFSET string            ; concatenate the value of quotient to output string
000000F8            loop_2:
000000F8 AC                lodsb    
000000F9 3C 20            cmp    al, 20h
000000FB 74 FB            je    loop_2
000000FD AA                stos
000000FE 3C 00            cmp        al, 0
00000100 E0 F6            loopne loop_2
00000102 4F                dec        edi    
00000103 BE 00000050 R        mov        esi, OFFSET output2            ; remainder string
00000108            loop_3:
00000108 AC                lods
00000109 AA                stos
0000010A 3C 00            cmp        al, 0
0000010C E0 FA            loopne loop_3
0000010E 4F                dec        edi    
                    dtoa    string, remainder            ; convert the remainder to ASCII characters
0000012B BE 00000060 R        mov        esi, OFFSET string            ; concatenate the value of remainder to output string
00000130            loop_4:
00000130 AC                lods
00000131 3C 20            cmp    al, 20h
00000133 74 FB            je    loop_4
00000135 AA                stos
00000136 3C 00            cmp        al, 0
00000138 E0 F6            loopne loop_4
0000013A 4F                dec        edi    
                    
                    output resultLbl, outputString        ; output label and sum
00000154 B8 00000000            mov eax, 0                        ; exit with return code 0
00000159 C3                ret
0000015A            _MainProc ENDP
                END                                        ; end of source code
�Microsoft (R) Macro Assembler Version 14.00.24210.0     09/26/20 00:58:42
ha.asm                             Symbols 2 - 1
Macros:
N a m e Type
atod . . . . . . . . . . . . . .    Proc
atow . . . . . . . . . . . . . .    Proc
dtoa . . . . . . . . . . . . . .    Proc
input . . . . . . . . . . . . .    Proc
output . . . . . . . . . . . . .    Proc
wtoa . . . . . . . . . . . . . .    Proc
Segments and Groups:
N a m e Size Length Align Combine Class
FLAT . . . . . . . . . . . . . .    GROUP
STACK . . . . . . . . . . . . .    32 Bit     00001000 Para     Stack     'STACK'    
_DATA . . . . . . . . . . . . .    32 Bit     000000D1 Para     Public 'DATA'    
_TEXT . . . . . . . . . . . . .    32 Bit     0000015A Para     Public 'CODE'    
Procedures, parameters, and locals:
N a m e Type Value Att
_MainProc . . . . . . . . . . .    P Near     00000000 _TEXT    Length= 0000015A Public
loop_1 . . . . . . . . . . . .    L Near     000000D0 _TEXT    
loop_2 . . . . . . . . . . . .    L Near     000000F8 _TEXT    
loop_3 . . . . . . . . . . . .    L Near     00000108 _TEXT    
loop_4 . . . . . . . . . . . .    L Near     00000130 _TEXT    
Symbols:
N a m e Type Value Att
@CodeSize . . . . . . . . . . .    Number     00000000h
@DataSize . . . . . . . . . . .    Number     00000000h
@Interface . . . . . . . . . . .    Number     00000000h
@Model . . . . . . . . . . . . .    Number     00000007h
@code . . . . . . . . . . . . .    Text      _TEXT
@data . . . . . . . . . . . . .    Text      FLAT
@fardata? . . . . . . . . . . .    Text      FLAT
@fardata . . . . . . . . . . . .    Text      FLAT
@stack . . . . . . . . . . . . .    Text      FLAT
_getInput . . . . . . . . . . .    L Near     00000000 FLAT    External
_showOutput . . . . . . . . . .    L Near     00000000 FLAT    External
a_value . . . . . . . . . . . .    DWord     00000000 _DATA    
atodproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
atowproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
_value . . . . . . . . . . . .    DWord     00000004 _DATA    
dtoaproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
output1 . . . . . . . . . . . .    Byte     00000043 _DATA    
output2 . . . . . . . . . . . .    Byte     00000050 _DATA    
outputString . . . . . . . . . .    Byte     00000091 _DATA    
prompt1 . . . . . . . . . . . .    Byte     00000010 _DATA    
prompt2 . . . . . . . . . . . .    Byte     00000021 _DATA    
prompt3 . . . . . . . . . . . .    Byte     00000032...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here