flat assembler
Message board for the users of flat assembler.

Index > OS Construction > A bad-looking mouse-processing pro

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
Code:
    mov [mousedup],eax     ;1 y x sta(0 0 y<0 x<0 1 btnm btnr btnl)
    bt  eax, 24+4
    sbb eax,eax
    mov al, [mousedup+2]
    add ax, [mousex]
    cmovs ax,[zero16p2-2]
    cmp ax, 640
    cmova ax, [$-2]
    mov [mousex],ax
    bt  dword [mousedup], 24+5
    sbb eax,eax
    mov al, [mousedup+1]
    neg ax
    add ax, [mousey]
    cmovs ax,[zero16p2-2]
    cmp ax, 480
    cmova ax, [$-2]
    mov [mousey],ax
    mov [mousedup],dword 0x100
    zero16p2:    

At least I think it's a mass
Post 14 Jul 2015, 13:03
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
it's not that messy. I think you should give some space between the two blocks (one block for x and one for y).

why do you write "eax" (the first instruction) if your only going to read it back in for y a moment later? personally I'd just use a second register and read from it instead.
Code:
shr eax, 8
bt eax, 16+4;instead of 24+4
sbb ebx, ebx
mov bl, ah
add bx,[mousex]
;.. etc...
    


I have my own mouse code but it provides a couple other features so it's not comparable.
Post 15 Jul 2015, 16:29
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
BAiC wrote:
it's not that messy. I think you should give some space between the two blocks (one block for x and one for y).

why do you write "eax" (the first instruction) if your only going to read it back in for y a moment later? personally I'd just use a second register and read from it instead.
Code:
shr eax, 8
bt eax, 16+4;instead of 24+4
sbb ebx, ebx
mov bl, ah
add bx,[mousex]
;.. etc...
    


I have my own mouse code but it provides a couple other features so it's not comparable.


what if I let ebp equal to mousedup
Post 20 Jul 2015, 03:46
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
you can use any of registers you want. on a technical note (as far as my example is concerned) the second byte of EBP isn't addressable by instructions. only AH,BH,CH,DH are available for eax,ebx,ecx,edx (respectively).

Stefan
Post 20 Jul 2015, 09:26
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
aimed at smaller os
Post 23 Jul 2015, 15:32
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.