flat assembler
Message board for the users of flat assembler.

Index > OS Construction > FASM syntax question

Author
Thread Post new topic Reply to topic
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 05 Jan 2016, 01:25
When I was doing a test compile to see how FASM liked my syntax, it appeared to choke on one bit of code:
Code:
        
        ; Our Kernel API is now loaded, so we need to set our IVT values.
        xor ax, ax
        xor bx, bx
        xor cx, cx
        xor dx, dx
        mov es, bx
        mov ax, 8000h
        mov bx, 0000h   ; Just to make sure
        mov [0000:21h*4+2], bx
        mov [0000:21h*4], ax
        sti
    

In particular, FASM did not like these lines:
Code:
        mov [0000:21h*4+2], bx
        mov [0000:21h*4], ax
    

These lines are needed to get the IVT address values in the right place, and just short of making the processor calculate these at runtime I have no idea how I would make this work. What I am trying to do is make the the segment address appear at (0x21 * 4d), with the offset at (0x21 * 4d) + 2d.

Help! Confused

_________________
It may look hard, but it won't take long if you take it one byte at a time.

NOS: www.github.com/nkeck720/nos
Post 05 Jan 2016, 01:25
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 05 Jan 2016, 01:40
nkeck72
The only instructions that allow you to use absolute addresses by specifying both segment selector and segment offset are far jumps and calls. Data access instructions such as mov cannot have segment selectors encoded in them and use values from the segment registers instead. Just remove the "0000:" part and either make sure your ds contains zero or use es: (which already contains zero in your code) to override the default ds.
Quote:
mov bx, 0000h ; Just to make sure

I like this part. Reminds me of an old piece of story, which I'm not getting tired to retell:
— Hey, why do you have here two identical successive jumps to the same address?
— Just in case the first one wouldn't work!

_________________
Faith is a superposition of knowledge and fallacy
Post 05 Jan 2016, 01:40
View user's profile Send private message Reply with quote
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 05 Jan 2016, 01:54
Thanks, will try!

That "Just to make sure" line comes from back in my DOS programming days when me and a friend were working on this one program, and my friend wrote a bit of code that had to do two INT 21 calls one after the other, both the AH=09h function. He had written something like this:
Code:
mov ah, 09h
mov dx, string_1
int 21h
mov ah, 09h
mov dx, string_2
int 21h
    

When I asked him why he did this, his immediate response was "I don't trust DOS with my registers." I still laugh at that sometimes, and I guess it rubbed off on me to the point that now I don't even trust the processor with my registers! Very Happy
Post 05 Jan 2016, 01:54
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 05 Jan 2016, 02:07
nkeck72
Right. And the Math with your numbers! ^_^

_________________
Faith is a superposition of knowledge and fallacy
Post 05 Jan 2016, 02:07
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 09 Jan 2016, 09:49
l_inc wrote:
Quote:
mov bx, 0000h ; Just to make sure

I like this part. Reminds me of an old piece of story, which I'm not getting tired to retell:
— Hey, why do you have here two identical successive jumps to the same address?
— Just in case the first one wouldn't work!
This reminds me of another old joke, that JMP is a conditional jump ("Jump if Memory Present").
Post 09 Jan 2016, 09:49
View user's profile Send private message Visit poster's website 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.