1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

ya

Discussion in 'Microcontrollers' started by mari_69, Jun 5, 2004.

  1. mari_69

    mari_69 New Member

    Joined:
    Apr 24, 2004
    Messages:
    2
    Likes:
    0
    Location:
    Bulgaria
    LIST P=16F872
    errorlevel -302
    ;filter set 800010
    include <p16f872.inc>
    temp equ 21
    temp1 equ 22
    dig1 equ 23
    dig2 equ 24
    dig3 equ 25
    ddig1 equ 26
    ddig2 equ 27
    ddig3 equ 28
    temp2 equ 29
    count equ 2A
    H_byte equ 2B
    L_byte equ 2C
    R0 equ 2D
    R1 equ 2E
    R2 equ 2F
    d2 equ 30
    ACCbHI equ 31
    ACCaHI equ 32
    ACCaLO equ 33
    ACCbLO equ 34
    LOOPCOUNT equ 60
    TEMPB0 equ 61
    div5 equ 62
    div6 equ 63
    Choise equ 64
    F1 EQU 65
    F2 EQU 66
    F3 equ 67
    z1 equ 68 ; temporary register
    L_temp equ 69 ; temporary register
    Multip equ 6a
    Loff1 equ 6b
    Loff2 equ 6c
    Bzero equ 6d
    Fzero1 equ 6e
    Fzero2 equ 6f
    Mode equ 70
    Input equ 71
    Range equ 72
    Czero1 equ 73
    Czero2 equ 74
    point equ 75

    m1 equ 35
    m2 equ 36
    m3 equ 37
    c1 equ 38
    c2 equ 39
    c3 EQU 3A
    ddig4 equ 3B
    ddig5 equ 3C
    m4 equ 3D
    ddig6 equ 3E
    c4 equ 3F
    d1 equ 40
    d3 equ 41

    ACCB0 equ 42
    ACCB1 equ 43
    ACCB2 EQU 44
    ACCB3 EQU 45
    SI equ 46
    div1 equ 47
    div2 equ 48
    div3 equ 49
    div4 equ 4a

    AARGB0 equ 4B
    AARGB1 equ 4C
    AARGB2 equ 4D
    AARGB3 equ 4E
    AARGB4 equ 4F
    AARGB5 equ 50
    BARGB0 equ 51
    BARGB1 EQU 52
    BARGB2 EQU 53
    BARGB3 EQU 54
    TEMPB1 EQU 55
    EXPBIAS equ 56
    lo equ 57


    EXP equ 58 ; 8 bit biased exponent
    ACC equ 59 ; most significant byte of contiguous 4 byte accumulator
    SIGN equ 5A ; save location for sign in MSB
    TEMP equ 5B ; temporary storage

    AEXP equ 58 ; 8 bit biased exponent for argument A
    AARG equ 59 ; most significant byte of mantissa for argument A
    BEXP equ 5C ; 8 bit biased exponent for argument B
    BARG equ 5D ; most significant byte of mantissa for argument B

    FPFLAGS equ 5E ; floating point library exception flags
    IOV equ 0 ; bit0 = integer overflow flag
    FOV equ 1 ; bit1 = floating point overflow flag
    FUN equ 2 ; bit2 = floating point underflow flag
    FDZ equ 3 ; bit3 = floating point divide by zero flag
    RND equ 6 ; bit6 = floating point rounding flag, 0 = truncation
    ; 1 = rounding to nearest LSB
    SAT equ 7 ; bit7 = floating point saturate flag, 0 = terminate on
    ; exception without saturation, 1 = terminate on
    ; exception with saturation to appropriate value

    ;PB0 DIN PC5
    ;PB1 LOAD
    ;PB2 CLK PC3
    ;PB3 CS PC7
    ;PB4 DOUT PC4
    ;PB5 RDY PC6
    __CONFIG _CP_OFF & _HS_OSC & _PWRTE_ON & _WDT_OFF & _DEBUG_OFF & _LVP_OFF & _BODEN_OFF & _WRT_ENABLE_OFF
    start
    MOVLW 0x7f
    MOVWF EXPBIAS
    movlw 0x30
    movwf SSPCON
    CLRF STATUS ; Do initialization (Bank 0)
    CLRF INTCON
    BSF STATUS, RP0 ; Bank 1
    MOVLW 0x00 ; :lol:
    MOVWF OPTION_REG
    MOVLW 0X40
    MOVWF SSPSTAT
    BCF STATUS, RP0 ; Bank 0
    CLRF PORTA ; ALL PORT output should output Low.
    CLRF PORTB
    BSF STATUS, RP0 ; Select Bank 1
    movlw 0x00
    movwf TRISA
    MOVWF TRISB
    movlw 0x97
    movwf TRISC
    BCF STATUS, RP0
    movlw 0x01
    movwf Choise
    movlw 0x80
    MOVWF point
    movwf z1
    bsf z1,2
    bsf FPFLAGS,6
    bsf FPFLAGS,7

    PP7 bsf z1,1
    PO
    movlw 0x0A
    movwf ddig1
    movwf ddig2
    movwf ddig3
    movwf ddig4
    movwf ddig5
    movlw 0xff
    movwf ddig6
    movwf lo
    call WE
    POP movlw 0x0B
    movwf ddig5
    movlw 0x0c
    movwf ddig4
    movlw 0x0D
    movwf ddig3
    movlw 0x0D
    movwf ddig2
    movlw 0x00
    movwf ddig1
    movlw 0xff
    movwf ddig6
    movwf lo
    call WE


    movlw 0x30
    CALL EEREAD
    movwf div1
    movlw 0x31
    CALL EEREAD
    movwf div2
    movlw 0x32
    CALL EEREAD
    movwf div3
    movlw 0x33
    CALL EEREAD
    movwf div4
    movlw 0x34
    CALL EEREAD
    movwf div5
    movlw 0x35
    CALL EEREAD
    movwf div6

    movlw 0x10
    call EEREAD
    movwf m1
    movlw 0x11
    CALL EEREAD
    movwf m2
    movlw 0x12
    call EEREAD
    movwf m3
    movlw 0x13
    CALL EEREAD
    movwf m4

    movlw 0x17
    CALL EEREAD
    movwf point

    movlw 0x14
    CALL EEREAD
    movwf Czero1

    movlw 0x15
    CALL EEREAD
    movwf Czero2

    movlw 0x00
    call EEREAD
    movwf c1
    movlw 0x01
    CALL EEREAD
    movwf c2
    movlw 0x02
    CALL EEREAD
    movwf c3
    movlw 0x03
    CALL EEREAD
    movwf c4

    movlw 0x20
    CALL EEREAD
    movwf F1
    movlw 0x21
    CALL EEREAD
    movwf F2

    movlw 0x04
    CALL EEREAD
    movwf Multip

    movlw 0x07
    CALL EEREAD
    movwf Mode

    movlw 0x0f
    CALL EEREAD
    movwf F3

    movlw 0x05 ;
    CALL EEREAD ;
    movwf Loff1 ;
    movlw 0x06 ;Light off
    CALL EEREAD ;
    movwf Loff2 ;

    movlw 0x22 ;
    call EEREAD ;
    movwf Fzero1 ;
    movlw 0x23 ;High zero
    CALL EEREAD ;
    movwf Fzero2 ;

    movlw 0x03 ;single write to filter reg
    movwf SSPBUF
    call Send
    movfw F1
    movwf SSPBUF
    call Send
    movfw F2
    movwf SSPBUF
    call Send
    movfw F3
    movwf SSPBUF
    call Send

    movlw 0x02 ;single write to mode reg
    movwf SSPBUF
    call Send
    movlw 0x31 ;
    movwf SSPBUF
    call Send
    movfw Mode
    movwf SSPBUF
    call Send

    AQ
    movlw 0x10
    movwf SSPBUF
    call Send
    movlw 0x00
    movwf SSPBUF
    call Send
    btfss SSPBUF,7
    call SaveData
    goto AQ

    ; Conversion BCD -> 7 segments
    segmenti
    nop
    addwf PCL,1
    retlw b'00111111' ; ..FEDCBA = '0'
    retlw b'00000110' ; .....CB. = '1'
    retlw b'01011011' ; .G.ED.BA = '2'
    retlw b'01001111' ; .G..DCBA = '3'
    retlw b'01100110' ; .GF..CB. = '4'
    retlw b'01101101' ; .GF.DC.A = '5'
    retlw b'01111101' ; .GFEDC.A = '6'
    retlw b'00000111' ; .....CBA = '7'
    retlw b'01111111' ; .GFEDCBA = '8'
    retlw b'01101111' ; .GF..CBA = '9'
    retlw b'01000000' ; H....... = '-'
    retlw b'01110110' ; H....... = 'H'
    retlw b'01111001' ; H....... = 'E'
    retlw b'00111000' ; H....... = 'L'
    retlw b'01110001' ; H....... = 'F'
    retlw b'00000000' ; H....... = ' '

    SaveData
    movlw 0x11
    movwf SSPBUF
    call Send
    movlw 0x00
    movwf SSPBUF
    call Send ;]
    movfw SSPBUF ;]
    movwf dig1 ;]
    movlw 0x00
    movwf SSPBUF
    call Send;]
    movfw SSPBUF ;]READ ADC
    movwf dig2 ;]
    movlw 0x00
    movwf SSPBUF
    call Send ;]
    movfw SSPBUF ;]
    movwf dig3

    btfsc z1,2
    goto STDY

    bcf STATUS,C
    btfss PORTC,7
    incf Choise,1

    movlw 0x02
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto INP

    movlw 0x03
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto RANG

    movlw 0x04
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto AC

    movlw 0x05
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto FILT

    movlw 0x06
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto ZERO

    movlw 0x07
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto COEFF

    movlw 0x08
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto DIV

    movlw 0x09
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto MULQ

    movlw 0x0A
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto UPP

    movlw 0x0B
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto BEG

    movlw 0x0C
    bcf STATUS,Z
    subwf Choise,0
    btfsc STATUS,Z
    goto POINT

    btfss PORTC,1
    goto STDY

    MOVFW dig1
    MOVWF AARGB0
    MOVFW dig2
    movwf AARGB1
    MOVFW dig3
    movwf AARGB2
    CALL FLO32
    btfsc z1,1
    goto II
    btfsc z1,0
    call ZERO1
    btfss PORTC,0
    call ZERO1
    II movfw m1
    movwf BEXP
    movfw m2
    movwf BARGB0
    movfw m3
    movwf BARGB1
    movfw m4
    movwf BARGB2
    CALL FPS32
    BCF SI,0
    BTFSC AARGB0,7
    BSF SI,0
    BCF AARGB0,7

    MOVFW c1
    MOVWF BEXP
    MOVFW c2
    movwf BARGB0
    MOVFW c3
    movwf BARGB1
    MOVFW c4
    MOVWF BARGB2
    CALL FPD32
    CALL INT32
    movfw AARGB2
    movwf dig1
    movfw AARGB3
    movwf dig2

    btfss z1,1
    goto GH1
    movfw dig1
    bcf STATUS,Z
    bcf STATUS,C
    subwf Fzero1,0
    btfss STATUS,C
    goto NOTH1
    btfss STATUS,Z
    goto GH1
    movfw dig2
    bcf STATUS,Z
    bcf STATUS,C
    subwf Fzero2,0
    btfss STATUS,C
    goto NOTH1
    btfsc STATUS,Z
    goto NOTH1

    GH1
    bcf z1,1
    movfw dig1
    bcf STATUS,Z
    bcf STATUS,C
    subwf Loff1,0
    btfss STATUS,C
    goto NOTH
    btfss STATUS,Z
    goto GH
    movfw dig2
    bcf STATUS,Z
    bcf STATUS,C
    subwf Loff2,0
    btfss STATUS,C
    goto NOTH
    btfsc STATUS,Z
    goto NOTH
    GH
    movfw dig1
    movwf AARGB0
    movfw dig2
    movwf AARGB1
    call MULT

    movfw AARGB1
    movwf H_byte
    movfw AARGB2
    movwf L_byte
    call B2_BCD
    movlw 0x17
    movwf lo
    call UPD
    GOTO AQ

    NOTH
    MOVLW 0X0a
    MOVWF ddig1
    MOVWF ddig4
    MOVLW 0X0f
    MOVWF ddig5
    MOVLW 0X0b
    MOVWF ddig3
    MOVWF ddig2
    movlw 0x50
    movwf lo
    CALL WE
    GOTO AQ

    NOTH1
    MOVLW 0X0b
    MOVWF ddig1
    MOVWF ddig4
    MOVLW 0X0f
    MOVWF ddig5
    MOVLW 0X0b
    MOVWF ddig3
    MOVWF ddig2
    movlw 0x50
    movwf lo
    CALL WE
    GOTO AQ

    STDY
    bcf z1,2
    MOVLW 0X01
    MOVWF Choise
    MOVLW 0X0a
    MOVWF ddig1
    MOVWF ddig5
    MOVLW 0X00
    MOVWF ddig4
    MOVLW 0X0e
    MOVWF ddig3
    MOVWF ddig2
    movlw 0xff
    movwf lo
    CALL WE

    movlw 0x02 ;single write to mode reg
    movwf SSPBUF
    call Send
    movlw 0x61 ;
    movwf SSPBUF
    call Send
    movlw 0x80
    movwf SSPBUF
    call Send

    STDY1
    MOVLW 0X0f
    MOVWF ddig1
    MOVWF ddig2
    MOVWF ddig3
    MOVWF ddig4
    MOVWF ddig5
    movlw 0x08
    MOVWF ddig6
    movlw 0x00
    movwf lo
    CALL WE
    btfss PORTC,1
    goto PP7
    goto STDY1

    Send
    bsf STATUS,RP0 ;select Bank0
    btfss SSPSTAT,BF ;check for BF set
    goto Send ;continue to wait
    bcf SSPSTAT,BF
    bcf STATUS,RP0 ;select Bank1
    return

    INP
    call DEL
    movfw Mode
    andlw 0x03
    movwf Input
    INP2 movlw 0x02
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO INP1
    movlw 0x0f
    movwf ddig2
    movwf ddig3
    movwf ddig4
    movlw 0x50
    movwf lo
    MOVLW 0x11
    MOVWF ddig5
    movfw Input
    movwf ddig1
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    GOTO INCR7
    GOTO INP2
    INCR7
    BCF STATUS,Z
    movlw 0x04
    INCF Input,1
    subwf Input,0
    btfsc STATUS,Z
    clrf Input
    goto INP2

    INP1
    bcf Mode,0
    bcf Mode,1
    movfw Input
    addwf Mode,1

    bcf STATUS,5
    bsf STATUS,6
    movfw Mode
    movwf EEDATA
    movlw 0x07
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    RANG
    swapf Mode,0
    andlw 0x03
    movwf Range
    RANG2 movlw 0x03
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO RANG1
    movlw 0x0f
    movwf ddig2
    movwf ddig3
    movwf ddig4
    movlw 0x50
    movwf lo
    MOVLW 0x02
    MOVWF ddig5
    movfw Range
    movwf ddig1
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    GOTO INCR8
    GOTO RANG2
    INCR8
    BCF STATUS,Z
    movlw 0x04
    INCF Range,1
    subwf Range,0
    btfsc STATUS,Z
    clrf Range
    goto RANG2

    RANG1
    swapf Mode,1
    bcf Mode,0
    bcf Mode,1
    movfw Range
    addwf Mode,1
    swapf Mode,1

    bcf STATUS,5
    bsf STATUS,6
    movfw Mode
    movwf EEDATA
    movlw 0x07
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP
    AC
    clrf temp
    AC2 movlw 0x04
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO AC1
    movlw 0x0f
    movwf ddig2
    movwf ddig3
    movwf ddig4
    movlw 0x50
    movwf lo
    MOVLW 0x03
    MOVWF ddig5
    movfw temp
    movwf ddig1
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    GOTO INCR9
    GOTO AC2
    INCR9
    BCF STATUS,Z
    movlw 0x02
    INCF temp,1
    subwf temp,0
    btfsc STATUS,Z
    clrf temp
    goto AC2

    AC1
    bcf F3,5
    btfsc temp,0
    bsf F3,5
    bcf STATUS,5
    bsf STATUS,6
    movfw F3
    movwf EEDATA
    movlw 0x0F
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP
    return
    FILT
    movlw 0x0A
    movwf ddig1
    movwf ddig2
    movwf ddig3
    movwf ddig4
    movwf ddig5
    movlw 0x50
    movwf lo
    call UPD
    BCF STATUS,C
    RRF F2,1
    BCF STATUS,C
    RRF F2,1
    BCF STATUS,C
    RRF F2,1
    BCF STATUS,C
    RRF F2,1
    MOVFW F1
    MOVWF temp
    swapf temp,0
    andlw 0xf0
    iorwf F2,1
    SWAPF F1,0
    ANDLW 0X0F
    MOVWF F1
    TT
    movlw 0x05
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO PO1
    MOVFW F1
    MOVWF H_byte
    MOVFW F2
    MOVWF L_byte
    CALL B2_BCD
    movlw 0x05
    movwf lo
    MOVLW 0x0E
    MOVWF ddig5
    CALL UPD
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,1
    GOTO DECR
    BTFSS PORTC,2
    GOTO INCR
    GOTO TT

    INCR INCFSZ F2,1
    GOTO TT
    INCF F1,1
    GOTO TT

    DECR DECFSZ F2,1
    GOTO TT
    DECF F1,1
    GOTO TT

    PO1
    BCF STATUS,C
    RLF F1,1
    BCF STATUS,C
    RLF F1,1
    BCF STATUS,C
    RLF F1,1
    BCF STATUS,C
    RLF F1,1
    MOVFW F2
    MOVWF temp
    swapf temp,0
    andlw 0x0f
    iorwf F1,1
    SWAPF F2,0
    ANDLW 0XF0
    MOVWF F2
    bcf STATUS,5
    bsf STATUS,6
    movfw F1
    movwf EEDATA
    movlw 0x20
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw F2
    movwf EEDATA
    movlw 0x21
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    ZERO1
    bcf z1,0
    movfw AEXP
    movwf m1
    movfw AARGB0
    movwf m2
    movfw AARGB1
    movwf m3
    movfw AARGB2
    movwf m4
    movlw 0xff
    movwf d2
    KL decfsz d2,1
    goto KL
    return


    ZERO
    movlw 0x06
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    MOVFW dig1
    MOVWF AARGB0
    MOVFW dig2
    movwf AARGB1
    MOVFW dig3
    movwf AARGB2
    CALL FLO32
    movfw dig2
    movwf H_byte
    movfw dig3
    movwf L_byte
    call B2_BCD
    movlw 0x50
    movwf lo
    movlw 0x05
    movwf ddig6
    call WE
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    incf Choise,1
    BTFSC PORTC,7
    GOTO AQ

    bcf STATUS,5
    bsf STATUS,6
    movfw AEXP
    movwf EEDATA
    movlw 0x10
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw dig1
    movwf EEDATA
    movlw 0x14
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw dig2
    movwf EEDATA
    movlw 0x15
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw dig3
    movwf EEDATA
    movlw 0x16
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB0
    movwf EEDATA
    movlw 0x11
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB1
    movwf EEDATA
    movlw 0x12
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB2
    movwf EEDATA
    movlw 0x13
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    COEFF
    movlw 0x07
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    movfw dig2
    movwf H_byte
    movfw dig3
    movwf L_byte
    call B2_BCD
    movlw 0x50
    movwf lo
    movlw 0x02
    movwf ddig6
    call WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    incf Choise,1
    BTFSC PORTC,7
    GOTO AQ

    MOVFW dig1
    MOVWF AARGB0
    movfw dig2
    movwf AARGB1
    movfw dig3
    movwf AARGB2

    CALL FLO32
    movfw m1
    movwf BEXP
    movfw m2
    movwf BARGB0
    movfw m3
    movwf BARGB1
    movfw m4
    movwf BARGB2
    call FPS32

    bcf STATUS,5
    bsf STATUS,6
    movfw AEXP
    movwf EEDATA
    movlw 0x08
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB0
    movwf EEDATA
    movlw 0x09
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB1
    movwf EEDATA
    movlw 0x0a
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB2
    movwf EEDATA
    movlw 0x0b
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    DIV
    movlw 0x08
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO DIV1
    MOVFW div5
    MOVWF H_byte
    MOVFW div6
    MOVWF L_byte
    CALL B2_BCD
    movlw 0x0a
    movwf lo
    MOVLW 0x0c
    MOVWF ddig5
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,1
    GOTO DECR1
    BTFSS PORTC,2
    GOTO INCR1
    GOTO DIV

    INCR1 INCFSZ div6,1
    GOTO DIV
    INCF div5,1
    GOTO DIV

    DECR1 DECFSZ div6,1
    GOTO DIV
    DECF div5,1
    GOTO DIV

    DIV1
    movfw div5
    movwf AARGB1
    movfw div6
    movwf AARGB2
    MOVLW 0X00
    MOVWF AARGB0
    CALL FLO32

    MOVFW AEXP
    MOVWF BEXP
    MOVFW AARGB0
    MOVWF BARGB0
    MOVFW AARGB1
    MOVWF BARGB1
    MOVFW AARGB2
    MOVWF BARGB2
    movlw 0x08
    call EEREAD
    movwf AEXP
    movlw 0x09
    call EEREAD
    movwf AARGB0
    movlw 0x0a
    call EEREAD
    movwf AARGB1
    movlw 0x0b
    call EEREAD
    movwf AARGB2
    CALL FPD32

    bcf STATUS,5
    bsf STATUS,6
    movfw AEXP
    movwf EEDATA
    movlw 0x00
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB0
    movwf EEDATA
    movlw 0x01
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB1
    movwf EEDATA
    movlw 0x02
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB2
    movwf EEDATA
    movlw 0x03
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    bcf STATUS,C

    bcf STATUS,5
    bsf STATUS,6
    movfw div5
    movwf EEDATA
    movlw 0x34
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw div6
    movwf EEDATA
    movlw 0x35
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    CALL INT32
    bcf STATUS,5
    bsf STATUS,6
    movfw AARGB2
    movwf EEDATA
    movlw 0x18
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    incf Choise,1
    GOTO POP

    BEG
    movlw 0x0B
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO Begin1
    MOVFW Fzero1
    MOVWF H_byte
    MOVFW Fzero2
    MOVWF L_byte
    CALL B2_BCD
    movlw 0x04
    movwf lo
    MOVLW 0x01
    MOVWF ddig5
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,1
    GOTO DECR4
    BTFSS PORTC,2
    GOTO INCR4
    GOTO BEG

    INCR4 INCFSZ Fzero2,1
    GOTO BEG
    INCF Fzero1,1
    GOTO BEG

    DECR4 DECFSZ Fzero2,1
    GOTO BEG
    DECF Fzero1,1
    GOTO BEG

    Begin1
    bcf STATUS,5
    bsf STATUS,6
    movfw Fzero1
    movwf EEDATA
    movlw 0x22
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw Fzero2
    movwf EEDATA
    movlw 0x23
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    UPP
    movlw 0x0A
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO Upper1
    MOVFW Loff1
    MOVWF H_byte
    MOVFW Loff2
    MOVWF L_byte
    CALL B2_BCD
    movlw 0x04
    movwf lo
    MOVLW 0x09
    MOVWF ddig5
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,1
    GOTO DECR3
    BTFSS PORTC,2
    GOTO INCR3
    GOTO UPP

    INCR3 INCFSZ Loff2,1
    GOTO UPP
    INCF Loff1,1
    GOTO UPP

    DECR3 DECFSZ Loff2,1
    GOTO UPP
    DECF Loff1,1
    GOTO UPP

    Upper1
    bcf STATUS,5
    bsf STATUS,6
    movfw Loff1
    movwf EEDATA
    movlw 0x05
    movwf EEADR
    call EEWRITE
    bcf STATUS,6

    bcf STATUS,5
    bsf STATUS,6
    movfw Loff2
    movwf EEDATA
    movlw 0x06
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    MULQ
    movlw 0x09
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO MULQ1
    movlw 0x0f
    movwf ddig2
    movwf ddig3
    movwf ddig4
    movlw 0x50
    movwf lo
    MOVLW 0x0a
    MOVWF ddig5
    movfw Multip
    movwf ddig1
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    GOTO INCR2
    GOTO MULQ
    INCR2
    BCF STATUS,Z
    movlw 0x06
    INCF Multip,1
    subwf Multip,0
    btfsc STATUS,Z
    clrf Multip
    goto MULQ

    MULQ1
    bcf STATUS,5
    bsf STATUS,6
    movfw Multip
    movwf EEDATA
    movlw 0x04
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    incf Choise,1
    GOTO POP

    POINT
    MOVLW 0X80
    movwf point
    POINT2 movlw 0x0C
    bcf STATUS,Z
    subwf Choise,0
    btfss STATUS,Z
    goto POP
    BTFSS PORTC,7
    GOTO POINT1
    movlw 0x0f
    movwf ddig2
    movwf ddig3
    movwf ddig4
    MOVWF ddig5
    movwf ddig1
    movlw 0x50
    movwf lo
    CALL WE
    BCF STATUS,C
    BTFSS PORTC,0
    decf Choise,1
    BTFSS PORTC,2
    GOTO INCR11
    GOTO POINT2
    INCR11
    BCF STATUS,Z
    movlw 0x01
    bcf STATUS,C
    RRF point,1
    subwf point,0
    btfss STATUS,Z
    goto POINT2
    movlw 0x80
    movwf point
    goto POINT2

    POINT1
    bcf STATUS,5
    bsf STATUS,6
    movfw point
    movwf EEDATA
    movlw 0x17
    movwf EEADR
    call EEWRITE
    bcf STATUS,6
    movlw 0x01
    movwf Choise
    GOTO POP
    EEWRITE

    BSF STATUS, RP1 ;
    BSF STATUS, RP0 ; Bank 3
    BCF EECON1, EEPGD ; Point to DATA memory
    BSF EECON1, WREN ; Enable writes
    bcf INTCON, GIE
    movlw 0x055
    movwf EECON2 & 0x07F
    movlw 0x0AA
    movwf EECON2 & 0x07F
    bsf EECON1 & 0x07F, WR
    bcf EECON1 & 0x07F, WREN
    EELoop
    clrwdt
    btfsc EECON1 & 0x07F, WR
    goto EELoop
    bcf INTCON, GIE
    BCF STATUS, RP1
    BCF STATUS, RP0
    RETURN

    EEREAD ; Read from EE Address in "w"
    BSF STATUS, RP1 ;
    BCF STATUS, RP0
    MOVWF EEADR
    BSF STATUS,RP0
    BCF EECON1, EEPGD ;Point to DATA memory
    BSF EECON1, RD ;EEPROM Read
    BCF STATUS, RP0 ;Bank 2
    MOVFW EEDATA ;W = EEDATA
    BCF STATUS, RP1 ;
    BCF STATUS, RP0 ;Bank 2
    RETURN


    B2_BCD

    bcf STATUS,0 ; clear the carry bit
    movlw .16
    movwf count
    clrf R0
    clrf R1
    clrf R2
    loop16 rlf L_byte, F
    rlf H_byte, F
    rlf R2, F
    rlf R1, F
    rlf R0, F
    ;
    decfsz count, F
    goto adjDEC
    movfw R0
    movwf ddig5
    movfw R1
    movwf ddig3
    swapf R1,0
    movwf ddig4
    movfw R2
    movwf ddig1
    swapf R2,0
    movwf ddig2
    return
    ;
    adjDEC movlw R2
    movwf FSR
    call adjBCD
    ;
    movlw R1
    movwf FSR
    call adjBCD
    ;
    movlw R0
    movwf FSR
    call adjBCD
    ;
    goto loop16
    ;
    adjBCD movlw 3
    addwf 0,W
    movwf temp
    btfsc temp,3 ; test if result > 7
    movwf 0
    movlw 30
    addwf 0,W
    movwf temp
    btfsc temp,7 ; test if result > 7
    movwf 0 ; save as MSD
    RETLW 0

    DEL
    movlw 0xFF
    movwf d1
    MP decfsz d1,1
    goto MP
    return


    UPD
    movlw 0x0f
    movwf ddig6
    BCF STATUS,Z
    MOVFW ddig4
    btfss STATUS,Z
    GOTO III
    BCF STATUS,Z
    MOVFW ddig3
    btfss STATUS,Z
    GOTO III
    BCF STATUS,Z
    MOVFW ddig2
    btfss STATUS,Z
    GOTO III
    BCF STATUS,Z
    MOVFW ddig1
    btfss STATUS,Z
    GOTO III
    clrf SI
    movlw 0x05
    movwf ddig6
    III
    BCF STATUS,Z
    MOVFW ddig5
    btfss STATUS,Z
    GOTO WE
    MOVLW 0X0f
    MOVWF ddig5
    btfss SI,0
    GOTO WE
    MOVLW 0X0A
    MOVWF ddig5

    WE
    LO decfsz lo,1
    goto LO1
    return
    LO1
    movfw ddig1
    ANDLW 0X0F
    call segmenti
    movwf PORTB
    ; btfsc point,2
    BSF PORTB,7
    bsf PORTA,0
    call DEL
    bcf PORTA,0
    BCF PORTB,7

    movfw ddig2
    ANDLW 0X0F
    call segmenti
    movwf PORTB
    ; btfsc point,3
    ; BSF PORTB,7
    bsf PORTA,1
    call DEL
    bcf PORTA,1
    ; BCF PORTB,7

    movfw ddig3
    ANDLW 0X0F
    call segmenti
    movwf PORTB
    ; btfsc point,4
    ; BSF PORTB,7
    bsf PORTA,2
    call DEL
    bcf PORTA,2
    ; BCF PORTB,7

    movfw ddig4
    ANDLW 0X0F
    call segmenti
    movwf PORTB
    ; btfsc point,5
    ; BSF PORTB,7
    bsf PORTA,3
    call DEL
    bcf PORTA,3
    ; BCF PORTB,7

    movfw ddig5
    ANDLW 0X0F
    call segmenti
    movwf PORTB
    ; btfsc point,6
    ; BSF PORTB,7
    bsf PORTC,6
    call DEL
    bcf PORTC,6
    ; BCF PORTB,7

    movfw ddig6
    ANDLW 0X0F
    call segmenti
    movwf PORTB
    bsf PORTA,5
    call DEL
    bcf PORTA,5
    goto LO
    FLO32
    MOVLW 0X96
    MOVWF EXP
    CLRF SIGN
    BTFSS AARGB0,7
    GOTO NRM3232
    COMF AARGB2,F
    COMF AARGB1,F
    COMF AARGB0,F
    INCF AARGB2,F
    BTFSC STATUS,Z
    INCF AARGB1,F
    BTFSC STATUS,Z
    INCF AARGB0,F
    BSF SIGN,7

    NRM3232
    NRM32
    CLRF TEMP
    MOVF AARGB0,W
    BTFSS STATUS,Z
    GOTO NORM3232
    MOVF AARGB1,W
    MOVWF AARGB0
    MOVF AARGB2,W
    MOVWF AARGB1
    CLRF AARGB2
    BSF TEMP,3
    MOVF AARGB0,W
    BTFSS STATUS,Z
    GOTO NORM3232
    MOVF AARGB1,W
    MOVWF AARGB0
    CLRF AARGB1
    BCF TEMP,3
    BSF TEMP,4
    MOVF AARGB0,W
    BTFSC STATUS,Z
    GOTO RES032
    NORM3232
    MOVF TEMP,W
    SUBWF EXP,F
    BTFSS STATUS,Z
    BTFSS STATUS,C
    GOTO SETFUN32
    BCF STATUS,C
    NORM3232A
    BTFSC AARGB0,7
    GOTO FIXSIGN32
    RLF AARGB2,F
    RLF AARGB1,F
    RLF AARGB0,F
    DECFSZ EXP,F
    GOTO NORM3232A
    GOTO SETFUN32
    FIXSIGN32
    BTFSS SIGN,7
    BCF AARGB0,7
    RETLW 0X00
    RES032
    CLRF AARGB0
    CLRF AARGB1
    CLRF AARGB2
    CLRF AARGB3
    CLRF EXP
    RETLW 0X00

    INT32
    CLRF AARGB3
    MOVF EXP,W ; test for zero argument
    BTFSC STATUS,Z
    RETLW 0x00

    MOVF AARGB0,W ; save sign in SIGN
    MOVWF SIGN
    BSF AARGB0,7 ; make MSB explicit

    MOVLW 0X9E ; remove bias from EXP
    SUBWF EXP,F
    BTFSS EXP,7
    GOTO SETIOV32
    COMF EXP,F
    INCF EXP,F

    MOVLW 0X08 ; do byte shift if EXP >= 8
    SUBWF EXP,W
    BTFSS STATUS,C
    GOTO TSHIFT3232
    MOVWF EXP
    RLF AARGB3,F ; rotate next bit for rounding
    MOVF AARGB2,W
    MOVWF AARGB3
    MOVF AARGB1,W
    MOVWF AARGB2
    MOVF AARGB0,W
    MOVWF AARGB1
    CLRF AARGB0

    MOVLW 0X08 ; do another byte shift if EXP >= 8
    SUBWF EXP,W
    BTFSS STATUS,C
    GOTO TSHIFT3232
    MOVWF EXP
    RLF AARGB3,F ; rotate next bit for rounding
    MOVF AARGB2,W
    MOVWF AARGB3
    MOVF AARGB1,W
    MOVWF AARGB2
    CLRF AARGB1

    MOVLW 0X08 ; do another byte shift if EXP >= 8
    SUBWF EXP,W
    BTFSS STATUS,C
    GOTO TSHIFT3232
    MOVWF EXP
    RLF AARGB3,F ; rotate next bit for rounding
    MOVF AARGB2,W
    MOVWF AARGB3
    CLRF AARGB2

    MOVLW 0X08 ; do another byte shift if EXP >= 8
    SUBWF EXP,W
    BTFSS STATUS,C
    GOTO TSHIFT3232
    MOVWF EXP
    RLF AARGB3,F ; rotate next bit for rounding
    CLRF AARGB3
    MOVF EXP,W
    BTFSS STATUS,Z
    BCF STATUS,C
    GOTO SHIFT3232OK

    TSHIFT3232
    MOVF EXP,W ; shift completed if EXP = 0
    BTFSC STATUS,Z
    GOTO SHIFT3232OK

    SHIFT3232
    BCF STATUS,C
    RRF AARGB0,F ; right shift by EXP
    RRF AARGB1,F
    RRF AARGB2,F
    RRF AARGB3,F
    DECFSZ EXP,F
    GOTO SHIFT3232

    SHIFT3232OK
    BTFSC FPFLAGS,RND
    BTFSS AARGB3,0
    GOTO INT3232OK
    BTFSS STATUS,C
    GOTO INT3232OK
    INCF AARGB3,F
    BTFSC STATUS,Z
    INCF AARGB2,F
    BTFSC STATUS,Z
    INCF AARGB1,F
    BTFSC STATUS,Z
    INCF AARGB0,F
    BTFSC AARGB0,7 ; test for overflow
    GOTO SETIOV3224

    INT3232OK
    BTFSS SIGN,7 ; if sign bit set, negate
    RETLW 0X00
    COMF AARGB0,F
    COMF AARGB1,F
    COMF AARGB2,F
    COMF AARGB3,F
    INCF AARGB3,F
    BTFSC STATUS,Z
    INCF AARGB2,F
    BTFSC STATUS,Z
    INCF AARGB1,F
    BTFSC STATUS,Z
    INCF AARGB0,F
    RETLW 0X00

    IRES032 CLRF AARGB0 ; integer result equals zero
    CLRF AARGB1
    CLRF AARGB2
    CLRF AARGB3
    RETLW 0X00

    SETIOV32
    BSF FPFLAGS,IOV ; set integer overflow flag
    BTFSS FPFLAGS,SAT ; test for saturation
    RETLW 0xFF ; return error code in WREG

    CLRF AARGB0 ; saturate to largest two's
    BTFSS SIGN,7 ; complement 32 bit integer
    MOVLW 0xFF
    MOVWF AARGB0 ; SIGN = 0, 0x 7F FF FF FF
    MOVWF AARGB1 ; SIGN = 1, 0x 80 00 00 00
    MOVWF AARGB2
    MOVWF AARGB3
    RLF SIGN,F
    RRF AARGB0,F
    RETLW 0xFF ; return error code in WREG
    SETIOV3224
    BSF FPFLAGS,IOV
    BTFSS FPFLAGS,SAT
    RETLW 0xFF
    CLRF AARGB0
    BTFSS SIGN,7
    MOVLW 0xFF
    MOVWF AARGB0
    MOVWF AARGB1
    MOVWF AARGB2
    RLF SIGN,F
    RRF AARGB0,F
    RETLW 0xFF

    NRM4032
    CLRF TEMP
    MOVF AARGB0,W ; test if highbyte=0
    BTFSS STATUS,Z
    GOTO NORM4032
    MOVF AARGB1,W ; if so, shift 8 bits by move
    MOVWF AARGB0
    MOVF AARGB2,W
    MOVWF AARGB1
    MOVF AARGB3,W
    MOVWF AARGB2
    CLRF AARGB3
    BSF TEMP,3 ; increase decrement by 8
    MOVF AARGB0,W ; test if highbyte=0
    BTFSS STATUS,Z
    GOTO NORM4032
    MOVF AARGB1,W ; if so, shift 8 bits by move
    MOVWF AARGB0
    MOVF AARGB2,W
    MOVWF AARGB1
    CLRF AARGB2
    BCF TEMP,3 ; increase decrement by 8
    BSF TEMP,4
    MOVF AARGB0,W ; test if highbyte=0
    BTFSS STATUS,Z
    GOTO NORM4032
    MOVF AARGB1,W ; if so, shift 8 bits by move
    MOVWF AARGB0
    CLRF AARGB1
    BSF TEMP,3 ; increase decrement by 8
    MOVF AARGB0,W ; if highbyte=0, result=0
    BTFSC STATUS,Z
    GOTO RES032
    NORM4032
    MOVF TEMP,W
    SUBWF EXP,F
    BTFSS STATUS,Z
    BTFSS STATUS,C
    GOTO SETFUN32
    BCF STATUS,C ; clear carry bit
    NORM4032A
    BTFSC AARGB0,7 ; if MSB=1, normalization done
    GOTO NRMRND4032
    RLF AARGB3,F ; otherwise, shift left and
    RLF AARGB2,F ; decrement EXP
    RLF AARGB1,F
    RLF AARGB0,F
    DECFSZ EXP,F
    GOTO NORM4032A
    GOTO SETFUN32 ; underflow if EXP=0

    NRMRND4032
    BTFSC FPFLAGS,RND
    BTFSS AARGB2,0
    GOTO FIXSIGN32
    BTFSS AARGB3,7 ; round if next bit is set
    GOTO FIXSIGN32
    INCF AARGB2,F
    BTFSC STATUS,Z
    INCF AARGB1,F
    BTFSC STATUS,Z
    INCF AARGB0,F
    BTFSS STATUS,Z ; has rounding caused carryout?
    GOTO FIXSIGN32
    RRF AARGB0,F ; if so, right shift
    RRF AARGB1,F
    RRF AARGB2,F
    INCF EXP,F
    BTFSC STATUS,Z ; check for overflow
    GOTO SETFOV32
    GOTO FIXSIGN32

    FPD32
    MOVF BEXP,W ; test for divide by zero
    BTFSC STATUS,Z
    GOTO SETFDZ32
    MOVF AEXP,W
    BTFSC STATUS,Z
    GOTO RES032
    D32BNE0
    MOVF AARGB0,W
    XORWF BARGB0,W
    MOVWF SIGN ; save sign in SIGN
    BSF AARGB0,7 ; make argument MSB’s explicit
    BSF BARGB0,7
    TALIGN32
    CLRF TEMP ; clear align increment
    MOVF AARGB0,W
    MOVWF AARGB3 ; test for alignment
    MOVF AARGB1,W
    MOVWF AARGB4
    MOVF AARGB2,W
    MOVWF AARGB5
    MOVF BARGB2,W
    SUBWF AARGB5,F
    MOVF BARGB1,W
    BTFSS STATUS,C
    INCFSZ BARGB1,W
    TS1ALIGN32
    SUBWF AARGB4,F
    MOVF BARGB0,W
    BTFSS STATUS,C
    INCFSZ BARGB0,W
    TS2ALIGN32
    SUBWF AARGB3,F
    CLRF AARGB3
    CLRF AARGB4
    CLRF AARGB5
    BTFSS STATUS,C
    GOTO DALIGN32OK
    BCF STATUS,C ; align if necessary
    RRF AARGB0,F
    RRF AARGB1,F
    RRF AARGB2,F
    RRF AARGB3,F
    MOVLW 0x01
    MOVWF TEMP ; save align increment
    DALIGN32OK
    MOVF BEXP,W ; compare AEXP and BEXP
    SUBWF EXP,F
    BTFSS STATUS,C
    GOTO ALTB32
    AGEB32
    MOVLW 0X7E
    ADDWF TEMP,W
    ADDWF EXP,F
    BTFSC STATUS,C
    GOTO SETFOV32
    GOTO DARGOK32 ; set overflow flag
    ALTB32
    MOVLW 0X7E
    ADDWF TEMP,W
    ADDWF EXP,F
    BTFSS STATUS,C
    GOTO SETFUN32 ; set underflow flag
    DARGOK32
    MOVLW 0X18 ; initialize counter
    MOVWF TEMPB1
    DLOOP32
    RLF AARGB5,F ; left shift
    RLF AARGB4,F
    RLF AARGB3,F
    RLF AARGB2,F
    RLF AARGB1,F
    RLF AARGB0,F
    RLF TEMP,F
    MOVF BARGB2,W ; subtract
    SUBWF AARGB2,F
    MOVF BARGB1,W
    BTFSS STATUS,C
    INCFSZ BARGB1,W
    DS132
    SUBWF AARGB1,F
    MOVF BARGB0,W
    BTFSS STATUS,C
    INCFSZ BARGB0,W
    DS232
    SUBWF AARGB0,F
    RLF BARGB0,W
    IORWF TEMP,F
    BTFSS TEMP,0 ; test for restore
    GOTO DREST32
    BSF AARGB5,0
    GOTO DOK32
    DREST32
    MOVF BARGB2,W ; restore if necessary
    ADDWF AARGB2,F
    MOVF BARGB1,W
    BTFSC STATUS,C
    INCFSZ BARGB1,W
    DAREST32
    ADDWF AARGB1,F
    MOVF BARGB0,W
    BTFSC STATUS,C
    INCF BARGB0,W
    ADDWF AARGB0,F
    BCF AARGB5,0
    DOK32 DECFSZ TEMPB1,F
    GOTO DLOOP32
    DROUND32
    BTFSC FPFLAGS,RND
    BTFSS AARGB5,0
    GOTO DIV32OK
    BCF STATUS,C
    RLF AARGB2,F ; compute next significant bit
    RLF AARGB1,F ; for rounding
    RLF AARGB0,F
    RLF TEMP,F
    MOVF BARGB2,W ; subtract
    SUBWF AARGB2,F
    MOVF BARGB1,W
    BTFSS STATUS,C
    INCFSZ BARGB1,W
    SUBWF AARGB1,F
    MOVF BARGB0,W
    BTFSS STATUS,C
    INCFSZ BARGB0,W
    SUBWF AARGB0,F
    RLF BARGB0,W
    IORWF TEMP,W
    ANDLW 0x01
    ADDWF AARGB5,F
    BTFSC STATUS,C
    INCF AARGB4,F
    BTFSC STATUS,Z
    INCF AARGB3,F
    BTFSS STATUS,Z ; test if rounding caused carryout
    GOTO DIV32OK
    RRF AARGB3,F
    RRF AARGB4,F
    RRF AARGB5,F
    INCF EXP,F
    BTFSC STATUS,Z ; test for overflow
    GOTO SETFOV32
    DIV32OK BTFSS SIGN,7
    BCF AARGB3,7 ; clear explicit MSB if positive
    MOVF AARGB3,W
    MOVWF AARGB0 ; move result to AARG
    MOVF AARGB4,W
    MOVWF AARGB1
    MOVF AARGB5,W
    MOVWF AARGB2
    RETLW 0
    SETFUN32
    BSF FPFLAGS,FUN ; set floating point underflag
    BTFSS FPFLAGS,SAT ; test for saturation
    RETLW 0xFF ; return error code in WREG
    MOVLW 0x01 ; saturate to smallest floating
    MOVWF AEXP ; point number = 0x 01 00 00 00
    CLRF AARGB0 ; modulo the appropriate sign bit
    CLRF AARGB1
    CLRF AARGB2
    RLF SIGN,F
    RRF AARGB0,F
    RETLW 0xFF ; return error code in WREG
    SETFDZ32
    BSF FPFLAGS,FDZ ; set divide by zero flag
    RETLW 0xFF

    FPS32 MOVLW 0x80
    XORWF BARGB0,F

    FPA32
    MOVF AARGB0,W ; exclusive or of signs in TEMP
    XORWF BARGB0,W
    MOVWF TEMP
    CLRF AARGB3 ; clear extended byte
    CLRF BARGB3
    MOVF AEXP,W ; use AARG if AEXP >= BEXP
    SUBWF BEXP,W
    BTFSS STATUS,C
    GOTO USEA32
    MOVF BEXP,W ; use BARG if AEXP < BEXP
    MOVWF AARGB5 ; therefore, swap AARG and BARG
    MOVF AEXP,W
    MOVWF BEXP
    MOVF AARGB5,W
    MOVWF AEXP
    MOVF BARGB0,W
    MOVWF AARGB5
    MOVF AARGB0,W
    MOVWF BARGB0
    MOVF AARGB5,W
    MOVWF AARGB0
    MOVF BARGB1,W
    MOVWF AARGB5
    MOVF AARGB1,W
    MOVWF BARGB1
    MOVF AARGB5,W
    MOVWF AARGB1
    MOVF BARGB2,W
    MOVWF AARGB5
    MOVF AARGB2,W
    MOVWF BARGB2
    MOVF AARGB5,W
    MOVWF AARGB2
    USEA32
    MOVF BEXP,W ; return AARG if BARG = 0
    BTFSC STATUS,Z
    RETLW 0x00
    MOVF AARGB0,W
    MOVWF SIGN ; save sign in SIGN
    BSF AARGB0,7 ; make MSB’s explicit
    BSF BARGB0,7
    MOVF BEXP,W ; compute shift count in BEXP
    SUBWF AEXP,W
    MOVWF BEXP
    BTFSC STATUS,Z
    GOTO ALIGNED32
    MOVLW 0X08
    SUBWF BEXP,W
    BTFSS STATUS,C ; if BEXP >= 8, do byte shift
    GOTO ALIGNB32
    MOVWF BEXP
    MOVF BARGB2,W ; keep for postnormalization
    MOVWF BARGB3
    MOVF BARGB1,W
    MOVWF BARGB2
    MOVF BARGB0,W
    MOVWF BARGB1
    CLRF BARGB0
    MOVLW 0X08
    SUBWF BEXP,W
    BTFSS STATUS,C ; if BEXP >= 8, do byte shift
    GOTO ALIGNB32
    MOVWF BEXP
    MOVF BARGB2,W ; keep for postnormalization
    MOVWF BARGB3
    MOVF BARGB1,W
    MOVWF BARGB2
    CLRF BARGB1
    MOVLW 0X08
    SUBWF BEXP,W
    BTFSS STATUS,C ; if BEXP >= 8, BARG = 0 relative to AARG
    GOTO ALIGNB32
    MOVF SIGN,W
    MOVWF AARGB0
    RETLW 0x00
    ALIGNB32
    MOVF BEXP,W ; already aligned if BEXP = 0
    BTFSC STATUS,Z
    GOTO ALIGNED32
    ALOOPB32
    BCF STATUS,C ; right shift by BEXP
    RRF BARGB0,F
    RRF BARGB1,F
    RRF BARGB2,F
    RRF BARGB3,F
    DECFSZ BEXP,F
    GOTO ALOOPB32
    ALIGNED32
    BTFSS TEMP,7 ; negate if signs opposite
    GOTO AOK32
    COMF BARGB3,F
    COMF BARGB2,F
    COMF BARGB1,F
    COMF BARGB0,F
    INCF BARGB3,F
    BTFSC STATUS,Z
    INCF BARGB2,F
    BTFSC STATUS,Z
    INCF BARGB1,F
    BTFSC STATUS,Z
    INCF BARGB0,F
    AOK32
    MOVF BARGB3,W
    ADDWF AARGB3,F
    MOVF BARGB2,W
    BTFSC STATUS,C
    INCFSZ BARGB2,W
    ADDWF AARGB2,F
    MOVF BARGB1,W
    BTFSC STATUS,C
    INCFSZ BARGB1,W
    ADDWF AARGB1,F
    MOVF BARGB0,W
    BTFSC STATUS,C
    INCFSZ BARGB0,W
    ADDWF AARGB0,F
    BTFSC TEMP,7
    GOTO ACOMP32
    BTFSS STATUS,C
    GOTO NRMRND4032
    RRF AARGB0,F ; shift right and increment EXP
    RRF AARGB1,F
    RRF AARGB2,F
    RRF AARGB3,F
    INCFSZ AEXP,F
    GOTO NRMRND4032
    GOTO SETFOV32
    ACOMP32
    BTFSC STATUS,C
    GOTO NRM4032 ; normalize and fix sign
    COMF AARGB3,F
    COMF AARGB2,F ; negate, toggle sign bit and
    COMF AARGB1,F ; then normalize
    COMF AARGB0,F
    INCF AARGB3,F
    BTFSC STATUS,Z
    INCF AARGB2,F
    BTFSC STATUS,Z
    INCF AARGB1,F
    BTFSC STATUS,Z
    INCF AARGB0,F
    MOVLW 0x80
    XORWF SIGN,F
    GOTO NRM32

    SETFOV32
    BSF FPFLAGS,FOV ; set floating point underflag
    BTFSS FPFLAGS,SAT ; test for saturation
    RETLW 0xFF ; return error code in WREG
    MOVLW 0xFF
    MOVWF AEXP ; saturate to largest floating
    MOVWF AARGB0 ; point number = 0x FF 7F FF FF
    MOVWF AARGB1 ; modulo the appropriate sign bit
    MOVWF AARGB2
    RLF SIGN,F
    RRF AARGB0,F
    RETLW 0xFF ; return error code in WREG

    FPM32 MOVF AEXP,0 ; test for zero arguments
    BTFSS STATUS,Z
    MOVF BEXP,0
    BTFSC STATUS,Z
    GOTO RES032
    M32BNE0 MOVF AARGB0,0
    XORWF BARGB0,0
    MOVWF SIGN ; save sign in SIGN
    MOVF BEXP,0
    ADDWF EXP,1
    MOVLW 0x7e
    BTFSS STATUS,C
    GOTO MTUN32
    SUBWF EXP,1
    BTFSC STATUS,C
    GOTO SETFOV32 ; set multiply overflow flag
    GOTO MOK32
    MTUN32 SUBWF EXP,1
    BTFSS STATUS,C
    GOTO SETFUN32
    MOK32 MOVF AARGB0,0
    MOVWF AARGB3
    MOVF AARGB1,0
    MOVWF AARGB4
    MOVF AARGB2,0
    MOVWF AARGB5
    BSF AARGB3,7 ; make argument MSB’s explicit
    BSF BARGB0,7
    BCF STATUS,C
    CLRF AARGB0 ; clear initial partial product
    CLRF AARGB1
    CLRF AARGB2
    MOVLW 0X18
    MOVWF TEMP ; initialize counter
    MLOOP32 BTFSS AARGB5,0 ; test next bit
    GOTO MNOADD32
    MADD32 MOVF BARGB2,0
    ADDWF AARGB2,1
    MOVF BARGB1,0
    BTFSC STATUS,C
    INCFSZ BARGB1,0
    ADDWF AARGB1,1
    MOVF BARGB0,0
    BTFSC STATUS,C
    INCFSZ BARGB0,0
    ADDWF AARGB0,1
    MNOADD32
    RRF AARGB0,1
    RRF AARGB1,1
    RRF AARGB2,1
    RRF AARGB3,1
    RRF AARGB4,1
    RRF AARGB5,1
    BCF STATUS,C
    DECFSZ TEMP,1
    GOTO MLOOP32
    BTFSC AARGB0,7 ; check for postnormalization
    GOTO MROUND32
    RLF AARGB3,1
    RLF AARGB2,1
    RLF AARGB1,1
    RLF AARGB0,1
    DECF EXP,1
    MROUND32
    BTFSC FPFLAGS,RND
    BTFSS AARGB2,0
    GOTO MUL32OK
    BTFSS AARGB3,7
    GOTO MUL32OK
    INCF AARGB2,1
    BTFSC STATUS,Z
    INCF AARGB1,1
    BTFSC STATUS,Z
    INCF AARGB0,1
    BTFSS STATUS,Z ; has rounding caused carryout?
    GOTO MUL32OK
    RRF AARGB0,1 ; if so, right shift
    RRF AARGB1,1
    RRF AARGB2,1
    INCF EXP,1
    BTFSC STATUS,Z ; check for overflow
    GOTO SETFOV32
    MUL32OK BTFSS SIGN,7
    BCF AARGB0,7 ; clear explicit MSB if positive
    RETLW 0

    MULT
    MOVFW Multip
    MOVWF BARGB0
    FXM1608U
    CLRF AARGB2 ; clear partial product
    MOVF AARGB0,W
    MOVWF TEMPB0
    MOVF AARGB1,W
    MOVWF TEMPB1


    MOVLW 0x08
    MOVWF LOOPCOUNT
    LOOPUM1608A
    RRF BARGB0, F
    BTFSC STATUS,C
    GOTO LUM1608NAP
    DECFSZ LOOPCOUNT, F
    GOTO LOOPUM1608A
    CLRF AARGB0
    CLRF AARGB1
    RETLW 0x00
    LUM1608NAP
    BCF STATUS,C
    GOTO LUM1608NA
    LOOPUM1608
    RRF BARGB0, F
    BTFSS STATUS,C
    GOTO LUM1608NA
    MOVF TEMPB1,W
    ADDWF AARGB1, F
    MOVF TEMPB0,W
    BTFSC STATUS,C
    INCFSZ TEMPB0,W
    ADDWF AARGB0, F
    LUM1608NA
    RRF AARGB0, F
    RRF AARGB1, F
    RRF AARGB2, F
    DECFSZ LOOPCOUNT, F
    GOTO LOOPUM1608
    RETURN

    end
     
  2. Exo

    Exo Active Member

    Joined:
    Sep 18, 2003
    Messages:
    1,953
    Likes:
    1
    Location:
    Belgium
    erm.. nice listing :?
    What are we supposed to do with it?
     
  3. samcheetah

    samcheetah New Member

    Joined:
    Dec 30, 2003
    Messages:
    872
    Likes:
    0
    Location:
    Pakistan
    LOLZZZZZZZ :lol: :lol: :lol: :lol:

    nice question.

    jokes apart, i think it looks like a program for temperature measurement. but the author of the post should have told something about it.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. pike

    pike Member

    Joined:
    Oct 25, 2003
    Messages:
    588
    Likes:
    0
    Location:
    Sydney, Australia

    i'm calling for spam...
     
  6. samcheetah

    samcheetah New Member

    Joined:
    Dec 30, 2003
    Messages:
    872
    Likes:
    0
    Location:
    Pakistan
    i know what this is :)

    i do the same sort of spamming when i want to give a source code to someone else. i just post it somewhere on the net and when i need to show it to someone else i just open the post and show it.

    most of the time i prepare lab assignments at home and then post it on some forum, then the next day i copy the program from the post and show it to my teacher :twisted:

    anyway the author shouldnt have done this here. we should all respect such a nice forum 8)
     

Share This Page