mirror of https://github.com/ksherlock/mpw.git
Compare commits
104 Commits
Author | SHA1 | Date |
---|---|---|
ksherlock | 9951892251 | |
Kelvin Sherlock | 79a8a93e03 | |
Stefan | f619ed31b3 | |
Kelvin Sherlock | f460696b4f | |
Kelvin Sherlock | 6151ca1e87 | |
Kelvin Sherlock | b9c7d9f95f | |
Kelvin Sherlock | 2dcb161f5e | |
Ryan Schmidt | f08d67333d | |
Ryan Schmidt | 2e7e75a2a9 | |
Ryan Schmidt | bdb1f4b2b9 | |
Ryan Schmidt | b8d17f4481 | |
Ryan Schmidt | a76287876c | |
Kelvin Sherlock | 022d4cffe9 | |
Kelvin Sherlock | 843ea2764c | |
Ryan Schmidt | fc15ad1d81 | |
Ryan Schmidt | 7ac2a88974 | |
Ryan Schmidt | 2703e00201 | |
Kelvin Sherlock | 5facdb095c | |
Kelvin Sherlock | 194c36c89a | |
Kelvin Sherlock | 3e2c02f796 | |
Kelvin Sherlock | 48d869c6e8 | |
ksherlock | 8c911ab83d | |
Giovanni Cappellotto | b6b0abefbf | |
ksherlock | 67253a69e5 | |
ksherlock | f3b3d221be | |
Uli Kusterer | f4e3bd70a1 | |
ksherlock | 1925dc172b | |
Kelvin Sherlock | 4730a70874 | |
Kelvin Sherlock | a70270be52 | |
Kelvin Sherlock | f12b3789c4 | |
Kelvin Sherlock | 6dfefb2343 | |
ksherlock | 35443c9aa8 | |
ksherlock | fcdfe76817 | |
ksherlock | a55b38104b | |
ksherlock | fb0d353716 | |
ksherlock | 7dc85091a3 | |
Kelvin Sherlock | 0cca883287 | |
ksherlock | 58f2557df5 | |
ksherlock | 031cdf0d08 | |
Kelvin Sherlock | c8310c0dbd | |
ksherlock | 3480881001 | |
ksherlock | 8f64923f9c | |
ksherlock | 7cb4c8cbc3 | |
Kelvin Sherlock | 1a9cb0d766 | |
Kelvin Sherlock | 02629c4eee | |
Kelvin Sherlock | fa1f4623c9 | |
Kelvin Sherlock | b560c66dda | |
Kelvin Sherlock | 2eb90481bc | |
Kelvin Sherlock | 8c38175492 | |
Kelvin Sherlock | 08fef2cef5 | |
Kelvin Sherlock | fb6d52a93d | |
Kelvin Sherlock | 26bd3f53b7 | |
Kelvin Sherlock | d11dab46e2 | |
Kelvin Sherlock | c3d1121f36 | |
Kelvin Sherlock | 776b385a41 | |
Kelvin Sherlock | 119d9aab57 | |
Kelvin Sherlock | 60b49a1ff4 | |
Kelvin Sherlock | e21aac4022 | |
Kelvin Sherlock | 60c4977dfa | |
Kelvin Sherlock | 58f4ca4ac6 | |
Kelvin Sherlock | 3ef7de4b8a | |
Kelvin Sherlock | 67d176856a | |
Kelvin Sherlock | ac3c3293d1 | |
Kelvin Sherlock | c3b235ee95 | |
Kelvin Sherlock | 51a86117b8 | |
Kelvin Sherlock | 5976f91a89 | |
Kelvin Sherlock | f79e74c510 | |
Kelvin Sherlock | 99d1ca04fd | |
ksherlock | b5a39a1a8f | |
ksherlock | 197726c6cc | |
ksherlock | c9c77d33b8 | |
ksherlock | 2e0cb34559 | |
ksherlock | eb54d7bb79 | |
Kelvin Sherlock | fc5e675a51 | |
Kelvin Sherlock | 4af7d59c9c | |
Kelvin Sherlock | 115acb493b | |
Kelvin Sherlock | 5ebc0b276b | |
ksherlock | 288a11e6af | |
Kelvin Sherlock | aae68c20dd | |
Kelvin Sherlock | cd99626176 | |
Kelvin Sherlock | dd460a21eb | |
Kelvin Sherlock | f52331035a | |
Kelvin Sherlock | a726a68dfc | |
Kelvin Sherlock | c17dd4f400 | |
Kelvin Sherlock | 97f7e734bb | |
Kelvin Sherlock | de50c3d796 | |
Kelvin Sherlock | 861ca9b83a | |
Kelvin Sherlock | 56fb5d9743 | |
Kelvin Sherlock | 2a62ad32d2 | |
Kelvin Sherlock | 559f36c437 | |
Kelvin Sherlock | 563dd0f485 | |
Kelvin Sherlock | 1bbcf1cc39 | |
Kelvin Sherlock | 8d40559a62 | |
Kelvin Sherlock | f17839cc7e | |
Kelvin Sherlock | f2dc249614 | |
Kelvin Sherlock | 2766493398 | |
ksherlock | ac4506b52e | |
tsupplis | 37220202a6 | |
tsupplis | 88bc42d153 | |
Kelvin Sherlock | 8bfff02114 | |
ksherlock | 29b780c712 | |
Kelvin Sherlock | b1d647d695 | |
Kelvin Sherlock | 84ff99c177 | |
Kelvin Sherlock | 1675a479c9 |
|
@ -0,0 +1,3 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: [ksherlock]
|
|
@ -0,0 +1,38 @@
|
|||
name: CMake fat
|
||||
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Brew
|
||||
run: brew install ragel lemon
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
shell: bash
|
||||
run: make mpw
|
||||
|
||||
- name: Archive
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpw fat
|
||||
path: ${{runner.workspace}}/build/bin/mpw
|
|
@ -0,0 +1,42 @@
|
|||
name: CMake
|
||||
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-12, macos-11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Brew
|
||||
run: brew install ragel lemon
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
- name: Archive
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpw ${{ matrix.os }}
|
||||
path: ${{runner.workspace}}/build/bin/mpw
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "libsane"]
|
||||
path = libsane
|
||||
url = https://github.com/ksherlock/libsane.git
|
|
@ -0,0 +1,18 @@
|
|||
os: osx
|
||||
osx_image:
|
||||
- xcode11
|
||||
- xcode12
|
||||
- xcode12.5
|
||||
language: cpp
|
||||
compiler: clang
|
||||
before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake ..
|
||||
script: make mpw
|
||||
before_install:
|
||||
- brew update
|
||||
- brew install lemon
|
||||
- brew install ragel
|
||||
# - brew install cmake # not needed.
|
||||
|
|
@ -1,10 +1,32 @@
|
|||
set(CMAKE_C_COMPILER "clang")
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -g")
|
||||
set(CMAKE_C_FLAGS " -Wall -g")
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(mpw VERSION 0.8.3 LANGUAGES CXX C)
|
||||
|
||||
project(mpw)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_CXX_EXTENSIONS FALSE)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_C_EXTENSIONS FALSE)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
# Clang or AppleClang
|
||||
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
# Clang or AppleClang
|
||||
set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
|
||||
|
||||
find_program(RAGEL NAMES ragel)
|
||||
if (NOT RAGEL)
|
||||
message(FATAL_ERROR "ragel (version 6) is required.")
|
||||
endif()
|
||||
|
||||
|
||||
include_directories("${CMAKE_SOURCE_DIR}")
|
||||
|
||||
add_subdirectory(bin)
|
||||
add_subdirectory(cpu)
|
||||
|
@ -12,3 +34,5 @@ add_subdirectory(toolbox)
|
|||
add_subdirectory(mplite)
|
||||
add_subdirectory(mpw)
|
||||
add_subdirectory(macos)
|
||||
|
||||
add_subdirectory(libsane)
|
||||
|
|
32
README.md
32
README.md
|
@ -5,14 +5,17 @@ by Kelvin W Sherlock, _et alia_
|
|||
|
||||
Please check the [wiki](https://github.com/ksherlock/mpw/wiki/_pages) for useful information.
|
||||
|
||||
Please check the [releases](https://github.com/ksherlock/mpw/releases) for compiled binaries.
|
||||
|
||||
|
||||
## System compatibility
|
||||
|
||||
Currently, only OS X 10.8 with case-insensitive HFS+ is supported.
|
||||
Currently, only OS X 10.8+ with case-insensitive HFS+ is supported.
|
||||
|
||||
## License
|
||||
|
||||
The 680x0 CPU code is from [WinFellow](http://fellow.sourceforge.net) and is
|
||||
licensed under GPL v2 or later. Consequently, the rest of the code is licensed
|
||||
licensed under GPL v2 or later. Consequently, the compiled binary is licensed
|
||||
under the GPL v2 as well.
|
||||
|
||||
The memory allocator (NewHandle/NewPointer) code is from [mempoolite](https://github.com/jeftyneg/mempoolite),
|
||||
|
@ -21,13 +24,18 @@ is in the public domain.
|
|||
|
||||
## Building
|
||||
|
||||
Compiling requires cmake, ragel, lemon, and a recent version of clang++ with
|
||||
c++11 support. It has only been built and tested with OS X 10.8.
|
||||
First initialize and fetch submodules:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
Compiling requires cmake, ragel, lemon, and a recent version of clang++ with
|
||||
c++11 support. It has only been built and tested with OS X 10.8+.
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
|
||||
This will generate `bin/mpw` and `bin/disasm`.
|
||||
|
||||
|
@ -82,11 +90,11 @@ or create a shell script (in `/usr/local/bin`, etc)
|
|||
|
||||
`/usr/local/bin/AsmIIgs`:
|
||||
|
||||
#!/usr/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
exec mpw AsmIIgs $@
|
||||
exec mpw AsmIIgs "$@"
|
||||
|
||||
|
||||
mpw looks in the current directory and then in the `$MPW:Tools:` directory
|
||||
for the command to run. The MPW `$Commands` variable is not yet supported.
|
||||
mpw uses the MPW `$Commands` variable to find the command, similar to `$PATH` on Unix. If the `$Commands` variable
|
||||
is not set, mpw looks in the current directory and then in the `$MPW:Tools:` directory.
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ or create a shell script (in /usr/local/bin, etc)
|
|||
|
||||
/usr/local/bin/AsmIIgs:
|
||||
|
||||
#!/usr/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
exec mpw AsmIIgs $@
|
||||
exec mpw AsmIIgs "$@"
|
||||
|
||||
mpw looks in the current directory and then in the $MPW:Tools: directory
|
||||
for the command to run. The MPW $Commands variable is not yet supported.
|
||||
|
|
|
@ -1,53 +1,47 @@
|
|||
#set(CMAKE_C_COMPILER "clang")
|
||||
#set(CMAKE_CXX_COMPILER "clang++")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Wno-deprecated-declarations -g")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-framework Carbon")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
add_definitions(-I ${CMAKE_SOURCE_DIR}/)
|
||||
|
||||
|
||||
# add_custom_command(
|
||||
# OUTPUT lexer.cpp
|
||||
# COMMAND re2c -b -i -o lexer.cpp "${CMAKE_CURRENT_SOURCE_DIR}/lexer.re.cpp"
|
||||
# MAIN_DEPENDENCY lexer.re.cpp
|
||||
# DEPENDS debugger.h parser.h
|
||||
# )
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
# Clang or AppleClang
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-variable")
|
||||
endif()
|
||||
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT lexer.cpp
|
||||
COMMAND ragel -p -G2 -o lexer.cpp "${CMAKE_CURRENT_SOURCE_DIR}/lexer.rl"
|
||||
COMMAND "${RAGEL}" -p -G2 -o lexer.cpp "${CMAKE_CURRENT_SOURCE_DIR}/lexer.rl"
|
||||
MAIN_DEPENDENCY lexer.rl
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT parser.cpp parser.h
|
||||
COMMAND cp -f "${CMAKE_CURRENT_SOURCE_DIR}/parser.lemon" "parser.lemon"
|
||||
COMMAND lemon parser.lemon
|
||||
COMMAND cp -f parser.h "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
COMMAND cp -f parser.out "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
COMMAND mv -f parser.c parser.cpp
|
||||
MAIN_DEPENDENCY parser.lemon
|
||||
DEPENDS debugger.h
|
||||
)
|
||||
find_program(LEMON NAMES lemon)
|
||||
|
||||
if (LEMON)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT template_parser.cpp template_parser.h
|
||||
COMMAND cp -f "${CMAKE_CURRENT_SOURCE_DIR}/template_parser.lemon" "template_parser.lemon"
|
||||
COMMAND lemon template_parser.lemon
|
||||
COMMAND cp -f template_parser.h "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
COMMAND cp -f template_parser.out "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
COMMAND mv -f template_parser.c template_parser.cpp
|
||||
MAIN_DEPENDENCY template_parser.lemon
|
||||
DEPENDS debugger.h
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/parser.h
|
||||
# COMMAND cp -f "${CMAKE_CURRENT_SOURCE_DIR}/parser.lemon" "parser.lemon"
|
||||
COMMAND ${LEMON} parser.lemon
|
||||
COMMAND mv -f parser.c parser.cpp
|
||||
MAIN_DEPENDENCY parser.lemon
|
||||
DEPENDS debugger.h
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/template_parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/template_parser.h
|
||||
# COMMAND cp -f "${CMAKE_CURRENT_SOURCE_DIR}/template_parser.lemon" "template_parser.lemon"
|
||||
COMMAND ${LEMON} template_parser.lemon
|
||||
COMMAND mv -f template_parser.c template_parser.cpp
|
||||
MAIN_DEPENDENCY template_parser.lemon
|
||||
DEPENDS debugger.h
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT loadtrap.cpp
|
||||
COMMAND ragel -p -G2 -o loadtrap.cpp "${CMAKE_CURRENT_SOURCE_DIR}/loadtrap.rl"
|
||||
COMMAND "${RAGEL}" -p -G2 -o loadtrap.cpp "${CMAKE_CURRENT_SOURCE_DIR}/loadtrap.rl"
|
||||
MAIN_DEPENDENCY loadtrap.rl
|
||||
DEPENDS debugger.h
|
||||
)
|
||||
|
@ -55,19 +49,12 @@ add_custom_command(
|
|||
|
||||
add_custom_command(
|
||||
OUTPUT template_loader.cpp
|
||||
COMMAND ragel -p -G2 -o template_loader.cpp "${CMAKE_CURRENT_SOURCE_DIR}/template_loader.rl"
|
||||
COMMAND "${RAGEL}" -p -G2 -o template_loader.cpp "${CMAKE_CURRENT_SOURCE_DIR}/template_loader.rl"
|
||||
MAIN_DEPENDENCY template_loader.rl
|
||||
DEPENDS debugger.h template_parser.h
|
||||
)
|
||||
|
||||
|
||||
set_source_files_properties(
|
||||
loadtrap.cpp lexer.cpp template_loader.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wno-unused-variable"
|
||||
)
|
||||
|
||||
add_executable(mpw loader.cpp debugger.cpp debugger_internal.cpp
|
||||
address_map.cpp lexer.cpp parser.cpp loadtrap.cpp
|
||||
commands.cpp
|
||||
|
@ -79,9 +66,17 @@ target_link_libraries(mpw TOOLBOX_LIB)
|
|||
target_link_libraries(mpw MPW_LIB)
|
||||
target_link_libraries(mpw MPLITE_LIB)
|
||||
target_link_libraries(mpw MACOS_LIB)
|
||||
set_target_properties(mpw PROPERTIES LINK_FLAGS "-ledit")
|
||||
|
||||
target_link_libraries(mpw -ledit)
|
||||
target_link_libraries(mpw "-framework Carbon")
|
||||
|
||||
add_executable(disasm disasm.cpp)
|
||||
target_link_libraries(disasm CPU_LIB)
|
||||
target_link_libraries(disasm MACOS_LIB)
|
||||
target_link_libraries(disasm "-framework Carbon")
|
||||
|
||||
install(
|
||||
PROGRAMS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mpw
|
||||
DESTINATION bin
|
||||
)
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -100,6 +100,3 @@ void ToolMap::remove(uint16_t tool)
|
|||
|
||||
map.erase(tool);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
{
|
||||
return map.end();
|
||||
}
|
||||
|
||||
|
||||
size_t size()
|
||||
{
|
||||
return map.size();
|
||||
|
@ -69,4 +69,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#include <toolbox/os.h>
|
||||
|
@ -28,16 +29,16 @@ namespace Debug {
|
|||
char buffer2[16 + 1];
|
||||
ssize_t offset = 0;
|
||||
unsigned i, j;
|
||||
|
||||
|
||||
|
||||
|
||||
while(size > 0)
|
||||
{
|
||||
{
|
||||
std::memset(buffer1, ' ', sizeof(buffer1));
|
||||
std::memset(buffer2, ' ', sizeof(buffer2));
|
||||
|
||||
|
||||
unsigned linelen = (unsigned)std::min(size, (ssize_t)16);
|
||||
|
||||
|
||||
|
||||
|
||||
for (i = 0, j = 0; i < linelen; i++)
|
||||
{
|
||||
unsigned x = data[i];
|
||||
|
@ -45,16 +46,16 @@ namespace Debug {
|
|||
buffer1[j++] = HexMap[x & 0x0f];
|
||||
j++;
|
||||
if (i == 7) j++;
|
||||
|
||||
|
||||
// isascii not part of std:: and may be a macro.
|
||||
buffer2[i] = isascii(x) && std::isprint(x) ? x : '.';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
buffer1[sizeof(buffer1)-1] = 0;
|
||||
buffer2[sizeof(buffer2)-1] = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
std::printf("%06x: %s %s\n", address + (unsigned)offset, buffer1, buffer2);
|
||||
offset += 16;
|
||||
data += 16;
|
||||
|
@ -75,7 +76,7 @@ namespace Debug {
|
|||
if ((int32_t)value > UINT16_MAX) return;
|
||||
if ((int32_t)value < INT16_MIN) return;
|
||||
|
||||
|
||||
|
||||
uint16_t error = value;
|
||||
printf("%d\n", (int16_t)error);
|
||||
|
||||
|
@ -105,7 +106,7 @@ namespace Debug {
|
|||
{
|
||||
printf("noErr\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,7 +184,7 @@ namespace Debug {
|
|||
uint32_t prevA6 = ReadLong(a6);
|
||||
if (prevA6 <= a6) break;
|
||||
|
||||
uint32_t pc = ReadLong(a6+4); //
|
||||
uint32_t pc = ReadLong(a6+4); //
|
||||
|
||||
|
||||
|
||||
|
@ -239,4 +240,4 @@ namespace Debug {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
|
@ -103,7 +104,7 @@ namespace {
|
|||
};
|
||||
|
||||
std::deque<BackTraceInfo> BackTrace;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -120,7 +121,7 @@ namespace {
|
|||
break;
|
||||
case 0x4E74: // rtd #
|
||||
mboffset = 4;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
|
@ -136,7 +137,7 @@ namespace {
|
|||
b -= 0x80;
|
||||
pc++;
|
||||
if (!b) b = Debug::ReadByte(pc++);
|
||||
|
||||
|
||||
s.reserve(b);
|
||||
for (unsigned i = 0; i < b; ++i)
|
||||
{
|
||||
|
@ -184,7 +185,7 @@ namespace {
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("$%08X Tool #$%04X ; %04X\n",
|
||||
printf("$%08X Tool #$%04X ; %04X\n",
|
||||
pc, opcode, opcode);
|
||||
}
|
||||
|
||||
|
@ -206,7 +207,7 @@ namespace {
|
|||
{
|
||||
case 0x4EBA: // jsr offset(pc)
|
||||
{
|
||||
int16_t offset = Debug::ReadWord(pc + 2);
|
||||
int16_t offset = Debug::ReadWord(pc + 2);
|
||||
address = pc + 2 + offset;
|
||||
break;
|
||||
}
|
||||
|
@ -214,7 +215,7 @@ namespace {
|
|||
{
|
||||
address = Debug::ReadLong(pc + 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 0x4EF9: // jmp address
|
||||
{
|
||||
address = Debug::ReadLong(pc + 2);
|
||||
|
@ -224,14 +225,14 @@ namespace {
|
|||
{
|
||||
// check if address is a jmp address (see above)
|
||||
// and follow it. a5 should never change.
|
||||
int16_t offset = Debug::ReadWord(pc + 2);
|
||||
int16_t offset = Debug::ReadWord(pc + 2);
|
||||
address = cpuGetAReg(5) + offset;
|
||||
|
||||
if (Debug::ReadWord(address) == 0x4EF9)
|
||||
if (Debug::ReadWord(address) == 0x4EF9)
|
||||
address = Debug::ReadLong(address + 2);
|
||||
else address = 0;
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// consider checking branches?
|
||||
|
@ -296,7 +297,7 @@ namespace {
|
|||
{
|
||||
if (!trace) disasm(pc);
|
||||
printf("CPU stopped\n");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sigInt)
|
||||
|
@ -304,7 +305,7 @@ namespace {
|
|||
if (!trace) disasm(pc);
|
||||
printf("^C break\n");
|
||||
sigInt = false;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memBreak)
|
||||
|
@ -376,7 +377,7 @@ namespace {
|
|||
break;
|
||||
case 4:
|
||||
fprintf(stdout, " [%08x]\n", value);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "\n");
|
||||
break;
|
||||
|
@ -606,7 +607,7 @@ void Print(uint32_t data)
|
|||
if (data <= 0xffff)
|
||||
printf(" '%s'", tmp + 2);
|
||||
break;
|
||||
|
||||
|
||||
case 0x08:
|
||||
if (data <= 0xff)
|
||||
printf(" '%s'", tmp + 3);
|
||||
|
@ -689,15 +690,15 @@ void PrintRegisters(const BackTraceInfo &i)
|
|||
{
|
||||
const char *srbits = srBits(i.csr);
|
||||
|
||||
printf(" 0 1 2 3 4 5 6 7\n");
|
||||
printf(" 0 1 2 3 4 5 6 7\n");
|
||||
printf("D: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
i.d[0], i.d[1], i.d[2], i.d[3],
|
||||
i.d[0], i.d[1], i.d[2], i.d[3],
|
||||
i.d[4], i.d[5], i.d[6], i.d[7]
|
||||
|
||||
);
|
||||
|
||||
printf("A: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
i.a[0], i.a[1], i.a[2], i.a[3],
|
||||
i.a[0], i.a[1], i.a[2], i.a[3],
|
||||
i.a[4], i.a[5], i.a[6], i.a[7]
|
||||
);
|
||||
|
||||
|
@ -710,15 +711,15 @@ void PrintRegisters()
|
|||
uint16_t sr = cpuGetSR();
|
||||
const char *srbits = srBits(sr);
|
||||
|
||||
printf(" 0 1 2 3 4 5 6 7\n");
|
||||
printf(" 0 1 2 3 4 5 6 7\n");
|
||||
printf("D: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
cpuGetDReg(0), cpuGetDReg(1), cpuGetDReg(2), cpuGetDReg(3),
|
||||
cpuGetDReg(0), cpuGetDReg(1), cpuGetDReg(2), cpuGetDReg(3),
|
||||
cpuGetDReg(4), cpuGetDReg(5), cpuGetDReg(6), cpuGetDReg(7)
|
||||
|
||||
);
|
||||
|
||||
printf("A: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
cpuGetAReg(0), cpuGetAReg(1), cpuGetAReg(2), cpuGetAReg(3),
|
||||
cpuGetAReg(0), cpuGetAReg(1), cpuGetAReg(2), cpuGetAReg(3),
|
||||
cpuGetAReg(4), cpuGetAReg(5), cpuGetAReg(6), cpuGetAReg(7)
|
||||
);
|
||||
|
||||
|
@ -786,7 +787,7 @@ void PrintBackTrace()
|
|||
disasm(prev->pc);
|
||||
btdiff(*prev, current);
|
||||
|
||||
//
|
||||
//
|
||||
prev = ¤t;
|
||||
}
|
||||
|
||||
|
@ -949,7 +950,7 @@ void Step(const Command &cmd)
|
|||
int count = 0;
|
||||
if (cmd.argc == 1) count = (int)cmd.argv[0];
|
||||
if (count < 1) count = 1;
|
||||
|
||||
|
||||
// TODO -- move to common function...
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
@ -1000,7 +1001,7 @@ void SetXRegister(unsigned reg, uint32_t value)
|
|||
if (value & 0x01)
|
||||
{
|
||||
fprintf(stderr, "Address is not aligned: $%08x\n", value);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (value > Flags.memorySize)
|
||||
{
|
||||
|
@ -1083,7 +1084,7 @@ void Info(uint32_t address)
|
|||
}
|
||||
|
||||
// 4 as an error
|
||||
// almost all are negative 16-bit values,
|
||||
// almost all are negative 16-bit values,
|
||||
// but may also be a positive 16-bit value.
|
||||
uint16_t error = 0;
|
||||
if (address <= 0xffff) error = address;
|
||||
|
@ -1134,6 +1135,8 @@ namespace {
|
|||
{
|
||||
std::string s(text);
|
||||
|
||||
rl_attempted_completion_over = 1; // suppress filename completion if no results.
|
||||
|
||||
// returns iter to first element _not less_ than key
|
||||
// ie, >= key.
|
||||
auto iter = SymbolTable.lower_bound(s);
|
||||
|
@ -1154,7 +1157,7 @@ namespace {
|
|||
auto end = iter;
|
||||
|
||||
if (!count) return NULL;
|
||||
if (count > 100) return NULL;
|
||||
if (count > 100) return NULL;
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
|
@ -1171,7 +1174,7 @@ namespace {
|
|||
auto min_length = begin->first.length();
|
||||
|
||||
// item 0 is the longest match. (fill in later.)
|
||||
buffer[i++] = NULL;
|
||||
buffer[i++] = NULL;
|
||||
for (iter = begin; iter != end; ++iter)
|
||||
{
|
||||
buffer[i++] = strdup(iter->first.c_str());
|
||||
|
@ -1187,7 +1190,7 @@ namespace {
|
|||
|
||||
if (i >= min_length)
|
||||
{
|
||||
buffer[0][i] = 0;
|
||||
buffer[0][i] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1212,19 +1215,11 @@ namespace {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
// this is here to prevent filename tab completion, for now.
|
||||
// state is 0 for first call, non-zero for subsequent calls. It
|
||||
// should return 1 match per invocation, NULL if no more matches.
|
||||
char *mpw_completion_entry_function(const char *text, int state)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void readline_init()
|
||||
{
|
||||
rl_readline_name = (char *)"mpw";
|
||||
rl_attempted_completion_function = mpw_attempted_completion_function;
|
||||
rl_completion_entry_function = (Function *)mpw_completion_entry_function;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1251,13 +1246,13 @@ void Shell()
|
|||
|
||||
// load the error code to error mnemonic
|
||||
ErrorTableInvert.reserve(ErrorTable.size());
|
||||
for (const auto kv : ErrorTable) {
|
||||
for (const auto &kv : ErrorTable) {
|
||||
ErrorTableInvert.emplace(std::make_pair(kv.second, kv.first));
|
||||
}
|
||||
|
||||
// address to function name.
|
||||
SymbolTableInvert.reserve(SymbolTable.size());
|
||||
for (const auto kv : SymbolTable) {
|
||||
for (const auto &kv : SymbolTable) {
|
||||
SymbolTableInvert.emplace(std::make_pair(kv.second.first, kv.first));
|
||||
}
|
||||
|
||||
|
@ -1307,8 +1302,10 @@ void Shell()
|
|||
}
|
||||
}
|
||||
|
||||
// todo -- don't add if same as previous command.
|
||||
add_history(cp);
|
||||
// don't add if same as previous entry.
|
||||
HIST_ENTRY *he = current_history();
|
||||
if (he == nullptr || strcmp(he->line, cp) != 0)
|
||||
add_history(cp);
|
||||
}
|
||||
free(cp);
|
||||
}
|
||||
|
@ -1316,5 +1313,3 @@ void Shell()
|
|||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ struct Token {
|
|||
intValue(0), stringValue(0), subtype(0)
|
||||
{}
|
||||
|
||||
Token(uint32_t i) :
|
||||
Token(uint32_t i) :
|
||||
intValue(i), subtype(0)
|
||||
{}
|
||||
|
||||
Token(std::string *s, unsigned st = 0) :
|
||||
Token(std::string *s, unsigned st = 0) :
|
||||
intValue(0), stringValue(s), subtype(st)
|
||||
{}
|
||||
#endif
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -97,7 +97,7 @@ void code0(uint32_t data_size)
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("$%08X ???\n", pc + 2);
|
||||
printf("$%08X ???\n", pc + 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -208,7 +208,7 @@ void disasm(const char *name, int segment, uint32_t data_size)
|
|||
|
||||
ToolBox(pc, op);
|
||||
pc += 2;
|
||||
prevOP = op;
|
||||
prevOP = op;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -305,4 +305,4 @@ int main(int argc, char **argv)
|
|||
CloseResFile(refNum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "intern.h"
|
||||
#include <unordered_map>
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -12,9 +13,9 @@ namespace {
|
|||
unsigned int hash = 5381;
|
||||
|
||||
for(size_t i = 0; i < length; ++i)
|
||||
{
|
||||
{
|
||||
hash = ((hash << 5) + hash) + (begin[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
@ -45,9 +46,9 @@ namespace Intern {
|
|||
// insert it. I suppose this could throw, in which case a string would leak.
|
||||
std::string *s = new std::string(std::move(str));
|
||||
InternTable.emplace(std::make_pair(hash, s));
|
||||
return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
const std::string *String(const char *begin, size_t size)
|
||||
{
|
||||
if (!size) return &EmptyString;
|
||||
|
@ -95,7 +96,3 @@ namespace Intern {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,4 +11,4 @@ namespace Intern {
|
|||
const std::string *String(const char *, const char *);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
// hd / hexdump expression [:expression]
|
||||
// stack ?
|
||||
// brk expression
|
||||
// tbrk expression
|
||||
// tbrk expression
|
||||
namespace {
|
||||
int tox(char c)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace {
|
|||
|
||||
uint32_t scan10(const char *begin, const char *end)
|
||||
{
|
||||
return std::accumulate(begin, end, 0,
|
||||
return std::accumulate(begin, end, 0,
|
||||
[](uint32_t value, char c){
|
||||
return value * 10 + c - '0';
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ namespace {
|
|||
|
||||
uint32_t scan16(const char *begin, const char *end)
|
||||
{
|
||||
return std::accumulate(begin, end, 0,
|
||||
return std::accumulate(begin, end, 0,
|
||||
[](uint32_t value, char c){
|
||||
return (value << 4) + tox(c);
|
||||
});
|
||||
|
@ -237,7 +237,7 @@ bool ParseLine(const char *iter, Command *command)
|
|||
|
||||
'tbrk' | 'tbreak' | 'toolbreak' {
|
||||
Parse(parser, tkTBREAK, 0, command);
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
'mbrk' | 'mbreak' | 'rwbrk' | 'rwbreak' {
|
||||
|
@ -265,7 +265,7 @@ bool ParseLine(const char *iter, Command *command)
|
|||
Parse(parser, tkPRINT, 0, command);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
'r' | 'run' {
|
||||
Parse(parser, tkCONTINUE, 0, command);
|
||||
continue;
|
||||
|
@ -324,4 +324,3 @@ bool ParseLine(const char *iter, Command *command)
|
|||
|
||||
|
||||
} // namespace Debugger
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <deque>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "debugger.h"
|
||||
|
@ -368,7 +369,7 @@ bool ParseLine(const char *iter, Command *command)
|
|||
//ParseTrace(stdout, "--> ");
|
||||
command->action = cmdNull;
|
||||
|
||||
int length = strlen(iter);
|
||||
int length = std::strlen(iter);
|
||||
const char *p = iter;
|
||||
const char *pe = iter + length;
|
||||
const char *eof = pe;
|
||||
|
@ -431,4 +432,4 @@ bool ParseLine(const char *iter, Command *command)
|
|||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -121,7 +121,7 @@ void reloc1(const uint8_t *r, uint32_t address, uint32_t offset)
|
|||
// %0xxxxxxx -> 7-bit value
|
||||
// %1xxxxxxx xxxxxxxx -> 15-bit value
|
||||
// %00000000 1xxxxxxx x{8} x{8} x{8} -> 31 bit value
|
||||
// ^ that's what the documentation says..
|
||||
// ^ that's what the documentation says..
|
||||
// that's how the 32-bit bootstrap works
|
||||
// DumpCode ignores the high 2 bytes.
|
||||
for(;;)
|
||||
|
@ -302,7 +302,7 @@ uint32_t load(const char *file)
|
|||
}
|
||||
|
||||
ReleaseResource(h);
|
||||
}
|
||||
}
|
||||
|
||||
// now link the segment 0 jump table...
|
||||
assert(a5);
|
||||
|
@ -392,11 +392,15 @@ void GlobalInit()
|
|||
// 0x0a06 - MinusOne
|
||||
memoryWriteLong(0xffffffff, MacOS::MinusOne);
|
||||
|
||||
|
||||
|
||||
// 0x0130 -- ApplLimit
|
||||
memoryWriteLong(Flags.memorySize - Flags.stackSize - 1, MacOS::ApplLimit);
|
||||
memoryWriteLong(kGlobalSize, MacOS::ApplZone);
|
||||
memoryWriteLong(Flags.memorySize - 1, MacOS::BufPtr);
|
||||
|
||||
//
|
||||
memoryWriteLong(Flags.stackRange.first, MacOS::CurStackBase);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -562,7 +566,7 @@ void MemoryLogger(uint32_t address, int size, int readWrite, uint32_t value)
|
|||
break;
|
||||
case 4:
|
||||
fprintf(stderr, " [%08x]\n", value);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "\n");
|
||||
break;
|
||||
|
@ -579,7 +583,7 @@ void MidInstructionExceptionFunc()
|
|||
}
|
||||
|
||||
|
||||
#define MPW_VERSION "0.8.0"
|
||||
#define MPW_VERSION "0.8.3"
|
||||
void help()
|
||||
{
|
||||
printf("MPW " MPW_VERSION "\n");
|
||||
|
@ -620,11 +624,11 @@ bool parse_number(const char *input, uint32_t *dest)
|
|||
if (*end)
|
||||
{
|
||||
int old = value;
|
||||
if (strcasecmp(end, "M") == 0)
|
||||
if (strcasecmp(end, "M") == 0 || strcasecmp(end, "MB") == 0)
|
||||
value *= 1024 * 1024;
|
||||
else if (strcasecmp(end, "K") == 0)
|
||||
else if (strcasecmp(end, "K") == 0 || strcasecmp(end, "KB") == 0)
|
||||
value *= 1024;
|
||||
else
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s - invalid input\n", input);
|
||||
return false;
|
||||
|
@ -687,7 +691,6 @@ std::string find_exe(const std::string &name)
|
|||
return "";
|
||||
}
|
||||
|
||||
|
||||
// otherwise, check the Commands variable for locations.
|
||||
std::string commands = MPW::GetEnv("Commands");
|
||||
if (commands.empty()) return old_find_exe(name);
|
||||
|
@ -748,7 +751,7 @@ void MainLoop()
|
|||
|
||||
if (cpuGetStop()) break; // will this also be set by an interrupt?
|
||||
|
||||
|
||||
|
||||
#ifndef CPU_INSTRUCTION_LOGGING
|
||||
if (Flags.traceCPU || Flags.traceMacsbug)
|
||||
{
|
||||
|
@ -781,8 +784,9 @@ int main(int argc, char **argv)
|
|||
kTraceMPW,
|
||||
kDebugger,
|
||||
kMemoryStats,
|
||||
kShell,
|
||||
};
|
||||
static struct option LongOpts[] =
|
||||
static struct option LongOpts[] =
|
||||
{
|
||||
{ "ram",required_argument, NULL, 'r' },
|
||||
{ "stack", required_argument, NULL, 's' },
|
||||
|
@ -801,6 +805,7 @@ int main(int argc, char **argv)
|
|||
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ "shell", no_argument, NULL, kShell },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -832,7 +837,7 @@ int main(int argc, char **argv)
|
|||
case kTraceMPW:
|
||||
Flags.traceMPW = true;
|
||||
break;
|
||||
|
||||
|
||||
case kMemoryStats:
|
||||
Flags.memoryStats = true;
|
||||
break;
|
||||
|
@ -841,6 +846,9 @@ int main(int argc, char **argv)
|
|||
Flags.debugger = true;
|
||||
break;
|
||||
|
||||
case kShell:
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (!parse_number(optarg, &Flags.machine))
|
||||
exit(EX_CONFIG);
|
||||
|
@ -938,6 +946,7 @@ int main(int argc, char **argv)
|
|||
|
||||
MM::Init(Memory, MemorySize, kGlobalSize, Flags.stackSize);
|
||||
OS::Init();
|
||||
ToolBox::Init();
|
||||
MPW::Init(argc, argv);
|
||||
|
||||
|
||||
|
@ -948,10 +957,19 @@ int main(int argc, char **argv)
|
|||
|
||||
#ifdef LOADER_LOAD
|
||||
uint16_t err = Loader::Native::LoadFile(command);
|
||||
if (err) exit(EX_CONFIG);
|
||||
if (err) {
|
||||
const char *cp = ErrorName(err);
|
||||
fprintf(stderr, "Unable to load command %s: ", command.c_str());
|
||||
if (cp) printf("%s\n", cp);
|
||||
else printf("%hd\n", err);
|
||||
exit(EX_SOFTWARE);
|
||||
}
|
||||
#else
|
||||
uint32_t address = load(command.c_str());
|
||||
if (!address) exit(EX_CONFIG);
|
||||
if (!address) {
|
||||
fprintf(stderr, "Unable to load command %s\n", command.c_str());
|
||||
exit(EX_SOFTWARE);
|
||||
}
|
||||
#endif
|
||||
GlobalInit();
|
||||
|
||||
|
@ -968,7 +986,7 @@ int main(int argc, char **argv)
|
|||
MPW::Trace = Flags.traceMPW;
|
||||
ToolBox::Trace = Flags.traceToolBox;
|
||||
|
||||
|
||||
|
||||
if (Flags.traceCPU || Flags.traceMacsbug)
|
||||
{
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
|
@ -995,6 +1013,6 @@ int main(int argc, char **argv)
|
|||
if (rv > 0xff) rv = 0xff;
|
||||
|
||||
|
||||
|
||||
|
||||
exit(rv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,86 @@
|
|||
#include <string>
|
||||
#include <cstdio>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace _loadtrap_rl {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
|
||||
#define _GETDELIM_MINLEN 4 /* minimum line buffer size */
|
||||
|
||||
ssize_t getdelim(char ** lineptr, size_t * n, int delimiter, FILE * stream) {
|
||||
char *buf, *pos;
|
||||
int c;
|
||||
ssize_t bytes;
|
||||
|
||||
if (lineptr == NULL || n == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (stream == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* resize (or allocate) the line buffer if necessary */
|
||||
buf = *lineptr;
|
||||
if (buf == NULL || *n < _GETDELIM_MINLEN) {
|
||||
buf = (char*)realloc(*lineptr, _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n = _GETDELIM_GROWBY;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
/* read characters until delimiter is found, end of file is reached, or an
|
||||
error occurs. */
|
||||
bytes = 0;
|
||||
pos = buf;
|
||||
while ((c = getc(stream)) != EOF) {
|
||||
if (bytes + 1 >= SSIZE_MAX) {
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
bytes++;
|
||||
if (bytes >= *n - 1) {
|
||||
buf = (char*)realloc(*lineptr, *n + _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n += _GETDELIM_GROWBY;
|
||||
pos = buf + bytes - 1;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
*pos++ = (char) c;
|
||||
if (c == delimiter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stream) || (feof(stream) && (bytes == 0))) {
|
||||
/* EOF, or an error from getc(). */
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pos = '\0';
|
||||
return bytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ssize_t getline(char ** lineptr, size_t * n, FILE * stream) {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
return getdelim(lineptr, n, '\n', stream);
|
||||
#else
|
||||
return ::getline(lineptr, n, stream);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
namespace {
|
||||
// private...
|
||||
%%{
|
||||
|
@ -155,7 +235,7 @@ namespace Debug {
|
|||
char *line;
|
||||
ssize_t length;
|
||||
|
||||
length = getline(&lineBuffer, &lineSize, fp);
|
||||
length = _loadtrap_rl::getline(&lineBuffer, &lineSize, fp);
|
||||
if (!length) continue; //?
|
||||
if (length < 0) break; // eof or error.
|
||||
|
||||
|
@ -216,4 +296,3 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,51 @@
|
|||
#define tkPIPEPIPE 1
|
||||
#define tkAMPAMP 2
|
||||
#define tkPIPE 3
|
||||
#define tkCARET 4
|
||||
#define tkAMP 5
|
||||
#define tkEQEQ 6
|
||||
#define tkBANGEQ 7
|
||||
#define tkLT 8
|
||||
#define tkLTEQ 9
|
||||
#define tkGT 10
|
||||
#define tkGTEQ 11
|
||||
#define tkLTLT 12
|
||||
#define tkGTGT 13
|
||||
#define tkPLUS 14
|
||||
#define tkMINUS 15
|
||||
#define tkSTAR 16
|
||||
#define tkSLASH 17
|
||||
#define tkPERCENT 18
|
||||
#define tkBANG 19
|
||||
#define tkTILDE 20
|
||||
#define tkEOL 21
|
||||
#define tkPRINT 22
|
||||
#define tkBREAK 23
|
||||
#define tkBACKTRACE 24
|
||||
#define tkCONTINUE 25
|
||||
#define tkTBREAK 26
|
||||
#define tkRBREAK 27
|
||||
#define tkWBREAK 28
|
||||
#define tkRWBREAK 29
|
||||
#define tkNEXT 30
|
||||
#define tkDUMP 31
|
||||
#define tkCOLON 32
|
||||
#define tkAT 33
|
||||
#define tkLIST 34
|
||||
#define tkSTACKCRAWL 35
|
||||
#define tkSEMI 36
|
||||
#define tkSEMIH 37
|
||||
#define tkSEMII 38
|
||||
#define tkSEMIL 39
|
||||
#define tkSEMIDATE 40
|
||||
#define tkSEMIERROR 41
|
||||
#define tkSEMIT 42
|
||||
#define tkIDENTIFIER 43
|
||||
#define tkDREGISTER 44
|
||||
#define tkEQ 45
|
||||
#define tkAREGISTER 46
|
||||
#define tkXREGISTER 47
|
||||
#define tkHELP 48
|
||||
#define tkLPAREN 49
|
||||
#define tkRPAREN 50
|
||||
#define tkINTEGER 51
|
|
@ -8,9 +8,10 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include "debugger.h"
|
||||
|
||||
#include <toolbox/MM.h>
|
||||
#include <toolbox/mm.h>
|
||||
|
||||
using Debug::Token;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "debugger_internal.h"
|
||||
#include "loader.h" // Flags.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <toolbox/toolbox.h>
|
||||
|
||||
|
||||
|
@ -81,7 +83,7 @@ namespace Debug {
|
|||
if (iter != Types.end())
|
||||
{
|
||||
if (iter->second == type) return; // ok, just a duplicate.
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
|
||||
return;
|
||||
|
@ -89,13 +91,13 @@ namespace Debug {
|
|||
|
||||
if (Templates.find(*name) != Templates.end())
|
||||
{
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
Types.emplace(std::make_pair(*name, type));
|
||||
Types.emplace(std::make_pair(*name, type));
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,16 +110,16 @@ namespace Debug {
|
|||
|
||||
if (Templates.find(*name) != Templates.end())
|
||||
{
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Types.find(*name) != Types.end())
|
||||
{
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
firstField = Reverse(firstField);
|
||||
|
@ -133,10 +135,10 @@ namespace Debug {
|
|||
return isprint(c) ? c : '.';
|
||||
});
|
||||
|
||||
if (s.size() > 40) {
|
||||
s.resize(37);
|
||||
if (s.size() > 40) {
|
||||
s.resize(37);
|
||||
s.append("...");
|
||||
}
|
||||
}
|
||||
}
|
||||
void PrettyPrint(uint32_t value, unsigned type)
|
||||
{
|
||||
|
@ -210,8 +212,8 @@ namespace Debug {
|
|||
unsigned s = (type & 0x0f00) >> 8;
|
||||
|
||||
for (unsigned i = 0; i < indent; ++i) fputc('>',stdout);
|
||||
fputs(e->name->c_str(),stdout);
|
||||
for(unsigned i = indent + e->name->length(); i < 40; ++i) fputc(' ',stdout);
|
||||
printf("%08x %s", address + offset, e->name->c_str());
|
||||
for(unsigned i = indent + e->name->length(); i < 32; ++i) fputc(' ',stdout);
|
||||
|
||||
// todo -- support arrays
|
||||
// todo -- pretty print values (boolean, oserr, ostype, etc.)
|
||||
|
@ -222,7 +224,7 @@ namespace Debug {
|
|||
uint8_t value = ReadByte(address + offset);
|
||||
printf(" %02x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
|
@ -230,7 +232,7 @@ namespace Debug {
|
|||
uint16_t value = ReadWord(address + offset);
|
||||
printf(" %04x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
|
@ -238,12 +240,12 @@ namespace Debug {
|
|||
uint32_t value = ReadLong(address + offset);
|
||||
printf("%08x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0:
|
||||
// either a pointer or a struct
|
||||
if (type & 0x8000) {
|
||||
if (type & 0x8000) {
|
||||
// pointer.
|
||||
uint32_t value = ReadLong(address + offset);
|
||||
printf("%08x", value);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
@ -251,4 +252,4 @@ bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::strin
|
|||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
|||
#define tkTYPEDEF 1
|
||||
#define tkIDENTIFIER 2
|
||||
#define tkSTRUCT 3
|
||||
#define tkLBRACE 4
|
||||
#define tkRBRACE 5
|
||||
#define tkSEMI 6
|
||||
#define tkTEMPLATE 7
|
||||
#define tkLBRACKET 8
|
||||
#define tkINTEGER 9
|
||||
#define tkRBRACKET 10
|
||||
#define tkVOLATILE 11
|
||||
#define tkSIGNED 12
|
||||
#define tkUNSIGNED 13
|
||||
#define tkCHAR 14
|
||||
#define tkSHORT 15
|
||||
#define tkLONG 16
|
||||
#define tkTYPECODE 17
|
||||
#define tkVOID 18
|
||||
#define tkSTAR 19
|
||||
#define tkINT 20
|
|
@ -8,6 +8,7 @@
|
|||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "template.h"
|
||||
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
# Clang or AppleClang
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wno-unused-function")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS " -Wall -Wno-unused-function -g")
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
# Clang or AppleClang
|
||||
set(CMAKE_C_FLAGS "-Wall -Wno-unused-function")
|
||||
endif()
|
||||
|
||||
set(CPU_SRC
|
||||
CpuModule.c
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/* @(#) $Id: CpuIntegration.c,v 1.10 2013-01-08 19:17:33 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* Initialization of 68000 core */
|
||||
/* Integrates the 68k emulation with custom chips */
|
||||
/* Integrates the 68k emulation with custom chips */
|
||||
/* */
|
||||
/* Author: Petter Schau */
|
||||
/* */
|
||||
|
@ -34,47 +33,47 @@
|
|||
#include "interrupt.h"
|
||||
|
||||
jmp_buf cpu_integration_exception_buffer;
|
||||
ULO cpu_integration_chip_interrupt_number;
|
||||
uint32_t cpu_integration_chip_interrupt_number;
|
||||
|
||||
/* Cycles spent by chips (Blitter) as a result of an instruction */
|
||||
static ULO cpu_integration_chip_cycles;
|
||||
static ULO cpu_integration_chip_slowdown;
|
||||
static uint32_t cpu_integration_chip_cycles;
|
||||
static uint32_t cpu_integration_chip_slowdown;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* CPU properties */
|
||||
/*===========================================================================*/
|
||||
|
||||
ULO cpu_integration_speed; // The speed as expressed in the fellow configuration settings
|
||||
ULO cpu_integration_speed_multiplier; // The cycle multiplier used to adjust the cpu-speed, calculated from cpu_integration_speed
|
||||
uint32_t cpu_integration_speed; // The speed as expressed in the fellow configuration settings
|
||||
uint32_t cpu_integration_speed_multiplier; // The cycle multiplier used to adjust the cpu-speed, calculated from cpu_integration_speed
|
||||
cpu_integration_models cpu_integration_model; // The cpu model as expressed in the fellow configuration settings
|
||||
|
||||
/*===========================================================================*/
|
||||
/* CPU properties */
|
||||
/*===========================================================================*/
|
||||
|
||||
void cpuIntegrationSetSpeed(ULO speed)
|
||||
void cpuIntegrationSetSpeed(uint32_t speed)
|
||||
{
|
||||
cpu_integration_speed = speed;
|
||||
}
|
||||
|
||||
ULO cpuIntegrationGetSpeed(void)
|
||||
uint32_t cpuIntegrationGetSpeed(void)
|
||||
{
|
||||
return cpu_integration_speed;
|
||||
}
|
||||
|
||||
static void cpuIntegrationSetSpeedMultiplier(ULO multiplier)
|
||||
static void cpuIntegrationSetSpeedMultiplier(uint32_t multiplier)
|
||||
{
|
||||
cpu_integration_speed_multiplier = multiplier;
|
||||
}
|
||||
|
||||
static ULO cpuIntegrationGetSpeedMultiplier(void)
|
||||
static uint32_t cpuIntegrationGetSpeedMultiplier(void)
|
||||
{
|
||||
return cpu_integration_speed_multiplier;
|
||||
}
|
||||
|
||||
void cpuIntegrationCalculateMultiplier(void)
|
||||
{
|
||||
ULO multiplier = 12;
|
||||
uint32_t multiplier = 12;
|
||||
|
||||
switch (cpuGetModelMajor())
|
||||
{
|
||||
|
@ -121,39 +120,39 @@ cpu_integration_models cpuIntegrationGetModel(void)
|
|||
return cpu_integration_model;
|
||||
}
|
||||
|
||||
void cpuIntegrationSetChipCycles(ULO chip_cycles)
|
||||
void cpuIntegrationSetChipCycles(uint32_t chip_cycles)
|
||||
{
|
||||
cpu_integration_chip_cycles = chip_cycles;
|
||||
}
|
||||
|
||||
ULO cpuIntegrationGetChipCycles(void)
|
||||
uint32_t cpuIntegrationGetChipCycles(void)
|
||||
{
|
||||
return cpu_integration_chip_cycles;
|
||||
}
|
||||
|
||||
void cpuIntegrationSetChipSlowdown(ULO chip_slowdown)
|
||||
void cpuIntegrationSetChipSlowdown(uint32_t chip_slowdown)
|
||||
{
|
||||
cpu_integration_chip_slowdown = chip_slowdown;
|
||||
}
|
||||
|
||||
ULO cpuIntegrationGetChipSlowdown(void)
|
||||
uint32_t cpuIntegrationGetChipSlowdown(void)
|
||||
{
|
||||
return cpu_integration_chip_slowdown;
|
||||
}
|
||||
|
||||
void cpuIntegrationSetChipInterruptNumber(ULO chip_interrupt_number)
|
||||
void cpuIntegrationSetChipInterruptNumber(uint32_t chip_interrupt_number)
|
||||
{
|
||||
cpu_integration_chip_interrupt_number = chip_interrupt_number;
|
||||
}
|
||||
|
||||
ULO cpuIntegrationGetChipInterruptNumber(void)
|
||||
uint32_t cpuIntegrationGetChipInterruptNumber(void)
|
||||
{
|
||||
return cpu_integration_chip_interrupt_number;
|
||||
}
|
||||
|
||||
// A wrapper for cpuSetIrqLevel that restarts the
|
||||
// scheduling of cpu events if the cpu was stoppped
|
||||
void cpuIntegrationSetIrqLevel(ULO new_interrupt_level, ULO chip_interrupt_number)
|
||||
void cpuIntegrationSetIrqLevel(uint32_t new_interrupt_level, uint32_t chip_interrupt_number)
|
||||
{
|
||||
if (cpuSetIrqLevel(new_interrupt_level))
|
||||
{
|
||||
|
@ -241,7 +240,7 @@ void cpuIntegrationInstructionLogging(void)
|
|||
fprintf(CPUINSTRUCTIONLOG, "SSP:%.6X USP:%.6X SP:%.4X %s %s\t%s\t%s\n", cpuGetSspDirect(), cpuGetUspDirect(), cpuGetSR(), saddress, sdata, sinstruction, soperands);
|
||||
}
|
||||
|
||||
void cpuIntegrationExceptionLogging(STR *description, ULO original_pc, UWO opcode)
|
||||
void cpuIntegrationExceptionLogging(char *description, uint32_t original_pc, uint16_t opcode)
|
||||
{
|
||||
if (cpu_disable_instruction_log) return;
|
||||
cpuInstructionLogOpen();
|
||||
|
@ -250,7 +249,7 @@ void cpuIntegrationExceptionLogging(STR *description, ULO original_pc, UWO opcod
|
|||
fprintf(CPUINSTRUCTIONLOG, "%s for opcode %.4X at PC %.8X from PC %.8X\n", description, opcode, original_pc, cpuGetPC());
|
||||
}
|
||||
|
||||
void cpuIntegrationInterruptLogging(ULO level, ULO vector_address)
|
||||
void cpuIntegrationInterruptLogging(uint32_t level, uint32_t vector_address)
|
||||
{
|
||||
if (cpu_disable_instruction_log) return;
|
||||
cpuInstructionLogOpen();
|
||||
|
@ -263,8 +262,7 @@ void cpuIntegrationInterruptLogging(ULO level, ULO vector_address)
|
|||
|
||||
void cpuIntegrationExecuteInstructionEventHandler68000Fast(void)
|
||||
{
|
||||
ULO cycles;
|
||||
cycles = cpuExecuteInstruction();
|
||||
uint32_t cycles = cpuExecuteInstruction();
|
||||
|
||||
if (cpuGetStop())
|
||||
{
|
||||
|
@ -279,8 +277,8 @@ void cpuIntegrationExecuteInstructionEventHandler68000Fast(void)
|
|||
|
||||
void cpuIntegrationExecuteInstructionEventHandler68000General(void)
|
||||
{
|
||||
ULO cycles = 0;
|
||||
ULO time_used = 0;
|
||||
uint32_t cycles = 0;
|
||||
uint32_t time_used = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -303,7 +301,7 @@ void cpuIntegrationExecuteInstructionEventHandler68000General(void)
|
|||
|
||||
void cpuIntegrationExecuteInstructionEventHandler68020(void)
|
||||
{
|
||||
ULO time_used = 0;
|
||||
uint32_t time_used = 0;
|
||||
do
|
||||
{
|
||||
cpuExecuteInstruction();
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#ifndef CpuIntegration_H
|
||||
#define CpuIntegration_H
|
||||
|
||||
#include <setjmp.h>
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -16,25 +13,25 @@ typedef enum {
|
|||
M68EC20 = 9
|
||||
} cpu_integration_models;
|
||||
|
||||
extern void cpuIntegrationSetUpInterruptEventHandler(void);
|
||||
extern void cpuIntegrationCalculateMultiplier(void);
|
||||
|
||||
extern void cpuIntegrationExecuteInstructionEventHandler68000Fast(void);
|
||||
extern void cpuIntegrationExecuteInstructionEventHandler68000General(void);
|
||||
extern void cpuIntegrationExecuteInstructionEventHandler68020(void);
|
||||
extern void cpuIntegrationCheckPendingInterrupts(void);
|
||||
extern ULO cpuIntegrationDisOpcode(ULO disasm_pc, STR *saddress, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern uint32_t cpuIntegrationDisOpcode(uint32_t disasm_pc, char *saddress, char *sdata, char *sinstruction, char *soperands);
|
||||
|
||||
extern BOOLE cpuIntegrationSetModel(cpu_integration_models model);
|
||||
extern cpu_integration_models cpuIntegrationGetModel(void);
|
||||
extern ULO cpuIntegrationGetModelMajor(void);
|
||||
extern ULO cpuIntegrationGetPC(void);
|
||||
extern uint32_t cpuIntegrationGetModelMajor(void);
|
||||
|
||||
extern ULO cpuIntegrationGetInstructionTime(void);
|
||||
extern void cpuIntegrationSetSpeed(ULO speed);
|
||||
extern ULO cpuIntegrationGetSpeed(void);
|
||||
extern void cpuIntegrationSetChipCycles(ULO chip_cycles);
|
||||
extern ULO cpuIntegrationGetChipCycles(void);
|
||||
extern void cpuIntegrationSetChipSlowdown(ULO chip_slowdown);
|
||||
extern ULO cpuIntegrationGetChipSlowdown(void);
|
||||
void cpuIntegrationSetIrqLevel(uint32_t new_interrupt_level, uint32_t chip_interrupt_number);
|
||||
extern uint32_t cpuIntegrationGetInstructionTime(void);
|
||||
extern void cpuIntegrationSetSpeed(uint32_t speed);
|
||||
extern uint32_t cpuIntegrationGetSpeed(void);
|
||||
extern void cpuIntegrationSetChipCycles(uint32_t chip_cycles);
|
||||
extern uint32_t cpuIntegrationGetChipCycles(void);
|
||||
extern void cpuIntegrationSetChipSlowdown(uint32_t chip_slowdown);
|
||||
extern uint32_t cpuIntegrationGetChipSlowdown(void);
|
||||
|
||||
extern jmp_buf cpu_integration_exception_buffer;
|
||||
|
||||
|
@ -50,5 +47,3 @@ extern void cpuIntegrationShutdown(void);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule.c,v 1.7 2012-08-12 16:51:02 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* Initialization of 68000 core */
|
||||
|
@ -24,16 +23,13 @@
|
|||
|
||||
#include "defs.h"
|
||||
#include "CpuModule.h"
|
||||
#include "fellow.h"
|
||||
#include "fmem.h"
|
||||
#include "CpuModule_Memory.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
void cpuClearEverything(void)
|
||||
{
|
||||
ULO i,j;
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
for (i = 0; i < 8; i++)
|
||||
for (uint32_t j = 0; j < 2; j++)
|
||||
for (uint32_t i = 0; i < 8; i++)
|
||||
cpuSetReg(j, i, 0);
|
||||
|
||||
cpuSetUspDirect(0);
|
||||
|
@ -48,7 +44,6 @@ void cpuClearEverything(void)
|
|||
cpuSetSfc(0);
|
||||
cpuSetDfc(0);
|
||||
cpuSetIrqLevel(0);
|
||||
cpuSetRaiseInterrupt(FALSE);
|
||||
cpuSetStop(FALSE);
|
||||
cpuSetInstructionTime(0);
|
||||
cpuSetOriginalPC(0);
|
||||
|
|
102
cpu/CpuModule.h
102
cpu/CpuModule.h
|
@ -1,90 +1,88 @@
|
|||
#ifndef CpuModule_H
|
||||
#define CpuModule_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// This header file defines the internal interfaces of the CPU module.
|
||||
|
||||
// MPW additions.
|
||||
typedef void (*cpuLineExceptionFunc)(uint16_t);
|
||||
extern void cpuSetALineExceptionFunc(cpuLineExceptionFunc func);
|
||||
extern void cpuSetFLineExceptionFunc(cpuLineExceptionFunc func);
|
||||
|
||||
// This header file defines the internal interfaces of the CPU module.
|
||||
|
||||
//#define CPU_INSTRUCTION_LOGGING
|
||||
|
||||
// Function to check if there are any external interrupt sources wanting to issue interrupts
|
||||
typedef BOOLE (*cpuCheckPendingInterruptsFunc)(void);
|
||||
extern void cpuSetCheckPendingInterruptsFunc(cpuCheckPendingInterruptsFunc func);
|
||||
extern void cpuCheckPendingInterrupts(void);
|
||||
void cpuSetUpInterrupt(ULO new_interrupt_level);
|
||||
extern void cpuInitializeFromNewPC(ULO new_pc);
|
||||
|
||||
|
||||
typedef void (*memoryLoggingFunc)(uint32_t address, int size, int readWrite, uint32_t value);
|
||||
extern void memorySetLoggingFunc(memoryLoggingFunc func);
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define CPU_INSTRUCTION_LOGGING
|
||||
#endif
|
||||
|
||||
// Function to check if there are any external interrupt sources wanting to issue interrupts
|
||||
typedef void (*cpuCheckPendingInterruptsFunc)(void);
|
||||
extern void cpuSetCheckPendingInterruptsFunc(cpuCheckPendingInterruptsFunc func);
|
||||
extern void cpuCheckPendingInterrupts(void);
|
||||
extern void cpuSetUpInterrupt(uint32_t new_interrupt_level);
|
||||
extern void cpuInitializeFromNewPC(uint32_t new_pc);
|
||||
|
||||
// Logging interface
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
|
||||
typedef void (*cpuInstructionLoggingFunc)(void);
|
||||
extern void cpuSetInstructionLoggingFunc(cpuInstructionLoggingFunc func);
|
||||
typedef void (*cpuExceptionLoggingFunc)(STR *description, ULO original_pc, UWO opcode);
|
||||
typedef void (*cpuExceptionLoggingFunc)(char *description, uint32_t original_pc, uint16_t opcode);
|
||||
extern void cpuSetExceptionLoggingFunc(cpuExceptionLoggingFunc func);
|
||||
typedef void (*cpuInterruptLoggingFunc)(ULO level, ULO vector_address);
|
||||
typedef void (*cpuInterruptLoggingFunc)(uint32_t level, uint32_t vector_address);
|
||||
extern void cpuSetInterruptLoggingFunc(cpuInterruptLoggingFunc func);
|
||||
|
||||
#endif
|
||||
|
||||
// CPU register and control properties
|
||||
extern void cpuSetPC(ULO pc);
|
||||
extern ULO cpuGetPC(void);
|
||||
extern void cpuSetPC(uint32_t pc);
|
||||
extern uint32_t cpuGetPC(void);
|
||||
|
||||
extern void cpuSetReg(ULO da, ULO i, ULO value);
|
||||
extern ULO cpuGetReg(ULO da, ULO i);
|
||||
extern void cpuSetReg(uint32_t da, uint32_t i, uint32_t value);
|
||||
extern uint32_t cpuGetReg(uint32_t da, uint32_t i);
|
||||
|
||||
extern void cpuSetDReg(ULO i, ULO value);
|
||||
extern ULO cpuGetDReg(ULO i);
|
||||
extern void cpuSetDReg(uint32_t i, uint32_t value);
|
||||
extern uint32_t cpuGetDReg(uint32_t i);
|
||||
|
||||
extern void cpuSetAReg(ULO i, ULO value);
|
||||
extern ULO cpuGetAReg(ULO i);
|
||||
extern void cpuSetAReg(uint32_t i, uint32_t value);
|
||||
extern uint32_t cpuGetAReg(uint32_t i);
|
||||
|
||||
extern void cpuSetSR(ULO sr);
|
||||
extern ULO cpuGetSR(void);
|
||||
extern void cpuSetSR(uint32_t sr);
|
||||
extern uint32_t cpuGetSR(void);
|
||||
|
||||
extern void cpuSetUspDirect(ULO usp);
|
||||
extern ULO cpuGetUspDirect(void);
|
||||
extern ULO cpuGetUspAutoMap(void);
|
||||
extern void cpuSetUspDirect(uint32_t usp);
|
||||
extern uint32_t cpuGetUspDirect(void);
|
||||
extern uint32_t cpuGetUspAutoMap(void);
|
||||
|
||||
extern void cpuSetMspDirect(ULO msp);
|
||||
extern ULO cpuGetMspDirect(void);
|
||||
extern void cpuSetMspDirect(uint32_t msp);
|
||||
extern uint32_t cpuGetMspDirect(void);
|
||||
|
||||
extern void cpuSetSspDirect(ULO ssp);
|
||||
extern ULO cpuGetSspDirect(void);
|
||||
extern ULO cpuGetSspAutoMap(void);
|
||||
extern void cpuSetSspDirect(uint32_t ssp);
|
||||
extern uint32_t cpuGetSspDirect(void);
|
||||
extern uint32_t cpuGetSspAutoMap(void);
|
||||
|
||||
extern ULO cpuGetVbr(void);
|
||||
extern uint32_t cpuGetVbr(void);
|
||||
|
||||
extern void cpuSetStop(BOOLE stop);
|
||||
extern BOOLE cpuGetStop(void);
|
||||
|
||||
extern void cpuSetInitialPC(ULO pc);
|
||||
extern ULO cpuGetInitialPC(void);
|
||||
extern void cpuSetInitialPC(uint32_t pc);
|
||||
extern uint32_t cpuGetInitialPC(void);
|
||||
|
||||
extern void cpuSetInitialSP(ULO sp);
|
||||
extern ULO cpuGetInitialSP(void);
|
||||
extern void cpuSetInitialSP(uint32_t sp);
|
||||
extern uint32_t cpuGetInitialSP(void);
|
||||
|
||||
extern ULO cpuGetInstructionTime(void);
|
||||
extern uint32_t cpuGetInstructionTime(void);
|
||||
|
||||
extern BOOLE cpuSetIrqLevel(ULO new_interrupt_level);
|
||||
extern ULO cpuGetIrqLevel(void);
|
||||
extern BOOLE cpuSetIrqLevel(uint32_t irq_level);
|
||||
extern uint32_t cpuGetIrqLevel(void);
|
||||
|
||||
extern void cpuSetIrqAddress(ULO irq_address);
|
||||
extern ULO cpuGetIrqAddress(void);
|
||||
|
||||
extern ULO cpuExecuteInstruction(void);
|
||||
extern ULO cpuDisOpcode(ULO disasm_pc, STR *saddress, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern uint32_t cpuExecuteInstruction(void);
|
||||
extern uint32_t cpuDisOpcode(uint32_t disasm_pc, char *saddress, char *sdata, char *sinstruction, char *soperands);
|
||||
|
||||
extern void cpuSaveState(FILE *F);
|
||||
extern void cpuLoadState(FILE *F);
|
||||
|
@ -99,12 +97,10 @@ typedef void (*cpuResetExceptionFunc)(void);
|
|||
extern void cpuSetResetExceptionFunc(cpuResetExceptionFunc func);
|
||||
|
||||
// Configuration settings
|
||||
extern void cpuSetModel(ULO major, ULO minor);
|
||||
extern ULO cpuGetModelMajor(void);
|
||||
extern ULO cpuGetModelMinor(void);
|
||||
extern void cpuSetModel(uint32_t major, uint32_t minor);
|
||||
extern uint32_t cpuGetModelMajor(void);
|
||||
extern uint32_t cpuGetModelMinor(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
10646
cpu/CpuModule_Code.h
10646
cpu/CpuModule_Code.h
File diff suppressed because it is too large
Load Diff
2609
cpu/CpuModule_Data.h
2609
cpu/CpuModule_Data.h
File diff suppressed because it is too large
Load Diff
3358
cpu/CpuModule_Decl.h
3358
cpu/CpuModule_Decl.h
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,105 +1,102 @@
|
|||
#ifndef CPUMODULE_DISASSEMBLER_H
|
||||
#define CPUMODULE_DISASSEMBLER_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ULO cpuDisOpcode(ULO disasm_pc, STR *saddress, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern uint32_t cpuDisOpcode(uint32_t disasm_pc, char *saddress, char *sdata, char *sinstruction, char *soperands);
|
||||
|
||||
extern ULO cpuDisIllegal(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAbcd(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAdd(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAdda(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAddi(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAddq(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAddx(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAnd(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAndi(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisAsx(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisBcc(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisBt(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisChk(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisClr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisCmp(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisCmpa(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisCmpi(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisCmpm(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisDBcc(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisDivs(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisDivu(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisEor(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisEori(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisExg(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisExt(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisJmp(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisJsr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisLea(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisLink(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisLsx(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMove(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoveToCcr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoveToSr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoveFromSr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoveUsp(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMovea(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMovem(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMovep(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoveq(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMuls(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMulu(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisNbcd(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisNeg(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisNegx(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisNop(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisNot(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisOr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisOri(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisPea(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisReset(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRox(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRoxx(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRte(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRtr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRts(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSbcd(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisScc(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisStop(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSub(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSuba(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSubi(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSubq(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSubx(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisSwap(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisTas(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisTrap(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisTrapv(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisTst(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisUnlk(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisBkpt(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisBf(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisCas(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisChkl(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisChk2(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisDivl(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisExtb(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisLinkl(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoveFromCcr(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMovec(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMoves(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisMull(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisPack(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisPflush030(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisPflush040(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisPtest040(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRtd(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisTrapcc(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisUnpk(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisCallm(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern ULO cpuDisRtm(ULO prc, ULO opc, STR *sdata, STR *sinstruction, STR *soperands);
|
||||
extern uint32_t cpuDisIllegal(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAbcd(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAdd(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAdda(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAddi(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAddq(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAddx(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAnd(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAndi(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisAsx(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisBcc(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisBt(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisChk(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisClr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisCmp(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisCmpa(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisCmpi(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisCmpm(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisDBcc(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisDivs(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisDivu(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisEor(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisEori(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisExg(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisExt(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisJmp(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisJsr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisLea(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisLink(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisLsx(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMove(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoveToCcr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoveToSr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoveFromSr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoveUsp(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMovea(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMovem(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMovep(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoveq(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMuls(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMulu(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisNbcd(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisNeg(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisNegx(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisNop(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisNot(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisOr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisOri(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisPea(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisReset(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRox(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRoxx(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRte(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRtr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRts(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSbcd(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisScc(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisStop(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSub(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSuba(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSubi(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSubq(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSubx(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisSwap(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisTas(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisTrap(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisTrapv(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisTst(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisUnlk(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisBkpt(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisBf(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisCas(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisChkl(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisChk2(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisDivl(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisExtb(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisLinkl(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoveFromCcr(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMovec(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMoves(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisMull(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisPack(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisPflush030(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisPflush040(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisPtest040(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRtd(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisTrapcc(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisUnpk(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisCallm(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
extern uint32_t cpuDisRtm(uint32_t prc, uint32_t opc, char *sdata, char *sinstruction, char *soperands);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef CPUMODULE_DISASSEMBLERFUNC_H
|
||||
#define CPUMODULE_DISASSEMBLERFUNC_H
|
||||
#pragma once
|
||||
|
||||
static UBY cpu_dis_func_tab[65536] =
|
||||
static uint8_t cpu_dis_func_tab[65536] =
|
||||
{
|
||||
60,60,60,60,60,60,60,60,0,0,0,0,0,0,0,0,
|
||||
60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,
|
||||
|
@ -259,7 +258,7 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
|
||||
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
|
||||
11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -267,31 +266,31 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -299,31 +298,31 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -331,23 +330,23 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -355,7 +354,7 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -363,23 +362,23 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -387,7 +386,7 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -395,23 +394,23 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -419,7 +418,7 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -427,23 +426,23 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -451,7 +450,7 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -459,23 +458,23 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -483,7 +482,7 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -491,23 +490,23 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,0,0,0,0,0,0,0,0,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
|
||||
39,39,39,39,39,39,39,39,39,39,39,39,39,0,0,0,
|
||||
|
@ -4100,4 +4099,3 @@ static UBY cpu_dis_func_tab[65536] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_EffectiveAddress.c,v 1.3 2012-07-15 22:20:35 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* CPU 68k effective address calculation functions */
|
||||
|
@ -24,29 +23,28 @@
|
|||
/*=========================================================================*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "fellow.h"
|
||||
#include "fmem.h"
|
||||
#include "CpuModule_Memory.h"
|
||||
|
||||
#include "CpuModule.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
/* Calculates EA for (Ax). */
|
||||
ULO cpuEA02(ULO regno)
|
||||
uint32_t cpuEA02(uint32_t regno)
|
||||
{
|
||||
return cpuGetAReg(regno);
|
||||
}
|
||||
|
||||
/* Calculates EA for (Ax)+ */
|
||||
ULO cpuEA03(ULO regno, ULO size)
|
||||
uint32_t cpuEA03(uint32_t regno, uint32_t size)
|
||||
{
|
||||
ULO tmp = cpuGetAReg(regno);
|
||||
uint32_t tmp = cpuGetAReg(regno);
|
||||
if (regno == 7 && size == 1) size++;
|
||||
cpuSetAReg(regno, tmp + size);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* Calculates EA for -(Ax) */
|
||||
ULO cpuEA04(ULO regno, ULO size)
|
||||
uint32_t cpuEA04(uint32_t regno, uint32_t size)
|
||||
{
|
||||
if (regno == 7 && size == 1) size++;
|
||||
cpuSetAReg(regno, cpuGetAReg(regno) - size);
|
||||
|
@ -54,20 +52,20 @@ ULO cpuEA04(ULO regno, ULO size)
|
|||
}
|
||||
|
||||
/* Calculates EA for disp16(Ax) */
|
||||
ULO cpuEA05(ULO regno)
|
||||
uint32_t cpuEA05(uint32_t regno)
|
||||
{
|
||||
return cpuGetAReg(regno) + cpuGetNextWordSignExt();
|
||||
}
|
||||
|
||||
/* Calculates EA for disp8(Ax,Ri.size) with 68020 extended modes. */
|
||||
static ULO cpuEA06Ext(UWO ext, ULO base_reg_value, ULO index_value)
|
||||
static uint32_t cpuEA06Ext(uint16_t ext, uint32_t base_reg_value, uint32_t index_value)
|
||||
{
|
||||
ULO base_displacement;
|
||||
ULO outer_displacement;
|
||||
uint32_t base_displacement;
|
||||
uint32_t outer_displacement;
|
||||
BOOLE index_register_suppressed = (ext & 0x0040);
|
||||
BOOLE base_register_suppressed = (ext & 0x0080);
|
||||
ULO base_displacement_size = (ext >> 4) & 3;
|
||||
ULO memory_indirect_action = (ext & 7);
|
||||
uint32_t base_displacement_size = (ext >> 4) & 3;
|
||||
uint32_t memory_indirect_action = (ext & 7);
|
||||
|
||||
if (memory_indirect_action == 4
|
||||
|| (memory_indirect_action > 4 && index_register_suppressed))
|
||||
|
@ -127,14 +125,14 @@ static ULO cpuEA06Ext(UWO ext, ULO base_reg_value, ULO index_value)
|
|||
}
|
||||
|
||||
/* Calculates EA for disp8(Ax,Ri.size), calls cpuEA06Ext() for 68020 extended modes. */
|
||||
ULO cpuEA06(ULO regno)
|
||||
uint32_t cpuEA06(uint32_t regno)
|
||||
{
|
||||
ULO reg_value = cpuGetAReg(regno);
|
||||
UWO ext = cpuGetNextWord();
|
||||
ULO index_value = cpuGetReg(ext >> 15, (ext >> 12) & 7);
|
||||
uint32_t reg_value = cpuGetAReg(regno);
|
||||
uint16_t ext = cpuGetNextWord();
|
||||
uint32_t index_value = cpuGetReg(ext >> 15, (ext >> 12) & 7);
|
||||
if (!(ext & 0x0800))
|
||||
{
|
||||
index_value = cpuSignExtWordToLong((UWO)index_value);
|
||||
index_value = cpuSignExtWordToLong((uint16_t)index_value);
|
||||
}
|
||||
if (cpuGetModelMajor() >= 2)
|
||||
{
|
||||
|
@ -144,17 +142,17 @@ ULO cpuEA06(ULO regno)
|
|||
return cpuEA06Ext(ext, reg_value, index_value);
|
||||
}
|
||||
}
|
||||
return reg_value + index_value + cpuSignExtByteToLong((UBY)ext);
|
||||
return reg_value + index_value + cpuSignExtByteToLong((uint8_t)ext);
|
||||
}
|
||||
|
||||
/* Calculates EA for xxxx.W */
|
||||
ULO cpuEA70(void)
|
||||
uint32_t cpuEA70()
|
||||
{
|
||||
return cpuGetNextWordSignExt();
|
||||
}
|
||||
|
||||
/* Calculates EA for xxxxxxxx.L */
|
||||
ULO cpuEA71(void)
|
||||
uint32_t cpuEA71()
|
||||
{
|
||||
return cpuGetNextLong();
|
||||
}
|
||||
|
@ -163,9 +161,9 @@ ULO cpuEA71(void)
|
|||
/// Calculates EA for disp16(PC)
|
||||
/// </summary>
|
||||
/// <returns>Address</returns>
|
||||
ULO cpuEA72(void)
|
||||
uint32_t cpuEA72()
|
||||
{
|
||||
ULO pc_tmp = cpuGetPC();
|
||||
uint32_t pc_tmp = cpuGetPC();
|
||||
return pc_tmp + cpuGetNextWordSignExt();
|
||||
}
|
||||
|
||||
|
@ -173,14 +171,14 @@ ULO cpuEA72(void)
|
|||
/// Calculates EA for disp8(PC,Ri.size). Calls cpuEA06Ext() to calculate extended 68020 modes.
|
||||
/// </summary>
|
||||
/// <returns>Address</returns>
|
||||
ULO cpuEA73(void)
|
||||
uint32_t cpuEA73()
|
||||
{
|
||||
ULO reg_value = cpuGetPC();
|
||||
UWO ext = cpuGetNextWord();
|
||||
ULO index_value = cpuGetReg(ext >> 15, (ext >> 12) & 0x7);
|
||||
uint32_t reg_value = cpuGetPC();
|
||||
uint16_t ext = cpuGetNextWord();
|
||||
uint32_t index_value = cpuGetReg(ext >> 15, (ext >> 12) & 0x7);
|
||||
if (!(ext & 0x0800))
|
||||
{
|
||||
index_value = cpuSignExtWordToLong((UWO)index_value);
|
||||
index_value = cpuSignExtWordToLong((uint16_t)index_value);
|
||||
}
|
||||
if (cpuGetModelMajor() >= 2)
|
||||
{
|
||||
|
@ -190,5 +188,5 @@ ULO cpuEA73(void)
|
|||
return cpuEA06Ext(ext, reg_value, index_value);
|
||||
}
|
||||
}
|
||||
return reg_value + index_value + cpuSignExtByteToLong((UBY)ext);
|
||||
return reg_value + index_value + cpuSignExtByteToLong((uint8_t)ext);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_Exceptions.c,v 1.5 2012-08-12 16:51:02 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* CPU 68k exception handling functions */
|
||||
|
@ -24,12 +23,27 @@
|
|||
/*=========================================================================*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "fellow.h"
|
||||
#include "fmem.h"
|
||||
#include "CpuModule_Memory.h"
|
||||
|
||||
#include "CpuModule.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
|
||||
// MPW
|
||||
static cpuLineExceptionFunc cpu_a_line_exception_func = NULL;
|
||||
static cpuLineExceptionFunc cpu_f_line_exception_func = NULL;
|
||||
|
||||
void cpuSetALineExceptionFunc(cpuLineExceptionFunc func)
|
||||
{
|
||||
cpu_a_line_exception_func = func;
|
||||
}
|
||||
|
||||
void cpuSetFLineExceptionFunc(cpuLineExceptionFunc func)
|
||||
{
|
||||
cpu_f_line_exception_func = func;
|
||||
}
|
||||
|
||||
|
||||
/* Function for exiting from mid-instruction exceptions */
|
||||
static cpuMidInstructionExceptionFunc cpu_mid_instruction_exception_func;
|
||||
|
||||
|
@ -56,12 +70,12 @@ void cpuSetResetExceptionFunc(cpuResetExceptionFunc func)
|
|||
cpu_reset_exception_func = func;
|
||||
}
|
||||
|
||||
static STR *cpuGetExceptionName(ULO vector_offset)
|
||||
static char *cpuGetExceptionName(uint32_t vector_offset)
|
||||
{
|
||||
char *name;
|
||||
|
||||
if (vector_offset == 0x8)
|
||||
name = "Exception: 2 - Access fault";
|
||||
name = "Exception: 2 - Bus error";
|
||||
else if (vector_offset == 0xc)
|
||||
name = "Exception: 3 - Address error";
|
||||
else if (vector_offset == 0x10)
|
||||
|
@ -107,9 +121,9 @@ void cpuExceptionFail(BOOLE executejmp)
|
|||
}
|
||||
}
|
||||
|
||||
void cpuThrowException(ULO vector_offset, ULO pc, BOOLE executejmp)
|
||||
void cpuThrowException(uint32_t vector_offset, uint32_t pc, BOOLE executejmp)
|
||||
{
|
||||
ULO vector_address;
|
||||
uint32_t vector_address;
|
||||
BOOLE is_address_error_on_sub_020 = (cpuGetModelMajor() < 2 && vector_offset == 0xc);
|
||||
BOOLE stack_is_even = !(cpuGetAReg(7) & 1);
|
||||
BOOLE vbr_is_even = !(cpuGetVbr() & 1);
|
||||
|
@ -134,7 +148,7 @@ void cpuThrowException(ULO vector_offset, ULO pc, BOOLE executejmp)
|
|||
return;
|
||||
}
|
||||
|
||||
cpuStackFrameGenerate((UWO) vector_offset, pc);
|
||||
cpuStackFrameGenerate((uint16_t) vector_offset, pc);
|
||||
|
||||
// read a memory position
|
||||
vector_address = memoryReadLong(cpuGetVbr() + vector_offset);
|
||||
|
@ -153,7 +167,40 @@ void cpuThrowException(ULO vector_offset, ULO pc, BOOLE executejmp)
|
|||
cpuSetStop(FALSE);
|
||||
|
||||
cpuInitializeFromNewPC(vector_address);
|
||||
cpuSetInstructionTime(40);
|
||||
|
||||
uint32_t exceptionCycles = 0;
|
||||
|
||||
switch (vector_offset)
|
||||
{
|
||||
case 0x08: exceptionCycles = 50; break; // Bus
|
||||
case 0x0c: exceptionCycles = 50; break; // Address
|
||||
case 0x10: exceptionCycles = 34; break; // Illegal
|
||||
case 0x14: exceptionCycles = 42; break; // Division by zero
|
||||
case 0x18: exceptionCycles = 28; break; // Chk
|
||||
case 0x1c: exceptionCycles = 34; break; // Trapcc/trapv
|
||||
case 0x20: exceptionCycles = 34; break; // Privilege
|
||||
case 0x24: exceptionCycles = 34; break; // Trace
|
||||
case 0x28: exceptionCycles = 34; break; // Line A
|
||||
case 0x2c: exceptionCycles = 34; break; // Line F
|
||||
case 0x80:
|
||||
case 0x84:
|
||||
case 0x88:
|
||||
case 0x8c:
|
||||
case 0x90:
|
||||
case 0x94:
|
||||
case 0x98:
|
||||
case 0x9c:
|
||||
case 0xa0:
|
||||
case 0xa4:
|
||||
case 0xa8:
|
||||
case 0xac:
|
||||
case 0xb0:
|
||||
case 0xb4:
|
||||
case 0xb8:
|
||||
case 0xbc: exceptionCycles = 34; break; // TRAP
|
||||
default: exceptionCycles = 4; break; // Should not come here
|
||||
}
|
||||
cpuSetInstructionTime(exceptionCycles);
|
||||
}
|
||||
|
||||
// If the exception happened mid-instruction...
|
||||
|
@ -165,6 +212,7 @@ void cpuThrowException(ULO vector_offset, ULO pc, BOOLE executejmp)
|
|||
|
||||
void cpuThrowPrivilegeViolationException(void)
|
||||
{
|
||||
cpuSetInstructionAborted(true);
|
||||
// The saved pc points to the instruction causing the violation
|
||||
// (And the kickstart excpects pc in the stack frame to be the opcode PC.)
|
||||
cpuThrowException(0x20, cpuGetOriginalPC(), FALSE);
|
||||
|
@ -172,18 +220,48 @@ void cpuThrowPrivilegeViolationException(void)
|
|||
|
||||
void cpuThrowIllegalInstructionException(BOOLE executejmp)
|
||||
{
|
||||
cpuSetInstructionAborted(true);
|
||||
// The saved pc points to the illegal instruction
|
||||
cpuThrowException(0x10, cpuGetOriginalPC(), executejmp);
|
||||
}
|
||||
|
||||
void cpuThrowIllegalInstructionExceptionFromBreakpoint(void)
|
||||
{
|
||||
cpuSetInstructionAborted(true);
|
||||
// The saved pc points to the illegal instruction
|
||||
cpuThrowException(0x10, cpuGetPC(), FALSE);
|
||||
}
|
||||
|
||||
void cpuThrowALineException(void)
|
||||
{
|
||||
// MPW
|
||||
if (cpu_a_line_exception_func)
|
||||
{
|
||||
uint16_t opcode = memoryReadWord(cpuGetPC() - 2);
|
||||
cpu_a_line_exception_func(opcode);
|
||||
cpuInitializeFromNewPC(cpuGetPC());
|
||||
cpuSetInstructionTime(512);
|
||||
return;
|
||||
}
|
||||
|
||||
cpuSetInstructionAborted(true);
|
||||
// The saved pc points to the a-line instruction
|
||||
cpuThrowException(0x28, cpuGetOriginalPC(), FALSE);
|
||||
}
|
||||
|
||||
void cpuThrowFLineException(void)
|
||||
{
|
||||
// MPW
|
||||
if (cpu_f_line_exception_func)
|
||||
{
|
||||
uint16_t opcode = memoryReadWord(cpuGetPC() - 2);
|
||||
cpu_f_line_exception_func(opcode);
|
||||
cpuInitializeFromNewPC(cpuGetPC());
|
||||
cpuSetInstructionTime(512);
|
||||
return;
|
||||
}
|
||||
|
||||
cpuSetInstructionAborted(true);
|
||||
// The saved pc points to the f-line instruction
|
||||
cpuThrowException(0x2c, cpuGetOriginalPC(), FALSE);
|
||||
}
|
||||
|
@ -194,13 +272,13 @@ void cpuThrowTrapVException(void)
|
|||
cpuThrowException(0x1c, cpuGetPC(), FALSE);
|
||||
}
|
||||
|
||||
void cpuThrowDivisionByZeroException(BOOLE executejmp)
|
||||
void cpuThrowDivisionByZeroException(void)
|
||||
{
|
||||
// The saved pc points to the next instruction, which is now in pc
|
||||
cpuThrowException(0x14, cpuGetPC(), executejmp);
|
||||
cpuThrowException(0x14, cpuGetPC(), FALSE);
|
||||
}
|
||||
|
||||
void cpuThrowTrapException(ULO vector_no)
|
||||
void cpuThrowTrapException(uint32_t vector_no)
|
||||
{
|
||||
// The saved pc points to the next instruction, which is now in pc
|
||||
cpuThrowException(0x80 + vector_no*4, cpuGetPC(), FALSE);
|
||||
|
@ -220,6 +298,7 @@ void cpuThrowTraceException(void)
|
|||
|
||||
void cpuThrowAddressErrorException(void)
|
||||
{
|
||||
cpuSetInstructionAborted(true);
|
||||
cpuThrowException(0xc, cpuGetPC() - 2, TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_Flags.c,v 1.3 2011-07-18 17:22:55 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* 68000 flag and condition code handling */
|
||||
|
@ -22,29 +21,28 @@
|
|||
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/*=========================================================================*/
|
||||
#include "defs.h"
|
||||
#include "fellow.h"
|
||||
#include "CpuModule.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
|
||||
/// Sets the Z flag for bit operations
|
||||
void cpuSetZFlagBitOpsB(UBY res)
|
||||
void cpuSetZFlagBitOpsB(uint8_t res)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfffb;
|
||||
uint32_t flags = cpu_sr & 0xfffb;
|
||||
if (res == 0) flags |= 4;
|
||||
cpu_sr = flags;
|
||||
}
|
||||
|
||||
/// Sets the Z flag for bit operations
|
||||
void cpuSetZFlagBitOpsL(ULO res)
|
||||
void cpuSetZFlagBitOpsL(uint32_t res)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfffb;
|
||||
uint32_t flags = cpu_sr & 0xfffb;
|
||||
if (res == 0) flags |= 4;
|
||||
cpu_sr = flags;
|
||||
}
|
||||
|
||||
// rm,dm,sm
|
||||
ULO cpu_xnvc_flag_add_table[2][2][2] = { 0,0x11,0x11,0x13,0xa,8,8,0x19};
|
||||
uint32_t cpu_xnvc_flag_add_table[2][2][2] = { 0,0x11,0x11,0x13,0xa,8,8,0x19};
|
||||
|
||||
/// <summary>
|
||||
/// Calculate XNVC flags of an add operation.
|
||||
|
@ -52,13 +50,13 @@ ULO cpu_xnvc_flag_add_table[2][2][2] = { 0,0x11,0x11,0x13,0xa,8,8,0x19};
|
|||
/// <param name="rm">The MSB of the result.</param>
|
||||
/// <param name="dm">The MSB of the destination source.</param>
|
||||
/// <param name="sm">The MSB of the source.</param>
|
||||
static ULO cpuMakeFlagXNVCAdd(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
static uint32_t cpuMakeFlagXNVCAdd(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
return cpu_xnvc_flag_add_table[rm][dm][sm];
|
||||
}
|
||||
|
||||
// rm,dm,sm
|
||||
ULO cpu_nvc_flag_add_table[2][2][2] = { 0,1,1,3,0xa,8,8,9};
|
||||
uint32_t cpu_nvc_flag_add_table[2][2][2] = { 0,1,1,3,0xa,8,8,9};
|
||||
|
||||
/// <summary>
|
||||
/// Calculate NVC flags of an add operation for instructions not setting X.
|
||||
|
@ -66,13 +64,13 @@ ULO cpu_nvc_flag_add_table[2][2][2] = { 0,1,1,3,0xa,8,8,9};
|
|||
/// <param name="rm">The MSB of the result.</param>
|
||||
/// <param name="dm">The MSB of the destination source.</param>
|
||||
/// <param name="sm">The MSB of the source.</param>
|
||||
static ULO cpuMakeFlagNVCAdd(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
static uint32_t cpuMakeFlagNVCAdd(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
return cpu_nvc_flag_add_table[rm][dm][sm];
|
||||
}
|
||||
|
||||
// rm,dm,sm
|
||||
ULO cpu_xnvc_flag_sub_table[2][2][2] = { 0,0x11,2,0,0x19,0x1b,8,0x19};
|
||||
uint32_t cpu_xnvc_flag_sub_table[2][2][2] = { 0,0x11,2,0,0x19,0x1b,8,0x19};
|
||||
|
||||
/// <summary>
|
||||
/// Calculate XNVC flags of a sub operation.
|
||||
|
@ -80,13 +78,13 @@ ULO cpu_xnvc_flag_sub_table[2][2][2] = { 0,0x11,2,0,0x19,0x1b,8,0x19};
|
|||
/// <param name="rm">The MSB of the result.</param>
|
||||
/// <param name="dm">The MSB of the destination source.</param>
|
||||
/// <param name="sm">The MSB of the source.</param>
|
||||
static ULO cpuMakeFlagXNVCSub(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
static uint32_t cpuMakeFlagXNVCSub(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
return cpu_xnvc_flag_sub_table[rm][dm][sm];
|
||||
}
|
||||
|
||||
// rm,dm,sm
|
||||
ULO cpu_nvc_flag_sub_table[2][2][2] = { 0,1,2,0,9,0xb,8,9};
|
||||
uint32_t cpu_nvc_flag_sub_table[2][2][2] = { 0,1,2,0,9,0xb,8,9};
|
||||
|
||||
/// <summary>
|
||||
/// Calculate NVC flags of a sub operation for instructions not setting X.
|
||||
|
@ -94,7 +92,7 @@ ULO cpu_nvc_flag_sub_table[2][2][2] = { 0,1,2,0,9,0xb,8,9};
|
|||
/// <param name="rm">The MSB of the result.</param>
|
||||
/// <param name="dm">The MSB of the destination source.</param>
|
||||
/// <param name="sm">The MSB of the source.</param>
|
||||
static ULO cpuMakeFlagNVCSub(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
static uint32_t cpuMakeFlagNVCSub(BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
return cpu_nvc_flag_sub_table[rm][dm][sm];
|
||||
}
|
||||
|
@ -126,14 +124,6 @@ void cpuSetFlagV(BOOLE f)
|
|||
cpu_sr = (cpu_sr & 0xfffd) | ((f) ? 2 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the V flag.
|
||||
/// </summary>
|
||||
static void cpuClearFlagV(void)
|
||||
{
|
||||
cpu_sr = cpu_sr & 0xfffd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the V flag.
|
||||
/// </summary>
|
||||
|
@ -160,22 +150,6 @@ void cpuSetFlagZ(BOOLE f)
|
|||
cpu_sr = (cpu_sr & 0xfffb) | ((f) ? 4 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the Z flag.
|
||||
/// </summary>
|
||||
static void cpuClearFlagZ(void)
|
||||
{
|
||||
cpu_sr = cpu_sr & 0xfffb;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Z flag.
|
||||
/// </summary>
|
||||
static BOOLE cpuGetFlagZ(void)
|
||||
{
|
||||
return cpu_sr & 0x4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the X flag.
|
||||
/// </summary>
|
||||
|
@ -195,18 +169,18 @@ void cpuSetFlags0100(void)
|
|||
/// <summary>
|
||||
/// Clear V and C.
|
||||
/// </summary>
|
||||
static void cpuClearFlagsVC(void)
|
||||
void cpuClearFlagsVC(void)
|
||||
{
|
||||
cpu_sr = cpu_sr & 0xfffc;
|
||||
}
|
||||
|
||||
UWO cpuGetZFlagB(UBY res) {return (UWO)((res) ? 0 : 4);}
|
||||
UWO cpuGetZFlagW(UWO res) {return (UWO)((res) ? 0 : 4);}
|
||||
UWO cpuGetZFlagL(ULO res) {return (UWO)((res) ? 0 : 4);}
|
||||
uint16_t cpuGetZFlagB(uint8_t res) {return (uint16_t)((res) ? 0 : 4);}
|
||||
uint16_t cpuGetZFlagW(uint16_t res) {return (uint16_t)((res) ? 0 : 4);}
|
||||
uint16_t cpuGetZFlagL(uint32_t res) {return (uint16_t)((res) ? 0 : 4);}
|
||||
|
||||
UWO cpuGetNFlagB(UBY res) {return (UWO)((res & 0x80) >> 4);}
|
||||
UWO cpuGetNFlagW(UWO res) {return (UWO)((res & 0x8000) >> 12);}
|
||||
UWO cpuGetNFlagL(ULO res) {return (UWO)((res & 0x80000000) >> 28);}
|
||||
uint16_t cpuGetNFlagB(uint8_t res) {return (uint16_t)((res & 0x80) >> 4);}
|
||||
uint16_t cpuGetNFlagW(uint16_t res) {return (uint16_t)((res & 0x8000) >> 12);}
|
||||
uint16_t cpuGetNFlagL(uint32_t res) {return (uint16_t)((res & 0x80000000) >> 28);}
|
||||
|
||||
/// <summary>
|
||||
/// Set the flags NZVC.
|
||||
|
@ -217,7 +191,7 @@ UWO cpuGetNFlagL(ULO res) {return (UWO)((res & 0x80000000) >> 28);}
|
|||
/// <param name="c">The C flag.</param>
|
||||
void cpuSetFlagsNZVC(BOOLE z, BOOLE n, BOOLE v, BOOLE c)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfff0;
|
||||
uint32_t flags = cpu_sr & 0xfff0;
|
||||
if (n) flags |= 8;
|
||||
else if (z) flags |= 4;
|
||||
if (v) flags |= 2;
|
||||
|
@ -232,7 +206,7 @@ void cpuSetFlagsNZVC(BOOLE z, BOOLE n, BOOLE v, BOOLE c)
|
|||
/// <param name="c">The C flag.</param>
|
||||
void cpuSetFlagsVC(BOOLE v, BOOLE c)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfffc;
|
||||
uint32_t flags = cpu_sr & 0xfffc;
|
||||
if (v) flags |= 2;
|
||||
if (c) flags |= 1;
|
||||
cpu_sr = flags;
|
||||
|
@ -247,7 +221,7 @@ void cpuSetFlagsVC(BOOLE v, BOOLE c)
|
|||
/// <param name="sm">The MSB of the source.</param>
|
||||
void cpuSetFlagsAdd(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xffe0;
|
||||
uint32_t flags = cpu_sr & 0xffe0;
|
||||
if (z) flags |= 4;
|
||||
flags |= cpuMakeFlagXNVCAdd(rm, dm, sm);
|
||||
cpu_sr = flags;
|
||||
|
@ -262,7 +236,7 @@ void cpuSetFlagsAdd(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
|||
/// <param name="sm">The MSB of the source.</param>
|
||||
void cpuSetFlagsSub(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xffe0;
|
||||
uint32_t flags = cpu_sr & 0xffe0;
|
||||
if (z) flags |= 4;
|
||||
flags |= cpuMakeFlagXNVCSub(rm, dm, sm);
|
||||
cpu_sr = flags;
|
||||
|
@ -277,7 +251,7 @@ void cpuSetFlagsSub(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
|||
/// <param name="sm">The MSB of the source.</param>
|
||||
void cpuSetFlagsAddX(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
ULO flags = cpu_sr & ((z) ? 0xffe4 : 0xffe0); // Clear z if result is non-zero
|
||||
uint32_t flags = cpu_sr & ((z) ? 0xffe4 : 0xffe0); // Clear z if result is non-zero
|
||||
flags |= cpuMakeFlagXNVCAdd(rm, dm, sm);
|
||||
cpu_sr = flags;
|
||||
}
|
||||
|
@ -291,7 +265,7 @@ void cpuSetFlagsAddX(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
|||
/// <param name="sm">The MSB of the source.</param>
|
||||
void cpuSetFlagsSubX(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
ULO flags = cpu_sr & ((z) ? 0xffe4 : 0xffe0); // Clear z if result is non-zero
|
||||
uint32_t flags = cpu_sr & ((z) ? 0xffe4 : 0xffe0); // Clear z if result is non-zero
|
||||
flags |= cpuMakeFlagXNVCSub(rm, dm, sm);
|
||||
cpu_sr = flags;
|
||||
}
|
||||
|
@ -304,7 +278,7 @@ void cpuSetFlagsSubX(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
|||
/// <param name="dm">The MSB of the destination source.</param>
|
||||
void cpuSetFlagsNeg(BOOLE z, BOOLE rm, BOOLE dm)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xffe0;
|
||||
uint32_t flags = cpu_sr & 0xffe0;
|
||||
if (z) flags |= 4;
|
||||
else
|
||||
{
|
||||
|
@ -326,7 +300,7 @@ void cpuSetFlagsNeg(BOOLE z, BOOLE rm, BOOLE dm)
|
|||
/// <param name="dm">The MSB of the destination source.</param>
|
||||
void cpuSetFlagsNegx(BOOLE z, BOOLE rm, BOOLE dm)
|
||||
{
|
||||
ULO flags = cpu_sr & ((z) ? 0xffe4 : 0xffe0); // Clear z if result is non-zero
|
||||
uint32_t flags = cpu_sr & ((z) ? 0xffe4 : 0xffe0); // Clear z if result is non-zero
|
||||
if (dm || rm)
|
||||
{
|
||||
flags |= 0x11; // XC
|
||||
|
@ -348,7 +322,7 @@ void cpuSetFlagsNegx(BOOLE z, BOOLE rm, BOOLE dm)
|
|||
/// <param name="sm">The MSB of the source.</param>
|
||||
void cpuSetFlagsCmp(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfff0;
|
||||
uint32_t flags = cpu_sr & 0xfff0;
|
||||
if (z) flags |= 4;
|
||||
flags |= cpuMakeFlagNVCSub(rm, dm, sm);
|
||||
cpu_sr = flags;
|
||||
|
@ -361,7 +335,7 @@ void cpuSetFlagsCmp(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm)
|
|||
/// <param name="rm">The MSB of the result.</param>
|
||||
void cpuSetFlagsShiftZero(BOOLE z, BOOLE rm)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfff0; // Always clearing the VC flag
|
||||
uint32_t flags = cpu_sr & 0xfff0; // Always clearing the VC flag
|
||||
if (rm) flags |= 8;
|
||||
else if (z) flags |= 4;
|
||||
cpu_sr = flags;
|
||||
|
@ -376,7 +350,7 @@ void cpuSetFlagsShiftZero(BOOLE z, BOOLE rm)
|
|||
/// <param name="c">The overflow of the result.</param>
|
||||
void cpuSetFlagsShift(BOOLE z, BOOLE rm, BOOLE c, BOOLE v)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xffe0;
|
||||
uint32_t flags = cpu_sr & 0xffe0;
|
||||
if (rm) flags |= 8;
|
||||
else if (z) flags |= 4;
|
||||
if (v) flags |= 2;
|
||||
|
@ -392,7 +366,7 @@ void cpuSetFlagsShift(BOOLE z, BOOLE rm, BOOLE c, BOOLE v)
|
|||
/// <param name="c">The carry of the result.</param>
|
||||
void cpuSetFlagsRotate(BOOLE z, BOOLE rm, BOOLE c)
|
||||
{
|
||||
ULO flags = cpu_sr & 0xfff0; // Always clearing the V flag
|
||||
uint32_t flags = cpu_sr & 0xfff0; // Always clearing the V flag
|
||||
|
||||
if (rm) flags |= 8;
|
||||
else if (z) flags |= 4;
|
||||
|
@ -407,7 +381,7 @@ void cpuSetFlagsRotate(BOOLE z, BOOLE rm, BOOLE c)
|
|||
/// <param name="z">The Z flag.</param>
|
||||
/// <param name="rm">The MSB of the result.</param>
|
||||
/// <param name="c">The extend bit and carry of the result.</param>
|
||||
void cpuSetFlagsRotateX(UWO z, UWO rm, UWO x)
|
||||
void cpuSetFlagsRotateX(uint16_t z, uint16_t rm, uint16_t x)
|
||||
{
|
||||
cpu_sr = (cpu_sr & 0xffe0) | z | rm | x;
|
||||
}
|
||||
|
@ -415,9 +389,9 @@ void cpuSetFlagsRotateX(UWO z, UWO rm, UWO x)
|
|||
/// <summary>
|
||||
/// Set the flags (ZN00).
|
||||
/// </summary>
|
||||
void cpuSetFlagsNZ00NewB(UBY res)
|
||||
void cpuSetFlagsNZ00NewB(uint8_t res)
|
||||
{
|
||||
ULO flag = cpu_sr & 0xfff0;
|
||||
uint32_t flag = cpu_sr & 0xfff0;
|
||||
if (res & 0x80) flag |= 0x8;
|
||||
else if (res == 0) flag |= 0x4;
|
||||
cpu_sr = flag;
|
||||
|
@ -426,9 +400,9 @@ void cpuSetFlagsNZ00NewB(UBY res)
|
|||
/// <summary>
|
||||
/// Set the flags (ZN00).
|
||||
/// </summary>
|
||||
void cpuSetFlagsNZ00NewW(UWO res)
|
||||
void cpuSetFlagsNZ00NewW(uint16_t res)
|
||||
{
|
||||
ULO flag = cpu_sr & 0xfff0;
|
||||
uint32_t flag = cpu_sr & 0xfff0;
|
||||
if (res & 0x8000) flag |= 0x8;
|
||||
else if (res == 0) flag |= 0x4;
|
||||
cpu_sr = flag;
|
||||
|
@ -437,9 +411,9 @@ void cpuSetFlagsNZ00NewW(UWO res)
|
|||
/// <summary>
|
||||
/// Set the flags (ZN00).
|
||||
/// </summary>
|
||||
void cpuSetFlagsNZ00NewL(ULO res)
|
||||
void cpuSetFlagsNZ00NewL(uint32_t res)
|
||||
{
|
||||
ULO flag = cpu_sr & 0xfff0;
|
||||
uint32_t flag = cpu_sr & 0xfff0;
|
||||
if (res & 0x80000000) flag |= 0x8;
|
||||
else if (res == 0) flag |= 0x4;
|
||||
cpu_sr = flag;
|
||||
|
@ -448,9 +422,9 @@ void cpuSetFlagsNZ00NewL(ULO res)
|
|||
/// <summary>
|
||||
/// Set the flags (ZN00).
|
||||
/// </summary>
|
||||
void cpuSetFlagsNZ00New64(LLO res)
|
||||
void cpuSetFlagsNZ00New64(int64_t res)
|
||||
{
|
||||
ULO flag = cpu_sr & 0xfff0;
|
||||
uint32_t flag = cpu_sr & 0xfff0;
|
||||
if (res < 0) flag |= 0x8;
|
||||
else if (res == 0) flag |= 0x4;
|
||||
cpu_sr = flag;
|
||||
|
@ -460,7 +434,7 @@ void cpuSetFlagsNZ00New64(LLO res)
|
|||
/// Set the 4 flags absolute.
|
||||
/// </summary>
|
||||
/// <param name="f">flags</param>
|
||||
void cpuSetFlagsAbs(UWO f)
|
||||
void cpuSetFlagsAbs(uint16_t f)
|
||||
{
|
||||
cpu_sr = (cpu_sr & 0xfff0) | f;
|
||||
}
|
||||
|
@ -531,29 +505,29 @@ BOOLE cpuCalculateConditionCode11(void)
|
|||
|
||||
BOOLE cpuCalculateConditionCode12(void)
|
||||
{
|
||||
ULO tmp = cpu_sr & 0xa;
|
||||
uint32_t tmp = cpu_sr & 0xa;
|
||||
return (tmp == 0xa) || (tmp == 0); // GE - (N && V) || (!N && !V)
|
||||
}
|
||||
|
||||
BOOLE cpuCalculateConditionCode13(void)
|
||||
{
|
||||
ULO tmp = cpu_sr & 0xa;
|
||||
uint32_t tmp = cpu_sr & 0xa;
|
||||
return (tmp == 0x8) || (tmp == 0x2); // LT - (N && !V) || (!N && V)
|
||||
}
|
||||
|
||||
BOOLE cpuCalculateConditionCode14(void)
|
||||
{
|
||||
ULO tmp = cpu_sr & 0xa;
|
||||
uint32_t tmp = cpu_sr & 0xa;
|
||||
return (!(cpu_sr & 0x4)) && ((tmp == 0xa) || (tmp == 0)); // GT - (N && V && !Z) || (!N && !V && !Z)
|
||||
}
|
||||
|
||||
BOOLE cpuCalculateConditionCode15(void)
|
||||
{
|
||||
ULO tmp = cpu_sr & 0xa;
|
||||
uint32_t tmp = cpu_sr & 0xa;
|
||||
return (cpu_sr & 0x4) || (tmp == 0x8) || (tmp == 2);// LE - Z || (N && !V) || (!N && V)
|
||||
}
|
||||
|
||||
BOOLE cpuCalculateConditionCode(ULO cc)
|
||||
BOOLE cpuCalculateConditionCode(uint32_t cc)
|
||||
{
|
||||
switch (cc & 0xf)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,119 +1,112 @@
|
|||
#ifndef CpuModule_Internal_H
|
||||
#define CpuModule_Internal_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
// This header file defines the internal interfaces of the CPU module.
|
||||
extern void cpuMakeOpcodeTableForModel(void);
|
||||
extern void cpuCreateMulTimeTables(void);
|
||||
|
||||
// StackFrameGen
|
||||
extern void cpuStackFrameGenerate(UWO vector_no, ULO pc);
|
||||
extern void cpuStackFrameGenerate(uint16_t vector_no, uint32_t pc);
|
||||
extern void cpuStackFrameInit(void);
|
||||
|
||||
// Registers
|
||||
extern ULO cpu_sr; // Not static because the flags calculation uses it extensively
|
||||
extern uint32_t cpu_sr; // Not static because the flags calculation uses it extensively
|
||||
extern BOOLE cpuGetFlagSupervisor(void);
|
||||
extern BOOLE cpuGetFlagMaster(void);
|
||||
extern void cpuSetUspDirect(ULO usp);
|
||||
extern ULO cpuGetUspDirect(void);
|
||||
extern ULO cpuGetUspAutoMap(void);
|
||||
extern void cpuSetSspDirect(ULO ssp);
|
||||
extern ULO cpuGetSspDirect(void);
|
||||
extern ULO cpuGetSspAutoMap(void);
|
||||
extern void cpuSetMspDirect(ULO msp);
|
||||
extern ULO cpuGetMspDirect(void);
|
||||
extern ULO cpuGetMspAutoMap(void);
|
||||
extern void cpuSetMspAutoMap(ULO new_msp);
|
||||
extern ULO cpuGetIspAutoMap(void);
|
||||
extern void cpuSetIspAutoMap(ULO new_isp);
|
||||
extern void cpuSetDReg(ULO i, ULO value);
|
||||
extern ULO cpuGetDReg(ULO i);
|
||||
extern void cpuSetAReg(ULO i, ULO value);
|
||||
extern ULO cpuGetAReg(ULO i);
|
||||
extern void cpuSetReg(ULO da, ULO i, ULO value);
|
||||
extern ULO cpuGetReg(ULO da, ULO i);
|
||||
extern void cpuSetPC(ULO address);
|
||||
extern ULO cpuGetPC(void);
|
||||
extern void cpuSetUspDirect(uint32_t usp);
|
||||
extern uint32_t cpuGetUspDirect(void);
|
||||
extern uint32_t cpuGetUspAutoMap(void);
|
||||
extern void cpuSetSspDirect(uint32_t ssp);
|
||||
extern uint32_t cpuGetSspDirect(void);
|
||||
extern uint32_t cpuGetSspAutoMap(void);
|
||||
extern void cpuSetMspDirect(uint32_t msp);
|
||||
extern uint32_t cpuGetMspDirect(void);
|
||||
extern uint32_t cpuGetMspAutoMap(void);
|
||||
extern void cpuSetMspAutoMap(uint32_t new_msp);
|
||||
extern uint32_t cpuGetIspAutoMap(void);
|
||||
extern void cpuSetIspAutoMap(uint32_t new_isp);
|
||||
extern void cpuSetDReg(uint32_t i, uint32_t value);
|
||||
extern uint32_t cpuGetDReg(uint32_t i);
|
||||
extern void cpuSetAReg(uint32_t i, uint32_t value);
|
||||
extern uint32_t cpuGetAReg(uint32_t i);
|
||||
extern void cpuSetReg(uint32_t da, uint32_t i, uint32_t value);
|
||||
extern uint32_t cpuGetReg(uint32_t da, uint32_t i);
|
||||
extern void cpuSetPC(uint32_t address);
|
||||
extern uint32_t cpuGetPC(void);
|
||||
extern void cpuSetStop(BOOLE stop);
|
||||
extern BOOLE cpuGetStop(void);
|
||||
extern void cpuSetVbr(ULO vbr);
|
||||
extern ULO cpuGetVbr(void);
|
||||
extern void cpuSetSfc(ULO sfc);
|
||||
extern ULO cpuGetSfc(void);
|
||||
extern void cpuSetDfc(ULO dfc);
|
||||
extern ULO cpuGetDfc(void);
|
||||
extern void cpuSetCacr(ULO cacr);
|
||||
extern ULO cpuGetCacr(void);
|
||||
extern void cpuSetCaar(ULO caar);
|
||||
extern ULO cpuGetCaar(void);
|
||||
extern void cpuSetSR(ULO sr);
|
||||
extern ULO cpuGetSR(void);
|
||||
extern BOOLE cpuSetIrqLevel(ULO new_interrupt_level);
|
||||
extern ULO cpuGetIrqLevel(void);
|
||||
extern void cpuSetIrqAddress(ULO irq_address);
|
||||
extern ULO cpuGetIrqAddress(void);
|
||||
extern void cpuSetInstructionTime(ULO cycles);
|
||||
extern ULO cpuGetInstructionTime(void);
|
||||
extern void cpuSetOriginalPC(ULO pc);
|
||||
extern ULO cpuGetOriginalPC(void);
|
||||
extern void cpuSetVbr(uint32_t vbr);
|
||||
extern uint32_t cpuGetVbr(void);
|
||||
extern void cpuSetSfc(uint32_t sfc);
|
||||
extern uint32_t cpuGetSfc(void);
|
||||
extern void cpuSetDfc(uint32_t dfc);
|
||||
extern uint32_t cpuGetDfc(void);
|
||||
extern void cpuSetCacr(uint32_t cacr);
|
||||
extern uint32_t cpuGetCacr(void);
|
||||
extern void cpuSetCaar(uint32_t caar);
|
||||
extern uint32_t cpuGetCaar(void);
|
||||
extern void cpuSetSR(uint32_t sr);
|
||||
extern uint32_t cpuGetSR(void);
|
||||
extern void cpuSetInstructionTime(uint32_t cycles);
|
||||
extern uint32_t cpuGetInstructionTime(void);
|
||||
extern void cpuSetOriginalPC(uint32_t pc);
|
||||
extern uint32_t cpuGetOriginalPC(void);
|
||||
extern void cpuSetInstructionAborted(bool aborted);
|
||||
extern bool cpuGetInstructionAborted(void);
|
||||
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
|
||||
extern void cpuSetCurrentOpcode(UWO opcode);
|
||||
extern UWO cpuGetCurrentOpcode(void);
|
||||
extern void cpuSetCurrentOpcode(uint16_t opcode);
|
||||
extern uint16_t cpuGetCurrentOpcode(void);
|
||||
|
||||
#endif
|
||||
|
||||
extern void cpuProfileWrite(void);
|
||||
|
||||
extern void cpuSetModelMask(UBY model_mask);
|
||||
extern UBY cpuGetModelMask(void);
|
||||
extern void cpuSetDRegWord(ULO regno, UWO val);
|
||||
extern void cpuSetDRegByte(ULO regno, UBY val);
|
||||
extern UWO cpuGetRegWord(ULO i, ULO regno);
|
||||
extern UWO cpuGetDRegWord(ULO regno);
|
||||
extern UBY cpuGetDRegByte(ULO regno);
|
||||
extern ULO cpuGetDRegWordSignExtLong(ULO regno);
|
||||
extern UWO cpuGetDRegByteSignExtWord(ULO regno);
|
||||
extern ULO cpuGetDRegByteSignExtLong(ULO regno);
|
||||
extern UWO cpuGetARegWord(ULO regno);
|
||||
extern UBY cpuGetARegByte(ULO regno);
|
||||
extern void cpuSetModelMask(uint8_t model_mask);
|
||||
extern uint8_t cpuGetModelMask(void);
|
||||
extern void cpuSetDRegWord(uint32_t regno, uint16_t val);
|
||||
extern void cpuSetDRegByte(uint32_t regno, uint8_t val);
|
||||
extern uint16_t cpuGetRegWord(uint32_t i, uint32_t regno);
|
||||
extern uint16_t cpuGetDRegWord(uint32_t regno);
|
||||
extern uint8_t cpuGetDRegByte(uint32_t regno);
|
||||
extern uint32_t cpuGetDRegWordSignExtLong(uint32_t regno);
|
||||
extern uint16_t cpuGetDRegByteSignExtWord(uint32_t regno);
|
||||
extern uint32_t cpuGetDRegByteSignExtLong(uint32_t regno);
|
||||
extern uint16_t cpuGetARegWord(uint32_t regno);
|
||||
extern uint8_t cpuGetARegByte(uint32_t regno);
|
||||
|
||||
extern UWO cpuGetNextWord(void);
|
||||
extern ULO cpuGetNextWordSignExt(void);
|
||||
extern ULO cpuGetNextLong(void);
|
||||
extern uint16_t cpuGetNextWord(void);
|
||||
extern uint32_t cpuGetNextWordSignExt(void);
|
||||
extern uint32_t cpuGetNextLong(void);
|
||||
extern void cpuSkipNextWord(void);
|
||||
extern void cpuSkipNextLong(void);
|
||||
extern void cpuClearPrefetch(void);
|
||||
extern void cpuValidateReadPointer(void);
|
||||
|
||||
extern void cpuInitializeFromNewPC(ULO new_pc);
|
||||
extern void cpuInitializeFromNewPC(uint32_t new_pc);
|
||||
|
||||
// Effective address
|
||||
extern ULO cpuEA02(ULO regno);
|
||||
extern ULO cpuEA03(ULO regno, ULO size);
|
||||
extern ULO cpuEA04(ULO regno, ULO size);
|
||||
extern ULO cpuEA05(ULO regno);
|
||||
extern ULO cpuEA06(ULO regno);
|
||||
extern ULO cpuEA70(void);
|
||||
extern ULO cpuEA71(void);
|
||||
extern ULO cpuEA72(void);
|
||||
extern ULO cpuEA73(void);
|
||||
extern uint32_t cpuEA02(uint32_t regno);
|
||||
extern uint32_t cpuEA03(uint32_t regno, uint32_t size);
|
||||
extern uint32_t cpuEA04(uint32_t regno, uint32_t size);
|
||||
extern uint32_t cpuEA05(uint32_t regno);
|
||||
extern uint32_t cpuEA06(uint32_t regno);
|
||||
extern uint32_t cpuEA70(void);
|
||||
extern uint32_t cpuEA71(void);
|
||||
extern uint32_t cpuEA72(void);
|
||||
extern uint32_t cpuEA73(void);
|
||||
|
||||
// Flags
|
||||
extern void cpuSetFlagsAdd(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm);
|
||||
extern void cpuSetFlagsSub(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm);
|
||||
extern void cpuSetFlagsCmp(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm);
|
||||
extern void cpuSetZFlagBitOpsB(UBY res);
|
||||
extern void cpuSetZFlagBitOpsL(ULO res);
|
||||
extern void cpuSetZFlagBitOpsB(uint8_t res);
|
||||
extern void cpuSetZFlagBitOpsL(uint32_t res);
|
||||
|
||||
extern void cpuSetFlagsNZ00NewB(UBY res);
|
||||
extern void cpuSetFlagsNZ00NewW(UWO res);
|
||||
extern void cpuSetFlagsNZ00NewL(ULO res);
|
||||
extern void cpuSetFlagsNZ00New64(LLO res);
|
||||
extern void cpuSetFlagsNZ00NewB(uint8_t res);
|
||||
extern void cpuSetFlagsNZ00NewW(uint16_t res);
|
||||
extern void cpuSetFlagsNZ00NewL(uint32_t res);
|
||||
extern void cpuSetFlagsNZ00New64(int64_t res);
|
||||
|
||||
extern void cpuSetFlagZ(BOOLE f);
|
||||
extern void cpuSetFlagN(BOOLE f);
|
||||
|
@ -130,16 +123,17 @@ extern void cpuSetFlagsVC(BOOLE v, BOOLE c);
|
|||
extern void cpuSetFlagsShiftZero(BOOLE z, BOOLE rm);
|
||||
extern void cpuSetFlagsShift(BOOLE z, BOOLE rm, BOOLE c, BOOLE v);
|
||||
extern void cpuSetFlagsRotate(BOOLE z, BOOLE rm, BOOLE c);
|
||||
extern void cpuSetFlagsRotateX(UWO z, UWO rm, UWO x);
|
||||
extern void cpuSetFlagsRotateX(uint16_t z, uint16_t rm, uint16_t x);
|
||||
extern void cpuSetFlagsAddX(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm);
|
||||
extern void cpuSetFlagsSubX(BOOLE z, BOOLE rm, BOOLE dm, BOOLE sm);
|
||||
extern void cpuSetFlagsAbs(UWO f);
|
||||
extern UWO cpuGetZFlagB(UBY res);
|
||||
extern UWO cpuGetZFlagW(UWO res);
|
||||
extern UWO cpuGetZFlagL(ULO res);
|
||||
extern UWO cpuGetNFlagB(UBY res);
|
||||
extern UWO cpuGetNFlagW(UWO res);
|
||||
extern UWO cpuGetNFlagL(ULO res);
|
||||
extern void cpuSetFlagsAbs(uint16_t f);
|
||||
extern uint16_t cpuGetZFlagB(uint8_t res);
|
||||
extern uint16_t cpuGetZFlagW(uint16_t res);
|
||||
extern uint16_t cpuGetZFlagL(uint32_t res);
|
||||
extern uint16_t cpuGetNFlagB(uint8_t res);
|
||||
extern uint16_t cpuGetNFlagW(uint16_t res);
|
||||
extern uint16_t cpuGetNFlagL(uint32_t res);
|
||||
extern void cpuClearFlagsVC(void);
|
||||
|
||||
extern BOOLE cpuCalculateConditionCode0(void);
|
||||
extern BOOLE cpuCalculateConditionCode1(void);
|
||||
|
@ -157,53 +151,47 @@ extern BOOLE cpuCalculateConditionCode12(void);
|
|||
extern BOOLE cpuCalculateConditionCode13(void);
|
||||
extern BOOLE cpuCalculateConditionCode14(void);
|
||||
extern BOOLE cpuCalculateConditionCode15(void);
|
||||
extern BOOLE cpuCalculateConditionCode(ULO cc);
|
||||
extern BOOLE cpuCalculateConditionCode(uint32_t cc);
|
||||
|
||||
// Logging
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
extern void cpuCallInstructionLoggingFunc(void);
|
||||
extern void cpuCallExceptionLoggingFunc(STR *description, ULO original_pc, UWO opcode);
|
||||
extern void cpuCallInterruptLoggingFunc(ULO level, ULO vector_address);
|
||||
extern void cpuCallExceptionLoggingFunc(char *description, uint32_t original_pc, uint16_t opcode);
|
||||
extern void cpuCallInterruptLoggingFunc(uint32_t level, uint32_t vector_address);
|
||||
#endif
|
||||
|
||||
// Interrupt
|
||||
extern ULO cpuActivateSSP(void);
|
||||
extern uint32_t cpuActivateSSP(void);
|
||||
extern void cpuSetRaiseInterrupt(BOOLE raise_irq);
|
||||
extern BOOLE cpuGetRaiseInterrupt(void);
|
||||
extern void cpuSetRaiseInterruptLevel(ULO raise_irq_level);
|
||||
extern ULO cpuGetRaiseInterruptLevel(void);
|
||||
extern void cpuSetRaiseInterruptLevel(uint32_t raise_irq_level);
|
||||
extern uint32_t cpuGetRaiseInterruptLevel(void);
|
||||
|
||||
// Exceptions
|
||||
extern void cpuThrowPrivilegeViolationException(void);
|
||||
extern void cpuThrowIllegalInstructionException(BOOLE executejmp);
|
||||
extern void cpuThrowIllegalInstructionExceptionFromBreakpoint(void);
|
||||
extern void cpuThrowFLineException(void);
|
||||
extern void cpuThrowALineException(void);
|
||||
extern void cpuThrowTrapVException(void);
|
||||
extern void cpuThrowTrapException(ULO vector_no);
|
||||
extern void cpuThrowDivisionByZeroException(BOOLE executejmp);
|
||||
extern void cpuThrowTrapException(uint32_t vector_no);
|
||||
extern void cpuThrowDivisionByZeroException(void);
|
||||
extern void cpuThrowChkException(void);
|
||||
extern void cpuThrowTraceException(void);
|
||||
extern void cpuThrowResetException(void);
|
||||
extern void cpuCallResetExceptionFunc(void);
|
||||
extern void cpuFrame1(UWO vector_offset, ULO pc);
|
||||
extern void cpuFrame1(uint16_t vector_offset, uint32_t pc);
|
||||
|
||||
// Private help functions
|
||||
static ULO cpuSignExtByteToLong(UBY v) {return (ULO)(LON)(BYT) v;}
|
||||
static UWO cpuSignExtByteToWord(UBY v) {return (UWO)(WOR)(BYT) v;}
|
||||
static ULO cpuSignExtWordToLong(UWO v) {return (ULO)(LON)(WOR) v;}
|
||||
static ULO cpuJoinWordToLong(UWO upper, UWO lower) {return (((ULO)upper) << 16) | ((ULO)lower);}
|
||||
static ULO cpuJoinByteToLong(UBY upper, UBY midh, UBY midl, UBY lower) {return (((ULO)upper) << 24) | (((ULO)midh) << 16) | (((ULO)midl) << 8) | ((ULO)lower);}
|
||||
static UWO cpuJoinByteToWord(UBY upper, UBY lower) {return (((UWO)upper) << 8) | ((UWO)lower);}
|
||||
static BOOLE cpuMsbB(UBY v) {return v>>7;}
|
||||
static BOOLE cpuMsbW(UWO v) {return v>>15;}
|
||||
static BOOLE cpuMsbL(ULO v) {return v>>31;}
|
||||
static BOOLE cpuIsZeroB(UBY v) {return v == 0;}
|
||||
static BOOLE cpuIsZeroW(UWO v) {return v == 0;}
|
||||
static BOOLE cpuIsZeroL(ULO v) {return v == 0;}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
static uint32_t cpuSignExtByteToLong(uint8_t v) {return (uint32_t)(int32_t)(int8_t) v;}
|
||||
static uint16_t cpuSignExtByteToWord(uint8_t v) {return (uint16_t)(int16_t)(int8_t) v;}
|
||||
static uint32_t cpuSignExtWordToLong(uint16_t v) {return (uint32_t)(int32_t)(int16_t) v;}
|
||||
static uint32_t cpuJoinWordToLong(uint16_t upper, uint16_t lower) {return (((uint32_t)upper) << 16) | ((uint32_t)lower);}
|
||||
static uint32_t cpuJoinByteToLong(uint8_t upper, uint8_t midh, uint8_t midl, uint8_t lower) {return (((uint32_t)upper) << 24) | (((uint32_t)midh) << 16) | (((uint32_t)midl) << 8) | ((uint32_t)lower);}
|
||||
static uint16_t cpuJoinByteToWord(uint8_t upper, uint8_t lower) {return (((uint16_t)upper) << 8) | ((uint16_t)lower);}
|
||||
static BOOLE cpuMsbB(uint8_t v) {return v>>7;}
|
||||
static BOOLE cpuMsbW(uint16_t v) {return v>>15;}
|
||||
static BOOLE cpuMsbL(uint32_t v) {return v>>31;}
|
||||
static BOOLE cpuIsZeroB(uint8_t v) {return v == 0;}
|
||||
static BOOLE cpuIsZeroW(uint16_t v) {return v == 0;}
|
||||
static BOOLE cpuIsZeroL(uint32_t v) {return v == 0;}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_InternalState.c,v 1.9 2012-08-12 16:51:02 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* 68000 internal state */
|
||||
|
@ -23,62 +22,62 @@
|
|||
/*=========================================================================*/
|
||||
#include "defs.h"
|
||||
#include "CpuModule.h"
|
||||
#include "fellow.h"
|
||||
#include "fmem.h"
|
||||
#include "CpuModule_Memory.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
/* M68k registers */
|
||||
static ULO cpu_regs[2][8]; /* 0 - data, 1 - address */
|
||||
static ULO cpu_pc;
|
||||
static ULO cpu_usp;
|
||||
static ULO cpu_ssp;
|
||||
static ULO cpu_msp;
|
||||
static ULO cpu_sfc;
|
||||
static ULO cpu_dfc;
|
||||
ULO cpu_sr; // Not static because flags calculation use it extensively
|
||||
static ULO cpu_vbr;
|
||||
static UWO cpu_prefetch_word;
|
||||
static ULO cpu_cacr;
|
||||
static ULO cpu_caar;
|
||||
static uint32_t cpu_regs[2][8]; /* 0 - data, 1 - address */
|
||||
static uint32_t cpu_pc;
|
||||
static uint32_t cpu_usp;
|
||||
static uint32_t cpu_ssp;
|
||||
static uint32_t cpu_msp;
|
||||
static uint32_t cpu_sfc;
|
||||
static uint32_t cpu_dfc;
|
||||
uint32_t cpu_sr; // Not static because flags calculation use it extensively
|
||||
static uint32_t cpu_vbr;
|
||||
static uint16_t cpu_prefetch_word;
|
||||
static uint32_t cpu_cacr;
|
||||
static uint32_t cpu_caar;
|
||||
|
||||
/* Irq management */
|
||||
static BOOLE cpu_raise_irq;
|
||||
static ULO cpu_raise_irq_level;
|
||||
static uint32_t cpu_raise_irq_level;
|
||||
|
||||
/* Reset values */
|
||||
static ULO cpu_initial_pc;
|
||||
static ULO cpu_initial_sp;
|
||||
static uint32_t cpu_initial_pc;
|
||||
static uint32_t cpu_initial_sp;
|
||||
|
||||
/* Flag set if CPU is stopped */
|
||||
static BOOLE cpu_stop;
|
||||
|
||||
/* The current CPU model */
|
||||
static ULO cpu_model_major = -1;
|
||||
static ULO cpu_model_minor;
|
||||
static UBY cpu_model_mask;
|
||||
static uint32_t cpu_model_major = -1;
|
||||
static uint32_t cpu_model_minor;
|
||||
static uint8_t cpu_model_mask;
|
||||
|
||||
/* For exception handling */
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
|
||||
static UWO cpu_current_opcode;
|
||||
static uint16_t cpu_current_opcode;
|
||||
|
||||
#endif
|
||||
|
||||
static ULO cpu_original_pc;
|
||||
static uint32_t cpu_original_pc;
|
||||
static bool cpu_instruction_aborted;
|
||||
|
||||
/* Number of cycles taken by the last intstruction */
|
||||
static ULO cpu_instruction_time;
|
||||
static uint32_t cpu_instruction_time;
|
||||
|
||||
/* Getters and setters */
|
||||
|
||||
void cpuSetDReg(ULO i, ULO value) {cpu_regs[0][i] = value;}
|
||||
ULO cpuGetDReg(ULO i) {return cpu_regs[0][i];}
|
||||
void cpuSetDReg(uint32_t i, uint32_t value) {cpu_regs[0][i] = value;}
|
||||
uint32_t cpuGetDReg(uint32_t i) {return cpu_regs[0][i];}
|
||||
|
||||
void cpuSetAReg(ULO i, ULO value) {cpu_regs[1][i] = value;}
|
||||
ULO cpuGetAReg(ULO i) {return cpu_regs[1][i];}
|
||||
void cpuSetAReg(uint32_t i, uint32_t value) {cpu_regs[1][i] = value;}
|
||||
uint32_t cpuGetAReg(uint32_t i) {return cpu_regs[1][i];}
|
||||
|
||||
void cpuSetReg(ULO da, ULO i, ULO value) {cpu_regs[da][i] = value;}
|
||||
ULO cpuGetReg(ULO da, ULO i) {return cpu_regs[da][i];}
|
||||
void cpuSetReg(uint32_t da, uint32_t i, uint32_t value) {cpu_regs[da][i] = value;}
|
||||
uint32_t cpuGetReg(uint32_t da, uint32_t i) {return cpu_regs[da][i];}
|
||||
|
||||
/// <summary>
|
||||
/// Get the supervisor bit from sr.
|
||||
|
@ -96,21 +95,21 @@ BOOLE cpuGetFlagMaster(void)
|
|||
return cpu_sr & 0x1000;
|
||||
}
|
||||
|
||||
void cpuSetUspDirect(ULO usp) {cpu_usp = usp;}
|
||||
ULO cpuGetUspDirect(void) {return cpu_usp;}
|
||||
ULO cpuGetUspAutoMap(void) {return (cpuGetFlagSupervisor()) ? cpuGetUspDirect() : cpuGetAReg(7);}
|
||||
void cpuSetUspDirect(uint32_t usp) {cpu_usp = usp;}
|
||||
uint32_t cpuGetUspDirect() {return cpu_usp;}
|
||||
uint32_t cpuGetUspAutoMap() {return (cpuGetFlagSupervisor()) ? cpuGetUspDirect() : cpuGetAReg(7);}
|
||||
|
||||
void cpuSetSspDirect(ULO ssp) {cpu_ssp = ssp;}
|
||||
ULO cpuGetSspDirect(void) {return cpu_ssp;}
|
||||
ULO cpuGetSspAutoMap(void) {return (cpuGetFlagSupervisor()) ? cpuGetAReg(7) : cpuGetSspDirect();}
|
||||
void cpuSetSspDirect(uint32_t ssp) {cpu_ssp = ssp;}
|
||||
uint32_t cpuGetSspDirect() {return cpu_ssp;}
|
||||
uint32_t cpuGetSspAutoMap() {return (cpuGetFlagSupervisor()) ? cpuGetAReg(7) : cpuGetSspDirect();}
|
||||
|
||||
void cpuSetMspDirect(ULO msp) {cpu_msp = msp;}
|
||||
ULO cpuGetMspDirect(void) {return cpu_msp;}
|
||||
void cpuSetMspDirect(uint32_t msp) {cpu_msp = msp;}
|
||||
uint32_t cpuGetMspDirect() {return cpu_msp;}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the master stack pointer.
|
||||
/// </summary>
|
||||
ULO cpuGetMspAutoMap(void)
|
||||
uint32_t cpuGetMspAutoMap(void)
|
||||
{
|
||||
if (cpuGetFlagSupervisor() && cpuGetFlagMaster())
|
||||
{
|
||||
|
@ -122,7 +121,7 @@ ULO cpuGetMspAutoMap(void)
|
|||
/// <summary>
|
||||
/// Sets the master stack pointer.
|
||||
/// </summary>
|
||||
void cpuSetMspAutoMap(ULO new_msp)
|
||||
void cpuSetMspAutoMap(uint32_t new_msp)
|
||||
{
|
||||
if (cpuGetFlagSupervisor() && cpuGetFlagMaster())
|
||||
{
|
||||
|
@ -137,7 +136,7 @@ void cpuSetMspAutoMap(ULO new_msp)
|
|||
/// <summary>
|
||||
/// Returns the interrupt stack pointer. ssp is used as isp.
|
||||
/// </summary>
|
||||
ULO cpuGetIspAutoMap(void)
|
||||
uint32_t cpuGetIspAutoMap(void)
|
||||
{
|
||||
if (cpuGetFlagSupervisor() && !cpuGetFlagMaster())
|
||||
{
|
||||
|
@ -149,7 +148,7 @@ ULO cpuGetIspAutoMap(void)
|
|||
/// <summary>
|
||||
/// Sets the interrupt stack pointer. ssp is used as isp.
|
||||
/// </summary>
|
||||
void cpuSetIspAutoMap(ULO new_isp)
|
||||
void cpuSetIspAutoMap(uint32_t new_isp)
|
||||
{
|
||||
if (cpuGetFlagSupervisor() && !cpuGetFlagMaster())
|
||||
{
|
||||
|
@ -161,61 +160,64 @@ void cpuSetIspAutoMap(ULO new_isp)
|
|||
}
|
||||
}
|
||||
|
||||
void cpuSetPC(ULO address) {cpu_pc = address;}
|
||||
ULO cpuGetPC(void) {return cpu_pc;}
|
||||
void cpuSetPC(uint32_t address) {cpu_pc = address;}
|
||||
uint32_t cpuGetPC() {return cpu_pc;}
|
||||
|
||||
void cpuSetStop(BOOLE stop) {cpu_stop = stop;}
|
||||
BOOLE cpuGetStop(void) {return cpu_stop;}
|
||||
BOOLE cpuGetStop() {return cpu_stop;}
|
||||
|
||||
void cpuSetVbr(ULO vbr) {cpu_vbr = vbr;}
|
||||
ULO cpuGetVbr(void) {return cpu_vbr;}
|
||||
void cpuSetVbr(uint32_t vbr) {cpu_vbr = vbr;}
|
||||
uint32_t cpuGetVbr() {return cpu_vbr;}
|
||||
|
||||
void cpuSetSfc(ULO sfc) {cpu_sfc = sfc;}
|
||||
ULO cpuGetSfc(void) {return cpu_sfc;}
|
||||
void cpuSetSfc(uint32_t sfc) {cpu_sfc = sfc;}
|
||||
uint32_t cpuGetSfc() {return cpu_sfc;}
|
||||
|
||||
void cpuSetDfc(ULO dfc) {cpu_dfc = dfc;}
|
||||
ULO cpuGetDfc(void) {return cpu_dfc;}
|
||||
void cpuSetDfc(uint32_t dfc) {cpu_dfc = dfc;}
|
||||
uint32_t cpuGetDfc() {return cpu_dfc;}
|
||||
|
||||
void cpuSetCacr(ULO cacr) {cpu_cacr = cacr;}
|
||||
ULO cpuGetCacr(void) {return cpu_cacr;}
|
||||
void cpuSetCacr(uint32_t cacr) {cpu_cacr = cacr;}
|
||||
uint32_t cpuGetCacr() {return cpu_cacr;}
|
||||
|
||||
void cpuSetCaar(ULO caar) {cpu_caar = caar;}
|
||||
ULO cpuGetCaar(void) {return cpu_caar;}
|
||||
void cpuSetCaar(uint32_t caar) {cpu_caar = caar;}
|
||||
uint32_t cpuGetCaar() {return cpu_caar;}
|
||||
|
||||
void cpuSetSR(ULO sr) {cpu_sr = sr;}
|
||||
ULO cpuGetSR(void) {return cpu_sr;}
|
||||
void cpuSetSR(uint32_t sr) {cpu_sr = sr;}
|
||||
uint32_t cpuGetSR() {return cpu_sr;}
|
||||
|
||||
void cpuSetInstructionTime(ULO cycles) {cpu_instruction_time = cycles;}
|
||||
ULO cpuGetInstructionTime(void) {return cpu_instruction_time;}
|
||||
void cpuSetInstructionTime(uint32_t cycles) {cpu_instruction_time = cycles;}
|
||||
uint32_t cpuGetInstructionTime() {return cpu_instruction_time;}
|
||||
|
||||
void cpuSetOriginalPC(ULO pc) {cpu_original_pc = pc;}
|
||||
ULO cpuGetOriginalPC(void) {return cpu_original_pc;}
|
||||
void cpuSetOriginalPC(uint32_t pc) {cpu_original_pc = pc;}
|
||||
uint32_t cpuGetOriginalPC() {return cpu_original_pc;}
|
||||
|
||||
void cpuSetInstructionAborted(bool aborted) {cpu_instruction_aborted = aborted;}
|
||||
bool cpuGetInstructionAborted() {return cpu_instruction_aborted;}
|
||||
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
|
||||
void cpuSetCurrentOpcode(UWO opcode) {cpu_current_opcode = opcode;}
|
||||
UWO cpuGetCurrentOpcode(void) {return cpu_current_opcode;}
|
||||
void cpuSetCurrentOpcode(uint16_t opcode) {cpu_current_opcode = opcode;}
|
||||
uint16_t cpuGetCurrentOpcode() {return cpu_current_opcode;}
|
||||
|
||||
#endif
|
||||
|
||||
void cpuSetRaiseInterrupt(BOOLE raise_irq) {cpu_raise_irq = raise_irq;}
|
||||
BOOLE cpuGetRaiseInterrupt(void) {return cpu_raise_irq;}
|
||||
void cpuSetRaiseInterruptLevel(ULO raise_irq_level) {cpu_raise_irq_level = raise_irq_level;}
|
||||
ULO cpuGetRaiseInterruptLevel(void) {return cpu_raise_irq_level;}
|
||||
BOOLE cpuGetRaiseInterrupt() {return cpu_raise_irq;}
|
||||
void cpuSetRaiseInterruptLevel(uint32_t raise_irq_level) {cpu_raise_irq_level = raise_irq_level;}
|
||||
uint32_t cpuGetRaiseInterruptLevel() {return cpu_raise_irq_level;}
|
||||
|
||||
ULO cpuGetIrqLevel(void) {return (cpu_sr & 0x0700) >> 8;}
|
||||
uint32_t cpuGetIrqLevel() {return (cpu_sr & 0x0700) >> 8;}
|
||||
|
||||
void cpuSetInitialPC(ULO pc) {cpu_initial_pc = pc;}
|
||||
ULO cpuGetInitialPC(void) {return cpu_initial_pc;}
|
||||
void cpuSetInitialPC(uint32_t pc) {cpu_initial_pc = pc;}
|
||||
uint32_t cpuGetInitialPC() {return cpu_initial_pc;}
|
||||
|
||||
void cpuSetInitialSP(ULO sp) {cpu_initial_sp = sp;}
|
||||
ULO cpuGetInitialSP(void) {return cpu_initial_sp;}
|
||||
void cpuSetInitialSP(uint32_t sp) {cpu_initial_sp = sp;}
|
||||
uint32_t cpuGetInitialSP() {return cpu_initial_sp;}
|
||||
|
||||
void cpuSetModelMask(UBY model_mask) {cpu_model_mask = model_mask;}
|
||||
UBY cpuGetModelMask(void) {return cpu_model_mask;}
|
||||
void cpuSetModelMask(uint8_t model_mask) {cpu_model_mask = model_mask;}
|
||||
uint8_t cpuGetModelMask() {return cpu_model_mask;}
|
||||
|
||||
ULO cpuGetModelMajor(void) {return cpu_model_major;}
|
||||
ULO cpuGetModelMinor(void) {return cpu_model_minor;}
|
||||
uint32_t cpuGetModelMajor() {return cpu_model_major;}
|
||||
uint32_t cpuGetModelMinor() {return cpu_model_minor;}
|
||||
|
||||
static void cpuCalculateModelMask(void)
|
||||
{
|
||||
|
@ -236,7 +238,7 @@ static void cpuCalculateModelMask(void)
|
|||
}
|
||||
}
|
||||
|
||||
void cpuSetModel(ULO major, ULO minor)
|
||||
void cpuSetModel(uint32_t major, uint32_t minor)
|
||||
{
|
||||
BOOLE makeOpcodeTable = (cpu_model_major != major);
|
||||
cpu_model_major = major;
|
||||
|
@ -246,53 +248,59 @@ void cpuSetModel(ULO major, ULO minor)
|
|||
if (makeOpcodeTable) cpuMakeOpcodeTableForModel();
|
||||
}
|
||||
|
||||
void cpuSetDRegWord(ULO regno, UWO val) {*((WOR*)&cpu_regs[0][regno]) = val;}
|
||||
void cpuSetDRegByte(ULO regno, UBY val) {*((UBY*)&cpu_regs[0][regno]) = val;}
|
||||
UWO cpuGetRegWord(ULO i, ULO regno) {return (UWO)cpu_regs[i][regno];}
|
||||
#if 0
|
||||
void cpuSetDRegWord(uint32_t regno, uint16_t val) {*((int16_t*)&cpu_regs[0][regno]) = val;}
|
||||
void cpuSetDRegByte(uint32_t regno, uint8_t val) {*((uint8_t*)&cpu_regs[0][regno]) = val;}
|
||||
#else
|
||||
// MPW -- above assumes little endian.
|
||||
void cpuSetDRegWord(uint32_t regno, uint16_t val) {cpu_regs[0][regno] &= 0xffff0000; cpu_regs[0][regno] |= val;}
|
||||
void cpuSetDRegByte(uint32_t regno, uint8_t val) {cpu_regs[0][regno] &= 0xffffff00; cpu_regs[0][regno] |= val;}
|
||||
#endif
|
||||
|
||||
UWO cpuGetDRegWord(ULO regno) {return (UWO)cpu_regs[0][regno];}
|
||||
UBY cpuGetDRegByte(ULO regno) {return (UBY)cpu_regs[0][regno];}
|
||||
uint16_t cpuGetRegWord(uint32_t i, uint32_t regno) {return (uint16_t)cpu_regs[i][regno];}
|
||||
uint16_t cpuGetDRegWord(uint32_t regno) {return (uint16_t)cpu_regs[0][regno];}
|
||||
uint8_t cpuGetDRegByte(uint32_t regno) {return (uint8_t)cpu_regs[0][regno];}
|
||||
|
||||
ULO cpuGetDRegWordSignExtLong(ULO regno) {return cpuSignExtWordToLong(cpuGetDRegWord(regno));}
|
||||
UWO cpuGetDRegByteSignExtWord(ULO regno) {return cpuSignExtByteToWord(cpuGetDRegByte(regno));}
|
||||
ULO cpuGetDRegByteSignExtLong(ULO regno) {return cpuSignExtByteToLong(cpuGetDRegByte(regno));}
|
||||
uint32_t cpuGetDRegWordSignExtLong(uint32_t regno) {return cpuSignExtWordToLong(cpuGetDRegWord(regno));}
|
||||
uint16_t cpuGetDRegByteSignExtWord(uint32_t regno) {return cpuSignExtByteToWord(cpuGetDRegByte(regno));}
|
||||
uint32_t cpuGetDRegByteSignExtLong(uint32_t regno) {return cpuSignExtByteToLong(cpuGetDRegByte(regno));}
|
||||
|
||||
UWO cpuGetARegWord(ULO regno) {return (UWO)cpu_regs[1][regno];}
|
||||
UBY cpuGetARegByte(ULO regno) {return (UBY)cpu_regs[1][regno];}
|
||||
uint16_t cpuGetARegWord(uint32_t regno) {return (uint16_t)cpu_regs[1][regno];}
|
||||
uint8_t cpuGetARegByte(uint32_t regno) {return (uint8_t)cpu_regs[1][regno];}
|
||||
|
||||
typedef UWO (*cpuGetWordFunc)(void);
|
||||
typedef ULO (*cpuGetLongFunc)(void);
|
||||
typedef uint16_t (*cpuGetWordFunc)(void);
|
||||
typedef uint32_t (*cpuGetLongFunc)(void);
|
||||
|
||||
static UWO cpuGetNextWordInternal(void)
|
||||
static uint16_t cpuGetNextWordInternal(void)
|
||||
{
|
||||
UWO data = memoryReadWord(cpuGetPC() + 2);
|
||||
uint16_t data = memoryReadWord(cpuGetPC() + 2);
|
||||
return data;
|
||||
}
|
||||
|
||||
static ULO cpuGetNextLongInternal(void)
|
||||
static uint32_t cpuGetNextLongInternal(void)
|
||||
{
|
||||
ULO data = memoryReadLong(cpuGetPC() + 2);
|
||||
uint32_t data = memoryReadLong(cpuGetPC() + 2);
|
||||
return data;
|
||||
}
|
||||
|
||||
UWO cpuGetNextWord(void)
|
||||
uint16_t cpuGetNextWord(void)
|
||||
{
|
||||
UWO tmp = cpu_prefetch_word;
|
||||
uint16_t tmp = cpu_prefetch_word;
|
||||
cpu_prefetch_word = cpuGetNextWordInternal();
|
||||
cpuSetPC(cpuGetPC() + 2);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
ULO cpuGetNextWordSignExt(void)
|
||||
uint32_t cpuGetNextWordSignExt(void)
|
||||
{
|
||||
return cpuSignExtWordToLong(cpuGetNextWord());
|
||||
}
|
||||
|
||||
ULO cpuGetNextLong(void)
|
||||
uint32_t cpuGetNextLong(void)
|
||||
{
|
||||
ULO tmp = cpu_prefetch_word << 16;
|
||||
ULO data = cpuGetNextLongInternal();
|
||||
cpu_prefetch_word = (UWO) data;
|
||||
uint32_t tmp = cpu_prefetch_word << 16;
|
||||
uint32_t data = cpuGetNextLongInternal();
|
||||
cpu_prefetch_word = (uint16_t) data;
|
||||
cpuSetPC(cpuGetPC() + 4);
|
||||
return tmp | (data >> 16);
|
||||
}
|
||||
|
@ -319,7 +327,7 @@ void cpuSkipNextLong(void)
|
|||
cpuInitializePrefetch();
|
||||
}
|
||||
|
||||
void cpuInitializeFromNewPC(ULO new_pc)
|
||||
void cpuInitializeFromNewPC(uint32_t new_pc)
|
||||
{
|
||||
cpuSetPC(new_pc);
|
||||
cpuInitializePrefetch();
|
||||
|
@ -327,13 +335,11 @@ void cpuInitializeFromNewPC(ULO new_pc)
|
|||
|
||||
void cpuSaveState(FILE *F)
|
||||
{
|
||||
ULO i, j;
|
||||
|
||||
fwrite(&cpu_model_major, sizeof(cpu_model_major), 1, F);
|
||||
fwrite(&cpu_model_minor, sizeof(cpu_model_minor), 1, F);
|
||||
for (i = 0; i < 2; i++)
|
||||
for (uint32_t i = 0; i < 2; i++)
|
||||
{
|
||||
for (j = 0; j < 7; j++)
|
||||
for (uint32_t j = 0; j < 7; j++)
|
||||
{
|
||||
fwrite(&cpu_regs[i][j], sizeof(cpu_regs[i][j]), 1, F);
|
||||
}
|
||||
|
@ -355,13 +361,11 @@ void cpuSaveState(FILE *F)
|
|||
|
||||
void cpuLoadState(FILE *F)
|
||||
{
|
||||
ULO i, j;
|
||||
|
||||
fread(&cpu_model_major, sizeof(cpu_model_major), 1, F);
|
||||
fread(&cpu_model_minor, sizeof(cpu_model_minor), 1, F);
|
||||
for (i = 0; i < 2; i++)
|
||||
for (uint32_t i = 0; i < 2; i++)
|
||||
{
|
||||
for (j = 0; j < 7; j++)
|
||||
for (uint32_t j = 0; j < 7; j++)
|
||||
{
|
||||
fread(&cpu_regs[i][j], sizeof(cpu_regs[i][j]), 1, F);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_Interrupts.c,v 1.5 2012-08-12 16:51:02 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* 68000 interrupt handling */
|
||||
|
@ -22,9 +21,7 @@
|
|||
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/*=========================================================================*/
|
||||
#include "defs.h"
|
||||
#include "fellow.h"
|
||||
#include "fmem.h"
|
||||
|
||||
#include "CpuModule_Memory.h"
|
||||
#include "CpuModule.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
|
@ -34,7 +31,7 @@ cpuCheckPendingInterruptsFunc cpu_check_pending_interrupts_func;
|
|||
void cpuCheckPendingInterrupts(void)
|
||||
{
|
||||
if (cpuGetRaiseInterrupt()) return;
|
||||
if (cpu_check_pending_interrupts_func) cpu_check_pending_interrupts_func();
|
||||
cpu_check_pending_interrupts_func();
|
||||
}
|
||||
|
||||
void cpuSetCheckPendingInterruptsFunc(cpuCheckPendingInterruptsFunc func)
|
||||
|
@ -42,9 +39,9 @@ void cpuSetCheckPendingInterruptsFunc(cpuCheckPendingInterruptsFunc func)
|
|||
cpu_check_pending_interrupts_func = func;
|
||||
}
|
||||
|
||||
ULO cpuActivateSSP(void)
|
||||
uint32_t cpuActivateSSP(void)
|
||||
{
|
||||
ULO currentSP = cpuGetAReg(7);
|
||||
uint32_t currentSP = cpuGetAReg(7);
|
||||
|
||||
// check supervisor bit number (bit 13) within the system byte of the status register
|
||||
if (!cpuGetFlagSupervisor())
|
||||
|
@ -68,7 +65,7 @@ ULO cpuActivateSSP(void)
|
|||
// Retrns TRUE if the CPU is in the stopped state,
|
||||
// this allows our scheduling queue to start
|
||||
// scheduling CPU events again.
|
||||
BOOLE cpuSetIrqLevel(ULO new_interrupt_level)
|
||||
BOOLE cpuSetIrqLevel(uint32_t new_interrupt_level)
|
||||
{
|
||||
cpuSetRaiseInterrupt(TRUE);
|
||||
cpuSetRaiseInterruptLevel(new_interrupt_level);
|
||||
|
@ -85,10 +82,10 @@ BOOLE cpuSetIrqLevel(ULO new_interrupt_level)
|
|||
Transfers control to an interrupt routine
|
||||
============================================================*/
|
||||
|
||||
void cpuSetUpInterrupt(ULO new_interrupt_level)
|
||||
void cpuSetUpInterrupt(uint32_t new_interrupt_level)
|
||||
{
|
||||
UWO vector_offset = (UWO) (0x60 + new_interrupt_level*4);
|
||||
ULO vector_address = memoryReadLong(cpuGetVbr() + vector_offset);
|
||||
uint16_t vector_offset = (uint16_t) (0x60 + new_interrupt_level*4);
|
||||
uint32_t vector_address = memoryReadLong(cpuGetVbr() + vector_offset);
|
||||
|
||||
cpuActivateSSP(); // Switch to using ssp or msp. Loads a7 and preserves usp if we came from user-mode.
|
||||
|
||||
|
@ -96,7 +93,7 @@ void cpuSetUpInterrupt(ULO new_interrupt_level)
|
|||
|
||||
cpuSetSR(cpuGetSR() & 0x38ff); // Clear interrupt level
|
||||
cpuSetSR(cpuGetSR() | 0x2000); // Set supervisor mode
|
||||
cpuSetSR(cpuGetSR() | (UWO)(new_interrupt_level << 8)); // Set interrupt level
|
||||
cpuSetSR(cpuGetSR() | (uint16_t)(new_interrupt_level << 8)); // Set interrupt level
|
||||
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
cpuCallInterruptLoggingFunc(new_interrupt_level, vector_address);
|
||||
|
@ -106,7 +103,7 @@ void cpuSetUpInterrupt(ULO new_interrupt_level)
|
|||
{
|
||||
if (cpuGetFlagMaster())
|
||||
{ // If the cpu was in master mode, preserve msp, and switch to using ssp (isp) in a7.
|
||||
ULO oldA7 = cpuGetAReg(7);
|
||||
uint32_t oldA7 = cpuGetAReg(7);
|
||||
cpuSetMspDirect(oldA7);
|
||||
cpuSetAReg(7, cpuGetSspDirect());
|
||||
cpuFrame1(vector_offset, cpuGetPC()); // Make the throwaway frame on ssp/isp
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_Logging.c,v 1.3 2012-08-12 16:51:02 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* CPU 68k logging functions */
|
||||
|
@ -24,8 +23,6 @@
|
|||
/*=========================================================================*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "fellow.h"
|
||||
|
||||
#include "CpuModule.h"
|
||||
|
||||
#ifdef CPU_INSTRUCTION_LOGGING
|
||||
|
@ -51,7 +48,7 @@ void cpuSetExceptionLoggingFunc(cpuExceptionLoggingFunc func)
|
|||
cpu_exception_logging_func = func;
|
||||
}
|
||||
|
||||
void cpuCallExceptionLoggingFunc(STR *description, ULO original_pc, UWO opcode)
|
||||
void cpuCallExceptionLoggingFunc(char *description, uint32_t original_pc, uint16_t opcode)
|
||||
{
|
||||
if (cpu_exception_logging_func != NULL)
|
||||
cpu_exception_logging_func(description, original_pc, opcode);
|
||||
|
@ -62,7 +59,7 @@ void cpuSetInterruptLoggingFunc(cpuInterruptLoggingFunc func)
|
|||
cpu_interrupt_logging_func = func;
|
||||
}
|
||||
|
||||
void cpuCallInterruptLoggingFunc(ULO level, ULO vector_address)
|
||||
void cpuCallInterruptLoggingFunc(uint32_t level, uint32_t vector_address)
|
||||
{
|
||||
if (cpu_interrupt_logging_func != NULL)
|
||||
cpu_interrupt_logging_func(level, vector_address);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "fmem.h"
|
|
@ -1,8 +1,5 @@
|
|||
#ifndef CPUMODULE_PROFILE_H
|
||||
#define CPUMODULE_PROFILE_H
|
||||
#pragma once
|
||||
|
||||
#include "fileops.h"
|
||||
void cpuProfileWrite(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* @(#) $Id: CpuModule_StackFrameGen.c,v 1.3 2011-07-18 17:22:55 peschau Exp $ */
|
||||
/*=========================================================================*/
|
||||
/* Fellow */
|
||||
/* 68000 stack frame generation */
|
||||
|
@ -22,17 +21,15 @@
|
|||
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/*=========================================================================*/
|
||||
#include "defs.h"
|
||||
#include "fellow.h"
|
||||
#include "fmem.h"
|
||||
|
||||
#include "CpuModule_Memory.h"
|
||||
#include "CpuModule.h"
|
||||
#include "CpuModule_Internal.h"
|
||||
|
||||
/* Exception stack frame jmptables */
|
||||
typedef void(*cpuStackFrameGenFunc)(UWO, ULO);
|
||||
typedef void(*cpuStackFrameGenFunc)(uint16_t, uint32_t);
|
||||
static cpuStackFrameGenFunc cpu_stack_frame_gen_func[64];
|
||||
|
||||
static void cpuSetStackFrameGenFunc(ULO vector_no, cpuStackFrameGenFunc func)
|
||||
static void cpuSetStackFrameGenFunc(uint32_t vector_no, cpuStackFrameGenFunc func)
|
||||
{
|
||||
cpu_stack_frame_gen_func[vector_no] = func;
|
||||
}
|
||||
|
@ -43,7 +40,7 @@ static void cpuSetStackFrameGenFunc(ULO vector_no, cpuStackFrameGenFunc func)
|
|||
000: All, except bus and address error
|
||||
========================================================================*/
|
||||
|
||||
static void cpuFrameGroup1(UWO vector_offset, ULO pcPtr)
|
||||
static void cpuFrameGroup1(uint16_t vector_offset, uint32_t pcPtr)
|
||||
{
|
||||
// save PC
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 4);
|
||||
|
@ -51,7 +48,7 @@ static void cpuFrameGroup1(UWO vector_offset, ULO pcPtr)
|
|||
|
||||
// save SR
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 2);
|
||||
memoryWriteWord((UWO)cpuGetSR(), cpuGetAReg(7));
|
||||
memoryWriteWord((uint16_t)cpuGetSR(), cpuGetAReg(7));
|
||||
}
|
||||
|
||||
/*========================================================================
|
||||
|
@ -63,7 +60,7 @@ static void cpuFrameGroup1(UWO vector_offset, ULO pcPtr)
|
|||
memory_fault_read is TRUE if the access was a read
|
||||
========================================================================*/
|
||||
|
||||
static void cpuFrameGroup2(UWO vector_offset, ULO pcPtr)
|
||||
static void cpuFrameGroup2(uint16_t vector_offset, uint32_t pcPtr)
|
||||
{
|
||||
// save PC
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 4);
|
||||
|
@ -71,7 +68,7 @@ static void cpuFrameGroup2(UWO vector_offset, ULO pcPtr)
|
|||
|
||||
// save SR
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 2);
|
||||
memoryWriteWord((UWO)cpuGetSR(), cpuGetAReg(7));
|
||||
memoryWriteWord((uint16_t)cpuGetSR(), cpuGetAReg(7));
|
||||
|
||||
// fault address, skip ireg
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 6);
|
||||
|
@ -81,7 +78,7 @@ static void cpuFrameGroup2(UWO vector_offset, ULO pcPtr)
|
|||
memoryWriteLong(memory_fault_read << 4, cpuGetAReg(7));
|
||||
}
|
||||
|
||||
static void cpuFrame4Words(UWO frame_code, UWO vector_offset, ULO pc)
|
||||
static void cpuFrame4Words(uint16_t frame_code, uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
// save vector_offset word
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 2);
|
||||
|
@ -93,7 +90,7 @@ static void cpuFrame4Words(UWO frame_code, UWO vector_offset, ULO pc)
|
|||
|
||||
// save SR
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 2);
|
||||
memoryWriteWord((UWO)cpuGetSR(), cpuGetAReg(7));
|
||||
memoryWriteWord((uint16_t)cpuGetSR(), cpuGetAReg(7));
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,7 +110,7 @@ static void cpuFrame4Words(UWO frame_code, UWO vector_offset, ULO pc)
|
|||
030: Same as for 020
|
||||
========================================================================*/
|
||||
|
||||
static void cpuFrame0(UWO vector_offset, ULO pc)
|
||||
static void cpuFrame0(uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
cpuFrame4Words(0x0000, vector_offset, pc);
|
||||
}
|
||||
|
@ -133,7 +130,7 @@ static void cpuFrame0(UWO vector_offset, ULO pc)
|
|||
040: Same as for 020
|
||||
========================================================================*/
|
||||
|
||||
void cpuFrame1(UWO vector_offset, ULO pc)
|
||||
void cpuFrame1(uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
cpuFrame4Words(0x1000, vector_offset, pc);
|
||||
}
|
||||
|
@ -149,7 +146,7 @@ void cpuFrame1(UWO vector_offset, ULO pc)
|
|||
060: Same as for 040
|
||||
========================================================================*/
|
||||
|
||||
static void cpuFrame2(UWO vector_offset, ULO pc)
|
||||
static void cpuFrame2(uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
// save inst address
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 4);
|
||||
|
@ -164,7 +161,7 @@ static void cpuFrame2(UWO vector_offset, ULO pc)
|
|||
|
||||
========================================================================*/
|
||||
|
||||
static void cpuFrame8(UWO vector_offset, ULO pc)
|
||||
static void cpuFrame8(uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 50);
|
||||
cpuFrame4Words(0x8000, vector_offset, pc);
|
||||
|
@ -180,14 +177,14 @@ static void cpuFrame8(UWO vector_offset, ULO pc)
|
|||
Fellow will always generate this frame for bus/address errors
|
||||
========================================================================*/
|
||||
|
||||
static void cpuFrameA(UWO vector_offset, ULO pc)
|
||||
static void cpuFrameA(uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
// save vector_offset offset
|
||||
cpuSetAReg(7, cpuGetAReg(7) - 24);
|
||||
cpuFrame4Words(0xa000, vector_offset, pc);
|
||||
}
|
||||
|
||||
void cpuStackFrameGenerate(UWO vector_offset, ULO pc)
|
||||
void cpuStackFrameGenerate(uint16_t vector_offset, uint32_t pc)
|
||||
{
|
||||
cpu_stack_frame_gen_func[vector_offset>>2](vector_offset, pc);
|
||||
}
|
||||
|
@ -198,8 +195,7 @@ void cpuStackFrameGenerate(UWO vector_offset, ULO pc)
|
|||
|
||||
static void cpuStackFrameInitSetDefaultFunc(cpuStackFrameGenFunc default_func)
|
||||
{
|
||||
ULO i;
|
||||
for (i = 0; i < 64; i++)
|
||||
for (uint32_t i = 0; i < 64; i++)
|
||||
cpuSetStackFrameGenFunc(i, default_func);
|
||||
}
|
||||
|
||||
|
|
50
cpu/defs.h
50
cpu/defs.h
|
@ -1,14 +1,10 @@
|
|||
#ifndef DEFS_H
|
||||
#define DEFS_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Maximum values for memory, don't change */
|
||||
|
||||
|
@ -17,27 +13,19 @@ extern "C" {
|
|||
#define BOGOMEM 0x1c0000
|
||||
#define KICKMEM 0x080000
|
||||
|
||||
/* Fellow types to ensure correct sizes */
|
||||
|
||||
typedef uint8_t UBY;
|
||||
typedef uint16_t UWO;
|
||||
typedef uint32_t ULO;
|
||||
typedef uint64_t ULL;
|
||||
typedef int8_t BYT;
|
||||
typedef int16_t WOR;
|
||||
typedef int32_t LON;
|
||||
typedef int64_t LLO;
|
||||
typedef int BOOLE;
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
typedef char STR;
|
||||
|
||||
/*
|
||||
#ifndef X64
|
||||
#define PTR_TO_INT(i) ((ULO)i)
|
||||
#define PTR_TO_INT(i) ((uint32_t)i)
|
||||
#define PTR_TO_INT_MASK_TYPE(i) ((uint32_t)i)
|
||||
#endif
|
||||
#ifdef X64
|
||||
#define PTR_TO_INT(i) ((ULL)i)
|
||||
#define PTR_TO_INT(i) ((uint64_t)i)
|
||||
#define PTR_TO_INT_MASK_TYPE(i) ((uint64_t)i)
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
@ -49,17 +37,17 @@ typedef char STR;
|
|||
/* The decode routines have this type */
|
||||
/*------------------------------------*/
|
||||
|
||||
typedef void (*decoderoutinetype)(ULO,ULO);
|
||||
typedef void (*decoderoutinetype)(uint32_t, uint32_t);
|
||||
|
||||
extern UBY configromname[];
|
||||
extern uint8_t configromname[];
|
||||
|
||||
typedef union {
|
||||
ULO *lptr;
|
||||
UWO *wptr;
|
||||
UBY *bptr;
|
||||
ULO lval;
|
||||
UWO wval[2];
|
||||
UBY bval[4];
|
||||
uint32_t *lptr;
|
||||
uint16_t *wptr;
|
||||
uint8_t *bptr;
|
||||
uint32_t lval;
|
||||
uint16_t wval[2];
|
||||
uint8_t bval[4];
|
||||
} ptunion;
|
||||
|
||||
typedef void (*planar2chunkyroutine)(void);
|
||||
|
@ -69,13 +57,3 @@ typedef void (*sound_before_emu_routine)(void);
|
|||
typedef void (*sound_after_emu_routine)(void);
|
||||
|
||||
typedef void (*buseventfunc)(void);
|
||||
|
||||
#define FELLOWVERSION "WinFellow alpha v0.5.0 build 0 (CVS)"
|
||||
#define FELLOWLONGVERSION "WinFellow Amiga Emulator alpha v0.5.0 - CVS"
|
||||
#define FELLOWNUMERICVERSION "0.5.0.0"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
1692
cpu/fmem.c
1692
cpu/fmem.c
File diff suppressed because it is too large
Load Diff
152
cpu/fmem.h
152
cpu/fmem.h
|
@ -1,41 +1,50 @@
|
|||
#ifndef FMEM_H
|
||||
#define FMEM_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// new functions
|
||||
|
||||
// MPW
|
||||
extern void memorySetMemory(uint8_t *memory, uint32_t size);
|
||||
extern void memorySetGlobalLog(uint32_t globalLog);
|
||||
extern uint8_t *memoryPointer(uint32_t address);
|
||||
|
||||
|
||||
/* Access for chipset emulation that already have validated addresses */
|
||||
|
||||
#define chipmemReadByte(address) (memory_chip[address])
|
||||
#define chipmemReadWord(address) ((((uint16_t) memory_chip[address]) << 8) | ((uint16_t) memory_chip[address + 1]))
|
||||
#define chipmemWriteWord(data, address) \
|
||||
memory_chip[address] = (uint8_t) (data >> 8); \
|
||||
memory_chip[address + 1] = (uint8_t) data
|
||||
|
||||
/* Memory access functions */
|
||||
|
||||
extern UBY memoryReadByte(ULO address);
|
||||
extern UWO memoryReadWord(ULO address);
|
||||
extern ULO memoryReadLong(ULO address);
|
||||
extern uint64_t memoryReadLongLong(ULO address);
|
||||
extern void memoryWriteByte(UBY data, ULO address);
|
||||
extern void memoryWriteWord(UWO data, ULO address);
|
||||
extern void memoryWriteLong(ULO data, ULO address);
|
||||
extern void memoryWriteLongLong(uint64_t data, ULO address);
|
||||
extern uint8_t memoryReadByte(uint32_t address);
|
||||
extern uint16_t memoryReadWord(uint32_t address);
|
||||
extern uint32_t memoryReadLong(uint32_t address);
|
||||
extern uint64_t memoryReadLongLong(uint32_t address);
|
||||
extern void memoryWriteByte(uint8_t data, uint32_t address);
|
||||
extern void memoryWriteWord(uint16_t data, uint32_t address);
|
||||
extern void memoryWriteLong(uint32_t data, uint32_t address);
|
||||
extern void memoryWriteLongLong(uint64_t data, uint32_t address);
|
||||
|
||||
extern UWO memoryChipReadWord(ULO address);
|
||||
extern void memoryChipWriteWord(UWO data, ULO address);
|
||||
extern uint16_t memoryChipReadWord(uint32_t address);
|
||||
extern void memoryChipWriteWord(uint16_t data, uint32_t address);
|
||||
|
||||
#define memoryReadByteFromPointer(address) (address[0])
|
||||
#define memoryReadWordFromPointer(address) ((address[0] << 8) | address[1])
|
||||
#define memoryReadLongFromPointer(address) ((address[0] << 24) | (address[1] << 16) | (address[2] << 8) | address[3])
|
||||
|
||||
extern void memoryWriteLongToPointer(uint32_t data, uint8_t *address);
|
||||
|
||||
/* IO Bank functions */
|
||||
|
||||
typedef UWO (*memoryIoReadFunc)(ULO address);
|
||||
typedef void (*memoryIoWriteFunc)(UWO data, ULO address);
|
||||
typedef uint16_t (*memoryIoReadFunc)(uint32_t address);
|
||||
typedef void (*memoryIoWriteFunc)(uint16_t data, uint32_t address);
|
||||
|
||||
extern void memorySetIoReadStub(ULO index, memoryIoReadFunc ioreadfunction);
|
||||
extern void memorySetIoWriteStub(ULO index, memoryIoWriteFunc iowritefunction);
|
||||
extern void memorySetIoReadStub(uint32_t index, memoryIoReadFunc ioreadfunction);
|
||||
extern void memorySetIoWriteStub(uint32_t index, memoryIoWriteFunc iowritefunction);
|
||||
|
||||
/* For the copper */
|
||||
extern memoryIoWriteFunc memory_iobank_write[257];
|
||||
|
@ -43,23 +52,24 @@ extern memoryIoWriteFunc memory_iobank_write[257];
|
|||
/* Expansion card functions */
|
||||
|
||||
typedef void (*memoryEmemCardInitFunc)(void);
|
||||
typedef void (*memoryEmemCardMapFunc)(ULO);
|
||||
typedef void (*memoryEmemCardMapFunc)(uint32_t);
|
||||
|
||||
extern void memoryEmemClear(void);
|
||||
extern void memoryEmemCardAdd(memoryEmemCardInitFunc cardinit,
|
||||
memoryEmemCardMapFunc cardmap);
|
||||
extern void memoryEmemSet(ULO index, ULO data);
|
||||
extern void memoryEmemMirror(ULO emem_offset, UBY *src, ULO size);
|
||||
extern void memoryEmemSet(uint32_t index, uint32_t data);
|
||||
extern void memoryEmemMirror(uint32_t emem_offset, uint8_t *src, uint32_t size);
|
||||
|
||||
/* Device memory functions. fhfile is using these. */
|
||||
|
||||
extern void memoryDmemSetByte(UBY data);
|
||||
extern void memoryDmemSetWord(UWO data);
|
||||
extern void memoryDmemSetLong(ULO data);
|
||||
extern void memoryDmemSetLongNoCounter(ULO data, ULO offset);
|
||||
extern void memoryDmemSetString(STR *data);
|
||||
extern void memoryDmemSetCounter(ULO val);
|
||||
extern ULO memoryDmemGetCounter(void);
|
||||
extern void memoryDmemSetByte(uint8_t data);
|
||||
extern void memoryDmemSetWord(uint16_t data);
|
||||
extern void memoryDmemSetLong(uint32_t data);
|
||||
extern void memoryDmemSetLongNoCounter(uint32_t data, uint32_t offset);
|
||||
extern void memoryDmemSetString(const char *data);
|
||||
extern void memoryDmemSetCounter(uint32_t val);
|
||||
extern uint32_t memoryDmemGetCounter(void);
|
||||
extern uint32_t memoryDmemGetCounterWithoutOffset(void);
|
||||
extern void memoryDmemClear(void);
|
||||
|
||||
/* Module management functions */
|
||||
|
@ -76,12 +86,12 @@ extern void memoryShutdown(void);
|
|||
|
||||
/* Memory bank functions */
|
||||
|
||||
typedef UBY (*memoryReadByteFunc)(ULO address);
|
||||
typedef UWO (*memoryReadWordFunc)(ULO address);
|
||||
typedef ULO (*memoryReadLongFunc)(ULO address);
|
||||
typedef void (*memoryWriteByteFunc)(UBY data, ULO address);
|
||||
typedef void (*memoryWriteWordFunc)(UWO data, ULO address);
|
||||
typedef void (*memoryWriteLongFunc)(ULO data, ULO address);
|
||||
typedef uint8_t (*memoryReadByteFunc)(uint32_t address);
|
||||
typedef uint16_t (*memoryReadWordFunc)(uint32_t address);
|
||||
typedef uint32_t (*memoryReadLongFunc)(uint32_t address);
|
||||
typedef void (*memoryWriteByteFunc)(uint8_t data, uint32_t address);
|
||||
typedef void (*memoryWriteWordFunc)(uint16_t data, uint32_t address);
|
||||
typedef void (*memoryWriteLongFunc)(uint32_t data, uint32_t address);
|
||||
|
||||
extern memoryReadByteFunc memory_bank_readbyte[65536];
|
||||
extern memoryReadWordFunc memory_bank_readword[65536];
|
||||
|
@ -90,8 +100,8 @@ extern memoryWriteByteFunc memory_bank_writebyte[65536];
|
|||
extern memoryWriteWordFunc memory_bank_writeword[65536];
|
||||
extern memoryWriteLongFunc memory_bank_writelong[65536];
|
||||
|
||||
extern UBY *memory_bank_pointer[65536];
|
||||
extern UBY *memory_bank_datapointer[65536];
|
||||
extern uint8_t *memory_bank_pointer[65536];
|
||||
extern uint8_t *memory_bank_datapointer[65536];
|
||||
|
||||
extern void memoryBankSet(memoryReadByteFunc rb,
|
||||
memoryReadWordFunc rw,
|
||||
|
@ -99,39 +109,43 @@ extern void memoryBankSet(memoryReadByteFunc rb,
|
|||
memoryWriteByteFunc wb,
|
||||
memoryWriteWordFunc ww,
|
||||
memoryWriteLongFunc wl,
|
||||
UBY *basep,
|
||||
ULO bank,
|
||||
ULO basebank,
|
||||
uint8_t *basep,
|
||||
uint32_t bank,
|
||||
uint32_t basebank,
|
||||
BOOLE pointer_can_write);
|
||||
extern UBY *memoryAddressToPtr(ULO address);
|
||||
extern void memoryChipMap(BOOLE overlay);
|
||||
extern uint8_t *memoryAddressToPtr(uint32_t address);
|
||||
extern void memoryChipMap(bool overlay);
|
||||
|
||||
/* Memory configuration properties */
|
||||
|
||||
extern BOOLE memorySetChipSize(ULO chipsize);
|
||||
extern ULO memoryGetChipSize(void);
|
||||
extern BOOLE memorySetFastSize(ULO fastsize);
|
||||
extern ULO memoryGetFastSize(void);
|
||||
extern void memorySetFastAllocatedSize(ULO fastallocatedsize);
|
||||
extern ULO memoryGetFastAllocatedSize(void);
|
||||
extern BOOLE memorySetSlowSize(ULO bogosize);
|
||||
extern ULO memoryGetSlowSize(void);
|
||||
extern BOOLE memorySetUseAutoconfig(BOOLE useautoconfig);
|
||||
extern BOOLE memoryGetUseAutoconfig(void);
|
||||
extern BOOLE memorySetChipSize(uint32_t chipsize);
|
||||
extern uint32_t memoryGetChipSize(void);
|
||||
extern BOOLE memorySetFastSize(uint32_t fastsize);
|
||||
extern uint32_t memoryGetFastSize(void);
|
||||
extern void memorySetFastAllocatedSize(uint32_t fastallocatedsize);
|
||||
extern uint32_t memoryGetFastAllocatedSize(void);
|
||||
extern BOOLE memorySetSlowSize(uint32_t bogosize);
|
||||
extern uint32_t memoryGetSlowSize(void);
|
||||
extern bool memorySetUseAutoconfig(bool useautoconfig);
|
||||
extern bool memoryGetUseAutoconfig(void);
|
||||
extern BOOLE memorySetAddress32Bit(BOOLE address32bit);
|
||||
extern BOOLE memoryGetAddress32Bit(void);
|
||||
extern BOOLE memorySetKickImage(STR *kickimage);
|
||||
extern STR *memoryGetKickImage(void);
|
||||
extern void memorySetKey(STR *key);
|
||||
extern STR *memoryGetKey(void);
|
||||
extern BOOLE memorySetKickImage(char *kickimage);
|
||||
extern BOOLE memorySetKickImageExtended(char *kickimageext);
|
||||
extern char *memoryGetKickImage(void);
|
||||
extern void memorySetKey(char *key);
|
||||
extern char *memoryGetKey(void);
|
||||
extern BOOLE memoryGetKickImageOK(void);
|
||||
|
||||
/* Derived from memory configuration */
|
||||
|
||||
extern ULO memoryGetKickImageBaseBank(void);
|
||||
extern ULO memoryGetKickImageVersion(void);
|
||||
extern ULO memoryInitialPC(void);
|
||||
extern ULO memoryInitialSP(void);
|
||||
extern uint32_t memoryGetKickImageBaseBank(void);
|
||||
extern uint32_t memoryGetKickImageVersion(void);
|
||||
extern uint32_t memoryInitialPC(void);
|
||||
extern uint32_t memoryInitialSP(void);
|
||||
|
||||
/* Kickstart decryption */
|
||||
extern int memoryKickLoadAF2(char *filename, FILE *F, uint8_t *memory_kick, const bool);
|
||||
|
||||
/* Kickstart load error handling */
|
||||
|
||||
|
@ -148,21 +162,19 @@ extern ULO memoryInitialSP(void);
|
|||
|
||||
/* Global variables */
|
||||
|
||||
extern UBY memory_chip[];
|
||||
extern UBY *memory_fast;
|
||||
extern UBY memory_slow[];
|
||||
extern UBY memory_kick[];
|
||||
extern ULO memory_chipsize;
|
||||
extern UBY memory_emem[];
|
||||
extern uint8_t memory_chip[];
|
||||
extern uint8_t *memory_fast;
|
||||
extern uint8_t memory_slow[];
|
||||
extern uint8_t memory_kick[];
|
||||
extern uint32_t memory_chipsize;
|
||||
extern uint8_t memory_emem[];
|
||||
|
||||
extern ULO intenar,intena,intreq;
|
||||
extern ULO potgor;
|
||||
extern uint32_t potgor;
|
||||
|
||||
extern ULO memory_fault_address;
|
||||
extern uint32_t memory_fault_address;
|
||||
extern BOOLE memory_fault_read;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
22
cpu/memory.c
22
cpu/memory.c
|
@ -8,14 +8,14 @@
|
|||
/*============================================================================*/
|
||||
|
||||
BOOLE memory_fault_read = FALSE; /* TRUE - read / FALSE - write */
|
||||
ULO memory_fault_address = 0;
|
||||
uint32_t memory_fault_address = 0;
|
||||
|
||||
/*==============================================================================
|
||||
Raises exception 3 when a word or long is accessing an odd address
|
||||
and the CPU is < 020
|
||||
==============================================================================*/
|
||||
|
||||
static void memoryOddRead(ULO address)
|
||||
static void memoryOddRead(uint32_t address)
|
||||
{
|
||||
if (address & 1)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ static void memoryOddRead(ULO address)
|
|||
}
|
||||
}
|
||||
|
||||
static void memoryOddWrite(ULO address)
|
||||
static void memoryOddWrite(uint32_t address)
|
||||
{
|
||||
if (address & 1)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ uint8_t *memoryPointer(uint32_t address)
|
|||
|
||||
// memory read of 0xffffffff not handled correctly
|
||||
// since the unsigned compare overflows.
|
||||
UBY memoryReadByte(ULO address)
|
||||
uint8_t memoryReadByte(uint32_t address)
|
||||
{
|
||||
|
||||
if (MemoryLoggingFunc)
|
||||
|
@ -88,7 +88,7 @@ UBY memoryReadByte(ULO address)
|
|||
return 0;
|
||||
}
|
||||
|
||||
UWO memoryReadWord(ULO address)
|
||||
uint16_t memoryReadWord(uint32_t address)
|
||||
{
|
||||
|
||||
if (MemoryLoggingFunc)
|
||||
|
@ -103,7 +103,7 @@ UWO memoryReadWord(ULO address)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ULO memoryReadLong(ULO address)
|
||||
uint32_t memoryReadLong(uint32_t address)
|
||||
{
|
||||
|
||||
if (MemoryLoggingFunc)
|
||||
|
@ -121,7 +121,7 @@ ULO memoryReadLong(ULO address)
|
|||
}
|
||||
|
||||
|
||||
uint64_t memoryReadLongLong(ULO address)
|
||||
uint64_t memoryReadLongLong(uint32_t address)
|
||||
{
|
||||
uint64_t tmp;
|
||||
|
||||
|
@ -132,7 +132,7 @@ uint64_t memoryReadLongLong(ULO address)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
void memoryWriteByte(UBY data, ULO address)
|
||||
void memoryWriteByte(uint8_t data, uint32_t address)
|
||||
{
|
||||
|
||||
if (MemoryLoggingFunc)
|
||||
|
@ -144,7 +144,7 @@ void memoryWriteByte(UBY data, ULO address)
|
|||
}
|
||||
}
|
||||
|
||||
void memoryWriteWord(UWO data, ULO address)
|
||||
void memoryWriteWord(uint16_t data, uint32_t address)
|
||||
{
|
||||
|
||||
if (MemoryLoggingFunc)
|
||||
|
@ -159,7 +159,7 @@ void memoryWriteWord(UWO data, ULO address)
|
|||
}
|
||||
}
|
||||
|
||||
void memoryWriteLong(ULO data, ULO address)
|
||||
void memoryWriteLong(uint32_t data, uint32_t address)
|
||||
{
|
||||
|
||||
if (MemoryLoggingFunc)
|
||||
|
@ -178,7 +178,7 @@ void memoryWriteLong(ULO data, ULO address)
|
|||
}
|
||||
|
||||
|
||||
void memoryWriteLongLong(uint64_t data, ULO address)
|
||||
void memoryWriteLongLong(uint64_t data, uint32_t address)
|
||||
{
|
||||
|
||||
if (address & 0x01) memoryOddWrite(address);
|
||||
|
|
|
@ -79,4 +79,3 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 8a47aacd7d8a19566701ae60dd03ff3c6e6b3634
|
|
@ -1,10 +1,3 @@
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -g")
|
||||
|
||||
add_definitions(-I ${CMAKE_SOURCE_DIR}/)
|
||||
|
||||
set(MACOS_SRC traps.c sysequ.c errors.cpp)
|
||||
|
||||
|
||||
add_library(MACOS_LIB ${MACOS_SRC})
|
|
@ -107,7 +107,7 @@ enum macos_error {
|
|||
envVersTooBig = -5502, /*Version bigger than call can handle*/
|
||||
fontDecError = -64, /*error during font declaration*/
|
||||
fontNotDeclared = -65, /*font not declared*/
|
||||
fontSubErr = -66, /*font substitution occured*/
|
||||
fontSubErr = -66, /*font substitution occurred*/
|
||||
fontNotOutlineErr = -32615, /*bitmap font passed to routine that does outlines only*/
|
||||
firstDskErr = -84, /*I/O System Errors*/
|
||||
lastDskErr = -64, /*I/O System Errors*/
|
||||
|
@ -196,7 +196,7 @@ enum macos_error {
|
|||
rgnTooBigErr = -500,
|
||||
updPixMemErr = -125, /*insufficient memory to update a pixmap*/
|
||||
pictInfoVersionErr = -11000, /* wrong version of the PictInfo structure */
|
||||
pictInfoIDErr = -11001, /* the internal consistancy check for the PictInfoID is wrong */
|
||||
pictInfoIDErr = -11001, /* the internal consistency check for the PictInfoID is wrong */
|
||||
pictInfoVerbErr = -11002, /* the passed verb was invalid */
|
||||
cantLoadPickMethodErr = -11003, /* unable to load the custom pick proc */
|
||||
colorsRequestedErr = -11004, /* the number of colors requested was illegal */
|
||||
|
@ -249,7 +249,7 @@ enum macos_error {
|
|||
smEmptySlot = -300, /*No card in slot*/
|
||||
smCRCFail = -301, /*CRC check failed for declaration data*/
|
||||
smFormatErr = -302, /*FHeader Format is not Apple's*/
|
||||
smRevisionErr = -303, /*Wrong revison level*/
|
||||
smRevisionErr = -303, /*Wrong revision level*/
|
||||
smNoDir = -304, /*Directory offset is Nil */
|
||||
smDisabledSlot = -305, /*This slot is disabled (-305 use to be smLWTstBad)*/
|
||||
smNosInfoArray = -306, /*No sInfoArray. Memory Mgr error.*/
|
||||
|
@ -258,14 +258,14 @@ enum macos_error {
|
|||
smResrvErr = -307, /*Fatal reserved error. Resreved field <> 0.*/
|
||||
smUnExBusErr = -308, /*Unexpected BusError*/
|
||||
smBLFieldBad = -309, /*ByteLanes field was bad.*/
|
||||
smFHBlockRdErr = -310, /*Error occured during _sGetFHeader.*/
|
||||
smFHBlkDispErr = -311, /*Error occured during _sDisposePtr (Dispose of FHeader block).*/
|
||||
smFHBlockRdErr = -310, /*Error occurred during _sGetFHeader.*/
|
||||
smFHBlkDispErr = -311, /*Error occurred during _sDisposePtr (Dispose of FHeader block).*/
|
||||
smDisposePErr = -312, /*_DisposePointer error*/
|
||||
smNoBoardSRsrc = -313, /*No Board sResource.*/
|
||||
smGetPRErr = -314, /*Error occured during _sGetPRAMRec (See SIMStatus).*/
|
||||
smGetPRErr = -314, /*Error occurred during _sGetPRAMRec (See SIMStatus).*/
|
||||
smNoBoardId = -315, /*No Board Id.*/
|
||||
smInitStatVErr = -316, /*The InitStatusV field was negative after primary or secondary init.*/
|
||||
smInitTblVErr = -317, /*An error occured while trying to initialize the Slot Resource Table.*/
|
||||
smInitTblVErr = -317, /*An error occurred while trying to initialize the Slot Resource Table.*/
|
||||
smNoJmpTbl = -318, /*SDM jump table could not be created.*/
|
||||
smBadBoardId = -319, /*BoardId was wrong; re-init the PRAM record.*/
|
||||
smBusErrTO = -320, /*BusError time out.*/
|
||||
|
@ -285,20 +285,20 @@ but a special error is needed to patch secondary inits.*/
|
|||
|
||||
smCPUErr = -334, /*Code revision is wrong*/
|
||||
smsPointerNil = -335, /*LPointer is nil From sOffsetData. If this error occurs; check sInfo rec for more information.*/
|
||||
smNilsBlockErr = -336, /*Nil sBlock error (Dont allocate and try to use a nil sBlock)*/
|
||||
smNilsBlockErr = -336, /*Nil sBlock error (Don't allocate and try to use a nil sBlock)*/
|
||||
smSlotOOBErr = -337, /*Slot out of bounds error*/
|
||||
smSelOOBErr = -338, /*Selector out of bounds error*/
|
||||
smNewPErr = -339, /*_NewPtr error*/
|
||||
smBlkMoveErr = -340, /*_BlockMove error*/
|
||||
smCkStatusErr = -341, /*Status of slot = fail.*/
|
||||
smGetDrvrNamErr = -342, /*Error occured during _sGetDrvrName.*/
|
||||
smDisDrvrNamErr = -343, /*Error occured during _sDisDrvrName.*/
|
||||
smGetDrvrNamErr = -342, /*Error occurred during _sGetDrvrName.*/
|
||||
smDisDrvrNamErr = -343, /*Error occurred during _sDisDrvrName.*/
|
||||
smNoMoresRsrcs = -344, /*No more sResources*/
|
||||
smsGetDrvrErr = -345, /*Error occurred during _sGetDriver.*/
|
||||
smBadsPtrErr = -346, /*Bad pointer was passed to sCalcsPointer*/
|
||||
smByteLanesErr = -347, /*NumByteLanes was determined to be zero.*/
|
||||
smOffsetErr = -348, /*Offset was too big (temporary error*/
|
||||
smNoGoodOpens = -349, /*No opens were successfull in the loop.*/
|
||||
smNoGoodOpens = -349, /*No opens were successful in the loop.*/
|
||||
smSRTOvrFlErr = -350, /*SRT over flow.*/
|
||||
smRecNotFnd = -351, /*Record not found in the SRT.*/
|
||||
editionMgrInitErr = -450, /*edition manager not inited by this app*/
|
||||
|
@ -333,7 +333,7 @@ but a special error is needed to patch secondary inits.*/
|
|||
|
||||
interruptsMaskedErr = -624, /*don't call with interrupts masked*/
|
||||
cannotDeferErr = -625, /*unable to defer additional functions*/
|
||||
ddpSktErr = -91, /*error in soket number*/
|
||||
ddpSktErr = -91, /*error in socket number*/
|
||||
ddpLenErr = -92, /*data length too big*/
|
||||
noBridgeErr = -93, /*no network bridge for non-local send*/
|
||||
lapProtErr = -94, /*error in attaching/detaching protocol*/
|
||||
|
@ -453,7 +453,7 @@ but a special error is needed to patch secondary inits.*/
|
|||
noDefaultUserErr = -922, /* user hasn't typed in owners name in Network Setup Control Pannel */
|
||||
notLoggedInErr = -923, /* The default userRefNum does not yet exist */
|
||||
noUserRefErr = -924, /* unable to create a new userRefNum */
|
||||
networkErr = -925, /* An error has occured in the network, not too likely */
|
||||
networkErr = -925, /* An error has occurred in the network, not too likely */
|
||||
noInformErr = -926, /* PPCStart failed because destination did not have inform pending */
|
||||
authFailErr = -927, /* unable to authenticate user at destination */
|
||||
noUserRecErr = -928, /* Invalid user reference number */
|
||||
|
@ -554,7 +554,7 @@ but a special error is needed to patch secondary inits.*/
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ enum {
|
|||
SMGlobals = 0x0CC4, /* (long) pointer to Sound Manager Globals*/
|
||||
TheGDevice = 0x0CC8, /*[GLOBAL VAR] (long) the current graphics device*/
|
||||
CQDGlobals = 0x0CCC, /* (long) quickDraw global extensions*/
|
||||
ADBBase = 0x0CF8, /*[GLOBAL VAR] (long) pointer to Front Desk Buss Variables*/
|
||||
ADBBase = 0x0CF8, /*[GLOBAL VAR] (long) pointer to Front Desk Bus Variables*/
|
||||
WarmStart = 0x0CFC, /*[GLOBAL VAR] (long) flag to indicate it is a warm start*/
|
||||
TimeDBRA = 0x0D00, /*[GLOBAL VAR] (word) number of iterations of DBRA per millisecond*/
|
||||
TimeSCCDB = 0x0D02, /*[GLOBAL VAR] (word) number of iter's of SCC access & DBRA.*/
|
||||
|
@ -263,7 +263,7 @@ enum {
|
|||
enum {
|
||||
SysParam = 0x1F8, /*[GLOBAL VAR] Low-memory copy of parameter RAM (20 bytes)
|
||||
system parameter memory [20 bytes]*/
|
||||
CrsrThresh = 0x8EC, /*[GLOBAL VAR] Mouse-scaling threshold (word)
|
||||
CrsrThresh = 0x8EC, /*[GLOBAL VAR] Mouse-scaling threshold (word)
|
||||
delta threshold for mouse scaling [word]*/
|
||||
JCrsrTask = 0x8EE, /*[GLOBAL VAR] address of CrsrVBLTask [long]*/
|
||||
MTemp = 0x828, /*[GLOBAL VAR] Low-level interrupt mouse location [long]*/
|
||||
|
@ -318,7 +318,7 @@ enum {
|
|||
MaskPtr = 0x31A, /*[GLOBAL VAR] Memory Manager Pointer Mask [long]*/
|
||||
MinStack = 0x31E, /*[GLOBAL VAR] Minimum space allotment for stack (long)
|
||||
min stack size used in InitApplZone [long]*/
|
||||
DefltStack = 0x322, /*[GLOBAL VAR] Default space allotment for stack (long)
|
||||
DefltStack = 0x322, /*[GLOBAL VAR] Default space allotment for stack (long)
|
||||
default size of stack [long]*/
|
||||
MMDefFlags = 0x326, /*[GLOBAL VAR] default zone flags [word]*/
|
||||
DSAlertTab = 0x2BA, /*[GLOBAL VAR] Pointer to system error alert table in use
|
||||
|
@ -362,7 +362,7 @@ enum {
|
|||
TagData = 0x2FA, /*[GLOBAL VAR] sector tag info for disk drivers [14 bytes]*/
|
||||
BufTgFNum = 0x2FC, /*[GLOBAL VAR] File tags buffer: file number (long)
|
||||
file number [long]*/
|
||||
BufTgFFlg = 0x300, /*[GLOBAL VAR] File tags buffer: flags (word: bit 1=1 if resource fork)
|
||||
BufTgFFlg = 0x300, /*[GLOBAL VAR] File tags buffer: flags (word: bit 1=1 if resource fork)
|
||||
flags [word]*/
|
||||
BufTgFBkNum = 0x302, /*[GLOBAL VAR] File tags buffer: logical block number (word)
|
||||
logical block number [word]*/
|
||||
|
@ -400,7 +400,7 @@ enum {
|
|||
Z-ordered linked list of windows [pointer]*/
|
||||
PaintWhite = 0x9DC, /*[GLOBAL VAR] Flag for whether to paint window white before update event (word)
|
||||
erase newly drawn windows? [word]*/
|
||||
WMgrPort = 0x9DE, /*[GLOBAL VAR] Pointer to Window Manager port
|
||||
WMgrPort = 0x9DE, /*[GLOBAL VAR] Pointer to Window Manager port
|
||||
window manager's grafport [pointer]*/
|
||||
GrayRgn = 0x9EE, /*[GLOBAL VAR] Handle to region drawn as desktop
|
||||
rounded gray desk region [handle]*/
|
||||
|
@ -439,7 +439,7 @@ enum {
|
|||
system map [handle]*/
|
||||
SysMap = 0xA58, /*[GLOBAL VAR] Reference number of system resource file (word)
|
||||
reference number of system map [word]*/
|
||||
CurMap = 0xA5A, /*[GLOBAL VAR] Reference number of current resource file (word)
|
||||
CurMap = 0xA5A, /*[GLOBAL VAR] Reference number of current resource file (word)
|
||||
reference number of current map [word]*/
|
||||
ResReadOnly = 0xA5C, /*[GLOBAL VAR] Read only flag [word]*/
|
||||
ResLoad = 0xA5E, /*[GLOBAL VAR] Current SetResLoad state (word)
|
||||
|
|
|
@ -73,13 +73,13 @@ namespace MacOS {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
constexpr const T* operator->() const
|
||||
{
|
||||
return &_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
constexpr const T& operator *() const
|
||||
{
|
||||
return _value;
|
||||
|
@ -117,7 +117,7 @@ namespace MacOS {
|
|||
{
|
||||
public:
|
||||
|
||||
tool_return()
|
||||
tool_return()
|
||||
{}
|
||||
|
||||
tool_return(macos_error error) : tool_return_base(error)
|
||||
|
@ -133,5 +133,5 @@ namespace MacOS {
|
|||
};
|
||||
|
||||
|
||||
} // namespace IIgs
|
||||
} // namespace
|
||||
#endif
|
||||
|
|
190
macos/traps.c
190
macos/traps.c
|
@ -7,10 +7,10 @@ const char *TrapName(uint16_t trap)
|
|||
|
||||
switch(trap)
|
||||
{
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; QuickDraw
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA817: return "_CopyMask";
|
||||
|
@ -196,10 +196,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA8FB: return "_MapRgn";
|
||||
case 0xA8FC: return "_MapPoly";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Toolbox
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA80D: return "_Count1Resources";
|
||||
|
@ -511,34 +511,34 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xABF2: return "_ThreadDispatch";
|
||||
case 0xABFF: return "_DebugStr";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Resource Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA822: return "_ResourceDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; PPCToolbox
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA0DD: return "_PPC";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Alias Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA823: return "_AliasDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Device Manager (some shared by the File Manager)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA000: return "_Open";
|
||||
|
@ -549,10 +549,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA005: return "_Status";
|
||||
case 0xA006: return "_KillIO";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; File Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA007: return "_GetVolInfo";
|
||||
|
@ -595,27 +595,27 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA241: return "_HSetFLock";
|
||||
case 0xA242: return "_HRstFLock";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; dispatch trap for remaining File Manager (and Desktop Manager) calls
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA060: return "_FSDispatch";
|
||||
case 0xA260: return "_HFSDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; High level FSSpec calls
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA52: return "_HighLevelHFSDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Memory Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA019: return "_InitZone";
|
||||
|
@ -652,10 +652,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA08F: return "_DeferUserFn";
|
||||
case 0xA08D: return "_DebugUtil";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Event Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA02F: return "_PostEvent";
|
||||
|
@ -697,8 +697,8 @@ const char *TrapName(uint16_t trap)
|
|||
// case 0xA057: return "_SetApplBase";
|
||||
case 0xA198: return "_HWPriv";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; New names for (mostly) new flavors of old LwrString trap (redone <13>)
|
||||
*/
|
||||
|
||||
|
@ -707,10 +707,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA456: return "_UpperText";
|
||||
case 0xA656: return "_StripUpperText";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Temporary Memory routines
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA88F: return "_OSDispatch";
|
||||
|
@ -765,10 +765,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA087: return "_IOPMsgRequest";
|
||||
case 0xA088: return "_IOPMoveData";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Power Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA09F: return "_PowerDispatch";
|
||||
|
@ -782,19 +782,19 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA48A: return "_SleepQRemove";
|
||||
// case 0xA48A: return "_SlpQRemove";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Comm. Toolbox
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA08B: return "_CommToolboxDispatch";
|
||||
case 0xA090: return "_SysEnvirons";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Egret Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA092: return "_EgretDispatch";
|
||||
|
@ -809,10 +809,10 @@ const char *TrapName(uint16_t trap)
|
|||
// case 0xA9C3: return "_KeyTrans";
|
||||
case 0xA9C3: return "_KeyTranslate";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; TextEdit
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA9CB: return "_TEGetText";
|
||||
|
@ -842,10 +842,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA83D: return "_TEDispatch";
|
||||
case 0xA83E: return "_TEStyleNew";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Color Quickdraw
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA00: return "_OpenCPort";
|
||||
|
@ -899,10 +899,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAA4F: return "_CalcCMask";
|
||||
case 0xAA51: return "_CopyDeepMask";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Routines for video devices
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA27: return "_GetMaxDevice";
|
||||
|
@ -920,10 +920,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAA32: return "_GetGDevice";
|
||||
case 0xABCA: return "_DeviceLoop";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Color Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA33: return "_Color2Index";
|
||||
|
@ -933,10 +933,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAA37: return "_GetSubTable";
|
||||
case 0xAA38: return "_UpdatePixMap";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Dialog Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// case 0xAA4B: return "_NewCDialog";
|
||||
|
@ -956,10 +956,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAA4E: return "_SetStdCProcs";
|
||||
case 0xABF8: return "_StdOpcodeProc";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; added to Toolbox for color
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA41: return "_SetWinColor";
|
||||
|
@ -976,10 +976,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA809: return "_GetControlVariant";
|
||||
case 0xA80A: return "_GetWVariant";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; added to Menu Manager for color
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// case 0xAA60: return "_DelMCEntries";
|
||||
|
@ -991,36 +991,36 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAA64: return "_GetMCEntry";
|
||||
case 0xAA65: return "_SetMCEntries";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Menu Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA66: return "_MenuChoice";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Dialog Manager?
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA67: return "_ModalDialogMenuSetup";
|
||||
case 0xAA68: return "_DialogDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Font Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA814: return "_SetFractEnable";
|
||||
case 0xA854: return "_FontDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Palette Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAA90: return "_InitPalettes";
|
||||
|
@ -1044,10 +1044,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAAA1: return "_CopyPalette";
|
||||
case 0xAAA2: return "_PaletteDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Sound Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA800: return "_SoundDispatch";
|
||||
|
@ -1079,26 +1079,26 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xA05E: return "_NMInstall";
|
||||
case 0xA05F: return "_NMRemove";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; All QDOffscreen Routines go through one trap with a selector
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xAB1D: return "_QDExtensions";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; UserDelay
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA84C: return "_UserDelay";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Component Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xA82A: return "_ComponentDispatch";
|
||||
|
@ -1114,10 +1114,10 @@ const char *TrapName(uint16_t trap)
|
|||
case 0xAA59: return "_MixedModeDispatch";
|
||||
case 0xAA5A: return "_CodeFragmentDispatch";
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
; Translation Manager
|
||||
|
||||
|
||||
*/
|
||||
|
||||
case 0xABFC: return "_TranslationDispatch";
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
File: Traps.h
|
||||
|
||||
|
||||
Contains: A-Trap constants.
|
||||
|
||||
|
||||
Version: Technology: Mac OS 9
|
||||
Release: Universal Interfaces 3.4
|
||||
|
||||
|
||||
Copyright: © 1985-2001 by Apple Computer, Inc., all rights reserved
|
||||
|
||||
|
||||
Bugs?: For bug reports, consult the following page on
|
||||
the World Wide Web:
|
||||
|
||||
|
||||
http://developer.apple.com/bugreporter/
|
||||
|
||||
|
||||
*/
|
||||
#ifndef __macos_traps__
|
||||
#define __macos_traps__
|
||||
|
@ -1047,7 +1047,7 @@ enum {
|
|||
};
|
||||
|
||||
enum {
|
||||
_ALMDispatch = 0xAAA4 /* Apple Location Manger*/
|
||||
_ALMDispatch = 0xAAA4 /* Apple Location Manager*/
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -1079,4 +1079,3 @@ enum {
|
|||
#endif
|
||||
|
||||
#endif /* __TRAPS__ */
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(MPLITE_SRC mplite.c)
|
||||
|
||||
add_library(MPLITE_LIB ${MPLITE_SRC})
|
|
@ -307,19 +307,17 @@ static int mplite_logarithm(const int iValue)
|
|||
}
|
||||
|
||||
/*
|
||||
** Return the size of an outstanding allocation, in bytes. The
|
||||
** size returned omits the 8-byte header overhead. This only
|
||||
** works for chunks that are currently checked out.
|
||||
** Return the size of an outstanding allocation, in bytes.
|
||||
** This only works for chunks that are currently checked out.
|
||||
*/
|
||||
static int mplite_size(const mplite_t *handle, const void *p)
|
||||
{
|
||||
int iSize = 0;
|
||||
if (p) {
|
||||
int i = (int)((uint8_t *) p - handle->zPool) / handle->szAtom;
|
||||
assert(i >= 0 && i < handle->nBlock);
|
||||
iSize = handle->szAtom *
|
||||
(1 << (handle->aCtrl[i] & MPLITE_CTRL_LOGSIZE));
|
||||
}
|
||||
int iSize, i;
|
||||
assert( p!=0 );
|
||||
i = (int)((uint8_t *) p - handle->zPool) / handle->szAtom;
|
||||
assert(i >= 0 && i < handle->nBlock);
|
||||
iSize = handle->szAtom * (1 << (handle->aCtrl[i] & MPLITE_CTRL_LOGSIZE));
|
||||
|
||||
return iSize;
|
||||
}
|
||||
|
||||
|
@ -388,19 +386,15 @@ static void *mplite_malloc_unsafe(mplite_t *handle, const int nByte)
|
|||
/* nByte must be a positive */
|
||||
assert(nByte > 0);
|
||||
|
||||
/* No more than 1GiB per allocation */
|
||||
if( nByte > MPLITE_MAX_ALLOC_SIZE ) return 0;
|
||||
|
||||
/* Keep track of the maximum allocation request. Even unfulfilled
|
||||
** requests are counted */
|
||||
if ((uint32_t) nByte > handle->maxRequest) {
|
||||
handle->maxRequest = nByte;
|
||||
}
|
||||
|
||||
/* Abort if the requested allocation size is larger than the largest
|
||||
** power of two that we can represent using 32-bit signed integers.
|
||||
*/
|
||||
if (nByte > MPLITE_MAX_ALLOC_SIZE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Round nByte up to the next valid power of two */
|
||||
for (iFullSz = handle->szAtom, iLogsize = 0; iFullSz < nByte; iFullSz *= 2,
|
||||
iLogsize++) {
|
||||
|
@ -443,6 +437,12 @@ static void *mplite_malloc_unsafe(mplite_t *handle, const int nByte)
|
|||
handle->maxOut = handle->currentOut;
|
||||
}
|
||||
|
||||
#ifdef MPLITE_DEBUG
|
||||
/* Make sure the allocated memory does not assume that it is set to zero
|
||||
** or retains a value from a previous allocation */
|
||||
memset(&handle->zPool[i * handle->szAtom], 0xAA, iFullSz);
|
||||
#endif
|
||||
|
||||
/* Return a pointer to the allocated memory. */
|
||||
return (void*) &handle->zPool[i * handle->szAtom];
|
||||
}
|
||||
|
@ -483,12 +483,12 @@ static void mplite_free_unsafe(mplite_t *handle, const void *pOld)
|
|||
int iBuddy;
|
||||
if ((iBlock >> iLogsize) & 1) {
|
||||
iBuddy = iBlock - size;
|
||||
assert(iBuddy >= 0);
|
||||
}
|
||||
else {
|
||||
iBuddy = iBlock + size;
|
||||
if (iBuddy >= handle->nBlock) break;
|
||||
}
|
||||
assert(iBuddy >= 0);
|
||||
if ((iBuddy + (1 << iLogsize)) > handle->nBlock) break;
|
||||
if (handle->aCtrl[iBuddy] != (MPLITE_CTRL_FREE | iLogsize)) break;
|
||||
mplite_unlink(handle, iBuddy, iLogsize);
|
||||
iLogsize++;
|
||||
|
@ -503,5 +503,12 @@ static void mplite_free_unsafe(mplite_t *handle, const void *pOld)
|
|||
}
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
#ifdef MPLITE_DEBUG
|
||||
/* Overwrite freed memory with the 0x55 bit pattern to verify that it is
|
||||
** not used after being freed */
|
||||
memset(&handle->zPool[iBlock * handle->szAtom], 0x55, size);
|
||||
#endif
|
||||
|
||||
mplite_link(handle, iBlock, iLogsize);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* This memory allocator uses the following algorithm:
|
||||
*
|
||||
* 1. All memory allocations sizes are rounded up to a power of 2.
|
||||
* 1. All memory allocation sizes are rounded up to a power of 2.
|
||||
*
|
||||
* 2. If two adjacent free blocks are the halves of a larger block,
|
||||
* then the two blocks are coalesced into the single larger block.
|
||||
|
@ -40,11 +40,7 @@
|
|||
#ifndef MPLITE_H
|
||||
#define MPLITE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "pstdint.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif /* #ifdef _WIN32 */
|
||||
|
||||
/**
|
||||
* @brief The function call returns success
|
||||
|
@ -114,9 +110,12 @@ typedef struct mplite {
|
|||
uint32_t maxCount; /**< Maximum instantaneous currentCount */
|
||||
uint32_t maxRequest; /**< Largest allocation (exclusive of internal frag) */
|
||||
|
||||
int aiFreelist[MPLITE_LOGMAX + 1]; /**< List of free blocks. aiFreelist[0]
|
||||
is a list of free blocks of size mplite_t.szAtom. aiFreelist[1] holds
|
||||
blocks of size szAtom * 2 and so forth.*/
|
||||
/**
|
||||
* Lists of free blocks. aiFreelist[0] is a list of free blocks of
|
||||
* size mplite_t.szAtom. aiFreelist[1] holds blocks of size szAtom*2.
|
||||
* aiFreelist[2] holds free blocks of size szAtom*4. And so forth.
|
||||
*/
|
||||
int aiFreelist[MPLITE_LOGMAX + 1];
|
||||
|
||||
uint8_t *aCtrl; /**< Space for tracking which blocks are checked out and the
|
||||
size of each block. One byte per block. */
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
* include stdint.h. The hope is that one or the other can be
|
||||
* used with no real difference.
|
||||
*
|
||||
* 5) In the current verison, if your platform can't represent
|
||||
* 5) In the current version, if your platform can't represent
|
||||
* int32_t, int16_t and int8_t, it just dumps out with a compiler
|
||||
* error.
|
||||
*
|
||||
|
|
|
@ -1,41 +1,17 @@
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -g")
|
||||
|
||||
add_definitions(-I ${CMAKE_SOURCE_DIR}/)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
set(MPW_SRC mpw.cpp mpw_io.cpp mpw_close.cpp mpw_access.cpp mpw_ioctl.cpp mpw_errno.cpp
|
||||
environment.cpp)
|
||||
|
||||
# add_custom_command(
|
||||
# OUTPUT environ.cpp
|
||||
# COMMAND ragel -p -G2 -o environ.cpp "${CMAKE_CURRENT_SOURCE_DIR}/environ.rl"
|
||||
# MAIN_DEPENDENCY environ.rl
|
||||
# )
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT environment.cpp
|
||||
COMMAND ragel -p -G2 -o environment.cpp "${CMAKE_CURRENT_SOURCE_DIR}/environment.rl"
|
||||
COMMAND "${RAGEL}" -p -G2 -o environment.cpp "${CMAKE_CURRENT_SOURCE_DIR}/environment.rl"
|
||||
MAIN_DEPENDENCY environment.rl
|
||||
)
|
||||
|
||||
|
||||
# add_custom_command(
|
||||
# OUTPUT epv.cpp
|
||||
# COMMAND ragel -p -G2 -o epv.cpp "${CMAKE_CURRENT_SOURCE_DIR}/epv.rl"
|
||||
# MAIN_DEPENDENCY epv.rl
|
||||
# )
|
||||
|
||||
|
||||
# add_custom_command(
|
||||
# OUTPUT ep.cpp
|
||||
# COMMAND ragel -p -G2 -o ep.cpp "${CMAKE_CURRENT_SOURCE_DIR}/ep.rl"
|
||||
# MAIN_DEPENDENCY ep.rl
|
||||
# )
|
||||
|
||||
|
||||
|
||||
|
||||
set_source_files_properties(
|
||||
environment.cpp # environ.cpp ep.cpp epv.cpp
|
||||
PROPERTIES
|
||||
|
|
|
@ -29,7 +29,7 @@ std::string EvalString(std::string &s, std::unordered_map<std::string, std::stri
|
|||
re2c:yyfill:enable = 0;
|
||||
re2c:yych:conversion = 1;
|
||||
re2c:indent:top = 1;
|
||||
|
||||
|
||||
'$' [A-Za-z0-9_]+ {
|
||||
std::string tmp(begin + 1, cp);
|
||||
|
||||
|
@ -44,7 +44,7 @@ std::string EvalString(std::string &s, std::unordered_map<std::string, std::stri
|
|||
}
|
||||
|
||||
'${' [A-Za-z0-9_]+ '}' {
|
||||
|
||||
|
||||
std::string tmp(begin + 2, cp - 1);
|
||||
|
||||
auto iter = env.find(tmp);
|
||||
|
@ -86,7 +86,7 @@ void LoadEnvironment(std::string &envfile, std::unordered_map<std::string, std::
|
|||
char *end;
|
||||
char *iter;
|
||||
|
||||
size_t length;
|
||||
size_t length;
|
||||
|
||||
begin = fgetln(fp, &length);
|
||||
if (!begin) break; // eof or error.
|
||||
|
@ -124,4 +124,4 @@ void LoadEnvironment(std::string &envfile, std::unordered_map<std::string, std::
|
|||
fclose(fp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,89 @@
|
|||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
|
||||
extern char **environ;
|
||||
|
||||
|
||||
namespace _env_rl {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
|
||||
#define _GETDELIM_MINLEN 4 /* minimum line buffer size */
|
||||
|
||||
ssize_t getdelim(char ** lineptr, size_t * n, int delimiter, FILE * stream) {
|
||||
char *buf, *pos;
|
||||
int c;
|
||||
ssize_t bytes;
|
||||
|
||||
if (lineptr == NULL || n == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (stream == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* resize (or allocate) the line buffer if necessary */
|
||||
buf = *lineptr;
|
||||
if (buf == NULL || *n < _GETDELIM_MINLEN) {
|
||||
buf = (char*)realloc(*lineptr, _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n = _GETDELIM_GROWBY;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
/* read characters until delimiter is found, end of file is reached, or an
|
||||
error occurs. */
|
||||
bytes = 0;
|
||||
pos = buf;
|
||||
while ((c = getc(stream)) != EOF) {
|
||||
if (bytes + 1 >= SSIZE_MAX) {
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
bytes++;
|
||||
if (bytes >= *n - 1) {
|
||||
buf = (char*)realloc(*lineptr, *n + _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n += _GETDELIM_GROWBY;
|
||||
pos = buf + bytes - 1;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
*pos++ = (char) c;
|
||||
if (c == delimiter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stream) || (feof(stream) && (bytes == 0))) {
|
||||
/* EOF, or an error from getc(). */
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pos = '\0';
|
||||
return bytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ssize_t getline(char ** lineptr, size_t * n, FILE * stream) {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
return getdelim(lineptr, n, '\n', stream);
|
||||
#else
|
||||
return ::getline(lineptr, n, stream);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace MPW
|
||||
{
|
||||
|
@ -283,6 +366,25 @@ namespace MPW {
|
|||
}
|
||||
}
|
||||
|
||||
void EnvLoadEnv() {
|
||||
/* load from environ */
|
||||
|
||||
for (unsigned i = 0; environ[i]; ++i) {
|
||||
if (memcmp(environ[i], "mpw$", 4)) continue;
|
||||
|
||||
std::string s(environ[i] + 4);
|
||||
auto pos = s.find('=');
|
||||
if (pos == 0) continue;
|
||||
if (pos == s.npos) {
|
||||
MPW::Environment.emplace(std::move(s), "");
|
||||
} else {
|
||||
MPW::Environment.emplace(s.substr(0, pos), s.substr(pos+1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void EnvLoadFile(const std::string &envfile)
|
||||
{
|
||||
|
@ -308,7 +410,7 @@ namespace MPW {
|
|||
char *line;
|
||||
ssize_t length;
|
||||
|
||||
length = getline(&lineBuffer, &lineSize, fp);
|
||||
length = _env_rl::getline(&lineBuffer, &lineSize, fp);
|
||||
if (!length) continue; //?
|
||||
if (length < 0) break; // eof or error.
|
||||
|
||||
|
|
23
mpw/mpw.cpp
23
mpw/mpw.cpp
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -45,7 +46,7 @@
|
|||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/fmem.h>
|
||||
#include <cpu/cpuModule.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
||||
#include <toolbox/toolbox.h>
|
||||
#include <toolbox/mm.h>
|
||||
|
@ -56,7 +57,7 @@
|
|||
extern char **environ;
|
||||
|
||||
|
||||
namespace MPW {
|
||||
namespace MPW {
|
||||
|
||||
// for dup counts, etc.
|
||||
//std::vector<int> FDTable;
|
||||
|
@ -151,7 +152,7 @@ namespace MPW
|
|||
{
|
||||
std::string s(pwd.pw_dir);
|
||||
if (s.back() != '/') s.push_back('/');
|
||||
s.append("mpw");
|
||||
s.append("mpw");
|
||||
if (isdir(s))
|
||||
{
|
||||
path = std::move(s);
|
||||
|
@ -180,6 +181,8 @@ namespace MPW
|
|||
{
|
||||
void EnvLoadFile(const std::string &envfile);
|
||||
void EnvLoadArray(const std::vector<std::string> &data);
|
||||
void EnvLoadEnv();
|
||||
|
||||
|
||||
std::string m(RootDir());
|
||||
if (!m.empty())
|
||||
|
@ -190,6 +193,8 @@ namespace MPW
|
|||
Environment.emplace(std::string("MPW"), mm);
|
||||
}
|
||||
|
||||
EnvLoadEnv(); // should do this first since it could set MPW??
|
||||
|
||||
if (defines.size())
|
||||
EnvLoadArray(defines);
|
||||
|
||||
|
@ -221,7 +226,7 @@ namespace MPW
|
|||
FDTable[STDOUT_FILENO].text = true;
|
||||
|
||||
FDTable[STDERR_FILENO].refcount = 1;
|
||||
FDTable[STDERR_FILENO].text = true;
|
||||
FDTable[STDERR_FILENO].text = true;
|
||||
*/
|
||||
|
||||
OS::Internal::FDEntry::allocate(STDIN_FILENO).text = true;
|
||||
|
@ -237,7 +242,7 @@ namespace MPW
|
|||
argv[0] = basename(argv[0]);
|
||||
|
||||
|
||||
// 0x0910 CurApName
|
||||
// 0x0910 CurApName
|
||||
{
|
||||
char str32[32];
|
||||
|
||||
|
@ -370,7 +375,7 @@ namespace MPW
|
|||
memoryWriteWord(0x4E75, fptr + 6); // rts
|
||||
|
||||
memoryWriteWord(fClose, fptr + 8);
|
||||
memoryWriteWord(0x4E75, fptr + 10); // rts
|
||||
memoryWriteWord(0x4E75, fptr + 10); // rts
|
||||
|
||||
memoryWriteWord(fRead, fptr + 12);
|
||||
memoryWriteWord(0x4E75, fptr + 14); // rts
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace MPW {
|
|||
|
||||
enum
|
||||
{
|
||||
kF_GTABINFO = (('e' << 8) | 0x00), /* get tab offset for file */
|
||||
kF_GTABINFO = (('e' << 8) | 0x00), /* get tab offset for file */
|
||||
kF_STABINFO = (('e' << 8) | 0x01), /* set " " " " */
|
||||
kF_GFONTINFO = (('e' << 8) | 0x02), /* get font number and size for file */
|
||||
kF_SFONTINFO = (('e' << 8) | 0x03), /* set " " " " " " */
|
||||
|
@ -122,4 +122,4 @@ namespace MPW {
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -44,7 +44,7 @@
|
|||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/fmem.h>
|
||||
#include <cpu/cpuModule.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
||||
#include <toolbox/toolbox.h>
|
||||
#include <toolbox/os.h>
|
||||
|
@ -93,7 +93,7 @@ namespace MPW
|
|||
{
|
||||
// get_tab_info(const char *name, uint32_t *tabSize)
|
||||
|
||||
// hard code for now.
|
||||
// hard code for now.
|
||||
// Could check xattr for actual value.
|
||||
// That would be rather pointless unless some editor respected
|
||||
// it.
|
||||
|
@ -124,7 +124,6 @@ namespace MPW
|
|||
|
||||
uint32_t ftrap_delete(uint32_t name)
|
||||
{
|
||||
|
||||
std::string sname;
|
||||
int rv;
|
||||
|
||||
|
@ -134,12 +133,68 @@ namespace MPW
|
|||
|
||||
rv = ::unlink(sname.c_str());
|
||||
if (rv < 0) return 0x40000000 | mpw_errno_from_errno();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ftrap_rename(uint32_t src, uint32_t dest)
|
||||
{
|
||||
std::string sname;
|
||||
std::string dname;
|
||||
int rv;
|
||||
|
||||
sname = ToolBox::ReadCString(src, true);
|
||||
dname = ToolBox::ReadCString(dest, true);
|
||||
|
||||
Log(" rename(%s, %s)\n", sname.c_str(), dname.c_str());
|
||||
rv = rename(sname.c_str(), dname.c_str());
|
||||
if (rv < 0) return 0x40000000 | mpw_errno_from_errno();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
MPW's open logic pseudo code:
|
||||
|
||||
if (flags & 0x1000) { // undocumented - use old tool calls
|
||||
oserr = flags & O_RSRC ? PBOPENRF() : PBOPEN();
|
||||
} else {
|
||||
oserr = flags & O_RSRC ? PBHOPENRF() : PBHOPEN();
|
||||
}
|
||||
if (!oserr) {
|
||||
if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) {
|
||||
errno = EEXIST;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (oserr == file not found) {
|
||||
if (flags & O_CREAT) {
|
||||
oserr = PBCreate();
|
||||
if (!oserr) {
|
||||
oserr = flag & O_RSRC ? PBOpenRF() : PBOpen();
|
||||
}
|
||||
}
|
||||
|
||||
PBGETFCBINFO();
|
||||
if (file size) {
|
||||
if (flags & O_TRUNC) {
|
||||
oserr = PBSetEOF();
|
||||
}
|
||||
if (!permission check) {
|
||||
errno = EPERM;
|
||||
PBClose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
uint32_t ftrap_open(uint32_t name, uint32_t parm)
|
||||
{
|
||||
uint32_t d0;
|
||||
|
@ -147,7 +202,7 @@ namespace MPW
|
|||
std::string sname;
|
||||
|
||||
MPWFile f;
|
||||
int nativeFlags;
|
||||
int nativeFlags = 0;
|
||||
std::memset(&f, 0, sizeof(f));
|
||||
|
||||
f.flags = memoryReadWord(parm);
|
||||
|
@ -179,15 +234,30 @@ namespace MPW
|
|||
|
||||
Log(" open(%s, %04x)\n", sname.c_str(), f.flags);
|
||||
|
||||
// TODO -- can you create a resource file like this?
|
||||
|
||||
if (f.flags & kO_RSRC)
|
||||
sname.append(_PATH_RSRCFORKSPEC);
|
||||
if (f.flags & kO_RSRC) {
|
||||
|
||||
if (f.flags & kO_CREAT)
|
||||
// O_CREAT and O_EXCL apply to the file, not the fork.
|
||||
int flags = O_RDONLY | (nativeFlags & (O_CREAT | O_EXCL));
|
||||
|
||||
int parent = ::open(sname.c_str(), flags, 0666);
|
||||
|
||||
fd = -1;
|
||||
if (parent >= 0) {
|
||||
|
||||
sname.append(_PATH_RSRCFORKSPEC);
|
||||
|
||||
nativeFlags &= ~O_EXCL;
|
||||
// APFS, etc - resource fork doesn't automatically exist so
|
||||
// need O_CREAT.
|
||||
if ((nativeFlags & O_ACCMODE) != O_RDONLY) nativeFlags |= O_CREAT;
|
||||
fd = ::open(sname.c_str(), nativeFlags, 0666);
|
||||
close(parent);
|
||||
}
|
||||
|
||||
} else {
|
||||
fd = ::open(sname.c_str(), nativeFlags, 0666);
|
||||
else
|
||||
fd = ::open(sname.c_str(), nativeFlags);
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
|
@ -204,7 +274,7 @@ namespace MPW
|
|||
|
||||
|
||||
// adjust the binary flags...
|
||||
// some apps are good about this but
|
||||
// some apps are good about this but
|
||||
// dumpobj, makelib, linkiigs don't set O_BINARY (but should)
|
||||
// MPW Assembler sets O_BINARY (but shouldn't)
|
||||
|
||||
|
@ -241,7 +311,7 @@ namespace MPW
|
|||
uint32_t parm = memoryReadLong(sp + 12);
|
||||
|
||||
Log("%04x Access(%08x, %04x, %08x)\n", trap, name, op, parm);
|
||||
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case kF_OPEN:
|
||||
|
@ -252,6 +322,10 @@ namespace MPW
|
|||
d0 = ftrap_delete(name);
|
||||
break;
|
||||
|
||||
case kF_RENAME:
|
||||
d0 = ftrap_rename(name, parm);
|
||||
break;
|
||||
|
||||
case kF_GTABINFO:
|
||||
d0 = ftrap_get_tab_info(name, parm);
|
||||
break;
|
||||
|
@ -268,16 +342,16 @@ namespace MPW
|
|||
d0 = ftrap_set_font_info(name, parm);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
d0 = 0x40000000 | kEINVAL;
|
||||
fprintf(stderr, "faccess - unsupported op %04x\n", op);
|
||||
exit(1);
|
||||
fprintf(stderr, "faccess - unsupported op %04x\n", op);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cpuSetDReg(0, d0);
|
||||
cpuSetDReg(0, d0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/fmem.h>
|
||||
#include <cpu/cpuModule.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
||||
#include <macos/errors.h>
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace MPW
|
|||
f.error = OS::notOpenErr;
|
||||
d0 = kEINVAL;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (--e.refcount == 0)
|
||||
{
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -159,7 +159,7 @@ namespace MPW {
|
|||
const std::error_category& mpw_system_category()
|
||||
{
|
||||
static __system_category s;
|
||||
return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace MPW
|
|||
{
|
||||
if (Trace) fprintf(stderr, format, args...);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/fmem.h>
|
||||
#include <cpu/cpuModule.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
||||
#include <macos/errors.h>
|
||||
|
||||
|
@ -74,7 +74,7 @@ namespace MPW
|
|||
int fd = f.cookie;
|
||||
ssize_t size;
|
||||
|
||||
Log(" read(%04x, %08x, %08x)", fd, f.buffer, f.count);
|
||||
Log(" read(%04x, %08x, %08x)\n", fd, f.buffer, f.count);
|
||||
size = OS::Internal::FDEntry::read(fd, memoryPointer(f.buffer), f.count);
|
||||
//Log(" -> %ld\n", size);
|
||||
|
||||
|
@ -138,8 +138,8 @@ namespace MPW
|
|||
// write back...
|
||||
memoryWriteWord(f.error, parm + 2);
|
||||
memoryWriteLong(f.count, parm + 12);
|
||||
|
||||
cpuSetDReg(0, d0);
|
||||
|
||||
cpuSetDReg(0, d0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -44,7 +44,7 @@
|
|||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/fmem.h>
|
||||
#include <cpu/cpuModule.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
||||
|
||||
#include <macos/errors.h>
|
||||
|
@ -57,7 +57,7 @@ using MacOS::macos_error_from_errno;
|
|||
|
||||
namespace MPW
|
||||
{
|
||||
|
||||
|
||||
uint32_t ftrap_dup(uint32_t parm, uint32_t arg)
|
||||
{
|
||||
uint32_t d0;
|
||||
|
@ -96,7 +96,7 @@ namespace MPW
|
|||
{
|
||||
d0 = 0;
|
||||
fd.refcount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d0 = kEINVAL;
|
||||
|
@ -139,7 +139,7 @@ namespace MPW
|
|||
|
||||
uint32_t ftrap_interactive(uint32_t parm, uint32_t arg)
|
||||
{
|
||||
// return 0 if interactive, an error if
|
||||
// return 0 if interactive, an error if
|
||||
// non-interactive.
|
||||
|
||||
uint32_t d0;
|
||||
|
@ -153,8 +153,8 @@ namespace MPW
|
|||
f.count = memoryReadLong(parm + 12);
|
||||
f.buffer = memoryReadLong(parm + 16);
|
||||
|
||||
// linkgs reads from stdin and
|
||||
// doesn't work quite right when
|
||||
// linkgs reads from stdin and
|
||||
// doesn't work quite right when
|
||||
// this returns 0. So, don't.
|
||||
|
||||
f.error = 0;
|
||||
|
@ -183,7 +183,7 @@ namespace MPW
|
|||
{
|
||||
int tty = ::isatty(fd);
|
||||
d0 = tty ? 0 : kEINVAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d0 = kEINVAL;
|
||||
|
@ -252,7 +252,7 @@ namespace MPW
|
|||
return kEINVAL;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
#if 0
|
||||
if (fd < 0 || fd >= FDTable.size() || !FDTable[fd])
|
||||
{
|
||||
|
@ -382,7 +382,7 @@ namespace MPW
|
|||
return kEINVAL;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
memoryWriteWord(f.error, parm + 2);
|
||||
return d0;
|
||||
|
@ -434,7 +434,7 @@ namespace MPW
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ioctl - unsupported op %04x\n", cmd);
|
||||
fprintf(stderr, "ioctl - unsupported op %04x\n", cmd);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
@ -443,4 +443,4 @@ namespace MPW
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ MAKEFLAGS += --no-builtin-rules
|
|||
.SUFFIXES:
|
||||
.SECONDARY:
|
||||
|
||||
MPW ?= mpw
|
||||
MPWFLAGS = -DMPWVersion=3.2
|
||||
MPW ?= mpw
|
||||
|
||||
LIBS = \
|
||||
{Libraries}Stubs.o \
|
||||
|
@ -25,7 +26,7 @@ LDFLAGS = -w -c 'MPS ' -t MPST \
|
|||
SCFLAGS = -p
|
||||
|
||||
TARGETS = test_new_handle test_new_handle_2 test_new_pointer test_volumes \
|
||||
test_createresfile test_hwpriv
|
||||
test_createresfile test_hwpriv test_sane
|
||||
|
||||
all : $(TARGETS)
|
||||
|
||||
|
@ -44,10 +45,16 @@ clean :
|
|||
# test_volumes : o/test_volumes.o
|
||||
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
test_sane: o/nan.o o/test_sane.o
|
||||
$(MPW) $(MPWFLAGS) Link $(LDFLAGS) -o $@ $^ $(LIBS) {CLibraries}CSANELib.o
|
||||
|
||||
% : o/%.o
|
||||
$(MPW) Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(MPW) $(MPWFLAGS) Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
o/%.o : %.c
|
||||
$(MPW) SC $(SCFLAGS) $< -o $@
|
||||
$(MPW) $(MPWFLAGS) SC $(SCFLAGS) $< -o $@
|
||||
|
||||
o/%.o : %.asm
|
||||
$(MPW) $(MPWFLAGS) Asm $(ASMFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
case on
|
||||
|
||||
export nan, __inf, inf
|
||||
|
||||
nan proc
|
||||
; The MPW 3.2 version of nan is broken. This what it's supposed to do.
|
||||
; extended (80-bit) returns via d0, d1, a0
|
||||
|
||||
MOVEM.L data,D0/D1/A0
|
||||
MOVE.W #$4000,D1
|
||||
MOVE.B $0004(A7),D1
|
||||
BNE.S swap
|
||||
MOVE.B #$15,D1
|
||||
swap
|
||||
SWAP D1
|
||||
RTS
|
||||
|
||||
entry inf
|
||||
entry __inf
|
||||
|
||||
inf
|
||||
__inf
|
||||
|
||||
MOVEM.L data,D0/D1/A0
|
||||
RTS
|
||||
|
||||
data
|
||||
dc.l $00007fff
|
||||
dc.l $00000000
|
||||
dc.l $00000000
|
||||
|
||||
end
|
||||
endp
|
||||
|
|
@ -0,0 +1,380 @@
|
|||
#include <Math.h>
|
||||
#include <SANE.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//extern pascal extended NAN(short x);
|
||||
|
||||
void dump_decimal(const decimal *d)
|
||||
{
|
||||
fprintf(stdout, "%d : %d : %.*s\n",
|
||||
d->sgn, d->exp, d->sig.length, d->sig.text);
|
||||
}
|
||||
|
||||
|
||||
void test_inf(void)
|
||||
{
|
||||
|
||||
decimal d;
|
||||
decform df;
|
||||
char buffer[80+1];
|
||||
|
||||
printf("\nInfinity\n");
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 10;
|
||||
num2dec(&df,-inf(), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, -inf(), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 0;
|
||||
num2dec(&df, inf(), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 0;
|
||||
num2dec(&df, inf(), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
}
|
||||
|
||||
void test_nan(void)
|
||||
{
|
||||
|
||||
|
||||
// num2dec generates N[16-digit]
|
||||
// str2dec generates NAN(001) -- NAN(255)
|
||||
|
||||
decimal d;
|
||||
decform df;
|
||||
char buffer[80+1];
|
||||
|
||||
printf("\nNaN\n");
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 0;
|
||||
num2dec(&df,nan(1), &d);
|
||||
dump_decimal(&d);
|
||||
// 7 : N4001000000000000
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 0;
|
||||
num2dec(&df, nan(2), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 10;
|
||||
num2dec(&df,-nan(3), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, nan(4), &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, nan(255), &d);
|
||||
dump_decimal(&d);
|
||||
// 7 : N40FF000000000000
|
||||
|
||||
dec2str(&df, &d, buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
}
|
||||
|
||||
void test_fxc2dec(void)
|
||||
{
|
||||
decimal d;
|
||||
decform df;
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 100;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : -18 : 1125000000000000000
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : -9 : 1125000000
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 2;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : -1 : 11
|
||||
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 100;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : -18 : 1125000000000000000
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : -10 : 11250000000
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 2;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
//0 : -2 : 112
|
||||
|
||||
//
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 100;
|
||||
num2dec(&df, 1e25, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : 7 : 1000000000000000000
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 1e25, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : 16 : 1000000000
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 2;
|
||||
num2dec(&df, 1e25, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : 24 : 10
|
||||
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 100;
|
||||
num2dec(&df, 1e25, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : 7 : 1000000000000000000
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 1e25, &d);
|
||||
dump_decimal(&d);
|
||||
// 0 : 7 : 1000000000000000000
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 2;
|
||||
num2dec(&df, 1e25, &d);
|
||||
dump_decimal(&d);
|
||||
//0 : 7 : 1000000000000000000
|
||||
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 0, &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 0, &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 0;
|
||||
num2dec(&df, -0.0, &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 0;
|
||||
num2dec(&df, -0.0, &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 0.125, &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 10;
|
||||
num2dec(&df, 0.125, &d);
|
||||
dump_decimal(&d);
|
||||
//
|
||||
|
||||
df.style = 0;
|
||||
df.digits = 4;
|
||||
num2dec(&df, 0.00000125, &d);
|
||||
dump_decimal(&d);
|
||||
// s/b -9 1250
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 4;
|
||||
num2dec(&df, 0.00000125, &d);
|
||||
dump_decimal(&d);
|
||||
// s/b -4 0
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 6;
|
||||
num2dec(&df, 0.0625, &d);
|
||||
dump_decimal(&d);
|
||||
// s/b -6 62500
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 6;
|
||||
num2dec(&df, 1.125, &d);
|
||||
dump_decimal(&d);
|
||||
// s/b -6 1125000
|
||||
|
||||
df.style = 1;
|
||||
df.digits = 6;
|
||||
num2dec(&df, 1.0625, &d);
|
||||
dump_decimal(&d);
|
||||
// s/b -6 1062500
|
||||
}
|
||||
|
||||
pascal void fp68k_3(void *, void *, unsigned short) = 0xA9EB;
|
||||
|
||||
void test_fx2l(void) {
|
||||
|
||||
long double x;
|
||||
long int l;
|
||||
int i;
|
||||
|
||||
static long double data[] = {
|
||||
1.25,
|
||||
1.5,
|
||||
1.75,
|
||||
2.25,
|
||||
2.5,
|
||||
2.75,
|
||||
-1.25,
|
||||
-1.5,
|
||||
-1.75,
|
||||
-2.25,
|
||||
-2.5,
|
||||
-2.75,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
x = inf(); // 1.0 / 0.0;
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(inf) = %lx\n", l);
|
||||
|
||||
|
||||
x = -inf(); // -1.0 / 0.0;
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(-inf) = %lx\n", l);
|
||||
|
||||
x = nan(1); // -1.0 / 0.0;
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(nan) = %lx\n", l);
|
||||
|
||||
|
||||
x = 1e21;
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(1e21) = %lx\n", l);
|
||||
|
||||
x = -1e21;
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(-1e21) = %lx\n", l);
|
||||
|
||||
|
||||
|
||||
setround(UPWARD);
|
||||
for (i = 0; i < 12; ++i) {
|
||||
x = data[i];
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(%f) = %ld\n", x, l);
|
||||
}
|
||||
setround(DOWNWARD);
|
||||
for (i = 0; i < 12; ++i) {
|
||||
x = data[i];
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(%f) = %ld\n", x, l);
|
||||
}
|
||||
|
||||
setround(TONEAREST);
|
||||
for (i = 0; i < 12; ++i) {
|
||||
x = data[i];
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(%f) = %ld\n", x, l);
|
||||
}
|
||||
setround(TOWARDZERO);
|
||||
for (i = 0; i < 12; ++i) {
|
||||
x = data[i];
|
||||
fp68k_3(&x, &l, 0x2810);
|
||||
printf("fx2l(%f) = %ld\n", x, l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//extended x;
|
||||
//decimal d;
|
||||
|
||||
//short index;
|
||||
//short valid;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
//index = 0;
|
||||
//valid = 0;
|
||||
//str2dec("1.125", &index, &d, &valid);
|
||||
//x = dec2num(&d);
|
||||
|
||||
|
||||
test_inf();
|
||||
test_nan();
|
||||
|
||||
test_fxc2dec();
|
||||
test_fx2l();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Wno-deprecated-declarations -g")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
# Clang or AppleClang
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
endif()
|
||||
|
||||
add_definitions(-I ${CMAKE_SOURCE_DIR}/)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
set(TOOLBOX_SRC
|
||||
toolbox.cpp
|
||||
|
@ -20,33 +22,31 @@ set(TOOLBOX_SRC
|
|||
os_volume.cpp
|
||||
qd.cpp
|
||||
sane.cpp
|
||||
saneparser.cpp
|
||||
packages.cpp
|
||||
pathnames.cpp
|
||||
process.cpp
|
||||
utility.cpp
|
||||
fs_spec.cpp
|
||||
realpath.c
|
||||
)
|
||||
dispatch.cpp
|
||||
fpinfo.cpp
|
||||
debug.cpp
|
||||
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT saneparser.cpp
|
||||
COMMAND ragel -p -G2 -o saneparser.cpp "${CMAKE_CURRENT_SOURCE_DIR}/saneparser.rl"
|
||||
MAIN_DEPENDENCY saneparser.rl
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT pathnames.cpp
|
||||
COMMAND ragel -p -G2 -o pathnames.cpp "${CMAKE_CURRENT_SOURCE_DIR}/pathnames.rl"
|
||||
COMMAND "${RAGEL}" -p -G2 -o pathnames.cpp "${CMAKE_CURRENT_SOURCE_DIR}/pathnames.rl"
|
||||
MAIN_DEPENDENCY pathnames.rl
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
saneparser.cpp pathnames.cpp
|
||||
pathnames.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wno-unused-variable"
|
||||
)
|
||||
|
||||
add_library(TOOLBOX_LIB ${TOOLBOX_SRC})
|
||||
|
||||
add_library(TOOLBOX_LIB ${TOOLBOX_SRC})
|
||||
target_link_libraries(TOOLBOX_LIB MACOS_LIB sane)
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
#ifndef __complex_h__
|
||||
#define __complex_h__
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
// comp is an int64_t but 0x8000_0000_0000_0000 is NaN
|
||||
//typedef int64_t complex;
|
||||
|
||||
struct complex {
|
||||
|
||||
public:
|
||||
const uint64_t NaN = 0x8000000000000000;
|
||||
|
||||
complex(const complex &rhs) = default;
|
||||
|
||||
complex(uint64_t rhs) : _data(rhs)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
complex(T t)
|
||||
{
|
||||
*this = t;
|
||||
}
|
||||
|
||||
bool isnan() const
|
||||
{
|
||||
return _data == NaN;
|
||||
}
|
||||
|
||||
complex &operator=(const complex &rhs) = default;
|
||||
|
||||
complex &operator=(uint64_t rhs)
|
||||
{
|
||||
_data = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
complex &operator=(T ld)
|
||||
{
|
||||
switch(std::fpclassify(ld))
|
||||
{
|
||||
case FP_NAN:
|
||||
_data = NaN;
|
||||
break;
|
||||
case FP_INFINITE:
|
||||
if (std::signbit(ld))
|
||||
{
|
||||
_data = -INT64_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data = INT64_MAX;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_data = ld;
|
||||
break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
operator uint64_t() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
operator int64_t() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
operator long double() const {
|
||||
if (_data == NaN)
|
||||
return NAN;
|
||||
return _data;
|
||||
}
|
||||
|
||||
operator double() const {
|
||||
if (_data == NaN)
|
||||
return NAN;
|
||||
return _data;
|
||||
}
|
||||
|
||||
operator float() const {
|
||||
if (_data == NaN)
|
||||
return NAN;
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
int64_t _data = 0;
|
||||
|
||||
};
|
||||
|
||||
namespace its_complicated {
|
||||
|
||||
|
||||
std::string to_string(complex c)
|
||||
{
|
||||
if (c.isnan()) return std::string("nan");
|
||||
|
||||
return std::to_string((int64_t)c);
|
||||
}
|
||||
|
||||
inline int fpclassify(complex c) {
|
||||
if (c.isnan()) return FP_NAN;
|
||||
if ((uint64_t)c == (uint64_t)0) return FP_ZERO;
|
||||
return FP_NORMAL;
|
||||
}
|
||||
|
||||
inline int signbit(complex c) {
|
||||
if (c.isnan()) return 0;
|
||||
return ((int64_t)c < (int64_t)0) ? 1 : 0;
|
||||
}
|
||||
|
||||
inline int isnan(complex c) {
|
||||
return c.isnan();
|
||||
}
|
||||
|
||||
inline int isinf(complex c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline int isfinite(complex c) {
|
||||
if (c.isnan()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline int isnormal(complex c) {
|
||||
if (c.isnan()) return false;
|
||||
if ((uint64_t)c == 0) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Kelvin W Sherlock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "toolbox.h"
|
||||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
#include <cpu/fmem.h>
|
||||
|
||||
#include "stackframe.h"
|
||||
|
||||
using ToolBox::Log;
|
||||
|
||||
namespace Debug {
|
||||
|
||||
// pascal void DebugStr(ConstStr255Param debuggerMsg)
|
||||
uint16_t DebugStr(uint16_t trap)
|
||||
{
|
||||
|
||||
uint32_t theString;
|
||||
uint32_t sp;
|
||||
|
||||
std::string s;
|
||||
|
||||
sp = StackFrame<4>(theString);
|
||||
|
||||
s = ToolBox::ReadPString(theString);
|
||||
|
||||
Log("%04x DebugStr(%s)\n", trap, s.c_str());
|
||||
fprintf(stderr, "%s\n", s.c_str());
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef __mpw_debug_h__
|
||||
#define __mpw_debug_h__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
|
||||
uint16_t DebugStr(uint16_t trap);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,106 @@
|
|||
#include "fpinfo.h"
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
|
||||
static_assert(sizeof(float) == 4, "Unexpected float size");
|
||||
static_assert(sizeof(double) == 8, "Unexpected double size");
|
||||
static_assert(sizeof(long double) == 8 || sizeof(long double) == 16, "Unexpected long double size");
|
||||
|
||||
void fpinfo::init(float *f)
|
||||
{
|
||||
union split {
|
||||
float f;
|
||||
uint32_t i;
|
||||
};
|
||||
|
||||
uint32_t i = ((split *)f)->i;
|
||||
|
||||
sign = i >> 31;
|
||||
one = 1;
|
||||
exp = (i >> 23) & ((1 << 8) - 1);
|
||||
sig = i & ((1 << 24) - 1);
|
||||
|
||||
if (exp == 255) {
|
||||
if (sig == 0) inf = true;
|
||||
else nan = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (exp == 0) {
|
||||
// 0 or denormalized.
|
||||
one = 0;
|
||||
exp = -126;
|
||||
return;
|
||||
}
|
||||
|
||||
exp -= 127; // bias
|
||||
}
|
||||
|
||||
void fpinfo::init(double *d)
|
||||
{
|
||||
|
||||
union split {
|
||||
double d;
|
||||
uint64_t i;
|
||||
};
|
||||
|
||||
uint64_t i = ((split *)d)->i;
|
||||
|
||||
sign = i >> 63;
|
||||
one = 1;
|
||||
exp = (i >> 52) & ((1 << 11) - 1);
|
||||
sig = i & ((UINT64_C(1) << 53) - 1);
|
||||
|
||||
|
||||
if (exp == 2047) {
|
||||
if (sig == 0) inf = true;
|
||||
else nan = true;
|
||||
return;
|
||||
}
|
||||
if (exp == 0) {
|
||||
// 0 or denormalized.
|
||||
one = 0;
|
||||
exp = -1022;
|
||||
return;
|
||||
}
|
||||
|
||||
exp -= 1023; // bias
|
||||
}
|
||||
|
||||
void fpinfo::init(long double *ld)
|
||||
{
|
||||
|
||||
union split {
|
||||
long double ld;
|
||||
uint64_t i[2];
|
||||
};
|
||||
|
||||
uint64_t i;
|
||||
uint32_t sexp;
|
||||
|
||||
|
||||
// this needs to be verified.
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
i = ((split *)ld)->i[0];
|
||||
sexp = ((split *)ld)->i[1];
|
||||
#else
|
||||
i = ((split *)ld)->i[1];
|
||||
sexp = ((split *)ld)->i[0] & 0xffff;
|
||||
#endif
|
||||
|
||||
sign = (sexp >> 15) & 0x01;
|
||||
exp = sexp & ((1 << 15) - 1);
|
||||
|
||||
one = i >> 63;
|
||||
sig = i & ((UINT64_C(1) << 63) - 1);
|
||||
|
||||
if (exp == 32767) {
|
||||
if (sig == 0) inf = true;
|
||||
else nan = true;
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
exp -= 16383;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef __fpinfo_h__
|
||||
#define __fpinfo_h__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct fpinfo {
|
||||
bool sign = false;
|
||||
bool one = false;
|
||||
int exp = 0;
|
||||
uint64_t sig = 0;
|
||||
|
||||
bool nan = false;
|
||||
bool inf = false;
|
||||
|
||||
fpinfo(float f) { init(&f); }
|
||||
fpinfo(double d) { init(&d); }
|
||||
fpinfo(long double ld) {
|
||||
if (sizeof(long double) == 16) init(&ld);
|
||||
if (sizeof(long double) == 8) init((double *)&ld);
|
||||
}
|
||||
|
||||
private:
|
||||
void init(float *);
|
||||
void init(double *);
|
||||
void init(long double *);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -35,7 +35,7 @@ namespace OS {
|
|||
char *cp;
|
||||
|
||||
cp = getcwd(buffer, sizeof(buffer));
|
||||
if (cp < 0) return 0;
|
||||
if (cp == 0) return 0;
|
||||
|
||||
std::string path(cp);
|
||||
|
||||
|
@ -141,4 +141,4 @@ namespace OS {
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,4 +42,4 @@ namespace OS {
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
|
@ -39,8 +40,8 @@
|
|||
#include "toolbox.h"
|
||||
#include "stackframe.h"
|
||||
|
||||
#include "RM.h"
|
||||
#include "MM.h"
|
||||
#include "rm.h"
|
||||
#include "mm.h"
|
||||
|
||||
#include <macos/sysequ.h>
|
||||
|
||||
|
@ -68,7 +69,7 @@ namespace Loader {
|
|||
// todo -- also add std::string segmentName?
|
||||
};
|
||||
|
||||
struct Segment0Info
|
||||
struct Segment0Info
|
||||
{
|
||||
Segment0Info()
|
||||
{}
|
||||
|
@ -87,7 +88,7 @@ namespace Loader {
|
|||
// %0xxxxxxx -> 7-bit value
|
||||
// %1xxxxxxx xxxxxxxx -> 15-bit value
|
||||
// %00000000 1xxxxxxx x{8} x{8} x{8} -> 31 bit value
|
||||
// ^ that's what the documentation says..
|
||||
// ^ that's what the documentation says..
|
||||
// that's how the 32-bit bootstrap works
|
||||
// DumpCode ignores the high 2 bytes.
|
||||
for(;;)
|
||||
|
@ -223,7 +224,7 @@ namespace Loader {
|
|||
|
||||
}
|
||||
|
||||
namespace Native
|
||||
namespace Native
|
||||
{
|
||||
|
||||
uint16_t LoadFile(const std::string &path)
|
||||
|
@ -247,10 +248,10 @@ namespace Loader {
|
|||
|
||||
::FSGetResourceForkName(&fork);
|
||||
|
||||
err = ::FSOpenResourceFile(&ref,
|
||||
fork.length,
|
||||
fork.unicode,
|
||||
fsRdPerm,
|
||||
err = ::FSOpenResourceFile(&ref,
|
||||
fork.length,
|
||||
fork.unicode,
|
||||
fsRdPerm,
|
||||
&refNum);
|
||||
|
||||
if (err) return err;
|
||||
|
@ -265,7 +266,7 @@ namespace Loader {
|
|||
Segment0Info seg0;
|
||||
err = LoadCode0(seg0);
|
||||
|
||||
// iterate through the jump table to get the other
|
||||
// iterate through the jump table to get the other
|
||||
// code segments to load
|
||||
bool farModel = false;
|
||||
for (uint32_t jtEntry = seg0.jtStart; jtEntry < seg0.jtEnd; jtEntry += 8)
|
||||
|
@ -362,7 +363,7 @@ namespace Loader {
|
|||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
void LoadDebugNames(DebugNameTable &table)
|
||||
{
|
||||
|
||||
|
@ -419,7 +420,7 @@ namespace Loader {
|
|||
case 0x4E74: // rtd #
|
||||
pc += 2; // skip the argument.
|
||||
eof = true;
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -473,7 +474,7 @@ namespace Loader {
|
|||
}
|
||||
|
||||
// verify name is legal.
|
||||
bool ok = std::all_of(s.begin(), s.end(),
|
||||
bool ok = std::all_of(s.begin(), s.end(),
|
||||
[](char c) {
|
||||
if (c >= 'A' && c <= 'Z') return true;
|
||||
if (c >= 'a' && c <= 'z') return true;
|
||||
|
@ -523,7 +524,7 @@ namespace Loader {
|
|||
|
||||
/*
|
||||
* struct { uint32_t a5; uint32_t pc; };
|
||||
* future state: Native::LoadFile(const std::string &path, a5pc) ->
|
||||
* future state: Native::LoadFile(const std::string &path, a5pc) ->
|
||||
* load file, set global page variables, set A5, return PC.
|
||||
*
|
||||
*/
|
||||
|
@ -531,7 +532,7 @@ namespace Loader {
|
|||
|
||||
uint16_t UnloadSeg(uint16_t trap)
|
||||
{
|
||||
// UnloadSeg (routineAddr: Ptr);
|
||||
// UnloadSeg (routineAddr: Ptr);
|
||||
|
||||
/*
|
||||
* ------------
|
||||
|
@ -552,4 +553,4 @@ namespace Loader {
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ namespace Loader {
|
|||
typedef std::map<std::string, std::pair<uint32_t, uint32_t>> DebugNameTable;
|
||||
namespace Native {
|
||||
|
||||
/*
|
||||
/*
|
||||
* loads the file
|
||||
* sets registers PC and A5.
|
||||
* sets certain globals.
|
||||
*
|
||||
* Dependencies: MM, RM
|
||||
* Dependencies: MM, RM
|
||||
*/
|
||||
uint16_t LoadFile(const std::string &path);
|
||||
|
||||
|
|
177
toolbox/mm.cpp
177
toolbox/mm.cpp
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <cpu/fmem.h>
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
@ -45,7 +46,7 @@
|
|||
using ToolBox::Log;
|
||||
|
||||
|
||||
namespace
|
||||
namespace
|
||||
{
|
||||
mplite_t pool;
|
||||
|
||||
|
@ -80,7 +81,7 @@ namespace
|
|||
{
|
||||
const unsigned HandleCount = 128; // 512 bytes of handle blocks.
|
||||
|
||||
uint8_t *block = (uint8_t *)mplite_malloc(&pool,
|
||||
uint8_t *block = (uint8_t *)mplite_malloc(&pool,
|
||||
sizeof(uint32_t) * HandleCount);
|
||||
|
||||
if (!block) return false;
|
||||
|
@ -91,7 +92,7 @@ namespace
|
|||
for ( ; hh < end; hh += sizeof(uint32_t))
|
||||
{
|
||||
HandleQueue.push_back(hh);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -117,10 +118,10 @@ namespace MM
|
|||
MemorySize = memorySize;
|
||||
HeapSize = memorySize - stack;
|
||||
|
||||
ok = mplite_init(&pool,
|
||||
memory + globals,
|
||||
memorySize - globals - stack,
|
||||
32,
|
||||
ok = mplite_init(&pool,
|
||||
memory + globals,
|
||||
memorySize - globals - stack,
|
||||
32,
|
||||
NULL);
|
||||
|
||||
if (ok != MPLITE_OK) return false;
|
||||
|
@ -153,7 +154,7 @@ namespace MM
|
|||
}
|
||||
|
||||
// 2. check if it's contained in a pointer
|
||||
for (const auto kv : PtrMap)
|
||||
for (const auto &kv : PtrMap)
|
||||
{
|
||||
if (address < kv.first) continue;
|
||||
if (address >= kv.first + kv.second) continue;
|
||||
|
@ -169,21 +170,21 @@ namespace MM
|
|||
if (iter != HandleMap.end())
|
||||
{
|
||||
const HandleInfo &info = iter->second;
|
||||
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
|
||||
iter->first,
|
||||
info.address,
|
||||
info.size,
|
||||
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
|
||||
iter->first,
|
||||
info.address,
|
||||
info.size,
|
||||
info.locked ? 'L' : ' ',
|
||||
info.purgeable ? 'P' : ' ',
|
||||
info.resource ? 'R' : ' '
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. check if the address is within a handle.
|
||||
{
|
||||
for (const auto kv : HandleMap)
|
||||
for (const auto &kv : HandleMap)
|
||||
{
|
||||
const HandleInfo &info = kv.second;
|
||||
|
||||
|
@ -194,10 +195,10 @@ namespace MM
|
|||
if (!info.size) end++;
|
||||
if (address >= begin && address < end)
|
||||
{
|
||||
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
|
||||
kv.first,
|
||||
info.address,
|
||||
info.size,
|
||||
printf("Handle $%08x Pointer: $%08x Size: $%08x Flags: %c %c %c\n",
|
||||
kv.first,
|
||||
info.address,
|
||||
info.size,
|
||||
info.locked ? 'L' : ' ',
|
||||
info.purgeable ? 'P' : ' ',
|
||||
info.resource ? 'R' : ' '
|
||||
|
@ -220,10 +221,10 @@ namespace MM
|
|||
const auto h = kv.first;
|
||||
const auto & info = kv.second;
|
||||
fprintf(stdout, "%08x %08x %08x %c %c %c\n",
|
||||
h,
|
||||
info.address,
|
||||
info.size,
|
||||
info.locked? 'L' : ' ',
|
||||
h,
|
||||
info.address,
|
||||
info.size,
|
||||
info.locked? 'L' : ' ',
|
||||
info.purgeable? 'P' : ' ',
|
||||
info.resource ? 'R' : ' '
|
||||
);
|
||||
|
@ -254,7 +255,7 @@ namespace MM
|
|||
|
||||
return SetMemError(0);
|
||||
}
|
||||
|
||||
|
||||
uint16_t DisposePtr(uint32_t mcptr)
|
||||
{
|
||||
|
||||
|
@ -304,7 +305,7 @@ namespace MM
|
|||
HandleQueue.push_back(hh);
|
||||
return SetMemError(MacOS::memFullErr);
|
||||
}
|
||||
mcptr = ptr - Memory;
|
||||
mcptr = ptr - Memory;
|
||||
|
||||
if (clear)
|
||||
std::memset(ptr, 0, size);
|
||||
|
@ -423,7 +424,7 @@ namespace MM
|
|||
// 1. - resizing to 0.
|
||||
if (!newSize)
|
||||
{
|
||||
if (info.locked)
|
||||
if (info.locked)
|
||||
{
|
||||
//return SetMemError(MacOS::memLockedErr);
|
||||
|
||||
|
@ -492,7 +493,7 @@ namespace MM
|
|||
}
|
||||
|
||||
fprintf(stderr, "mplite_realloc failed.\n");
|
||||
Native::PrintMemoryStats();
|
||||
Native::PrintMemoryStats();
|
||||
|
||||
if (i > 0) return SetMemError(MacOS::memFullErr);
|
||||
|
||||
|
@ -599,7 +600,7 @@ namespace MM
|
|||
|
||||
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
|
||||
SetMemError(0);
|
||||
return iter->second;
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
|
||||
|
@ -610,8 +611,8 @@ namespace MM
|
|||
{
|
||||
// also implements BlockMoveData.
|
||||
// BlockMove will flush caches, BlockMoveData will not.
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Pointer to source
|
||||
* A1 Pointer to destination
|
||||
|
@ -637,7 +638,7 @@ namespace MM
|
|||
if (source == 0 || dest == 0 || count == 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
||||
std::memmove(Memory + dest, Memory + source, count);
|
||||
|
||||
return 0;
|
||||
|
@ -648,7 +649,7 @@ namespace MM
|
|||
{
|
||||
// todo -- add function to check pool for largest block?
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0: cbNeeded (long word)
|
||||
*
|
||||
|
@ -668,7 +669,7 @@ namespace MM
|
|||
uint32_t MaxMem(uint16_t trap)
|
||||
{
|
||||
// return largest contiguous free block size.
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* (nothing)
|
||||
*
|
||||
|
@ -686,12 +687,12 @@ namespace MM
|
|||
uint32_t MaxBlock(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
* The MaxBlock function returns the maximum contiguous space, in bytes, that you
|
||||
* could obtain after compacting the current heap zone. MaxBlock does not actually
|
||||
* The MaxBlock function returns the maximum contiguous space, in bytes, that you
|
||||
* could obtain after compacting the current heap zone. MaxBlock does not actually
|
||||
* do the compaction.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* on entry:
|
||||
* (nothing)
|
||||
*
|
||||
|
@ -709,7 +710,7 @@ namespace MM
|
|||
uint32_t FreeMem(uint16_t trap)
|
||||
{
|
||||
// total free memory.
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* (nothing)
|
||||
*
|
||||
|
@ -729,7 +730,7 @@ namespace MM
|
|||
|
||||
uint16_t ReserveMem(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0: cbNeeded (long word)
|
||||
*
|
||||
|
@ -753,7 +754,7 @@ namespace MM
|
|||
|
||||
uint16_t MoveHHi(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0: Handle to move
|
||||
*
|
||||
|
@ -778,7 +779,7 @@ namespace MM
|
|||
uint32_t StackSpace(uint16_t trap)
|
||||
{
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
*
|
||||
* on exit:
|
||||
|
@ -806,7 +807,7 @@ namespace MM
|
|||
|
||||
uint16_t NewPtr(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0 Number of logical bytes requested
|
||||
*
|
||||
|
@ -837,7 +838,7 @@ namespace MM
|
|||
|
||||
uint16_t DisposePtr(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Pointer to the nonrelocatable block to be disposed of
|
||||
*
|
||||
|
@ -859,7 +860,7 @@ namespace MM
|
|||
|
||||
uint32_t GetPtrSize(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 pointer
|
||||
*
|
||||
|
@ -881,7 +882,7 @@ namespace MM
|
|||
|
||||
uint16_t SetPtrSize(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 pointer
|
||||
* D0 new size
|
||||
|
@ -917,7 +918,7 @@ namespace MM
|
|||
|
||||
uint16_t NewHandle(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0 Number of logical bytes requested
|
||||
*
|
||||
|
@ -945,7 +946,7 @@ namespace MM
|
|||
|
||||
uint16_t DisposeHandle(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle to be disposed of
|
||||
*
|
||||
|
@ -963,7 +964,7 @@ namespace MM
|
|||
|
||||
uint16_t EmptyHandle(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle to be disposed of
|
||||
*
|
||||
|
@ -996,7 +997,7 @@ namespace MM
|
|||
|
||||
/*
|
||||
* ReallocHandle (h: Handle; logicalSize: Size);
|
||||
*
|
||||
*
|
||||
* ReallocHandle allocates a new relocatable block with a logical
|
||||
* size of logicalSize bytes. It then updates handle h by setting
|
||||
* its master pointer to point to the new block. The main use of
|
||||
|
@ -1005,12 +1006,12 @@ namespace MM
|
|||
* be: If it points to an existing block, that block is released
|
||||
* before the new block is created.
|
||||
*
|
||||
* In case of an error, no new block is allocated and handle h is
|
||||
* In case of an error, no new block is allocated and handle h is
|
||||
* left unchanged.
|
||||
*/
|
||||
uint16_t ReallocHandle(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle to be disposed of
|
||||
* D0 Logical Size
|
||||
|
@ -1069,7 +1070,7 @@ namespace MM
|
|||
|
||||
uint32_t GetHandleSize(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 handle
|
||||
*
|
||||
|
@ -1104,7 +1105,7 @@ namespace MM
|
|||
uint16_t SetHandleSize(uint16_t trap)
|
||||
{
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 pointer
|
||||
* D0 new size
|
||||
|
@ -1132,7 +1133,7 @@ namespace MM
|
|||
* A0 Master pointer
|
||||
*
|
||||
* on exit:
|
||||
* A0 Handle to master pointer’s relocatable block
|
||||
* A0 Handle to master pointer’s relocatable block
|
||||
* D0 Unchanged
|
||||
*
|
||||
*/
|
||||
|
@ -1144,7 +1145,7 @@ namespace MM
|
|||
Log("%04x RecoverHandle(%08x)\n", trap, p);
|
||||
|
||||
uint16_t error = MacOS::memBCErr;
|
||||
for (const auto kv : HandleMap)
|
||||
for (const auto &kv : HandleMap)
|
||||
{
|
||||
const HandleInfo &info = kv.second;
|
||||
|
||||
|
@ -1202,13 +1203,13 @@ namespace MM
|
|||
|
||||
const auto &info = iter->second;
|
||||
|
||||
// resouce not yet supported...
|
||||
// resource not yet supported...
|
||||
// would need extra field and support in RM:: when
|
||||
// creating.
|
||||
// see HSetRBit, HClrRBit
|
||||
if (info.resource) flags |= (1 << 5);
|
||||
if (info.purgeable) flags |= (1 << 6);
|
||||
if (info.locked) flags |= (1 << 7);
|
||||
if (info.locked) flags |= (1 << 7);
|
||||
|
||||
SetMemError(0);
|
||||
return flags;
|
||||
|
@ -1247,7 +1248,7 @@ namespace MM
|
|||
|
||||
uint16_t HPurge(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle
|
||||
*
|
||||
|
@ -1272,7 +1273,7 @@ namespace MM
|
|||
|
||||
uint16_t HNoPurge(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle
|
||||
*
|
||||
|
@ -1296,7 +1297,7 @@ namespace MM
|
|||
|
||||
uint16_t HLock(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle
|
||||
*
|
||||
|
@ -1319,7 +1320,7 @@ namespace MM
|
|||
|
||||
uint16_t HUnlock(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle
|
||||
*
|
||||
|
@ -1345,7 +1346,7 @@ namespace MM
|
|||
|
||||
uint16_t HandToHand(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 source Handle
|
||||
*
|
||||
|
@ -1364,7 +1365,7 @@ namespace MM
|
|||
return SetMemError(MacOS::memWZErr);
|
||||
|
||||
|
||||
auto const info = iter->second;
|
||||
auto const info = iter->second;
|
||||
|
||||
|
||||
uint32_t destHandle;
|
||||
|
@ -1374,7 +1375,7 @@ namespace MM
|
|||
{
|
||||
std::memmove(memoryPointer(destPtr), memoryPointer(info.address), info.size);
|
||||
}
|
||||
|
||||
|
||||
cpuSetAReg(0, destHandle);
|
||||
return d0; // SetMemError called by Native::NewHandle.
|
||||
}
|
||||
|
@ -1382,7 +1383,7 @@ namespace MM
|
|||
|
||||
uint16_t PtrToHand(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 source Pointer
|
||||
* D0 size
|
||||
|
@ -1405,7 +1406,7 @@ namespace MM
|
|||
{
|
||||
std::memmove(memoryPointer(destPtr), memoryPointer(mcptr), size);
|
||||
}
|
||||
|
||||
|
||||
cpuSetAReg(0, destHandle);
|
||||
return d0; // SetMemError called by Native::NewHandle.
|
||||
}
|
||||
|
@ -1414,7 +1415,7 @@ namespace MM
|
|||
{
|
||||
// FUNCTION PtrAndHand (pntr: Ptr; hndl: Handle; size: LongInt): OSErr;
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 source Pointer
|
||||
* A1 dest Handle
|
||||
|
@ -1451,7 +1452,7 @@ namespace MM
|
|||
if (iter == HandleMap.end())
|
||||
return SetMemError(MacOS::memWZErr);
|
||||
|
||||
auto const info = iter->second;
|
||||
auto const info = iter->second;
|
||||
|
||||
std::memmove(memoryPointer(info.address + oldSize), memoryPointer(ptr), size);
|
||||
|
||||
|
@ -1464,7 +1465,7 @@ namespace MM
|
|||
#pragma mark -
|
||||
uint32_t StripAddress(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* d0 Address to strip
|
||||
*
|
||||
|
@ -1490,12 +1491,12 @@ namespace MM
|
|||
uint16_t HandleZone(uint16_t trap)
|
||||
{
|
||||
// FUNCTION HandleZone (h: Handle): THz;
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Handle whose zone is to be found
|
||||
*
|
||||
* on exit:
|
||||
* A0 Pointer to handle’s heap zone
|
||||
* A0 Pointer to handle’s heap zone
|
||||
* D0 Result code
|
||||
*
|
||||
*/
|
||||
|
@ -1524,7 +1525,7 @@ namespace MM
|
|||
* on entry:
|
||||
*
|
||||
* on exit:
|
||||
* A0 Pointer to current heap zone
|
||||
* A0 Pointer to current heap zone
|
||||
* D0 Result code
|
||||
*/
|
||||
|
||||
|
@ -1566,13 +1567,33 @@ namespace MM
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint16_t SetApplLimit(uint16_t trap)
|
||||
{
|
||||
// PROCEDURE SetApplLimit (zoneLimit: Ptr);
|
||||
|
||||
/*
|
||||
* on entry
|
||||
* A0 Pointer to desired new zone limit
|
||||
*
|
||||
* on exit
|
||||
* D0 Result code
|
||||
*/
|
||||
|
||||
uint32_t zoneLimit = cpuGetAReg(0);
|
||||
|
||||
Log("%04x SetApplLimit(%08x)\n", trap, zoneLimit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t PurgeSpace(uint16_t trap)
|
||||
{
|
||||
// PROCEDURE PurgeSpace (VAR total: LongInt; VAR contig: LongInt);
|
||||
|
||||
/*
|
||||
* Registers on exit:
|
||||
* A0 Maximum number of contiguous bytes after purge
|
||||
* A0 Maximum number of contiguous bytes after purge
|
||||
* D0 Total free memory after purge
|
||||
*/
|
||||
|
||||
|
@ -1634,7 +1655,7 @@ namespace MM
|
|||
|
||||
uint16_t TempHLock(void)
|
||||
{
|
||||
// PROCEDURE TempHLock (theHandle: Handle; VAR resultCode: OSErr);
|
||||
// PROCEDURE TempHLock (theHandle: Handle; VAR resultCode: OSErr);
|
||||
uint32_t theHandle;
|
||||
uint32_t resultCode;
|
||||
|
||||
|
@ -1650,7 +1671,7 @@ namespace MM
|
|||
|
||||
uint16_t TempHUnlock(void)
|
||||
{
|
||||
// PROCEDURE TempHUnlock (theHandle: Handle; VAR resultCode: OSErr);
|
||||
// PROCEDURE TempHUnlock (theHandle: Handle; VAR resultCode: OSErr);
|
||||
uint32_t theHandle;
|
||||
uint32_t resultCode;
|
||||
|
||||
|
@ -1667,7 +1688,7 @@ namespace MM
|
|||
|
||||
uint16_t TempDisposeHandle(void)
|
||||
{
|
||||
// PROCEDURE TempDisposeHandle (theHandle: Handle; VAR resultCode: OSErr);
|
||||
// PROCEDURE TempDisposeHandle (theHandle: Handle; VAR resultCode: OSErr);
|
||||
uint32_t theHandle;
|
||||
uint32_t resultCode;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace MM
|
|||
bool purgeable = false;
|
||||
bool resource = false;
|
||||
|
||||
HandleInfo(uint32_t a = 0, uint32_t s = 0) :
|
||||
HandleInfo(uint32_t a = 0, uint32_t s = 0) :
|
||||
address(a), size(s)
|
||||
{}
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ namespace MM
|
|||
uint32_t FreeMem(uint16_t trap);
|
||||
uint16_t ReserveMem(uint16_t trap);
|
||||
uint32_t PurgeSpace(uint16_t trap);
|
||||
|
||||
|
||||
|
||||
uint16_t DisposeHandle(uint16_t trap);
|
||||
uint16_t DisposePtr(uint16_t trap);
|
||||
|
@ -115,6 +115,8 @@ namespace MM
|
|||
|
||||
uint16_t MaxApplZone(uint16_t trap);
|
||||
|
||||
uint16_t SetApplLimit(uint16_t trap);
|
||||
|
||||
// OS Dispatch
|
||||
|
||||
uint16_t TempMaxMem(void);
|
||||
|
@ -128,4 +130,4 @@ namespace MM
|
|||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
126
toolbox/os.cpp
126
toolbox/os.cpp
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -77,13 +77,13 @@ namespace {
|
|||
|
||||
pos = s.find_last_of("./:");
|
||||
|
||||
if (pos == s.npos) return tmp;
|
||||
if (pos == s.npos) return tmp;
|
||||
if (s[pos++] != '.') return tmp;
|
||||
if (pos >= s.length()) return tmp;
|
||||
|
||||
tmp = s.substr(pos);
|
||||
|
||||
std::transform(tmp.begin(), tmp.end(), tmp.begin(),
|
||||
std::transform(tmp.begin(), tmp.end(), tmp.begin(),
|
||||
[](char c) { return tolower(c); }
|
||||
);
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace OS
|
|||
if (rv >= 8 && memcmp(buffer, "TEXT", 4) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::string ext = extension(s);
|
||||
if (ext.empty()) return false;
|
||||
|
||||
|
@ -157,8 +157,10 @@ namespace OS
|
|||
case 'e':
|
||||
if (ext == "equ") // asm iigs include file.
|
||||
return true;
|
||||
if (ext == "equates") // asm iigs include file.
|
||||
return true;
|
||||
break;
|
||||
|
||||
|
||||
case 'i':
|
||||
if (ext == "i") // asmiigs include file
|
||||
return true;
|
||||
|
@ -167,7 +169,7 @@ namespace OS
|
|||
break;
|
||||
|
||||
case 'h':
|
||||
if (ext == "h") // c header
|
||||
if (ext == "h") // c header
|
||||
return true;
|
||||
break;
|
||||
|
||||
|
@ -242,7 +244,7 @@ namespace OS
|
|||
if (buffer[0] == 'B' && buffer[2] == ' ' && buffer[3] == ' ')
|
||||
return true;
|
||||
|
||||
// "p" $uv $wx $yz
|
||||
// "p" $uv $wx $yz
|
||||
if (buffer[0] == 'p')
|
||||
{
|
||||
uint8_t fileType = buffer[1];
|
||||
|
@ -271,7 +273,7 @@ namespace OS
|
|||
return true;
|
||||
// Newton C++ Tools output
|
||||
if (ext == "ntkc")
|
||||
return true;
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
|
@ -284,7 +286,12 @@ namespace OS
|
|||
case 's':
|
||||
// Newton C++ Intermediate file
|
||||
if (ext == "sym")
|
||||
return true;
|
||||
return true;
|
||||
break;
|
||||
case 'x':
|
||||
// xcoff object file
|
||||
if (ext == "x")
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -382,7 +389,7 @@ namespace OS
|
|||
else
|
||||
{
|
||||
::close(fd);
|
||||
d0 = 0;
|
||||
d0 = 0;
|
||||
}
|
||||
|
||||
memoryWriteWord(d0, parm + _ioResult);
|
||||
|
@ -421,7 +428,7 @@ namespace OS
|
|||
|
||||
int fd;
|
||||
|
||||
uint8_t ioPermission = memoryReadByte(parm + _ioPermssn);
|
||||
uint8_t ioPermission = memoryReadByte(parm + _ioPermssn);
|
||||
uint32_t namePtr = memoryReadLong(parm + _ioNamePtr);
|
||||
|
||||
std::string sname = ToolBox::ReadPString(namePtr, true);
|
||||
|
@ -436,7 +443,7 @@ namespace OS
|
|||
d0 = fd < 0 ? fd : 0;
|
||||
if (fd >= 0)
|
||||
{
|
||||
memoryWriteWord(fd, parm + _ioRefNum);
|
||||
memoryWriteWord(fd, parm + _ioRefNum);
|
||||
}
|
||||
|
||||
memoryWriteWord(d0, parm + _ioResult);
|
||||
|
@ -507,9 +514,9 @@ namespace OS
|
|||
d0 = 0;
|
||||
pos += count;
|
||||
memoryWriteLong(count, parm + 40);
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
if (count == 0 && ioReqCount > 0)
|
||||
{
|
||||
d0 = MacOS::eofErr;
|
||||
}
|
||||
|
@ -567,7 +574,7 @@ namespace OS
|
|||
d0 = 0;
|
||||
pos += count;
|
||||
memoryWriteLong(count, parm + 40);
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
|
@ -781,11 +788,11 @@ namespace OS
|
|||
uint16_t CmpString(uint16_t trap)
|
||||
{
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Pointer to first character of first string
|
||||
* A1 Pointer to first character of second string
|
||||
* D0 (high) length of first string
|
||||
* D0 (high) length of first string
|
||||
* D0 (low) length of second string
|
||||
*
|
||||
* on exit:
|
||||
|
@ -793,8 +800,8 @@ namespace OS
|
|||
*
|
||||
*/
|
||||
|
||||
bool caseSens = trap & (1 << 9);
|
||||
//bool diacSens = trap & (1 << 10); // ignore for now...
|
||||
//bool diacSens = trap & (1 << 9); // ignore for now...
|
||||
bool caseSens = trap & (1 << 10);
|
||||
|
||||
uint32_t aStr = cpuGetAReg(0);
|
||||
uint32_t bStr = cpuGetAReg(1);
|
||||
|
@ -814,9 +821,9 @@ namespace OS
|
|||
|
||||
bool eq;
|
||||
eq = std::equal(
|
||||
a.begin(),
|
||||
a.end(),
|
||||
b.begin(),
|
||||
a.begin(),
|
||||
a.end(),
|
||||
b.begin(),
|
||||
[caseSens](char a, char b){
|
||||
if (!caseSens)
|
||||
{
|
||||
|
@ -831,6 +838,55 @@ namespace OS
|
|||
}
|
||||
|
||||
|
||||
uint16_t RelString(uint16_t trap)
|
||||
{
|
||||
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Pointer to first character of first string
|
||||
* A1 Pointer to first character of second string
|
||||
* D0 (high) length of first string
|
||||
* D0 (low) length of second string
|
||||
*
|
||||
* on exit:
|
||||
* D0 0 if strings equal, -1 if first < second, 1 if first > second
|
||||
*
|
||||
*/
|
||||
|
||||
//bool diacSens = trap & (1 << 9); // ignore for now...
|
||||
bool caseSens = trap & (1 << 10);
|
||||
|
||||
uint32_t aStr = cpuGetAReg(0);
|
||||
uint32_t bStr = cpuGetAReg(1);
|
||||
|
||||
uint32_t length = cpuGetDReg(0);
|
||||
|
||||
uint32_t aLen = (length >> 16);
|
||||
uint32_t bLen = (length & 0xffff);
|
||||
|
||||
std::string a = ToolBox::ReadString(aStr, aLen);
|
||||
std::string b = ToolBox::ReadString(bStr, bLen);
|
||||
|
||||
Log("%04x RelString(%s, %s)\n", trap, a.c_str(), b.c_str());
|
||||
|
||||
if (aStr == bStr) return 0; // same ptr...
|
||||
|
||||
for (uint32_t i = 0; i < std::min(aLen, bLen); ++i) {
|
||||
unsigned aa = a[i];
|
||||
unsigned bb = b[i];
|
||||
if (!caseSens) {
|
||||
aa = toupper(aa);
|
||||
bb = toupper(bb);
|
||||
}
|
||||
if (aa == bb) continue;
|
||||
return aa < bb ? -1 : 1;
|
||||
}
|
||||
if (aLen == bLen) return 0;
|
||||
return aLen < bLen ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - Time Utilities
|
||||
|
||||
time_t UnixToMac(time_t t)
|
||||
|
@ -846,7 +902,7 @@ namespace OS
|
|||
uint16_t ReadDateTime(uint16_t trap)
|
||||
{
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Pointer to long word secs
|
||||
*
|
||||
|
@ -875,7 +931,7 @@ namespace OS
|
|||
|
||||
uint16_t SecondsToDate(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0 Seconds since midnight, January 1, 1904
|
||||
* A0 pointer to date-time record
|
||||
|
@ -933,7 +989,7 @@ namespace OS
|
|||
uint16_t Microseconds(uint16_t trap)
|
||||
{
|
||||
|
||||
// UnsignedWide is a uint64_t
|
||||
// UnsignedWide is a uint64_t
|
||||
// Microseconds(UnsignedWide * microTickCount)
|
||||
// FOURWORDINLINE(0xA193, 0x225F, 0x22C8, 0x2280);
|
||||
|
||||
|
@ -958,9 +1014,10 @@ namespace OS
|
|||
|
||||
#pragma mark - Trap Manager
|
||||
|
||||
#ifdef OLD_TRAP_DISPATCH
|
||||
uint16_t GetToolTrapAddress(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0 trap number
|
||||
*
|
||||
|
@ -982,7 +1039,7 @@ namespace OS
|
|||
{
|
||||
//pascal void SetToolTrapAddress(long trapAddr, short trapNum);
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Address of patch
|
||||
* D0 trap number
|
||||
|
@ -1008,7 +1065,7 @@ namespace OS
|
|||
|
||||
uint16_t GetOSTrapAddress(uint16_t trap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* D0 trap number
|
||||
*
|
||||
|
@ -1030,7 +1087,7 @@ namespace OS
|
|||
{
|
||||
//pascal void SetOSTrapAddress(long trapAddr, short trapNum);
|
||||
|
||||
/*
|
||||
/*
|
||||
* on entry:
|
||||
* A0 Address of patch
|
||||
* D0 trap number
|
||||
|
@ -1050,6 +1107,7 @@ namespace OS
|
|||
|
||||
return MacOS::dsCoreErr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#pragma mark XP - RAM
|
||||
|
@ -1180,7 +1238,7 @@ namespace OS
|
|||
iter->when = now + std::chrono::microseconds(micro);
|
||||
|
||||
}
|
||||
memoryWriteWord(tmTaskPtr + _qType, 0x8000);
|
||||
memoryWriteWord(0x8000, tmTaskPtr + _qType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1239,8 +1297,8 @@ namespace OS
|
|||
count = micro / 10000;
|
||||
}
|
||||
|
||||
memoryWriteWord(tmTaskPtr + _qType, 0);
|
||||
memoryWriteLong(tmTaskPtr + _tmCount, count);
|
||||
memoryWriteWord(0, tmTaskPtr + _qType);
|
||||
memoryWriteLong(count, tmTaskPtr + _tmCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace OS
|
|||
uint16_t Create(uint16_t trap);
|
||||
uint16_t Delete(uint16_t trap);
|
||||
uint16_t FlushVol(uint16_t trap);
|
||||
|
||||
|
||||
uint16_t GetFileInfo(uint16_t trap);
|
||||
uint16_t HGetFileInfo(uint16_t trap);
|
||||
uint16_t SetFileInfo(uint16_t trap);
|
||||
|
@ -56,7 +56,7 @@ namespace OS
|
|||
|
||||
uint16_t GetVol(uint16_t trap);
|
||||
uint16_t HGetVol(uint16_t trap);
|
||||
|
||||
|
||||
uint16_t HGetVInfo(uint16_t trap);
|
||||
|
||||
uint16_t SetVol(uint16_t trap);
|
||||
|
@ -71,6 +71,7 @@ namespace OS
|
|||
|
||||
#pragma mark String Utilities
|
||||
uint16_t CmpString(uint16_t trap);
|
||||
uint16_t RelString(uint16_t trap);
|
||||
|
||||
|
||||
#pragma mark - Time Utilities
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -74,13 +74,13 @@ namespace OS {
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "AliasDispatch: selector $%04x not implemented\n",
|
||||
fprintf(stderr, "AliasDispatch: selector $%04x not implemented\n",
|
||||
selector);
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ToolReturn<2>(-1, d0);
|
||||
return d0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -59,7 +59,9 @@ using ToolBox::Log;
|
|||
|
||||
using MacOS::macos_error_from_errno;
|
||||
|
||||
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define st_birthtime st_mtime
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -86,7 +88,7 @@ namespace {
|
|||
}
|
||||
|
||||
namespace OS {
|
||||
|
||||
|
||||
|
||||
uint16_t GetFileInfo(uint16_t trap)
|
||||
{
|
||||
|
@ -169,7 +171,7 @@ namespace OS {
|
|||
}
|
||||
|
||||
|
||||
Internal::GetFinderInfo(sname, memoryPointer(parm + _ioFlFndrInfo), false);
|
||||
Internal::GetFinderInfo(sname, memoryPointer(parm + _ioFlFndrInfo), false);
|
||||
|
||||
|
||||
// file reference number
|
||||
|
@ -294,7 +296,7 @@ namespace OS {
|
|||
{
|
||||
d0 = macos_error_from_errno();
|
||||
memoryWriteWord(d0, parm + _ioResult);
|
||||
return d0;
|
||||
return d0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,7 +316,7 @@ namespace OS {
|
|||
|
||||
uint16_t HGetFileInfo(uint16_t trap)
|
||||
{
|
||||
|
||||
|
||||
enum { // HFileParam
|
||||
_qLink = 0,
|
||||
_qType = 4,
|
||||
|
@ -348,4 +350,4 @@ namespace OS {
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <deque>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
|
||||
#include <sys/xattr.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -55,6 +56,8 @@
|
|||
|
||||
using ToolBox::Log;
|
||||
|
||||
#define FOUR_CHAR_CODE(x) x
|
||||
|
||||
namespace OS {
|
||||
|
||||
enum
|
||||
|
@ -65,9 +68,45 @@ namespace OS {
|
|||
gestaltLocationErr = -5553,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
gestaltOSAttr = FOUR_CHAR_CODE('os '), /* o/s attributes */
|
||||
gestaltSysZoneGrowable = 0, /* system heap is growable */
|
||||
gestaltLaunchCanReturn = 1, /* can return from launch */
|
||||
gestaltLaunchFullFileSpec = 2, /* can launch from full file spec */
|
||||
gestaltLaunchControl = 3, /* launch control support available */
|
||||
gestaltTempMemSupport = 4, /* temp memory support */
|
||||
gestaltRealTempMemory = 5, /* temp memory handles are real */
|
||||
gestaltTempMemTracked = 6, /* temporary memory handles are tracked */
|
||||
gestaltIPCSupport = 7, /* IPC support is present */
|
||||
gestaltSysDebuggerSupport = 8, /* system debugger support is present */
|
||||
gestaltNativeProcessMgrBit = 19 /* the process manager itself is native */
|
||||
};
|
||||
|
||||
|
||||
template<unsigned...>
|
||||
struct make_bitmask;
|
||||
|
||||
template<>
|
||||
struct make_bitmask<> : public std::integral_constant<uint32_t, 0>
|
||||
{};
|
||||
|
||||
template<unsigned First, unsigned... Rest>
|
||||
struct make_bitmask<First, Rest...> :
|
||||
public std::integral_constant<uint32_t, (1 << First) | make_bitmask<Rest...>::value >
|
||||
{};
|
||||
|
||||
|
||||
|
||||
|
||||
std::map<uint32_t, uint32_t> GestaltMap = {
|
||||
{'alis', 1}, // Alias Manager
|
||||
{'tmgr', 2}, // Time Manager (2 = revised, 3 = extended.)
|
||||
{
|
||||
// enable temp memory for codewarrior
|
||||
gestaltOSAttr,
|
||||
make_bitmask<gestaltTempMemSupport, gestaltRealTempMemory, gestaltTempMemTracked>::value
|
||||
},
|
||||
};
|
||||
|
||||
uint16_t Gestalt(uint16_t trap)
|
||||
|
@ -154,4 +193,3 @@ namespace OS {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue