flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
smiddy 20 Feb 2010, 16:53
Here's a routine I wrote a while back, but as you can see, for the most part E801h is not reliable for checking all your memory:
Code: BIOSE801Message DB 'E801: ',0 BIOSE801ErrorMessage DB 'ERROR: Function unsupported.',13,10,0 BIOSE801ErrorUnreliableMessage db 'ERROR: Function unreliable, gives greater than 15 MB.',13,10,0 E801TotalMemory DD 0 ; Saving the Extended Memory ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; BIOSE801Memory ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BIOSE801Memory: mov si,BIOSE801Message call PrintString xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx mov eax,0E801h ; Load function int 0x15 ; Call BIOS jc .BIOSE801Error ; If function not support, Try 88xx mov [TheEBX],ebx ; Save EBX cmp eax,dword 3c00h ; Check maximum value, greater it is unreliable ja .BIOSE801Error ; Unreliable if greater than the 15 MB je .DoNextRegister ; If equal, then move on to next register mov ebx,400h ; Multiply by 1024 mul ebx add eax,100000h ; Add bottom 1MB of RAM ; mov eax,100000h ; Testing Probing and over all memory mov [E801TotalMemory],eax ; Save bytes installed (intialized) call ToDecimal call AddCommas mov si,CommaBuffer call PrintString mov si,TheBytes call PrintString mov si,TheEndOfLine call PrintString jmp .Done .DoNextRegister: mov eax,[TheEBX] mov ebx,10000h mul ebx ; Multiply by 64 KB add eax,1000000h ; Add 16 MB mov [E801TotalMemory],eax call ToDecimal call AddCommas mov si,CommaBuffer call PrintString mov si,TheBytes call PrintString mov si,TheEndOfLine call PrintString jmp .Done .BIOSE801Error: mov si,BIOSE801ErrorMessage call PrintString jmp .Done .BIOSE801ErrorUnreliable: mov si,BIOSE801ErrorUnreliableMessage call PrintString .Done: ret |
|||
![]() |
|
Fanael 20 Feb 2010, 17:36
Check whether ECX is zero or it's left intact (if ECX is 0 before calling BIOS, then only first check should be performed, as second would do exactly the same thing). If it is, then AX-BX pair contain valid result, otherwise CX-DX does.
Code from my bootloader: Code: xor ebx, ebx xor ecx, ecx xor edx, edx mov eax, 0E801h int 15h ;get it from BIOS jc .memSizeError ;error? cmp ah, 80h je .memSizeError ;invalid command? cmp ah, 86h je .memSizeError ;unsupported function? jcxz .use_ax ;if result is in CX and DX, then... mov ax, cx ; ...move CX to AX... mov bx, dx ;...and DX to BX... ; ... and use AX-BX pair .use_ax: movzx ebx, bx movzx eax, ax shl ebx, 6 ;multiply EBX by 64 lea eax, [eax + ebx + 1024] ;put memory size in KB to EAX Use E820 instead of this! Last edited by Fanael on 20 Feb 2010, 17:44; edited 1 time in total |
|||
![]() |
|
zhak 20 Feb 2010, 17:43
hmm have you ever faced such systems that returned > 3c00 in ax?
|
|||
![]() |
|
smiddy 20 Feb 2010, 20:43
Yes. I don't recall where...however. It has been quite a while since I ran tests on this code.
|
|||
![]() |
|
zhak 20 Feb 2010, 21:39
thanks guys. i implemented it in similar way as Fanael - test cx-dx pair first, and added "> 3c00" check as smiddy advised.
by the way, are that "cmp ah, 80h/cmp ah, 86h" checks necessary? i always thought that CF set should be enough to determine whether a function succeeded or not |
|||
![]() |
|
Fanael 20 Feb 2010, 23:11
zhak wrote: by the way, are that "cmp ah, 80h/cmp ah, 86h" checks necessary? ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.