home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1266 / hack.S < prev    next >
Encoding:
Text File  |  1990-12-28  |  948 b   |  42 lines

  1. / minimal 2 syscalls for demonstration echo program
  2. / Just write and _exit defined here.
  3. / Abstracted from syscall library by:
  4. / From: pgd@compuram.bbt.se
  5. / Message-Id: <9004162210.AA14300@compuram.bbt.se>
  6. / which was reposted to comp.unix.xenix by:
  7. / From: dws@uafsun4.uark.edu (David W. Summers)
  8. / Message-ID: <4088@uafhp.uark.edu>
  9.  
  10.     .set    exit,1
  11.     .set    write,4
  12.  
  13. #define    sys(fun)    movl    $fun,%eax;.byte    0x9a,0,0,0,0,7,0
  14.  
  15. #define    DEFSYS(fun,lbl)            \
  16.     .globl    lbl        ;    \
  17. lbl:    sys(fun)        ;    \
  18.     jb    1f        ;    \
  19.     ret            ;    \
  20. 1:    movl    %eax,_errno    ;    \
  21.     movl    $-1,%eax    ;    \
  22.     ret                \
  23.  
  24.     .text
  25. DEFSYS(write,_write)    
  26.  
  27.     .globl    __exit
  28. __exit:
  29.     sys(exit)
  30.     movl    %eax,_errno
  31.     movl    $-1,%eax
  32.     ret
  33.  
  34. / Gross hack.  This program _doesn't_ use flotaing point printf, but there's
  35. / no easy way we can tell when its needed, so the __fltused EXTDEF is
  36. / generated in the normal case for safety.  SO we define it here to keep the
  37. / linker happy.
  38.     .data
  39.     .globl __fltused
  40. __fltused:
  41.     .byte 0
  42.