27 February 2016, 11:17 | #1 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
calc string length in asm
Hi,
I am a bit confused. Is the following code correct to calc the length of a string in bytes or should the "not.w" rather be a "neg.w"? Code:
moveq #-1,d0 .name_length tst.b (a0)+ dbeq d0,.name_length not.w d0 |
27 February 2016, 12:17 | #2 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,635
|
if you use neg, the count will include the terminating zero, if you use not, it won't.
|
27 February 2016, 12:21 | #3 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
ah, ok. thanks. this was exactly what I need to kow.
|
27 February 2016, 15:31 | #4 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,647
|
A standard technique was also to put a byte before the first char containing the length of the string from 0 to 255. All string functions that insert or delete characters must then update the length value, but that's just 1 instruction. It's much more efficient.
|
09 March 2016, 19:31 | #5 |
Registered User
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
|
neg is equivalent to not followed by add #1
So the sequence neg d0 add #1,d0 can be optimized as not d0 |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Final Calc wanted | AlfaRomeo | request.Apps | 5 | 05 November 2016 22:45 |
ARexx string length limit | amiga | support.Apps | 5 | 15 August 2015 06:00 |
calc-2.12.4.13 | alkis | Coders. Releases | 8 | 18 October 2014 16:12 |
os 3.1 string length limit | Miggy | support.Apps | 1 | 07 September 2014 21:05 |
Chessboard speed calc? | h0ffman | Coders. General | 4 | 14 September 2011 08:31 |
|
|