1 ;
2 ; 64 bit Menuet example
3 ;
4 ; Compile with FASM 1.60 or above
5 ;
6
7 use64
8
9 org 0x0
10
11 db 'MENUET64' ; Header identifier
12 dq 0x01 ; Version
13 dq START ; Start of code
14 dq image_end ; Size of image
15 dq 0x100000 ; Memory for app
16 dq 0xffff0 ; Esp
17 dq 0x00 ; Prm
18 dq 0x00 ; Icon
19
20
21 START:
22
23 call draw_window ; At first, draw the window
24
25 still:
26
27 mov rax , 0xA ; Wait here for event
28 int 0x60
29
30 test rax , 0x1 ; Window redraw
31 jnz window_event
32 test rax , 0x2 ; Keyboard press
33 jnz key_event
34 test rax , 0x4 ; Button press
35 jnz button_event
36
37 jmp still
38
39 window_event:
40
41 call draw_window
42 jmp still
43
44 key_event:
45
46 mov rax , 0x2 ; Read the key and ignore
47 int 0x60
48
49 jmp still
50
51 button_event:
52
53 mov rax , 0x11
54 int 0x60
55
56 ; rax = status
57 ; rbx = button id
58
59 cmp rbx , 0x10000001
60 jne no_application_terminate_button
61 mov rax , 0x200
62 int 0x60
63 no_application_terminate_button:
64
65 cmp rbx , 0x106
66 jne no_application_terminate_menu
67 mov rax , 0x200
68 int 0x60
69 no_application_terminate_menu:
70
71 jmp still
72
73
74 draw_window:
75
76 mov rax , 0xC ; Beginning of window draw
77 mov rbx , 0x1
78 int 0x60
79
80 mov rax , 0x0 ; Draw window
81 mov rbx , 0x0000010000000100 ; x start & size
82 mov rcx , 0x00000080000000C0 ; y start & size
83 mov rdx , 0x0000000000FFFFFF ; type & border color
84 mov r8 , 0x0000000000000001 ; draw flags
85 mov r9 , window_label ; 0 or label - asciiz
86 mov r10 , menu_struct ; 0 or pointer to menu struct
87 int 0x60
88
89 mov rax , 0x4 ; Display text
90 mov rbx , text
91 mov rcx , 0x20
92 mov rdx , 0x40
93 mov rsi , 0x0
94 mov r9 , 0x1
95 mov r8 , 0x3
96
97 newline:
98
99 int 0x60
100
101 add rbx , 0x1F
102 add rdx , 0x10
103 dec r8
104 jnz newline
105
106 mov rax , 0xC ; End of window draw
107 mov rbx , 0x2
108 int 0x60
109
110 ret
111
112
113 ; Data area
114
115 window_label:
116
117 db 'EXAMPLE',0 ; Window label
118
119 text:
120
121 db 'HELLO WORLD FROM 64 BIT MENUET',0
122 db 'Second line ',0
123 db 'Third line ',0
124
125 menu_struct: ; Menu Struct
126
127 dq 0 ; Version
128
129 dq 0x100 ; Start value of ID to return ( ID + Line )
130
131 ; Returned when menu closes and
132 ; user made no selections.
133
134 db 0,'FILE',0 ; ID = 0x100 + 1
135 db 1,'New',0 ; ID = 0x100 + 2
136 db 1,'Open..',0 ; ID = 0x100 + 3
137 db 1,'Save..',0 ; ID = 0x100 + 4
138 db 1,'-',0 ; ID = 0x100 + 5
139 db 1,'Quit',0 ; ID = 0x100 + 6
140
141 db 0,'HELP',0 ; ID = 0x100 + 7
142 db 1,'Contents..',0 ; ID = 0x100 + 8
143 db 1,'About..',0 ; ID = 0x100 + 9
144
145 db 255 ; End of Menu Struct
146
147 image_end:
148
149
我不懂汇编,但是我感觉汇编语言的语句似乎都比较短。2 ; 64 bit Menuet example
3 ;
4 ; Compile with FASM 1.60 or above
5 ;
6
7 use64
8
9 org 0x0
10
11 db 'MENUET64' ; Header identifier
12 dq 0x01 ; Version
13 dq START ; Start of code
14 dq image_end ; Size of image
15 dq 0x100000 ; Memory for app
16 dq 0xffff0 ; Esp
17 dq 0x00 ; Prm
18 dq 0x00 ; Icon
19
20
21 START:
22
23 call draw_window ; At first, draw the window
24
25 still:
26
27 mov rax , 0xA ; Wait here for event
28 int 0x60
29
30 test rax , 0x1 ; Window redraw
31 jnz window_event
32 test rax , 0x2 ; Keyboard press
33 jnz key_event
34 test rax , 0x4 ; Button press
35 jnz button_event
36
37 jmp still
38
39 window_event:
40
41 call draw_window
42 jmp still
43
44 key_event:
45
46 mov rax , 0x2 ; Read the key and ignore
47 int 0x60
48
49 jmp still
50
51 button_event:
52
53 mov rax , 0x11
54 int 0x60
55
56 ; rax = status
57 ; rbx = button id
58
59 cmp rbx , 0x10000001
60 jne no_application_terminate_button
61 mov rax , 0x200
62 int 0x60
63 no_application_terminate_button:
64
65 cmp rbx , 0x106
66 jne no_application_terminate_menu
67 mov rax , 0x200
68 int 0x60
69 no_application_terminate_menu:
70
71 jmp still
72
73
74 draw_window:
75
76 mov rax , 0xC ; Beginning of window draw
77 mov rbx , 0x1
78 int 0x60
79
80 mov rax , 0x0 ; Draw window
81 mov rbx , 0x0000010000000100 ; x start & size
82 mov rcx , 0x00000080000000C0 ; y start & size
83 mov rdx , 0x0000000000FFFFFF ; type & border color
84 mov r8 , 0x0000000000000001 ; draw flags
85 mov r9 , window_label ; 0 or label - asciiz
86 mov r10 , menu_struct ; 0 or pointer to menu struct
87 int 0x60
88
89 mov rax , 0x4 ; Display text
90 mov rbx , text
91 mov rcx , 0x20
92 mov rdx , 0x40
93 mov rsi , 0x0
94 mov r9 , 0x1
95 mov r8 , 0x3
96
97 newline:
98
99 int 0x60
100
101 add rbx , 0x1F
102 add rdx , 0x10
103 dec r8
104 jnz newline
105
106 mov rax , 0xC ; End of window draw
107 mov rbx , 0x2
108 int 0x60
109
110 ret
111
112
113 ; Data area
114
115 window_label:
116
117 db 'EXAMPLE',0 ; Window label
118
119 text:
120
121 db 'HELLO WORLD FROM 64 BIT MENUET',0
122 db 'Second line ',0
123 db 'Third line ',0
124
125 menu_struct: ; Menu Struct
126
127 dq 0 ; Version
128
129 dq 0x100 ; Start value of ID to return ( ID + Line )
130
131 ; Returned when menu closes and
132 ; user made no selections.
133
134 db 0,'FILE',0 ; ID = 0x100 + 1
135 db 1,'New',0 ; ID = 0x100 + 2
136 db 1,'Open..',0 ; ID = 0x100 + 3
137 db 1,'Save..',0 ; ID = 0x100 + 4
138 db 1,'-',0 ; ID = 0x100 + 5
139 db 1,'Quit',0 ; ID = 0x100 + 6
140
141 db 0,'HELP',0 ; ID = 0x100 + 7
142 db 1,'Contents..',0 ; ID = 0x100 + 8
143 db 1,'About..',0 ; ID = 0x100 + 9
144
145 db 255 ; End of Menu Struct
146
147 image_end:
148
149
下面是一些官方网站上提供的截图:
谁知道这会不会是下一个Windows呢?