1

I know similar questions have been asked, but listen anyway.

I've written quite a few Easy68k programs this semester, and I am curious why org directive is always set to $1000, or $2000, or $2500.

While the answer is "by personal convention", I am more interested in understanding the following:

  • What are the benefits of setting org directive, CPU can execute anything from 0x0 to 0xffffffff, so what is the need to offset the program start all the way to 0x1000?

For instance:

    org $1000
start:
    moveq #9, d0
    trap  #15

    end start

works, but is offset by 4096 bytes down

start:
    moveq #9, d0
    trap  #15

    end start

works also, but is not offset at all

So why is this directive needed? I am not reserving [0x0, 0x1000) for any particular purpose, so what is the point of keeping this offset?

Conclusions so far

  • Easy68k does not have a default place for global variables, they are placed at pc (usually at the end of program by convention).
  • Easy68k's default stack pointer is at 0, growing downwords to 0xffffffe, and downwards (it is word aligned): this means that there is no conflict with [0, 0x1000) region. In fact, it would corrupt the code before corrupting the [0, 0x1000) region.

I'm really curious.

Thanks ahead of time!

~Dmitry

Dmytro
  • 5,068
  • 4
  • 39
  • 50
  • It really sounds like a convention, that allows reserving stack, command-line parameters, some global memory etc. at fixed positions. I've only ever written a few lines of 68000 assembler, so I can't remember if some placing commonly used variables etc. would make most opcodes shorter. But it's a possibility (like zero-page in 6502). – Aki Suihkonen Mar 17 '13 at 08:49
  • I don't believe Easy68k has any command line arguments, it's a GUI simulator. I addressed the global memory and stack in my post. Also, length of opcodes is not really relevant, but moving immediate 0x12345678 is only 12 clocks, whereas moving it from memory is 20 clocks, and the opcodes are both 6 bytes, respectively for immediate and from memory: 203c 12345678, 2039 0000001a, which also shows that global data is stored at end of code, as 1a 0000001a memory exactly following my "move #9, d0; trap #15" code indicating "simhalt" – Dmytro Mar 17 '13 at 09:03

1 Answers1

0

Address 0 through approximately address $800 are reserved for exception vectors in the 68000. $1000 is used as the default starting address to stay clear of the reserved area. The stack defaults to the top of memory and grows toward address 0.

  • Wasn't there a formula for where the vectors are. If I recall correctly they weren't 0 through $800. Let me check. Wait... are you really "Professor Kelly"? Sorry i've been really confused about interrupt vectors so I apologize for arguing with the creator of the program, I love your program and even tried looking at its' code, although it was kinda hard to since it was made for borland C last time I checked. Understanding exceptions is one of the most confusing part of Easy68k, It's the part I just couldn't find any sources that could explain it in a way I could understand. – Dmytro Jul 07 '16 at 20:49