Hi to all:
My English is poor. But I try.
How can I detect the number of ltp port and what is the address of each port detected in Assembler ?
One example or tutorial. Something.
All December, January and don´t work. No ethernet document, no englihs, no espanish, please help me.
-EYE--. Don't work. Test only.
Seg_LPT EQU 0400H
;Ofs_LPT EQU 08H
True EQU 1H
False EQU -1H
;Len_Str EQU $-LPT_Is
LPT_Addr EQU 0400H
Ofs_LPT1 EQU 08h ; \
Ofs_LPT2 EQU 0Ah ; >Offset de los puertos
Ofs_LPT3 EQU 0Ch ; /
Byte_R_W EQU 44H
jmp start
There_is DB False
;LPT_Is LABEL BYTE
; DB 'First', '$'
; DB 'Second', '$'
; DB 'Third', '$'
Lpt_Found DB 13,10,' LPT port found !',13,10,'$'
No_LPT DB 'There is: no LPT adapter installed !',13,10,'$'
;There_is DB ?
port1 dw ?
port2 dw ?
port3 dw ?
pru dw ?
p_dec1 db 'Puerto 1 es: Hex: 378h, Dec: 888 $'
p_dec2 db 'Puerto 2 es: Hex: 278h, Dec: 632 $'
p_dec3 db 'Puerto 3 es: Hex: 3BCh, Dec: 956 $'
Start:
Check_LPT PROC NEAR
MOV CX,3 ;Carga el contador con 3
MOV AX,Seg_LPT ;Carga AX con 0040:0000
ADD AX,Ofs_LPT3
MOV ES,AX ;carga ES con 0040:0000
MOV DI,ES
;MOV ES,Ofs_LPT3 ;Ofs_LPT
MOV BX,DI
XOR BH,BH
;lea ax,[bx]
Lop_LPT: MOV AX,WORD PTR ES:[BX]
MOV DX,ES:[0408H]
;LES DX,[SP]
;POP DI
MOV DX,ES:[DI] ;-
;mov dx,SP ;-bl
;pop DX ;-
mov pru,dx ;-
CMP AL,0 ;This statement checking LPT Port
JZ Next_LPT
MOV There_Is,True
MOV AX,Ofs_LPT3 ;Len_Str
MUL CL
MOV DX,AX
ADD DX,OFFSET Lpt_Found ;Lpt_Is
;LEA DX,LPT_Found
;Interrup para mostrar en Pantalla.
MOV AH,09H
INT 21H
LEA DX,LPT_Found
;Interrup para mostrar en Pantalla.
MOV AH,09H
INT 21H
Next_LPT: DEC BL
DEC BL
MOV AX,ES
XOR AL,AL
ADD AL,BL
MOV ES,AX
LOOP Lop_LPT
CMP There_Is,False
JNE End_Check_LPT
LEA DX,No_LPT
;Interrup para mostrar en Pantalla.
MOV AH,09H
INT 21H
End_Check_LPT:
;RET
Check_LPT ENDP
INT 20h
end start
Thank. By(t)e ('-')
You cannot assume that the port I/O addresses will be in the order 378h, 278h, 3BCh, and even though these addresses are normal other addresses are possible. I used my support file just to make it easier to display hex values and pause the program waiting for the user to press a key.
.model small,c
.386
.stack
.NOLIST
include support.asm
.LIST
.data
.code
.startup
push 40h
pop es
mov bx, 8
runloop:
mov ax, es:[bx]
cmp ax, 0
je @F
print hexword$(ax),"h",NL
@@:
add bx, 2
cmp bx, 0eh
jb runloop
print NL,"Press any normal key to exit...",NL
call waitkey
.exit
end
[attachment deleted by admin]
IAO,
As you didn't say what was working, I will add something that confused me the first time I worked with more than one LPT port. The BIOS POST code looks at the standard addresses: 03bch, 0378h, & 0278h The one found with the highest address is assigned to LPT1, the next highest address--if found--is assigned to LPT2, and the next highest address--if found--is assigned LPT3
Therefore is 0278h would be LPT1 if it is the only port found on the machine!
hth,
farrier
Hi to all:
My English is poor. But I try.
Mr. MichaelW:
Thank you. I goto my home to probe your example-- tomorrow write.
Mr.Farrier:
I have a single C program.
It scan and show all address in hex.
If no port device, show cero (00).
Is difficult for me in english.
I like that program, but in assembler.
Thank.
By(t)e ('-').
Hi to all:
My English is poor. But I try.
Mr. MichaelW:
I modified his code for the EMU8086 emulator. It worked perfect.
Sometimes, a small example, is more valuable that four books.
#make_COM#
ORG 100h
start:
push 40h
pop SS
mov bx, 0ch
mov bp,bx
runloop:
mov bx, ss:[bp]
mov dx,bx
cmp dx,0
je aqui
aqui:
dec bp
dec bp
cmp bp,06h
ja runloop
.exit
end
You are a brain. You are lamp on my feet.
Two months tried, without profits. It was so easy.
I do not know like expressing thanks. But:
THANKS = (THANKS)^1'000'000 <=> THANKS == (THANKS + THANKS + THANKS....bis.... bis...)
God blesses to you.
By(t)e ('-').
You're welcome.
You should avoid using BP as a general-purpose base or index register because BP is a special register that is normally used to access procedure parameters. If you changed the value of BP within a procedure that had parameters the program could crash. Even outside of a procedure there is a potential problem in programs where DS != SS, because for instructions that reference BP the default segment register is SS instead of DS.
Hi to all:
My English is poor. But I try.
Mr. MichaelW:
I understand.
But, in the emulator (EMU8086) it worked perfect, with BP.
It did not work with ES.
The EMU8086, it is very good to beginner.
It does not require data or code segment.
You see the register, stack, stepper motor and more.
EMU8086 is very nice.
THANKS = (THANKS)^1'000'000 <=> THANKS == (THANKS + THANKS + THANKS....bis.... bis...)
God blesses to you.
by(t)e ('-').
Quote from: IAO on January 25, 2006, 12:58:18 PM
start:
push 40h
pop SS
I think you are asking for problems if your SS points to 0040.
DOS lives from 0070, so your SP could be killing DOS...