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

📄 dcm44m.a51

📁 8051实时操作系统
💻 A51
字号:
;***************************************************************************

;*

;*     TITLE:          iDCM 44 COMMUNICATIONS FIRMWARE: MACRO MODULE

;*

;*     RELEASE:        2.0

;*

;*     DESCRIPTION:    THIS MODULE CONTAINS THE MACRO PROCEDURES

;*

;*     UPDATES:

;*

;***************************************************************************

;*         

;*           COPYRIGHT 1983, 1986 INTEL CORPORATION

;*

;*           INTEL CORPORATION PROPRIETARY INFORMATION.  THIS LISTING

;*           IS SUPPLIED UNDER THE TERMS OF A LICENSE  AGREEMENT WITH

;*           INTEL CORPORATION  AND MAY NOT  BE COPIED NOR  DISCLOSED

;*           EXCEPT IN  ACCORDANCE WITH THE  TERMS OF THAT AGREEMENT.

;* 

;***************************************************************************



$EJECT

;***************************************************************************

;*

;*     MACRO:          enqueue_message

;*

;*     PURPOSE:        enqueue serial message stores a message in the output 

;*                     queue for later transmission.

;*

;*     CALLED BY:      send_serial

;*

;*     CALLS:          None

;*

;*     INPUTS:         QUEUE_PTR:      Either S_Queue_Ptr or O_Queue_Ptr

;*                     Msg_Ptr:        R0

;*

;*     MODIFIES:       QUEUE_PTR:      Either S_Queue_Ptr or O_Queue_Ptr

;*

;*     DESTROYS:       R1, A

;*

;*     RETURNS:        Nothing

;*

;*     DESCRIPTION:    enqueue_message runs down the S_Queue linked

;*                     list until a message link is found whose value is 0.

;*                     That message, or the S_Queue_Ptr itself, is set to

;*                     the location of the message's link field (low byte).

;*                     the message's link field (low byte) is set to 0.

;*

;*     REGISTER BANK:  Independent

;*

;***************************************************************************



%*DEFINE (enqueue_message_def(QUEUE_PTR))

    LOCAL enqueue_message eq_find_end (



%enqueue_message:



        MOV     @R0, #0                         ;Set the new messages high

                                                ; byte of the link

                                                ;  field to zero

        MOV     A, #%QUEUE_PTR                  ;get address of header



%eq_find_end:



        MOV     R1, A                           ;get location of next message

        MOV     A, @R1                          ;get link of next message

        JNZ     %eq_find_end                    ;If not zero then get

                                                ;  do again

        

        MOV     A, R0

        MOV     @R1, A                          ;Set the last link field to

                                                ;  point to the new message's

                                                ;  link field

)



$EJECT

;***************************************************************************

;*

;*     MACRO:          dequeue_message

;*

;*     PURPOSE:        dequeue serial message takes a message from the output

;*                     queue for transmission.

;*

;*     CALLED BY:      output_interrupt_check

;*

;*     CALLS:          None

;*

;*     INPUTS:         QUEUE_PTR:      Either S_Queue_Ptr or O_Queue_Ptr

;*

;*     MODIFIES:       QUEUE_PTR:      Either S_Queue_Ptr or O_Queue_Ptr

;*

;*     DESTROYS:       A, R0

;*

;*     RETURNS:        Msg_Ptr:  A

;*

;*     DESCRIPTION:    remove first message from linked list defined by

