6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 4:34 pm

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Sep 27, 2022 7:36 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
I decided to use a terminal window for my Typescript-based emulator as it's more suitable to my Forth operating system. Here it's doing some floating point math:
Attachment:
debug_ts.png
debug_ts.png [ 457.95 KiB | Viewed 3968 times ]

Dr Jefyll wrote:
Developing a simulator is a large investment of effort, as you know. And, until it's 100% debugged, it has potential to actually hinder your progress (although of course at other times it will help).
This bit me in porting my Python-based 65816 emulator to Typescript. I was trying to improve my code during the port and thought that
Code:
    private isSet(x: number): boolean {
        return (this.p & x) === 0;
    }
in Typescript was a better typed way of expressing
Code:
    def isSET(self, x):
        return self.p & x
in Python. It's not. It took me a bit of testing to track this bug down. Unfortunately, it would be too much effort to port the extensive unit tests I have for the Python emulator to Typescript. I'll just have to live with the uncertainty for now as the debugging experience in the Typescript version is much better than in the Python version.


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 29, 2022 8:49 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
I wonder how hard this would be to hook up to the actual hardware. I have an Arduino that can take the role of bus master and stream back to the PC what happens with the busses and control signals. You would probably still have to run the sim in parallel to get access to internal registers, but it might be useful to find when the sim is not agreeing with the hardware?

Would love to play with these, bytearray and tmr4, if you're able to share the link :-)

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 29, 2022 6:13 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
That would be a fun and interesting technical project. I'm using a message-based system for communications between the emulator and the debug adapter, which implements Microsoft's interface protocol for passing runtime events and information to the VS Code frontend. Adapting this for the Arduino should be easy. More in line with Microsoft's vision though would be developing a debug adapter to link directly to the Arduino. The technical details on that are beyond me right now but it doesn't seem much different than the process used by the VS65 Debugger extension (github), that does something similar for the VICE emulator.

As for validating the simulation, I'd rather just port my Python unit tests to Typescript. There are some 65816-based tests packages you could use (here and here for example) but unless you're using the developer's system, getting them to run on your system could be a pain (so much so that I just expanded the PY65 65c02 unit tests into the above, not a small task and it's only about 98% complete at this point).

My code isn't ready for sharing yet. It's hardcoded to my Forth operating system binary and listing file and still has limited functionality. I'll be posting it here though at some point. Note that it uses a custom ca65 listing file. It looks like bytearray is using an approach that fits much better with the VS Code source file paradigm. I imagine keeping things synched up is harder with that approach but is more technically satisfying as it doesn't need a consolidated listing file.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 25, 2022 8:46 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
I've updated my GitHub with my version of a VS Code 65816 simulator. It has the following features:

    * Runs a program from reset vector, optionally stopping on entry
    * Supports multi-file programs
    * Can set launch arguments for program
    * Follow along with execution directly in assembly source files
    * Control program execution with continue/pause, single step, step-into, step-over, step-out and run-to-cursor
    * Four types of breakpoints (conditional breakpoints not yet supported):
      * Source: set directly in assembly source files; stops execution when that line is reached
      * Function: set on function name or memory address; stops execution when that function is entered or memory address is reached during program execution
      * Data: set on X, Y, K, B and D register; stops execution when a write access to these registers is made
      * Instruction mnemonic or opcode (opcode allows a break even if there is no supporting source code)
    * Registers and hardware stack displayed in Variables pane and can be modified when program is paused
    * Watch pane functional for program symbols and memory addresses (not expressions) and the values of these can be changed when the program is paused
    * Variable/watch changes highlighted after each step and on execution pause
    * Drill down on variables/watches that represent a memory range (variable ranges can be opened in a separate hex editor window allowing modification of the memory range)
    * Symbol address and value displayed when hovering over a symbol in source code
    * Call stack displayed when stepping through program. Clicking on an entry opens the source code in an editor at that line. On continue, call stack collapses stack to current instruction.
    * Integrated terminal window for input/output with default read/write addresses at $f004 and $f001 respectively.
    * Source files listed in debug pane Loaded Scripts Explorer

The simulator runs as a VS Code extension and uses CC65 assembler source and listing files, along with the map and symbol files from the linker. I've included a "hello world" example if you'd like to try it out without bothering with CC65.


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 28, 2022 8:17 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Thanks for sharing the source! This looks really promising. I've had a play with it and added it to the list of things to implement in my build.

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 25, 2022 3:27 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
akohlbecker wrote:
I wonder how hard this would be to hook up to the actual hardware. I have an Arduino that can take the role of bus master and stream back to the PC what happens with the busses and control signals. You would probably still have to run the sim in parallel to get access to internal registers, but it might be useful to find when the sim is not agreeing with the hardware?

I found a VS Code extension that hooks VS Code up to a W65C02SXB. It was released a few days ago. It's available at the Visual Studio Marketplace. There might be something in there to incorporate into your project. I believe it's mostly written in C#.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 06, 2024 8:34 am 
Offline

Joined: Wed Nov 18, 2020 6:44 am
Posts: 6
I made my Github repo public with my 65816 OS and the included vscode debugger + emulator written in TypeScript.

https://github.com/alexanderbh/65816-OS

It is a bit of a mess as it is just a playground for myself. But perhaps someone out there could take some inspiration from it.

You can read about each of the parts (OS, debugger, emulator) in the readme.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 06, 2024 8:38 am 
Online
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Thanks for publishing! I think it's almost always the right thing to do, for works-in-progress as well as polished-and-final projects.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 06, 2024 8:48 am 
Offline

Joined: Wed Nov 18, 2020 6:44 am
Posts: 6
BigEd wrote:
Thanks for publishing! I think it's almost always the right thing to do, for works-in-progress as well as polished-and-final projects.


I agree. There is just that barrier of publishing something that is just a hobby project and far from complete/stable.

But for sure there are things I have made in that repo that I would have loved to find somewhere else. Things like how to connect to the vscode debugger UI. How to map between memory addresses and source file lines.

Maybe someone will stumble upon this and use it to make something far better.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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: