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-07-05 08:39
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » How to access the BP register? View 1,868 Replies 3
Original Poster Posted 2010-11-08 05:43 ·  中国 广东 深圳 电信
初级用户
Credits 65
Posts 26
Joined 2010-07-29 17:15
15-year member
UID 171437
Gender Male
Status Offline
```c
// struct REGPACK reg;

reg.r_ax=0x1130;
reg.r_bx=reg_bx;
int86(0x10,&reg);

return MK_FP(reg.r_es,reg.r_bp);
```
Floor 2 Posted 2010-11-08 10:00 ·  中国 广东 深圳 福田区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
```c
// Get the starting address of the 8x8 character set
unsigned char* GetCharacterPoint()
{

unsigned short wSeg = 0;
unsigned short wOff = 0;

__asm push es
__asm push bp

__asm mov ax, 1130H
__asm mov bh, 03H // Get the starting address of the 8x8 font
__asm int 10h

__asm mov ax, bp
__asm pop bp // Very important, otherwise the program will crash
__asm mov wOff, ax

__asm mov ax, es
__asm mov wSeg, ax
__asm pop es

return ((unsigned char *)(unsigned long)MK_FP(wSeg, wOff));
}

[ Last edited by firstsail on 2010-11-8 at 10:02 ]
```
Floor 3 Posted 2010-11-08 15:23 ·  中国 广东 电信
初级用户
Credits 65
Posts 26
Joined 2010-07-29 17:15
15-year member
UID 171437
Gender Male
Status Offline
Uh, boss upstairs, I need C language, no inline assembly...
Floor 4 Posted 2010-11-26 08:21 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
18-year member
UID 94024
Gender Male
Status Offline
In C language, although you can declare register variables to use registers as much as possible for variables, bp is generally used to pass parameters. So even when using embedded assembly to use bp, you have to be very careful, otherwise the program is very easy to crash.
Forum Jump: