Well here goes my question: I set up VGA Mode 13h (320 * 200 px). Then I draw the whole screen black. Then I want my program to draw given points in green. The points are stored in WORD format as relative distances in Memory from A0000. So the only thing I have to do is setting ES to A000 and loading DI with the current point, then writing a given value to ES:DI. I could of course do this with lodsw, then mov DI, AX. But I think it could be done easier by setting SS to the beginning of the Coordinates and SP to Zero, then set the direction Flag an simply pop all the values to DI. Would that work, and is it faster?
Posted on 2006-09-19 10:37:35 by Firefall

Would that work, and is it faster?


I would suggest studying some opcode timing charts... like Agner Fog's. If it seems feesable, then test your theory :)
Posted on 2006-09-19 13:25:12 by SpooK
Well I just worked out that the stack actually isn't affected by the direction Flag, so this possibility's gone (Unless I want to reverse my coordinates, what I don't want). But I have now two possibilities:
Possibility 1:
mov CX,NUM_OF_COORDINATES ;Constant
mov DL,10h
DrawPoints:
lodsw
mov BX,AX
mov ,DL
loop DrawPoints

Possibility 2:
mov CX,NUM_OF_COORDINATES ;Constant
mov AL,10h
DrawPoints:
mov DI,
stosb
add BX,02h
loop DrawPoints

Now which one is faster? Or do you have any code suggestions that produce the same effect that I want? (8086 compatible only, please)
Posted on 2006-09-19 14:21:27 by Firefall
LODSW and string instructions of such kind take more time to execute than their equivalent instructions made of simple "MOV"s, therefore i think if you are optimizing for speed, you are better off using simplified instructions rarther than string instructions due to the fact that string instructions take about 4 times more than the simplified instructions to execute.

About the screen thing, you can load any of the segment registers with the video adapter's segment address and use any of the base index registers to navigate through individual offsets from the given segment. You can use either SS or ES or DS as the segment addresses and BX or DI or SI as offsets to form the complete 24bit segmented address.
Posted on 2006-09-20 01:47:16 by XCHG
If you're using si strings then maybe movsb would be easier

set di to its position

mov cx,10    ;or FF, or whatever
rep movsb    ;draws the si data set to the screen


Posted on 2006-09-20 04:41:56 by eek
@ eek: Youmuts have misunderstood me. I don't wanna move data around. I want to load DI (or BX or whatever) with an Offset and write a constant value to that Offset.
Posted on 2006-09-20 11:21:31 by Firefall