"Fossies" - the Fresh Open Source Software Archive 
Member "fasm/source/Linux/x64/fasm.asm" (21 Feb 2022, 6653 Bytes) of package /linux/misc/fasm-1.73.30.tgz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Generic Assembler source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "fasm.asm":
1.73.29_vs_1.73.30.
1
2 ; flat assembler interface for Linux x64
3 ; Copyright (c) 1999-2022, Tomasz Grysztar.
4 ; All rights reserved.
5
6 format ELF64 executable 3 at 400000h
7 entry start
8
9 include 'modes.inc'
10
11 segment readable executable
12
13 start:
14
15 mov [con_handle],1
16 mov esi,_logo
17 call display_string
18
19 mov [command_line],rsp
20 mov rcx,[rsp]
21 lea rbx,[rsp+8+rcx*8+8]
22 mov [environment],rbx
23 call get_params
24 jc information
25
26 call init_memory
27
28 mov esi,_memory_prefix
29 call display_string
30 mov eax,[memory_end]
31 sub eax,[memory_start]
32 add eax,[additional_memory_end]
33 sub eax,[additional_memory]
34 shr eax,10
35 call display_number
36 mov esi,_memory_suffix
37 call display_string
38
39 mov eax,96
40 mov edi,buffer
41 xor esi,esi
42 syscall
43 mov eax,dword [buffer]
44 mov ecx,1000
45 mul ecx
46 mov ebx,eax
47 mov eax,dword [buffer+4]
48 div ecx
49 add eax,ebx
50 mov [start_time],eax
51
52 and [preprocessing_done],0
53 call preprocessor
54 or [preprocessing_done],-1
55 call parser
56 call assembler
57 call formatter
58
59 call display_user_messages
60 movzx eax,[current_pass]
61 inc eax
62 call display_number
63 mov esi,_passes_suffix
64 call display_string
65 mov eax,96
66 mov edi,buffer
67 xor esi,esi
68 syscall
69 mov eax,dword [buffer]
70 mov ecx,1000
71 mul ecx
72 mov ebx,eax
73 mov eax,dword [buffer+4]
74 div ecx
75 add eax,ebx
76 sub eax,[start_time]
77 jnc time_ok
78 add eax,3600000
79 time_ok:
80 xor edx,edx
81 mov ebx,100
82 div ebx
83 or eax,eax
84 jz display_bytes_count
85 xor edx,edx
86 mov ebx,10
87 div ebx
88 push edx
89 call display_number
90 mov dl,'.'
91 call display_character
92 pop eax
93 call display_number
94 mov esi,_seconds_suffix
95 call display_string
96 display_bytes_count:
97 mov eax,[written_size]
98 call display_number
99 mov esi,_bytes_suffix
100 call display_string
101 xor al,al
102 jmp exit_program
103
104 information:
105 mov esi,_usage
106 call display_string
107 mov al,1
108 jmp exit_program
109
110 get_params:
111 mov rbx,[command_line]
112 mov [input_file],0
113 mov [output_file],0
114 mov [symbols_file],0
115 mov [memory_setting],0
116 mov [passes_limit],100
117 mov rcx,[rbx]
118 add rbx,8*2
119 dec rcx
120 jz bad_params
121 mov [definitions_pointer],predefinitions
122 mov [path_pointer],paths
123 get_param:
124 mov rsi,[rbx]
125 mov al,[rsi]
126 cmp al,'-'
127 je option_param
128 cmp [input_file],0
129 jne get_output_file
130 call collect_path
131 mov [input_file],edx
132 jmp next_param
133 get_output_file:
134 cmp [output_file],0
135 jne bad_params
136 call collect_path
137 mov [output_file],edx
138 jmp next_param
139 option_param:
140 inc rsi
141 lodsb
142 cmp al,'m'
143 je memory_option
144 cmp al,'M'
145 je memory_option
146 cmp al,'p'
147 je passes_option
148 cmp al,'P'
149 je passes_option
150 cmp al,'d'
151 je definition_option
152 cmp al,'D'
153 je definition_option
154 cmp al,'s'
155 je symbols_option
156 cmp al,'S'
157 je symbols_option
158 bad_params:
159 stc
160 ret
161 memory_option:
162 cmp byte [rsi],0
163 jne get_memory_setting
164 dec rcx
165 jz bad_params
166 add rbx,8
167 mov rsi,[rbx]
168 get_memory_setting:
169 call get_option_value
170 or edx,edx
171 jz bad_params
172 cmp edx,1 shl (32-10)
173 jae bad_params
174 mov [memory_setting],edx
175 jmp next_param
176 passes_option:
177 cmp byte [rsi],0
178 jne get_passes_setting
179 dec rcx
180 jz bad_params
181 add rbx,8
182 mov rsi,[rbx]
183 get_passes_setting:
184 call get_option_value
185 or edx,edx
186 jz bad_params
187 cmp edx,10000h
188 ja bad_params
189 mov [passes_limit],dx
190 next_param:
191 add rbx,8
192 dec rcx
193 jnz get_param
194 cmp [input_file],0
195 je bad_params
196 mov eax,[definitions_pointer]
197 mov byte [eax],0
198 mov [initial_definitions],predefinitions
199 clc
200 ret
201 definition_option:
202 cmp byte [rsi],0
203 jne get_definition
204 dec rcx
205 jz bad_params
206 add rbx,8
207 mov rsi,[rbx]
208 get_definition:
209 mov r12d,edi
210 mov edi,[definitions_pointer]
211 call convert_definition_option
212 mov [definitions_pointer],edi
213 mov edi,r12d
214 jc bad_params
215 jmp next_param
216 symbols_option:
217 cmp byte [rsi],0
218 jne get_symbols_setting
219 dec rcx
220 jz bad_params
221 add rbx,8
222 mov rsi,[rbx]
223 get_symbols_setting:
224 call collect_path
225 mov [symbols_file],edx
226 jmp next_param
227 get_option_value:
228 xor eax,eax
229 mov edx,eax
230 get_option_digit:
231 lodsb
232 cmp al,20h
233 je option_value_ok
234 or al,al
235 jz option_value_ok
236 sub al,30h
237 jc invalid_option_value
238 cmp al,9
239 ja invalid_option_value
240 imul edx,10
241 jo invalid_option_value
242 add edx,eax
243 jc invalid_option_value
244 jmp get_option_digit
245 option_value_ok:
246 dec rsi
247 clc
248 ret
249 invalid_option_value:
250 stc
251 ret
252 convert_definition_option:
253 mov edx,edi
254 cmp edi,predefinitions+1000h
255 jae bad_definition_option
256 xor al,al
257 stosb
258 copy_definition_name:
259 lodsb
260 cmp al,'='
261 je copy_definition_value
262 cmp al,20h
263 je bad_definition_option
264 or al,al
265 jz bad_definition_option
266 cmp edi,predefinitions+1000h
267 jae bad_definition_option
268 stosb
269 inc byte [edx]
270 jnz copy_definition_name
271 bad_definition_option:
272 stc
273 ret
274 copy_definition_value:
275 lodsb
276 cmp al,20h
277 je definition_value_end
278 or al,al
279 jz definition_value_end
280 cmp edi,predefinitions+1000h
281 jae bad_definition_option
282 stosb
283 jmp copy_definition_value
284 definition_value_end:
285 dec rsi
286 cmp edi,predefinitions+1000h
287 jae bad_definition_option
288 xor al,al
289 stosb
290 clc
291 ret
292 collect_path:
293 mov edi,[path_pointer]
294 mov edx,edi
295 copy_path_to_low_memory:
296 lodsb
297 stosb
298 test al,al
299 jnz copy_path_to_low_memory
300 mov [path_pointer],edi
301 retn
302
303 include 'system.inc'
304
305 include '..\..\version.inc'
306
307 _copyright db 'Copyright (c) 1999-2022, Tomasz Grysztar',0xA,0
308
309 _logo db 'flat assembler version ',VERSION_STRING,0
310 _usage db 0xA
311 db 'usage: fasm <source> [output]',0xA
312 db 'optional settings:',0xA
313 db ' -m <limit> set the limit in kilobytes for the available memory',0xA
314 db ' -p <limit> set the maximum allowed number of passes',0xA
315 db ' -d <name>=<value> define symbolic variable',0xA
316 db ' -s <file> dump symbolic information for debugging',0xA
317 db 0
318 _memory_prefix db ' (',0
319 _memory_suffix db ' kilobytes memory, x64)',0xA,0
320 _passes_suffix db ' passes, ',0
321 _seconds_suffix db ' seconds, ',0
322 _bytes_suffix db ' bytes.',0xA,0
323 _no_low_memory db 'failed to allocate memory within 32-bit addressing range',0
324
325 include '..\..\errors.inc'
326 include '..\..\symbdump.inc'
327 include '..\..\preproce.inc'
328 include '..\..\parser.inc'
329 include '..\..\exprpars.inc'
330 include '..\..\assemble.inc'
331 include '..\..\exprcalc.inc'
332 include '..\..\x86_64.inc'
333 include '..\..\avx.inc'
334 include '..\..\formats.inc'
335
336 include '..\..\tables.inc'
337 include '..\..\messages.inc'
338
339 segment readable writeable
340
341 align 4
342
343 include '..\..\variable.inc'
344
345 command_line dq ?
346 memory_setting dd ?
347 path_pointer dd ?
348 definitions_pointer dd ?
349 environment dq ?
350 timestamp dq ?
351 start_time dd ?
352 con_handle dd ?
353 displayed_count dd ?
354 last_displayed db ?
355 character db ?
356 preprocessing_done db ?
357
358 buffer rb 1000h
359 predefinitions rb 1000h
360 paths rb 10000h