flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Strange problems with code and code size

Author
Thread Post new topic Reply to topic
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 08 Jan 2005, 11:39
I´ve ported my loader to fasm (from nasm) and now I have some strange problems with my code. The code works if I write some nops or just some other code to make the code size bigger. If I don´t do this the code won´t work?! I had similar problems some 100 bytes ago Wink What could this be?
Post 08 Jan 2005, 11:39
View user's profile Send private message Reply with quote
listonoš



Joined: 24 Dec 2004
Posts: 6
Location: Czech republic
listonoš 08 Jan 2005, 14:17
Hi FlashBurn, you should post the code in order to solve this problem easier.
Post 08 Jan 2005, 14:17
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 08 Jan 2005, 15:55
OK, now I know that it has something do to with the position of one function.
The behaviour for the several function addresses:

0x104e0 -> doesn´t work
0x104e4 -> function works and code doesn´t
0x104e8 -> doesn´t work
0x104ec -> function and code works
0x104f0 -> function and code works
0x104f4 -> function and code works
0x104f8 -> function works and code doesn´t
0x104fc -> function works and code doesn´t
0x10500 -> doesn´t work
0x10504 -> function works and code doesn´t

These are the first lines of the function and it seems that the problem is here:
Code:
;----------------------------
proc get_memmap
;----------------------------
; <-------------------------- from here
begin
      push es

 mov ax,9f00h
        mov es,ax
   
.e820h:
     mov eax,0e820h
      mov edx,534d4150h
   xor ebx,ebx
 mov ecx,20
  xor di,di
   int 15h

 jc .e801h
   
    add di,cx

.loop:
 mov edx,eax
; <------------------------- till here you have to insert 2 nops and the function and the code works
      mov eax,0e820h
      int 15h

 jc .end

 add di,cx

       test ebx,ebx
        jz .end
     
    jmp .loop
    


These are the needed macros:
Code:
;----------------------------
macro proc name,[arg]
{
common
          prog_args fix arg
   if ..OPEN > 0
            display "ERROR: no endp before proc",13,10
            ..OPEN= 0
   end if
              ..OPEN= ..OPEN+1
    if ~ arg eq
         virtual at bp+4
forward
          local ..arg
         ..arg dw ?
          arg equ ..arg
common
             end virtual
 end if
              ..LOCALS= 0
         align 4
             name:
}
;----------------------------

;----------------------------
macro begin
{
  if ..OPEN = 0
               display "ERROR: begin without proc",13,10
     end if
              push bp
             mov bp,sp
   if ..LOCALS > 0
          sub sp,2*..LOCALS
   end if
}
;----------------------------
    


With function works I mean that he comes through the function. And with code works I mean that the above code did the right thing. When the function doesn´t work, I get a "RIP>CS.limit" in Bochs. When the code doesn´t work he writes nothing into the mem, but he increases the pointer to the right position.
Post 08 Jan 2005, 15:55
View user's profile Send private message Reply with quote
listono&#353;



Joined: 24 Dec 2004
Posts: 6
Location: Czech republic
listono&#353; 09 Jan 2005, 16:05
I think your function shouldn't be on adress 0x10... because this adress is reserved for bios stuff (maybe for video things). Try lower or above 1MB

Also you use ax and eax side by side without use32 or use16 directives. While you are using bios function (so you are in real mode) you should put use16 before your code (work in 16bit mode).
Post 09 Jan 2005, 16:05
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 09 Jan 2005, 16:20
This is only a piece of my function and my code does have the use16 instruction at the beginning! The area from 0x10000 till 0xa0000 is save to use! But I think I will start to use the Bochs debugger to come behind.
Post 09 Jan 2005, 16:20
View user's profile Send private message Reply with quote
listono&#353;



Joined: 24 Dec 2004
Posts: 6
Location: Czech republic
listono&#353; 09 Jan 2005, 16:53
So wether you have use16 at the begining you should use ax instead of eax, but this is not what you are looking for. (sorry for my bad english)
Post 09 Jan 2005, 16:53
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 06 Mar 2005, 08:52
I found the problem, but anyway thanks for your time!
Post 06 Mar 2005, 08:52
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 06 Mar 2005, 10:12
What was the problem?
Post 06 Mar 2005, 10:12
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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.