회원가입 ID/PW 찾기

1) 지식 창고는 본인이 작성한 콘텐츠(팁/노하우/리소스/강좌 등)을 무료 혹은 가상화폐인 납포인트를 통해 공유하는 공간입니다.
2) 본인이 작성한 콘텐츠에 대해서만 지식 창고에 등록할 수 있으며, 저작권에 위배되는 콘텐츠는 사전경고 없이 삭제될 수 있습니다.
3) 콘텐츠 구매 및 첨부파일 다운로드는 회원그룹 '연구원' 이상 가능하오니, 경험치를 쌓아 진급한 후에 이용 부탁드립니다.
4) 무료 콘텐츠의 본문은 구매절차 없이 즉시 이용할 수 있으며, 판매 납포인트가 있는 콘텐츠는 구매 후 이용할 수 있습니다.
5) 콘텐츠 판매에 따른 납포인트 수익은 지정한 비율(50%)에 따라 판매자에게 지급하며, 납포인트 수익을 통해 진급을 빨리할 수 있습니다.
6) 구매 후 평가를 하면 구매 납포인트의 20%를 돌려 드립니다.

콘텐츠 수 33
판매자 qusgmltjd 판매 납포인트 무료 평점 0점 / 총 0명 참여
출처 : http://blog.naver.com/hsmc77?Redirect=Log&logNo=47507888
AVR 어셈블리어 수업 자료 입니다.
어셈블리 명령어 설명 입니다.

[추가내용]
AVR 명령어 정리

출처 : http://cafe.naver.com/allcyber.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=1023

 2. AVR 명령어 정리

 

1. 전체 명령어 정리

Rd: Destination (and source) register in the register file
Rr: Source register in the register file
b: Constant (0-7), can be a constant expression
s: Constant (0-7), can be a constant expression
P: Constant (0-31/63), can be a constant expression
K6; Constant (0-63), can be a constant expression
K8: Constant (0-255), can be a constant expression
k: Constant, value range depending on instruction. Can be a constant expression
q: Constant (0-63), can be a constant expression
Rdl:  R24, R26, R28, R30. For ADIW and SBIW instructions
X,Y,Z: Indirect address registers (X=R27:R26, Y=R29:R28, Z=R31:R30)

Arithmetic and Logic Instructions

Mnemonic

Operands

Description

Operation

Flags

Cycles

ADD 

Rd,Rr 

Add without Carry 

Rd = Rd + Rr 

Z,C,N,V,H,S 

1

ADC

Rd,Rr

Add with Carry

Rd = Rd + Rr + C

Z,C,N,V,H,S

1

SUB

Rd,Rr

Subtract without Carry

Rd = Rd - Rr

Z,C,N,V,H,S

1

SUBI

Rd,K8

Subtract Immediate

Rd = Rd - K8

Z,C,N,V,H,S

1

SBC

Rd,Rr

Subtract with Carry

Rd = Rd - Rr - C

Z,C,N,V,H,S

1

SBCI

Rd,K8

Subtract with Carry Immedtiate

Rd = Rd - K8 - C

Z,C,N,V,H,S

1

AND

Rd,Rr

Logical AND

Rd = Rd · Rr

Z,N,V,S 

1

ANDI

Rd,K8

Logical AND with Immediate

Rd = Rd · K8

Z,N,V,S

1

OR

Rd,Rr

Logical OR

Rd = Rd V Rr

Z,N,V,S

1

ORI

Rd,K8

Logical OR with Immediate

Rd = Rd V K8

Z,N,V,S

1

EOR

Rd,Rr

Logical Exclusive OR

Rd = Rd EOR Rr

Z,N,V,S

1

COM

Rd

One's Complement

Rd = $FF - Rd

Z,C,N,V,S

1

NEG

Rd

Two's Complement

Rd = $00 - Rd

Z,C,N,V,H,S

1

SBR

Rd,K8

Set Bit(s) in Register

Rd = Rd V K8

Z,C,N,V,S

1

CBR

Rd,K8

Clear Bit(s) in Register

Rd = Rd · ($FF - K8)

Z,C,N,V,S

1

INC

Rd

Increment Register

Rd = Rd + 1

Z,N,V,S

1

DEC

Rd

Decrement Register

Rd = Rd -1

Z,N,V,S

1

TST

Rd

Test for Zero or Negative

Rd = Rd · Rd

Z,C,N,V,S

1

CLR

Rd

Clear Register

Rd = 0

Z,C,N,V,S

1

SER

Rd

Set Register

Rd = $FF

None

1

ADIW

Rdl,K6

Add Immediate to Word

Rdh:Rdl = Rdh:Rdl + K6 

