Here the multiple used math is more revealant than Pulsout Itself. Yeah i still refer to the same method to measure the code size... let's see
Code:
<font color="#000080">@ __CONFIG _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
</font>PORTB=0
TRISB=0
Led1 <font color="#000080">VAR </font>PORTB.0
Led2 <font color="#000080">VAR </font>PORTB.1
Led3 <font color="#000080">VAR </font>PORTB.2
Led4 <font color="#000080">VAR </font>PORTB.3
Led5 <font color="#000080">VAR </font>PORTB.4
Led6 <font color="#000080">VAR </font>PORTB.5
Led7 <font color="#000080">VAR </font>PORTB.6
Led8 <font color="#000080">VAR </font>PORTB.7
ByteA <font color="#000080">VAR BYTE
</font>ByteB <font color="#000080">VAR BYTE
</font>Worda <font color="#000080">VAR WORD
</font>PORT <font color="#000080">VAR BYTE
</font>DURATION <font color="#000080">VAR WORD
GOTO </font>Start
<font color="#000080">ASM
HOGSTART MACRO
BLOCKSTART=$
ENDM
HOGEND MACRO BLOCKNAME
BLOCKNAME = $-BLOCKSTART
ENDM
CUSTOM_PULSOUT MACRO PORT, PIN, DURATION, BYTEA
PULSOUT?TC PORT,PIN,DURATION
MOVE?CB BYTEA,_ByteA
L?CALL _DO_CALC
ENDM
ENDASM
</font>DO_CALC:
ByteB=50+ByteA
Worda=(ByteA+ByteB)*100
<font color="#000080">RETURN
</font>Start:
@ HOGSTART
<font color="#000080">PULSOUT </font>Led1,10000
ByteA=10
ByteB=50 + ByteA
Worda=(ByteA+ByteB)*100
<font color="#000080">PULSOUT </font>Led2,10000
ByteA=20
ByteB=50 + ByteA
Worda=(ByteA+ByteB)*100
<font color="#000080">PULSOUT </font>Led3,10000
ByteA=30
ByteB=50 + ByteA
Worda=(ByteA+ByteB)*100
<font color="#000080">PULSOUT </font>Led4,10000
ByteA=40
ByteB=50 + ByteA
Worda=(ByteA+ByteB)*100
@ HOGEND ____MULTIPLEPULSOUT
<font color="#000080">ASM
HOGSTART
CUSTOM_PULSOUT _Led1,10000,10
CUSTOM_PULSOUT _Led2,10000,20
CUSTOM_PULSOUT _Led3,10000,30
CUSTOM_PULSOUT _Led4,10000,40
HOGEND ____MACRO_CUSTOM_PULSOUT
ENDASM
</font>SPIN: <font color="#000080">GOTO </font>SPIN
Compile this with MPASM, and open the according .LST file... and discover that...

Originally Posted by
...LST file
SYMBOL TABLE
LABEL VALUE
____MACRO_CUSTOM_PULSOUT 0000002C
____MULTIPLEPULSOUT 00000074
2c=44 decimal
74=116 Decimal
here the simple macro and sub call will use 116/44=~2.6 time less code and make the code MUCH MORE readable... at least to me.. case not.. hum, hum, just fart in Darrel's direction

How handy they are
Bookmarks