Inline Assembler: 'bx(lr)' raises TypeError
Posted: Thu Oct 15, 2020 8:10 am
Hi, not sure what I'm doing wrong here, but I've been trying to use the inline assembler to process data coming in at a high rate. I have some very basic knowledge of assembly having written a few assembly functions to speed up timing-critical sections of C-Code before on embedded platforms, but I wouldn't go as far as to say I'm experienced.
I have followed examples in the documentation (which was surprisingly clear and well documented so Kudos), however i keep getting a type error if I add the function to return from the subroutine. This is some psuedo-code to demonstrate the flow of my function:
If I add the 'bx(lr)' then I get:
However, if I comment that out and instead uncomment out the line below(directly going to that branch) then it doesn't raise the type error. I tried the Fibonacci example from the documentation http://docs.micropython.org/en/latest/r ... _tips.html and that works fine, including the 'bx(lr)' instruction so it must be my code.
I assume I'm doing something obviously wrong, but I just can't work out what it is! Any help would be hugely appreciated.
I have followed examples in the documentation (which was surprisingly clear and well documented so Kudos), however i keep getting a type error if I add the
Code: Select all
bx(lr)
Code: Select all
TRUE = const(1)
@micropython.asm_thumb
def asm_process(r0, r1, r2):
vldr(s1, [r2, 4]) # Start Bit
vcvt_s32_f32(s0, s0)
vldr(s2, [r2, 8]) # length
vcvt_s32_f32(s1, s1)
vldr(s3, [r2, 12]) # scaling
vldr(s4, [r2, 16]) # wrong_format_flag
mov(r4, TRUE) # required as vmov requires register not constant
vmov(s10, r4)
b(START)
label(CONVERT)
push({lr}) # push to stack for inner loop
add(r4, r0, r1)
sub(r4, 1)
label(CONVERTLOOP)
#convert data format code
cmp(r4, r0) #check how many bytes left to convert
bpl(CONVERTLOOP)
pop({lr})
bx(lr) #TypeError: function doesn't take keyword arguments
# b(MAINPROCESS)
label(START)
vcmp(s4, s10) #check if flag set
vmrs(APSR_nzcv, FPSCR) #move comparison from FPU
beq(CONVERT)
label(MAINPROCESS)
#rest of code
Code: Select all
TypeError: function doesn't take keyword argument
I assume I'm doing something obviously wrong, but I just can't work out what it is! Any help would be hugely appreciated.