keil有bug吗?我怎么不能单步调试?进来看看!

2020-01-30 14:05发布

写了很简单的一个程序,但是查看了反汇编之后,那个函数根本就没有对应的汇编,我设置断点之后,在stepin进去,直接就出来函数了,难道keil有bug?

这是主程序:
void data_tst();

void main()

{
        uint i = 0;
        i = sizeof(uint);
        data_tst();
}

void data_tst(void)
{
        uint temp = 0,yy = 0;
        temp = sizeof(uchar);
        yy = sizeof(uint);
}
下面上图:


我调试时候的图片 (原文件名:keil.JPG)


当单步进入data_tst()函数的时候,汇编是:
C:0x0013    020016   LJMP     data_tst(C:0016)
但是再继续往下执行时 下一条指令是:
C:0x0016    22       RET      
直接就返回了,那我写的函数语句呢???
再往下执行就是 :
C:0x0017    00       NOP      
C:0x0018    00       NOP
C:0x0019    00       NOP
C:0x001A    00       NOP

难道是我的keil版本的问题??



我的keil版本 (原文件名:keil_version.JPG)


大家有遇到过这个问题吗?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
23条回答
ohmytime
1楼-- · 2020-01-31 17:13
回复【12楼】tcp1985 你是不是党员
-----------------------------------------------------------------------

多谢了!我去看看!
lcq007
2楼-- · 2020-01-31 17:27
 精彩回答 2  元偷偷看……
skystalker
3楼-- · 2020-01-31 17:44
可以在要设断点的函数前加上
#ifdef DEBUG
#pragma OT(3)
#endif
括号里填优化等级,这里是3,这样DEBUG的时候就很方便啦

下面是KEIL的详细说明

OPTIMIZE Compiler Directive
Abbreviation OT

Arguments A decimal number between 0 and 11 enclosed in parentheses optionally followed by SIZE or SPEED to specify code size or execution speed emphasis.

Default OPTIMIZE (8, SPEED)

µVision Options — C51 — Code Optimization.

Description The OPTIMIZE directive sets the optimization level and emphasis the Cx51 Compiler uses when generating object code.

Level Description
0 Constant Folding: The compiler performs calculations that reduce expressions to numeric constants, where possible. This includes calculations of run-time addresses.

Simple Access Optimizing: The compiler optimizes access of internal data and bit addresses in the 8051 system.

Jump Optimizing: The compiler always extends jumps to the final target. Jumps to jumps are eliminated.
1 Dead Code Elimination: Unused code fragments and artifacts are eliminated.

Jump Negation: Conditional jumps are closely examined to see if they can be streamlined or eliminated by the inversion of the test logic.
2 Data Overlaying: Data and bit segments suitable for static overlay are identified and internally marked. The BL51 Linker/Locator has the capability, through global data flow analysis, of selecting segments which can then be overlaid.
3 Peephole Optimizing: Redundant MOV instructions are removed. This includes unnecessary loading of objects from the memory as well as load operations with constants. Complex operations are replaced by simple operations when memory space or execution time can be saved.
4 Register Variables: Automatic variables and function arguments are located in registers when possible. Reservation of data memory for these variables is omitted.

Extended Access Optimizing: Variables from the IDATA, XDATA, PDATA and CODE areas are directly included in operations. Intermediate registers are frequently unnecessary.

Local Common Subexpression Elimination: The compiler detects multiple uses of the same expression or subexpression. The result of the first expression is saved and reused when possible. Superfluous expression calculations are eliminated from the code.

Case/Switch Optimizing: Code involving switch and case statements is optimized using jump tables or jump strings.

Simple Loop Optimizing: Program loops that fill a memory range with a constant are converted and optimized.
5 Global Common Subexpression Elimination: Identical subexpressions within a function are calculated only once when possible. The intermediate result is stored in a register and reused.
6 Loop Rotation: Program loops are rotated if the resulting program code is faster and more efficient. The loop expression of for and while loops is evaluated once at the top of the loop and then at the bottom of the loop. This optimization generates more code but speeds up execution.
7 Extended Index Access Optimizing: DPTR is used for register variables where appropriate. Pointer and array access are optimized for both execution speed and code size.
8 Common Tail Merging: When there are multiple calls to a single function, some of the setup code can be reused, thereby reducing program size.
9 Common Block Subroutines: Recurring instruction sequences are detected and converted into subroutines. The Cx51 Compiler rearranges code to obtain larger recurring sequences.
10 Rearrange Code (Linker Optimization): When detecting common block subroutines, code is rearranged to obtain larger recurring sequences.
11 Reuse of Common Exit Code (Linker Optimization): Identical exit sequences are reused. This may reduce the size of common block subroutines even further. This optimization level generates the most compact program code possible.

Note

Each higher optimization level contains all of the characteristics of the preceding lower optimization level. For example, OPTIMIZE level 9 includes all optimizations of levels 0 to 8.
You may change the optimizer level on a function-by-function basis as needed. For example:
#pragma OT(3)
void funct_1 (void)
{
...
}

#pragma OT(9)
void func_2 (void)
{
...
}

See Also OBJECTADVANCED

Example C51 SAMPLE.C OPTIMIZE (9)

C51 SAMPLE.C OPTIMIZE (0)

#pragma ot(6, SIZE)

#pragma ot(size)
fwluck
4楼-- · 2020-01-31 21:04
keil的这个功能确实不好用。伤的次数太多了。
ohmytime
5楼-- · 2020-01-31 21:23
回复【16楼】fwluck
keil的这个功能确实不好用。伤的次数太多了。
-----------------------------------------------------------------------

你是说哪个方面?volatile吗?
chengying
6楼-- · 2020-01-31 23:58
学习了,伤不起

一周热门 更多>