Re: Questions about packed decimal and bit string data.

From: Robert Redelmeier (redelm_at_ev1.net.invalid)
Date: 12/27/03


Date: Fri, 26 Dec 2003 23:02:32 +0000 (UTC)

John H. Lindsay <jlin_DELETE_THIS_SPAM_ZOT_dsay@kingston.net> wrote:
> (v) If a packed decimal number is stored from an FPU, are the
> bytes high-endian or low-endian within the resulting byte

x86 is little-endian. I sometimes format dumps to print
right-to-left to make numbers easier to recognize/decode.

x86 `fbld` and `fbst` instructions expect and deliver
[respectively] 80 bit values, 18 packed BCD digits and
sign as bit 79. Remainder of high byte ignored.

> Now how about bit strings? Suppose that in a 2-byte binary
> integer in bytes at addresses a and a+1 starting at bit 4
> of byte a. Does the bit string include bits 4, 5, 6 and 7 of
> a and bits 0, 1, 2, 3, 4, 5 and 6 of b, or does it include
> bits 4, 3, 2, 1 and 0 of a and bits 7, 6, 5, 4, 3 and 2 of
> byte a+1 or any of the other possibilities?

You can code anything you like. This bitpacking is
usually done to trade-off space for speed. You will
probably find the `shrd` and `shld` double-shift
instructions useful, but I don't know how fast they are
on modern CPUs.

> (3) I've gone through a number of books on x86 assemblers and
> I've never seen this sort of thing spelled out; are there
> any books that go to this level of detail? If so, which?

Not books, manuals. Intel releases a fine set at:
http://www.intel.com/design/pentium4/manuals/245470.htm

Books omit detail to make way for instruction and
hopefully insight. Manuals describe precisely what
is there, not how to use it.

Both can be failures or successes, but they have to
be judged by different standards.

-- Robert



Relevant Pages

  • Re: Two Click disassembly/reassembly
    ... Map the extra x86 registers to memory. ... > equivalents to the string instructions. ... > got such a limited RISC like instruction set that the assembler is more ...
    (alt.lang.asm)
  • Re: Are 80x86 badly designed processors ?
    ... not because of poor initial design. ... Only 5 instructions, and they are specialized. ... Backward compatibility is the primary thing x86 has in its favor. ... Current x86 processors are actually better understood as RISC processors ...
    (comp.lang.asm.x86)
  • Re: What does it mean
    ... It's a RISC core, served by microcode decoding x86 ... instructions. ...
    (rec.games.computer.ultima.dragons)
  • [GIT PULL] x86/urgent fixes for v2.6.31
    ... x86: Detect use of extended APIC ID for AMD CPUs ... Some instructions like VIA's padlock instructions generate a spurious ... * in interrupt context interact wrongly with other user/kernel fpu usage, ...
    (Linux-Kernel)
  • Re: scalar integer unit and SIMD share one pipeline
    ... In x86, integer SIMD ... MMX instructions, but MMX in x86 is one functional unit, which means ... I think in x86 MMX has its own register file, register allocation may ...
    (comp.arch)