zoukankan      html  css  js  c++  java
  • 汇编程序返回dos

    汇编程序返回dos有两种方式:

    1.            push ds

                   sub ax,ax

                   push ax

                   ...

                   ret

    作用:一开始ds是指向psp的,在psp:0000处放着int 20h(即终止程序的指令),然后用ret,会把psp指向给cs,0给ip,运行int 21h终止代码继续运行

     代码实例:

    data segment
    datatable dw routine_1
    dw routine_2
    dw routine_3
    dw routine_4
    dw routine_5
    dw routine_6
    dw routine_7
    dw routine_8
    result dw ?
    data ends
    ;********************88
    code segment
    main proc far
    assume cs:code, ds:data
    start:
    push ds
    sub ax, ax
    push ax
    mov ax, data
    mov ds, ax
    ;mian proc start here
    ;set al = 1
    mov al, 1
    cmp al, 0
    je coutinue_main_line
    mov si,0
    l:
    shr al, 1
    jnb not_yet
    jmp datatable[si]
    not_yet:
    add si, type datatable
    jmp l
    coutinue_main_line:
    mov result, 1110h
    jmp exit
    routine_1:
    mov result, 1111h
    jmp exit
    routine_2:
    routine_3:
    routine_4:
    routine_5:
    routine_6:
    routine_7:
    routine_8:
    exit:
    ret
    main endp
    code ends
    end start

    2.

    mov ah, 4CH

    int 21H

    代码实例:

    data segment
    datatable dw routine_1
    dw routine_2
    dw routine_3
    dw routine_4
    dw routine_5
    dw routine_6
    dw routine_7
    dw routine_8
    result dw ?
    data ends
    ;********************88
    code segment
    main proc far
    assume cs:code, ds:data
    start:
    mov ax, data
    mov ds, ax
    ;mian proc start here
    ;set al = 1
    mov al, 1
    cmp al, 0
    je coutinue_main_line
    mov si,0
    l:
    shr al, 1
    jnb not_yet
    jmp datatable[si]
    not_yet:
    add si, type datatable
    jmp l
    coutinue_main_line:
    mov result, 1110h
    jmp exit
    routine_1:
    mov result, 1111h
    jmp exit
    routine_2:
    routine_3:
    routine_4:
    routine_5:
    routine_6:
    routine_7:
    routine_8:
    exit:
    mov ah, 4ch
    int 21h
    ret
    main endp
    code ends
    end start

     

  • 相关阅读:
    你必须知道的关于大数据的七个概念
    SAS中的聚类分析方法总结
    SAS中的聚类分析方法总结
    数据分析的关键是制定聪明的决策
    数据分析的关键是制定聪明的决策
    想使用 MongoDB ,你应该了解这8个方面!
    利用crtmpserver搭建rtmp服务器
    【leetcode】Jump Game I, II 跳跃游戏一和二
    iOS中从零開始使用protobuf
    session.use_cookies有什么作用,
  • 原文地址:https://www.cnblogs.com/liubiyonge/p/9121486.html
Copyright © 2011-2022 走看看