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...

1 answer below »
follow the lecture video:https://www.youtube.com/watch?v=1oPWmnnBUKU&feature=youtu.behttps://www.youtube.com/watch?v=Jph3eGnWzCs&feature=youtu.be
https://www.youtube.com/watch?v=JAYlBTOVXu4&feature=youtu.be



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, ""); break; 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); } } break; } break; case WM_CLOSE: EndDialog(hwnd, 0); break; 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 bar // 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(); } 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 ///////////////////////////////////////////////////////////////////////////// windows32/ha.asm ; Example assembly language program -- adds two numbers ; Author: R. Detmer ; Date: 1/2013 .586 .MODEL FLAT INCLUDE io.h; header file for input/output .STACK 4096 .DATA number1 DWORD ? number2 DWORD ? prompt1 BYTE "Enter first number", 0 prompt2 BYTE "Enter second number", 0 string BYTE 40 DUP (?) resultLbl BYTE "The sum is", 0 sum BYTE 11 DUP (?), 0 .CODE _MainProc PROC input prompt1, string, 40; read ASCII characters atod string; convert to integer mov number1, eax; store in memory input prompt2, string, 40; repeat for second number atod string mov number2, eax mov eax, number1; first number to EAX add eax, number2; add second number dtoa sum, eax; convert to ASCII characters output resultLbl, sum ; output label and sum mov eax, 0; exit with return code 0 ret _MainProc ENDP END; end of source code windows32/io.asm ; data conversion procedures - 32-bit versions ; author: R. Detmer ; revised: 10/2007 .586 .MODEL FLAT PUBLIC wtoaproc, atowproc, dtoaproc, atodproc .CODE ; wtoaproc(source, dest) ; convert integer (source) to string of 6 characters at given destination address ; source integer passed as a doubleword, but only low-order word is processed wtoaproc PROC push ebp ; save base pointer mov ebp, esp ; establish stack frame push eax ; Save registers push ebx push ecx push edx push edi pushfd ; save flags mov eax, [ebp+8] ; first parameter (source integer) and eax, 0ffffh ; mask high-order word mov edi, [ebp+12] ; second parameter (dest offset) ifSpecW: cmp ax,8000h ; special case -32,768? jne EndIfSpecW ; if not, then normal case mov BYTE PTR [edi],'-' ; manually put in ASCII codes mov BYTE PTR [edi+1],'3' ; for -32,768 mov BYTE PTR [edi+2],'2' mov BYTE PTR [edi+3],'7' mov BYTE PTR [edi+4],'6' mov BYTE PTR [edi+5],'8' jmp ExitIToA ; done with special case EndIfSpecW: push eax ; save source number mov al,' ' ; put blanks in mov ecx,5 ; first five cld ; bytes of rep stosb ; destination field pop eax ; restore source number mov cl,' ' ; default sign (blank for +) IfNegW: cmp ax,0 ; check sign of number jge EndIfNegW ; skip if not negative mov cl,'-' ; sign for negative number neg ax ; number in AX now >= 0 EndIfNegW: mov bx,10 ; divisor WhileMoreW: mov dx,0 ; extend number to doubleword div bx ; divide by 10 add dl,'0' ; convert remainder to character mov [edi],dl ; put character in string dec
Answered Same DayOct 02, 2021

Answer To: windows32/framework.c #include #include "resource.h" static char buf[255]; static char...

