Vous êtes sur la page 1sur 19

ST7 MICROCONTROLLER TRAINING

1. INTRODUCTION
2. CORE
3. ADRESSING MODES
4. PERIPHERALS
5. ST7 SOFTWARE TOOLS
6. ST7 HARDWARE TOOLS
7. STVD7

SOFTWARE DESCRIPTION
Source Program Format

A program is made up of lines. Each assembler line consists


of up to 4 fields
The label field: it is an identifying label
The operation field: it contains a word which specifies the action to be
performed by the assembly process
The operand field: it is constitued of quantity (number or register) on
which the operation is performed
The comment field: for any comment concerning the line

substract

sub A, #$22

; substract $22 to the value hold by A

Operand

Label

Comment
Operation

INHERENT

The OP code fully specify all required information for the cpu
to process the operation (The inherent instructions are single
byte long).

Example

RCF - Reset Carry Flag ; RSP - Reset Stack Pointer


HALT ; WFI - Low consumption modes
TRAP - Enter software interrupt
RET - Return ; IRET -Interrupt Return
SIM - Set Interrupt Mask ; RIM - Reset Interrupt Mask
PUSH A ; POP Y - Stack operation

IMMEDIATE ADDRESSING MODE


BCP A, #$FF
XOR A, #%01001110
LD X, #255
z

Example

Before Completion

A = Previous value

After Completion

LD A, #$55

A = $55

SHORT DIRECT ADDRESSING MODE

ADDRESSABLE SPACE: 00 to FF
INC variable
NEG variable
SRA variable

Example
If label is an 8 bit symbol defined as $86

Before Completion

$086

5A

After Completion

INC label

$086

5B

LONG DIRECT ADDRESSING MODE

ADDRESSABLE SPACE: 0000 to FFFF


CP Y, VARIABLE
SBC A, VARIABLE

Example
If label is an 16 bit symbol defined as $F1D6

Before Completion

After Completion
A = $CB

A = $C1
$F1D6

0A

ADD A, LABEL

NO OFFSET INDEXED ADDRESSING MODE

ADDRESSABLE SPACE: 00 to FF
CPL (X)
DEC (Y)
OR A, (X)

Example

Before Completion
X = $D4
$D4

0A

After Completion

CPL (X)

$D4

F5

SHORT INDEXED ADDRESSING MODE

ADDRESSABLE SPACE : 000 to 1FE


RRC (variable, X)
SWAP (variable, Y)

Example
If label is an 8 bit symbol defined as $90

Before Completion
X = 03 and C=1
$90
$91
$92
$93

0A
1E
F6
A8

After Completion
C=0
RRC (label, X)

$90
$91
$92
$93

0A
1E
F6
D4

LONG INDEXED ADDRESSING MODE

ADDRESSABLE SPACE: 0000 to FFFF


ADD A, (variable, Y)
XOR A, (variable, X)

Example
If label is an 16 bit symbol defined as $2E6D

Before Completion
X = 02
$2E6D
$2E6E
$2E6F
$2E70

0A
1E
2F
A8

After Completion
X = $2F

LD X, (LABEL, X)

SHORT INDIRECT ADDRESSING MODE

ADDRESSABLE SPACE: 00 to FF
TNZ [variable]
CLR [variable]

Example
If label is an 8 bit symbol defined as $4B

Before Completion

After Completion

$20

$20

4D

$4B

20

D4
SWAP [label]

$4B

20

10

LONG INDIRECT ADDRESSING MODE

ADDRESSABLE SPACE: 0000 to FFFF


ADC A, [variable.w]
BCP A, [variable.w]

Example
If label is an 8 bit symbol defined as $40

Before Completion
$40
$41

42
E5

$42E5

11

After Completion
LD A, [label.w]

A = $11

11

SHORT INDIRECT INDEXED

ADDRESSABLE SPACE: 000 to 1FE


RLC ([variable], Y)
LD X, ([variable], X)

Example
If label is an 8 bit symbol defined as $C8

Before Completion
X = 04

After Completion

$0C8

FE

$0C8

FE

$0FE
$0FF
$100
$101
$102

0A
1E
F6
A8
B3

$0FE
$0FF
$100
$101
$102

0A
1E
F6
A8
00

CLR ([label], X)

12

LONG INDIRECT INDEXED

ADDRESSABLE SPACE : 0000 to FFFF


