Romhacking => Programming => Topic started by: DPMHHacker on December 12, 2019, 04:21:48 pm

Title: 68000 Parenthesis Question Lea (0x7c, PC), A5
Post by: DPMHHacker on December 12, 2019, 04:21:48 pm
For the Sega Genesis's 68000 programming languages:

e.g.    lea   (0x7c, PC), A5

What does it mean when there are parenthesis in the code? Like, what do the Parenthesizes do? Thanks.
Title: Re: 68000 Parenthesis Question Lea (0x7c, PC), A5
Post by: FAST6191 on December 13, 2019, 02:35:40 pm
For the record there is no such thing as "Sega Genesis's 68000 programming languages".

Each assembler can choose to parse opcodes, operators and the like in whatever manner they please.
Some people make different ones because they are used to another syntax from another assembler/system (the classic first thing being whether you do opcode source/immediate destination or opcode destination source/immediate), others to do other things with it that the strict interpretation of assembly won't allow and might include extra syntax to make it work for the programmer. Many will try to settle on whatever the first main manual for the chip uses, or what the actual binary most represents, but that is probably getting off topic.

To that end what assembler are you trying to use for your project?

Still from a random 68K PDF ( , page 27 for the start of the instruction in question) a search spat back at me
"For example, LEA (TABLE,PC),A0
calculates the effective address of "TABLE" with respect to the PC and deposits it in A0."
For others playing along at home PC in most assembly languages means program counter, aka where the CPU is currently located. The output here presumably being of use for things like BRA (more or less a jump/goto command) which use the program counter instead of absolute addresses (which have JMP instead).

At this point I don't know if it has other meanings in other instructions, or possibly for maths purposes in your assembler of choice.