The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: ilian007 on October 16, 2009, 09:18:57 PM

Title: Encode 7 bit Interger
Post by: ilian007 on October 16, 2009, 09:18:57 PM
Hi we have to encode 7bit unsigned integer using certain procedure.

However for starting it I dont know how to get to the point where i will have only 7bit binary number.

From the keyboard it is 8 16 or etc .... The teacher just said: dont take attention of the 8 one .... any ideas ?

regular getdec will get 8 16 or etc number .... 

thanks
Title: Re: Encode 7 bit Interger
Post by: dedndave on October 16, 2009, 09:24:40 PM
well - if it is a signed integer, it can be from -64 to +63
if it is unsigned, it can be from 0 to 127
the real work here is the routine that reads the keyboard
you have to limit input to whichever range applies
Title: Re: Encode 7 bit Interger
Post by: FORTRANS on October 16, 2009, 09:33:08 PM
Hi,

   To get a 7-bit number, use AND to delete all higher bits.


; Limit contents of AX to only 7 bits.
        AND     AX,0000000001111111B


   This assumes you've got some data in AX to begin with
of course.

Steve N.
Title: Re: Encode 7 bit Interger
Post by: ilian007 on October 16, 2009, 10:14:56 PM
yeah I see thank you :) I was looking online and it says AND it with 7F which is I guess same as what FORTRANs said in HEX

thanks will start doing the procedure using that new info  :)
Title: Re: Encode 7 bit Interger
Post by: ilian007 on October 17, 2009, 07:54:40 AM
I have a binary number : "0000000100110101"  when trying to represent it in oct with putoct it prints "000465".

Please can you help me with how to make it to display number without the zeroes which I dont need in that case?

Would be great if I can make it instead of "000465" to display "465" or even better "465Q"

Thank you :)
Title: Re: Encode 7 bit Interger
Post by: dedndave on October 17, 2009, 09:51:42 AM
try the attached file...
Title: Re: Encode 7 bit Interger
Post by: ilian007 on October 28, 2009, 12:19:13 AM
Thanks dedndave it works great. However, the teacher is ok if we leave the number with 0's in front 000344Q is ok for him :P Now, studying for midterm tomorrow :)