.data buf: .fill 1 counter: .fill 4 linecounter: .fill 4 .text .global _start _start: movl $0,counter movl $0,linecounter LoopBegin: movl $3,%eax movl $0,%ebx movl $buf,%ecx movl $1,%edx int $0x80 cmpl $0,%eax jz CondEnd # %eax is nonzero, we read a char cmpb $'\n',buf jnz CondEnd # add one to linecounter addl $1,linecounter CondEnd: addl %eax,counter cmpl $0,%eax jnz LoopBegin LoopExit: movl $1,%eax movl $0,%ebx int $0x80