Author Topic: bootloader  (Read 1504 times)

mabdelouahab

  • Member
  • ***
  • Posts: 449
bootloader
« on: February 21, 2017, 07:47:20 PM »
In the past, I mention that I have made bootloader by Nasm,my Very small os, but it works
Are there samples in HJWasm (32/64)

johnsa

  • Member
  • ****
  • Posts: 805
    • Uasm
Re: bootloader
« Reply #1 on: March 13, 2017, 12:43:25 AM »
Hey,

With the changes I implemented a few versions back yes.. I used it for exactly that purpose. I have a bios and pxe boot loader written in hjwasm which starts something like :

Code: [Select]

option flat:1
.code

use16

include bootconfig.asm

;--------------------------------------------------------------------------------
; Ensure the assembler generates 0 relative offsets for our later CS correction.
; -> Some PXE BIOSes will load the boot sector code to 0000:7c00 while others
; -> will load it to 07c0:0000. We move it to this in either event for
; -> simplicity and to ensure we can re-locate the code to a different segment
; -> without affecting the offsets.
;--------------------------------------------------------------------------------
org 0h

start:

db 0eah
dw offset cs_correction, 07c0h ; Hard-coded long jump to force cs:ofs correction.

;--------------------------------------------------------------------------------
; Configure Stack and Segment Registers.
;--------------------------------------------------------------------------------
cs_correction:
cld ; Ensure the direction flag is clear.
cli ; Switch off interrupts while we setup the stack.
mov ax,CONFIG_SPACE
mov fs,ax


You can make use of
option:flat

and use16, use32, use64 in the file to switch codegen types, things which were lacking in hjwasm imho when compared to something like fasm.