如何使用Keil仿真环境查看CPU类型字长?【worldsing笔记】

笔者上次写了如何用IAR查CPU的字长和数据类长度的方法:点击这里查看

今天试着在Keil MDK 5.0 里查看CPU的字长和数据类长度,打开一个已有的工程,编译并进入Debug,如图1.1所示:

 image

                                             图1.1 Keil 进入Debug仿真

打开Watch窗口,View->Watch Windows->Watch 1,点击<Enter expression>并输入sizeof(int),如图1.2所示,但是发现Value栏无法显示出来,不管是输入是sizeof(int)还是sizeof(char) 最后的Type栏都显示uchar

image

                                        图1.2 Watch 查看变量

看来只能用代码来测试了,同样的方法将定义的类型变量长度放到Watch窗口来看,图1.3所示

char CharTypeLen   = sizeof(char);
     char uCharTypeLen  = sizeof(unsigned char);
     char ShortTypeLen  = sizeof(short);
     char uShortTypeLen = sizeof(unsigned short);
     char IntTypeLen    = sizeof(int);
     char uIntTypeLen   = sizeof(unsigned int);
     char LongTypeLen   = sizeof( long);
     char uLongTypeLen  = sizeof(unsigned long);
     char lLongTypeLen  = sizeof(long long);
     char FloatTyepLen  = sizeof(float);
     char DoubleTypeLen = sizeof(double);

image

                                                     图1.3 代码测法

 

原文地址:https://www.cnblogs.com/worldsing/p/3454774.html