home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s230 / 2.ddi / DEMO96.LST < prev    next >
Encoding:
File List  |  1980-01-01  |  15.2 KB  |  415 lines

  1. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   1
  2.                                                                    01-01-80
  3.  
  4.  
  5.                 ; Demo96.ASM    8096 Simulator Demonstration
  6.                 
  7.                 ; This program monitors Analog Channel 3, and
  8.                 ; changes operating states between "Rising"
  9.                 ; and "Falling", depending on a comparison
  10.                 ; between the current analog value and predefined
  11.                 ; high and low threshold values.  When the value is
  12.                 ; between the thresholds, the state is not changed.
  13.                 
  14.                 ; In the "Rising" state, an embedded macro is invoked
  15.                 ; that increases the analog value, while in the
  16.                 ; "Falling" state, an embedded macro is invoked to
  17.                 ; decrease the analog value.
  18.                 
  19.  0000           Fseg    ; Special Function Regs
  20.                 
  21.  0000 =         R0    word 00h
  22.  0002 =         AD_Cmd    data 02h
  23.  0002 =         ADResL    data 02h
  24.  0003 =         ADResH    data 03h
  25.  0003 =         HSIMode data 03h
  26.  0004 =         HSITime word 04h
  27.  0004 =         HSOTime word 04h
  28.  0006 =         HSIStat data 06h
  29.  0006 =         HSOCmd    data 06h
  30.  0007 =         SBUF_Rx data 07h
  31.  0007 =         SBUF_Tx data 07h
  32.  0008 =         IntMask data 08h
  33.  0009 =         IntPend data 09h
  34.  000A =         WDogClr data 0Ah
  35.  000A =         T1    word 0Ah
  36.  000C =         T2    word 0Ch
  37.  000E =         Baud    data 0Eh
  38.  000E =         P0    data 0Eh
  39.  000F =         P1    data 0Fh
  40.  0010 =         P2    data 10h
  41.  0011 =         SPCon    data 11h
  42.  0011 =         SPStat    data 11h
  43.  0015 =         IOC0    data 15h
  44.  0015 =         IOS0    data 15h
  45.  0016 =         IOC1    data 16h
  46.  0016 =         IOS1    data 16h
  47.  0017 =         PWMCtrl data 17h
  48.                 
  49.  0020           endS
  50.                 
  51.                 ;    Data Definitions
  52.                 
  53.  0024 =         AX    WORD 24h   ; Word register
  54.  7532 =         Val1    Equ  7532h ; Integer value
  55.  0018 =         SP    word 18h   ; Stack Pointer
  56.  0024 =         AL    data AX    ; byte components
  57.  0025 =         AH    data AX+1
  58.  0028 =         BX    word 28h
  59.  0028 =         BL    data BX
  60. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   2
  61.                                                                    01-01-80
  62.  
  63.  
  64.  0029 =         BH    data BX+1
  65.  002A =         CX    word 2Ah
  66.  002A =         CL    data CX
  67.  002B =         CH    data CX+1
  68.  0032 =         DX    word 32h
  69.  0032 =         DL    data DX
  70.  0033 =         DH    data DX+1
  71.                 
  72.  0052 =         SerStat data 52h
  73.  0053 =         SerData data 53h
  74.  0054 =         P2Image data 54h
  75.                 
  76.  0056 =         AnStat     data 56h ; for status tests
  77.  0002 =         UpBit     equ 02   ; steering bit
  78.  0058 =         AnValue  data 58h ; data holding word
  79.  0191 =         HiThresh equ 401  ; upper threshold
  80.  0129 =         LoThresh equ 297  ; lower threshold
  81.                 
  82.                 ;%S    Copyright 1985 Cybernetic Micro Systems, Inc.
  83.                 
  84.  2000           org 2000h    ; Interrupt Vectors
  85.                 
  86.  2000 4621      dw TimerInt
  87.  2002 4721      dw ADConvInt
  88.  2004 5121      dw HSIDataInt
  89.  2006 5821      dw HSOLineInt
  90.  2008 7321      dw HSIzeroInt
  91.  200A 7421      dw SoftHSOInt
  92.  200C 9221      dw SerialInt
  93.  200E A821      dw ExtInt
  94.  2010 AF21      dw TRAPInt
  95.                 
  96.                 
  97.  2080           Org 2080h    ; powerup reset address
  98.                 
  99.                 ; Initialize various hardware functions
  100.                 
  101.                 Start:
  102.  2080 A1A00018  ld  SP,#0A0h    ; stack area
  103.  2084 A1420024  ld  AX,#42h
  104.  2088 A0242A    ld  CX,AX
  105.  208B 662B28    add BX,[CX]+
  106.  208E 67247632  add DX,76h[AX]
  107.                 
  108.                 ; Define two macros, one to increase the
  109.                 ; analog voltage on channel 3, the other
  110.                 ; to decrease it.
  111.                 
  112.  2092 B02425    ldb AH,AL
  113.  2095 B11A2A    ldb CL,#26    ;!3 A3+47,; Analog Voltage Rising
  114.  2098 B22A28    ldb BL,[CX]
  115.  209B B3250020  ldb DH,2000h[AX] ;!4 A3-25,; Analog Voltage Falling
  116. -209F 33        
  117.                 
  118.                 
  119. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   3
  120.                                                                    01-01-80
  121.  
  122.  
  123.                 ClearDog:      ;:Enable Watch Dog
  124.  20A0 B11E0A    ldb WDogClr,#01Eh
  125.  20A3 B1E10A    ldb WDogClr,#0E1h ; clear watch dog
  126.                 
  127.                 PWM_On:      ;:Set PWM
  128.  20A6 B12517    ldb PWMCtrl,#25h ; turn on PWM
  129.                 
  130.                 AtoD_On:    ;:A/D Value
  131.  20A9 B10B26    ldb 26h,#0Bh    ; channel 3 to start
  132.  20AC B02602    ldb AD_Cmd,26h    ; get initial value
  133.                 
  134.  20AF 640446    add 46h,04    ; unload HSI FIFO
  135.                 
  136.                 HSOLineOn:    ;:High Speed CAM On
  137.  20B2 B13106    ldb HSOCmd,#31h ; set HSO line 1
  138.  20B5 B13147    ldb 47h,#31h    ; record of HSO cmd
  139.  20B8 A1100048  ld  48h,#10h
  140.  20BC 640A48    add 48h,T1    ; get T1 + 10h
  141.  20BF A04804    ld  HSOTime,48h ; write time to HSO
  142.                 
  143.                 SerialOn:    ;:Enable Serial
  144.  20C2 B1110E    ldb Baud,#11h    ; baud rate 8011h
  145.  20C5 B1800E    ldb Baud,#80h
  146.  20C8 B10911    ldb SPCon,#09h     ; mode 1, REN
  147.  20CB B12052    ldb SerStat,#20h ; Transmitter ready
  148.                 
  149.                 InterruptsOn:
  150.  20CE B15515    ldb IOC0,#55h      ; IOC0, enable HSI lines
  151.  20D1 B12D16    ldb IOC1,#02Dh      ; IOC1, PWM,T1,T2,TxD
  152.  20D4 B1C154    ldb P2Image,#0C1h ; initial Port 2 outputs
  153.  20D7 B1FF08    ldb IntMask,#0FFh ; enable all interrupts
  154.  20DA FB        ei
  155.  20DB B10456    ldb AnStat,#04h   ; set status byte, set a value
  156.  20DE A18D0158  ld  AnValue,#LoThresh+100
  157.                 
  158.                 ; Main Program Loop
  159.                 
  160.                 MainLoop:
  161.  20E2 1749      incb 73
  162.  20E4 65210024  add AX,#21h
  163.  20E8 918054    orb P2Image,#80h
  164.  20EB B05410    ldb P2,P2Image    ; set P2.7
  165.  20EE 0736      inc 36H
  166.  20F0 A132753A  ld  58,#Val1    ; 16 bit data, LSB first
  167.                 
  168.                 ; Only check the analog state while byte 36h,
  169.                 ; bit 2 is low.  36h incremented once per loop.
  170.                 
  171.  20F4 3A3608    jbs 36h,2,SkipChk ;?Skip Tests
  172.                 
  173.  20F7 282C      scall Test_Analog
  174.                 
  175.  20F9 080524    shr AX,#5
  176.  20FC 843A24    xor AX,58    ; modify AX
  177.                 
  178. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   4
  179.                                                                    01-01-80
  180.  
  181.  
  182.                 SkipChk:
  183.  20FF 717F54    andb P2Image,#NOT 80h
  184.  2102 B05410    ldb P2,P2Image    ; clear P2.7
  185.  2105 FE5C282A  mulb 92h,CL,BL
  186. -2109 92        
  187.                 
  188.                 
  189.                 ; Branch to Up or Down routine, depending on
  190.                 ; state set by TestAnalog subroutine
  191.                 
  192.  210A 3A560C    jbs AnStat,UpBit,GoingUp ;?Rising Value
  193.                 
  194.                 ; Change P1 value for DeCrementing, and
  195.                 ; lower analog value through embedded macro
  196.                 
  197.                 GoingDown:     ;:Falling Analog
  198.  210D B1DC0F    ldb P1,#0DCh     ; decrementing
  199.  2110 65B17324  add AX,#Val1-385 ;#4
  200.  2114 B0492A    ldb CL,73     ; copy byte 73 to CL
  201.  2117 27C9      sjmp MainLoop
  202.                 
  203.                 ; Change P1 value for AdDing, and raise
  204.                 ; analog value through embedded macro
  205.                 
  206.                 GoingUp:    ;:Rising Analog
  207.  2119 B1AD0F    ldb P1,#0ADh    ; incrementing
  208.  211C B04932    ldb DL,73    ;#3
  209.  211F 69697724  sub AX,#Val1+567
  210.  2123 27BD      sjmp MainLoop
  211.                 
  212.                 ; Start a new conversion if one is not in
  213.                 ; progress.  Use the old converted value to
  214.                 ; check against the threshold.    If above the
  215.                 ; high threshold, set the "Falling" state and
  216.                 ; drive P2.6 low.  If below the low threshold,
  217.                 ; set the "Rising" state and drive P2.6 high.
  218.                 
  219.                 Test_Analog:        ;:Threshold Check
  220.  2125 3B0203    jbs ADResL,3,ConvOK ;?In Process
  221.  2128 B02602    ldb AD_Cmd,26h        ; else start a new conversion
  222.                 
  223.                 ConvOK:
  224.  212B 89910158  cmp AnValue,#HiThresh
  225.  212F D607      jge OverMax          ;?Max Value
  226.  2131 89290158  cmp AnValue,#LoThresh
  227.  2135 DE08      jlt UnderMin          ;?Min Value
  228.                 NoChange:
  229.  2137 F0        ret
  230.                 
  231.                 OverMax:          ;:Upper Limit
  232.  2138 B1FB56    ldb AnStat,#Not 04h   ; switch to down mode
  233.  213B 71BF54    andb P2Image,#Not 40h ; make P2.6 low
  234.  213E F0        ret
  235.                 
  236.                 UnderMin:          ;:Lower Limit
  237. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   5
  238.                                                                    01-01-80
  239.  
  240.  
  241.  213F B10456    ldb AnStat,#04h       ; switch to up mode
  242.  2142 714054    andb P2Image,#40h     ; make P2.6 high
  243.  2145 F0        ret
  244.                 
  245.                 TimerInt:          ;:Timer Int
  246.  2146 F0        ret
  247.                 
  248.                 ADConvInt:          ;:A/D Int
  249.  2147 B00258    ldb AnValue,ADResL    ; get low result
  250.  214A B00359    ldb AnValue+1,ADResH  ; and high
  251.  214D 080658    shr AnValue,#6          ; align to bytes
  252.  2150 F0        ret
  253.                 
  254.                 HSIDataInt:          ;:HSI Event
  255.  2151 B00643    ldb 43h,HSIStat       ; get status
  256.  2154 A00444    ld  44h,HSITime       ; get HSI time
  257.  2157 F0        ret
  258.                 
  259.                 HSOLineInt:          ;:HSO Line
  260.  2158 F2        pushf              ; disable ints
  261.  2159 1747      incb 47h          ; record of HSO cmd
  262.  215B 334703    jbc 47h,3,HSO_Ok      ;?Cmd OK
  263.  215E 952047    xorb 47h,#20h          ; change set/clear bit
  264.                 HSO_Ok:
  265.  2161 713747    andb 47h,#37h
  266.  2164 B04706    ldb HSOCmd,47h          ; set HSO cmd
  267.  2167 A1250048  ld  48h,#25h
  268.  216B 640A48    add 48h,T1          ; get T1 + 25h
  269.  216E A04804    ld  HSOTime,48h       ; write time to HSO
  270.  2171 F3        popf
  271.  2172 F0        ret
  272.                 
  273.                 HSIzeroInt:          ;:HSI.0 Int
  274.  2173 F0        ret
  275.                 
  276.                 SoftHSOInt:          ;:HSO Timer
  277.  2174 F2        pushf
  278.  2175 174B      incb 4Bh
  279.  2177 324B03    jbc 4Bh,2,ValOK       ;?Not C or D
  280.  217A 91024B    orb 4Bh,#02h
  281.                 ValOK:
  282.  217D 710F4B    andb 4Bh,#0Fh
  283.  2180 91384B    orb 4Bh,#38h          ; HSO events 8 - F
  284.  2183 B04B06    ldb HSOCmd,4Bh
  285.  2186 A1220048  ld  48h,#22h
  286.  218A 640A48    add 48h,0Ah          ; T1 + 22h
  287.  218D A04804    ld  HSOTime,48h       ; set HSO time
  288.  2190 F3        popf
  289.  2191 F0        ret
  290.                 
  291.                 SerialInt:          ;:Serial Data
  292.  2192 901152    orb SerStat,SPStat    ; preserve status bits
  293.  2195 365206    jbc SerStat,6,ChkTx   ;?Not Receiver
  294.  2198 71BF52    andb SerStat,#NOT 40h ; clear RI bit
  295.  219B B00753    ldb SerData,Sbuf_Rx   ; read receiver
  296. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   6
  297.                                                                    01-01-80
  298.  
  299.  
  300.                 
  301.                 ChkTx:
  302.  219E 355206    jbc SerStat,5,SerDone ;?Not Transmitter
  303.  21A1 71DF52    andb SerStat,#NOT 20h ; clear TI bit
  304.  21A4 B02507    ldb Sbuf_Tx,AH          ; write a char
  305.                 
  306.                 SerDone:
  307.  21A7 F0        ret
  308.                 
  309.                 ExtInt:           ;:External Int
  310.  21A8 B11E0A    ldb WDogClr,#01Eh
  311.  21AB B1E10A    ldb WDogClr,#0E1h     ; clear watch dog
  312.  21AE F0        ret
  313.                 
  314.                 TRAPInt:          ;:TRAP Instr
  315.  21AF F0        ret
  316.                 
  317.  21B0 FD        nop
  318.                 
  319.                 ;%E    Copyright 1985 Cybernetic Micro Systems, Inc.
  320.                 
  321.  2080           END START          ; Starting Address
  322. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   7
  323.                                                                    01-01-80
  324.  
  325.  
  326.  
  327.  ;%T   Symbol Name            Type Value
  328.  
  329.  ADCONVINT . . . . . . . . . . . L 2147
  330.  ADRESH. . . . . . . . . . . . . F 0003
  331.  ADRESL. . . . . . . . . . . . . F 0002
  332.  AD_CMD. . . . . . . . . . . . . F 0002
  333.  AH. . . . . . . . . . . . . . . D 0025
  334.  AL. . . . . . . . . . . . . . . D 0024
  335.  ANSTAT. . . . . . . . . . . . . D 0056
  336.  ANVALUE . . . . . . . . . . . . D 0058
  337.  ATOD_ON . . . . . . . . . . . . L 20A9
  338.  AX. . . . . . . . . . . . . . . W 0024
  339.  BAUD. . . . . . . . . . . . . . F 000E
  340.  BH. . . . . . . . . . . . . . . D 0029
  341.  BL. . . . . . . . . . . . . . . D 0028
  342.  BX. . . . . . . . . . . . . . . W 0028
  343.  CH. . . . . . . . . . . . . . . D 002B
  344.  CHKTX . . . . . . . . . . . . . L 219E
  345.  CL. . . . . . . . . . . . . . . D 002A
  346.  CLEARDOG. . . . . . . . . . . . L 20A0
  347.  CONVOK. . . . . . . . . . . . . L 212B
  348.  CX. . . . . . . . . . . . . . . W 002A
  349.  DH. . . . . . . . . . . . . . . D 0033
  350.  DL. . . . . . . . . . . . . . . D 0032
  351.  DX. . . . . . . . . . . . . . . W 0032
  352.  EXTINT. . . . . . . . . . . . . L 21A8
  353.  GOINGDOWN . . . . . . . . . . . L 210D
  354.  GOINGUP . . . . . . . . . . . . L 2119
  355.  HITHRESH. . . . . . . . . . . . I 0191
  356.  HSIDATAINT. . . . . . . . . . . L 2151
  357.  HSIMODE . . . . . . . . . . . . F 0003
  358.  HSISTAT . . . . . . . . . . . . F 0006
  359.  HSITIME . . . . . . . . . . . . G 0004
  360.  HSIZEROINT. . . . . . . . . . . L 2173
  361.  HSOCMD. . . . . . . . . . . . . F 0006
  362.  HSOLINEINT. . . . . . . . . . . L 2158
  363.  HSOLINEON . . . . . . . . . . . L 20B2
  364.  HSOTIME . . . . . . . . . . . . G 0004
  365.  HSO_OK. . . . . . . . . . . . . L 2161
  366.  INTERRUPTSON. . . . . . . . . . L 20CE
  367.  INTMASK . . . . . . . . . . . . F 0008
  368.  INTPEND . . . . . . . . . . . . F 0009
  369.  IOC0. . . . . . . . . . . . . . F 0015
  370.  IOC1. . . . . . . . . . . . . . F 0016
  371.  IOS0. . . . . . . . . . . . . . F 0015
  372.  IOS1. . . . . . . . . . . . . . F 0016
  373.  LOTHRESH. . . . . . . . . . . . I 0129
  374.  MAINLOOP. . . . . . . . . . . . L 20E2
  375.  NOCHANGE. . . . . . . . . . . . L 2137
  376.  OVERMAX . . . . . . . . . . . . L 2138
  377.  P0. . . . . . . . . . . . . . . F 000E
  378.  P1. . . . . . . . . . . . . . . F 000F
  379.  P2. . . . . . . . . . . . . . . F 0010
  380.  P2IMAGE . . . . . . . . . . . . D 0054
  381. The Cybernetic Micro Systems 8096 Family Assembler, Version 3.01   Page   8
  382.                                                                    01-01-80
  383.  
  384.  
  385.  PWMCTRL . . . . . . . . . . . . F 0017
  386.  PWM_ON. . . . . . . . . . . . . L 20A6
  387.  R0. . . . . . . . . . . . . . . G 0000
  388.  SBUF_RX . . . . . . . . . . . . F 0007
  389.  SBUF_TX . . . . . . . . . . . . F 0007
  390.  SERDATA . . . . . . . . . . . . D 0053
  391.  SERDONE . . . . . . . . . . . . L 21A7
  392.  SERIALINT . . . . . . . . . . . L 2192
  393.  SERIALON. . . . . . . . . . . . L 20C2
  394.  SERSTAT . . . . . . . . . . . . D 0052
  395.  SKIPCHK . . . . . . . . . . . . L 20FF
  396.  SOFTHSOINT. . . . . . . . . . . L 2174
  397.  SP. . . . . . . . . . . . . . . W 0018
  398.  SPCON . . . . . . . . . . . . . F 0011
  399.  SPSTAT. . . . . . . . . . . . . F 0011
  400.  START . . . . . . . . . . . . . L 2080
  401.  T1. . . . . . . . . . . . . . . G 000A
  402.  T2. . . . . . . . . . . . . . . G 000C
  403.  TEST_ANALOG . . . . . . . . . . L 2125
  404.  TIMERINT. . . . . . . . . . . . L 2146
  405.  TRAPINT . . . . . . . . . . . . L 21AF
  406.  UNDERMIN. . . . . . . . . . . . L 213F
  407.  UPBIT . . . . . . . . . . . . . I 0002
  408.  VAL1. . . . . . . . . . . . . . I 7532
  409.  VALOK . . . . . . . . . . . . . L 217D
  410.  WDOGCLR . . . . . . . . . . . . F 000A
  411.  
  412.  ;%Z 
  413.  
  414.  00 Errors  (0000)
  415.