1

I'm newbie in assembler, but have to replace LDR command with ADR command in this sample.

Blit8To16RevAsm:
    ;@ r0 = pixFrom
    ;@ r1 = pixTo
    ;@ r2 = pal lookup
    stmfd sp!,{r4-r9}
    sub r1, r1, #4
    mov r9,r3,lsr#4
1:
    ldmia r0!,{r3-r6}
    and r7,r3,#0x000000FF
    ldr r7,[r2,r7,lsl#2]
    and r8,r3,#0x0000FF00
    ldr r8,[r2,r8,lsr#6]
    orr r7,r8,r7,lsl#16
    str r7,[r1],#-4
    and r7,r3,#0x00FF0000
    ldr r7,[r2,r7,lsr#14]
    and r8,r3,#0xFF000000
    ldr r8,[r2,r8,lsr#22]
    orr r7,r8,r7,lsl#16
    str r7,[r1],#-4

Simply replacing LDR by ADR gives me an error, that ] is missing. So, how can I replace this two commands. Thanks in advance!

Johan
  • 74,508
  • 24
  • 191
  • 319
MSerg
  • 122
  • 8
  • 1
    Which assembly? What platform? Why do you need to replace it since they do different things? – Sami Kuhmonen Feb 06 '17 at 10:27
  • 3
    I'm not an expert on ARM, but [ADR](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204f/Babcjaii.html) can at most replace the [LDR pseudo instruction](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/Babbfdih.html) not the [LDR instruction](https://www.heyrick.co.uk/armwiki/LDR). I don't see any LDR pseudo instructions in your code at first glance – Margaret Bloom Feb 06 '17 at 10:31
  • @SamiKuhmonen this is ARM platform. I need to replace it to avoid some text relocations – MSerg Feb 06 '17 at 13:53
  • @MargaretBloom thnx for response, I follow this [link](http://stackoverflow.com/questions/33510601/avoiding-text-relocations-when-mixing-c-c-and-assembly-in-a-so), but corresponding to description LDR and LDR pseudo instruction are the same, isn't it? – MSerg Feb 06 '17 at 13:58
  • 2
    Possible duplicate of [Getting an label address to a register on ARM?](http://stackoverflow.com/questions/15774581/getting-an-label-address-to-a-register-on-arm). The `LDR Rx,=xxx` will translate to `LDR Rx,[pc,#offset]` and the offset is a 'literal pool'. The `ADR` is to get the address of the literal pool type constant to a register. The 'literal pool' lives with code in the ARM and is typically after the end of a function. – artless noise Feb 06 '17 at 14:31

0 Answers0