Gaurav answered on Oct 07 2021
163 Votes
ha4-1/.vs/windows32/v14/.suo
ha4-1/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
ha4-1/windows32.VC.db
ha4-1/windows32/Debug/windows32.Build.CppClean.log
c:\users\ganapathy\desktop\ha4-1\windows32\debug\vc140.pdb
c:\users\ganapathy\desktop\ha4-1\windows32\debug\vc140.idb
c:\users\ganapathy\desktop\ha4-1\windows32\debug\framework.obj
c:\users\ganapathy\desktop\ha4-1\windows32\debug\framework.cod
c:\users\ganapathy\desktop\ha4-1\debug\windows32.ilk
c:\users\ganapathy\desktop\ha4-1\debug\windows32.exe
c:\users\ganapathy\desktop\ha4-1\debug\windows32.map
c:\users\ganapathy\desktop\ha4-1\debug\windows32.pdb
c:\users\gan
apathy\desktop\ha4-1\windows32\debug\framework.res
c:\users\ganapathy\desktop\ha4-1\windows32\debug\ha.obj
c:\users\ganapathy\desktop\ha4-1\windows32\debug\io.obj
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\cl.command.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\cl.read.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\cl.write.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\link.command.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\link.read.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\link.write.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\rc.command.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\rc.read.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\rc.write.1.tlog
c:\users\ganapathy\desktop\ha4-1\windows32\debug\windows32.tlog\windows32.write.1u.tlog
ha4-1/windows32/Debug/windows32.log
ha4-1/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, "");
        break;
        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);
                    }
                }
                break;
            }
        break;
        case WM_CLOSE:
            EndDialog(hwnd, 0);
        break;
        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 bar
// 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();
}
ha4-1/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
/////////////////////////////////////////////////////////////////////////////
ha4-1/windows32/ha.asm
; Example assembly language program -- adds two numbers
; Author: R. Detmer
; Date: 1/2013
.586
.MODEL FLAT
INCLUDE io.h                ; header file for input/output
.STACK 4096
.DATA
number1 DWORD ?
number2 DWORD ?
prompt1 BYTE "a : ", 0
prompt2 BYTE "b : ", 0
string BYTE 40 DUP (?)
resultLbl BYTE "gcd : ", 0
sum BYTE 11 DUP (?), 0
.CODE
_MainProc PROC
    input prompt1, string, 40    ; read ASCII characters
    atod string                ; convert to integer
    mov number1, eax        ; store in memory
    input prompt2, string, 40    ; repeat for second number
    atod string
    mov number2, eax
    mov        ebx, number1        ; gcd
    mov        edx, number2        ; remainder
GCD:
    mov        eax, ebx            ; numerator
    mov        ebx, edx            ; gcd
    mov        edx, 0                ; clear edx for division
    idiv    ebx                    ; eax = numerator / gcd, edx = numerator % gcd
    cmp        edx, 0                ; remainder == 0
    jne        GCD                    ; if (remainder != 0) then repeat
    
    dtoa sum, ebx            ; convert to ASCII characters
    output resultLbl, sum ; output label and sum
    mov eax, 0                ; exit with return code 0
    ret
_MainProc ENDP
END                    ; end of source code
ha4-1/windows32/ha.lst
Microsoft (R) Macro Assembler Version 14.00.24210.0     10/07/20 23:03:13
ha.asm                             Page 1 - 1
                ; Example assembly language program -- adds two numbers
                ; Author: R. Detmer
                ; Date: 1/2013
                .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        number1 DWORD ?
00000004 00000000        number2 DWORD ?
00000008 61 20 3A 20 00    prompt1 BYTE "a : ", 0
0000000D 62 20 3A 20 00    prompt2 BYTE "b : ", 0
00000012 00000028 [        string BYTE 40 DUP (?)
     00
     ]
0000003A 67 63 64 20 3A    resultLbl BYTE "gcd : ", 0
     20 00
00000041 0000000B [        sum BYTE 11 DUP (?), 0
     00
     ] 00
00000000            .CODE
00000000            _MainProc PROC
                    input prompt1, string, 40    ; read ASCII characters
                    atod string                ; convert to integer
0000002D A3 00000000 R        mov number1, eax        ; store in memory
                    input prompt2, string, 40    ; repeat for second number
                    atod string
