The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: mhyshe on August 27, 2008, 05:17:34 AM

Title: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 27, 2008, 05:17:34 AM
really need some help with regards to this program.. Me and my classmate have written this program before but its such a long time and have forgotten the code.. Please help me by putting some comments on it.. And it does not run but does not have errors on it...

What the program do is it light leds using parallel port using masm programming assembly language help me please...

This are my questions..
1. Can you command parallel port using windows xp as your OS and using MASM assembly language if not what should you used?
2. How many ports or led or register can you command.
3. WhAT does this code "MOV CX, 60000" why does it have a 60000 counter.. does it means 6 seconds or loops 60000 times or is it so fast that you need to loop it for 6000 times.. help me with this one.

mov cx,60000


.model small
.stack
.code

mov dx,0378h ; use to communicate to the parallel port.
mov cx,60000 ; help me with this one. i know it is used to loop but how many times? or does this means 6 seconds?

mov bl, 1 ; moves 1 to bl and use as a counter

start: ; label for the loop

bitis:   ; label for the loop
mov ax,16 ; turns on a register or leds but i don't know which one.. needs help with this one.
out dx,ax ; output the mov ax,16 to dx which is connected to the parallel port.
loop bitis ; loops code. also needs help with this one, why do you need to loop this one?

off0: ; label for the loop
mov ax,00 ; all the part of the code with label "off" means it turns off all the port or register so im gonna skip putting comments to the rest of them.
out dx,ax ; output the mov ax,00
loop off0 ; loops the code

on:
mov ax,48 ; help what does it turns on
out dx,ax
loop on

off:
mov ax,00
out dx,ax
loop off

on2:
mov ax,80 ; help what does it turns on
out dx,ax
loop on2

off2:
mov ax,00
out dx,ax
loop off2

on3:
mov ax,144 ; help what does it turns on
out dx,ax
loop on3

off3:
mov ax,00
out dx,ax
loop off3

on4:
mov ax,240 ; help what does it turns on
out dx,ax
loop on4

off4:
mov ax,00
out dx,ax
loop off4

all:
mov ax,144 ; help what does it turns on
out dx,ax
loop all

off5:
mov ax,00
out dx,ax
loop off5

on6:
mov ax,80 ; help what does it turns on
out dx,ax
loop on6

off6:
mov ax,00
out dx,ax
loop off6

on7:
mov ax,48 ; help what does it turns on
out dx,ax
loop on7

off7:
mov ax,00
out dx,ax
loop off7

on8:
mov ax,16 ; help what does it turns on
out dx,ax
loop on8

off8:
mov ax,00
out dx,ax
loop off8

on9:
mov ax,240 ; help what does it turns on
out dx,ax
loop on9

off9:
mov ax,00
out dx,ax
loop off9

on10:
mov ax,16 ; help what does it turns on
out dx,ax
loop on10

off10:
mov ax,00
out dx,ax
loop off10

on11:
mov ax,48 ; help what does it turns on
out dx,ax
loop on11

off11:
mov ax,00
out dx,ax
loop off11

on12:
mov ax,112 ; help what does it turns on
out dx,ax
loop on12

off12:
mov ax,00
out dx,ax
loop off12

on13:
mov ax,240 ; help what does it turns on
out dx,ax
loop on13

off13:
mov ax,00
out dx,ax
loop off13

on14:
mov ax,112 ; help what does it turns on
out dx,ax
loop on14

off14:
mov ax,00
out dx,ax
loop off14

on15:
mov ax,48 ; bitis and 1st
out dx,ax
loop on15

off15:
mov ax,00
out dx,ax
loop off15

on16:
mov ax,16 ; bitis
out dx,ax
loop on16

off16:
mov ax,00
out dx,ax
loop off16

on17:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on17

off17:
mov ax,00
out dx,ax
loop off17

on18:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on18

off18:
mov ax,00
out dx,ax
loop off18

on19:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on19

off19:
mov ax,00
out dx,ax
loop off19


inc bl
cmp bl,20
jne start

