cancel
Showing results for 
Search instead for 
Did you mean: 

What is it the strange CPU instruction generated by SDCC?

Vyacheslav Azarov
Associate III

Hello everyone.

SLCC generated a strange instruction similar to JRF, represented as .byte 0x21 pseudo-instruction. Can anyone explain what this is? A code snippet is provided in the attachment. The compiler options are as follows: -mstm8 --out-fmt-elf --opt-code-speed --max-allocs-per-node 6900 - -stack-auto -c

Thanks in advance.

2 REPLIES 2

Just causes it to EAT the next byte/instruction. JRF (Jump if FALSE, ie NEVER) will take the next byte as the intended target, which it never acts upon. Think of it as the first byte of a two byte NOP, equivalent in this situation to a JRA 00106$ without the pipeline hit, and uses less code

478 ;	-----------------------------------------
                                    479 ;	 function USART1_RX_TIM5_CC_IRQHandler
                                    480 ;	-----------------------------------------
      00011F                        481 _USART1_RX_TIM5_CC_IRQHandler:
      00011F 4F               [ 1]  482 	clr	a
      000120 62               [ 2]  483 	div	x, a
                                    484 ;	/home/master/workspace/_myrtos-newview-0.0.0/SPL/stm8l15x_tim5.h: 1996: tim5_flag_l = (uint8_t)(TIM5->SR1 & (uint8_t)(TIM5_FLAG));
      000121 C6 53 06         [ 1]  485 	ld	a, 0x5306
      000124 A4 04            [ 1]  486 	and	a, #0x04
      000126 97               [ 1]  487 	ld	xl, a
                                    488 ;	/home/master/workspace/_myrtos-newview-0.0.0/SPL/stm8l15x_tim5.h: 1997: tim5_flag_h = (uint8_t)(TIM5->SR2 & (uint8_t)((uint16_t)TIM5_FLAG >> 8));
      000127 C6 53 07         [ 1]  489 	ld	a, 0x5307
                                    490 ;	/home/master/workspace/_myrtos-newview-0.0.0/SPL/stm8l15x_tim5.h: 1999: if ((uint8_t)(tim5_flag_l | tim5_flag_h) != 0)
      00012A 9F               [ 1]  491 	ld	a, xl
      00012B 4D               [ 1]  492 	tnz	a
      00012C 27 03            [ 1]  493 	jreq	00105$
                                    494 ;	/home/master/workspace/_myrtos-newview-0.0.0/SPL/stm8l15x_tim5.h: 2001: bitstatus = SET;
      00012E A6 01            [ 1]  495 	ld	a, #0x01
                                    496 ;	/home/master/workspace/_myrtos-newview-0.0.0/SPL/stm8l15x_tim5.h: 2005: bitstatus = RESET;
      000130 21                     497 	.byte 0x21
      000131                        498 00105$:
      000131 4F               [ 1]  499 	clr	a
      000132                        500 00106$:
                                    501 ;	../stm8l15x_it.c: 363: if (TIM5_GetFlagStatus(TIM5_FLAG_CC2) == SET) os_yield();
      000132 4A               [ 1]  502 	dec	a
      000133 26 05            [ 1]  503 	jrne	00102$
      000135 CDr00r00         [ 4]  504 	call	_os_yield
      000138 20 06            [ 2]  505 	jra	00108$
      00013A                        506 00102$:
                                    507 ;	../stm8l15x_it.c: 365: os_handle_interrupt_error(28);
      00013A 4B 1C            [ 1]  508 	push	#0x1c
      00013C CDr00r00         [ 4]  509 	call	_os_handle_interrupt_error
      00013F 84               [ 1]  510 	pop	a
      000140                        511 00108$:
                                    512 ;	../stm8l15x_it.c: 366: }
      000140 80               [11]  513 	iret

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Super skip! Very original, as well as bypassing the error of the first division. Thank you very much.