Metropoli BBS
VIEWER: system.asm MODE: TEXT (ASCII)
include qlib.inc
include string.inc
include stdlib.inc
include errno.inc
include stdio.inc

.data?
  comspec db 128 dup (?)
  arglen db 0
  args db 128 dup (?)
.data
  pbs struct  ;parameter block
    enviroff dd ?
    envirsel dw ?
    cto dd offset arglen
    cts dw ?
    fcb1 dd 0
    fcb2 dd 0
  pbs ends
  pb pbs <>
.code
system proc,sys:dword
  mov ax,seldata
  mov pb.envirsel,ax
  mov pb.cts,ax
  mov eax,_environ
  mov pb.enviroff,eax
  callp getenv,"COMSPEC"
  .if eax==NULL
    jmp bad
  .endif
  callp strcpy,offset comspec,eax
  callp strcpy,offset args," /C "  ;FIX : v2.00 Beta #2
  callp strcat,offset args,sys
  callp strlen,offset args
  .if eax>127
    mov errno,E2BIG
    jmp bad
  .endif
  mov arglen,al
  pushad
  mov edx,offset comspec
  mov ebx,offset pb
  mov ax,4b00h
  int 21h
  .if carry?
    mov eax,ERROR
    jmp bad
  .endif
  mov edx,_dta
  mov ah,1ah
  int 21h  ;reset DTA
  popad
  xor eax,eax
  ret
bad:
  mov edx,_dta
  mov ah,1ah
  int 21h  ;reset DTA
  popad
  mov eax,ERROR
  ret
system endp
end

[ RETURN TO DIRECTORY ]