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

📄 prog2a.asm

📁 主要是8051源代码
💻 ASM
字号:
;  PROG2 - Arithmetic Operations
;
;  This Application, using the Accumulator ("A") and the Bank Registers
;   Demonstrates various Arithmetic Operations.
;
;  Myke Predko
;  98.01.30
;
;  Hardware Notes:
;   This program is only meant to run on the Simulator

;  Variable Declarations
;   R0, R1 and R2 Used as Variables

;  Macro Declarations

MACRO csub(Parm)
  clr     C
  subb    A,Parm
ENDMAC

;  Mainline
 org 0                          ;  Execution Starts Here

;  Initialize Registers

  mov    R0,#137                ;  Load Bank Register R0 with 137

  mov    R1,#33                 ;  Load Bank Register R1 with 33

  mov    R2,#86                 ;  Load Bank Register R2 with 86

;  Execute the Data Processing Instructions

  mov    A,R1                   ;  A = 33
  add    A,R0                   ;  A = A + 137
                                ;    = 170 (0AAh)

  add    A,R2                   ;  170 + 86 = 256, A = 0, C and OV Flags Set


  mov    A,R2                   ;  86 - 33 = 53, Positive Result
  clr    C                      ;   NOTE: Clear Carry Explicitly
  subb   A,R1

  csub(R2)

  csub(#12)

  subb   A,R2                   ;  A = 53 - 86 = -33
                                ;    NOTE: Carry was Reset from Previous Operation

  mov    A,R2                   ;  Repeat first subtraction without clearing Carry
  subb   A,#33                  ;   Result = 86 - 33 - (c) = 52


  mov    A,R1                   ;  Now, Do Multiplication
  mov    B,R1
  mul    AB                     ;  Do 33 Squared with:
                                ;   High Byte of Result in B
                                ;   Low Byte of Result in A

  mov    A,R2                   ;  Get Mod 10 of 86
  mov    B,#10
  div    AB                     ;  Result in "A", Remainder in "B"


  xrl    A,R0                   ;  XOR the Bits with Values in other Registers

  rlc    A                      ;  Shift the Value in Accumulator 1x to the
                                ;   left and put the previous Carry Value in
                                ;   Bit 0 and Load Carry with Bit 7

  rr     A                      ;  Shift the Value in the Accumulator to the
                                ;   Right, but avoid the Carry Flag

  swap   A                      ;  Swap the Nybbles in the Accumulator

Loop:                           ;  Loop Here Forever when Finished
  ajmp   Loop

⌨️ 快捷键说明

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