Basics: ECHO | Index | Memory: Allocate

Write Your Own OS from Scratch - Chapter 3. Memory

Memory: Initialize

We will create a new file called mem.asm to put our memory functions in.

First we will add our memory map structure.

struc memarena
    .signature  resb 1
    .owner      resw 1
    .size       resw 1
    .reserved   resb 3
    .name       resb 8
endstruc
		

Next we will add the memmode variable

memmode:        db      0
		

Now we get into the first function memory initalize.

;-------------------------------------------------------
; Memory Initialize
; Input:
;      ds = mcb first block
;      bx = size
; Output:
;      None
;-------------------------------------------------------
meminit:
    push   ax                                           ; Save registers
    push   cx
    mov    al, 'Z'                                      ; Set arena signature to end
    mov    [ds:memarena.signature], al
    mov    [ds:memarena.size], bx                       ; Set arena size
    xor    ax, ax                                       ; Set arena owner
    mov    [ds:memarena.owner], ax
    mov    cx, 8                                        ; Set arena name
meminitnextname:
    mov    si, cx
    mov    al, [cs:si+memnamestr-1]                     ; string for name
    mov    [ds:si+memarena.name-1], al
    loop   meminitnextname                              ; all 8 characters
    mov    [cs:memmode], byte 1                         ; Memory mode allocate first
    pop    cx                                           ; Restore registers
    pop    ax
    ret                                                 ; Return from subroutine
		

Next we will add a couple support functions check signature and next arena.

;-------------------------------------------------------
; Memory Next Arena
; Input:
;      DS = Arena
; Output:
;      DS = Next Arena
;-------------------------------------------------------
memarenanext:
    push   ax                                         ; Save AX
    mov    ax, ds                                     ; Get current arena
    add    ax, [ds:memarena.size]                     ; Add arena size
    inc    ax                                         ; Increment past end of alloc
    mov    ds, ax                                     ; Set new arena
    pop    ax                                         ; Restore AX
                                                      ; Drop into check signature
;-------------------------------------------------------
; Memory Check Signature
; Input:
;      DS = Arena
; Output:
;      Carry Set = Not Valid
;      Carry Clear = Valid
;-------------------------------------------------------
memchecksignature:
    cmp    [ds:memarena.signature], byte 'M'            ; Check if signature M
    jz     memchecksignaturevalid                       ;   if yes then valid
    cmp    [ds:memarena.signature], byte 'Z'            ; Check if signature Z
    jz     memchecksignaturevalid                       ;   if yes then valid
    stc                                                 ; Set carry not valid
    ret                                                 ; Return from subroutine
memchecksignaturevalid:
    clc                                                 ; Clear carry valid
    ret                                                 ; Return from subroutine
		

mem.asm

;=======================================================
; Memory - mem.asm
; -----------------------------------------------------
; Written in NASM
; Written by Marcus Kelly
;=======================================================
struc memarena
    .signature  resb 1
    .owner      resw 1
    .size       resw 1
    .reserved   resb 3
    .name       resb 8
endstruc

memmode:        db      0

;-------------------------------------------------------
; Memory Initialize
; Input:
;      ds = mcb first block
;      bx = size
; Output:
;      None
;-------------------------------------------------------
meminit:
    push   ax                                           ; Save registers
    push   cx
    mov    al, 'Z'                                      ; Set arena signature to end
    mov    [ds:memarena.signature], al
    mov    [ds:memarena.size], bx                       ; Set arena size
    xor    ax, ax                                       ; Set arena owner
    mov    [ds:memarena.owner], ax
    mov    [cs:memmode], byte 1                         ; Memory mode allocate first
    pop    cx                                           ; Restore registers
    pop    ax
    ret                                                 ; Return from subroutine

;-------------------------------------------------------
; Memory Next Arena
; Input:
;      DS = Arena
; Output:
;      DS = Next Arena
;-------------------------------------------------------
memarenanext:
    push   ax                                         ; Save AX
    mov    ax, ds                                     ; Get current arena
    add    ax, [ds:memarena.size]                     ; Add arena size
    inc    ax                                         ; Increment past end of alloc
    mov    ds, ax                                     ; Set new arena
    pop    ax                                         ; Restore AX
                                                      ; Drop into check signature
