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

📄 prog15.asm

📁 包括了各种常用的8051单片机的程序
💻 ASM
字号:
;  PROG15 - 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 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"

  pop    3                      ;  Pop the Return Address to Access the Values
  pop    4

  pop    1                      ;  Load the 16 Bit Counter into the Bank
  pop    0                      ;   Storage Registers

  inc    0                      ;  Increment the Low Byte of "i"

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

  inc    1                      ;   Increment High Byte

Inc_Skip:

  push   0                      ;  Store the Values Back Onto the Stack
  push   1

  push   4                      ;  Restore the Program Counter
  push   3

  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 + -