Setting cursor loaction - Review my asm code

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Setting cursor loaction - Review my asm code

Post by TylerH »

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.

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                   
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: Setting cursor loaction - Review my asm code

Post by earlz »

TylerAnon wrote:I want to...
Not to say that adding more code is bad, but I think it's trivial to convert the C code already there to assembly. I think adding assembly code to it just complicates the page for no real gain.
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Re: Setting cursor loaction - Review my asm code

Post by TylerH »

Okay, I'll leave the page as it is...
Post Reply