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

📄 prog14.asm

📁 主要是8051源代码
💻 ASM
字号:
;  PROG14 - Passing Subroutine Parameters via the Bank Registers
;
;  This Application Increments the 16 bit value in a subroutine.  Note that
;   There are two Increment Subroutines, One Increments the value and returns
;   It, the Other Increments an Index to the value.
;
;  This program will run in the UMPS simulator for a DS80C320.
;
;  Myke Predko
;  98.02.12
;
;  Hardware Notes:
;   This program is only meant to run on the Simulator

;  Variable Declarations
i EQU 020h                      ;  Define the 16 Bit Value to Increment

j EQU 022h			;  Want to see the Value Roll

;  Mainline
 org 0                          ;  Execution Starts Here

  mov    i,#0F0h                ;  Initialize it to 0x012F0
  mov    i+1,#012h

  mov	 j,#16			;  Want to Increment 32 Times

MLLoop:

  mov    R0,i                   ;  Load up the 16 Bit Value for Incrementing
  mov    R1,i+1
  acall  Increment              ;  Now, Increment R0/R1
  mov    i+1,R1                 ;  Return the Incremented Values
  mov    i,R0

  mov    R0,#i                  ;  Increment the Pointer to the Value
  acall  Increment_Ptr

  djnz	 j,MLLoop		;  Keep Looping Around


Loop:                           ;  Loop Here Forever when Finished
  ajmp   Loop


Increment:                      ;  Increment the 16 bit value in "R0"/"Ri"

  inc    R0                     ;  Increment the Low Byte of "i"

  cjne	 R0,#0,Inc_Skip		;  Was the Result == 0?
  inc    R1                     ;  The Low Byte is == 0, Increment High Byte
Inc_Skip:

  ret                           ;  Return to caller

Increment_Ptr:                  ;  Increment the Index to the 16 Bit Value

  inc    @R0                    ;  Increment the Low 8 Bits of the Value

  cjne   @R0,#0,IP_Skip
  inc    R0                     ;  Increment the High 8 Bits of the Number
  inc    @R0
  dec    R0
IP_Skip:

  ret

⌨️ 快捷键说明

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