⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.cod

📁 模拟电梯程序
💻 COD
📖 第 1 页 / 共 2 页
字号:
	TITLE	C:\Documents and Settings\Administrator\桌面\07412 4 LIFT\control.c
	.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS	ENDS
$$SYMBOLS	SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS	ENDS
$$TYPES	SEGMENT BYTE USE32 'DEBTYP'
$$TYPES	ENDS
_TLS	SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS	ENDS
;	COMDAT _control
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _ChangeGoalFloor
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _ChangeCurrentFloor
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC	_StatusFloor
PUBLIC	_GoalFloor
PUBLIC	_Time
PUBLIC	_State
PUBLIC	_CurrentDirection
PUBLIC	_RunTime
_BSS	SEGMENT
_GoalFloor DD	01H DUP (?)
_Time	DD	01H DUP (?)
_BSS	ENDS
_DATA	SEGMENT
COMM	_hEggs:DWORD:064H
_DATA	ENDS
_BSS	SEGMENT
_State	DD	01H DUP (?)
_CurrentDirection DD 01H DUP (?)
_BSS	ENDS
_DATA	SEGMENT
COMM	_CountTime:DWORD
_StatusFloor DD	01H
_RunTime DD	01H
_DATA	ENDS
PUBLIC	_ChangeGoalFloor
PUBLIC	_ChangeCurrentFloor
PUBLIC	_control
EXTRN	_ControlCallPTR:DWORD
EXTRN	_ControlPausePTR:DWORD
EXTRN	_Deletenode:NEAR
EXTRN	_GetInput2:NEAR
EXTRN	_StartFlash:NEAR
EXTRN	_ControlFlash:NEAR
EXTRN	_Output:NEAR
EXTRN	__chkesp:NEAR
;	COMDAT _control
_TEXT	SEGMENT
_control PROC NEAR					; COMDAT

; 19   : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	83 ec 40	 sub	 esp, 64			; 00000040H
  00006	53		 push	 ebx
  00007	56		 push	 esi
  00008	57		 push	 edi
  00009	8d 7d c0	 lea	 edi, DWORD PTR [ebp-64]
  0000c	b9 10 00 00 00	 mov	 ecx, 16			; 00000010H
  00011	b8 cc cc cc cc	 mov	 eax, -858993460		; ccccccccH
  00016	f3 ab		 rep stosd

; 20   :      StartFlash();

  00018	e8 00 00 00 00	 call	 _StartFlash
$L52968:

; 21   :      while(1){

  0001d	b8 01 00 00 00	 mov	 eax, 1
  00022	85 c0		 test	 eax, eax
  00024	74 59		 je	 SHORT $L52969

; 22   :         Time++;  /*时间片加1*/ 

  00026	8b 0d 00 00 00
	00		 mov	 ecx, DWORD PTR _Time
  0002c	83 c1 01	 add	 ecx, 1
  0002f	89 0d 00 00 00
	00		 mov	 DWORD PTR _Time, ecx

; 23   : 		GetInput2(Time);

  00035	8b 15 00 00 00
	00		 mov	 edx, DWORD PTR _Time
  0003b	52		 push	 edx
  0003c	e8 00 00 00 00	 call	 _GetInput2
  00041	83 c4 04	 add	 esp, 4

; 24   :         ChangeCurrentFloor(&ControlPausePTR);

  00044	68 00 00 00 00	 push	 OFFSET FLAT:_ControlPausePTR
  00049	e8 00 00 00 00	 call	 _ChangeCurrentFloor
  0004e	83 c4 04	 add	 esp, 4

; 25   :         Deletenode(&ControlCallPTR);

  00051	68 00 00 00 00	 push	 OFFSET FLAT:_ControlCallPTR
  00056	e8 00 00 00 00	 call	 _Deletenode
  0005b	83 c4 04	 add	 esp, 4

; 26   :         ChangeGoalFloor(&ControlCallPTR);

  0005e	68 00 00 00 00	 push	 OFFSET FLAT:_ControlCallPTR
  00063	e8 00 00 00 00	 call	 _ChangeGoalFloor
  00068	83 c4 04	 add	 esp, 4

; 27   :         ControlFlash();

  0006b	e8 00 00 00 00	 call	 _ControlFlash

; 28   :         Output(&ControlPausePTR);

  00070	68 00 00 00 00	 push	 OFFSET FLAT:_ControlPausePTR
  00075	e8 00 00 00 00	 call	 _Output
  0007a	83 c4 04	 add	 esp, 4

; 29   : 	 }

  0007d	eb 9e		 jmp	 SHORT $L52968
