Mixing ASM problem

General discussion on mikroBasic PRO for 8051.
Post Reply
Author
Message
BarryP
Posts: 517
Joined: 02 Apr 2007 03:57
Location: New Zealand

Mixing ASM problem

#1 Post by BarryP » 02 Feb 2011 04:46

Code: Select all

program test
  dim OutBufCount as Byte
  sub procedure BT_UART0_ISR()  '   org 0x0023
      asm
         JBC SCON0.1 , Tx_ISR
         JBC SCON0.0 , Rx_ISR
      end asm
      exit     'If This is commented out , the code compiles correctly
      asm
Tx_ISR:
      end asm
      if OutBufCount = 0 then exit end if
      'code
      asm
Rx_ISR:
      end asm
      'code
  end sub
main:
  while true
        BT_UART0_ISR
  wend
end.
This is the Result.

Code: Select all

_BT_UART0_ISR:
0x00AE	0x109905  	JBC SCON0.B1, Tx_ISR
0x00B1	0x109806  	JBC SCON0.B0, Rx_ISR
;test.mbas,8 :: 		exit     'If This is commented out , the code compiles correctly
0x00B4	0x8004    	SJMP L_end__BT_UART0_ISR
Tx_ISR:
;test.mbas,12 :: 		if OutBufCount = 0 then exit end if
0x00B6	0xE508    	MOV A, _OutBufCount
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PROBLEM HERE
L__BT_UART0_ISR2 doesn't exist  & it jumps to nevernever land. (  Rel 0xF4  in this case.)
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0x00B8	0x70F4    	JNZ L__BT_UART0_ISR2
Rx_ISR:
L_end__BT_UART0_ISR:
0x00BA	0x22      	RET
_main:
0x00BB	0x758180  	MOV SP, #128


User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Mixing ASM problem

#2 Post by zristic » 02 Feb 2011 12:40

If you call EXIT, any code underneath is not going to be executed, therefore, it does not need to get included in the final HEX.

BarryP
Posts: 517
Joined: 02 Apr 2007 03:57
Location: New Zealand

Re: Mixing ASM problem

#3 Post by BarryP » 02 Feb 2011 19:55

The First Instruction JBC SCON0.B1, Tx_ISR Will Jump Over The Exit To The Tx_ISR Label.


>> The Code <<
if OutBufCount = 0 then exit end if

>> Resultant ASM <<
MOV A, _OutBufCount
JNZ L__BT_UART0_ISR2 (70F4)
------------------------
This looks OK BUT The Label L__BT_UART0_ISR2 Doesn't exist.
A Rel Jump of 0xF4 Takes it Out Of The Original Procedure.
The Zero condition Just falls thru to Rx_ISR: Label

With The Exit commented Out The Code is OK with correct labels etc

Code: Select all

_BT_UART0_ISR:
;test.mbas,3 :: 		sub procedure BT_UART0_ISR()  '   org 0x0023
;test.mbas,5 :: 		JBC SCON0.1 , Tx_ISR
0x00AE	0x109903  	JBC SCON0.B1, Tx_ISR
;test.mbas,6 :: 		JBC SCON0.0 , Rx_ISR
0x00B1	0x109806  	JBC SCON0.B0, Rx_ISR
;test.mbas,10 :: 		Tx_ISR:
Tx_ISR:
;test.mbas,12 :: 		if OutBufCount = 0 then exit end if
0x00B4	0xE508    	MOV A, _OutBufCount
0x00B6	0x7002    	JNZ L__BT_UART0_ISR2
0x00B8	0x8000    	SJMP L_end__BT_UART0_ISR
L__BT_UART0_ISR2:
;test.mbas,15 :: 		Rx_ISR:
Rx_ISR:
;test.mbas,16 :: 		end asm
L_end__BT_UART0_ISR:
0x00BA	0x22      	RET
; end of _BT_UART0_ISR

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Mixing ASM problem

#4 Post by zristic » 04 Feb 2011 13:44

Ok, i get the point. Sorry that I did not understand from the start.
We'll have to fix the issue, I've added it to the bugzilla.

Post Reply

Return to “mikroBasic PRO for 8051 General”