More Than 25 lines and you're doing too much in one procedure.Split it up.
call LoadBuff
...
loadBuff:
push eax ; a1
push ebx ; a2
push edx ; a3
mov eax, 3 ; sys_read call
mov ebx, 0 ; File Descriptor 0: stdin
mov ecx, Buff ; offset of the buffer to read to
mov edx, BUFFLEN ; number of bytes to read at one pass
int 80h ; sys_read
mov ebp, eax
xor ecx, ecx
pop edx ; b1
pop ebx ; b2
pop eax ; b3
ret
pushad
...
popad
DumpLin db " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
DUMPLEN equ $-DumpLin
ASCLin db "|................|", 10
ASCLEN equ $-ASCLin
FULLLEN equ $-DumpLin
lea edi, [edx*2+edx] ; trick to calculate 3*edx
Scan:
xor eax, eax
...
.modTest:
test esi, 0000000Fh
...
jne Scan ; Short jump, to within 127 bytes in either direction
jne near Scan ; Near jump, anywhere in the current code segment
section .text
extern ClearLine
global _start
_start:
...
call ClearLine
...
section .text
global ClearLine
...
ClearLine:
...
Rules:
[section .data]
PositionTerm db 27, "[01;01H" ; <ESC>[<Y>;<X>H -This sequences move the cursor to (X, Y)
ClearTerm db 27, "[2J" ; <ESC>[2J -This sequences clears the display.
GreenBack db 27, "[42m" ; <ESC>[42m -turns the consoles background green
For more details about console escape codes: man console_codes
%macro WriteStr 2 ; 2 arguments
push eax
push ebx
mov ecx, %1 ; %1 invokes the first argument (Prompt)
mov edx, %2 ; %2 invokes the second argument (PROMPTLEN)
mov eax, 4
mov edx, 1
int 80h
pop ebx
pop eax
%endmacro
....
....
WriteStr Prompt, PROMPTLEN
; When a macro is invoked, its arguments are separated by commas.
%macro UpCase 2
mov edx, %1
mov ecx, %2
%%IsLC:
cmp byte [edx+ecx-1], 'a'
jb %%Bump
cmp byte [edx+ecx-1], 'z'
ja %%Bump
sub byte [edx+ecx-1], 20h
%%Bump:
dec ecx
jnz %%IsLC
%endmacro
%include "mylib.mac"