$L52969:

; 30   : }

  0007f	5f		 pop	 edi
  00080	5e		 pop	 esi
  00081	5b		 pop	 ebx
  00082	83 c4 40	 add	 esp, 64			; 00000040H
  00085	3b ec		 cmp	 ebp, esp
  00087	e8 00 00 00 00	 call	 __chkesp
  0008c	8b e5		 mov	 esp, ebp
  0008e	5d		 pop	 ebp
  0008f	c3		 ret	 0
_control ENDP
_TEXT	ENDS
;	COMDAT _ChangeGoalFloor
_TEXT	SEGMENT
_startPtr$ = 8
_curruntPtr$ = -4
_ChangeGoalFloor PROC NEAR				; COMDAT

; 34   : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	83 ec 48	 sub	 esp, 72			; 00000048H
  00006	53		 push	 ebx
  00007	56		 push	 esi
  00008	57		 push	 edi
  00009	8d 7d b8	 lea	 edi, DWORD PTR [ebp-72]
  0000c	b9 12 00 00 00	 mov	 ecx, 18			; 00000012H
  00011	b8 cc cc cc cc	 mov	 eax, -858993460		; ccccccccH
  00016	f3 ab		 rep stosd

; 35   :     CALLPTR curruntPtr, tempPtr;
; 36   :     if(State==0){/*当电梯空闲时*/ 

  00018	83 3d 00 00 00
	00 00		 cmp	 DWORD PTR _State, 0
  0001f	75 23		 jne	 SHORT $L52976

; 37   :        if(GoalFloor==0){

  00021	83 3d 00 00 00
	00 00		 cmp	 DWORD PTR _GoalFloor, 0
  00028	75 15		 jne	 SHORT $L52979

; 38   :           if((*startPtr)!=NULL)/*当有呼叫请求时,将目标楼层定为呼叫请求*/

  0002a	8b 45 08	 mov	 eax, DWORD PTR _startPtr$[ebp]
  0002d	83 38 00	 cmp	 DWORD PTR [eax], 0
  00030	74 0d		 je	 SHORT $L52979

; 39   :              GoalFloor=(*startPtr)->CallFloor;

  00032	8b 4d 08	 mov	 ecx, DWORD PTR _startPtr$[ebp]
  00035	8b 11		 mov	 edx, DWORD PTR [ecx]
  00037	8b 42 04	 mov	 eax, DWORD PTR [edx+4]
  0003a	a3 00 00 00 00	 mov	 DWORD PTR _GoalFloor, eax
$L52979:

; 42   :     else{

  0003f	e9 cf 02 00 00	 jmp	 $L53042
$L52976:

; 43   :        if(State==1){/*当电梯停靠时*/ 

  00044	83 3d 00 00 00
	00 01		 cmp	 DWORD PTR _State, 1
  0004b	0f 85 00 02 00
	00		 jne	 $L52981

; 44   :           if((*startPtr)!=NULL){/*当有呼叫请求时*/ 

  00051	8b 4d 08	 mov	 ecx, DWORD PTR _startPtr$[ebp]
  00054	83 39 00	 cmp	 DWORD PTR [ecx], 0
  00057	0f 84 ef 01 00
	00		 je	 $L53023

; 45   :              curruntPtr=*startPtr;

  0005d	8b 55 08	 mov	 edx, DWORD PTR _startPtr$[ebp]
  00060	8b 02		 mov	 eax, DWORD PTR [edx]
  00062	89 45 fc	 mov	 DWORD PTR _curruntPtr$[ebp], eax

; 46   :              if(CurrentDirection==1){/*当电梯向上驶来*/

  00065	83 3d 00 00 00
	00 01		 cmp	 DWORD PTR _CurrentDirection, 1
  0006c	0f 85 eb 00 00
	00		 jne	 $L52984
$L52987:

; 47   :                 while(curruntPtr!=NULL){/*以最低的高于当前楼层的有向上呼叫或者目标的楼层为目标*/ 

  00072	83 7d fc 00	 cmp	 DWORD PTR _curruntPtr$[ebp], 0
  00076	74 34		 je	 SHORT $L52988

; 48   :                    if((curruntPtr->CallDirection==0||curruntPtr->CallDirection==1)
; 49   :                       &&curruntPtr->CallFloor>StatusFloor)

  00078	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  0007b	83 39 00	 cmp	 DWORD PTR [ecx], 0
  0007e	74 08		 je	 SHORT $L52990
  00080	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  00083	83 3a 01	 cmp	 DWORD PTR [edx], 1
  00086	75 19		 jne	 SHORT $L52989
$L52990:
  00088	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  0008b	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  0008e	3b 0d 00 00 00
	00		 cmp	 ecx, DWORD PTR _StatusFloor
  00094	7e 0b		 jle	 SHORT $L52989

; 50   :                       GoalFloor=curruntPtr->CallFloor;

  00096	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  00099	8b 42 04	 mov	 eax, DWORD PTR [edx+4]
  0009c	a3 00 00 00 00	 mov	 DWORD PTR _GoalFloor, eax
$L52989:

; 51   :                    curruntPtr=curruntPtr->Nextptr;

  000a1	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  000a4	8b 51 08	 mov	 edx, DWORD PTR [ecx+8]
  000a7	89 55 fc	 mov	 DWORD PTR _curruntPtr$[ebp], edx

; 52   :                 }

  000aa	eb c6		 jmp	 SHORT $L52987
$L52988:

; 53   :                 if(GoalFloor!=0){

  000ac	83 3d 00 00 00
	00 00		 cmp	 DWORD PTR _GoalFloor, 0
  000b3	74 52		 je	 SHORT $L52991

; 54   :                    curruntPtr=*startPtr;

  000b5	8b 45 08	 mov	 eax, DWORD PTR _startPtr$[ebp]
  000b8	8b 08		 mov	 ecx, DWORD PTR [eax]
  000ba	89 4d fc	 mov	 DWORD PTR _curruntPtr$[ebp], ecx
$L52994:

; 55   :                    while(curruntPtr!=NULL){

  000bd	83 7d fc 00	 cmp	 DWORD PTR _curruntPtr$[ebp], 0
  000c1	74 42		 je	 SHORT $L52995

; 56   :                       if((curruntPtr->CallDirection==1||curruntPtr->CallDirection==0)&&
; 57   :                          (curruntPtr->CallFloor>StatusFloor)&&(curruntPtr->CallFloor<GoalFloor))

  000c3	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  000c6	83 3a 01	 cmp	 DWORD PTR [edx], 1
  000c9	74 08		 je	 SHORT $L52997
  000cb	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  000ce	83 38 00	 cmp	 DWORD PTR [eax], 0
  000d1	75 27		 jne	 SHORT $L52996
$L52997:
  000d3	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  000d6	8b 51 04	 mov	 edx, DWORD PTR [ecx+4]
  000d9	3b 15 00 00 00
	00		 cmp	 edx, DWORD PTR _StatusFloor
  000df	7e 19		 jle	 SHORT $L52996
  000e1	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  000e4	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  000e7	3b 0d 00 00 00
	00		 cmp	 ecx, DWORD PTR _GoalFloor
  000ed	7d 0b		 jge	 SHORT $L52996

; 58   :                          GoalFloor=curruntPtr->CallFloor;

  000ef	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  000f2	8b 42 04	 mov	 eax, DWORD PTR [edx+4]
  000f5	a3 00 00 00 00	 mov	 DWORD PTR _GoalFloor, eax
$L52996:

; 59   :                       curruntPtr=curruntPtr->Nextptr;

  000fa	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  000fd	8b 51 08	 mov	 edx, DWORD PTR [ecx+8]
  00100	89 55 fc	 mov	 DWORD PTR _curruntPtr$[ebp], edx

; 60   :                    }

  00103	eb b8		 jmp	 SHORT $L52994
$L52995:

; 62   :                 else{

  00105	eb 51		 jmp	 SHORT $L53002
$L52991:

; 63   :                     GoalFloor=(*startPtr)->CallFloor;

  00107	8b 45 08	 mov	 eax, DWORD PTR _startPtr$[ebp]
  0010a	8b 08		 mov	 ecx, DWORD PTR [eax]
  0010c	8b 51 04	 mov	 edx, DWORD PTR [ecx+4]
  0010f	89 15 00 00 00
	00		 mov	 DWORD PTR _GoalFloor, edx

; 64   :                     curruntPtr=*startPtr;

  00115	8b 45 08	 mov	 eax, DWORD PTR _startPtr$[ebp]
  00118	8b 08		 mov	 ecx, DWORD PTR [eax]
  0011a	89 4d fc	 mov	 DWORD PTR _curruntPtr$[ebp], ecx
$L53001:

; 65   :                     while(curruntPtr!=NULL){

  0011d	83 7d fc 00	 cmp	 DWORD PTR _curruntPtr$[ebp], 0
  00121	74 35		 je	 SHORT $L53002

; 66   :                        if((curruntPtr->CallDirection==2||curruntPtr->CallDirection==0)&&
; 67   :                           (curruntPtr->CallFloor>GoalFloor))

  00123	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  00126	83 3a 02	 cmp	 DWORD PTR [edx], 2
  00129	74 08		 je	 SHORT $L53004
  0012b	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  0012e	83 38 00	 cmp	 DWORD PTR [eax], 0
  00131	75 1a		 jne	 SHORT $L53003
$L53004:
  00133	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  00136	8b 51 04	 mov	 edx, DWORD PTR [ecx+4]
  00139	3b 15 00 00 00
	00		 cmp	 edx, DWORD PTR _GoalFloor
  0013f	7e 0c		 jle	 SHORT $L53003

; 68   :                           GoalFloor=curruntPtr->CallFloor;

  00141	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  00144	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  00147	89 0d 00 00 00
	00		 mov	 DWORD PTR _GoalFloor, ecx
$L53003:

; 69   :                        curruntPtr=curruntPtr->Nextptr;

  0014d	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  00150	8b 42 08	 mov	 eax, DWORD PTR [edx+8]
  00153	89 45 fc	 mov	 DWORD PTR _curruntPtr$[ebp], eax

; 70   :                     }

  00156	eb c5		 jmp	 SHORT $L53001
$L53002:

; 73   :              else{/*当电梯向下驶来*/

  00158	e9 ef 00 00 00	 jmp	 $L53023
$L52984:

; 74   :                 curruntPtr=*startPtr;

  0015d	8b 4d 08	 mov	 ecx, DWORD PTR _startPtr$[ebp]
  00160	8b 11		 mov	 edx, DWORD PTR [ecx]
  00162	89 55 fc	 mov	 DWORD PTR _curruntPtr$[ebp], edx
$L53008:

; 75   :                 while(curruntPtr!=NULL){/*以最高的低于当前楼层的有向下呼叫或者目标的楼层为目标*/ 

  00165	83 7d fc 00	 cmp	 DWORD PTR _curruntPtr$[ebp], 0
  00169	74 35		 je	 SHORT $L53009

; 76   :                    if((curruntPtr->CallDirection==0||curruntPtr->CallDirection==2)
; 77   :                       &&curruntPtr->CallFloor<StatusFloor)

  0016b	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  0016e	83 38 00	 cmp	 DWORD PTR [eax], 0
  00171	74 08		 je	 SHORT $L53011
  00173	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  00176	83 39 02	 cmp	 DWORD PTR [ecx], 2
  00179	75 1a		 jne	 SHORT $L53010
$L53011:
  0017b	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  0017e	8b 42 04	 mov	 eax, DWORD PTR [edx+4]
  00181	3b 05 00 00 00
	00		 cmp	 eax, DWORD PTR _StatusFloor
  00187	7d 0c		 jge	 SHORT $L53010

; 78   :                       GoalFloor=curruntPtr->CallFloor;

  00189	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  0018c	8b 51 04	 mov	 edx, DWORD PTR [ecx+4]
  0018f	89 15 00 00 00
	00		 mov	 DWORD PTR _GoalFloor, edx
$L53010:

; 79   :                    curruntPtr=curruntPtr->Nextptr;

  00195	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  00198	8b 48 08	 mov	 ecx, DWORD PTR [eax+8]
  0019b	89 4d fc	 mov	 DWORD PTR _curruntPtr$[ebp], ecx

; 80   :                 }

  0019e	eb c5		 jmp	 SHORT $L53008
$L53009:

; 81   :                 curruntPtr=*startPtr;

  001a0	8b 55 08	 mov	 edx, DWORD PTR _startPtr$[ebp]
  001a3	8b 02		 mov	 eax, DWORD PTR [edx]
  001a5	89 45 fc	 mov	 DWORD PTR _curruntPtr$[ebp], eax

; 82   :                 if(GoalFloor!=0){

  001a8	83 3d 00 00 00
	00 00		 cmp	 DWORD PTR _GoalFloor, 0
  001af	74 4b		 je	 SHORT $L53012
$L53015:

; 83   :                    while(curruntPtr!=NULL){

  001b1	83 7d fc 00	 cmp	 DWORD PTR _curruntPtr$[ebp], 0
  001b5	74 43		 je	 SHORT $L53016

; 84   :                       if((curruntPtr->CallDirection==2||curruntPtr->CallDirection==0)&&
; 85   :                          (curruntPtr->CallFloor<StatusFloor)&&(curruntPtr->CallFloor>GoalFloor))

  001b7	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  001ba	83 39 02	 cmp	 DWORD PTR [ecx], 2
  001bd	74 08		 je	 SHORT $L53018
  001bf	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  001c2	83 3a 00	 cmp	 DWORD PTR [edx], 0
  001c5	75 28		 jne	 SHORT $L53017
$L53018:
  001c7	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  001ca	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  001cd	3b 0d 00 00 00
	00		 cmp	 ecx, DWORD PTR _StatusFloor
  001d3	7d 1a		 jge	 SHORT $L53017
  001d5	8b 55 fc	 mov	 edx, DWORD PTR _curruntPtr$[ebp]
  001d8	8b 42 04	 mov	 eax, DWORD PTR [edx+4]
  001db	3b 05 00 00 00
	00		 cmp	 eax, DWORD PTR _GoalFloor
  001e1	7e 0c		 jle	 SHORT $L53017

; 86   :                          GoalFloor=curruntPtr->CallFloor;

  001e3	8b 4d fc	 mov	 ecx, DWORD PTR _curruntPtr$[ebp]
  001e6	8b 51 04	 mov	 edx, DWORD PTR [ecx+4]
  001e9	89 15 00 00 00
	00		 mov	 DWORD PTR _GoalFloor, edx
$L53017:

; 87   :                       curruntPtr=curruntPtr->Nextptr;

  001ef	8b 45 fc	 mov	 eax, DWORD PTR _curruntPtr$[ebp]
  001f2	8b 48 08	 mov	 ecx, DWORD PTR [eax+8]
  001f5	89 4d fc	 mov	 DWORD PTR _curruntPtr$[ebp], ecx

; 88   :                    }

  001f8	eb b7		 jmp	 SHORT $L53015
$L53016:

; 90   :                 else{

  001fa	eb 50		 jmp	 SHORT $L53023
$L53012:

; 91   :                    GoalFloor=(*startPtr)->CallFloor;

  001fc	8b 55 08	 mov	 edx, DWORD PTR _startPtr$[ebp]
  001ff	8b 02		 mov	 eax, DWORD PTR [edx]
  00201	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  00204	89 0d 00 00 00
	00		 mov	 DWORD PTR _GoalFloor, ecx

; 92   :                    curruntPtr=*startPtr;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -