3.4.2 Z80/Z180 Storage Class Language Extensions

Next: 3.4.3 HC08 Storage Class Up: 3.4 Storage Class Language Previous: 3.4.1 MCS51/DS390 Storage Class Contents Index
Subsections

- 3.4.2.1 sfr (in/out to 8-bit addresses)
- 3.4.2.2 banked sfr (in/out to 16-bit addresses)
- 3.4.2.3 sfr (in0/out0 to 8 bit addresses on Z180/HD64180)

##
3.4.2 Z80/Z180 Storage Class Language Extensions

###
3.4.2.1 sfr (in/out to 8-bit addresses)

The Z80 family has separate address spaces for memory and input/output memory. I/O memory is accessed with special instructions, e.g.:

> `sfr at 0x78 IoPort; /* define a var in I/O space at 78h called IoPort */`

Writing 0x01 to this variable generates the assembly code:

> `3E 01 ld a,#0x01`
> `D3 78 out (_IoPort),a`

###
3.4.2.2 banked sfr (in/out to 16-bit addresses)

The keyword banked is used to support 16 bit addresses in I/O memory e.g.:

> `sfr banked at 0x123 IoPort;`

Writing 0x01 to this variable generates the assembly code:

> `01 23 01 ld bc,#_IoPort`
> `3E 01 ld a,#0x01`
> `ED 79 out (c),a`

###
3.4.2.3 sfr (in0/out0 to 8 bit addresses on Z180/HD64180)

The compiler option --portmode=180 (80) and a compiler #pragma portmode z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructions `in0/out0` instead of `in/out`. If you include the file z180.h this will be set automatically.

Next: 3.4.3 HC08 Storage Class Up: 3.4 Storage Class Language Previous: 3.4.1 MCS51/DS390 Storage Class Contents Index