; Made by HotHeart http://www.xujiwei.com ; vipxjw@tom.com ; MENUET RUN 0.4 ; 1) 缺省目录 /RD/1/ ; 2) 可以更改程序目录,在SETUP里设置硬盘后可以运行 ;    硬盘上的程序 ; 3) 只能访问根目录 ; 4) 自动根据屏幕大小调整窗口位置(限任务栏为文字模式) use32 org    0×0 db ‘MENUET01′ ; 8 byte id dd 0×01                    ; header version dd START                   ; start of code dd I_END                   ; size of image dd 0×100000                ; memory for app dd 0x7fff0                 ; esp dd 0×0 , 0×0               ; I_Param , I_Icon START:                          ; start of execution ; 计算窗口位置 mov eax,14 int 0×40 mov [screenysize],ax xor eax,eax mov ax,[screenysize] sub eax,116+20 imul eax,65536 add eax,116 mov [winy],eax ; 初始化变量 mov [filestr],dword runprogram mov [dir],dword rundir mov [ya],dword 53 mov [yb],dword 69 call draw_window still: mov eax,23                 ; wait here for event int 0×40 cmp eax,1                  ; redraw request ? je red cmp eax,2                  ; key in buffer ? je key cmp eax,3                  ; button in buffer ? je button jmp still red:                          ; redraw call draw_window jmp still key:                          ; key mov eax,2                  ; just read it and ignore int 0×40 jmp still button:                       ; button mov eax,17                 ; get id int 0×40 cmp ah,4                  ; id=4 结束 je close cmp ah,1 je close cmp ah,2                  ; id=2 输入文件名 je inputfile cmp ah,5                  ; id=5 输入路径 je inputdir cmp ah,3                  ; id=3 运行程序 je runp jmp still file_start: dd 16 dd 0,0,0,0×10000 rundir:     db ‘/RD/1/’ ; 缺省目录 runprogram: db ‘RUN’,0        ; 缺省程序 times 60 db 0 filestr  dd 0×0 dir      dd 0×0 addr dd 0×0 ya       dd 0×0 yb       dd 0×0 ;========================================================== close: ;结束程序 mov eax,-1 int 0×40 inputfile: ;输入文件名 call read_string_file jmp still inputdir: ;输入路径 call read_string_dir jmp still ;========================================================== runp: ;运行程序 mov eax,58        ;运行 mov ebx,file_start int 0×40 jmp still ;========================================================== read_string_file: ;输入文件名 mov edi,[filestr] mov eax,0 mov ecx,40 cld rep stosb call print_file mov edi,[filestr] file_fun: mov eax,23        ; 等待事件 mov ebx,100    ; 延时100毫秒 int 0×40 cmp eax,0        ; eax=0 无事件 je file_fun    ; 继续等待事件过程 cmp eax,2        ; eax=2 按钮事件 jne file_read_done    ; 跳到读取键盘事件结束 mov eax,2        ; 获取击键 ascii 码 int 0×40 shr eax,8 cmp eax,13        ; 是否为回车键 je file_read_done    ; 是则跳到读取结束 cmp eax,8        ; 是否为退格键 jnz file_nobsl    ; 不是则跳到 nobsl cmp edi,[filestr] jz file_fun sub edi,1        ; 字符数量减 1 mov [edi],byte 32    ; 退格 call print_file    ; 显示字符串 jmp file_fun    ; 继续读取 file_nobsl: cmp al,95        ; 判断是否为小写 jbe file_cok    ; 是则跳到 cok sub al,32        ; 不是则将 ascii 减去 32 file_cok: mov [edi],al ; 添加到字符串 call print_file    ; 显示字符串 add edi,1        ; 已读取字符数量 mov esi,[filestr]    ; 读入字符串地址 add esi,30        ; 加上 30 cmp esi,edi ; 比较 jnz file_fun    ; 未到最大长度 file_read_done:    ; 读取结束 mov [edi],byte 0    ; 结束标志 call print_file    ; 显示字符串 jmp still        ; 事件循环 ;========================================================== read_string_dir: mov edi,[dir] mov eax,0 mov ecx,6 cld rep stosb call print_dir mov edi,[dir] dir_fun: mov eax,23        ; 等待事件 mov ebx,100    ; 延时100毫秒 int 0×40 cmp eax,0        ; eax=0 无事件 je dir_fun    ; 继续等待事件过程 cmp eax,2        ; eax=2 按钮事件 jne dir_read_done    ; 跳到读取键盘事件结束 mov eax,2        ; 获取击键 ascii 码 int 0×40 shr eax,8 cmp eax,13        ; 是否为回车键 je dir_read_done    ; 是则跳到读取结束 cmp eax,8        ; 是否为退格键 jnz dir_nobsl    ; 不是则跳到 nobsl cmp edi,[filestr] jz dir_fun sub edi,1 mov [edi],byte 32 call print_dir    ; 显示字符串 jmp dir_fun    ; 继续读取 dir_nobsl: cmp al,95        ; 判断是否为小写 jbe dir_cok    ; 是则跳到 cok sub al,32        ; 不是则将 ascii 减去 32 dir_cok: mov [edi],al ; 添加到字符串 call print_dir    ; 显示字符串 add edi,1        ; 已读取字符数量 mov esi,[dir]    ; 读入字符串地址 add esi,6        ; 加上 6 cmp esi,edi ; 比较 jnz dir_fun    ; 未到最大长度 dir_read_done:    ; 读取结束 call print_dir    ; 显示字符串 jmp still        ; 事件循环 ;========================================================== print_dir: ;显示路径 pusha mov eax,13        ; 画底纹 mov ebx,55*65536+31*6 mov ecx,[ya] shl ecx,16 mov cx,12 sub ecx,2*65536 mov edx,0xeeeeee int 0×40 mov eax,4        ; 显示路径 mov edx,[dir] mov ebx,56*65536 add ebx,[ya] mov ecx,0×444444 mov esi,6 int 0×40 popa ret ;========================================================== print_file: ;显示文件名 pusha mov eax,13        ; 画底纹 mov ebx,55*65536+31*6 mov ecx,[yb] shl ecx,16 mov cx,12 sub ecx,2*65536 mov edx,0xeeeeee int 0×40 mov eax,4        ; 显示文件名 mov edx,[filestr] mov ebx,56*65536 add ebx,[yb] mov ecx,0×444444 mov esi,30 int 0×40 popa ret ;========================================================== ;   ********************************************* ;   *******  WINDOW DEFINITIONS AND DRAW ******** ;   ********************************************* draw_window: mov eax,12                    ; function 12:tell os about windowdraw mov ebx,1                     ; 1, start of draw int 0×40 ; DRAW WINDOW mov eax,0                ; function 0 : define and draw window mov ebx,1*65536+250    ; [x start] *65536 + [x size] mov ecx,[winy]            ; [y start] *65536 + [y size] mov edx,0x03ffffff        ; color of work area RRGGBB,8->color gl mov esi,0x805080d0        ; color of grab bar  RRGGBB,8->color gl mov edi,0x005080d0        ; color of frames    RRGGBB int 0×40 ; WINDOW LABEL mov eax,4                ; function 4 : write text to window mov ebx,8*65536+8        ; [x start] *65536 + [y start] mov ecx,0x10ddeeff        ; font 1 & color ( 0xF0RRGGBB ) mov edx,labelt            ; pointer to text beginning mov esi,labellen-labelt; text length int 0×40 mov eax,8                ; 路径输入 id=5 mov ebx,13*65536+40 mov ecx,50*65536+12 mov edx,5 mov esi,0xaabbcc int 0×40 mov eax,8                ; 文件名输入 id=2 mov ebx,13*65536+40 mov ecx,66*65536+12 mov edx,2 mov esi,0xaabbcc int 0×40 mov eax,8                ; 确定 id=3 mov ebx,128*65536+48 mov ecx,84*65536+18 mov edx,3 mov esi,0xaabbcc int 0×40 mov eax,8                ; 取消 id=4 mov ebx,182*65536+48 mov ecx,84*65536+18 mov edx,4 mov esi,0xaabbcc int 0×40 mov ebx,13*65536+34    ; 提示信息 mov ecx,0×666666 mov edx,txttxt mov esi,30 mov eax,4 int 0×40 mov eax,4                ; Path按钮文本 mov ebx,21*65536+53 mov ecx,0×666666 mov edx,txtdir mov esi,4 int 0×40 mov ebx,21*65536+69    ; File按钮文本 mov ecx,0×444444 mov edx,txtfile mov esi,4 mov eax,4 int 0×40 mov ebx,140*65536+89    ; 确定取消按钮文本 mov ecx,0×444444 mov edx,txtbutton mov esi,13 mov eax,4 int 0×40 call print_dir call print_file mov eax,12                ; function 12:tell os about windowdraw mov ebx,2                ; 2, end of draw int 0×40 ret ; DATA AREA tcolor      dd 0×000000 txttxt      db ‘请输入要运行程序的路径和文件名’,‘x’ txtdir      db ‘Path’,‘x’ txtfile     db ‘File’,‘x’ txtbutton   db ‘确定     取消’,‘x’ screenysize dw 0×0 winy        dd 0×0 labelt: db ‘运行’ labellen: I_END:

[本日志由 xujiwei 于 2005-07-22 06:24 PM 编辑]

Comments (0), Views (2955), Pings (0), Leave a response!