don't click here

How does this code assemble - further question on last post

Discussion in 'Engineering & Reverse Engineering' started by cokyen, Jul 21, 2016.

  1. cokyen

    cokyen

    Member
    24
    0
    0
    I spent hours researching before asking to. This is a continuation of the previous thread I recently posted . I have this m68k code from a tutorial that works. I just want to know how the assembler is running through the code. I will use pseudo code to simplify just providing enough of what is TRUELY INPORTANT .

    Main.asm is the root file we assembly and is like so.

    Main.asm
    Code (Text):
    1.  
    2.  Include 'header.asm'
    3.  Include 'Init.asm'
    4.  
    5. __Main:
    6.  
    7. Code
    8.  
    9. Reference to stuff in palettes.asm
    10.  
    11. Main:
    12.  
    13. Implement labels you DC.l their adresss in header.as
    14.  
    15.   Include 'data.asm'
    16.  Include 'palettes.asm'
    17.  Include 'character.asm'
    18.  
    Header.asm
    Code (Text):
    1.  
    2.  
    3. Bunch of DC.l
    4.  
    5. Jmp to  __init in init.asm
    6.  
    7.  
    Init.asm

    Code (Text):
    1.  
    2.  
    3. __init
    4. Code
    5.  
    6. Jmp __main
    7.  
    8. References to stuff in main.asm
    9.  
    I am using asm68k.exe assembler. So when main.asm is assembled , at the very top , the header.asm code is dumped at top. and at
    the end of this dumping of header.asm in main , it jmps to __init. But, Init.asm's __init label hasn't been defined untill right after this ( after header.asm is dumped in main) so how can it forward reference? Is asm68k a two pass compiler ? Does where you include the .asm file In another asm file , have no affect on anything ? What are the rules with including to make sure the file included is still local to other asm files include? When I ask this, I mean for example , when header.asm is included in main.Asm root , when you include data.asm at the bottom of main.asm , can data.asm mess with stuff included in main.asm like __init?
     
  2. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Just an FYI, there is a Basic Questions & Answers thread. This kind of fits there, as does your other thread.

    Anyway:
    • (pedantic ass) asm68k is not a compiler, it is an assembler; so it cannot be a two pass compiler.
    • asm68k is a single pass assembler: it reads the source once. Every time it finds something it does not know yet, it marks the location where it happened and the symbol it is looking for. Once the source is fully read, it goes back fixing up all these locations, and raises an error if something was used but never defined.
    • Not all assemblers work like this; for example, AS is a multi-pass assembler and will read your source more than once to find stuff it missed on the first go, then more times if it needs to adjust branch sizes.
    • Where you include the code can have an effect, yes: (1) the header MUST be at the start of ROM; (2) code must always be aligned in a 2-byte boundary; (3) there are addressing modes that can more efficiently access code or data at the start of ROM (first 32kB of ROM) or at the end of RAM (last 32kB); (4) there are addressing modes that can more efficiently access code or data up to 32kB before or after the code's location. Other than this, where you include your asm files is largely immaterial.
    • When including, you also can't have duplicate names unless they are local names (in asm68k, local names start with a @).
     
  3. cokyen

    cokyen

    Member
    24
    0
    0
    Thanks for letting me know about the other forum. I misspoke saying compiler. Let me get back after treading your while response again . Also you described asm68k as pedantic ... Is their way better alternatives to asm68k?
     
  4. TheInvisibleSun

    TheInvisibleSun

    OVER THE TOP TECHNO-BLAST Member
    1,626
    193
    43
    Buffalo, NY, USA
    The Water
    I think he was describing himself as pedantic for pointing out that asm68K was an assembler rather than a compiler.
     
  5. cokyen

    cokyen

    Member
    24
    0
    0
    Thanks all . I found The asm68k manual but would like more info than that .Where is their info on asm68k being one pass? I assume since this manual on asm68k http://www.textfiles.com/bitsavers/pdf/corvus/7100-03035_68000asmRef.pdf is by the former company Corvus Concepts in California , they are the developers of asm68k ? Sadly, they are not a company around and I get the feeling their exists much info on the asebler that is either hard to find on the Internet , or Isn't even on the internet .
     
  6. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    216
    24
    18
    Finland
    AMPS
    The version of asm68k most people refer to here is described in this handy document. Given the syntax shown in the other post of yours, it looks like it indeed is different assembler. I would not have high hopes to get much technical information for that assembler, as this is not likely something people have a lot of knowledge in. I do not think there is a direct download for ASM68K described on this document I linked, but some disassemblies include it in their downloads by default.