flat assembler
Message board for the users of flat assembler.

Index > Main > Aligned vs unaligned

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
macomics



Joined: 26 Jan 2021
Posts: 1042
Location: Russia
macomics 06 May 2022, 12:29
Andy wrote:
Why? Isn't this the way other instructions work?
The instructions work like this, but the addresses continue to number bytes. To do the same with the pointer, you will have to scale the addresses to 32-byte values at each step of the loop.
Andy wrote:
And would be better like saving the offset in a different register and use it something like that?
Then it will be more difficult to determine the alignment of addresses. The value of the sum of the two registers must be aligned.
Code:
esi rdx
 0   0 = 0
 1  31 = 32, head loop 31 times
 2  30 = 32, ...
 3  29 = 32
  ...    

Code:
    test esi, 00011111b ; 31
    jz ok
hl:
    ...
    inc esi
    test esi, 00011111b; 31, address
    loopnz hl ; counter
ok:    
Code:
    xor edx, edx
    lea eax, [esi + edx]
    test al, 00011111b
    jz ok
hl:
    ...
    inc edx
    lea eax, [esi + edx]
    test al, 00011111b; address
    loopnz hl; counter
ok:    

But it may become easier if you go to the end address instead of the byte counter. Then you will get rid of the need for double inc/dec.
Code:
add ecx, esi    
Maybe.
Post 06 May 2022, 12:29
View user's profile Send private message Reply with quote
Andy



Joined: 17 Oct 2011
Posts: 55
Andy 06 May 2022, 22:58
macomics wrote:

But it may become easier if you go to the end address instead of the byte counter. Then you will get rid of the need for double inc/dec.
Code:
add ecx, esi    
Maybe.


That's smart. Thanks for tip.
Post 06 May 2022, 22:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.