Page 1 of 1

RAM dump

Posted: Sun Feb 22, 2004 5:07 pm
by St8ic
A function in my console is the ability to dump ram to the screen, and it works great if I specify a value for it's "bytes to display" value...

I'm trying to get it so that the user can enter how many bytes to display before the function returns. The following code makes it display all the ram and then return.

Code: Select all

// Kernel.asm
_ramdump: mov bx,0x0000
                mov cx,si
                call dump
      ret

_input:                         ;INPUT FOR ASM FUNCTIONS
   mov di,input
   mov cx,64
   mov dx, di
getkey:
   xor ax, ax
   int 16h
   cmp al, 13
   je AH_3hd
   cmp al, 8
   je backspaceb
   mov bx, di
   sub bx, dx
   cmp bx, cx
   jae getkey
   mov ah, 0Eh
   mov bx, 0001h
   int 10h
   stosb
   jmp getkey   
backspaceb:            
   dec di
   mov al, 8
   mov ah, 0Eh
   mov bx, 0001h
   int 10h
   mov al, 32
   mov ah, 0Eh
   mov bx, 0001h
   int 10h
   mov al, 8
   mov ah, 0Eh
   mov bx, 0001h
   int 10h
   jmp getkey
AH_3hd:
   mov cx, di
   sub cx, dx
   xor al,al
   stosb
   xor ax, ax
   mov si,input
   mov ax,si
   mov dx,si
   ret

dump: push di
      push si
      push dx
      push cx
      push bx
      push ax
dump_1: xor di,di
dump_2: or cx,cx
   je dump_5
   xor dx,dx
   xor ah,ah
   mov al,[bx + di]
   shr al,1
   shr al,1
   shr al,1
   shr al,1
   add al,'0'
   cmp al,'9'
   jbe dump_3
   add al,('A'-('9'+1))
dump_3:
   call putch
   mov al,[bx + di]
   and al,0Fh
   add al,'0'
   cmp al,'9'
   jbe dump_4
   add al,('A'-('9'+1))
dump_4: call putch
   mov al,' '
   call putch
   dec cx
   inc di
   cmp di,16
   jb dump_2
dump_5:   mov al,' '
   call putch
   mov dx,di
   xor di,di
dump_6:   mov al,[bx + di]
   cmp al,' '
   jae dump_7
   mov al,'.'
dump_7: call putch
   inc di
   cmp di,dx
   jb dump_6
   add bx,16
   or cx,cx
   jne dump_1
   pop ax
   pop bx
   pop cx
   pop dx
   pop si
   pop di
   ret

// Kernel.H

void ramdumpb()
{
        static int load;
        printf("Syntax: ");
        load=input();
        ramdump();
}


Re:RAM dump

Posted: Mon Feb 23, 2004 4:58 am
by Pype.Clicker
what about a 'ramdump(load)' in your C code ??

Re:RAM dump

Posted: Mon Feb 23, 2004 8:21 am
by St8ic
I just assumed that you would assume that I called it that way...

sorry.

Re:RAM dump

Posted: Tue Feb 24, 2004 12:11 pm
by Pype.Clicker
did you made sure the amount of bytes to be displayed was properly decoded by 'input' ? (for instance by echoing it on screen with a printf("%d",load) ... )