>Has anyone here done any serial programming? I need to support multiple
>ports as interfaces for machine control. The serial programming HOWTO seems
>to contain errors, is more than a bit thin, and hasn't been updated in
about
>18 months.
Below is a file posted elsewhere (in the 80xxx echo from fidonet to be
exact) on performing the 'fire' display in linux using assembly. The code
uses i/o port writes in assembly, so perhaps it can show you how to do the
calls you need to make in order to write to the i/o ports. I read the howto
file as well, and seems to work the same as the fire code does. One thought
that the howto mentioned was that the code will only work for users logged
in as 'root'. If you need to access the i/o ports w/o being "root" you'll
need to use the /dev/ports file access method, or develop a driver for the
kernal.
[DOS - http://asmjournal.freeservers.com/apj_4.txt]
----------------------------------------------------------------------------
-
; 66 bytes Graphic Fire demo.
; assemble using 'Tasm FIRE.ASM' and 'Tlink /t FIRE.OBJ'
;======================================================================FIRE.
AS
.MODEL TINY
.CODE
.386
ORG 100H
START:
push 0a000h
pop es
push es
pop ds
mov al,13h ; mode 13h. (AX=0)
int 10h
; gray-scale routine
mov dx,3c8h
CBW ; set ax=0
out dx,al
inc dx
gs_loop:
out dx,al
out dx,al
out dx,al
inc ax
jnz short gs_loop
;---
MainLoop:
mov si,1280 ;
mov ch,5dh ; y-pos, the less the faster demo
push si
push cx
Sloop:
lodsb
add al,[si] ; pick color and
add al,[si+320] ; pick one more and
shr al,2 ; divide, we got a
; 'smooth-fire-routine'
mov [si-960],al ; put color
loop short Sloop
pop di
pop cx
Randoml:
mul word ptr [di+1] ; 'random' routine.
inc ax
stosw
loop short Randoml
MOV AH,1 ; check keypress
INT 16h
Jz short MainLoop
;---
Die:
mov ax,3 ; text-mode
int 10h
ret ; A com program may end using ret
END start
;==========================================================================-
----------------------------------------------------------------------------
-
[My Linux-port GNU-assembler and SVGALIB]
>>> File: /home/jan/assembler/fire.linux/fire.s <<<
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
call vga_init # Init vga
pushl $5
call vga_setmode # set mode to 5 = 320x200x256
addl $4,%esp
pushl $0
call vga_setpage # Point to page 0 (There is only 1 page)
addl $4,%esp
pushl $0x3c8 # Get IOpermission, starting from 3c8h
pushl $2 # to 3c9h
pushl $1 # Turn On value
call ioperm
addl $12,%esp
pushl $0x60 # Get IOpermission, for 60h : keyboard
pushl $1
Pushl $1
call ioperm
addl $12,%esp
in $0x60,%al # Read current value of keyboard
movb %al,key
movw $0x3c8,%dx
movw $0,%ax
outb %al,%dx
incw %dx
lus:
outb %al,%dx
outb %al,%dx
outb %al,%dx
incw %ax
jnz lus
movl graph_mem,%ebx
Mainloop:
movl $1280,%esi # mov si,1280 ;
movl $0x5d00,%ecx # mov ch,5dh ; y-pos, the less the faster
demo
pushl %esi # push si
pushl %ecx # push cx
Sloop:
movb (%ebx,%esi),%al # lodsb
incl %esi #
addb (%ebx,%esi),%al # al,[si] ; pick color and
addb 320(%ebx,%esi),%al # add al,[si+320] ; pick one more
and
shrb $2,%al # shr al,2
movb %al,-960(%ebx,%esi) # mov [si-960],al ; put color
loop Sloop
popl %edi # pop di
popl %ecx # pop cx
Randoml:
mulw 1(%ebx,%edi) # mul word ptr [di+1] ; 'random'
routine.
incw %ax
movw %ax,(%ebx,%edi) #stosw
incl %edi
incl %edi
loop Randoml
inb $0x60,%al
cmpb key,%al
jz Mainloop
pushl $0
call exit
addl $4,%esp
movl %ebp,%esp
popl %ebp
ret
.data
key:
.byte 0
>>> EndFile <<<
gcc fire.s -o fire -lvga.
Have a nice day All. - Jan Wagemakers -