Tải bản đầy đủ (.doc) (2 trang)

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

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (65.2 KB, 2 trang )

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:
0x5044
0x800a: label: rla.w r4
0x800C:
0x23FE
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”.)
0x4090 FFFE 0002
Note: x(PC)=TOM
0x8014: TOM mov.w TOM,BOB
Or 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

BYU, ECEn/CS 124

1.

2.
3.

Homework #4

MOV.W
#WDTPW+WDTHOLD,&WDTCTL
Phải dừng chế độ WATCHDOG trước rồi
mới cho hoạt động ở chế độ INTERVAL
TIMER
bic.w #CPUOFF, SR ; Exit LPM0
bis.b #0x01,&P1DIR; set P1.0 làm ouput


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
mov


sqrtFunc
r0,result

;save

result: .word 0
sqrtFun:
push
push

mov
pop
pop
ret

r4
r5
r6,r0

; calculate square root
; return results in R0

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

r4
r5

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

BYU, ECEn/CS 124

Homework #4




×