📄 comprefix.s
字号:
/* We need a real mode stack that won't be stomped on by Etherboot which starts at 0x20000. Choose something that's sufficiently high, but not in DOC territory. Note that we couldn't do this in a real .com program since stack variables are in the same segment as the code and data, but this isn't really a .com program, it just looks like one to make DOS load it into memory. It still has the 64kB limitation of .com files though. */#define STACK_SEG 0x7000 .text .code16 .globl _start/* Cheat a little with the relocations: .COM files are loaded at 0x100 */_start: movw $STACK_SEG,%ax movw %ax,%ss push %cs # generate return address movw $retaddr-_start +0x100,%ax pushw %ax/* Intel didn't specify an indirect far call that loads the address from * a near operand - it seems like nobody does computed far calls. So do it * the ugly way - dump it on the stack and "return" to the destination. */ movw %cs,%ax /* calculate start address of loader */ movw $_body - _start +0x100,%bx movb $4,%cl shrw %cl,%bx addw %bx,%ax pushw %ax /* new code segment */ xorw %ax,%ax pushw %ax /* new offset */ lretretaddr: movw $0x4c00,%ax /* return to DOS */ int $0x21 /* reach this on Quit *//* The body of etherboot is attached here at build time. * Force 16 byte alignment (so that the code segment starts at 0) */ .align 16,0_body:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -