OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:35 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Setting cursor loaction - Review my asm code
PostPosted: Sun Apr 25, 2010 10:55 pm 
Offline
Member
Member

Joined: Tue Apr 13, 2010 8:00 pm
Posts: 285
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:
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                   


Top
 Profile  
 
 Post subject: Re: Setting cursor loaction - Review my asm code
PostPosted: Mon Apr 26, 2010 1:18 am 
Offline
Member
Member

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

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: Setting cursor loaction - Review my asm code
PostPosted: Mon Apr 26, 2010 1:37 am 
Offline
Member
Member

Joined: Tue Apr 13, 2010 8:00 pm
Posts: 285
Okay, I'll leave the page as it is...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group