From: Michel Pollet Date: Wed, 25 Aug 2010 15:07:31 +0000 (+0100) Subject: core: CALL/RET instructions fix X-Git-Tag: v1.0a5~4 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=e0e85ba6e358f9d5b757671e1a7d236f522f3bb4;p=sx%2Fsimavr.git core: CALL/RET instructions fix Swap LSB and MSB of return address on the stack. Thanks to "Peter" on the simavr mailing list. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/sim_core.c b/simavr/sim/sim_core.c index 06f4f45..ebb4646 100644 --- a/simavr/sim/sim_core.c +++ b/simavr/sim/sim_core.c @@ -230,14 +230,14 @@ static inline uint8_t _avr_pop8(avr_t * avr) inline void _avr_push16(avr_t * avr, uint16_t v) { - _avr_push8(avr, v >> 8); _avr_push8(avr, v); + _avr_push8(avr, v >> 8); } static inline uint16_t _avr_pop16(avr_t * avr) { - uint16_t res = _avr_pop8(avr); - res |= _avr_pop8(avr) << 8; + uint16_t res = _avr_pop8(avr) << 8; + res |= _avr_pop8(avr); return res; }