0000005F A3 00000004 R        mov number2, eax
00000064 8B 1D 00000000 R        mov        ebx, number1        ; gcd
0000006A 8B 15 00000004 R        mov        edx, number2        ; remainder
00000070            GCD:
00000070 8B C3            mov        eax, ebx            ; numerator
00000072 8B DA            mov        ebx, edx            ; gcd
00000074 BA 00000000            mov        edx, 0                ; clear edx for division
00000079 F7 FB            idiv    ebx                    ; eax = numerator / gcd, edx = numerator % gcd
0000007B 83 FA 00            cmp        edx, 0                ; remainder == 0
0000007E 75 F0            jne        GCD                    ; if (remainder != 0) then repeat
                    
                    dtoa sum, ebx            ; convert to ASCII characters
                    output resultLbl, sum ; output label and sum
000000B1 B8 00000000            mov eax, 0                ; exit with return code 0
000000B6 C3                ret
000000B7            _MainProc ENDP
                END                    ; end of source code
�Microsoft (R) Macro Assembler Version 14.00.24210.0     10/07/20 23:03:13
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     0000004D Para     Public 'DATA'    
_TEXT . . . . . . . . . . . . .    32 Bit     000000B7 Para     Public 'CODE'    
Procedures, parameters, and locals:
N a m e Type Value Attr
_MainProc . . . . . . . . . . .    P Near     00000000 _TEXT    Length= 000000B7 Public
GCD . . . . . . . . . . . . .    L Near     00000070 _TEXT    
Symbols:
N a m e Type Value Attr
@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
atodproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
atowproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
dtoaproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
number1 . . . . . . . . . . . .    DWord     00000000 _DATA    
number2 . . . . . . . . . . . .    DWord     00000004 _DATA    
prompt1 . . . . . . . . . . . .    Byte     00000008 _DATA    
prompt2 . . . . . . . . . . . .    Byte     0000000D _DATA    
resultLbl . . . . . . . . . . .    Byte     0000003A _DATA    
string . . . . . . . . . . . . .    Byte     00000012 _DATA    
sum . . . . . . . . . . . . . .    Byte     00000041 _DATA    
wtoaproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
     0 Warnings
     0 Errors
ha4-1/windows32/io.asm
; data conversion procedures - 32-bit versions
; author: R. Detmer
; revised: 10/2007
.586
.MODEL FLAT
PUBLIC wtoaproc, atowproc, dtoaproc, atodproc
.CODE
; wtoaproc(source, dest)
; convert integer (source) to string of 6 characters at given destination address
; source integer passed as a doubleword, but only low-order word is processed
wtoaproc PROC
push ebp ; save base pointer
mov ebp, esp ; establish stack frame
push eax ; Save registers
push ebx
push ecx
push edx
push edi
pushfd ; save flags
mov eax, [ebp+8] ; first parameter (source integer)
and eax, 0ffffh ; mask high-order word
mov edi, [ebp+12] ; second parameter (dest offset)
ifSpecW: cmp ax,8000h ; special case -32,768?
jne EndIfSpecW ; if not, then normal case
mov BYTE PTR [edi],'-' ; manually put in ASCII codes
mov BYTE PTR [edi+1],'3' ; for -32,768
mov BYTE PTR [edi+2],'2'
mov BYTE PTR [edi+3],'7'
mov BYTE PTR [edi+4],'6'
mov BYTE PTR [edi+5],'8'
jmp ExitIToA ; done with special case
EndIfSpecW:
push eax ; save source number
mov al,' ' ; put blanks in
mov ecx,5 ; first five
cld ; bytes of
rep stosb ; destination field
pop eax ; restore source number
mov cl,' ' ; default sign (blank for +)
IfNegW: cmp ax,0 ; check sign of number
jge EndIfNegW ; skip if not negative
mov cl,'-' ; sign for negative number
neg ax ; number in AX now >= 0
EndIfNegW:
mov bx,10 ; divisor
WhileMoreW: mov dx,0 ; extend number to doubleword
div bx ; divide by 10
add dl,'0' ; convert remainder to character
mov [edi],dl ; put character in string
dec edi ; move forward to next position
cmp ax,0 ; check quotient
jnz WhileMoreW ; continue if quotient not zero
mov [edi],cl ; insert blank or "-" for sign
ExitIToA: popfd ; restore flags and registers
pop edi
pop edx
pop ecx
pop ebx...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here