I originally had some code that would let me create a space for each message in real mode. I am now in protected mode and want to do the same thing.
How would I do this?
Heres the code I used before:
newline:
push ax ; pushes the stack onto the ax register
mov ah,0x0E ; set function to teletype mode
mov al,0x0D ; load a carriage return
int 0x10 ; and print it
mov al,0x0A ; load a line feed
int 0x10 ; and print it
ret ; return
how to print a space in protected mode?
Re:how to print a space in protected mode?
Basically, what you need to to do is reset the cursor horizonal to zero (a carriage return, in other words) and the increment the cursor vertical by one (a line feed). Assuming the print32 function from your earlier post, you could just use the following macro, which behaves more or less as the old version did:beyondsociety wrote: I originally had some code that would let me create a space for each message in real mode. I am now in protected mode and want to do the same thing. How would I do this?
Code: Select all
CR equ 0x0A ; carriage return
LF equ 0x0D ; line feed
%macro newline 0
push ax
mov al, CR ; leave atribute as is, set 'character' to CR
call print32
mov al, LF ; perform a line feed
call print32
pop ax
%endmacro
Code: Select all
newline:
mov [xposition], 0
inc byte [yposition]
call hardware_move_cursor
ret
BTW, I noticed that your own code you consistently use "ADD byte [yposition], 1" rather than "INC byte [yposition]". Was there any particular reason for that? Just curious.
Re:how to print a space in protected mode?
when I use this:
newline:
mov [xposition], 0
inc byte [yposition]
call hardware_move_cursor
ret
Nasm complains about a operation size not specified with this line. Why is this?
mov [xposition],0
newline:
mov [xposition], 0
inc byte [yposition]
call hardware_move_cursor
ret
Nasm complains about a operation size not specified with this line. Why is this?
mov [xposition],0
Re:how to print a space in protected mode?
add byte before the 0
eg
if xposition is defined as a byte in your code
xposition db 0
then it should be
mov [xposition],byte 0
if its a word dw 0
then mov [xposition],word 0
etc ;D
eg
if xposition is defined as a byte in your code
xposition db 0
then it should be
mov [xposition],byte 0
if its a word dw 0
then mov [xposition],word 0
etc ;D
Re:how to print a space in protected mode?
Thanks!, Im going to see if it works, and then I'll get back to you.
Re:how to print a space in protected mode?
It works, thanks codeslasher!
Schol-R-LEA, I dont know why I used [add byte [yposition],1. Whats the difference between the two?
Thanks for your help!
Schol-R-LEA, I dont know why I used [add byte [yposition],1. Whats the difference between the two?
Thanks for your help!
Re:how to print a space in protected mode?
The
add [yposition],1
and
inc byte [yposition]
do the same thing but inc takes less bytes (i think ;D )
add [yposition],1
and
inc byte [yposition]
do the same thing but inc takes less bytes (i think ;D )