home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Heaven Sunny 2 / APPARE2.BIN / oh_towns / ugoku / ugokulib / etc / console.asm next >
Assembly Source File  |  1995-06-20  |  4KB  |  244 lines

  1. ;        Graph_lib
  2. ;
  3. ;        call from High C
  4. ;
  5. ;        1990 4  Hiroshi TODA
  6. ;
  7.  
  8.     .386p
  9.  
  10. work4    struc        ; files WORK
  11. ;data area
  12. path    dd    ?    ; path name address
  13. output    dd    ?    ; file name output address
  14. dta    dd    ?    ; DTA trans address
  15. attr    dd    ?    ; attr
  16. fmode    dd    ?    ; 0:first 1:next 2:end
  17. ;work area
  18. pathbuf    dd    ?    ; path 転送
  19.     dd    ?
  20.     dd    ?
  21.     dd    ?
  22.     dd    ?
  23.     dd    ?
  24.     dd    ?
  25.     dd    ?
  26.     dd    ?
  27.     dd    ?
  28.     dd    ?
  29.     dd    ?
  30.     dd    ?
  31.     dd    ?
  32.     dd    ?
  33.     dd    ?
  34. fbuf    dd    ?
  35. work4    ends
  36.  
  37. work5    struc        ; key console BIOS WORK
  38. x51    dd    ?
  39. x52    dd    ?
  40. x53    dd    ?
  41. x54    dd    ?
  42. work5    ends
  43.  
  44.         cseg    segment    'CODE'
  45.     assume    cs:cseg,ds:cseg
  46.  
  47. ;files(work,para) para=eax --> path-addre out-addre DTAout-add attr mode
  48.  
  49.     public    files
  50.     db    'files',5
  51. files    proc    near
  52.     push    ebp
  53.     mov    ebp,esp            ; ebp <-- param area top add
  54.     push    esi
  55.     push    edi
  56.     push    ebx
  57.     mov    esi,offset #buffer    ; esi <-- 自前の buffer
  58.     mov    edi,[ebp+12]        ; edi <-- para. add.
  59.     xor    ecx,ecx            ; ecx=count
  60. file01:    mov    eax,[edi][ecx*4]    ; para. --> work area
  61.     mov    [esi][ecx*4],eax
  62.     inc    ecx
  63.     cmp    ecx,5
  64.     jb    file01
  65.     mov    edx,[esi].path        ; path trans
  66.     lea    edi,[esi].pathbuf
  67.     xor    ecx,ecx
  68. file0A:    mov    eax,[edx][ecx*4]
  69.     mov    [edi][ecx*4],eax
  70.     inc    ecx
  71.     cmp    ecx,16
  72.     jb    file0A
  73.     mov    eax,[esi].fmode        ; eax <-- mode
  74.     cmp    eax,0
  75.     jne    file05
  76.     lea    edx,[esi].fbuf    ; mode 0
  77. file02:    mov    ah,1Ah            ; buffer set
  78.     int    21H
  79.     mov    edx,[esi].path
  80. file03:    mov    ah,4Eh            ; first search
  81.     mov    ecx,[esi].attr        ; attr.
  82.     int    21h
  83.     jc    file07            ; no file
  84.     call    putf
  85.     xor    eax,eax
  86.     jmp    file08
  87. file05:    cmp    eax,1
  88.     jne    file08
  89.     mov    ah,4Fh        ; mode 1
  90.     int    21h
  91.     jc    file07
  92.     call    putf
  93.     xor    eax,eax
  94.     jmp    file08
  95. file07:    and    eax,0FFFFh
  96. file08:    pop    ebx
  97.     pop    edi
  98.     pop    esi
  99.     mov    esp,ebp
  100.     pop    ebp
  101.     ret
  102.  
  103. putf:    lea    edx,[esi].fbuf+1Eh    ; display f-name out
  104.     mov    edi,[esi].output
  105.     xor    ecx,ecx
  106. putf01:    mov    byte ptr [edi][ecx],20h
  107.     inc    ecx
  108.     cmp    ecx,16
  109.     jb    putf01
  110.     mov    eax,[edx]
  111.     and    eax,0FFFFh        ; '..', '.' check
  112.     cmp    eax,02E2Eh
  113.     je    putf02
  114.     cmp    eax,02Eh
  115.     jne    putf0A
  116. putf02:    mov    [edi],eax
  117.     jmp    putf05
  118. putf0A:    xor    ecx,ecx
  119. putf03:    mov    al,[edx][ecx]
  120.     cmp    al,'.'
  121.     je    putf04
  122.     mov    [edi][ecx],al
  123.     inc    ecx
  124.     cmp    ecx,13
  125.     jb    putf03
  126.     jmp    putf05
  127. putf04:    inc    ecx
  128.     mov    eax,[edx][ecx]
  129.     mov    [edi].9,eax
  130. putf05:    lea    edx,[esi].fbuf        ; DTA out
  131.     mov    edi,[esi].dta
  132.     xor    ecx,ecx
  133. putf06:    mov    al,[edx][ecx]
  134.     mov    [edi][ecx],al
  135.     inc    ecx
  136.     cmp    ecx,43
  137.     jb    putf06
  138.     ret
  139.  
  140. #buffer    db    256 dup(0)
  141.  
  142. files    endp
  143.  
  144. ;get_directory(drive,path_name_address)
  145.  
  146.     public    get_directory
  147.     db    'get_directory',13
  148. get_directory proc    near
  149.     push    ebp
  150.     mov    ebp,esp            ; ebp <-- param area top add
  151.     push    esi
  152.     push    edi
  153.     push    ebx
  154.     mov    esi,[ebp+12]        ; path_name address
  155.     mov    edx,[ebp+8]        ; drive number
  156.     mov    ah,47h
  157.     int    21h
  158.     jc    #get01
  159.     xor    eax,eax
  160. #get01:    and    eax,0000FFFFh
  161.     pop    ebx
  162.     pop    edi
  163.     pop    esi
  164.     mov    esp,ebp
  165.     pop    ebp
  166.     ret
  167. get_directory endp
  168.  
  169. ;keyin(out,para) para=eax,ebx,ecx,edx --> out=eax,ebx,ecx,edx
  170.  
  171.     public    keyin
  172.     db    'keyin',5
  173. keyin    proc    near
  174.     push    ebp
  175.     mov    ebp,esp            ; ebp <-- param area top add
  176.     push    esi
  177.     push    edi
  178.     push    ebx
  179.     mov    esi,[ebp+8]        ; esi <-- work area top add
  180.     mov    edi,[ebp+12]        ; edi <-- para. add.
  181.     xor    ecx,ecx            ; ecx=count
  182. key01:    mov    eax,[edi][ecx*4]    ; para. --> work area
  183.     mov    [esi][ecx*4],eax
  184.     inc    ecx
  185.     cmp    ecx,4
  186.     jb    key01
  187.     mov    eax,[esi].x51        ; ES store
  188.     mov    ebx,[esi].x52
  189.     mov    ecx,[esi].x53
  190.     mov    edx,[esi].x54
  191.     int    90H
  192.     mov    [esi].x51,eax
  193.     mov    [esi].x52,ebx
  194.     mov    [esi].x53,ecx
  195.     mov    [esi].x54,edx
  196.     xor    eax,eax
  197.     pop    ebx
  198.     pop    edi
  199.     pop    esi
  200.     mov    esp,ebp
  201.     pop    ebp
  202.     ret
  203. keyin    endp
  204.  
  205. ;console(out,para) para=eax,ebx,ecx,edx --> out=eax,ebx,ecx,edx
  206.  
  207.     public    console
  208.     db    'console',7
  209. console    proc    near
  210.     push    ebp
  211.     mov    ebp,esp            ; ebp <-- param area top add
  212.     push    esi
  213.     push    edi
  214.     push    ebx
  215.     mov    esi,[ebp+8]        ; esi <-- work area top add
  216.     mov    edi,[ebp+12]        ; edi <-- para. add.
  217.     xor    ecx,ecx            ; ecx=count
  218. cns01:    mov    eax,[edi][ecx*4]    ; para. --> work area
  219.     mov    [esi][ecx*4],eax
  220.     inc    ecx
  221.     cmp    ecx,4
  222.     jb    cns01
  223.     mov    eax,[esi].x51        ; ES store
  224.     mov    ebx,[esi].x52
  225.     mov    ecx,[esi].x53
  226.     mov    edx,[esi].x54
  227.     int    91H
  228.     mov    [esi].x51,eax
  229.     mov    [esi].x52,ebx
  230.     mov    [esi].x53,ecx
  231.     mov    [esi].x54,edx
  232.     xor    eax,eax
  233.     pop    ebx
  234.     pop    edi
  235.     pop    esi
  236.     mov    esp,ebp
  237.     pop    ebp
  238.     ret
  239. console    endp
  240.  
  241.         cseg    ends
  242.     end
  243.  
  244.