I seem to run into a new problem daily... Anyhow I'm trying to get the amount of RAM available.
...EDIT (see later posts)...
Sorry for asking sooo many questions recently
![Confused :?](./images/smilies/icon_confused.gif)
Lster
Since he states he isn't using GRUB (and he didn't mention any other ready-made bootloader), presumably he's writing his own and can use the BIOS from there, before entering PM (assuming he enters it at all).Brynet-Inc wrote:Are you in protected mode? If you are you can't use BIOS interrupts..
Are you sure about this?Lprogster wrote:I can't seem to use EAX, EDX, EBX and ECX in 16 bit mode.
Code: Select all
org 0x7c00
bits 16
main:
; clear screen
mov ax, 0xb800
mov es, ax
mov fs, ax ; needed later
xor di, di
mov ax, 0x0720
mov cx, 25*80
rep stosw
xor bp, bp ; needed later as well
; set up stack and ds, es
mov ss, bp
mov ds, bp
mov es, bp
mov sp, 0x7c00
; Initial value for interrupt
xor ebx, ebx
.iter:
; Preserved:
; ebx -- continuation
; fs:ebp -- screen position
; ss:esp -- stack
; Clobbered:
; eax
; es
; ds
; edx
; ecx
; esi
; edi
mov di, 0x500
mov eax, 0x0000E820
mov edx, 0x534D4150
mov ecx, 20
int 0x15
jc .halt
mov si, di
lodsd
mov [low], eax
lodsd
mov [high], eax
call printhex
mov eax, [low]
call printhex
mov ax, '-'
call printchar
lodsd
add [low], eax
lodsd
adc [high], eax
mov eax, [high]
call printhex
mov eax, [low]
call printhex
mov ax, ':'
call printchar
lodsd
call printhex
call newline
cmp ebx, 0
je .ebxzero
jmp .iter
.ebxzero:
mov word [fs:24*80*2+1], 'Z'
.halt:
mov word [fs:24*80*2], 'D' | 0x0700
cli
hlt
jmp .halt
; Requires:
; eax -- number to print
; fs:ebp -- preserved
; Clobbers:
; ecx
; edx
; eax
printhex:
mov edx, eax
mov cx, 8
.loop:
push cx
; prepare shift
dec cx
shl cx, 2
; apply shift
mov eax, edx
shr eax, cl
pop cx
; mask one digit
and eax, 0xf
; print digit
mov ax, [hexdigs+eax] ;; reads one byte too much
mov ah, 0 ;; clear extra byte
call printchar
loop .loop
ret
; Requires:
; fs:ebp -- Next character on screen
; al -- character to print
; Clobbers:
; ah
printchar:
mov ah, 0x07
mov word [fs:bp], ax
add bp, 2
ret
newline:
mov bp, [line]
add bp, 80 * 2
mov [line], bp
cmp bp, 24*80*2
jae main.halt
ret
low: dd 0 ; The low 32 bits of a 64-bit address
high: dd 0 ; The high 32 bits of a 64-bit address
hexdigs:db "0123456789abcdef" ; Obvious :)
line: dw 0 ; The location of the next line
times 510-($ - $$) db 0
db 0x55, 0xAA
Code: Select all
nasm -f bin -o bs.bin bs.asm
Code: Select all
qemu -fda bs.bin
Code: Select all
0000000000000000-000000000009fc00:00000001
0000000000100000-0000000008000000:00000001
That's a tough one.. I'm guessing the best way would be to do it before switching into protected mode, storing the value some how?neon wrote:Rather then starting a new thread on the same subject...
How would one find out the amount of RAM available in pmode?
Just curious...