|
|
|
[求助]百鸡问题
至于公鸡为什么比母鸡贵我就不知道了 这是书里面的题目 |
|
|
|
[讨论]DEV C++中初学者编程 共同学习者顶起来
#include "math.h" #include "stdio.h" main() { double s; int a; float b=3.14,c; scanf("%d",&a); s=pow(a,2)*b; c=(s*1000-(int)(s*1000))*1000; printf("%f\n",c); c=(int)c; printf("%f\n",c); if (c<5) s=s; else s=s+0.01; printf("%0.2f",s); fflush(stdin); getchar(); } |
|
恳请高手回答我的问题,请相信在此之前,我已在网上找了无数答案,苦想了许多天仍不能弄懂,怕以请高手们给详细地说说
引用: 最初由 wulfalone发布 恳请高手回答我的问题,请相信在此之前,我已在网上找了无数答案,苦想了许多天仍不能弄懂,怕以请高手们给详细地说说 我在学汇编语言,可每本书都到CPU执行一条命令过程说得不清不楚,差不多都是这样说的:“8086机中,任意时刻,CPU将CS:IP指向的内容当作指令执行,取一条指令后,IP中的值自动增加,以使CPU可以读取下一条指令”。我就不明白了,既然“任意时刻,CPU将CS:IP指向的内容当作指令执行,取一条指令后,IP中的值自动增加,以使CPU可以读取下一条指令”,那我们为什么还可以用debug调试程度,在用debug调试程序时,CS:IP里的值不应该是指向debug的下一条指令吗?为什么我们还可以看到原程序执行时CS:IP里面的值?还有CPU如何知道CS:IP指向的命令有多长,应该读入多少字节的数据?搞了好久都没有想明白, 一、为什么可以调试? re: 请参考4楼phrain、14楼SJQIANG的回复。我再重复一下4楼的,比如设置断点,大体上是这样的: 1. 在地址x的指令上设置断点:调试器(如windows的windbg,linux的gdb)把内存中x地址处的原始指令保存起来,然后把x地址的指令改为调试中断int 3 2. 调试器开始调试被调试程序:调试器把自己注册到系统,这样系统遇到调试中断时,知道该通知谁 3. cpu执行到x地址,因为该指令是int 3,所以触发调试中断:调试中断被系统处理,通知当前的调试器。 调试器处理此中断,调整显示信息,响应后续的用户请求 4. 用户选择单步跟踪或者其他方式继续执行:调试器把被调试程序的x地址处的调试中断指令,恢复为原始指令(在第1步已保存),让cpu继续运行。 其他还有单步跟踪、内存数据读写访问断点等,步骤与上述有差别,但是基本原理都是类似的,就是利用调试中断。 所以,为什么能调试? 首先,需要cpu支持:能够触发调试中断,调试中断时的现场需要保留下来,供中断处理函数读取。这方面,可以找cpu的芯片资料来了解。 其次,需要操作系统支持:能够允许应用程序(如windbg、gdb)把自己注册为调试器;能够在cpu触发调试中断时,把中断时的现场数据从cpu中得到,然后通知已注册的调试器。windows、linux等操作系统应该都提供了一些API,供第三方开发调试器使用。 二、cpu如何知道IP指向的命令有多长? re: 请参考2楼SJQIANG、4楼phrain的回复。 另,虽然8086指令是不定长的,但是也有不少其它cpu是定长指令集。 具体的,可以参考各种不同cpu的芯片资料,会有cpu取指步骤的详细描述。 |
|
|
|
[讨论]DEV C++中初学者编程 共同学习者顶起来
for(x=0;x<10;x++) { printf("%d",a[x]); } fflush(stdin); getchar(); 这个是干什么用的??? 不要这个行不? |
|
|
|
|
|
|
|
|
|
|
|
[讨论]DEV C++中初学者编程 共同学习者顶起来
老师真棒哈!!谢谢!!! |
|
|
|
[讨论]DEV C++中初学者编程 共同学习者顶起来
#include "stdio.h" main() { int i,j,n; scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n-j;j++) printf(" "); for(j=1;j<=2*n-1;j++) printf("*"); printf("\n"); } for(i=1;i<=n;i++) { for(j=1;j<=i-j;j++) printf(" "); for(j=1;j<=2*n+1-2*i;j++) printf("*"); } getchar(); getchar(); getchar(); } |
|
[讨论]DEV C++中初学者编程 共同学习者顶起来
老师真棒!!! |
|
[讨论]DEV C++中初学者编程 共同学习者顶起来
#include "stdio.h" main() { int s,i,n; s=3,i=2,n=0; while(n<=21) {s=s+i; i=s-i; n++; } printf("%d",s); getchar(); } |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值