| 1 |
<!doctype html public"-//w3c//dtd xhtml 1.0 Transitional//en"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>D52 Disassembler User's Manual</title> |
| 5 |
</head> |
| 6 |
<body> |
| 7 |
<a name="topofdoc"></a> |
| 8 |
<div align="center"> |
| 9 |
<font size="8" color="#ff0000"> |
| 10 |
<strong><i>D52 Disassembler User's Manual</i></strong><br> |
| 11 |
</font> |
| 12 |
<hr> |
| 13 |
<font size="4" color="#000000"> |
| 14 |
8052 Disassembler for Linux and Windows<br> |
| 15 |
GNU General Public License Version 3<br> |
| 16 |
Copyright 2007 by Jeffery L. Post<br> |
| 17 |
j_post <AT> pacbell <DOT> net<br> |
| 18 |
Hosted on <a href="http://www.8052.com/users/disasm">www.8052.com</a> |
| 19 |
<br><br> |
| 20 |
Version 3.4.1 - September, 2007 |
| 21 |
</font> |
| 22 |
<hr> |
| 23 |
</div> |
| 24 |
|
| 25 |
This program is free software; you can redistribute it and/or modify |
| 26 |
it under the terms of the GNU General Public License as published by |
| 27 |
the Free Software Foundation, either version 3 of the License, or |
| 28 |
(at your option) any later version. |
| 29 |
This program is distributed in the hope that it will be useful, |
| 30 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 |
GNU General Public License for more details. |
| 33 |
You should have received a copy of the GNU General Public License |
| 34 |
along with this program; if not, write to the Free Software |
| 35 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 36 |
<br><br> |
| 37 |
The file COPYING contains the full text of the GNU General Public License, Version 3. |
| 38 |
<br><br> |
| 39 |
<i><b>NOTE: As Novell and Microsoft are in violation of the GPL, this software |
| 40 |
may not be distributed by either Novell or Microsoft. The same prohibition applies |
| 41 |
to any company that enters into an agreement with Microsoft regarding Microsoft's |
| 42 |
phony patent claims against Linux. In addition, no one who cannot or will not |
| 43 |
honor ALL the requirements of GPL version 3 may distribute this software.</b></i> |
| 44 |
<hr> |
| 45 |
|
| 46 |
<h3>TABLE OF CONTENTS</h3> |
| 47 |
<ul> |
| 48 |
<li><a href="#introduction">Introduction</a><br> |
| 49 |
<li><a href="#disclaimer">Disclaimer</a><br> |
| 50 |
<li><a href="#starting">Getting Started</a><br> |
| 51 |
<li><a href="#options">Command Line Options</a><br> |
| 52 |
<a href="#aoption"> A option - define ascii macro</a><br> |
| 53 |
<a href="#boption"> B option - disassemble binary file</a><br> |
| 54 |
<a href="#doption"> D option - put data in comment field</a><br> |
| 55 |
<a href="#hoption"> H option - disassemble hex file</a><br> |
| 56 |
<a href="#ioption"> I option - add include for 'sfr52.inc' file</a><br> |
| 57 |
<a href="#koption"> K option - disassemble for older (DOS) Keil A51</a><br> |
| 58 |
<a href="#noption"> N option - output operands in C style format (0xcd instead of 0cdh)</a><br> |
| 59 |
<a href="#poption"> P option - put dot '.' in front of pseudo ops (eg: .equ instead of equ) </a><br> |
| 60 |
<a href="#soption"> S option - change pseudo op for ascii strings</a><br> |
| 61 |
<a href="#toption"> T option - trace and analyze code before disassembly</a><br> |
| 62 |
<a href="#uoption"> U option - output labels, mnemonics, etc in upper case</a><br> |
| 63 |
<a href="#xoption"> X option - add hex offset to addresses</a><br> |
| 64 |
<a href="#zoption"> Z option - read cycle count file (d52 only)</a><br> |
| 65 |
<li><a href="#directives">Control File Directives - define interpretation of disassembly data</a><br> |
| 66 |
<a href="#adirective"> A directive - address data</a><br> |
| 67 |
<a href="#bdirective"> B directive - byte (8 bit) data</a><br> |
| 68 |
<a href="#cdirective"> C directive - code (force disassembly)</a><br> |
| 69 |
<a href="#ddirective"> D directive - data type (label or symbol)</a><br> |
| 70 |
<a href="#fdirective"> F directive - define SFR label</a><br> |
| 71 |
<a href="#idirective"> I directive - ignore data (do not disassemble)</a><br> |
| 72 |
<a href="#kdirective"> K directive - define name for SFR bit</a><br> |
| 73 |
<a href="#ldirective"> L directive - define label</a><br> |
| 74 |
<a href="#mdirective"> M directive - define name for bit addressable memory</a><br> |
| 75 |
<a href="#ndirective"> N directive - suppress label generation for an address</a><br> |
| 76 |
<a href="#odirective"> O directive - add hex offset to addresses</a><br> |
| 77 |
<a href="#pdirective"> P directive - patch inline code</a><br> |
| 78 |
<a href="#rdirective"> R directive - define register name</a><br> |
| 79 |
<a href="#sdirective"> S directive - define symbol</a><br> |
| 80 |
<a href="#tdirective"> T directive - ascii text</a><br> |
| 81 |
<a href="#wdirective"> W directive - word (16 bit) data </a><br> |
| 82 |
<a href="#xdirective"> X directive - define name for specific operand</a><br> |
| 83 |
<a href="#ydirective"> Y directive - define name for specific operand but suppress EQU generation</a><br> |
| 84 |
<a href="#zdirective"> Z directive - specify code for which to generate cycle counts</a><br> |
| 85 |
<a href="#commentdirective"> # directive - header comment</a><br> |
| 86 |
<a href="#icommentdirective"> ! directive - inline comment</a><br> |
| 87 |
<li><a href="#symnote">A Note on Symbols, Labels and Names</a><br> |
| 88 |
<li><a href="#outfile">Format of Output File</a><br> |
| 89 |
<li><a href="#summary">Summary</a><br> |
| 90 |
<li><a href="#regmaps">8052 Register Maps</a><br> |
| 91 |
<li><a href="#bsfr">8052 Bit Addressable SFRs</a><br> |
| 92 |
<li><a href="#bmem">8052 Bit Addressable Memory</a><br> |
| 93 |
</li> |
| 94 |
</ul> |
| 95 |
<br><br> |
| 96 |
|
| 97 |
<a href="#topofdoc">Back to top</a><br> |
| 98 |
|
| 99 |
<a name="introduction"></a> |
| 100 |
<h4><em>Introduction</em></h4> |
| 101 |
<hr> |
| 102 |
|
| 103 |
The D52 disassembler allows the user to specify memory areas as code, |
| 104 |
binary data (8 or 16 bit), ascii text, address tables, or data that should |
| 105 |
be ignored (not disassembled). You may specify such areas in an ascii text |
| 106 |
file with the same name as the file to be disassembled, but with an extension |
| 107 |
of <em>ctl</em> (for example: program.ctl controls the disassembly of program.hex or |
| 108 |
program.bin). |
| 109 |
<br><br> |
| 110 |
With the use of a control file, you can, by an iterative process, get a |
| 111 |
progressively more meaningful disassembly by modifying the control file |
| 112 |
based on examination of the output of previous runs of the disassembler. |
| 113 |
You can also specify names for labels and symbols in the control file, |
| 114 |
resulting in a much more readable source file. |
| 115 |
<br><br> |
| 116 |
Labels and symbols may have as many characters as will fit in one line of |
| 117 |
the control file, but some cross assemblers (and especially cross linkers) |
| 118 |
will truncate any more than some fixed number of characters. Consult your |
| 119 |
cross development tool documentation. Labels and symbols are not case sensitive. |
| 120 |
<br><br> |
| 121 |
The control file may exist in either the current directory or the |
| 122 |
directory of the file to be disassembled. If it is in both directories, |
| 123 |
the control file in the current directory will take precedence. The |
| 124 |
output file will always be placed in the current directory. |
| 125 |
<br><br> |
| 126 |
The |
| 127 |
<a href="#starting">getting started</a> |
| 128 |
section of this document gives some minimal information |
| 129 |
for users who are eager to try out the disassembler. For best |
| 130 |
use of the disassembler, however, you should read the sections on |
| 131 |
<a href="#options">command line options</a> |
| 132 |
and |
| 133 |
<a href="#directives">control file directives</a> |
| 134 |
before proceeding. |
| 135 |
<br><br> |
| 136 |
Much of the information in this manual also applies to the 8048 and Z80 |
| 137 |
disassemblers. Invoking the disassemblers without any command line |
| 138 |
parameters will display a list of options. |
| 139 |
<br><br> |
| 140 |
|
| 141 |
<a name="disclaimer"><em>Disclaimer</em></a><hr> |
| 142 |
D52 is a tool for educational use and for recovering source code that has been |
| 143 |
lost or is unavailable. |
| 144 |
<em>Disassembling a program may be unethical or illegal under some circumstances.</em> |
| 145 |
It is your sole responsibility to determine whether use of D52 for a particular |
| 146 |
purpose is both legal and ethical. |
| 147 |
<br><br> |
| 148 |
|
| 149 |
<br><br> |
| 150 |
<a href="#topofdoc">Back to top</a><br> |
| 151 |
|
| 152 |
<a name="starting"></a> |
| 153 |
<h4><em>Getting Started</em></h4> |
| 154 |
<hr> |
| 155 |
|
| 156 |
D52 is a command line disassembler. To disassemble a file called 'program.bin' |
| 157 |
or 'program.hex', type in (at the command line prompt): |
| 158 |
|
| 159 |
<table cellspacing=5 summary=""> |
| 160 |
<tr><td></td><td></td><td></td><td></td><td>d52 -d program</td></tr> |
| 161 |
</table> |
| 162 |
|
| 163 |
A control file with the same name as the file to be disassembled, but with |
| 164 |
an extension of '.ctl' can be created in which you can specify areas of |
| 165 |
memory to be ascii text, 8-bit binary data, 16-bit binary data, etc. |
| 166 |
A control file is not necessary for disassembly, but as will be seen, |
| 167 |
it will provide for a much more complete disassembly. The |
| 168 |
<a href="#toption">t option</a> |
| 169 |
will cause D52 to trace and analyze the code before disassembly, and will |
| 170 |
create a preliminary control file. |
| 171 |
|
| 172 |
<br><br> |
| 173 |
If a file extension is not provided and neither the |
| 174 |
<a href="#boption">b option</a> |
| 175 |
nor the |
| 176 |
<a href="#hoption">h option</a> |
| 177 |
is specified on the command line, the disassembler will first search for a hex |
| 178 |
file and, if it is not found, will then search for a bin file. The disassembler |
| 179 |
can be forced to look for only one or the other by specifying either the |
| 180 |
<a href="#boption">binary</a> |
| 181 |
or the |
| 182 |
<a href="#hoption">hex</a> |
| 183 |
option on the command line: |
| 184 |
|
| 185 |
<table cellspacing=5 summary=""> |
| 186 |
<tr><td></td><td></td><td></td><td></td><td>d52 -db program</td> |
| 187 |
<td></td><td></td><td></td><td></td><td>for the file program.bin, or</td></tr> |
| 188 |
<tr><td></td><td></td><td></td><td></td><td>d52 -dh program</td> |
| 189 |
<td></td><td></td><td></td><td></td><td>for the file program.hex</td></tr> |
| 190 |
</table> |
| 191 |
|
| 192 |
If a file extension of '.hex' or '.bin' is provided in the filename (ie: d52 test.hex), |
| 193 |
that is equivalent to using the |
| 194 |
<a href="#hoption">h option</a> |
| 195 |
or |
| 196 |
<a href="#boption">b option</a>. |
| 197 |
<br><br> |
| 198 |
|
| 199 |
D52 will produce a file named 'program.d52' containing the disassembly of |
| 200 |
the 8051/8052 instructions in the original hex or binary file. It is |
| 201 |
very useful on the first few disassemblies to use the |
| 202 |
<a href="#doption">d option</a> |
| 203 |
, which adds a comment field to every line. The comment field contains the |
| 204 |
hexadecimal address of each instruction, the hex data for each byte in |
| 205 |
the instruction, and the ascii code for each byte of the instruction. |
| 206 |
<br>Example: |
| 207 |
|
| 208 |
<table cellspacing=5 summary=""> |
| 209 |
<tr><td></td><td></td><td></td><td></td><td></td><td>(opcode/operands)</td><td>(address)</td><td>(data)</td><td>(ascii)</td></tr> |
| 210 |
<tr><td></td><td></td><td></td><td></td><td></td><td>orl a,#42h</td><td>; 0df6</td><td>44 42</td><td>DB</td></tr> |
| 211 |
</table> |
| 212 |
|
| 213 |
This makes it easy to spot areas of ascii text or other nonexecutable |
| 214 |
code, and you can then modify the control file to tell the disassembler |
| 215 |
that these areas should be treated as some other kind of data on subsequent |
| 216 |
disassemblies. Please see the section on |
| 217 |
<a href="#directives">control file directives</a> |
| 218 |
for specific information. |
| 219 |
<br><br> |
| 220 |
|
| 221 |
By examining the output file and then modifying the control file based |
| 222 |
on the information obtained, you can get a progressively better disassembly |
| 223 |
of your program. Generally, about half a dozen iterations of the disassembly |
| 224 |
are enough to produce a very readable source file that can then be modified |
| 225 |
and reassembled. |
| 226 |
|
| 227 |
<br><br> |
| 228 |
<a href="#topofdoc">Back to top</a><br> |
| 229 |
|
| 230 |
<a name="options"></a> |
| 231 |
<h4><em>Command Line Options</em></h4> |
| 232 |
<hr> |
| 233 |
|
| 234 |
Command line options modify the operation of the disassembler. |
| 235 |
They may be specified on the command line using either Unix style |
| 236 |
options: |
| 237 |
|
| 238 |
<table cellspacing=5 summary=""> |
| 239 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 -db filename</td></tr> |
| 240 |
</table> |
| 241 |
|
| 242 |
or DOS style options: |
| 243 |
|
| 244 |
<table cellspacing=5 summary=""> |
| 245 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 /d /b filename</td></tr> |
| 246 |
</table> |
| 247 |
|
| 248 |
Options may be entered in a freeform fashion (in any order or format) |
| 249 |
provided that any options preceeding the filename of the program to be |
| 250 |
disassembled must begin with either a dash (-) or a slash (/). For example: |
| 251 |
|
| 252 |
<table cellspacing=5 summary=""> |
| 253 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 /db filename -x1000</td></tr> |
| 254 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 filename -d b x1000</td></tr> |
| 255 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 -d filename bx1000</td></tr> |
| 256 |
</table> |
| 257 |
|
| 258 |
all mean exactly the same thing and will cause the disassembler to |
| 259 |
behave in exactly the same way. Exceptions are that the |
| 260 |
<a href="#xoption">X option</a> |
| 261 |
, if used, must be the last option given, and if both the |
| 262 |
<a href="#aoption">A option</a> and the |
| 263 |
<a href="#soption">S option</a> |
| 264 |
are used, the S option must preceed the A option. |
| 265 |
<br><br> |
| 266 |
Note that the file name specified on the command line does <em>not</em> |
| 267 |
include the .hex or .bin extention. |
| 268 |
<br><br> |
| 269 |
Command line options are: |
| 270 |
<hr> |
| 271 |
|
| 272 |
<a name="aoption"></a> |
| 273 |
<h4><em>A Option (ascii macro)</em></h4> |
| 274 |
|
| 275 |
The A option tells the disassembler to change the db/defb pseudo op to |
| 276 |
the ascii macro (pseudo op 'ascii' instead of 'db' or 'defb') for areas |
| 277 |
defined as ascii text. This will cause the disassembler to include a |
| 278 |
macro definition in the disassembly output file that should expand to |
| 279 |
'db' for the cross assembler. To use this option, your cross assembler |
| 280 |
must be able to handle macros, and in particular, D52's macro format. |
| 281 |
If used in conjunction with the |
| 282 |
<a href="#soption">S option</a> |
| 283 |
, the S option must come first on the command line. |
| 284 |
<br><br> |
| 285 |
There are some caveats regarding the ascii macro. The intent of |
| 286 |
this macro is to make ascii text easier to find in the output file. |
| 287 |
Once you're satisfied with the readability of the output file, you |
| 288 |
may want to run the disassembler once more without the A option to |
| 289 |
produce a file compatible with your cross assembler. |
| 290 |
<br><br> |
| 291 |
Some cross assemblers treat certain characters within a macro as |
| 292 |
special meta-characters. The Huntsville Microsystems HMA8051, for |
| 293 |
example, regards the characters '#', '.' and '\' as special within a |
| 294 |
macro. If these characters occur in ascii text using the ascii macro |
| 295 |
of D52, the assembler will do strange and not so wonderful things with |
| 296 |
them. If this happens, just do not use the A option (by default, it is off). |
| 297 |
<br><br> |
| 298 |
A problem that will be common with all cross assemblers is that |
| 299 |
the disassembler does not currently treat the single quote (') |
| 300 |
character differently than it does other characters within |
| 301 |
ascii text. Since the disassembler delineates ascii text (whether using |
| 302 |
the A option or not) with the single quote character, its presence |
| 303 |
in ascii text areas will cause problems. The only solution to this is to |
| 304 |
manually edit the output file of the disassembler or to define the byte |
| 305 |
of the single quote as a binary byte in the control file (see the |
| 306 |
<a href="#bdirective"> B control file directive</a> |
| 307 |
). |
| 308 |
|
| 309 |
<a name="boption"></a> |
| 310 |
<h4><em>B Option (read binary file)</em></h4> |
| 311 |
|
| 312 |
The B option forces the disassembler to read a binary file |
| 313 |
(extention '.bin') instead of an Intel hex file (extention .hex). |
| 314 |
If neither the B option nor the |
| 315 |
<a href="#hoption">H option</a> |
| 316 |
are specified, the disassembler will first search for a file with an |
| 317 |
extention of .hex, and if not found, will then search for a binary |
| 318 |
file with an extention of .bin. |
| 319 |
|
| 320 |
<a name="doption"></a> |
| 321 |
<h4><em>D Option (put data in comment field)</em></h4> |
| 322 |
|
| 323 |
The D option tells the disassembler to include a comment field |
| 324 |
in each disassembled line. The comment field will contain the |
| 325 |
hexadecimal address of each instruction, the hex data for each |
| 326 |
byte in the instruction, and the ascii code for each byte of the |
| 327 |
instruction. Example: |
| 328 |
|
| 329 |
<table cellspacing=5 summary=""> |
| 330 |
<tr><td></td><td></td><td></td><td></td><td></td><td>(opcode/operands)</td> |
| 331 |
<td>(address)</td><td>(data)</td><td>(ascii)</td></tr> |
| 332 |
<tr><td></td><td></td><td></td><td></td><td></td><td>orl a,#42h</td> |
| 333 |
<td>; 0df6</td><td>44 42</td><td>DB</td></tr> |
| 334 |
</table> |
| 335 |
|
| 336 |
This makes it easy to spot areas of ascii text or other nonexecutable |
| 337 |
code, and then modify the control file to tell the disassembler that |
| 338 |
these areas should be treated as some other kind of data on subsequent |
| 339 |
disassemblies. Please see the section on |
| 340 |
|
| 341 |
<a href="#directives">control file directives</a> |
| 342 |
|
| 343 |
for specific information. |
| 344 |
|
| 345 |
<a name="hoption"></a> |
| 346 |
<h4><em>H Option (read hexadecimal file)</em></h4> |
| 347 |
|
| 348 |
The H option forces the disassembler to read an Intel hex file |
| 349 |
(extention '.hex') instead of a binary file (extention '.bin'). |
| 350 |
If neither the |
| 351 |
<a href="#boption">B option</a> |
| 352 |
nor the H option are specified, the disassembler will first |
| 353 |
search for a file with an extention of '.hex', and if not found, |
| 354 |
will then search for a binary file with an extention of '.bin'. |
| 355 |
|
| 356 |
<a name="ioption"></a> |
| 357 |
<h4><em>I option (add include for 'sfr52.inc' file)</em></h4> |
| 358 |
|
| 359 |
The I option adds this line to the .d52 disassembly file: |
| 360 |
|
| 361 |
<br><br> |
| 362 |
<pre> |
| 363 |
include "sfr52.inc" |
| 364 |
</pre> |
| 365 |
<br><br> |
| 366 |
|
| 367 |
The file 'sfr52.inc' includes equates for 8052 special function registers |
| 368 |
and SFR bits that may be needed by some cross assemblers. The sfr52.inc |
| 369 |
file <em>should be modified to suite your 8052 cross assembler</em> |
| 370 |
since the equates required will vary from assembler to assembler. |
| 371 |
For example, one cross assembler I test with requires the equate for |
| 372 |
'acc', and yet another cross assembler not only does not require it, |
| 373 |
but will generate an error if it is present. You may also need to |
| 374 |
edit the 'include' pseudo-op in the disassembly file if your cross |
| 375 |
assembler uses some other pseudo-op to include files (or edit the |
| 376 |
source file 'd52p2.c' and recompile). |
| 377 |
<br><br> |
| 378 |
It is best to start out with all the equates in sfr52.inc commented out, |
| 379 |
find out what undefined label errors your cross assembler generates, |
| 380 |
then uncomment the required equates in sfr52.inc. |
| 381 |
<br><br> |
| 382 |
This option is incompatible with the |
| 383 |
<a href="#koption">K option</a>. |
| 384 |
|
| 385 |
<a name="koption"></a> |
| 386 |
<h4><em>K Option (disassemble for Keil's A51 assembler)</em></h4> |
| 387 |
|
| 388 |
Tells D52 to generate source code compatible with the older Keil A51 assembler. |
| 389 |
<br><br> |
| 390 |
<i><b>NOTE:</b> Newer versions of Keil's A51 assembler (tested with version 7.10) |
| 391 |
have come into compliance with the rest of the world. <b>Do not</b> use this option |
| 392 |
with newer versions of A51.</i> |
| 393 |
|
| 394 |
<a name="noption"></a> |
| 395 |
<h4><em>N Option (use C type operands)</em></h4> |
| 396 |
|
| 397 |
Use this option to have the disassembler output hexadecimal operands using C |
| 398 |
notation, ie: 0xcd instead of the default 0cdh. |
| 399 |
|
| 400 |
<a name="poption"></a> |
| 401 |
<h4><em>P Option (add dot in front of pseudo ops)</em></h4> |
| 402 |
|
| 403 |
Some assemblers require pseudo operations to begin with a dot. Use this option |
| 404 |
to have the disassembler output ".equ" instead of "equ" and similar for org and |
| 405 |
other pseudo operations. |
| 406 |
|
| 407 |
<a name="soption"></a> |
| 408 |
<h4><em>S Option (set string pseudo op)</em></h4> |
| 409 |
|
| 410 |
This option tells the disassembler to generate the pseudo ops |
| 411 |
'defb' and 'defw' instead of 'db' and 'dw' for those cross |
| 412 |
assemblers that may require this. Most cross assemblers understand |
| 413 |
'db' and 'dw', so these are the defaults for the disassembler. Use |
| 414 |
this option for cross assemblers that do not recognize 'db' and |
| 415 |
'dw'. If used in conjunction with the |
| 416 |
<a href="#aoption">A option</a> |
| 417 |
, the S option must preceed the A option on the command line. |
| 418 |
|
| 419 |
<a name="toption"></a> |
| 420 |
<h4><em>T Option (trace and analyze code)</em></h4> |
| 421 |
|
| 422 |
This option tells D52 to trace and analyze the 8052 code before disassembling it. |
| 423 |
D52 will attempt to determine which parts of the code are actually code, and |
| 424 |
which parts are ascii text, binary data, pointers, etc. While it does a reasonably |
| 425 |
good job of analyzing the code on most files, no program can do as good a job as |
| 426 |
a human programmer. A control file with the same name as the hex or bin file, but |
| 427 |
with an extension of '.ctl', will be created before the actual disassembly is |
| 428 |
performed. You can then edit the control file to correct any erroneous directives, |
| 429 |
or to add new directives. |
| 430 |
|
| 431 |
<br><br> |
| 432 |
<em>Warning:</em> Using this option will <em>overwrite</em> any control file |
| 433 |
that may already exist for the code file being disassembled. It is intended to |
| 434 |
be used on the <em>first</em> disassembly only. |
| 435 |
|
| 436 |
<a name="uoption"></a> |
| 437 |
<h4><em>U Option (upper case output)</em></h4> |
| 438 |
|
| 439 |
Causes labels, symbols, mnemonics, etc to be output in upper case, for cross |
| 440 |
assemblers that may require upper case code. Comments, literal data values, |
| 441 |
strings, and other output are not affected by this option. |
| 442 |
|
| 443 |
<a name="xoption"></a> |
| 444 |
<h4><em>X Option (add hexadecimal offset to addresses)</em></h4> |
| 445 |
|
| 446 |
This option causes the disassembler to add a hexadecimal offset |
| 447 |
to the address of every location in the code file. This may be |
| 448 |
useful for disassembling code that was read from the second (or |
| 449 |
subsequent) rom of a set of roms. For example, suppose that |
| 450 |
binary data was obtained from a set of 4K byte eproms (call them |
| 451 |
rom1 and rom2). Then the first file should be disassembled with |
| 452 |
the command line: |
| 453 |
|
| 454 |
<table cellspacing=5 summary=""> |
| 455 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 -d rom1</td> |
| 456 |
</table> |
| 457 |
|
| 458 |
and the second should be disassembled with the X option: |
| 459 |
|
| 460 |
<table cellspacing=5 summary=""> |
| 461 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 -d rom2 x1000</td> |
| 462 |
</table> |
| 463 |
|
| 464 |
The two files then can be combined into one and all references |
| 465 |
within the disassembled code will be to the correct addresses. |
| 466 |
<br><br> |
| 467 |
If given on the command line, the X option overrides any <a href="#odirective"> |
| 468 |
O directive</a> in the control file. |
| 469 |
|
| 470 |
<a name="zoption"></a> |
| 471 |
<h4><em>Z Option (read cycle count file - d52 only)</em></h4> |
| 472 |
|
| 473 |
Jan Waclawek has added code to generate cycle counts for all three disassemblers. |
| 474 |
In addition, d52 can read customized cycle count files for 8052 derivatives. |
| 475 |
See the <a href="#zdirective">Z directive</a> for more information. |
| 476 |
|
| 477 |
Please read Jan's documentation in the 'cyclefiles' directory. |
| 478 |
|
| 479 |
<table cellspacing=5 summary=""> |
| 480 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d52 -zfilename</td> |
| 481 |
</table> |
| 482 |
|
| 483 |
Many thanks to Jan for a great job! |
| 484 |
|
| 485 |
<br><br> |
| 486 |
<a href="#topofdoc">Back to top</a><br> |
| 487 |
|
| 488 |
<a name="directives"></a> |
| 489 |
<h4><em>Control File Directives</em></h4> |
| 490 |
<hr> |
| 491 |
|
| 492 |
Control directives tell the disassembler to treat specified areas |
| 493 |
of the code to be disassembled as something other than executable |
| 494 |
code. The user specifies control directives by editing (with any |
| 495 |
text editor) a control file with the same name as the file to be |
| 496 |
disassembled, but with a file extention of .ctl (eg: program.ctl |
| 497 |
to control the disassembly of the file program.hex or program.bin). |
| 498 |
A generic control file called 'generic.ctl' is provided to get the |
| 499 |
user started. Copy 'generic.ctl' to 'file.ctl' where 'file' is the |
| 500 |
name of the binary or Intel hex file to be disassembled, and modify |
| 501 |
as required based on the output of the disassembler. Then run the |
| 502 |
disassembler again to get a more readable disassembly of the code. |
| 503 |
<br><br> |
| 504 |
All directives consist of a character that specifies the type of data, |
| 505 |
followed by a hexadecimal number specifying the value or range of |
| 506 |
values of the data. In the case of a |
| 507 |
<a href="#ldirective">label</a> |
| 508 |
or |
| 509 |
<a href="#sdirective">symbol</a> |
| 510 |
directive, the hexadecimal number is followed by ascii text defining |
| 511 |
the label or symbol. See individual directives for examples. All |
| 512 |
directives must be in the first column of the line. Directives may be |
| 513 |
complete words, but only the first character is significant, ie: |
| 514 |
|
| 515 |
<table cellspacing=5 summary=""> |
| 516 |
<tr><td></td><td></td><td></td><td></td><td></td><td>Label</td> |
| 517 |
<td></td><td></td><td></td><td>0</td> |
| 518 |
<td></td><td></td><td></td><td>reset</td> |
| 519 |
<td></td><td></td><td></td><td></td><td></td> |
| 520 |
<td></td><td></td><td></td><td></td><td>and</td></tr> |
| 521 |
<tr><td></td><td></td><td></td><td></td><td></td><td>looney</td> |
| 522 |
<td></td><td></td><td></td><td>0</td> |
| 523 |
<td></td><td></td><td></td><td>reset</td></tr> |
| 524 |
</table> |
| 525 |
|
| 526 |
will both generate the label "reset" for address 0. Note that they |
| 527 |
are not case sensitive. |
| 528 |
<br><br> |
| 529 |
Numerical values must be in hexadecimal and may optionally be preceeded by |
| 530 |
"0x". For example, a hexadecimal number may be entered as "1234" or |
| 531 |
"0x1234". Either will be interpreted as the number 1234H. |
| 532 |
<br><br> |
| 533 |
Everything following a semi-colon (;) is a comment and will be |
| 534 |
ignored by the disassembler. |
| 535 |
<br><br> |
| 536 |
Label and symbol directives differ in that a label refers to an |
| 537 |
address and a symbol refers to any 8 or 16 bit immediate data. |
| 538 |
Therefore an opcode such as |
| 539 |
|
| 540 |
<table cellspacing=5 summary=""> |
| 541 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 542 |
<td></td><td></td><td></td><td></td><td></td><td>r2,#data</td></tr> |
| 543 |
</table> |
| 544 |
|
| 545 |
will cause the disassembler to search only the symbol table for a |
| 546 |
matching value whereas an opcode such as |
| 547 |
|
| 548 |
<table cellspacing=5 summary=""> |
| 549 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 550 |
<td></td><td></td><td></td><td></td><td></td><td>dptr,#data</td> |
| 551 |
</tr> |
| 552 |
</table> |
| 553 |
|
| 554 |
will cause the disassembler to search the label table first, and |
| 555 |
if no matching value is found, to then search the symbol table. |
| 556 |
|
| 557 |
<br><br> |
| 558 |
Symbols apply only to immediate data. To specify a symbol for an 8052 |
| 559 |
data memory location, use the |
| 560 |
<a href="#rdirective">R directive</a> |
| 561 |
, or to force name substitution for an operand at a given address, use the |
| 562 |
<a href="#xdirective">X directive</a>. |
| 563 |
<br><br> |
| 564 |
|
| 565 |
Single values are specified by entering just the value; ranges of |
| 566 |
values are specified by a start and stop address separated by a dash |
| 567 |
(-), or by a start address and count separated by a plus (+), ie: |
| 568 |
|
| 569 |
<table cellspacing=5 summary=""> |
| 570 |
<tr><td></td><td></td><td></td><td></td><td></td><td>t 1000</td> |
| 571 |
<td></td><td></td><td></td><td></td><td></td><td></td> |
| 572 |
<td>the data at address 1000H is ascii text.</td></tr> |
| 573 |
<tr><td></td><td></td><td></td><td></td><td></td><td>t 1000-1010</td> |
| 574 |
<td></td><td></td><td></td><td></td><td></td><td></td> |
| 575 |
<td>the data from address 1000H to (and including) |
| 576 |
address 1010H is ascii text.</td></tr> |
| 577 |
<tr><td></td><td></td><td></td><td></td><td></td><td>t 1000+6</td> |
| 578 |
<td></td><td></td><td></td><td></td><td></td><td></td> |
| 579 |
<td>ascii text starting at 1000H for 6 bytes.</td></tr> |
| 580 |
</table> |
| 581 |
|
| 582 |
Directives are processed in the order in which they are read from |
| 583 |
the control file. Specifying an area as ascii data and then later |
| 584 |
specifying it as data to be ignored (uninitialized data) will cause |
| 585 |
that area to not be disassembled at all. Care must be taken in |
| 586 |
specifying areas in the control file. |
| 587 |
|
| 588 |
|
| 589 |
<a name="adirective"></a> |
| 590 |
<h4><em>A Directive (address data)</em></h4> |
| 591 |
|
| 592 |
Specifies that the address contains a word value corresponding |
| 593 |
to an address for which a label should be generated. For example, |
| 594 |
a vector table may be located at address 0x1000 containing four |
| 595 |
entries. The user can modify the control file by adding the |
| 596 |
following entry: |
| 597 |
|
| 598 |
<table cellspacing=5 summary=""> |
| 599 |
<tr><td></td><td></td><td></td><td></td><td></td><td>a 1000-1007</td></tr> |
| 600 |
</table> |
| 601 |
|
| 602 |
This will cause the disassembler to generate the following |
| 603 |
output lines: |
| 604 |
|
| 605 |
<table cellspacing=5 summary=""> |
| 606 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw</td> |
| 607 |
<td></td><td></td><td></td><td></td><td>vec1</td></tr> |
| 608 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw</td> |
| 609 |
<td></td><td></td><td></td><td></td><td>vec2</td></tr> |
| 610 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw</td> |
| 611 |
<td></td><td></td><td></td><td></td><td>vec3</td></tr> |
| 612 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw</td> |
| 613 |
<td></td><td></td><td></td><td></td><td>vec4</td></tr> |
| 614 |
</table> |
| 615 |
|
| 616 |
assuming that the control file also contains entries for the |
| 617 |
values found at those addresses to generate the labels vec1 |
| 618 |
through vec4. The addresses referenced will be flagged so |
| 619 |
that labels will be generated in the output file at those |
| 620 |
addresses. |
| 621 |
|
| 622 |
<a name="bdirective"></a> |
| 623 |
<h4><em>B Directive (byte binary data)</em></h4> |
| 624 |
|
| 625 |
Specifies that the data is to be interpreted as 8 bit binary |
| 626 |
data. For example: |
| 627 |
|
| 628 |
<table cellspacing=5 summary=""> |
| 629 |
<tr><td></td><td></td><td></td><td></td><td></td><td>b 1000-1007</td></tr> |
| 630 |
</table> |
| 631 |
|
| 632 |
tells the disassembler that the data from address 1000H to 1007H |
| 633 |
should generate the line: |
| 634 |
|
| 635 |
<table cellspacing=5 summary=""> |
| 636 |
<tr><td></td><td></td><td></td><td></td><td></td><td>db</td> |
| 637 |
<td></td><td></td><td></td><td></td><td>0,1,2,3,4,5,6,7</td></tr> |
| 638 |
</table> |
| 639 |
|
| 640 |
assuming that the data at address 1000H and up is 00H, 01H, etc. |
| 641 |
|
| 642 |
<a name="cdirective"></a> |
| 643 |
<h4><em>C Directive (code data)</em></h4> |
| 644 |
|
| 645 |
Forces the disassembler to interpret the data as executable code. |
| 646 |
This may be necessary because the disassembler skips over strings |
| 647 |
of 00H or ffH bytes that occur since they are unlikely to be real |
| 648 |
code. However, sometimes programmers insert several NOPs for timing |
| 649 |
purposes. |
| 650 |
|
| 651 |
<a name="ddirective"></a> |
| 652 |
<h4><em>D Directive (define data type (label or symbol))</em></h4> |
| 653 |
|
| 654 |
<table cellspacing=5 summary=""> |
| 655 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d address [0 or label]</td> |
| 656 |
<td></td><td></td><td></td><td></td><td>search label table only</td></tr> |
| 657 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d address [1 or symbol]</td> |
| 658 |
<td></td><td></td><td></td><td></td><td>search symbol table only</td></tr> |
| 659 |
<tr><td></td><td></td><td></td><td></td><td></td><td>d address [2 or none]</td> |
| 660 |
<td></td><td></td><td></td><td></td><td>don't search either table</td></tr> |
| 661 |
</table> |
| 662 |
|
| 663 |
Forces the disassembler to search only the label or symbol table. This |
| 664 |
allows you to specify a label and a symbol for the same value. For example: |
| 665 |
|
| 666 |
<table cellspacing=5 summary=""> |
| 667 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov dptr,#1234</td> |
| 668 |
</tr> |
| 669 |
</table> |
| 670 |
|
| 671 |
would normally search only the label table assuming that the data refers |
| 672 |
to a code address. If the data is really a constant with the same value as |
| 673 |
a label, then |
| 674 |
|
| 675 |
<table summary=""> |
| 676 |
<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>d 1 address</td></tr> |
| 677 |
</table> |
| 678 |
|
| 679 |
will force the disassmbler to look only in the symbol table for the string |
| 680 |
that represents the value of the data. The address is the address of the |
| 681 |
opcode, not the code location of the data operand. |
| 682 |
<br><br> |
| 683 |
Note that the last parameter can be either a number (0, 1, or 2) or a word |
| 684 |
(label, symbol, none). If the last parameter is a word, only the first |
| 685 |
character is checked for L, S, or N, and is not case sensitive. |
| 686 |
|
| 687 |
<a name="fdirective"></a> |
| 688 |
<h4><em>F Directive (SFR label definition)</em></h4> |
| 689 |
|
| 690 |
Causes reference to an SFR (special function register) to |
| 691 |
generate a label for the specified SFR address. This is useful |
| 692 |
for naming SFR's for non-standard members of the 8052 family. |
| 693 |
For example, suppose that some manufacturer designs a new 8052 |
| 694 |
variant and decides to use address efH as a new special function |
| 695 |
register called 'NEWREG'. Then by adding: |
| 696 |
|
| 697 |
<table cellspacing=5 summary=""> |
| 698 |
<tr><td></td><td></td><td></td><td></td><td></td><td>f ef newreg</td></tr> |
| 699 |
</table> |
| 700 |
|
| 701 |
to the control file, D52 will disassemble the opcodes f5 ef as: |
| 702 |
|
| 703 |
<table cellspacing=5 summary=""> |
| 704 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 705 |
<td></td><td></td><td></td><td></td><td>newreg,a</td></tr> |
| 706 |
</table> |
| 707 |
|
| 708 |
instead of: |
| 709 |
|
| 710 |
<table cellspacing=5 summary=""> |
| 711 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 712 |
<td></td><td></td><td></td><td></td><td>0efh,a</td></tr> |
| 713 |
</table> |
| 714 |
|
| 715 |
SFR label names are limited to fifteen characters. |
| 716 |
|
| 717 |
<a name="idirective"></a> |
| 718 |
<h4><em>I Directive (ignore data)</em></h4> |
| 719 |
|
| 720 |
Tells the disassembler to ignore a range of addresses that may be |
| 721 |
initialized by the input file. This is useful when the input file |
| 722 |
is a binary file generated by an eprom programmer that dumps the |
| 723 |
entire eprom space. The valid data from a 4K eprom might only be, |
| 724 |
say, 3K in length. By adding |
| 725 |
|
| 726 |
<table cellspacing=5 summary=""> |
| 727 |
<tr><td></td><td></td><td></td><td></td><td></td><td>i c00-fff</td></tr> |
| 728 |
</table> |
| 729 |
|
| 730 |
to the control file, you tell the disassembler to not disassemble |
| 731 |
the data from address 0c00H to 0fffH. |
| 732 |
|
| 733 |
<a name="kdirective"></a> |
| 734 |
<h4><em>K Directive (SFR bit definition)</em></h4> |
| 735 |
|
| 736 |
As with the |
| 737 |
<a href="#fdirective">F directive</a> |
| 738 |
, you can give a name to a new SFR bit. If a new variant of the 8052 |
| 739 |
family adds a new interrupt, for instance, its enable bit in the IE |
| 740 |
register might be bit 6. By adding: |
| 741 |
|
| 742 |
<table cellspacing=5 summary=""> |
| 743 |
<tr><td></td><td></td><td></td><td></td><td></td><td>k ae newint</td> |
| 744 |
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>(ae is the address of IE.6)</td></tr> |
| 745 |
</table> |
| 746 |
|
| 747 |
you define bit 6 of the interrupt enable register to be 'ie.newint'. |
| 748 |
Like SFR label names, SFR bit names are limited to fifteen characters. |
| 749 |
|
| 750 |
<a name="ldirective"></a> |
| 751 |
<h4><em>L Directive (label definition)</em></h4> |
| 752 |
|
| 753 |
Defines a label to the disassembler. Labels are generated in the |
| 754 |
output disassembly file whenever a reference to the address is |
| 755 |
found and the label exists in the label table. Suppose that |
| 756 |
address 0000H contains the code 01 43 (ajmp 0043H). Then the entry |
| 757 |
|
| 758 |
<table cellspacing=5 summary=""> |
| 759 |
<tr><td></td><td></td><td></td><td></td><td></td><td>l 43 start</td></tr> |
| 760 |
</table> |
| 761 |
|
| 762 |
in the control file will cause D52 to disassemble this code as: |
| 763 |
|
| 764 |
<table cellspacing=5 summary=""> |
| 765 |
<tr><td></td><td></td><td></td><td></td><td></td><td>ajmp</td> |
| 766 |
<td></td><td></td><td></td><td></td><td>start</td></tr> |
| 767 |
</table> |
| 768 |
|
| 769 |
rather than: |
| 770 |
|
| 771 |
<table cellspacing=5 summary=""> |
| 772 |
<tr><td></td><td></td><td></td><td></td><td></td><td>ajmp</td> |
| 773 |
<td></td><td></td><td></td><td></td><td>X0043</td></tr> |
| 774 |
</table> |
| 775 |
|
| 776 |
The code beginning at address 43H will then have the label |
| 777 |
'start' in the label field rather than the label 'X0043'. See |
| 778 |
the entry for the |
| 779 |
<a href="#sdirective">S directive</a> |
| 780 |
for an explanation of the difference between labels and symbols. |
| 781 |
|
| 782 |
<a name="mdirective"></a> |
| 783 |
<h4><em>M Directive (bit addressable memory label)</em></h4> |
| 784 |
|
| 785 |
Similar to the |
| 786 |
<a href="#kdirective">K directive</a> |
| 787 |
, the M directive gives a name to a bit addressable memory location. Example: |
| 788 |
|
| 789 |
<table cellspacing=5 summary=""> |
| 790 |
<tr><td></td><td></td><td></td><td></td><td></td><td>m 12 bitflag</td> |
| 791 |
<td></td><td></td><td></td><td></td><td>(12h is the bit address of 22h.2)</td></tr> |
| 792 |
</table> |
| 793 |
|
| 794 |
would cause the bytes d2 12 to be disassembled as |
| 795 |
|
| 796 |
<table cellspacing=5 summary=""> |
| 797 |
<tr><td></td><td></td><td></td><td></td><td></td><td>setb</td> |
| 798 |
<td></td><td></td><td></td><td></td><td></td><td>bitflag</td></tr> |
| 799 |
</table> |
| 800 |
|
| 801 |
instead of |
| 802 |
|
| 803 |
<table cellspacing=5 summary=""> |
| 804 |
<tr><td></td><td></td><td></td><td></td><td></td><td>setb</td> |
| 805 |
<td></td><td></td><td></td><td></td><td></td><td>22h.2</td></tr> |
| 806 |
</table> |
| 807 |
|
| 808 |
As with the K directive, names are limited to fifteen characters. |
| 809 |
|
| 810 |
<a name="ndirective"></a> |
| 811 |
<h4><em>N Directive (suppress address label generation)</em></h4> |
| 812 |
|
| 813 |
The disassembler will generate labels for addresses that are referenced by code |
| 814 |
such as |
| 815 |
|
| 816 |
<table cellspacing=5 summary=""> |
| 817 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 818 |
<td></td><td></td><td></td><td></td><td></td><td>dptr,#6</td></tr> |
| 819 |
</table> |
| 820 |
|
| 821 |
If the operand represents a constant rather than an address, you can suppress |
| 822 |
the automatic generation of a label (X0006) for address 6h by entering |
| 823 |
|
| 824 |
<table cellspacing=5 summary=""> |
| 825 |
<tr><td></td><td></td><td></td><td></td><td></td><td>n 6</td> |
| 826 |
</table> |
| 827 |
|
| 828 |
in the control file. You'd want to make sure that address 6h isn't legitimately |
| 829 |
addressed by some other code before using this directive. |
| 830 |
|
| 831 |
<a name="odirective"></a> |
| 832 |
<h4><em>O Directive (add hexadecimal offset to addresses)</em></h4> |
| 833 |
|
| 834 |
This directive causes the disassembler to add a hexadecimal offset to the address |
| 835 |
of every location in the code file. See the <a href="#xoption">X option</a> |
| 836 |
for details. It will be overridden by any <a href="#xoption">X option</a> |
| 837 |
specified on the command line. If the <a href="#toption">T option</a> (trace and |
| 838 |
analyze code) is given on the command line, the O directive has no effect since |
| 839 |
any existing control file will be rewritten. In this case you must use the command |
| 840 |
line X option to specify an offset. |
| 841 |
|
| 842 |
<a name="pdirective"></a> |
| 843 |
<h4><em>P Directive (patch inline code)</em></h4> |
| 844 |
|
| 845 |
This directive is of dubious value, but has been added for anyone who might find |
| 846 |
it useful. The P directive is similar to the |
| 847 |
<a href="#commentdirective">comment directive</a> |
| 848 |
except that the user supplied string is patched into the output stream as |
| 849 |
<i>code</i>, not as a comment. You could, for instance, patch in a macro |
| 850 |
definition or an include statement. Patching in executable code is not a real |
| 851 |
good idea. |
| 852 |
|
| 853 |
<a name="rdirective"></a> |
| 854 |
<h4><em>R Directive (register definition)</em></h4> |
| 855 |
|
| 856 |
This directive specifies a name for an 8052 register. Direct |
| 857 |
accesses to registers will normally be disassembled as: |
| 858 |
|
| 859 |
<table cellspacing=5 summary=""> |
| 860 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 861 |
<td></td><td></td><td></td><td></td><td></td><td>rb2r5,a</td></tr> |
| 862 |
</table> |
| 863 |
|
| 864 |
in the case of register 5 of register bank 2. If the user |
| 865 |
determines that register 5 of bank 2 is being used as a loop |
| 866 |
counter, for example, he can give it the name loop by adding: |
| 867 |
|
| 868 |
<table cellspacing=5 summary=""> |
| 869 |
<tr><td></td><td></td><td></td><td></td><td></td><td>r 15 loop</td></tr> |
| 870 |
</table> |
| 871 |
|
| 872 |
to the control file, and the above code will be disassembled as: |
| 873 |
|
| 874 |
<table cellspacing=5 summary=""> |
| 875 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov |
| 876 |
<td></td><td></td><td></td><td></td><td></td><td>loop,a</td></tr> |
| 877 |
</table> |
| 878 |
|
| 879 |
The R directive can assign a name to any internal memory location |
| 880 |
below the SFR address space. |
| 881 |
|
| 882 |
<a name="sdirective"></a> |
| 883 |
<h4><em>S Directive (symbol definition)</em></h4> |
| 884 |
|
| 885 |
Defines a symbol to the disassembler. Symbols are output to the |
| 886 |
disassembly file whenever the value is encountered in the input |
| 887 |
file and the symbol exists in the symbol table. The user can |
| 888 |
specify a symbol for a value by a line such as: |
| 889 |
|
| 890 |
<table cellspacing=5 summary=""> |
| 891 |
<tr><td></td><td></td><td></td><td></td><td></td><td>s 20 space</td></tr> |
| 892 |
</table> |
| 893 |
|
| 894 |
Code which uses this value, such as: |
| 895 |
|
| 896 |
<table cellspacing=5 summary=""> |
| 897 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 898 |
<td></td><td></td><td></td><td></td><td>a,#20h</td> |
| 899 |
</tr> |
| 900 |
</table> |
| 901 |
|
| 902 |
will then be disassembled as: |
| 903 |
|
| 904 |
<table cellspacing=5 summary=""> |
| 905 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 906 |
<td></td><td></td><td></td><td></td><td>a,#space</td> |
| 907 |
</tr> |
| 908 |
</table> |
| 909 |
|
| 910 |
Labels and symbols differ in that a label applies to an address, |
| 911 |
whereas a symbol applies to any 8 or 16 bit immediate data. For |
| 912 |
code which can only refer to values, such as |
| 913 |
|
| 914 |
<table cellspacing=5 summary=""> |
| 915 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 916 |
<td></td><td></td><td></td><td></td><td>a,#20h</td> |
| 917 |
</tr> |
| 918 |
</table> |
| 919 |
|
| 920 |
only the symbol table will be searched for a matching value. For |
| 921 |
code which could refer to either an address or a value, such as: |
| 922 |
|
| 923 |
<table cellspacing=5 summary=""> |
| 924 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 925 |
<td></td><td></td><td></td><td></td><td>dptr,#1234h</td> |
| 926 |
</tr> |
| 927 |
</table> |
| 928 |
|
| 929 |
the label table will be searched first, and only if no matching |
| 930 |
value is found will the symbol table then be searched. This search |
| 931 |
behavior can be modified by use of the |
| 932 |
<a href="#ddirective">d directive</a> or the |
| 933 |
<a href="#xdirective">x directive</a>. |
| 934 |
|
| 935 |
<a name="tdirective"></a> |
| 936 |
<h4><em>T Directive (text [ascii] data)</em></h4> |
| 937 |
|
| 938 |
Forces the data in the range specified to be disassembled as |
| 939 |
text (ascii data). Thus the code: 48 69 20 74 68 65 72 65 at |
| 940 |
address 1000H will be disassembled as: |
| 941 |
|
| 942 |
<table cellspacing=5 summary=""> |
| 943 |
<tr><td></td><td></td><td></td><td></td><td></td><td>db</td> |
| 944 |
<td></td><td></td><td></td><td></td><td></td><td>'Hi there'</td> |
| 945 |
<td></td><td></td><td></td><td></td><td></td><td>or</td></tr> |
| 946 |
<tr><td></td><td></td><td></td><td></td><td></td><td>ascii</td> |
| 947 |
<td></td><td></td><td></td><td></td><td></td><td>'Hi there'</td> |
| 948 |
<td></td><td></td><td></td><td></td><td></td><td>(command line option A used)</td></tr> |
| 949 |
</table> |
| 950 |
|
| 951 |
by putting the line: |
| 952 |
|
| 953 |
<table cellspacing=5 summary=""> |
| 954 |
<tr><td></td><td></td><td></td><td></td><td></td><td>t 1000-1007</td></tr> |
| 955 |
</table> |
| 956 |
|
| 957 |
in the control file. Otherwise it would be interpreted as: |
| 958 |
|
| 959 |
<table cellspacing=5 summary=""> |
| 960 |
<tr><td></td><td></td><td></td><td></td><td></td><td>orl</td> |
| 961 |
<td></td><td></td><td></td><td></td><td></td><td>a,r0</td> |
| 962 |
<td></td><td></td><td></td><td></td><td></td><td>; 1000</td> |
| 963 |
<td></td><td></td><td>48</td> |
| 964 |
<td></td><td></td><td>H</td></tr> |
| 965 |
<tr><td></td><td></td><td></td><td></td><td></td><td>xrl</td> |
| 966 |
<td></td><td></td><td></td><td></td><td></td><td>a,r1</td> |
| 967 |
<td></td><td></td><td></td><td></td><td></td><td>; 1001</td> |
| 968 |
<td></td><td></td><td>69</td> |
| 969 |
<td></td><td></td><td>i</td></tr> |
| 970 |
<tr><td></td><td></td><td></td><td></td><td></td><td>jb</td> |
| 971 |
<td></td><td></td><td></td><td></td><td></td><td>2eh.4,X106d</td> |
| 972 |
<td></td><td></td><td></td><td></td><td></td><td>; 1002</td> |
| 973 |
<td></td><td></td><td>20 74 68</td> |
| 974 |
<td></td><td></td><td>th</td></tr> |
| 975 |
<tr><td></td><td></td><td></td><td></td><td></td><td>xrl</td> |
| 976 |
<td></td><td></td><td></td><td></td><td></td><td>a,72h</td> |
| 977 |
<td></td><td></td><td></td><td></td><td></td><td>; 1005</td> |
| 978 |
<td></td><td></td><td>65 72</td> |
| 979 |
<td></td><td></td><td>er</td></tr> |
| 980 |
<tr><td></td><td></td><td></td><td></td><td></td><td>xrl</td> |
| 981 |
<td></td><td></td><td></td><td></td><td></td><td>a,t3</td> |
| 982 |
<td></td><td></td><td></td><td></td><td></td><td>; 1007</td> |
| 983 |
<td></td><td></td><td>65 ff</td> |
| 984 |
<td></td><td></td><td>e.</td></tr> |
| 985 |
</table> |
| 986 |
|
| 987 |
which is unlikely to be what was intended by the original |
| 988 |
programmer. Data specified by this directive is not checked |
| 989 |
to verify that it really is ascii data--be careful. |
| 990 |
|
| 991 |
<a name="wdirective"></a> |
| 992 |
<h4><em>W Directive (word binary data)</em></h4> |
| 993 |
|
| 994 |
Specifies that the data is to be interpreted as 16 bit binary |
| 995 |
data. For example: |
| 996 |
|
| 997 |
<table cellspacing=5 summary=""> |
| 998 |
<tr><td></td><td></td><td></td><td></td><td></td><td>w 1000-1007</td></tr> |
| 999 |
</table> |
| 1000 |
|
| 1001 |
tells the disassembler that the data from address 1000H to 1007H |
| 1002 |
should generate the lines: |
| 1003 |
|
| 1004 |
<table cellspacing=5 summary=""> |
| 1005 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw</td> |
| 1006 |
<td></td><td></td><td></td><td></td><td>0</td></tr> |
| 1007 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw |
| 1008 |
<td></td><td></td><td></td><td></td><td>1</td></tr> |
| 1009 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw |
| 1010 |
<td></td><td></td><td></td><td></td><td>2</td></tr> |
| 1011 |
<tr><td></td><td></td><td></td><td></td><td></td><td>dw |
| 1012 |
<td></td><td></td><td></td><td></td><td>3</td></tr> |
| 1013 |
</table> |
| 1014 |
|
| 1015 |
assuming that the data at address 1000H and up is 00H, 00H, |
| 1016 |
00H, 01H, 00H, 02H, etc. This differs from the A (address) |
| 1017 |
directive in that the |
| 1018 |
<a href="#adirective">A directive</a> |
| 1019 |
also causes a reference to be made to the indirect address. |
| 1020 |
In other words, if the data at address 1000H is 1234H, the A |
| 1021 |
directive will cause a label (X1234) to be put in the output |
| 1022 |
file at address 1234H, whereas the W directive will not. |
| 1023 |
|
| 1024 |
<a name="xdirective"></a> |
| 1025 |
<h4><em>X Directive (specify name for operand data)</em></h4> |
| 1026 |
|
| 1027 |
Specify a name for an operand at a particular address. This is similar |
| 1028 |
to the |
| 1029 |
<a href="#sdirective">S directive</a> |
| 1030 |
except that it applies only to the given address. For example, if the |
| 1031 |
<em>symbol</em> 'CR' is defined as 0dh, every instance of 0dh as an operand will |
| 1032 |
have the symbol 'CR' substituted. It may be, however, that the value |
| 1033 |
0dh has a different meaning when used as an operand for a particular |
| 1034 |
instruction. The X directive allows you to modify the interpretation |
| 1035 |
of an operand at specific operand locations. Why not then use the X |
| 1036 |
directive exclusively? Because that would force you to place an X |
| 1037 |
directive in the control file for <em>every</em> instance in which |
| 1038 |
that value appeared as an operand. The S directive, defined only once |
| 1039 |
for an operand value, will substitute the symbol text for <em>every</em> |
| 1040 |
occurrance of that operand value unless overridden by the X directive. |
| 1041 |
Note that the address defined in the X directive is the address of the |
| 1042 |
operand, not the address of the instruction. For example: |
| 1043 |
|
| 1044 |
<table cellspacing=5 summary=""> |
| 1045 |
<tr><td></td><td></td><td></td><td></td><td></td><td>X 102 loopinit</td></tr> |
| 1046 |
</table> |
| 1047 |
|
| 1048 |
forces substitution of the text 'loopinit' for the operand located at |
| 1049 |
address 102h. Therefore an instruction that should be interpreted as |
| 1050 |
|
| 1051 |
<table cellspacing=5 summary=""> |
| 1052 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 1053 |
<td></td><td></td><td>r0,#loopinit</td></tr> |
| 1054 |
</table> |
| 1055 |
|
| 1056 |
will not be disassembled as |
| 1057 |
|
| 1058 |
<table cellspacing=5 summary=""> |
| 1059 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 1060 |
<td></td><td></td><td>r0,#CR</td></tr> |
| 1061 |
</table> |
| 1062 |
|
| 1063 |
if the control file contains the above x directive, and also contains an |
| 1064 |
<a href="#sdirective">S directive</a> |
| 1065 |
defining 0dh as 'CR', and the value of the operand for the mov |
| 1066 |
instruction happens to also be 0dh. |
| 1067 |
|
| 1068 |
<a name="ydirective"></a> |
| 1069 |
<h4><em>Y Directive (specify name for operand data but suppress EQU generation)</em></h4> |
| 1070 |
|
| 1071 |
This is similar to the X directive except that the disassembler will not |
| 1072 |
generate an EQU statement for the operand value in the output file. This should |
| 1073 |
be used when you want to specify a name for an operand that is an assembler |
| 1074 |
pseudo-op such as LOW() or HIGH(). |
| 1075 |
|
| 1076 |
<a name="zdirective"></a> |
| 1077 |
<h4><em>Z Directive (specify code for which to generate cycle count information)</em></h4> |
| 1078 |
|
| 1079 |
Specify addresses for which cycle count information will be added in the |
| 1080 |
disassembly file. Also see the <a href="#zoption">Z option</a>. |
| 1081 |
<br> |
| 1082 |
Please read Jan's documentation in the 'cyclefiles' directory. |
| 1083 |
|
| 1084 |
<a name="commentdirective"></a> |
| 1085 |
<h4><em># Directive (header comment string)</em></h4> |
| 1086 |
|
| 1087 |
Defines a comment string to be output prior to disassembly at |
| 1088 |
the specified address. For example:<br><br> |
| 1089 |
|
| 1090 |
<!-- This is one time we DO want to use <pre> --> |
| 1091 |
|
| 1092 |
<pre> |
| 1093 |
# 95 |
| 1094 |
# 95 Start of initialization |
| 1095 |
# 95 |
| 1096 |
</pre> |
| 1097 |
<br><br> |
| 1098 |
in the ctl file would cause the output<br><br> |
| 1099 |
<pre> |
| 1100 |
; |
| 1101 |
; Start of initialization |
| 1102 |
; |
| 1103 |
clr ea ;0095 c2 af B/ |
| 1104 |
</pre> |
| 1105 |
<br><br> |
| 1106 |
assuming that the code 'c2 af' was located at address 0x95. |
| 1107 |
Since ASCII strings consume prodigious amounts of memory, it is |
| 1108 |
wise to use this directive sparingly. It is, however, useful for |
| 1109 |
marking blocks of code that have been identified in previous |
| 1110 |
runs of D52. |
| 1111 |
|
| 1112 |
<a name="icommentdirective"></a> |
| 1113 |
<h4><em>! Directive (inline comment string)</em></h4> |
| 1114 |
|
| 1115 |
Defines a comment string to be output after disassembly at |
| 1116 |
the specified address. For example:<br><br> |
| 1117 |
|
| 1118 |
<!-- This is one time we DO want to use <pre> --> |
| 1119 |
|
| 1120 |
<pre> |
| 1121 |
! 95 Start of initialization |
| 1122 |
</pre> |
| 1123 |
<br><br> |
| 1124 |
in the ctl file would cause the output<br><br> |
| 1125 |
<pre> |
| 1126 |
clr ea ;0095 c2 af B/ ; Start of initialization |
| 1127 |
</pre> |
| 1128 |
<br><br> |
| 1129 |
for the above example. Note that inline comments are only available for code |
| 1130 |
and word data, and will do nothing if the data at the specified address is defined |
| 1131 |
as data other than code or word data (ascii text, for example). |
| 1132 |
|
| 1133 |
<br><br> |
| 1134 |
<a href="#topofdoc">Back to top</a><br> |
| 1135 |
|
| 1136 |
<a name="symnote"></a> |
| 1137 |
<h4><em>A Note on Symbols, Labels and Names</em></h4> |
| 1138 |
<hr> |
| 1139 |
An example will best explain the difference between labels, symbols, operand |
| 1140 |
names and register names. Labels refer to program code locations, symbols |
| 1141 |
refer to immediate operands, register names and operand names refer to data |
| 1142 |
memory locations. |
| 1143 |
<br><br> |
| 1144 |
|
| 1145 |
<em>Given the hex or binary file produced from the follow source code:</em> |
| 1146 |
<br><br> |
| 1147 |
|
| 1148 |
<table cellspacing=5 summary=""> |
| 1149 |
<tr><td></td><td></td><td></td><td></td><td></td><td>org</td> |
| 1150 |
<td></td><td></td><td>30h</td></tr> |
| 1151 |
<tr><td>main</td><td></td><td></td><td></td><td></td><td>mov</td> |
| 1152 |
<td></td><td></td><td>a,30h</td></tr> |
| 1153 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 1154 |
<td></td><td></td><td>30h,r0</td></tr> |
| 1155 |
<tr><td></td><td></td><td></td><td></td><td></td><td>mov</td> |
| 1156 |
<td></td><td></td><td>r1,#30h</td></tr> |
| 1157 |
<tr><td></td><td></td><td></td><td></td><td></td><td>sjmp</td> |
| 1158 |
<td></td><td></td><td>main</td></tr> |
| 1159 |
<tr><td></td><td></td><td></td><td></td><td></td><td>end</td></tr> |
| 1160 |
</table> |
| 1161 |
|
| 1162 |
<br> |
| 1163 |
<em>and this control file:</em> |
| 1164 |
<br><br> |
| 1165 |
|
| 1166 |
<table cellspacing=5 summary=""> |
| 1167 |
<tr><td>l 30</td><td>main</td><td></td><td>; label for code address</td></tr> |
| 1168 |
<tr><td>x 33</td><td>thirty</td><td></td><td>; name for operand at address 33h</td></tr> |
| 1169 |
<tr><td>s 30</td><td>alsothirty</td><td></td><td>; symbol for immediate operand</td></tr> |
| 1170 |
<tr><td>r 30</td><td>counter</td><td></td><td>; name for data memory address (register) at 30h</td></tr> |
| 1171 |
</table> |
| 1172 |
<br><br> |
| 1173 |
|
| 1174 |
<em>D52 will produce the following output:</em> |
| 1175 |
<br><br> |
| 1176 |
|
| 1177 |
<table cellspacing=5 summary=""> |
| 1178 |
<tr><td>;</td></tr> |
| 1179 |
<tr><td></td><td></td><td>org</td><td></td><td></td><td></td><td>30h</td></tr> |
| 1180 |
<tr><td>;</td></tr> |
| 1181 |
<tr><td>main:</td><td></td><td>mov</td><td></td><td>a,counter</td><td></td><td>; 0030 e5 30</td><td></td><td>e0</td></tr> |
| 1182 |
<tr><td></td><td></td><td>mov</td><td></td><td>thirty,r0</td><td></td><td>; 0032 88 30</td><td></td><td>.0</td></tr> |
| 1183 |
<tr><td></td><td></td><td>mov</td><td></td><td>r1,#alsothirty</td><td></td><td>; 0034 79 30</td><td></td><td>y0</td></tr> |
| 1184 |
<tr><td></td><td></td><td>sjmp</td><td></td><td>main</td><td></td><td>; 0036 80 f8</td><td></td><td>.x</td></tr> |
| 1185 |
<tr><td>;</td></tr> |
| 1186 |
<tr><td>counter</td><td></td><td>equ</td><td></td><td>30h</td></tr> |
| 1187 |
<tr><td>alsothirty</td><td></td><td>equ</td><td></td><td>30h</td></tr> |
| 1188 |
<tr><td>thirty</td><td></td><td>equ</td><td></td><td>30h</td></tr> |
| 1189 |
<tr><td>;</td></tr> |
| 1190 |
<tr><td></td><td></td><td>end</td></tr> |
| 1191 |
<tr><td>;</td></tr> |
| 1192 |
</table> |
| 1193 |
<br><br> |
| 1194 |
|
| 1195 |
Note that the label, symbol, register name, and operand name all have |
| 1196 |
the same value: 30h. But the operand name directive ( |
| 1197 |
<a href="#xdirective">x directive</a>) in |
| 1198 |
the control file specifies the <em>address</em> of the operand (in |
| 1199 |
this case 33h), and the other three control file directives refer to |
| 1200 |
the <em>value</em> of the operand. The x directive allows you to use |
| 1201 |
a different name for the same value (unlike a symbol), so that, for |
| 1202 |
example, an operand value of 0dh in one place can be disassembled with |
| 1203 |
the name 'CR' and in another place as, say, 'loop_init_count'. |
| 1204 |
|
| 1205 |
<br><br> |
| 1206 |
|
| 1207 |
<a name="outfile"></a> |
| 1208 |
<h4><em>Format of Output File</em></h4> |
| 1209 |
<hr> |
| 1210 |
|
| 1211 |
The output file for D52 (extention '.d52') contains 8052 instructions |
| 1212 |
and pseudo ops in a format that should be acceptable to any 8052 |
| 1213 |
cross assembler. When assembled, the source file should produce an Intel |
| 1214 |
hex file or binary file that is identical to the original. Identical, in |
| 1215 |
this case, means that the code is the same, not that it necessarily has |
| 1216 |
the same format. The number of bytes in each line of the hex file may |
| 1217 |
differ from the original depending on whether the original was produced |
| 1218 |
by an assembler or was read from an eprom. |
| 1219 |
|
| 1220 |
Each output line is in the following format: |
| 1221 |
|
| 1222 |
<table cellspacing=5 summary=""> |
| 1223 |
<tr><td></td><td></td><td></td><td></td><td></td><td>LABEL:</td> |
| 1224 |
<td></td><td></td><td>OPCODE</td> |
| 1225 |
<td></td><td></td><td>OPERANDS</td> |
| 1226 |
<td></td><td></td><td>; COMMENT</td></tr> |
| 1227 |
</table> |
| 1228 |
|
| 1229 |
The label field will be generated only if the address of the code |
| 1230 |
is referenced by some other code (a call, for instance), or if the |
| 1231 |
user has specified a label for that address in the control file. |
| 1232 |
The comment field is only generated if the user specifies the D |
| 1233 |
option on the command line. Comments begin with a semicolon and are |
| 1234 |
followed by the hexadecimal address of the instruction, the hex |
| 1235 |
value of the byte(s) for the instruction, and finally by the ascii |
| 1236 |
representation of the instruction byte(s). For example: |
| 1237 |
|
| 1238 |
<table cellspacing=5 summary=""> |
| 1239 |
<tr><td></td><td></td><td></td><td></td><td></td><td>X004f:</td> |
| 1240 |
<td></td><td></td><td></td><td>orl</td> |
| 1241 |
<td></td><td></td><td></td><td>p3,#0ffh</td> |
| 1242 |
<td></td><td></td><td></td><td>; 004f</td> |
| 1243 |
<td></td><td></td><td></td><td>43 b0 ff</td> |
| 1244 |
<td></td><td></td><td></td><td>C0.</td></tr> |
| 1245 |
<tr><td></td><td></td><td></td><td></td><td></td><td>label</td> |
| 1246 |
<td></td><td></td><td></td><td>opcode</td> |
| 1247 |
<td></td><td></td><td></td><td>operands</td> |
| 1248 |
<td></td><td></td><td></td><td>comment</td></tr> |
| 1249 |
</table> |
| 1250 |
|
| 1251 |
Several things should be noted in this example. The label is 'X' |
| 1252 |
followed by the address of the instruction in four hex digits. |
| 1253 |
This type of label is created by the disassembler when some other |
| 1254 |
code references the address. If the user specifies a label name for |
| 1255 |
the address in the control file ('what' for example), the generated |
| 1256 |
code becomes: |
| 1257 |
|
| 1258 |
<table cellspacing=5 summary=""> |
| 1259 |
<tr><td></td><td></td><td></td><td></td><td></td><td>what:</td> |
| 1260 |
<td></td><td></td><td></td><td>orl</td> |
| 1261 |
<td></td><td></td><td></td><td>p3,#0ffh</td> |
| 1262 |
<td></td><td></td><td></td><td>; 004f</td> |
| 1263 |
<td></td><td></td><td></td><td>43 b0 ff</td> |
| 1264 |
<td></td><td></td><td></td><td>C0.</td></tr> |
| 1265 |
</table> |
| 1266 |
|
| 1267 |
If the user were to specify the symbol 'ones' for the value 0ffH, |
| 1268 |
the output would then become: |
| 1269 |
|
| 1270 |
<table cellspacing=5 summary=""> |
| 1271 |
<tr><td></td><td></td><td></td><td></td><td></td><td>what:</td> |
| 1272 |
<td></td><td></td><td></td><td>orl</td> |
| 1273 |
<td></td><td></td><td></td><td>p3,#ones</td> |
| 1274 |
<td></td><td></td><td></td><td>; 004f</td> |
| 1275 |
<td></td><td></td><td></td><td>43 b0 ff</td> |
| 1276 |
<td></td><td></td><td></td><td>C0.</td></tr> |
| 1277 |
</table> |
| 1278 |
|
| 1279 |
Also note the ascii representation of the instruction bytes. Bit |
| 1280 |
7 is forced to zero so that ascii with the high bit set can be |
| 1281 |
viewed (b0H in the example becomes 30H, which is ascii '0'). Any |
| 1282 |
code which is not printable ascii (a control code, for example) |
| 1283 |
is output as a period. This is the case for the byte 0ffH above. |
| 1284 |
<br><br> |
| 1285 |
The comment field starts at a different position in the output |
| 1286 |
line depending on the type of data in the input file. For normal |
| 1287 |
executable code, the comment field starts in column 32; for hex |
| 1288 |
data it starts at column 49, and for ascii data it starts in |
| 1289 |
column 56. For many programs, this makes for a more readable |
| 1290 |
source file, but if there is a mix of data types in a short range |
| 1291 |
of addresses, this can lead to some strange looking formatting. |
| 1292 |
The user may want to correct this with a text editor in the final |
| 1293 |
disassembly before modification and reassembly. |
| 1294 |
|
| 1295 |
<br><br> |
| 1296 |
<a href="#topofdoc">Back to top</a><br> |
| 1297 |
<br><br> |
| 1298 |
|
| 1299 |
<a name="summary"></a> |
| 1300 |
<h4><em>Summary</em></h4> |
| 1301 |
<hr> |
| 1302 |
|
| 1303 |
D52 is distributed under the GNU General Public License. See the file COPYING |
| 1304 |
for details. D52 versions 3.1 and higher are a continuation of the earlier |
| 1305 |
disassembler named D51. |
| 1306 |
<br><br> |
| 1307 |
D52 allows the user to specify how code should be disassembled via a control |
| 1308 |
file that defines given areas of the code as ascii text, binary data or other |
| 1309 |
types of non-executable code. By an iterative process of disassembly, control |
| 1310 |
file modification, and further disassembly, the user can obtain a very readable |
| 1311 |
source file that can then be modified and re-assembled by a cross assembler. |
| 1312 |
Several public domain cross assemblers are available. |
| 1313 |
<br><br> |
| 1314 |
I've encountered several problems when reassembling the output of D52. |
| 1315 |
Almost all are due to the cross assembler not recognizing SFRs of some |
| 1316 |
of the newer or more exotic 8052 variants. The D52 tables include |
| 1317 |
names for all SFRs that I'm aware of as of May 1995 (there are likely |
| 1318 |
some that I'm not aware of). Such errors might be corrected just by |
| 1319 |
defining a symbol for the SFR in the control file (see the |
| 1320 |
<a href="#fdirective">F directive</a> |
| 1321 |
), but this depends on whether your cross assembler will accept it as a |
| 1322 |
valid operand. If all else fails, replace the offending instruction |
| 1323 |
with a 'db' pseudo op and put the mnemonic and operand in a comment. |
| 1324 |
A similar problem is the assembler not being able to handle a bit |
| 1325 |
addressable SFR address; the only solution I see to this is to use a |
| 1326 |
'db' pseudo op. All other problems I've seen (not many) have been due |
| 1327 |
to disassembling data as code; this is easily corrected by modifying |
| 1328 |
the control file to specify the correct data type. |
| 1329 |
<br><br> |
| 1330 |
|
| 1331 |
Many thanks to numerous beta testers who have made invaluable |
| 1332 |
suggestions for improvement and found more bugs than I care to think about. |
| 1333 |
Also thanks to all the users who have, over the years, also made significant |
| 1334 |
contributions to the betterment of D52. Any remaining deficiencies are solely |
| 1335 |
my fault. |
| 1336 |
|
| 1337 |
<br><br> |
| 1338 |
|
| 1339 |
<h4><em>Summary of command line options and control file directives</em></h4> |
| 1340 |
Command line options: |
| 1341 |
<br> |
| 1342 |
<ul> |
| 1343 |
<li>A - Change db/defb pseudo op to 'ascii' macro for text |
| 1344 |
<li>B - Force read of binary file (.bin extention) |
| 1345 |
<li>D - Add address and data info in comment field |
| 1346 |
<li>H - Force read of Intel hex file (.hex extention) |
| 1347 |
<li>I - Add statement to include file 'sfr52.inc' in output file |
| 1348 |
<li>K - Disassemble for older Keil A51 assembler |
| 1349 |
<li>N - Output C style hexadecimal operands |
| 1350 |
<li>P - Add a dot '.' to beginning of pseudo operation codes |
| 1351 |
<li>S - Change db and dw pseudo ops to defb and defw |
| 1352 |
<li>T - Trace and analyze code before disassembly |
| 1353 |
<li>U - Output labels, mnemonics, etc in upper case |
| 1354 |
<li>X - Add hexadecimal offset to all program locations |
| 1355 |
<li>Z - Read cycle count file (d52 only) |
| 1356 |
</ul> |
| 1357 |
Control file directives: |
| 1358 |
<br> |
| 1359 |
<ul> |
| 1360 |
<li>A - Specifies that words in program space are addresses |
| 1361 |
<li>B - Data is 8 bit binary |
| 1362 |
<li>C - Program space is executable code |
| 1363 |
<li>D - Force search of only label table or only symbol table for operand name |
| 1364 |
<li>F - Specify SFR label |
| 1365 |
<li>I - Ignore data (uninitialize program space) |
| 1366 |
<li>K - Specify label for SFR bit |
| 1367 |
<li>L - Define label |
| 1368 |
<li>M - Specify label for bit addressable memory |
| 1369 |
<li>N - Suppress generation of address label |
| 1370 |
<li>O - Add hexadecimal offset to all program locations |
| 1371 |
<li>P - Patch inline code |
| 1372 |
<li>R - Define register name |
| 1373 |
<li>S - Define symbol |
| 1374 |
<li>T - Specify ascii text |
| 1375 |
<li>W - Data is 16 bit binary |
| 1376 |
<li>X - Specify name for a specific operand |
| 1377 |
<li>Y - Specify name for a specific operand but do not generate an EQU statement |
| 1378 |
<li>Z - Specify addresses for which to generate cycle count information |
| 1379 |
<li># - Define a header comment string |
| 1380 |
<li>! - Define an inline comment string |
| 1381 |
</ul> |
| 1382 |
<br><br> |
| 1383 |
<a href="#topofdoc">Back to top</a><br> |
| 1384 |
|
| 1385 |
<a name="regmaps"></a> |
| 1386 |
<h4><em>8052 Register Maps</em></h4> |
| 1387 |
<hr> |
| 1388 |
|
| 1389 |
Addresses of 8052 registers: |
| 1390 |
<table border summary=""> |
| 1391 |
<tr><th>Bank</th><th>R0</th><th>R1</th><th>R2</th><th>R3</th><th>R4</th><th>R5</th><th>R6</th><th>R7</th></tr> |
| 1392 |
<tr><td>0</td><td>00</td><td>01</td><td>02</td><td>03</td><td>04</td><td>05</td><td>06</td><td>07</td></tr> |
| 1393 |
<tr><td>1</td><td>08</td><td>09</td><td>0A</td><td>0B</td><td>0C</td><td>0D</td><td>0E</td><td>0F</td></tr> |
| 1394 |
<tr><td>2</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td></tr> |
| 1395 |
<tr><td>3</td><td>18</td><td>19</td><td>1A</td><td>1B</td><td>1C</td><td>1D</td><td>1E</td><td>1F</td></tr> |
| 1396 |
</table> |
| 1397 |
|
| 1398 |
<br><br> |
| 1399 |
Addresses of 8052 Special Function Registers: |
| 1400 |
<table border summary=""> |
| 1401 |
<tr><th>Address</th><th>Symbol</th><th>Name</th></tr> |
| 1402 |
<tr><td> 80 </td><td> P0 </td><td> Port 0</td></tr> |
| 1403 |
<tr><td> 81 </td><td> SP </td><td> Stack Pointer</td></tr> |
| 1404 |
<tr><td> 82 </td><td> DPL </td><td> Data Pointer (low byte)</td></tr> |
| 1405 |
<tr><td> 83 </td><td> DPH </td><td> Data Pointer (high byte)</td></tr> |
| 1406 |
<tr><td> 87 </td><td> PCON </td><td> Power Control</td></tr> |
| 1407 |
<tr><td> 88 </td><td> TCON </td><td> Timer/Counter Control</td></tr> |
| 1408 |
<tr><td> 89 </td><td> TMOD </td><td> Timer/Counter Mode</td></tr> |
| 1409 |
<tr><td> 8A </td><td> TL0 </td><td> Timer/Counter 0 (low byte)</td></tr> |
| 1410 |
<tr><td> 8B </td><td> TL1 </td><td> Timer/Counter 1 (low byte)</td></tr> |
| 1411 |
<tr><td> 8C </td><td> TH0 </td><td> Timer/Counter 0 (high byte)</td></tr> |
| 1412 |
<tr><td> 8D </td><td> TH1 </td><td> Timer/Counter 1 (high byte)</td></tr> |
| 1413 |
<tr><td> 90 </td><td> P1 </td><td> Port 1</td></tr> |
| 1414 |
<tr><td> 98 </td><td> SCON </td><td> Serial Port Control</td></tr> |
| 1415 |
<tr><td> 99 </td><td> SBUF </td><td> Serial Data Buffer</td></tr> |
| 1416 |
<tr><td> A0 </td><td> P2 </td><td> Port 2</td></tr> |
| 1417 |
<tr><td> A8 </td><td> IE </td><td> Interrupt Enable</td></tr> |
| 1418 |
<tr><td> B0 </td><td> P3 </td><td> Port 3</td></tr> |
| 1419 |
<tr><td> B8 </td><td> IP </td><td> Interrupt Priority</td></tr> |
| 1420 |
<tr><td> D0 </td><td> PSW </td><td> Program Status Word</td></tr> |
| 1421 |
<tr><td> E0 </td><td> ACC </td><td> Accumulator</td></tr> |
| 1422 |
<tr><td> F0 </td><td> B </td><td> B Register</td></tr> |
| 1423 |
</table> |
| 1424 |
<br><br> |
| 1425 |
<a href="#topofdoc">Back to top</a><br> |
| 1426 |
|
| 1427 |
<a name="bsfr"></a> |
| 1428 |
<h4><em>Bit Addressable Special Function Registers</em></h4> |
| 1429 |
|
| 1430 |
<table border summary=""> |
| 1431 |
<tr><th>Address</th><th>Symbol</th><th>Bit name</th><th>Function</th></tr> |
| 1432 |
<tr><td> 80-87 </td><td> P0.0-7 </td><td> </td><td>Port 0</td></tr> |
| 1433 |
<tr><td> 88 </td><td> IT0 </td><td> TCON.0 </td><td>External Interrupt 0 Type Control</td></tr> |
| 1434 |
<tr><td> 89 </td><td> IE0 </td><td> TCON.1 </td><td>External Interrupt 0 Edge Control</td></tr> |
| 1435 |
<tr><td> 8A </td><td> IT1 </td><td> TCON.2 </td><td>External Interrupt 1 Type Control</td></tr> |
| 1436 |
<tr><td> 8B </td><td> IE1 </td><td> TCON.3 </td><td>External Interrupt 1 Edge Control</td></tr> |
| 1437 |
<tr><td> 8C </td><td> TR0 </td><td> TCON.4 </td><td>Timer 0 Run Control</td></tr> |
| 1438 |
<tr><td> 8D </td><td> TF0 </td><td> TCON.5 </td><td>Timer 0 Overflow Flag</td></tr> |
| 1439 |
<tr><td> 8E </td><td> TR1 </td><td> TCON.6 </td><td>Timer 1 Run Control</td></tr> |
| 1440 |
<tr><td> 8F </td><td> TF1 </td><td> TCON.7 </td><td>Timer 1 Overflow Flag</td></tr> |
| 1441 |
<tr><td> 90-97 </td><td> P1.0-7 </td><td> </td><td>Port 1</td></tr> |
| 1442 |
<tr><td> 98 </td><td> RI </td><td> SCON.0 </td><td>Serial Receive Interrupt Flag</td></tr> |
| 1443 |
<tr><td> 99 </td><td> TI </td><td> SCON.1 </td><td>Serial Transmit Interrupt Flag</td></tr> |
| 1444 |
<tr><td> 9A </td><td> RB8 </td><td> SCON.2 </td><td>Serial Receive Bit 8</td></tr> |
| 1445 |
<tr><td> 9B </td><td> TB8 </td><td> SCON.3 </td><td>Serial Transmit Bit 8</td></tr> |
| 1446 |
<tr><td> 9C </td><td> REN </td><td> SCON.4 </td><td>Serial Receive Enable</td></tr> |
| 1447 |
<tr><td> 9D </td><td> SM2 </td><td> SCON.5 </td><td>Serial Port Mode Specifier</td></tr> |
| 1448 |
<tr><td> 9E </td><td> SM1 </td><td> SCON.6 </td><td>Serial Port Mode Specifier</td></tr> |
| 1449 |
<tr><td> 9F </td><td> SM0 </td><td> SCON.7 </td><td>Serial Port Mode Specifier</td></tr> |
| 1450 |
<tr><td> A0-A7 </td><td> P2.0-7 </td><td> </td><td>Port 2</td></tr> |
| 1451 |
<tr><td> A8 </td><td> EX0 </td><td> IE.0 </td><td>Enable External Interrupt 0</td></tr> |
| 1452 |
<tr><td> A9 </td><td> ET0 </td><td> IE.1 </td><td>Enable Timer 0 Interrupt</td></tr> |
| 1453 |
<tr><td> AA </td><td> EX1 </td><td> IE.2 </td><td>Enable External Interrupt 1</td></tr> |
| 1454 |
<tr><td> AB </td><td> ET1 </td><td> IE.3 </td><td>Enable Timer 1 Interrupt</td></tr> |
| 1455 |
<tr><td> AC </td><td> ES </td><td> IE.4 </td><td>Enable Serial Port Interrupt</td></tr> |
| 1456 |
<tr><td> AF </td><td> EA </td><td> IE.7 </td><td>Enable Interrupts</td></tr> |
| 1457 |
<tr><td> B0-B7 </td><td> P3.0-7 </td><td> </td><td>Port 3</td></tr> |
| 1458 |
<tr><td> B8 </td><td> PX0 </td><td> IP.0 </td><td>External Interrupt 0 Priority</td></tr> |
| 1459 |
<tr><td> B9 </td><td> PT0 </td><td> IP.1 </td><td>Timer 0 Interrupt Priority</td></tr> |
| 1460 |
<tr><td> BA </td><td> PX1 </td><td> IP.2 </td><td>External Interrupt 1 Priority</td></tr> |
| 1461 |
<tr><td> BB </td><td> PT1 </td><td> IP.3 </td><td>Timer 1 Interrupt Priority</td></tr> |
| 1462 |
<tr><td> BC </td><td> PS </td><td> IP.4 </td><td>Serial Port Interrupt Priority</td></tr> |
| 1463 |
<tr><td> D0 </td><td> P </td><td> PSW.0 </td><td>Parity</td></tr> |
| 1464 |
<tr><td> D2 </td><td> OV </td><td> PSW.2 </td><td>Overflow Flag</td></tr> |
| 1465 |
<tr><td> D3 </td><td> RS0 </td><td> PSW.3 </td><td>Register Bank Select Bit 0</td></tr> |
| 1466 |
<tr><td> D4 </td><td> RS1 </td><td> PSW.4 </td><td>Register Bank Select Bit 1</td></tr> |
| 1467 |
<tr><td> D5 </td><td> F0 </td><td> PSW.5 </td><td>Flag 0 (general purpose flag)</td></tr> |
| 1468 |
<tr><td> D6 </td><td> AC </td><td> PSW.6 </td><td>Auxiliary Carry Flag</td></tr> |
| 1469 |
<tr><td> D7 </td><td> CY </td><td> PSW.7 </td><td>Carry Flag</td></tr> |
| 1470 |
<tr><td> E0-E7 </td><td> ACC.0-7 </td><td> </td><td>Accumulator Bits</td></tr> |
| 1471 |
<tr><td> F0-F7 </td><td> B.0-7 </td><td> </td><td>B Register Bits</td></tr> |
| 1472 |
</table> |
| 1473 |
<br><br> |
| 1474 |
<a href="#topofdoc">Back to top</a><br> |
| 1475 |
|
| 1476 |
<a name="bmem"></a> |
| 1477 |
<h4><em>Addresses of Bit Addressable Memory Locations</em></h4> |
| 1478 |
|
| 1479 |
<table border summary=""> |
| 1480 |
<tr><th>Address</th><th>Memory location</th></tr> |
| 1481 |
<tr><td>00-07</td><td>20.0 - 20.7</td></tr> |
| 1482 |
<tr><td>08-0F</td><td>21.0 - 21.7</td></tr> |
| 1483 |
<tr><td>10-17</td><td>22.0 - 22.7</td></tr> |
| 1484 |
<tr><td>18-1F</td><td>23.0 - 23.7</td></tr> |
| 1485 |
<tr><td>20-27</td><td>24.0 - 24.7</td></tr> |
| 1486 |
<tr><td>28-2F</td><td>25.0 - 25.7</td></tr> |
| 1487 |
<tr><td>30-37</td><td>26.0 - 26.7</td></tr> |
| 1488 |
<tr><td>38-3F</td><td>27.0 - 27.7</td></tr> |
| 1489 |
<tr><td>40-47</td><td>28.0 - 28.7</td></tr> |
| 1490 |
<tr><td>48-4F</td><td>29.0 - 29.7</td></tr> |
| 1491 |
<tr><td>50-57</td><td>2A.0 - 2A.7</td></tr> |
| 1492 |
<tr><td>58-5F</td><td>2B.0 - 2B.7</td></tr> |
| 1493 |
<tr><td>60-67</td><td>2C.0 - 2C.7</td></tr> |
| 1494 |
<tr><td>68-6F</td><td>2D.0 - 2D.7</td></tr> |
| 1495 |
<tr><td>70-77</td><td>2E.0 - 2E.7</td></tr> |
| 1496 |
<tr><td>78-7F</td><td>2F.0 - 2F.7</td></tr> |
| 1497 |
</table> |
| 1498 |
<br><br> |
| 1499 |
|
| 1500 |
<a href="#topofdoc">Back to top</a><br> |
| 1501 |
<br><br><br><br> |
| 1502 |
</body> |
| 1503 |
</html> |