Rev 607 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 607 | Rev 624 | ||
---|---|---|---|
Line 274... | Line 274... | ||
274 | jne illegal_instruction |
274 | jne illegal_instruction |
275 | bt [format_flags],0 |
275 | bt [format_flags],0 |
276 | jc illegal_instruction |
276 | jc illegal_instruction |
277 | public_allowed: |
277 | public_allowed: |
278 | lods byte [esi] |
278 | mov [base_code],0C0h |
- | 279 | lods byte [esi] |
|
279 | cmp al,2 |
280 | cmp al,2 |
280 | jne invalid_argument |
281 | je public_label |
- | 282 | cmp al,1Dh |
|
- | 283 | jne invalid_argument |
|
281 | lods dword [esi] |
284 | lods byte [esi] |
- | 285 | and al,7 |
|
- | 286 | add [base_code],al |
|
- | 287 | lods byte [esi] |
|
- | 288 | cmp al,2 |
|
- | 289 | jne invalid_argument |
|
- | 290 | public_label: |
|
- | 291 | lods dword [esi] |
|
282 | cmp eax,0Fh |
292 | cmp eax,0Fh |
283 | jb invalid_use_of_symbol |
293 | jb invalid_use_of_symbol |
284 | je reserved_word_used_as_symbol |
294 | je reserved_word_used_as_symbol |
285 | mov dx,[current_pass] |
295 | mov dx,[current_pass] |
286 | mov [eax+18],dx |
296 | mov [eax+18],dx |
Line 302... | Line 312... | ||
302 | jne invalid_argument |
312 | jne invalid_argument |
303 | mov [ebx+4],esi |
313 | mov [ebx+4],esi |
304 | lods dword [esi] |
314 | lods dword [esi] |
305 | lea esi,[esi+eax+1] |
315 | lea esi,[esi+eax+1] |
306 | mov byte [ebx],80h |
316 | mov al,[base_code] |
- | 317 | mov [ebx],al |
|
307 | jmp instruction_assembled |
318 | jmp instruction_assembled |
308 | extrn_directive: |
319 | extrn_directive: |
309 | mov al,[output_format] |
320 | mov al,[output_format] |
310 | cmp al,4 |
321 | cmp al,4 |
311 | je extrn_allowed |
322 | je extrn_allowed |
312 | cmp al,5 |
323 | cmp al,5 |
Line 324... | Line 335... | ||
324 | lea eax,[edx+0Ch] |
335 | lea eax,[edx+0Ch] |
325 | cmp eax,[structures_buffer] |
336 | cmp eax,[structures_buffer] |
326 | jae out_of_memory |
337 | jae out_of_memory |
327 | mov [free_additional_memory],eax |
338 | mov [free_additional_memory],eax |
328 | mov byte [edx],81h |
339 | mov byte [edx],80h |
329 | mov [edx+4],ebx |
340 | mov [edx+4],ebx |
330 | lods byte [esi] |
341 | lods byte [esi] |
331 | cmp al,86h |
342 | cmp al,86h |
332 | jne invalid_argument |
343 | jne invalid_argument |
333 | lods byte [esi] |
344 | lods byte [esi] |
334 | cmp al,2 |
345 | cmp al,2 |
Line 2406... | Line 2417... | ||
2406 | je symbols_enumerated |
2417 | je symbols_enumerated |
2407 | mov dl,[esi] |
2418 | mov dl,[esi] |
2408 | or dl,dl |
2419 | or dl,dl |
2409 | jz enumerate_section |
2420 | jz enumerate_section |
2410 | cmp dl,80h |
2421 | cmp dl,0C0h |
- | 2422 | jae enumerate_public |
|
- | 2423 | cmp dl,80h |
|
2411 | je enumerate_public |
2424 | jae enumerate_extrn |
2412 | ja enumerate_extrn |
- | |
2413 | add esi,0Ch |
2425 | add esi,0Ch |
2414 | jmp enumerate_symbols |
2426 | jmp enumerate_symbols |
2415 | enumerate_section: |
2427 | enumerate_section: |
2416 | mov edx,eax |
2428 | mov edx,eax |
2417 | shl edx,8 |
2429 | shl edx,8 |
2418 | mov [esi],edx |
2430 | mov [esi],edx |
Line 2423... | Line 2435... | ||
2423 | jmp enumerate_symbols |
2435 | jmp enumerate_symbols |
2424 | enumerate_public: |
2436 | enumerate_public: |
2425 | mov edx,eax |
2437 | mov edx,eax |
2426 | shl edx,8 |
2438 | shl edx,8 |
2427 | mov dl,80h |
2439 | mov dl,[esi] |
2428 | mov [esi],edx |
2440 | mov [esi],edx |
2429 | mov edx,[esi+8] |
2441 | mov edx,[esi+8] |
2430 | add esi,10h |
2442 | add esi,10h |
2431 | inc eax |
2443 | inc eax |
2432 | cmp byte [edx+11],2 |
2444 | cmp byte [edx+11],2 |
2433 | jne enumerate_symbols |
2445 | jne enumerate_symbols |
2434 | mov edx,[edx+20] |
2446 | mov edx,[edx+20] |
2435 | cmp byte [edx],81h |
2447 | cmp byte [edx],0C0h |
- | 2448 | jae enumerate_symbols |
|
- | 2449 | cmp byte [edx],80h |
|
2436 | jne enumerate_symbols |
2450 | jb enumerate_symbols |
2437 | inc eax |
2451 | inc eax |
2438 | jmp enumerate_symbols |
2452 | jmp enumerate_symbols |
2439 | enumerate_extrn: |
2453 | enumerate_extrn: |
2440 | mov edx,eax |
2454 | mov edx,eax |
2441 | shl edx,8 |
2455 | shl edx,8 |
2442 | mov dl,81h |
2456 | mov dl,[esi] |
2443 | mov [esi],edx |
2457 | mov [esi],edx |
2444 | add esi,0Ch |
2458 | add esi,0Ch |
2445 | inc eax |
2459 | inc eax |
2446 | jmp enumerate_symbols |
2460 | jmp enumerate_symbols |
2447 | prepare_default_section: |
2461 | prepare_default_section: |
2448 | mov ebx,[symbols_stream] |
2462 | mov ebx,[symbols_stream] |
Line 2459... | Line 2473... | ||
2459 | check_reference: |
2473 | check_reference: |
2460 | mov al,[ebx] |
2474 | mov al,[ebx] |
2461 | or al,al |
2475 | or al,al |
2462 | jz skip_other_section |
2476 | jz skip_other_section |
2463 | cmp al,80h |
2477 | cmp al,0C0h |
- | 2478 | jae check_public_reference |
|
- | 2479 | cmp al,80h |
|
2464 | je check_public_reference |
2480 | jae next_reference |
2465 | ja next_reference |
- | |
2466 | cmp edx,[ebx+8] |
2481 | cmp edx,[ebx+8] |
2467 | je default_section_ok |
2482 | je default_section_ok |
2468 | next_reference: |
2483 | next_reference: |
2469 | add ebx,0Ch |
2484 | add ebx,0Ch |
2470 | jmp find_references_to_default_section |
2485 | jmp find_references_to_default_section |
2471 | check_public_reference: |
2486 | check_public_reference: |
Line 2498... | Line 2513... | ||
2498 | mov al,[esi] |
2513 | mov al,[esi] |
2499 | or al,al |
2514 | or al,al |
2500 | jz section_found |
2515 | jz section_found |
2501 | add esi,0Ch |
2516 | add esi,0Ch |
2502 | cmp al,80h |
2517 | cmp al,0C0h |
2503 | jne find_section |
2518 | jb find_section |
2504 | add esi,4 |
2519 | add esi,4 |
2505 | jmp find_section |
2520 | jmp find_section |
2506 | section_found: |
2521 | section_found: |
2507 | push esi edi |
2522 | push esi edi |
2508 | mov esi,[esi+4] |
2523 | mov esi,[esi+4] |
2509 | or esi,esi |
2524 | or esi,esi |
Line 2543... | Line 2558... | ||
2543 | or al,al |
2558 | or al,al |
2544 | jz section_relocations_done |
2559 | jz section_relocations_done |
2545 | cmp al,80h |
2560 | cmp al,80h |
2546 | jb add_relocation |
2561 | jb add_relocation |
2547 | ja next_relocation |
2562 | cmp al,0C0h |
- | 2563 | jb next_relocation |
|
2548 | add esi,10h |
2564 | add esi,10h |
2549 | jmp find_relocations |
2565 | jmp find_relocations |
2550 | add_relocation: |
2566 | add_relocation: |
2551 | lea eax,[ebx+0Ah] |
2567 | lea eax,[ebx+0Ah] |
2552 | cmp eax,[display_buffer] |
2568 | cmp eax,[display_buffer] |
2553 | ja out_of_memory |
2569 | ja out_of_memory |
Line 2620... | Line 2636... | ||
2620 | make_symbols_table: |
2636 | make_symbols_table: |
2621 | cmp esi,[free_additional_memory] |
2637 | cmp esi,[free_additional_memory] |
2622 | je symbols_table_ok |
2638 | je symbols_table_ok |
2623 | mov al,[esi] |
2639 | mov al,[esi] |
2624 | cmp al,80h |
2640 | cmp al,0C0h |
- | 2641 | jae add_public_symbol |
|
- | 2642 | cmp al,80h |
|
2625 | je add_public_symbol |
2643 | jae add_extrn_symbol |
2626 | ja add_extrn_symbol |
- | |
2627 | or al,al |
2644 | or al,al |
2628 | jz add_section_symbol |
2645 | jz add_section_symbol |
2629 | add esi,0Ch |
2646 | add esi,0Ch |
2630 | jmp make_symbols_table |
2647 | jmp make_symbols_table |
2631 | add_section_symbol: |
2648 | add_section_symbol: |
2632 | call store_symbol_name |
2649 | call store_symbol_name |
Line 2664... | Line 2681... | ||
2664 | cmp cl,4 |
2681 | cmp cl,4 |
2665 | jne invalid_use_of_symbol |
2682 | jne invalid_use_of_symbol |
2666 | public_symbol_type_ok: |
2683 | public_symbol_type_ok: |
2667 | mov ecx,[eax+20] |
2684 | mov ecx,[eax+20] |
2668 | cmp byte [ecx],81h |
2685 | cmp byte [ecx],80h |
2669 | je alias_symbol |
2686 | je alias_symbol |
2670 | cmp byte [ecx],0 |
2687 | cmp byte [ecx],0 |
2671 | jne invalid_use_of_symbol |
2688 | jne invalid_use_of_symbol |
2672 | mov cx,[ecx+1Eh] |
2689 | mov cx,[ecx+1Eh] |
2673 | mov [ebx+0Ch],cx |
2690 | mov [ebx+0Ch],cx |
2674 | public_symbol_section_ok: |
2691 | public_symbol_section_ok: |
Line 2680... | Line 2697... | ||
2680 | jnc value_out_of_range |
2697 | jnc value_out_of_range |
2681 | store_public_symbol: |
2698 | store_public_symbol: |
2682 | mov eax,[eax] |
2699 | mov eax,[eax] |
2683 | mov [ebx+8],eax |
2700 | mov [ebx+8],eax |
2684 | mov byte [ebx+10h],2 |
2701 | mov al,2 |
- | 2702 | cmp byte [esi],0C0h |
|
- | 2703 | je store_symbol_class |
|
- | 2704 | inc al |
|
- | 2705 | cmp byte [esi],0C1h |
|
- | 2706 | je store_symbol_class |
|
- | 2707 | mov al,105 |
|
- | 2708 | store_symbol_class: |
|
- | 2709 | mov byte [ebx+10h],al |
|
2685 | add esi,10h |
2710 | add esi,10h |
2686 | add ebx,12h |
2711 | add ebx,12h |
2687 | jmp make_symbols_table |
2712 | jmp make_symbols_table |
2688 | alias_symbol: |
2713 | alias_symbol: |
2689 | bt [format_flags],0 |
2714 | bt [format_flags],0 |
2690 | jnc invalid_use_of_symbol |
2715 | jnc invalid_use_of_symbol |
Line 2969... | Line 2994... | ||
2969 | find_first_section: |
2994 | find_first_section: |
2970 | mov al,[esi] |
2995 | mov al,[esi] |
2971 | or al,al |
2996 | or al,al |
2972 | jz first_section_found |
2997 | jz first_section_found |
2973 | cmp al,80h |
2998 | cmp al,0C0h |
2974 | jne skip_other_symbol |
2999 | jb skip_other_symbol |
2975 | add esi,4 |
3000 | add esi,4 |
2976 | skip_other_symbol: |
3001 | skip_other_symbol: |
2977 | add esi,0Ch |
3002 | add esi,0Ch |
2978 | jmp find_first_section |
3003 | jmp find_first_section |
2979 | first_section_found: |
3004 | first_section_found: |
2980 | mov ebx,esi |
3005 | mov ebx,esi |
Line 2987... | Line 3012... | ||
2987 | je make_section_symbol |
3012 | je make_section_symbol |
2988 | mov al,[esi] |
3013 | mov al,[esi] |
2989 | or al,al |
3014 | or al,al |
2990 | jz make_section_symbol |
3015 | jz make_section_symbol |
2991 | cmp al,80h |
3016 | cmp al,0C0h |
- | 3017 | jae skip_public |
|
- | 3018 | cmp al,80h |
|
2992 | je skip_public |
3019 | jae skip_extrn |
2993 | ja skip_extrn |
- | |
2994 | or byte [ebx+14h],40h |
3020 | or byte [ebx+14h],40h |
2995 | skip_extrn: |
3021 | skip_extrn: |
2996 | add esi,0Ch |
3022 | add esi,0Ch |
2997 | jmp find_next_section |
3023 | jmp find_next_section |
2998 | skip_public: |
3024 | skip_public: |
2999 | add esi,10h |
3025 | add esi,10h |
Line 3048... | Line 3074... | ||
3048 | je elf_symbol_table_ok |
3074 | je elf_symbol_table_ok |
3049 | mov al,[esi] |
3075 | mov al,[esi] |
3050 | or al,al |
3076 | or al,al |
3051 | jz skip_section |
3077 | jz skip_section |
3052 | cmp al,80h |
3078 | cmp al,0C0h |
- | 3079 | jae make_public_symbol |
|
- | 3080 | cmp al,80h |
|
3053 | je make_public_symbol |
3081 | jae make_extrn_symbol |
3054 | ja make_extrn_symbol |
- | |
3055 | add esi,0Ch |
3082 | add esi,0Ch |
3056 | jmp find_other_symbols |
3083 | jmp find_other_symbols |
3057 | skip_section: |
3084 | skip_section: |
3058 | add esi,20h |
3085 | add esi,20h |
3059 | jmp find_other_symbols |
3086 | jmp find_other_symbols |
3060 | make_public_symbol: |
3087 | make_public_symbol: |
3061 | mov eax,[esi+0Ch] |
3088 | mov eax,[esi+0Ch] |
3062 | mov [current_line],eax |
3089 | mov [current_line],eax |
3063 | mov ebx,[esi+8] |
3090 | cmp byte [esi],0C0h |
- | 3091 | jne invalid_argument |
|
- | 3092 | mov ebx,[esi+8] |
|
3064 | test byte [ebx+8],1 |
3093 | test byte [ebx+8],1 |
3065 | jz undefined_symbol |
3094 | jz undefined_symbol |
3066 | mov ax,[current_pass] |
3095 | mov ax,[current_pass] |
3067 | cmp ax,[ebx+16] |
3096 | cmp ax,[ebx+16] |
3068 | jne undefined_symbol |
3097 | jne undefined_symbol |
Line 3131... | Line 3160... | ||
3131 | public_symbol_ok: |
3160 | public_symbol_ok: |
3132 | inc ecx |
3161 | inc ecx |
3133 | mov eax,ecx |
3162 | mov eax,ecx |
3134 | shl eax,8 |
3163 | shl eax,8 |
3135 | mov al,80h |
3164 | mov al,0C0h |
3136 | mov [esi],eax |
3165 | mov [esi],eax |
3137 | add esi,10h |
3166 | add esi,10h |
3138 | jmp find_other_symbols |
3167 | jmp find_other_symbols |
3139 | get_public_value: |
3168 | get_public_value: |
3140 | mov eax,[ebx] |
3169 | mov eax,[ebx] |
3141 | cmp dword [ebx+4],0 |
3170 | cmp dword [ebx+4],0 |
Line 3171... | Line 3200... | ||
3171 | extrn_symbol_ok: |
3200 | extrn_symbol_ok: |
3172 | inc ecx |
3201 | inc ecx |
3173 | mov eax,ecx |
3202 | mov eax,ecx |
3174 | shl eax,8 |
3203 | shl eax,8 |
3175 | mov al,81h |
3204 | mov al,80h |
3176 | mov [esi],eax |
3205 | mov [esi],eax |
3177 | add esi,0Ch |
3206 | add esi,0Ch |
3178 | jmp find_other_symbols |
3207 | jmp find_other_symbols |
3179 | elf_symbol_table_ok: |
3208 | elf_symbol_table_ok: |
3180 | mov edx,edi |
3209 | mov edx,edi |
3181 | mov ebx,[free_additional_memory] |
3210 | mov ebx,[free_additional_memory] |
Line 3310... | Line 3339... | ||
3310 | or al,al |
3339 | or al,al |
3311 | jz relocations_converted |
3340 | jz relocations_converted |
3312 | cmp al,80h |
3341 | cmp al,80h |
3313 | jb make_relocation_entry |
3342 | jb make_relocation_entry |
3314 | ja relocation_entry_ok |
3343 | cmp al,0C0h |
- | 3344 | jb relocation_entry_ok |
|
3315 | add esi,10h |
3345 | add esi,10h |
3316 | jmp convert_relocations |
3346 | jmp convert_relocations |
3317 | make_relocation_entry: |
3347 | make_relocation_entry: |
3318 | test [format_flags],8 |
3348 | test [format_flags],8 |
3319 | jnz make_elf64_relocation_entry |
3349 | jnz make_elf64_relocation_entry |
3320 | mov eax,[esi+4] |
3350 | mov eax,[esi+4] |