## Octal "assembler", based on osm.c, osma.s, and osmb.s, syscalls. .globl _start _start: main: xor %esi, %esi # flag for whether we have data xor %edi, %edi # the data we maybe have next: push %esi # stack balance, also zero the buffer xor %eax, %eax mov $3, %al # __NR_read xor %ebx, %ebx # fd = stdin, 0 mov %esp, %ecx # buf on stack xor %edx, %edx # count = inc %edx # 1 int $0x80 # system call, results in %eax dec %eax test %eax, %eax # if not 1: jnz end # bail out pop %eax # fetch character read sub $'0, %eax cmp $7, %eax ja emit # if non-digit, emit buffered byte if any shl $3, %edi # otherwise shift to make space for digit inc %esi # and set flag or %eax, %edi jmp next emit: test %esi, %esi # Do we have buffered data to emit? je next xor %eax, %eax mov $4, %al # __NR_write xor %ebx, %ebx # fd = inc %ebx # stdout, 1 push %edi mov %esp, %ecx # buf on stack again xor %edx, %edx inc %edx # count = 1 int $0x80 pop %edx jmp main end: xor %eax, %eax # __NR_exit = inc %eax # 1 int $0x80