Made __uitoa comply with our calling convention
Changed __uitoa order of arguments from src,base,target to src,target,base Also returns target in EAX
This commit is contained in:
parent
0d9fcf5ae4
commit
f9e2dc33e9
2 changed files with 35 additions and 31 deletions
23
src/itoa.asm
23
src/itoa.asm
|
@ -1,8 +1,12 @@
|
|||
;; Modified from: https://gist.github.com/SplittyDev/8e728627012e57ac0deac196660014fb
|
||||
|
||||
; __itoa(src int, target addr, base)
|
||||
;target address returned in EAX
|
||||
;EBX, EBP, ESP preserved as our calling convention,
|
||||
;refer to docs or something
|
||||
|
||||
;
|
||||
; Routine to convert a 32-bit integer to a string.
|
||||
; Registers are preserved.
|
||||
;
|
||||
; EAX: Source integer
|
||||
; EBX: Target address
|
||||
|
@ -26,9 +30,13 @@
|
|||
; ECX: Target address (active)
|
||||
; EDX: Target address (temporary)
|
||||
;
|
||||
; return:
|
||||
; put original target at EAX
|
||||
; (we trust this blindly)
|
||||
|
||||
macro kuitoa src*, dest*, base* {
|
||||
push dest
|
||||
push base
|
||||
push dest
|
||||
push src
|
||||
call __uitoa
|
||||
add esp, 3*4
|
||||
|
@ -39,14 +47,11 @@ __uitoa:
|
|||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov eax, [ebp+8]
|
||||
mov ecx, [ebp+12]
|
||||
mov ebx, [ebp+16]
|
||||
mov ebx, [ebp+12]
|
||||
mov ecx, [ebp+16]
|
||||
|
||||
mov edx, ecx
|
||||
mov ecx, ebx
|
||||
|
@ -83,11 +88,9 @@ __uitoa:
|
|||
dec ecx
|
||||
jmp .reverse
|
||||
.end:
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
mov eax, [ebp+12] ; Return target address
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
|
|
@ -52,45 +52,46 @@ start:
|
|||
add esp, 2*4
|
||||
|
||||
sub esp, 36 ;Reserve stack for return
|
||||
kuitoa [mbootinfo.fb_addr], esp, 16
|
||||
serw stuff.fbaddrmsgpfx, esp
|
||||
mov ebx, esp ;Store str buff addr
|
||||
|
||||
kuitoa [mbootinfo.fb_width], esp, 10
|
||||
serw stuff.fbdimensionsmsgpfx, esp, stuff.x
|
||||
kuitoa [mbootinfo.fb_addr], ebx, 16
|
||||
serw stuff.fbaddrmsgpfx, ebx
|
||||
|
||||
kuitoa [mbootinfo.fb_height], esp, 10
|
||||
serw esp, stuff.x
|
||||
kuitoa [mbootinfo.fb_width], ebx, 10
|
||||
serw stuff.fbdimensionsmsgpfx, ebx, stuff.x
|
||||
|
||||
kuitoa [mbootinfo.fb_height], ebx, 10
|
||||
serw ebx, stuff.x
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_bpp]
|
||||
kuitoa eax, esp, 10
|
||||
serw esp
|
||||
kuitoa eax, ebx, 10
|
||||
serw ebx
|
||||
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_rpos]
|
||||
kuitoa eax, esp, 10
|
||||
serw stuff.rpostxt, esp
|
||||
kuitoa eax, ebx, 10
|
||||
serw stuff.rpostxt, ebx
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_gpos]
|
||||
kuitoa eax, esp, 10
|
||||
serw stuff.gpostxt, esp
|
||||
kuitoa eax, ebx, 10
|
||||
serw stuff.gpostxt, ebx
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_bpos]
|
||||
kuitoa eax, esp, 10
|
||||
serw stuff.bpostxt, esp
|
||||
|
||||
kuitoa eax, ebx, 10
|
||||
serw stuff.bpostxt, ebx
|
||||
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_rmasksize]
|
||||
kuitoa eax, esp, 10
|
||||
serw stuff.rmasksizetxt, esp
|
||||
kuitoa eax, ebx, 10
|
||||
serw stuff.rmasksizetxt, ebx
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_gmasksize]
|
||||
kuitoa eax, esp, 10
|
||||
serw stuff.gmasksizetxt, esp
|
||||
kuitoa eax, ebx, 10
|
||||
serw stuff.gmasksizetxt, ebx
|
||||
|
||||
movzx eax, byte [mbootinfo.fb_bmasksize]
|
||||
kuitoa eax, esp, 10
|
||||
serw stuff.bmasksizetxt, esp
|
||||
kuitoa eax, ebx, 10
|
||||
serw stuff.bmasksizetxt, ebx
|
||||
|
||||
add esp, 36 ;Clean reserved uitoa return string from stack
|
||||
|
||||
|
|
Loading…
Reference in a new issue