Board index » delphi » Seg, Ofs Problem...

Seg, Ofs Problem...

I am trying to perform an interrupt call(AX:= $1100- Load user specified
character patterns). I have made an array to store the pattern in:

CharInfo: Array[0..15, 0..256] of CHAR;

What I am having difficulty in is giving ES the segment of the array and BP the
offset of the array. I used this code:

CharSeg:= Seg(CharInfo[0, 0]); {Both variables are defined as WORD}
CharOfs:= Ofs(CharInfo[0, 0]);

Asm
   Mov ES, CharSeg  {In addition I have put the other information in the
registers}
   Mov BP, CharOfs  {needed to perform the interrupt under this Asm block}
End;

I have figured out that the problem is in the CharSeg & CharOfs variables
because
when I made them equal the address for the default font, it worked fine. When
they are set to the address of CharInfo, the font is not changed properly(ie:
the characters will all be funny dots and whatever...)

*Any and all HELP is appreciated!*
                  C.J.

 

Re:Seg, Ofs Problem...


In article <1998082022364500.SAA25...@ladder01.news.aol.com>,

Quote
C1284J <c12...@aol.com> wrote:
>I am trying to perform an interrupt call(AX:= $1100- Load user specified
>character patterns). I have made an array to store the pattern in:

>CharInfo: Array[0..15, 0..256] of CHAR;

>What I am having difficulty in is giving ES the segment of the array and BP the
>offset of the array. I used this code:

>CharSeg:= Seg(CharInfo[0, 0]); {Both variables are defined as WORD}
>CharOfs:= Ofs(CharInfo[0, 0]);

>Asm
>   Mov ES, CharSeg  {In addition I have put the other information in the
>registers}
>   Mov BP, CharOfs  {needed to perform the interrupt under this Asm block}
>End;

Did you remember that you must save BP and restore it after the ASM
block ends? Did you remember that you cannot access any local variables
after you have changed the BP? Why not use Intr()?

Osmo

Re:Seg, Ofs Problem...


In article <6rj3q5...@kruuna.helsinki.fi>,

Quote
Osmo Ronkanen <ronka...@cc.helsinki.fi> wrote:

>Did you remember that you must save BP and restore it after the ASM
>block ends?

That should naturally be "before the ASM block ends"

Osmo

Re:Seg, Ofs Problem...


Quote
C1284J wrote:
> I am trying to perform an interrupt call(AX:= $1100- Load user specified
> character patterns). I have made an array to store the pattern in:

> CharInfo: Array[0..15, 0..256] of CHAR;

> What I am having difficulty in is giving ES the segment of the array and BP the
> offset of the array. I used this code:

> CharSeg:= Seg(CharInfo[0, 0]); {Both variables are defined as WORD}
> CharOfs:= Ofs(CharInfo[0, 0]);

BTW, seg(charinfo) and ofs(charinfo) should provide the same results -- no
need to specify the base of the array.  However, in reference to the array
itself, it's backward.  You need to declare it as:

var
  CharInfo : array[0..256,0..15] of char; {or byte}

That ought to help a bit.  The way you have it declared causes the data to be
stored out of the order the video BIOS will require it.

Quote
> Asm
>    Mov ES, CharSeg  {In addition I have put the other information in the
> registers}
>    Mov BP, CharOfs  {needed to perform the interrupt under this Asm block}
> End;

Couple things to point out here. . . .

1.)  You're trashing BP.  It's one of the variables that TP requires to be
restored after using.

2.)  You don't *need* variables to store the segment and offset.  Try this:

procedure setfont (var font); assembler;

asm
  push  bp
  les   bp,[font]
  mov   ax,1100h
  mov   bx,1000h  {16 bytes per char, load into block 0}
  mov   cx,0100h  {load 256 characters}
  xor   dx,dx
  int   10h
  pop   bp
end;

Just call this with setfont(CharInfo); (this assumes some default values,
which you may or may not want).

Quote
> I have figured out that the problem is in the CharSeg & CharOfs variables
> because
> when I made them equal the address for the default font, it worked fine. When
> they are set to the address of CharInfo, the font is not changed properly(ie:
> the characters will all be funny dots and whatever...)

See above comment for likely solution to this problem.

Quote
> *Any and all HELP is appreciated!*
>                   C.J.

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Re:Seg, Ofs Problem...


Quote
C1284J wrote:
> I am trying to perform an interrupt call(AX:= $1100- Load user specified
> character patterns). I have made an array to store the pattern in:

> CharInfo: Array[0..15, 0..256] of CHAR;

> What I am having difficulty in is giving ES the segment of the array and BP the
> offset of the array. I used this code:

> CharSeg:= Seg(CharInfo[0, 0]); {Both variables are defined as WORD}
> CharOfs:= Ofs(CharInfo[0, 0]);

> Asm
>    Mov ES, CharSeg  {In addition I have put the other information in the
> registers}
>    Mov BP, CharOfs  {needed to perform the interrupt under this Asm block}
> End;

> I have figured out that the problem is in the CharSeg & CharOfs variables
> because
> when I made them equal the address for the default font, it worked fine. When
> they are set to the address of CharInfo, the font is not changed properly(ie:
> the characters will all be funny dots and whatever...)

> *Any and all HELP is appreciated!*
>                   C.J.

First, the replies you've gotten so far missed the point (most were {*word*75}ing about
using BP).

second, they failed to mention the address operator (@).
seg and ofs only return the high and low words of a pointer. the @ sign returns a
pointer to a variable, so the way you were trying it could work if you used

CharSeg:= Seg(@CharInfo[0, 0]); {Both variables are defined as WORD}
CharOfs:= Ofs(@CharInfo[0, 0]);

example:

uses dos;

var
  er:registers;
begin
  er.ax:=$1100;
  er.bx:=$1000;
  er.cx:=$0100;
  er.dx:=0;
  er.es:=seg(@charinfo)
  er.bp:=ofs(@charinfo);
  intr($10,er);
end;

or try

asm
  push bp
  les  bp,@charinfo
  mov  ax,$1100
  mov  bx,$1000
  mov  cx,$0100
  xor  dx,dx
  int  10h
  pop  bp
end;

Hope this helps...

Re:Seg, Ofs Problem...


In article <35E0090C.C0802...@nzc.com>,

Quote
Deathshadow  <jason.kni...@nzc.com> wrote:

>second, they failed to mention the address operator (@).
>seg and ofs only return the high and low words of a pointer. the @ sign returns a
>pointer to a variable, so the way you were trying it could work if you used

Seg and ofs return the segment and offset of any variable, pointer or
not. They do NOT reference the pointer.

Quote

>CharSeg:= Seg(@CharInfo[0, 0]); {Both variables are defined as WORD}
>CharOfs:= Ofs(@CharInfo[0, 0]);

That does not even compile as you ware attempting to take segment and
offset of a constant (addresses of static variables are constants).

Osmo

Other Threads