vim-like editor in 6502 assembly?

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
pdragon
Posts: 126
Joined: 26 Sep 2023

vim-like editor in 6502 assembly?

Post by pdragon »

Struggling to get google to help me here. Is anyone aware of a vim-like editor implemented in 6502 assembly? (I just read that the original vim 'stevie' started on an Atari ST, a 68000 I guess?).

Taliforth has a simple line-oriented `ed` and a block editor but I haven't been able to find something with basic cursor movement and insert/overwrite behavior. I could no doubt write something extending 'ed' but i'm sure others have been there before me.

Thanks,
Patrick
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: vim-like editor in 6502 assembly?

Post by BigEd »

Over in the land of Acorn there is EDIT (or *EDIT) and also an in-house predecessor E (or E40 or E80)

See the thread
"Edit" Source Code
which includes links to source and binaries.

Code: Select all

 here's E for you to try. Unfortunately I can't now remember all of the command set, and unlike edit there's no help. < is load, > is save, /:;@ as laid out on a BBC/S3 keyboard give you the cursor movement diamond; I think 'i' must be insert.
Edit: there is documentation further downthread.
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: vim-like editor in 6502 assembly?

Post by BigDumbDinosaur »

pdragon wrote:
Struggling to get google to help me here. Is anyone aware of a vim-like editor implemented in 6502 assembly?

I’ve not heard of one.  Such a thing would be an ambitious programming project, to say the least—vim is more like a mini-operating system than a mere text editor.  :shock:  Even in a higher-level language, it would be a formidable challenge.

Quote:
(I just read that the original vim 'stevie' started on an Atari ST, a 68000 I guess?).

Correct on the 68000.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: vim-like editor in 6502 assembly?

Post by Yuri »

BigDumbDinosaur wrote:
pdragon wrote:
Struggling to get google to help me here. Is anyone aware of a vim-like editor implemented in 6502 assembly?
I’ve not heard of one.  Such a thing would be an ambitious programming project, to say the least—vim is more like a mini-operating system than a mere text editor.  :shock:  Even in a higher-level language, it would be a formidable challenge.
Just about any modestly complex editor is pretty ambitious, vim, emacs, Visual Studio, Atom, VS Code, etc. all have their own high level command processing language you can use to automate various tasks.

The core line editing is a bit tricky to handle to say the least, I was trying to get some basic GNU Readline like functionality for Lemon, and even that was driving me nuts.

Hence my gripe about escape sequences... >_<

Edit:
Here's the github of Lemon, where I started some work on ANSI handling and a editline functionality. After reviewing some stuff about the escape sequences (see above gripe) I realized this code could probably be rethought out.

Anyhow, hope this helps: https://github.com/Kelmar/Lemon
pdragon
Posts: 126
Joined: 26 Sep 2023

Re: vim-like editor in 6502 assembly?

Post by pdragon »

for sure, i'm imagining <1% of vim: navigating a cursor up/down/left/right x n, insert/delete characters, perhaps search
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: vim-like editor in 6502 assembly?

Post by drogon »

Many years back (like over 3 decades ago) I ported STeVIe to a Transputer based Unix system as it was all C and we had a C compiler for it... I liked it back then. Very simple and easy to use (I was already a VI enthusiast by then anyway) however to port that I had to go down the route of porting, actually writing from scratch as there really wasn't any open source then, all the support like Termcap, then man, more, troff and so on, then MicroEmacs as others were Emacsians ... I lost track of what I wrote but it was the bulk of a usable Unix user-land system for what it was at the time. Sadly, never thought to keep any of it as we never did back then and now it's all lost to landfill somewhere )-:

I did make a start to write a VI like thing for the 6502, but in C - quickly gave up as I had no immediate need, but I did port another editor I wrote to it. The other editor is a nano-like editor - about 1500 lines of C and compiles to about 15KB of 6502 code with cc65. It was an integral part of my Basic interpreter but I was able to make it standalone enough to work.

I ported that editor to my BCPL system - about the same lines of code, but compiles to about 7KB of bytecode.

I still yearn for a VI like thing for my 6502/65816 board though... Maybe one day!

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

Re: vim-like editor in 6502 assembly?

Post by 6502inside »

I wrote this many years ago, though it's really a shell on another editor that takes vi-like key sequences. I suppose I should look around for where the source went, but you can still play with it.

http://www.floodgap.com/retrotech/cbm/svicc/
SamCoVT
Posts: 344
Joined: 13 May 2018

