MPASM 01.01.02 Int SAMPLE.ASM 8-9-1994 10:12:18 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT 0001 ;******************************************************************* 0002 ; SAMPLE.ASM 0003 ; 8x8 Software Multiplier 0004 ;******************************************************************* 0005 ; 0006 ; The 16 bit result is stored in 2 bytes 0007 ; 0008 ; Before calling the subroutine " mpy ", the multiplier should 0009 ; be loaded in location " mulplr ", and the multiplicand in 0010 ; " mulcnd " . The 16 bit result is stored in locations 0011 ; H_byte & L_byte. 0012 ; 0013 ; Performance : 0014 ; Program Memory : 15 locations 0015 ; # of cycles : 71 0016 ; Scratch RAM : 0 locations 0017 ; 0018 ; This routine is optimized for code efficiency ( looped code ) 0019 ; For time efficiency code refer to "mult8x8F.asm" ( straight line code ) 0020 ;******************************************************************* 0021 ; 0022 LIST p=16C54 ; PIC16C54 is the target processor 0023 0009 0024 mulcnd equ 09 ; 8 bit multiplicand 0010 0025 mulplr equ 10 ; 8 bit multiplier 0012 0026 H_byte equ 12 ; High byte of the 16 bit result 0013 0027 L_byte equ 13 ; Low byte of the 16 bit result 0014 0028 count equ 14 ; loop counter 0006 0029 portb equ 06 ; I/O register F6 0003 0030 STATUS equ 03 ; STATUS register F3 0000 0031 CARRY equ 0 ; Carry bit in status register 0001 0032 Same equ 1 ; 0033 ; 0034 ; 0035 ; ***************************** Begin Multiplier Routine 0000 0072 0036 mpy_S clrf H_byte 0001 0073 0037 clrf L_byte 0002 0C08 0038 movlw 8 0003 0034 0039 movwf count 0004 0209 0040 movf mulcnd,w 0005 0403 0041 bcf STATUS,CARRY ; Clear the carry bit in the status Reg. 0006 0330 0042 loop rrf mulplr 0007 0603 0043 btfsc STATUS,CARRY 0008 01F2 0044 addwf H_byte,Same 0009 0332 0045 rrf H_byte,Same 000A 0333 0046 rrf L_byte,Same 000B 02F4 0047 decfsz count 000C 0A06 0048 goto loop 0049 ; 000D 0800 0050 retlw 0 0051 ; 0052 ;******************************************************************** 0053 ; Test Program MPASM 01.01.02 Int SAMPLE.ASM 8-9-1994 10:12:18 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT 0054 ;********************************************************************* 000E 0040 0055 start clrw 000F 0002 0056 option 0010 0206 0057 main movf portb,w 0011 0030 0058 movwf mulplr ; multiplier (in mulplr) = 05 0012 0206 0059 movf portb,w 0013 0029 0060 movwf mulcnd 0061 ; 0014 0900 0062 call_m call mpy_S ; The result is in locations F12 & F13 0063 ; H_byte & L_byte 0064 ; 0015 0A10 0065 goto main 0066 ; 0067 org 01FFh 01FF 0A0E 0068 goto start 0069 ; 0070 END 0071 0072 0073 MPASM 01.01.02 Int SAMPLE.ASM 8-9-1994 10:12:18 PAGE 3 SYMBOL TABLE LABEL VALUE CARRY 0000 H_byte 0012 L_byte 0013 STATUS 0003 Same 0001 call_m 0014 count 0014 loop 0006 main 0010 mpy_S 0000 mulcnd 0009 mulplr 0010 portb 0006 start 000E MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XXXXXXXXXXXXXXXX XXXXXX---------- ---------------- ---------------- 0040 : ---------------- ---------------- ---------------- ---------------- 0180 : ---------------- ---------------- ---------------- ---------------- 01C0 : ---------------- ---------------- ---------------- ---------------X All other memory blocks unused. Errors : 0 Warnings : 0