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