At 11:04 AM 11/30/2012, Tom Ehlert wrote:

> > We have this snippet of code:
>
> > var a:array[0..255] of byte;
> > begin
> > asm
> >  seges lea di,a
> >  mov bx,0ffffh
> >  mov dx,0ffffh
> >  mov cx,256
> >  mov ax,6501h
> >  int 21h
> > end;
>
>it's simply a bug in your program.
>
>         ES:DI -> country information buffer (see #01750)
>
>but your code does not load ES. so ES most likely points 'somewhere'

I think that is what he tries to do with that SEGES instruction. 
Never used this and I was kind of surprised that my Borland Pascal 7 
compiler is actually accepting it!
I don't have my Borland Pascal 7 manuals at hand (they are in 
storage, as I haven't used them in years) and the (German) online 
help in BP7 only refers to it as "segment prefix" with no further 
explanation...

>where you don't expect it.
>         push ss
>         pop  es
>should work (otherwise use a debugger)
>
> > If A is assigned to constant value (for i:=0 to 255 do a[i]:=2) it works.
>because your smart compiler turns this into something like
>
>     push ss
>     pop es
>     mov cx,256
>     mov al,2
>     rep stosb
>
>and now es points to right segment.

Well, or simply using a different instruction all together, replacing

                 SEGES   LEA DI, a

with

                 LES, DI, a
(while still considering the side effects of messing with the ES 
register, but IIRC, that is within a BP7 program save to do)

That will properly point ES:DI to the buffer to fill...

Ralf 


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to