Vous êtes sur la page 1sur 11

;************************************************* www.x-robotics.

com
*******
; PROGRAMA : X-LCD3310.lib
; Funcion : Libreria Control LCD grafico NOKIA 3310
;
;
; En la variable "rotulo" debemos definir la etiqueta que contiene
; el rotulo que queremos mostrar por ejemplo:
;
; mensaje1 dt "HOLA MUNDO", 0xFD
;
; el byte 0xFD indica el final del rotulo y es del todo necesario.
;
; movlw mensaje1 ;<---- esto define la posicion del
rotulo
; movwf rotulo ;y la guardamos en la variable
"rotulo"
;
; call lee_rotulo ;llamada a la subrutina de lectura
; ;e impresion en el display.
;
; INI_LCD -Inicializa SPI y LCD con la configuracion por defecto
;
; RST_LCD -Resetea el LCD
;
; CLR_LCD -Limpia toda la ram del LCD
;
; X_address -define cursor X en el display para empezar a pintar
; Y_address -define cursor Y en el display para empezar a pintar
;
; Invert_video -Invierte los colores de la pantalla
;
; normal_video -colores normales
;
; TX_SPI_C -Envia comando al LCD
; TX_SPI -Envia dato al LCD
;
;------------------------------------------------------------------------
---
; Revision : 2.00 Fecha: 8/10/2005 Programa para : PIC16F876
; CPU Clock : 4 MHz Tiempo instruccion : 1uS
; WDT : OFF Tipo de reloj : XT
; Code Prot : OFF cfg USART rs232 ; none
; Autor : Daniel C. Martin " ionitron@x-robotics.com "
;************************************************* www.x-robotics.com
*******

PDel0 EQU 0x21


PDel1 EQU 0x22
PDel2 EQU 0x23
BUFFER EQU 0x24
INNER EQU 0x25 ;delay variable mS
OUTER EQU 0x26 ;delay variable mS
BucleExt EQU 0x27
BucleInt EQU 0x28

SCE EQU d'0' ;lineas de protocolo en PORTC


DC EQU d'1' ; "
RST EQU d'2' ; "

caracter EQU 0x30


offset_caractr EQU 0x31
puntero_msg EQU 0x32 ;puntero usado para leer las
matrices
;que contienen mensajes (max. 255
caracteres)
rotulo EQU 0x33 ;indicara la posicion PCL donde
esta hubicado el mensaje

ProgramCounter EQU 0x32 ;var temporal para sumas con carry


de PCL

DATAL EQU 0x33


DATAH EQU 0x34

ACCaLO equ 0x61 ;Variables de calculos


ACCaHI equ 0x60
ACCbLO equ 0x63
ACCbHI equ 0x62
ACCcLO equ 0x65
ACCcHI equ 0x64
ACCdLO equ 0x67
ACCdHI equ 0x66
temp equ 0x68
Flags equ 0x69

;############# lectura de la flash de programa en tiempo de ejecucion


#######################
lee_rotulo movf rotulo,W ;carga el vector donde apunta la
etiqueta del mensaje
bsf STATUS, RP1 ;
bcf STATUS, RP0 ;Banco 2
movwf EEADR
movlw 0x00 ;util si los mensajes estan en otra
pagina de memoria
movwf EEADRH
bsf STATUS, RP0 ;banco 3
bsf EECON1,EEPGD ;puntero a codigo de programa
bsf EECON1,RD ;inicia la lectura
nop ;espera 2 nops para concluir la
lectura
nop ;(obligatorio)
bcf STATUS, RP0 ;banco 2
movf EEDATA, W ;byte bajo
bcf STATUS, RP1 ;banco 0
movwf caracter
bsf STATUS, RP1 ;banco 2
; movf EEDATH, W ;byte alto
; movwf DATAH
bcf STATUS, RP1 ;banco 0

movlw 0xFD
subwf caracter,W
btfsc STATUS,Z
return ;finaliza la lectura

call pinta_letra

incf rotulo
goto lee_rotulo

;############## pinta un caracter compuesto por 6 columnas de 8 bits o


