Skip to main content
Hansel
Senior
April 4, 2024
Solved

ARMv4 instruction "ADC R0, R1, LSL #1" not recognized

  • April 4, 2024
  • 2 replies
  • 2409 views

I am using STM32CubeIDE 1.15.0, writing code in C, including some assembler code, for the STM32G431.

According to ST's programming manual PM0214 in Section 3.5.1, I should be allowed to use

adc r0, r1, lsl #1

However, gcc barfs (I am using standard gnu18) with the following message:

garbage following instruction -- 'adc r0,r1,lsl#1'

What am I missing?

 

 

Best answer by Tesla DeLorean

These forms ALL work in KEIL

 234 00000008 EB40 0041 adc r0,r1,lsl#1
 235 0000000C EB40 0041 adc.w r0, r0, r1, lsl #1
 236 00000010 EB40 0041 ADC r0,r0,r1,LSL #1

Will poke GNU/GAS later..

2 replies

gbm
Lead III
April 4, 2024

You are missing register name before lsl.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
April 4, 2024

These forms ALL work in KEIL

 234 00000008 EB40 0041 adc r0,r1,lsl#1
 235 0000000C EB40 0041 adc.w r0, r0, r1, lsl #1
 236 00000010 EB40 0041 ADC r0,r0,r1,LSL #1

Will poke GNU/GAS later..

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
April 4, 2024

The version of GAS I'm using found these latter two were acceptable

 121 0034 40EB4100 	 adc.w r0, r0, r1, lsl #1
 122 0038 40EB4100 	 ADC r0,r0,r1,LSL #1

objdump -d yielded this form, which is the form I'd choose for re-assembly

 34:	eb40 0041 	adc.w	r0, r0, r1, lsl #1
 38:	eb40 0041 	adc.w	r0, r0, r1, lsl #1

 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Hansel
HanselAuthor
Senior
April 4, 2024

Thanks, guys, for helping me out. It works now!

Tesla DeLorean
Guru
April 4, 2024

I'm a little disappointed than GNU/GAS won't handle the short/truncated version.

I tend to use KEIL / ARMASM to rebuild recovered source, and I do find the syntax differences between tools to be frustrating at times. Although I guess I'd prefer it error than fail to generate the right opcodes

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