mov ah,04ch
int 21h
end


guys please help me with this program.. if you need to ask me something that you don't understand or lack info's that you need please tell me.. help me with this code..
Guys please help me.. i don't know what's wrong... everything is set up correctly.. does masm parallel port works with xp.. help me.. i don't know what seems to be the problem..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: NPNW on August 27, 2008, 05:20:09 AM
looks like old dos code.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 27, 2008, 07:10:59 AM
uhm yes this is masm language and run in command prompt, i mean compile and link in command prompt. if anyone knows how to program like this one please put comments on each line and what does it do..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: Neil on August 27, 2008, 08:06:31 AM
Well from what I remember the printer port has to be initialised before it can be used :-

        mov ah,1    ;function
        mov dx,0    ;LPT1 (LPT2 = 1, LPT3 = 2 etc.)
        int 17h       ;initialise
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: sinsi on August 27, 2008, 08:15:56 AM
I guess if it's controlling LED's then it's not talking to a printer but to *something* connected to the printer (parallel) port.
If it's not a printer then who knows what sort of commands it expects?

Quote from: mhyshe on August 27, 2008, 05:17:34 AM
Me and my classmate have written this program before but its such a long time and have forgotten the code
So what did it control?
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: MichaelW on August 27, 2008, 08:16:16 AM
The first problem I see is that the on13 label is duplicated, so when I try to assemble the code MASM returns:

mhyshe.asm(202) : error A2005: symbol redefinition : on13


off18:
mov ax,00
out dx,ax
loop off18

on13:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on12

off19:
mov ax,00
out dx,ax
loop off19


There is another problem with the first on13 loop:

on13:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on12


The code will take a long time to execute because the first loop runs 60000 times and the other loops run 65536 times each, and the whole thing repeats 20 times.

Also, your code is accessing the Parallel Port Data register as if it were a 16-bit register, when it is actually an 8-bit register.

I have no idea if a DOS program can control the parallel port under Window XP. If I were doing this I would first experiment with the Output command in the DOS Debug program to determine if I could control the parallel port. You can start Debug from the Run command on the Start menu. The Debug output command sends a byte to an I/O port. The syntax is:

O port byte

Debug recognizes only hex numbers, so for example to send the value 1 to I/O port 378h you would type "O 378 1" at the Debug prompt, like this:

-O 378 1

And then press Enter.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 28, 2008, 05:50:54 AM
Quote from: Neil on August 27, 2008, 08:06:31 AM
Well from what I remember the printer port has to be initialised before it can be used :-

        mov ah,1    ;function
        mov dx,0    ;LPT1 (LPT2 = 1, LPT3 = 2 etc.)
        int 17h       ;initialise

uhm yes it is actually initialize.. and i know its included in my code...
       like the mov 0378h.. i think this is the specific register to call.. im not that sure though..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 28, 2008, 05:52:54 AM
Quote from: sinsi on August 27, 2008, 08:15:56 AM
I guess if it's controlling LED's then it's not talking to a printer but to *something* connected to the printer (parallel) port.
If it's not a printer then who knows what sort of commands it expects?

Quote from: mhyshe on August 27, 2008, 05:17:34 AM
Me and my classmate have written this program before but its such a long time and have forgotten the code
So what did it control?

yes that's what I mean man.. controlling the leds using the printer port or parallel port as you may say..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 28, 2008, 06:34:58 AM
Quote from: MichaelW on August 27, 2008, 08:16:16 AM
The first problem I see is that the on13 label is duplicated, so when I try to assemble the code MASM returns:

mhyshe.asm(202) : error A2005: symbol redefinition : on13


off18:
mov ax,00
out dx,ax
loop off18

on13:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on12

off19:
mov ax,00
out dx,ax
loop off19


There is another problem with the first on13 loop:

on13:
mov ax,240 ; bitis, 1st, 2nd and 3rd
out dx,ax
loop on12


The code will take a long time to execute because the first loop runs 60000 times and the other loops run 65536 times each, and the whole thing repeats 20 times.

