SERial line reset

Anything QL Software or Programming Related.
Derek_Stewart
Font of All Knowledge
Posts: 3953
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: SERial line reset

Post by Derek_Stewart »

Hi Tom,

You could look at the 8049 disassembly by Laurence Reeves:

http://www.dilwyn.me.uk/docs/disassem/ipc8049.zip

Which is commented, this may give some clues. The Hermes code was developed from this code, so maybe this point the direction in QDOS to solve the problems you have.


Regards,

Derek
tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: SERial line reset

Post by tcat »

Hi,

Trying to revive an old topic of mine.
Found a small binary SER_RESET, packaged with SERMOUSE.

Generally, I sometimes need to empty serial buffers, after disabling mouse.
SerMOff [SERMOUSE]
PTR_OFF [DIY Mouse]
otherwise serial transfer from QL to PC is corrupt.

To clean buffers, I use a small basic code

Code: Select all

OPEN#10,ser2ir: CLOSE#10
But I am now curious how SER_RESET works, as it seems it not only cleans buffers
but also somehow resets IPC, possible?

I have the QL with standard IPC [no HERMES], wishing to understand the code.
Many thanks
Tom

Code: Select all

~/ql/mouse $ hd SERRESET_CDE
00000000  60 1e 00 18 53 45 52 5f  52 45 53 45 54 20 56 31  |`...SER_RESET V1|
00000010  2e 30 30 20 7f 31 39 39  32 4a 6f 0a 32 34 30 31  |.00 .1992Jo.2401|
00000020  43 fa ff e0 91 c8 34 78  00 d0 4e 92 43 fa 00 08  |C.....4x..N.C...|
00000030  34 78 01 10 4e d2 00 01  00 1e 09 53 45 52 5f 52  |4x..N......SER_R|
00000040  45 53 45 54 00 00 00 01  00 de 08 42 41 55 44 52  |ESET.......BAUDR|
00000050  41 54 45 00 00 00 61 00  00 c6 4a ad 00 98 66 06  |ATE...a...J...f.|
00000060  4a ad 00 9c 67 78 40 c6  4e 40 00 7c 07 00 76 7f  |J...gx@.N@.|..v.|
00000070  47 fa 00 d0 70 11 4e 41  02 01 00 0f 67 08 61 68  |G...p.NA....g.ah|
00000080  51 cb ff ee 60 5c 76 7f  10 39 00 01 80 21 0c 00  |Q...`\v..9...!..|
00000090  00 e0 67 08 61 52 51 cb  ff f0 60 46 47 fa 00 9c  |..g.aRQ...`FG...|
000000a0  70 11 4e 41 70 01 48 40  61 50 20 2d 00 98 67 02  |p.NAp.H@aP -..g.|
000000b0  61 4e 20 2d 00 9c 67 02  61 46 61 54 70 12 4e 41  |aN -..g.aFaTp.NA|
000000c0  4a ad 00 98 67 08 47 fa  00 82 70 11 4e 41 4a ad  |J...g.G...p.NAJ.|
000000d0  00 9c 67 08 47 fa 00 7c  70 11 4e 41 46 c6 70 00  |..g.G..|p.NAF.p.|
000000e0  4e 75 46 c6 70 ff 4e 75  46 c6 20 3c 00 00 10 00  |NuF.p.NuF. <....|
000000f0  61 08 4e 40 00 7c 07 00  4e 75 53 80 6e fc 4e 75  |a.N@.|..NuS.n.Nu|
00000100  24 40 25 6a 00 0c 00 08  25 6a 00 6e 00 6a 4e 75  |$@%j....%j.n.jNu|
00000110  72 07 c2 2d 00 a0 d2 41  32 3b 10 40 4e 75 70 00  |r..-...A2;.@Nup.|
00000120  4e 41 2a 48 4e 75 61 f6  61 e6 55 ae 00 58 22 6e  |NA*HNua.a.U..X"n|
00000130  00 58 3d 81 98 00 78 03  60 a4 00 00 00 00 00 00  |.X=...x.`.......|
00000140  01 ff 01 00 00 00 00 00  02 ff 02 00 00 00 00 00  |................|
00000150  01 ff 03 00 00 00 00 00  01 ff 4b 00 25 80 12 c0  |..........K.%...|
00000160  09 60 04 b0 02 58 01 2c  00 4b 45 6e 64 65        |.`...X.,.KEnde|

Code: Select all

;  DISA-Listing: ram1_serreset_dis        filetype  0
        section disa
        data    0
start   equ     *
        bra.s   L0020
L0002   ori.b   #$45,(a0)+
        addq.w  #$01,(a7)+
        addq.w  #$01,d5
        subq.w  #$01,d5
        addq.b  #$02,-(a0)
        addq.b  #$03,$30(a1,d2.l)
        move.w  -(a0),d0
        illegal
        move.w  $324A6F0A,-(a4)
        move.w  $31(a4,d3.w),d1
L0020   lea     L0002(pc),a1
        suba.l  a0,a0
        movea.w $000000D0,a2    ; UT_MTEXT
        jsr     (a2)
        lea     L0036(pc),a1
        movea.w $00000110,a2    ; BP_INIT
        jmp     (a2)
; 
L0036   ori.b   #$1E,d1
        bchg    d4,(a3)
        illegal
        subq.w  #$07,(a2)
        illegal
        illegal
        ori.b   #$01,d0
        illegal
        bchg    #$55,d2
        neg.w   (a2)
        illegal
        illegal
        ori.b   #$00,d0
        illegal
        tst.l   $0098(a5)
          bne.s L0066
        tst.l   $009C(a5)
          beq.s L00DE
L0066   move.w  sr,d6
        trap    #$00            ; MT_SUPERV
        ori.w   #$0700,sr
        moveq   #$7F,d3
L0070   lea     L0142(pc),a3
        moveq   #$11,d0         ; MT_IPCOM
        trap    #$01
        andi.b  #$0F,d1
          beq.s L0086
        bsr.s   L00E8
        dbf     d3,L0070
        bra.s   L00E2
L0086   moveq   #$7F,d3
L0088   move.b  $00018021,d0
        cmpi.b  #$E0,d0
          beq.s L009C
        bsr.s   L00E8
        dbf     d3,L0088
        bra.s   L00E2
L009C   lea     L013A(pc),a3
        moveq   #$11,d0         ; MT_IPCOM
        trap    #$01
        moveq   #$01,d0
        swap    d0
        bsr.s   L00FA
        move.l  $0098(a5),d0
          beq.s L00B2
        bsr.s   L0100
L00B2   move.l  $009C(a5),d0
          beq.s L00BA
        bsr.s   L0100
L00BA   bsr.s   L0110
        moveq   #$12,d0         ; MT_BAUD
        trap    #$01
        tst.l   $0098(a5)
          beq.s L00CE
        lea     L014A(pc),a3
        moveq   #$11,d0         ; MT_IPCOM
        trap    #$01
L00CE   tst.l   $009C(a5)
          beq.s L00DC
        lea     L0152(pc),a3
        moveq   #$11,d0         ; MT_IPCOM
        trap    #$01
L00DC   move.w  d6,sr
L00DE   moveq   #$00,d0
        rts
; 
L00E2   move.w  d6,sr
        moveq   #-$01,d0        ; ERR_NC
        rts
; 
L00E8   move.w  d6,sr
        move.l  #$00001000,d0
        bsr.s   L00FA
        trap    #$00            ; MT_SUPERV
        ori.w   #$0700,sr
        rts
; 
L00FA   subq.l  #$01,d0
          bgt.s L00FA
        rts
; 
L0100   movea.l d0,a2
        move.l  $000C(a2),$0008(a2)
        move.l  $006E(a2),$006A(a2)
        rts
; 
L0110   moveq   #$07,d1
        and.b   $00A0(a5),d1
        add.w   d1,d1
        move.w  L015A(pc,d1.w),d1
        rts
; 
L011E   moveq   #$00,d0         ; MT_INF
; 
        trap    #$01
        movea.l a0,a5
        rts
; 
        bsr.s   L011E
        bsr.s   L0110
        subq.l  #$02,$0058(a6)
        movea.l $0058(a6),a1
        move.w  d1,$00(a6,a1.l)
        moveq   #$03,d4
        bra.s   L00DE
L013A   ori.b   #$00,d0
        ori.b   #$FF,d0
L0142   btst    d0,d0
        ori.b   #$00,d0
        illegal
L014A   andi.b  #$00,d0
        ori.b   #$FF,d0
L0152   btst    d1,d0
        ori.b   #$00,d0
        illegal
L015A   illegal
        move.l  d0,-$40(a2,d1.w)
        bchg    d4,-(a0)
        subi.l  #$0258012C,$4B(a0,d0.w)
        illegal
          bcc.s H01D3
L016E   equ     *
        end


User avatar
tofro
Font of All Knowledge
Posts: 2699
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: SERial line reset

Post by tofro »

tcat wrote:Hi,


But I am now curious how SER_RESET works, as it seems it not only cleans buffers
but also somehow resets IPC, possible?

Tom
Yes, IPC command 0 (zero) resets the IPC.

I didn't look into the code you've provided, you seem to have disassembled a lot of strings and other data into instructions.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: SERial line reset

Post by tcat »

I didn't look into the code you've provided, you seem to have disassembled a lot of strings and other data into instructions.
Quite right, learning DISA, it can mark blocks as DC.B or CODE, will try to improve disassembly.
Command `0' resets IPC
- perfect, will try to extend my code doing this as well.


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: SERial line reset

Post by mk79 »

Apparently that was written by my friend Jochen Hassler (who incidentally also wrote DISA) and as it happens I have the source code of PCMouse, a precursor to SERMouse, which also includes the code. Enjoy.
Attachments
pcmouse101.zip
(7.72 KiB) Downloaded 88 times


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: SERial line reset

Post by tcat »

Marcel,
Many thanks, great stuff to learn from...


Post Reply