[asm] Status-Byte (printer)
First of all i have to say that I am very new to the Assembler programming language.
I tried the following on a linux ix86 box without success.
Does anyone has any idea how to solve this problem?
Thanks in advance,
I have never programmed in assembly on Linux and
it has been a while since I've touched assembly at all
but off the top of my head I see:
1) This might be it, I think you might not be able
to access the hardware directly like that from
user space. Try running the program as root.
I doubt that will work. You will probably have
to use system calls to get the information
2) This just kind of jumped out at me but won't solve
your problem you jump unecessarily.
could just be
And the same for the other times you do it.
and when you
There is no point, you will always fall through
Hope this helps
you are right, the jumps are unecessary. I thought I can prevent some problems if the program becomes more complex. :-) But that shouldnt be the reason for the segmentation fault when calling int 17h.
You said accessing the hardware directly from user space might not work. Do I have the opportunity to implement these lines into a LKM? Or which syscall do I need to access the hardware to get the printers status byte?
Thanks in advance
You could do that from kernel module but I don't know if you'd
have a conflict form the normal parallel port driver. But as we've
just left user space and entered the kernel I am way out of my
league. It would be a terrible security risk to be able to have
direct hardware access from userspace. If you can find out what
int 0x17 does exactly you might be able to stay in nice friendly
userspace by manipulating the i/o lines. See the i/o port programming
i think the problem is the same one encountered often in shellcode. it has to do with
the registers being clean when making interrupts, here:
movl eax, 02 works. that might be the cause.
Interupts don't work from userspace.
but you're right problems are often caused
by dirty registers. However he moves 2 to ah
not al so it should be
mov_l eax, 0x200
int = interrupt, right? you interrupt the kernel to make the system call on your behalf i thought.
yep, my bad with ah/al i havent worked in asm in a bit.
edit: yep after reading intel manual int i was correct, int:
"...int genreates a call to the interrupt or exception handler specified by arggument"
we prolly jus got messed up on definitions?
I should be more clear.
int 0x80 is allowed and you are correct that is how you
interact with the kernel for system calls. Other interrupts
aren't allowed. int is a privileged instruction. Using int in
usermode generates an exception which is why his program
segfaults. The kernel masks int 0x80 and catches the exception
it when a process uses it. The kernel does this sort of thing for
other stuff too. For example when you want to use floating
point instructions on an i386 w/ no fpu. The kernel will catch
the "illegal" instruction exception and instead of giving your
program a SIGILL it will emulate the instruction and hand it
back to the program transparently.
ahhh now i gotcha. thanks for the xtra info as well i wasn't fully aware that's how int 0x80 was handled. :)
Ok, thank you all. I think, now I understand why it doesnt work to call the interrupt, but another question regarding that topic ... What is the way a driver (module in the linux world) initialize the printer to communicate with the system. Interrupt 17h, function 1 (ah =1) specifies a printer initialization. What does that mean in clear text? Does that has anything to do with driver wrtiting or is it just another method to confuse me. :-)
|All times are GMT -5. The time now is 10:43 PM.|