flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > registers algebra engine Goto page Previous 1, 2 |
Author |
|
revolution 25 Jun 2010, 16:54
What do you propose to replace it?
|
|||
25 Jun 2010, 16:54 |
|
LocoDelAssembly 25 Jun 2010, 18:06
Why a new thread for this was needed when you reported the same thing in the sticky post? ( http://board.flatassembler.net/topic.php?t=11611 )
If you want, I can merge this thread into your older one. |
|||
25 Jun 2010, 18:06 |
|
LocoDelAssembly 25 Jun 2010, 18:37
Merge done.
|
|||
25 Jun 2010, 18:37 |
|
Tomasz Grysztar 25 Jun 2010, 20:34
ouadji wrote: Most of the time, Tomasz has very difficult to admit there is a problem ... When you call some choices that were substantial in the design of fasm the "problems", you're certainly looking for some other assembler. Feel free to make a fork, but I'm going to stay with my principles. |
|||
25 Jun 2010, 20:34 |
|
Tomasz Grysztar 25 Jun 2010, 21:03
Tomasz Grysztar wrote:
|
|||
25 Jun 2010, 21:03 |
|
ouadji 25 Jun 2010, 23:20
Nothing to do with "shorter" or "longer". It's only a question of compliance with the code requested. With a asm compiler, no opcode should be unattainable or banned. You talk about principles ... i think respect the code requested by the programmer is the first principle ! A compiler must be an evolving program, the designer must be listening to users ... especially when the comments are correct. This is a pity ... Fasm is a very good compiler and few things could make it perfect !... but you seem to refuse any ideas of change and improvement. Many people use Fasm, It is unfortunate to note that its designer does not take into consideration the comments and requests from users. Don't forget that without the users, fasm would not exist ! Thank you very much |
|||
25 Jun 2010, 23:20 |
|
ouadji 26 Jun 2010, 13:38
my first patch. This patch handles the difference between "reg+reg" and "reg* 2" It seems to give very good results, I still have not noticed errors with 32bits code. Code: EXPRESSI.INC ;patch = (A)+(B) ------------- ..... sib_allowed: or bh,bh jnz check_index_scale cmp cl,2 je reg2_ ;<---------- (A) "reg2_" instead of "special_index_scale" cmp cl,3 je special_index_scale cmp cl,5 je special_index_scale cmp cl,9 je special_index_scale check_index_scale: or cl,cl jz check_immediate_address cmp cl,1 je check_immediate_address cmp cl,2 je check_immediate_address cmp cl,4 je check_immediate_address cmp cl,8 je check_immediate_address jmp invalid_address reg2_: cmp byte[edi+1Eh],1 ;+(B) jne check_immediate_address ;+ special_index_scale: mov bh,bl dec cl check_immediate_address: mov al,[address_size] and al,0Fh ..... Last edited by ouadji on 29 Jun 2010, 13:27; edited 5 times in total |
|||
26 Jun 2010, 13:38 |
|
Tomasz Grysztar 26 Jun 2010, 13:42
ouadji wrote: With a asm compiler, no opcode should be unattainable or banned. As for the EBP*2 problem, the only real problem I see there is the ambiguity of the default segment register used for addressing. In flat mode it doesn't really matter and you can leave to assembler to choose whatever form (again: the shortest one possible). But when you are working in segmented mode, the ambiguity caused by this approach might be a problem - thus you'd need to use segment prefix just to be on the safe side (and force assembler to choose an encoding that uses this default segment). However the problem might be considered marginal (solution is: use segment override when feel unsure about what segment will be used, fasm still is going to choose the shortest form, possibly without a segment prefix) and does not justify for me getting rid of the register algebra, which a substantial feature of fasm's internal. If you got rid of it, the pieces of code like this one would no longer work: Code: virtual at EBP-100h some_structure MY_STRUC some_parames sizeof.some_structure = $ - some_structure ouadji wrote: It is unfortunate to note that its designer does not take into consideration the comments and requests from users. ouadji wrote: Don't forget that without the users, fasm would not exist ! |
|||
26 Jun 2010, 13:42 |
|
ouadji 26 Jun 2010, 13:56
sorry if I was a bit "direct" in my comments. Again, "Fasm" is a wonderfull and very good compiler. congratulations ! I agree with you on all of your message. just above a small fix for this "problem". and if you prefer don't change this, ok ! (Sorry for my bad english) |
|||
26 Jun 2010, 13:56 |
|
ouadji 29 Jun 2010, 23:48
Please Tomasz, could you look at this, thank you. I think I found an interesting idea to solve this problem with "ebp". the problem occurs only with the Registry ebp/rbp, and only with an result multiplier of 2. 1) with any registers exept ebp/rbp, priotity to "reg+reg", like "FASM" works currently! 2) with ebp/rbp, by default ... give priority to the form with "reg*reg" inc dword [ebp+ebp+ebp-ebp] ... it will be compiled like this : inc dword [ebp*2] In this case, if no segment register is specified, then this is the segment register "DS" which is used by default by the processor. 3) with ebp/rbp, If we want to use the segment register "SS" instead of "DS" ! In this case, we will ask that by specifying the register " SS" like this : Code: inc dword [ss:ebp+ebp+ebp-ebp] BUT, A) in this case, the priority will be given to the form with "+" B) and we will cancel the request to add the prefix "ss". Indeed, with the form with "+", the segment register used by default is already the register "ss"! Code: summary of these two cases (with ebp/rbp) ---------------------------------------- by default : inc dword [ebp+ebp+ebp-ebp] ==> inc dword [ebp*2] ; "ds" by default if we want "SS" : inc dword [ss:ebp+ebp+ebp-ebp] ==> inc dword [ebp+ebp] ; without "ss:" because here,"ss" is by defaut !! this works fine. It's a easy and effective way to solve this problem. The code: Code: EXPRESSI.INC ------------ ..... sib_allowed: or bh,bh jnz check_index_scale cmp cl,2 jne no_two cmp bl,45h je ss__ cmp bl,85h jne special_index_scale; ---> any registre except ebp/rbp --> (reg + reg) ss__: cmp [segment_register],3 jne check_immediate_address ; ---> ebp/rbp but not "ss:" --> (reg * 2) mov [segment_register],0 jmp special_index_scale ; ---> ebp/rbp and "ss:" --> (reg + reg) ;and remove "ss" (useless) no_two: cmp cl,3 je special_index_scale ..... Code: results ------- inc dword[(eax+eax+eax-eax)] ; ==> [eax+eax] - ds by default inc dword[(ebp+ebp+ebp-ebp)] ; ==> [(ebp*2) + 00000000h] - ds by default inc dword[ss: (ebp+ebp+ebp-ebp)] ; ==> [ebp+ebp+00h] without "ss:" - ss by default |
|||
29 Jun 2010, 23:48 |
|
ouadji 01 Jul 2010, 15:19
NASM vs FASM (quick test) NASM ------ Code: inc dword [ebp+ebp] inc dword [ebp*2] inc dword [ebp+ebp+(ebp*3)-ebp-(ebp*2)] results ------- a) 0FFh, 44h, 2Dh, 00h b) 0FFh, 44h, 2Dh, 00h c) 0FFh, 44h, 2Dh, 00h FASM ------ Code: inc dword [ebp+ebp] inc dword [ebp*2] inc dword [ebp+ebp+(ebp*3)-ebp-(ebp*2)] results ------- a) 0FFh, 44h, 2Dh, 00h b) 0FFh, 44h, 2Dh, 00h c) 0FFh, 44h, 2Dh, 00h 0FFh, 44h, 2Dh, 00h == inc dword [ebp+ebp] NASM builds the same code as FASM, apparently, NASM has a algebra engine like FASM and makes exactly the same mistake ! (about "ss:") thus I keep Fasm, because fasm is nevertheless much better ! |
|||
01 Jul 2010, 15:19 |
|
revolution 01 Jul 2010, 15:57
Code: inc dword [ds:ebp+ebp] inc dword [ds:ebp*2] inc dword [ds:ebp+ebp+(ebp*3)-ebp-(ebp*2)] results ------- a) 0x3e,0xff,0x44,0x2d,0x00 b) 0x3e,0xff,0x44,0x2d,0x00 c) 0x3e,0xff,0x44,0x2d,0x00 inc dword [ss:ebp+ebp] inc dword [ss:ebp*2] inc dword [ss:ebp+ebp+(ebp*3)-ebp-(ebp*2)] results ------- a) 0xff,0x44,0x2d,0x00 b) 0xff,0x44,0x2d,0x00 c) 0xff,0x44,0x2d,0x00 |
|||
01 Jul 2010, 15:57 |
|
chaoscode 07 Jul 2010, 10:47
what about that:
do what the user enters, if it is possibile. (even it's not the best way.) if it's not possibile try to modify it. Example [ebp*2] -> [ebp*2] [ebp+ebp]-> [ebp+ebp] [ebp*3] not possibile, try to modifie it ( will result in [ebp*2+ebp]) |
|||
07 Jul 2010, 10:47 |
|
revolution 07 Jul 2010, 11:21
chaoscode wrote: what about that: |
|||
07 Jul 2010, 11:21 |
|
ouadji 07 Jul 2010, 11:56
add separately terms with +/- and terms with '*'. "ebp+ebp*2-ebp" +/- : +1 -1 = 0 * : +2 result : ebp*2 give priority to the positive term. (ebp*4)-ebp-ebp ---> (ebp*2) ebp+ebp+ebp+ebp-(ebp*2) ---> ebp+ebp |
|||
07 Jul 2010, 11:56 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.