Also, your code is accessing the Parallel Port Data register as if it were a 16-bit register, when it is actually an 8-bit register.

I have no idea if a DOS program can control the parallel port under Window XP. If I were doing this I would first experiment with the Output command in the DOS Debug program to determine if I could control the parallel port. You can start Debug from the Run command on the Start menu. The Debug output command sends a byte to an I/O port. The syntax is:

O port byte

Debug recognizes only hex numbers, so for example to send the value 1 to I/O port 378h you would type "O 378 1" at the Debug prompt, like this:

-O 378 1

And then press Enter.



Hi sir i have edited the program. Thanks for the correction in the code.. i have corrected those commands before but i have copied the wrong copy of it.. now this is the correct one my apologies on that matter.. please analyze it again sir..

and o Sir

what do you mean by this

The code will take a long time to execute because the first loop runs 60000 times and the other loops run 65536 times each, and the whole thing repeats 20 times.

why would it loop 65536? i know where 60000 came from, but im not sure about 65536. and oh sir does that 60000 means it would loop 60000 times or it would count 60000? because of what i remember my instructor said before that it is used to count.. ahh im not sure about those.. please need clarification..

Also this one sir.. What do you mean by this?
Also, your code is accessing the Parallel Port Data register as if it were a 16-bit register, when it is actually an 8-bit register.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: Neil on August 28, 2008, 07:45:24 AM
What MichaelW means about the CX register is when it reaches zero & you don't give it some other value, it reverts back to all ones & starts counting down again from 65535.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: Neil on August 28, 2008, 07:55:11 AM
Also as MichaelW says you are addressing the port as a 16 bit register i.e.    OUT DX,AX whereas it should be OUT DX,AL. :thumbu
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: MichaelW on August 28, 2008, 02:09:45 PM
mhyshe,

I suggested above that you use the DOS Debug program and its Output command to experiment with the parallel port, to easily determine if it can be controlled from a DOS program running under Windows XP. Debug is easy to use, and it is included with every version of Windows through Windows XP. I posted a Debug Tutorial  here (http://www.masm32.com/board/index.php?topic=1993.msg16019#msg16019) (sorry, English language only). If you do not understand how the LOOP instruction works, I suggest you use Debug to experiment with it. The code below is an example copied from the Debug window. Here are the steps involved:

Start Debug (always starts in command mode)
Type "A" and press Enter to enter assembly mode
Type in "MOV CX,2" and press Enter
Type in "LOOP 103" and press Enter
Type in "NOP" and press Enter
Press Enter again to exit assembly mode (and return to command mode)
Type "T" to trace through the first instruction
Type "T" to trace through the LOOP
Type "T" to trace through the LOOP


-A
0B05:0100 MOV CX, 2
0B05:0103 LOOP 103
0B05:0105 NOP
0B05:0106
-T

AX=0000  BX=0000  CX=0002  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=0001  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0105   NV UP EI PL NZ NA PO NC
0B05:0105 90            NOP
-


In this code the loop consists of only the LOOP instruction (note how the offset address operand matches the offset address of the instruction). The Trace command causes Debug to execute the next instruction in the execution sequence, then display the registers and flags, and below that the next instruction to be executed. Note how each LOOP instruction decrements CX, and the looping continues until CX=0, and at that point the next instruction to be executed is the NOP instruction at offset address 105, instead of the LOOP instruction at offset address 103.

And this code shows what happens when you start the LOOP instruction with CX=0:


-A
0B05:0100 MOV CX, 0
0B05:0103 LOOP 103
0B05:0105
-T

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=FFFF  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=FFFE  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-


Note that in Debug you use addresses directly, where in MASM code you would normally use labels that represent addresses.

Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: BogdanOntanu on August 28, 2008, 02:26:14 PM
mhyshe,

It will be more polite of you IF you DID NOT edit your top post and change it seriously AFTER people have answered your original top post. This way people can follow the flow of the discussion. Otherwise the answers might look out of order and other people will not understand the discussion.

Editing your posts after somebody did answer them should be restricted to fixing misspelled words in order to make reading easier.

Just an advice ;)
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 30, 2008, 07:19:32 AM
Quote from: Neil on August 28, 2008, 07:55:11 AM
Also as MichaelW says you are addressing the port as a 16 bit register i.e.    OUT DX,AX whereas it should be OUT DX,AL. :thumbu

