Setting cursor loaction - Review my asm code
Posted: Sun Apr 25, 2010 10:55 pm
I want to post my cursor managing code to the wiki, because it annoys me when there isn't an asm example. Tell me what you think.
The cursor is updated from the col and row variables, I did it that way instead of passing args because the need for variables to keep up with columns and rows already exists for many other reasons.
The cursor is updated from the col and row variables, I did it that way instead of passing args because the need for variables to keep up with columns and rows already exists for many other reasons.
Code: Select all
update_cursor_pos:
push ebp
mov ebp,esp
pushad
xor eax,eax
mov al,[row] ; Get new row
mov dl,80
mul dl ; row*80
add al,[col] ; row*80+col
mov [pos],ax ; pos=row*80+col
mov al,0fh
mov dx,[vid_ctrl_reg]
out dx,al ; Set video reg to f
mov ax,[pos]
and al,0ffh
mov dx,[vid_out_reg]
out dx,al ; Access video reg f
mov al,0eh
mov dx,[vid_ctrl_reg]
out dx,al ; Set video reg to e
mov ax,[pos]
mov al,ah
and al,0ffh
mov dx,[vid_out_reg]
out dx,al ; Access video reg e
popad
mov esp,ebp
pop ebp
ret
vid_ctrl_reg dw 3d4h
vid_out_reg dw 3d5h
col db 0
row db 0
pos dw 0