Question


I have learned a bit of assembly code and also learned that there is't that much good tutorials on the internet for this. I was wondering about sending signals with to certain devices
ex. parallel ports, usb(perhaps)
I was wondering if there was any code anyone can share to lead me in the right direction. And in-case you didn't know by signal I mean sending out voltage.

So to sum it up I would like to know how to interact with certain ports with assembly

I am currently using DosBox for running assembly, and using flat assembler to program. This is all running on window 8.

Thanks in advance, 36redsoxfan

Was it helpful?

Solution

I'm not an fasm expert... But, according to this post... Which may or may not be for fasm...

http://board.flatassembler.net/topic.php?t=8638

Set your bios as Bidirectional Parallel port mode (SPP)

This sets the I/O permission:

mov eax,101                      ; SYS_IOPERM 
mov ebx,Base_Parallel         ; 378H 
mov ecx,Size                      ; 3 
mov edx,1                         ; Turn ON 
int 80H 
test eax,eax 
js Error_Set_IO 

To Write:

mov dx,37ah 
in al,dx 
and al,11011111b             ; reset bit 5 ( Write mode) 
out dx,al   

mov al,0ffh                         ; turn on all 8 pin 
mov dx,378h 
out dx,al                           ; Write byte 

To Read:

mov dx,37ah 
in     al,dx 
or     al,00100000b          ; set bit 5 ( Read mode) 
out   dx,al 

mov dx,378h 
in    al,dx                        ; Read byte 

OTHER TIPS

It's all a matter of writing the correct bits to the correct ports using in and out, as has already been stated. The big problem will be that if you are running in user mode on a Windows box you aren't going to have sufficient permissions to let you do this - you need to be running as a kernel-mode driver (and even then you're probably calling OS supplied interfaces, rather than doing assembly-level hardware access). I haven't used DosBox myself, but in general an emulator like this will only emulate access to the underlying hardware - so it might allow you to write to an emulated parallel port, but this won't actually change the voltage levels on your hardware parallel port - this is still subject to Windows restrictions..

Your options then depend a bit on what exactly you want to do. Some possible options:

  • If you just want to play around with assembly accessing hardware, but don't need to actually access physical hardware then you can probably find an emulator which will emulate at least some hardware, and show you the results of your assembly operations on this emulated hardware.
  • If you want to access physical hardware using assembly in a Windows environment then you'll probably have to look around and see if there are any emulators which use windows drivers to pass your commands through to the physical hardware, rather than just an emulated device.
  • If you want to access physical hardware using assembly outside of a Windows environment then you just need to find an OS or bootloader which allows your assembly code to directly access the hardware.
  • If it doesn't have to be assembly then there are other options available (this is the path I've gone in the past when playing around with the parallel port in a Windows environment).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top