ASM Instruction(s) ... ENDASM
Function
ASM allows the insertion a block of assembly language statements into the SX/B program.
The assembly language block is terminated with ENDASM. Code in the ASM..ENDASM
block is inserted into the program verbatim.
Explanation
Certain time-critical routines are best coded in straight assembly language, and while the
\ symbol allows the programmer to insert a single line of assembly code, it is not
convenient for large blocks.
' Use: inByte = SHIFTIO outByte ' -- sends (via ShOut) and receives (via ShIn) bytes LSBFIRST SHIFTIO: \ CLR tmpB1 ' clear input byte \ MOV idx, #8 ' do 8 bits ShIO_Loop: ASM MOVB ShOut, __PARAM1.0 ' move LSB out to pin MOV __PARAM3, #50 ' 50 us pause @ 4 MHz DJNZ __PARAM3, $ XOR RA, #%00000001 ' toggle clock MOV __PARAM3, #50 DJNZ __PARAM3, $ CLC RR tmpB1 ' prep for input bit MOVB tmpB1.7, ShIn ' capture input bit (LSB) XOR RA, #%00000001 ' toggle clock CLC RR __PARAM1 ' prep for next output bit DJNZ idx, ShIO_Loop ' repeat for 8 bits ENDASM RETURN tmpB1
Related example: INTERRUPT Examples