Getting Started with the TExaS Simulator

advertisement
Introduction to Embedded Microcomputer Systems
Lecture 24.1
“But what’s it good for? ”
Engineer at the Advanced Computing Systems Division at IBM,
commenting on the microchip 1968
Quiz 3 solutions
(5) Question 1. The measurement system range is 0 to 1999. How many decimal
digits is it?
2000 alternatives is 3½ decimal digits
(5) Question 1. The measurement system range is 0 to 19999. How many decimal
digits is it?
20000 alternatives is 4 ½ decimal digits
(5) Question 1. The measurement system range is 0 to 3999. How many decimal
digits is it?
4000 alternatives is 3¾ decimal digits
(5) Question 1. The measurement system range is 0 to 39999. How many decimal
digits is it?
40000 alternatives is 4¾ decimal digits
(5) Question 6.
bset
(5) Question 6.
bset
(5) Question 6.
bclr
(5) Question 6.
bclr
Write friendly assembly code that makes PORTT bit 6 an output.
DDRT,#$40
Write friendly assembly code that makes PORTT bit 6 high.
PORTT,#$40
Write friendly assembly code that makes PORTT bit 6 low.
PORTT,#$40
Write friendly assembly code that makes PORTT bit 6 an input.
DDRT,#$40
(5) Question 8. What is the effect of executing these two instructions?
pshd
pulx
Value of Reg D is copied to Reg X
(5) Question 9. A signed 16-bit binary fixed point number system has a resolution
of . What is the corresponding value of the number if the integer part stored in
memory is 2000?
value = 2000*

Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
Lecture 24.2
(5) Question 10. What is the effective address of this instruction?
$F000 EDE4
ldy A,X
Effective address is X+A
(5) Question 11. Which op code should be used in the ??? position? Unsigned.
PORTA
>100
PORTB=0
skip
ldaa
cmpa
???
clr
PORTA
#100
skip
PORTB
bls
PORTA
<100
PORTB=0
skip
ldaa
cmpa
???
clr
PORTA
#100
skip
PORTB
bhs
PORTA
>100
PORTB=0
skip
ldaa
cmpa
???
clr
PORTA
#100
skip
PORTB
blo
PORTA
<100
PORTB=0
skip
ldaa
cmpa
???
clr
PORTA
#100
skip
PORTB
bhi
(5) Question 12. Since 10 bits/frame and 1 frame/byte, bandwidth=baud rate/10
Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
Lecture 24.3
(5) Question 13. Which answer is the data flow graph for the following program?
The main program calls InChar.
RDRF
equ
$20
InChar brclr SC0SR1,#RDRF,*
ldaa SC0DRL
read ASCII character
rts
SCI input
serial port
driver
main
(5) Question 14. Consider a matrix with 4 rows and 7 columns, stored in columnmajor zero-index format. Each element is 1 byte or 8 bits. Which equation
correctly calculates the address of the element at row I and column J?
C.
base+I+4*J
(5) Question 14. Consider a matrix with 4 rows and 7 columns, stored in rowmajor zero-index format. Each element is 1 byte or 8 bits. Which equation
correctly calculates the address of the element at row I and column J?
D.
base+7*I+J
(5) Question 14. Consider a matrix with 7 rows and 4 columns, stored in rowmajor zero-index format. Each element is 1 byte or 8 bits. Which equation
correctly calculates the address of the element at row I and column J?
B.
base+4*I+J
(5) Question 14. Consider a matrix with 7 rows and 4 columns, stored in columnmajor zero-index format. Each element is 1 byte or 8 bits. Which equation
correctly calculates the address of the element at row I and column J?
E.
base+I+7*J
(5) Question 15. What digital result occurs when the
6812 ADC converts?
Dout = Dmin + (Dmax-Dmin)(Vin-Vmin)/(Vmax-Vmin)
Dout = 255*Vin/5
(5) Question 16. Give the general equation showing
LED current Id as a function of LED voltage Vd, gate
output voltage VOL, and resistance R1.
Id = (5 -Vd - VOL)/R1
Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
Lecture 24.4
(5) Question 17. Which registers are pushed by swi and pulled off by rti?
all registers but the SP
(5) Question 18. Five interpreters were presented in Tutorial 10. Assuming each
interpreter was modified to accept 26 commands, labeled A-Z, which technique
will have the fastest lookup speed?
array containing list of functions to execute
(10) Question 19. Consider the following linked list FSM
PORTA equ 0
DDRA equ 2
org $0800
pt
rmb 2
org $F000
SA
fcb 10
output
fdb SB
next state
SB
fcb 25
output
fdb SA
next state
main movw #SA,pt
loop ldx pt
movb 0,x,PORTA
ldx 1,x
stx pt
bra loop
org $FFFE
fdb main
Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
Lecture 24.5
Trap or software interrupt
Why


How:




