TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Jasen Betts
from: Roger Scudder
date: 2003-11-12 06:06:24
subject: [--- Ebcdic ---]

On: 10 Nov 03  06:17:51 Jasen Betts wrote to Neil Heller:

 > Hi Neil.
 > 08-Nov-03 13:14:00, Neil Heller wrote to Jasen Betts
 >  NH>> To make things more interesting, integer values were little
 >  NH>> endian but were only 12 bits long.  The 13th bit was the start of
 >  NH>> the next number. That way every 3 bytes held 2 integer values.
 >  JB>> use sscanf() instead of atoi() - you can specifiy field
 >  JB>> widths....
 >  NH> Hmmm... if I received a byte value (ASCII) 65 ('A') how would I
 >  NH> use sscanf() to specify that val_1 = 6 and val_2 = 5?  I've never
 >  NH> seen that done with sscanf(). Could you also do do that sprintf()?
 > you need to convert to hex first (I thought that was obvious from the
 > context, sorry.)
 > char buffer[20];
 > int received='A',val_2,val_2;
 > sprintf( buffer, "%02x", received);
 > sscansf( buffer, "%1d%1d", &val_1,&val_2);
 > it's slightly more impressive with longer inputs.
 > char buffer[20];
 > Long received=0x747323;
 > int val_1,val_2;
 > sprintf( buffer, "%06x", received);
 > sscansf( buffer, "%3d%3d", &val_1,&val_2);

I'm not following you here...  He is describing a system that is based on a
12 bit word.

Assuming that the system did supported the concept of a 6 bit byte and
ascii as we know it (where 'A' == 41h, which seems to be what he is saying)
and that this was a little endian system, the character string
"test" would be transmitted like this... 
	
 110100 000001 100101 000001 110011 000001 110100 000001

 converted to hex the values would look like this...

 34h 01h 25h 01h 33h 01h 34h 01h

 when received at the 8 bit byte machine the stream would flatten out like this...	

 11010000 00011001 01000001 11001100 00011101 00000001

 converted to hex...

 D0h 19h 41h CCh 1Dh 01h

 I can't see anyway to convert this data without masking and bit shifting. 
You had me going on the sscanf for a minute, but after thinking about it, I
don't think sscanf really helps at all.

-Roger

--- Spinone v0.1.79 Win32
* Origin: Scudder's Point (1:261/38.11)
SEEN-BY: 633/267 270
@PATH: 261/38 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.