China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 05:44
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » C Language Example Using the RET Interrupt Jump Instruction! View 1,262 Replies 3
Original Poster Posted 2003-11-07 00:00 ·  中国 河北 石家庄 电信
中级用户
★★
疯狂的流浪者
Credits 276
Posts 56
Joined 2003-09-25 00:00
22-year member
UID 10329
Gender Male
Status Offline
C Language example using the interrupt jump instruction RET!
/*********************************************/
/*   C language example using interrupt jump instruction   */
/*       Author: xy_god         */
/*      Debugged and passed under tc2.0        */
/*********************************************/
#include "dos.h"
#include "stdio.h"
#include "conio.h"

void setretint();         /*Set interrupt 96H as an interrupt jump interrupt,
                   entry address as follows: x, segment address; bx, off
                   set address*/

void retf(int destseg,int destoff);/*Jump to destseg:destoff to run*/

main()/*****************Main function**************************/
{
int segsrc=0x2000,offsrc=0x0000;int i=0;
char abscode={0x00,0x0D,0xB4,0x09,0x00,0x0F,/*Machine instruction code*/
         0xB0,0x2A,0x00,0x11,0xB7,0x00,
         0x00,0x13,0xB3,0xDA,0x00,0x15,
         0xB9,0x05,0x00,0x00,0x18,0xCD,0x10};
for(i=0;i<=24;i++)
pokeb(segsrc,offsrc+i,abscode);
setretint();
retf(0x2000,0x000);
}

void retf(int destseg,int destoff) /*Jump to destseg:destoff to run*/
{
asm mov cx,destseg
asm mov bx,destoff
asm int 96h
}

void setretint()/*Set interrupt 96H as an interrupt jump interrupt,
         Entry address as follows:
         cx, segment address, bx, offset address*/
{
int segsrc=0x1000,offsrc=0x0000;int i=0;
char abscode={0x8B,0xC1, /*MOV   AX,CX*/
         0x50,   /*PUSH  AX  */
         0x8B,0xC3,/*MOV   AX,BX*/
         0x50,   /*PUSH  AX  */
         0xCB};  /*RETF     */
for(i=0;i<=6;i++)
pokeb(segsrc,offsrc+i,abscode);
asm MOV AX,1000h /*Set the entry address of interrupt 96h*/
asm MOV DS,AX
asm MOV DX,0000h
asm MOV AL,96h
asm MOV AH,25H
asm INT 21H
}
临河居士
http://www.xygod.pc5.org
Floor 2 Posted 2003-11-07 00:00 ·  中国 河北 石家庄 电信
中级用户
★★
疯狂的流浪者
Credits 276
Posts 56
Joined 2003-09-25 00:00
22-year member
UID 10329
Gender Male
Status Offline
Last time I wrote some assembly code to execute machine instructions and surprisingly nobody replied. This time here's a C language version, let's see if we can study it together! Hehe!
临河居士
http://www.xygod.pc5.org
Floor 3 Posted 2004-02-03 00:00 ·  中国 福建 福州 电信
初级用户
Credits 139
Posts 17
Joined 2004-02-03 00:00
22-year member
UID 16635
Gender Male
Status Offline
This is too troublesome, just do it directly like this:
void retf(int destseg,int destoff) /*Jump to destseg:destoff to run*/
{
asm push destseg
asm push destoff
asm retf
}
Floor 4 Posted 2004-02-03 00:00 ·  中国 湖北 武汉 联通
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
Can I get a QB version??
Forum Jump: