Assembly "variable" troubles

Programming, for all ages and all languages.
Post Reply
jh302
Posts: 2
Joined: Fri Nov 27, 2009 3:41 pm

Assembly "variable" troubles

Post 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
User avatar
f2
Member
Member
Posts: 311
Joined: Mon Jun 15, 2009 10:01 am
Location: France

Re: Assembly "variable" troubles

Post 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 ...
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Assembly "variable" troubles

Post by qw »

Looks like you haven't initialized your segment registers.
Post Reply