• 沒有找到結果。

IEEE floating point format


Academic year: 2022

Share "IEEE floating point format"

顯示更多 ( 頁)



Real Arithmetic

Computer Organization and Assembly Languages Yung-Yu Chuang




• Grade for homework #3 is online

• You are encouraged to work in pairs for your final project

• You will have to schedule a demo session with your TA for your final project

• The final project will be due on the week after final week


Binary real numbers

• Binary real to decimal real

• Decimal real to binary real

4.5625 = 100.10012


0 100 0001 1 011 1110 1100 1100 1100 1100

IEEE floating point format

• IEEE defines two formats with different precisions: single and double

23.85 = 10111.1101102=1.0111110110x24 e = 127+4=83h


IEEE floating point format

IEEE double precision

special values


Denormalized numbers

• Number smaller than 1.0x2-126 can’t be

presented by a single with normalized form.

However, we can represent it with denormalized format.

• 1.001x2-129=0.01001x2-127


IA-32 floating point architecture

• Original 8086 only has integers. It is possible to simulate real arithmetic using software, but it is slow.

• 8087 floating-point processor was sold

separately at early time. Later, FPU (floating- point unit) was integrated into CPU.


FPU data types

• Three floating-point types


FPU data types

• Four integer types


Data registers

• Load: push, TOP--

• Store: pop, TOP++

• Instructions access the stack using ST(i)

relative to TOP

• If TOP=0 and push, TOP wraps to R7

• If TOP=7 and pop,

result in an exception

• Floating-point values are transferred to and from memory and stored in 10-byte temporary format.

When storing, convert back to integer, long, real, long real.


Special-purpose registers


Special-purpose registers

• Last data pointer stores the memory address of the operand for the last non-control instruction.

Last instruction pointer stored the address of the last non-control instruction. Both are 48 bits, 32 for offset, 16 for segment selector.

1 1 0 1 1


Status register


Control register

Initial 037Fh


Instruction format

• Begin with ‘F’. The second letter could be ‘B’

(binary-coded decimal), ‘I’ (binary integer) or none (real).

• Up to two operands, at least one of them is a floating-point register. Hence, no memory-

memory operation. No immediate and CPU register operands.


Instruction format

{…}: implied operands


Classic stack

• ST(0) as source, ST(1) as destination. Result is stored at ST(1) and ST(0) is popped, leaving the result on the top.


Real memory and integer memory

• ST(0) as the implied destination. The second operand is from memory.


Register and register pop

• Register: operands are FP data registers, one must be ST.

• Register pop: the same as register with a ST pop afterwards.


Example: evaluating an expression



FLDPI stores π

FLDL2T stores log2(10) FLDL2E stores log2(e) FLDLG2 stores log10(2) FLDLN2 stores ln(2)












Example: array sum

.data N = 20

array REAL8 N DUP(1.0) sum REAL8 0.0


mov ecx, N

mov esi, OFFSET array

fldz ; ST0 = 0

lp: fadd REAL8 PTR [esi]; ST0 += *(esi)

add esi, 8 ; move to next double loop lp

fstp sum ; store result



FMULP ST(1)=ST(0)*ST(1), pop ST(0)







• The above instructions change FPU’s status register of FPU and the following instructions are used to transfer them to CPU.

• SAHF copies C0 into carry, C2 into parity and C3 to zero. Since the sign and overflow flags are not set, use conditional jumps for unsigned integers (ja, jae, jb, jbe, je, jz).




Example: comparison


x REAL8 1.0 y REAL8 2.0 .code

; if (x>y) return 1 else return 0

fld x ; ST0 = x

fcomp y ; compare ST0 and y

fstsw ax ; move C bits into FLAGS sahf

jna else_part ; if x not above y, ...


mov eax, 1 jmp end_if else_part:

mov eax, 0 end_if:


Pentium Pro new comparison

• Pentium Pro supports two new comparison

instructions that directly modify CPU’s FLAGS.

The format should be FCOMI ST(0), src FCOMIP ST(0), src


Example: max=max(x,y)

.686 .data

x REAL8 1.0

y REAL8 2.0

max REAL8 ? .code

fld y

fld x ; ST0=x, ST1=y

fcomip st(0), st(1) jna y_bigger

fcomp st(0) ; pop y from stack

fld x ; ST0=x


fstp max


Miscellaneous instructions


x REAL4 2.75 five REAL4 5.2 .code

fld five ; ST0=5.2

fld x ; ST0=2.75, ST1=5.2

fscale ; ST0=2.75*32=88

; ST1=5.2


Example: quadratic formula


Example: quadratic formula


Example: quadratic formula



Second, Chinese last names provide much less information than non-Chinese ones because some Chinese last names are very common (e.g., “Wang” and “Lin”) and the romanization

Animal or vegetable fats and oils and their fractiors, boiled, oxidised, dehydrated, sulphurised, blown, polymerised by heat in vacuum or in inert gas or otherwise chemically

Milk and cream, in powder, granule or other solid form, of a fat content, by weight, exceeding 1.5%, not containing added sugar or other sweetening matter.

Two of his works, Mona Lisa and The Last Supper, are still famous today.. The Mona Lisa is kept in the Louvre Museum in

Estimated resident population by age and sex in statistical local areas, New South Wales, June 1990 (No. Canberra, Australian Capital

Fetch operands (OF): (memory operand needed) read value from memory E t th i t ti (IE). Execute the

The new control is also similar to an R-format instruction, because we want to write the result of the ALU into a register (and thus MemtoReg = 0, RegWrite = 1) and of course we

• Last data pointer stores the memory address of the operand for the last non control instruction the operand for the last non-control instruction.. Last instruction pointer

Depending on the specified transfer protocol and data format, this action may return the InstanceID of an AVTransport service that the Control Point can use to control the flow of

You are given the wavelength and total energy of a light pulse and asked to find the number of photons it

volume suppressed mass: (TeV) 2 /M P ∼ 10 −4 eV → mm range can be experimentally tested for any number of extra dimensions - Light U(1) gauge bosons: no derivative couplings. =>

incapable to extract any quantities from QCD, nor to tackle the most interesting physics, namely, the spontaneously chiral symmetry breaking and the color confinement.. 

(B) Some students went to the concert last night; the other stayed at home studying. (C) Some of the students went to the concert last night; others stayed at

• Formation of massive primordial stars as origin of objects in the early universe. • Supernova explosions might be visible to the most

The average TPI for the last four quarters ended the second quarter of 2011 increased by 12.22% from the previous period, with index of Accommodation and Miscellaneous Goods

Second, we replicate the AN+MM and use European options sampling at exercise as control variates (CV-at-exercise). Last, we also replicate the AN+MM and use

In case of non UPnP AV scenario, any application (acting as a Control Point) can invoke the QosManager service for setting up the Quality of Service for a particular traffic..

In the school opening ceremony, the principal announces that she, Miss Shen, t is going to retire early.. There will be a new teacher from

(Another example of close harmony is the four-bar unaccompanied vocal introduction to “Paperback Writer”, a somewhat later Beatles song.) Overall, Lennon’s and McCartney’s

The packed comparison instructions compare the destination (second) operand to the source (first) oper- and to test for equality or greater than.. These instructions compare eight

Microphone and 600 ohm line conduits shall be mechanically and electrically connected to receptacle boxes and electrically grounded to the audio system ground point.. Lines in

Four performance metrics: completeness of Pareto-optimal solutions, robustness of solution quality, the first and the last hitting time of Pareto-optimal solutions

Over the last decade, many research has gone into the development of more efficient alternate energy technologies, especially solar photovoltaic cells, are becoming