I wrote an operating system in 16bit asm (NASM), and thought it was easy. Then I came up with the crazy idea that I could learn 32bit asm.. And quickly became disgusted.
All of the 32bit tutorials out there TELL you to use C or a similar language; I want nothing to do with C at all. AT ALL. I honestly would much rather code all of the functions myself, no interrupts, no C.. just the friendly asm syntax.
So my first idea was to print a string to the screen. Simple, right? Wrong.
In 16bit, you can easily do it by writing directly to 0xB800 or A000..
(Code taken from my OS..)
msg1 db "Hello, world!",0 %macro prints 2 mov ah,%1 mov si,%2 call printstr %endmacro prints 0x0C,msg1 Other stuff here.. etc etc ;---- Not executed except by calls print_textbuffer: mov byte[@display],2 ;Text buffer mode jmp print printstr: mov byte[@display],1 ;String mode print: push es push ax mov ax,0xB800 mov es,ax xor bx,bx call calculate_line pop ax cmp byte[@display],1 je .string cmp byte[@display],2 je .buffer mov word[counter],cx .write: mov word[es:bx],ax dec word[counter] jz .done add bx,2 ;*2 for word value jmp .write .string: ;Displays string in SI terminated by 0 lodsb test al,al jz .done mov word[es:bx],ax add bx,2 jmp .string .buffer: mov byte[counter],0x00 .buffer_loop: lodsb cmp al,'$' je .buffer_nextline test al,al jz .done mov word[es:bx],ax add bx,2 inc word[counter2] inc byte[counter] jmp .buffer_loop .buffer_nextline: xor dx,dx mov dl,[counter] sub bx,dx sub bx,dx add bx,160 ;Add one line mov byte[counter],0x00 ;Reset counter jmp .buffer_loop .done: mov byte[@display],0 pop es ret calculate_line: ;Converts X and Y position counters into a value to be written to memory cmp byte[cursor_y],0x00 ;First line? je .done ;If so, only apply the X position mov dl,[cursor_y] mov byte[counter],dl .loop: cmp byte[counter],0x00 je .done add bx,160 ;*2 for word value dec byte[counter] jmp .loop .done: mov al,[cursor_x] xor ah,ah add bx,ax add bx,ax ;*2 for word value ret
And in 32bit, from what I read, you are supposed to push the string, then call some sickly C function called printf.
msg1 db "Message!%s" lea eax,msg1 push eax call dword ptr printf
Is there REALLY no other way to do it? Do I HAVE to use C?
Sorry for such a long post, just a bit annoyed that there are no 'real' tutorials out there for 32bit. Thanks for reading..