-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCM.ewp
More file actions
61 lines (55 loc) · 1.5 KB
/
LCM.ewp
File metadata and controls
61 lines (55 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "msp430.h" ; #define controlled include file
ORG 0X3010
DW 0X0005
DW 0X0006
NAME main ; module name
PUBLIC main ; make the main label vissible
; outside this module
ORG 0FFFEh
DC16 init ; set reset vector to 'init' label
RSEG CSTACK ; pre-declaration of segment
RSEG CODE ; place program in 'CODE' segment
init: MOV #SFE(CSTACK), SP ; set up stack
main: NOP ; main program
MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
CLR R4
MOV #0X3010,R5
MOV @R5,R7
MOV R7,R13
INC R5
INC R5
MOV @R5,R8
MOV R8,R14
CMP R7,R8
JC l1
l1: MOV R7,R8
MOV @R5,R7
BACK: CALL #DIV
TST R8
JZ FINAL
MOV R7,R10
MOV R8,R7
MOV R10,R8
JMP BACK
FINAL: CALL #MULT
MOV R14,R8
CALL #DIV
MOV R6,0X3040(R4);HAS LCM AND R7 HAS HCF
JMP $
DIV: CLR R6
L2: SUB R7,R8
ADD #0001H,R6
CMP R7,R8
JN L3
JMP L2
L3: RET
MULT: MOV R13,R12
MOV R14,R11
BACK1: DEC R13
JZ END1
ADD R11,R1 ;MOV R14,R8
MOV R14,0X3030(R4)
JMP BACK1
END1: RET
END
JMP $