                         .module keypad1.c
                         .area text
 0000                 L4:
 0000 0031              .word 49
 0002 0032              .word 50
 0004 0033              .word 51
 0006 0041              .word 65
 0008 0034              .word 52
 000A 0035              .word 53
 000C 0036              .word 54
 000E 0042              .word 66
 0010 0037              .word 55
 0012 0038              .word 56
 0014 0039              .word 57
 0016 0043              .word 67
 0018 002A              .word 42
 001A 0030              .word 48
 001C 0023              .word 35
 001E 0044              .word 68
 0020                 L20:
 0020 00DD              .word L19
 0022 00D6              .word L18
 0024 00E4              .word L14
 0026 00CF              .word L17
 0028 00E4              .word L14
 002A 00E4              .word L14
 002C 00E4              .word L14
 002E 00C8              .word L16
                       ;  IX -> 0,x
                       ;  rMEM -> 2,x
                       ;         keypad -> +4,x
                       ;           newv -> +36,x
                       ;            col -> +38,x
                       ;          store -> +40,x
                       ;          value -> +42,x
                       ;          count -> +44,x
                       ;              i -> +46,x
 0030                 _main::
 0030 BD0000            jsr __enterb
 0033 30                .byte 0x30
                       ; #include <hc11.h>
                       ; #include <stdio.h>
                       ; 
                       ; 
                       ; void main (void)
                       ; {
                       ;      int i=0, value=0, store=0,count=0,col=0,newv=0;
 0034 CC0000            ldd #0
 0037 ED2E              std 46,x
 0039 CC0000            ldd #0
 003C ED2A              std 42,x
 003E CC0000            ldd #0
 0041 ED28              std 40,x
 0043 CC0000            ldd #0
 0046 ED2C              std 44,x
 0048 CC0000            ldd #0
 004B ED26              std 38,x
 004D CC0000            ldd #0
 0050 ED24              std 36,x
                       ;      int keypad[4][4]={
 0052 EC00              ldd 0,x
 0054 C30004            addd #4
 0057 18CE0000          ldy #L4
 005B 3C                pshx
 005C 8F                xgdx
 005D CC0020            ldd #32
 0060 BD0000            jsr __asgnblk
 0063 38                pulx
                       ;                        {0x31,0x32,0x33,0x41},
                       ;                        {0x34,0X35,0x36,0x42},
                       ;                        {0x37,0x38,0x39,0x43},
                       ;                        {0x2a,0x30,0x23,0x44}
                       ;                       };
                       ;      setbaud(BAUD9600);
 0064 CC0030            ldd #48
 0067 BD0000            jsr _setbaud
                       ;      DDRD=0x3e;
 006A C63E              ldab #62
 006C F71009            stab 0x1009
 006F 7E011B            jmp L6
 0072                 L5:
                       ; 
                       ;      while (1)
                       ;      {
                       ;      i=0x04;     
 0072 CC0004            ldd #4
 0075 ED2E              std 46,x
                       ;      for (count=0; count <=3; count++)
 0077 CC0000            ldd #0
 007A ED2C              std 44,x
 007C                 L8:
                       ;      {     
                       ;            PORTD=i;
 007C EC2E              ldd 46,x
 007E F71008            stab 0x1008
                       ;            value=PORTE;
                         ; vol
 0081 F6100A            ldab 0x100a
 0084 4F                clra
 0085 ED2A              std 42,x
                       ;            if ( value != 0)
 0087 EC2A              ldd 42,x
 0089 2708              beq L12
                       ;            {
                       ;               store=count;
 008B EC2C              ldd 44,x
 008D ED28              std 40,x
                       ;               col=value;
 008F EC2A              ldd 42,x
 0091 ED26              std 38,x
                       ;            }
 0093                 L12:
 0093 EC2E              ldd 46,x
 0095 05                lsld
 0096 ED2E              std 46,x
 0098                 L9:
 0098 EC2C              ldd 44,x
 009A C30001            addd #1
 009D ED2C              std 44,x
 009F EC2C              ldd 44,x
 00A1 1A830003          cpd #3
 00A5 2FD5              ble L8
                       ;            i=i<<1;
                       ;            
                       ;      }      
                       ;            switch (col)
 00A7 EC26              ldd 38,x
 00A9 1A830001          cpd #1
 00AD 2D35              blt L14
 00AF EC26              ldd 38,x
 00B1 1A830008          cpd #8
 00B5 2E2D              bgt L14
 00B7 EC26              ldd 38,x
 00B9 830001            subd #1
 00BC 05                lsld
 00BD C30020            addd #L20
 00C0 188F              xgdy
 00C2 18EE00            ldy 0,y
 00C5 186E00            jmp 0,y
 00C8                 X0:
                       ;            {
 00C8                 L16:
                       ;             case 8:
                       ;                  newv=3;
 00C8 CC0003            ldd #3
 00CB ED24              std 36,x
                       ;                  break;
 00CD 201A              bra L15
 00CF                 L17:
                       ;             case 4:
                       ;                  newv=2;
 00CF CC0002            ldd #2
 00D2 ED24              std 36,x
                       ;                  break;
 00D4 2013              bra L15
 00D6                 L18:
                       ;             case 2:
                       ;                  newv=1;
 00D6 CC0001            ldd #1
 00D9 ED24              std 36,x
                       ;                  break;
 00DB 200C              bra L15
 00DD                 L19:
                       ;             case 1:
                       ;                  newv=0;
 00DD CC0000            ldd #0
 00E0 ED24              std 36,x
                       ;                  break;
 00E2 2005              bra L15
 00E4                 L14:
                       ;             default:
                       ;                  newv=99;
 00E4 CC0063            ldd #99
 00E7 ED24              std 36,x
                       ;                  break;
 00E9                 L15:
 00E9 EC28              ldd 40,x
 00EB 05                lsld
 00EC 05                lsld
 00ED 05                lsld
 00EE 37                pshb ; 
 00EF 36                psha ; spill
 00F0 EC00              ldd 0,x
 00F2 C30004            addd #4
 00F5 ED02              std 2,x
 00F7 32                pula ; 
 00F8 33                pulb ; reload
 00F9 E302              addd 2,x
 00FB ED02              std 2,x
 00FD EC24              ldd 36,x
 00FF 05                lsld
 0100 E302              addd 2,x
 0102 188F              xgdy
 0104 18EC00            ldd 0,y
 0107 37                pshb
 0108 36                psha
 0109 EC24              ldd 36,x
 010B 37                pshb
 010C 36                psha
 010D EC28              ldd 40,x
 010F 37                pshb
 0110 36                psha
 0111 CC0126            ldd #L21
 0114 BD0000            jsr _printf
 0117 BD0000            jsr __movspb
 011A 06                .byte 6
 011B                 L6:
 011B 7E0072            jmp L5
 011E                 X1:
                       ;             }
                       ;                     
                       ;            printf("%d %d  %x\n",store, newv, keypad[store][newv]);
                       ;      } 
                       ; }    
 011E                 L3:
 011E 8F                xgdx
 011F C30030            addd #48
 0122 8F                xgdx
 0123 35                txs
 0124 38                pulx
 0125                   .dbline 0 ; func end
 0125 39                rts
 0126                 L21:
 0126 2564202564202025780A00     .byte 37,'d,32,37,'d,32,32,37,'x,10,0
