Board index » delphi » More inline ASM problems (extended registers)

More inline ASM problems (extended registers)

OK, I've been working on my VESA library some more, and now everything works
except ONE LINE. Here it is:

db 66h; mov ax, word ptr [lines[y]]; {eax = lines[y]}

Here Lines is a global array (ARRAY[0..1200] of Longint). What's wrong with
this line? It keeps giving me odd results. For example, Line[0] = 0.(Lines[y]
is the offset of line y in video memory.) When I try PutPixel(0,0,SomeColor),
and step through it with the de{*word*81}, watching the registers, after this
command I get odd numbers like 0e54h. Where is this coming from when it should
be 0? I'm guessing that the problem has something to do with the fact that
lines[y] involves a memory look-up?? I tried changing this line to

db 66h; mov ax, word ptr [lines+y];

but that didn't work either. Is there something I've overlooked here? Is 'word
ptr' somehow messing things up?
Thanks in advance for your help.

(One other question: about what speed should I expect for filling the screen
with putpixel commands in 800x600 mode? Right now it's taking about 1 second, I
think. Filling the screen with HLine calls is much faster, happening almost
instantaneously - I think it all works in one vertical retrace period.)

 

Re:More inline ASM problems (extended registers)


In article <1998040623365201.TAA21...@ladder03.news.aol.com>,

Quote
SWars Matt <swarsm...@aol.com> wrote:
>OK, I've been working on my VESA library some more, and now everything works
>except ONE LINE. Here it is:

>db 66h; mov ax, word ptr [lines[y]]; {eax = lines[y]}

Come on, assembler is not Pascal. You cannot do stuff like that in
assembler any more than you can do mov ax,succ(round(x+y+z*ln(b)). You
need to calculate the address yourself.

Quote

>Here Lines is a global array (ARRAY[0..1200] of Longint). What's wrong with
>this line? It keeps giving me odd results. For example, Line[0] = 0.(Lines[y]
>is the offset of line y in video memory.) When I try PutPixel(0,0,SomeColor),
>and step through it with the de{*word*81}, watching the registers, after this
>command I get odd numbers like 0e54h. Where is this coming from when it should
>be 0? I'm guessing that the problem has something to do with the fact that
>lines[y] involves a memory look-up?? I tried changing this line to

>db 66h; mov ax, word ptr [lines+y];

>but that didn't work either. Is there something I've overlooked here? Is 'word
>ptr' somehow messing things up?

Well you cannot just do things like indexing with a variable in ASM.
Also assembler uses byte indexing, not dword one.

Try:

      mov di,y
      shl di,2  { multiply by 4 }
      db $66h; mov ax,word ptr [lines+di]

(remember to set 286 code on. $G+)

Osmo

Other Threads