25 October 2019, 05:35 | #1 |
OctaMED Music Composer
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
|
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... |
25 October 2019, 06:51 | #2 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
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:
Code:
tst.w d0 bne 1$ bar subroutine 1$ more code... Last edited by deimos; 25 October 2019 at 07:35. |
25 October 2019, 23:42 | #3 |
OctaMED Music Composer
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
|
WORKED! thanks!
|
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 |
|
|