📄 main.lst
字号:
C51 COMPILER V6.23a MAIN 11/06/2002 10:00:18 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c LARGE 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
6 #ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
9 /* is enabled */
10 #define N 10
11
12 /*------------------------------------------------
13 The main C function. Program execution starts
14 here after stack initialization.
15 ------------------------------------------------*/
16 void main (void) {
17 1
18 1 void input(int arr[],int n);/*函数声明*/
19 1 void sort(int *ptr,int n);
20 1 void output(int arr[],int n);
21 1 int a[N],*p;/*定义一维数组和指针变量*/
22 1
23 1 /*------------------------------------------------
24 1 Setup the serial port for 1200 baud at 16MHz.
25 1 ------------------------------------------------*/
26 1 #ifndef MONITOR51
27 1 SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
28 1 TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
29 1 TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */
30 1 TR1 = 1; /* TR1: timer 1 run */
31 1 TI = 1; /* TI: set TI to send first char of UART */
32 1 #endif
33 1 /*------------------------------------------------
34 1 Note that an embedded program never exits (because
35 1 there is no operating system to return to). It
36 1 must loop and execute forever.
37 1 ------------------------------------------------*/
38 1 input(a,N) ;/*数据输入函数调用,实参a 是数组名*/
39 1 p = a ;/*指针变量指向数组的首地址*/
40 1 sort(p,N) ;/*排序,实参p 是指针变量*/
41 1 output(p,N) ;/*输出,实参p 是指针变量*/
42 1 while (1) {};
43 1 }
44 void input(int arr[],int n)/*无需返回值的输入数据函数定义,形参a r r 是数组*/
45 {
46 1 int i;
47 1 printf("input data:\n");
48 1 for( i = 0 ; i < n ; i++ )/*采用传统的下标法*/
49 1 scanf( "%d" , &arr[i] ) ;
50 1 }
51 void sort(int *ptr,int n)/*冒泡排序,形参p t r 是指针变量*/
52 {
53 1 int i,j,t;
54 1 for( i = 0 ; i < n - 1 ; i++ )
55 1 for( j = 0 ; j < n - 1 - i ; j++ )
C51 COMPILER V6.23a MAIN 11/06/2002 10:00:18 PAGE 2
56 1 if (*(ptr+j)>*(ptr+j+1))/*相临两个元素进行比较*/
57 1 {
58 2 t = * (ptr+ j ) ;/*两个元素进行交换*/
59 2 *(ptr+ j ) = * (ptr +j+1) ;
60 2 *(ptr+ j + 1 ) = t ;
61 2 }
62 1 }
63 void output(int arr[],int n)/*数据输出*/
64 {
65 1 int *ptr=arr;/*利用指针指向数组的首地址*/
66 1 printf("output data:\n");
67 1 for( ; ptr-arr<n ; ptr++ )/*输出数组的n 个元素*/
68 1 printf("%4d",*ptr) ;
69 1 printf("\n");
70 1 }
71
72
73
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 641 ----
CONSTANT SIZE = 36 ----
XDATA SIZE = ---- 49
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
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 + -