Small (Dis)Assembler

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
mkl0815
Posts: 183
Joined: 25 Mar 2013
Location: Germany
Contact:

Small (Dis)Assembler

Post by mkl0815 »

Hello everybody,

today my little project MOUSE made a big step forward to be a real computer. While waiting for the PCB I've ordered, I spent some hours writing code for the current breadboard version. I have now a tiny monitor program that is able to dump memory, jump to a specific address, soft-reset the computer and input a stream of hex values to a given address. Today I took the time to adjusted the code from the (VTL-2 language) to my layout. MOUSE. Programs can be send to the computer via serial connection (just copy paste the VTL code to the terminal that takes care to wait a few ms between the single characters).
All the current code fits in 2k of the 8k EEPROM I have installed. Now I'm looking for a simple assembler/disassembler that may take the rest of the EEPROM to have a second language to work with.

I found the 2KSA as a PDF but it would be hard to type in the complete code. Has anybody a small 65C02 (or 6502) dis-/assembler that can adopted to use simple getchr and putchr routines that I can use?

Mario.
How should I know what I think, until I hear what I've said.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Re: Small (Dis)Assembler

Post by 8BIT »

My SBC-2's OS fit in about 6k and included Apple ][ -like monitor, including disassembler and mini -assembler.

The source is located here: http://sbc.rictor.org/sbcos.html

It includes EhBASIC, which puts it over 8k, but that can be removed easily. If you are interested, I can help with any integration issues that you encounter.

Daryl
Please visit my website -> https://sbc.rictor.org/
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Small (Dis)Assembler

Post by barrym95838 »

Well done, Mario! It's nice to hear about VTL02 being put to good use, although I still haven't quite figured out why the German members here seem to like it more than the rest ;-)

A while back, a certain Mr. Wozniak wrote a dis-assembler (<500 bytes code and data), and a mini (no symbolic labels) assembler (<320 bytes of additional code when paired with the dis-assembler). You can find an OCR version here:

ftp://ftp.apple.asimov.net/pub/apple_II ... 20Info.pdf

Woz writes some tasty spaghetti code. SWEET 16 is there too, for an additional <375 bytes.

You still have enough ROM space left for a stripped-down (but easily expandable into RAM at cold start) Forth kernel, if you so desire.

How much RAM are you running now?

Mike B.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Small (Dis)Assembler

Post by BigEd »

(Thanks for that PDF Mike, it contains several substantial pieces of 6502 software, both source and documentation:
Contents
* Apple II ROM (12 KB binary)
* Memory map of the Apple II ROMs
* Summary of Monitor Commands
* Red Book Monitor listing
* Red Book Sweet-16 listing
* WOZPAK Sweet-16 article by Steve Wozniak
* WOZPAK Sweet-16 article by Dick Sedgewick
* Red Book Mini-Assembler listing
* Red Book Floating point listing
* WOZPAK Floating point routines description
* DDJ Floating point article
* IA Floating point article
* SYM Monitor listing
* AIM Monitor listing
* AIM BASIC Language Reference Manual
)
mkl0815
Posts: 183
Joined: 25 Mar 2013
Location: Germany
Contact:

Re: Small (Dis)Assembler

Post by mkl0815 »

Thanks for the reply.

@Mike: My first computer should have been a Z1013 what is a kind of small computer kit sold in the 80s in east Germany based on a U880 (Z80 clone). But as well as for a car you had to wait a long time for it. I ordered one for me but I never got it. There were also some homebrew receipts for tiny computers like this one : Ju+Te Computer also based in Z80 technology but with built in TINY BASIC (U883). Using VTL2 is like traveling back in time for me, because writing small programs in VTL is quite near to how using these old computer kits should have been.
Beside the fact, that having a higher language built in 1k of ROM is a really cool feature. Played the tic-tac-toe example over and over again with my self made piece of hardware. Even watching the thing calculating big numbers with the factorial demo was fun :-). Yes I like that little language

