Jump to content
IGNORED

Session 18: Asymmetrical Playfields - Part 2


Recommended Posts

Actually in C it works exactly the same. :)

 

Yeh, the error dew2050 made is similar to this one:

 

#include

#include

int variable1;

int variable2;

 

printf("Hello Worldn");

 

void main(void){

/*some code in here*/

}

 

In essence, you tried to put code outside of any subroutine. You'd have just the same problems in C if you tried to insert code that was not "anchored" in a subroutine. The ORG statement tells the assembler where to start putting code. Being without an ORG is like being without a subroutine in C.

 

 

The order of subroutines doesn't matter in C because the compiler always sets the code to start running at main() even though the actual sequence of code in the final compiled binary is completely different.

 

You can do the same thing in assembly, but you have to implictly set it up that way - That's what ORG is for and that's what those two pointers you have at $FFFC are for. There's no real reason* other than convention NOT to put your data tables at the start of your ROM if you want to but again, you'd have to set it up properly so your program starts running from the right place.

 

This kind of thing is the very essence of the difference between a high level and low level language. Like the difference between a standard and automatic transmission on a car. A high level language will shift gears (allocate ROM and place your code seamlessly) for you while in a standard you must shift gears manually (place code explicitly yourself). The former is easier drive, particularly for a beginnner. The latter gives the driver more control and is generally more efficient resulting in a faster vehicle (Yeh, yeh you'll hear claims of great compilers that can generate faster, more optimised code then humans. And I have a really nice bridge I'll be listing on eBay next week...)

 

Chris...

 

 

*Atari 2600 will often put their display kernal at or very near the begining of ROM. This is so that as you add code later you are almost always adding it after the kernal. This avoids moving the kernal around which can cause timing problems ie: Moving a loop around so a branch instruction suddenly crosses a page boundary.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...