allow binding of user/OS software
introduction to hardware interrupts
OS software is trap handler
User program calls OS program executing trap #num
any number $30-$39 or $40-$FF
trap vector is $FFF8, swi vector is $FFF6
* OS software
In
equ $30
Out
equ $31
org xxxx
Traphan
ldx 7,s
ldab -1,x trap num
cmpb #In
bne notIC
brclr SC0SR1,#$20,*
ldaa SC0DRL
input
staa 2,s
bra done
notIC cmpb #Out
bne done
brclr SC0SR1,#$80,*
staa SC0DRL output
done rti
org $FFF8
fdb Traphan
*User software
In
equ $30
Out
equ $31
main
loop
org
lds
ldaa
trap
trap
trap
bra
yyyy
#$0C00
#13
#Out
#In
#Out
loop
org
fdb
$FFFE
main
Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
before trap #$31
SP →
Lecture 24.6
after trap #$31
0BF5
0BF6
0BF7
0BF8
0BF9
0BFA
0BFB
0BFC
0BFD
0BFE
0BFF
0C00
SP → oldCC
oldB
oldA
oldX high
oldX low
oldY high
oldY low
SP+7→ oldPC high
oldPC low
Quiz3 will be similar in style to the online Homework
Quiz3 will cover material from Chapters 1,2,3,4,5,6,7,8,10.
Good things to study are
the Homework questions and solutions
the lecture notes aLec1 to aLec32
It will be closed book with about 25 short answer questions
I will give you similar technical documents as I did with Quiz1
The numerical questions will be simple enough not to require a calculator.
Mark W. Welker (From Jonathan W. Valvano)
0BF5
0BF6
0BF7
0BF8
0BF9
0BFA
0BFB
0BFC
0BFD
0BFE
0BFF
0C00
Introduction to Embedded Microcomputer Systems
Quiz 3 review
Number conversions, 8-bit (fill in the blank)
convert one format to another without a calculator
signed decimal
e.g., -56
unsigned decimal e.g., 200
binary
e.g., %11001000
hexadecimal
e.g., $C8
volatile, nonvolatile
static efficiency, dynamic efficiency
structured program, flowchart, call graph, data flow graph
basis, precision,
fixed-point,
given resolution convert between value and integer
value = integer*
given precision and range choose the fixed-point format
promotion, demotion
setting N, Z, V, C after 8-bit add or subtract
overflow, ceiling and floor, drop out,
bus, address bus, data bus,
bus cycle, read cycle, write cycle,
simplified cycle by cycle execution
assembly listing to execution cycles (Lab 3.1)
machine code to execution cycles (Lab 3.4)
IR, EAR, BIU, CU, ALU, registers,
device driver,
friendly,
ldaa DDRD
oraa #$80
staa DDRD
bset DDRD,#$80
mask, toggle,
ldaa PORTD
eora #$80
staa PORTD
8-bit versus 16-bit data
reset vector
pass 1, pass 2, symbol table
Mark W. Welker (From Jonathan W. Valvano)
Lecture 24.7
Introduction to Embedded Microcomputer Systems
Lecture 24.8
direction register
baud rate, bandwidth, frame, start bit, stop bit, parity
busy-waiting, gadfly, or polling
flow chart, call graph, data flow graph
device driver
ADC 0<Vin<5 to 0<Dout<255 If Vin=2.5012345679V, then Dout =128
Straight binary format, example conversions
resolution, range, precision
Timer_Wait
addd TCNT
TCNT at end of delay
Wloop cpd TCNT
is EndT<TCNT
bpl Wloop
rts
debugging
ScanPoint, intrusiveness, monitor, profiling, dump
measuring execution time, desk check, stabilization
functional debugging, performance debugging, profiling
Real time systems, bounded latency
Finite state machine, Mealy, Moore, linked list, table
Switch/LED interfacing (LED equation)
5=I*R+Vd+Vol
Arrays and strings (address math, scanning, variable size)
Matrices (address math, scanning, fixed size)
row major, column major, bit/byte/word
Tables (address math, scanning, fixed size)
Producer/consumer problem
Multiple Access Circular Queues, FIFO queues, double buffer
Binary tree
Linked list (address math, scanning, fixed size)
Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
Lecture 24.9
scope local vs global
allocation dynamic vs permanent
local variables and parameters on the stack
S binding, X stack frame binding
binding , allocation, access, deallocation
C programming
static volatile const
call by reference, call by value
Reverse Polish Notation using a separate data stack
swi trap rti instructions
decimal digits
3
3½
3¾
4
4½
4¾
5
5½
5¾
6
6½
6¾
N
N½
N¾
exact range
0 to 999
0 to 1999
0 to 3999
0 to 9999
0 to 19,999
0 to 39,999
0 to 99,999
0 to 199,999
0 to 399,999
0 to 999,999
0 to 199,999
0 to 3,999,999
0 to 10N-1
0 to 2*10N-1
0 to 4*10N-1
exact alternatives
1,000
2,000
4,000
10,000
20,000
40,000
100,000
200,000
400,000
1,000,000
2,000,000
4,000,000
10N
2*10N
4*10N
approximate bits
≈ 10
≈ 11
≈ 12
≈ 13
≈ 14
≈ 15
≈ 17
≈ 18
≈ 19
≈ 20
≈ 21
≈ 22
≈ N*log2(10)
≈ N*log2(10)+1
≈ N*log2(10)+2
Table 2.2. Standard definition of decimal digits.
Mark W. Welker (From Jonathan W. Valvano)
Introduction to Embedded Microcomputer Systems
You get the same tables as Quiz 1
P1 set ???
P2 set ???
L1 set ???
Subroutine
leas –2,s
allocated L1
ldd P2,s
addd P1,s
std L1,s
leas 2,s
rts
Main lds #$c00
movw #1000,2,-s
movw #2000,2,-s
jsr Subroutine
leas 4,s
P1 set ???
P2 set ???
L1 set ???
Subroutine pshx
p1
p2
tsx
leas –2,s
allocated L1
ldd P2,x
addd P1,x
std L1,x
txs
pulx
Rts
Main lds #$c00
movw #1000,2,-s p1
movw #2000,2,-s p2
jsr Subroutine
leas 4,s
Mark W. Welker (From Jonathan W. Valvano)
Lecture 24.10
Download