DOS and Interrupts

DOS specific questions.
MystikShadows
Posts: 613
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

DOS and Interrupts

Post by MystikShadows »

AS the subject says :-)

Basically I want to call interrupt 10h to change the video mode, for example

or should i do it with some inline assembly? still if it was possible I'd love to use the good ole call interrupt ;-).
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

Here you are (haven't you read the examples yet? :P):

Code: Select all

#include "dos/dpmi.bi"

dim r as __dpmi_regs
r.x.ax = &H13
__dpmi_int(&H10, @r) ' change to VGA mode 13h
MystikShadows
Posts: 613
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Post by MystikShadows »

Oh byte me right here (*|_) lol

*washes the glass right out of his glasses to see if he'll see bettah...lol

Thank you Dr_V, always appreciate your work and efforts, always a fan, etc etc :-).
qb45
Posts: 4
Joined: Aug 07, 2005 9:10

Post by qb45 »

int 21h
ah=9
ds:dx=seg:off

freeBASIC not SEG,

How Get SEG and OFF??

DEMO:

.................dpmi.bi"

test$="123456"+"$"
strADD=sadd(test$)
strSEG=strADD\&h10
strOFF=strADD-srtSEG*&h10

......ax=&H900
......ds=strSEG
......dx=srtOFF
......int 21

run ......
error display


i need a example
please give me

(sorry ,I am CHINA men)
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

To transfer data between DOS memory (real mode) and your applications memory (protected mode) is a bit more difficult.

You have two ways:
  1. For a small amount of data you can simply use the GO32 transfer buffer

    See _go32_info_block in inc/dos/go32.bi. You get a linear address and a segment
  2. Or you can allocate your own transfer buffer

    inc/dos/dpmi.h
    See _go32_dpmi_allocate_dos_memory or __dpmi_allocate_dos_memory.

    __dpmi_allocate_dos_memory returns the selector to the DOS memory block in the second argument. The DOS segment is returned directly.

    Allocating the memory using _go32_dpmi_allocate_dos_memory is almost the same.
The selector is required for accessing the memory from protected mode and the segment is required for DOS.

To transfer the memory between DOS and your application, I'd prefer movedata() from inc/dos/go32.bi.

To get you applications "normal" data selector, you can use _my_ds() from the same header file.

Here's an example of a procedure using the second method: http://www.freebasic.net/forum/viewtopic.php?p=2766

Regards,
Mark
qb45
Posts: 4
Joined: Aug 07, 2005 9:10

Post by qb45 »

it's too hard to me
please use this databook
brief and to the point example
ok??

INT 21 AH = 09h
DS:DX -> '$'-terminated string
Return: AL = 24h (the '$' terminating the string, despite official docs which
state that nothing is returned) (at least DOS 2.1-7.0 and
NWDOS)
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

Code: Select all

''
'' example of calling DOS interrupt requiring a pointer
''

#include "dos/dpmi.bi"
#include "dos/dos.bi"
#include "dos/sys/movedata.bi"

option explicit
option escape

sub print_dos(s as string)
	dim s2 as string
	dim dos_seg as integer, dos_sel as integer
	
	dim regs as __dpmi_regs
	
	s2 = s + "$" '' this is inefficient; better to use _farpokeb to add $ in low memory
	
	dos_seg = __dpmi_allocate_dos_memory((Len(s2) + 15) \ 16, @dos_sel)
	if dos_seg = 0 then exit sub ' out of memory
	
	dosmemput(strptr(s2), len(s2), dos_seg * 16)
	
	regs.h.ah = &H09
	regs.x.dx = 0
	regs.x.ds = dos_seg
	__dpmi_int(&H21, @regs)
	
	__dpmi_free_dos_memory(dos_sel)
end sub

print_dos("Hello ")
print_dos("World\n")
qb45
Posts: 4
Joined: Aug 07, 2005 9:10

Post by qb45 »

thank you!! ^_^

use _farpokeb to add $ in low memory??
brief and to the point example
please use this databook!
------------------ INT 13-----------------------------
DISK - READ SECTOR(S) INTO MEMORY
AH = 02h
AL = number of sectors to read (must be nonzero)
CH = low eight bits of cylinder number
CL = sector number 1-63 (bits 0-5)
high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer
Return: CF set on error
------------------------------------------------------
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

I'm sorry, but I don't think I can write one for that - NT-based versions of Windows (like XP, which I use) don't allow direct disk access, but you should be able to figure out that one from the other examples...
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

Sorry that I might sound rude, but we're not here to develop your software. Please learn from the text I wrote and the translation DrV gave you and try developing this yourself.

Regards,
Mark
qb45
Posts: 4
Joined: Aug 07, 2005 9:10

Post by qb45 »

MY program run DOS system

can you help me,please!!
etko
Posts: 113
Joined: May 27, 2005 7:55
Location: Slovakia
Contact:

Post by etko »

Even on DOS system logical memory might be mapped differently from physical memory, it all depends on DPMII server, that's why you must use selectors and remap vyrutal space etc. Ususally DPMII server creates some
buffer, it depends per server. Use google PMODE to get some info ;).
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Post by yetifoot »

after setting the mode i use
__djgpp_nearptr_enable();

then (0xA0000 + __djgpp_conventional_base)

gives you the start of video memory
etko
Posts: 113
Joined: May 27, 2005 7:55
Location: Slovakia
Contact:

Post by etko »

Anyway isn't it possible to get PMODE video BIOS routine address by calling special INT 10h subfuncion and then use VBIOS directly from PMODE without switching to RMODE?
rugxulo
Posts: 221
Joined: Jun 30, 2006 5:31
Location: Usono (aka, USA)
Contact:

Re:

Post by rugxulo »

etko wrote:Anyway isn't it possible to get PMODE video BIOS routine address by calling special INT 10h subfuncion and then use VBIOS directly from PMODE without switching to RMODE?
Sorry for bumping this old thread. I'm definitely not a systems programmer, but ...

Since FreeBASIC for DOS uses DJGPP v2, it's all DPMI all the time, which basically guarantees that you can call any interrupt (DOS, BIOS), without the address translation (int 31h, 300h), if you're not using references to data addresses. In other words, any register-based call (int 10h, 0013h) should presumably pass through and work correctly. Whether that goes to real mode or V86 mode (and thus incurring whatever very minimal speed penalty) is up to the DPMI host and cpu.

Code: Select all

ASM
mov ah,0xE
mov al,0x48
int 0x10
mov al,0x69
int 0x10
END ASM
For instance, CWSDPMI.EXE is ring 3 but (unless EMM386 is loaded) always reflects back to real mode. Probably not totally ideal, but switching to V86 is more complicated, so it probably wasn't worth the hassle. (In latest r7, it will try to use 4 MB pages if your cpu supports it, for big allocations, for faster speed. But that is not possible when using EMM386, which forces 4 kb pages and V86 mode. Also, 4 MB pages is not DPMI 1.0 compliant, but that's rarely a problem anyways, and IIRC you can disable it via CWSPARAM.)
Post Reply