oh yes about that 16 bit register... now i get what you guys mean about that.. yes AX. ah, and al.. thx guys.. for clearing that one out..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 30, 2008, 07:22:42 AM
Quote from: MichaelW on August 28, 2008, 02:09:45 PM
mhyshe,

I suggested above that you use the DOS Debug program and its Output command to experiment with the parallel port, to easily determine if it can be controlled from a DOS program running under Windows XP. Debug is easy to use, and it is included with every version of Windows through Windows XP. I posted a Debug Tutorial  here (http://www.masm32.com/board/index.php?topic=1993.msg16019#msg16019) (sorry, English language only). If you do not understand how the LOOP instruction works, I suggest you use Debug to experiment with it. The code below is an example copied from the Debug window. Here are the steps involved:

Start Debug (always starts in command mode)
Type "A" and press Enter to enter assembly mode
Type in "MOV CX,2" and press Enter
Type in "LOOP 103" and press Enter
Type in "NOP" and press Enter
Press Enter again to exit assembly mode (and return to command mode)
Type "T" to trace through the first instruction
Type "T" to trace through the LOOP
Type "T" to trace through the LOOP


-A
0B05:0100 MOV CX, 2
0B05:0103 LOOP 103
0B05:0105 NOP
0B05:0106
-T

AX=0000  BX=0000  CX=0002  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=0001  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0105   NV UP EI PL NZ NA PO NC
0B05:0105 90            NOP
-


In this code the loop consists of only the LOOP instruction (note how the offset address operand matches the offset address of the instruction). The Trace command causes Debug to execute the next instruction in the execution sequence, then display the registers and flags, and below that the next instruction to be executed. Note how each LOOP instruction decrements CX, and the looping continues until CX=0, and at that point the next instruction to be executed is the NOP instruction at offset address 105, instead of the LOOP instruction at offset address 103.

And this code shows what happens when you start the LOOP instruction with CX=0:


-A
0B05:0100 MOV CX, 0
0B05:0103 LOOP 103
0B05:0105
-T

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=FFFF  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-T

AX=0000  BX=0000  CX=FFFE  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B05  ES=0B05  SS=0B05  CS=0B05  IP=0103   NV UP EI PL NZ NA PO NC
0B05:0103 E2FE          LOOP    0103
-


Note that in Debug you use addresses directly, where in MASM code you would normally use labels that represent addresses.



thx Sir.. thank you also the direct link to the tutorial.. il read about it soon enough...
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 30, 2008, 07:24:14 AM
Quote from: BogdanOntanu on August 28, 2008, 02:26:14 PM
mhyshe,

It will be more polite of you IF you DID NOT edit your top post and change it seriously AFTER people have answered your original top post. This way people can follow the flow of the discussion. Otherwise the answers might look out of order and other people will not understand the discussion.

Editing your posts after somebody did answer them should be restricted to fixing misspelled words in order to make reading easier.

Just an advice ;)

Thank you very much for the advice sir.. I just hope i could revert what have been done but I can't anymore.. Anyways' i'll follow your advice.. to the rest of my posting..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 30, 2008, 07:47:26 AM
This is the last thing i would like to ask about controlling parallel port using masm..

How many pins can you control? what are their address. What I only know is that their address are like binary like this one... 00000000 having eight zeros or ones.. or you can use their converted hexadecimal value instead of the binary. What I want to ask you guys is that starting from what address can you command how many are they.. because for what i know some of them are use for grounds and others are reserved. Hope you could help me with this one.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: Neil on August 30, 2008, 10:03:21 AM
As MichaelW says the output data port (for LPT1) is 378H. I only know what they do as regards a printer. Bit 0 is the data output setting, Bit 1 is the line feed setting, Bits 2,3 &4 are various initialisation settigs & Bits 5,6 & 7 are not used, but if you are not controlling a printer then you could send a 'one' out to any of them. What the actual pinouts are I don't know, maybe someone else will tell you or just look it up on the Web.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: Neil on August 30, 2008, 10:06:07 AM
Here you are I found it straight away :-

