# Copyright 2022 The ChromiumOS Authors1# Use of this source code is governed by a BSD-style license that can be2# found in the LICENSE file.34# Build instructions:5#6# For a 64-bit kernel:7# x86_64-linux-gnu-as test_elf.S -o test_elf64.o8# x86_64-linux-gnu-ld test_elf64.o -o test_elf64.bin -T test_elf.ld9#10# For a 32-bit kernel:11# i686-linux-gnu-as test_elf.S -o test_elf32.o12# i686-linux-gnu-ld test_elf32.o -o test_elf32.bin -T test_elf.ld1314.intel_syntax noprefix1516.section .rodata17hello_world:18.string "Hello world!\n"19.set hello_size, .-hello_world2021.text22.globl _start23_start:24lea esi, [hello_world] # esi -> message string25mov ecx, hello_size # ecx = length of message26mov dx, 0x3F8 # dx = COM1 port2728.print_loop:29# Wait for the transmit buffer to be empty by polling the line status.30add dx, 5 # dx = line status register31.wait_empty:32in al, dx # read line status33test al, 0x20 # check buffer empty flag34jz .wait_empty # keep waiting if flag is not set3536.wait_done:37sub dx, 5 # dx = data register3839# Load a byte of the message and send it to the serial port.40lodsb # load message byte from RSI to AL41out dx, al # send byte to serial port42loop .print_loop # repeat hello_size times4344.done:45int3 # cause vcpu to exit464748