www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: asm, access violation?

reply Brian Bober <netdemonz yahoo.com> writes:
Do you mean that the D language does not support generation of 16-bit
code, or that the existing D compilers do not generate 16-bit code? The
older versions of Microsoft Visual C++ (Visual C++ V1.52) supported 16-bit
code generation with far and near pointers, meaning that at least with
non-standard extensions such as the aforementioned near and far pointers,
C++ could support writing 16-bit programs. Is it concievable a compiler
could be written for different memory architectures than flat 32/64 bit
architectures? Could it be written for, say, a 600Mhz microcontroller that
had 16-bit unmapped, unprotected segmented architecture that supported 8
bit segment addresses with 16 bit offsets and 16MB of main memory? Let's
say that this architecture had near (16-bit addresses) and far pointers
(24-bit addresses)... Would a compiler for such an architecture be
possible?

On Thu, 29 Apr 2004 09:29:56
-0700, Walter wrote:

 
 "LightEater" <LightEater_member pathlink.com> wrote in message
 news:c6qlmd$omq$1 digitaldaemon.com...
 I'm trying to set the cursor position using inline asm, i came up with
 the following nifty function, the program compiles, however when i call
 the
function
 i get an "Error: Access Violation". Any ideas on what might be wrong?

 void GotoXY (ubyte x, ubyte y)
 {
 asm {
 mov AH, 2; /* cursor position */
 mov DH, y;
 mov DL, x;

 int 0x10;
 }
 }
 }
Generating interrupts only works when running a 16 bit program. D only supports 32 bit programming. Generating an interrupt from a Win32 program will cause an access violation. To set the cursor position in a 32 bit Win32 program, check out the Windows console API.
Sep 22 2004
parent "Walter" <newshound digitalmars.com> writes:
"Brian Bober" <netdemonz yahoo.com> wrote in message
news:cit1nf$2q3$1 digitaldaemon.com...
 Do you mean that the D language does not support generation of 16-bit
 code, or that the existing D compilers do not generate 16-bit code?
Yes and yes.
 The
 older versions of Microsoft Visual C++ (Visual C++ V1.52) supported 16-bit
 code generation with far and near pointers, meaning that at least with
 non-standard extensions such as the aforementioned near and far pointers,
 C++ could support writing 16-bit programs.
Digital Mars C++ also supports writing 16 bit programs, and does so with the current version.
 Is it concievable a compiler
 could be written for different memory architectures than flat 32/64 bit
 architectures? Could it be written for, say, a 600Mhz microcontroller that
 had 16-bit unmapped, unprotected segmented architecture that supported 8
 bit segment addresses with 16 bit offsets and 16MB of main memory? Let's
 say that this architecture had near (16-bit addresses) and far pointers
 (24-bit addresses)... Would a compiler for such an architecture be
 possible?
Yes, it's just a lot of work to do. I don't see sufficient demand for those architectures to justify it. But if some company was to offer to fund its development, any reasonable platform could be supported.
Sep 22 2004