Help with as and ld

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with as and ld

1,696 Views
Nathan
Contributor I

I'm teaching a lab for a computer architecture course, and we use the CF5435 chip as a nice microprocessor to get students familiar with low level, yet somewhat advance programming. I need to teach the class using only assembly, as most of the students are hardware EE's and don't know how to program in C. That rules out CodeWarrior, and I've been searching for a replacement set of tools to compile assembly source code, and use it on our boards. So far, I've found GNU as and ld, and 'cfasm' from www.calm.hw.ac.uk/davidf/coldfire.html. I like the cfasm better because it's a one stop deal for going from a .asm file to a .s19. The problem is, it only supports a very basic set of opcodes, and I was hoping to utilize more of the advance functions on the newer chip. The as and ld set from GNU seem to support more recent chips, but I can't get them to work. After a lot of reading and playing, I was able to compile a .asm file into a .o file with as. I used the following command: "as -0 asmtest.o -m5204 al asmtest2.s" The target is different because I'm compiling to run on a simulator of the 5204 I found.
I think this is ok. What I am now struggling with is getting the .o file into a .s19 file. I have read most of the ld manual on GNU tools website, and done several experiments but can't get a file to be created. My best guess as to a correct implementation of ld is
: "ld -e 0x10000 -o asmtest.s19 --oformat srec asmtest.o" When I run this though I get the following error "ld: cannot perform PE operations on non PE output file 'asmtest.s19'" I've tried removing options from the ld command one at a time, and this warning always shows up. When I don't specify an output with -o, I get the same error only pointing to 'a.exe' which is the default output.

 

If anyone has been successful in getting as and ld to work for the CF, I would love to hear how. I'd like to make it work from the command line before I start trying to write scripts. Just to aid in my understanding, so I can pass it on to my students.

 

Nathan

Labels (1)
0 Kudos
3 Replies

498 Views
TomE
Specialist II

As Paul said, "objcopy" is what you use to turn an ELF file into SREC.

> That rules out CodeWarrior,

As Nouchi says, you should be able to use CodeWarrior. It has to be able to handle assembly files. Why did you think use of Assembly ruled it out?

I would also strongly suggest using CW because of all the other MODERN things it does for you and your students.

I assume you're not teaching a "History of Ancient Computing". If you were you'd force all your students to learn how to use "vi" or even "emacs" before they could even enter their first program. Then you'd have them hand-assemble the code (very educational :-) and then load it in through a debugger in Hex or through a real switches-and-lamps front panel. Maybe multi-pass editing and building using paper tape and an ASR-33 (yes, I've done that, once). As for debugging, it would be "run and crash while blinking a light". Or command-line GDB (which I still have to use a lot). That sort of thing would prepare some of them for life in companies that won't spend any money on tools, but would put most of them off the idea of programming for life.

I'd recommend aiming as "high and easy" as you can, with sensible integrated IDEs that make editing easy, building and loading a "one click" operation with syntax errors shown in the editor, and then gives full symbolic debugging. CodeWarrior should be able to do all of that with assembly source. It might be possible to set up an Eclipse project to do the same, but that's what I think you should be aiming for so the students can concentrate on the code design and writing without all the other stuff getting in the way of getting anything done.

Paul wrote:

> I am using the CodeSourcery toolchain

If you didn't grab a copy in 2011 you can't get it now. Mentor isn't supporting (or making available) the free ColdFire tool chain any more. I think you can still buy supported versions though.

https://community.freescale.com/message/101270#101270

Tom

0 Kudos

498 Views
mccPaul
Contributor I
I am using the CodeSourcery toolchain which seems very good and I have also got it working well with Eclipse to give me a graphical IDE and debugger. I've posted about this already.
 
Once thing you should know, the GNU assembler, as, is designed to be called by gcc and although it seems wrong, you may find it easier to 'compile' your assembler because gcc 'knows' the correct switches to pass on to as!
 
I have a lot of assembler in my startup code and I am assembling it with:
 
gcc -mcpu=528x -x assembler-with-cpp -c -g -Wa,--register-prefix-optional
 
I am actually using an m68k-elf version of the toolchain, and my linker output is an elf file. I then use m68k-elf-objcopy to convert from elf to binary, but this tool also converts to and from many other formats, including srec.
 
It may be worth looking at objcopy in the toolchain you have to see if you can use it to create an srec file from your object file.
 
Paul.
 
0 Kudos

498 Views
Nouchi
Senior Contributor II
Hello,



Nathan wrote:
I'm teaching a lab for a computer architecture course, and we use the CF5435 chip as a nice microprocessor to get students familiar with low level, yet somewhat advance programming. I need to teach the class using only assembly, as most of the students are hardware EE's and don't know how to program in C. That rules out CodeWarrior, and I've been searching for a replacement set of tools to compile assembly source code, and use it on our boards.

   You can also use assembly with CodeWarrior, have a look to the MCF5407 project stationery, the starting code  is written in assembler (mcf5407_lo, vector.s).


Emmanuel,

0 Kudos