English Amiga Board

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

Thread Tools
Old 25 October 2019, 05:35   #1
OctaMED Music Composer

KONEY's Avatar
Join Date: Jan 2009
Location: Venice - Italy
Age: 46
Posts: 423
nOOb needing help to understand Conditional Branching

My first steps in 68k assembly and already stuck in something very trivial like how to reuse pieces of code

I learnt a subroutine is made up by a label, some code and a RTS statement. Call it with "BSR label" and after the code inside is executed and the RTS reached the flow continues from below where the BSR was issued.

But what if I need to execute a function only with some conditions AND go back? BEQ and BNE jump to a subroutine but at the RTS the program exits. I need instead to BRA to a specific label to make it work but this prevents me from being able to call the subroutine from any part of the code I'd like.

I'm missing something... but I can't figure out what to look in manuals. All I can find are sentences like: "conditional branching will not continue from where it was called, thanks for reading." : banghead

any help...
KONEY is offline  
Old 25 October 2019, 06:51   #2
Registered User

Join Date: Jul 2018
Location: France
Posts: 555
You conditionally branch, using the opposite condition, over a branch, so that the bar only gets e ecuted if your condition was true. So to call a subroutine only if d0 is equal to zero:

        tst.w   d0
        bne     1$
        bar     subroutine
1$      more code...
Use local labels for stuff like this, otherwise you'll spend more time thinking of names than coding.

Last edited by deimos; 25 October 2019 at 07:35.
deimos is offline  
Old 25 October 2019, 23:42   #3
OctaMED Music Composer

KONEY's Avatar
Join Date: Jan 2009
Location: Venice - Italy
Age: 46
Posts: 423
WORKED! thanks!
KONEY 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
Motherboard: Can someone help me understand what this is and how to clean it? Sim085 support.Hardware 15 30 August 2019 21:24
conditional breakpoints jotd request.UAE Wishlist 2 12 June 2016 19:36
Noobie Help (conditional branching) bodhi Coders. Asm / Hardware 7 03 January 2013 00:55
Anyone understand Japanese? Jawsykilla Retrogaming General Discussion 19 02 April 2010 21:26
Total noob needing help with Amiga Forever Kitt New to Emulation or Amiga scene 5 10 August 2007 00:00

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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.06482 seconds with 15 queries