@Daryl: I already downloaded your sbcos some time ago, but I did not remember that. I added your uchess version to my "OS" after converting the code to ophis assembler syntax. I can start the game and reset it, but at a certain point it seems to branch to my VTL interpreter. The chess is located in my ROM, but I'm not sure if the game should be located in RAM.

I have 32k RAM from 0x0000 to 0x7fff. The 6850 ACIA (115.2k baud) is located at $C000 and my ROM starts at $E000.

Mario.

UPDATE: I found the bug, branching to VTL. I had to rename some labels but forgot one "MOVE" in chess.asm. That caused the jump into the VTL interpreter.
How should I know what I think, until I hear what I've said.
mkl0815
Posts: 183
Joined: 25 Mar 2013
Location: Germany
Contact:

Re: Small (Dis)Assembler

Post by mkl0815 »

How should I know what I think, until I hear what I've said.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Small (Dis)Assembler

Post by BigEd »

Bravo!
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Small (Dis)Assembler

Post by BigDumbDinosaur »

Hey! Works pretty good! :D
x86?  We ain't got no x86.  We don't NEED no stinking x86!
mkl0815
Posts: 183
Joined: 25 Mar 2013
Location: Germany
Contact:

Re: Small (Dis)Assembler

Post by mkl0815 »

@Mike: If you have a small (4k) forth kernel it would like to test and integrate it to my current OS.

Mario.
How should I know what I think, until I hear what I've said.
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Small (Dis)Assembler

Post by barrym95838 »

The Apple ][ version of figForth weighs in at 6201 bytes, but less than half of that consists of primitives. I have never attempted it, but I believe that I have heard of systems that keep just enough Forth in ROM to allow a cold start to quickly compile the rest of the system into RAM from secondary storage. I'm certainly NOT a Forth expert, so I'll leave the rest of the discussion to others with far more knowledge of the possibilities, or lack there-of.

Mike B.
User avatar
Michael
Posts: 633
Joined: 13 Feb 2013
Location: Michigan, USA

Re: Small (Dis)Assembler

Post by Michael »

Very nice, Mario...
mkl0815
Posts: 183
Joined: 25 Mar 2013
Location: Germany
Contact:

Re: Small (Dis)Assembler

Post by mkl0815 »

I found a 65C02 disassembler on github and modified it to work with my preferred ophis assembler and with my I/O routines.
It is not memory optimizes, so it takes about 1.5k, but it works.

Code: Select all

MOUSE 65C02 micro computer (c) 2015
M-OS V0.3
READY.
MOUSE MON V 0.3


>h OK
commands:
b - execute brk
c - start microchess
d <addr> - disassemble from address
f <addr>:<addr> %val - fill memory with %val
g <addr> - jump to <addr>
h - this help
i <addr> - input <addr> input data to memory '.' ends the input
m <addr> %cols %rows - dump memory from address
o <addr>:<addr> - output memory range
r - jump to reset vector
v - start VTL2 language
 <addr> - 16bit address, %xx - 8 bit value
>d e000 OK
e000   a9 15       LDA   #$15
e002   85 00       STA   $00
e004   a9 e2       LDA   #$e2
e006   85 01       STA   $01
e008   20 7e f3    JSR   $f37e
e00b   20 bd e1    JSR   $e1bd
e00e   20 b1 e1    JSR   $e1b1
e011   20 93 f3    JSR   $f393
e014   b0 fb       BCS   $e011
e016   c9 0d       CMP   #$0d
e018   f0 14       BEQ   $e02e
e01a   c9 0a       CMP   #$0a
e01c   f0 10       BEQ   $e02e
e01e   20 8f f3    JSR   $f38f
e021   a6 0f       LDX   $0f
e023   95 10       STA   $10,X
e025   e8          INX
e026   86 0f       STX   $0f
e028   e0 20       CPX   #$20
e02a   f0 02       BEQ   $e02e
e02c   80 e3       BRA   $e011
e02e   a2 00       LDX   #$00
e030   b5 10       LDA   $10,X
How should I know what I think, until I hear what I've said.
Post Reply