Z,C,N,V,S

2

SBIW

Rdl,K6

Subtract Immediate from Word

Rdh:Rdl = Rdh:Rdl - K 6

Z,C,N,V,S

2

MUL

Rd,Rr

Multiply Unsigned

R1:R0 = Rd * Rr

Z,C

2

MULS

Rd,Rr

Multiply Signed

R1:R0 = Rd * Rr

Z,C

2

MULSU

Rd,Rr

Multiply Signed with Unsigned

R1:R0 = Rd * Rr

Z,C

2

FMUL

Rd,Rr

Fractional Multiply Unsigned

R1:R0 = (Rd * Rr) << 1

Z,C

2

FMULS

Rd,Rr

Fractional Multiply Signed

R1:R0 = (Rd *Rr) << 1

Z,C

2

FMULSU

Rd,Rr

Fractional Multiply Signed with Unsigned

R1:R0 = (Rd * Rr) << 1

Z,C

2

 

Branch Instructions

Mnemonic

Operands

Description

Operation

Flags

Cycles

RJMP

k

Relative Jump

PC = PC + k +1

None

2

IJMP

None

Indirect Jump to

PC = Z

None

2

EIJMP

None

Extended Indirect Jump (Z)

STACK = PC+1, PC(15:0) = Z, PC(21:16) = EIND

None

2

JMP

k

Jump 

PC = k

None

3

RCALL

k

Relative Call Subroutine

STACK = PC+1, PC = PC + k + 1

None

3/4*

ICALL

None

Indirect Call to (Z)

STACK = PC+1, PC = Z 

None

3/4*

EICALL

None

Extended Indirect Call to (Z)

STACK = PC+1, PC(15:0) = Z, PC(21:16) =EIND

None

4*

CALL

k

Call Subroutine

STACK = PC+2, PC = k

None

4/5*

RET

None

Subroutine Return

PC = STACK

None

4/5*

RETI

None

Interrupt Return

PC = STACK

I

4/5*

CPSE

Rd,Rr

Compare, Skip if equal 

if (Rd ==Rr) PC = PC 2 or 3

None

1/2/3

CP

Rd,Rr

Compare

Rd -Rr

Z,C,N,V,H,S

1

CPC

Rd,Rr

Compare with Carry

Rd - Rr - C

Z,C,N,V,H,S

1

CPI

Rd,K8

Compare with Immediate

Rd - K

Z,C,N,V,H,S

1

SBRC

Rr,b

Skip if bit in register cleared

if(Rr(b)==0) PC = PC + 2 or 3

None

1/2/3

SBRS

Rr,b

Skip if bit in register set

if(Rr(b)==1) PC = PC + 2 or 3

None

1/2/3

SBIC

P,b

Skip if bit in I/O register cleared

if(I/O(P,b)==0) PC = PC + 2 or 3

None

1/2/3

SBIS

P,b

Skip if bit in I/O register set

if(I/O(P,b)==1) PC = PC + 2 or 3

None

1/2/3

BRBC

s,k

Branch if Status flag cleared

if(SREG(s)==0) PC = PC + k + 1

None

1/2

BRBS

s,k

Branch if Status flag set

if(SREG(s)==1) PC = PC + k + 1

None

1/2

BREQ

k

Branch if equal

if(Z==1) PC = PC + k + 1

None

1/2

BRNE

k

Branch if not equal

if(Z==0) PC = PC + k + 1

None

1/2

BRCS

k

Branch if carry set

if(C==1) PC = PC + k + 1

None

1/2

BRCC

k

Branch if carry cleared

if(C==0) PC = PC + k + 1

None

1/2

BRSH

k

Branch if same or higher

if(C==0) PC = PC + k + 1

None

1/2

BRLO

k

Branch if lower

if(C==1) PC = PC + k + 1

None

1/2

BRMI

k

Branch if minus

if(N==1) PC = PC + k + 1

None

1/2

BRPL

k

Branch if plus

if(N==0) PC = PC + k + 1

None

1/2

BRGE

k

Branch if greater than or equal (signed)

if(S==0) PC = PC + k + 1

None

1/2

BRLT

k

Branch if less than (signed)

if(S==1) PC = PC + k + 1

None

1/2

BRHS

k

Branch if half carry flag set

if(H==1) PC = PC + k + 1

None

1/2

BRHC

k

Branch if half carry flag cleared

if(H==0) PC = PC + k + 1

None

1/2

BRTS

k

Branch if T flag set

if(T==1) PC = PC + k + 1

None

1/2

BRTC

k

Branch if T flag cleared

if(T==0) PC = PC + k + 1

None

