24 October 2018, 00:47 | #21 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Corrected code: Code:
;-- copy chars into textBuffer and zero-terminate it ;in: a0: source pointer ;in: d0: # characters to copy copyToBuffer: move.l 4.w,a6 ;keep lib base in a6; a6 might get changed (?) move.l d0,d2 ;CopyMem() does not necessarily preserve d0 lea textBuffer,a1 jsr _LVOCopyMem(a6) lea textBuffer,a1 ;CopyMem() does not necessarily preserve a1 add.l d2,a1 move.b #asciiNULL,(a1) .return: rts |
|
24 October 2018, 00:48 | #22 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
|
|
24 October 2018, 01:38 | #23 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
|
Quote:
Code:
;-- copy chars into textBuffer and zero-terminate it ;in: a0: source pointer ;in: d0: # characters to copy copyToBuffer: move.l 4.w,a6 ;keep lib base in a6; a6 might get changed (?) lea textBuffer,a1 move.b #asciiNULL,(a1,D0.L) JMP _LVOCopyMem(a6) |
|
24 October 2018, 01:59 | #24 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Oh, the register indirect with index and offset adressing mode, you mean? Thanks, you're absolutely right! No idea how I could've missed that, tbh.. |
|
24 October 2018, 08:31 | #25 |
Registered User
Join Date: Nov 2016
Location: Fadden ACT Australia
Posts: 128
|
Couple of comments:
1) it would be good practice to check the return code in d0 and handle it appropriately after calling a system library routine 2) the "JMP _LVOCopyMem(a6)" in the example above instead of a "JSR ...." assumes that the stack contains the valid return address of the routine that called your code and that your routine has left the stack in a clean state! Otherwise !!!!!! |
24 October 2018, 08:36 | #26 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
Edit: And CopyMem has no return code! Last edited by StingRay; 24 October 2018 at 08:41. |
|
24 October 2018, 09:12 | #27 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Actually it can be further optimized, knowing that #asciiNULL==0x00
|
24 October 2018, 11:17 | #28 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
On a side note: where do you get your info about how many cycles and how many bytes a given instruction takes? Because it's not documented (at least not consistently) in any books I have. Is there an online source I could check? |
|
24 October 2018, 11:18 | #29 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
|
24 October 2018, 11:37 | #30 | |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Quote:
Code:
jsr/bsr xyz rts Code:
jmp/bra xyz Last edited by hooverphonique; 24 October 2018 at 15:44. |
|
24 October 2018, 11:52 | #31 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
|
|
24 October 2018, 12:06 | #32 | ||
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
clr.b (a1,d0.l) Quote:
Suppose you have something like this: Code:
maincode: register_setup bsr calc_subroutine blabla_code1 bsr calc_subroutine blabla_code2 bsr calc_subroutine rts calc_subroutine: code_code rts Code:
maincode: register_setup bsr calc_subroutine blabla_code1 bsr calc_subroutine blabla_code2 calc_subroutine: code_code rts |
||
24 October 2018, 12:20 | #33 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
|
24 October 2018, 16:48 | #34 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 839
|
Some assemblers can optimize away all those. BAsm does AFAIR. (If you tell it to.)
|
24 October 2018, 16:58 | #35 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
But not perfect in optimizing code (no other assembler is perfect too). I've got some 'wrong' optimization with it that give me no more working code. So use it only for a 'suggestion' then manually optimize, or write optimized from the start |
|
24 October 2018, 18:16 | #36 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 839
|
If you don't have a Vampire(just not optimal) then you can take subroutine runs and turn them on the head:
jsr sub1 jsr sub2 jsr sub3 rts -> pea sub3 pea sub2 jmp sub1 |
24 October 2018, 18:25 | #37 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Oh cool, so you're kinda 'stringing' those calls together by pushing their adresses on the stack, rather than always coming back to the calling routine. Nice! And no, I don't have a Vampire (yet)..
|
24 October 2018, 18:55 | #38 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Not if you use an absolute addressing mode like the proposed example.
jsr $absoluteand pea $absoluteare the same cycles on 68000 and the rtsneed to be executed anyway. Different the jsr offset(pc)and pea offset(pc)case where peais faster than the jsr/bsrcounterpart. EDIT: well, considering the two messages in sequence (optimization by the assembler and pea/jsr couple), is clear why that code is considered faster. It is simply the assembler that optimizes it (if it can), making it pc relative. But always better understand what is behind it . Last edited by ross; 24 October 2018 at 19:36. |
24 October 2018, 19:22 | #39 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
What is a reliable source for this kind of information? I found this (http://oldwww.nvg.ntnu.no/amiga/MC68...000timing.HTML), but I find it a bit strangely organised. Maybe that's just me, though, not really understanding all the nuances and subtleties this entails.
What would be great is some kind of interactive version of this. So I just type in my instruction, and it comes back with timing information (maybe broken down into address calculation time + the rest) and preferably also size information. Now thát would be a handy tool! |
24 October 2018, 19:32 | #40 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
I use this https://wiki.neogeodev.org/index.php...ctions_timings (which basically refers to what you have linked)
or the official Motorola manuals. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OCS collision and clx registers | PiCiJi | Coders. Asm / Hardware | 11 | 30 July 2019 06:15 |
A4000 IDE registers | mark_k | Coders. Asm / Hardware | 6 | 11 May 2015 17:05 |
Using FPU registers? | oRBIT | Coders. General | 16 | 26 April 2010 13:34 |
Need DA8000-DAFFFF registers documentation | BlueAchenar | Coders. General | 2 | 13 December 2008 15:39 |
Gayle Hardware Registers | bluea | support.Hardware | 5 | 09 July 2006 17:07 |
|
|