EASy68K
http://www.easy68k.com/EASy68Kforum/

Low memory/TRAP vectors in Simulator
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=5&t=406
Page 1 of 1

Author:  urbancamo [ Wed May 30, 2007 11:07 pm ]
Post subject:  Low memory/TRAP vectors in Simulator

A quick question before I got to bed: I'm writing a program that I want to develop using the assembler/simulator then retarget to my MECB clone. I was thinking that in order to determine whether the program was running on the simulator or not I could check for a 0L value in the TRAP 15 address in low memory (the MECB does not implement TRAP 15).

When I run code that does this, and examine the memory within the simulator, I notice that all low memory is zero. Are the exception/trap vectors not simulated?

Is there an easy way for me to tell if I am running on the simulator?

I would like to implement a TRAP 14 handler to implement enough of the MECB functions to within the simulator so that when I target the real MECB those functions will be available.

Is it possible for me to implement a TRAP 14 handler?

Thanks very much for the help!

Regards, Mark.

Author:  profkelly [ Thu May 31, 2007 12:53 am ]
Post subject: 

Exception handling is supported. If you want to write programs that use exceptions go to the 'Options' menu of the simulator and check 'Enable Exceptions'.

Trap #15 is used by the Simulator for I/O and control. I would not recommend using it in your programs for other purposes. If you must use it be sure the value in D0 is larger than any valid trap task number supported by Sim68K when the Trap #15 is executed.

I would also recommend you download and use the latest beta version, it is very stable and will be a full release shortly.

Author:  urbancamo [ Fri Jun 01, 2007 1:28 pm ]
Post subject:  Low memory vector

I downloaded the beta version and am now using it, thank you.

What I am doing is implementing a TRAP #14 handler within the Simulator. The (limited) function table provided by the TRAP #14 handler will make use of TRAP #15 calls where required to implement the required functionality.

This enables me to write code that makes use of TRAP #14 functions within the simulator. The functions are implemented in ROM on the MECB. By doing this I can retarget the code to the MECB whilst changing as little as possible. The only risk is that my simulation of the TRAP #14 functions is not perfect.

My interest in the TRAP #15 low-memory vector address was purely to allow my code to differentiate between when it is running on the simulator and when it is running on real MECB hardware. This allows run-time rather than assemble-time targetting of the code to the appropriate environment.

I'm not sure there is a question in there, just clarification of what I'm attempting to achieve. It appears that the TRAP #15 implementation within the simulator runs without there being an associated vector address placed in the low-memory vector address area for trap calls (forgive me if my notation is imprecise). This makes sense in that you do not specify any 'ROM' area within the program help where this code would be implemented. I take it TRAP #15 is implemented by the simulator framework rather than within 68k code running in the simulator?

Thanks for the help,

Mark.

Author:  ABeakyboy [ Fri Jun 01, 2007 2:11 pm ]
Post subject:  Re: Low memory vector

urbancamo wrote:
I take it TRAP #15 is implemented by the simulator framework rather than within 68k code running in the simulator?


Correct, I believe the simulator "traps" the TRAP #15 calls. No 68000 code in the simulator is "executed" by the simulator.

If you're looking for a way to check at runtime whether or not you're running on SIM68K, I would think that the easiest way would be to call a TRAP #15 function that is supported by SIM68K. At the same time, in your code, you somehow set up a TRAP #15 handler yourself. If, when you call the trap, your handler is executed, then you know that you're not on SIM68K. If your handler is not executed, then you know you're on SIM68K.

That's the approach I would take. I can't be absolutely sure if it would work being that it's been a long while since I did programming in assembler. Someone else will have to come along and tell me if I'm right.

Author:  profkelly [ Fri Jun 01, 2007 2:41 pm ]
Post subject:  Re: Low memory vector

urbancamo wrote:
It appears that the TRAP #15 implementation within the simulator runs without there being an associated vector address placed in the low-memory vector address area for trap calls (forgive me if my notation is imprecise). This makes sense in that you do not specify any 'ROM' area within the program help where this code would be implemented. I take it TRAP #15 is implemented by the simulator framework rather than within 68k code running in the simulator?


That is correct. You may use TRAP #15 in your own code if the contents of D0.B are greater than any valid trap task recognized by EASy68K. I would recommend setting it to $FF. EASy68K does not use the TRAP #15 vector address.

Author:  urbancamo [ Fri Jun 01, 2007 2:57 pm ]
Post subject:  Detecting the simulator

Thanks for the helpful replies.

I may approach the problem from the opposite direction - I know TRAP #14 is implemented on the MECB but not the simulator, so if I check for #$00000000 or #$FFFFFFFF in the TRAP #14 vector address then I know we're running on the simulator.

Did the initialization of the low memory area change with the new beta version? I noticed in my previous version that it was initialized to all #$00 but in the beta version it is all #$FF?

Regards, Mark.

Author:  ABeakyboy [ Fri Jun 01, 2007 5:18 pm ]
Post subject:  Re: Detecting the simulator

urbancamo wrote:
Thanks for the helpful replies.

I may approach the problem from the opposite direction - I know TRAP #14 is implemented on the MECB but not the simulator, so if I check for #$00000000 or #$FFFFFFFF in the TRAP #14 vector address then I know we're running on the simulator.

Did the initialization of the low memory area change with the new beta version? I noticed in my previous version that it was initialized to all #$00 but in the beta version it is all #$FF?

Regards, Mark.


I believe that is a recent change, yes. I think it was made to prevent coding errors caused by the assumption that memory is always initialized to 00s, which is not so. Initializing to FFs causes programs that assume 00s to break...which then allows them to be fixed.

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