flat assembler
Message board for the users of flat assembler.

Index > OS Construction > lds les ect...

Author
Thread Post new topic Reply to topic
Hayden



Joined: 06 Oct 2005
Posts: 132
Hayden 05 Dec 2015, 11:41
its been a while since i done any low level programming and i cant seem to remember how to use the lds instructrion.

here is what I have so far :

Code:
IVT     = 00000000h          ; The Interrupt Vector Table
BDA     = 00000400h          ; The BIOS Data Area
BDA_END = 00000500h  - 1     ; End of BIOS Data Area

use16                        ; Make sure compiler uses 16-bit code
org 00000500h                ; Start of OS

MemoryConfig dp ?
virtual at MemoryConfig
    MaxLowMemory   dw ?
    TotalLowMemory dw ?
    ExtendedMemory dw ?
end virtual

MemoryMap dp ?
virtual at MemoryMap
    LengthOfTable       dw ? ; excluding this word
    LocalMem1Mto16M     dd ? ; in 1K blocks
    LocalMem16Mto4G     dd ? ; in 1K blocks
    SystemMem1Mto16M    dd ? ; in 1K blocks
    SystemMem16Mto4G    dd ? ; in 1K blocks
    CacheableMem1Mto16M dd ? ; in 1K blocks
    CacheableMem16Mto4G dd ? ; in 1K blocks
    StartNonSystemMem1Mto16M dd ?
    StartNonSystemMem16Mto4G dd ?
    StartSegLargestBlock     dw ? ; from C0000h-DFFFFh
    SizeLargestBlock         dw ?
                             dd ? ; reserved
end virtual

int 12h                          ; GET MEMORY SIZE
mov word [MaxLowMemory],   ax    ; kilobytes of contiguous memory starting at 00000h
inc ax                           ; + Extended BIOS Data Area (1kB)
mov word [TotalLowMemory], ax    ; Total low memory

START_SCREEN = 000A0000h          ; Sart of VGA memory
; END_SCREEN   = 000E0000h        ; End of VGA memory (Expaned Memory)
START_VRE    = 000C0000h          ; Video ROM Extensions

mov ah, 000000C7h
lds si, [MemoryMap]
int 15h                

    


also shaould I be useing struc or virtual to define data structures

_________________
New User.. Hayden McKay.
Post 05 Dec 2015, 11:41
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 413
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 05 Dec 2015, 12:24
it is looking out this way:
Code:
FarAddress dd ? ; dw Offset dw Segment
...
lds ax,[FarAddress]    

OR
Code:
FarAddress df ? ; dd Offset dw Segment
...
lds ebx,[FarAddress]    

OR
Code:
FarAddress dw Offset,Segment
...
lds bx,dword [cs:FarAddress]    


variants are still possible:
les edx,[...], lfs esi,[...], lgs di,[...], lss esp,[...]

your code should look this way:
Code:
        mov     [MemoryMap+2],cs
        mov     [MemoryMap+0],MemoryMapStart
        ...

        ...
        push    ds
        lds     si,[MemoryMap]
        mov     ah,0xC7
        int     15h
        pop     ds
        ...

        mov     eax,[MemoryMapStart+LocalMem1Mto16M]
        ...
        mov     eax,[MemoryMapStart+SystemMem16Mto4G]


MemoryMap dw ?,?

virtual at 0
    LengthOfTable       dw ? ; excluding this word
    LocalMem1Mto16M     dd ? ; in 1K blocks
    LocalMem16Mto4G     dd ? ; in 1K blocks
    SystemMem1Mto16M    dd ? ; in 1K blocks
    SystemMem16Mto4G    dd ? ; in 1K blocks
    CacheableMem1Mto16M dd ? ; in 1K blocks
    CacheableMem16Mto4G dd ? ; in 1K blocks
    StartNonSystemMem1Mto16M dd ?
    StartNonSystemMem16Mto4G dd ?
    StartSegLargestBlock     dw ? ; from C0000h-DFFFFh
    SizeLargestBlock         dw ?
                             dd ? ; reserved
    MemoryMapSize: ; = $
end virtual


MemoryMapStart: rb MemoryMapSize
    

_________________
smaller is better
Post 05 Dec 2015, 12:24
View user's profile Send private message Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada 10 Dec 2015, 09:51
In code you posted you not need appeal to LDS for help: mov si,MemoryMap is good.

-------------------------------------------------------------------------------------

None saw it;
Neither did Aminadab appear.

Ya Allah Ya Allah Ya Allah
Post 10 Dec 2015, 09:51
View user's profile Send private message 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.