flat assembler
Message board for the users of flat assembler.
Index
> Main > Null termination? Goto page Previous 1, 2, 3, 4 Next |
Author |
|
buzzkill 30 Mar 2009, 18:25
Azu wrote: I'd really rather not use functions Not a big fan of structured programming? |
|||
30 Mar 2009, 18:25 |
|
Azu 30 Mar 2009, 18:27
buzzkill wrote:
revolution wrote:
|
|||
30 Mar 2009, 18:27 |
|
revolution 30 Mar 2009, 18:29
Azu wrote: I did. Twice. |
|||
30 Mar 2009, 18:29 |
|
buzzkill 30 Mar 2009, 18:32
Azu wrote:
I meant, normally you would divide your program into functions, each one containing a piece of the total functionality. This helps to keep your program logically structured, and promotes code reuse. If you really think that using functions is a waste because of a call/ret, I wonder what your programs look like... |
|||
30 Mar 2009, 18:32 |
|
Azu 30 Mar 2009, 18:32
revolution wrote:
buzzkill wrote:
It might be BIGGER.. but compressing that would be ridiculously easy, and uncompressing it once at the very beginning of execution wouldn't be a big deal performance wise for a long running application. |
|||
30 Mar 2009, 18:32 |
|
revolution 30 Mar 2009, 18:38
Azu wrote: String comparison (checking if two strings are equal, and at what byte they differ if not) scanning (seeing if a byte (or substring) exists in a string, and at what byte), and copying (setting the bytes in one string to the bytes in another), with strings of varying sizes, and a big load. I think it would be easier just to code up two or three versions and test. |
|||
30 Mar 2009, 18:38 |
|
Azu 30 Mar 2009, 18:42
revolution wrote:
|
|||
30 Mar 2009, 18:42 |
|
revolution 30 Mar 2009, 18:47
Azu wrote: Those are unknown except for on my own computer, under some artificial test. Which is why I am trying to figure out which is faster in general. |
|||
30 Mar 2009, 18:47 |
|
Azu 30 Mar 2009, 18:49
revolution wrote: unless you change the underlying algorithms or some other fundamental change. |
|||
30 Mar 2009, 18:49 |
|
revolution 30 Mar 2009, 18:57
But you still need to define how much time is spent processing strings? Is it 10%, 90%, what? I can't imagine an app that needs such a large amount of time just to process strings, but nevertheless, you did say that you want to optimise so naturally that means just for your situation.
String scanning, appending, searching algos etc. are also reliant on the type of strings you use. The length, the composition, the expected match hit position etc. You still need to define your usage model! You don't have to define it to me, but to yourself. And then you can start to make better decisions about what way to move forward with algo selections. |
|||
30 Mar 2009, 18:57 |
|
Azu 30 Mar 2009, 19:02
revolution wrote: But you still need to define how much time is spent processing strings? Is it 10%, 90%, what? I can't imagine an app that needs such a large amount of time just to process strings, but nevertheless, you did say that you want to optimise so naturally that means just for your situation. |
|||
30 Mar 2009, 19:02 |
|
revolution 30 Mar 2009, 19:03
For example if all your strings are expected to be < 4 bytes then null termination may work out great. But what if all the string are > 1 MB then maybe length prefix is better. What if you need to have a null in the string, well then your decision is easy, length prefix. Hmm, what about an app that uses lots of printf type function calls, well then null termination might be just the thing.
|
|||
30 Mar 2009, 19:03 |
|
revolution 30 Mar 2009, 19:05
Azu wrote: What I mean is, these things will be varying drastically. I don't know what % are going to be long and what % are going to be short, or how much % of the CPU is going to be used. Under this condition should I base the program on null termination, or prepended length? |
|||
30 Mar 2009, 19:05 |
|
Azu 30 Mar 2009, 19:06
revolution wrote: For example if all your strings are expected to be < 4 bytes then null termination may work out great. But what if all the string are > 1 MB then maybe length prefix is better. What if you need to have a null in the string, well then your decision is easy, length prefix. Hmm, what about an app that uses lots of printf type function calls, well then null termination might be just the thing. It would be a bit faster/smaller to be able to use all 256 values per byte instead of having to reserve one for null, but that's not really a deal maker or breaker unless it's a tie or very close.. revolution wrote:
I just want to know which is faster in general for string operations; null or length? |
|||
30 Mar 2009, 19:06 |
|
revolution 30 Mar 2009, 19:12
Azu wrote: I just want to know which is faster in general for string operations; null or length? But we are starting to get somewhere, you now mention that your strings average 1kb. Okay, so that sounds kind of longish to me so scanning just to get a length would quite probably not be as efficient as a length prefix. But, on the other hand, printf things might benefit from an extra register in the loop so a null terminator might be better. Hmm, you see, it depends upon your usage. |
|||
30 Mar 2009, 19:12 |
|
Azu 30 Mar 2009, 19:26
Thank you. I'll go with prepended length then. If I run out of registers I'll just use the length in memory.
|
|||
30 Mar 2009, 19:26 |
|
Azu 30 Mar 2009, 22:07
BTW what's the best way to do something like this?
Code: var db var.len db 'foo',30+var2 dw var3 dd 0,1 var.len equ $-var It doesn't like that var.len is defined after var. =/ Do I have to make a macro for this? Or is there something in FASM that can handle it? Sorry for the n00b question.. |
|||
30 Mar 2009, 22:07 |
|
LocoDelAssembly 30 Mar 2009, 22:21
Almost correct
Code: var.len = $ - var ; ("=" instead of "equ") |
|||
30 Mar 2009, 22:21 |
|
Azu 30 Mar 2009, 22:23
Perfect. Thanks a bunch
|
|||
30 Mar 2009, 22:23 |
|
Goto page Previous 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.