;-------------------------------------------------------
; Memory Check Signature
; Input:
;      DS = Arena
; Output:
;      Carry Set = Not Valid
;      Carry Clear = Valid
;-------------------------------------------------------
memchecksignature:
    cmp    [ds:memarena.signature], byte 'M'            ; Check if signature M
    jz     memchecksignaturevalid                       ;   if yes then valid
    cmp    [ds:memarena.signature], byte 'Z'            ; Check if signature Z
    jz     memchecksignaturevalid                       ;   if yes then valid
    stc                                                 ; Set carry not valid
    ret                                                 ; Return from subroutine
memchecksignaturevalid:
    clc                                                 ; Clear carry valid
    ret                                                 ; Return from subroutine
		

Adding some functionality to io.asm

This is three seperate routines but each one requires the one below. This is code to print hexidecimal numbers.

;-------------------------------------------------------
; Hex Word Output
; Input:
;       AX = Value
; Output:
;       None
;-------------------------------------------------------
hexwordout:
    push   ax                                           ; Save AX
    xchg   ah, al                                       ; Exchange high and low bytes
    call   hexbyteout                                   ; Call hex byte out
    pop    ax                                           ; Restore AX
                                                        ; Drop into hexbyteout for low byte
;-------------------------------------------------------
; Hex Byte Output
; Input:
;       AL = Value
; Output:
;       None
;-------------------------------------------------------
hexbyteout:
    push   ax                                           ; Save registers
    push   cx
    mov    cl, 4                                        ; Shift in upper nibble
    shr    al, cl
    call   hexnibbleout                                 ; Output upper nibble
    pop    cx                                           ; Restore registers
    pop    ax
                                                        ; Drop into hexnibbleout for low nibble
;-------------------------------------------------------
; Hex Nibble Output
; Input:
;       AL[0:3] = Value
; Output:
;       None
;-------------------------------------------------------
hexnibbleout:
    push   ax                                           ; Save registers
    push   dx
    and    al, 00Fh                                     ; Clear upper bits
    cmp    al, 00Ah                                     ; Check greater than "9"
    jl     hexnibbleout2                                ;  if greater add 7
    add    al, 007h
hexnibbleout2:
    add    al, '0'                                      ; Add '0' for number to print
    mov    dl, al                                       ; Move to dl for stdout
    call   stdout
    pop    dx                                           ; Restore registers
    pop    ax
    ret                                                 ; Return from subroutine
		

io.asm

;=======================================================
; Input / Output - io.asm
; -----------------------------------------------------
; Written in NASM
; Written by Marcus Kelly
;=======================================================

;-------------------------------------------------------
; Standard Output
; Input:
;       DL = Character to print
; Output:
;       AL = Input Character
;-------------------------------------------------------
stdout:
    mov    al, dl                                       ; Place character in al 
    push   ax						; Save ax
    push   bx						; Save bx
    mov    ah, 00Eh                                     ; BIOS Service Print Character
    mov    bx, 00007h
    int    010h
    pop    bx                                           ; Restore bx
    pop    ax                                           ; Restore ax
    ret							; Return from subroutine

;-------------------------------------------------------
; String Output
; Input:
;       DS:DX = String to print
; Output:
;       AL = '$'
;-------------------------------------------------------
strout:
    push   dx                                           ; Save dx
    push   si                                           ; Save si
    mov    si, dx                                       ; Move string pointer to si
stroutnext:
    lodsb                                               ; Get character from string
    cmp    al, '$'                                      ; Check end of string
    jz     stroutdone                                   ;    if yes we are done
    mov    dl, al                                       ; Move char to dl for stdout
    call   stdout                                       ; Call stdout
    jmp    stroutnext                                   ; Next character
stroutdone:
    pop    si                                           ; Restore si
    pop    dx                                           ; Restore di
    mov    ah, 9                                        ; Place 9 back into ah
    ret							; Return from subroutine


;-------------------------------------------------------
; Standard Input
; Input:
;       None
; Output:
;       AL = Character
;-------------------------------------------------------
stdin:
    xor    ax, ax                                       ; Wait for key BIOS Call
    int    016h
    mov    ah, 8                                        ; Restore ah to 8
    ret                                                 ; Return from subroutine

