19 January 2007, 18:58 | #21 |
move.w #$4489,$dff07e
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
|
Yup, I agree EQU is very useful in making your code both easier to read and manage. If any of you guys know any C/C++ you could say EQU is very much like #define in some respects.
Just as an example when loading a colour register it's much easier to read your code when you are doing something like: Code:
COLOR EQU $dff180 move.w d0,COLOR Code:
move.w d0,$dff180 It's best to bear this stuff in mind NOW so you don't start bad habits. |
19 January 2007, 19:03 | #22 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Everything I've posted thus-far is discussed later in the book i'm reading. I'll naturally cover it when I get that far
|
19 January 2007, 19:49 | #23 | |
Registered User
Join Date: Feb 2005
Location: montreal / canada
Age: 47
Posts: 722
|
Quote:
|
|
19 January 2007, 20:43 | #24 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
ds.b 1 will allocate 1 byte in memory
ds.w 1 will allocate 2 bytes ds.l 1 will allocate 4 bytes The allocated memory will be empty and just the address associated with the name |
19 January 2007, 21:39 | #25 |
Moderator
|
in nearly every assembler command the amount of bytes is stored via:
xxx.b -> 1 byte xxx.w -> 2 bytes xxx.l -> 4 bytes and there is a special "form" of "type" the nibble... xxx.s -> 1/2 byte -> 4 bits just to mention it... and the dc.x "command" (it´s not really a command !!) is neccessary for PC relative coding !!!! |
20 January 2007, 00:37 | #26 | ||
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
Quote:
|
||
20 January 2007, 12:53 | #27 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
This thread is going to get too complex too quickly.
I have not mention (pcP relative coding yet but it will be covered. I'll also be covering other area's, just give it time and please you seasoned asm guys, if you mention something new explain it! |
20 January 2007, 14:32 | #28 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Simple arithmetic
Code:
add.<size> source,destination an example Code:
move.l NUMBER1,d0 Copy contents of NUMBER1 into d0 add.l d0,NUMBER2 Add the contents of d0 to that already in NUMBER2 rts NUMBER1 dc.l 3 Set NUMBER1 to 3 NUMBER2 dc.l 4 set NUMBER2 to 4 That is pretty much all the book covers on arithmetic, though there will be more i'm sure |
20 January 2007, 14:52 | #29 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Loops
The following new commands will be used here
Code:
lea source address, register moveq source, destination subq source,destination beq address bne address bra address Code:
lea NEW_WINDOW,a0 Loops Loops have 4 identifiable sections
Code:
post-test loop moveq #10,d0 put 10 into d0 LOOP MAIN BODY ; here is where the main body of the loop would be subq #1,d0 ; Subtract 1 from d0 bne LOOP ; if d0 doesn't equal 0 then loop Code:
pre-test loop moveq #10,d0 put 10 into d0 LOOP beq LOOP_END if d0 equals 0 jump past loop MAIN BODY ; here is where the main body of the loop would be subq #1,d0 ; Subtract 1 from d0 bra LOOP ; branch back and loop LOOP_END Last edited by BippyM; 20 January 2007 at 15:45. |
20 January 2007, 20:53 | #30 |
Registered User
Join Date: Feb 2005
Location: montreal / canada
Age: 47
Posts: 722
|
thanks bippy ...what would be the difference between moveq and move.l ?
|
21 January 2007, 01:18 | #31 |
Registered User
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 364
|
moveq is the "quick" version, only used for values +/- 128, but it takes less cpu cycles than the normal move...
|
23 January 2007, 12:26 | #32 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Some asm stuff i found on the net
Last edited by BippyM; 10 July 2013 at 23:00. |
24 January 2007, 15:20 | #33 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
String Conversion
One way to store characters in memory would be to store a count of the number of characters in the string.
Code:
TEXT dc.b 5,"HELLO" Code:
TEXT dc.b "HELLO",0 We shall program a routine which will convert the pre-calculated method to the 0 terminating method. We need to start by loading a register with the address of the first character which we can then copy into d0. Code:
lea TEXT,a0 load a0 with start address of TEXT move.b (a0),d0 Copy character count into d0 Code:
COPY ds.b 6 Reserve 6 bytes for the copy and terminating 0 Code:
lea COPY,a1 Address of destination into a1 We need to move the address of a0 to point to the first letter of the string so the following code needs to be included Code:
addq.l #1,a0 ; increas address in a0 by 1 Code:
lea TEXT, a0 Put start address of TEXT into a0 move.b (a0), d0 Copy Char count to d0 (5) addq.l #1, a0 Increase a0 address by 1 lea COPY, a1 Start address of dest into a1 <Main Loop, Not Yet written> rts TEXT dc.b 5,"HELLO" COPY ds.b 6 Code:
move.b (a0),(a1) copy contents of a0 to a1 subq.b #1,d0 reduce count by 1 Code:
addq.l #1,a0 increase a0 by 1 When d0 equals 0 (zero) then the loop is effectively over so a BNE (Branch Not Equal) loop can be used our loop now looks like Code:
LOOP move.b (a0),(a1) Copy contents of a0 to a1 addq.l #1,a0 Increase address by 1 addq.l #1,a1 and again fore a1 subq.b #1,d0 decrease count by 1 bne LOOP if d0<>0 loop Code:
move.b #0,(a1) add termination (and before someone says yes I know there are quicker and better ways of doing this ((a0)+ etc), and that is next so please keep quiet!) |
24 January 2007, 16:03 | #34 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
is anyone finding this useful?
|
24 January 2007, 16:16 | #35 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
I find it interesting to read, even though I know my 68k asm pretty well by now.
|
24 January 2007, 16:22 | #36 | |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Quote:
|
|
24 January 2007, 16:24 | #37 |
Lesser Talent
Join Date: Jan 2003
Location: UK
Age: 42
Posts: 7,957
|
I'm reading every post, makes interesting reading
@Bip: can't remember what I wanted on IRC... |
24 January 2007, 16:58 | #38 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
|
|
24 January 2007, 17:39 | #39 |
Registered User
Join Date: Feb 2005
Location: montreal / canada
Age: 47
Posts: 722
|
keep up with your great project! amazing
|
25 January 2007, 01:49 | #40 |
superFreak
|
god dang... now I'm gonna have to learn asm..... bastards....
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Downfall - diary of a game... | Graham Humphrey | Amiga scene | 505 | 15 March 2015 19:26 |
Uridium 2 : Diary of a Game | silkworm | Amiga scene | 15 | 09 August 2011 09:00 |
19 Part One - Boot Camp | Retro-Nerd | project.aGTW | 2 | 19 February 2008 22:11 |
Help....what is this part 2? | Dizzy | Retrogaming General Discussion | 7 | 05 June 2007 15:27 |
|
|