atari2600land, on Tue Dec 7, 2010 5:30 PM, said:
OK, Now I know how to get a .p file. Through trial and error, I discovered that if you drag an .a48 file to AS's icon and there's no programming errors, it spits out a .p file in the same folder. I then use the batch file I made to get a ROM. What I don't think I'll ever understand, though, is assembly. I think I'm just too dumb to grasp anything about it.
Assembly isn't impossible, you just have to know the general rules about how computers work and then have all the documentation handy about the particular CPU and system you're dealing with.
With any computer system you're dealing with you'll need to know:
1. binary number systems. You need to know how to do binary math and how bits combine to make bytes (or larger numbers on other systems) and you need to know how bitwise operations work like AND, OR, XOR, etc.
2. Understand the concept of memory and address space. Each byte of memory has an address. I can store a value in byte location 432 and when I read location 432 later, the value will be there. Some areas of memory are for your use for variables, and some locations have a special purpose within the system you're using. The full range of possible locations are the address space. Not all locations may be available to you since the CPU may be capable of using more memory than is installed.
3. Understand the concept of a program. The CPU will do the operations it is instructed to do by following a sequence of numbers stored in memory (sometimes this memory is the same as your variable memory and sometimes the program has its own separate memory. The 6502 and 8048 are different in this regard). Assembly language is an easier to understand representation of the machine-language program so you don't have to type in raw instruction data to write a program.
4. Understand the concept of hardware registers. While the majority of available address locations will be memory, some will be special purpose registers inside other IC's. These will allow you to access the video, sound, inputs (like joysticks), and other special functions of the system. Generally, RAM is used to prepare the necessary values to put into these register locations to achieve the desired output from the system.
5. Finally, understand how a typical CPU allows you to read and write values from memory and perform operations on them. CPU's also have registers that preform special functions or allow you to quickly store a number for later use. Many CPU's have an Accumulator which is where the results of an operation are made available.
Here's a program on a simple made-up CPU to show the sort of things one might do (not fully 8048 compliant):
mov A, #3 this instruction would put the number 3 in the Accumulator (note the # means this is a number)
add #2 this instruction would add the number 2 to the 3 we've already got.
mov 1, A this instruction would put the result of 5 into memory location 1 (note the # is missing)
and #1 this instruction would AND the accumulator (5) with 1, leaving us with 1.
mov R1, 1 this instruction would fetch the 5 from location 1 and put it in a CPU register called R1
add A, R1 add 1 to 5 so A=6.
shl A shift A to the left. By moving all bits up one, we cause a multiply by 2. A now equals 12.
Anyway, once you get the hang of the CPU and study some existing programs you start to get the concepts you need to build your own program. Game consoles aren't always the best place to start because they're often not meant to be easy to program. Instead, they're made to be programmed by experts and cheap to produce. For example, anyone who tries to learn 6502 on a 2600 is insane, but someone who has written many 6502 programs can concentrate on just learning the peculiar requirements of the system.
At some point, when you're studying programming it will all just click and you'll be on your way.