Re: vim-like editor in 6502 assembly?

Post by SamCoVT »

If you're open to a Forth version, there is Samuel Falvo's VIBE editor in TaliForth's "forth_examples" folder that has vi-ish keybindings. The downside is that it redraws the entire screen so it's rather slow if used over a serial link. I also wrote a full screen editor for Forth screens available here: https://github.com/SamCoVT/ForthSoftware as editor.fs
That version doesn't redraw the entire screen (unless you ask with CTRL-L). Both of those are for editing Forth screens, though, which may not be what you are looking for.
dmsc
Posts: 153
Joined: 17 Sep 2018

Re: vim-like editor in 6502 assembly?

Post by dmsc »

Hi!
pdragon wrote:
Struggling to get google to help me here. Is anyone aware of a vim-like editor implemented in 6502 assembly? (I just read that the original vim 'stevie' started on an Atari ST, a 68000 I guess?).
Have you seen VI65? From https://singularcrew.hu/vi65/

Source code is at: https://sourceforge.net/p/vi65/code/HEAD/tree/trunk/

If you don't need VI compatibility, there are a lot of simple text editors, my own FastBasic IDE has a small integrated editor.

Have Fun!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: vim-like editor in 6502 assembly?

Post by BigEd »

wow - good find!

Edit: binary size is something between 4k and 8k, depending on platform and display format. Pretty compact!
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: vim-like editor in 6502 assembly?

Post by BigDumbDinosaur »

Yuri wrote:
Just about any modestly complex editor is pretty ambitious, vim, emacs, Visual Studio, Atom, VS Code, etc. all have their own high level command processing language you can use to automate various tasks.

The core line editing is a bit tricky to handle to say the least, I was trying to get some basic GNU Readline like functionality for Lemon, and even that was driving me nuts.

Hence my gripe about escape sequences... >_<

In a practical text editor, the functions that interact with the “console” should have no direct relationship to the functions that manipulate the text being edited.

Your editor should be able to “talk” to any console by use of a separate driver that knows how to run the display, as well as how to decode what is coming from the keyboard.  That driver would accept a set of commands that your editor would emit to control the display, such as scroll up, delete a line, position the cursor, etc.  Similarly, your driver would emit ASCII bytes for QWERTY characters typed on the console, along with editor-specific codes that would indicate use of the control keys, e.g., backspace, delete, cursor movement, etc.

With the driver handling the interface between the editor and console, your editor can be focused on the mechanics of text entry.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: vim-like editor in 6502 assembly?

Post by Yuri »

BigDumbDinosaur wrote:
...
Your editor should be able to “talk” to any console by use of a separate driver that knows how to run the display, as well as how to decode what is coming from the keyboard. 
...
Correct, but you have to start with a driver of some sort if you don't have one. If you look at the code I was working on, I was working towards trying to keep the ANSI escape stuff isolated from the editor; distilling down the "key presses" into more or less single "command" bytes indicated by the carry flag in the 6502. The idea being that I might want to interface with a PS/2 or custom keyboard later on.

E.g.:
Convert: <esc>[0 ==> KEY_HOME

The actual editor portion then figures out what to do with KEY_HOME, and has little care that the sequence was an ANSI escape or a direct key press on a keyboard.

This will get refined later down the road as I keep working on this of course.

That being said things can get complex regardless of it being ANSI or not depending on how much you need to update the display.

Wozmon for example leaves the characters on my terminal when I hit backspace. (Guessing it did this on the Apple I as well, but I wouldn't know for sure)
If I wanted to "erase" the character I'd have to actually start adding some code to blank that character out, one way or another.

Adding a character in the middle of the line? Now you need to shift multiple characters around; adds up quick.
pdragon
Posts: 126
Joined: 26 Sep 2023

Re: vim-like editor in 6502 assembly?

Post by pdragon »

Nice! Thanks for the suggestions.
Dietrich
Posts: 45
Joined: 01 Jan 2003

Re: vim-like editor in 6502 assembly?

Post by Dietrich »

You might want to look at my EDIT.COM (https://github.com/Dietrich-L/CPM-65/bl ... L/EDIT.ASM)
The Editor operates with single keystroke Control keys and uses only cursor control commands for the screen output on the terminal. Only basic editing commands are available.
The source code can be adapted to most systems.

Dietrich
My system: Elektor Junior Computer, GitHub https://github.com/Dietrich-L
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: vim-like editor in 6502 assembly?

Post by BigEd »

And open source too- great!
Post Reply