Where did I get this stack?
Posted: Sun Jun 06, 2004 4:33 am
I wrote this bootsector that draws a small checkerboard pattern on
the screen. It works ok...but why does it not crash when it tries
to use a stack that (AFAIK) does not exist? Does the BIOS set up
a stack, or is this a fluke?
.code16
.globl _start
_start:
mov $0x7c0,%ax
mov %ax,%ds
movw $0x13,%ax
int $0x10
push $0x0A000
pop %es
xor %di,%di
mov $image,%si
movw $63,%cx
write_loop:
lodsb
cmp $0,%cx
jz halt
cmp $9,%al
jz next_line
stosb
loop write_loop
halt:
jmp halt
next_line:
add $320,%di
sub $8,%di
dec %cx
jmp write_loop
image:
.byte 0,15,0,15,0,15,0,15,9
.byte 15,0,15,0,15,0,15,0,9
.byte 0,15,0,15,0,15,0,15,9
.byte 15,0,15,0,15,0,15,0,9
.byte 0,15,0,15,0,15,0,15,9
.byte 15,0,15,0,15,0,15,0,9
.byte 0,15,0,15,0,15,0,15,9
.org 510,0
.byte 0x55,0xAA
the screen. It works ok...but why does it not crash when it tries
to use a stack that (AFAIK) does not exist? Does the BIOS set up
a stack, or is this a fluke?
.code16
.globl _start
_start:
mov $0x7c0,%ax
mov %ax,%ds
movw $0x13,%ax
int $0x10
push $0x0A000
pop %es
xor %di,%di
mov $image,%si
movw $63,%cx
write_loop:
lodsb
cmp $0,%cx
jz halt
cmp $9,%al
jz next_line
stosb
loop write_loop
halt:
jmp halt
next_line:
add $320,%di
sub $8,%di
dec %cx
jmp write_loop
image:
.byte 0,15,0,15,0,15,0,15,9
.byte 15,0,15,0,15,0,15,0,9
.byte 0,15,0,15,0,15,0,15,9
.byte 15,0,15,0,15,0,15,0,9
.byte 0,15,0,15,0,15,0,15,9
.byte 15,0,15,0,15,0,15,0,9
.byte 0,15,0,15,0,15,0,15,9
.org 510,0
.byte 0x55,0xAA