diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2017-11-29 11:34:58 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2017-11-29 11:34:58 -0500 |
commit | 523322dc13a2599014e26780518bf06277a57e30 (patch) | |
tree | be76bcaee0b550f01cf6c89c8fbf3de42cd742d2 /stdio.asm | |
parent | 1dd05ebe61c95985b16d170bf2d3f081a02dfd7d (diff) | |
download | minos-523322dc13a2599014e26780518bf06277a57e30.tar.gz |
add print[i,h] and normalize load addresses
Diffstat (limited to 'stdio.asm')
-rw-r--r-- | stdio.asm | 89 |
1 files changed, 88 insertions, 1 deletions
@@ -17,7 +17,7 @@ puts: lodsb ; load byte at [si] into al or al, 0 ; 0 | 0 = 0 (detect null terminator) je .end - int 10h ; BIOS video service + call putc jmp .loop .end: popa @@ -25,4 +25,91 @@ puts: pop bp ret + +printi: + push bp + mov bp, sp + + mov ax, [bp + 4] ; integer WORD + mov cx, 0 ; counter + cmp ax, 0 + je .write_no_pop + +.divide: + xor dx, dx + mov di, 10 ; divisor + div di + + push dx + inc cx + cmp ax, 0 + jne .divide + + jmp .write + +.write_no_pop: + or al, 30h + call putc + jmp .return + +.write: + pop ax + + or al, 30h + call putc + dec cx + jne .write + +.return: + mov sp, bp + pop bp + ret + +printh: + push bp + mov bp, sp + + mov ax, [bp + 4] ; integer WORD + mov cx, 0 ; counter + cmp ax, 0 + je .write_no_pop + +.divide: + xor dx, dx + mov di, 16 ; divisor + div di + + push dx + inc cx + cmp ax, 0 + jne .divide + + jmp .write + +.write_no_pop: + or al, 30h + call putc + jmp .return + +.write: + pop ax + cmp al, 10 + jge .alpha + + or al, 30h + jmp .decimal + +.alpha: + sub al, 10 + add al, 'A' + +.decimal: + call putc + dec cx + jne .write + +.return: + mov sp, bp + pop bp + ret %endif |