EASy68K
http://easy68k.com/EASy68Kforum/

Use gcc with easy68k?
http://easy68k.com/EASy68Kforum/viewtopic.php?f=5&t=1215
Page 1 of 1

Author:  Hazematman [ Sun Oct 06, 2013 11:12 pm ]
Post subject:  Use gcc with easy68k?

Hey! I've been playing around with easy68k and its pretty cool, but I would like to trying programming on it with c. I've compiled m68k-gcc-elf and I've written this code:
Code:
int main(){
   char *text="Hello World!";
   asm volatile("LEA %0,%%A1\n"
         "MOVE.B #14,%%D0\n"
         "TRAP #15\n"
         "MOVE.B #9,%%D0\n"
         "TRAP #15\n"
         :/*no outputs */
         :"m"(text)
         :"%d0","%a1"
         );
   return 0;
}


I compiled it using
Code:
m68k-elf-gcc test.c -o test.elf -ffreestanding -nostdlib -m68000
m68k-elf-objcopy -O binary test.elf test.bin


I then used Easybin to convert the .bin file to a .s68. When I got to run the code in the simulator I get this error:
Code:
Address Error: Instruction at    4 accessing address fffffb


Has anyone ever got gcc working with easy68k? or does anyone have any idea on how I could get it to work?

Author:  profkelly [ Mon Oct 07, 2013 12:42 am ]
Post subject:  Re: Use gcc with easy68k?

Try moving the string declaration to the bottom. Move the code away from address 0, try $1000, before you create the .S68 file. The address at zero up to $400 or so should not be used to run program code.

Code:
int main(){
   asm volatile("LEA %0,%%A1\n"
         "MOVE.B #14,%%D0\n"
         "TRAP #15\n"
         "MOVE.B #9,%%D0\n"
         "TRAP #15\n"
         :/*no outputs */
         :"m"(text)
         :"%d0","%a1"
         );
   return 0;
   char *text="Hello World!";
}

Author:  Hazematman [ Mon Oct 07, 2013 1:25 am ]
Post subject:  Re: Use gcc with easy68k?

When I change the start address to be $1000 in easybin the program runs without giving an error, it just doesn't print anything to the screen. Also moving the string declaration to the bottom doesn't work as it is being declared after it needs to be used.

Author:  profkelly [ Mon Oct 07, 2013 5:06 pm ]
Post subject:  Re: Use gcc with easy68k?

Here is a working example written in Assembly.

Code:
00001000 Starting Address
Assembler used: EASy68K Editor/Assembler v5.12.29
Created On: 10/7/2013 1:06:31 PM

00000000                             1  *-----------------------------------------------------------
00000000                             2  * Title      :
00000000                             3  * Written by :
00000000                             4  * Date       :
00000000                             5  * Description:
00000000                             6  *-----------------------------------------------------------
00001000                             7      ORG    $1000
00001000                             8  START:                  ; first instruction of program
00001000  43F9 00001010              9      LEA     TEXT,A1
00001006  103C 000E                 10      MOVE.B  #14,D0
0000100A  4E4F                      11      TRAP    #15
0000100C  FFFF FFFF                 12      SIMHALT             ; halt simulator
00001010                            13 
00001010                            14  * Put variables and constants here
00001010= 48 65 6C 6C 6F 20 ...     15  TEXT    DC.B    'Hello World!',0
0000101D                            16      END    START        ; last line of source

No errors detected
No warnings generated


SYMBOL TABLE INFORMATION
Symbol-name         Value
-------------------------
START               1000
TEXT                1010

Author:  Hazematman [ Wed Oct 09, 2013 11:21 pm ]
Post subject:  Re: Use gcc with easy68k?

Thanks for the example, I was using the code from here to create the foundation of my program. I think the problem lies with not having a correct linker script for the compiler, but I do not know enough about that to solve my issue.

Author:  hancock [ Sat Jun 14, 2014 9:09 am ]
Post subject:  Re: Use gcc with easy68k?

In case anybody is interested:
Recently I have cross-compiled with an uClinux-toolchain on Ubuntu-Linux (Virtualbox) the "hello world" and executed successfully in Easy68k.
This was one step to be inserted before porting the (very old) stand-alone Motorola FBUG-monitor which I am taking up now again.

Ultimately I am intending to bring up a piece of the Linux-kernel as proof of concept - not quite sure whether I will succeed. Is a long road to go.

Rgds

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/