Do I understand that you want to represent the ascii codes as decimal? (why? hex is much more civilized!) Well, okay... this is crude, but I think it does what you want...
; display characters and decimal ascii codes from a file
;
; nasm -f elf32 myfile.asm
; ld -o myfile myfile.o -melf_i386
SECTION .data
file_name db 'abc.txt'
SECTION .bss
fd_in resd 1
filecontent resb 250
fbuff_len equ $-filecontent
length_read resd 1
SECTION .text
global _start
_start:
mov eax,5 ;open a file
mov ebx,file_name
mov ecx,0
mov edx,777
int 80h
; did open succeed?
test eax, eax
js exit
mov dword[fd_in],eax
mov eax,3 ;read from file
mov ebx,[fd_in]
mov ecx,filecontent
mov edx,fbuff_len
int 80h
; eax has length actually read
mov [length_read], eax
mov esi,filecontent
; point edi to end of file
mov edi, esi
add edi, [length_read]
xor eax, eax ; just to make sure upper bytes are clear
nextnum:
mov al,byte[esi]
call putc
push eax
mov al, '='
call putc
pop eax
dispnum:
call showeaxd
mov al, 10 ; linefeed
call putc
inc esi
cmp esi, edi
jnz nextnum
mov eax,6 ; __NR_close
mov ebx,[fd_in]
int 80h
; pretend no error
xor eax, eax
exit:
mov ebx, eax ; possible error number in ebx
neg ebx ; negate it for easier reading with "echo $?"
mov eax,1
int 80h
;---------------------------
; print character in al
putc:
push edx
push ecx
push ebx
push eax ;this serves as our buffer
mov ecx, esp ; buffer
mov edx, 1 ; just 1
mov ebx, 1 ; stdout
mov eax, 4 ; __NR_write
int 80h
pop eax
pop ebx
pop ecx
pop edx
ret
;------------------------------
;---------------------------------
; showeaxd - print a decimal representation of eax to stdout
; for "debug purposes only"... mostly
; expects: number in eax
; returns; nothing useful
showeaxd:
push eax
push ebx
push ecx
push edx
push esi
sub esp, 10h
lea ecx, [esp + 12]
mov ebx, 10
xor esi, esi
.top:
dec ecx
xor edx, edx
div ebx
add dl, '0'
mov [ecx], dl
inc esi
or eax, eax
jnz .top
mov edx, esi
mov ebx, 1
mov eax, 4
int 80h
add esp, 10h
pop esi
pop edx
pop ecx
pop ebx
pop eax
ret
;---------------------------------
Best,
Frank