flat assembler
Message board for the users of flat assembler.

 Index > Main > C to Asm
Author
jInuQ

Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ
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
14 Mar 2004, 12:27
gorshing

Joined: 27 Jul 2003
Posts: 72
Location: Okla, US
gorshing
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
15 Mar 2004, 14:52
jInuQ

Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ
yeah, a long on my box is 4.

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
15 Mar 2004, 18:57
roticv

Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
It is not possible to move from memory to memory...
15 Mar 2004, 19:33
vid
Verbosity in development

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

http://board.flatassembler.net/topic.php?t=1178
15 Mar 2004, 20:13
jInuQ

Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ
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
16 Mar 2004, 08:09
aaro

Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro
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
```
16 Mar 2004, 10:08
jInuQ

Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ
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
16 Mar 2004, 17:17
Matrix

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

yess? why not?

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
```
27 Oct 2004, 13:01
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum