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

📄 prog15a.asm

📁 主要是8051源代码
💻 ASM
字号:
;  PROG15A - Passing Subroutine Parameters Via the Stack
;
;  This Application Increments a 16 bit value in a subroutine.  The value
;   to be incremented is passed and returned on the stack.
;
;  This Program uses a Pointer for accessing the Data on the Stack
;
;  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
;  Address 0 and 1 used for Temporary Values in "Increment" 

i EQU 044h                      ;  Define the 16 Bit Value to Increment

j EQU 043h                      ;  Eight bit Counter

;  Mainline
 org 0                          ;  Execution Starts Here

  ajmp   Mainline


Increment:                      ;  Increment the 16 bit value starting at
                                ;   "i"

  mov    A,SP                   ;  Load R0 To Point to the Start of the Parameters
  add    A,#0FDh                ;   Take 3 Away from the Start of the Parameter
  mov    R0,A

  inc    @R0                    ;  Increment the Low Byte of "i"

  cjne   @R0,#0,Inc_Skip        ;  If the Inc Result == 0

  inc    R0                     ;  Increment the Pointer to the Next Byte
  inc    @R0                    ;   Increment High Byte

Inc_Skip:

  ret                           ;  Return to caller


Mainline:                       ;  Mainline, Initialize "i" and then
                                ;   Increment it 32x

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

  mov    j,#32                  ;  Want to Increment the Number 32x

MLLoop:

  push   i                      ;  Save the Parameter for the call
  push   i+1
  acall  Increment              ;  Now, Increment "i"
  pop    i+1
  pop    i

  djnz   j,MLLoop               ;  Do 32x


Loop:                           ;  Loop Here Forever when Finished
  ajmp   Loop

⌨️ 快捷键说明

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