| ??? 05/12/06 15:33 Read: times |
#116095 - use this as starting point Responding to: ???'s previous message |
You could use the example source given in the SDCC manual ( http://sdcc.sourceforge.net/doc/sdccman.pdf ) chapter 3.5 "Absolute Addressing" as a starting point.
It compiles to the code below. For Keil which I assume you'll be using you'd have to use r7 instead of dpl for parameter passing. Then strip off a few byte from the SDCC generated code below:
;------------------------------------------------------------
;Allocation info for local variables in function 'spi_io'
;------------------------------------------------------------
;out_byte Allocated to registers r2
;i Allocated to registers r3
;------------------------------------------------------------
;spi_io.c:8: unsigned char spi_io(unsigned char out_byte)
; -----------------------------------------
; function spi_io
; -----------------------------------------
_spi_io:
mov r2,dpl; <------------------ adapt
;spi_io.c:11: do {
mov r3,#0x08
00103$:
;spi_io.c:12: MOSI = out_byte & 0x80;
;spi_io.c:13: out_byte <<= 1;
mov a,r2
add a,r2
mov _MOSI,c
mov r2,a
;spi_io.c:14: MCLK = 1;
setb _MCLK
;spi_io.c:16: if(MISO)
jnb _MISO,00102$
;spi_io.c:17: out_byte += 1;
inc r2
00102$:
;spi_io.c:18: MCLK = 0;
clr _MCLK
;spi_io.c:19: } while(--i);
djnz r3,00103$
00114$:
;spi_io.c:20: return out_byte;
mov dpl,r2 ; <----------------- adapt
ret
Greetings, Frieder |
| Topic | Author | Date |
| Assembler SW SPI control for 80c51 | 01/01/70 00:00 | |
| Simple | 01/01/70 00:00 | |
| should be about 10 lines | 01/01/70 00:00 | |
| use this as starting point | 01/01/70 00:00 | |
serial memory | 01/01/70 00:00 |