pixels #########
pinta_letra clrf offset_caractr
call Tabla_ascii ;devuelve columna 1 del caracter
call TX_SPI ;manda el dato al LCD para
visualizarlo
incf offset_caractr,F;incrementa la columna
call Tabla_ascii ;devuelve columna 2 del caracter
call TX_SPI ;manda el dato al LCD para
visualizarlo
incf offset_caractr,F;incrementa la columna
call Tabla_ascii ;devuelve columna 3 del caracter
call TX_SPI ;manda el dato al LCD para
visualizarlo
incf offset_caractr,F;incrementa la columna
call Tabla_ascii ;devuelve columna 4 del caracter
call TX_SPI ;manda el dato al LCD para
visualizarlo
incf offset_caractr,F;incrementa la columna
call Tabla_ascii ;devuelve columna 5 del caracter
call TX_SPI ;manda el dato al LCD para
visualizarlo
incf offset_caractr,F;incrementa la columna
call Tabla_ascii ;devuelve columna 6 del caracter
call TX_SPI ;manda el dato al LCD para
visualizarlo
incf offset_caractr,F;incrementa la columna

return ;retorna el control

;########################################################################
####
;############### RUTINAS CONTROL LCD NOKIA 3310 Y PUERTO SPI
################
;########################################################################
####
;_______________________Inicializacion del
LCD_______________________________
INI_LCD call CFG_SPI ;configura puerto SPI
movlw d'30'
call delay
call RST_LCD ;primer reset de LCD antes de inic.
call SET_LCD ;inicializacion del LCD
call CLR_LCD ;puesta a cero de la matriz.
movlw d'10'
call delay
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_____________________Configuracion puerto serie
SPI________________________
CFG_SPI bsf STATUS,RP0 ;banco 1 >>>>
movlw b'01000000'
movwf SSPSTAT
bcf STATUS,RP0 ;banco 0 >>>>

movlw b'00100000' ;divisor de frecuencia /4


movwf SSPCON
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_____________Generacion primer Reset para inicializacion
LCD3310____________
RST_LCD bcf PORTC,RST ;activa reset a nivel bajo
nop ;retardo
bsf PORTC,RST ;desactiva reset- inic. completa
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_______________________Inicializacion del
LCD_______________________________
SET_LCD movlw b'00100001' ;chip activo, V Addres, H=1
call TX_SPI_C
movlw b'11001011' ;comando valor de Vout
call TX_SPI_C
movlw b'00010011' ;bias System
call TX_SPI_C

movlw b'00100000' ;chip activo, H=0


