I an a newbie to assembly language, been reading jeff duntemann's book, and I have been trying to write some code by myself too. There is an example in the book on converting binary values to hex values. I decided to re-write the code again by myself for self-practice but i get a segmentation fault. Here is the code:

section .bss
	BUFFLEN equ 16
	BUFF resb 16

section .data
	HexStr: db " 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h",10
	HexLen equ $-HexStr
	Digits: db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,61h,62h,63h,64h,65h,66h

section .text
	global _start

	mov eax,3
	mov ebx,0
	mov ecx,BUFFLEN
	mov edx,BUFF
	INT 80H
	cmp eax,0
	je Done
	mov ebp,eax 
	mov ebx,Digits
	xor ecx,ecx
	xor eax,eax
	xor edx,edx

	  mov al,byte [BUFF+ecx] 
	  mov edx,eax 
	  and eax,0fh
	  mov byte [HexStr+4*ecx+2],al

	  shr dl,4
	  mov al,dl
	  mov byte [HexStr+4*ecx+1],al
	  inc ecx
	  cmp ecx,ebp

	  jb Translate

	  mov eax,4
	  mov ebx,1
	  mov ecx,HexLen
	  mov edx,HexStr
	  int 80h
	  jmp Read

	mov eax,1
	mov ebx,0
	int 80h

anw i found the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.