Author Topic: work whith parallel port in nasm for linux  (Read 19135 times)

nobody

  • Guest
work whith parallel port in nasm for linux
« on: October 26, 2004, 08:35:51 AM »
Hi,
I want to send to parallel port a byte using nasm program, in linux, that:

segment .text
BITS   16
   global  _start
_start:
  mov  al,0ffh
  mov  dx,378h
  out   dx,al
  nop
  jmp   _start

My program run, but To parallel port is same state
(040h).
 Please, help me!

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: work whith parallel port in nasm for linux
« Reply #1 on: October 26, 2004, 10:54:20 AM »
Well, the "BITS 16" is a problem. No Linux distro I'm aware of runs in 16-bit mode! With Nasm told to emit 16-bit code, and the cpu running in 32-bit mode, your "mov dx, 378h" is seen as "mov edx, 378EE90h", gobbling up the "out dx, al" and the "nop". Removing the "BITS 16" (the default for "-f elf" is 32-bits) does the "out", and the program segfaults as expected - you don't have permission to access this port! You'll need to do "sys_ioperm" or "sys_iopl" first. Either will require you to be root, I think. I don't know too much about 'em...

Best,
Frank

nobody

  • Guest
Re: work whith parallel port in nasm for linux
« Reply #2 on: October 28, 2004, 04:31:27 AM »
thank you, Frank!
Please, I prefer to use the Bios services, but I don't
how to use LRMI library for that.