call TX_SPI_C
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''
movlw b'00001001' ;mode [Pantalla negra]
call TX_SPI_C
movlw d'100' ;espera 100mS
call delay
movlw b'00001100' ;mode [Normal mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;______________________LIMPIA MEMORIA RAM del
LCD____________________________
CLR_LCD movlw b'00001000' ;mode [Pantalla Blanca]
call TX_SPI_C ;para que no se vea el borrado.
movlw d'2'
movwf BucleExt
Bint movlw d'252' ;carga 252 vueltas que seran x2=504
movwf BucleInt ;para borrar todo el LCD

movlw b'00000000'
call TX_SPI
decfsz BucleInt ;espera 252 vueltas
goto $-3
decfsz BucleExt ;da 2 x 252 = 504 vueltas
goto Bint
movlw b'00001100' ;mode [Normal mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;___________________________ posicion X
_____________________________________
X_address iorlw b'10000000' ;añade bit de comando
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;___________________________ posicion Y
_____________________________________
Y_address iorlw b'01000000' ;añade bit de comando
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_________________________video
invertido____________________________________
Invert_video movlw b'00001101' ;mode [Inverse video mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;_________________________video
normal____________________________________
normal_video movlw b'00001100' ;mode [normal mode]
call TX_SPI_C
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;________________Transmision de datos por puerto serie
SPI___________________
TX_SPI_C bcf PORTC,DC ;Modo COMANDO
TX_SPI bcf PORTC,SCE ;enable
display!!!!!!!!!!!!!!!!!!!!!!

movwf SSPBUF ;Transmision por puerto SPI

espera btfss PIR1,SSPIF ;espera a que se envie el dato


goto espera
bcf PIR1,SSPIF ;borra flag interrupcion
bsf PORTC,SCE ;display OFF
bsf PORTC,DC ;Modo DATO (por defecto)
return
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""
;########################################################################
###
del_1ms movlw d'199' ;delay 1mS
movwf INNER
in_lp nop
nop
decfsz INNER,F
goto in_lp
return

delay movwf OUTER ;vueltas de 1mS


out_lp call del_1ms
decfsz OUTER,F
goto out_lp
return
;########################################################################
###

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>

org 0x3FF ;posicion de la tabla en memoria de


programa

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>

;TABLAS DE CARACTERES ASCII

Tabla_ascii movf caracter,W


movwf ACCaLO ;carga el ascii en el primer
operando para la multiplicacion
movlw .0 ;A ;ResultHHI
movwf ACCaHI
movwf ACCbHI ;como el operando b alto tb sera 0
aprovecha...
movlw .6
movwf ACCbLO ;carga el segundo operando para la
multiplicacion

call D_mpyS ;multiplica ascii*6 para encontrar


datos en las tablas
;------------------------------------
movlw .4 ;posicion actual de la tabla en
pagina 4
movwf PCLATH

movlw ini_tabla ;carga dato temporal para comprobar


mas tarde el acarreo
movwf ProgramCounter ;sin saltar realmente.

movf ACCcHI,W
addwf PCLATH,F
movf ACCcLO,W
addwf offset_caractr,W;suma el desplazamiento de columna
para lcd grafico
btfsc STATUS,C ;comprueba acarreo de la suma
incf PCLATH,F ;si se genero acarreo incrementa
PCLATH

addwf ProgramCounter,F;suma aqui primero para comprobar


si hay acarreo
;y una vez comprobado lo hace
realmente en PCL para saltar

btfsc STATUS,C ;comprueba acarreo de la suma


incf PCLATH,F ;si se genero acarreo incrementa
PCLATH

ini_tabla addwf PCL,F ;tanto si hubo carry como si no..


suma el byte bajo

dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x00
'configurable........
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x01
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x02
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x03
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x04
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x05
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x06
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x07
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x08
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x09
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0A
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0B
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0C
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0D
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0E
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x0F

dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x10
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x11
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x12
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x13
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x14
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x15
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x16
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x17
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x18
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x19
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1A
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1B
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1C
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1D
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1E
dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x1F
'configurable........

dt 0x0,0x0,0x0,0x0,0x00,0x00 ; 0x20 space


dt 0x0,0x0,0x5F,0x0,0x00,0x00 ; ! 0x21
dt 0x0,0x7,0x0,0x7,0x00,0x00 ; " 0x22
dt 0x14,0x7F,0x14,0x7F,0x14,0x00 ; # 0x23
dt 0x24,0x2A,0x7F,0x2A,0x12,0x00 ; $ 0x24
dt 0x26,0x16,0x8,0x34,0x32,0x00 ; % 0x25
dt 0x76,0x49,0x55,0x22,0x50,0x00 ; & 0x26
dt 0x0,0x0,0x5,0x3,0x0,0x00 ; ' 0x27
dt 0x0,0x1C,0x22,0x41,0x0,0x00 ; ( 0x28
dt 0x0,0x41,0x22,0x1C,0x0,0x00 ; ) 0x29
dt 0x14,0x8,0x3E,0x8,0x14,0x00 ; * 0x2A
dt 0x8,0x8,0x3E,0x8,0x8,0x00 ; + 0x2B
dt 0x0,0x50,0x30,0x0,0x0,0x00 ; , 0x2C
dt 0x8,0x8,0x8,0x8,0x8,0x00 ; - 0x2D
dt 0x0,0x60,0x60,0x0,0x0,0x00 ; . 0x2E
dt 0x20,0x10,0x8,0x4,0x2,0x00 ; / 0x2F

dt 0x3E,0x51,0x49,0x45,0x3E,0x00 ; 0 0x30
dt 0x0,0x42,0x7F,0x40,0x0,0x00 ; 1 0x31
dt 0x42,0x61,0x51,0x49,0x46,0x00 ; 2 0x32
dt 0x21,0x41,0x45,0x4B,0x31,0x00 ; 3 0x33
dt 0x18,0x14,0x12,0x7F,0x10,0x00 ; 4 0x34
dt 0x27,0x45,0x45,0x45,0x39,0x00 ; 5 0x35
dt 0x3C,0x4A,0x49,0x49,0x30,0x00 ; 6 0x36
dt 0x1,0x1,0x79,0x5,0x3,0x00 ; 7 0x37
dt 0x36,0x49,0x49,0x49,0x36,0x00 ; 8 0x38
dt 0x6,0x49,0x49,0x29,0x1E,0x00 ; 9 0x39
dt 0x0,0x36,0x36,0x0,0x0,0x00 ; : 0x3A
dt 0x0,0x56,0x36,0x0,0x0,0x00 ; ; 0x3B
dt 0x0,0x8,0x14,0x22,0x41,0x00 ; < 0x3C
dt 0x14,0x14,0x14,0x14,0x14,0x00 ; = 0x3D
dt 0x41,0x22,0x14,0x8,0x0,0x00 ; > 0x3E
dt 0x2,0x1,0x51,0x9,0x6,0x00 ; ? 0x3F

dt 0x3E,0x41,0x49,0x55,0x5E,0x00 ; @ 0x40
dt 0x7E,0x11,0x11,0x11,0x7E,0x00 ; A 0x41
dt 0x7F,0x49,0x49,0x49,0x36,0x00 ; B 0x42
dt 0x3E,0x41,0x41,0x41,0x22,0x00 ; C 0x43
dt 0x7F,0x41,0x41,0x22,0x1C,0x00 ; D 0x44
dt 0x7F,0x49,0x49,0x49,0x41,0x00 ; E 0x45
dt 0x7F,0x9,0x9,0x9,0x1,0x00 ; F 0x46
dt 0x3E,0x41,0x49,0x49,0x3A,0x00 ; G 0x47
dt 0x7F,0x8,0x8,0x8,0x7F,0x00 ; H 0x48
dt 0x0,0x41,0x7F,0x41,0x0,0x00 ; I 0x49
dt 0x20,0x41,0x41,0x3F,0x0,0x00 ; J 0x4A
dt 0x7F,0x8,0x14,0x22,0x41,0x00 ; K 0x4B
dt 0x7F,0x40,0x40,0x40,0x40,0x00 ; L 0x4C
dt 0x7F,0x2,0xC,0x2,0x7F,0x00 ; M 0x4D
dt 0x7F,0x4,0x8,0x10,0x7F,0x00 ; N 0x4E
dt 0x3E,0x41,0x41,0x41,0x3E,0x00 ; O 0x4F

dt 0x7F,0x9,0x9,0x9,0x6,0x00 ; P 0x50
dt 0x3E,0x41,0x51,0x21,0x5E,0x00 ; Q 0x51
dt 0x7F,0x9,0x19,0x29,0x46,0x00 ; R 0x52
dt 0x46,0x49,0x49,0x49,0x31,0x00 ; S 0x53
dt 0x1,0x1,0x7F,0x1,0x1,0x00 ; T 0x54
dt 0x3F,0x40,0x40,0x40,0x3F,0x00 ; U 0x55
dt 0x1F,0x20,0x40,0x20,0x1F,0x00 ; V 0x56
dt 0x3F,0x40,0x3C,0x40,0x3F,0x00 ; W 0x57
dt 0x63,0x14,0x8,0x14,0x63,0x00 ; X 0x58
dt 0x7,0x8,0x70,0x8,0x7,0x00 ; Y 0x59
dt 0x61,0x51,0x49,0x45,0x43,0x00 ; Z 0x5A
dt 0x0,0x7F,0x41,0x41,0x0,0x00 ; [ 0x5B
dt 0x2,0x4,0x8,0x10,0x20,0x00 ; \ 0x5C
dt 0x0,0x41,0x41,0x7F,0x0,0x00 ; ] 0x5D
dt 0x4,0x2,0x1,0x2,0x4,0x00 ; ^ 0x5E
dt 0x40,0x40,0x40,0x40,0x40,0x00 ; _ 0x5F

dt 0x0,0x1,0x2,0x4,0x0,0x00 ; ` 0x60
dt 0x20,0x54,0x54,0x54,0x78,0x00 ; a 0x61
dt 0x7F,0x48,0x44,0x44,0x38,0x00 ; b 0x62
dt 0x38,0x44,0x44,0x44,0x20,0x00 ; c 0x63
dt 0x38,0x44,0x44,0x48,0x7F,0x00 ; d 0x64
dt 0x38,0x54,0x54,0x54,0x18,0x00 ; e 0x65
dt 0x8,0x7E,0x9,0x1,0x2,0x00 ; f 0x66
dt 0x8,0x54,0x54,0x54,0x3C,0x00 ; g 0x67
dt 0x7F,0x8,0x4,0x4,0x78,0x00 ; h 0x68
dt 0x0,0x44,0x7D,0x40,0x0,0x00 ; i 0x69
dt 0x20,0x40,0x44,0x3D,0x0,0x00 ; j 0x6A
dt 0x7F,0x10,0x28,0x44,0x0,0x00 ; k 0x6B
dt 0x0,0x41,0x7F,0x40,0x0,0x00 ; l 0x6C
dt 0x7C,0x4,0x18,0x4,0x78,0x00 ; m 0x6D
dt 0x7C,0x8,0x4,0x4,0x78,0x00 ; n 0x6E
dt 0x38,0x44,0x44,0x44,0x38,0x0 ; o 0x6F

dt 0x7C,0x14,0x14,0x14,0x8,0x0 ; p 0x70
dt 0x8,0x14,0x14,0x18,0x7C,0x0 ; q 0x71
dt 0x7C,0x8,0x4,0x4,0x8,0x0 ; r 0x72
dt 0x48,0x54,0x54,0x54,0x20,0x0 ; s 0x73
dt 0x4,0x3F,0x44,0x40,0x20,0x0 ; t 0x74
dt 0x3C,0x40,0x40,0x20,0x7C,0x0 ; u 0x75
dt 0x1C,0x20,0x40,0x20,0x1C,0x0 ; v 0x76
dt 0x3C,0x40,0x38,0x40,0x3C,0x0 ; w 0x77
dt 0x44,0x28,0x10,0x28,0x44,0x0 ; x 0x78
dt 0xC,0x50,0x50,0x50,0x3C,0x0 ; y 0x79
dt 0x44,0x64,0x54,0x4C,0x44,0x0 ; z 0x7A
dt 0x0,0x8,0x36,0x41,0x0,0x0 ; { 0x7B
dt 0x0,0x0,0x7F,0x0,0x0,0x0 ; | 0x7C
dt 0x0,0x41,0x36,0x8,0x0,0x0 ; } 0x7D
dt 0x8,0x8,0x2A,0x1C,0x8,0x0 ; ->0x7E
dt 0x8,0x1C,0x2A,0x8,0x8,0x0 ; <-0x7F

;========================================================================
=========
;========================================================================
=========
;========================================================================
=========

;*******************************************************************
; Double Precision Multiplication
;
; ( Optimized for Code Size : Looped Code )
;
;*******************************************************************;
; Multiplication : ACCb(16 bits) * ACCa(16 bits) -> ACCb,ACCc ( 32 bits
)
; (a) Load the 1st operand in location ACCaLO & ACCaHI ( 16 bits )
; (b) Load the 2nd operand in location ACCbLO & ACCbHI ( 16 bits )
; (c) CALL D_mpy
; (d) The 32 bit result is in location ( ACCbHI,ACCbLO,ACCcHI,ACCcLO
)
;*******************************************************************;
;
;
;*******************************************************************
; Double Precision Multiply ( 16x16 -> 32 )
; ( ACCb*ACCa -> ACCb,ACCc ) : 32 bit output with high word
; in ACCb ( ACCbHI,ACCbLO ) and low word in ACCc ( ACCcHI,ACCcLO ).
;

D_mpyS ;results in ACCb(16 msb's) and ACCc(16


lsb's)
call setupmult
bcf STATUS,C
mloop
rrf ACCdHI,F ;rotate d right
rrf ACCdLO,F
btfss STATUS,C ;need to add?
goto No_add
movf ACCaLO,W ; Addition ( ACCb + ACCa -> ACCb )
addwf ACCbLO,F ;add lsb
btfsc STATUS,C ;add in carry
incf ACCbHI,F
movf ACCaHI,W
addwf ACCbHI,F ;add msb

No_add rrf ACCbHI,F


rrf ACCbLO,F
rrf ACCcHI,F
rrf ACCcLO,F
decfsz temp,F ;loop until all bits checked
goto mloop
goto end1

; Double Precision Addition ( ACCb + ACCa -> ACCb )


;
D_add bcf Flags,C ;Clear temp Carry bit
movf ACCaLO,W ; Addition ( ACCb + ACCa -> ACCb )
addwf ACCbLO,F ;add lsb
btfsc STATUS,C ;add in carry
incf ACCbHI,F
btfsc STATUS,C
bsf Flags,C
movf ACCaHI,W
addwf ACCbHI,F ;add msb
btfsc Flags,C
bsf STATUS,C
return

;
;
;*******************************************************************
;
setupmult movlw .16 ; for 16 shifts
movwf temp
movf ACCbHI,W ;move ACCb to ACCd
movwf ACCdHI
movf ACCbLO,W
movwf ACCdLO
clrf ACCbHI
clrf ACCbLO
return
;
;****************************************************************
end1 return

END
;************************************************* www.x-robotics.com
*******
v

Vous aimerez peut-être aussi