Annotation of nono/exp/dmac3.has, revision 1.1.1.1

1.1       root        1: ;
                      2: ; nono
                      3: ; Copyright (C) 2020 nono project
                      4: ;
                      5: ; Redistribution and use in source and binary forms, with or without
                      6: ; modification, are permitted provided that the following conditions
                      7: ; are met:
                      8: ; 1. Redistributions of source code must retain the above copyright
                      9: ;    notice, this list of conditions and the following disclaimer.
                     10: ; 2. Redistributions in binary form must reproduce the above copyright
                     11: ;    notice, this list of conditions and the following disclaimer in the
                     12: ;    documentation and/or other materials provided with the distribution.
                     13: ;
                     14: ; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     15: ; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     16: ; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     17: ; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     18: ; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
                     19: ; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
                     20: ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
                     21: ; AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
                     22: ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     23: ; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     24: ; SUCH DAMAGE.
                     25: 
                     26: ; DMAC の STR をワード書き込みした時の挙動を調べる。
                     27: ;
                     28: ; 実機での実行結果:
                     29: ;  before 0008
                     30: ;  after  0508
                     31: ;  CSR|CER   9102
                     32: ;  int_occur 00ff
                     33: ;
                     34: ; SCR|CCR のワードに書き込んだ $0588 のうち SCR 部分の $05 は書き込まれる。
                     35: ; ただしタイミングエラーになったため CCR:STR は落とされている。
                     36: ; int_occur は上位バイトが NIV、下位バイトが EIV が起きたことを示しており
                     37: ; この場合当然エラー割り込みが起きる。
                     38: ; 割り込み発生時の CER はタイミングエラーを示している
                     39: ; (この後 CSR.ERR に書き込むと CER もクリアされる)。
                     40: 
                     41:                .include        doscall.mac
                     42:                .include        iocscall.mac
                     43:                .xref   hexstr_word
                     44: 
                     45: DMAC_ch2:      .equ    $e84080
                     46: DMAC_CSR:      .equ    $00
                     47: DMAC_DCR:      .equ    $04
                     48: DMAC_OCR:      .equ    $05
                     49: DMAC_SCR:      .equ    $06
                     50: DMAC_CCR:      .equ    $07
                     51: DMAC_MTC:      .equ    $0a
                     52: DMAC_MAR:      .equ    $0c
                     53: DMAC_DAR:      .equ    $14
                     54: DMAC_NIV:      .equ    $25
                     55: DMAC_EIV:      .equ    $27
                     56: 
                     57: PRINT          .macro  str
                     58:                pea             str
                     59:                DOS             _PRINT
                     60:                addq.l  #4,sp
                     61:                .endm
                     62: 
                     63:                .cpu    68000
                     64:                .list
                     65:                .text
                     66:                .even
                     67: start:
                     68:                clr.l   -(sp)
                     69:                DOS     _SUPER
                     70:                addq.l  #4,sp
                     71: 
                     72:                movea.l #DMAC_ch2,a4
                     73: 
                     74:                moveq.l #$68,d1                 ; NIV 設定
                     75:                move.b  d1,DMAC_NIV(a4)
                     76:                lea.l   niv_handler(pc),a1
                     77:                IOCS    _B_INTVCS
                     78:                move.l  d0,niv_backup
                     79: 
                     80:                moveq.l #$69,d1                 ; EIV 設定
                     81:                move.b  d1,DMAC_EIV(a4)
                     82:                lea.l   eiv_handler(pc),a1
                     83:                IOCS    _B_INTVCS
                     84:                move.l  d0,eiv_backup
                     85: 
                     86:                exg.l   sp,sp                   ; ブレークポイント
                     87: 
                     88:                move.b  #$08,DMAC_CCR(a4)       ; INT enable
                     89:                move.w  #$0002,DMAC_MTC(a4)
                     90:                lea.l   start(pc),a0
                     91:                move.l  a0,DMAC_MAR(a4)
                     92:                lea.l   buf(pc),a0
                     93:                move.l  a0,DMAC_DAR(a4)
                     94: 
                     95:                move.b  #$08,DMAC_DCR(a4)       ; DCR=16bit
                     96:                move.b  #$11,DMAC_OCR(a4)       ; OCR=MtoD,Word
                     97:                move.b  #$00,DMAC_SCR(a4)       ; SCR=MAC=,DAC=
                     98: 
                     99:                move.w  DMAC_SCR(a4),d4         ; Backup SCR|CCR
                    100:                move.w  d4,d0
                    101:                ori.w   #$0580,d0
                    102:                move.w  d0,DMAC_SCR(a4)         ; SET STR ON WORD ACCESS!!
                    103: 
                    104:                move.w  DMAC_SCR(a4),d5         ; Fetch SCR|CCR again
                    105: 
                    106:                PRINT   msg_before(pc)          ; 書き込み前の SCR|CCR
                    107:                move.l  d4,d0
                    108:                bsr     putword
                    109:                PRINT   msg_after(pc)           ; 書き込み後の SCR|CCR
                    110:                move.l  d5,d0
                    111:                bsr     putword
                    112:                PRINT   msg_csr(pc)             ; CSR|CER
                    113:                move.w  csr_after(pc),d0
                    114:                bsr     putword
                    115:                PRINT   msg_intr(pc)            ; 割り込み起きたかどうか
                    116:                move.w  niv_occur(pc),d0
                    117:                bsr     putword
                    118: 
                    119:                ; 後始末
                    120:                move.b  #$00,DMAC_CCR(a4)       ; INT disable
                    121:                moveq.l #$68,d1                 ; EIV ハンドラ復元
                    122:                movea.l niv_backup,a0
                    123:                IOCS    _B_INTVCS
                    124:                moveq.l #$69,d1                 ; NIV ハンドラ復元
                    125:                movea.l eiv_backup,a0
                    126:                IOCS    _B_INTVCS
                    127: 
                    128:                DOS     _EXIT
                    129: 
                    130: niv_handler:
                    131:                st      niv_occur
                    132:                rte
                    133: eiv_handler:
                    134:                st      eiv_occur
                    135:                move.w  DMAC_CSR(a4),d0         ; clear interrupts
                    136:                move.w  d0,DMAC_CSR(a4)
                    137:                lea.l   csr_after(pc),a0        ; save CSR|CER
                    138:                move.w  d0,(a0)
                    139:                rte
                    140: 
                    141: putword:
                    142:                swap    d0
                    143:                lea.l   buf(pc),a0
                    144:                bsr     hexstr_word
                    145:                move.b  #$0d,(a0)+
                    146:                move.b  #$0a,(a0)+
                    147:                clr.b   (a0)
                    148:                pea.l   buf(pc)
                    149:                DOS     _PRINT
                    150:                addq.l  #4,sp
                    151:                rts
                    152: 
                    153: msg_before:    .dc.b   "before ",0
                    154: msg_after:     .dc.b   "after  ",0
                    155: msg_csr:       .dc.b   "CSR|CER   ",0
                    156: msg_intr:      .dc.b   "int_occur ",0
                    157: 
                    158:                .even
                    159: niv_backup:    .ds.l   1
                    160: eiv_backup:    .ds.l   1
                    161: csr_after:     .ds.w   1
                    162: niv_occur:     .dc.b   0
                    163: eiv_occur:     .dc.b   0
                    164: buf:           .ds     16
                    165: 
                    166:                .end
                    167: ; vi:set ts=8:

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.