1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Bài tập Kỹ thuật vi xử lý - DTVT - BKDN (bài04)

2 30 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 2
Dung lượng 50 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Bài tập Kỹ thuật vi xử lý - DTVT - BKDN

Trang 1

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

1 (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: label: rla.w r4 0x800c: jne label

2 (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”.)

0x8014: TOM mov.w TOM,BOB

BOB

3 (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

1 MOV.W

#WDTPW+WDTHOLD,&WDTCTL Phải dừng chế độ WATCHDOG trước rồi mới cho hoạt động ở chế độ INTERVAL TIMER

2 bic.w #CPUOFF, SR ; Exit LPM0

3 bis.b #0x01,&P1DIR; set P1.0 làm ouput

0x4090 FFFE 0002 Note: x(PC)=TOM

Or BOB

Trang 2

4 (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 sqrtFunc

mov r0,result ;save

result: word 0

sqrtFun:

push r4

push r5

… ; calculate square root

mov r6,r0 ; return results in R0

pop r4

pop r5

ret

5 (3 points) What is the difference between PC-relative and register-indexed addressing

modes? How are they the same? How do they differ?

- Khác:

+ PC relative: ADDR cho phép truy cập một địa chỉ cụ thể thông qua nhãn của nó + Indexed mode: x(Rn) truy cập địa chỉ (x+Rn)

- Giống: PC relative là trường hợp đặc biệt của Indexed mode

ADDR  - x(PC) với x = ADDR -PC

6 (3 points) The MSP430 ISA uses only 1 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

1 Call #sqrtFunc thiếu #

2 sqrtFun: -> sqrtFunc:

3 push r4 push r5

Pop r5 Pop r4

4 mov r6, r0 sai, phải dung thanh ghi khác để tránh sai địa chỉ PC

Ngày đăng: 06/09/2021, 17:29

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w