home *** CD-ROM | disk | FTP | other *** search
File List | 1993-08-12 | 11.8 KB | 255 lines |
- 16c5x/xx Cross-Assembler V4.12.01 Intermediate Thu Aug 12 15:47:18 1993 Page 1
-
- Line PC Opcode
-
- 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 s
- hould
- 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" ( str
- aight line code )
- 0020 ;********************************************************
- ***********
- 0021 ;
- 0022 0009 mulcnd equ 09 ; 8 bit multiplicand
- 0023 0010 mulplr equ 10 ; 8 bit multiplier
- 0024 0012 H_byte equ 12 ; High byte of the 16 bit result
- 0025 0013 L_byte equ 13 ; Low byte of the 16 bit result
- 0026 0014 count equ 14 ; loop counter
- 0027 0006 portb equ 06 ; I/O register F6
- 0028 ;
- 0029 ;
- 0030 include "picreg.equ"
- 0031 ;************************** PIC16C5X Header *********
- ****************
- 0032 ;
- 0033 ;
- 0034 01FF PIC54 equ 1FFH ; Define Reset Vectors
- 0035 01FF PIC55 equ 1FFH
- 0036 03FF PIC56 equ 3FFH
- 0037 07FF PIC57 equ 7FFH
- 0038 0000 PIC71 equ 0H
- 0039 ;
- 0040 0001 RTCC equ 1h
- 0041 0002 PC equ 2h
- 0042 0003 STATUS equ 3h ; F3 Reg is STATUS Reg.
- 0043 0004 FSR equ 4h
- 0044 ;
- 0045 0005 Port_A equ 5h
- 0046 0006 Port_B equ 6h ; I/O Port Assignments
- 0047 0007 Port_C equ 7h
- 0048 ;
- 0049 ;
- 0050 0009 ADRES equ 9h ;16C71 Special-purpose registers
- 0051 0008 ADCON0 equ 8h ;16C71 Special-purpose registers
- 16c5x/xx Cross-Assembler V4.12.01 Intermediate Thu Aug 12 15:47:18 1993 Page 2
-
- Line PC Opcode
-
- 0052 0088 ADCON1 equ 88h ;16C71 Special-purpose registers
- 0053 000A PCLATH equ 0AH ;16C71 Special-purpose registers
- 0054 000B INTCON equ 0BH ;16C71 Special-purpose registers
- 0055 0085 TRISA equ 85H ;16C71 Special-purpose registers
- 0056 0086 TRISB equ 86H ;16C71 Special-purpose registers
- 0057 ;
- 0058 ;
- 0059 ;
- 0060 ;********************************************************
- *****************
- 0061 ;
- 0062 ; ; STATUS REG. Bits
- 0063 0000 CARRY equ 0h ; Carry Bit is Bit.0 of F
- 3
- 0064 0000 C equ 0h
- 0065 0001 DCARRY equ 1h
- 0066 0001 DC equ 1h
- 0067 0002 Z_bit equ 2h ; Bit 2 of F3 is Zero Bit
-
- 0068 0002 Z equ 2h
- 0069 0003 P_DOWN equ 3h
- 0070 0003 PD equ 3h
- 0071 0004 T_OUT equ 4h
- 0072 0004 TO equ 4h
- 0073 0005 PA0 equ 5h ;16C5X Status bits
- 0074 0006 PA1 equ 6h ;16C5X Status bits
- 0075 0007 PA2 equ 7h ;16C5X Status bits
- 0076 ;
- 0077 ;
- 0078 0005 RP0 equ 5h ;16C71 Status bits
- 0079 0006 RP1 equ 6h ;16C71 Status bits
- 0080 0007 IRP equ 7h ;16C71 Status bits
- 0081 0007 GIE equ 7h ;16C71 INTCON register bits
- 0082 0006 ADIE equ 6h ;16C71 INTCON register bits
- 0083 0005 RTIE equ 5h ;16C71 INTCON register bits
- 0084 0004 INTE equ 4h ;16C71 INTCON register bits
- 0085 0003 RBIE equ 3h ;16C71 INTCON register bits
- 0086 0002 RTIF equ 2h ;16C71 INTCON register bits
- 0087 0001 INTF equ 1h ;16C71 INTCON register bits
- 0088 0000 RBIF equ 0 ;16C71 INTCON register bits
- 0089 0007 ADCS1 equ 7h ;16C71 ADCN0 register bits
- 0090 0006 ADCS0 equ 6h ;16C71 ADCN0 register bits
- 0091 0004 CHS1 equ 4h ;16C71 ADCN0 register bits
- 0092 0003 CHS0 equ 3h ;16C71 ADCN0 register bits
- 0093 0002 GO equ 2h ;16C71 ADCN0 register bits
- 0094 0001 ADIF equ 1h ;16C71 ADCN0 register bits
- 0095 0000 ADON equ 0 ;16C71 ADCN0 register bits
- 0096 0001 PCFG1 equ 1h ;16C71 ADCN1 register bits
- 0097 0000 PCFG0 equ 0 ;16C71 ADCN1 register bits
- 0098 ;
- 0099 ;
- 0100 0001 Same equ 1h
- 0101 ;
- 0102 0000 LSB equ 0h
- 16c5x/xx Cross-Assembler V4.12.01 Intermediate Thu Aug 12 15:47:18 1993 Page 3
-
- Line PC Opcode
-
- 0103 0007 MSB equ 7h
- 0104 ;
- 0105 0001 TRUE equ 1h
- 0106 0001 YES equ 1h
- 0107 0000 FALSE equ 0h
- 0108 0000 NO equ 0h
- 0109 ;
- 0110 ;********************************************************
- *****************
- 0111
- 0112 ;
- 0113 ; ***************************** Begin Multiplier
- Routine
- 0114 0000 0072 mpy_S clrf H_byte
- 0115 0001 0073 clrf L_byte
- 0116 0002 0C08 movlw 8
- 0117 0003 0034 movwf count
- 0118 0004 0209 movf mulcnd,w
- 0119 0005 0403 bcf STATUS,CARRY ; Clear the carry bit in
- the status Reg.
- 0120 0006 0330 loop rrf mulplr
- 0121 0007 0603 btfsc STATUS,CARRY
- 0122 0008 01F2 addwf H_byte,Same
- 0123 0009 0332 rrf H_byte,Same
- 0124 000A 0333 rrf L_byte,Same
- 0125 000B 02F4 decfsz count
- 0126 000C 0A06 goto loop
- 0127 ;
- 0128 000D 0800 retlw 0
- 0129 ;
- 0130 ;********************************************************
- ************
- 0131 ; Test Program
- 0132 ;********************************************************
- *************
- 0133 000E 0040 start clrw
- 0134 000F 0002 option
- 0135 0010 0206 main movf portb,w
- 0136 0011 0030 movwf mulplr ; multiplier (in mulplr)
- = 05
- 0137 0012 0206 movf portb,w
- 0138 0013 0029 movwf mulcnd
- 0139 ;
- 0140 0014 0900 call_m call mpy_S ; The result is in locati
- ons F12 & F13
- 0141 ; H_byte & L_byte
- 0142 ;
- 0143 0015 0A10 goto main
- 0144 ;
- 0145 0000 org 01FFh
- 0146 01FF 0A0E goto start
- 0147 ;
- 0148 0000 END
- 16c5x/xx Cross-Assembler V4.12.01 Intermediate Thu Aug 12 15:47:18 1993 Page 4
-
-
-
- Cross-Reference Listing
- LABEL VALUE DEFN REFERENCES
- ADCON0 8 51 51
- ADCON1 136 52 52
- ADCS0 6 90 90
- ADCS1 7 89 89
- ADIE 6 82 82
- ADIF 1 94 94
- ADON 0 95 95
- ADRES 9 50 50
- C 0 64 64
- CARRY 0 63 63 119 121
- CHS0 3 92 92
- CHS1 4 91 91
- DC 1 66 66
- DCARRY 1 65 65
- FALSE 0 107 107
- FSR 4 43 43
- GIE 7 81 81
- GO 2 93 93
- H_byte 18 24 24 114 122 123
- INTCON 11 54 54
- INTE 4 84 84
- INTF 1 87 87
- IRP 7 80 80
- LSB 0 102 102
- L_byte 19 25 25 115 124
- MSB 7 103 103
- NO 0 108 108
- PA0 5 73 73
- PA1 6 74 74
- PA2 7 75 75
- PC 2 41 41
- PCFG0 0 97 97
- PCFG1 1 96 96
- PCLATH 10 53 53
- PD 3 70 70
- PIC54 511 34 34
- PIC55 511 35 35
- PIC56 1023 36 36
- PIC57 2047 37 37
- PIC71 0 38 38
- P_DOWN 3 69 69
- Port_A 5 45 45
- Port_B 6 46 46
- Port_C 7 47 47
- RBIE 3 85 85
- RBIF 0 88 88
- RP0 5 78 78
- RP1 6 79 79
- RTCC 1 40 40
- RTIE 5 83 83
- RTIF 2 86 86
- STATUS 3 42 42 119 121
- Same 1 100 100 122 123 124
- TO 4 72 72
- TRISA 133 55 55
- TRISB 134 56 56
- TRUE 1 105 105
- T_OUT 4 71 71
- YES 1 106 106
- Z 2 68 68
- Z_bit 2 67 67
- call_m 20 140 140
- count 20 26 26 117 125
- loop 6 120 120 126
- main 16 135 135 143
- mpy_S 0 114 114 140
- mulcnd 9 22 22 118 138
- mulplr 16 23 23 120 136
- portb 6 27 27 135 137
- start 14 133 133 146
-