;*                     QUEUE_PTR (Either S_Queue_Ptr or O_Queue_Ptr, update the

;*                     header to the next entry, if any, and return message

;*                     properly offset.

;*

;*     REGISTER BANK:  0

;*

;***************************************************************************



%*DEFINE (dequeue_message_def(QUEUE_PTR))

    LOCAL dequeue_message de_no_message (



%dequeue_message:



        MOV     A, %QUEUE_PTR

        JZ      %de_no_message

        MOV     R0, A

        MOV     %QUEUE_PTR, @R0

        

%de_no_message:



)



$EJECT

;***************************************************************************

;*

;*     MACRO:          enqueue_poll_station

;*

;*     PURPOSE:        Put a station into the poll list

;*

;*     CALLED BY:      Station Message Swap

;*

;*     CALLS:          None

;*

;*     INPUTS:         station_address in STAD

;*

;*     MODIFIES:       S_Poll_Queue_In

;*                     S_Poll_Queue_Out

;*                     S_Station_Poll (STAD)

;*

;*     DESTROYS:       DPTR, A

;*

;*     RETURNS:        None

;*

;*     DESCRIPTION:    The polling queue is logically a queue of

;*                     station addresses where each station in the

;*                     queue is to be polled for information.  Physically,

;*                     the queue is created by linking elements of

;*                     an array, S_Station_Poll, into a singly-linked

;*                     list.  Each entry of the array is one byte, and

;*                     its index represents the associated station

;*                     address.  Byte(0) and Byte(0FFH) are not used.

;*                     S_Station_Poll is located on a 256 byte boundary

;*                     such that the DPL register can be used as index

;*                     and station address.  The queue ends are referenced

;*                     via S_Poll_Queue_In (most recent) and S_Poll_Queue_Out

;*                     (least recent).  These on-chip data bytes contain the

;*                     indices (station addresses) for the most recent and

;*                     least recent members of the queue, respectively.  If

;*                     the queue is empty, then their values are zero.

;*                     The queue is back-linked, meaning that the pointers

;*                     (pointer => array index => station address) point

;*                     from least recently entered stations to more recently

;*                     entered stations.

;*

;*                     Procedure checks the polling queue in pointer for

;*                     a non-zero value.  If so then the queue is not

;*                     empty and the STAD'th location in the poll station

;*                     array (S_Station_Poll) is set to zero, the location

;*                     pointed to by S_Poll_Queue_In pointer and the

;*                     S_Poll_Queue_In pointer itself are set to

;*                     point to the STAD'th location.  If the queue is empty,

;*                     then the S_Poll_Queue_Out pointer is set to

;*                     point to the STAD'th location also.

;*

;*     REGISTER BANK:  Independent

;*

;***************************************************************************



%*DEFINE (enqueue_poll_station_def) LOCAL enqueue_poll_station

                                          eps_not_empty

                      eps_end

(

%enqueue_poll_station:



        MOV     DPTR, #s_station_poll   ;get external poll base

        MOV     A, S_Poll_Queue_Out     ;check for empty queue  

        JNZ     %eps_not_empty          ;if not empty, jump    

                                        ;Queue is empty,

        MOV     S_Poll_Queue_Out, STAD  ;set up out pointers to

        MOV     S_Poll_Queue_In, STAD   ;point to one and only entry

        SJMP    %eps_end                ;

%eps_not_empty:

        MOV   A,s_poll_queue_in         ;Is the station already enqueued?

        XRL   A,STAD                    ;

        JZ    %eps_end                  ;If so, branch out

        MOV   DPL,STAD                  ;

        MOVX  A,@DPTR                   ;

        JNZ   %eps_end                  ;If so, branch out

	    MOV	DPL, S_Poll_Queue_In		;Else, get last entry in queue

	    MOV   A,STAD                    ;Get current STAD

	    MOVX	@DPTR, A                ;set back link

	    MOV	S_Poll_Queue_In,A           ;set new last entry

%eps_end:

)

        

$EJECT

;***************************************************************************

;*

;*     MACRO:          dequeue_poll_station

;*

;*     PURPOSE:        Take a station from the poll list

;*

;*     CALLED BY:      Non_auto_information_receive

;*

;*     CALLS:          None

;*

;*     INPUTS:         None

;*

;*     MODIFIES:       S_Poll_Queue_In

;*                     S_Poll_Queue_Out

;*                     S_Station_Poll (STAD)

;*

;*     DESTROYS:       A, DPTR

;*

;*     RETURNS:        None

;*

;*     DESCRIPTION:    See "Enqueue_Poll_Station" for a description of

;*                     the Poll Queue structure and usage.

;*

;*                     Dequeue_Poll_Station checks for a empty queue, i.e.

;*                     S_Poll_Queue_In = S_Poll_Queue_Out.  If so, the

;*                     rest is skipped.  Otherwise, the out pointer,

;*                     S_Poll_Queue_Out is set to the index (station

;*                     address) referenced by the array entry to which

;*                     S_Poll_Queue_Out points.  If that index is zero,

;*                     then the queue is now empty, and the S_Poll_Queue_In

;*                     pointer is set to zero also.

;*

;*     REGISTER BANK:  Independent

;*

;***************************************************************************



%*DEFINE (dequeue_poll_station_def) LOCAL dequeue_poll_station

(

%dequeue_poll_station:



        MOV     DPTR, #s_station_poll   ;get external poll stack base

        MOV     DPL, S_Poll_Queue_Out   ;get first entry

        MOVX    A, @DPTR                ;

        MOV     S_Poll_Queue_Out, A     ;set new first entry

        CLR     A                       ;Clear dequeued entry

        MOVX    @DPTR,A                 ;

        MOV     A, DPL                  ;get dequeued entry



)

        

%*DEFINE (set_msg_ptr(offset))

(
%'

%' Point to a specified field within a message

%' Inputs: r0 = the address of the beginning of the message

%'         %offset = the offset of the desired field

%' Output: r1 = the absolute address of the specified message

%' 

%' Note: It is assumed that the message is in internal RAM space.

%' 

    mov     a,r0                     ;a => message

    add     a,#%offset               ;a => message.offset

    mov     r1,a                     ;r1 => message.offset

)

⌨️ 快捷键说明

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