1/2

BRVS

k

Branch if overflow flag set

if(V==1) PC = PC + k + 1

None

1/2

BRVC

k

Branch if overflow flag cleared

if(V==0) PC = PC + k + 1

None

1/2

BRIE

k

Branch if interrupt enabled

if(I==1) PC = PC + k + 1

None

1/2

BRID

k

Branch if interrupt disabled

if(I==0) PC = PC + k + 1

None

1/2

 

Data Transfer Instructions

Mnemonic

Operands

Description

Operation

Flags

Cycles

MOV

Rd,Rr

Copy register

Rd = Rr

None

1

MOVW

Rd,Rr

Copy register pair

Rd+1:Rd = Rr+1:Rr, r,d even

None

1

LDI

Rd,K8

Load Immediate

Rd = K

None

1

LDS

Rd,k

Load Direct

Rd = (k)

None

2*

LD

Rd,X

Load Indirect

Rd = (X)

None

2*

LD

Rd,X+

Load Indirect and Post-Increment

Rd = (X), X=X+1

None

2*

LD

Rd,-X

Load Indirect and Pre-Decrement

X=X-1, Rd = (X)

None

2*

LD

Rd,Y

Load Indirect

Rd = (Y)

None

2*

LD

Rd,Y+

Load Indirect and Post-Increment

Rd = (Y), Y=Y+1

None

2*

LD

Rd,-Y

Load Indirect and Pre-Decrement

Y=Y-1, Rd = (Y)

None

2*

LDD

Rd,Y+q

Load Indirect with displacement

Rd = (Y+q)

None

2*

LD

Rd,Z

Load Indirect 

Rd = (Z)

None

2*

LD

Rd,Z+

Load Indirect and Post-Increment

Rd = (Z), Z=Z+1

None

2*

LD

Rd,-Z

Load Indirect and Pre-Decrement

Z=Z-1, Rd = (Z)

None

2*

LDD

Rd,Z+q

Load Indirect with displacement

Rd = (Z+q)

None

2*

STS

k,Rr

Store Direct

(k) = Rr

None

2*

ST

X,Rr

Store Indirect

(X) = Rr

None

2*

ST

X+,Rr

Store Indirect and Post-Increment

(X) = Rr, X=X+1

None

2*

ST

-X,Rr

Store Indirect and Pre-Decrement

X=X-1, (X)=Rr

None

2*

ST

Y,Rr

Store Indirect

(Y) = Rr

None

2*

ST

Y+,Rr

Store Indirect and Post-Increment

(Y) = Rr, Y=Y+1

None

2

ST

-Y,Rr

Store Indirect and Pre-Decrement

Y=Y-1, (Y) = Rr

None

2

ST

Y+q,Rr

Store Indirect with displacement

(Y+q) = Rr

None

2

ST

Z,Rr

Store Indirect

(Z) = Rr

None

2

ST

Z+,Rr

Store Indirect and Post-Increment

(Z) = Rr, Z=Z+1

None

2

ST

-Z,Rr

Store Indirect and Pre-Decrement

Z=Z-1, (Z) = Rr

None

2

ST

Z+q,Rr

Store Indirect with displacement

(Z+q) = Rr

None

2

LPM

None

Load Program Memory

R0 = (Z)

None

3

LPM

Rd,Z

Load Program Memory

Rd = (Z)

None

3

LPM

Rd,Z+

Load Program Memory and Post-Increment

Rd = (Z), Z=Z+1

None

3

ELPM

None

Extended Load Program Memory

R0 = (RAMPZ:Z)

None

3

ELPM

Rd,Z

Extended Load Program Memory

Rd = (RAMPZ:Z)

None

3

ELPM

Rd,Z+

Extended Load Program Memory and Post Increment

Rd = (RAMPZ:Z), Z = Z+1

None

3

SPM

None

Store Program Memory

(Z) = R1:R0

None

-

ESPM

None

Extended Store Program Memory

(RAMPZ:Z) = R1:R0

None

-

IN

Rd,P

In Port

Rd = P

None

1

OUT

P,Rr

Out Port

P = Rr

None

1

PUSH

Rr

Push register on Stack

STACK = Rr

None

2

POP

Rd

Pop register from Stack

Rd = STACK

None

2

* Cycle times for data memory accesses assume internal memory accesses and are not valid for accesses through the external RAM interface. For the LD, ST, LDD, STD, LDS, STS, PUSH and  POP instructions, add one cycle plus one cycle for each wait state.

Bit and Bit-test Instructions

Mnemonic

Operands

Description

Operation

Flags

Cycles

LSL

Rd

Logical shift left

