;Adobe Helvetica normal ;------------------------------------------------- ; Code for the best assembler: The Netwide Assembler: NASM ; Copyright (C) 2004 by Sebastian Beck; sebastian.bw@freenet.de ; Wenn Sie eine Spende machen wollen, fragen Sie mich über E-Mail ; nach meiner Bankverbindung. ; If you want to make a donation, please question me by e-mail for ; my banking connection. ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as ; published by the Free Software Foundation. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; http://www.gnu.org/ ;------------------------------------------------- ;-- Get input and output permission to a port. -- ; You must have root permission for execution mov eax,101 ;ioperm mov ebx,$37A ;start port / parallelport mov ecx,1 ;1port long mov edx,1 ;allow int $80 cmp eax,0 jz .continue call error ;your error procedure jmp end .continue: ;-- Open a File with read/write access -- mov eax,5 ;open File mov ebx,datname ;-> file name mov ecx,2 ;read/write int $80 cmp eax,0 jge .continue call error ;your error procedure jmp end .continue: ;-- Get max priority for shedule in fifo (first in first out) mode. -- ;Useful with the next one. mov eax,159 ;SCHED_GET_PRIORITY_MAX mov ebx,1 ;policy FIFO int $80 cmp eax,0 ;priority jg .continue call error ;your error procedure jmp end .continue: ;-- Change shedule mode to fifo. -- ;That's the only way under Linux to get ful realtime control of (port) outputs. ;Disatvantage: You can't use the Xterminal any more and such programms they use it, ;because all other tasks are stoped until you switch back to shed other mode f.e. ;So no mouse pointer is moveing and no key that's pressed is written to the display. ;So it is absolutly necessary to give the user a possibility to exit your program. See next. mov eax,156 ;SCHED_SETSCHEDULAR mov ebx,0 ;pid = root mov ecx,1 ;policy = SCHED_FIFO mov edx,priority ;-> priority int $80 cmp eax,0 jz .continue call error ;your error procedure jmp end .continue: ;-- Get the terminal attributes. -- ;Necessary to resore them later. mov eax,54 mov ebx,0 mov ecx,0x5401 ;get terminal attributes mov edx,.buf1 ; -> .buf1 resb 28 int 80h cmp eax,0 jz .continue call error ;your error procedure jmp end .continue: ;-- Set the terminal attributes. -- ;Set and clear the right bits before: ;To make the terminal return after 1 key is pressed (noncanonical) do this like: ;Don't forget to restore the terminal attributes with this funktion. Without you'll be ;not able to use any opened terminal / program normaly. ;buf2 is a copy of buf1. and dword[.buf2+12],11111111111111111111111111110101b or dword[.buf2+12],00000000000000000100000000000000b and byte[.buf2+17],11011111b mov eax,54 mov ebx,0 mov ecx,0x5402 ;set terminal attributes mov edx,.buf2 ; -> .buf2 resb 28 int 80h cmp eax,0 jz .continue call error ;your error procedure jmp end .continue: ;-- Read 1 byte from the standart input (keyboard). -- mov eax,3 ;Syscall read mov ebx,0 ;file number mov ecx,buf+1 ;-> buf db mov edx,1 ;count bytes int 80h ;read 1 byte cmp eax,1 ;count bytes je .continue call error ;your error procedure jmp end .continue: