Bài tập Kỹ thuật vi xử lý - DTVT - BKDN
Homework #4 Interrupts (Ch 6), eZ430X (Ch 7), ISA (Ch 8) In order to automate the grading process, please follow the exact instruction when answer the questions and don’t use extra or unnecessary words (4 points) An assembly language program contains the following two instructions After assembly is completed, what is in memory locations 0x800a and 0x800c? (Give your answer in hexadecimal with “0x”.) 0x800A: 0x5044 0x800a: label: rla.w r4 0x800C: 0x23FE 0x800c: jne label (6 points) Assemble the following MSP430 assembly instructions The label TOM is located at address 0x8014 After assembly is completed, what is in memory locations 0x8014, 0x8016, and 0x8018? (Give your answer in hexadecimal with “0x”.) 0x4090 FFFE 0002 Note: x(PC)=TOM 0x8014: TOM mov.w TOM,BOB Or BOB BOB (6 points) Identify three problems in the following assembly program How would you fix the problems? (to Identify the problems and change or add instructions fix them.) cdecls C,LIST,"msp430x22x4.h" ; -.text ; Code ; -; Set WDT ~27ms interval timer ; and enable interrupts RESET: mov.w #0x0300,SP ; Set stack mov.w #WDT_MDLY_32,&WDTCTL bis.b #WDTIE,&IE1 ; ; turn CPU off and enable interrupts ; Mainloop: bis.w #CPUOFF+GIE,SR xor.b #001h,&P1OUT ; Toggle P1.0 jmp Mainloop ; ; -; exit low power mode on WD WDT_ISR: bic.w #CPUOFF,2(SP) ; Exit LPM0 ret ; -; Interrupt Vectors sect ".reset" ; RESET Vector word RESET sect ".int10" ; WDT Vector word WDT_ISR BYU, ECEn/CS 124 Homework #4 MOV.W #WDTPW+WDTHOLD,&WDTCTL Phải dừng chế độ WATCHDOG trước cho hoạt động chế độ INTERVAL TIMER bic.w #CPUOFF, SR ; Exit LPM0 bis.b #0x01,&P1DIR; set P1.0 làm ouput (8 points) Identify four problems in the following assembly program How would you fix the problems? (Identify the problems and change or add instructions to fix them.) call mov … sqrtFunc r0,result ;save result: word sqrtFun: push push … mov pop pop ret r4 r5 r6,r0 ; calculate square root ; return results in R0 Call #sqrtFunc thiếu # sqrtFun: -> sqrtFunc: push r4 push r5 Pop r5 Pop r4 mov r6, r0 sai, phải dung ghi khác để tránh sai địa PC r4 r5 (3 points) What is the difference between PC-relative and register-indexed addressing modes? How are they the same? How they differ? - Khác: + PC relative: ADDR cho phép truy cập địa cụ thể thơng qua nhãn + Indexed mode: x(Rn) truy cập địa (x+Rn) Giống: PC relative trường hợp đặc biệt Indexed mode ADDR - x(PC) với x = ADDR -PC (3 points) The MSP430 ISA uses only bit for selecting the destination address mode There are four destination addressing modes Which two registers are used to uniquely represent the symbolic and absolute addressing modes? (write the answer without an “and” in between, e.g., R7 R8)? R0, R2 BYU, ECEn/CS 124 Homework #4