flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
JohnFound 14 Mar 2004, 16:18
At first, you have to use "use16" for bootloader, because in the time of boot, processor is in real mode.
Regards |
|||
![]() |
|
milind 14 Mar 2004, 16:33
Yes I know that and my bootloader uses 'use16' this is the program that is loaded by the bootloader so its using use32. My main problem is how do I display a character on the screen from this program if I load it from the 1MB mark since from there I don't think the BIOS interrupts (int 10h) will work to display on screen.
|
|||
![]() |
|
asmdemon 14 Mar 2004, 16:59
did you load into protected mode? cuz only protected mode can execute 32bit instructions
_________________ It is better to be on the right side of the devil than in his path. |
|||
![]() |
|
milind 14 Mar 2004, 17:37
I am not in protected mode, but I am not executing any instruction that is exclusive to protected mode yet. Only the addresses are 32 bit, so I think this should not be a problem.
|
|||
![]() |
|
JohnFound 14 Mar 2004, 17:50
milind wrote: I am not in protected mode, but I am not executing any instruction that is exclusive to protected mode yet. Only the addresses are 32 bit, so I think this should not be a problem. If you are not in protected mode, you can't use 32bit addresses. (Even if you want it, the CPU doesn't know what you want). OTOH, if you ARE in protected mode, you can't use "mov ax, $b800 mov es, $b800", there are another segments. I think you should read more about real and protected mode. I can't explain it in one post only. Regards. |
|||
![]() |
|
milind 14 Mar 2004, 19:50
JohnFound wrote:
Ok 1st of all 32 bit offsets and addresses can be used in Protected mode as the Intel manual says: Quote:
The only limitation is that if the 32 bit offset is not in the range 0 to FFFFh then it generates a pseudo-protection faults (interrupt 12 or 13). But as u can see in the code above the offset never goes above FFFF. Also B8000h is an address below 1MB and can be generated in Real mode. So if I replace use32 by use16 will the code work?? |
|||
![]() |
|
JohnFound 14 Mar 2004, 20:01
milind wrote: So if I replace use32 by use16 will the code work?? ![]() ![]() Regards. |
|||
![]() |
|
hawk 17 Mar 2004, 07:35
Well, since I begun the same way (trying to write on the screen w/o help from BIOS) I'll post here the code for both 16bit and 32bit versions of a so called "print" routines.
Please note that the routines can probably be improved, however since they worked I left them in the original state. Hope those would be of some help. 32 bit procedure expects pointer to null terminated string on stack, gets/sets cursor position from video card registers and doesn't take care of the processor registers. Code: proc print_tty,lpsz xor edx,edx xor ebx,ebx ; ---- CURSOR PROBLEMS ---- ; ---- GET VGA (/CGA/EGA) CURSOR POSITION mov dx,3d4h mov al,0eh out dx,al mov dx,3d5h in al,dx mov bl,al mov dx,3d4h mov al,0fh out dx,al mov dx,3d5h in al,dx shl bx,8 mov bl,al shl ebx,1 mov edi,0b8000h add edi,ebx mov esi,[lpsz] @@: lodsb cmp al,0 jz @f cmp al,10 jnz not_lf add edi,160 jmp @b not_lf: cmp al,13 jnz not_cr mov edx,0 mov eax,edi sub eax,0b8000h xor edx,edx mov ebx,160 div ebx sub edi,edx jmp @b not_cr: stosb inc edi jmp @b @@: mov ebx,edi sub ebx,0b8000h shr ebx,1 mov dx,3d4h mov al,0fh out dx,al mov dx,3d5h mov al,bl out dx,al mov dx,3d4h mov al,0eh out dx,al mov dx,3d5h shr bx,8 mov al,bl out dx,al return 16bit version is only for the boot loader, thus more simple, w/o hardware cursor positioning - uses a variable to store cursor position; pointer to null terminated string in si Code: cursor dw 0 print16_msg: mov ax,0b800h mov es,ax mov di,[cursor] shl di,1 @@: mov al,[si] cmp al,0 jz @f cmp al,10 jnz @@not_lf add di,160 inc si jmp @b @@not_lf: cmp al,13 jnz @@not_cr mov dx,0 mov ax,di mov bx,160 div bx mov dx,0 mul bx mov di,ax inc si jmp @b @@not_cr: stosb inc di inc si jmp @b @@: shr di,1 mov [cursor],di ret One more thing: Video memory starts at segment B800h for CGA/EGA/VGA compatible cards. Very OLD video cards (like Hercules Mono and MDA) start at segment B000h. However I don't think that would be your problem. I tested my loader and routines on various configurations and all seem to work. And yet another: I don't handle scrolling, so if you hit the bottom of the screen it is YOUR problem ![]() But I will, and if anyone is interrested I'll post the updated routine here. _________________ Always begining something |
|||
![]() |
|
Cas 05 Apr 2004, 05:41
Look, if you write this:
use16 mov ax,0b800h mov ds,ax it is coded as normal. Now, if you use 32 bit instructions, but then run the code in 16 bit mode (that is, in real mode in this case), these instructions: use32 mov ax,0b800h mov ds,ax will be interpreted as if you had written this: use16 mov eax,08e66b800h That is, a completely different instruction. I would expect the computer to hang almost immediately after that. ![]() _________________ «Earth is my country; science is my religion» - Christian Huygens |
|||
![]() |
|
vid 05 Apr 2004, 18:45
why dont you use 32bit real mode (used by FASM DOS version for example?)
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.