From 4b37a0556e203fe1aa32647b2dae1bc661c5851e Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sun, 20 Jun 2021 00:57:45 -0400 Subject: [PATCH] final clean up --- README.md | 9 +++++++-- fileutils.asm | 14 +++----------- makefile | 11 ++++++++++- repl.asm | 10 ++++++---- sped.asm | 6 ++++-- utils.asm | 3 +++ 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7f87c88..d4fc9f6 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,16 @@ This is my own stupid and pointless attempt at writing such line editor. with `gcc` and `nasm` installed, you can simply run ``` -make +sudo make install ``` to build the project -### COMMANDS +### USAGE/COMMANDS + +**sped** takes a single command line argument, the file you wish to open. +``` +sped [file] +``` **p** - prints the contents of the current line diff --git a/fileutils.asm b/fileutils.asm index 54c9895..32dcef6 100644 --- a/fileutils.asm +++ b/fileutils.asm @@ -1,3 +1,6 @@ +; sped - the stupidly pointless editor +; written by pinosaur +; fileutils.asm: file i/o %include "macros.S" @@ -70,10 +73,6 @@ readFile: cmp DWORD [ebp-IS_EOF], 1 je _readFile_exit - - ; push esi - ; call printf - ; make string buffer bigger mov eax, DWORD [ebp-LINES_READ] add eax, 1 @@ -160,13 +159,6 @@ readLine: add ecx, [ebp-CHAR_COUNT] mov edx, 1 int 0x80 - - ; mov eax, 4 - ; mov ebx, 1 - ; mov ecx, [ebp-STR_PTR] - ; add ecx, [ebp-CHAR_COUNT] - ; mov edx, 1 - ; int 0x80 ; check for eof cmp eax, 0 ; eax has zero on eof diff --git a/makefile b/makefile index e77e686..26aeb07 100644 --- a/makefile +++ b/makefile @@ -2,8 +2,9 @@ CC=gcc CFLAGS=-m32 -no-pie ASM=nasm ASMFLAGS=-f elf32 -g +PREFIX=/usr/bin -.PHONY: clean +.PHONY: clean install uninstall make: sped @@ -13,5 +14,13 @@ make: sped sped: sped.o fileutils.o repl.o utils.o $(CC) $(CFLAGS) -o $@ $^ +install: sped + mkdir -p $(PREFIX) + cp -f sped $(PREFIX) + chmod 775 $(PREFIX)/sped + +uninstall: + rm -f $(PREFIX)/sped + clean: rm sped *.o diff --git a/repl.asm b/repl.asm index 038bb1a..750e430 100644 --- a/repl.asm +++ b/repl.asm @@ -1,3 +1,6 @@ +; sped - the stupidly pointless editor +; written by pinosaur +; repl.asm: user interactions extern printf extern fflush @@ -13,10 +16,9 @@ global repl section .data 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 + 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 currentline_str db `current line: %i\n`, 0x00 echo_str db `%s`, 0x00 ; print strings without format exploit diff --git a/sped.asm b/sped.asm index 544ec3c..e0920a1 100644 --- a/sped.asm +++ b/sped.asm @@ -1,4 +1,6 @@ ; sped - the stupidly pointless editor +; written by pinosaur +; sped.asm: main file %include "macros.S" @@ -11,8 +13,8 @@ global main section .data banner_str db `SPED - the stupidly pointless editor\n`, 0x00 - nofile_str db `no file provided\n`, 0x00 - readlines_str db `opened file with %i lines\n`, 0x00 + nofile_str db `no file provided.\n`, 0x00 + readlines_str db `opened file with %i lines.\n`, 0x00 section .text main: diff --git a/utils.asm b/utils.asm index 441efc1..8878040 100644 --- a/utils.asm +++ b/utils.asm @@ -1,3 +1,6 @@ +; sped - the stupidly pointless editor +; written by pinosaur +; utils.asm: some buffer utilities %include "macros.S" -- 2.20.1