flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > getting data from i/o port

Author
Thread Post new topic Reply to topic
cylo



Joined: 06 Nov 2004
Posts: 20
hello!

i am realy new in assembler and need to get an memory mapped register adress through a i/o port.

i program on a amd geode gx1 cpu.
http://tech.parvus.com/documents/GeodeGX1.pdf

i need to get the gx_base adress which is saved in the gc register index B8h (p.98 ). to do that i have to use the memory i/o port 22h/23h (p.53). i have to set the index in 22h with a OUT(?) instructuion to get data through the 23h port.

but i dont realy know how the syntax could be look like...

need help! Embarassed

[Matrix_Spell_Checking=adjust,reason="there are memory mapped i/o ports and they are mapped by device ex.: $a000 so use with mov, xor ... so topic name should be without memory"]Matrix[/Matrix_Spell_Checking]
Post 10 Nov 2004, 08:11
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
howdy,
i recomend you Ralph Brown's Port List,

however in / outis a simple thing
Code:

in al,$60 ; read immediate port till $ff
in ax,$60 ; note: you can't do this with a byte port, unless you wanna read 2 byte ports
in eax,$60 ; note: you can't do this with a byte port, unless you wanna read 4 byte ports

out $60,al ; write immediate port till $ff
out $60,ax ; note: you can't do this with a byte port, unless you wanna write 2 byte ports
out $60,eax ; note: you can't do this with a byte port, unless you wanna write 4 byte ports

mov dx,$378
in al,dx ; read from port dx

in ax,dx ; note: you can't do this with a byte port, unless you wanna read 2 byte ports
in eax,dx ; note: you can't do this with a byte port, unless you wanna read 4 byte ports


mov dx,$378
out dx,al ; read from port dx

out dx,ax ; note: you can't do this with a byte port, unless you wanna write 2 byte ports
out dx,eax ; note: you can't do this with a byte port, unless you wanna write 4 byte ports
    
Post 10 Nov 2004, 12:16
View user's profile Send private message Visit poster's website Reply with quote
cylo



Joined: 06 Nov 2004
Posts: 20
Code:
mov dx,$22
mov al,$B8
out dx,al
mov dx,$23
in al,dx
mov al,myvar
    


i didnt get it... right? Smile
Post 10 Nov 2004, 16:39
View user's profile Send private message Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 340
Location: Trollhättan, Sweden
right, except:
Code:
mov [myvar], al    
Post 10 Nov 2004, 17:19
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
yeah, you're right, you can also do this cause posrt number is below 255

Code:
mov al,$B8 
out $22,al 
in al,$23 
mov [myvar],al

myvar rb 1 ; reserve 1 bytes for myvar
    


however using dx can give the ability for a relocateable port addressing

example:
Code:

mov [baseaddress],$378 ; reset initial value ( printer port 1 )

call readprinterstatus
call readdata

int 20h

readprinterstatus:
mov dx,baseaddress
add dx,1 ; this will read status register
in al,dx
ret

readprinterdata:
mov dx,baseaddress ; this will data port
in al,dx
ret

baseaddress dw $278 ; initial value ( printer port 2 )
    
Post 10 Nov 2004, 18:19
View user's profile Send private message Visit poster's website Reply with quote
cylo



Joined: 06 Nov 2004
Posts: 20
okay. this code works better... :p

mov al,$B8
out $22,al
in al,$23
mov [myvar],al

but in the sheet is written that only bit 1:0 of the 8bit gc register has the gx_base adress i need. how can i filter this two bits?
Post 10 Nov 2004, 19:17
View user's profile Send private message Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
The best thing you can do is get this code, it works in the same way as the code you want, but its for sound, you can see from the code how it is done,(not the wav bit, but the AC97 bit).
http://www.programmersheaven.com/zone10/cat592/23237.htm

\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Post 10 Nov 2004, 19:59
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
you know basic instructions no?

Code:

;get bit 2 from al
test al,100b ; binary
; now bit is in carry

;get bit 2 from al same with complex 386 microcode
bt ax,2 ; put bit 2 in carry
; now bit is in carry

;or if you don't care al is destroyed do:
and al,100b ; binary
setnz al ; this puts not zero flag in al

;or if you don't care al is destroyed do:
shr al,2 ; shift arithmetical right 2 bits
and al,1 ; mask out bit 0
; now al has the bit 2

;or if you don't care al is destroyed do:
shr al,3 ; shift arithmetical right 2 bits
; now carry has bit 2

;u can use carry like:
jc label1
; not carry
label1:
carry:
    
Post 10 Nov 2004, 19:59
View user's profile Send private message Visit poster's website Reply with quote
cylo



Joined: 06 Nov 2004
Posts: 20
okay now i got it...

Code:
and al,3    


that gives me the result i am looking for. sorry i am a asm noob Wink
Post 10 Nov 2004, 20:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.