Page 1 of 1

Baking Pi

Posted: Tue Jan 22, 2013 8:08 pm
by buteman
I have been looking at the Baking Pi code and am wondering how I would go about combining the code from the ok05 , screen04 and input02 sections as I can see main.s in each.
Do I copy and paste form the different main.s files into one or is there some other way of doing the job?
As you can tell i am new to this :o
The only assembler coding I have done was many many years ago on my Acorn Atom 6502 based PC.
I have ordered Bruce Smith's – A Hands On Guide to Assembly Language on the Raspberry Pi so I no doubt could wait till then to find out :cry:

Re: Baking Pi

Posted: Wed Jan 23, 2013 6:45 am
by mark_3094
As you go through each of the tutorials, you will build on the previous one, so you won't have to do anything special to combine the functionality of input, drawing to screen and the ok light.

If you want a challenge afterward, try porting it to C or another high level language.

Re: Baking Pi

Posted: Wed Jan 23, 2013 8:25 pm
by buteman
I don't understand how that works. All the oko code has it's own main.s as does the screen and the input tutorials. These are all different so how can I compile then into one program?
If I end up with the full oko5 , screen04 and input02 they appear to be entirely separate.
I cannot copy each main.s into the same directory so unless there is something I need as parameters for the compiler I am at a loss.

Re: Baking Pi

Posted: Wed Jan 23, 2013 9:35 pm
by mark_3094
Each tutorial will explain how a particular feature works (such as the OK light [or ACT light if you have the new RPi], the frame buffer or input).

These features are implemented in functions, and the main function calls them (AKA 'branches' to them, in ARM ASM terminology) in a way that is specific to what you want to achieve.

So, if you want to implement a flashing light, while drawing to screen and getting input, you as the programmer must decide how you put it together. Essentially you will use the main function to call these other functions with the input that you decide upon, depending on what outcome you want to achieve.
buteman wrote:I have ordered Bruce Smith's – A Hands On Guide to Assembly Language on the Raspberry Pi so I no doubt could wait till then to find out :cry:
Have you started the tutorials yet, or are you waiting for the book first? The tutorials will explain how to implement the functions in main. In my opinion, you don't need the book to start the tutorials. It may be useful to build on what you learn, but not necessary to start.

I hope that helps in some way. It's a bit of a 'how long is a piece of string' answer.

Re: Baking Pi

Posted: Wed Jan 23, 2013 9:58 pm
by buteman
I haven't got my R.Pi yet so I have been reading through the tutorials and I think I can understand what's going on with each one.
So, if I have it right, I keep one main.s in a directory, add the various functions from the final tutorials in each section and edit the one main.s to allow it to call each of the functions according to what I want to do. I assume then that i would have some outer loop which continues until I select some exit function and inside that I code the parts to monitor the input and respond accordingly.
Then does it mean I need to create what amounts to a combination makefile?
for example:
input02 has
# Rule to make the elf file.
$(BUILD)output.elf : $(OBJECTS) $(LINKER)
$(ARMGNU)-ld --no-undefined $(OBJECTS) -Map $(MAP) -o $(BUILD)output.elf -T $(LINKER)
and ok05 has
$(BUILD)output.elf : $(OBJECTS) $(LINKER)
$(ARMGNU)-ld --no-undefined $(OBJECTS) -L. $(patsubst %,-l %,$(LIBRARIES)) -Map $(MAP) -o $(BUILD)output.elf -T $(LINKER)
Which are obviously different so do I create a combination of those to accomplish this or not?

Re: Baking Pi

Posted: Thu Jan 24, 2013 12:58 am
by mark_3094
buteman wrote:So, if I have it right, I keep one main.s in a directory, add the various functions from the final tutorials in each section and edit the one main.s to allow it to call each of the functions according to what I want to do. I assume then that i would have some outer loop which continues until I select some exit function and inside that I code the parts to monitor the input and respond accordingly.
Yep, that sounds right.
buteman wrote:$(ARMGNU)-ld --no-undefined $(OBJECTS) -L. $(patsubst %,-l %,$(LIBRARIES)) -Map $(MAP) -o $(BUILD)output.elf -T $(LINKER)
I think this one is just defining a location where external libraries are stored. I think either case will work for you.
buteman wrote:I haven't got my R.Pi yet
As your RPi is new, it will most likely be the 512MB model. I would suggest having a read of this thread before you start:
http://www.raspberrypi.org/phpBB3/viewt ... 72&t=30399
This refers to some minor changes you will have to make in memory addressing and the linker script. I suggest having a quick look at page 5 of the BCM2835 manual to see how it organizes memory (don't worry if it doesn't make sense straight away, it may take a while to sink in).

Re: Baking Pi

Posted: Thu Jan 24, 2013 7:16 pm
by buteman
Thanks Mark,
I'll take that into account. No doubt I will be asking more questions before I get it fully working.