Re: A85: Small C v4.1 released


[Prev][Index][Thread]

Re: A85: Small C v4.1 released



At 09:01 PM 9/30/97 +0000, you wrote:
>Can the Small C compiler access the port on the calc?
>                                                    -=<Matt>=-
>

There is no c function at this point that handles port communication, but writing one is almost trivial. Since inline assembly is supported, you would only need to get the source code to a get/send assembly function, and write a small wrapper around it. For example:

// Get a byte from the link port
get() {
#asm
   ; Insert assembly routine here
   ; put return value in hl
#endasm
}

// Send a byte to the link port
send(x) char x; {
#asm
    ; Get argument 'x' off the stack
    ld  hl,2
    add hl,sp
    ld  a,(hl) ; assuming the byte is to be placed in 'a'
    ; Insert assembly routine here
#endasm
}



References: