home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / lisp / xlisp / xlsp21_src / sources / asm / system < prev   
Encoding:
Text File  |  1992-02-17  |  2.6 KB  |  114 lines

  1.     title   SYSTEM call
  2.     page    54,130
  3. ; This file is used by the Metaware High-C386 version of XLISP.
  4. ; It provides a "system()" call, which is broken in some versions of High-C.
  5. ; It also provides fast graphics for EGA/VGA only!
  6.     .386p
  7.     .xlisti
  8. @system segment 'DATA'
  9.     public  bytesperline
  10. bytesperline    DD  -1      ; maximum x value -- graphics
  11. commandBlock DD 0           ; env string offset
  12.     DW  0           ; env string segment
  13. commandTail DD  0           ; command tail offset
  14. ctseg   DW  0           ; and its segment
  15. savemode DB 0
  16. @system ends
  17. DGROUP  group   @system
  18. system  segment use32 'CODE'
  19. CGROUP  group   system
  20.     assume  cs:CGROUP, ds:DGROUP
  21.     public  ssystem
  22. ssystem PROC    NEAR
  23.     mov EAX, 8[ESP] ; argument (command string "tail")
  24.     mov commandTail,EAX
  25.     mov ctseg, DS       ; arg's segment
  26.     mov EDX, 4[ESP]     ; command
  27.     push    EBX
  28.     push    ESI
  29.     push    EDI
  30.     mov EBX, OFFSET commandBlock
  31.     mov EAX, 4b00h      ; exec
  32.     int 21h
  33.     jc  SHORT fail      ; fail if carry set
  34.     xor eax, eax        ; return zero on success
  35. fail:   pop EDI
  36.     pop ESI
  37.     pop EBX
  38.     ret
  39. ssystem endp
  40.  
  41.  
  42.  
  43. ; Set pixel (EGA/VGA modes) Derived from Richard Wilton's book
  44.     public setdrawmode
  45. setdrawmode PROC NEAR
  46.     mov dx, 3ceh
  47.     mov ax, 205H        ; write mode 2, read mode 0
  48.     out dx,ax
  49.     mov EAX, 4[ESP]
  50.     mov savemode, AL
  51.     mov AH, 0
  52.     test    AL, 80H
  53.     jz  SHORT overmode
  54.     mov AH, 18H
  55. overmode:
  56.     mov AL, 3
  57.     out dx,ax
  58.     ret
  59. setdrawmode endp
  60.  
  61.     public unsetdrawmode
  62. unsetdrawmode PROC NEAR
  63.     mov dx, 3ceh
  64.     mov ax, 0ff08h      ; restore defaults
  65.     out dx, ax
  66.     mov ax, 5
  67.     out dx, ax
  68.     mov ax, 3
  69.     out dx, ax
  70.     ret
  71. unsetdrawmode endp
  72.  
  73.  
  74.     public setpixel
  75. setpixel PROC   NEAR
  76.     push    EBP
  77.     mov EBP, ESP        ; set up new stack base
  78.     push    EBX         ; save BX
  79.     push    ES          ;  and ES
  80. ARGx    EQU DWORD PTR [EBP+8]
  81. ARGy    EQU DWORD PTR [EBP+12]
  82.  
  83.     mov EAX, ARGy
  84.     mov EBX, ARGx
  85.     mov CL, BL          ; low byte of x
  86.     imul    EAX, bytesperline   ; bytes per line * y address
  87.     shr EBX, 3          ; x/8
  88.     add EBX, EAX        ; byte offset
  89.     add EBX, 0A0000H        ; address of display
  90.  
  91.     mov ax, 34H         ; 1 Meg address space
  92.     mov ES, ax
  93.  
  94.     and CL, 7           ; x & 7
  95.     xor CL, 7           ; number of bits to shift left
  96.     mov AH, 1           ; shift mask
  97.  
  98.     shl AH, CL          ; bit mask is generated
  99.     mov dx, 3ceh
  100.     mov al, 8           ; set bit mask
  101.     out dx,ax
  102.  
  103.     mov al,es:[ebx]
  104.     mov al,savemode
  105.     mov es:[ebx],al
  106.  
  107.     pop ES
  108.     pop EBX
  109.     pop EBP
  110.     ret
  111. setpixel endp
  112. system  ends
  113. end
  114.