Talk About Network

Google





Programming > Assembly Language > Re: Variable va...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 6 Topic 5080 of 5194
Post > Topic >>

Re: Variable values are lost

by Frank Kotler <fbkotler@[EMAIL PROTECTED] > Jul 24, 2008 at 08:19 AM

NiTiN wrote:
> Hi!
> 
> I've got some really simple code that boots the system and displays a
> string. I've looked at a couple of examples and I'm aware of the load
> to 0x7c00. My jump references are fine but when I try to access
> variables, I get nulls instead of the actual data.
> 
> Here's the source code:
> bits 16
> org 0x7c00
> 
> jmp start
> 
> helloMsg db 'A'
> 
> start:

xor ax, ax
mov ds, ax

> mov al, [helloMsg] ;copy the A
> cmp al, 65
> jne wrongChar
> 
> call printChar ;print the A
> jmp end
> 
> wrongChar:
> mov al, 66 ;print B if wrong character
> call printChar
> 
> end:
> jmp $
> 
> printChar:
> mov ah, 0eh
> ;mov al, 65
> mov bh, 0h
> mov bl, 7h
> int 10h
> ret
> 
> ;510 bytes plus the 2 byte signature
> zero_padding: times 510 - ($ - $$) db 0
> 
> ;boot signature
> boot_sig: dw 0xaa55
> 
> 
> The output I get on running this code is 'B' when it should be 'A'. I
> must be missing something.

ASSume nothing, except that your code is loaded at 7C00h, and the boot 
drive is in dl. Might want to think about where your stack is, too...

Best,
Frank
 




 6 Posts in Topic:
Variable values are lost
NiTiN <k.nitin.r@[EMAI  2008-07-24 03:06:57 
Re: Variable values are lost
Frank Kotler <fbkotler  2008-07-24 08:19:45 
Re: Variable values are lost
"Wolfgang Kern"  2008-07-24 15:22:02 
Re: Variable values are lost
NiTiN <k.nitin.r@[EMAI  2008-07-24 07:48:11 
Re: Variable values are lost
Frank Kotler <fbkotler  2008-07-24 21:07:32 
Re: Variable values are lost
NiTiN <k.nitin.r@[EMAI  2008-07-24 07:55:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 17:47:36 PST 2009.