dce .DOSSEG .MODEL SMALL .386 .DATA strbuf db 128 actual db ? db 128 dup(?) .DATA? buf db 10 dup(?) col db ? row db ? .CODE PUBLIC getdec PUBLIC writedec PUBLIC dirwr PUBLIC crlf PUBLIC clrscr PUBLIC setcur PUBLIC hidecur PUBLIC showcur getdec PROC push bx push cx push si push di mov ah,0ah ;Buffered keyboard input mov dx,offset strbuf int 21h mov di,offset strbuf+2 xor ax,ax xor bx,bx xor cx,cx mov cl,actual mov si,10 convert: mov bl,[di] inc di sub bl,030h mul si add ax,bx loop convert getdec_rdy: mov dx,ax ;;Place result in DX pop di pop si pop cx pop bx ret getdec ENDP writedec PROC push bx push cx push dx push es push di mov ax,@data ;Fyll buffern med 0 mov es,ax mov di,OFFSET buf mov ax,0 mov cx,7 cld rep stosb mov di,OFFSET buf+1 cmp dx,0000h jnz not_zero mov byte ptr[di],'0' ;;¸tminstone ETT v„rde jmp conv_rdy not_zero: mov cx,10 ;;10 -> CX ('N„mnare') cld Kvot_0: mov ax,dx ;;Hex-talet -> AX mov dx,0000h ;;Nollst DX ('Rest') div cx ;;Operation AX/CX ;;Kvot -> AX och Rest -> DX xchg ax,dx ;;Kvot -> DX, Rest -> AX add al,30h ;;HEX -> ASCII stosb ;;ASCII-v„rdet sparas i buffert cmp dx,0000h ;;Kvoten i div = 0 ? jnz Kvot_0 ;;Forts„tt tills kvot = 0 dec di conv_rdy: mov ah,03h ;;Fetch old cursor position mov bh,0 int 10h mov col,dl mov row,dh next_char: mov bl,[di] ;;Tecken -> DL i ordn MSB -> LSB cmp bl,00h ;;Testa om tecken = 00 jz from_buf_rdy mov dh,row mov dl,col mov bh,07h call dirwr inc col dec di ;;Peka p† n„sta tecken jmp next_char from_buf_rdy: mov dl,col ;;Put cursor at new position mov dh,row call setcur pop di pop es pop dx pop cx pop bx ret writedec ENDP ; dh = row dl = col bl = character bh = attrib dirwr PROC push es push di mov ax,0b800h mov es,ax xor ax,ax mov al,dh mov dh,160 ;Each row has 160 bytes... mul dh xor dh,dh shl dl,1 add ax,dx ;Take attribute bytes in account mov di,ax mov byte ptr es:[di],bl ;First the character... inc di mov byte ptr es:[di],bh ;then the attribute byte pop di pop es ret dirwr ENDP crlf PROC push dx mov ah,2 mov dl,13 int 21h mov ah,2 mov dl,10 int 21h pop dx ret crlf ENDP clrscr PROC mov ah,0fh int 10h mov ah,00h int 10h ret clrscr ENDP setcur PROC mov ah,2 mov bh,0 int 10h ret setcur ENDP hidecur PROC push cx mov ah,01H mov ch,00100110b mov cl,00000111b int 10H pop cx ret hidecur ENDP showcur PROC push cx mov ah,01H mov ch,00000110b mov cl,00000111b int 10H pop cx ret showcur ENDP END . 0