**sped** is a line editor written in x86 assembly. Back in the day, before visual editors, line editors like **ed** were used.
This is my own stupid and pointless attempt at writing such line editor.
-### FEATURES/NON-FEATURES
-
-
-
### INSTALLATION
#### Build from source
**c** - change the contents of the current line
+**o/O** - insert line after/before current line
+
+**d** - delete current line
+
**w** - saves file
**q** - exists the program
### FAQ
+**what is the point of this**
+
+obviously, we live in a day and age where we have the comfort of visual editors, so line editors like these have become obsolete. i simply wanted to work on a relatively easy to implement project so i can learn some assembly.
+
**are you insane**
yes
prompt_str db `sped > `, 0x00
invalidcmd_str db `invalid command\n`, 0x00
invalidaddr_str db `invalid address\n`, 0x00
+ oneline_str db `cannot delete line, as there is only one line\n`, 0x00
charcount_str db `read %i chars\n`, 0x00
currentline_str db `current line: %i\n`, 0x00
echo_str db `%s`, 0x00 ; print strings without format exploit
jne _repl_cmd_delete_end
; check to make sure we don't have only one line
+ cmp DWORD [buffer_lines], 1
+ jle _repl_oneline
; delete the line
push DWORD [buffer]
sub DWORD [buffer_lines], 1
+ ; if it's the last line, move one down
+ mov eax, DWORD [buffer_lines]
+ cmp DWORD [cur_line], eax
+ jl _repl_continue
+ sub DWORD [cur_line], 1
+
jmp _repl_continue
_repl_cmd_delete_end:
; o appends text after line =-=-=-=-=-=-=-=-=
mov eax, DWORD [ebp-CMDSTR]
cmp BYTE [eax], 'o'
+ jne _repl_cmd_appenddown_end
+
+ ; make room first
+ push DWORD [buffer]
+ push DWORD [buffer_lines]
+ mov eax, DWORD [cur_line]
+ add eax, 1
+ push eax
+ call shiftRight
+ mov [buffer], eax
+
+ ; input text
+ push 0
+ call readLine
+ mov esi, eax
+
+ ; insert new string
+ mov eax, [cur_line]
+ add eax, 1
+ mov ecx, 4
+ mul ecx
+ add eax, DWORD [buffer]
+ mov [eax], esi
+
+ add DWORD [buffer_lines], 1
+
+ jmp _repl_continue
+ _repl_cmd_appenddown_end:
+
+ ; O oppens text before line =-=-=-=-=-=-=-=
+ mov eax, DWORD [ebp-CMDSTR]
+ cmp BYTE [eax], 'O'
jne _repl_cmd_appendup_end
; make room first
mul ecx
add eax, DWORD [buffer]
mov [eax], esi
+
+ ; also move cursor down one
+ add DWORD [cur_line], 1
add DWORD [buffer_lines], 1
jmp _repl_continue
_repl_cmd_appendup_end:
+
; w writes file =-=-=-=-=-=-=-=-=-=-=-=-=
mov eax, DWORD [ebp-CMDSTR]
cmp BYTE [eax], 'w'
call printf
jmp _repl_continue
+ _repl_oneline:
+ push oneline_str
+ call printf
+ jmp _repl_continue
+
_repl_continue:
jmp _repl_loop