Page 1 of 1

ASM question

Posted: Fri Jun 10, 2005 5:51 pm
by TeddyLM
Hi all,

how can i use the IN and OUT asm commands within PB ?

(Example)

Procedure ATA_IDENTIFY_DRIVE()
MOV DX, 1F7h
IN AL,DX
EndProcedure

(IN AL,DX is reported as illegal instruction !!
Any idea how to address the IDE controller directly ?)

Posted: Fri Jun 10, 2005 7:06 pm
by GeoTrail
Did you enable ASM in the compiler?

Posted: Fri Jun 10, 2005 7:17 pm
by TeddyLM
Yes

MOV DX, 1F7h is accepted ! (but not IN AL,DX)

Posted: Sat Jun 11, 2005 3:12 am
by VPureBasic
Hi TeddyLM,

Just and Ideal like that...Maybe the register DX is for WORD value And AL is Byte!

Roger

Posted: Sat Jun 11, 2005 7:20 am
by TeddyLM
Hi VPureBasic

i don't think it's the problem here !
found on the Net :

...
In x86 assembler you use in( ) and out( ) instructions. They move single bytes. There is also inw( ) and outw( ) for moving 16 bit words
The format of the instructions are <instruction name> ( target, source ) Target and source are a port address or data
NOTE: For port addresses below 0x100h you can directly use the port address as a number.
For port addresses above 0xffh you have to load the address into the DX register
Examples:
mov dx, 379h
in al, dx (Reads port 0x379h -LPT1 status register- into al register)
...

Posted: Sat Jun 11, 2005 9:43 am
by Pupil
Have you tried to pass it directly to FASM by using the '!' operator, like this:

Code: Select all

! mov dx, 1f7h
! in al, dx

Posted: Sat Jun 11, 2005 10:06 am
by TeddyLM
Yes

nothing changed !
Are these commands prohibited in FASM for windows ?

Posted: Sat Jun 11, 2005 12:24 pm
by Pupil
Ok, i missunderstood you, i thought that the compiler complained. I'm pretty sure that on win2k & XP you're not allowed to mess directly with a port, be it com or lpt, you must do it through a driver.

Posted: Sat Jun 11, 2005 12:28 pm
by dell_jockey
Pupil wrote:I'm pretty sure that on win2k & XP you're not allowed to mess directly with a port, be it com or lpt, you must do it through a driver.
That's correct.

Posted: Sat Jun 11, 2005 2:56 pm
by TeddyLM
looks like i'll have to use CreateFile and DeviceIOControl API functions !

thanks for the help anyway

Did somebody write something to get access to device sectors ?

Posted: Sat Jun 11, 2005 4:56 pm
by dell_jockey
Check out http://www.purearea.net/ and search for "IO_DLL_WRAPPER".

Posted: Sat Jun 11, 2005 6:17 pm
by TeddyLM
That's interresting !

Thank you