25 Pin D-Sub Connector PinOut  Pin #  Pin Name  Pin Description and Function 
1  /STROBE  Strobe 
2  D0  Data Bit 0 
3  D1  Data Bit 1 
4  D2  Data Bit 2 
5  D3  Data Bit 3 
6  D4  Data Bit 4 
7  D5  Data Bit 5 
8  D6  Data Bit 6 
9  D7  Data Bit 7 
10  /ACK  Acknowledge 
11  BUSY  Busy 
12  PE  Paper End 
13  SEL  Select 
14  /AUTOFD  Autofeed 
15  /ERROR  Error 
16  /INIT  Initialize 
17  /SELIN  Select In 
18  GND  Strobe Ground 
19  GND  Data bit 1 and 2 Ground 
20  GND  Data bit 3 and 4 Ground 
21  GND  Data bit 5 and 6 Ground 
22  GND  Data bit 7 and 8 Ground 
23  GND  Busy and Fault Ground 
24  GND  Paper out, Select, and Acknowledge Ground 
25  GND  AutoFeed, Select input and Initialize Ground 
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on August 30, 2008, 12:32:36 PM
Quote from: Neil on August 30, 2008, 10:06:07 AM
Here you are I found it straight away :-

25 Pin D-Sub Connector PinOut  Pin #  Pin Name  Pin Description and Function 
1  /STROBE  Strobe 
2  D0  Data Bit 0 
3  D1  Data Bit 1 
4  D2  Data Bit 2 
5  D3  Data Bit 3 
6  D4  Data Bit 4 
7  D5  Data Bit 5 
8  D6  Data Bit 6 
9  D7  Data Bit 7 
10  /ACK  Acknowledge 
11  BUSY  Busy 
12  PE  Paper End 
13  SEL  Select 
14  /AUTOFD  Autofeed 
15  /ERROR  Error 
16  /INIT  Initialize 
17  /SELIN  Select In 
18  GND  Strobe Ground 
19  GND  Data bit 1 and 2 Ground 
20  GND  Data bit 3 and 4 Ground 
21  GND  Data bit 5 and 6 Ground 
22  GND  Data bit 7 and 8 Ground 
23  GND  Busy and Fault Ground 
24  GND  Paper out, Select, and Acknowledge Ground 
25  GND  AutoFeed, Select input and Initialize Ground 



Hehehehe i think this is indeed for a printer.. What i don't know if this is the same as what i am searching for.. il try to search for it..
il post it here if ill see it.. but hey Mr. Neil if you can find something that is used to command the LPT port using MASM i would be greatful.. thank you very much.. im searching right now..
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: MichaelW on August 30, 2008, 03:38:54 PM
For information on the parallel port try these links:
http://en.wikipedia.org/wiki/Parallel_port
http://www.beyondlogic.org/spp/parallel.htm

When programming the parallel port the first thing you need to do is determine how many parallel ports are present and what their base I/O addresses are. Under DOS you would typically start by checking the BIOS data area to determine which parallel ports the BIOS identified during its POST (Power On Self Test) routine. The BIOS stores the base I/O addresses of the first 3 parallel ports it finds in the BIOS data area at locations 40:08h, 40:0Ah, and 40:0Ch, where the 40h is the segment address of the BIOS data area and the 08h, 0Ah, and 0Ch are the offset addresses of the 16-bit words that store the base addresses. Using the Debug Dump command to do this on my Windows 2000 system I get:

-D 40:08
0040:0000                          BC 03 78 03 78 02 C0 9F           ..x.x...


