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

📄 dcm44r.a51

📁 8051实时操作系统
💻 A51
📖 第 1 页 / 共 3 页
字号:
; 

;---------------------------------------------------------------------------



c_ext_update_io:

    jb      c_protect_mode,p_error_return   ;if rac protect is in effect

    mov     a,r6                            ;if no data to update, exit

    jz      c_ext_update_io_exit            ;

    mov     dph,#ext_io_page                ;dph => i/o area



c_ext_update_io_loop:

    mov     dpl,@r1                         ;dptr => abs. i/o address

    inc     r1                              ;write next i/o byte from msg.

    mov     a,@r1                           ;

    movx    @dptr,a                         ;

    movx    a,@dptr                         ;read back i/o byte into msg.

    mov     @r1,a                           ;

    inc     r1                              ;r1 => next i/o offset addr.

    djnz    r6,c_ext_update_io_loop         ;check for more items



c_ext_update_io_exit:

    ajmp    local_gateway_switch            ;return message



;---------------------------------------------------------------------------

; 

;   Entries:        ext_or_io, ext_and_io, and ext_xor_io

; 

;   Purpose:        Perform logical operation on bytes of i/o memory

;                   and return message

; 

;   Entered From:   process_rac_cmd

; 

;   Calls:          none

; 

;   Enters:         local_gateway_switch    (msg_ptr in R0)

; 

;   Inputs:         message pointer in R0

;                   data pointer in R1

;                   data count in R6

; 

;   Returns:        None

; 

;   Description:    Computes number of or, and, or xor requests, reads the

;                   specified external memory locations, performs a logical

;                   op on the value with the message data, writes

;                   to the specified external memory location, and 

;                   returns the results in the reply message.

; 

;---------------------------------------------------------------------------



%*define(ext_logical_io (op)) local log_op_loop log_op_exit

(

%'

%' This macro is used for or-ing, and-ing, and xor-ing bytes of data

%' into i/o ports.

%' Input: %op = or | anl | xrl 

%'

    jb      c_protect_mode,p_error_return   ;if rac protect is in effect

    mov     a,r6                            ;if no data to update, exit

    jz      %log_op_exit                    ;

    mov     dph,#ext_io_page                ;dph => i/o area



%log_op_loop:

    mov     dpl,@r1                         ;dptr => abs. i/o address

    inc     r1                              ;write next i/o byte from msg.

    movx    a,@dptr                         ;read i/o byte

    %op     a,@r1                           ;perform logical operation on i/o

    movx    @dptr,a                         ;

    movx    a,@dptr                         ;read back byte from port

    mov     @r1,a                           ;and place in message

    inc     r1                              ;r1 => next i/o offset addr.

    djnz    r6,%log_op_loop                 ;check for more items



%log_op_exit:

    ajmp    local_gateway_switch            ;return message

)



c_ext_or_io:

    %ext_logical_io(orl)                    ;perform or-io rac function



c_ext_and_io:

    %ext_logical_io(anl)                    ;perform and-io rac function



c_ext_xor_io:

    %ext_logical_io(xrl)                    ;perform xor-io rac function



p_error_return:

; Rac-Protect error return routine

; Inputs: r1 => message.data

;

    dec     r1                              ;r1 => message.reply

    mov     b,#e_rac_protected              ;

    ajmp    c_error_return                  ;



;---------------------------------------------------------------------------

; 

;   Entry Point:   int_read

; 

;   Purpose:        read bytes of internal memory and return message

; 

;   Entered From:   process_rac_cmd

; 

;   Calls:          none

; 

;   Enters:         local_gateway_switch    (msg_ptr in R0)

; 

;   Inputs:         message pointer in R0

;                   data pointer in R1

;                   data count in R6

; 

;   Returns:        None

; 

;   Description:    Computes number of read requests, reads the

;                   specified internal memory locations, and 

;                   returns the results in the reply message.

; 

;---------------------------------------------------------------------------



c_int_read:

    jb      c_protect_mode,p_error_return   ;if rac protect is in effect

    mov     a,r6                            ;if no bytes to read, exit

    jz      c_int_read_exit                 ;

    mov     b,r0                            ;save msg ptr in b



c_int_read_repeat:

    mov     ar0,@r1                         ;r0 => byte to be read

    mov     a,@r0                           ;a =  read byte

    inc     r1                              ;r1 => next msg. data space

    mov     @r1,a                           ;write data into msg. data space

    inc     r1                              ;r1 => next msg. addr. value

    djnz    r6,c_int_read_repeat            ;check for more items



    mov     r0,b                            ;restore msg ptr to r0

c_int_read_exit:

    ajmp    local_gateway_switch            ;return message to sender



 

;---------------------------------------------------------------------------

