Hello. I am attempting to write assembler code using as an example code for GPIO taken from the following publication.
Raspberry Pi Assembly Language Programming: ARM Processor Coding
Stephen Smith
Gibsons, BC, Canada
I believe the following section, which takes a memory map of a section of the GPIO registers required, results in an ‘illegal instruction’ error caused by user privileges when reading from this area of “memory”.
@ Macro to map memory for GPIO Registers
.macro mapMem
openFile devmem, S_RDWR @ open /dev/mem
movs r4, r0 @ fd for memmap
@ check for error and print error msg if necessary
BPL 1f @ pos number file opened ok
MOV R1, #1 @ stdout
LDR R2, =memOpnsz @ Error msg
LDR R2, [R2]
writeFile R1, memOpnErr, R2 @ print the error
B _end
The following is a disassembly of this section,
00000000 <_start>:
0: e59f0238 ldr r0, [pc, #568] ; 240 <_end+0xc>
4: e30011b6 movw r1, #438 ; 0x1b6
8: e30021b6 movw r2, #438 ; 0x1b6
c: e3a07005 mov r7, #5
10: ef000000 svc 0x00000000
14: e1b04000 movs r4, r0
18: 5a000008 bpl 40 <_start+0x40>
1c: e3a01001 mov r1, #1
20: e59f221c ldr r2, [pc, #540] ; 244 <_end+0x10>
24: e5922000 ldr r2, [r2]
28: e1a00001 mov r0, r1
2c: e59f1214 ldr r1, [pc, #532] ; 248 <_end+0x14>
30: e1a02002 mov r2, r2
34: e3a07004 mov r7, #4
38: ef000000 svc 0x00000000
3c: ea00007c b 234 <_end>
40: e59f5204 ldr r5, [pc, #516] ; 24c <_end+0x18>
Thought I would reach out for possible assistance?
In the meantime I will continue to search.
Regards to all.