-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx2Mod1.asm
More file actions
78 lines (63 loc) · 2.4 KB
/
Ex2Mod1.asm
File metadata and controls
78 lines (63 loc) · 2.4 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
;-------------------------------------------------------------------------------
.def RESET ; Export program entry-point to
; make it known to linker.
;-------------------------------------------------------------------------------
.text ; Assemble into program memory.
.retain ; Override ELF conditional linking
; and retain current section.
.retainrefs ; And retain any sections that have
; references to current section.
;-------------------------------------------------------------------------------
RESET mov.w #__STACK_END,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
mov #vetor, R5
call #MAIOR16
jmp $
MAIOR16:
mov @R5+,R9
mov #0,R7
mov @R5,R6
jmp LOOP
ret
LOOP:
dec R9
jn END
mov @R5+,R8
cmp R8,R6
jn SWAP
jz EQUAL
jmp LOOP
ret
SWAP:
mov R8,R6
mov #1,R7
jmp LOOP
ret
EQUAL:
inc R7
jmp LOOP
ret
END:
ret
.data
.retain
vetor: .byte 6,0, "JOAQUIMJOSE",0
;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET