home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm_kit / spacewar.asm < prev    next >
Assembly Source File  |  1985-06-21  |  3KB  |  62 lines

  1. ;SPACEWARS--Uses Timer2 to run speaker
  2. ;  produces weird rising bubble
  3. ;
  4. ;********************************************************************
  5. prognam       segment                  ;define code segment
  6. ;
  7. ;--------------------------------------------------------------------
  8. main          proc      far            ;main part of program
  9. ;
  10.               assume    cs:prognam
  11. ;
  12. ;REM          org       100h           ;first address
  13. ;
  14. ;
  15. start:                                 ;starting execution address
  16. ;
  17. ;initial value of 1/pitch
  18.               mov  bx,200h             ;set 1/pitch in BX
  19. ;
  20. ;
  21. ;sound the tone
  22. sounder:
  23.               mov al,10110110b         ;magic number
  24.               out 43h,al                ;to timer2
  25. tone:         mov ax,bx                ;move 1/pitch into AX
  26.               out 42h,al               ;LSB into timer2
  27.               mov al,ah                ;MSB to AL, then
  28.               out 42h,al               ;   to timer2
  29.               in al,61h                ;read port B into AL
  30.               or al,3                  ;turn on bits 0 and 1
  31.               out 61h,al               ;to turn speaker on
  32. ;
  33. ;increase the pitch and wait a bit
  34.               dec bx                   ;increase the pitch
  35.               jz  start                ;when BX=0, reset it
  36. ;
  37.               mov cx,800d              ;setup wait loop
  38. wait:         loop wait                ;wait
  39. ;
  40. ;check if keyboard character typed
  41.               mov ah,0bh               ;get keyboard status
  42.               int 21h                  ;call DOS
  43.               inc al                   ;if AL not FF, then
  44.               jnz sounder              ;  no key pressed
  45. ;key pressed, return to DOS
  46.               int 20h                  ;return to DOS
  47. ;
  48. main          endp                     ;end main part of program
  49. ;--------------------------------------------------------------------
  50. prognam       ends                     ;end code segment
  51. ;********************************************************************
  52.               end                      ;end of assembly
  53. ;====================================================================
  54. main          endp                     ;end main part of program
  55. ;--------------------------------------------------------------------
  56. ;
  57. prognam       ends                    ;end of code segment
  58. ;********************************************************************
  59. ;
  60.               end       start         ;end assembly
  61. ;====================================================================
  62.