Skip to contentSkip to conversation

assembler -> linux system calls

DISCUSSION Bart Vandewoestyne 3 participants 4 messages Aug 23, 2001

lore
Share & tools
lore
#0 lore raw

I am trying to write a linux device driver for a data acquisition card. The little homepage for my project is at
http://mc303.ulyssis.org/heim/
There is already a DOS driver available, and I am trying to port the DOS code right now.

Somewhere in the DOS code, there is some assembler code included:

.RADIX 16
.MODEL SMALL

.486

.CODE

PUBLIC _inpl

_inpl PROC FAR

push bp
mov bp,sp

mov dx, Word Ptr [bp+6]
in EAX,dx

; bswap EAX

      push   EAX
      pop    ax
      pop    dx

mov sp,bp
pop bp
ret
_inpl ENDP

PUBLIC _inplI

_inplI PROC FAR

push bp
mov bp,sp

mov dx, Word Ptr [bp+6]
in EAX,dx

push EAX
pop ax
pop dx

mov sp,bp
pop bp
ret
_inplI ENDP

PUBLIC _swem

_swem PROC FAR

push bp
mov bp,sp

mov EAX, DWord Ptr [bp+6]

bswap EAX

push EAX
pop ax
pop dx

mov sp,bp
pop bp
ret
_swem ENDP

PUBLIC _outpl

_outpl PROC FAR

push bp
mov bp,sp

mov dx, Word Ptr [bp+0ah]
mov ax, Word Ptr [bp+8]
push ax
push dx
pop EAX
mov dx, Word Ptr [bp+6]
out dx,EAX

mov sp,bp
pop bp
ret
_outpl ENDP

PUBLIC _outplI

_outplI PROC FAR

push bp
mov bp,sp

mov dx, Word Ptr [bp+8]
mov ax, Word Ptr [bp+0ah]
push ax
push dx
pop EAX
mov dx, Word Ptr [bp+6]
out dx,EAX

mov sp,bp
pop bp
ret
_outplI ENDP

END

I would like to know by what linux native system calls I can replace the commands inpl, inplI, outpl, outplI, swem. I guess the following mapping should do it:

DOS assembler -> Linux

inpl inpl
inplI ???
outpl outpl
outplI ???
swem ???

Could somebody tell me what function to use where the question marks are written? Are the other mappings from inpl and outpl also correct?

Thanks for helping me out,
mc303

PS: The DOS code is also at http://mc303.ulyssis.org/heim

Signature · 5 lines
Ing. Bart Vandewoestyne			 [email protected]
Hugo Verrieststraat 48			       GSM: +32 (0)478 397 697
B-8550 Zwevegem			 http://users.pandora.be/vandewoestyne
----------------------------------------------------------------------
"Any fool can know, the point is to understand." - Albert Einstein
#1 lore raw
Quoted 7 lines · Bart Vandewoestyne

I am trying to write a linux device driver for a data acquisition card. The little homepage for my project is at
http://mc303.ulyssis.org/heim/
There is already a DOS driver available, and I am trying to port the DOS code right now.

Somewhere in the DOS code, there is some assembler code included:

[SNIPPED...]

File:
/usr/include/asm/io.h
...contains most of the I/O macros you need.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be attributed to Microsoft. Once I realized that Ctrl-Alt-Del was handled in the BIOS, I found that there aren't any.

#2 lore raw
Quoted 10 lines · Richard B. Johnson
Quoted 7 lines · Bart Vandewoestyne

I am trying to write a linux device driver for a data acquisition card. The little homepage for my project is at
http://mc303.ulyssis.org/heim/
There is already a DOS driver available, and I am trying to port the DOS code right now.

Somewhere in the DOS code, there is some assembler code included:

-> assembler code at: http://mc303.ulyssis.org/heim/downloads/INPL.ASM

Quoted 3 lines

File:
/usr/include/asm/io.h
...contains most of the I/O macros you need.

Hmm... I looked through that file, and it only talks about inl and outl functions. I guess the 'inpl' from the assembler code can be mapped to 'inl' from /usr/include/asm/io.h and the same for 'outpl', but what about 'inplI' and 'outplI' from the assembler code? My assembler skills ar zero, so I don't know if i can also just replace those by 'inl' and 'outl' from the linux source...

Greetzzz,
mc303

Signature · 5 lines
Ing. Bart Vandewoestyne			 [email protected]
Hugo Verrieststraat 48			       GSM: +32 (0)478 397 697
B-8550 Zwevegem			 http://users.pandora.be/vandewoestyne
----------------------------------------------------------------------
"Any fool can know, the point is to understand." - Albert Einstein
#3 lore raw
In reply to Bart Vandewoestyne
Quoted 2 lines

Could somebody tell me what function to use where the question marks are written? Are the other mappings from inpl and outpl also correct?

The look like the inb/inw/outb/outw functions. Im not sure how DOS asm maps byte and word sized in and out

swmem is a byte swap. There isnt a trivial equivalent because its almost never the case you want to byteswap but you want to convert endiannesses htons() will probably do the right thing while you figure it out