EASy68K  
It is currently Tue Apr 25, 2017 2:27 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Use gcc with easy68k?
PostPosted: Sun Oct 06, 2013 11:12 pm 
Offline

Joined: Sun Oct 06, 2013 10:58 pm
Posts: 3
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?


Top
 Profile  
 
PostPosted: Mon Oct 07, 2013 12:42 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1036
Location: Monroe County Community College, Monroe Michigan, U.S.A.
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!";
}

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Mon Oct 07, 2013 1:25 am 
Offline

Joined: Sun Oct 06, 2013 10:58 pm
Posts: 3
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.


Top
 Profile  
 
PostPosted: Mon Oct 07, 2013 5:06 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1036
Location: Monroe County Community College, Monroe Michigan, U.S.A.
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

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Wed Oct 09, 2013 11:21 pm 
Offline

Joined: Sun Oct 06, 2013 10:58 pm
Posts: 3
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.


Top
 Profile  
 
PostPosted: Sat Jun 14, 2014 9:09 am 
Offline

Joined: Thu Feb 16, 2012 4:34 pm
Posts: 15
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group