マイコンを使った工作

pnseq2.asm

最終更新:

匿名ユーザー

- view
管理者のみ編集可
pnseq2.asm
;       AVR Noise Source -- A PN Sequence Generator
;       Copyright (C) 2003  Chuck
;
;       This program is free software; you can redistribute it and/or
;       modify it under the terms of the GNU General Public License
;       as published by the Free Software Foundation; either version 2
;       of the License, or (at your option) any later version.
;
;       This program is distributed in the hope that it will be useful,
;       but WITHOUT ANY WARRANTY; without even the implied warranty of
;       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;       GNU General Public License for more details.
;
;       You should have received a copy of the GNU General Public License
;       along with this program; if not, write to the Free Software
;       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
;
;
;       Title:          AVR Noise Source
;       Author:         Chuck
;       Date:           16, August, 2003
;       Software:       AVR Studio to assemble
;       Hardware:       AT90S2323
;
;

.NOLIST                                         ;List Disable
        .include        "2323def.inc"
.LIST                                           ;List Enable

.EQU    PN_OUT  =       PB0


.DEF    TEMP            =       R16
.DEF    STACK           =       R17

.DEF    SREGH           =       R18
.DEF    SREGL           =       R19
.DEF    SREGM           =       R20

.DEF    TEMP2           =       R21

.CSEG

;---- Vector ----
.ORG    0
        RJMP    INIT
        RETI
        RETI

INIT:
        CLI
        LDI             TEMP, 0b00000001
        OUT             DDRB, TEMP
        LDI             TEMP, 0b00000000
        OUT     PORTB, TEMP

    LDI         SREGH, 0xAA
    LDI         SREGM, 0x0F
        LDI     SREGL, 0xAA

;---- main loop ----
LOOP:

        CLR             TEMP                    ; calculate parity section
        BST             SREGH,7
        BLD             TEMP,0
        CLR             TEMP2
        BST             SREGH, 6
        BLD             TEMP2, 0
        EOR             TEMP, TEMP2
        BST             SREGL, 6
        BLD             TEMP2, 0
        EOR             TEMP, TEMP2
        BST             SREGL, 0
        BLD             TEMP2, 0
        EOR             TEMP, TEMP2

        SBRC    SREGL, PN_OUT   ; output PN sequence section
        SBI             PORTB, PN_OUT
        SBRS    SREGL, PN_OUT
        CBI             PORTB, PN_OUT

        CLC                                             ; shift section
        SBRC    TEMP, 0
        SEC
        ROR             SREGH
        ROR             SREGM
        ROR             SREGL


        RJMP    LOOP
人気記事ランキング
目安箱バナー