Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/07/04 17:46
Read: times


 
Msg Score: -2
 -2 Didn't Search First
#82709 - 24bit /8bit long division
I have a quick question for you

r4/r3/r2 contain the following 24 bit number; FFFFh.

How do I find the solution of the FFFFh / 1Eh? Is this possible? Basically I just need to come up with the average of the contents of a table. There are 30(1Eh), 16bit numbers in the table.

Following is my interrupt routine based on some examples you sent me a while back.

ISR_EXT_1:
clr tr0 ;stop the timer
clr ex1 ;disable external 1 interrupt
lcall save_registers ;save all the register values
mov r0, tl0
mov r1, th0 ;get timer reading into r0, and r1
;start FIFO
;shift data
mov LFIFO+59, LFIFO+57
mov LFIFO+58, LFIFO+56

mov LFIFO+55, LFIFO+53
mov LFIFO+54, LFIFO+52

mov LFIFO+51, LFIFO+49
mov LFIFO+50, LFIFO+48

mov LFIFO+47, LFIFO+45
mov LFIFO+46, LFIFO+44

mov LFIFO+43, LFIFO+41
mov LFIFO+42, LFIFO+40

mov LFIFO+39, LFIFO+37
mov LFIFO+38, LFIFO+36

mov LFIFO+35, LFIFO+33
mov LFIFO+34, LFIFO+32

mov LFIFO+31, LFIFO+29
mov LFIFO+30, LFIFO+28

mov LFIFO+27, LFIFO+25
mov LFIFO+26, LFIFO+24

mov LFIFO+23, LFIFO+21
mov LFIFO+22, LFIFO+20

mov LFIFO+19, LFIFO+17
mov LFIFO+18, LFIFO+16

mov LFIFO+15, LFIFO+13
mov LFIFO+14, LFIFO+12

mov LFIFO+11, LFIFO+9
mov LFIFO+10, LFIFO+8

mov LFIFO+7, LFIFO+5
mov LFIFO+6, LFIFO+4

mov LFIFO+3, LFIFO+1
mov LFIFO+2, LFIFO+0

mov LFIFO+0, r0 ;put timer value in beginning of table
mov LFIFO+1, r1

clr a
mov r2, a ;r4/r3/r2 holds sum
mov r3, a
mov r4, a
mov r0, LFIFO ;r0 is pointer to 30 word FIFO Table
sumloop:
mov a, @r0
add a, r2
mov r2, a
inc r0
mov a, @r0
addc a, r3
mov r3, a
inc r0
mov a, r4
addc a, #0
mov r4,a
cjne r0, #LFIFO+60, sumloop
;here's where I'm stuck!!!
;devide the value at r4/r3/r2 into 30 and store in variable LFIFO_avg
;
lcall restore_registers
setb ex0 ;enable external 0 interrupt
reti


Thanks in advance for your help.


Chris Seeley


List of 8 messages in thread
TopicAuthorDate
24bit /8bit long division            01/01/70 00:00      
   24bit /8bit long division            01/01/70 00:00      
      How about rotate left?            01/01/70 00:00      
         multibyte rotate            01/01/70 00:00      
            Compact code            01/01/70 00:00      
               Rotate in hardware.            01/01/70 00:00      
         Yes, that's better            01/01/70 00:00      
            Some other suggestions            01/01/70 00:00      

Back to Subject List