;//--------------------------------------------------------------- ;// memsize.s ;// ;// This boot-sector program demonstrates use of the ROM-BIOS ;// 'Get Memory Size' service (int 0x12) in order to find out ;// the upper limit on memory available for use in real-mode. ;// ;// assemble with: $ as86 memsize.s -b memsize.b ;// install using: $ dd if=memsize.b of=/dev/fd0 ;// ;// programmer: ALLAN CRUSE ;// written on: 28 JAN 2004 ;//--------------------------------------------------------------- .SECT .TEXT ;----------------------------------------------------------------- start: jmpf #main, #0x07C0 ; renormalize CS and IP ;----------------------------------------------------------------- msg1: .ASCII "\n\r Real-Mode Memory: " ; message legend info: .ASCII " 0 KB \n\r" ; info to report len1: .WORD * - msg1 ; message length ;----------------------------------------------------------------- main: ; setup segment-registers to address our program data mov ax, cs ; address thus segment mov ds, ax ; with DS register mov es, ax ; also ES register ; obtain memory-size (in KB) and use repeated division by ; ten to convert binary value into a decimal digit-string int 0x12 ; get ram's size in AX lea di, info+5 ; point DS:DI to dest'n mov bx, #10 ; decimal-system radix nxdgt: xor dx, dx ; extend AX for divide div bx ; divide by number-base dec di ; move pointer to left or dl, #0x30 ; convert the remainder mov [di], dl ; to ascii and store it or ax, ax ; did quotient equal 0? jnz nxdgt ; no, get another digit ; use ROM-BIOS video services to display message mov ah, #0x0F ; get video-page into BH int 0x10 ; request VIDEO service mov ah, #0x03 ; cursor (row,col) to DX int 0x10 ; request VIDEO service lea bp, msg1 ; point ES:DP to string mov cx, len1 ; setup CX with length mov bl, #0x0D ; setup BL with colors mov ax, #0x1301 ; specify write_string int 0x10 ; request VIDEO service freeze: jmp freeze ; loop here until reboot ;----------------------------------------------------------------- .ORG 510 ; boot-signature's offset .BYTE 0x55, 0xAA ; value of boot-signature ;----------------------------------------------------------------- END