简体   繁体   English

如何在C编译器的ASM输出中启用DIV指令

[英]How to enable the DIV instruction in ASM output of C compiler

I am using vbcc compiler to translate my C code into Motorola 68000 ASM. 我正在使用vbcc编译器将C代码转换为Motorola 68000 ASM。

For whatever reason, every time I use the division (just integer, not floats) in code, the compiler only inserts the following stub into the ASM output (that I get generated upon every recompile): 无论出于什么原因,每次我在代码中使用除法(只是整数,而不是浮点数)时,编译器都只会在ASM输出中插入以下存根(我在每次重新编译时都会生成):

public  __ldivs
jsr __ldivs

I explicitly searched for all variations of DIVS/DIVU, but every single time, there is just that stub above. 我明确搜索了DIVS / DIVU的所有变体,但是每次都只有一个存根。 The code itself works (I debugged it on target device), so the final code does have the DIV instruction, just not the intermediate output. 代码本身可以工作(我在目标设备上对其进行了调试),因此最终代码的确具有DIV指令,而没有中间输出。

Since this is the most expensive instruction and it's in an inner loop, I really gotta experiment with tweaking the code to get the max performance of it. 由于这是最昂贵的指令,并且处于内部循环中,因此我真的必须尝试调整代码以使其发挥最大性能。

However, I can't do it if I don't see the resulting ASM code. 但是,如果看不到生成的ASM代码,则无法执行。 Any ideas how to enable it ? 任何想法如何启用它? The compiler manual does not specify anything like that, so there must clearly must be some other - probably common - higher principle in play ? 编译器手册中未指定类似的内容,因此显然必须在起作用​​吗?

From the vbcc compiler system manual by Volker Barthelmann: 从Volker Barthelmann 撰写的vbcc编译器系统手册中:

4.1 Additional options 4.1其他选项

This backend provides the following additional options: 该后端提供以下附加选项:
  • -cpu=n Generate code for cpu n (eg -cpu=68020), default: 68000. -cpu=n生成cpu n的代码(例如-cpu = 68020),默认值:68000。
... ...

4.5 CPUs 4.5个CPU

The values of -cpu=n have those e?ffects: -cpu=n的值具有以下效果:
... ...
n>=68020
  • 32bit multiplication/division/modulo is done with the mul?.l, div?.l and div?ll instructions. 32位乘法/除法/模是通过mul?.l,div?.l和div?ll指令完成的。

The original 68000 CPU didn't have support for 32-bit divides, only 16-bit division, so by default vbcc doesn't generate 32-bit divide instructions. 原始的68000 CPU不支持32位除法,仅支持16位除法,因此默认情况下,vbcc不会生成32位除法指令。

Basically your question doesn't even belong here. 基本上,您的问题甚至都不属于这里。 You're asking about the workings of your compiler not the 68K cpu family. 您是在问编译器的工作原理,而不是68K cpu系列的问题。

Since this is the most expensive instruction and it's in an inner loop, I really gotta experiment with tweaking the code to get the max performance of it. 由于这是最昂贵的指令,并且处于内部循环中,因此我真的必须尝试调整代码以使其发挥最大性能。

Then you are already fighting windmills. 那你已经在和风车战斗了。 Chosing an obscure C compiler while at the same time desiring top performance are conflicting goals. 选择晦涩难懂的C编译器,同时又希望获得最佳性能,这是相互矛盾的目标。

If you really need MC68000 code compatibility, the choice of C is questionable. 如果您确实需要MC68000代码兼容性,则选择C值得怀疑。 Since the 68000 has zero cache, store/load orgies that simple C compilers tend to produce en masse, have a huge performance impact. 由于68000的缓存为零,简单的C编译器往往会大量产生存储/加载逻辑,因此会对性能产生巨大影响。 It lessens considerably for the higher members and may become invisible on the superscalar pipelined ones (erm, one; the 68060). 对于较高的成员,它会大大减少,并且在超标量流水线的成员(erm,其中之一; 68060)上可能会变得不可见。

Switch to 68020 code model if target platform permits, and switch compiler if you're not satisfied with your current one. 如果目标平台允许,请切换到68020代码模型,如果对当前版本不满意,请切换到编译器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM