用代码的直接定址表改写程序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013589137/article/details/80684530
assume cs:code, ss:stack
stack segment
     db 100H dup (?)
stack ends
code  segment
      org 100h
start:
      jmp beg
menu  db 10,13,10,13,'           MENU          '
      db 10,13
      db 10,13,'           1. FILE'
      db 10,13,'           2. EDIT'
      db 10,13,'           3. COMPILE'
      db 10,13,'           4. RUN'
      db 10,13,'           5. DEBUG'
      db 10,13,'           0. QUIT'
      db 10,13
      db 10,13,'   please choose one of 0~4:','$'
codetab dw sub1, sub2, sub3, sub4, sub5

beg:
      push cs
      pop ds     ;设置数据段
disp0:
      lea dx,menu ;DS:DX=待输出字符的地址
      mov ah,9
      int 21h     ;调用21h中断的第9号功能,显示以'$'结束的字符串

      mov ah,1
      int 21h     ;调用21h中断的第1号功能,从键盘读入字符,AL保存读入字符的ASCII码
      
      sub al,30h
      cmp al,0
      je exit

      mov bl,al
      mov bh,0
      add bx,bx
      sub bx,2
      call word ptr codetab[bx]
      jmp disp0

exit:
      mov ah,4ch
      int 21h



sub1  proc near
      jmp sub1_disp
      file db 10,13,'   --new, open, save, print files.---','$',10,13
sub1_disp:
      lea dx,file
      mov ah,9
      int 21h     ;调用21h中断的第9号功能,显示以'$'结束的字符串
      ret
sub1  endp

sub2  proc near
      jmp sub2_disp
      edit db 10,13,'   --copy, cut, paste the text.---','$',10,13
sub2_disp:
      lea dx,edit
      mov ah,9
      int 21h     ;调用21h中断的第9号功能,显示以'$'结束的字符串
      ret
sub2  endp

sub3  proc near
      jmp sub3_disp
      compile db 10,13,'   --compile the source file, then get target file.---','$',10,13
sub3_disp:
      lea dx,compile
      mov ah,9
      int 21h     ;调用21h中断的第9号功能,显示以'$'结束的字符串
      ret
sub3  endp

sub4  proc near
      jmp sub4_disp
      run db 10,13,'   --run, run, run, cannot stop.---','$',10,13
sub4_disp:
      lea dx,run
      mov ah,9
      int 21h     ;调用21h中断的第9号功能,显示以'$'结束的字符串
      ret
sub4  endp

sub5  proc near
      jmp sub5_disp
      debug db 10,13,'   --debug ---','$',10,13
sub5_disp:
      lea dx, debug
      mov ah,9
      int 21h     ;调用21h中断的第9号功能,显示以'$'结束的字符串
      ret
sub5  endp

code  ends
      end start



猜你喜欢

转载自blog.csdn.net/u013589137/article/details/80684530