📄 ex15.lst
字号:
C51 COMPILER V6.02 EX15 09/15/2002 22:22:16 PAGE 1
C51 COMPILER V6.02, COMPILATION OF MODULE EX15
OBJECT MODULE PLACED IN .\ex15.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\ex15.c DEBUG OBJECTEXTEND
stmt level source
1 #include <REG52.H> /* special function register declarations */
2 /* for the intended 8051 derivative */
3
4 #include <stdio.h> /* prototype declarations for I/O functions */
5 #include <math.h>
6
7 #ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
10 /* is enabled */
11
12
13 /*------------------------------------------------
14 The main C function. Program execution starts
15 here after stack initialization.
16 ------------------------------------------------*/
17 void main (void) {
18 1
19 1 float a,b,c,s,x1,x2;
20 1 double t;
21 1 /*------------------------------------------------
22 1 Setup the serial port for 1200 baud at 16MHz.
23 1 ------------------------------------------------*/
24 1 #ifndef MONITOR51
25 1 SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
26 1 TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
27 1 TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */
28 1 TR1 = 1; /* TR1: timer 1 run */
29 1 TI = 1; /* TI: set TI to send first char of UART */
30 1 #endif
31 1 /*------------------------------------------------
32 1 Note that an embedded program never exits (because
33 1 there is no operating system to return to). It
34 1 must loop and execute forever.
35 1 ------------------------------------------------*/
36 1 printf(" please input a,b,c:");
37 1 scanf("%f %f %f ",&a,&b,&c) ;
38 1 if(a==0.0)
39 1 if(b!=0.0)
40 1 printf("the root is :%f\n",-c/b);
41 1 else if(c==0.0)
42 1 printf("x is inexactive\n ");
43 1 else
44 1 printf("no root!\n");
45 1 else
46 1 {
47 2 s=b*b-4*a*c;
48 2 if(s>=0.0)
49 2 if(s>0.0)
50 2 {
51 3 t=sqrt(s);
52 3 x1=-0.5*(b+t)/a;
53 3 x2=-0.5*(b-t)/a;
54 3 // printf("There are two different roots:%f and %f\n",x1,x2);
55 3 printf("There are two different roots:%f and %f\n",x1,x2);
C51 COMPILER V6.02 EX15 09/15/2002 22:22:16 PAGE 2
56 3 }
57 2 else
58 2 printf("There are two equal roots:%f\n",-0.5*b/a);
59 2 else
60 2 {
61 3 t=sqrt(-s) ;
62 3 x1=-0.5*b/a; /*实部*/
63 3 x2=abs(0.5*t/a); /*虚部的绝对值*/
64 3 printf("There are two virtual roots:");
65 3 printf("%f+i%f\t\t%f-i%f\n",x1,x2,x1,x2 );
66 3 }
67 2 }
68 1 while (1) {};
69 1 }
70
71
72
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 657 ----
CONSTANT SIZE = 192 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 28
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -