%include "asm_io.inc"
;
; initialized data is put in the .data segment
;
segment .data
tab db	0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1
    db	2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2
    db	2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3
    db	4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3
    db	2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3
    db	4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4
    db	4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5
    db	6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
	
;
; uninitialized data is put in the .bss segment
;
segment .bss
 

;
; code is put in the .text segment
;
segment .text
        global  asm_main
asm_main:
        enter   0,0               ; mise en place 
        pusha

	call read_int
	mov ecx,0
	mov edx,0
	mov ebx,eax
	and ebx,0x000000FF
	add ebx,tab
	mov dl,[ebx]
	add ecx,edx
        mov ebx,eax
	and ebx,0x0000FF00
	shr ebx,8
	add ebx,tab
	mov dl,[ebx]
	add ecx,edx
	mov ebx,eax
	and ebx,0x00FF0000
	shr ebx,16
	add ebx,tab
	mov dl,[ebx]
	add ecx,edx
	mov ebx,eax
	and ebx,0xFF000000
	shr ebx,24
	add ebx,tab
	mov dl,[ebx]
	add ecx,edx
	mov eax,ecx
	call print_int 
	
        popa
        mov     eax, 0            ; retour vers le C
        leave                     
        ret


