summaryrefslogtreecommitdiff
path: root/stdio.asm
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2017-12-02 16:35:43 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2017-12-02 16:35:43 -0500
commitc9d2819d72bece6470bb3a7cf0edf669699a7ab4 (patch)
tree6382ef3e19f388a7e6d805ce62893c16d37f2acc /stdio.asm
parent11adba68c348ca81961943940e6b64d7e8f3e2ac (diff)
downloadminos-c9d2819d72bece6470bb3a7cf0edf669699a7ab4.tar.gz
Fixup possible register clobbering
Diffstat (limited to 'stdio.asm')
-rw-r--r--stdio.asm9
1 files changed, 7 insertions, 2 deletions
diff --git a/stdio.asm b/stdio.asm
index b4b54a4..35f4cd6 100644
--- a/stdio.asm
+++ b/stdio.asm
@@ -29,9 +29,11 @@ puts:
printi:
push bp
mov bp, sp
+ push ax
mov ax, [bp + 4]
call putint
.return:
+ pop ax
mov sp, bp
pop bp
ret
@@ -55,8 +57,8 @@ printh:
puthex:
push ax
push bx
- push dx
push cx
+ push dx
; ax is integer to print
ror ah, 4 ; reverse hex value
@@ -91,8 +93,8 @@ puthex:
jne .divide
.return:
- pop cx
pop dx
+ pop cx
pop bx
pop ax
ret
@@ -141,6 +143,8 @@ printf:
mov bp, sp
mov di, bp ; save base pointer address
+ push di
+
mov bx, [bp + 4] ; format string address
add bp, 6 ; set base pointer to beginning of '...' args
@@ -234,6 +238,7 @@ printf:
; a procedure modifies DI without restoring
; it, we're doomed; we'll roll right off the
; edge into oblivion.
+ pop di
mov sp, bp
pop bp
ret