Article From:https://www.cnblogs.com/liubiyonge/p/9121486.html

There are two ways to return the assembler to DOS:

1.            push ds

               sub ax,ax

               push ax

               …

               ret

Function: at first, DS is directed to PSP, with a int 20h (that is, the instruction to terminate the program) at psp:0000, and then RET, which points PSP to CS, 0 to IP, and int 21h terminates the code to continue running

 Code instance:

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

Code instance:

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

 

Similar Posts:

Link of this Article: Assembler return to DOS

Leave a Reply

Your email address will not be published. Required fields are marked *