• Aucun résultat trouvé

FUNCTION Div3_76( A : 3 BYTES { !rC:E }) 3 BYTES { !rO:2 }

N/A
N/A
Protected

Academic year: 2022

Partager "FUNCTION Div3_76( A : 3 BYTES { !rC:E }) 3 BYTES { !rO:2 } "

Copied!
5
0
0

Texte intégral

(1)

.00 External

. LSTON

. Page

;»»»»»»»»»»»»»»»»>

· ....

J '

; > Module: Math

· ....

~ ,

;>

BANK 1 MODULE

; }-

; }

. : }

; )

; ::-

.: >

; }

; >

.: }-

· ' )

~ .

; >

; ) .: }

· ~

J '

• ">

~ .

This module contains all the special purpose math routines used in the Widget firmware .

FUNCTION Oiv3_19( A 3 BVTES { !rC:E }) 3 BYTES { !rO:2 } FUNCTION Div3-38( A 3 BYTES { !rC:E }) 3 BYTES { !rO:2 }

FUNCTION Div3_76( A : 3 BYTES { !rC:E }) 3 BYTES { !rO:2 }

FUNCTION MuIRO-m( RO : BYTE { IrO } ) 3 BYTES { IrO:2 } FUNCTION DivHdsSctrs( A : 3 BYTES { !rO:2 } ) :

Quotient:

BVTE {

!rO:l } Remainder : BYTE { !r3 }

Fl~CTION DivSctrs( A : BVTE { !r3 } ) : Quotient : BYTE { !r2 } Remainder : BYTE { !r3 }

; } } } } ) } » » » ) } » » > } } ) } ) } } ) } } ) } } }

. LSTOFF

.FIN

.00 External . LSTON

. Page

;»»»»»»»>}»»»»»»»)

· ....

. ' '

;} This function performs the following 24 bit arithmetic operations:

.; ).

;>

Div3_19 Result (-- A DIU 19

; )

;>

Div3_76 Result (-- A DIU 76

· ' ..

~ ,

;>

Inputs:

;>

A: 3 BVTES { !rC) !rD} !rE}

; >

; > Outputs:

;:> Resul t: 3 BVTES { !t--O .. !rl .. !t""2 }

· )

.' ;»»»»»»»»»»»»»»»>

. LSTOFF

.FIN

.00 Internal

. LSTON

. Page .FIN

; ) } } » » ) } » } } » ) } » } )

; >

;>

Div3_19: Quotient := Dividend DIV 19

; )

.:;- Local lJor'iables:

;>

Divisor: 3 ~(TES { !rC:E }

;>

Quotient: 3 BYTES { ~r7:9 }

;:> Dividetld : 3 BVTES { !r4:6 }

; ::-

;>

BEGIN

; > Dh ... iisor· := $013000 { 19 *= 2'"( 13 - 1 ) }

(2)

;~ Qoutient := 0

;> FOR

i :=

1 TO 13 DO

;>

IF ( Dividend >= Divisor)

;) THEN

;>

Dividend := Dividend - Divisor

; > Quotient := ( Quotient

*

2 ) +

;>

ELSE Quotient := ( Quotient

*

2 )

;>

Divisor := Divisor DIU 2

; ~. END

; )

;»»»»»»»»»»>

Div3_76: Ld ScrRegC1#$04 ;Divisor := $04COOO ScrRegDI#$CO

Div3-38:

Div3_19:

Div3.~:

Ld Ld ,Jr Ld Ld Ld

Jr Ld Ld

Ld Ld Ld Ld

ScrRegE,#$OO Oiv3--X

ScrRegC1#$02 ;Divisor - $026000 ScrRegD/·$60

ScrRegE,·$OO Div3-x

ScrRegC, #$0 1 ;Divisor - $013000 ScrRegDI#$30

ScrRegE1#$OO

ScrReg4,!rC ;pass dividend to routine ScrReg5., ! rD

Scr-Reg6 I IrE Push Rp ;save context Srp #Wrk-Scr

Clr !r7 ;Quotient := 0 Clr !r8

Clr !r"g

Ld !rA .. #13 ; FOR i := 1 TO 13 00

; c I ear cart ... y Rcf

Ric RIc Ric

!rg ;Quotient := Quotient

*

2

!r8

!r7

Ld IrOllr4 ;IF ( Dividend >= Divisor) Ld !r1 .. !r5

Ld h-·2 .. !

r'o

Call Sub3

Jr C1Div3_19-Div2

Ld !r4} !rO ;Oividend := Dividend - Divisor Ld !r5 .. !rl

Ld It ...

o ..

Ir2

Add ~rg,#l ;quotient := quotient + 1 Adc IrSI#O

Adc !r7 .. #O

D;.. .... .-3_19-Div2: Ref ;clear carry flag

Rt ... c Rt ... c

Rrc

!rC ;Divisor := Divisor DIU 2 IrO

!rE

(3)

Pop Rp ;context switch

Ld ! rO J ScrReg7 ; pass quo t i en t t.J ca I I er' Ld ! r 1 .. ScrRegS

Ld !r2 .. ScrReg9 Jp Bank-Ret

. LSTOFF

· DO Extet-'na I

. LSTON

. Page

;»»»»»»»»»»»»>

· >

.I

;>

Function: MuIRO-m {Multiply RO by m }

; >

; > This function mul ipl ies the byte in !rO by m where:

; )0

;>

For 10Mbyte Profi Ie: m

=

256

;>

