2021-06-08 00:14:16 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2021-06-28 20:37:26 +00:00
|
|
|
<!-- START: /head-incl.html -->
|
|
|
|
<!-- common head elements -->
|
2021-06-08 00:14:16 +00:00
|
|
|
<meta charset="utf-8"/>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
|
|
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"
|
|
|
|
integrity="sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK" crossorigin="anonymous"></script>
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
|
2021-06-28 20:37:26 +00:00
|
|
|
<link rel="stylesheet" href="../main.css"/>
|
|
|
|
<!-- END: /head-incl.html -->
|
2021-06-08 00:14:16 +00:00
|
|
|
|
|
|
|
<title>Digging Deeper - SourceGen Tutorial</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="masthead">
|
|
|
|
<!-- START: /masthead-incl.html -->
|
2021-06-28 20:37:26 +00:00
|
|
|
<!--<div class="masthead-title" style="background-image: url('images/screenshot-mainwin.png');">-->
|
|
|
|
<div class="masthead-title">
|
|
|
|
6502bench
|
|
|
|
</div>
|
2021-06-08 00:14:16 +00:00
|
|
|
<!-- END: /masthead-incl.html -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="topnav">
|
|
|
|
<!-- START: /topnav-incl.html active:#topnav-sgtutorial -->
|
2021-06-28 20:37:26 +00:00
|
|
|
<!-- top navigation bar contents -->
|
|
|
|
<nav>
|
|
|
|
<a id="topnav-home" href=".././">HOME</a>
|
|
|
|
<a id="topnav-sgtutorial" class="active" href="../sgtutorial">SourceGen Tutorial</a>
|
|
|
|
<a id="topnav-menuicon" href="javascript:void(0);" class="icon" onclick="toggleSidenav()">
|
|
|
|
<i class="fa fa-bars"></i>
|
|
|
|
</a>
|
|
|
|
</nav>
|
|
|
|
<script>
|
|
|
|
// Sidenav toggle function.
|
|
|
|
//
|
|
|
|
// Use a jQuery function to toggle the sidenav bar. The initial state
|
|
|
|
// is undefined / inherited, so it will pop in and out as the screen
|
|
|
|
// resizes around the "large" breakpoint.
|
|
|
|
function toggleSidenav() {
|
|
|
|
$("#sidenav").toggle("fast");
|
|
|
|
}
|
|
|
|
</script>
|
2021-06-08 00:14:16 +00:00
|
|
|
<!-- END: /topnav-incl.html -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="sidenav">
|
|
|
|
<!-- START: sidenav-incl.html active:#sidenav-digging-deeper -->
|
2021-06-28 20:37:26 +00:00
|
|
|
<!-- side navigation bar contents -->
|
2021-06-08 00:14:16 +00:00
|
|
|
<ul>
|
2021-06-28 20:37:26 +00:00
|
|
|
<li id="sidenav-index"><a href="./">Introduction</a></li>
|
|
|
|
<li id="sidenav-about-disasm"><a href="about-disasm.html">About Disassembly</a></li>
|
|
|
|
<li id="sidenav-using-sourcegen"><a href="using-sourcegen.html">Using SourceGen</a>
|
|
|
|
<ul>
|
|
|
|
<li id="sidenav-moving-around"><a href="moving-around.html">Moving Around</a></li>
|
|
|
|
<li id="sidenav-simple-edits"><a href="simple-edits.html">Simple Edits</a></li>
|
|
|
|
<li id="sidenav-labels-symbols"><a href="labels-symbols.html">Labels & Symbols</a></li>
|
|
|
|
<li id="sidenav-editing-data"><a href="editing-data.html">Editing Data Operands</a></li>
|
|
|
|
<li id="sidenav-generating-code"><a href="generating-code.html">Generating Code</a></li>
|
|
|
|
</ul></li>
|
|
|
|
<li id="sidenav-digging-deeper" class="active"><a href="digging-deeper.html">Digging Deeper</a>
|
|
|
|
<ul>
|
|
|
|
<li id="sidenav-string-formatting"><a href="string-formatting.html">String Formatting</a></li>
|
|
|
|
<li id="sidenav-local-variables"><a href="local-variables.html">Local Variables</a></li>
|
|
|
|
<li id="sidenav-inline-data"><a href="inline-data.html">Inline Data</a></li>
|
|
|
|
<li id="sidenav-odds-ends"><a href="odds-ends.html">Odds & Ends</a></li>
|
|
|
|
</ul></li>
|
|
|
|
<li id="sidenav-advanced-topics"><a href="advanced-topics.html">Advanced Topics</a>
|
|
|
|
<ul>
|
|
|
|
<li id="sidenav-address-tables"><a href="address-tables.html">Address Tables</a></li>
|
|
|
|
<li id="sidenav-extension-scripts"><a href="extension-scripts.html">Extension Scripts</a></li>
|
|
|
|
<li id="sidenav-visualizations"><a href="visualizations.html">Visualizations</a></li>
|
|
|
|
</ul></li>
|
|
|
|
</ul>
|
2021-06-08 00:14:16 +00:00
|
|
|
<!-- END: sidenav-incl.html -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="main">
|
|
|
|
|
|
|
|
<h2>Digging Deeper</h2>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>This tutorial will walk you through some of the fancier things SourceGen
|
|
|
|
can do. We assume you've already finished the basic features tutorial,
|
|
|
|
and know how to create projects and move around in them.</p>
|
|
|
|
<p>Start a new project. Select <samp>Generic 6502</samp>. For the
|
|
|
|
data file, navigate to the Examples directory, then from the Tutorial
|
|
|
|
directory select "Tutorial2".</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-image">
|
|
|
|
<img src="images/t2-tutorial-top.png" alt="t2-tutorial-top"/>
|
|
|
|
</div>
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>Looking at the code list, the first thing you'll notice is that we
|
|
|
|
immediately ran into a
|
|
|
|
<code>BRK</code>, which is a pretty reliable sign that we're not in
|
|
|
|
a code section. This particular file begins with <code>00 20</code>, which
|
|
|
|
could be a load address (e.g. some C64 binaries look like this). So let's start
|
|
|
|
with that assumption.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>As discussed in the introductory material, SourceGen separates code
|
|
|
|
from data by tracing all possible execution paths from declared entry
|
|
|
|
points. The generic profiles mark the first byte of the file as an entry
|
|
|
|
point, but that's wrong here. We want to change the entry point to
|
|
|
|
be after the 16-bit load address, at offset +000002.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-image">
|
|
|
|
<img src="images/t2-1000-edit1.png" alt="t2-1000-edit1"/>
|
|
|
|
</div>
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>Click on the first line of code at address $1000, and select
|
|
|
|
<samp>Actions > Remove Analyzer Tags</samp>
|
|
|
|
(<kbd class="key">Ctrl+H</kbd> <kbd class="key">Ctrl+R</kbd>).
|
|
|
|
This removes the "code entry point" tag.
|
|
|
|
Unfortunately the $20 is still auto-detected as being part of a string
|
|
|
|
directive.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-image">
|
|
|
|
<img src="images/t2-1000-edit2.png" alt="t2-1000-edit2"/>
|
|
|
|
</div>
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>The string is making it hard to manipulate the next few bytes,
|
|
|
|
so let's fix that by selecting <samp>Edit > Toggle Data Scan</samp>
|
|
|
|
(<kbd class="key">Ctrl+D</kbd>). This turns off the feature that
|
|
|
|
automatically generates string and <code>.FILL</code> directives,
|
|
|
|
so now each uncategorized byte is on its own line.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-image">
|
|
|
|
<img src="images/t2-1000-fmt-word.png" alt="t2-1000-fmt-word"/>
|
|
|
|
</div>
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>You could select the first two lines and use
|
|
|
|
<samp>Actions > Edit Operand</samp> to format them as a 16-bit
|
|
|
|
little-endian hex value, but there's a shortcut: select the first
|
|
|
|
line with data (address $1000), then <samp>Actions > Format As Word</samp>
|
|
|
|
(<kbd class="key">Ctrl+W</kbd>).
|
|
|
|
It automatically grabbed the following byte and combined them.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-image">
|
|
|
|
<img src="images/t2-1000-setcode.png" alt="t2-1000-setcode"/>
|
|
|
|
</div>
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>Since we believe $2000 is the load address for everything that follows,
|
|
|
|
click on the line with address $1002, select
|
|
|
|
<samp>Actions > Set Address</samp>, and enter "2000". With that line
|
|
|
|
still selected, use <samp>Actions > Tag Address As Code Start Point</samp>
|
|
|
|
(<kbd class="key">Ctrl+H</kbd> <kbd class="key">Ctrl+C</kbd>) to
|
|
|
|
tell the analyzer to start looking for code there.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grid-container">
|
|
|
|
<div class="grid-item-image">
|
|
|
|
<img src="images/t2-1000-ready.png" alt="t2-1000-ready"/>
|
|
|
|
</div>
|
|
|
|
<div class="grid-item-text">
|
|
|
|
<p>That looks better, but the branch destination ($203D) is off the bottom of the
|
|
|
|
screen (unless you have a really tall screen or small fonts) because of
|
|
|
|
all the intervening data. Use <samp>Edit > Toggle Data Scan</samp>
|
|
|
|
(<kbd class="key">Ctrl+D</kbd>)
|
|
|
|
to turn the string-finder back on. Now it's easier to read.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div> <!-- #main -->
|
|
|
|
|
|
|
|
<div id="prevnext">
|
|
|
|
<a href="generating-code.html" class="btn-previous">« Previous</a>
|
|
|
|
<a href="string-formatting.html" class="btn-next">Next »</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="footer">
|
|
|
|
<!-- START: /footer-incl.html -->
|
2021-06-28 20:37:26 +00:00
|
|
|
<hr/>
|
|
|
|
<p>Copyright 2021 faddenSoft</p>
|
|
|
|
<!-- <p id="screen-size"></p>
|
|
|
|
<script>
|
|
|
|
var w = window.innerWidth;
|
|
|
|
var h = window.innerHeight;
|
|
|
|
var x = document.getElementById("screen-size");
|
|
|
|
x.innerHTML = "DEBUG: initial window size " + w + "x" + h;
|
|
|
|
</script> -->
|
2021-06-08 00:14:16 +00:00
|
|
|
<!-- END: /footer-incl.html -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|