Page 52 - The Art of Designing Embedded Systems
P. 52

Stop Writing Big  Programs  39


                     - text         segment

                     ; -get-cba-min-read  a min value at  (index) from the
                     ; CBA  buffer. Called by a C program with the  (index)
                     ; argument on the stack.


                     ; Returns result in AX.

                        public -get-cba-min
                     - get-cba-min  proc far
                        mov       bx,  SP
                        mov       bx, [bx+4]       ; bx= index in buf to read
                         add      bx, cba-buf      ; add offset to make addr
                         push     ds
                         mov      dx,buffer-seg ; point to the buffer seg
                         mov      es , dx
                         mov      ax, es : bx      : read the min value
                         POP      ds
                         retf
                         endp
                     - text      ends


                     ; CBA  buffer, which is managed by the *-cba routines.
                     ; Format:  100 entries, each of which looks like:
                     ;    buf+0  min value (word)
                     ;    buf+2  max value (word)
                     ;    buf+4  number of iterations (word)


                     - data       segment para  ‘DATA’
                     cba-bu f     ds               100 *  6     ; CBA  buffer
                     - data       ends

                    FIWRE 3-1  Encapsulation in assembly language. Note that the data is
                    not defined Public.
   47   48   49   50   51   52   53   54   55   56   57