Page 1 of 1

Assembly "variable" troubles

Posted: Fri Dec 04, 2009 5:25 pm
by jh302
Hi Everyone.

I'm attempting to write a FAT 12 boot loader. Doing so the "header" of my boot sector contains
the BIOS Parameter block. It looks as follows (AT&T)

Code: Select all

.code16
.text
.global _start
_start:
jmp begin
nop
bpbHeadsPerCylinder: 	.word 2
I'm linking with the following command ld --oformat binary -Ttext 7c00 -Tdata 7c10 -o boot boot.o
The problem is when I try to access the value of the entries in the header, e.g

Code: Select all

mov bpbHeadsPerCylinder,%ax
The value of %ax becomes 7, or 720 (hex).
I wrote the following tiny linux program (that does what is intended,set a "header" variable as the exit status

Code: Select all

code
.section .text
.global _start
var:	.byte 4
_start:
mov var,%bx
mov $1,%ax
int $0x80
I do not grasp the difference, hope that someone, can enlighten me.
Thx

Re: Assembly "variable" troubles

Posted: Fri Dec 04, 2009 6:00 pm
by f2
Hi jh302,

Code: Select all

.code16
.text
.global _start
_start:
jmp begin
nop
bpbHeadsPerCylinder: 	.word 2
If we had the entire code, maybe we could do something ...

Re: Assembly "variable" troubles

Posted: Mon Dec 07, 2009 3:00 am
by qw
Looks like you haven't initialized your segment registers.