Simulkin Stas,
о Watcom ASM лучше напрямую с Charles Kludge разговаривать
по поводу примеров - COM файл для Watcom
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
| ; wasm dos com #
.model tiny
.286
.code
org 100h
start: mov ah,9
mov dx,offset Hello
int 21h
ret
Hello db 'Hello, world, from WASM-DOS-COM!$'
end start |
|
bat-файл для сборки СОМ
Кликните здесь для просмотра всего текста
| Code | 1
2
| %wasm_path%\bin\wasm %filename%.asm
%wasm_path%\bin\wlink file %filename%.obj form dos com |
|
- EXE под DOS
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
| ; wasm dos exe #
.model small
.286
.code
start: mov ax,DGROUP
mov ds,ax
mov ah,9
mov dx,offset Hello
int 21h
mov ax,4C00h
int 21h
.data
Hello db 'Hello, world, from WASM-DOS-EXE!$'
end start |
|
bat-файл для сборки DOS-EXE
Кликните здесь для просмотра всего текста
| Code | 1
2
| %wasm_path%\bin\wasm %filename%.asm
%wasm_path%\bin\wlink file %filename%.obj form dos |
|
6 первых уроков Iczelion'a -
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| ; wasm windows gui #
.686P
.model flat
extern __imp__MessageBoxA@16:dword
.code
start: xor eax,eax
push eax
push offset msgBoxCaption
push offset msgBoxText
push eax
call __imp__MessageBoxA@16
ret
msgBoxText db 'Win32 Assembly with WASM is Great!',0
msgBoxCaption db 'Iczelion Tutorial #2:MessageBox',0
end start |
|
-
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| ; wasm windows gui #
include "windows.inc"
extern __imp__RegisterClassA@4:dword
extern __imp__CreateWindowExA@48:dword
extern __imp__GetMessageA@16:dword
extern __imp__DispatchMessageA@4:dword
extern __imp__ExitProcess@4:dword
extern __imp__DefWindowProcA@16:dword
.code
start: xor ebx,ebx
mov edi,offset wTitle
mov esi,400000h
; +------------------------------+
; | registering the window class |
; +------------------------------+
push edi
push ebx
push COLOR_WINDOW+1
push 10011h
push ebx
push esi
push ebx
push ebx
push offset window_procedure
push ebx
push esp
call __imp__RegisterClassA@4
; +--------------------------+
; | creating the main window |
; +--------------------------+
push ebx
push esi
push ebx
push ebx
shl esi,9
push esi
push esi
push esi
push esi
push WS_OVERLAPPEDWINDOW+WS_VISIBLE
push edi
push edi
push ebx
call __imp__CreateWindowExA@48
mov ebp,esp
; +---------------------------+
; | entering the message loop |
; +---------------------------+
message_loop: push ebx
push ebx
push ebx
push ebp
call __imp__GetMessageA@16
push ebp
call __imp__DispatchMessageA@4
jmp message_loop
; +----------------------+
; | the window procedure |
; +----------------------+
window_procedure: cmp dword ptr [esp+8],WM_DESTROY
je wmDESTROY
jmp dword ptr __imp__DefWindowProcA@16
wmDESTROY: push ebx
call __imp__ExitProcess@4
wTitle db 'Iczelion Tutorial #3:A Simple Window in WASM',0 ;name of our window
end start |
|
-
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| ; wasm windows gui #
include "windows.inc"
extern __imp__RegisterClassA@4:dword
extern __imp__CreateWindowExA@48:dword
extern __imp__GetMessageA@16:dword
extern __imp__DispatchMessageA@4:dword
extern __imp__ExitProcess@4:dword
extern __imp__DefWindowProcA@16:dword
extern __imp__BeginPaint@8:dword
extern __imp__GetClientRect@8:dword
extern __imp__DrawTextA@20:dword
extern __imp__EndPaint@8:dword
.code
;
START: xor ebx,ebx
mov edi,offset wTitle
mov esi,400000h
; +------------------------------+
; | registering the window class |
; +------------------------------+
push edi
push ebx
push COLOR_WINDOW+1
push 10011h
push ebx
push esi
push ebx
push ebx
push offset window_procedure
push CS_HREDRAW or CS_VREDRAW
push esp
call __imp__RegisterClassA@4
; +--------------------------+
; | creating the main window |
; +--------------------------+
push ebx
push esi
push ebx
push ebx
shl esi,9
push esi
push esi
push esi
push esi
push WS_OVERLAPPEDWINDOW+WS_VISIBLE
push edi
push edi
push ebx
call __imp__CreateWindowExA@48
mov ebp,esp
; +---------------------------+
; | entering the message loop |
; +---------------------------+
message_loop: push ebx
push ebx
push ebx
push ebp
call __imp__GetMessageA@16
push ebp
call __imp__DispatchMessageA@4
jmp message_loop
; +----------------------+
; | the window procedure |
; +----------------------+
window_procedure proc
; hWnd:dword,uMsg:dword,wParam:dword,lParam:dword
;LOCAL expRect:RECT
;LOCAL ps:PAINTSTRUCT
hWnd equ [ebp+8]
uMsg equ [ebp+0Ch]
expRect equ [ebp-SIZEOF RECT]
N = SIZEOF RECT+SIZEOF PAINTSTRUCT
enter N,0;50h,0
mov eax,[uMsg]
mov edi,[hWnd]
dec eax
dec eax; cmp uMsg,WM_DESTROY
je wmDESTROY
sub eax,WM_PAINT-WM_DESTROY; cmp uMsg,WM_PAINT
je wmPAINT
leave
jmp dword ptr __imp__DefWindowProcA@16
wmPAINT: push esp;lea eax,[expPs]
push edi
call __imp__BeginPaint@8
lea esi,[expRect]
push eax
push esi
push edi
call __imp__GetClientRect@8
pop eax
push (DT_SINGLELINE or DT_CENTER or DT_VCENTER)
push esi
push -1
push offset expTxt
push eax
call __imp__DrawTextA@20
push esp
push edi
call __imp__EndPaint@8
leave
retn 10h
wmDESTROY: push ebx
call __imp__ExitProcess@4
window_procedure endp
;.data
wTitle db 'Iczelion Tutorial #4:Painting with Text in WASM',0 ;name of our window
expTxt db 'Win32 assembly with WASM is great and easy',0
end start |
|
-
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
| ; wasm windows gui #
include "windows.inc"
extern __imp__RegisterClassA@4:dword
extern __imp__CreateWindowExA@48:dword
extern __imp__GetMessageA@16:dword
extern __imp__DispatchMessageA@4:dword
extern __imp__ExitProcess@4:dword
extern __imp__DefWindowProcA@16:dword
extern __imp__BeginPaint@8:dword
extern __imp__EndPaint@8:dword
extern __imp__GetCurrentObject@8:dword
extern __imp__SetTextColor@8:dword
extern __imp__CreateFontA@56:dword
extern __imp__SetBkColor@8:dword
extern __imp__TextOutA@20:dword
extern __imp__SelectObject@8:dword
.code
;
start:
xor ebx,ebx
mov edi,offset wTitle
mov esi,400000h
; +------------------------------+
; | registering the window class |
; +------------------------------+
push edi
push ebx
push COLOR_WINDOW+1
push 10011h
push ebx
push esi
push ebx
push ebx
push offset window_procedure
push ebx
push esp
call __imp__RegisterClassA@4
; +--------------------------+
; | creating the main window |
; +--------------------------+
push ebx
push esi
push ebx
push ebx
shl esi,9
push esi
push esi
push esi
push esi
push WS_OVERLAPPEDWINDOW+WS_VISIBLE
push edi
push edi
push ebx
call __imp__CreateWindowExA@48
mov ebp,esp
; +---------------------------+
; | entering the message loop |
; +---------------------------+
message_loop: push ebx
push ebx
push ebx
push ebp
call __imp__GetMessageA@16
push ebp
call __imp__DispatchMessageA@4
jmp message_loop
; +----------------------+
; | the window procedure |
; +----------------------+
window_procedure proc
hWnd equ [ebp+8]
uMsg equ [ebp+0Ch]
enter sizeof PAINTSTRUCT,0
mov eax,[uMsg]
mov edi,[hWnd]
dec eax
dec eax; cmp uMsg,WM_DESTROY
je wmDESTROY
sub eax,WM_PAINT-WM_DESTROY; cmp uMsg,WM_PAINT
je wmPAINT
leave
jmp dword ptr __imp__DefWindowProcA@16
wmPAINT: push esp;lea eax,[expPs]
push edi
call __imp__BeginPaint@8
mov esi,eax
push ebx;OBJ_FONT
push eax
call __imp__GetCurrentObject@8
push eax ;default font object
push offset expFont
push DEFAULT_PITCH or FF_SCRIPT
push ebx;DEFAULT_QUALITY
push ebx;CLIP_DEFAULT_PRECIS
push ebx;OUT_DEFAULT_PRECIS
push -1;OEM_CHARSET
push ebx
push ebx
push ebx
push 400
push ebx
push ebx
push 12
push 26
call __imp__CreateFontA@56
push eax
push esi
call __imp__SelectObject@8
push 32C8C8h;RGB=50,200,200
push esi
call __imp__SetTextColor@8
push 0FF0000h;RGB=0,0,255
push esi
call __imp__SetBkColor@8
push Num-expTxt
push offset expTxt
push ebx
push ebx
push esi
call __imp__TextOutA@20
push esi
call __imp__SelectObject@8
push esp
push edi
call __imp__EndPaint@8
leave
retn 0x10
wmDESTROY: push ebx
call __imp__ExitProcess@4
window_procedure endp
;.data
expFont db 'script',0
wTitle db 'Iczelion Tutorial #5:More about Text in WASM',0 ;name of our window
expTxt db 'Win32 assembly with WASM is great and easy'
Num db 0
end start |
|
-
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
| ; wasm windows gui #
include "windows.inc"
extern __imp__RegisterClassA@4:dword
extern __imp__CreateWindowExA@48:dword
extern __imp__GetMessageA@16:dword
extern __imp__DispatchMessageA@4:dword
extern __imp__ExitProcess@4:dword
extern __imp__DefWindowProcA@16:dword
extern __imp__BeginPaint@8:dword
extern __imp__EndPaint@8:dword
extern __imp__InvalidateRect@12:dword
extern __imp__TranslateMessage@4:dword
extern __imp__TextOutA@20:dword
.code
;
START:
xor ebx,ebx
mov edi,offset wTitle
mov esi,400000h
; +------------------------------+
; | registering the window class |
; +------------------------------+
push edi
push ebx
push COLOR_WINDOW+1
push 10011h
push ebx
push esi
push ebx
push ebx
push offset window_procedure
push ebx
push esp
call __imp__RegisterClassA@4
; +--------------------------+
; | creating the main window |
; +--------------------------+
push ebx
push esi
push ebx
push ebx
shl esi,9
push esi
push esi
push esi
push esi
push WS_OVERLAPPEDWINDOW+WS_VISIBLE
push edi
push edi
push ebx
call __imp__CreateWindowExA@48
mov ebp,esp
; +---------------------------+
; | entering the message loop |
; +---------------------------+
message_loop: push ebx
push ebx
push ebx
push ebp
call __imp__GetMessageA@16
push ebp
call __imp__TranslateMessage@4
push ebp
call __imp__DispatchMessageA@4
jmp message_loop
; +----------------------+
; | the window procedure |
; +----------------------+
window_procedure proc
hWnd equ [ebp+8]
uMsg equ [ebp+0Ch]
wParam equ [ebp+10h]
enter sizeof PAINTSTRUCT,0
mov eax,uMsg
mov edi,hWnd
mov esi,offset expChar
dec eax; cmp uMsg,WM_DESTROY
dec eax
je wmDESTROY
sub eax,WM_PAINT-WM_DESTROY; cmp uMsg,WM_PAINT
je wmPAINT
sub eax,WM_CHAR-WM_PAINT
je wmCHAR
leave
jmp dword ptr __imp__DefWindowProcA@16
wmCHAR: push wParam
pop dword ptr [esi]
push TRUE
push eax
push edi
call __imp__InvalidateRect@12
jmp wmBYE
wmPAINT: push esp;lea eax,[expPs]
push edi
call __imp__BeginPaint@8
push 4
push esi
push ebx
push ebx
push eax
call __imp__TextOutA@20
push esp
push edi
call __imp__EndPaint@8
wmBYE: leave
retn 10h
wmDESTROY: push ebx
call __imp__ExitProcess@4
window_procedure endp
.data
;exp = experiment
wTitle db 'Iczelion Tutorial #6:Keyboard Input in WASM',0 ;name of our window
expChar dd ' ';0x20
end start |
|
-
Кликните здесь для просмотра всего текста
| Assembler | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
| ; wasm windows gui #
include "windows.inc"
extern __imp__CreateWindowExA@48:dword
extern __imp__DefWindowProcA@16:dword
extern __imp__DispatchMessageA@4:dword
extern __imp__GetMessageA@16:dword
extern __imp__ExitProcess@4:dword
extern __imp__RegisterClassA@4:dword
extern __imp__BeginPaint@8:dword
extern __imp__EndPaint@8:dword
extern __imp__TextOutA@20:dword
extern __imp__InvalidateRect@12:dword
extern __imp__MessageBeep@4:dword
extern __imp__SetBkMode@8:dword
MAXRECTS = 40
.code
;
start:
xor ebx,ebx
mov edi,offset wTitle
mov esi,400000h
; +------------------------------+
; | registering the window class |
; +------------------------------+
push edi
push ebx
push COLOR_WINDOW+1
push 10011h
push ebx
push esi
push ebx
push ebx
push offset window_procedure
push ebx
push esp
call __imp__RegisterClassA@4
; +--------------------------+
; | creating the main window |
; +--------------------------+
push ebx
push esi
push ebx
push ebx
shl esi,9
push esi
push esi
push esi
push esi
push WS_OVERLAPPEDWINDOW+WS_VISIBLE
push edi
push edi
push ebx
call __imp__CreateWindowExA@48
mov ebp,esp
; +---------------------------+
; | entering the message loop |
; +---------------------------+
message_loop: push ebx
push ebx
push ebx
push ebp
call __imp__GetMessageA@16
push ebp
call __imp__DispatchMessageA@4
jmp message_loop
; +----------------------+
; | the window procedure |
; +----------------------+
window_procedure proc
hWnd equ [ebp+8]
uMsg equ [ebp+0xC]
wParam equ [ebp+0x10]
lParam equ [ebp+0x14]
xrect equ [ebp - sizeof RECT]
enter sizeof PAINTSTRUCT+sizeof RECT,0
mov eax,[uMsg]
mov edi,[hWnd]
dec eax; cmp uMsg,WM_DESTROY
dec eax
je wmDESTROY
sub eax,WM_PAINT-WM_DESTROY; cmp uMsg,WM_PAINT
je wmPAINT
sub eax,WM_LBUTTONDOWN-WM_PAINT;cmp eax,WM_LBUTTONDOWN
je wmLBUTTONDOWN
sub eax,WM_RBUTTONDOWN-WM_LBUTTONDOWN
je wmRBUTTONDOWN
leave
jmp dword ptr __imp__DefWindowProcA@16
wmPAINT: mov ebx,[nextRect]
inc ebx;cmp nextRect,-1
jz a1
push esp
push edi
call __imp__BeginPaint@8
mov esi,eax;hdc,eax
push TRANSPARENT
push eax
call __imp__SetBkMode@8
a3: mov edx,8
mov eax,[ebx*4+recs-4]
mov ecx,eax
shl ecx,1
jnc a4
shl edx,1
a4: shr ecx,17
push [PS+edx];numtext1
push [PS+edx+4];offset text1
push ecx
movzx eax,ax
push eax
push esi
call __imp__TextOutA@20
dec ebx
jnz a3
push esp
push edi
call __imp__EndPaint@8
jmp a1
wmLBUTTONDOWN: mov eax,80000000h
wmRBUTTONDOWN: add eax,lParam
cmp dword ptr nextRect,MAXRECTS-2
jge a5
inc dword ptr nextRect
mov ecx,nextRect
mov [ecx*4+recs],eax
movzx edx,ax
shl eax,1
shr eax,17
lea esi,xrect
mov [esi+RECT.left],edx
mov [esi+RECT.top],eax
add edx,150
mov [esi+RECT.right],edx
add eax,20
mov [esi+RECT.bottom],eax
push ebx
push esi
push edi
call __imp__InvalidateRect@12
jmp a1
a5:
push ebx
call __imp__MessageBeep@4
a1: leave
retn 0x10
wmDESTROY: push eax
call __imp__ExitProcess@4
window_procedure endp
.data
wTitle db 'Iczelion Tutorial #7:Mouse Input in WASM',0 ;name of our window
text1 db 'Нажата левая кнопка'
text2 db 'Нажата правая кнопка'
PS dd 0,0,text2-text1, text1, PS-text2, text2
recs dd MAXRECTS dup (?)
nextRect dd -1
end start |
|
сборка WinGUI-программ происходит батником
Кликните здесь для просмотра всего текста
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
| cls
set wasm_path=...
set filename=...
if exist %1.exe del %1.exe
%wasm_path%\bin\wasm -6prs -mf %filename%.asm || exit
%wasm_path%\bin\wlink file %filename%.obj form windows nt op c LIBPath ^
%wasm_path%\lib\ Library user32.lib,kernel32.lib,gdi32.lib,^
comctl32.lib,shell32.lib,ole32.lib,comdlg32.lib option Alignment= 512 || exit
if exist %filename%.rc (
%wasm_path%\bin\wrc -bt=nt -t %filename%.rc
del %filename%.res
)
if exist %filename%.obj del %filename%.obj |
|
если есть файл ресурсов, то его имя должно совпадать с именем asm-файла
1
|