Compare commits

...

22 Commits

Author SHA1 Message Date
Tennessee Carmel-Veilleux 680c212992
Merge pull request #3 from ratherlargerobot/fread-brk-bugfix
Use fread() return value to count bytes
2018-09-02 15:28:46 -04:00
Nathan Rosenquist 8b01d8b204 Use fread() return value to count bytes
This commit changes the behavior of dcc6502, so that it consults the
return value of fread(), and then increments the value of byte_count
by the number returned by fread(), rather than implicitly incrementing
it every time.

Previously, a warning occurred during compilation, because the return value
of fread() was ignored. Instead, the number of bytes in the input file were
counted implicitly by incrementing a byte_count variable after every fread()
call.

Additionally, I created a two-byte test input file consisting of the
bytes #$a9ff, which corresponds to LDA #$FF. When dcc6502 tried to
disassemble this input file, it reported that the file had a size of three
bytes. It reported the first two opcodes correctly, but then incorrectly
displayed a BRK as the third opcode.

After this change, the input file now has a reported size of two bytes,
without the phantom BRK opcode at the end.
2018-09-01 20:44:41 -04:00
Tennessee Carmel-Veilleux c003395dd7 Bumped version to 2.1 after -s added 2018-02-21 09:43:20 -05:00
Tennessee Carmel-Veilleux 2c46640706
Merge pull request #2 from KaleviKolttonen/input_file_offset
Add a command line option -s for specifying file offset to start disa…
2018-02-21 09:40:34 -05:00
Kalevi Kolttonen ab33fe1c84 Minor cleanups for new command line option -s code 2018-02-21 16:31:05 +02:00
Kalevi Kolttonen 1ff0a0949b Add a command line option -s for specifying file offset to start disassembling from 2018-02-21 15:21:22 +02:00
Tennessee Carmel-Veilleux 91f4853529 Updated .gitignore 2014-07-24 23:22:12 -04:00
Tennessee Carmel-Veilleux 6f0226a7e6 Fixed argument error handling and usage message 2014-07-24 23:18:00 -04:00
Tennessee Carmel-Veilleux aa6c897c1a Fixed cycle counting and finished 2.0
* Added rules for branch taken/not taken
* Fixed incorrect adding of cycles for many ALU instructions
* Fixed timing for ASL, DEC, INC, LSR, ROL, and ROR
* Renamed global opcode_table to g_opcode_table
* Normalized all hex output to be capitals
2014-07-24 23:00:31 -04:00
Tennessee Carmel-Veilleux d8869a8d28 Major refactoring of arguments handling 2014-07-24 22:23:54 -04:00
Tennessee Carmel-Veilleux 57e20cdf26 Started version 2.0
* Simplified mnemonic name lookup
* Started refactor of argument parsing
* Converted addressing modes to an enum
* Renamed poorly named variables
2014-07-24 19:35:02 -04:00
Tennessee Carmel-Veilleux 34ccb70eae Simplified hex value conversions for args 2014-07-24 18:56:51 -04:00
Tennessee Carmel-Veilleux 0ffacd9e5d Greatly simplified disassembly code 2014-07-24 17:22:40 -04:00
Tennessee Carmel-Veilleux 4c9a2daeb4 Refactored disassembly code to combine steps 2014-07-24 16:40:08 -04:00
Tennessee Carmel-Veilleux 7985830ecd Started main clean-up of version 1.6
* Fixed all compiler warnings
* Killed union usage
* Started using C99 fixed width types
* Started normalization of whitespace width in listing
* Simplified internal addresses computations
2014-07-24 16:09:53 -04:00
Tennessee Carmel-Veilleux e19fc4568c Fixed some compiler warnings 2014-07-24 14:13:24 -04:00
Tennessee Carmel-Veilleux 18114bf7df Updated license in file and added FIXME markers 2014-07-23 15:36:35 -04:00
Tennessee Carmel-Veilleux 11eb27cced Fixed copyright date 2014-07-23 15:08:55 -04:00
Tennessee Carmel-Veilleux 676ddb5177 Added whitespace for each run-in comma 2014-07-23 15:07:19 -04:00
Tennessee Carmel-Veilleux 984edd2187 Added Makefile and cleaned-up indent 2014-07-23 14:57:21 -04:00
Tennessee Carmel-Veilleux 2955bbb7ef Updated README.md 2014-07-23 14:16:22 -04:00
Tennessee Carmel-Veilleux 2e2e0f7b1d Update to legacy version 1.5 2014-07-23 13:59:14 -04:00
4 changed files with 721 additions and 632 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@
*.i*86
*.x86_64
*.hex
/Default/

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
CC=gcc
CFLAGS=-O
dcc6502: dcc6502.c
$(CC) -o $@ $^ $(CFLAGS)
clean:
rm -f *.o dcc6502 dcc6502.exe
all: dcc6502

View File

@ -1,4 +1,28 @@
dcc6502
=======
Disassembler for 6502 processors
Disassembler for 6502 processors.
# Features
* Simple command-line interface
* Single file, ANSI C source
* Annotation for addresses of Nintendo Entertainment System (NES) system registers
* Cycle-counting output
* Machine code display inline with the disassembly
# History tidbit
The original 1.0 version of dcc6502 was written overnight on Christmas eve
1998. At the time, I (Tennessee Carmel-Veilleux) was a 16-year-old NES
hacker learning 6502 assembly. Of course, as many teenagers are, I was
a bit arrogant and really thought my code was pretty hot back then :)
Fast-forward 15 years and I'm a grown-up engineer who is quite a bit more
humble about his code. Looking back, I think the tool did the job, but
obviously, 15 years of experience later, I would have made it quite a
bit cleaner. The disassembler has floated online on miscalleanous NES
development sites since 1998. I decided to put it on github starting at
version 1.4 and I will be cleaning-up the code over until version 2.0.
This disassembler has made the rounds and has been used for a lot of
different purposes by many different people over the years. Hopefully
it will continue to be useful going forward.

1316
dcc6502.c

File diff suppressed because it is too large Load Diff