/[projet1]/public/pc/tools/osdk/main/Osdk/_final_/lib/mult32.s
Defence Force logotype

Contents of /public/pc/tools/osdk/main/Osdk/_final_/lib/mult32.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 781 - (show annotations)
Sat Jan 21 22:33:21 2012 UTC (7 years, 9 months ago) by dbug
File size: 1632 byte(s)
Updated the depot with the source code of the OSDK 0.019
1
2 ; unsigned 32 bit multiply with 64 bit product
3 ; tmp0/1 x tmp2/3 -> tmp4/5/6/6/7
4 mul32u
5 .(
6 lda #$00
7 sta tmp4+4 ;Clear upper half of
8 sta tmp4+5 ;product
9 sta tmp4+6
10 sta tmp4+7
11 ldx #32 ;Set binary count to 32
12 SHIFT_R
13 lsr tmp0+3 ;Shift multiplyer right
14 ror tmp0+2
15 ror tmp0+1
16 ror tmp0
17 bcc ROTATE_R ;Go rotate right if c = 0
18 lda tmp4+4 ;Get upper half of product
19 clc ; and add multiplicand to
20 adc tmp2 ; it
21 sta tmp4+4
22 lda tmp4+5
23 adc tmp2+1
24 sta tmp4+5
25 lda tmp4+6
26 adc tmp2+2
27 sta tmp4+6
28 lda tmp4+7
29 adc tmp2+3
30 ROTATE_R
31 ror ;Rotate partial product
32 sta tmp4+7 ; right
33 ror tmp4+6
34 ror tmp4+5
35 ror tmp4+4
36 ror tmp4+3
37 ror tmp4+2
38 ror tmp4+1
39 ror tmp4+0
40 dex ;Decrement bit count and
41 bne SHIFT_R ; loop until 32 bits are
42 ;clc ; done
43 ;lda MULXP1 ;Add dps and put sum in MULXP2
44 ;adc MULXP2
45 ;sta MULXP2
46 rts
47 .)
48
49
50 /*
51 int rand(void)
52 {
53 return( ((_holdrand = _holdrand * 214013L + 2531011L) >> 16) & 0x7fff );
54 }
55 */
56
57 _randseedLow .byt 0,0
58 _randseedTop .byt 0,0
59
60 _rand32
61 ;jmp _pcrand
62 .(
63 ; Left side, old seed
64 lda _randseedLow+0
65 sta tmp0+0
66 lda _randseedLow+1
67 sta tmp0+1
68 lda _randseedLow+2
69 sta tmp0+2
70 lda _randseedLow+3
71 sta tmp0+3
72
73 ; Righ side, 214013 -> $00 03 43 FD
74 lda #$FD
75 sta tmp2+0
76 lda #$43
77 sta tmp2+1
78 lda #$03
79 sta tmp2+2
80 lda #$00
81 sta tmp2+3
82
83 ; Multiply
84 ; Result in tmp4/5/6/6/7
85 jsr mul32u
86
87 ; Add 2531011 -> $00 26 9E C3
88 clc
89 lda tmp4+0
90 adc #$C3
91 sta _randseedLow+0
92 lda tmp4+1
93 adc #$9E
94 sta _randseedLow+1
95 lda tmp4+2
96 adc #$26
97 sta _randseedLow+2
98 lda tmp4+3
99 adc #$00
100 sta _randseedLow+3
101
102 rts
103 .)
104
105
106

  ViewVC Help
Powered by ViewVC 1.1.26