Earlier quoted context omitted.
Not a MOV and an ADD?
You can use that method (arm usually uses a "mov" and "movt" to load upper and lower half-words), but you would be using 2 instructions to accomplish the same thing that ldr with a literal pool does in one.
Baking Pi – Operating Systems Development
11–15 of 15 posts
Re: Baking Pi – Operating Systems Development
#12Earlier quoted context omitted.
You can use that method (arm usually uses a "mov" and "movt" to load upper and lower half-words), but you would be using 2 instructions to accomplish the same thing that ldr with a literal pool does in one.
Not sure about a MOVT (my ARM assembler is only current to an ARM2...) but it's two (pipelined) instructions vs one instruction and a slow memory access. But then again, I'm thinking of a previous era with no instruction or data caches !
Your literal pool has a high degree of spacial locality WRT the instruction that references it. You can take measures to optimize this (see the ltorg directive) making I$ hits very likely.
In the end, the assembler is free to pick and choose which method is best for the target CPU and input code.
Re: Baking Pi – Operating Systems Development
#13So, I haven't written ARM assembly since I owned an Archimedes computer many years ago, but isn't there a mistake describing the very first assembly language instruction in lesson 1? ldr r0,=0x20200000 Shouldn't the LDR be a MOV?
From what I can tell, yes. ldr r0, =0x20200000 loads from memory. In C, r0 = *0x20200000; what we would want is just r0 = 0x20200000; or mov r0, #0x20200000
The immediate pseudo-instruction:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....
The regular form:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....
Re: Baking Pi – Operating Systems Development
#14However, I wonder if it isn't too painful in the long run to teach OS programming on a target where you have to flip SD cards every time you compile (as opposed to one of those with a hardware debugger included, like Launchpad or ST Discovery).
When I took Operating Systems (INF242 at Oslo) ten years ago, we wrote an operating system for PCs that booted from floppies, and debugging was largely a matter of poking bytes to 0xB800:0000, which made this course somewhat unpopular with students with little low-level programming experience.