pub fn semihost_return(processor: &mut Processor, response: &SemihostingResponse) {
    match *response {
        SemihostingResponse::SysOpen { result } => match result {
            Ok(handle) => processor.set_r(Reg::R0, handle),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysFlen { result } => match result {
            Ok(size) => processor.set_r(Reg::R0, size),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysIstty { result } => match result {
            Ok(response) => processor.set_r(Reg::R0, response),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysException { success, stop }
        | SemihostingResponse::SysExitExtended { success, stop } => {
            if success {
                processor.state.set_bit(0, !stop);
            }
        }
        SemihostingResponse::SysClose { success } | SemihostingResponse::SysSeek { success } => {
            if success {
                processor.set_r(Reg::R0, 0);
            } else {
                processor.set_r(Reg::R0, (-1_i32) as u32);
            }
        }
        SemihostingResponse::SysWrite { result } => match result {
            Ok(_) => processor.set_r(Reg::R0, 0),
            Err(unwritten_bytes) => processor.set_r(Reg::R0, unwritten_bytes as u32),
        },
        SemihostingResponse::SysRead { ref result } => match result {
            Ok((memoryptr, data, diff)) => {
                let mut addr = *memoryptr;
                for x in data {
                    processor.write8(addr, *x);
                    addr += 1;
                }
                processor.set_r(Reg::R0, *diff);
            }
            Err(error_code) => processor.set_r(Reg::R0, *error_code as u32),
        },
        SemihostingResponse::SysClock { result } => match result {
            Ok(centiseconds) => processor.set_r(Reg::R0, centiseconds),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysErrno { result } => {
            processor.set_r(Reg::R0, result);
        }
    }
}
///
/// Handle semihosting response received from semihosting implementation
///
Handle semihosting response received from semihosting implementation
Handle semihosting response received from semihosting implementation
pub fn semihost_return(processor: &mut Processor, response: &SemihostingResponse) {
    match *response {
        SemihostingResponse::SysOpen { result } => match result {
            Ok(handle) => processor.set_r(Reg::R0, handle),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysFlen { result } => match result {
            Ok(size) => processor.set_r(Reg::R0, size),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysIstty { result } => match result {
            Ok(response) => processor.set_r(Reg::R0, response),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysException { success, stop }
        | SemihostingResponse::SysExitExtended { success, stop } => {
            if success {
                processor.state.set_bit(0, !stop);
            }
        }
        SemihostingResponse::SysClose { success } | SemihostingResponse::SysSeek { success } => {
            if success {
                processor.set_r(Reg::R0, 0);
            } else {
                processor.set_r(Reg::R0, (-1_i32) as u32);
            }
        }
        SemihostingResponse::SysWrite { result } => match result {
            Ok(_) => processor.set_r(Reg::R0, 0),
            Err(unwritten_bytes) => processor.set_r(Reg::R0, unwritten_bytes as u32),
        },
        SemihostingResponse::SysRead { ref result } => match result {
            Ok((memoryptr, data, diff)) => {
                let mut addr = *memoryptr;
                for x in data {
                    processor.write8(addr, *x);
                    addr += 1;
                }
                processor.set_r(Reg::R0, *diff);
            }
            Err(error_code) => processor.set_r(Reg::R0, *error_code as u32),
        },
        SemihostingResponse::SysClock { result } => match result {
            Ok(centiseconds) => processor.set_r(Reg::R0, centiseconds),
            Err(error_code) => processor.set_r(Reg::R0, error_code as u32),
        },
        SemihostingResponse::SysErrno { result } => {
            processor.set_r(Reg::R0, result);
        }
    }
}
pub fn semihost_return ( processor : & mut Processor , response : & SemihostingResponse ) { match * response { SemihostingResponse :: SysOpen { result } => match result { Ok ( handle ) => processor . set_r ( Reg :: R0 , handle ) , Err ( error_code ) => processor . set_r ( Reg :: R0 , error_code as u32 ) , } , SemihostingResponse :: SysFlen { result } => match result { Ok ( size ) => processor . set_r ( Reg :: R0 , size ) , Err ( error_code ) => processor . set_r ( Reg :: R0 , error_code as u32 ) , } , SemihostingResponse :: SysIstty { result } => match result { Ok ( response ) => processor . set_r ( Reg :: R0 , response ) , Err ( error_code ) => processor . set_r ( Reg :: R0 , error_code as u32 ) , } , SemihostingResponse :: SysException { success , stop } | SemihostingResponse :: SysExitExtended { success , stop } => { if success { processor . state . set_bit ( 0 , ! stop ) ; } } SemihostingResponse :: SysClose { success } | SemihostingResponse :: SysSeek { success } => { if success { processor . set_r ( Reg :: R0 , 0 ) ; } else { processor . set_r ( Reg :: R0 , ( - 1_i32 ) as u32 ) ; } } SemihostingResponse :: SysWrite { result } => match result { Ok ( _ ) => processor . set_r ( Reg :: R0 , 0 ) , Err ( unwritten_bytes ) => processor . set_r ( Reg :: R0 , unwritten_bytes as u32 ) , } , SemihostingResponse :: SysRead { ref result } => match result { Ok ( ( memoryptr , data , diff ) ) => { let mut addr = * memoryptr ; for x in data { processor . write8 ( addr , * x ) ; addr += 1 ; } processor . set_r ( Reg :: R0 , * diff ) ; } Err ( error_code ) => processor . set_r ( Reg :: R0 , * error_code as u32 ) , } , SemihostingResponse :: SysClock { result } => match result { Ok ( centiseconds ) => processor . set_r ( Reg :: R0 , centiseconds ) , Err ( error_code ) => processor . set_r ( Reg :: R0 , error_code as u32 ) , } , SemihostingResponse :: SysErrno { result } => { processor . set_r ( Reg :: R0 , result ) ; } } }
Handle semihosting response received from semihosting implementation
Handle semihosting response received from semihosting implementation
processor
&mut Processor
response
&SemihostingResponse
processor
&mut Processor
response
&SemihostingResponse