flat assembler
Message board for the users of flat assembler.

Index > Main > C to Asm

Author
Thread Post new topic Reply to topic
jInuQ



Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ 14 Mar 2004, 12:27
I am converting some C code to assembly. Can anyone tell me if this is on the right track?

Code:
proc _vorbis_apply_window, d, window_p, blocksizes, lW, W, nW
window rd 2
n  rq 1
ln rq 1
rn rq 1
leftbegin  rq 1
leftend    rq 1
rightbegin rq 1
rightend   rq 1
i rd 1
p rd 1
enter

        lea eax,     [window]
        mov eax,     [window_p]
        mov [eax+4], [window_p+4]

        return

;void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
;                          long *blocksizes,
;                          int lW,int W,int nW){

;  LOOKUP_T *window[2]={window_p[0],window_p[1]};
;  long n=blocksizes[W];
;  long ln=blocksizes[lW];
;  long rn=blocksizes[nW];

;  long leftbegin=n/4-ln/4;
;  long leftend=leftbegin+ln/2;

;  long rightbegin=n/2+n/4-rn/4;
;  long rightend=rightbegin+rn/2;

;  int i,p;

;  for(i=0;i<leftbegin;i++)
;    d[i]=0;

;  for(p=0;i<leftend;i++,p++)
;    d[i]=MULT31(d[i],window[lW][p]);

;  for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
;    d[i]=MULT31(d[i],window[nW][p]);

;  for(;i<n;i++)
;    d[i]=0;
;
    

_________________
jInuQ

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
- Antoine de Saint Exupery
Post 14 Mar 2004, 12:27
View user's profile Send private message Visit poster's website AIM Address Reply with quote
gorshing



Joined: 27 Jul 2003
Posts: 72
Location: Okla, US
gorshing 15 Mar 2004, 14:52
I believe that a long is only four bytes long, so I would change n, ln, rn, leftbegin, leftend, rightbegin, rightend to dword. An easy way to check that would be to output sizeof(long) from a C program.

And
Code:
mov eax,     [window_p]    

Should be
Code:
mov [eax],     [window_p]    


Or am I wrong?

_________________
gorshing
Post 15 Mar 2004, 14:52
View user's profile Send private message Visit poster's website Reply with quote
jInuQ



Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ 15 Mar 2004, 18:57
yeah, a long on my box is 4. Surprised

This is how I understand the whole braket thing with regard to registers.
Am I confused?

Code:
;This moves 15 to eax
    mov eax, 15

; And this moves  the dword pointed to by eax to ecx
    mov [ecx], [eax]

    

_________________
jInuQ

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
- Antoine de Saint Exupery
Post 15 Mar 2004, 18:57
View user's profile Send private message Visit poster's website AIM Address Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 15 Mar 2004, 19:33
It is not possible to move from memory to memory...
Post 15 Mar 2004, 19:33
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 15 Mar 2004, 20:13
did you check my tuts? There are answers on some of your questions

http://board.flatassembler.net/topic.php?t=1178
Post 15 Mar 2004, 20:13
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
jInuQ



Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ 16 Mar 2004, 08:09
My problem is not moving from memory to memory. As this is not what I am tring to do. I am trying to copy the address of the two pointers in the window_p array.

Code:


; Is this what I am looing for?
mov eax, [window_p]
mov ecx, [window_p+4]

    

_________________
jInuQ

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
- Antoine de Saint Exupery
Post 16 Mar 2004, 08:09
View user's profile Send private message Visit poster's website AIM Address Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 16 Mar 2004, 10:08
window_p is pointer to table of to pointers, am i right?
So you have to do it like this:
Code:
mov eax, [window_p]
mov ecx, [eax+4]
mov eax, [eax]
    

Now eax has value of the first pointer and ecx has the second. Now to modify memory the pointers are pointing to:
Code:
mov [eax], 1
mov [ecx], 2
    
Post 16 Mar 2004, 10:08
View user's profile Send private message Reply with quote
jInuQ



Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ 16 Mar 2004, 17:17
Sounds right. Thanks for the help. 8^)

_________________
jInuQ

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
- Antoine de Saint Exupery
Post 16 Mar 2004, 17:17
View user's profile Send private message Visit poster's website AIM Address Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 27 Oct 2004, 13:01
roticv wrote:
It is not possible to move from memory to memory...


yess? why not? Smile

Code:
org 256
push es
push ds
pop es

mov dx,msg
mov ah,9
int 21h

mov di,chgstring
mov si,string2
mov cx,length_string2
call movestring2string

int 21h

pop es
int 20h

movestring2string: ; ds:si > es:di , cx = count
rep
movs byte [es:di],byte [ds:si] ; alternatively : movsb
ret

msg: db 'Hello World!'
chgstring:db 'Is it possible to move string 2 string?',13,10,'$'
string2:  db 'It is possible to move string 2 string!',13,10,'$'
endstring2:
length_string2 dw endstring2-string2
    
Post 27 Oct 2004, 13:01
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.