Newsgroups: comp.lang.perl
Path: utzoo!utgpu!cunews!micor!latour!mcr
From: mcr@Sandelman.OCUnix.on.ca (Michael Richardson)
Subject: 'H' and 'h' in pack/unpack.
Message-ID: <1991May27.043119.12173@Sandelman.OCUnix.on.ca>
Summary: what do they do?
Organization: Sandelman Software Works, Debugging Department, Ottawa, ON
Distribution: comp
Date: Mon, 27 May 1991 04:31:19 GMT

  I haven't been reading comp.lang.perl regularly, nor have I been
using Perl for more than a month, but I don't think this is a FAQ. 

  I have some binary data which I'd like to turn into S-records. (My
knowledge of S-records is far from complete though). I also have a
6809 assemblers that produce S-records in a format that I don't think
is appropriate for the 6809 board I want to download them to.
  I thought that Perl would be appropriate, with the use of
pack/unpack for the S-record manipulation. Checking my copy of the
Perl book, I see 
  h - A hexadecimal string, low nybble first.
  H - A hexadecimal string, high nybble first.

  (I've never seen hex where the low nybble was first..)

  I've come to the conclusion that these options are NOT for extracting
hexadecimal data to and from (binary) strings. I finally checked the
code (in doarg.c and dolist.c) but that didn't help. I'm really not
sure what that code does as it doesn't seem to have the loop in the
right place. 
  What are they for?? Is there a way to use pack/unpack to do what I
want?
  S-record format, btw, is something like this:


S113AABB00112233445566778899aabbccddeeffZZ

	S1	start of data record
	13	number of data bytes in the record + 3 (16 decimal)
	AABB	data to be loaded at address AABB (16 bit address)
	00112233445566778899aabbccddeeff	data
	ZZ	checksum of all bytes (include 13, don't include S1)


  I'm resorting to hex(), loops and sprintf("%02x",$val) right now.

  BTW: this is 4.003 as posted to comp.sources.unix.
  Thanks.




-- 
   :!mcr!:            |  The postmaster never | So much mail, 
   Michael Richardson |    resolves twice.    |  so little time.
HOME: mcr@sandelman.ocunix.on.ca 	Bell: (613) 237-5629
    Small Ottawa nodes contact me about joining ocunix.on.ca!
