[Vollbild]  [Home]TUX

Code Snippets

LICENSE

Get input and output permission to a port
Open a File with read/write access
Get max priority for shedule in fifo (first in first out) mode
Change shedule mode to fifo
Get the terminal attributes
Set the terminal attributes
Read 1 byte from the standart input (keyboard)

;-- Get input and output permission to a port. --
; You must have root permission for execution
moveax,101;ioperm
movebx,$37A;start port / parallelport
movecx,1;1port long
movedx,1;allow
int$80
cmpeax,0
jzcontinue
callerror;your error procedure
jmpend
.continue:


;-- Open a File with read/write access --

moveax,5;open File
movebx,datname;-> file name
movecx,2;read/write
int$80
cmpeax,0
jge.continue
callerror;your error procedure
jmpend

.continue:


;-- Get max priority for shedule in fifo (first in first out) mode. --
;Useful with the next one.
moveax,159;SCHED_GET_PRIORITY_MAX
movebx,1;policy FIFO
int$80
cmpeax,0;priority
jg.continue
callerror;your error procedure
jmpend

.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.

moveax,156;SCHED_SETSCHEDULAR
movebx,0;pid = root
movecx,1;policy = SCHED_FIFO
movedx,priority;-> priority
int$80
cmpeax,0
jz.continue
callerror;your error procedure
jmpend

.continue:


;-- Get the terminal attributes. --
;Necessary to restore them later.

moveax,54
movebx,0
movecx,0x5401;get terminal attributes
movedx,.buf1; -> .buf1 resb 28
int$80h
cmpeax,0
jz.continue
callerror;your error procedure
jmpend

.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.

;buf2 is a copy of buf1.
anddword[.buf2+12],11111111111111111111111111110101b
ordword[.buf2+12],00000000000000000100000000000000b
andbyte[.buf2+17],11011111b

moveax,54
movebx,0
movecx,0x5402;set terminal attributes
movedx,.buf2; -> .buf2   resb   28
int80h
cmpeax,0
jz.continue
callerror;your error procedure
jmpend

.continue:


;-- Read 1 byte from the standart input (keyboard). --

moveax,3;Syscall read
movebx,0;file number
movecx,buf+1;-> buf db
movedx,1;count bytes
int80h;read 1 byte
cmpeax,1;count bytes
je.continue
callerror;your error procedure
jmpend

.continue:


Free Web Hosting