| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [--- Ebcdic ---] |
On: 08 Nov 03 13:14:00 Neil Heller wrote to Jasen Betts:
Hi Neil...
> JB> NH> To make things more interesting, integer values were little
> JB> NH> endian but were only 12 bits long. The 13th bit was the start
> JB> NH> of the next number. That way every 3 bytes held 2 integer
> JB> NH> values.
> JB> use sscanf() instead of atoi() - you can specifiy field widths....
> Hmmm... if I received a byte value (ASCII) 65 ('A') how would I use
> sscanf() to specify that val_1 = 6 and val_2 = 5? I've never seen that
> done with sscanf(). Could you also do do that sprintf()?
This message is a little old, but I thought the idea of reading data that
was written on a machine with a 12 bit word architecture was just too
interesting to pass by...
I realize that the topic is ebcdic, but I only care to comment on the
problem of reading data that was written on the architecture that JB
describes.
On the question about the character 'A'
The ASCII value of 65 is not stored as you suggest, 6 in the low order
byte and 5 in the high order byte. (I suppose I missed your point, but
I'll go on with my thoughts anyway...) In an x86 architecture machine 65
fits into the first byte and if it is stored as a 16 bit word it would look
like this in a hex editor: 41 00
Supposing a machine architecture that uses a 12 bit word and uses little
endian byte order, the integer value would look like this in a hex editor:
01 01
The reason being that (if my interpretation is correct) a 6 bit byte has an
unsigned range of 0 - 63
111 111 = 63
...I suppose this could be adequate for business processing using a
language like COBOL (well, maybe at one time... I think this may have had
something to do with the Y2K thing... the way they packed dates back
then).
...on the question of how to read data created on such an architecture
using the scanf family of functions...
As jasen writes... since the intel host's architecture uses 8 bit bytes,
there is no way to read one byte, or even a single two byte word using
sscanf, so you would need to specify a field width of 3 bytes (24 bits)
which would allow you to read two 12 bit words. You would then need apply
some masking and bit shifting to align the data into a format that would be
usable on the host system.
-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™.