home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / PC_V11_B.LZH / DEMO_ASS / DEMO_ASS / DEMO.S < prev    next >
Text File  |  1991-08-27  |  5KB  |  139 lines

  1. ;       Demoprogramm für Pure Assembler
  2.  
  3.                 import _StkSize                 ; von PLINK definiert !
  4.  
  5. start:          lea.l   start-256, a1           ; Start der Basepage
  6.                 move.l  12(a1), d1              ; Grö₧e des Textsegments
  7.                 add.l   20(a1), d1              ; Grö₧e des Datensegments
  8.                 add.l   28(a1), d1              ; Grö₧e des BSS-Segments
  9.                 add.l   #256,   d1              ; Grö₧e der Basepage
  10.  
  11.                 move.l  d1,  -(sp)              ; Benötigter Speicher
  12.                 move.l  a1,  -(sp)              ; Startadresse
  13.                 clr     -(sp)                   ; dummy
  14.                 move    #74, -(sp)              ; Mshrink
  15.                 trap    #1                      ; Gemdos
  16.  
  17.                 add.l   a1, d1                  ; new stack
  18.                 and.b   #$fc, d1                ; gerade Adresse
  19.                 move.l  d1, sp                  ; Stack liegt im BSS
  20.  
  21.                 ; Bildschirm löschen:
  22.                 move.l  #clearscreen, -(sp)
  23.                 move    #9, -(sp)               ; Cconws
  24.                 trap    #1                      ; Gemdos
  25.                 addq.l  #6, sp                  ; Stackkorektur
  26.  
  27.                 ; Cconws("Hello world\n\r")
  28.                 move.l  #hello, -(sp)
  29.                 move    #9, -(sp)
  30.                 trap    #1
  31.                 addq.l  #6, sp
  32.  
  33.                 ; Cconws("Stacksize: $");
  34.                 move.l  #stack, -(sp)
  35.                 move    #9, -(sp)
  36.                 trap    #1
  37.                 addq.l  #6, sp
  38.  
  39.                 ; Cconws(ltohex(_StkSize))
  40.                 move.l  #_StkSize, -(sp)
  41.                 jsr     ltohex(pc)
  42.                 move.l  a0, (sp)
  43.                 move    #9, -(sp)
  44.                 trap    #1
  45.                 addq.l  #6, sp
  46.  
  47.  
  48.                 ; Cconws("\n\rWir wollen würfeln...")
  49.                 move.l  #wuerfeln, -(sp)
  50.                 move    #9, -(sp)
  51.                 trap    #1
  52.                 addq.l  #6, sp
  53.  
  54. main_loop:      ; Cconws("\n\rDie gewürfelte Zahl lautet: ");
  55.                 move.l  #ergebnis, -(sp)
  56.                 move    #9, -(sp)
  57.                 trap    #1
  58.                 addq.l  #6, sp
  59.  
  60.                 ; Random()
  61.                 move    #17, -(sp)              ; Random
  62.                 trap    #14                     ; xbios
  63.                 addq.l  #2, sp
  64.  
  65.                 and.l   #$FFFF, d0              ; damit kein Überlauf
  66.                 divu    #6, d0                  ; Zufallszahl durch 6
  67.                 swap    d0                      ; modulo 6
  68.                 add     #$31, d0                ; eins drauf ist Zufallsz.
  69.  
  70.                 ; Cconout(d0)
  71.                 move    d0, -(sp)
  72.                 move    #2, -(sp)               ; Cconout
  73.                 trap    #1
  74.                 addq.l  #4, sp
  75.  
  76. small_loop:     ; Cconws("\n\rnochmal (j/n)?");
  77.                 move.l  #nochmal, -(sp)
  78.                 move    #9, -(sp)
  79.                 trap    #1
  80.                 addq.l  #6, sp
  81.  
  82.                 ; Cconin()
  83.                 move    #1, -(sp)
  84.                 trap    #1
  85.                 addq.l  #2, sp
  86.  
  87.                 cmp.b   #'j', d0
  88.                 beq     main_loop
  89.                 cmp.b   #'J', d0
  90.                 beq     main_loop
  91.  
  92.                 cmp.b   #'n', d0
  93.                 beq     exit
  94.                 cmp.b   #'N', d0
  95.                 bne     small_loop
  96.  
  97. exit:           ; Pterm0()
  98.                 move    #0, -(sp)
  99.                 trap    #1
  100.  
  101.  
  102. ; Diese Funktion wandelt einen long Parameter vom Stack in Hex-ascii
  103. ; um und benutzt dabei den Buffer. Rückgabewert ist die Adresse des
  104. ; Buffers in a0
  105.  
  106. ltohex:         move.l  a1, -(sp)               ; save a1
  107.                 move.l  d1, -(sp)               ; save d1
  108.                 move.l  d2, -(sp)               ; save d2
  109.  
  110.                 move.l  16(sp), d0              ; hole parameter
  111.                 move.l  #buffer, a0
  112.                 move.l  #ziffern, a1
  113.  
  114.                 move    #8, d2
  115. hex_loop:       move.b  d0, d1
  116.                 and.b   #$0f, d1
  117.                 ext     d1
  118.                 move.b  (a1, d1.w), (a0, d2)
  119.                 asr.l   #4, d0
  120.                 dbeq    d2, hex_loop
  121.  
  122.  
  123.                 move.l  (sp)+, d2
  124.                 move.l  (sp)+, d1
  125.                 move.l  (sp)+, a1
  126.                 rts
  127.  
  128.  
  129.                 data
  130.  
  131. clearscreen:    dc.b    27, 'E', 0
  132. hello:          dc.b    "Hello world", $d, $a, 0
  133. stack:          dc.b    "Stacksize: $", 0
  134. wuerfeln:       dc.b    $d, $a, "Wir wollen würfeln...", 0
  135. ergebnis:       dc.b    $d, $a, "Die gewürfelte Zahl lautet: ", 0
  136. nochmal:        dc.b    $d, $a, "Nochmal (j/n)?", 0
  137. ziffern:        dc.b    "0123456789ABCDEF"
  138. buffer:         dc.b    "00000000", 0
  139.