Ive just downloaded an old code sample dated 1991 called Masmwin from Microsoft.com, i fell across it, just looking around but what has me confused is this line
.model small,pascal
Pascal?I know Masm can support C style prototyping and other High Level functions, but pascal? ive never seen this before? i was wondering, becuase Microsoft's C compilers supported Pascal calling methods ( For DLL's made with pascal? ) if this was the same thing?
The full sample
;
; MASMWIN.ASM
; Brian Lieuallen
; Copyright (c) 1991 Microsoft Corporation. All rights reserved.
.model small,pascal
.286
.287
OPTION CASEMAP:NONE
include windows.inc
?WINDOWS=1
include winpro.inc
OPTION PROLOGUE:cPrologue
OPTION EPILOGUE:cEpilogue
WndProc PROTO FAR hwnd:HWND,message:WORD,wParam:WORD,lParam:DWORD
AboutBoxProc PROTO FAR hwnd:HWND,message:WORD,wParam:WORD,lParam:DWORD
ID_ICON equ 1000
.data
localheaphead db 16 dup (?)
szAppName BYTE 'MasmWin',0
szTitle byte 'A windows program in MASM',0
string1 byte 'Masm is great',0
string2 byte 'C is for wimps',0
about byte 'ABOUT',0
menuname byte 'GenericMenu',0
flag word 0
hInst word ?
lpProcAbout dword ?
extern __acrtused:abs
.code
WinMain PROC uses si di, hInstance :HANDLE,
hPrevInstance:HANDLE,
lpszCmdParam :LPSTR,
nCmdShow :WORD
LOCAL hwnd :HWND,
msg :MSG,
wndclass :WNDCLASS
cmp hPrevInstance,0
jne dontregister
mov wndclass.style, CS_HREDRAW OR CS_VREDRAW
mov word ptr wndclass.lpfnWndProc, offset WndProc
mov word ptr wndclass.lpfnWndProc+2, seg WndProc
mov wndclass.cbClsExtra,0
mov wndclass.cbWndExtra,0
mov ax,hInstance
mov hInst,ax
mov wndclass.hInstance,ax
INVOKE LoadIcon, ax, ID_ICON
mov wndclass.hIcon,ax
INVOKE LoadCursor, 0,32512 ; IDC_ARROW
mov wndclass.hCursor,ax
INVOKE GetStockObject,WHITE_BRUSH
mov wndclass.hbrBackground,ax
mov word ptr wndclass.lpszMenuName, offset menuname
mov word ptr wndclass.lpszMenuName+2,ds
mov word ptr wndclass.lpszClassName, offset szAppName
mov word ptr wndclass.lpszClassName+2, ds
INVOKE RegisterClass,ADDR wndclass
or ax,ax
je progexit
dontregister:
INVOKE CreateWindow, ADDR szAppName,
ADDR szTitle,
WS_OVERLAPPEDWINDOW,
08000h,
08000h,
08000h,
08000h,
0,
0,
hInstance,
0
or ax,ax
je progexit
mov hwnd,ax
INVOKE ShowWindow,hwnd,nCmdShow
INVOKE UpdateWindow,hwnd
messageloop:
INVOKE GetMessage,ADDR msg,NULL,0,0
test ax,ax
je progexit
INVOKE TranslateMessage,ADDR msg
INVOKE DispatchMessage,ADDR msg
jmp short messageloop
mov ax,msg.wParam
progexit:
ret
WinMain endp
WndProc PROC FAR EXPORT uses si di, hwnd :HWND,
message :WORD,
wParam :WORD,
lParam :DWORD
LOCAL hdc :HDC,
ps :PAINTSTRUCT
mov ax,message
cmp ax,WM_CREATE
jne @f
INVOKE SetTimer,hwnd,1,1000,NULL
jmp Return0
@@: cmp ax,WM_TIMER
jne @f
cmp wParam,1
jne Return0
test flag,-1
jne settext1
INVOKE SetWindowText,hwnd,ADDR string1
not flag
jmp Return0
settext1:
INVOKE SetWindowText,hwnd,ADDR string2
not flag
jmp Return0
@@: cmp ax,WM_PAINT
jne @f
INVOKE BeginPaint,hwnd,ADDR ps
mov ax,hdc
INVOKE EndPaint,hwnd,addr ps
jmp Return0
@@: cmp ax,WM_KEYDOWN
jne @f
jmp Return0
@@: cmp ax,WM_COMMAND
jne @f
cmp wParam,200
jne @f
mov bx,offset AboutBoxProc
INVOKE MakeProcInstance, cs::bx,hInst
mov word ptr lpProcAbout,ax
mov word ptr lpProcAbout+2,dx
INVOKE DialogBox,hInst,ADDR about,hwnd,lpProcAbout
INVOKE FreeProcInstance,lpProcAbout
jmp Return0
@@: cmp ax,WM_DESTROY
jne @f
INVOKE PostQuitMessage,0
jmp Return0
@@: INVOKE DefWindowProc,hwnd,message,wParam,lParam
jmp ProcEnd
Return0:
xor ax,ax
mov dx,ax
ProcEnd:
ret
WndProc ENDP
AboutBoxProc PROC FAR EXPORT uses si di, hwnd :HWND,
message :WORD,
wParam :WORD,
lParam :DWORD
mov ax,message
cmp ax,WM_INITDIALOG
jne @f
jmp Return0
@@: cmp ax,WM_COMMAND
jne @f
mov ax,wParam
cmp ax,100
jne Return0
INVOKE EndDialog,hwnd,1
mov ax,1
jmp ProcEnd
@@:
Return0:
xor ax,ax
mov dx,ax
ProcEnd:
ret
AboutBoxProc ENDP
end
Ive uploaded the self extracting EXE that contains the samples, also seems to have some sort of Early Windows.inc? im guessing Win3.x era? with the code being dated 1991 and the Memory Model being 'Small' .
[attachment deleted by admin]
Yes,
Its 16 bit Windows code. You could probably build it with MASM 6.11 with the versions of ML and LINK.
'pascal' is a calling convention just like __cdecl, __stdcall, __fastcall, etc. In Win32, pascal is defined as nothing. Just one of the many ways to help the conversion of programmers from other languages to "c" back when there was a big influx.
Relvinian