flat assembler
Message board for the users of flat assembler.

Index > Windows > Words to mem/file

Author
Thread Post new topic Reply to topic
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes
If ax=0000 append 'cat'
if ax=0001 append 'dog'
.....
if ax=ffff append 'end'
Which is the best solution?
write sthng, file_end?
write to mem,'cat' add edi,3 write to mem 'doghouses' add edi,9 ?
Post 11 Jul 2022, 09:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18846
Location: In your JS exploiting you and your system
revolution
Please define your criteria for "best"?
Post 11 Jul 2022, 09:19
View user's profile Send private message Visit poster's website Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes
Small
Fast.
Post 11 Jul 2022, 10:16
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 652
Location: Russia
macomics
Code:
; switch 0 .. 65535
        mov si, ax
        add si, si
        jc @f
        mov ds, word [fs:si] ; 64 kb segment
        jmp next

@@:
        mov ds, word [gs:si] ; 64 kb segment

next:
; append word:
;   align 16
;   db 3, 'cat'
;   align 16
;   db 3, 'dog'
; ...
;   align 16
;   db 3, 'end'
        pushf
        cld
        xor si, si
        lods byte [si]
        movzx cx, al
  rep  movs byte [di], [si]
        popf    
Post 11 Jul 2022, 10:31
View user's profile Send private message Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes
Thx!I will try.
mov dword[edi],'dogs'
add edi,4
mov dword[edi],'cats'
mm0 and xmm0 doesnt work with 'text' Sad
Post 11 Jul 2022, 15:09
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1251
Roman
Quote:

rep movs byte [di], [si]

Weird !
Its equal:
rep movsb
Post 11 Jul 2022, 17:08
View user's profile Send private message Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes
mov dword[edi],'sedi'
mov dword[eax],'seax'
mov dword[ebx],'sebx'
mov dword[ecx],'secx'
mov dword[edx],'sedx'
mov dword[esi],'sesi'
mov dword[ebp],'sebp'
add edi,28
Post 11 Jul 2022, 18:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18846
Location: In your JS exploiting you and your system
revolution
Fastestcodes wrote:
Small
Fast.
There is no objective measure of "fast". It depends upon the circumstances of it's execution.

Combining "small" with "fast" will lead to contradictions. You have to choose one that outweighs the other. Or you need to define a formula or function that combines the two in some way that achieves your goal.

"Small" is by far the easiest criterion to work with. I'd suggest you drop the "fast" criterion. It is the hardest to define and measure.
Post 11 Jul 2022, 19:10
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.