Rd(n+1)=Rd(n), Rd(0)=0, C=Rd(7)

Z,C,N,V,H,S

1

LSR

Rd

Logical shift right

Rd(n)=Rd(n+1), Rd(7)=0, C=Rd(0)

Z,C,N,V,S

1

ROL

Rd

Rotate left through carry

Rd(0)=C, Rd(n+1)=Rd(n), C=Rd(7)

Z,C,N,V,H,S

1

ROR

Rd

Rotate right through carry

Rd(7)=C, Rd(n)=Rd(n+1), C=Rd(0)

Z,C,N,V,S

1

ASR

Rd

Arithmetic shift right

Rd(n)=Rd(n+1), n=0,...,6

Z,C,N,V,S

1

SWAP

Rd

Swap nibbles

Rd(3..0) = Rd(7..4), Rd(7..4) = Rd(3..0)

None

1

BSET 

s

Set flag

SREG(s) = 1

SREG(s)

1

BCLR

s

Clear flag

SREG(s) = 0

SREG(s)

1

SBI

P,b

Set bit in I/O register

I/O(P,b) = 1

None

2

CBI

P,b

Clear bit in I/O register

I/O(P,b) = 0

None

2

BST

Rr,b

Bit store from register to T

T = Rr(b)

T

1

BLD

Rd,b

Bit load from register to T

Rd(b) = T

None

1

SEC

None

Set carry flag

C =1

C

1

CLC

None

Clear carry flag

C = 0

C

1

SEN

None

Set negative flag

N = 1

N

1

CLN

None

Clear negative flag

N = 0

N

1

SEZ

None

Set zero flag

Z = 1

Z

1

CLZ

None

Clear zero flag

Z = 0

Z

1

SEI

None

Set interrupt flag

I = 1

I

1

CLI

None

Clear interrupt flag

I = 0

I

1

SES

None

Set signed flag

S = 1

S

1

CLN

None

Clear signed flag

S = 0

S

1

SEV

None

Set overflow flag

V = 1

V

1

CLV

None

Clear overflow flag

V = 0

V

1

SET

None

Set T-flag

T = 1

T

1

CLT

None

Clear T-flag

T = 0

T

1

SEH

None

Set half carry flag

H = 1

H

1

CLH

None

Clear half carry flag

H = 0

H

1

NOP

None

No operation

None

None

1

SLEEP

None

Sleep

See instruction manual

None

1

WDR

None

Watchdog Reset

See instruction manual

None

1



2. AVR ASM 에서 사용하는 예약어.

 

1) BYTE byte 변수 지정
           
.DSEG
           
var1:    .BYTE 1            ; reserve 1 byte to var1

2) CSEG - Code segment 지정

 

3) DB - Define constant byte(s) in program memory and EEPROM

            .CSEG
           
consts: .DB 0, 255, 0b01010101, -128, 0xaa

            .ESEG
           
const2: .DB 1,2,3

 

4) DEF - Set a symbolic name on a register

            .DEF temp=R16
            .DEF ior=R0

 

5) DEVICE - Define which device to assemble for

            Syntax:
           
.DEVICE AT90S1200 |AT90S2313 | AT90S2323 | AT90S2333 | AT90S2343 | AT90S4414

            | AT90S4433 | AT90S4434 | AT90S8515 | AT90S8534 | AT90S8535 | ATtiny11 | ATtiny12

            | ATtiny22 | ATmega603 | ATmega103

            Example:

            .DEVICE AT90S1200  ; Use the AT90S1200

 

6) DSEG - Data Segment

            .DSEG                        ; Start data segment

            var1:  .BYTE 1               ; reserve 1 byte to var1
           
table:  .BYTE tab_size       ; reserve tab_size bytes.

 

7) DW - Define constant word(s) in program memory and EEPROM

            .CSEG
           
varlist:  .DW 0, 0xffff, 0b1001110001010101, -32768, 65535

            .ESEG
           
eevarlst: .DW 0,0xffff,10

 

8) ENDMACRO - End macro

            .MACRO SUBI16               ; Start macro definition
                                subi r16,low(@0)    ; Subtract low byte
                                sbci r17,high(@0)   ; Subtract high byte
           
.ENDMACRO

 

9) EQU - Set a symbol equal to an expression

            .EQU io_offset = 0x23
           
.EQU porta     = io_offset + 2

 

10) ESEG - EEPROM Segment

            .ESEG
           
eevar1: .DW 0xffff        ; initialize 1 word in EEPROM

 

11) EXIT - Exit this file. 이 예약어 이후의 코드는 어셈블하지않는다.

 

12) INCLUDE - Include another file

 

13) LIST - Turn the listfile generation on

            .NOLIST                ; Disable listfile generation
           
.INCLUDE "macro.inc"   ; The included files will not
           
.INCLUDE "const.def"   ; be shown in the listfile
           
.LIST                  ; Reenable listfile generation

 

14) LISTMAC - Turn macro expansion on

 

15) MACRO - Begin macro

 

16) NOLIST - Turn listfile generation off

 

17) ORG - Set program origin

 

18) SET - Set a symbol equal to an expression

            .SET io_offset = 0x23
           
.SET porta     = io_offset + 2

            .CSEG                 ; Start code segment
                                clr r2        ; Clear register 2
                                out porta,r2  ; Write to Port A

 

 

 



profile
JYP 2010.10.20 00:47

감사합니다

profile
인지 2010.11.25 10:54
어셈블리어 재미있지요...^^
profile
Radar22 2012.09.13 15:07
감사합니다^^
profile
시나브로69 2016.07.16 16:35

좋은 자료 감사합니다.

search
List of Articles
번호 분류 제목 평점 포인트 판매자 등록일 구매수 조회 수
공지 공공의 목적으로 공유하고자 하는 소프트웨어는 '소프트웨어 자료실'에 업로드를 요청드립니다.
공지 구매후 평점 댓글을 남겨주시면 구매포인트의 20%를 돌려드립니다.
33 Software & IDEs fortran에서 수치해석 라이브러리 IMSL사용하기 [3] 무료 도시인 2014-03-04 0 215
32 Software & IDEs C# - GPS 예제 [4] 무료 달리는거북이 2010-12-03 0 3645
31 Software & IDEs 저는 학원에서 패스했습니다 ㅋ 무료 뒤집기달인y 2010-10-22 0 1993
30 Software & IDEs VS6 MFC기반에서 Rchedit 컨트롤 추가시 에러 무료 아크마 2010-10-04 0 2101
29 Software & IDEs MFC 테트리스프로그램 입니다^^ [8] 무료 초짜초짜초짜 2010-09-27 0 3104
28 Software & IDEs [Win32api/게임 ] 갤러그 [4] 무료 밍구리 2010-07-02 0 3576
27 Software & IDEs VB 에서 VC++ 처럼 메시지 이벤트 사용 [2] 무료 전자과조교 2010-05-04 0 1893
26 Software & IDEs Serial로 데이터 받아 처리하는 신체검사프로그램 [7] 무료 맑은소리 2010-04-26 0 1852
25 Software & IDEs 그리기 예제입니다 ^^ [5] 무료 전설의사나이 2010-04-10 0 1855
24 Software & IDEs MFC를 이용한 타자게임 입니다 ^^ [4] 무료 전설의사나이 2010-04-10 0 3197
23 Software & IDEs Winsock API 한글 도움말 입니다 . [6] 무료 쑤잉아 2010-04-08 0 2032
22 Software & IDEs unix network 프로그래밍 관련 자료 입니다. [2] 무료 블루미르7 2010-01-05 0 1782
21 Software & IDEs 강아지 키트를 이용하여 만들었습니다~~~ [17] 무료 kimd 2009-11-20 0 2118
20 Software & IDEs [MFC] 날짜 계산기입니다 [8] 무료 shindy 2009-10-28 0 3538
19 Software & IDEs 제어용DSP 추천합니다 [1] 무료 날아가는잡쉐 2008-09-25 0 1282
18 Software & IDEs API 시리얼통신 함수 사용방법 입니다. 참고하세요 [10] 무료 뺘쑝 2008-04-30 0 3911
17 Software & IDEs [MFC] 윈도우 크기 고정하기 [6] 무료 아크마 2008-04-28 0 3956
16 Software & IDEs 섭씨 화씨 변환 프로그램 [8] 무료 아크마 2008-04-23 0 2536
15 Software & IDEs 저.. 지금 딱 두번 글을 올려 봤는데.. 움.. 먼가 좀 바꿔야 될듯 해서..;; ㅋㅋ [1] 무료 행복하면 2007-12-03 0 1313
14 Software & IDEs c언어와 c++ 할 줄은 아는데.. 개념이 조금 부족하신분.. [14] 무료 행복하면 2007-11-29 0 1966
  • 사람은 자기가 한 약속을 지킬만한 좋은 기억력을 가져야 한다.
    - 니체
  • * 납포인트 정보 *
  • 글 작성 : 3
  • 댓글 작성 : 1
저작권법에 위배되는 콘텐츠는 등록 불가하며, 저작물에 대한 권리는 저작자에게 있습니다.
Copyright 2006-2021 © hardwareis.com, All rights reserved.