//---------------------------------------------------------------- // nocbreak.s // // This program disables the terminal's -C capability. // // programmer: ALLAN CRUSE // written on: 23 SEP 2003 //---------------------------------------------------------------- # our symbolic constants .equ KEYBOARD, 0 # keyboard device number .equ DISPLAY, 1 # display device number .equ TCSAFLUSH, 2 # termios constant value .equ ISIG, 0 # bit-number of ISIG bit .equ ESCAPE, 0x1B # ascii code for ESC-key .section .data ttysav: .space 60 # initial termios object ttywrk: .space 60 # working termios object inchar: .space 1 # keyboard input-buffer newlin: .ascii "\n" # ascii code for newline wasesc: .byte 0 # flag used for quitting .section .text main: # get the initial terminal settings pushl $ttywrk # function argument #2 pushl $KEYBOARD # function argument #1 call tcgetattr # call runtime library addl $8, %esp # discard the arguments # make a copy of these settings movl $ttywrk, %esi # setup source address movl $ttysav, %edi # setup dest'n address movl $60, %ecx # setup the loop count nxmov: movb (%esi), %al # get next source byte movb %al, (%edi) # put into dest'n byte incl %esi # advance source address incl %edi # advance dest'n address loop nxmov # copy remaining bytes # turn off ISIG bit in the 'c_lflags' field movl $12, %ebx # offset to 'c_lflag' btr $ISIG, ttywrk(%ebx) # reset the ISIG bit # install our modified terminal settings pushl $ttywrk # function argument #3 pushl $TCSAFLUSH # function argument #2 pushl $KEYBOARD # function argument #1 call tcsetattr # call runtime library addl $12, %esp # discard the arguments # accept keyboard input until -code is received again: # read next byte from keyboard device pushl $1 # function argument #3 pushl $inchar # function argument #2 pushl $KEYBOARD # function argument #1 call read # call runtime library addl $12, %esp # discard the arguments # continue unless an -code was read cmpb $ESCAPE, inchar # was -code? jne again # no, keep on reading # write 'newline' code to display device pushl $1 # function argument #3 pushl $newlin # function argument #2 pushl $DISPLAY # function argument #1 call write # call runtime library addl $12, %esp # discard the arguments # restore the original terminal settings pushl $ttysav # function argument #3 pushl $TCSAFLUSH # function argument #2 pushl $KEYBOARD # function argument #1 call tcsetattr # call runtime library addl $12, %esp # discard the arguments ret # return control to Linux .globl main # make entry-point visible