                         .module lab1.c
                         .area text
                       ;  IX -> 0,x
                       ;           temp -> +2,x
                       ;          input -> +3,x
 0000                 _main::
 0000 BD0000            jsr __enterb
 0003 04                .byte 0x4
                       ; /************************************************************************
                       ; * Term:   Fall 2003
                       ; * Course: ECE 473
                       ; * Name:   Olamide Adabonyan
                       ; * E-mail: o_mide@yahoo.com
                       ; *
                       ; * REVISION HISTORY
                       ; *
                       ; * First Draft: 9/24-26/02
                       ; *              -while loops not working correctly because inchar()
                       ; *                   functionstops program
                       ; *            date: 9/27/02
                       ; *                  -function to check input buffer coded and running
                       ; *                  -PROGRAM COMPLETE...
                       ; *
                       ; * Date Submitted:   9/30/02
                       ; * Demo Approval:    ________
                       ; ************************************************************************/
                       ; 
                       ; #include <hc11.h>
                       ; 
                       ; #define endProg() asm("swi")
                       ; #define iteration_max 300   //max # of iterations
                       ; 
                       ; char InChar(void);
                       ; void iteration(void);
                       ; 
                       ; main()
                       ; {
                       ;     char input=0, temp;
 0004 6F03              clr 3,x
                       ;     printf("Toggling PA4... Press any key to continue\n");
 0006 CC0110            ldd #L4
 0009 BD0000            jsr _printf
                       ; 
                       ;     //RDRF set by default, so it must be cleared [chk pink book 4 instructions]
                       ;     temp = SCSR;
                         ; vol
 000C F6102E            ldab 0x102e
 000F E702              stab 2,x
                       ;     temp = SCDR;
                         ; vol
 0011 F6102F            ldab 0x102f
 0014 E702              stab 2,x
 0016 200D              bra L6
 0018                 L5:
                         ; vol
 0018 F61000            ldab 0x1000
 001B C810              eorb #16
 001D F71000            stab 0x1000
 0020 BD0087            jsr _InChar
 0023 E703              stab 3,x
 0025                 L6:
                       ;     
                       ;     while (input == 0)
 0025 6D03              tst 3,x
 0027 27EF              beq L5
                       ;     {
                       ;         PORTA = PORTA^0x10;
                       ;         input = InChar();
                       ;     }
                       ; 
                       ;     iteration();
 0029 BD0046            jsr _iteration
                       ; 
                       ;     printf("\nProgram Complete...");
 002C CC00FB            ldd #L8
 002F BD0000            jsr _printf
                       ;     printf("\n\nOlamide Adabonyan");
 0032 CC00E7            ldd #L9
 0035 BD0000            jsr _printf
                       ;     printf("\n[ECE 473] | [lab #1-b] | [Sept 30, 2002]");
 0038 CC00BD            ldd #L10
 003B BD0000            jsr _printf
                       ;     endProg();
 003E 3F                    swi
                       
                       ; }
 003F                 L3:
 003F 08                inx
 0040 08                inx
 0041 08                inx
 0042 08                inx
 0043 35                txs
 0044 38                pulx
 0045                   .dbline 0 ; func end
 0045 39                rts
                       ;  IX -> 0,x
                       ;         input2 -> +3,x
                       ;  iteration_num -> +4,x
 0046                 _iteration::
 0046 BD0000            jsr __enterb
 0049 06                .byte 0x6
                       ; 
                       ; 
                       ; void iteration(void)
                       ; {
                       ;     char input2 = 0;
 004A 6F03              clr 3,x
                       ;     unsigned short iteration_num=1;
 004C CC0001            ldd #1
 004F ED04              std 4,x
 0051 2020              bra L13
 0053                 L12:
                         ; vol
 0053 F61000            ldab 0x1000
 0056 C810              eorb #16
 0058 F71000            stab 0x1000
 005B EC04              ldd 4,x
 005D 37                pshb
 005E 36                psha
 005F CC00A7            ldd #L15
 0062 BD0000            jsr _printf
 0065 1838              puly
 0067 EC04              ldd 4,x
 0069 C30001            addd #1
 006C ED04              std 4,x
 006E BD0087            jsr _InChar
 0071 E703              stab 3,x
 0073                 L13:
                       ;     
                       ;     while((iteration_num < (iteration_max + 1)) && (input2 == 0))
 0073 EC04              ldd 4,x
 0075 1A83012D          cpd #301
 0079 2404              bhs L16
 007B 6D03              tst 3,x
 007D 27D4              beq L12
 007F                 L16:
                       ;     {
                       ;         PORTA ^= 0x10;
                       ;         printf("\nIteration Number: %d", iteration_num);
                       ;         ++iteration_num;
                       ;         input2 = InChar();
                       ;     }
                       ; }
 007F                 L11:
 007F 8F                xgdx
 0080 C30006            addd #6
 0083 8F                xgdx
 0084 35                txs
 0085 38                pulx
 0086                   .dbline 0 ; func end
 0086 39                rts
                       ;  IX -> 0,x
                       ;           temp -> +3,x
 0087                 _InChar::
 0087 BD0000            jsr __enterb
 008A 04                .byte 0x4
                       ; 
                       ; 
                       ; char InChar(void)
                       ; {
                       ;     char temp;
                       ;     
                       ;     if((SCSR & 0x20))
 008B 18CE102E          ldy #0x102e
 008F 181F002007        brclr 0,y,#32,L18
                       ;      temp = SCDR;
                         ; vol
 0094 F6102F            ldab 0x102f
 0097 E703              stab 3,x
 0099 2002              bra L19
 009B                 L18:
                       ;     else
                       ;      temp = 0;
 009B 6F03              clr 3,x
 009D                 L19:
                       ;                     
                       ;     return(temp);
 009D E603              ldab 3,x
 009F 4F                clra
 00A0                 L17:
 00A0 08                inx
 00A1 08                inx
 00A2 08                inx
 00A3 08                inx
 00A4 35                txs
 00A5 38                pulx
 00A6                   .dbline 0 ; func end
 00A6 39                rts
 00A7                 L15:
 00A7 0A497465726174696F6E204E756D6265   .byte 10,'I,'t,'e,'r,'a,'t,'i,'o,'n,32,'N,'u,'m,'b,'e
 00B7 723A20256400      .byte 'r,58,32,37,'d,0
 00BD                 L10:
 00BD 0A5B454345203437335D207C205B6C61   .byte 10,91,'E,'C,'E,32,52,55,51,93,32,124,32,91,'l,'a
 00CD 622023312D625D207C205B5365707420   .byte 'b,32,35,49,45,'b,93,32,124,32,91,'S,'e,'p,'t,32
 00DD 33302C20323030325D00   .byte 51,48,44,32,50,48,48,50,93,0
 00E7                 L9:
 00E7 0A0A4F6C616D69646520416461626F6E   .byte 10,10,'O,'l,'a,'m,'i,'d,'e,32,'A,'d,'a,'b,'o,'n
 00F7 79616E00          .byte 'y,'a,'n,0
 00FB                 L8:
 00FB 0A50726F6772616D20436F6D706C6574   .byte 10,'P,'r,'o,'g,'r,'a,'m,32,'C,'o,'m,'p,'l,'e,'t
 010B 652E2E2E00        .byte 'e,46,46,46,0
 0110                 L4:
 0110 546F67676C696E67205041342E2E2E20   .byte 'T,'o,'g,'g,'l,'i,'n,'g,32,'P,'A,52,46,46,46,32
 0120 507265737320616E79206B657920746F   .byte 'P,'r,'e,'s,'s,32,'a,'n,'y,32,'k,'e,'y,32,'t,'o
 0130 20636F6E74696E75650A00     .byte 32,'c,'o,'n,'t,'i,'n,'u,'e,10,0