;-------------------------------------------------------
; String Input
; Input:
;       DS:DX = Input Buffer Structure
;       db Buffer Size
;       dw 0  (This has a function we aren't using)
;       db rep[Buffer Size]
; Output:
;       DS:DX+3 = Input String
;-------------------------------------------------------
strin:
    push   ax                                           ; Save registers
    push   bx
    push   cx
    push   dx
    push   di
    push   es
    push   ds                                           ; Move ds to es
    pop    es
    mov    di, dx                                       ; Move dx to di
    xor    ch, ch
    mov    cl, [es:di]                                  ; cl = buffer size remaining
    or     cl, cl                                       ; if cl is zero we are done
    jz     strindone
    add    di, 2                                        ; Skip to start of buffer
    mov    bx, di                                       ; Save start of buffer
strinnext:
    call   stdin                                        ; Wait for key press
    cmp    al, 0x0d                                     ; Check if enter was pressed
    jz     strinenter                                   ;   if yes exit routine
    cmp    al, 0x08                                     ; Check if backspace was pressed
    jz     strinbs                                      ;   if yes goto backspace
    or     cl, cl                                       ; Check if buffer is full
    jz     strinbf                                      ;   if yes goto buffer full
    mov    dl, al                                       ; Otherwise output character
    call   stdout
    stosb                                               ; Store character in the buffer
    dec    cl                                           ; Decriment buffer size remaining
    jmp    strinnext                                    ; Get next character
strinbs:
    cmp    di, bx                                      ; Check if we are at buffer start
    jz     strinnext                                   ;   if yes skip and get next key
    dec    di                                          ; Overwrite previous character 
    mov    al, 0                                       ;    in memory
    stosb
    dec    di                                          ; Backup 1 space in memory
    mov    dl, 8                                       ; Overwrite previous character
    call   stdout                                      ;   on the screen
    mov    dl, 0
    call   stdout
    mov    dl, 8                                       ; Backup 1 space on screen
    call   stdout
    inc    cl                                          ; Add 1 to buffer size remaining
    jmp    strinnext                                   ; Get next character
strinbf:
    jmp    strinnext                                   ; Buffer full get next character
strinenter:
    stosb                                              ; Store 00Dh in the buffer
    dec    cl                                          ; Add it to the count
    mov    ax, [es:bx-2]                               ; get buffer size
    sub    ax, cx                                      ; subtract remaining to get length
    dec    ax                                          ; 0D does not count in lenght
    mov    [es:bx-1], al                               ; Store length in buffer
strindone:
    pop    es                                          ; Restore registers
    pop    di
    pop    dx
    pop    cx
    pop    bx
    pop    ax
    ret                                                ; Return from subroutine

;-------------------------------------------------------
; Carrige Return / Line Feed
; Input:
;       None
; Output:
;       None
;-------------------------------------------------------
crlf:
    push   ax                                           ; Save registers
    push   dx
    mov    dl, 00Dh                                     ; Output carriage return
    call   stdout
    mov    dl, 00Ah                                     ; Output line feed
    call   stdout
    pop    dx                                           ; Restore registers
    pop    ax
    ret                                                 ; Return from subroutine

;-------------------------------------------------------
; To Upper Case
; Input:
;      al = Character
; Output:
;      al = Character
;-------------------------------------------------------
toup:
    cmp    al, 'a'                                      ; Compare to "a"
    jl     toupdone                                     ; If less than a don't change
    cmp    al, 'z'                                      ; Compare to "z"
    jg     toupdone                                     ; If greater than z don't change
    and    al, 0DFh                                     ; Remove uppercase bit
toupdone:
    ret                                                 ; Return from subroutine

;-------------------------------------------------------
; Hex Word Output
; Input:
;       AX = Value
; Output:
;       None
;-------------------------------------------------------
hexwordout:
    push   ax                                           ; Save AX
    xchg   ah, al                                       ; Exchange high and low bytes
    call   hexbyteout                                   ; Call hex byte out
    pop    ax                                           ; Restore AX
                                                        ; Drop into hexbyteout for low byte
;-------------------------------------------------------
; Hex Byte Output
; Input:
;       AL = Value
; Output:
;       None
;-------------------------------------------------------
hexbyteout:
    push   ax                                           ; Save registers
    push   cx
    mov    cl, 4                                        ; Shift in upper nibble
    shr    al, cl
    call   hexnibbleout                                 ; Output upper nibble
    pop    cx                                           ; Restore registers
    pop    ax
                                                        ; Drop into hexnibbleout for low nibble
;-------------------------------------------------------
; Hex Nibble Output
; Input:
;       AL[0:3] = Value
; Output:
;       None
;-------------------------------------------------------
hexnibbleout:
    push   ax                                           ; Save registers
    push   dx
    and    al, 00Fh                                     ; Clear upper bits
    cmp    al, 00Ah                                     ; Check greater than "9"
    jl     hexnibbleout2                                ;  if greater add 7
    add    al, 007h
hexnibbleout2:
    add    al, '0'                                      ; Add '0' for number to print
    mov    dl, al                                       ; Move to dl for stdout
    call   stdout
    pop    dx                                           ; Restore registers
    pop    ax
    ret                                                 ; Return from subroutine
		

Using the new code in demoos.asm

We will start by adding a variable to locate the memory control block start.

mcbfirst:       dw      0
		

We are also creating a new command called mcb so lets add the string for that.

mcbstr:         db      "MCB", 0
		

We need to include our newly created mem.asm file so lets do that.

%include "mem.asm"
		

Now lets add the code for our new command.

;-------------------------------------------------------
; Memory Control Block Command
; Input:
;      None
; Output:
;      AX is Destroyed
;-------------------------------------------------------
mcb:
    push   ax                                           ; Save Registers
    push   dx
    push   ds
    call   crlf                                         ; Print CR / LF
    mov    ax, [mcbfirst]                               ; DS = first mcb
    mov    ds, ax
mcbnext:
    mov    ax, ds                                       ; Print arena segment
    call   hexwordout
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    mov    ah, 002h                                     ; Print signature
    mov    dl, [ds:memarena.signature]
    push   dx                                           ; Save signature
    int    021h
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    mov    ax, [ds:memarena.owner]                      ; Print owner
    call   hexwordout
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    mov    ax, [ds:memarena.size]                       ; Print size
    call   hexwordout
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    xor    si, si                                       ; Print name
    mov    cx, 8
mcbnextname:
    mov    dl, [ds:si+memarena.name]                    ; Read name byte
    mov    ah, 002h                                     ; Print name byte
    int    021h
    inc    si                                           ; Increment name byte
    loop   mcbnextname                                  ; Get next name byte
    pop    dx                                           ; Restore signature
    cmp    dl, 'Z'                                      ; Compare to end arena
    jz     mcbdone                                      ;   if yes were done
    call   memarenanext                                 ; Get next arena
    jc     mcbdone                                      ;   failed were done
    call   crlf                                         ; Print CR / LF for next arena
    jmp    mcbnext                                      ; Next arena
mcbdone:
    call   crlf                                         ; Print CR / LF
    pop    ds                                           ; Restore registers
    pop    dx
    pop    ax
    ret                                                 ; Return from subroutine
		

Make sure we are checking for the mcb command so in main loop add:

    mov    si, mcbstr                                   ; Point to command text
    call   cmpcmd                                       ; Compare
    jc     cmdnmcb                                      ; Carry set if not equal
    call   mcb                                          ; Call function
    jmp    main                                         ; We're done checking
cmdnmcb:
		

Then we initialize the memory.

    push   ds                                           ; Save DS
    mov    ax, 00FFFh                                   ; Set first MCB
    mov    [mcbfirst], ax                               ; Save first MCB
    mov    ds, ax
    mov    bx, 07000h                                   ; Size to initialize
    call   meminit                                      ; Initialize memory
    pop    ds  
		

Finally change:

version:        db      00Dh, 00Ah, "DEMO OS V0.07"     ; Message to be printed
                db      00Dh, 00Ah, '$'
		

to

version:        db      00Dh, 00Ah, "DEMO OS V0.08"     ; Message to be printed
                db      00Dh, 00Ah, '$'
		

demoos.asm

;=======================================================
; Demo OS - demoos.asm
; -----------------------------------------------------
; Written in NASM
; Written by Marcus Kelly
;=======================================================

    org     00000h                                      ; Assemble code for this offset

start:
    cli                                                 ; Turn off interrupts
    cld							; Make sure we are going forward
    mov     ax, cs                                      ; Set all segments to code segment
    mov     ds, ax                                      ; Make sure data segment is zero
    mov     es, ax                                      ; Make sure extra segment is zero
    mov     ss, ax                                      ; Make sure stack segment is zero
    mov     sp, 07C00h                                  ; Place stack ptr before boot sector
    sti                                                 ; Turn on interrupts

    call   intinit                                      ; Initialize interrupts
    push   ds                                           ; Save DS
    mov    ax, 00FFFh                                   ; Set first MCB
    mov    [mcbfirst], ax                               ; Save first MCB
    mov    ds, ax
    mov    bx, 07000h                                   ; Size to initialize
    call   meminit                                      ; Initialize memory
    pop    ds                                           ; Restore DS
    call   ver

main:
    call   crlf                                         ; Print carriage return / line feed
    mov    ah, 002h                                     ; Service standard output
    mov    dl, '>'                                      ; Print '>'
    int    021h
    mov    dl, ' '                                      ; Print Space
    int    021h
    mov    ah, 00Ah                                     ; Service string input
    mov    dx, buffer                                   ; Set dx to our buffer
    int    021h
    call   crlf                                         ; Print carriage return / line feed

    mov    di, buffer+2                                 ; Point to the string we typed

    mov    si, verstr                                   ; Point to command text
    call   cmpcmd                                       ; Compare
    jc     cmdnver                                      ; Carry set if not equal
    call   ver                                          ; Call function
    jmp    main                                         ; We're done checking
cmdnver:

    mov    si, clsstr                                   ; Point to command text
    call   cmpcmd                                       ; Compare
    jc     cmdncls                                      ; Carry set if not equal
    call   cls                                          ; Call function
    jmp    main                                         ; We're done checking
cmdncls:

    mov    si, echostr                                  ; Point to command text
    call   cmpcmd                                       ; Compare
    jc     cmdnecho                                     ; Carry set if not equal
    call   echo                                         ; Call function
    jmp    main                                         ; We're done checking
cmdnecho:

    mov    si, mcbstr                                   ; Point to command text
    call   cmpcmd                                       ; Compare
    jc     cmdnmcb                                      ; Carry set if not equal
    call   mcb                                          ; Call function
    jmp    main                                         ; We're done checking
cmdnmcb:

    mov    ah, 009h                                     ; Service Print String
    mov    dx, invalid                                  ; Invalid command
    int    021h                                         ; Our Service
    call   crlf                                         ; New line
    jmp    main                                         ; Repeat forever

;-------------------------------------------------------
; Compare Command
; Input:
;      DS:SI = Command String
;      ES:DI = Buffer String
; Output:
;      Carry set if not equal
;      Carry clear if equal
;-------------------------------------------------------
cmpcmd:
    push   ax                                           ; Save registers
    push   si
    push   di
cmpcmdnext:
    mov    al, [es:di]                                  ; Load char from command line 
    inc    di                                           ; Point to next character
    call   toup                                         ; Convert to uppercase
    mov    ah, [ds:si]                                  ; Load char to test against
    inc    si                                           ; Point to next character
    cmp    ah, al                                       ; Compare both characters
    jz     cmpcmdnext                                   ; If they are the same check next
    dec    si                                           ; Adjust to point to last char
    dec    di
    cmp    [ds:si], byte 0                              ; Our test command end should be 0
    jnz    cmpcmdne                                     ; If it isn't not our command
    cmp    [es:di], byte ' '                            ; Our input cmd might be space
    jz     cmpcmde                                      ; If it is this is our command
    cmp    [es:di], byte 00Dh                           ; Our input cmd might be CR
    jz     cmpcmde                                      ; If it is this is our command
    jmp    cmpcmdne                                     ; Otherwise not our command
cmpcmde:
    pop    di                                           ; Restore registers
    pop    si
    pop    ax
    clc                                                 ; Clear carry for match
    ret                                                 ; Return from subroutine
cmpcmdne:
    pop    di                                           ; Restore registers
    pop    si
    pop    ax
    stc                                                 ; Set carry if not a match
    ret                                                 ; Return from subroutine

;-------------------------------------------------------
; Version Command
; Input:
;      None
; Output:
;      AX, DX are Destroyed
;-------------------------------------------------------
ver:
    mov    ah, 009h                                     ; Service string output
    mov    dx, version                                  ; dx is set to offset version
    int    021h                                         ; Call the service
    ret

;-------------------------------------------------------
; Clear Screen Command
; Input:
;      None
; Output:
;      AX is Destroyed
;-------------------------------------------------------
cls:
    mov    ah, 00Fh                                     ; Get video mode
    int    010h
    mov    ah, 000h                                     ; Set video mode
    int    010h                                         ;  this automatically clears the screen
    ret

;-------------------------------------------------------
; Echo Command
; Input:
;      None
; Output:
;      None
;-------------------------------------------------------
echo:
    push   ax                                           ; Save registers
    push   dx
    push   di
    xor    ah, ah                                       ; Clear upper part of ax
    mov    al, [buffer+1]                               ; Get count from buffer
    mov    di, buffer+2                                 ; Get start of buffer
    add    di, ax                                       ; Add for end of buffer
    mov    al, '$'                                      ; Place '$' at end for printing
    mov    [di], al
    mov    ah, 009h                                     ; Service print string
    mov    dx, buffer+7                                 ; Get start of string to print
    int    021h                                         ;    7 to exclude echo
    call   crlf
    pop    di                                           ; Restore regsiters
    pop    dx
    pop    ax
    ret                                                 ; Return from subroutine

;-------------------------------------------------------
; Memory Control Block Command
; Input:
;      None
; Output:
;      AX is Destroyed
;-------------------------------------------------------
mcb:
    push   ax                                           ; Save Registers
    push   dx
    push   ds
    call   crlf                                         ; Print CR / LF
    mov    ax, [mcbfirst]                               ; DS = first mcb
    mov    ds, ax
mcbnext:
    mov    ax, ds                                       ; Print arena segment
    call   hexwordout
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    mov    ah, 002h                                     ; Print signature
    mov    dl, [ds:memarena.signature]
    push   dx                                           ; Save signature
    int    021h
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    mov    ax, [ds:memarena.owner]                      ; Print owner
    call   hexwordout
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    mov    ax, [ds:memarena.size]                       ; Print size
    call   hexwordout
    mov    ah, 002h
    mov    dl, ' '                                      ; Print space
    int    021h
    xor    si, si                                       ; Print name
    mov    cx, 8
mcbnextname:
    mov    dl, [ds:si+memarena.name]                    ; Read name byte
    mov    ah, 002h                                     ; Print name byte
    int    021h
    inc    si                                           ; Increment name byte
    loop   mcbnextname                                  ; Get next name byte
    pop    dx                                           ; Restore signature
    cmp    dl, 'Z'                                      ; Compare to end arena
    jz     mcbdone                                      ;   if yes were done
    call   memarenanext                                 ; Get next arena
    jc     mcbdone                                      ;   failed were done
    call   crlf                                         ; Print CR / LF for next arena
    jmp    mcbnext                                      ; Next arena
mcbdone:
    call   crlf                                         ; Print CR / LF
    pop    ds                                           ; Restore registers
    pop    dx
    pop    ax
    ret                                                 ; Return from subroutine

%include "io.asm"
%include "int.asm"
%include "mem.asm"

;-------------------------------------------------------
; Data Area
;-------------------------------------------------------

verstr:         db      "VER", 0
clsstr:         db      "CLS", 0
echostr:        db      "ECHO", 0
mcbstr:         db      "MCB", 0

version:        db      00Dh, 00Ah, "DEMO OS V0.08"     ; Message to be printed
                db      00Dh, 00Ah, '$'

invalid:        db      00Dh, 00Ah, "Invalid Command"   ; Message to be printed
                db      00Dh, 00Ah, '$'

buffer:         db      64                              ; Buffer for string input
                db      0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0
                db      0, 0, 0, 0, 0, 0, 0, 0

mcbfirst:       dw      0
		

Modify the disk image

Now lets build our disk. If you are running the previous tutorial in VirtualBox Remember to remove the disk or close virtual box before assembling the disk image.

> nasm demoos.asm -o demoos.bin
> nasm osdisk.asm -o osdisk.img
		

Your osdisk.img can now be loaded with VirtualBox. The result should be as follows:

DEMO OS V0.08

> mcb

Z 0000 7000 INITIAL

>
		
Basics: ECHO | Index | Memory: Allocate

Support This Project On Patreon

Copyright © 2021 Marcus Kelly