diff --git a/programs/develop/fasm/trunk/assemble.inc b/programs/develop/fasm/trunk/assemble.inc index 621fbdb75a..20bf19e96c 100644 --- a/programs/develop/fasm/trunk/assemble.inc +++ b/programs/develop/fasm/trunk/assemble.inc @@ -618,14 +618,17 @@ load_directive: load_from_code: cmp byte [esi],'.' je invalid_value - call get_relative_offset - neg eax + call get_qword_value + call calculate_relative_offset + push esi edi cmp [next_pass_needed],0 - jne load_address_ok + jne load_address_type_ok cmp [value_type],0 jne invalid_use_of_symbol - load_address_ok: - push esi edi + load_address_type_ok: + cmp edx,-1 + jne bad_load_address + neg eax mov esi,edi sub esi,eax jc bad_load_address @@ -673,14 +676,17 @@ store_directive: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_relative_offset - neg eax + call get_qword_value + call calculate_relative_offset + push esi edi cmp [next_pass_needed],0 - jne store_address_ok + jne store_address_type_ok cmp [value_type],0 jne invalid_use_of_symbol - store_address_ok: - push esi edi + store_address_type_ok: + cmp edx,-1 + jne bad_store_address + neg eax sub edi,eax jc bad_store_address cmp edi,[org_start] diff --git a/programs/develop/fasm/trunk/expressi.inc b/programs/develop/fasm/trunk/expressi.inc index ea59bf0635..29a3d43613 100644 --- a/programs/develop/fasm/trunk/expressi.inc +++ b/programs/develop/fasm/trunk/expressi.inc @@ -841,6 +841,8 @@ calculate_expression: sub ebx,14h cmp al,0E0h je calculate_rva + cmp al,0E1h + je calculate_plt cmp al,0D0h je calculate_not cmp al,083h @@ -1145,12 +1147,7 @@ calculate_expression: xor ah,ah mov ecx,[edi+16] cmp ecx,[ebx+16] - je sub_values - cmp ecx,[org_symbol] jne invalid_sub - test byte [ebx+12],1 - jnz invalid_sub - mov ah,3 sub_values: mov [ebx+12],ah mov eax,[edi] @@ -1556,17 +1553,41 @@ calculate_expression: calculate_gotoff: test [format_flags],8+1 jnz invalid_expression + mov dl,5 cmp byte [edi+12],2 - je gotoff_ok + je change_value_type + incorrect_change_of_value_type: cmp [error_line],0 - jne pe64_rva_ok + jne change_value_type mov eax,[current_line] mov [error_line],eax mov [error],invalid_use_of_symbol - gotoff_ok: - mov byte [edi+12],5 + change_value_type: + mov byte [edi+12],dl add edi,14h jmp calculation_loop + calculate_plt: + cmp word [edi+8],0 + jne invalid_expression + cmp [output_format],5 + jne invalid_expression + test [format_flags],1 + jnz invalid_expression + mov dl,6 + mov dh,2 + test [format_flags],8 + jz check_value_for_plt + mov dh,4 + check_value_for_plt: + mov eax,[edi] + or eax,[edi+4] + jnz incorrect_change_of_value_type + cmp byte [edi+12],dh + jne incorrect_change_of_value_type + mov eax,[edi+16] + cmp byte [eax],81h + jne incorrect_change_of_value_type + jmp change_value_type div_64: xor ebx,ebx cmp dword [edi],0 @@ -1955,6 +1976,7 @@ get_address_value: mov [value_type],al cmp al,5 je gotoff_address + ja invalid_use_of_symbol test al,1 jnz invalid_use_of_symbol or al,al @@ -1984,8 +2006,10 @@ get_address_value: mov [error_line],ecx mov [error],value_out_of_range address_size_ok: - xor bx,bx - xor cl,cl + xor ebx,ebx + xor ecx,ecx + mov cl,[value_type] + shl ecx,16 mov ch,[address_size] cmp word [edi+8],0 je check_immediate_address @@ -2071,42 +2095,31 @@ get_address_value: cmp [address_size],4 je check_dword_value jmp check_qword_value -get_relative_offset: - mov [value_size],4 - mov [size_override],-1 - call calculate_expression - calculate_relative_offset: - push esi - add edi,14h - mov esi,[display_buffer] - sub esi,7 - lea eax,[esi-14h] - cmp eax,edi - jb out_of_memory - mov byte [esi],11h - xor eax,eax - mov dword [esi+1],eax - mov word [esi+5],')' shl 8 + 81h - call calculation_loop - pop esi - cmp word [edi+8],0 - jne invalid_value - mov al,[edi+12] - mov [value_type],al - mov eax,[edi+16] - mov [symbol_identifier],eax - mov eax,[edi] - mov edx,[edi+4] - or edx,edx - jz offset_positive - cmp edx,-1 - jne range_exceeded - bt eax,31 - jnc range_exceeded +calculate_relative_offset: + cmp [value_undefined],0 + jne relative_offset_ok + add eax,dword [org_origin] + adc edx,dword [org_origin+4] + sub eax,edi + sbb edx,0 + mov bl,[value_type] + or bl,bl + je relative_offset_ok + test bl,1 + jnz invalid_use_of_symbol + cmp bl,6 + je plt_relative_offset + cmp bl,[labels_type] + jne invalid_use_of_symbol + mov [value_type],0 + mov ecx,[symbol_identifier] + cmp ecx,[org_symbol] + je relative_offset_ok + mov [value_type],3 + relative_offset_ok: ret - offset_positive: - bt eax,31 - jc range_exceeded + plt_relative_offset: + mov [value_type],7 ret preevaluate_logical_expression: diff --git a/programs/develop/fasm/trunk/fasm.asm b/programs/develop/fasm/trunk/fasm.asm index 1d7ad939ae..85d4a83a9c 100644 --- a/programs/develop/fasm/trunk/fasm.asm +++ b/programs/develop/fasm/trunk/fasm.asm @@ -11,26 +11,29 @@ NORMAL_MODE = 8 CONSOLE_MODE = 32 -MAGIC1 = 6*(text.line_size-1)+6*2+2 -MAGIC2 = 14 -MAGIC3 = 1 -MAGIC4 = 7 -OUTPUTXY = (5+MAGIC4) shl 16 + MAGIC2*3+MAGIC3+MAGIC4+1+2 -MAX_PATH = 100 +MAGIC1 = 6*(text.line_size-1)+14 +MAGIC2 = 14 +MAGIC3 = 1 +MAGIC4 = 7 +OUTPUTXY = 7 shl 16 + 53 +MAX_PATH = 100 -APP_MEMORY = 0x00800000 +APP_MEMORY = 0x00800000 ;; Menuet header +appname equ "FASM " +version equ "1.67.11" + use32 org 0x0 db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd START ; program start + dd 0x01 ; header version + dd START ; program start dd program_end ; program image size dd APP_MEMORY ; required amount of memory - dd 0xDFFF0 ; stack + dd 0xDFFF0 ; stack dd params,0x0 ; parameters,icon include 'lang.inc' @@ -40,105 +43,100 @@ center fix true START: ; Start of execution - cmp [params],0 - jz noparams + cmp [params],0 + jz red - mov ecx,10 - mov al,' ' - mov edi,infile - push ecx + mov ecx,10 + mov al,' ' + mov edi,infile + push ecx cld - rep stosd - mov ecx,[esp] - mov edi,outfile - rep stosd - pop ecx - mov edi,path - rep stosd + rep stosd + mov ecx,[esp] + mov edi,outfile + rep stosd + pop ecx + mov edi,path + rep stosd - mov esi,params + mov esi,params ; DEBUGF "params: %s\n",esi - mov edi,infile + mov edi,infile call mov_param_str ; mov edi,infile ; DEBUGF " input: %s\n",edi - inc esi - mov edi,outfile + inc esi + mov edi,outfile call mov_param_str ; mov edi,outfile ; DEBUGF "output: %s\n",edi - inc esi - mov edi,path + inc esi + mov edi,path call mov_param_str ; mov edi,path ; DEBUGF " path: %s\n",edi - cmp [esi], dword ',run' - jne @f - mov [_run_outfile],1 + cmp [esi], dword ',run' + jne @f + mov [_run_outfile],1 @@: - mov [_mode],CONSOLE_MODE - jmp start + mov [_mode],CONSOLE_MODE + jmp start - noparams: - - call draw_window - -still: - - mcall 10 ; Wait here for event - - dec eax ; Redraw request - jz red - dec eax ; Key in buffer - jz key - dec eax ; Button in buffer - jz button - - jmp still red: ; Redraw call draw_window - jmp still -key: ; Key - mcall 2 ; Read it and ignore +still: + push 10 ; Wait here for event + pop eax + int 40h + dec eax + je red ; Redraw request + dec eax + jne button ; Button in buffer + +key: ; Key + mov al,2 ; Read it and ignore + int 0x40 jmp still button: ; Button in Window - mcall 17 + mov al,17 + int 0x40 - cmp ah,2 ; Start compiling - je start - cmp ah,3 ; Start compiled file + cmp ah,1 + jne noclose + or eax,-1 + int 0x40 + +noclose: + cmp ah,2 ; Start compiling + je start + cmp ah,3 ; Start compiled file jnz norunout mov edx,outfile call make_fullpaths - mcall 58,file_info_start + mcall 70,file_info_start ; xor ecx,ecx jmp still norunout: - mov ecx,[skinh] - add ecx,MAGIC3+MAGIC2/2-3 + mov ecx,5 mov [ya],ecx cmp ah,11 ; Infile - je f1 + je f1 cmp ah,12 ; Outfile - je f2 + je f2 cmp ah,13 ; Path - je f3 + je f3 - dec ah ; Close application - jnz still + jmp still - mcall -1 - -skinh dd ? draw_window: @@ -148,15 +146,19 @@ draw_window: get_sys_colors 1,0 - mcall 0,<50,280>,<50,250>,[sc.work] ; Draw Window + mov eax,0 + mov ebx,50*65536+280 + mov ecx,50*65536+250 + mov edx,[sc.work] + or edx,0x33000000 + mov edi,header ; Draw Window Label Text + int 0x40 - draw_caption header,header.size ; Draw Window Label Text + mcall 9,PROCESSINFO,-1 - mov ecx,[skinh-2] - mov cx,word[skinh] - madd ecx,MAGIC3,MAGIC3 + mpack ecx,1,1 mov ebx,[pinfo.x_size] - madd ebx,5,-5 + sub ebx,10 push ecx madd ecx,MAGIC2*3+2,MAGIC2*3+2 @@ -164,7 +166,6 @@ draw_window: pop ecx sub ebx,MAGIC1+3 - mcall madd ecx,MAGIC2,MAGIC2 mcall @@ -173,17 +174,16 @@ draw_window: madd ecx,MAGIC2,MAGIC2 mcall push ebx - mpack ebx,MAGIC1+5,MAGIC1+5 - sub cx,MAGIC2*3 + mpack ebx,MAGIC1,MAGIC1 + sub ecx,MAGIC2*3 mcall mov ebx,[esp-2] pop bx mcall add esp,2 - mpack ebx,5,MAGIC1-1 - mpack ecx,[skinh],MAGIC2-2 - madd ecx,MAGIC3+1,0 + mpack ebx,0,MAGIC1-1 + mpack ecx,MAGIC3+1,MAGIC2-2 mcall 8,,,0x4000000B ; Button: Enter Infile madd ecx,MAGIC2,0 mcall ,,,0x4000000C ; Button: Enter Outfile @@ -191,36 +191,35 @@ draw_window: mcall ,,,0x4000000D ; Button: Enter Path mpack ebx,[pinfo.x_size],MAGIC1 - msub ebx,MAGIC1+5+1,0 - mpack ecx,[skinh],MAGIC2*3/2-1 + msub ebx,MAGIC1+10+1,0 + mpack ecx,0,MAGIC2*3/2-1 madd ecx,MAGIC3,0 mcall ,,,0x00000002,[sc.work_button] madd ecx,MAGIC2*3/2+1,0 mcall ,,,0x00000003 - mpack ebx,5+6,[skinh] ; Draw Window Text - add bx,MAGIC3+MAGIC2/2-3 + mpack ebx,6,0 ; Draw Window Text + add ebx,MAGIC3+MAGIC2/2-3 mov ecx,[sc.work_text] mov edx,text mov esi,text.line_size mov eax,4 newline: - mcall + int 0x40 add ebx,MAGIC2 add edx,text.line_size cmp byte[edx],'x' jne newline mov ebx,[pinfo.x_size] - sub ebx,MAGIC1+5+1-9 + sub ebx,MAGIC1+10+1-9 shl ebx,16 - mov bx,word[skinh] - add bx,MAGIC3+(MAGIC2*3/2-1)/2-3 + add ebx,MAGIC3+(MAGIC2*3/2-1)/2-3 mcall ,,[sc.work_button_text],s_compile,7 add ebx,MAGIC2*3/2+1 mcall ,,,s_run - mpack ebx,MAGIC1+5+6,[skinh] + mpack ebx,MAGIC1+6,0 add ebx,MAGIC3+MAGIC2/2-3+MAGIC2*0 mov esi,[pinfo.x_size] sub esi,MAGIC1*2+5*2+6+3 @@ -248,15 +247,14 @@ bottom_right dd ? draw_messages: mov eax,13 ; clear work area - mpack ebx,5+MAGIC4-2,[pinfo.x_size] + mpack ebx,MAGIC4-2,[pinfo.x_size] sub ebx,5*2+MAGIC4*2-1-2*2 - mpack ecx,[skinh],[pinfo.y_size] - madd ecx,MAGIC2*3+MAGIC3+MAGIC4+1,-(MAGIC2*3+MAGIC3+MAGIC4*2+5)+2 + mpack ecx,0,[pinfo.y_size] + madd ecx,MAGIC2*3+MAGIC3+MAGIC4+1,-(MAGIC2*3+MAGIC3+MAGIC4*2+25) mov word[bottom_right+2],bx mov word[bottom_right],cx msub [bottom_right],7,11 add [bottom_right],OUTPUTXY - sub ecx,[skinh] mov edx,[sc.work] int 0x40 _cy = 0 @@ -264,7 +262,7 @@ _sy = 2 _cx = 4 _sx = 6 push ebx ecx - mpack ebx,5+MAGIC4-3,5+MAGIC4-2 + mpack ebx,MAGIC4-3,MAGIC4-2 add bx,[esp+_cx] mov ecx,[esp+_sy-2] mov cx,[esp+_sy] @@ -276,7 +274,7 @@ _sx = 6 add ecx,esi madd ecx,1,1 mcall - mpack ebx,5+MAGIC4-3,5+MAGIC4-3 + mpack ebx,MAGIC4-3,MAGIC4-3 mov esi,[esp+_sy-2] mov si,cx mov ecx,esi @@ -363,14 +361,14 @@ f11:mcall 10 print_text: - mpack ebx,MAGIC1+5+6,[pinfo.x_size] + mpack ebx,MAGIC1+6,[pinfo.x_size] sub ebx,MAGIC1*2+5*2+6+3 movzx esi,bx mov ecx,[ya-2] mov cx,8 mcall 13,,,[sc.work] - mpack ebx,MAGIC1+5+6,[ya] + mpack ebx,MAGIC1+6,[ya] mov eax,esi mov cl,6 div cl @@ -385,7 +383,7 @@ print_text: ; DATA -sz header,'FASM FOR MENUET' +header db appname,version,0 text: db ' INFILE:' @@ -430,7 +428,7 @@ start: cmp [_mode],NORMAL_MODE jne @f call draw_messages - push [skinh] + push 0 pop [textxy] add [textxy],OUTPUTXY @@: @@ -489,7 +487,7 @@ start: je @f mov edx,outfile call make_fullpaths - mov eax,58 + mov eax,70 mov ebx,file_info_start xor ecx,ecx int 0x40 diff --git a/programs/develop/fasm/trunk/formats.inc b/programs/develop/fasm/trunk/formats.inc index a9434d5d52..63d77bdafe 100644 --- a/programs/develop/fasm/trunk/formats.inc +++ b/programs/develop/fasm/trunk/formats.inc @@ -2887,18 +2887,23 @@ elf_section: mark_elf_relocation: cmp [value_type],3 je elf_relocation_relative + cmp [value_type],7 + je elf_relocation_relative push ebx eax - cmp [value_type],3 + cmp [value_type],5 je elf_gotoff_relocation - mov al,1 + ja invalid_use_of_symbol + mov al,1 ; R_386_32 / R_AMD64_64 test [format_flags],8 jz coff_relocation cmp [value_type],4 je coff_relocation - mov al,11 + mov al,11 ; R_AMD64_32S jmp coff_relocation elf_gotoff_relocation: - mov al,9 + test [format_flags],8 + jnz invalid_use_of_symbol + mov al,9 ; R_386_GOTOFF jmp coff_relocation elf_relocation_relative: cmp [labels_type],0 @@ -2909,7 +2914,10 @@ mark_elf_relocation: sub ebx,edi sub eax,ebx push eax - mov al,2 + mov al,2 ; R_386_PC32 / R_AMD64_PC32 + cmp [value_type],3 + je coff_relocation + mov al,4 ; R_386_PLT32 / R_AMD64_PLT32 jmp coff_relocation close_elf: bt [format_flags],0 diff --git a/programs/develop/fasm/trunk/system.inc b/programs/develop/fasm/trunk/system.inc index a3710aed1f..2790964ec1 100644 --- a/programs/develop/fasm/trunk/system.inc +++ b/programs/develop/fasm/trunk/system.inc @@ -5,15 +5,21 @@ ; MenuetOS system.inc by VT file_info_open: dd 0,0,0xffffff,0x20000,0xf0000 -fullpath_open:; db '/HD/1/EXAMPLE.ASM' +fullpath_open: ; db '/RD/1/EXAMPLE.ASM' times MAX_PATH db 0 + file_info_write: dd 1,0,0,0,0xf0000 -fullpath_write:; db '/HD/1/EXAMPLE' +fullpath_write:; db '/RD/1/EXAMPLE' times MAX_PATH db 0 -file_info_start: dd 16,0,0,0,0xf0000 -fullpath_start:; db '/HD/1/EXAMPLE' +file_info_start: ;this part is already rewrited to 70th function + dd 7 + dd 0 + dd 0 + dd 0 + dd 0 +fullpath_start: ; db '/RD/1/EXAMPLE' times MAX_PATH db 0 _ramdisk db '/RD/1/' @@ -69,10 +75,10 @@ open: jz @f cmp eax,6 jne file_error - @@: mov [filesize],ebx +@@: mov [filesize],ebx clc ret - file_error: +file_error: stc ret @@ -212,9 +218,11 @@ display_character: jnz dc1 and [textxy],0x0000FFFF add [textxy],OUTPUTXY and 0xFFFF0000 + 10 -dc2: popa +dc2: + popa ret -dc1: mov eax,[textxy] +dc1: + mov eax,[textxy] cmp ax,word[bottom_right] ja dc2 shr eax,16 @@ -225,7 +233,8 @@ dc1: mov eax,[textxy] add [textxy],0x00060000 popa ret -@@: mov eax,63 +@@: + mov eax,63 mov ebx,1 mov cl,dl int 0x40 @@ -233,16 +242,17 @@ dc1: mov eax,[textxy] ret - display_string: pusha - @@: cmp byte[esi],0 +@@: + cmp byte[esi],0 je @f mov dl,[esi] call display_character add esi,1 jmp @b - @@: popa +@@: + popa ret display_number: @@ -250,7 +260,7 @@ display_number: mov ecx,1000000000 xor edx,edx xor bl,bl - display_loop: +display_loop: div ecx push edx cmp ecx,1 @@ -260,13 +270,13 @@ display_number: or al,al jz digit_ok not bl - display_digit: +display_digit: mov dl,al add dl,30h push ebx ecx call display_character pop ecx ebx - digit_ok: +digit_ok: mov eax,ecx xor edx,edx mov ecx,10 @@ -292,15 +302,15 @@ display_user_messages: je line_break_ok cmp ax,0D0Ah je line_break_ok - make_line_break: +make_line_break: mov esi,lf call display_string - line_break_ok: +line_break_ok: ret display_block: pusha - @@: mov dl,[esi] +@@: mov dl,[esi] call display_character inc esi loop @b @@ -323,19 +333,19 @@ assembler_error: call display_user_messages push dword 0 mov ebx,[current_line] - get_error_lines: +get_error_lines: push ebx test byte [ebx+7],80h jz display_error_line mov edx,ebx - find_definition_origin: +find_definition_origin: mov edx,[edx+12] test byte [edx+7],80h jnz find_definition_origin push edx mov ebx,[ebx+8] jmp get_error_lines - display_error_line: +display_error_line: mov esi,[ebx] call display_string mov esi,line_number_start @@ -363,7 +373,7 @@ assembler_error: call display_number mov dl,']' call display_character - line_number_ok: +line_number_ok: mov esi,line_data_start call display_string mov esi,ebx @@ -386,7 +396,7 @@ assembler_error: call close pop ecx mov esi,[additional_memory] - get_line_data: +get_line_data: mov al,[esi] cmp al,0Ah je display_line_data @@ -398,7 +408,7 @@ assembler_error: jz display_line_data inc esi loop get_line_data - display_line_data: +display_line_data: mov ecx,esi mov esi,[additional_memory] sub ecx,esi @@ -416,32 +426,6 @@ assembler_error: call display_string jmp exit_program -__draw_caption: -; mcall 48,4 -; mov [skinh],eax -; mov ebx,eax -; shr ebx,1 -; adc ebx,1+0x000A0000-4 -; mcall 4,,[sc.grab_text],s_title,[s_title.size] - - mcall 48,4 - mov [skinh],eax - shr eax,1 - adc eax,0 - add eax,1-4 - push ax - if center eq true - mcall 9,PROCESSINFO,-1 - mov ebx,[PROCESSINFO+process_information.x_size] - shr ebx,1 - sub ebx,header.size*6/2 + 8 - else - mov ebx,8 - end if - shl ebx,16 - pop bx - mcall 4,,[SYSTEMCOLORS+system_colors.grab_text] - ret character db ?,0 bytes_count dd ? @@ -459,4 +443,4 @@ line_data_start db ':' cr_lf db 0Dh,0Ah,0 line_number_start db ' [',0 -macro dm string { db string,0 } \ No newline at end of file +macro dm string { db string,0 } diff --git a/programs/develop/fasm/trunk/tables.inc b/programs/develop/fasm/trunk/tables.inc index 17559b1b5c..ef9057c233 100644 --- a/programs/develop/fasm/trunk/tables.inc +++ b/programs/develop/fasm/trunk/tables.inc @@ -61,6 +61,7 @@ single_operand_operators: db 1,'+',0 db 1,'-',083h db 3,'not',0D0h + db 3,'plt',0E1h db 3,'rva',0E0h db 0 @@ -513,8 +514,8 @@ instructions_3: dw single_operand_instruction-assembler db 'neg',3 dw single_operand_instruction-assembler - db 'nop',90h - dw simple_instruction-assembler + ;db 'nop',90h + ;dw nop_instruction-assembler db 'not',2 dw single_operand_instruction-assembler db 'org',0 @@ -524,7 +525,7 @@ instructions_3: db 'pop',0 dw pop_instruction-assembler db 'por',0EBh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'rcl',2 dw sh_instruction-assembler db 'rcr',3 @@ -687,7 +688,7 @@ instructions_4: db 'outs',6Eh dw outs_instruction-assembler db 'pand',0DBh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'popa',61h dw simple_instruction_except64-assembler db 'popd',4 @@ -701,7 +702,7 @@ instructions_4: db 'push',0 dw push_instruction-assembler db 'pxor',0EFh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'repe',0F3h dw prefix_instruction-assembler db 'repz',0F3h @@ -991,22 +992,28 @@ instructions_5: dw simple_instruction_32bit-assembler db 'outsw',6Fh dw simple_instruction_16bit-assembler + db 'pabsb',1Ch + dw ssse3_instruction-assembler + db 'pabsd',1Eh + dw ssse3_instruction-assembler + db 'pabsw',1Dh + dw ssse3_instruction-assembler db 'paddb',0FCh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'paddd',0FEh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'paddq',0D4h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'paddw',0FDh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pandn',0DFh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pause',0 dw pause_instruction-assembler db 'pavgb',0E0h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pavgw',0E3h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pf2id',1Dh dw amd3dnow_instruction-assembler db 'pf2iw',1Ch @@ -1056,13 +1063,13 @@ instructions_5: db 'psrlw',0D1h dw mmx_ps_instruction-assembler db 'psubb',0F8h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'psubd',0FAh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'psubq',0FBh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'psubw',0F9h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pusha',60h dw simple_instruction_except64-assembler db 'pushd',4 @@ -1341,43 +1348,59 @@ instructions_6: db 'movups',10h dw movps_instruction-assembler db 'paddsb',0ECh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'paddsw',0EDh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pextrw',0C5h dw pextrw_instruction-assembler db 'pfnacc',8Ah dw amd3dnow_instruction-assembler db 'pfsubr',0AAh dw amd3dnow_instruction-assembler + db 'phaddd',2 + dw ssse3_instruction-assembler + db 'phaddw',1 + dw ssse3_instruction-assembler + db 'phsubd',6 + dw ssse3_instruction-assembler + db 'phsubw',5 + dw ssse3_instruction-assembler db 'pinsrw',0C4h dw pinsrw_instruction-assembler db 'pmaxsw',0EEh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pmaxub',0DEh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pminsw',0EAh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pminub',0DAh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pmulhw',0E5h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pmullw',0D5h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'psadbw',0F6h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler + db 'pshufb',0 + dw ssse3_instruction-assembler db 'pshufd',66h dw pshufd_instruction-assembler db 'pshufw',0 dw pshufw_instruction-assembler + db 'psignb',8 + dw ssse3_instruction-assembler + db 'psignd',0Ah + dw ssse3_instruction-assembler + db 'psignw',9 + dw ssse3_instruction-assembler db 'pslldq',111b dw ps_dq_instruction-assembler db 'psrldq',011b dw ps_dq_instruction-assembler db 'psubsb',0E8h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'psubsw',0E9h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pswapd',0BBh dw amd3dnow_instruction-assembler db 'public',0 @@ -1544,23 +1567,25 @@ instructions_7: db 'movq2dq',0 dw movq2dq_instruction-assembler db 'paddusb',0DCh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'paddusw',0DDh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler + db 'palignr',0 + dw palignr_instruction-assembler db 'pavgusb',0BFh dw amd3dnow_instruction-assembler db 'pcmpeqb',74h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pcmpeqd',76h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pcmpeqw',75h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pcmpgtb',64h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pcmpgtd',66h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pcmpgtw',65h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pfcmpeq',0B0h dw amd3dnow_instruction-assembler db 'pfcmpge',90h @@ -1571,22 +1596,26 @@ instructions_7: dw amd3dnow_instruction-assembler db 'pfrsqrt',97h dw amd3dnow_instruction-assembler + db 'phaddsw',3 + dw ssse3_instruction-assembler + db 'phsubsw',7 + dw ssse3_instruction-assembler db 'pmaddwd',0F5h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pmulhrw',0B7h dw amd3dnow_instruction-assembler db 'pmulhuw',0E4h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pmuludq',0F4h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pshufhw',0F3h dw pshufd_instruction-assembler db 'pshuflw',0F2h dw pshufd_instruction-assembler db 'psubusb',0D8h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'psubusw',0D9h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'rsqrtps',52h dw sse_ps_instruction-assembler db 'rsqrtss',52h @@ -1701,11 +1730,11 @@ instructions_8: db 'movsldup',12h dw cvtdq2pd_instruction-assembler db 'packssdw',6Bh - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'packsswb',63h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'packuswb',67h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'pfrcpit1',0A6h dw amd3dnow_instruction-assembler db 'pfrcpit2',0B6h @@ -1714,6 +1743,8 @@ instructions_8: dw amd3dnow_instruction-assembler db 'pmovmskb',0D7h dw pextrw_instruction-assembler + db 'pmulhrsw',0Bh + dw ssse3_instruction-assembler db 'prefetch',0 dw amd_prefetch_instruction-assembler db 'sysenter',34h @@ -1747,20 +1778,22 @@ instructions_9: dw cvtsd2si_instruction-assembler db 'cvttss2si',2Ch dw cvtss2si_instruction-assembler + db 'pmaddubsw',4 + dw ssse3_instruction-assembler db 'prefetchw',1 dw amd_prefetch_instruction-assembler db 'punpckhbw',68h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'punpckhdq',6Ah - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'punpckhwd',69h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'punpcklbw',60h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'punpckldq',62h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler db 'punpcklwd',61h - dw mmx_instruction-assembler + dw basic_mmx_instruction-assembler instructions_10: db 'cmpunordpd',3 dw cmp_pd_instruction-assembler diff --git a/programs/develop/fasm/trunk/variable.inc b/programs/develop/fasm/trunk/variable.inc index 827fe57ddf..5997a413e2 100644 --- a/programs/develop/fasm/trunk/variable.inc +++ b/programs/develop/fasm/trunk/variable.inc @@ -106,6 +106,7 @@ value_type db ? compare_type db ? base_code db ? extended_code db ? +supplemental_code db ? postbyte_register db ? segment_register db ? mmx_size db ? diff --git a/programs/develop/fasm/trunk/version.inc b/programs/develop/fasm/trunk/version.inc index 5d27dab018..7951ebcd20 100644 --- a/programs/develop/fasm/trunk/version.inc +++ b/programs/develop/fasm/trunk/version.inc @@ -33,7 +33,7 @@ ; cannot simply be copied and put under another distribution licence ; (including the GNU Public Licence). -VERSION_STRING equ "1.67.9" +VERSION_STRING equ "1.67.11" VERSION_MAJOR = 1 VERSION_MINOR = 67 diff --git a/programs/develop/fasm/trunk/x86_64.inc b/programs/develop/fasm/trunk/x86_64.inc index f2b0b12f92..f9217f0276 100644 --- a/programs/develop/fasm/trunk/x86_64.inc +++ b/programs/develop/fasm/trunk/x86_64.inc @@ -114,7 +114,7 @@ basic_instruction: jne invalid_operand basic_mem: call get_address - push edx bx cx + push edx ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -128,7 +128,7 @@ basic_instruction: lods byte [esi] call convert_register mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx mov al,ah cmp al,1 je basic_mem_reg_8bit @@ -160,7 +160,7 @@ basic_instruction: mov al,[base_code] shr al,3 mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx mov [base_code],80h call store_instruction_with_imm8 jmp instruction_assembled @@ -171,7 +171,7 @@ basic_instruction: mov al,[base_code] shr al,3 mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx cmp [value_type],0 jne basic_mem_imm_16bit_store cmp [size_declared],0 @@ -196,7 +196,7 @@ basic_instruction: mov al,[base_code] shr al,3 mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx cmp [value_type],0 jne basic_mem_imm_32bit_store cmp [size_declared],0 @@ -430,7 +430,7 @@ mov_instruction: jne invalid_operand mov_mem: call get_address - push edx bx cx + push edx ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -449,7 +449,7 @@ mov_instruction: mov_mem_general_reg: call convert_register mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx cmp ah,1 je mov_mem_reg_8bit mov al,ah @@ -542,7 +542,7 @@ mov_instruction: mov_mem_sreg: sub al,61h mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx mov ah,[operand_size] or ah,ah jz mov_mem_sreg_store @@ -575,7 +575,7 @@ mov_instruction: mov byte [value],al mov [postbyte_register],0 mov [base_code],0C6h - pop cx bx edx + pop ecx ebx edx call store_instruction_with_imm8 jmp instruction_assembled mov_mem_imm_16bit: @@ -584,7 +584,7 @@ mov_instruction: mov word [value],ax mov [postbyte_register],0 mov [base_code],0C7h - pop cx bx edx + pop ecx ebx edx call store_instruction_with_imm16 jmp instruction_assembled mov_mem_imm_32bit: @@ -594,7 +594,7 @@ mov_instruction: mov dword [value],eax mov [postbyte_register],0 mov [base_code],0C7h - pop cx bx edx + pop ecx ebx edx call store_instruction_with_imm32 jmp instruction_assembled mov_mem_imm_64bit: @@ -998,7 +998,7 @@ test_instruction: jne invalid_operand test_mem: call get_address - push edx bx cx + push edx ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -1012,7 +1012,7 @@ test_instruction: lods byte [esi] call convert_register mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx mov al,ah cmp al,1 je test_mem_reg_8bit @@ -1044,7 +1044,7 @@ test_instruction: mov byte [value],al mov [postbyte_register],0 mov [base_code],0F6h - pop cx bx edx + pop ecx ebx edx call store_instruction_with_imm8 jmp instruction_assembled test_mem_imm_16bit: @@ -1053,7 +1053,7 @@ test_instruction: mov word [value],ax mov [postbyte_register],0 mov [base_code],0F7h - pop cx bx edx + pop ecx ebx edx call store_instruction_with_imm16 jmp instruction_assembled test_mem_imm_32bit: @@ -1063,7 +1063,7 @@ test_instruction: mov dword [value],eax mov [postbyte_register],0 mov [base_code],0F7h - pop cx bx edx + pop ecx ebx edx call store_instruction_with_imm32 jmp instruction_assembled test_mem_imm_64bit: @@ -1200,7 +1200,7 @@ xchg_instruction: jne invalid_operand xchg_mem: call get_address - push edx bx cx + push edx ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -2055,7 +2055,7 @@ sh_instruction: jne invalid_operand sh_mem: call get_address - push edx bx cx + push edx ebx ecx mov al,[operand_size] push eax mov [operand_size],0 @@ -2072,7 +2072,7 @@ sh_instruction: lods byte [esi] cmp al,11h jne invalid_operand - pop eax cx bx edx + pop eax ecx ebx edx cmp al,1 je sh_mem_cl_8bit jb sh_mem_cl_nosize @@ -2099,7 +2099,7 @@ sh_instruction: sh_mem_imm_size_ok: call get_byte_value mov byte [value],al - pop eax cx bx edx + pop eax ecx ebx edx cmp al,1 je sh_mem_imm_8bit jb sh_mem_imm_nosize @@ -2207,7 +2207,7 @@ shd_instruction: jne invalid_operand shd_mem: call get_address - push edx bx cx + push edx ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -2233,7 +2233,7 @@ shd_instruction: lods byte [esi] cmp al,11h jne invalid_operand - pop eax cx bx edx + pop eax ecx ebx edx call operand_autodetect inc [extended_code] call store_instruction @@ -2247,7 +2247,7 @@ shd_instruction: shd_mem_reg_imm_size_ok: call get_byte_value mov byte [value],al - pop eax cx bx edx + pop eax ecx ebx edx call operand_autodetect call store_instruction_with_imm8 jmp instruction_assembled @@ -2422,7 +2422,7 @@ bt_instruction: cmp al,'[' jne invalid_operand call get_address - push eax bx cx + push eax ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -2440,7 +2440,7 @@ bt_instruction: lods byte [esi] call convert_register mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx mov al,ah call operand_autodetect call store_instruction @@ -2466,7 +2466,7 @@ bt_instruction: jz bt_mem_imm_nosize call operand_autodetect bt_mem_imm_store: - pop cx bx edx + pop ecx ebx edx mov [extended_code],0BAh call store_instruction_with_imm8 jmp instruction_assembled @@ -2620,12 +2620,12 @@ imul_instruction: jne invalid_operand imul_reg_mem: call get_address - push edx bx cx + push edx ebx ecx cmp byte [esi],',' je imul_reg_mem_imm mov al,[operand_size] call operand_autodetect - pop cx bx edx + pop ecx ebx edx mov [base_code],0Fh mov [extended_code],0AFh call store_instruction @@ -2657,7 +2657,7 @@ imul_instruction: cmp ax,80h jl imul_reg_mem_imm_8bit_store imul_reg_mem_imm_16bit_store: - pop cx bx edx + pop ecx ebx edx mov [base_code],69h call store_instruction_with_imm16 jmp instruction_assembled @@ -2675,7 +2675,7 @@ imul_instruction: cmp eax,80h jl imul_reg_mem_imm_8bit_store imul_reg_mem_imm_32bit_store: - pop cx bx edx + pop ecx ebx edx mov [base_code],69h call store_instruction_with_imm32 jmp instruction_assembled @@ -2688,7 +2688,7 @@ imul_instruction: jae long_immediate_not_encodable jmp imul_reg_mem_imm_32bit_ok imul_reg_mem_imm_8bit_store: - pop cx bx edx + pop ecx ebx edx mov [base_code],6Bh call store_instruction_with_imm8 jmp instruction_assembled @@ -3168,26 +3168,9 @@ jmp_instruction: stos word [edi] jmp instruction_assembled calculate_jump_offset: - cmp [value_undefined],0 - jne jump_offset_ok - add eax,dword [org_origin] - adc edx,dword [org_origin+4] - lea ebx,[edi+2] - sub eax,ebx - sbb edx,0 - mov bl,[value_type] - or bl,bl - je jump_offset_ok - test bl,1 - jnz invalid_use_of_symbol - cmp bl,[labels_type] - jne invalid_use_of_symbol - mov [value_type],0 - mov ecx,[symbol_identifier] - cmp ecx,[org_symbol] - je jump_offset_ok - mov [value_type],3 - jump_offset_ok: + add edi,2 + call calculate_relative_offset + sub edi,2 ret check_for_short_jump: cmp [jump_type],1 @@ -3610,7 +3593,7 @@ cmps_instruction: or bl,ch jnz invalid_address mov al,[segment_register] - push ax bx + push eax ebx lods byte [esi] cmp al,',' jne invalid_operand @@ -3623,7 +3606,7 @@ cmps_instruction: jnz invalid_address or bl,ch jnz invalid_address - pop dx ax + pop edx eax cmp [segment_register],1 ja invalid_address mov [segment_register],al @@ -3954,7 +3937,7 @@ basic_486_instruction: cmp al,'[' jne invalid_operand call get_address - push edx bx cx + push edx ebx ecx lods byte [esi] cmp al,',' jne invalid_operand @@ -3965,7 +3948,7 @@ basic_486_instruction: lods byte [esi] call convert_register mov [postbyte_register],al - pop cx bx edx + pop ecx ebx edx mov al,ah cmp al,1 je basic_486_mem_reg_8bit @@ -4046,6 +4029,49 @@ cmpxchgx_instruction: cmpxchgx_store: call store_instruction jmp instruction_assembled +nop_instruction: + mov ah,[esi] + cmp ah,10h + je extended_nop + cmp ah,11h + je extended_nop + cmp ah,'[' + je extended_nop + stos byte [edi] + jmp instruction_assembled + extended_nop: + mov [base_code],0Fh + mov [extended_code],1Fh + mov [postbyte_register],0 + lods byte [esi] + call get_size_operator + cmp al,10h + je extended_nop_reg + cmp al,'[' + jne invalid_operand + call get_address + mov al,[operand_size] + or al,al + jz extended_nop_nosize + call operand_autodetect + extended_nop_store: + call store_instruction + jmp instruction_assembled + extended_nop_nosize: + cmp [error_line],0 + jne extended_nop_store + mov eax,[current_line] + mov [error_line],eax + mov [error],operand_size_not_specified + jmp extended_nop_store + extended_nop_reg: + lods byte [esi] + call convert_register + mov bl,al + mov al,ah + call operand_autodetect + call store_nomem_instruction + jmp instruction_assembled basic_fpu_instruction: mov [postbyte_register],al @@ -4472,9 +4498,10 @@ fcomip_instruction: stos word [edi] jmp instruction_assembled -mmx_instruction: +basic_mmx_instruction: mov [base_code],0Fh mov [extended_code],al + mmx_instruction: lods byte [esi] call get_size_operator cmp al,10h @@ -4573,7 +4600,7 @@ pextrw_instruction: call store_nomem_instruction jmp instruction_assembled mmx_imm8: - push bx cx edx + push ebx ecx edx mov [operand_size],0 lods byte [esi] cmp al,',' @@ -4586,7 +4613,7 @@ pextrw_instruction: jne invalid_operand call get_byte_value mov byte [value],al - pop edx cx bx + pop edx ecx ebx call store_instruction_with_imm8 jmp instruction_assembled mmx_nomem_imm8: @@ -5318,9 +5345,9 @@ sse_cmp_instruction: cmp al,[mmx_size] jne invalid_operand_size sse_cmp_size_ok: - push bx cx edx + push ebx ecx edx call get_nextbyte - pop edx cx bx + pop edx ecx ebx call store_instruction_with_imm8 jmp instruction_assembled sse_cmp_xmmreg_xmmreg: @@ -5482,6 +5509,40 @@ cvtsd2si_instruction: jne invalid_operand_size call operand_64bit jmp sse_reg + +ssse3_instruction: + mov [base_code],0Fh + mov [extended_code],38h + mov [supplemental_code],al + jmp mmx_instruction +palignr_instruction: + mov [base_code],0Fh + mov [extended_code],3Ah + mov [supplemental_code],0Fh + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_mmx_register + call make_mmx_prefix + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + call get_size_operator + cmp al,10h + je palignr_mmreg_mmreg + cmp al,'[' + jne invalid_operand + call get_address + jmp mmx_imm8 + palignr_mmreg_mmreg: + lods byte [esi] + call convert_mmx_register + mov bl,al + jmp mmx_nomem_imm8 amd3dnow_instruction: mov [base_code],0Fh mov [extended_code],0Fh @@ -5948,15 +6009,11 @@ get_address: jnz address_ok calculate_relative_address: call calculate_relative_offset - cmp byte [esi-1],']' - jne invalid_address mov [address_high],edx mov edx,[symbol_identifier] mov [address_symbol],edx mov edx,eax - mov ch,[value_type] mov bx,0FF00h - xor cl,cl address_ok: ret @@ -6051,8 +6108,16 @@ store_instruction_code: store_extended_code: mov al,[extended_code] stos byte [edi] + cmp al,38h + je store_supplemental_code + cmp al,3Ah + je store_supplemental_code instruction_code_ok: ret + store_supplemental_code: + mov al,[supplemental_code] + stos byte [edi] + ret store_nomem_instruction: test [postbyte_register],1000b jz nomem_reg_code_ok @@ -6373,7 +6438,8 @@ store_instruction: store_address_32bit_value: test ch,0F0h jz address_32bit_relocation_ok - mov al,2 + mov eax,ecx + shr eax,16 xchg [value_type],al mov ebx,[address_symbol] xchg ebx,[symbol_identifier] @@ -6387,7 +6453,8 @@ store_instruction: store_address_64bit_value: test ch,0F0h jz address_64bit_relocation_ok - mov al,4 + mov eax,ecx + shr eax,16 xchg [value_type],al mov ebx,[address_symbol] xchg ebx,[symbol_identifier] @@ -6403,8 +6470,8 @@ store_instruction: address_immediate_sib: test ch,not 44h jnz invalid_address_size - cmp [value_type],0 - jne address_immediate_sib_nosignextend + test ecx,0FF0000h + jnz address_immediate_sib_nosignextend test edx,80000000h jz address_immediate_sib_prefix_ok address_immediate_sib_nosignextend: @@ -6436,12 +6503,13 @@ store_instruction: shl cl,3 or al,cl stos byte [edi] - xchg [value_type],ch + shr ecx,16 + xchg [value_type],cl mov ebx,[address_symbol] xchg ebx,[symbol_identifier] mov eax,edx call mark_relocation - mov [value_type],ch + mov [value_type],cl mov [symbol_identifier],ebx stos dword [edi] ret