home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s220 / 4.ddi / PULSE.LST < prev    next >
Encoding:
File List  |  1989-09-07  |  2.9 KB  |  54 lines

  1. ################################################################################
  2. #                                                                              #
  3. #      Archimedes 8051 Assembler V1.80/MD2              07/Sep/89  15:00:20    #
  4. #                                                                              #
  5. #       Source   =   pulse.s03                                                 #
  6. #       List     =   pulse.lst                                                 #
  7. #       Object   =   pulse.r03                                                 #
  8. #       Options  =                                                             #
  9. #                                                                              #
  10. #                                       (c) Copyright Archimedes Software 1985 #
  11. ################################################################################
  12.  
  13.  
  14.     1                 ;-----------------------------------------------------------
  15.     2                 ;
  16.     3                 ;       PULSE.S03
  17.     4                 ;       int pulse(int count, byte value);
  18.     5                 ;
  19.     6                 ; This is a sample routine called by EXAMPLE.C to
  20.     7                 ; demonstrate how to call assembly routines from C.
  21.     8                 ;
  22.     9                 ; This function is invoked with an integer (count)
  23.    10                 ; loaded in R2:R3 as the first formal C parameter 
  24.    11                 ; and a byte (value) as the second parameter, which
  25.    12                 ; is on the top of the C stack.
  26.    13                 ; The 8051 I/O pin P1.7 is pulsed for count number of
  27.    14                 ; cycles at maximum frequency, then value is written
  28.    15                 ; to Port 1.  It returns the current value of Port 3.
  29.    16                 ;
  30.    17                 ;-----------------------------------------------------------
  31.    18                 
  32.    19  0000                   MODULE  pulse
  33.    20  0000                   PUBLIC  pulse
  34.    21  0000                   EXTERN  ?POP_R3_L17
  35.    22  0000                   RSEG    CODE
  36.    23  0000           pulse:
  37.    24                                                 ; count is in R2/R3
  38.    25  0000 C297              CLR     P1.7            ; turn off/on P1.7
  39.    26  0002 00                NOP
  40.    27  0003 D297              SETB    P1.7
  41.    28  0005 DBF9              DJNZ    R3,pulse        ; using only lo-byte for count
  42.    29  0007 120000            LCALL   ?POP_R3_L17     ; get second parameter into R5
  43.    30  000A 8B80              MOV     P0,R3           ;  write to P1
  44.    31  000C ABB0              MOV     R3,P3           ; return with int value of
  45.    32  000E 7A00              MOV     R2,#0           ;  Port 3 in R2-R3 pair
  46.    33  0010 22                RET
  47.    34                 
  48.    35  0011                   END
  49.  
  50.     Errors:  None          #########
  51.     Bytes:   17            # pulse #
  52.     CRC:     34E9          #########
  53.  
  54.