title: Print ARGC in NASM without printf
body: <p>Any good NASM/Intel Assembly programmers out there? If so, I have a question for you!</p>
  
  <p>Every tutorial I can find online, shows the usage of "printf" for printing the actual value of ARGC to the screen (fd:/dev/stdout). Is it not possible to simply print it with sys_write() for example:</p>
  
  <pre><code>SEGMENT .data ; nothing here
  
  SEGMENT .text ; sauce
          global _start
          _start:
                  pop ECX ; get ARGC value
                  mov EAX, 4 ; sys_write()
                          mov EBX, 1 ; /dev/stdout
                          mov EDX, 1 ; a single byte
                  int 0x80
                  mov EAX, 1 ; sys_exit()
                          mov EBX, 0 ; return 0
                  int 0x80
  SEGMENT .bss ; nothing here
  </code></pre>
  
  <p>When I run this, I get no output at all. I have tried copying ESP into EBP and tried using byte[EBP+4], (i was told the brackets de-reference the memory address). </p>
  
  <p>I can confirm that the value when compared to a constant, works. For instance, 
  this code works:</p>
  
  <pre><code>pop ebp ; put the first argument on the stack
  mov ebp, esp ; make a copy 
  cmp byte[ebp+4],0x5 ; does it equal 5?
  je _good ; goto _good, &amp;good, good()
  jne _bad ; goto _bad, &amp;bad, bad()
  </code></pre>
  
  <p>When we "pop" the stack, we technically should get the full number of arguments, no? Oh, btw, I compile with:</p>
  
  <pre><code>nasm -f elf test.asm -o test.o
  ld -o test test.o
  </code></pre>
  
  <p>not sure if that is relevant. Let me know if i need to provide more information, or format my code for readability.</p>