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

📄 8×8位定点数乘法子程序(容量).txt

📁 实用子程序.rar本子程序库对《单片机应用程序设计技术》一书附录中的子程序库作了重大修订
💻 TXT
字号:
;*******************************************************************
;                   8x8 Software Multiplier
;               ( Code Efficient : Looped Code )
;*******************************************************************
;
;   The 16 bit result is stored in 2 bytes
;
; Before calling the subroutine " mpy ", the multiplier should
; be loaded in location " mulplr ", and the multiplicand in
; " mulcnd " . The 16 bit result is stored in locations
; H_byte & L_byte.
;
;       Performance :
;                       Program Memory  :  15 locations
;                       # of cycles     :  71
;                       Scratch RAM     :   0 locations
;
;  This routine is optimized for code efficiency ( looped code )
;  For time efficiency code refer to "mult8x8F.asm" ( straight line code )
;*******************************************************************
;
mulcnd  equ     20h      ; 8 bit multiplicand
mulplr  equ     21h      ; 8 bit multiplier
H_byte  equ     22h      ; High byte of the 16 bit result
L_byte  equ     23h      ; Low byte of the 16 bit result
count   equ     24h      ; loop counter
Same    equ     25h
;
;
    INCLUDE        p16f877.inc
;

	org     00
	goto    main

; *****************************         Begin Multiplier Routine
mpy_S   clrf    H_byte
	clrf    L_byte
	movlw   8
	movwf   count
	movf    mulcnd,w
	bcf     STATUS,C    ; Clear the carry bit in the status Reg.
loop    rrf     mulplr
	btfsc   STATUS,C
	addwf   H_byte,Same
	rrf     H_byte,Same
	rrf     L_byte,Same
	decfsz  count
	goto    loop
;
	retlw   0
;
;********************************************************************
;               Test Program
;*********************************************************************
main    movlw   0FF
	movwf   mulplr          ; multiplier (in mulplr) = 0FF
	movlw   0FF             ; multiplicand(W Reg )   = 0FF
	movwf   mulcnd
;
	call    mpy_S           ; The result 0FF*0FF = FE01 is in locations
;                               ; H_byte & L_byte
;
self    goto    self
;

;
	END

⌨️ 快捷键说明

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