flat assembler
Message board for the users of flat assembler.

Index > OS Construction > beginner boot program issues

Author
Thread Post new topic Reply to topic
VexisMorlock



Joined: 18 Dec 2020
Posts: 2
VexisMorlock 18 Dec 2020, 11:03
Hey guys,

I am just getting into this and have been experimenting with writing boot programs and ran into an issue. I am just booting up this program into virtualbox and I am getting the wrong output sorry if this is a simple issue I am still new.
Code:

format binary as 'img'
jmp 0x07b5:START

START:
        mov ah, 0eh ;tele prompt
        mov             edx,say
writing:
        mov             al,[edx]
        int     10h ;print
        jmp             done

say:
        db      'B'

done:
        mov             al,'X'
        int             10h
        

        cli ; clear interrupt flag
        hlt ; halt execution

times 510-$ db 0
dw 0xAA55  

    


When I run this I end up with "SX" instead of "BX". When I run a similar program in windows or Linux I get the correct ascii back. Is there something about running programs in real mode that I do not understand? Would love some help thanks in advance.
Post 18 Dec 2020, 11:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 18 Dec 2020, 11:35
Your segment register DS hasn't been initialised.
Code:
mov al,[cs: edx]    
Post 18 Dec 2020, 11:35
View user's profile Send private message Visit poster's website Reply with quote
VexisMorlock



Joined: 18 Dec 2020
Posts: 2
VexisMorlock 18 Dec 2020, 14:21
revolution wrote:
Your segment register DS hasn't been initialised.
Code:
mov al,[cs: edx]    


I am assuming that has to do with segmented registers after spending a bunch of time looking into it, and now hate myself. It may be because I don't really know how to implement this but I just ended up with only 'X' for the output. I did get my code to do what I wanted after spending a bunch of time looking at tuts online here. I changed the 2nd line to
Code:
org 0x7c00    

and the 2nd to last line to:
Code:
times 510-($-$$) db 0     

I'm going back to the books to try and understand this a bit better. Thank you for trying to help me. If you can recommend any resources for learning about segmentation it would be awesome. It's not super easy to find.
Post 18 Dec 2020, 14:21
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 314
Mac2004 17 Jul 2021, 04:38
I took a quick look at your code.

Firstly you are not setting a stack pointer at all.

Secondly you are not setting proper values for int 10h call.
(https://en.wikipedia.org/wiki/INT_10H), which says'
...
Teletype output AH=0Eh AL = Character, BH = Page Number, BL = Color (only in graphic mode)
...'

The character needs to be in AL, which you are doing.
BH register is not set by you and BH register is probably in a state where bios has left.

Regards
M2004
Post 17 Jul 2021, 04:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.