I’m puzzled by the code from the Pintos OS, named loader.S. I don’t get how the string .string “PiLo” is used by puts when there’s no label involved.
sub %dx, %dx # Serial port 0.
mov $0xe3, %al # 9600 bps, N-8-1.
# AH is already 0 (Initialize Port).
int $0x14 # Destroys AX.
call puts
.string "PiLo"
puts:
xchg %si, %ss:(%esp)
push %ax
next_char:
mov %cs:(%si), %al
inc %si
test %al, %al
jz 1f
call putc
jmp next_char
1: pop %ax
xchg %si, %ss:(%esp)
ret
putc:
pusha
1: sub %bh, %bh # Page 0.
mov $0x0e, %ah # Teletype output service.
int $0x10
mov $0x01, %ah # Serial port output service.
sub %dx, %dx # Serial port 0.
2: int $0x14 # Destroys AH.
test $0x80, %ah # Output timed out?
jz 3f
movw $0x9090, 2b # Turn "int $0x14" above into NOPs.
3:
cmp $'r', %al
jne popa_ret
mov $'n', %al
jmp 1b
if someone can help to understand the code.
New contributor
hamid sverige is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.