Endpoint Table Handling - Motorola HC12 Refrence Manual

Table of Contents

Advertisement

BEGIN
LDY
FIND_LOOP
CMPA
BLS
* on fall thru, XB@-2,Y YB@-1,Y XE@0,Y and YE@1,Y
TFR
CLRA
LDAB
SUBB
EXG
SUBA
EXG
FDIV
EXG
EXG
TSTA
BPL
INCB
NO_ROUND
LDAA
PSHA
LDAA
PSHA
TBL
The basic idea is to find the segment of interest, temporarily build a one-segment table
of the correct format on the stack, then use TBL with stack relative indexed addressing
to interpolate. The most difficult part of the routine is calculating the proportional dis-
tance from the beginning of the segment to the lookup point versus the width of the
segment ((XL–XB)/(XE–XB)). With this type of table, this calculation must be done at
run time. In the previous type of table, this proportional term is an inherent part (the
lowest order bits) of the data input to the table.
Some fuzzy theorists have suggested membership functions should be shaped like
normal distribution curves or other mathematical functions. This may be correct, but
the processing requirements to solve for an intercept on such a function would be un-
acceptable for most microcontroller-based fuzzy systems. Such a function could be
encoded into a table of one of the previously described types.
For many common systems, the thing that is most important about membership func-
tion shape is that there is a gradual transition from non-membership to membership
as the system input value approaches the central range of the membership function.
Let us examine the human problem of stopping a car at an intersection. We might use
rules like "If intersection is close and speed is fast, apply brakes." The meaning (re-
flected in membership function shape and position) of the labels "close" and "fast" will
be different for a teenager than they are for a grandmother, but both can accomplish
the goal of stopping. It makes intuitive sense that the exact shape of a membership
function is much less important than the fact that it has gradual boundaries.
MOTOROLA
9-28
#TABLE_START-2
2,+Y
FIND_LOOP
D,X
0,Y
-2,Y
D,X
-2,Y
A,D
D,X
A,B
NO_ROUND
1,Y
-1,Y
2,SP+
Figure 9-12 Endpoint Table Handling
FUZZY LOGIC SUPPORT
;setup initial table pointer
;find first Xn > XL
;(auto pre-inc Y by 2)
;loop if XL .le. Xn
;save XL in high half of X
;zero upper half of D
;D = 0:XE
;D = 0:(XE-XB)
;X = (XE-XB).. D = XL:junk
;A = (XL-XB)
;D = 0:(XL-XB), uses trick of EXG
;X reg = (XL-XB)/(XE-XB)
;move fractional result to A:B
;byte swap - need result in B
;check for rounding
;round B up by 1
;YE
;put on stack for TBL later
;YB
;now YB@0,SP and YE@1,SP
;interpolate and deallocate
;stack temps
CPU12
REFERENCE MANUAL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cpu12

Table of Contents