Hi all,

I have 2 questions:

1) Can I run an asm programs in DOS if I do not make any Windows related references in it?

2) How can I use the IN and OUT instructions withouth being canceled for using privileged instructions?


Posted on 2002-11-06 13:40:28 by firmo
Hi firmo,


You can't. To access serial port you can use API-function CreateFile and ReadFile.

For Example:

; Initialized data ================================

;The DCB structure defines the control setting for a serial communications device
dcb DCB <>

;The COMMTIMEOUTS structure is used to set and query the time-out parameters for a communications device

; Connect to commport=============================
mov dcb.BaudRate,4800
mov dcb.ByteSize,8
mov dcb.Parity,0
mov dcb.StopBits,0

mov TO.ReadTotalTimeoutConstant,2000 ;2 sek

mov hComm,eax

; Reading from commport==========================
INVOKE ReadFile,hComm,pMemory,MEMSIZE,ADDR nBits,NULL

; Timeout ?======================================
mov eax,pMemory
mov eax,
cmp al,0
je @stop

I hope this example can be of any help for you,

Posted on 2002-11-06 16:38:07 by minor28
Question 1: :stupid:

Question 2: Depends on your linker; there is an linker on the download page that will allow you to use MASM32 for dos projects.
Posted on 2002-11-06 17:10:29 by VBprogrammer
#2: Well... it depends....

Under W95/8, certain I/O addresses (such as the COM ports) are virtualized, so you need a VxD to access them.

However, other I/O addresses not so virtualized you can bang freely with IN and OUT instructions. I've done so many times when accessing an 8255 based I/O card (which gives you 3 bytes of either IN or OUT physical electrical lines).

Under any of the NT variants, all I/O is virtualized, and you need an appropiate driver. WinIO (freeware package)can be very helpful here.
Posted on 2002-11-06 20:28:08 by Ernie
Hi guys,

First of all thanks for the replies.

However, since posting my questions I read somewere that using .386P (instead of just .386) would give one access to privileged instructions.

I guess thats not true then!

Best, Firmo
Posted on 2002-11-07 07:55:37 by firmo
Typing .386p will allow MASM to assemble them without errors, but windows still won't let them run so it terminates your program :)
Posted on 2002-11-07 08:55:44 by Qweerdy
Thanks Qweerdy.

I will eventually learn all these details.

Best, Firmo
Posted on 2002-11-07 10:05:27 by firmo

SADD macro?????
Posted on 2006-03-02 13:39:49 by korte

The SADD macro returns an address for the string 'COM1'

You could just as easily use addr szCom1
where szCom1 is a string defined in your data section
szCom1 db 'COM1', 0

Posted on 2006-03-02 14:42:55 by farrier

how to help and list of macros  masm32 macros.asm file?

Posted on 2006-03-02 23:15:18 by korte