CPU is skipping an instruction
Posted: Sun Jan 25, 2015 3:41 pm
I'm trying to write a basic bootsector which writes some stuff to the serial port. I was having some issues and finally realized that one of the lines in my source code was never being executed. It is the line ' movb %cl, %al # Character to transmit' below. When stepping through the code with bochs, it just skips that instruction. The same happens in qemu. I've checked with objdump that the instruction is in fact making it into the final binary. I presume I'm doing something pretty dumb here, but I'm at a total loss. Anyone here see the issue?
Here is my boot sector boot.s
Here is my bochs config file:
Here is my Makefile:
Here is my boot sector boot.s
Code: Select all
.section .boot
.start:
# Set up the serial port.
movb $0, %ah # Initialize opcode
movb $0b11100011, %al # Parameter data.
movw $0, %dx # COM1: port.
int $0x14
# Test the serial port.
mov $0x100, %cl
.loop:
movw $0, %dx # Select COM1:
# NEXT LINE IS THE PROBLEM!
movb %cl, %al # Character to transmit
movb $1, %ah # Transmit opcode
int $0x14
dec %cl
jnz .loop
# Infinite loop.
.idle:
jmp .idle
.end:
# Fill out rest of the boot sector.
.skip 512 - 2 - (.end - .start)
.word 0xaa55
Code: Select all
floppya: 1_44=boot.img, status=inserted
boot: floppy
display_library: sdl2
com1: enabled=1, mode=file, dev=logfile.log
magic_break: enabled=1
Code: Select all
build:
as boot.s -o boot.o
objcopy -O binary --set-section-flags .boot=alloc --only-section=.boot boot.o boot.img
install:
dd if=boot.img of=/dev/sdb
run: bochs
bochs:
bochs -f bochs.cfg
qemu:
qemu-system-x86_64 -hda boot.img -nographic -serial file:logfile.log
clean:
rm -f *.o boot.img *.log