title: Don't line break in shell after executing asm programm. [AT&T]
body: <p>Like in the title said the asm programm should not automatically break a new line after executing it. My programm is a simplified version of the "echo" command in linux. It prints the arguments given by the user. If the users first argument is '-n' the prompt should be to the right of the output and not break the line. So my question is how do i force NOT breaking a line in AT&amp;T after executing?</p>
  
  <pre><code>.code32
  .section .data
      lf: .ascii "-n"             # Lf = line feed
      withoutLF: .long 0             # helper flag
      counter: .long 0            # is the counter of bytes of an argument
      arguments: .long 0          # number of arguments
      white_space: .ascii " "     # is white space
  
  .section .text
  
  .globl _start
  
  _start:
      movl (%esp), %esi           # gets the argument count of the stack to ESI
      movl %esi, arguments        # moves argument count to arguments variable
      decl arguments              # decrement counter
      addl $8, %esp               # move the esp to the actual arguments
  
      ### check if first argument is '-n' ###
  
      movl (%esp), %esi           # move first string to ESI
      movl $lf, %edi              # move second string to EDI
      movl $2, %ecx               # number of  bytes which should be compared
      cld                         # clear Flag D, wihtout clearance the compare ill occur in inverse order 
      rep cmpsb                   # the actual comparing of the 2 strings
      jz _without_lf              # if the same jump to _without_lf
  
  _arg:
      movl (%esp), %esi           # moves argument of stack to ESI
      cmpl $0, arguments          # compares if there any arguments left
      je _exit                    # out of arguments --&gt; exit progamm
      jmp _print_white_space      # if NOT out of arguments --&gt; print a white space
  
  
  _numberOfBytes:
      lodsb                       # load string in bytes from ESI --&gt; saves byte in EAX
      cmpb $0, %al                # compare if byte is equal 0
      je _print_arg               # jumps to section to print the actual argument
      incl counter                # increment the counter (number of bytes)
      jmp _numberOfBytes          # jump to the beginning of _numberOfBytes (to read the left bytes)
  
  _print_arg:
      movl counter, %edx          # EDX message length 
      movl $1, %ebx               # EBX = file descriptor (1 = stdout)
      movl (%esp), %ecx           # ECX = address of message
      movl $4, %eax               # syscall number (4 = write)
      int $0x80                   # call kernel by interrupt
  
      addl $4, %esp               # move ESP to next argument (1 argument = 4 bytes)
      decl arguments              # decrement the number of arguments
      movl $0, counter            # reset the counter of bytes
      jmp _arg                    # jump to the top of _arg
  
  _print_white_space:
      movl $1, %edx               # EDX message length
      movl $1, %ebx               # EBX = file descriptor (1 = stdout)
      movl $white_space, %ecx     # ECX = address of message (startaddress)
      movl $4, %eax               # syscall number (4 = write)
      int $0x80                   # call kernel by interrupt
      jmp _numberOfBytes          # jump to _numberOfBytes --&gt; still arguments left to print
  
  _without_lf:
      addl $4, %esp               # move ESP to next argument of the stack
      decl arguments              # decrement arguments counter --&gt; '-n' is not counted, just used
      incl withoutLF              # move 1 to withLF (helper flag)
      jmp _arg
  
     _exit:                       # exit the program
       movl $0, %ebx
       movl $1, %eax
       int $0x80
  </code></pre>
  
  <p>Here is the output of my program</p>
  
  <p><a href="https://i.stack.imgur.com/RClwJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RClwJ.png" alt="Here is the output of my program"></a></p>
  
  <p>Output of $PS1, $PS1 and the normal echo command:</p>
  
  <p><a href="https://i.stack.imgur.com/JQYuW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JQYuW.png" alt="enter image description here"></a></p>
  
  <p>Count of bytes is 6 of the word "Hello" so with a null termination</p>
  
  <p><a href="https://i.stack.imgur.com/CvRRW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CvRRW.png" alt="Count of bytes"></a></p>