From 7c8e830b90d4e23f10e0c7e30ca00c59dfd785d3 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 17 Oct 2017 22:34:49 -0400 Subject: [PATCH] Adjusted the Acorn tape parser to avoid signed left shifts. --- Storage/Tape/Parsers/Acorn.cpp | 10 +++++----- Storage/Tape/Parsers/Acorn.hpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Storage/Tape/Parsers/Acorn.cpp b/Storage/Tape/Parsers/Acorn.cpp index 80a7b14d0..3bcb2f496 100644 --- a/Storage/Tape/Parsers/Acorn.cpp +++ b/Storage/Tape/Parsers/Acorn.cpp @@ -41,14 +41,14 @@ int Parser::get_next_byte(const std::shared_ptr &tape) { return value; } -int Parser::get_next_short(const std::shared_ptr &tape) { - int result = get_next_byte(tape); - result |= get_next_byte(tape) << 8; +unsigned int Parser::get_next_short(const std::shared_ptr &tape) { + unsigned int result = static_cast(get_next_byte(tape)); + result |= static_cast(get_next_byte(tape)) << 8; return result; } -int Parser::get_next_word(const std::shared_ptr &tape) { - int result = get_next_short(tape); +unsigned int Parser::get_next_word(const std::shared_ptr &tape) { + unsigned int result = get_next_short(tape); result |= get_next_short(tape) << 8; return result; } diff --git a/Storage/Tape/Parsers/Acorn.hpp b/Storage/Tape/Parsers/Acorn.hpp index 5a749d23b..102c877b0 100644 --- a/Storage/Tape/Parsers/Acorn.hpp +++ b/Storage/Tape/Parsers/Acorn.hpp @@ -53,8 +53,8 @@ class Parser: public Storage::Tape::Parser, public Shifter::Delegate int get_next_bit(const std::shared_ptr &tape); int get_next_byte(const std::shared_ptr &tape); - int get_next_short(const std::shared_ptr &tape); - int get_next_word(const std::shared_ptr &tape); + unsigned int get_next_short(const std::shared_ptr &tape); + unsigned int get_next_word(const std::shared_ptr &tape); void reset_crc(); uint16_t get_crc();