2

I'm trying to issue a DMB instruction in a Go program, and I'm using asm function defined in a .s file. I'm compiling with Go 1.7.3 on an ARMv7 device.

DMB isn't a supported instruction in Go, but I see documentation here on how to use unsupported opcodes.

Using some ARM gcc binutils, I found the opcode for DMB is f57ff05f. The issue_dmb.s file I have is below.

TEXT ·issue_dmb(SB),$0

    // DMB: opcode f57ff05f
    BYTE $0xF5; BYTE $0x7F; BYTE $0xF0; BYTE $0x5F

    RET

When I build, I get an error: unrecognized instruction "BYTE"

(Possibly related: I got the same error about NOSPLIT when I used this in the first line of the .s file as I see in many examples, so I removed it).

Am I missing something to get the assembler to recognise these keywords?

user3340499
  • 189
  • 1
  • 10
  • You might need to a 32-bit "word" size directive to emit the opcode because ARM doesn't have any 8-bit instructions, they're all 32-bits. That would also solve your other problem, that you've got the byte order backwards and 0xF57FF05F is 0x5F, 0xF0, 0x7F, 0xF5 in the little endian byte order that ARM uses. – Ross Ridge Mar 20 '17 at 19:09
  • 1
    Thanks a lot, this solved it, using `WORD` directive instead of `BYTE`. – user3340499 Mar 20 '17 at 21:02

0 Answers0