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 ยป
assembly languageplease watch video:https://www.youtube.com/watch?v=-LJgsE6MhVc&feature=youtu.be


https://www.youtube.com/watch?v=-4-gv2VQ0YU&feature=youtu.be


https://www.youtube.com/watch?v=28d4qXb_JSc&feature=youtu.be


https://www.youtube.com/watch?v=bV_vvhwMNNU&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 DayNov 12, 2021

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

Gaurav answered on Nov 15 2021
153 Votes
ha1-kpb1h1ih/.vs/windows32/v14/.suo
ha1-kpb1h1ih/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
ha1-kpb1h1ih/windows32.VC.db
ha1-kpb1h1ih/windows32/Debug/windows32.Build.CppClean.log
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\vc140.pdb
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\vc140.idb
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\framework.obj
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\framework.cod
c:\users\ganapathy\desktop\ha1-kpb1h1ih\debug\windows32.ilk
c:\users\ganapathy\desktop\ha1-kpb1h1ih\debug\windows32.exe
c:\users\ganapathy\desktop\ha1-kpb1h1ih\debug\windows32.map
c:\users\ganapathy\desktop\ha1-kpb1h1ih\deb
ug\windows32.pdb
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\framework.res
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\ha.obj
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\io.obj
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\cl.command.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\cl.read.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\cl.write.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\link.command.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\link.read.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\link.write.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\rc.command.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\rc.read.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\rc.write.1.tlog
c:\users\ganapathy\desktop\ha1-kpb1h1ih\windows32\debug\windows32.tlog\windows32.write.1u.tlog
ha1-kpb1h1ih/windows32/Debug/windows32.log
ha1-kpb1h1ih/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();
}
ha1-kpb1h1ih/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
/////////////////////////////////////////////////////////////////////////////
ha1-kpb1h1ih/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 a ", 0
prompt2 BYTE "Enter 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
    push    number2
    push    number1
    call    gcd
    add        esp, 8
    
    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
gcd PROC
    push ebx                    ; save temporary register
    mov eax, [esp + 8]            ; get a
    mov ebx, [esp + 12]        ; get b
    cmp eax, ebx                ; compare a and b
    jl     lesser                    ; a < b
    jg     greater                ; a > b
    jmp     return                    ; a = b
greater:
    cmp     ebx, 0                    ; b > 0
    jle lesser
    sub eax, ebx                ; a - b    
    jmp     recurse_call
lesser:    
    cmp eax, 0                    ; a > 0
    jle     return    
    sub ebx, eax                ; b - a
recurse_call:
    push ebx                    ; b - second argument
    push eax                    ; a - first argument
    call gcd                    ; recursive call
    add     esp, 8                    ; restore the stack from arguments
return:    
    pop ebx                        ; restore the register
    ret                            ; return from subroutine
gcd ENDP        
END                                ; end of source code        
ha1-kpb1h1ih/windows32/ha.lst
Microsoft (R) Macro Assembler Version 14.00.24210.0     11/15/20 21:28:39
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 45 6E 74 65 72    prompt1 BYTE "Enter a ", 0
     20 61 20 00
00000011 45 6E 74 65 72    prompt2 BYTE "Enter b ", 0
     20 62 20 00
0000001A 00000028 [        string BYTE 40 DUP (?)
     00
     ]
00000042 47 43 44 20 3A    resultLbl BYTE "GCD : ", 0
     20 00
00000049 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 FF 35 00000004 R        push    number2
0000006A FF 35 00000000 R        push    number1
00000070 E8 0000003A            call    gcd
00000075 83 C4 08            add        esp, 8
                    
                    dtoa sum, eax            ; convert to ASCII characters
                    output resultLbl, sum ; output label and sum
000000A9 B8 00000000            mov eax, 0                ; exit with return code 0
000000AE C3                ret
000000AF            _MainProc ENDP
000000AF            gcd PROC
000000AF 53                push ebx                    ; save temporary register
000000B0 8B 44 24 08            mov eax, [esp + 8]            ; get a
000000B4 8B 5C 24 0C            mov ebx, [esp + 12]        ; get b
000000B8 3B C3            cmp eax, ebx                ; compare a and b
000000BA 7C 0D            jl     lesser                    ; a < b
000000BC 7F 02            jg     greater                ; a > b
000000BE EB 1A            jmp     return                    ; a = b
000000C0            greater:
000000C0 83 FB 00            cmp     ebx, 0                    ; b > 0
000000C3 7E 04            jle lesser
000000C5 2B C3            sub eax, ebx                ; a - b    
000000C7 EB 07            jmp     recurse_call
000000C9            lesser:    
000000C9 83 F8 00            cmp eax, 0                    ; a > 0
000000CC 7E 0C            jle     return    
000000CE 2B D8            sub ebx, eax                ; b - a
000000D0            recurse_call:
000000D0 53                push ebx                    ; b - second argument
000000D1 50                push eax                    ; a - first argument
000000D2 E8 FFFFFFD8            call gcd                    ; recursive call
000000D7 83 C4 08            add     esp, 8                    ; restore the stack from arguments
000000DA            return:    
000000DA 5B                pop ebx                        ; restore the register
000000DB C3                ret                            ; return from subroutine
000000DC            gcd ENDP        
                END                                ; end of source code        
๏ฟฝMicrosoft (R) Macro Assembler Version 14.00.24210.0     11/15/20 21:28:39
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     00000055 Para     Public 'DATA'    
_TEXT . . . . . . . . . . . . .    32 Bit     000000DC Para     Public 'CODE'    
Procedures, parameters, and locals:
N a m e Type Value Attr
_MainProc . . . . . . . . . . .    P Near     00000000 _TEXT    Length= 000000AF Public
gcd . . . . . . . . . . . . . .    P Near     000000AF _TEXT    Length= 0000002D Public
greater . . . . . . . . . . .    L Near     000000C0 _TEXT    
lesser . . . . . . . . . . . .    L Near     000000C9 _TEXT    
recurse_call . . . . . . . . .    L Near     000000D0 _TEXT    
return . . . . . . . . . . . .    L Near     000000DA _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     00000011 _DATA    
resultLbl . . . . . . . . . . .    Byte     00000042 _DATA    
string . . . . . . . . . . . . .    Byte     0000001A _DATA    
sum . . . . . . . . . . . . . .    Byte     00000049 _DATA    
wtoaproc . . . . . . . . . . . .    L Near     00000000 FLAT    External
     0 Warnings
     0 Errors
ha1-kpb1h1ih/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
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here