English Amiga Board


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

 
 
Thread Tools
Old 19 April 2024, 09:22   #1
Honitos
Registered User
 
Honitos's Avatar
 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 145
Do these 2 asm-routines do exactly the same thing?

Hi guys,

when investigating the old blitzbasic2 compiler source, I found these two routines.
I guess they do absolutly the same, except the second one being a bit more "smart". Both routines are used!

What it does it to copy the data from adress in A0 until A1 to a destination pointer that is handled by the routine "writeword".

Do you see any possible difference in the output?

pokecode1:
Code:
.pokecode:   ;a0= start of code, a1=end of code
  MOVE.w (A0)+,D1
  BSR.w writeword
 'loop
    CMPA.l A1,A0
    BCC.w 'done
      MOVE.w (A0)+,D1
      BSR.w writeword
  BRA.w 'loop
 'done
RTS
pokecode2:
Code:
.pokecode2:
  MOVE.w (A0)+,D1
  BSR.w writeword
  CMPA.l A1,A0
  BCS.w pokecode2
RTS

Last edited by Honitos; 19 April 2024 at 22:42.
Honitos is offline  
Old 19 April 2024, 09:49   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
no. BTW those routines don't take into account that A1 could be equal or below A0, which is a big problem as zero byte memory range would still do something.
jotd is offline  
Old 19 April 2024, 10:23   #3
Honitos
Registered User
 
Honitos's Avatar
 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 145
Smile

Thanks jotd,

I - respectively the original coder - was aware of this and refrained from checking A1 in that routine for speed reasons, I guess.
Honitos is offline  
Old 19 April 2024, 18:39   #4
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
Well, the code already spends a bsr per read word, which should be costly. The second one is slightly faster.

Minimal change to solve the 0 length issue JOTD points out would be

Code:
.pokecode2:
bra.b .pokecode2check
.pokecode2L:
  MOVE.w (A0)+,D1
  BSR.w writeword
.pokecode2check:
  CMPA.l A1,A0
  BCS.w pokecode2L
RTS
Photon is offline  
Old 19 April 2024, 20:13   #5
Rob68K
Registered User
 
Rob68K's Avatar
 
Join Date: Apr 2021
Location: Kingston / UK
Posts: 102
I don't think I've ever used BCC BCS on 68000.
Tell me why I'm wrong.
Rob68K is offline  
Old 19 April 2024, 20:39   #6
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
I prefer BHS/BLO aliases unless I'm explicitely checking the C flag (rarely). I find them more self-explanatory (= fewer comments needed), but it also requires more discipline because if you happen to switch to signed, in some cases it's not as trivial as HS/LO -> GE/LT because of the V flag that is part of the signed combo.
a/b 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
Help with CanDo routines fstltna support.Apps 2 10 March 2023 19:18
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 13 30 December 2020 11:57
ASM: Asm-ONE or AsmPro - how to set a Hello amiga coders, I hope it is ok to hijack ? Fireball Coders. Asm / Hardware 2 24 April 2020 21:16
decompression routines Toni Wilen Coders. General 12 17 May 2017 00:30
Checksum routines in games Joejoe Coders. Tutorials 11 26 December 2009 20:24

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 13:39.

Top

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