home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / caway349.zip / BIN / INTASM.ASM < prev    next >
Assembly Source File  |  1996-06-17  |  2KB  |  123 lines

  1. ; INTASM.ASM
  2. ; Demonstrates calling interrupt not natively supported by CauseWay
  3. ;  that uses segment:offset pointers.
  4. ; Assembly language version, C version is INTC.C
  5.  
  6. .MODEL MEDIUM
  7. .STACK 400H
  8.  
  9. .CONST
  10. FileName    DB    'INTASM.EXE',0
  11.  
  12. .DATA
  13.  
  14. ASCIIZSegment    DW    0
  15. ASCIIZSelector    DW    0
  16. CanonicalSegment    DW    0
  17. CanonicalSelector    DW    0
  18.  
  19. RealRegsStruc STRUC
  20.     Real_EDI    DD    ?    ;EDI
  21.     Real_ESI    DD    ?    ;ESI
  22.     Real_EBP    DD    ?    ;EBP
  23.                 DD    ?    ;Reserved.
  24.     Real_EBX    DD    ?    ;EBX
  25.     Real_EDX    DD    ?    ;EDX
  26.     Real_ECX    DD    ?    ;ECX
  27.     Real_EAX    DD    ?    ;EAX
  28.     Real_Flags    DW    ?    ;FLAGS
  29.     Real_ES        DW    ?    ;ES
  30.     Real_DS        DW    ?    ;DS
  31.     Real_FS        DW    ?    ;FS
  32.     Real_GS        DW    ?    ;GS
  33.     Real_IP        DW    ?    ;IP
  34.     Real_CS        DW    ?    ;CS
  35.     Real_SP        DW    ?    ;SP
  36.     Real_SS        DW    ?    ;SS
  37. RealRegsStruc ENDS
  38.  
  39. RealRegs    RealRegsStruc    <>
  40.  
  41. .CODE
  42. .386
  43.  
  44. start:
  45.     mov    ax,DGROUP
  46.     mov    ds,ax
  47.  
  48. ; allocate low dos memory for the two buffers
  49.     mov    bx,8        ; # paras to allocate
  50.     mov    ax,0ff21h    ; GetMemDOS
  51.     int    31h
  52.     jc    errout
  53.     mov    ASCIIZSelector,dx
  54.     mov    ASCIIZSegment,ax
  55.  
  56.     mov    bx,8        ; # paras to allocate
  57.     mov    ax,0ff21h    ; GetMemDOS
  58.     int    31h
  59.     jc    errout
  60.     mov    CanonicalSelector,dx
  61.     mov    CanonicalSegment,ax
  62.  
  63. ; copy ASCIIZ file name into buffer
  64. ;  use INTASM.EXE for example
  65.     mov    es,ASCIIZSelector
  66.     mov    si,OFFSET DGROUP:FileName
  67.     xor    di,di
  68.  
  69. looper:
  70.     movsb
  71.     cmp    BYTE PTR ds:[si-1],0
  72.     jne    looper
  73.  
  74. ; setup register values to pass to real mode
  75.     mov    RealRegs.Real_ESI,0    ; zero offset on DOS memory allocations
  76.     mov    RealRegs.Real_EDI,0
  77.     mov    ax,ASCIIZSegment    ; setup segments with real mode values
  78.     mov    RealRegs.Real_DS,ax
  79.     mov    ax,CanonicalSegment
  80.     mov    RealRegs.Real_ES,ax
  81.     mov    ah,60h                ; truename function
  82.     mov    WORD PTR RealRegs.Real_EAX,ax
  83.  
  84. ; perform real mode interrupt call
  85.     push    ds
  86.     pop    es
  87.     mov    bl,21h
  88.     mov    di,OFFSET DGROUP:RealRegs
  89.     mov    ax,0ff01h        ; IntXX
  90.     int    31h
  91.  
  92.     test    RealRegs.Real_Flags,1    ; check carry flag error status
  93.     jne    errout
  94.  
  95. ; display truename
  96.     push    ds
  97.     mov    ds,CanonicalSelector
  98.     xor    edx,edx
  99.  
  100. ; mindless one char at a time display loop of ASCIIZ string
  101. display:
  102.     cmp    BYTE PTR [edx],0
  103.     je    done
  104.     mov    cx,1
  105.     mov    bx,1            ; stdout
  106.     mov    ah,40h
  107.     int    21h
  108.     inc    edx
  109.     jmp    display
  110.  
  111. done:
  112.     pop    ds
  113.  
  114.     mov    ax,4c00h
  115.     int    21h
  116.  
  117. ; error allocating memory or in real mode interrupt
  118. errout:
  119.     mov    ax,4c01h
  120.     int    21h
  121.  
  122. END    start
  123.