Memory layout of a data structure: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added version 2. -- ~~~~)
m (→‎version 2: define all unassigned bits as unassigned (24 pin RS-232 is actually a 25 pin RS-232). -- ~~~~)
Line 767: Line 767:
exit /*stick a fork in it, we're done.*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────RS_232 subroutine───────────────────*/
/*──────────────────────────────────RS_232 subroutine───────────────────*/
rs_232: arg pins,x; parse arg ,ox; @.= /*x is uppercased when using ARG.*/
rs_232: arg pins,x; parse arg ,ox /*x is uppercased when using ARG.*/
@. = '??? unassigned bit' /*assigned default for all bits. */
@.24.1 = 'PG protective ground'
@.24.1 = 'PG protective ground'
@.24.2 = 'TD transmitted data' ; @.9.3 = @.24.2
@.24.2 = 'TD transmitted data' ; @.9.3 = @.24.2
Line 778: Line 779:
@.24.9 = '+ positive voltage'
@.24.9 = '+ positive voltage'
@.24.10 = '- negative voltage'
@.24.10 = '- negative voltage'
@.24.11 = 'B11 unassigned bit 11'
@.24.12 = 'SCD secondary CD'
@.24.12 = 'SCD secondary CD'
@.24.13 = 'SCS secondary CTS'
@.24.13 = 'SCS secondary CTS'
Line 785: Line 785:
@.24.16 = 'SRD secondary RD'
@.24.16 = 'SRD secondary RD'
@.24.17 = 'RC receiver clock'
@.24.17 = 'RC receiver clock'
@.24.18 = 'B18 unassigned bit 18'
@.24.19 = 'SRS secondary RTS'
@.24.19 = 'SRS secondary RTS'
@.24.20 = 'DTR data terminal ready' ; @.9.4 = @.24.20
@.24.20 = 'DTR data terminal ready' ; @.9.4 = @.24.20
Line 792: Line 791:
@.24.23 = 'DRS data rate select'
@.24.23 = 'DRS data rate select'
@.24.24 = 'XTC external clock'
@.24.24 = 'XTC external clock'
select

when right(x,1)=='B' then bits= strip(x,'T',"B")
select
when right(x,1)=='B' then bits= strip(x,'T',"B")
when right(x,1)=='X' then bits=x2b(strip(x,'T',"X"))
when right(x,1)=='X' then bits=x2b(strip(x,'T',"X"))
otherwise bits=x2b( d2x(x))
otherwise bits=x2b( d2x(x))
end /*select*/
end /*select*/

bits=right(bits,pins,0) /*right justify the pin readings.*/
bits=right(bits,pins,0) /*right justify the pin readings.*/
say; say '───────── For a' pins "pin RS─232 plug, with a reading of: " ox
say; say '───────── For a' pins "pin RS─232 plug, with a reading of: " ox