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();
}