I used pseudocode, not an existing language, normally it should be rather easy to convert it to any existing structured language such as assembly. Since I don't understand the assembly language you are using, I can't translate it for you; but I'll explain a few things:
,
,
and
are constants denoting the valid hi- and low time intervals.
is a constant denoting the number of digits a telephone number consists of. The number 02 555 46 03 would require
.
is an array (or vector) of bytes (i.e. a succession of byte-sized values) in which each member can be accessed by calculating a memory offset, relative to the start location of the first element in the array.
is a function that returns a byte-sized value, denoting the number of pulses that are counted in a certain group. The function works as follows:
Code:
________ ___ ___ _______
|__| |__| |__|
a bc d e f
a) initial hi time is ignored (
)
b) hi switches to lo, the ingnoring loop ends and the reading loop starts.
c) The first part of the reading loop counts the number of milliseconds that pass during lo.
d) lo switches to hi, 3 conditions are checked: was the interval shorter than the minimum required lo time interval, either the minlotime constant has a wrong value, or there must be a corrupt connection; in this case, the routine should end and the connection be closed. The second condition is that the lo time exceeds the maximum lo time; in this case you can assume that the line remains lo thus indicating that the user must have hung up. The last case is the one where the measured time lies within the preset interval, so one correct pulse has been received; the pulse counter is then increased with 1.
e) The second part of the reading loop counts the number of milliseconds that pass during hi. Again, there are three conditions: time elapsed is too short, in bound or too long. In the latter case, we cannot wait until the signal becomes lo again, because that would mean that the dialing of the next digit has started, so we exit the function, returning the number of pulses that we counted. If the elapsed time was too short, the connection may be bad or the user may have hung up; in both cases the routine ends and the connection should be closed. In the third case (elapsed time lies in bounds) nothing special has to happen and the reading loop should continue.
f) Restart the whole procedure from c, with the difference that the pulse counter has now been increased by 1.
The
routine reads as many digits as are specified in the max constant. The loop starts and the first digit is read. If the read digit has one of the values in the interval 1..9, this digit is stored in the array; if the digit is 10 (i.e. there are 10 pulses received), a 0 is stored; if any other value is received, it must be invalid since telephone numbers consist of digits in the interval 0..9 and an error is generated (the connection should also be closed).
This is how I would receive pulse dialed numbers.
If you still have questions, be specific to which part they are related. Also, are you familiar with other programming languages? Is this a kind of school assignment? Exactly how familiar are you with the assembly language you're using?
Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.