
PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 1



                        1  **    Test program       **
                        2  **    19.6.96            **
                        3  **      Pavlic Bogdan    **
                        4  ***************************
 0000                   5            org   0000
 0000                   6  ZASLON    RMB   $20          ; Zaslon=Display 
                             Buffer (only DISPLAY functions writes directly to 
                                                                           LCD)
 0020                   7  TOFS      RMB   2            ; Timer overflow 
                                                                        counter
 0022                   8  OC1S      RMB   2            ; OC1 counter
 0024                   9  CURSOR    RMB   1            ; Virtual cursor
                       10  
 0025                  11  vectors   EQU   $ffd6
                       12  
 0025                  13  RDATLCDI  EQU   $1602        ; LCD port: SIM11 
                                                     presumes 1600h as LCD port
 0025                  14  DATLCDI   EQU   $1600
 0025                  15  DATLCDD   EQU   $1601
                       16  
 0025                  17  DIODE1    EQU   $1e00        ; We will write to 
                                                                         diodes
 0025                  18  DIODE2    EQU   $1c00
 0025                  19  DIODE3    EQU   $1a00
                       20  
 E000                  21            org   $e000
                       22  
 E000 [03] 8E00FF      23  start     lds   #$ff
 E003 [03] 7EE391      24            jmp   main
                       25  
 E006                  26            include 'display.s'
                       27  ****************************************************
                                               ********************************
 E006 [04] 3C          28  lcd_dly  pshx
 E007 [03] 09          29  lcd015   dex         ; each loop adds 7 T period 
                                                                         delay.
 E008 [04] 8C0000      30      cpx  #!0
 E00B [03] 26FA        31      bne  lcd015
 E00D [05] 38          32      pulx
 E00E [05] 39          33      rts
                       34  
                       35  ****************************************************
                                                            *******************
                       36  * lcd_wrd : Izpise kar je v Ak. A na kurzor;navidezn
                                                            o                 *
                       37  ****************************************************
                                                            *******************
                       38  lcd_wrd
 E00F [04] 3C          39        pshx
 E010 [03] 37          40        pshb
 E011 [03] 36          41        psha
 E012 [03] CE0000      42        ldx   #ZASLON
 E015 [03] D624        43        ldab  CURSOR
 E017 [03] 3A          44        abx
 E018 [04] A700        45        staa  0,x
 E01A [06] 7C0024      46        inc   CURSOR
 E01D [04] 32          47        pula
 E01E [04] 33          48        pulb


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 2



 E01F [05] 38          49        pulx
 E020 [05] 39          50        rts
                       51  
 E021 [04] 3C          52  lcd_wri pshx
 E022 [03] 37          53          pshb
 E023 [03] CE0500      54          ldx #500
 E026 [04] F61602      55  lcd000  ldab RDATLCDI
 E029 [02] C480        56          andb #%10000000             ; can display 
                                                                   accept data?
 E02B [02] 5D          57          tstb
 E02C [03] 2708        58          beq lcdfff
 E02E [03] 09          59          dex
 E02F [04] 8C0000      60          cpx #0
 E032 [03] 2702        61          beq lcdfff
 E034 [03] 20F0        62          bra lcd000
 E036 [04] B71600      63  lcdfff  staa DATLCDI
 E039 [04] 33          64          pulb
 E03A [05] 38          65          pulx
 E03B [05] 39          66          rts
                       67  
                       68  ;***************************************************
                                                                 **************
                       69  ;lcd_wrd:     writes data which is placed in /A/ to 
                                                                  LCD CG/DD RAM
                       70  ;it contains time-out exit if display is not present
                       71  ;***************************************************
                                                                 **************
                       72  lcd_wrdd
 E03C [04] 3C          73          pshx
 E03D [03] 37          74          pshb
 E03E [03] CE0500      75          ldx #500
 E041 [04] F61602      76  lcd001  ldab RDATLCDI
 E044 [02] C480        77          andb #%10000000
 E046 [02] 5D          78          tstb
 E047 [03] 2708        79          beq lcd014
 E049 [03] 09          80          dex
 E04A [04] 8C0000      81          cpx #0
 E04D [03] 2702        82          beq lcd014
 E04F [03] 20F0        83          bra lcd001
 E051 [04] B71601      84  lcd014  staa DATLCDD
 E054 [04] 33          85          pulb
 E055 [05] 38          86          pulx
 E056 [05] 39          87          rts
                       88  
 E057 [03] 36          89  lcd_init psha
 E058 [04] 3C          90           pshx
 E059 [02] 8638        91           ldaa  #%00111000
 E05B [04] B71600      92           staa  DATLCDI
 E05E [06] BDE384      93           jsr   ClrCOP
 E061 [03] CE03E8      94           ldx   #!1000
 E064 [06] BDE006      95           jsr   lcd_dly                    ; 7000 T 
                                                                  periods delay
 E067 [04] B71600      96           staa  DATLCDI
 E06A [03] CE03E8      97           ldx   #!1000
 E06D [06] BDE006      98           jsr   lcd_dly                    ; 700 T 
                                                                  periods delay
 E070 [04] B71600      99           staa  DATLCDI                    ; HITACHI 
                                                                            end


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 3



 E073 [02] 8638       100           ldaa  #%00111000
 E075 [06] BDE021     101           jsr   lcd_wri                    ; 8-bit, 
                                                        5x7 dot, 2 line display
 E078 [02] 860C       102           ldaa  #%00001100
 E07A [06] BDE021     103           jsr   lcd_wri                    ; display 
                                                                 on, cursor off
 E07D [02] 8606       104           ldaa  #%00000110
 E07F [06] BDE021     105           jsr   lcd_wri
 E082 [02] 860E       106           ldaa  #%00001110
 E084 [06] BDE021     107           jsr   lcd_wri
 E087 [06] BDE384     108           jsr   ClrCOP
 E08A [03] CE03E8     109           ldx   #!1000
 E08D [06] BDE006     110           jsr   lcd_dly
 E090 [06] BDE384     111           jsr   ClrCOP
 E093 [05] 38         112           pulx
 E094 [04] 32         113           pula
 E095 [05] 39         114           rts
                      115  
 E096 [04] 3C         116  lcd_prs pshx
 E097 [03] 36         117          psha
 E098 [03] 37         118          pshb
 E099 [03] 30         119          tsx
 E09A [03] 08         120          inx
 E09B [03] 08         121          inx
 E09C [03] 08         122          inx
 E09D [03] 08         123          inx
 E09E [04] A600       124          ldaa 0,x
 E0A0 [04] E601       125          ldab 1,x
 E0A2 [03] 8F         126          xgdx
 E0A3 [04] A600       127  lcd004  ldaa 0,x
 E0A5 [02] 813B       128          cmpa #!59
 E0A7 [03] 2706       129          beq  lcd005
 E0A9 [06] BDE00F     130          jsr  lcd_wrd
 E0AC [03] 08         131          inx
 E0AD [03] 20F4       132          bra  lcd004
 E0AF [03] 08         133  lcd005  inx           ; there must be at least 
                                                             endstring symbol ;
 E0B0 [03] 8F         134          xgdx
 E0B1 [03] 30         135          tsx
 E0B2 [03] 08         136          inx
 E0B3 [03] 08         137          inx
 E0B4 [03] 08         138          inx
 E0B5 [03] 08         139          inx
 E0B6 [04] A700       140          staa 0,x
 E0B8 [04] E701       141          stab 1,x
 E0BA [04] 33         142          pulb
 E0BB [04] 32         143          pula
 E0BC [05] 38         144          pulx
 E0BD [05] 39         145          rts
                      146  
 E0BE [04] 3C         147  lcd_NM  pshx
 E0BF [03] 36         148          psha
 E0C0 [03] 37         149          pshb
 E0C1 [03] 30         150          tsx
 E0C2 [03] 08         151          inx
 E0C3 [03] 08         152          inx
 E0C4 [03] 08         153          inx
 E0C5 [03] 08         154          inx


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 4



 E0C6 [04] A600       155          ldaa 0,x
 E0C8 [04] E601       156          ldab 1,x
 E0CA [03] 8F         157          xgdx
 E0CB [04] A600       158  lcd004a ldaa 0,x
 E0CD [02] 813B       159          cmpa #!59
 E0CF [03] 2706       160          beq  lcd005a
 E0D1 [06] BDE03C     161          jsr  lcd_wrdd
 E0D4 [03] 08         162          inx
 E0D5 [03] 20F4       163          bra  lcd004a
 E0D7 [03] 08         164  lcd005a inx           ; there must be at least 
                                                             endstring symbol ;
 E0D8 [03] 8F         165          xgdx
 E0D9 [03] 30         166          tsx
 E0DA [03] 08         167          inx
 E0DB [03] 08         168          inx
 E0DC [03] 08         169          inx
 E0DD [03] 08         170          inx
 E0DE [04] A700       171          staa 0,x
 E0E0 [04] E701       172          stab 1,x
 E0E2 [04] 33         173          pulb
 E0E3 [04] 32         174          pula
 E0E4 [05] 38         175          pulx
 E0E5 [05] 39         176          rts
                      177  
 E0E6 [03] 36         178  lcd_clr psha
 E0E7 [04] 3C         179          pshx
 E0E8 [02] 8601       180          ldaa  #%00000001
 E0EA [06] BDE021     181          jsr   lcd_wri
 E0ED [02] 8602       182          ldaa  #%00000010
 E0EF [06] BDE021     183          jsr   lcd_wri
 E0F2 [06] BDE384     184          jsr   ClrCOP
 E0F5 [03] CE03E8     185          ldx   #!1000
 E0F8 [06] BDE006     186          jsr   lcd_dly
 E0FB [06] BDE384     187          jsr   ClrCOP
 E0FE [05] 38         188          pulx
 E0FF [04] 32         189          pula
 E100 [05] 39         190          rts
                      191  
                      192  ****************************************************
                                                                      *********
                      193  **                                                  
                                                                             **
                      194  **  set_cursor:  postavi cursor na /B/              
                                                                             **
                      195  **                                                  
                                                                             **
                      196  ****************************************************
                                                                      *********
                      197  set_cursor
 E101 [03] D724       198             stab  CURSOR
 E103 [05] 39         199             rts
                      200  
                      201  SetCursor
 E104 [03] 36         202             psha
 E105 [03] 37         203             pshb
 E106 [04] 3C         204             pshx
 E107 [02] C108       205             cmpb  #!8
 E109 [03] 2502       206             blo   prva


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 5



 E10B [02] CB20       207             addb  #!32        ; druga zato pristej 
                                                                  razliko=40-16
 E10D [02] 8680       208  prva       ldaa  #%10000000
 E10F [02] 1B         209             aba
 E110 [06] BDE021     210             jsr   lcd_wri
 E113 [03] CE0064     211             ldx   #!100
 E116 [06] BDE006     212             jsr   lcd_dly
 E119 [05] 38         213             pulx
 E11A [04] 33         214             pulb
 E11B [04] 32         215             pula
 E11C [05] 39         216             rts
                      217  
 E11D [06] 7F0024     218  nulll:     clr   CURSOR
 E120 [05] 39         219             rts
                      220  
 E121 [06] 7F0024     221  clrscr    clr   CURSOR
 E124 [06] BDE096     222             jsr   lcd_prs
 E127      20202020   223             db    '                ;'
           20202020 
           20202020 
           20202020 
           3B 
 E138 [05] 39         224             rts
                      225  
                      226  *************************************************
                      227  ****************************************************
                                                                   ************
                      228  *lcd_02 :  16-BIT division subroutine. Dividend is 
                                                                  placed in /X/
                      229  *          and is 16-bit wide. Divisor is placed in 
                                                                     /B/ and is
                      230  *          8-bit wide. Operation performed is X/B. 
                                                                      Result is
                      231  *          returned in /X/ and reminder in /B/. /A/ 
                                                                         is not
                      232  *          altered.
                      233  *
                      234  *input :   /X/ dividend (deljenec) 16-bit
                      235  *          /B/ divisor (deljitelj) 8-bit
                      236  *operation  X/B
                      237  *output :  /X/ result
                      238  *          /B/ reminder
                      239  *
                      240  ****************************************************
                                                                   ************
                      241  *
 E139 [03] 36         242  lcd_02 psha
 E13A [02] 8611       243   ldaa #!17
 E13C [03] 36         244   psha
 E13D [02] 8600       245   ldaa #0
                      246  *
 E13F [04] 3C         247  lcd01f pshx
 E140 [03] 30         248   tsx
 E141 [03] 08         249   inx
 E142 [03] 08         250   inx
 E143 [06] 6A00       251   dec 0,x
 E145 [03] 2713       252   beq lcd022
                      253  *


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 6



 E147 [05] 38         254   pulx
 E148 [03] 8F         255   xgdx
 E149 [03] 05         256   asld
 E14A [03] 2405       257   bcc lcd020
 E14C [03] 8F         258   xgdx
 E14D [02] 48         259   asla
 E14E [02] 4C         260   inca
 E14F [03] 2002       261   bra lcd021
 E151 [03] 8F         262  lcd020 xgdx
 E152 [02] 48         263   asla
 E153 [02] 11         264  lcd021 cba
 E154 [03] 2BE9       265   bmi lcd01f
 E156 [02] 10         266   sba
 E157 [03] 08         267   inx
 E158 [03] 20E5       268   bra lcd01f
 E15A [05] 38         269  lcd022 pulx
 E15B [02] 16         270   tab
 E15C [04] 32         271   pula
 E15D [04] 32         272   pula
 E15E [05] 39         273   rts
                      274  ****************************************************
                                                                     **********
                      275  *lcd_04   :  16-bit binary number stored in /X/ is 
                                                                      converted
                      276  *            in 5-digit BCD number stored as 
                                                                      follows :
                      277  *            MS digit is stored in /B/ while least 
                                                                    significant
                      278  *            digits are stored in /X/. Upper four 
                                                                    bits of /B/
                      279  *            are zero.
                      280  *
                      281  *input   :   /X/ 16-bit binary number
                      282  *output  :   /B-X/ 5-digit BCD number
                      283  *uses    :    div_16  16-bit division subroutine
                      284  *
                      285  ****************************************************
                                                                     **********
 E15F [03] 36         286  lcd_04 psha
 E160 [02] 8600       287   ldaa #0
 E162 [02] C60A       288  lcd025 ldab #!10
 E164 [04] 8C000A     289   cpx #!10
 E167 [03] 2507       290   bcs lcd026
 E169 [06] BDE139     291   jsr lcd_02
 E16C [03] 37         292   pshb
 E16D [02] 4C         293   inca
 E16E [03] 20F2       294   bra lcd025
 E170 [03] 8F         295  lcd026 xgdx
 E171 [03] 37         296   pshb
 E172 [03] 8F         297   xgdx
 E173 [02] 4C         298   inca
 E174 [02] 8105       299  lcd027 cmpa #5
 E176 [03] 2706       300   beq lcd028
 E178 [02] 4C         301   inca
 E179 [02] C600       302   ldab #0
 E17B [03] 37         303   pshb
 E17C [03] 20F6       304   bra lcd027
 E17E [04] 33         305  lcd028 pulb


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 7



 E17F [03] 8F         306   xgdx
 E180 [04] 32         307   pula
 E181 [02] 48         308   asla
 E182 [02] 48         309   asla
 E183 [02] 48         310   asla
 E184 [02] 48         311   asla
 E185 [04] 33         312   pulb
 E186 [02] 1B         313   aba
 E187 [02] C600       314   ldab #0
 E189 [03] 8F         315   xgdx
 E18A [02] 17         316   tba
 E18B [04] 33         317   pulb
 E18C [02] 58         318   aslb
 E18D [02] 58         319   aslb
 E18E [02] 58         320   aslb
 E18F [02] 58         321   aslb
 E190 [03] 3A         322   abx
 E191 [04] 33         323   pulb
 E192 [03] 3A         324   abx
 E193 [02] 16         325   tab
 E194 [04] 32         326   pula
 E195 [05] 39         327   rts
                      328  *
                      329  *
                      330  ****************************************************
                                                                   ************
                      331  *lcd_16dd :16-bit unsigned binary number stored in 
                                                                  /D/ writes in
                      332  *          decimal to the current cursor location. 
                                                                        Leading
                      333  *          zeroes are also displayed.
                      334  *uses subroutines : lcd_00, lcd_04, lcd_wrd
                      335  *
                      336  ****************************************************
                                                                   ************
                      337  *
 E196 [03] 36         338  lcd_16dd psha
 E197 [03] 37         339   pshb
 E198 [04] 3C         340   pshx
 E199 [03] 8F         341   xgdx
 E19A [06] BDE15F     342   jsr lcd_04
 E19D [02] C40F       343   andb #%00001111
 E19F [02] 17         344   tba
 E1A0 [06] BDE1D3     345   jsr lcd_00
                      346   ;jsr lcd_wrd
 E1A3 [06] 7C0024     347   inc  CURSOR
 E1A6 [03] 8F         348   xgdx
 E1A7 [03] 36         349   psha
 E1A8 [02] 44         350   lsra
 E1A9 [02] 44         351   lsra
 E1AA [02] 44         352   lsra
 E1AB [02] 44         353   lsra
 E1AC [06] BDE1D3     354   jsr lcd_00
 E1AF [06] BDE00F     355   jsr lcd_wrd
 E1B2 [04] 32         356   pula
 E1B3 [02] 840F       357   anda #%00001111
 E1B5 [06] BDE1D3     358   jsr lcd_00
 E1B8 [06] BDE00F     359   jsr lcd_wrd


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 8



 E1BB [02] 17         360   tba
 E1BC [02] 44         361   lsra
 E1BD [02] 44         362   lsra
 E1BE [02] 44         363   lsra
 E1BF [02] 44         364   lsra
 E1C0 [06] BDE1D3     365   jsr lcd_00
 E1C3 [06] BDE00F     366   jsr lcd_wrd
 E1C6 [02] 17         367   tba
 E1C7 [02] 840F       368   anda #%00001111
 E1C9 [06] BDE1D3     369   jsr lcd_00
 E1CC [06] BDE00F     370   jsr lcd_wrd
 E1CF [05] 38         371   pulx
 E1D0 [04] 33         372   pulb
 E1D1 [04] 32         373   pula
 E1D2 [05] 39         374   rts
                      375  *
                      376  *
 E1D3 [02] 840F       377  lcd_00 anda  #%00001111
 E1D5 [02] 810A       378         cmpa  #!10
 E1D7 [03] 2A03       379         bpl   lcd016
 E1D9 [02] 8B30       380         adda  #$30
 E1DB [05] 39         381         rts
 E1DC [02] 8B37       382  lcd016 adda  #$37
 E1DE [05] 39         383         rts
                      384  
 E1DF [04] 3C         385  lcd_01 pshx
 E1E0 [03] 36         386         psha
 E1E1 [02] 8609       387         ldaa  #9
 E1E3 [03] 36         388         psha
 E1E4 [05] 38         389         pulx
 E1E5 [02] 8600       390         ldaa  #0       ; working register=0
                      391  
 E1E7 [03] 8F         392  lcd01b xgdx
 E1E8 [02] 4A         393         deca
 E1E9 [03] 2711       394         beq  lcd01e
 E1EB [02] 58         395         aslb
 E1EC [03] 2405       396         bcc  lcd01c
 E1EE [03] 8F         397         xgdx
 E1EF [02] 48         398         asla
 E1F0 [02] 4C         399         inca
 E1F1 [03] 2002       400         bra  lcd01d
 E1F3 [03] 8F         401  lcd01c xgdx
 E1F4 [02] 48         402         asla
 E1F5 [02] 11         403  lcd01d cba
 E1F6 [03] 2BEF       404         bmi  lcd01b
 E1F8 [02] 10         405         sba
 E1F9 [03] 08         406         inx
 E1FA [03] 20EB       407         bra  lcd01b
 E1FC [03] 37         408  lcd01e pshb
 E1FD [03] 8F         409         xgdx
 E1FE [03] 36         410         psha
 E1FF [04] 33         411         pulb
 E200 [04] 32         412         pula
 E201 [05] 38         413         pulx
 E202 [05] 39         414         rts
                      415  
 E203 [04] 3C         416  lcd_03 pshx
 E204 [03] CE0000     417         ldx  #0


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 9



 E207 [02] C60A       418  lcd023 ldab #!10
 E209 [02] 11         419         cba
 E20A [03] 2507       420         bcs  lcd024
 E20C [06] BDE1DF     421         jsr  lcd_01
 E20F [03] 37         422         pshb
 E210 [03] 08         423         inx
 E211 [03] 20F4       424         bra  lcd023
 E213 [03] 36         425  lcd024 psha
 E214 [03] 08         426         inx
 E215 [04] 8C0003     427  lcdff6 cpx  #3
 E218 [03] 2706       428         beq  lcdff5
 E21A [03] 08         429         inx
 E21B [02] 8600       430         ldaa #0
 E21D [03] 36         431         psha
 E21E [03] 20F5       432         bra  lcdff6
 E220 [04] 32         433  lcdff5 pula
 E221 [04] 33         434         pulb
 E222 [02] 58         435         aslb
 E223 [02] 58         436         aslb
 E224 [02] 58         437         aslb
 E225 [02] 58         438         aslb
 E226 [03] 8F         439         xgdx
 E227 [04] 33         440         pulb
 E228 [03] 3A         441         abx
 E229 [03] 8F         442         xgdx
 E22A [05] 38         443         pulx
 E22B [05] 39         444         rts
                      445  
                      446  ****************************************************
                                                                   ************
                      447  *lcd_8dd:    8-bit unsigned binary number stored in 
                                                                  /A/ writes in
                      448  *           decimal to the current cursor location. 
                                                                        Leading
                      449  *           zeroes are also displayed.
                      450  *uses subroutines :  lcd_00, lcd_03, lcd_wrd
                      451  *
                      452  ****************************************************
                                                                   ************
                      453  *
 E22C [03] 36         454  lcd_8dd psha
 E22D [03] 37         455   pshb
 E22E [06] BDE203     456   jsr lcd_03
                      457  *
 E231 [02] 840F       458   anda #%00001111
 E233 [06] BDE1D3     459   jsr lcd_00
 E236 [06] BDE00F     460   jsr lcd_wrd
 E239 [02] 17         461   tba
 E23A [02] 44         462   lsra
 E23B [02] 44         463   lsra
 E23C [02] 44         464   lsra
 E23D [02] 44         465   lsra
 E23E [06] BDE1D3     466   jsr lcd_00
 E241 [06] BDE00F     467   jsr lcd_wrd
 E244 [02] 17         468   tba
 E245 [02] 840F       469   anda #%00001111
 E247 [06] BDE1D3     470   jsr lcd_00
 E24A [06] BDE00F     471   jsr lcd_wrd


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 10



 E24D [04] 33         472   pulb
 E24E [04] 32         473   pula
 E24F [05] 39         474   rts
                      475  *
                      476  
                      477  *
                      478  ****************************************************
                                                                  *************
                      479  *            display and cursor control subroutines
                      480  *
                      481  *lcd_con: sets cursor on and display on
                      482  *lcd_cof: sets cursor off and display on
                      483  *lcd_dof: sets display and cursor off
                      484  *lcd_don: the same as lcd_cof
                      485  *
                      486  *         these subrutines does not alter other 
                                                                  parameters of
                      487  *         display nor the CG/DD RAM content
                      488  ****************************************************
                                                                  *************
 E250 [03] 36         489  lcd_con psha
 E251 [02] 860E       490   ldaa #%00001110
 E253 [06] BDE021     491   jsr lcd_wri
 E256 [04] 32         492   pula                       ;display on, cursor on, 
                                                                   blinking off
 E257 [05] 39         493   rts
 E258 [02] 01         494  lcd_cof nop
 E259 [03] 36         495  lcd_don psha
 E25A [02] 860C       496   ldaa #%00001100
 E25C [06] BDE021     497   jsr lcd_wri                ;display on, cursor 
                                                              off, blinking off
 E25F [04] 32         498   pula
 E260 [05] 39         499   rts
 E261 [03] 36         500  lcd_dof psha
 E262 [02] 8608       501    ldaa #%00001000
 E264 [06] BDE021     502   jsr lcd_wri
 E267 [04] 32         503   pula
 E268 [05] 39         504   rts
                      505  *
                      506  
                      507  ****************************************************
                                                                   ************
                      508  *lcd_8d:    8-bit unsigned binary number stored in 
                                                                  /A/ writes in
                      509  *           decimal to the current cursor location. 
                                                                        Leading
                      510  *           zeroes are not displayed.
                      511  *uses subroutines :  lcd_00, lcd_03, lcd_wrd
                      512  *
                      513  ****************************************************
                                                                   ************
                      514  *
 E269 [03] 36         515  lcd_8d psha
 E26A [03] 37         516         pshb
 E26B [06] BDE203     517         jsr  lcd_03
                      518  *
 E26E [02] 840F       519         anda #%00001111
 E270 [03] 271D       520         beq  lcd02f


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 11



 E272 [06] BDE1D3     521         jsr  lcd_00
 E275 [06] BDE00F     522         jsr  lcd_wrd
 E278 [02] 17         523         tba
 E279 [02] 44         524         lsra
 E27A [02] 44         525         lsra
 E27B [02] 44         526         lsra
 E27C [02] 44         527         lsra
 E27D [06] BDE1D3     528         jsr  lcd_00
 E280 [06] BDE00F     529         jsr  lcd_wrd
 E283 [02] 17         530         tba
 E284 [02] 840F       531         anda #%00001111
 E286 [06] BDE1D3     532         jsr  lcd_00
 E289 [06] BDE00F     533         jsr  lcd_wrd
 E28C [04] 33         534         pulb
 E28D [04] 32         535         pula
 E28E [05] 39         536         rts
 E28F [02] 17         537  lcd02f tba
 E290 [02] 84F0       538         anda #%11110000
 E292 [03] 2716       539         beq  lcd030
 E294 [02] 44         540         lsra
 E295 [02] 44         541         lsra
 E296 [02] 44         542         lsra
 E297 [02] 44         543         lsra
 E298 [06] BDE1D3     544         jsr  lcd_00
 E29B [06] BDE00F     545         jsr  lcd_wrd
 E29E [02] 17         546         tba
 E29F [02] 840F       547         anda #%00001111
 E2A1 [06] BDE1D3     548         jsr  lcd_00
 E2A4 [06] BDE00F     549         jsr  lcd_wrd
 E2A7 [04] 33         550         pulb
 E2A8 [04] 32         551         pula
 E2A9 [05] 39         552         rts
 E2AA [02] 17         553  lcd030 tba
 E2AB [02] 840F       554         anda #%00001111
 E2AD [06] BDE1D3     555         jsr  lcd_00
 E2B0 [06] BDE00F     556         jsr  lcd_wrd
 E2B3 [04] 33         557         pulb
 E2B4 [04] 32         558         pula
 E2B5 [05] 39         559         rts
                      560  *
                      561  ****************************************************
                                                                   ************
                      562  *lcd_01 :  8-bit division subroutine. Dividend 
                                                                  (deljenec) is
                      563  *          placed in /A/, divisor (deljitelj) is 
                                                                 placed in /B/.
                      564  *          Operation performed is A/B. Result is 
                                                                  placed in /A/
                      565  *          while reminder is placed in /B/. 
                                                           Division is unsigned
                      566  *
                      567  *input:       /A/...dividend (deljenec)
                      568  *             /B/...divisor (deljitelj)   A/B
                      569  *output:      /A/...result
                      570  *             /B/...remainder
                      571  *
                      572  ****************************************************
                                                                   ************


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 12



 E2B6 [04] 3C         573  dlcd_01    pshx
 E2B7 [03] 36         574            psha
 E2B8 [02] 8609       575            ldaa  #9
 E2BA [03] 36         576            psha
 E2BB [05] 38         577            pulx
 E2BC [02] 8600       578            ldaa  #0
                      579  *
 E2BE [03] 8F         580  dlcd01b   xgdx
 E2BF [02] 4A         581            deca
 E2C0 [03] 2711       582            beq   dlcd01e
                      583  *
 E2C2 [02] 58         584            aslb
 E2C3 [03] 2405       585            bcc   dlcd01c
 E2C5 [03] 8F         586            xgdx
 E2C6 [02] 48         587            asla
 E2C7 [02] 4C         588            inca
 E2C8 [03] 2002       589            bra   dlcd01d
 E2CA [03] 8F         590  dlcd01c   xgdx
 E2CB [02] 48         591            asla
 E2CC [02] 11         592  dlcd01d   cba
 E2CD [03] 2BEF       593            bmi   dlcd01b
 E2CF [02] 10         594            sba
 E2D0 [03] 08         595            inx
 E2D1 [03] 20EB       596            bra   dlcd01b
 E2D3 [03] 37         597  dlcd01e   pshb
 E2D4 [03] 8F         598            xgdx
 E2D5 [03] 36         599            psha
 E2D6 [04] 33         600            pulb
 E2D7 [04] 32         601            pula
 E2D8 [05] 38         602            pulx
 E2D9 [05] 39         603            rts
                      604  
                      605  ***** /A/ vrednost  /B/ cursor posicionn ******
                      606  
 E2DA [03] 36         607  IzpisiUre:psha
 E2DB [03] 37         608            pshb
 E2DC [02] C60A       609            ldab  #!10
 E2DE [06] BDE2B6     610            jsr   dlcd_01
 E2E1 [03] 37         611            pshb
 E2E2 [02] 8B30       612            adda  #!48
 E2E4 [06] BDE00F     613            jsr   lcd_wrd
 E2E7 [02] 8030       614            suba  #!48
 E2E9 [04] 32         615            pula
 E2EA [02] 8B30       616            adda  #!48
 E2EC [06] BDE00F     617            jsr   lcd_wrd
 E2EF [04] 33         618            pulb
 E2F0 [04] 32         619            pula
 E2F1 [05] 39         620            rts
                      621  
 E2F2 [03] 37         622  lcd_cmr pshb
 E2F3 [03] 36         623          psha
 E2F4 [02] 16         624          tab
 E2F5 [02] C601       625          ldab  #1
 E2F7 [02] 8614       626          ldaa  #%00010100            ; shift cursor 
                                                                          right
 E2F9 [02] 5D         627  lcd006  tstb
 E2FA [03] 2706       628          beq   lcd007
 E2FC [06] BDE021     629          jsr   lcd_wri


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 13



 E2FF [02] 5A         630          decb
 E300 [03] 20F7       631          bra   lcd006
 E302 [04] 32         632  lcd007  pula
 E303 [04] 33         633          pulb
 E304 [05] 39         634          rts
 E305 [03] 37         635  lcd_cml pshb
 E306 [03] 36         636   psha
 E307 [02] 16         637   tab
 E308 [02] 8610       638   ldaa #%00010000            ; shift cursor left
 E30A [02] 5D         639  lcd008 tstb
 E30B [03] 2706       640   beq lcd009
 E30D [06] BDE021     641   jsr lcd_wri
 E310 [02] 5A         642   decb
 E311 [03] 20F7       643   bra lcd008
 E313 [04] 32         644  lcd009 pula
 E314 [04] 33         645   pulb
 E315 [05] 39         646   rts
 E316 [03] 36         647  lcd_c10 psha
 E317 [02] 8680       648   ldaa #%10000000            ; sets dd ram address 00
 E319 [06] BDE021     649   jsr lcd_wri
 E31C [04] 32         650   pula
 E31D [05] 39         651   rts
 E31E [03] 36         652  lcd_c18 psha
 E31F [02] 8688       653   ldaa #%10001000            ; sets dd ram address 08
 E321 [06] BDE021     654   jsr lcd_wri
 E324 [04] 32         655   pula
 E325 [05] 39         656   rts
 E326 [03] 36         657  lcd_c20 psha
 E327 [02] 86C0       658   ldaa #%11000000            ; sets dd ram address 40
 E329 [06] BDE021     659   jsr lcd_wri
 E32C [04] 32         660   pula
 E32D [05] 39         661   rts
 E32E [03] 36         662  lcd_c28 psha
 E32F [02] 86C8       663   ldaa #%11001000            ; sets dd ram address 48
 E331 [06] BDE021     664   jsr lcd_wri
 E334 [04] 32         665   pula
 E335 [05] 39         666   rts
                      667  
                      668  
 E336 [03] CE0000     669  DISPLAY:  ldx   #ZASLON
 E339 [02] 5F         670            clrb
 E33A [06] BDE104     671            jsr   SetCursor
 E33D [02] C110       672  doit      cmpb  #!16
 E33F [03] 2715       673            beq   Konceki
 E341 [02] C108       674            cmpb  #8
 E343 [03] 2603       675            bne   naprek
 E345 [06] BDE326     676            jsr   lcd_c20
 E348 [04] A600       677  naprek    ldaa  0,x
 E34A [06] BDE03C     678            jsr   lcd_wrdd
 E34D [03] 2003       679            bra   NiZA
 E34F [06] BDE2F2     680  NiZAL     jsr   lcd_cmr
 E352 [03] 08         681  NiZA      inx
 E353 [02] 5C         682            incb
 E354 [03] 20E7       683            bra   doit
 E356 [05] 39         684  Konceki   rts
                      685  
 E357 [06] BDE057     686  initialo: jsr   lcd_init
 E35A [02] 860E       687            ldaa  #%00001110


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 14



 E35C [06] BDE021     688            jsr   lcd_wri
 E35F [06] BDE384     689            jsr   ClrCOP
 E362 [03] CE03E8     690            ldx   #!1000
 E365 [06] BDE006     691            jsr   lcd_dly
 E368 [06] BDE0E6     692            jsr   lcd_clr
 E36B [02] C60E       693            ldab  #$E
 E36D [06] BDE258     694            jsr   lcd_cof
 E370 [06] BDE0E6     695  Konecx    jsr   lcd_clr
 E373 [05] 39         696            rts
                      697  
                      698  COP                                 ; this version 
                                                     of SIM11 has COP always on
 E374 [03] CEFFFE     699  OPCODE    ldx   #$fffe              ; like 9h in 
                                                                CONFIG register
 E377 [03] 6E00       700            jmp   0,x
                      701  
 E379 [04] B61039     702  InitCop   ldaa  $1039
 E37C [02] 84FC       703            anda  #$ff-3
 E37E [02] 8A0A       704            oraa  #$a
 E380 [04] B71039     705            staa  $1039
 E383 [05] 39         706            rts
                      707  
 E384 [03] 36         708  ClrCOP    psha
 E385 [02] 8655       709            ldaa  #$55
 E387 [04] B7103A     710            staa  $103A
 E38A [02] 86AA       711            ldaa  #$AA
 E38C [04] B7103A     712            staa  $103A
 E38F [04] 32         713            pula
 E390 [05] 39         714            rts
                      715  
 E391 [06] BDE379     716  main      jsr   InitCOP          ; Initialize COP 
                                                                          timer
 E394 [06] BDE384     717            jsr   ClrCOP
 E397 [06] BDE357     718            jsr   initialo         ; Initialize LCD
 E39A [06] BDE384     719            jsr   ClrCOP
                      720  
 E39D [02] 8680       721            ldaa  #$80             ; OC enable
 E39F [04] B71022     722            staa  $1022
 E3A2 [02] 8680       723            ldaa  #$80             ; TOF enable
 E3A4 [04] B71024     724            staa  $1024
                      725  
 E3A7 [03] CE0000     726            ldx   #0
 E3AA [04] DF20       727            stx   TOFS
 E3AC [04] DF22       728            stx   OC1S
                      729  
 E3AE [06] BDE121     730            jsr   clrscr
 E3B1 [02] 0E         731            cli
                      732  
 E3B2 [06] 7F0024     733  mainloop  clr   CURSOR
 E3B5 [04] DC20       734            ldd   TOFS
 E3B7 [06] BDE196     735            jsr   lcd_16dd        ; print number of 
                                                      Timer Overflow Interrupts
 E3BA [02] C608       736            ldab  #8
 E3BC [03] D724       737            stab  CURSOR
 E3BE [04] DC22       738            ldd   OC1S
 E3C0 [06] BDE196     739            jsr   lcd_16dd
 E3C3 [06] BDE384     740            jsr   ClrCOP
 E3C6 [03] 20EA       741            bra   mainloop


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 15



                      742  
 E3C8 [03] CE1000     743  OCR1INT   ldx   #$1000
 E3CB [07] 1D237F     744            bclr  $23,x,$7F
 E3CE [03] CCC350     745            ldd   #!50000         ; Interrupt every 
                                                                          25 ms
 E3D1 [06] F31016     746            addd  $1016
 E3D4 [05] FD1016     747            std   $1016
 E3D7 [04] DE22       748            ldx   OC1S
 E3D9 [03] 08         749            inx
 E3DA [04] DF22       750            stx   OC1S
 E3DC [03] 9623       751            ldaa  OC1S+1
 E3DE [04] B71E00     752            staa  DIODE1
 E3E1 [12] 3B         753  nouse     rti
                      754  
 E3E2 [03] CE1000     755  TOF       ldx   #$1000
 E3E5 [07] 1D257F     756            bclr  $25,x,$7F
 E3E8 [04] DE20       757            ldx   TOFS
 E3EA [03] 08         758            inx
 E3EB [04] DF20       759            stx   TOFS
 E3ED [03] 9621       760            ldaa  TOFS+1
 E3EF [04] B71C00     761            staa  DIODE2
 E3F2 [06] BDE336     762            jsr   DISPLAY
 E3F5 [12] 3B         763            rti
                      764  
 FFD6                 765            org   vectors
 FFD6      E3E1       766            fdb   nouse            ; SCI interrupt
 FFD8      E3E1       767            fdb   nouse
 FFDA      E3E1       768            fdb   nouse
 FFDC      E3E1       769            fdb   nouse
 FFDE      E3E2       770            fdb   TOF
 FFE0      E3E1       771            fdb   nouse
 FFE2      E3E1       772            fdb   nouse
 FFE4      E3E1       773            fdb   nouse
 FFE6      E3E1       774            fdb   nouse
 FFE8      E3C8       775            fdb   OCR1INT      ;e8
 FFEA      E3E1       776            fdb   nouse        ;ea
 FFEC      E3E1       777            fdb   nouse        ;ec
 FFEE      E3E1       778            fdb   nouse        ;ee
 FFF0      E3E1       779            fdb   nouse        ;f0
 FFF2      E3E1       780            fdb   nouse        ;f2
 FFF4      E3E1       781            fdb   nouse        ;f4
 FFF6      E3E1       782            fdb   nouse        ;f6
 FFF8      E374       783            fdb   OPCODE       ;f8
 FFFA      E374       784            fdb   COP          ;fa
 FFFC      E000       785            fdb   start        ;fc
 FFFE      E000       786            fdb   start        ;fe
                      787  
 0000                 788            end
                      789  **********************************
                      790  
                      791  

 Symbol Table 

CLRCOP           E384
CLRSCR           E121
COP              E374
CURSOR           0024


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 16



DATLCDD          1601
DATLCDI          1600
DIODE1           1E00
DIODE2           1C00
DIODE3           1A00
DISPLAY          E336
DLCD01B          E2BE
DLCD01C          E2CA
DLCD01D          E2CC
DLCD01E          E2D3
DLCD_01          E2B6
DOIT             E33D
INITCOP          E379
INITIALO         E357
IZPISIURE        E2DA
KONCEKI          E356
KONECX           E370
LCD000           E026
LCD001           E041
LCD004           E0A3
LCD004A          E0CB
LCD005           E0AF
LCD005A          E0D7
LCD006           E2F9
LCD007           E302
LCD008           E30A
LCD009           E313
LCD014           E051
LCD015           E007
LCD016           E1DC
LCD01B           E1E7
LCD01C           E1F3
LCD01D           E1F5
LCD01E           E1FC
LCD01F           E13F
LCD020           E151
LCD021           E153
LCD022           E15A
LCD023           E207
LCD024           E213
LCD025           E162
LCD026           E170
LCD027           E174
LCD028           E17E
LCD02F           E28F
LCD030           E2AA
LCDFF5           E220
LCDFF6           E215
LCDFFF           E036
LCD_00           E1D3
LCD_01           E1DF
LCD_02           E139
LCD_03           E203
LCD_04           E15F
LCD_16DD         E196
LCD_8D           E269
LCD_8DD          E22C
LCD_C10          E316


PRIMER.S               Assembled with IASM   06/20/1996  16:35  PAGE 17



LCD_C18          E31E
LCD_C20          E326
LCD_C28          E32E
LCD_CLR          E0E6
LCD_CML          E305
LCD_CMR          E2F2
LCD_COF          E258
LCD_CON          E250
LCD_DLY          E006
LCD_DOF          E261
LCD_DON          E259
LCD_INIT         E057
LCD_NM           E0BE
LCD_PRS          E096
LCD_WRD          E00F
LCD_WRDD         E03C
LCD_WRI          E021
MAIN             E391
MAINLOOP         E3B2
NAPREK           E348
NIZA             E352
NIZAL            E34F
NOUSE            E3E1
NULLL            E11D
OC1S             0022
OCR1INT          E3C8
OPCODE           E374
PRVA             E10D
RDATLCDI         1602
SETCURSOR        E104
SET_CURSOR       E101
START            E000
TOF              E3E2
TOFS             0020
VECTORS          FFD6
ZASLON           0000
