













































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Review study guide and cheat sheet on Assembly Language Programming
Typology: Cheat Sheet
1 / 53
This page cannot be seen from the preview
Don't miss anything!
;******************************************************************************* ; CS/ECEn 124 Example Code ;******************************************************************************* .cdecls C,LIST, "msp430x22x4.h“ ; include C header COUNT .equ 2000 ;------------------------------------------------------------------------------ .bss cnt,2 ; ISR counter ;------------------------------------------------------------------------------ .text ; Program reset RESET: mov.w #0x0280,SP ; Initialize stack pointer mov.w #WDT_MDLY_0_5,&WDTCTL ; Set Watchdog interval to ~0.5ms bis.w #LPM0+GIE,SR ; Enter LPM0 w/ interrupt jmp $ ; Loop forever; interrupts do all .sect ".reset" ; MSP430 RESET Vector .word RESET ; Power Up ISR .end Directives
;******************************************************************************* ; CS/ECEn 124 Lab 4 - morse.asm: Student Code ;******************************************************************************* .cdecls C,LIST, "msp430x22x4.h“ ; include C header COUNT .equ 2000 ;------------------------------------------------------------------------------ .data ; data .bss cnt,2 ; ISR counter ;------------------------------------------------------------------------------ .text ; Program reset RESET: mov.w #0x0280,SP ; Initialize stack pointer mov.w #WDT_MDLY_0_5,&WDTCTL ; Set Watchdog interval to ~0.5ms mov.b #WDTIE,&IE1 ; Enable WDT interrupt bis.b #0x01,&P1DIR ; P1.0 output bis.b #0x20,&P4DIR ; P4.0 output mov.w #COUNT,&cnt ; initialize counter bis.w #LPM0+GIE,SR ; Enter LPM0 w/ interrupt jmp $ ; Loop forever; interrupts do all ; Watchdog Timer interrupt service routine ; WDT_ISR: xor.b #0x20,&P4OUT ; pulse buzzer dec.w &cnt ; decrement counter jne WDT_exit mov.w #COUNT,&cnt ; initialize counter xor.b #0x01,&P1OUT ; toggle P1. WDT_exit: reti ; return from interrupt .sect ".int10" ; MSP430 RESET Vector .word WDT_ISR ; Watchdog ISR .sect ".reset" ; MSP430 RESET Vector .word RESET ; Power Up ISR .end Labels Instructions Comments Directives
n This register always points to the next instruction to be fetched
n The MSP430 CPU stores the return address of routines or interrupts on the stack n User programs store local data on the stack
n The status of the MSP430 CPU is defined by a set of bits contained in register R
Examples MOV.w #0x08,R5! !; move source to destination! !! !; assign a hexadecimal value 0x08 to Register R5! AND.w #0x00,R6! !; bitwise AND source with destination! !! !; whatever value in R6 is ANDed with 0 -> R6=0! ADD.w #0x03,R6! !; add source to destination! !! !; R6 = R6+3 = 0+3 = 3! SUB.w !R6, R5! !; subtract source from destination! !! !; R5 = R5-R6 = R5+(Not R6)+1 = 8-3 = 5! XOR.w !R6, R5! !; bitwise XOR source with destination! !! !; R5 = 0011 XOR 0101 = 0110 = 6! BIC.w !#0x03, R5 !; clear bits in destination! !! !; (Not 0011) AND 0110 = 1100 AND 0110 = 0100 = 4! BIS.w !#0x08, R5 !; set bits in destination! !! !; 1000 OR 0100 = 1100 = 12! BIT.w !#0x08, R5 !; test bits in destination! !! !; 1000 AND 1100 = 1000 -> Bit 3 is not zero! CMP.w !R6, R5! !; compare source to destination! !! !; R5-R6 = 12-6 = 6 greater than 0, so R5 > R6! 19
Format II: 7 Single Operand Instructions l Single operand instructions:
20