You are on page 1of 3

B mn: C in T Khoa: C kh Mn: Lp: Ngy thi: Thi gian:

P N GIA HK II/10-11
K THUT VI X L CK07CTM1 08/04/2011 60 pht (Sinh vin C s dng ti liu)

Cu 1) (2 im)
8 bits c s dng hin thc s nguyn c du theo 3 cch l twos complement, 8-bit signed magnitude v 8-bit excess 128. in cc mu 8 bits tng ng vo bng sau. Signed Integer +5 +4 -4 -5 Twos Complement 0000 0101 0000 0100 1111 1100 1111 1011 8-bit Signed Magnitude 0000 0101 0000 0100 1000 0100 1000 0101 8-bit Excess 128 1000 0101 1000 0100 0111 1100 0111 1011

Cu 2) (3 im)
From

Address To 00 7FFFH 41 FFFFH 80 0000H 80 0001H 00 0000H 40 0000H 80 0000H 80 0001H

Device ROM RAM I/O 0 I/O 1

Gi s mch gii m s dng ROM 32K bytes, RAM 128K bytes, 2 I/O devices v IC gii m 74LS139. Hy in tm a ch ca cc thit b vo bng bn v thit k mch gii m.

Cu 3) (2 im)
Hy gii thch ti sao on chng trnh PIC 16F877 sau chy ng 1ms (Tn s xung clock l 4Mhz). Gi : Chy tng bc v xc nh s chu k my. Cho bit: Hu ht cc lnh ca PIC (khng lm thay i thanh ghi PC) u mt 1 chu k my thi hnh, cn cc lnh r nhnh (thay i thanh ghi PC) nh GOTO, CALL, RETURN, RETLW, RETFIE th mt 2 chu k my.

cblock 0x20 count1 counta countb endc

; khai bo cc bin ; Gi tr ca bin count1 c lu nh c a ch 0x20 ; Gi tr ca bin counta c lu nh c a ch 0x21 ; Gi tr ca bin countb c lu nh c a ch 0x22

Delay d1

Delay_0

movlw movwf movlw movwf movlw movwf decfsz goto decfsz goto decfsz goto retlw

d'1' count1 0xC7 counta 0x01 countb counta, 1 $+2 countb, 1 Delay_0 count1 ,1 d1 0x00

; delay 1 ms (4 MHz clock)

p n:
Ta c:

Tcycle 4 Tclk 4

1 1s 4 10 6

Do counta = 0xc7=199, nn vng lp c nhn Delay_0 chy 198 ln, mi ln mt 5 chu k my, ngha l mt 198 x 5 = 990s. 6 lnh (mi lnh 1 chu k my) t nhn Delay n nhn Delay_0 gn cc gi tr cho cc bin count1, counta, countb ngha l mt 6s. Cc Lnh decfsz counta, 1; decfsz countb, 1; decfsz count1,1; lnh retlw 0x00 (hoc goto d1) mt 8 chu k my, ngha l mt 8s.

Nh vy, on code trn s chy mt 1004s.

Cu 4) (3 im)
Cho mch in nh hnh v. Hy vit on chng trnh bng ngn ng assembly c cc gi tr nhp vo t cc nt nhn portB v xut ra cc led tng ng portC. Gi : S dng lnh movf PORTB, W c cc nt nhn.

p n:
list p = 16f877 include p16f877.inc org nop banksel movlw movwf banksel movlw movwf movlw movwf banksel main movf movwf main PORTB, W PORTC ; a input t cc nt nhn vo thanh ghi W ; Xut ra cc leds ; lp li vng loop main 0x0000 PORTC b00000000 PORTC TRISC b00000000 TRISC b11111111 TRISB PORTC ; Chng trnh bt u a ch 0x0000. ; chn bank 0 ; reset portc ; chn bank 1 ; portc l cc ng xut ; portb l cc ng nhp ; chn bank 0

goto end