-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot_sect_stack.asm
63 lines (48 loc) · 1.03 KB
/
boot_sect_stack.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
mov ah, 0x0e ; tty mode
mov bp, 0x8000 ; this is an address far away from 0x7c00 so that we don't get overwritten
mov sp, bp ; if the stack is empty then sp points to bp
; LUIGINA
push 'A'
push 'N'
push 'I'
push 'G'
push 'I'
push 'U'
push 'L'
; to show how the stack grows downwards
mov al, [0x7ffe] ; 0x8000 - 2
int 0x10
; 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
; recover our characters using the standard procedure: 'pop'
; We can only pop full words so we need an auxiliary register to manipulate
; the lower byte
pop bx
mov al, bl
int 0x10 ; prints L
pop bx
mov al, bl
int 0x10 ; prints U
pop bx
mov al, bl
int 0x10 ; prints I
pop bx
mov al, bl
int 0x10 ; prints G
pop bx
mov al, bl
int 0x10 ; prints I
pop bx
mov al, bl
int 0x10 ; prints U
pop bx
mov al, bl
int 0x10 ; prints L
; data that has been pop'd from the stack is garbage now
mov al, [0x8000]
int 0x10
jmp $
times 510-($-$$) db 0
dw 0xaa55