Mercurial > public > hwos_code
comparison src/math.asm @ 628:cd58f7fc86db
3.05 stable work
author | heinrichsweikamp |
---|---|
date | Thu, 19 Sep 2019 12:01:29 +0200 |
parents | c40025d8e750 |
children | 4050675965ea |
comparison
equal
deleted
inserted
replaced
627:bf5fee575701 | 628:cd58f7fc86db |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File math.asm combined next generation V3.03.2 | 3 ; File math.asm combined next generation V3.04.3 |
4 ; | 4 ; |
5 ; Math subroutines | 5 ; Math subroutines |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
50 rlcf divA+0,F ; rotate left low byte, carry into LSB, MSB into carry | 50 rlcf divA+0,F ; rotate left low byte, carry into LSB, MSB into carry |
51 rlcf divA+1,F ; rotate left high byte, carry into LSB, MSB into carry | 51 rlcf divA+1,F ; rotate left high byte, carry into LSB, MSB into carry |
52 decfsz WREG ; decrement counter, done? | 52 decfsz WREG ; decrement counter, done? |
53 bra mult16 ; NO - loop | 53 bra mult16 ; NO - loop |
54 return ; YES - done | 54 return ; YES - done |
55 | |
56 | |
57 global addU16 ; ; sub_c:2 = sub_a:2 + sub_b:2 with USIGNED values | |
58 ; trashes WREG | |
59 addU16: | |
60 movf sub_a+0,W ; get 1st summand (low byte) to WREG | |
61 addwf sub_b+0,W ; add 2nd summand (low byte) and store result in WREG | |
62 movwf sub_c+0 ; copy result (low byte) to sub_c | |
63 movf sub_a+1,W ; get 1st summand (high byte) to WREG | |
64 addwfc sub_b+1,W ; add 2nd summand (high byte) and store result in WREG | |
65 movwf sub_c+1 ; copy result (high byte) to sub_c | |
66 return ; done | |
55 | 67 |
56 | 68 |
57 global sub16 ; sub_c:2 = sub_a:2 - sub_b:2 with SIGNED values | 69 global sub16 ; sub_c:2 = sub_a:2 - sub_b:2 with SIGNED values |
58 ; sets neg_flag if result is < 0 | 70 ; sets neg_flag if result is < 0 |
59 ; trashes WREG | 71 ; trashes WREG |