Reputation: 86
I'm wondering how to print a character in assembly without int 0x80
and other system calls. I am doing this for a kernel. I have a working print function, but I want to write one in assembly, so I better understand how it actually works w/o just compiling everything to assembly. I'm using QEMU. I'm new to assembly and have only been able to print strings using syscalls. I am using NASM assembler and I would like the output to be ELF32. This is pseudo-assembly of what I'm trying to accomplish:
section .text
global _start
extern magic_print_function
_start:
mov edx,1;length of buffer
mov ecx,'c';character c to print
;somehow magically print the character without specifying stdout, maybe something like the VGA buffer?
call magic_print_function
Upvotes: 4
Views: 3025
Reputation: 258
Okay, you say You don't want any c. That's a tad difficult, but I'm sure it's possible.
To start out, you want to set ax and dx equal to 0. Then start the stack off at 0. Then, you'll want to load the video memory into ax. The video memory starts at 0xb800. Then make es the same value as ax.
Load your message into a variable and put it into si. At this point, call a function that writes a string to the video memory. This function is made of of smaller functions that individually write characters and move the cursor one spot to the right.
Once you've got the code to write a string, hang it with a loop. that's incredibly simple:
loop:
jmp loop
For more, try this http://wiki.osdev.org/Babystep4
Upvotes: 2