os-tutorial icon indicating copy to clipboard operation
os-tutorial copied to clipboard

04-bootsector-stack

Open INotWant opened this issue 5 years ago • 5 comments

 mov ah, 0x0e

 mov bp, 0x8000
 mov sp, bp

 push 'A'

 mov al, [0x8000]
 int 0x10            ; can't

 mov al, [0x7ffe]
 int 0x10            ; print A

 push 'B'

 mov al, [0x8000]
 int 0x10            ; can't

 mov al, [0x7ffe]
 int 0x10            ; print A

 mov al, [0x7ffd]
 int 0x10            ; can't

 mov al, [0x7ffc]
 int 0x10            ; print B

 jmp $
 times 510-($-$$) db 0
 dw 0xaa55

I can get A A B,so i think we can access element in stack by using pointer.

INotWant avatar Sep 25 '20 07:09 INotWant

  1. why dont you use pop al?
  2. what is your question?

algorithmx51 avatar Sep 25 '20 08:09 algorithmx51

  1. why dont you use pop al?
  2. what is your question?

in boot_sect_stack.asm file, say

; however, don't try to access [0x8000] now, because it won't work
; you can only access the stack top so, at this point, only 0x7ffe (look above)
mov al, [0x8000]
int 0x10

so i try to use point to access the element of the stack. From my example, it is indeed possible to use pointers to obtain non-top elements.

thanks for the reply!

INotWant avatar Sep 25 '20 08:09 INotWant

I don't understand why mov al, [0x7ffe] wouldn't work in the first place, so it makes sense that you can print A A B

algorithmx51 avatar Sep 25 '20 08:09 algorithmx51

I don't understand why mov al, [0x7ffe] wouldn't work in the first place, so it makes sense that you can print A A B mov al, [0x7ffe] can work sorry, print is A A B

INotWant avatar Sep 25 '20 08:09 INotWant

ok so what is your question again?

algorithmx51 avatar Sep 25 '20 08:09 algorithmx51