   section    .data

msg: db "The number of command line arguments is "
len	equ	$ - msg			;length of our dear string
char db 'character'
charlen db $ - char
;
    SECTION .bss
cline:resb 81    ;space to hold command line arguments for output for argc
result:resb 20    ;space to hold command line arguments for output for argv[0]
;

section	.text
    global main         ;must be declared for using gcc
;
main:	                ;tell linker entry point
  ;  
  mov ecx,0          ;count output characters
  pop eax            ;reject this 32 bits
  pop eax    :        ;get argc
  add al, 30H        ;convert integer to ascii
  mov edi, cline     ;put char in output buffer cline
  mov byte[edi],al   ;move argc into edi memory address
 inc ecx            ;increment char count
 inc edi            ;increment pointer to o/p buffer 
 mov al, 0aH        ;LF to end line
 mov byte[edi],al   ;put it at end of output line
 inc ecx            ;increment output char count
 
 pop eax            ;get argv[0]
 cmp eax,0
 jz message
 add eax,0
 add al, 30H       ;convert integer to ascii
 mov edi, result    ;put char in output buffer result
 mov byte[edi],al   ;move argv[0] into edi memory address
 inc ecx            ;increment output char count
 inc edi            ;increment pointer to o/p buffer

 message:
 mov edx,len        ;length of string to write
 mov ecx,msg        ;addr of string
 mov ebx, 1         ;file descriptor 1 = stdout
 mov eax, 4         ;"write" system call
 int 0x80           ;call the kernel
 ;
 
 pop edx            ;restore char count into edx for system call
 mov ecx,cline      ;address of string
 mov ebx, 1         ;file descriptor 1=stdout
 mov eax, 4         ;"write" system call
 int 0x80           ;call the kernel

 ;
 mov edx,charlen    ;length of string to write
 mov ecx,char       ;addr of string
 mov ebx, 1         ;file descriptor 1 = stdout
 mov eax, 4         ;"write" system call
 int 0x80           ;call the kernel
 ;
 pop edx            ;restore char count into edx for system call
 mov ecx,result      ;address of string
 mov ebx, 1         ;file descriptor 1=stdout
 mov eax, 4         ;"write" system call
 int 0x80           ;call the kernel
 ;

 mov ebx, 0         ;exit with error code 0
 mov eax, 1         ;"exit" system call
 int 0x80           ;call the kernel