flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Can anyone find the problem with my code?

Author
Thread Post new topic Reply to topic
Rottbott



Joined: 03 Sep 2003
Posts: 3
Rottbott 03 Sep 2003, 10:44
Hi.. new here. I decided to have a go at writing the OS the other day, but this is my first ever excursion into assembly and I'm not very good at it yet Smile Anyway I found various tutorials and have come up with this very basic code to go in the boot sector of a floppy, load more code stored in sector 2, and jump to it. However, it doesn't work, despite being more or less the same as code I found in 2 of the tutorials (just adapted for FASM). It just sits there with a black screen and blinking cursor where it should be displaying some coloured ASCII characters. So, can anyone here see if I've made some obvious glaring mistake?

The code:

BOOT SECTOR

Code:
format binary
use16

; This boot sector just loads code in sector 2 and jumps to it.
jmp start
start:
      mov ax, 0x1000
      mov es, ax
  mov bx, 0

       mov dl, 0
   mov dh, 0
   mov ch, 0
   mov cl, 2
   mov al, 1

       mov ah, 02h

     int 13h

 jmp 0x1000:0    


SECTOR 2 CODE:

Code:
format binary
use16
org 0x0

; Display some ASCII characters
       jmp start
start:
     mov ax, 0xb800
      mov gs, ax
  mov byte [gs:0], 0x45
   mov byte [gs:2], 0x4C
   mov byte [gs:4], 0x49
   mov byte [gs:6], 0x4C
   mov byte [gs:8], 0x45
   mov cx, 5
   attribloop:
             mov si, cx
          add si, cx
          sub si, 1
           mov byte [gs:si], 0x1f
  loopw attribloop
loop1:
      jmp loop1    


I have one theory about what's wrong - that the "jmp 0x1000:0" in the boot sector code is a relative jump, jumping 1000 ahead of where it is rather than to an absolute memory location. If so, how do I do an absolute jump?
Post 03 Sep 2003, 10:44
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Rottbott



Joined: 03 Sep 2003
Posts: 3
Rottbott 03 Sep 2003, 16:30
Nevermind! Like most bugs, it was just me being incredibly stupid! The code itself is actually fine. Problem is that loads off of the SECOND sector, which is actually sector number 1 since they start at zero. I had been writing my code to sector number 2, i.e. the third sector. What an idiot!
Post 03 Sep 2003, 16:30
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
lagg070988



Joined: 09 Jul 2011
Posts: 5
lagg070988 15 Jul 2011, 22:54
Smile sometimes it happens
Post 15 Jul 2011, 22:54
View user's profile Send private message MSN Messenger Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 16 Jul 2011, 02:35
And sometimes we reply to 8 year old posts...

> 03 Sep 2003, 16:30 Rolling Eyes
Post 16 Jul 2011, 02:35
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 16 Jul 2011, 03:04
And sometimes are just sometimes
Post 16 Jul 2011, 03:04
View user's profile Send private message Reply with quote
xleelz



Joined: 12 Mar 2011
Posts: 86
Location: In Google Code Server... waiting for someone to download me
xleelz 16 Jul 2011, 22:55
I wonder how that dude's doing with OS dev now?
Post 16 Jul 2011, 22:55
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 17 Jul 2011, 07:09
xleelz wrote:
I wonder how that dude's doing with OS dev now?
That was 8 years ago. He could be making the next Windows for all we know LOL
Post 17 Jul 2011, 07:09
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop 17 Jul 2011, 09:55
me239 wrote:
xleelz wrote:
I wonder how that dude's doing with OS dev now?
That was 8 years ago. He could be making the next Windows for all we know LOL
yep i gues your thinking his initial screwup with sector numbers makes him well qualified for that job Wink
Post 17 Jul 2011, 09:55
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 17 Jul 2011, 19:01
nop wrote:
me239 wrote:
xleelz wrote:
I wonder how that dude's doing with OS dev now?
That was 8 years ago. He could be making the next Windows for all we know LOL
yep i gues your thinking his initial screwup with sector numbers makes him well qualified for that job Wink
Hey, he could have learned fast in the EIGHT years that passed.
Post 17 Jul 2011, 19:01
View user's profile Send private message Reply with quote
lagg070988



Joined: 09 Jul 2011
Posts: 5
lagg070988 25 Sep 2011, 15:39
bitshifter wrote:
And sometimes we reply to 8 year old posts...

> 03 Sep 2003, 16:30 Rolling Eyes


jajajja come on, is just for fun...
Post 25 Sep 2011, 15:39
View user's profile Send private message MSN Messenger Reply with quote
p3rlphr33k



Joined: 22 Dec 2009
Posts: 17
Location: Grand Forks ND
p3rlphr33k 08 Apr 2012, 18:48
Can someone make explain or comment the code at the beginning of this post? I am still learning and I am trying to understand what is happening and what went wrong. Thank you to whoever can explain the code.

_________________
-p3rlphr33k-
(Soon to be ASMphr33k)
Post 08 Apr 2012, 18:48
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger ICQ Number Reply with quote
kalambong



Joined: 08 Nov 2008
Posts: 165
kalambong 09 Apr 2012, 09:22
p3rlphr33k wrote:
Can someone make explain or comment the code at the beginning of this post? I am still learning and I am trying to understand what is happening and what went wrong. Thank you to whoever can explain the code.



Everything starts from 0 (zero)
Post 09 Apr 2012, 09:22
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.