In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bernoulli wrote: Bean, thank you for the reply. Your answer goes against the information contained within the SX/B documentation and against the reason for having the ASM command. The need for a \ likely shows the ASM command is not even acted on by the compiler but simply ignored. Maybe someone forgot to code it into the compiler? If so, maybe someone can easily rewrite that section of code for the compiler to make ASM a functioning command as described by the documentation. Or remove that command from the documentations. Below are two excerpts from the Help file under the command of ASM and from the example program for INTERRUPT Examples (found at the bottom of the page for the ASM command description). Neither shows the requirement for the \ within a ASM...ENDASM block. [code] ASM...ENDASM 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 [/code] [code] ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ' This program demonstrates the construction of an ISR to receive serial ' data "in the background" using a 16-byte circular buffer. ' ' Note: Requires SX/B 1.2 or later ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "ISR UART" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- Sin VAR RA.0 ' serial in Blinker VAR RB.0 ' blinking LED LEDs VAR RC ' eight LEDs (7-segs) TRIS_LEDs VAR TRIS_C ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- B1200 CON 64 ' 1200 Baud B2400 CON 32 ' 2400 Baud B4800 CON 16 ' 4800 Baud B9600 CON 8 ' 9600 Baud B19K2 CON 4 ' 19.2 kBaud (max @ 4 MHz) BitTm CON B19K2 ' samples per bit BitTm15 CON 3*BitTm/2 ' 1.5 bits ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- rxHead VAR Byte ' available slot rxTail VAR Byte ' next byte to read rxByte VAR Byte ' serial byte rxCount VAR Byte ' bits to receive rxTimer VAR Byte ' bit timer for ISR rxBuf VAR Byte(16) ' circular buffer tmpB1 VAR Byte ' parameter ' ------------------------------------------------------------------------- INTERRUPT NOPRESERVE ' ------------------------------------------------------------------------- ' ISR is setup to receive N81, true mode. ISR_Start: ASM MOVB C, Sin ' sample serial input TEST rxCount ' receiving now? JNZ RX_Bit ' yes if rxCount > 0 MOV W, #9 ' start + 8 bits SC ' skip if no start bit MOV rxCount, W ' got start, load bit count MOV rxTimer, #BitTm15 ' delay 1.5 bits RX_Bit: DJNZ rxTimer, ISR_Exit ' update bit timer MOV rxTimer, #BitTm ' reload bit timer DEC rxCount ' mark bit done SZ ' if last bit, we're done RR rxByte ' move bit into rxByte SZ ' if not 0, get more bits JMP ISR_Exit RX_Buffer: MOV FSR, #rxBuf ' get buffer address ADD FSR, rxHead ' point to head MOV IND, rxByte ' move rxByte to head INC rxHead ' update head CLRB rxHead.4 ' keep 0 - 15 ENDASM ISR_Exit: RETURNINT 52 ' 13 uS @ 4 MHz ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- GET_BYTE SUB 0 ' returns byte from buffer ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: TRIS_LEDs = %00000000 ' make LED pins outputs OPTION = $88 ' interrupt, no prescaler Main: IF rxHead <> rxTail THEN ' if buffer has data LEDs = GET_BYTE ' get byte from buffer ENDIF TOGGLE Blinker ' blink LED PAUSE 50 ' small pause GOTO Main ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- ' Use: aVar = GET_BYTE ' -- if data is in buffer, the next byte is move to 'aVar' ' -- if called when buffer empty, code waits for character to arrive GET_BYTE: DO WHILE rxHead = rxTail ' wait while empty LOOP tmpB1 = rxBuf(rxTail) ' get first available INC rxTail ' update tail position \ CLRB rxTail.4 ' keep 0 - 15 RETURN tmpB1 [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=250803#m250901 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)