English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 27 February 2016, 11:17   #1
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
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
AGS is offline  
Old 27 February 2016, 12:17   #2
hooverphonique
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.
hooverphonique is offline  
Old 27 February 2016, 12:21   #3
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
ah, ok. thanks. this was exactly what I need to kow.
AGS is offline  
Old 27 February 2016, 15:31   #4
Photon
Moderator
 
Photon's Avatar
 
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.
Photon is offline  
Old 09 March 2016, 19:31   #5
TheDarkCoder
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
TheDarkCoder is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:54.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07455 seconds with 13 queries