; 

;   Entry Point:   int_write

; 

;   Purpose:        write bytes of internal memory and return message

; 

;   Entered From:   process_rac_cmd

; 

;   Calls:          none

; 

;   Enters:         local_gateway_switch    (msg_ptr in R0)

; 

;   Inputs:         message pointer in R0

;                   data pointer in R1

;                   data count in R6

; 

;   Returns:        None

; 

;   Description:    Computes number of write requests, writes the

;                   specified internal memory locations, and 

;                   returns the results in the reply message.

; 

;---------------------------------------------------------------------------



c_int_write:

    jb      c_protect_mode,p_error_return   ;if rac protect is in effect

    mov     a,r6                            ;if no bytes to write, exit

    jz      c_int_write_exit                ;

    mov     b,r0                            ;save msg ptr in b



c_int_write_repeat:

    mov     ar0,@r1                         ;r0 => address to be written to

    inc     r1                              ;r1 => next value to be written

    mov     a,@r1                           ;a = value to be written

    mov     @r0,a                           ;write value to int. mem.

    inc     r1                              ;r1 => next msg. addr. value

    djnz    r6,c_int_write_repeat           ;check for more items



    mov     r0,b                            ;restore msg ptr to r0

c_int_write_exit:

    ajmp    local_gateway_switch            ;return message to sender



 

;---------------------------------------------------------------------------

; 

;   Entry Point:   ext_upload_data, ext_upload_code

; 

;   Purpose:        ext_upload_data uploads bytes of external data memory

;                   and returns the message.

;                   ext_upload_code uploads bytes of code memory and returns

;                   the message

; 

;   Entered From:   process_rac_cmd

; 

;   Calls:          none

; 

;   Enters:         local_gateway_switch    (msg_ptr in R0)

; 

;   Inputs:         message pointer in R0

;                   data pointer in R1

;                   data count in R7

; 

;   Returns:        None

; 

;   Description:    Computes number of upload requests, reads the

;                   specified external memory locations, and 

;                   returns the results in the reply message.

; 

;---------------------------------------------------------------------------



c_upload_data:

    clr     b.0                             ;indicate upload ext mem op

    sjmp    c_upload                        ;go upload



c_upload_code:

    setb    b.0                             ;indicate upload code mem op

;   sjmp    c_upload                        ;go upload



c_upload:  

    jb      c_protect_mode,p_error_return   ;if rac protect is in effect

    %jlt(r7,#3,c_ext_upload_exit)           ;if no data to upload, exit

    dec     r7                              ;compute # of iterations

    dec     r7                              ;r7 = # of iterations

    mov     dph,@r1                         ;Set upload start location

    inc     r1                              ;

    mov     dpl,@r1                         ;

        

c_ext_upload_repeat:

    inc     r1                              ;r1 => next data entry

    jb      b.0,move_in_code                ;if uploading code, jump



    movx    a,@dptr                         ;move in next ext data byte

    sjmp    upload_mdata                    ;



move_in_code:

    clr     a                               ;move in next code byte

    movc    a,@a+dptr                       ;



upload_mdata:

    mov     @r1,a                           ;upload data to message  

    inc     dptr                            ;increment to next address

    djnz    r7,c_ext_upload_repeat          ;check for more items



c_ext_upload_exit:

    ajmp    local_gateway_switch            ;return message



 

;---------------------------------------------------------------------------

; 

;   Entry Point:   ext_dnload_data, ext_dnload_code

; 

;   Purpose:        dnload bytes of external memory and return message

;                   ext_dnload_code adds a ~20msec delay between 

;                   byte writes.  This is for downloading code into e2prom.

; 

;   Entered From:   process_rac_cmd

; 

;   Calls:          none

; 

;   Enters:         local_gateway_switch    (msg_ptr in R0)

; 

;   Inputs:         message pointer in R0

;                   data pointer in R1

;                   data count in R7

; 

;   Returns:        None

; 

;   Description:    Computes number of dnload requests, writes the

;                   specified external memory locations, and 

;                   returns the results in the reply message.

; 

;---------------------------------------------------------------------------



c_dnload_data:

    clr     b.0                             ;clear code flag

    sjmp    c_dnload                        ;go execute dnload routine



c_dnload_code:

    setb    b.0                             ;set code flag

;   sjmp    c_dnload                        ;go execute dnload routine



c_dnload:    

    jb      c_protect_mode,p_error_return   ;if rac protect off, jump

    %jlt(r7,#3,c_ext_dnload_exit)           ;if no data to dnload, exit

    dec     r7                              ;

    dec     r7                              ;r7 = # of dnload iterations

    mov     dph,@r1                         ;set external data location

⌨️ 快捷键说明

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