SUB A, ([variable.w], X)
AND A, ([variable.w], Y)

Example
If label is an 8 bit symbol defined as $40

Before Completion
X = 01
$40
$41

After Completion

42
E5
LD A, ([label.w],X,)

$42E5

A = $84

11
84

13

RELATIVE ADDRESSING MODE


z

DIRECT ADDRESSABLE SPACE: PC-128 to PC+127


JRUGE label
CALLR label

.label
JRMI label

PC

INDIRECT ADDRESSABLE SPACE: PC-128 to PC+127


JRNC [label]
JRH [label]

PC
.label

40

JRMI [label]
.PC + 40

14

BIT MANIPULATION

DIRECT ADDRESSABLE SPACE: 00 to FF


variable
1 1 0 0 0 0 0 0

variable
BSET variable, #2

1 1 0 0 0 1 0 0

INDIRECT ADDRESSABLE SPACE: 00 to FF


variable = $86
$86
1 1 0 0 0 0 0 0

$86
BRES [variable], #7

0 1 0 0 0 0 0 0

15

RELATIVE JUMP ON BIT TEST

DIRECT ADDRESSABLE SPACE: 00 to FF

variable = $85
$85

F8

BTJT variable, #3, label

Relative jump to
label in range PC128 to PC+127

INDIRECT ADDRESSABLE SPACE: 00 to FF


variable = $4B
$20

D4

$4B

20

BTJF [variable], #7, label

Execute next
instruction

16

SHIFT AND ROTATE INSTRUCTIONS

RLC

7 6 5 43 2 1 0

RRC

7 6 5 43 2 1 0

SLA and SLL

7 6 5 43 2 1 0

SRA

7 6 5 43 2 1 0

SRL

7 6 5 43 2 1 0

17

ADDRESSING MODES Summary

A D D R E S S IN G M O D E

S YN TA X E X A M P LE S

AD DR ESS R ANG E

In h e re n t

R C F ; M U L X ,A ; S W A P A ; C L R X ; W F I

N o t a p p lica b le

Im m e d ia te

B C P A , #$0F F ; X O R A , #% 01001110

N o t a p p lica b le

S h o rt D ire ct

IN C va ria b le ; N E G va ria b le ; S R A va ria b le 00...F F

L o n g D ire ct

C P Y , V A R IA B L E ; S B C A , V A R IA B L E

0000...F F F F

N o o ffse t In d e x e d

C P L (X ) ; D E C (Y ) ; O R A , (X )

00...F F

S h o rt In d e x e d

R R C (va ria b le , X ) ; S W A P (va ria b le , Y )

000...1F E

L o n g In d e x e d

A D D A , (V A R IA B L E , Y )

0000...F F F F

S h o rt In d ire ct

T N Z [va ria b le ]

00...F F

L o n g In d ire ct

A D C A , [va ria b le .w ]

0000...F F F F

S h o rt In d ire ct In d e x e d

R L C ([va ria b le ], Y ) ; L D X , ([va ria b le ], X )

000...1F E

L o n g In d ire ct In d e x e d

S U B A , ([va ria b le .w ], X )

R e la tive D ire ct

JR U G E la b e l ; C A L L R la b e l

R e la tive In d ire ct

JR N C [la b e l] ; JR H [la b e l]

0000...F F F F
P C -128/+ 127
P C -128/+ 128

B it D ire ct

B R E S va ria b le , #7

B it In d ire ct

B S E T [va ria b le ], #7

00...F F

R e la tive B it D ire ct

B T JT va ria b le , #3, la b e l

00...F F

B T JF [va ria b le ], #7, la b e l

00...F F

R e la tive B it In d ire ct

00...F F

18

EXERCICES ON ADDRESSING MODES

What is the content of the registers X,Y and A


after the execution of the 3 instructions ?

Before Completion
X = 03 and Y = 04
LD
LD

X,(Label,X)
Y,([Label],Y)

LD A,([Label2.w],Y)

After Completion
X=?
Y=?
A=?

L ab el2:

L ab el:

M em o ry A d d ress

M em o ry C o n ten t

$009F

OO

$00A 0

A6

$00A 1

53

$00A 2

A0

$00A 3

B8

$00A 4

O1

$00A 5

O4

$00A 6

D3

$00A 7

61

19

Vous aimerez peut-être aussi