; > ShowIOMDRs
; Source for ShowIOMDRegisters functions
;
; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************
;
; Date       Who  Version       Description
; ----       ---  -------       -----------
; 24-Jun-96  BAR  0.01          Started.
; 05-Jul-96  BAR  0.02          Fix all sorts of bugs ... !
; 08-Jul-96  BAR  0.03          Fixed some more bugs ... hopfully !
; 25-Jul-96  BAR  0.04          Fixed some more bugs ... hopfuly !
; 29-Jul-96  BAR  0.05          Changed not to show skipped.
;                               Basically working now.
;
; Will show the contents of selected IOMD registers via the display adaptor.
;
; Show contents of IOMD Regs via display adaptor
; Note : Contents of the registers are not checked, therefore this code will
;        not thus won't cause a failure. Contents can't be relied upon,
;        because of changes to H/W OS etc..
;
ALIGN
sir_IgnoreTable &       &88888888       ;+00C,+008,+004,+000
                &       &88888888       ;+01C,+018,+014,+010
                &       &88888888       ;+02C,+028,+024,+020
                &       &88888888       ;+03C,+038,+034,+030
                &       &88888888       ;+04C,+048,+044,+040
                &       &88888888       ;+05C,+058,+054,+050
                &       &88888888       ;+06C,+068,+064,+060
                &       &00888888       ;+07C,+078,+074,+070
                &       &88008888       ;+08C,+088,+084,+080
                &       &88888800       ;+09C,+098,+094,+090
                &       &88880000       ;+0AC,+0A8,+0A4,+0A0
                &       &00000000       ;+0BC,+0B8,+0B4,+0B0
                &       &88888800       ;+0CC,+0C8,+0C4,+0C0
                &       &00008888       ;+0DC,+0D8,+0D4,+0D0
                &       &90888888       ;+0EC,+0E8,+0E4,+0E0
                &       &00909090       ;+0FC,+0F8,+0F4,+0F0
                &       &00000000       ;+10C,+108,+104,+100
                &       &00000000       ;+11C,+118,+114,+110
                &       &00000000       ;+12C,+128,+124,+120
                &       &00000000       ;+13C,+138,+134,+130
                &       &00000000       ;+14C,+148,+144,+140
                &       &00000000       ;+15C,+158,+154,+150
                &       &00000000       ;+16C,+168,+164,+160
                &       &00000000       ;+17C,+178,+174,+170
                &       &A0A0A0A0       ;+18C,+188,+184,+180
                &       &00008888       ;+19C,+198,+194,+190
                &       &00000000       ;+1AC,+1A8,+1A4,+1A0
                &       &00000000       ;+1BC,+1B8,+1B4,+1B0
                &       &00A0A0A0       ;+1CC,+1C8,+1C4,+1C0
                &       &A0A0A0A0       ;+1DC,+1D8,+1D4,+1D0
                &       &00A00088       ;+1EC,+1E8,+1E4,+1E0
                &       &00888888       ;+1FC,+1F8,+1F4,+1F0
;
; The above is the Show Register Ignore table. It defines if a register is ;
; to be shown and if it is what size the register is. Registers are ;
; expressed as an offset from the base address of IOMD. The registers are ;
; word aligned. To reduce size this table uses one byte per register. The
; table is arranged so that each word repesents 4 registers. The size of the
; register is either 8, 16 or 32 bits, which can be repesented in hex as
; &08, &10 and &20. Threrefore the maximum bit in any byte needed for size
; is bit 5. Therefore bit 8 is used as the flag to indicate if the register
; is to be used, whilst the remaining 7 bits are used for the size. A size
; of 0 is not allowed, therfore the following values for each byte can be
; expected :-
;   <= &80 Register will be skipped
;   =  &88 Show the register and its 8 bits wide
;   =  &90 Show the register and its 16 bits wide
;   =  &A0 Show the register and its 32 bits wide
; Any other value is liable to cause havoc !

sir_ShowIOMDRegs        ROUT
;
; Read the IOMD Register.
;
; Display Adaptor has a 16 char display.
; 32bit no. is 8 chars long
; Display Columns &80+  : 0123456789012345
; Start message         : IOMD Regs:
; Each location read    : +01FC 12345678
; Each location skipped : +01FC Skipped
;
; Define the messages
;"0123456789ABCDEF"
        ALIGN
1
        =       "IOMD Regs:",0
        ALIGN
2
        =       "+",&FF,&FF,&FF,&8B,&FF,&FF,&FF,&FF,&FF,0
;"+123       12345"
        ALIGN
3
        =       "+",&FF,&FF,&FF,&89,"Skipped",0
;"+123     Skipped"
        ALIGN
4
        =       "+",&FF,&FF,&FF,0
;"+123"
        ALIGN
5
        =       &88,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,0
;"        12345678"
        ALIGN
