Getting Started with the TExaS Simulator
“There is no reason anyone would want a computer in their home. ”
Ken Olson, president,, chairman and founder of Digital Equipment Corporation, 1977
Quiz 1 review
closed book, no calculator
Lectures 1-11
Online HW1-3
Labs 1 and 2
1) Definitions (matching or multiple choice)
volatile, nonvolatile, RAM, ROM, port
static efficiency, dynamic efficiency
structured program, call graph, data flow graph
basis, nibble, precision, decimal digits (see table below)
fixed-point, overflow, ceiling and floor, drop out,
bus, address bus, data bus,
memory-mapped, I/O mapped
bus cycle, read cycle, write cycle,
IR, EAR, BIU, CU, ALU, registers,
device driver, reset vector
friendly, mask, toggle,
22 = 4
23 = 8
24 = 16
25 = 32
26 = 64
27 = 128
28 = 256
29 = 512
210 = 1024≈ 103
211 = 2048
212 = 4096
213 = 8192
214 = 16384
215 = 32768
216 = 65536
162 = 256
163 = 4096
164 = 65536
|decimal digits |exact range |exact alternatives |approximate bits |
|3 |0 to 999 |1,000 |≈ 10 |
|3½ |0 to 1999 |2,000 |≈ 11 |
|3¾ |0 to 3999 |4,000 |≈ 12 |
|4 |0 to 9999 |10,000 |≈ 13 |
|4½ |0 to 19,999 |20,000 |≈ 14 |
|4¾ |0 to 39,999 |40,000 |≈ 15 |
|5 |0 to 99,999 |100,000 |≈ 17 |
|5½ |0 to 199,999 |200,000 |≈ 18 |
|5¾ |0 to 399,999 |400,000 |≈ 19 |
|6 |0 to 999,999 |1,000,000 |≈ 20 |
|6½ |0 to 199,999 |2,000,000 |≈ 21 |
|6¾ |0 to 3,999,999 |4,000,000 |≈ 22 |
|N |0 to 10N-1 |10N |≈ N*log2(10) |
|N½ |0 to 2*10N-1 |2*10N |≈ N*log2(10)+1 |
|N¾ |0 to 4*10N-1 |4*10N |≈ N*log2(10)+2 |
Table 2.2. Standard definition of decimal digits.
2) 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
I won’t ask you to convert signed binary or signed hex:
signed binary e.g., -%00101111
signed hexadecimal e.g., -$2F
fixed-point representations
given resolution convert between value and integer
given precision and range choose the fixed-point format
3) Details of executing single instructions
8-bit addition, subtraction yielding result, N, Z, V, C
(like HW2, HW3)
simplified cycle by cycle execution
assembly listing to execution cycles (Lab 3.6)
for indexed mode addresses, for example
ldaa 4,x
ldaa 40,x
ldaa -4,x
ldaa -40,x
ldaa $400,x
ldaa 4,+x
ldaa 4,-x
ldaa 4,x+
ldaa 4,x-
calculate effective address
go from assembly to machine code xb
go from machine code xb to assembly
simple multiply and divide (mul idiv fdiv)
stack functions for bsr and rts
4) Simple programs (look at assembly code in Chap 1,2,3)
initialize stack
create global variables
set reset vector
specify an I/O pin is an input
specify an I/O pin is an output
clear an I/O output pin to zero
set an I/O output pin to one
toggle an I/O output pin
check if an I/O input pin is high or low
e.g., if PA4 is low then make PB2 high
8-bit operations
add, sub, shift left, shift right, and, or, eor
simple if-then like examples in Chapter 3
no if-then-else
no if((uG1>5)&&(uG2 Threshold){ | ldab PTT |
|♪♫♪♫♫ |cmpb Threshold |
|} |bls next |
| |♪♫♪♫♫ |
| |next |
|if(PTT >= Threshold){ | ldab PTT |
|♪♫♪♫♫ |cmpb Threshold |
|} |blo next |
| |♪♫♪♫♫ |
| |next |
|if(PTT < Threshold){ | ldab PTT |
|♪♫♪♫♫ |cmpb Threshold |
|} |bhs next |
| |♪♫♪♫♫ |
| |next |
|if(PTT = 5){ |cmpa #5 |
|♪♫♪♫♫ |blo next |
|} |♪♫♪♫♫ |
| |next |
| | ldaa sG |
|if(sG >= 5){ |cmpa #5 |
|♪♫♪♫♫ |blt next |
|} |♪♫♪♫♫ |
| |next |
Compare 8-bit versus 16-bit conditionals
Assume uG1 and uG2 are unsigned 8-bit variables
Assume uH1 and uH2 are unsigned 16-bit variables
|C code |assembly code |
| | ldaa uG2 |
|if(uG2 >= uG1){ |cmpa uG1 |
|♪♫♪♫♫ |blo next |
|} |♪♫♪♫♫ |
| |next |
| | ldd uH2 |
|if(uH2 >= uH1){ |cpd uH1 |
|♪♫♪♫♫ |blo next |
|} |♪♫♪♫♫ |
| |next |
for(uG=0;uG=5
♪♫♪♫♫ ; body of while loop
inc uG
bra loop
next
for(i=0;i=5
loop
♪♫♪♫♫ ; body of while loop
bra loop
Problem: write code that waits for a switch to be pressed. Assume PM3 is an input with a switch attached.
“640K ought to be enough for anybody. ”
Bill Gates, 1981
4. Assembly Language Programming
Chapter 4 objectives are to:
• Present an introduction to product development,
• Discuss the TExaS editor and assembler,
• Basic approach to assembly language programming,
• Define the pseudo-ops supported by TExaS.
4.1.1. Assembly language development
• editor
• source code
• assembler
• crossassembler
• object code
• loader
• debugger
[pic]
Figure 4.1. Assembly language development process.
The first pass
check for syntax errors
size of each line of object code
create the symbol table
The second pass
check for syntax errors, errors reported in listing file
create object code, S19 file if needed for real 6812
recreate the symbol table, phasing error if different
put object code, details and source into listing file
add symbol table to the end of the listing file
A symbol table is a mapping between symbolic names
PTT equals $0240
The actual object code is in bold face.
S121F000CF0C00180B8000024D008018030FA008009600847FB1F033260EFE0800091F
S119F01E7E080026EE4C008020E918030FA008004D008020DE23A9
S105FFFEF0000D
S903F0000C
Errors that occur during the assembly process
1) Label previously defined error: label occurs multiple times
2) Undefined opcode error: operation does not exist
3) Operand error: syntax error within the operand
expression error
undefined symbol in expression
addressing mode error
size of allocated storage too big, e.g., ds 100*1000
4) Phasing error: value of symbol changes from pass1 to pass2
5) Can't program address error
6) Branch too far error: destination address is too far away
7) Illegal string termination: e.g., "Hello World!
4.4.9. Assembler pseudo-ops
Pseudo-ops are specific commands to the assembler
or assembly directive
|A |B |C |Meaning |
|org |org |.org |Specific absolute address to put subsequent object code |
|= |equ | |Define a constant symbol |
| |set | |Define or redefine a constant symbol |
|dc.b db |fcb |.byte |Allocate byte(s) of storage with initialized values |
| |fcc | |Create an ASCII string (no termination character) |
|dc.w dw |fdb |.word |Allocate word(s) of storage with initialized values |
|dc.l dl | |.long |Allocate 32-bit long word(s) of storage with initialized values |
|ds ds.b |rmb |.blkb |Allocate bytes of storage without initialization |
|ds.w | |.blkw |Allocate bytes of storage without initialization |
|ds.l | |.blkl |Allocate 32-bit words of storage without initialization |
|end |end |.end |Signifies the end of the source code (TExaS ignores these) |
Table 4.8. Assembly directives supported by TExaS.
Equate symbol to a value
equ ()
= ()
|; 9S12C32 |
|org $3800 |
|size equ 5 |
|data rmb size |
|org $4000 |
|sum ldaa #size |
|ldx #data |
|clrb |
|loop addb 1,x+ |
|dbne A,loop |
|rts |
Program 4.3. A constant implemented with equ might make the program easier to change.
; ********** port12.rtf ****************
ATDDIEN equ 0x008D ; ATD Input Enable
DDRAD equ 0x0272 ; Port AD Data
DDRM equ 0x0252 ; Port M Direction
DDRT equ 0x0242 ; Port T Direction
PTAD equ 0x0270 ; Port AD I/O Register
PTM equ 0x0250 ; Port M I/O Register
PTT equ 0x0240 ; Port T I/O Register
Programming tip: Use equ definitions only if it makes the program easier to understand, to debug, or to change.
Redefinable equate symbol to a value
set ()
More information about local variables in Chapter 8.
|; 6812 |
|; *****binding phase************* |
|I set 0 |
|J set 1 |
|; ******allocation phase ******** |
|function |
|leas –2,sp allocate I,J |
|; ********access phase ********** |
|clr I,sp Clear I |
|ldab I,sp Reg B is copy of I |
|staa J,sp store into J |
|; ********deallocation phase ***** |
|leas 2,sp deallocate J,I |
|rts |
Program 4.4. Simple functions with local variables using set.
Form constant byte
() fcb (,,...,)
() dc.b (,,...,)
() db (,,...,)
() .byte (,,...,)
str1 fcb "Hello World",0
str2 fcb ‘Hello World’,0
str3 fcb \Hello World\,0
Form constant character string
() fcc
\
LABEL1 FCC 'ABC'
LABEL2 fcc "Jon Valvano "
LABEL4 fcc \Welcome to FunCity!\
The ASCII string generated by fcc is not null-terminated, so if a termination is needed, you must add it explicitly using either
Strg1 fcc "happy"
fcb 0
or
Strg2 fcb "happy",0
Form double byte
() fdb (,,...,)
() dc.w (,,...,)
() dw (,,...,)
() .word (,,...,)
org $FFFE
fdb main
Define 32-bit constant
() dc.l (,,...,)
() dl (,,...,)
() .long (,,...,)
S1 dl 100000,$12345678
S2 .long 1,1000,1000000,1000000000
S3 dc.l -1,0,1
Set program counter origin
org ()
.org ()
Reserve multiple bytes
() rmb ()
() ds ()
() ds.b ()
() .blkb ()
Checkpoint 4.8: Why can’t you use a forward reference in a rmb directive?
Reserve multiple words
() ds.w ()
() .blkw ()
ds.l Reserve multiple 32-bit words
() ds.l ()
() .blkl ()
End of program (optional)
end ()
.end ()
|; 9S12C32 |
|size equ 4 |
|DDRT equ $0242 ; Port T Direction |
|PTT equ $0240 ; PT3-PT0 to stepper |
| |
|org $3800 ;RAM |
|Count ds 1 |
|Angle ds 2 ;resolution 0.1 deg |
|org $4000 |
|main movb #$FF,DDRT ;PT3-PT0 outputs |
|movw #0,Angle ;0 deg |
|run movb #size,Count |
|ldx #steps |
|step movb 1,x+,PTT ;step the motor |
|ldd Angle ;0 to 358.2 deg |
|addd #18 ;step 1.8 deg |
|cpd #3600 ;full rotation? |
|bne skip |
|ldd #0 ;back to beginning |
|skip std Angle |
|dec Count ;4,3,2,1 |
|bne step |
|bra run |
|steps fcb 5,6,10,9 ;output sequence |
|org $FFFE |
|fdb main |
Program 4.5. A stepper motor controller using fcb.
Start TExaS
New program, microcomputer, IO,
Add Angle, Count to Viewbox
copy, paste Program 4.5
add robot car PT0 to left wheel, PT4 to right wheel
Tire circumference to 4π=25.13272
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- getting started in mutual funds
- getting started with minecraft
- getting started with minecraft pi
- getting started with mutual funds
- minecraft getting started guide
- getting started in minecraft xbox
- getting started with amazon fba
- salesforce getting started workbook
- getting started in minecraft
- salesforce getting started guide
- getting started with youtube
- getting started on ebay selling