flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Bit Isolation

Author
Thread Post new topic Reply to topic
Pixelator



Joined: 07 Jan 2008
Posts: 13
Location: Over there
Pixelator
Hi, im new to fasm and i was wondering if it is possible to examine a single bit on and imput port?

_________________
Do not your will but the Lord's will.
Post 08 Jan 2008, 17:06
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
What do you mean exactly?
Post 08 Jan 2008, 17:11
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
No, but you can access a byte and later perform bit manipulation instructions to test the desired bit, for example:
Code:
; DX = holds desired port
desired_bit_to_test = 5 ; Change "5" to your desired bit (counting from zero)
in al, dx
test al, 1 shl desired_bit_to_test
; At this point ZF (Zero Flag) is set if the bit was zero and is cleared otherwise
setnz al ; Now AL holds a copy of the bit (not required, it is just to do something, you could use branching instructions here instead)    


http://flatassembler.net/docs.php?article=manual#2.1.7


Last edited by LocoDelAssembly on 08 Jan 2008, 17:18; edited 1 time in total
Post 08 Jan 2008, 17:17
View user's profile Send private message Reply with quote
Pixelator



Joined: 07 Jan 2008
Posts: 13
Location: Over there
Pixelator
well, i would like to check and see if bit 5 on the inputport 64h is 0 and if so, jump to a subrutine.

[edit]

sorry LocoDelAssembly i just saw your code, thankyou, it is just whan i needed to see Very Happy


Last edited by Pixelator on 08 Jan 2008, 17:20; edited 1 time in total
Post 08 Jan 2008, 17:18
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
in al, $64
test al, 1 shl 5
jnz @f
call subroutine
@@:    
Post 08 Jan 2008, 17:19
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
or with newer BT instruction:
Code:
in al, 64h
bt al, 5
jc bit_set
jnc bit_not_set
    
Post 08 Jan 2008, 18:17
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Pixelator



Joined: 07 Jan 2008
Posts: 13
Location: Over there
Pixelator
thank you very much
Post 09 Jan 2008, 16:04
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
or with the dear old and instruction, the same as test but with overwrite of register.
Post 09 Jan 2008, 19:54
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.