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

1.1       root        1: ; vi:set ts=8:
                      2: 
                      3: ; nono
                      4: ; Copyright (C) 2025 nono project
                      5: ;
                      6: ; Redistribution and use in source and binary forms, with or without
                      7: ; modification, are permitted provided that the following conditions
                      8: ; are met:
                      9: ; 1. Redistributions of source code must retain the above copyright
                     10: ;    notice, this list of conditions and the following disclaimer.
                     11: ; 2. Redistributions in binary form must reproduce the above copyright
                     12: ;    notice, this list of conditions and the following disclaimer in the
                     13: ;    documentation and/or other materials provided with the distribution.
                     14: ;
                     15: ; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     16: ; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     17: ; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     18: ; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     19: ; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
                     20: ; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
                     21: ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
                     22: ; AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
                     23: ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24: ; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25: ; SUCH DAMAGE.
                     26: 
                     27: ; CAS.[BWL] Dc,Du,<ea>
                     28: ;
                     29: ;  cc := *(ea) - Dc
                     30: ;  If (Z), *(ea) := Du
                     31: ;  Else    Dc := *(ea)
                     32: 
                     33:        .xref   hexstr_long
                     34:        .include doscall.mac
                     35:        .list
                     36:        .cpu    68030
                     37: 
                     38: PRINT  .macro  msg
                     39:        pea.l   msg
                     40:        DOS     _PRINT
                     41:        addq.l  #4,sp
                     42:        .endm
                     43: 
                     44:        .offset 0
                     45: o_initea:      .ds.l   1
                     46: o_exp_dc:      .ds.l   1
                     47: o_exp_du:      .ds.l   1
                     48: o_exp_ac:      .ds.l   1
                     49: o_exp_au:      .ds.l   1
                     50: o_exp_ea:      .ds.l   1
                     51: o_inst:                .ds.w   3
                     52: o_msg:         .ds.b   0
                     53: 
                     54:        .text
                     55:        .even
                     56: 
                     57:        ; d0-d1 汎用
                     58:        ; d2-d3 Dc,Du 用
                     59:        ; d4    <ea> 入出力用
                     60:        ; d7    テスト番号
                     61:        ; a2-a3 Ac,Au 用
                     62:        ; a4    <ea>
                     63:        ; a5    テストデータ
                     64: 
                     65: start:
                     66:        lea.l   data(pc),a4
                     67: 
                     68:        moveq.l #0,d7
                     69: loop:
                     70:        bsr     do_test
                     71:        addq.l  #1,d7
                     72:        cmpi.l  #8,d7
                     73:        bne     loop
                     74: 
                     75:        DOS     _EXIT
                     76: 
                     77: do_test:
                     78:        lea.l   testdata,a5
                     79:        move.l  (a5,d7.l*4),a5
                     80:        PRINT   o_msg(a5)
                     81:        ; Exec
                     82:        movem.l initial(pc),d2-d3/a2-a3
                     83:        move.l  o_initea(a5),(a4)
                     84:        jsr     o_inst(a5)
                     85: check:
                     86: check_dc:
                     87:        move.l  o_exp_dc(a5),d1
                     88:        cmp.l   d1,d2
                     89:        beq     @f
                     90:        pea.l   msg_dc(pc)
                     91:        move.l  d1,-(sp)
                     92:        move.l  d2,-(sp)
                     93:        bsr     fail
                     94:        lea.l   12(sp),sp
                     95: @@:
                     96: check_du:
                     97:        move.l  o_exp_du(a5),d1
                     98:        cmp.l   d1,d3
                     99:        beq     @f
                    100:        pea.l   msg_du(pc)
                    101:        move.l  d1,-(sp)
                    102:        move.l  d3,-(sp)
                    103:        bsr     fail
                    104:        lea.l   12(sp),sp
                    105: @@:
                    106: check_ac:
                    107:        move.l  o_exp_ac(a5),d1
                    108:        cmpa.l  d1,a2
                    109:        beq     @f
                    110:        pea.l   msg_ac(pc)
                    111:        move.l  d1,-(sp)
                    112:        move.l  a2,-(sp)
                    113:        bsr     fail
                    114:        lea.l   12(sp),sp
                    115: @@:
                    116: check_au:
                    117:        move.l  o_exp_au(a5),d1
                    118:        cmpa.l  d1,a3
                    119:        beq     @f
                    120:        pea.l   msg_au(pc)
                    121:        move.l  d1,-(sp)
                    122:        move.l  a3,-(sp)
                    123:        bsr     fail
                    124:        lea.l   12(sp),sp
                    125: @@:
                    126: check_ea:
                    127:        move.l  o_exp_ea(a5),d1
                    128:        cmp.l   (a4),d1
                    129:        beq     @f
                    130:        pea.l   msg_ea(pc)
                    131:        move.l  d1,-(sp)
                    132:        move.l  (a4),-(sp)
                    133:        bsr     fail
                    134:        lea.l   12(sp),sp
                    135: @@:
                    136: check_done:
                    137:        rts
                    138: 
                    139: ; arg: +$4.l actual
                    140: ;      +$8.l expected
                    141: ;      +$c.l name
                    142: fail:
                    143:        PRINT   msg_fail(pc)
                    144:        move.l  $c(sp),-(sp)
                    145:        DOS     _PRINT
                    146:        addq.l  #4,sp
                    147:        PRINT   msg_expects(pc)
                    148:        move.l  $8(sp),d0
                    149:        lea.l   hexbuf(pc),a0
                    150:        bsr     hexstr_long
                    151:        PRINT   hexbuf(pc)
                    152:        PRINT   msg_but(pc)
                    153:        move.l  $4(sp),d0
                    154:        lea.l   hexbuf(pc),a0
                    155:        bsr     hexstr_long
                    156:        PRINT   hexbuf(pc)
                    157:        PRINT   msg_crlf(pc)
                    158:        rts
                    159: 
                    160:        ; d2-d3/a2-a3 の初期値
                    161: initial:
                    162:        .dc.l   1, 2, 3, 4
                    163: 
                    164: testdata:
                    165:        .dc.l   testdata0
                    166:        .dc.l   testdata1
                    167:        .dc.l   testdata2
                    168:        .dc.l   testdata3
                    169:        .dc.l   testdata4
                    170:        .dc.l   testdata5
                    171:        .dc.l   testdata6
                    172:        .dc.l   testdata7
                    173: 
                    174:        ; <ea> の初期値
                    175:        ; Dc, Du, Ac, Au, <ea> の期待値
                    176:        ; 実行する命令; rts
                    177:        ; 表示するテスト名
                    178: 
                    179: testdata0:
                    180:        .dc.l   1
                    181:        .dc.l   1, 2, 3, 4, 2
                    182:        cas.l   d2,d3,(a4)
                    183:        rts
                    184:        .dc.b   "CAS Dc,Du,<ea> (EQ)",$d,$a,0
                    185:        .even
                    186: testdata1:
                    187:        .dc.l   0
                    188:        .dc.l   0, 2, 3, 4, 0
                    189:        cas.l   d2,d3,(a4)
                    190:        rts
                    191:        .dc.b   "CAS Dc,Du,<ea> (NE)",$d,$a,0
                    192:        .even
                    193: testdata2:
                    194:        .dc.l   1
                    195:        .dc.l   1, 2, 3, 4, 2
                    196:        .dc.w   $0ed4, $2+($b<<6)       ; cas.l d2,a3,(a4)
                    197:        rts
                    198:        .dc.b   "CAS Dc,Au,<ea> (EQ)",$d,$a,0
                    199:        .even
                    200: testdata3:
                    201:        .dc.l   0
                    202:        .dc.l   0, 2, 3, 4, 0
                    203:        .dc.w   $0ed4, $2+($b<<6)       ; cas.l d2,a3,(a4)
                    204:        rts
                    205:        .dc.b   "CAS Dc,Au,<ea> (NE)",$d,$a,0
                    206:        .even
                    207: testdata4:
                    208:        .dc.l   3
                    209:        .dc.l   1, 2, 3, 4, 2
                    210:        .dc.w   $0ed4, $a+($3<<6)       ; cas.l a2,d3,(a4)
                    211:        rts
                    212:        .dc.b   "CAS Ac,Du,<ea> (EQ)",$d,$a,0
                    213:        .even
                    214: testdata5:
                    215:        .dc.l   0
                    216:        .dc.l   1, 2, 0, 4, 0
                    217:        .dc.w   $0ed4, $a+($3<<6)       ; cas.l a2,d3,(a4)
                    218:        rts
                    219:        .dc.b   "CAS Ac,Du,<ea> (NE)",$d,$a,0
                    220:        .even
                    221: testdata6:
                    222:        .dc.l   3
                    223:        .dc.l   1, 2, 3, 4, 4
                    224:        .dc.w   $0ed4, $a+($b<<6)       ; cas.l a2,a3,(a4)
                    225:        rts
                    226:        .dc.b   "CAS Ac,Au,<ea> (EQ)",$d,$a,0
                    227:        .even
                    228: testdata7:
                    229:        .dc.l   0
                    230:        .dc.l   1, 2, 0, 4, 0
                    231:        .dc.w   $0ed4, $a+($b<<6)       ; cas.l a2,a3,(a4)
                    232:        rts
                    233:        .dc.b   "CAS Ac,Au,<ea> (NE)",$d,$a,0
                    234:        .even
                    235: 
                    236: msg_dc:        .dc.b   "Dc",0
                    237: msg_du:        .dc.b   "Du",0
                    238: msg_ac:        .dc.b   "Ac",0
                    239: msg_au:        .dc.b   "Au",0
                    240: msg_ea:        .dc.b   "<ea>",0
                    241: msg_crlf:
                    242:        .dc.b   $d,$a,0
                    243: msg_fail:
                    244:        .dc.b   $9,"*** ",0
                    245: msg_expects:
                    246:        .dc.b   " expects ",0
                    247: msg_but:
                    248:        .dc.b   " but got ",0
                    249: 
                    250:        .bss
                    251: data:
                    252:        .ds.l   1
                    253: hexbuf:
                    254:        .ds.b   16

unix.superglobalmegacorp.com

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