1 / 7

Floating Point Unit

The Floating Point Unit (FPU) utilizes eight registers, ST(0) to ST(7), maintained as a stack for efficient data processing. The top register ST(0) holds the most recent value. This article explores the FPU's architecture and provides a code example for generating Fibonacci numbers through iterative calculations in assembly language. Using the FPU, we can efficiently calculate sequences and utilize conditional jumps for comparisons. This overview is ideal for programmers keen on mastering floating-point operations and series generation.

gavan
Download Presentation

Floating Point Unit

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Floating Point Unit

  2. Floating Point Unit ( FPU ) • There are eight registers, namely ST(0), ST(1), ST(2), …, ST(7). • They are maintained as a stack.

  3. Floating Point Unit ( FPU ) The top element of the stack is always named as ST(0). For example, .data v1 REAL8 1.23 v2 REAL8 6.3 v3 REAL8 7.9 • .code • finit • fld v1 • fld v2 • fld v3 • finitfinitfinitfinit • fld v1 fld v1fld v1fld v1 • fld v2 fld v2 fld v2fld v2 • fld v3 fld v3 fld v3 fld v3 ST(0) 7.9 ST(0) 1.23 6.3 ST(0) 6.3 ST(1) 1.23 ST(1) 1.23 ST(2)

  4. .code movedi, 0 finit fld ONE fst v[edi] movecx, num dececx cmpecx, 0 ;signed jleLdone L1: finit fld ONE fld v[edi] fadd ST(0), ST(1) add edi, 8 fst v[edi] loop L1 Ldone: Generate a series: 1, 2, 3, 4, …, (1) Sn+1 = Sn + 1 (2) S1 = 1 Store the elements in an array. We need to initialize the first element and then apply (1). .data v REAL8 100 DUP(?) ONE REAL8 1.0 num DWORD 10

  5. Generate Fibonacci series (numbers) (1) Sn+2 = Sn+1 + Sn (2) S0 = 1, S1 = 1 (seed values) Generate the first m numbers.

  6. .code movedi, 2*8 movesi, 0 movecx, m sub ecx, 2 cmpecx, 0 jleLdone ;signed L1: finit fld S[esi] fld S[esi+8] fadd ST(0), ST(1) fst S[edi] add edi, 8 add esi, 8 loop L1 Ldone: Generate Fibonacci series (numbers) (1) Sn+2 = Sn+1 + Sn (2) S0 = 0, S1 = 1 (seed values) Generate the first m numbers. .code S REAL8 0.0, 1.0, 100 DUP(?) m DWORD 10

  7. Conditional jumps • cmpeax, a • ja L1 ; eax> a ; unsigned comparison • jb L1 ; eax < a • jae L1 ; eax >= a • je L1 ; eax == a • jl, jg ; signed comparison

More Related