forked from cirosantilli/x86-bare-metal-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
real_segmentation.S
50 lines (42 loc) · 942 Bytes
/
real_segmentation.S
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
/* https://github.com/cirosantilli/x86-bare-metal-examples#real-mode-segmentation */
#include "common.h"
BEGIN
CLEAR
/* It is not possible to encode moving immediates
* to segment registers: we must either:
*
* * pass through a general register ax
* * pop from the stack
*/
mov $1, %ax
mov %ax, %ds
mov %ds:msg, %al
PUTC <%al>
/* %ds is the default segment for GAS memory operations
* if we don't write it explicitly.
*/
mov msg, %al
PUTC <%al>
mov $1, %ax
mov %ax, %es
mov %es:msg, %al
PUTC <%al>
mov $1, %ax
mov %ax, %fs
mov %fs:msg, %al
PUTC <%al>
mov $1, %ax
mov %ax, %gs
mov %gs:msg, %al
PUTC <%al>
mov $1, %ax
mov %ax, %ss
mov %ss:msg, %al
PUTC <%al>
hlt
msg:
/* Push the correct A forward 16 bytes in memory
* to compensate for the segments.
*/
.fill 0x10
.byte 'A'