Memory layout of a data structure: Difference between revisions

no edit summary
m (→‎{{header|Phix}}: added syntax colouring the hard way)
No edit summary
Line 35:
24 - XTC External clock
25 -
=={{header|6502 Assembly}}==
<lang 6502asm>soft_rs232_lo equ $20 ;%87654321
soft_rs232_hi equ $21 ;%-------9</lang>
 
The values $20 and $21 do not matter; any zero page memory location is acceptable. The comments explain which bit position represents which pin, written in the format one would write a binary literal in the assembler. A "-" means that particular bit is unused.
 
This example non-destructively writes a "1" to pin 3:
<lang 6502asm>LDA soft_rs232_lo
ora #%00000100
sta soft_rs232_lo</lang>
 
The common practice is to have "soft" ports in zero page which get written to the memory-mapped location of the actual hardware interface by only a single subroutine that is run at a fixed interval. All other routines only ever update the "soft" port. (Hardware ports such as this example are typically write-only so the only way to non-destructively write to individual bits is through this indirect method.)
 
 
=={{header|Ada}}==
1,489

edits