简体   繁体   English

Easy68k汇编ORG指令

[英]Easy68k Assembly ORG directive

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. 这个学期我写了很多Easy68k程序,我很好奇为什么org指令总是设置为$ 1000或$ 2000或$ 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? 设置org指令的好处是什么,CPU可以执行从0x0到0xffffffff的任何内容,那么将程序启动一直偏移到0x1000的需求是什么?

For instance: 例如:

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

    end start

works, but is offset by 4096 bytes down 可以,但向下偏移4096字节

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? 我没有为任何特定目的保留[0x0,0x1000),那么保持此偏移量有什么意义呢?

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没有全局变量的默认位置,它们放置在pc上(通常按照惯例放在程序的末尾)。
  • 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. Easy68k的默认堆栈指针为0,向下字增加为0xffffffe,然后向下(字对齐):这意味着与[0,0x1000)区域没有冲突。 In fact, it would corrupt the code before corrupting the [0, 0x1000) region. 实际上,它会在破坏[0,0x1000)区域之前破坏代码。

I'm really curious. 我真的很好奇

Thanks ahead of time! 提前谢谢!

~Dmitry 〜德米特里

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. 地址6到大约地址$ 800为68000中的异常向量保留。$ 1000用作默认的起始地址,以避开保留区域。 The stack defaults to the top of memory and grows toward address 0. 堆栈默认为内存顶部,并向地址0扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM