Author Topic: jump short  (Read 99669 times)

kaisermtv

  • Newbie
  • *
  • Posts: 4
    • View Profile
jump short
« on: June 08, 2018, 09:21:23 PM »
Hello sir Bogdan.
I'm having trouble with my bootloader code.
The code size after the build exceeds 512 bytes.
You can optimize jump functions in 16bit mode
Code: [Select]
je label ; 4byte "0F 84 XX XX"
je short label ; 2byte "74 XX"

Code: [Select]
jmp label ; 3byte "E9 XX XX"
jmp short label  ; 2 byte "EB XX"

If you can provide or add the following functions in 16bit mode
Code: [Select]
ljmp segment:offset ; jmp segment:offset

mov {reg},[es:{reg}] ; mov ax,[es:di]
mov {reg},[ss:{reg}] ; mov ax,[ss:di]

cmpsb



bogdanontanu

  • Administrator
  • Newbie
  • *****
  • Posts: 22
    • View Profile
    • oby.ro
Re: jump short
« Reply #1 on: June 18, 2018, 02:08:57 PM »
Hello sir Bogdan.
I'm having trouble with my bootloader code.
The code size after the build exceeds 512 bytes.
You can optimize jump functions in 16bit mode
Code: [Select]
je label ; 4byte "0F 84 XX XX"
je short label ; 2byte "74 XX"

Code: [Select]
jmp label ; 3byte "E9 XX XX"
jmp short label  ; 2 byte "EB XX"

If you can provide or add the following functions in 16bit mode
Code: [Select]
ljmp segment:offset ; jmp segment:offset

mov {reg},[es:{reg}] ; mov ax,[es:di]
mov {reg},[ss:{reg}] ; mov ax,[ss:di]

cmpsb



Hi kaiser,

Thanks for checking this,
I will check it out and see if I can improve the size of the 16 bits encodings.
I will also add the missing long jump and cmpsb instructions.

Meanwhile
I also have bootloader code in Solar_OS (same 512 bytes) and I have managed to fit the code in there.

However I did not try to add all the code in there.

The general advice here is to simply load a 2nd stage boot loader code with a bigger size.

For example in my boot loader I load 24 sectors for 12Kilo bytes right after the boot loader.
And then I jump to that code ;)

This way I avoid trying to stuff all the boot loader code in the first 512 bytes



« Last Edit: June 18, 2018, 02:10:57 PM by bogdanontanu »

kaisermtv

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: jump short
« Reply #2 on: June 20, 2018, 11:36:58 AM »
I want to make a partition for the floppy. This makes it easier for me to manage files and code.
So the task of bootload (512 bytes) is to load a file "BOOT" up to start phase 2

bogdanontanu

  • Administrator
  • Newbie
  • *****
  • Posts: 22
    • View Profile
    • oby.ro
Re: jump short
« Reply #3 on: June 20, 2018, 10:03:49 PM »
I want to make a partition for the floppy. This makes it easier for me to manage files and code.
So the task of bootload (512 bytes) is to load a file "BOOT" up to start phase 2

Hi keiser,

A partition for the floppy is kind of unusual. You can have files on a floppy. But usually there is no partition on a floppy.
A HDD does have a partition table and one or more partitions.

It is OK to arrange your files like that.

However it might be a task that is too complicated for the first 512 bytes.
I guess that it can be done for FAT12, maybe even for FAT32. I doubt it can be done for NTFS.

Anyway it will be complicated and cumbersome to try and fit a real filesystem read in 512 bytes :D

I still think it is better to read some stage 2 code in and then let that stage 2 code implement a filesystem and read files from boot floppy or boot HDD if you want to.

Just my personal opinion of course ;)

You are free to try. I have heard that some people have succeed in doing this.

However I personally would not do it.
It is IMHO too complicated to fit good (bug free) filesystem reading code in just 512 bytes or less ;)