EASy68K  
It is currently Wed Jun 03, 2020 3:02 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: 68000 TRAP (HOW DO IT)
PostPosted: Mon Jan 21, 2013 4:56 pm 
Offline

Joined: Mon Jan 21, 2013 12:01 pm
Posts: 9
Hi All,

Sorry for my english, I am braziliam and I am studing english.

I am new here, and I am do a project using 68000. The hardware its doing, but the software, I am intent use easy68k. But him use TRAP instruction. I know how trap works, but I dont can found any sample that How I implement a trap (in location, for sample, trap #15, what I put in $0BC ? Jumper ? Any Jumper ? Or a special instruction jumper ?)

I question this, becaus I programmer and make hardware to Z80 and PIC (Microchip), using call and another instructions for this, I know 68000 from long years ago, but never can use this, now I can.



Ty for help.
Moacir Jr.


Top
 Profile  
 
PostPosted: Mon Jan 21, 2013 6:35 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
EASy68K uses Trap #15 to call internal Input/Output routines. There is no need to initialize the $0BC exception vector when using the internal Trap #15 I/O calls. For example, the following code displays the null terminated text string at location message:
Code:
    move    #14,d0      task number 14 (display null string)
    lea     message,a1  address of string
    trap    #15         display it

The string is defined using the DC.B directive like this:
Code:
message dc.b    'Hello World',$d,$a,0   null terminated string


If you wish to use Trap instructions for your own purposes then it is necessary to initialize the appropriate Trap vector with the address of the trap handler code. The following example program has a Trap #14 exception handler that displays the message 'Hello World'.
Code:
* Demonstration of Trap 14
    ORG     $0B8    Trap #14 vector
    dc.l    trap14  address of trap 14 handler

START   ORG $1000   the program will load into address $1000
    nop
    trap    #14     cause Trap 14 exception
    SIMHALT         halt the program

* Trap 14 handler
trap14
    movem.l a1/d0,-(a7) save registers
    move    #14,d0      task number 14 (display null string)
    lea     message,a1  address of string
    trap    #15         display it
    movem.l (a7)+,a1/d0 restore registers
    rte                 return from exception

*------------------------------------
* Variable storage and strings
message dc.b    'Hello World',$d,$a,0   null terminated string

    END START   end of program with start address specified

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Tue Jan 22, 2013 8:31 am 
Offline

Joined: Mon Jan 21, 2013 12:01 pm
Posts: 9
Yes... is it... is exactly it... In this case, in position $0B8 have the adress of trap, that 68000 was read and execute.. Ty very much... I will use the trap of simulator, but in my project, I will put my code in trap 15 and etc....



Very Thanks.
Moacir Jr.


Top
 Profile  
 
PostPosted: Tue Jan 22, 2013 9:16 am 
Offline

Joined: Mon Jan 21, 2013 12:01 pm
Posts: 9
One more question. I will searching this case in internet, but i cant founded:

trap #15 // Trap Function
dc.w #9 // Subfunction os trap

How 68000 can get this value from this position after trap ? Why he dont execute this "instruction" (#9) if he is imediatly after trap instruction ? I supose that "trap #15" modify pc os stack pointer when in "RTE" the 68000 get the SP+2, and "jump" #9.



Ty a Lot
Moacir Jr.


Top
 Profile  
 
PostPosted: Tue Jan 22, 2013 12:13 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
moahrs wrote:
I supose that "trap #15" modify pc os stack pointer when in "RTE" the 68000 get the SP+2, and "jump" #9.

That is correct. The trap #15 handler code adjusts the return address on the stack to skip over the dc.w #9.

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Tue Jan 22, 2013 12:16 pm 
Offline

Joined: Mon Jan 21, 2013 12:01 pm
Posts: 9
profkelly,

Very thanks for help...



Moacir Jr.


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 15 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:  
cron
Powered by phpBB® Forum Software © phpBB Group