This is an opened project focused to make a little bit more easy the of assembler code editing of .asm files
Usually assembly programs (.asm format with nasm, masm, gas, yasm, etc.) are very long because only one instruction is allowed in each line of code. I thought of finding a way to solve this and here it is.
For instance: This assembly program will shows one line once executed
file sample.asm
SECTION .data
msg dd "Editing successful!",0xa
len equ $ - msg
SECTION .text
global _start
_start:
;; sys_write(edx,len=length ; ecx=message ; ebx,1=descriptor 1 ; eax,4=screen)
mov edx,len
mov ecx, msg
mov ebx,1
mov eax,4
int 0x80
;; exit
mov eax,1
mov ebx,0
int 0x80
Could the same code be edited differently? The answer is yes:
file: sample.txt
SECTION .data
\t msg dd "Editing successful!",0xa
\t len equ $ - msg
SECTION .text
global _start
\t\t _start:
;; sys_write(edx,len=length ; ecx=message ; ebx,1=descriptor 1 ; eax,4=screen)
\t\t mov edx,len \n\t\t mov ecx, msg \n\t\t mov ebx,1 \n\t\t mov eax,4
\t\t int 0x80
;; exit
\t\t mov eax,1 \n\t\t mov ebx,0
\t\t int 0x80
The difference is that you can add tabulators "\t" and new line "\n" characters between instructions, labels and sections.
This would be impossible to compile with gcc in this way, unless you use a program like this:
#!/bin/bash
#########################################################
# Title: qweac.sh
# Description: Quickly Way of Edit Assembly Code (qweac)
# Version: 0.1 beta
# Author: Ferran (Tiny Core Linux' user)
# Original-Site: http://forum.tinycorelinux.net/
# Size:1.3 Kb
# #Comments:
# A tool that allows you to compile assembly code in an original way
# (as explained in the Tiny Core Linux forum web) making your own
# ELF binaries files from automatic pre-compiled sample.asm files.
#_________
#qweac.sh requieres bash.tcz, gcc.tcz & nasm.tcz
# _________
# Current: 2020/04/29 (First Beta Version)
#########################################################
index=0
unset array
while IFS= read -r; do
array[index+=1,$index]=$REPLY
done <$1
[[ $REPLY ]] && array[index]=$REPLY
for line in `seq 0 ${#array[*]}`;
do
echo -e "${array[$line]}" >> sample.asm
done
nasm -felf32 sample.asm
gcc -nostdlib -m32 sample.o -o sample
TIP for the people:
If you aren't familiar with assembly code, after to download this code as if you will execute it with
./qweac.sh sample.txt #If you wants use the above file sample.txt
It will make 3 more files (f.i): sample.asm, sample.o and sample (as if). If you can see the message without issues. Then you already will run it with
$ ./sample
$ Editing successful!
$
This program will be compatible in the most computers around the world.
NOTE: At the moment you should use 32-bit assembly code, intended for x386 architectures
Basically still have a couple of things to do yet:
1) Be able to compile .asm in 64 bits
2) The name of the sample file (f.i. myfile.txt) is the same as the .asm file (such as myfile.asm, myfile.o and the executable ELF file).
If you want to help, complain, provide solutions, give me a house with jacuzzi, etc. you are welcome.