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();
}
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 XXXXXXXXXXIDC_TEXT,7,21,193,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDC_OK,156,40,44,14
EDITTEXT XXXXXXXXXXIDC_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
XXXXXXXXXXLEFTMARGIN, 7
XXXXXXXXXXRIGHTMARGIN, 200
XXXXXXXXXXTOPMARGIN, 6
XXXXXXXXXXBOTTOMMARGIN, 56
END
END
#endif
APSTUDIO_INVOKED
#endif
English (U.S.) resources
windows32/ha.asm
; Example assembly language program -- adds two numbers
; Author: R. Detme
; 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 (?)
esultLbl BYTE "The sum is", 0
sum BYTE 11 DUP (?), 0
.CODE
_MainProc PROC
input prompt1, string, 40 ; read ASCII characters
atod string ; convert to intege
mov number1, eax ; store in memory
input prompt2, string, 40 ; repeat for second numbe
atod string
mov number2, eax
mov eax, number1 ; first number to EAX
add eax, number2 ; add second numbe
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. Detme
; 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
XXXXXXXXXXpush ebp ; save base pointe
XXXXXXXXXXmov ebp, esp ; establish stack frame
XXXXXXXXXXpush eax ; Save registers
XXXXXXXXXXpush ebx
XXXXXXXXXXpush ecx
XXXXXXXXXXpush edx
XXXXXXXXXXpush edi
XXXXXXXXXXpushfd ; save flags
XXXXXXXXXXmov eax, [ebp+8] ; first parameter (source integer)
XXXXXXXXXXand eax, 0ffffh ; mask high-order word
XXXXXXXXXXmov edi, [ebp+12] ; second parameter (dest offset)
ifSpecW: cmp ax,8000h ; special case -32,768?
XXXXXXXXXXjne EndIfSpecW ; if not, then normal case
XXXXXXXXXXmov BYTE PTR [edi],'-' ; manually put in ASCII codes
XXXXXXXXXXmov BYTE PTR [edi+1],'3' ; for -32,768
XXXXXXXXXXmov BYTE PTR [edi+2],'2'
XXXXXXXXXXmov BYTE PTR [edi+3],'7'
XXXXXXXXXXmov BYTE PTR [edi+4],'6'
XXXXXXXXXXmov BYTE PTR [edi+5],'8'
XXXXXXXXXXjmp ExitIToA ; done with special case
EndIfSpecW:
XXXXXXXXXXpush eax ; save source numbe
XXXXXXXXXXmov al,' ' ; put blanks in
XXXXXXXXXXmov ecx,5 ; first five
XXXXXXXXXXcld ; bytes of
XXXXXXXXXXrep stosb ; destination field
XXXXXXXXXXpop eax ; restore source numbe
XXXXXXXXXXmov cl,' ' ; default sign (blank for +)
IfNegW: cmp ax,0 ; check sign of numbe
XXXXXXXXXXjge EndIfNegW ; skip if not negative
XXXXXXXXXXmov cl,'-' ; sign for negative numbe
XXXXXXXXXXneg ax ; number in AX now >= 0
EndIfNegW:
XXXXXXXXXXmov bx,10 ; diviso
WhileMoreW: mov dx,0 ; extend number to doubleword
XXXXXXXXXXdiv bx ; divide by 10
XXXXXXXXXXadd dl,'0' ; convert remainder to characte
XXXXXXXXXXmov [edi],dl ; put character in string
XXXXXXXXXXdec