I am relatively new to OSdev, and am building a very simple monotasking OS, but Ive been neglecting this for a while and I need a way to print numbers to the screen.
So I tried writing this code.
Code: Select all
;===============================================================
; PRINT INT TO STRING
; CONVERTS AN INTEGER TO A STRING FOR PRINTING
;
; GIVE INT in EAX
; Prints a number to screen
;
;===============================================================
Print_Int_to_str:
pusha
mov dword [.num], eax
mov dword [.temp], 0
.startloop:
div eax, 10 ;<-- This is what fails :(
cmp eax, 0 ;I am making the assumption that eax holds the result, edx the remainder
je .end
push eax
add edx, 30 ;Makes the number in the numeric range move to num in ascii range
mov dword [.output], edx
mov dword [.output+1], 0
mov ebx, .output
call PutChar32 ;String ptr in ebx, this prints to screen.
pop eax
jmp .startloop
.end:
popa
ret
.num dd 0
.temp dd 0
.output db 0, 0
This is under NASM on win XP btw.Error: Invalid combination of opcode and operands.
Thankyou very very very much in advance.
-Hyperzap