home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.os.development      Operating system development chatter      4,255 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,925 of 4,255   
   Robert Pengelly to wolfgang kern   
   Re: COM1 interrupt for 16-bit OS (1/2)   
   13 Nov 23 00:49:12   
   
   From: robertapengelly@gmail.com   
      
   On Monday, 13 November 2023 at 08:37:18 UTC, wolfgang kern wrote:   
   > On 13/11/2023 05:16, wolfgang kern wrote:   
   > ...   
   > >>>>>>>> So I was doing it right. I have:   
   >   
   > >>>>>>>> xor ax, ax   
   > >>>>>>>> xor dx, dx   
   > >>>>>>>> xor cx, cx   
   > >>>>>>>>   
   > >>>>>>>> mov al, [buffer]   
   > I'd check here for the sync bit and reset IRQ4 variables if not.   
   >   
   > >>>>>>>> and al, HEX (0C) get b7&6 Y into b3&2 AL   
   > >>>>>>>>   
   > >>>>>>>> mov dl, [buffer] get b7&6 X into b1&0 DL   
   > >>>>>>>> and dl, HEX (03)   
   > >>>>>>>>   
   > >>>>>>>> mov cl, 4   
   > >>>>>>>> shl ax, cl OK b7&6 Y are correct in AL   
   > >>>>>>>>   
   > >>>>>>>> mov cl, 6   
   > >>>>>>>> shl dx, cl OK b7&6 X are correct in DL   
   >   
   > I found my hand written notes from 1980 on Serial Mice now,   
   > two button standard:   
   > 1200 baud, No Parity, 7(or8)bit, 1 stop bit   
   > 1st byte   
   > 7 * don't care   
   > 6 == 1 sync bit   
   > 5 Right Button Down   
   > 4 Left Button Down   
   > 3 b7 Y   
   > 2 b6 Y   
   > 1 b7 X   
   > 0 b6 X   
   > 2nd byte   
   > 7 *   
   > 6 == 0   
   > 5..0 b5..0 X   
   > 3rd byte   
   > 7 *   
   > 6 ==0   
   > 5..0 b5..0 Y   
   > assume BX points to buffer yet   
   > >>> mov cl, [bx + 2]   
   > AND CL, 0x7f ;can't be sure for b7==0   
   > ;missed to sign extend AX,AL   
   > CBW makes AX sign extended from AL   
   > or ax, cx OK insert low 6 bits   
   >   
   > ADD [mouse_y],AX it does a SUB if AX is negativ   
   > mov cl, [bx + 1]   
   > AND CX,0x7f   
   > MOV AL,DL   
   > CBW   
   > OR AX,CX   
   > ADD [mouse_x],AX   
   > DONE:   
   > >>>>>>> I'd keep mouse positions stored in pixels and only scale down for   
   > >>>>>>> cursor   
   > >>>>>>> updates.   
   > >>>>>> The following code gives weird results as well:   
   > >>>>>>   
   > >>>>>> timer_handler:   
   > >>>>>>   
   > >>>>>> mov bx, cs:[mouse_x]   
   > >>>>>> shr bx   
   > >>>>>> shr bx   
   > >>>>>> shr bx   
   > >>>>>>   
   > >>>>>> mov cx, cs:[mouse_y]   
   > >>>>>> shr cx   
   > >>>>>> shr cx   
   > >>>>>> shr cx   
   > >>>>>> shr cx   
   > >>>>>>   
   > >>>>>> timer_handler.move:   
   > >>>>>>   
   > >>>>>> mov ah, HEX (02)   
   > >>>>>> xor bh, bh   
   > >>>>>> mov dh, cl   
   > >>>>>> mov dl, bl   
   > >>>>>> int HEX (10)   
   > >>>   
   > >>>>>> I've removed the shifts from the irq handler but the cursor is dodgy.   
   > >>>>> then I assume that it is off screen, so you may not clip it correct.   
   > >>>> Can you see anything wrong with the irq handler I sent a few   
   > >>>> messages ago? Also, can you see anything that may be wrong in:   
   > I'll check on the following later on ...   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Clear interrupts while we set other up.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> cli   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; We'll use the extra segment to offset the correct positions   
   > >>>> ;; so make sure it is zero.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> xor ax, ax   
   > >>>> mov es, ax   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Setup INT 0Ch.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov word ptr es:[HEX (0C) * 4], offset serial_handler   
   > >>>> mov word ptr es:[HEX (0C) * 4 + 2], cs   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Set DLAB on.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03FB)   
   > >>>> mov al, HEX (80)   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Set baud rate (low).   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03F8)   
   > >>>> mov al, HEX (60)   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Set baud rate (high).   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03F9)   
   > >>>> xor al, al   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; 8 bits, no parity, one stop bit.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03FB)   
   > >>>> mov al, HEX (03)   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; FIFO Control Register.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03FC)   
   > >>>> mov al, HEX (0B)   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Turn on DTR, RTS and OUT2.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03FA)   
   > >>>> mov al, HEX (C7)   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Interrupt when data received.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> mov dx, HEX (03F9)   
   > >>>> mov al, HEX (01)   
   > >>>> out dx, al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Enable interrupts on IRQ4.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> in al, HEX (21)   
   > >>>>   
   > >>>> and al, HEX (EF)   
   > >>>> out HEX (21), al   
   > >>>>   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> ;; Restore interrupts.   
   > >>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   ;;;;;;;;;;;;;;;;   
   > >>>> sti   
   > >   
   > >> I forgot that I was using bx when I modified the code.  That's been   
   > >> fixed but still having problems, did you see anything else wrong?   
   > YES   
   > __   
   > wolfgang   
   Just as I was going to reply you sent that last message.  Anyways this seems   
   to work:   
      
       xor     ax,     ax   
       xor     dx,     dx   
       xor     cx,     cx   
       mov     bx,     offset buffer   
      
       mov     al,     [bx]   
       and     al,     HEX (0C)   
      
       mov     cl,     4   
       shl     ax,     cl   
      
       cbw   
      
       mov     cl,     [bx + 2]   
       or      ax,     cx   
       add     [mouse_y],      ax   
      
       mov     al,     [bx]   
       and     al,     HEX (03)   
      
       mov     cl,     6   
       shl     ax,     cl   
      
       cbw   
      
       mov     cl,     [bx + 1]   
       or      ax,     cx   
       add     [mouse_x],      ax   
      
   but not sure if it's right or not.  You did just have "CBW makes AX sign   
   extended from AL" so maybe the code is right.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca