4 err ; fasm 1 assembly not supported
14 format MachO executable
17 include '../version.inc'
19 interpreter
'/usr/lib/dyld'
20 uses
'/usr/lib/libSystem.B.dylib'
22 import libc.malloc
,'_malloc',\
23 libc.realloc
,'_realloc',\
26 libc.fclose
,'_fclose',\
28 libc.fwrite
,'_fwrite',\
34 gettimeofday
,'_gettimeofday',\
42 segment '__TEXT' readable executable
44 section '__text' align 16
63 jnz display_usage_information
66 mov ecx,[verbosity_level
]
68 or al,TRACE_ERROR_STACK
75 ccall gettimeofday
,start_time
,0
78 mov esi,[initial_commands
]
83 mov eax,[current_pass
]
84 cmp eax,[maximum_number_of_passes
]
87 call show_display_data
91 call display_error_string
92 mov esi,_code_cannot_be_generated
94 call display_error_string
95 mov esi,_message_suffix
97 call display_error_string
103 call show_display_data
110 mov eax,[current_pass
]
116 jne display_passes_suffix
118 display_passes_suffix:
121 ccall gettimeofday
,end_time
,0
122 mov eax,[end_time.time_t
]
123 sub eax,[start_time.time_t
]
126 add eax,[end_time.suseconds_t
]
128 sub eax,[start_time.suseconds_t
]
138 mov [tenths_of_second
],eax
141 jz display_output_length
145 mov esi,_message_suffix
148 mov eax,[tenths_of_second
]
155 display_output_length:
156 call get_output_length
163 jne display_bytes_suffix
165 jnz display_bytes_suffix
167 display_bytes_suffix:
175 mov ebx,[source_path
]
176 mov edi,[output_path
]
177 call write_output_file
180 call assembly_shutdown
189 call assembly_shutdown
195 mov ebx,_write_failed
199 mov ebx,_out_of_memory
204 mov esi,_error_prefix
206 call display_error_string
209 call display_error_string
210 mov esi,_message_suffix
212 call display_error_string
214 call assembly_shutdown
219 display_usage_information:
231 mov [initial_commands
],eax
232 mov [source_path
],eax
233 mov [output_path
],eax
235 mov [verbosity_level
],eax
236 mov [maximum_number_of_passes
],100
237 mov [maximum_number_of_errors
],1
238 mov [maximum_depth_of_stack
],10000
243 jz error_in_arguments
251 mov [source_path
],esi
255 jne error_in_arguments
256 mov [output_path
],esi
266 je insert_initial_command
268 je insert_initial_command
274 je set_recursion_limit
276 je set_recursion_limit
284 jne error_in_arguments
294 jne get_verbose_setting
296 jz error_in_arguments
300 call get_option_value
302 ja error_in_arguments
303 mov [verbosity_level
],edx
307 jne get_errors_setting
309 jz error_in_arguments
313 call get_option_value
315 jz error_in_arguments
316 mov [maximum_number_of_errors
],edx
320 jne get_recursion_setting
322 jz error_in_arguments
325 get_recursion_setting:
326 call get_option_value
328 jz error_in_arguments
329 mov [maximum_depth_of_stack
],edx
333 jne get_passes_setting
335 jz error_in_arguments
339 call get_option_value
341 jz error_in_arguments
342 mov [maximum_number_of_passes
],edx
348 je error_in_arguments
358 jmp find_option_value
364 jc invalid_option_value
366 ja invalid_option_value
368 jo invalid_option_value
370 jc invalid_option_value
376 invalid_option_value:
379 insert_initial_command:
381 jne measure_initial_command
383 jz error_in_arguments
386 measure_initial_command:
394 mov edi,[initial_commands
]
397 jz allocate_initial_commands_buffer
398 mov edx,[initial_commands_length
]
401 cmp eax,[initial_commands_maximum_length
]
402 ja grow_initial_commands_buffer
403 copy_initial_command:
408 sub edi,[initial_commands
]
409 mov [initial_commands_length
],edi
412 allocate_initial_commands_buffer:
416 mov [initial_commands
],eax
417 mov [initial_commands_maximum_length
],ecx
420 jmp copy_initial_command
421 grow_initial_commands_buffer:
424 mov eax,[initial_commands
]
426 mov [initial_commands
],eax
427 mov [initial_commands_maximum_length
],ecx
429 add edi,[initial_commands_length
]
431 jmp copy_initial_command
435 include '../assembler.inc'
436 include '../symbols.inc'
437 include '../expressions.inc'
438 include '../conditions.inc'
439 include '../floats.inc'
440 include '../directives.inc'
441 include '../calm.inc'
442 include '../errors.inc'
444 include '../reader.inc'
445 include '../output.inc'
446 include '../console.inc'
448 section '__cstring' align 4
450 _logo
db 'flat assembler version g.',VERSION
,10,0
452 _usage
db 'Usage: fasmg source [output]',10
453 db 'Optional settings:',10
454 db ' -p limit Set the maximum allowed number of passes (default 100)',10
455 db ' -e limit Set the maximum number of displayed errors (default 1)',10
456 db ' -r limit Set the maximum depth of stack (default 10000)',10
457 db ' -v flag Enable or disable showing all lines from the stack (default 0)',10
458 db ' -i command Insert instruction at the beginning of source',13,10
459 db ' -n Do not show logo nor summary',13,10
463 _passes
db ' passes, ',0
465 _seconds
db ' seconds, ',0
467 _bytes
db ' bytes.',0
469 _write_failed
db 'failed to write the output file',0
470 _out_of_memory
db 'not enough memory to complete the assembly',0
471 _code_cannot_be_generated
db 'could not generate code within the allowed number of passes',0
474 _create_mode
db 'w',0
476 include '../tables.inc'
477 include '../messages.inc'
479 segment '__DATA' readable writable
481 section '__bss' align 4
483 include '../variables.inc'
487 maximum_number_of_passes
dd ?
489 initial_commands
dd ?
490 initial_commands_length
dd ?
491 initial_commands_maximum_length
dd ?
499 tenths_of_second
dd ?