title: Why does adding cmpb 0x20, %al prevent text output?
body: <p>I'm trying to do a quick test program in x86 assembly that takes a string and just outputs it again, that also detects if there is a space and displays some text. This program is mainly so I can figure out detection of the space character.</p>
  <pre><code>LC0:
      .ascii &quot;Enter a string: \0&quot;
  LC1:
      .ascii &quot;%[^\n]\0&quot;
  LC2:
      .ascii &quot;Your string is:\12\0&quot;
  LC4:
      .ascii &quot;%c\12\0&quot;  # print out the character 
  LC6:
      .ascii &quot;Yeehaw!\12\0&quot; # test message
      
      .globl  _main
      .def    _main;  .scl    2;  .type   32; .endef
  _main:
      pushl   %ebp
      movl    %esp, %ebp
      
      pushl   %ebx
      subl    $112, %esp
      
      movl    $LC0, (%esp)
      call    _puts                # similar to _printf function
      leal    8(%esp), %eax
      movl    %eax, 4(%esp)
      
      movl    $LC1, (%esp)
      call    _scanf               # get string 
      
      movl    $LC2, (%esp)
      call    _printf              # printout the output text of LC2
      
              ###### A[i] ###### ebx is the index 
      movl    $0, %ebx             #index of array i=0    
      jmp     .L2
      
  .L1: #TEXT PORTION
      movsbl  %al, %eax           # eax =FFFFFFXX  XX means for each character print out the input character 
      incl    %ebx                # next index of array 
      
      movl    %eax, 4(%esp)       # print out from the first element of the array
      movl    $LC4, (%esp)
      call    _printf
          
  .L2: #TEXT PORTION
      movzbl  8(%esp,%ebx), %eax  # the value of esp+8+0 strating address of the array to eax
      
      #Problem lines
      cmpb 0x20, %al # compare eax to see if it is a space
      jne .EndOfLine
      
      #should only run if %al is a space
      movl    $LC6, (%esp) # test message to check if properly detecting spaces
      call _printf
      
  .EndOfLine:
      testb   %al, %al            # if eax is not equal to zero jump to L3, if is zero menas end of the string 
      jne     .L1 
      
      movl    $0, %eax
      addl    $112, %esp
      leave
      ret
  </code></pre>
  <p>Without <em>cmpb 0x20, %al</em> my program works just fine (if input is &quot;Hello&quot;, will print &quot;Hello&quot;), but as soon as I add that line it doesn't print anything and just goes to the end of the program. Anyone know why this is happening?</p>