Data copy program (ASM) of MCS51 microcontroller

Publisher:SereneMeadowLatest update time:2023-08-30 Source: eefocusKeywords:MCS51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Data copy program (ASM) of MCS51 microcontroller

;Internal RAM data copy program
; Entry: R0, R7
; Occupied resources: A
; Stack requirement: 2 bytes
; Exit: R1


IBMOV    :MOV    A,R0
          ADD    A,R7
          MOV    R0,A
          MOV    A,R1
          ADD    A,R7
          MOV    R1,A
IBM1     :DEC    R0
          DEC    R1
          MOV    A,@R0
          MOV    @R1,A
          DJNZ   R7,IBM1
          RET

;External RAM data copy program
; Entry: ADDPH, ADDPL, R7
; Occupied resources: ACC
; Stack requirement: 2 bytes
; Exits: R0, R1

EBMOV1   :MOV    A,ADDPL
          ADD    A,R7
          MOV    DPL,A
          CLR    A
          ADDC   A,ADDPH
          MOV    DPH,A
          MOV    A,R7
          ADD    A,R1
          XCH    A,R0
          ADDC   A,#00H
          MOV    P2,A
EBM11    :DEC    R0
          CJNE   R0,#0FFH,EBM12
          DEC    P2
EBM12    :DEC    DPL
          MOV    A,DPL
          CJNE   A,#0FFH,EBM13
          DEC    DPH
EBM13    :MOVX   A,@R0
          MOVX   @DPTR,A
          DJNZ   R7,EBM11
          RET

;External RAM data copy program
; Entry: ADDPH, ADDPL, R6, R7
; Occupied resources: ACC
; Stack requirement: 2 bytes
; Exit: R0, R1

EBMOV2   :MOV    A,ADDPL
          ADD    A,R7
          MOV    DPL,A
          MOV    A,R6
          ADDC   A,ADDPH
          MOV    DPH,A
          MOV    A,R7
          ADD    A,R1
          XCH    A,R0
          ADDC   A,R6
          MOV    P2,A
          MOV    A,R7
          JZ     EBM21
          INC    R6
EBM21    :DEC    R0
          CJNE   R0,#0FFH,EBM22
          DEC    P2
EBM22    :DEC    DPL
          MOV    A,DPL
          CJNE   A,#0FFH,EBM23
          DEC    DPH
EBM23    :MOVX   A,@R0
          MOVX   @DPTR,A
          DJNZ   R7,EBM21
          DJNZ   R6,EBM21
          RET

;Copy external RAM data to internal RAM program
; Entry: ADDPH, ADDPL, R7
; Occupied resources: ACC
; Stack requirement: 2 bytes
; Exit: R0

ITEMOV  :MOV    A,ADDPL
         ADD    A,R7
         MOV    DPL,A
         MOV    A,ADDPH
         ADDC   A,#00H
         MOV    DPH,A
         MOV    A,R0
         ADD    A,R7
         MOV    R0,A
ITEM1   :DEC    R0
         DEC    DPL
         MOV    A,DPL
         CJNE   A,#0FFH,ITEM2
         DEC    DPH
ITEM2   :MOVX   A,@DPTR
         MOV    @R0,A
         DJNZ   R7,ITEM1
         RET


Keywords:MCS51 Reference address:Data copy program (ASM) of MCS51 microcontroller

Previous article:Analysis on the method of realizing PWM output function in MCS-51 series microcontroller
Next article:MCS-51 microcontroller driver based on K9F5608A

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号