For 20MByte Profi Ie: m

=

512

;>

For 30MByte Profi Ie: m = 1024

· >

.I

.> Inputs:

A BYTE { !rO }

; :: ..

• : )0 Outputs:

.> Result: 3 BVTES { !rC} !rO} !rE }

· "'-

J '

;»»»»»»»»»»»»>

.FIN

MuIRO...m:

· DO I n terna I . LSTON

.FIN

Clr Ld

crr

. LSTOFF

!r·E .;Resul t

!rO,,!rO

!rC

.00 W-20MB

+

W_40MB

. LSTON

It-'O

*

256

Ric !r·E ; Resu I t := Resul t

*

2

RIc !rO

Ric !rC . LSTOFF .FIN

.00 l.J_40~lB

. LSTON

Ric !rE .;Resul t := Resul t

*

2

Ric !rO

Ric !rC . LSTOFF

.FIN

· DO I nterna I . LSTON

.FIN

Jp Bank-Ret

(4)

. LSTOFF

.00 External . LSTON

. Page

;}»»»»»»»»»»»»»»»

; >

;>

Function: DivHdsSctrs {Divide by Heads

*

Sectors}

·

"

~

;>

This function takes the 24 bit word passed to it and returns

;>

a 2 byte integer ( representing the cylinder number) and

;>

the remainder from the divide.

; >

; > Inputs:

;>

A : 3

BVTES {

~rCI ~rOI ~rE

}

; }

;" Outputs:

;} Cyl inder : WORD { ! !rO }

.: > Remainder : 1 BYTE { !r3 }

· >

.&

;»»»»»»»»»»»»»»»>

. LSTOFF

o

i \}HdsSc tt-'S :

.FIN

.00 Internal . LSTON

.FIN

.00 Call

.FIN .00 Gill I

.FBi

W_l0MB Di .... ·:3-28

W-20MB + W_40MB Oiv3_76

;return with !rO:2 = result

ScrReg4:6 = remainder

;return with !rO:2

=

result

ScrReg4:6

=

remainde--

Ld ! rO} ! r 1 ; H i CI:J I : = Ld !rll!r2 ; LoCy I :=

Ld !r3}ScrReg6 ;Remainder Jp BankJRet

.lSTOFF

.00 External . LSTON

. Page

;}}}}}}»»»»»»»»»»»»>

; }

; } Fur-Ict i on: 0 i vSctrs {D i v i de by Sector's } .: )-

;>

This fur~tion takes the 1 byte word passed to it and returns

; > a 1 byte in teget-. ( represent i ng the head number ) and

;>

the remainder from the divide ( the remainder is the sector # ) ..

·

,.

}

;::. Inpl~ts:

Outputs:

· ~

.& •

A 1 BYTE { h--3 }

Quotient : 1 BYTE { !r2 } Remai nder : 1 B~lTE { ! r3 }

;> Algorithm:

(5)

.. -;-

;. · }

I

• >

0' · }

I-; }

; ).

; >

· ) l-· ).

l-· ).

;.

Note that there are only 2 t~ads on the widget, therefore if A ) NumberOfSectors then Head := 1, else Head := 0 and if A ). NumberOfSectors then Sector := A - NumberOfSectors

else Sector := A

Also} the sector is logically remapped to account for different inteaved drives. The mapping table is located

in the SpareTable: when the physical sector is found it's value is used as an index into the Map-Table and the value stored at that location of the table becomes the new sector.

;»»»»»»»»»»»»»»»>

DivSctrs:

D..5c tt-·s 1 :

D-Bctrs2:

ReMap.£ec tOt"' :

. LSTOFF .FIN

. DO Internal . LSTON

. Page .FIN

Ld

Cp Jr

Ld Sub .Jr Clr Ret Push Push

L.j

Ld Add Adc Lde Pop Pop

~ rO 1 #NbrSc trs

!r3} !rO Lt.1O--Sctrs1

!r21-#1

!r'31 !rO D-.Sctrs2

h-'2

!rE ;save regs

!rF

; load number of sectors into !rO

;check for A greater/equal

;select head 1

; se I act head 0

!rE}#.HIBVTE. Map_Table

!rF;.#.LOUBVTE. Map_Table

!rF.1!rO ; index into table

!rE,,#O

IrO.1@I~rE ;get remapped sector

!rF

!t-.E Jp Bm1k-Ret

. LSTOFF

Références

Documents relatifs

The ATmega32 provides the following features: 32K bytes of In-System Programmable Flash Program memory with Read-While-Write capabilities, 1024 bytes EEPROM, 2K byte SRAM, 32

In ATmega103 compatibility mode, the first 4,096 data memory locations address both the Register File, the I/O memory and the internal data SRAM.. The first 32 locations address

The AT89C2051 provides the following standard features: 2K Bytes of Flash, 128 bytes of RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture,

The corresponding interrupt (at vector $003) is executed if a compare match in Timer/Counter2 occurs (i.e., when the OCF2 bit is set in the Timer/Counter Interrupt Flag

Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR).. In

There is no need to perform the Chip Erase operation to reprogram any memory location in the serial programming mode unless any of the lock bits have been programmed. In the

2. I/O Registers within the address range 0x00 - 0x1F are directly bit-accessible using the SBI and CBI instructions. In these registers, the value of single bits can be checked

When the SM[1:0] bits are written to 01, the SLEEP instruction makes the MCU enter ADC Noise Reduction mode, stopping the CPU but allowing the ADC, the external interrupts, and