Jump to content
Sign in to follow this  
Asmusr

Debugger instructions

Recommended Posts

Has anyone thought of using some of the unused opcodes for debugger output instructions? For instance, you could have an instruction PRINT R0 that you insert in the program which would print the current value of R0 to the debugger's console. This would only work on a combination of an assembler and an emulator that understood the new instructions, of course. I assume a real TI would ignore illegal instructions if you left them in (wasting some clock cycles), but usually you would remove them first by setting a switch in the assembler. The instruction set could include instructions for printing registers/PC/ST/CPU/VDP/GROM memory, strings, VDP registers, statuses, etc. The point is that in many cases this would be faster and easier than traditional debugging using single stepping and breakpoints because the debugger output would be resistant to program changes that shifts the memory addresses around.

 

Share this post


Link to post
Share on other sites

It was done in Win994A - there's a set of opcodes that were repurposed. I've declined to do so in Classic99.

Share this post


Link to post
Share on other sites

It was done in Win994A - there's a set of opcodes that were repurposed. I've declined to do so in Classic99.

 

I think those were for implementing an imaginary improved machine with a stack pointer etc. I'm talking about instructions to assist in debugging with no side effect on the program.

Share this post


Link to post
Share on other sites

I've previously put the forward the idea of a HALT instruction that would stop the emulator and open the debugger, but it's not high on Tursi's list of priorities, which I can understand. I think I suggested other instructions, too (all related to debugging) but I can't remember them now!

  • Like 1

Share this post


Link to post
Share on other sites

As for the MAME/MESS debugger, you can set breakpoints or watchpoints (monitoring access to memory locations), so I don't really miss such a command, actually. Also, a particular debugger command takes up memory space and thus shifts the next commands, so it may have some unwanted effect.

  • Like 1

Share this post


Link to post
Share on other sites

... you can set breakpoints or watchpoints (monitoring access to memory locations), so I don't really miss such a command, actually.

Yes, that's right. I use breakpoint R12=BEEF all the time. LI R12,>BEEF is then inserted, moved around *), activated and deactivated (using a comment directive).

 

*) As a consequence of altering other code, or of course by moving the instruction(s) (LI R12,>BEEF) itself.

 

Edit:

And if you accidentally leave the instruction(s) in a release, it won't do much harm. Well, all things being relative, I only use R12 for 9901, and set it prior to i/o.

 

;)

Edited by sometimes99er
  • Like 1

Share this post


Link to post
Share on other sites

I've previously put the forward the idea of a HALT instruction that would stop the emulator and open the debugger, but it's not high on Tursi's list of priorities, which I can understand. I think I suggested other instructions, too (all related to debugging) but I can't remember them now!

 

Cool idea. I think I will implement that in JS99er.

  • Like 1

Share this post


Link to post
Share on other sites

Back when I first starting messing with TI software again, I instrumented ti99sim with a 'debug print device'. Basically, I added a bunch of registers to the VDP to which I could send a printf style string and a bunch of variables. The emulator would then format and print that string to the console. Originally, I had the TI do the formatting, but that was just stupidly slow. Something like that would be great for those of us programming in higher level languages.

 

Another thing I looked at but never got around to was adding support for resolving gcc symbols to js99er. When compiling a program with gcc, you can have it output a file that contains the memory locations of all symbols (variables, constants & functions). The idea would be that you could load this file and have a tab where you could monitor all variables in real time. I started doing this, but once you have things like structures and arrays in your programs it's not very straightforward to do the 'decoding' of memory contents.

  • Like 1

Share this post


Link to post
Share on other sites

 

Cool idea. I think I will implement that in JS99er.

 

Yeah. Once an op-code has been selected, it can be done with a data statement for assemblers that don't know about specific specialist debugging instructions.

 

HALT EQU $9999

 

...

...

some code

...

...

DATA HALT

...

...

...

 

In Classic99 there is a "halt on undefined opcode" option, so one can just insert a nonsense op-code into the code and it has the same effect.

Edited by Willsy

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...