English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 09 August 2012, 13:43   #21
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Hey there - gonna get back into coding cracktros and stuff? Would be cool

From your code, you could replace:

Code:
                    jsr                 _LVOOpenLibrary(a6)
                    tst.l               d0
                    beq.b               .no_lib
                    move.l              d0,a6
with:

Code:
                    jsr                 _LVOOpenLibrary(a6)
                    move.l              d0,a6
                    beq.b               .no_lib
but I'd say your 15 years old memory is working pretty good
pmc is offline  
AdSense AdSense  
Old 09 August 2012, 13:55   #22
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by pmc View Post
Code:
                    jsr                 _LVOOpenLibrary(a6)
                    move.l              d0,a6
                    beq.b               .no_lib
but I'd say your 15 years old memory is working pretty good
This is buggy code because move dx,ax does not set any flags! The tst.l is required in his code.
StingRay is offline  
Old 09 August 2012, 14:57   #23
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
LOL. That told me then!
pmc is offline  
Old 09 August 2012, 15:02   #24
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
It's quite a common mistake actually, yours truly is guilty of having written such code too.
StingRay is offline  
Old 09 August 2012, 15:04   #25
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by Lonewolf10 View Post
I think it is necessary to write stupid comments in the beginning, because if anything else it helps to build ones confidence in using the instruction. Atleast if you forgot what it does you have an easy lookup.
I do think it's definately a good idea to write a "stupid comment" after instructions like move.l 4(a0,d0.w),d1 which are quite confusing for beginners - or atleast it was for me.
If the new style formatting was used, it would be a little easier to explain move.l (4,a0,d0.w),d1 for beginners. Think of a '+' everywhere there is a ',' gives move.l (4+a0+d0.w),d1. I used to use the old style formatting but gave it up because the new style is better (easier to read) and any decent assembler accepts the new style even for the 68000. There is no reason to teach new programmers old stubborn habits. At least you are using small caps in code for the instructions which is easier to read .
matthey is offline  
Old 10 August 2012, 00:38   #26
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 38
Posts: 1,917
Quote:
Originally Posted by matthey View Post
If the new style formatting was used, it would be a little easier to explain move.l (4,a0,d0.w),d1 for beginners. Think of a '+' everywhere there is a ',' gives move.l (4+a0+d0.w),d1. I used to use the old style formatting but gave it up because the new style is better (easier to read) and any decent assembler accepts the new style even for the 68000. There is no reason to teach new programmers old stubborn habits.
I wasn't aware there was an old vs. new style for that. However, I am actually used to the old style so will probably stick with that


Quote:
Originally Posted by matthey View Post
At least you are using small caps in code for the instructions which is easier to read .
I don't understand why anyone would write (type) the instructions in capitals. The only thing I type all in capitals is the names of the registers, with some of the address labels and variables occasionally having capital letters (or underscores) to improve readability (e.g. yscreenposition vs. yScreenPosition).


Quote:
Originally Posted by StingRay View Post
This is buggy code because move dx,ax does not set any flags! The tst.l is required in his code.
I may have overlooked this in some of the manuals, but is there a list of which instructions set/clear the flags (other than obvious ones such as mulu/muls (for overflow) and divu/divs (for underflow))?
Lonewolf10 is offline  
Old 10 August 2012, 02:58   #27
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by Lonewolf10 View Post
I may have overlooked this in some of the manuals, but is there a list of which instructions set/clear the flags (other than obvious ones such as mulu/muls (for overflow) and divu/divs (for underflow))?
The M68000PRM shows how the condition codes are set for each instruction:

http://www.freescale.com/files/archi.../M68000PRM.pdf

Any OPA instruction (An destination), except CMPA, does not affect the CCR. Additionally, all OPA instructions with a word size immediate sign extend the data to a longword before the operation. Note that TST.W An does only test the lower word of An. Vasm (fixed in latest version) and PhxAss have an optimization bug that does CMPA.W #0,An -> TST.W An for 68020+ (TST An not allowed on 68000). This should be CMPA.W #0,An -> TST.L An. The bug went unreported for many years.
matthey is offline  
Old 29 September 2012, 22:56   #28
pintcat
Registered User
 
Join Date: Mar 2008
Location: Berlin/Germany
Posts: 210
Quote:
Originally Posted by StingRay View Post
Quote:
Originally Posted by pmc
Code:
jsr _LVOOpenLibrary(a6)
move.l d0,a6
beq.b .no_lib
This is buggy code because move dx,ax does not set any flags! The tst.l is required in his code.
Ugh... I've seen this often in other source codes which I was intended to learn from. I had no clue that this is actually pointless.
Another (nooby) question which might be a bit off-topic here: I know how to check a library version by calling the exec function OpenLib(). But what if I want to check the version of the exec.library itself? Do I have to use OpenLib() here too or are there other ways?
(OpenLib wouldn't work on Kickstarts below 1.1 and OldOpenLib doesn't check the version, that's why I'm asking)
pintcat is offline  
Old 29 September 2012, 23:57   #29
Leffmann

 
Join Date: Jul 2008
Location: Sweden
Posts: 2,029
The library version is stored in the library base, so in the case of exec it would be SysBase->LibNode.lib_Version, it's an unsigned 16-bit word at offset 20 from the library base.
Leffmann is offline  
Old 30 September 2012, 02:59   #30
pintcat
Registered User
 
Join Date: Mar 2008
Location: Berlin/Germany
Posts: 210
Yay - that sounds easy even to me! Thanx for the hint Leffmann. Now I have to finish some code...
pintcat is offline  
Old 01 October 2012, 11:54   #31
redblade
Zone Friend

redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 33
Posts: 1,049
Quote:
Originally Posted by StingRay View Post
This is buggy code because move dx,ax does not set any flags! The tst.l is required in his code.
Glad I read this thread, I make that mistake :/

Last edited by redblade; 01 October 2012 at 11:55. Reason: type-O
redblade is offline  
Old 09 October 2012, 19:12   #32
AlfaRomeo
A1200 040 SAM440EP 667
AlfaRomeo's Avatar
 
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 775
Someone could explain me the difference between brs and jsr?
Thanks in advance
AlfaRomeo is offline  
Old 09 October 2012, 19:25   #33
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
bsr and jsr are basically the same commands, jsr just allows a larger branch distance than bsr. If you need to call a routine in a different section you need to use jsr for example. I'd just always use bsr, your assembler will give you an error message if the distance is too large, then you can change the bsr to jsr.
StingRay is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Danish Amiga Assembly Programming Course Controller Coders. Tutorials 60 01 June 2014 01:16
Beginning Programming robheaton Coders. General 60 16 April 2011 12:49
New to forum Love AMIGA of old and beginning an emulation state catwatch3 New to Emulation or Amiga scene 15 30 December 2010 13:38
Amiga Assembly sources - Please help! D4Ni3L3 Amiga scene 21 16 July 2008 09:13
Beginning Amiga programming in C++ zardoz Coders. General 3 17 May 2006 14:14

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 16:06.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.22950 seconds with 14 queries