Article 3385 of comp.sys.handhelds: Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod!unix.cis.pitt.edu!dsinc!ub!acsu.buffalo.edu From: cloos@acsu.buffalo.edu (James H. Cloos) Newsgroups: comp.sys.handhelds Subject: On Unit Objects Message-ID: <54397@eerie.acsu.Buffalo.EDU> Date: 15 Jan 91 02:01:11 GMT Sender: news@acsu.Buffalo.EDU Organization: State University of New York @ Buffalo Lines: 40 Nntp-Posting-Host: lictor.acsu.buffalo.edu Hello all. Hope you had a good holiday season. (Hmmm, after this I think that the linked array will be the only object type whose format is unknown (to the net at large).) Before I proceed, thanks to Jan & Derek for compiling their internals lists, 'frechett@boulder' for posting Derek's to c.s.h, and Jake for combining it with Jan's list. Without Derek's list in specific, I would not have figured this out as quickly. Anyway, it turns out that Unit objects are stored just like lists, programs, and algebraics (aka Symbolics). The format looks like this: UNIT real unit1 _ ; (where 'unit1' would be a string) for a simple un-prefixed unit, such as 2_m. The '_' though, is just an empty list, but a specific empty list. The prefixes are implemented by combining a CHARACTER with the string representing the main unit. (This room is closing shortly, so I'll be blunt below. Questions are gladly answered ;) The five list's addresses What they do ------------ ------------ 10b72 ^ aka power 10b5e * aka mult 10b68 / aka divide 10b86 _ aka combine real to units 10b7c combine character prefix to unit string I have to go now, so I'll post a followup tomorrow with some more info, but this should whet your appatite 'till then. ;) -JimC -- James H. Cloos, Jr. Phone: +1 716 673-1250 cloos@ACSU.Buffalo.EDU Snail: PersonalZipCode: 14048-0772, USA cloos@ub.UUCP Quote: <> Article 3427 of comp.sys.handhelds: Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!rex!wuarchive!zaphod.mps.ohio-state.edu!ub!acsu.buffalo.edu From: cloos@acsu.buffalo.edu (James H. Cloos) Newsgroups: comp.sys.handhelds Subject: Re: On Unit Objects Message-ID: <54927@eerie.acsu.Buffalo.EDU> Date: 17 Jan 91 23:41:35 GMT References: <54397@eerie.acsu.Buffalo.EDU> Sender: news@acsu.Buffalo.EDU Organization: State University of New York @ Buffalo Lines: 123 Nntp-Posting-Host: lictor.acsu.buffalo.edu In article <54397@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos) writes: >Hello all. Hope you had a good holiday season. > >(Hmmm, after this I think that the linked array will be the only >object type whose format is unknown (to the net at large).) > >Before I proceed, thanks to Jan & Derek for compiling their internals >lists, 'frechett@boulder' for posting Derek's to c.s.h, and Jake for >combining it with Jan's list. Without Derek's list in specific, I >would not have figured this out as quickly. > >Anyway, it turns out that Unit objects are stored just like lists, >programs, and algebraics (aka Symbolics). The format looks like this: >UNIT real unit1 _ ; >(where 'unit1' would be a string) for a simple un-prefixed unit, such >as 2_m. The '_' though, is just an empty list, but a specific empty >list. > >The prefixes are implemented by combining a CHARACTER with the string >representing the main unit. > >(This room is closing shortly, so I'll be blunt below. Questions are >gladly answered ;) > >The five list's addresses What they do >------------ ------------ >10b72 ^ aka power >10b5e * aka mult >10b68 / aka divide >10b86 _ aka combine real to units >10b7c combine character prefix to unit string > > >I have to go now, so I'll post a followup tomorrow with some more >info, but this should whet your appatite 'till then. ;) Well, a little later than I expected, but I'mm baaaaaaaaack. Before I forget it, the list of base units is at #FA53h. So, let me show how the above looks in an actual unit object: Lets look first at 1_Pa and then UBASE(1_Pa) which is 1_kg/(m*s^2): 1_Pa CMP\-> \->LIST looks like { 1 "Pa" { } } on the stack. 1_Pa \->HX looks like "ADA209C2A2C2A2090000051668B01B2130". Let's break that up a bit: ADA20 Unit header 9C2A2 %1 aka real_1 C2A20 String header 90000 String is 9 nybbles long, including these 5 05 16 Characters #50h and #61h, ie P & a make up the string 68B01 This is the empty list, above we see it means '_' B2130 ; aka SEMI aka END : Marks end of Unit,List,Symbolic,Program IF we then ubase this, we get 1_kg/(m*s^2). Because we used UBASE, rather than entering it with the unit menus or the command line, it will reference the elements of the list at #FA53 that I mentioned above. (This list contains: { 1_kg 1_m 1_A 1_s 1_K 1_cd 1_mol 1_? } 1_kg/(m*s^2) CMP\-> \->LIST will look like the following no matter how you enter it: { 1 Character "g" { } "m" "s" 2 { } { } { } { } } However, when you look at it with \->HX, you do get a difference. If UBASE is used, you get: "ADA209C2A226AF096AF0C7B01E8AF0ECAF0ED2A227B01E5B0186B0168B01B2130" or: ADA20 Unit header 9C2A2 %1 26AF0 Char_k from the BASE list 96AF0 Chs_"g" from the BASE list C7B01 Combine Char prefix to unit String E8AF0 Chs_"m" from the BASE list ECAF0 Chs_"s" from the BASE list ED2A2 %2 27B01 ^ for units (really empty list) E5B01 * for units (really empty list) 86B01 / for units (really empty list) 68B01 _ for units (really empty list) B2130 ; If this were entered directly, rather than using UBASE, the character and the 3 strings would be directly in the object. This is why if you enter a unit object using either the menus or the command line, using only base units, DUP it, UBASE the copy, and try SAME, you get 0. (If you are curious, the char_k looks like "FB920B6" in place of the 26AF0, "g" looks like C2A207000076 in place of 96AF), "m" to C2A2070000D6 in place of E8AF0, and "s" to C2A207000037 in place of ECAF0. So that you too can enjoy digging into these, I've included below 2 ASCified programs. The first, CMP\->, stands for CoMPosite OUT, and will break up a list, unit, symbolic, or program. The actual syseval that does this is #1C973; the rest of the code just makes sure that you give it a unit, program, list or symbolic. \->UNT will take a broken up unit and put it back together. Just like \->LIST, \->PRG, and \->ALG. The routines are basicly the same, but the syseval for \->UNT is #5481. I must warn you, though: Trying to put together an improper unit object has resulted in a mem lost for me each time. (Luckily I had a backup in my ram card, which was R/O at the time just in case ;-) DIR CMP\->.ASC "D9D20ECE8112040379C1F3040379C194040379C1B7040379C1B21303471" \->UNT.ASC "D9D2043C8118450B21302A8A" END I hope this proves to be useful. -JimC -- James H. Cloos, Jr. Phone: +1 716 673-1250 cloos@ACSU.Buffalo.EDU Snail: PersonalZipCode: 14048-0772, USA cloos@ub.UUCP Quote: <> ----- Here's hoping the Air-to-Ground combat finishes everything, and the ground forces do not need to become directly involved; and that no more allied jets go down!