I made driver that should to work with vmem, but it doesn't work. I think mistake is registers that I uses to direct to the memory.
there is code of driver:
;;;;;;; Primary Video Driver
PVideo:
.treadbyte: ; in:eax=ID, [0 - 3440]; out:cl=BYTE [0 - 255]
push eax ebx
mov ebx, 0xb8000
imul eax, 2
inc eax
add ebx, eax
mov cl, byte[ebx]
pop eax ebx di
ret
.treadattr: ; in:eax=ID, [0 - 3440]; out:cl=BYTE [0 - 255]
push eax ebx
mov ebx, 0xb8000
imul eax, 2
add ebx, eax
mov cl, byte[ebx]
pop eax ebx
ret
.twritebyte: ; in:eax=ID, [0 - 3440]/dl=BYTE, [0 - 255]; out:none
push eax ebx
mov ebx, 0xb8000
imul eax, 2
inc ax
add ebx, eax
mov byte[ebx], dl
pop eax ebx
ret
.twriteattr: ; in:eax=ID, [0 - 3440]/dl=BYTE, [0 - 255]; out:none
push eax ebx
mov ebx, 0xb8000
imul eax, 2
add ebx, eax
mov byte[ebx], dl
pop eax ebx
ret
.twritezs: ; in:eax=POS, [0 - 3440-len(ZS)]/si=ZS, offset[0 - 32512]/dl=BYTE; out:none
push eax ebx
mov ebx, 0xb8000
;imul eax, 2
;inc eax
add ebx, eax
.l:
lodsb
cmp al, 0x00
je .ret
mov byte[ebx], dl
inc ebx
mov byte[ebx], al
inc ebx
jmp .l
.ret:
pop eax ebx
ret
I am analyzed code, but can't find no one mistake.
P.S.: I tested only .twritezs function, maybe another doesn't work too.
These are the things that are wrong in the code snippets:
pushon the stack needs to come off in reverse order (if usingpop).You can get your .twritezs code faster if you store the ASCII (at even address) and the Attribute (at next odd address) together in one instruction.
Do notice that
(E)SIis modified. You didn'tpushit.It's not clear why you would want to multiply by 2, the value in
EAXin the other code snippets. Isn'tEAXalready a ready-to-use offset in the video buffer, just like in the .twritezs code?