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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/13/02 11:16
Read: times


 
#27168 - RE: Just had a job interview....
Hi,
About the moving average thing... SORRY!! I actually meant Indirect Addressing MOV@ instead of MOVC .... Oops!! :-))

I used mov@ thus:

<asm+C pseudo-code>
counter C = 0 ; initially
int N = number of samples for average
...
;assume data arriving on P1

Data_arrived: ;interrupt / event
mov R1,P1 ;read data in R1
mov R0,#ARR ;array address in RAM
add R0, C
mov @R0,R1 ;store data in arr[C]
inc C
cjne C, N, Go_back
C = 0 ;reset C to 0
;So next sample(x) will replace old sample (x-N)
Take_avg:
mov sum ,#00h
mov R0, #ARR
for(int i =0; i< N;i++) {
add R0,i
mov a,@R0
sum=sum+a
}
avg = sum / N
Go_back:
ret
</asm+C pseudo-code>

Of course, if this were an interrupt itself, it would probably read the port and set a flag for the main loop to do the rest of the processing.

It basically replaces the outdated record in an array with the latet sample. Since only the sum and not the order of samples is required, it is an efficient method. Other people I asked the same question to came up with methods to do the same without indirect addressing, which made their code bulkier and unweildy. My code was hence better than theirs.

I am not doing anything complex, but Peter's way seems to be the simplest solution :-)) I think that was what was expected of me, and the interviewer was probably glad to see something different :-))

Anyway, I was asking about interviews and how to ace them... Any hints, ideas, advice from Gurus out there?

kundi

List of 29 messages in thread
TopicAuthorDate
Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Interruptions            01/01/70 00:00      
RE: Interruptions            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Just had a job in, Kunal            01/01/70 00:00      
RE: Just had a job interview....            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      
RE: Jons words.            01/01/70 00:00      

Back to Subject List