flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Macros to choose target CPU Goto page 1, 2, 3 Next |
Author |
|
revolution 03 Apr 2007, 11:41
Attached is a macro to help those people that might be programming for older CPU's. I have been using this macro from some time now with my 80286 systems. Especially, the jump code is very useful, ordinary fasm will "optimise" the long conditional jumps with prefixes that the old 286 doesn't support.
Using these macro's you can feel safe programming for any chosen architecture from 8086 up to EM64T (x64) without fear of accidentally including an unsupported instruction. I expect if you are making a program designed to run that supports a certain minimum specification that you can make use of these macro's when your test machine is actually more capable than what you want to support. eg. you might like to support from 80386 and up but your test machine is a P4. with a combination like this you might accidentally slip a bswap in your code and not realise until someone else runs it on their machine and your program crashes. Anyhow, I hope some of you might find this useful.
Last edited by revolution on 31 Aug 2010, 23:53; edited 3 times in total |
|||||||||||
03 Apr 2007, 11:41 |
|
vid 03 Apr 2007, 12:41
nice job, i will highlight this thread, and also include this to FASM package draft.
|
|||
03 Apr 2007, 12:41 |
|
vid 03 Apr 2007, 13:55
it is my try to create some package of useful FASM stuff we produce on board - macros, routines, libraries, include files/equates, examples...
I created example package demonstrating how it all could look like. It is targeted for win32, but packages for linux, linux-amd64, win64 etc... can be created aswell. http://board.flatassembler.net/topic.php?p=54538#54538 |
|||
03 Apr 2007, 13:55 |
|
LocoDelAssembly 03 Apr 2007, 20:35
Beautiful piece of code and very useful aswell
Thanks for sharing!! |
|||
03 Apr 2007, 20:35 |
|
vid 03 Apr 2007, 20:45
just a note: why do you call 64bit architecture EM64T and not AMD64? :]
|
|||
03 Apr 2007, 20:45 |
|
LocoDelAssembly 03 Apr 2007, 21:05
http://board.flatassembler.net/topic.php?t=4267
I don't know if the difference stills valid but Tomasz said there that EM64T supports 80-bit far jumps while AMD64 don't. Since ".EM64T" does not disable anything* then it can't be renamed to ".AMD64". *3DNow and Enhanced 3DNow are disabled by other macros by default (with posibility to re-enable those instruction sets). |
|||
03 Apr 2007, 21:05 |
|
pelaillo 03 Apr 2007, 21:42
Thanks for a very useful contribution!
|
|||
03 Apr 2007, 21:42 |
|
revolution 03 Apr 2007, 23:12
vid wrote: why do you call 64bit architecture EM64T and not AMD64? However, the macros can be altered for things like LAHF and SAHF etc. Let's discuss and try to make the macros better. |
|||
03 Apr 2007, 23:12 |
|
vid 03 Apr 2007, 23:30
yes, i think that you support both ".em64t" and "amd64". Links in thread loco mentioned should be useful.
Note that both of these should disable something, due to http://www.sandpile.org/post/msgs/20005265.htm |
|||
03 Apr 2007, 23:30 |
|
LocoDelAssembly 03 Apr 2007, 23:33
I think that since you define with precision the CPU type (defining not only ".pentium4" but ".pentium4prescott" also), the improvements should go in that way, exact CPU definition so the programmer will be warned if LAHF/SAHF is not supported by a particular CPU implementing EM64T. However I think that ".EM64T" SHOULD NOT be removed but instead adding ".IA32" and those ones allowing the programmer to use the full instruction set available for those arquitectures at the present time.
Intel has 90% of the market? Surely not where the dollar is expensive like where I live, here AMD has more than 10% for sure. |
|||
03 Apr 2007, 23:33 |
|
revolution 04 Apr 2007, 09:23
Thanks for your suggestions LocoDelAssembly and vid. I am happy to include these things. But do you have a suggestion as to what to name the LAHF/SAHF variants? Maybe: .EM64T_no_LAHF_SAHF and .EM64T_with_LAHF_SAHF? They are very long and ugly. Did Intel have an official name for the different processors. And also the same question applies for the AMD versions.
I incuded the prescott because it added the SSE3 instructions and there was a clear differece between the two processors. But the LAHF/SAHF thing is much more blurry as to when Intel changed the processors. Also, to note that I have not included the SSSE3 stuff either, i need to add that as well. |
|||
04 Apr 2007, 09:23 |
|
revolution 04 Apr 2007, 09:27
LocoDelAssembly wrote: Intel has 90% of the market? Surely not where the dollar is expensive like where I live, here AMD has more than 10% for sure. |
|||
04 Apr 2007, 09:27 |
|
MazeGen 04 Apr 2007, 10:21
revolution wrote: Thanks for your suggestions LocoDelAssembly and vid. I am happy to include these things. But do you have a suggestion as to what to name the LAHF/SAHF variants? Maybe: .EM64T_no_LAHF_SAHF and .EM64T_with_LAHF_SAHF? They are very long and ugly. Did Intel have an official name for the different processors. http://en.wikipedia.org/wiki/X86-64#Previously Intel released them with Pentium 4 G1 step. They give some codename to this stepping perhaps. |
|||
04 Apr 2007, 10:21 |
|
revolution 04 Apr 2007, 11:53
Something I just realised with the LAHF/SAHF problem is that these instructions are only marked invalid in 64bit mode (by hardware on earlier processors and by software on later processors) but are still valid in 32bit mode. This makes the macros more complicated to implement. eg.
Code: .EM64T_no_LAHF_SAHF use64 ;blah blah use32 lahf ;<-- oops the macros said this is invalid! Perhaps it might be best to cater to the lowest common denominator? i.e. disallow cmpxchg16b, lahf and sahf (this way your code works with both AMD and Intel) and allow the programmer to use them selectively by using at least one upper case character. The expectation is that if you put an upper case character in there to use the instruction then that means you already know what you are doing and have already prepared for any possible bad consequences. |
|||
04 Apr 2007, 11:53 |
|
LocoDelAssembly 04 Apr 2007, 14:09
With AMD it's a little hard because then always use the Athlon64 name but there are some cores that supports up to SSE3 (like Venice) while others supports only up to SSE2 (like New Castle). A possible sintax could be ".processor_name core=core_name", supposing that Prescott is the core name then it should be used like ".pentium4 core=prescott". The cores sometimes has revision numbers too but I don't remember any example of a core having more instructions in a revision than another, only bug fixes + extentions that has nothing to do with the instruction set.
About a list showing the differencies between cores I haven't got one, I'll try to find one and post it here. |
|||
04 Apr 2007, 14:09 |
|
vid 04 Apr 2007, 14:23
revolution: i think you should overload "use32" and "use64" directives.
|
|||
04 Apr 2007, 14:23 |
|
revolution 07 Apr 2007, 18:09
I have uploaded a new version at the top of this thread. I have added SSSE3, VME and 64bit_safe macros.
I have not yet decided upon how to handle the processor selection issue. There is a lot of variation among the processors and their associated instruction sets (especially the P4 and Xeon variants). So, for the meantime I have not changed that part. If you have a specific requirement then you will be best to manually use the specific instruction disable macros. I would appreciate if you have any suggestions about how to implement a nice way to select the different processors. However, the original purpose of these macros was not a fine grained selection of processor capabilities, so I think for the meantime the current would suffice in most situations. vid wrote: i think you should overload "use32" and "use64" directives. |
|||
07 Apr 2007, 18:09 |
|
LocoDelAssembly 09 Apr 2007, 14:12
I found some info in the wikipedia for the Ahtlon64 series http://en.wikipedia.org/wiki/Athlon_64
About Intel I'm not familiar with the core names so I can't do a google search like I did with AMD which gave me the link to the wikipedia. However, looking at http://www.intel.com/products/processor/pentium4/specs.htm# seems that they don't give a new core name when something is instroduced, just a part number... This is so frustrating that I think the best way will be enabling just the instruction set of the first processor model and then enabling extra instructions separately. For example, not enable SSE3 with ".Athlon64" until some option/macro call says otherwise. |
|||
09 Apr 2007, 14:12 |
|
revolution 09 Apr 2007, 22:47
LocoDelAssembly wrote: For example, not enable SSE3 with ".Athlon64" until some option/macro call says otherwise. Thanks LocoDelAssembly, I see you also find it somewhat frustrating to properly pin down the core/name/instructions matching. I think your suggestion above is good but how to implement it in a nice way without making the whole thing ugly? |
|||
09 Apr 2007, 22:47 |
|
Goto page 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.