Sonic and Sega Retro Message Board: How does this code assemble - further question on last post - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

How does this code assemble - further question on last post Directives forward referencing

#1 User is offline cokyen 

Posted 20 July 2016 - 06:12 PM

  • Posts: 24
  • Joined: 19-June 16
  • Gender:Male
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
 Include 'header.asm'
 Include 'Init.asm'

__Main:

Code

Reference to stuff in palettes.asm

Main:

Implement labels you DC.l their adresss in header.as

  Include 'data.asm'
 Include 'palettes.asm'
 Include 'character.asm'



Header.asm
Bunch of DC.l 

Jmp to  __init in init.asm




Init.asm

__init
Code

Jmp __main

References to stuff in main.asm


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?
This post has been edited by cokyen: 20 July 2016 - 06:32 PM

#2 User is offline flamewing 

Posted 20 July 2016 - 10:05 PM

  • Emerald Hunter
  • Posts: 1138
  • Joined: 11-October 10
  • Gender:Male
  • Location:🇫🇷 France
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
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 User is offline cokyen 

Posted 21 July 2016 - 08:36 AM

  • Posts: 24
  • Joined: 19-June 16
  • Gender:Male
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?
This post has been edited by cokyen: 21 July 2016 - 08:40 AM

#4 User is offline TheInvisibleSun 

Posted 21 July 2016 - 11:57 AM

  • OVER THE TOP TECHNO-BLAST
  • Posts: 1382
  • Joined: 09-December 09
  • Gender:Male
  • Location:Buffalo, NY, USA
  • Project:Sonic 1 Color Contrast

View Postcokyen, on 21 July 2016 - 08:36 AM, said:

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?


I think he was describing himself as pedantic for pointing out that asm68K was an assembler rather than a compiler.
This post has been edited by TheInvisibleSun: 21 July 2016 - 11:58 AM

#5 User is offline cokyen 

Posted 23 July 2016 - 07:48 PM

  • Posts: 24
  • Joined: 19-June 16
  • Gender:Male
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...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 .
This post has been edited by cokyen: 23 July 2016 - 08:02 PM

#6 User is offline Natsumi 

Posted 24 July 2016 - 05:13 AM

  • Miss Fox
  • Posts: 170
  • Joined: 08-February 12
  • Gender:Female
  • Location:Otter's lap
  • Project:Being with my boyfriend
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.

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users