Solved

# C to assembly conversion help

Posted on 1997-07-29

Hello, I am having trouble converting this function to assembly because i barely know assembly, so i need some help. Below is the C function(bout 20 lines) and after that is what i have started on(I know its all wrong). So let me explain the variables below:

is_cached - is hit a lot more often

n - is from 0 to 319

tex - is char *

tex_row_table - is int [258]

swim_u & swim_v - is int [256]

g_mip - is int either 0,1,2,3

wid * ht - are int

#include "s.h"

#include "fix.h"

#include "tm.h"

void draw_affine(int n, char *dest, fix u, fix v, fix du, fix dv)

{

if (is_cached) {

while (n--) {

int iu = u >> 16;

int iv = v >> 16;

*dest++ = tex[tex_row_table[iv+1] + iu];

u += du;

v += dv;

}

} else {

while (n--) {

int iu = ((u + (swim_u[(((v<<g_mip) >> 16) & 0xff)] >> g_mip)) >> 16) & wid;

int iv = ((v + (swim_v[(((u<<g_mip) >> 16) & 0xff)] >> g_mip)) >> 16) & ht;

*dest++ = tex[tex_row_table[iv+1] + iu];

u += du;

v += dv;

}

}

}

this is what i have for assembly; (just for some sorta skeleton ;)

.file "affine.asm"

.medium

.486

_global draw_affine

draw_affine:

mov si,n

les di,dest

mov eax,u

mov ebx,v

mov ecx,du

mov edx,dv

mov ax,tex_row_table

cmpl is_cached,0

je scandone

scanloop:

add ax,eax

add ax,ebx

adc bx,ax

mov bx,tex

mov ah,[bx]

mov es:[di],ah

add eax,ecx

add ebx,edx

dec si

jnz scanloop

scandone:

ret

so im sure a lot, a lot of that is wrong so thats why i need help, i also only attempted the if(is_cached). This should be enough points for this, and any other questions email me at benco@gisco.net.

Thanx a lot in advance