flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Something you may consider useful - Pmode cursor positioning |
Author |
|
baldr 26 Apr 2010, 07:23
Tyler,
Several comments:
|
|||
26 Apr 2010, 07:23 |
|
Tyler 26 Apr 2010, 23:20
I've gotten rid of the stack frame and the bit maskings, corrected the issue you pointed out where [pos] equals 0 incorectly. The mov ax,[pos] is just to keep from me coming back a month later, splicing my code into different places, then discovering a weird bug with no idea where it came from.
pos is used in other places, I use it here to keep all printing centered around a single place keeper. Non 80 column modes are A LONG WAY AWAY for me, you know that. Now I've reworked my print function around the centralized pos variable, but I would appreciate your thoughts on my function made just to update pos based on col and row. Code: update_pos: pushad xor eax,eax mov al,[row] ; Get new row mov dl,80 mul dl ; row*80 xor dx,dx mov dl,[col] add ax,dx ; row*80+col mov [pos],eax ; pos=row*80+col popad ret |
|||
26 Apr 2010, 23:20 |
|
Tyler 26 Apr 2010, 23:22
As to pos's importance, it is useful in my print function because it is the offset from the base of video memory to print to the col and row I want.
|
|||
26 Apr 2010, 23:22 |
|
baldr 27 Apr 2010, 06:41
Tyler,
Then your print function updates row/col as well? If their usage is infrequent, they can be dropped altogether (and recalculated from pos when needed, which in turn could be read from CRTC ). BTW pos (it suddenly becomes dword) is only a half of the offset. pushad / popad seems unnecessary. Is the rest of your code suppose that all registers are preserved across calls? xor eax, eax; mov al, [row] causes partial register stall to mul dl. movzx edx, [row]; imul eax, edx, 80 looks better. The same for xor dx, dx; mov dl, [col]; add ax, dx. |
|||
27 Apr 2010, 06:41 |
|
Tyler 28 Apr 2010, 02:35
I use row and col to manipulate pos because rows and columns are a lot easier to comprehend than an offset.
Quote:
Sorry, forgot to update the code above. I changed it to a dword for simplicity. Quote:
No, but it helps in debugging when you now an entire function couldn't be what is screwing up a register. I do it because I don't need to return anything, so there's no reason to trash any regs. Thanks for the info on the register stall thing, I didn't even know that existed. I'll use you suggestion and use your movzx+imul method. I'll come back and update the code after I get my scroll function working. |
|||
28 Apr 2010, 02:35 |
|
baldr 28 Apr 2010, 08:11
Tyler,
You may change row/col to dword too and use imul eax, [row], 80. Partial register stalls are make/model-specific (Core architecture is said to have much less latency for them than NetBurst, and PPro mentioned special handling of partial register write after xor r32, r32). It's just a rule-of-thumb, I think. |
|||
28 Apr 2010, 08:11 |
|
bitshifter 16 Jun 2010, 21:32
These are the ones i made a while back...
Code: ; Get current caret offset. mov ax,0x0F0E mov dx,0x03D4 out dx,al inc dx in al,dx xchg ah,al dec dx out dx,al inc dx in al,dx ; AX = offset ; Set new caret offset. ; BX = offset mov al,0x0E mov ah,bh mov dx,0x03D4 out dx,ax inc ax mov ah,bl out dx,ax |
|||
16 Jun 2010, 21:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.