;
; Define some constants
;
sir_mask8       *       &FF             ; 8  bit register mask
sir_mask16      *       &FFFF           ; 16 bit register mask
sir_mask32      *       &FFFFFFFF       ; 32 bit register mask
sir_MaxOffset   *       &1FC            ; Maximum register offset.
;
; ts_showtext I/f is :-
; r4 = text string to leave
; r8 = number to subsitute
; r0 - r3, r5 - r7 corrupted
;
; r9 = table loop counter +1
; r10 = iomd offset loop counter +4
; r11 = iomd base
;       tempory copy of r1, contents of IOMD - 32bit data
; r12 = table address
;
        MOV     r13,r14                 ; Put r14 in r13 for later use.
        MOV     r0,#0                   ; data read from the Ignore table
        MOV     r1,#0                   ; data read from iomd
        MOV     r4,#0                   ; Pointer to string for display adaptor
        MOV     r8,#0                   ; Number to subsitue in display adaptor
        MOV     r9,#0                   ; Ignore table counter (+1)
        MOV     r10,#0                  ; IOMD Offset counter (+4)
        MOV     r11,#0                  ; IOMD's base address.
                                        ; Tempory copy of r1.
        ADR     r12,sir_IgnoreTable     ; Get IOMD Ignore table address.
;
sir_loop
; ok, lets do some work here guys
        LDRB    r0,[r12,r9]             ; Get data from Ignore Table
        CMPS    r0,#&80                 ; Check top bit set
;        BLE     sir_DisplaySkip         ; Jump to display skip msg if skipped
                                        ; Don't show skipped - makes post too long,
                                        ; Remove comment to re-instate and comment line below
        BLE     sir_LoopControl         ; Jump to loop control.

        AND     r0,r0,#&7F              ; Mask off top bit to get reg size

        CMPS    r0,#&08                 ; Is reg size = 8
        LDREQ   r0,=sir_mask8           ; If yes : mask = &FF
        BEQ     sir_cont                ; Jump on to continue

        CMPS    r0,#&10                 ; Is reg size = 16
        LDREQ   r0,=sir_mask16          ; If yes : mask = &FFFF
        BEQ     sir_cont                ; Jump on to continue

        CMPS    r0,#&20                 ; Is reg size = 32
        LDREQ   r0,=sir_mask32          ; If yes : mask = &FFFFFFFF

sir_cont
; Ok, we've got the mask in r0, lets get the data from IOMD
        LDR     r11,=IOMD_Base          ; Get IOMD's base address.
                                        ; Need to 'cos r11 is also used as tmp store for r1
        LDR     r1,[r11,r10]            ; Get data from IOMD (base [r11] + offsert [r10])
        AND     r1,r1,r0                ; Mask off the reqd. data
        MOV     r8,r10,LSL #20          ; Put offset that was read into r8 and
                                        ; shifted left 20 to fill top 3 nibles
        MOV     r2,#&10                 ; Put CMP data in r2, this will be shift left 12
        CMPS    r0,r2,LSL #12           ; Is mask < &10000 ? (&10<<12)

        BHI     sir_TwoLine             ; Mask > &10000 : jump to code to show
                                        ; offset & data on two lines
; The mask is less then &10000
        ADD     r8,r8,r1                ; Add to r8 the masked data
        ADR     r4,%BT2                 ; r4 -> result message #2

        BL      ts_SendText             ; Anyway : Display the message :-
                                        ; Mask < &10000 : +XXX    XXXXX
        B       sir_LoopControl         ; Go to loop control

sir_TwoLine
; Code to disply the offset and data on two lines, because the data is 32
; bits wide.
; The mask is greater then &1000
; r1 has the data read from IOMD in it.
        ADR     r4,%BT4                 ; r4 -> result message #4
        MOV     r11,r1                  ; Need to make a tempory copy of R1
        BL      ts_SendText             ; Anyway : Display the message :-
                                        ; Mask > &10000 : +XXX
        MOV     r8,r11                  ; r8 = the masked data
                                        ; r11 is the tempory copy of r1
        ADR     r4,%BT5                 ; r4 -> result message #5
        BL      ts_MoreText             ; Add the data to the line.
        B       sir_LoopControl         ; Go to loop control

sir_DisplaySkip
; Ok, we don't want to display this register
        MOV     r8,r10,LSL #20          ; Mask < &10000 : r8 = offset that was read
                                        ; shifted left 20 to fill top 3 nibles
                                        ; r8 = offset that was skipped
        ADR     r4,%BT3                 ; R4 -> skipping message
        BL      ts_SendText             ; Display the message

sir_LoopControl
; ok lets see if we need to do some more
        ADD     r9,r9,#1                ; Increment table counter
        ADD     r10,r10,#4              ; Increment IOMD offset counter
        CMP     r10,#sir_MaxOffset      ; Have we reached the end ?
        BLE     sir_loop                ; If <= end then loop back

; Nop, that's it all done !
        MOV     pc,r13                  ; Return to caller, r13 help retn addr.

        END