Date: Mon, 30 Apr 2001 12:04:11 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Rafal Maj cc: djgpp AT delorie DOT com Subject: Re: Assembler smal question In-Reply-To: <9chviu$1ps$1@info.cyf-kr.edu.pl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 29 Apr 2001, Rafal Maj wrote: > I'm using modem, so I REALY can't read online documentation or FAQ > for DJGPP. Download faq230b.zip, and you will be able to read it on your local machine. > How can I write code like this : > > mov AX,0x10 > int 0x13 #include __dpmi_regs r; r.x.ax = 0x10; _dpmi_int (0x13, &r); > I want to use assembler direct inside my C++ functions like: > int main() { _asm { mov AX,0x10 } } What do you need assembly for? Issuing real-mode interrupts from a protected-mode program has a large overhead (due to the need to switch the CPU from protected to real mode and back), so any advantages of doing so with inline assembly are null and void. See section 17.8 of the FAQ for more details. > How can I fill memory from A000:0000 to A000:0FFF with pattern of increasing > bytes ? Something like this : > > mov cx,0x0FFF > xor dl,dl > begin : > mov bx:cx, dl > inc dl > dec cx > loop begin Use the _farpokeb/_farnspokeb library functions. Example (untested): #include _farsetsel (_dos_ds); for (i = 0; i < 0x1000; i++) _farnspokeb (i + 0xa0000, i); When compiled with -O2, this loop will expand into inline assembly with only a couple of instructions in the body of the loop. See sections 18.4 and 18.6 of the FAQ for more details.