Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/math.asm @ 344:797e2ac42d24 ScreenDump
MERGE with 1.91 main trunk.
author | JeanDo |
---|---|
date | Sat, 21 May 2011 14:48:07 +0200 |
parents | 06299199dfb9 |
children | cec312042b94 |
comparison
equal
deleted
inserted
replaced
337:6bdf80d7276c | 344:797e2ac42d24 |
---|---|
51 subwf sub_a+0, W ; Do the High Byte | 51 subwf sub_a+0, W ; Do the High Byte |
52 movwf sub_c+0 | 52 movwf sub_c+0 |
53 movf sub_b+1, W ; Get the Value to be Subbed | 53 movf sub_b+1, W ; Get the Value to be Subbed |
54 subwfb sub_a+1, W | 54 subwfb sub_a+1, W |
55 movwf sub_c+1 | 55 movwf sub_c+1 |
56 | |
56 btfsc STATUS,C | 57 btfsc STATUS,C |
57 return ; result positve | 58 return ; result positve |
58 ; sub_c = sub_a - sub_b | 59 |
59 bsf neg_flag ; result negative | 60 bsf neg_flag ; result negative |
60 movff sub_c+0,sub_b+0 | 61 |
61 movff sub_c+1,sub_b+1 | 62 comf sub_c+1 ; 16bit sign change. |
62 setf sub_a | 63 negf sub_c+0 |
63 setf sub_a+1 | 64 btfsc STATUS,C ; Carry to propagate ? |
64 movf sub_b+0, W ; Get Value to be subtracted | 65 incf sub_c+1,F ; YES: do it. |
65 subwf sub_a+0, W ; Do the High Byte | 66 |
66 movwf sub_c+0 | |
67 movf sub_b+1, W ; Get the Value to be Subbed | |
68 subwfb sub_a+1, W | |
69 movwf sub_c+1 | |
70 return | 67 return |
71 | |
72 | 68 |
73 mult16x16: ;xA*xB=xC | 69 mult16x16: ;xA*xB=xC |
74 clrf xC+2 ; Clear the High-Order Bits | 70 clrf xC+2 ; Clear the High-Order Bits |
75 clrf xC+3 | 71 clrf xC+3 |
76 movf xA, w ; Do the "L" Multiplication first | 72 movf xA, w ; Do the "L" Multiplication first |