This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how can choose

This is a function that i wrote using assembly:

;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;NAME:    clearXdataNBytes
;FUNCTION:
;         This functioin clear n bytes in the external ;space starting with the address specified
;PARAMETERS:
;         B(unsigned byte)---the numbers of bytes to ;be cleared!
;         DPTR(unsigned word)---the starting address
;RETURNS: None!
;PROLOGUE       BY      CALLING:
;    PUSH DPL,PUSH ;DPH,PUSH B,MOV DPTR,#startAddr,MOV ;B,#nbytes!
;EPILOG BY CALLING:NONE!
;NOTES:   The MAX number of bytes to be cleared is 255!And,we use A as temporary variables!There is no check if the external space pointed by DPTR is legal!
;EXAMPLES:
; ...
; //Prologue:
; PUSH  DPL
; PUSH  DPH
; PUSH  B
; //Move the parameters
; MOV   DPTR,#startAddr
; MOV   B,#200
; //Call this function
; LCALL clearXdataNBytes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
clearXdataNBytes:

          PUSH      ACC
          CLR       A
clearXdataNBytes_LOOP:
          MOVX      @DPTR,A
          INC       DPTR
          DJNZ      B,LOOP

          POP       ACC
          POP       B
          POP       DPH
          POP       DPL

          RET


well,about
PUSH ACC
CLR A
...
POP ACC
POP B
POP DPH
POP DPL

if i call this function in a loop,it seems that these codes are executed repeatedly,and it seems that it's an overhead in my system?Is that possible or is there some wrong thinking?How can i solve it?!

Parents
  • Not if you follow the stated Prologue:

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;NAME:    clearXdataNBytes
    ;FUNCTION:
    ;         This functioin clear n bytes in the external
    ;         space starting with the address specified
    ;PARAMETERS:
    ;         B(unsigned byte)---the numbers of bytes to ;be cleared!
    ;         DPTR(unsigned word)---the starting address
    ;RETURNS: None!
    ;PROLOGUE       BY      CALLING:
    ;    PUSH DPL,PUSH ;DPH,PUSH B,MOV DPTR,#startAddr,MOV ;B,#nbytes!
    ;EPILOG BY CALLING:NONE!
    ;NOTES:   The MAX number of bytes to be cleared is 255...
    ;EXAMPLES:
    ; ...
    ; //Prologue:
    ; PUSH  DPL
    ; PUSH  DPH
    ; PUSH  B
    ; //Move the parameters
    ; MOV   DPTR,#startAddr
    ; MOV   B,#200
    ; //Call this function
    ; LCALL clearXdataNBytes
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    

Reply
  • Not if you follow the stated Prologue:

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;NAME:    clearXdataNBytes
    ;FUNCTION:
    ;         This functioin clear n bytes in the external
    ;         space starting with the address specified
    ;PARAMETERS:
    ;         B(unsigned byte)---the numbers of bytes to ;be cleared!
    ;         DPTR(unsigned word)---the starting address
    ;RETURNS: None!
    ;PROLOGUE       BY      CALLING:
    ;    PUSH DPL,PUSH ;DPH,PUSH B,MOV DPTR,#startAddr,MOV ;B,#nbytes!
    ;EPILOG BY CALLING:NONE!
    ;NOTES:   The MAX number of bytes to be cleared is 255...
    ;EXAMPLES:
    ; ...
    ; //Prologue:
    ; PUSH  DPL
    ; PUSH  DPH
    ; PUSH  B
    ; //Move the parameters
    ; MOV   DPTR,#startAddr
    ; MOV   B,#200
    ; //Call this function
    ; LCALL clearXdataNBytes
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    

Children