flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > coloured print problem |
Author |
|
mike.dld 06 Jan 2006, 23:49
You should manually update cursor position with INT 0x10/AH=2
|
|||
06 Jan 2006, 23:49 |
|
mike.dld 06 Jan 2006, 23:58
Try this out (just as an example, don't learn to write code from it ):
Code: format MZ push cs cs pop es ds mov si,aaaa mov al,0x40 call draw_text mov ax,0x4C00 int 0x21 aaaa db 'mike.dld',0 cur_pos: curx db 0 cury db 0 ; ES:SI - text to draw (null-terminated) ; AL - attribute (color) draw_text: pusha mov dl,al mov dh,0 cld @@: lodsb cmp al,0 je @f push dx si ds cmp al,8 jne .lp0 dec [curx] jmp .lp2 .lp0: cmp al,10 jne .lp1 mov [curx],0 inc [cury] jmp .lp2 .lp1: cmp al,13 je .lp3 mov bx,dx mov ah,9 mov cx,1 int 0x10 inc [curx] .lp2: mov ah,2 mov bh,0 mov dx,[cur_pos] int 0x10 .lp3: pop ds si dx jmp @b @@: popa ret |
|||
06 Jan 2006, 23:58 |
|
RedGhost 07 Jan 2006, 00:40
thanks mike, but the problem is fixed, and it updates cursor for me
there was two problems A) it says to set bit 0 (index 0), for move cursor, not actually set the register to 0 (thanks daverr from fasm irc) B) since service $03 of int $10 returns with CL/CH i obviously should have thought it would modify cx (which contains the string length) (doh, cant believe i overlooked that) working code: Code: ;print coloured string, bp = offset of buffer (doesn't need to be zero terminated), cx = string length, bl = colour @printcstr: push cx mov ah, $03 ;service $03 (get cursor position and size) xor bh, bh ;page 00 int $10 pop cx ;dh now holds the current row ;dl now holds the current column mov ah, $13 ;service $13 (write string) xor al, al ;clear al or al, $01 ;set the first bit index ($01), so it moves the cursor xor bh, bh ;page 00 int $10 retn ;--- _________________ redghost.ca |
|||
07 Jan 2006, 00:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.