Words are stored in memory with the bytes reversed, so the base I/O addresses are 3BCh, 378h, and 278h. On this system there is actually only 1 parallel port, at base I/O address 378h, and Windows is providing the others as "virtual" parallel ports. I think you will have the same problem under Windows XP. One way around this is to access the BIOS data area from a Win32 program using  WinIo (http://www.internals.com/) and the WinIo import library in include file that I posted  here (http://www.masm32.com/board/index.php?topic=3894.msg29042#msg29042). When I do this on my Windows 2000 system I find only 378h listed in the BIOS data area.

Each parallel port will use 3 sequential I/O addresses starting at the base I/O address, so on my system the parallel port data port will be at I/O address 378h, the status port at 379h, and the control port at 37Ah. Note that all of the ports are 8 bit, the status port is read only, and the control port may be write only. Once you have identified the parallel port and know the base I/O address, you can then use the Debug Input and Output commands to determine if you can write to the data port write latch. Note that this assumes that you have a bi-directional parallel port, which is likely, and that bit5 of the control port is set, which on my Windows 2000 system with a printer attached to the port, it is:

-I 378
AA
-O 378 55
-I 378
55
-


In the above code I read the initial value of the data port as AAh, wrote the value 55h, and then read it back to ensure that the write succeeded. To actually write to the parallel port connector, you would need to clear bit5 of the control port, in which case you would not be able to read the value written back. See the links above for details.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: ChrisLeslie on August 30, 2008, 09:12:16 PM
QuoteQuote from: mhyshe on August 27, 2008, 06:17:34 am
Me and my classmate have written this program before but its such a long time and have forgotten the code
So what did it control?

mhyshe is trying to control a bank of leds to make a pretty flashing loop. There is no reason why the parallel port can't, in DOS, control a home built device since it has controllable input and output pins. Trouble is, originally, the loop counter useage was screwed up but luckily would work as a loop because of the 65526 limitation to cx.


Chris
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: mhyshe on September 02, 2008, 02:14:37 AM
Quote from: ChrisLeslie on August 30, 2008, 09:12:16 PM
QuoteQuote from: mhyshe on August 27, 2008, 06:17:34 am
Me and my classmate have written this program before but its such a long time and have forgotten the code
So what did it control?

mhyshe is trying to control a bank of leds to make a pretty flashing loop. There is no reason why the parallel port can't, in DOS, control a home built device since it has controllable input and output pins. Trouble is, originally, the loop counter useage was screwed up but luckily would work as a loop because of the 65526 limitation to cx.


Chris

yes chris.. this is entirely true.. I am just trying to control some leds connected to the parallel port by also using the parallel cable and connecting it to the said port. thus i can't the program to output the commands.. my main trouble is.. i cant communicate with the device but im sure that the port address is correct.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: MichaelW on September 02, 2008, 03:14:55 AM
Did you clear bit 5 of the control port?
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: tenkey on September 08, 2008, 04:21:19 PM
For LEDs, you need to be sure they are connected in the proper direction, because they have polarity. Never having hooked them up to a parallel port, I can't say if they also need current limiting resistors.

The long loops are necessary because the human eye will blur images as the frequency approaches 24 Hz. Above that frequency, the lights will look solidly lit.

I would start debugging by using DEBUG and a voltmeter. Then hook up one LED and try to turn it on and off with DEBUG. If that works, then you should be able to hook up the rest of the LEDs and run the program.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: Mark Jones on September 08, 2008, 11:19:47 PM
It would be advisable, to wire the pins you are using through TTL buffers or inverters to your LEDs. Reason being, if you short out an LED or accidentally short out a pin while testing with a meter, the "extra chip" will go poof and not your mainboard's I/O controller. The latter is much, much harder to replace. i.e.,


               |
       Parallel|
         Port  |   U1      R1
               |   |\      ___
        Out--> |---| >o---|___|-+
        Pin    |   |/      470  |
               |   Buffer       V -> D1
               |    or          -    LED
               |   Inverter     |
               |               ===
               |               GND
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: daydreamer on September 10, 2008, 10:08:33 AM
trying to prepare a old pc I stripped down to a one board pentium, so I made a CDRW from data I saved from an old win98 start disk and it starts up a very incomplete msdos
but it is enough to place my asmprogram's name in autoexec.bat
I think that is the way to go
do I really need to put a worn noisy cpufan on it?, cant I just put some alumiumplates on it and put it right behind a big car electric fan?

Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: FORTRANS on September 10, 2008, 08:23:08 PM
Quote from: daydreamer on September 10, 2008, 10:08:33 AM
trying to prepare a old pc I stripped down to a one board pentium, so I made a CDRW from data I saved from an old win98 start disk and it starts up a very incomplete msdos
but it is enough to place my asmprogram's name in autoexec.bat
I think that is the way to go
do I really need to put a worn noisy cpufan on it?, cant I just put some alumiumplates on it and put it right behind a big car electric fan?

Hi,

   As they say on television, "insufficient data".  I
would think you could see how hot it gets in a short
time, and extrapolate to continuous usage.  I have a
Pentium laptop with no fan at all.  I also have a
Pentium desktop computer, and the only fan is in
the power supply.  If you meant a much newer
processor (PIII or better), I would use a cpu fan.
And a good heat sink designed for a CPU would
be better than aluminum plates that are not a real
heat sink.  If your motherboard supports it, you
could monitor the temperature with a TSR program.

$0.02

Steve N.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: MichaelW on September 10, 2008, 08:43:47 PM
Since you did not specify which Pentium, I recommend that you not try running it at all without a heat sink, in good thermal contact with the processor.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: daydreamer on September 11, 2008, 01:22:21 PM
Quote from: MichaelW on September 10, 2008, 08:43:47 PM
Since you did not specify which Pentium, I recommend that you not try running it at all without a heat sink, in good thermal contact with the processor.
comon, I already ran it many times now like that, short intervals and it is still working, it's only a old 75mhz crap that I can throw in dustbin and put in another P1 on mobo if anything happens, even started it with win98 start CDRW successfully from a old slow CDROM drive
I have forgotten where I have lied that CDRW and what program I used that was easy to make a startable CD with

Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: FORTRANS on September 11, 2008, 04:55:48 PM
Hi,

   You have a parts drawer with extra CPU's and no heat sinks?
I was talking to a friend earlier this week, and his internet
connection was responding erratically, and he found a fan had
stopped.   Well, at least tell us how hot it gets.

   Oh, what I started talking to him about was one of my hard
drives was reporting errors.  It went yesterday, so a reminder
to all of us that don't do backups...

Regards,

Steve N.
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: daydreamer on September 14, 2008, 10:56:15 AM
Quote from: FORTRANS on September 11, 2008, 04:55:48 PM
Hi,

   You have a parts drawer with extra CPU's and no heat sinks?
I was talking to a friend earlier this week, and his internet
connection was responding erratically, and he found a fan had
stopped.   Well, at least tell us how hot it gets.

   Oh, what I started talking to him about was one of my hard
drives was reporting errors.  It went yesterday, so a reminder
to all of us that don't do backups...

Regards,

Steve N.
we come from different walks of life, I am no carpenter like Edgar, but I have spent years with working with aluminium so I think I can make my own heatsink

yes it is not fun to lose projects from cashing hard drive, but you can end up with a better version you reconstruct from vagly remember how your code looks, makes you start a different approach of solving the problem, well at least it is what I did with 3d model I lost in storm
Title: Re: MASM PARALLEL PORT NEED HELP BADLY...
Post by: FORTRANS on September 14, 2008, 05:23:45 PM
Quote from: daydreamer on September 14, 2008, 10:56:15 AM
we come from different walks of life, I am no carpenter like Edgar, but I have spent years with working with aluminium so I think I can make my own heatsink

   Certainly, I just found it interesting that you had a
(to me fairly rare) spare CPU and not a (to me more
common) heat sink.  I took a thermometer, and placed
beside/on my Pentium, it reads over 140 F.  Probably
not so good?

Regards,

Steve