Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22185fd

Browse files
authored
Merge pull request#408 from TG9541/onewire
Onewire and minor UM/MOD improvement
2 parents0c3dcaf +b80c180 commit22185fd

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

‎forth.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,10 +1508,10 @@ UMMOD:
15081508
CPW X,YTEMP
15091509
JRULT MMSM1 ; X is still on the R-stack
15101510
POPW X ; restore stack pointer
1511-
LDW Y,#0xFFFF ; overflow result:
1512-
LDW (X),Y ; quotient max. 16 bit value
15131511
CLRW Y
15141512
LDW (2,X),Y ; remainder 0
1513+
DECW Y
1514+
LDW (X),Y ; quotient max. 16 bit value
15151515
RET
15161516
MMSM1:
15171517
LD A,#16 ; loop count

‎inc/defconf.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
;--------------------------------------------------------
55
RELVER1 =2 ; Revision digit1
66
RELVER0 =7 ; Revision digit0
7-
PRE_REL =3 ; Pre Release digit0 (0: release)
7+
PRE_REL =0 ; Pre Release digit0 (0: release)
88

99
TERM_LINUX =1 ; LF terminates line
1010

‎lib/CRC8

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
\ STM8 eForth: CRC8 for 1-Wire protocol, polynomial x8 + x5 + x4 + 1
2+
\ refer to github.com/TG9541/stm8ef/blob/master/LICENSE.md
3+
4+
\ implementation for 1-wire protocol
5+
6+
: CRC8 ( crc c -- crc ) [ \ 1-Wire CRC8
7+
$A608 , \ LD A,#8 ; loop through 8 bits
8+
$F7 C, \ LD (X),A ; use MSB as bit counter
9+
$E601 , \ LD A,(1,X) ;
10+
$E803 , \ 1$: XOR A,(3,X) ; crc XOR c.bit0
11+
$46 C, \ RRC A ; to carry
12+
$E603 , \ LD A,(3,X) ; crc -> A
13+
$2402 , \ JRNC 0$
14+
$A818 , \ XOR A,#0x18 ; apply x5 + x4
15+
$46 C, \ 0$: RRC A ; apply x8 + 1
16+
$E703 , \ LD (3,X),A ; update crc value
17+
$6401 , \ SRL (1,X) ; next c.bit0
18+
$E601 , \ LD A,(1,X)
19+
$7A C, \ DEC (X) ; bit counter until 0
20+
$26ED , \ JRNE 1$ ; loop?
21+
$5C C, \ INCW X ; DROP
22+
$5C C, \ INCW X
23+
] ;
24+
25+
\\ Test
26+
27+
\ DALLAS MAXIM AN937 Figure 3 Example Calculation for DOW CRC
28+
HEX 0 2 CRC8 1C CRC8 B8 CRC8 1 CRC8 0 CRC8 0 CRC8 0 CRC8 . DECIMAL \ -> A2

‎lib/LSHIFT

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
\ STM8eForth : LSHIFT TG9541-210301
2+
\ refer to github.com/TG9541/stm8ef/blob/master/LICENSE.md
3+
4+
: LSHIFT ( n c - n ) \ shift n left c times
5+
[ $5C C, \ INCW X
6+
$F6 C, \ LD A,(X)
7+
$5C C, \ INCW X
8+
$4D C, \ TNZ A
9+
$2705 , \ JREQ 1$
10+
$6801 , \ 2$: SLA (1,X)
11+
$79 C, \ RLC (X)
12+
$4A C, \ DEC A
13+
$26F8 , \ JRNE 2$
14+
] \ 1$:
15+
;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp