Main 
Home
Tools & Emus
Programming
Guestbook
Links
Contact
About

Demos 
C64-Demos Main
Sourcecodes
T100 Downloaded
T100 Voted
Latest
Parties
Demo-Requests
Submit Demos

Search 
Search Demo/Group:

User - Login here 
User:
Pass:
 

Not a User yet?
Register here!


Lost your Password?
Get it back!

Statistics 
Users 30415
Demos 7492
Groups 1181
Downloads 7984808
Votes 8870
Guestbook 399
Links 165

Corporate 
©1998-2009 C64.CH
Servertime: 20.08.2017 19:19:55

We're valid! 
Programming - Move Commands 

Move Commands
 
Time for some commands, which gives you the power to command the commodore to do anything you want it to. The first ones we're going to look at are in the category "move commands", since they can move data. On other platforms you often have a command called move or mov, but on a c64 they're called other things like LDA, STA, etc. The principle of move commands on c64 is that either you move something into a processor register, or you move from a register to a memory address. The registers are called A (accumulator), X and Y. They can each hold a byte, which is a number from 0 to 255, or in hex 00 to FF, or in binary 00000000 to 11111111. Let's have a little example, which you can type in and test like the previous piece of code... (Remember to type .A2000 before the 1st line and all that!)

LDA #$07
STA $D021
BRK


Again, start it with G2000, and the amazing result should be a yellow screen.

Explaination:

LDA #$07 means "load accumulator with the value 7" and moves the number 7 (the color code for yellow) into the accumulator (aka the A register.)

STA $D021 means "store the value of the accumulator into the memory address $D021", which is where the background color is located.

BRK breaks out of the program so you return to the mon. This is necessary because the code doesn't loop forever like in the flicker example.

Instead of LDA #$07 we could also write LDA $07, which would mean that it was the content of the address $0007 we were moving into the accumulator. That's ofcuz a whole another story, so please notice that there's a big difference between LDA value and LDA address. Always remember the number sign (#) when it's a value you wanna LDA! If you try this...

LDA $D021
STA $D020
BRK


... it moves the background color to the border. Or maybe "move" is the wrong word since it doesn't change the source address, it just copies it. As you might have guessed $D020 and $D021 controls the border/background color. Everything that has to do with graphics is controlled by the addresses that start with $D0, but more about that later.

Time to see what we can use the X and Y registers for. Every time we write LDA or STA we could just aswell have used LDX/STX or LDY/STY. That would have resulted in the same effect, the only difference is that it's the X and Y registers that are used instead of A. But these registers can also be used for some more purposes. Let's try this...

LDX #$21
LDA #$0B
STA $D000,X
BRK


This is an example of socalled relative addressing. The first line loads X with the value $21, in the next line A gets the value $00, and in the 3rd line the value of A is moved to the address $D000+X, which means $D021 in this case. (The background color again... I'm really original, huh?)... Y can also be used for realive addressing (STA $1234,Y), and you can also LDA relaive (LDA $1234,X)... The relative addressing modes are very useful in loops, but more about that in the Compare/Branch section.

Another type of move commands is called transfer commands, and they move data within the registers. An example is TXA which means transfer X to A. So if X held the value $DF, A is now $DF. As in other move commands the source (X in this case) is not affected, so they both holds the value $DF now. Here's some more transfer commands is: TXA, TYA, TAX and TAY. They all transfer the 1st register to the 2nd - eg. TAY means A -> Y.

Well, we haven't really covered all of the move commands, but I guess it's time to move on, so it doesn't get too boring...








Banner Exchange - scenebanner.net 
The C64 Banner Exchange
Demo_Rand(); 
Lifeline by Stars On Sixtyfour

Top Voted 
10.00 - Edge of D..
8.83 - Cycle
8.46 - Dutch Bre..
8.45 - Biba 2 - ..
8.40 - Deus Ex M..
8.34 - +H2K
8.21 - Tower Pow..
8.17 - Delirious..
8.15 - Altered S..
8.14 - Krestolog..

Last Added Demos 
7512 - 20 Years..
7511 - Monday N..
7510 - Rust
7509 - Senpitui..
7508 - Spaceout
7507 - Wonderla..
7506 - XNX-Colo..
7505 - The Expr..
7504 - Saddamne..
7503 - First One

Top Downloaded 
39588 - X-2004 Mu..
30836 - Deus Ex M..
23096 - Dutch Bre..
21091 - Second Re..
19309 - Biba 2 - ..
19071 - Cycle
16606 - +H2K
15731 - Soiled Le..
15626 - Altered S..
14408 - Dawnfall

Sponsors 


© 1998 - 2007 C64.CH, send comments and bugreports to webmaster@c64.ch
Page rendered in 0.0031 Seconds