Gaudalier, do you mind if I mention something? You are translating a graphic routine from C to asm? Presumably the aim is to make it faster. I strongly suspect you're going to be disappointed in this approach...
I also assume you're probably using a VGA or similar graphics system. If so, then each generic pixel write first has to prepare the VGA card using a number of port "out" instructions, which are outrageously slow. Therefore if you clear the whole screen in a nested loop like this, you make as many of these "outs" as there are pixels. If you need to speed it up, the better approach in asm is to do one set-up outside the nested loop, and then do all the screen writing within the loop.
Of course there's a balance between generic code (the for-loop to Ximage is as generic as you can get; it doesn't even need to know the screen dimensions) and hardware-near efficiency. But if you're moving from C to asm, you must be interested in speed rather than genericness??
For interest, in 16-bit assembly for VGA you'd be doing something like:
{ set up all the VGA registers by out statements. I can't remember the addresses of VGA ports and their meaning withoug consulting suitable reference, but you'll have lots of statements like:
mov dx, 03CEh
mov ax, 0305h ;mode 3 is where I usually do drawing
out dx, ax }
....
mov di, size_of_screen
mov ax, 0A000h ; location of screen
mov es, ax
sub ax, ax
label:
mov es:di, ax
dec di
jnz label
mov es:di, ax
-all done--- (I could have burst into string instructions, but didn't because I'm lazy; in practice it won't make much difference to speed)
If you're not writing for VGA, please disregard nearly all I've written! Note that in VGA you can also cover 8 pixels with one write, which is useful for setting large areas of screen to one colour.