mirror of https://github.com/ksherlock/mpw.git
Compare commits
196 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 | |
Kelvin Sherlock | a7301cfd5d | |
Kelvin Sherlock | d48f3c39da | |
Kelvin Sherlock | 67cb2b6e09 | |
Kelvin Sherlock | 42fe265dd2 | |
Kelvin Sherlock | 9fda034e0e | |
Kelvin Sherlock | f0e585aada | |
Kelvin Sherlock | 279c8c2300 | |
Kelvin Sherlock | 3ff0697e46 | |
Kelvin Sherlock | 6197910e3e | |
Kelvin Sherlock | 33ba7e076a | |
Kelvin Sherlock | acf93dacbf | |
Kelvin Sherlock | ab6259c030 | |
Kelvin Sherlock | bfc36cb872 | |
Kelvin Sherlock | 7168fe8ba3 | |
Kelvin Sherlock | ce3b1ca11d | |
Kelvin Sherlock | ddeea8620f | |
Kelvin Sherlock | 710da65650 | |
Kelvin Sherlock | 023d233c40 | |
Kelvin Sherlock | d0d1e84162 | |
ksherlock | 5bab4d85eb | |
Jake-B | cbe642bfc8 | |
Jake-B | f02b930700 | |
Kelvin Sherlock | 176fb108a6 | |
Kelvin Sherlock | 928010f800 | |
Kelvin Sherlock | 792e21d0c1 | |
Kelvin Sherlock | 7c928c8eb5 | |
Kelvin Sherlock | 3e64b3e087 | |
Kelvin Sherlock | e4ad003bc7 | |
Kelvin Sherlock | 7beb3a7b43 | |
Kelvin Sherlock | 813e36a6c4 | |
Kelvin Sherlock | 44d19f7d1b | |
Kelvin Sherlock | 3615fbe941 | |
Kelvin Sherlock | 172da3e250 | |
Kelvin Sherlock | acea989367 | |
Kelvin Sherlock | 3448078612 | |
Kelvin Sherlock | 24666c209f | |
Kelvin Sherlock | 34d1fba0f1 | |
Kelvin Sherlock | 654baccabc | |
Kelvin Sherlock | 92d465fb56 | |
Kelvin Sherlock | e8d756c1b6 | |
Kelvin Sherlock | 74370db603 | |
Kelvin Sherlock | b146399a7e | |
Kelvin Sherlock | 245fabe648 | |
Kelvin Sherlock | 6c8511838e | |
Kelvin Sherlock | cc477e0865 | |
Kelvin Sherlock | 863fafda98 | |
Kelvin Sherlock | eca0516094 | |
Kelvin Sherlock | d2bca7efe0 | |
Kelvin Sherlock | cf4a8e2fcc | |
Kelvin Sherlock | cb08a2e4c2 | |
Kelvin Sherlock | dbdcbea31c | |
Kelvin Sherlock | 80efa55c24 | |
Kelvin Sherlock | 5deea9eb84 | |
Kelvin Sherlock | bfa09940e7 | |
Kelvin Sherlock | f42c8e06dd | |
Kelvin Sherlock | ff9a0aad3e | |
Kelvin Sherlock | 6aaadb8861 | |
Kelvin Sherlock | dba511a103 | |
Kelvin Sherlock | 3f4dd56d78 | |
Kelvin Sherlock | b9fcbf2aac | |
Kelvin Sherlock | 45c89042ee | |
Kelvin Sherlock | 2bb2bd4326 | |
Kelvin Sherlock | d043ff9d9c | |
Kelvin Sherlock | 2adbe82704 | |
Kelvin Sherlock | 42a1f5030d | |
Kelvin Sherlock | 02e95874d1 | |
Kelvin Sherlock | 1e2c1a8f5d | |
Kelvin Sherlock | 7eb33de435 | |
Kelvin Sherlock | 24e47c7f9b | |
Kelvin Sherlock | 183078925e | |
Kelvin Sherlock | 6449892f51 | |
Kelvin Sherlock | ac66233f40 | |
Kelvin Sherlock | 00c38721a7 | |
Kelvin Sherlock | 3b904ee3de | |
Kelvin Sherlock | 806a4b7eaf | |
Kelvin Sherlock | a78226c536 | |
Kelvin Sherlock | 6acd7797af | |
Kelvin Sherlock | 25357e2666 | |
Kelvin Sherlock | 15d0eded63 | |
Kelvin Sherlock | 427a4a6f31 | |
Kelvin Sherlock | 5aa9f08870 | |
Kelvin Sherlock | b707e02295 | |
Kelvin Sherlock | cbe66b6798 | |
Kelvin Sherlock | f946dc1884 | |
Kelvin Sherlock | f6cc3925a7 | |
Kelvin Sherlock | f7bee265cc | |
Kelvin Sherlock | 8e434d39f8 | |
Kelvin Sherlock | d400bfb4da | |
Kelvin Sherlock | 1cd59d36f3 | |
Kelvin Sherlock | 7691267dea | |
Kelvin Sherlock | a111120033 | |
Kelvin Sherlock | 490519b0d1 |
|
@ -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
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
.DS_Store
|
||||
*.dSYM
|
||||
build/
|
||||
fellow/
|
||||
fellow/
|
||||
dist/
|
||||
rtl/
|
||||
docs/
|
||||
MrC/
|
||||
testing/
|
||||
|
||||
|
|
|
@ -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,3 +1,23 @@
|
|||
|
||||
-------------------------
|
||||
0.8.0 - February 12, 2014
|
||||
-------------------------
|
||||
|
||||
* new debugger feature: templates ("a0;t HFileInfo" to display as an HFileInfo struct)
|
||||
* Prevent OS X Resource Manager from byteswapping resource data. Rez and DeRez now work.
|
||||
* .sym and .ntkc files considered binary (Newton tools)
|
||||
* some support for the MetroWerks MPW tools
|
||||
* Lots of other miscellaneous bug fixes and tweaks
|
||||
|
||||
-------------------------
|
||||
0.7.9.a - January 4, 2014
|
||||
-------------------------
|
||||
|
||||
* Improved MrC/pp compatibility. MrC creates a binary temp file that was treated as text which caused problems.
|
||||
* added TempNewHandle, TempHLock, TempHUnlock, and TempDisposeHandle toolcalls
|
||||
* added ;date debugger command: expr;date will display expr as a MacOS date/time
|
||||
* added ;error debugger command: expr;error will display exrp as a MacOS error.
|
||||
|
||||
------------------------
|
||||
0.7.9 - December 28, 2014
|
||||
------------------------
|
||||
|
|
|
@ -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,61 +1,82 @@
|
|||
#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 ${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
|
||||
)
|
||||
|
||||
|
||||
set_source_files_properties(
|
||||
loadtrap.cpp lexer.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wno-unused-variable"
|
||||
add_custom_command(
|
||||
OUTPUT template_loader.cpp
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
add_executable(mpw loader.cpp debugger.cpp address_map.cpp lexer.cpp parser.cpp loadtrap.cpp)
|
||||
add_executable(mpw loader.cpp debugger.cpp debugger_internal.cpp
|
||||
address_map.cpp lexer.cpp parser.cpp loadtrap.cpp
|
||||
commands.cpp
|
||||
template_loader.cpp template_parser.cpp intern.cpp template.cpp)
|
||||
|
||||
|
||||
target_link_libraries(mpw CPU_LIB)
|
||||
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
|
||||
|
|
|
@ -0,0 +1,243 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#include <toolbox/os.h>
|
||||
#include <macos/errors.h>
|
||||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
||||
#include "debugger.h"
|
||||
#include "debugger_internal.h"
|
||||
#include "loader.h" // Flags
|
||||
|
||||
|
||||
namespace Debug {
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
|
||||
void hexdump(const uint8_t *data, ssize_t size, uint32_t address = 0)
|
||||
{
|
||||
const char *HexMap = "0123456789abcdef";
|
||||
|
||||
char buffer1[16 * 3 + 1 + 1];
|
||||
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];
|
||||
buffer1[j++] = HexMap[x >> 4];
|
||||
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;
|
||||
size -= 16;
|
||||
}
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PrintError(uint32_t value)
|
||||
{
|
||||
/* expr ; error -- interpret expr as an OSErr */
|
||||
|
||||
|
||||
// errors are signed 16-bit values.
|
||||
|
||||
if ((int32_t)value > UINT16_MAX) return;
|
||||
if ((int32_t)value < INT16_MIN) return;
|
||||
|
||||
|
||||
uint16_t error = value;
|
||||
printf("%d\n", (int16_t)error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
bool found = false;
|
||||
const char *cp = ErrorName(error);
|
||||
if (cp)
|
||||
{
|
||||
printf("%s\n", cp);
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
||||
for (auto iter = ErrorTableInvert.find(error); iter != ErrorTableInvert.end(); ++iter) {
|
||||
|
||||
// multimap - continue until error doesn't match.
|
||||
if (iter->first != error) break;
|
||||
|
||||
printf("%s\n", iter->second.c_str());
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) printf("Unknown error\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("noErr\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrintDate(uint32_t value)
|
||||
{
|
||||
/* expr ; date -- interpret expr as a macos date */
|
||||
|
||||
char buffer[64];
|
||||
struct tm *tm;
|
||||
time_t t = OS::MacToUnix(value);
|
||||
|
||||
// localtime vs gmtime?
|
||||
tm = ::localtime(&t);
|
||||
strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M:%S %p", tm);
|
||||
puts(buffer);
|
||||
}
|
||||
|
||||
|
||||
void Moof(void)
|
||||
{
|
||||
|
||||
puts("");
|
||||
puts(" ## ");
|
||||
puts(" ## ## #### ");
|
||||
puts(" ## #### ## ");
|
||||
puts(" ## ## ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ## ## #### ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ######## #### ## ## ");
|
||||
puts(" ## #################### ## ");
|
||||
puts(" ## ############## ## ");
|
||||
puts(" #### ############ ## ");
|
||||
puts(" ###### ###### ## ");
|
||||
puts(" ###### ## ");
|
||||
puts(" #### ## ");
|
||||
puts(" ## ## ");
|
||||
puts(" ## ################ ## ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ## ## ## ## ");
|
||||
puts(" ###### ###### ");
|
||||
puts("");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void StackCrawl(void)
|
||||
{
|
||||
// stack crawl based on a6 frame pointers. (link/unlink)
|
||||
// start with current a6.
|
||||
|
||||
uint32_t a6 = cpuGetAReg(6);
|
||||
|
||||
/*
|
||||
* a6: previous a6
|
||||
* a6+4 return pc
|
||||
* .... parameters, locals, stack data
|
||||
* previous a6
|
||||
* return pc
|
||||
* ....
|
||||
*/
|
||||
// todo -- need a function to verify address is w/in stack range.
|
||||
|
||||
// todo print in reverse order so newest frame doesn't scroll away.
|
||||
|
||||
if (!a6) return;
|
||||
printf("a6: %08x\n", a6);
|
||||
|
||||
while(a6)
|
||||
{
|
||||
|
||||
uint32_t prevA6 = ReadLong(a6);
|
||||
if (prevA6 <= a6) break;
|
||||
|
||||
uint32_t pc = ReadLong(a6+4); //
|
||||
|
||||
|
||||
|
||||
// hexdump contents between pc and previous....
|
||||
ssize_t size = prevA6 - a6 - 8;
|
||||
hexdump(Flags.memory + a6 + 8, size);
|
||||
|
||||
|
||||
|
||||
puts("------------");
|
||||
printf("a6: %08x\n", prevA6);
|
||||
printf("pc: %08x", pc);
|
||||
|
||||
// find the routine name...
|
||||
for (const auto &kv : SymbolTable)
|
||||
{
|
||||
const auto &name = kv.first;
|
||||
auto range = kv.second;
|
||||
|
||||
// range end may be 0
|
||||
if ((pc == range.first) || (pc >= range.first && pc < range.second))
|
||||
{
|
||||
uint32_t offset = pc - range.first;
|
||||
if (offset)
|
||||
printf(" %s+$%x", name.c_str(), offset);
|
||||
else
|
||||
printf(" %s", name.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
puts("");
|
||||
|
||||
a6 = prevA6;
|
||||
}
|
||||
}
|
||||
|
||||
void Dump(uint32_t start, int size)
|
||||
{
|
||||
// TODO -- if no address, use previous address.
|
||||
// TODO -- support range?
|
||||
|
||||
|
||||
if (size <= 0) return;
|
||||
|
||||
uint32_t end = start + size;
|
||||
|
||||
if (start >= Flags.memorySize) return;
|
||||
|
||||
end = std::min(end, Flags.memorySize);
|
||||
size = end - start;
|
||||
|
||||
hexdump(Flags.memory + start, size, start);
|
||||
}
|
||||
|
||||
|
||||
}
|
215
bin/debugger.cpp
215
bin/debugger.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
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
|
@ -48,6 +49,8 @@
|
|||
#include "address_map.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "debugger_internal.h"
|
||||
#include "template.h"
|
||||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
|
@ -58,13 +61,15 @@
|
|||
|
||||
#include <mpw/mpw.h>
|
||||
|
||||
#include <toolbox/loader.h>
|
||||
#include <toolbox/mm.h>
|
||||
#include <toolbox/loader.h>
|
||||
#include <toolbox/mm.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace Debug::Internal;
|
||||
|
||||
const uint32_t kGlobalSize = 0x10000;
|
||||
const uint32_t kBackTraceSize = 20;
|
||||
const uint32_t kBackTraceSize = 50;
|
||||
|
||||
bool sigInt = false;
|
||||
bool memBreak = false;
|
||||
|
@ -78,14 +83,8 @@ namespace {
|
|||
AddressMap wbrkMap; // write breaks.
|
||||
ToolMap tbrkMap; // tool breaks.
|
||||
|
||||
Loader::DebugNameTable SymbolTable;
|
||||
|
||||
std::map<std::string, uint16_t> ErrorTable;
|
||||
std::map<std::string, uint16_t> GlobalTable;
|
||||
std::map<std::string, uint16_t> TrapTable;
|
||||
|
||||
std::unordered_multimap<uint16_t, std::string> ErrorTableInvert;
|
||||
std::unordered_map<uint32_t, std::string> SymbolTableInvert;
|
||||
std::unordered_map<std::string, Debug::Template> TemplateTable;
|
||||
|
||||
struct BackTraceInfo {
|
||||
uint32_t a[8];
|
||||
|
@ -105,49 +104,8 @@ namespace {
|
|||
};
|
||||
|
||||
std::deque<BackTraceInfo> BackTrace;
|
||||
|
||||
void hexdump(const uint8_t *data, ssize_t size, uint32_t address = 0)
|
||||
{
|
||||
const char *HexMap = "0123456789abcdef";
|
||||
|
||||
char buffer1[16 * 3 + 1 + 1];
|
||||
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];
|
||||
buffer1[j++] = HexMap[x >> 4];
|
||||
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;
|
||||
size -= 16;
|
||||
}
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void printMacsbug(uint32_t pc, uint32_t opcode, uint32_t *newPC = nullptr)
|
||||
|
@ -163,7 +121,7 @@ namespace {
|
|||
break;
|
||||
case 0x4E74: // rtd #
|
||||
mboffset = 4;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
|
@ -179,7 +137,7 @@ namespace {
|
|||
b -= 0x80;
|
||||
pc++;
|
||||
if (!b) b = Debug::ReadByte(pc++);
|
||||
|
||||
|
||||
s.reserve(b);
|
||||
for (unsigned i = 0; i < b; ++i)
|
||||
{
|
||||
|
@ -227,7 +185,7 @@ namespace {
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("$%08X Tool #$%04X ; %04X\n",
|
||||
printf("$%08X Tool #$%04X ; %04X\n",
|
||||
pc, opcode, opcode);
|
||||
}
|
||||
|
||||
|
@ -249,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;
|
||||
}
|
||||
|
@ -257,7 +215,7 @@ namespace {
|
|||
{
|
||||
address = Debug::ReadLong(pc + 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 0x4EF9: // jmp address
|
||||
{
|
||||
address = Debug::ReadLong(pc + 2);
|
||||
|
@ -267,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?
|
||||
|
@ -339,7 +297,7 @@ namespace {
|
|||
{
|
||||
if (!trace) disasm(pc);
|
||||
printf("CPU stopped\n");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sigInt)
|
||||
|
@ -347,7 +305,7 @@ namespace {
|
|||
if (!trace) disasm(pc);
|
||||
printf("^C break\n");
|
||||
sigInt = false;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memBreak)
|
||||
|
@ -419,7 +377,7 @@ namespace {
|
|||
break;
|
||||
case 4:
|
||||
fprintf(stdout, " [%08x]\n", value);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "\n");
|
||||
break;
|
||||
|
@ -482,6 +440,34 @@ namespace {
|
|||
|
||||
namespace Debug {
|
||||
|
||||
std::string ReadPString(uint32_t address)
|
||||
{
|
||||
std::string tmp;
|
||||
unsigned size = ReadByte(address++);
|
||||
|
||||
tmp.reserve(size);
|
||||
for (unsigned i = 0; i < size; ++i)
|
||||
tmp.push_back(ReadByte(address++));
|
||||
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
std::string ReadCString(uint32_t address)
|
||||
{
|
||||
std::string tmp;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char c = ReadByte(address++);
|
||||
if (!c) break;
|
||||
tmp.push_back(c);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ReadLong(uint32_t address)
|
||||
{
|
||||
uint32_t tmp = 0;
|
||||
|
@ -621,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);
|
||||
|
@ -636,23 +622,6 @@ void Print(uint32_t data)
|
|||
}
|
||||
|
||||
|
||||
void Dump(uint32_t start, int size)
|
||||
{
|
||||
// TODO -- if no address, use previous address.
|
||||
// TODO -- support range?
|
||||
|
||||
|
||||
if (size <= 0) return;
|
||||
|
||||
uint32_t end = start + size;
|
||||
|
||||
if (start >= Flags.memorySize) return;
|
||||
|
||||
end = std::min(end, Flags.memorySize);
|
||||
size = end - start;
|
||||
|
||||
hexdump(Flags.memory + start, size, start);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -675,7 +644,7 @@ void List(uint32_t pc, int count)
|
|||
|
||||
void List(uint32_t pc, uint32_t endpc)
|
||||
{
|
||||
if (endpc < pc) return;
|
||||
if ((int32_t)endpc < (int32_t)pc) return;
|
||||
|
||||
if (pc & 0x01)
|
||||
{
|
||||
|
@ -721,19 +690,19 @@ 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]
|
||||
);
|
||||
|
||||
printf("PC: %08X CSR: %04x %s\n", i.pc, i.csr, srbits);
|
||||
printf("PC: %08x CSR: %04x %s\n", i.pc, i.csr, srbits);
|
||||
|
||||
}
|
||||
|
||||
|
@ -742,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)
|
||||
);
|
||||
|
||||
|
@ -818,7 +787,7 @@ void PrintBackTrace()
|
|||
disasm(prev->pc);
|
||||
btdiff(*prev, current);
|
||||
|
||||
//
|
||||
//
|
||||
prev = ¤t;
|
||||
}
|
||||
|
||||
|
@ -896,7 +865,7 @@ void Break(int32_t address)
|
|||
remove = true;
|
||||
}
|
||||
|
||||
// what was I thinking? only allow 24-bit addresses?
|
||||
// 24-bit address only.
|
||||
if ((address & 0xff000000) == 0)
|
||||
{
|
||||
if (remove) brkMap.remove(address);
|
||||
|
@ -981,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)
|
||||
{
|
||||
|
@ -1032,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)
|
||||
{
|
||||
|
@ -1115,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;
|
||||
|
@ -1138,8 +1107,24 @@ void Info(uint32_t address)
|
|||
cp = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ApplyTemplate(int32_t address, const std::string &name)
|
||||
{
|
||||
// find the template..
|
||||
|
||||
auto iter = TemplateTable.find(name);
|
||||
if (iter == TemplateTable.end()) {
|
||||
fprintf(stderr, "Unknown template: %s\n", name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
FieldEntry *e = iter->second;
|
||||
ApplyTemplate(address, e);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
/*
|
||||
|
@ -1150,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);
|
||||
|
@ -1170,13 +1157,14 @@ namespace {
|
|||
auto end = iter;
|
||||
|
||||
if (!count) return NULL;
|
||||
if (count > 100) return NULL;
|
||||
if (count > 100) return NULL;
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
char **buffer = (char **)malloc(2 * sizeof(char *));
|
||||
buffer[0] = strdup(begin->first.c_str());
|
||||
buffer[1] = NULL;
|
||||
char **buffer = (char **)malloc(3 * sizeof(char *));
|
||||
buffer[0] = strdup(begin->first.c_str()); // longest substring match
|
||||
buffer[1] = strdup(begin->first.c_str()); // the match
|
||||
buffer[2] = NULL;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -1186,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());
|
||||
|
@ -1202,7 +1190,7 @@ namespace {
|
|||
|
||||
if (i >= min_length)
|
||||
{
|
||||
buffer[0][i] = 0;
|
||||
buffer[0][i] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1227,17 +1215,11 @@ namespace {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
// this is here to prevent filename tab completion, for now.
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1258,16 +1240,19 @@ void Shell()
|
|||
LoadTrapFile(MPW::RootDirPathForFile("Globals.text"), GlobalTable);
|
||||
LoadTrapFile(MPW::RootDirPathForFile("Traps.text"), TrapTable);
|
||||
|
||||
LoadTemplateFile(MPW::RootDirPathForFile("Templates.text"), TemplateTable);
|
||||
|
||||
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
@ -1317,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);
|
||||
}
|
||||
|
@ -1326,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
|
||||
|
@ -110,6 +110,9 @@ uint32_t ReadLong(uint32_t);
|
|||
uint16_t ReadWord(uint32_t);
|
||||
uint8_t ReadByte(uint32_t);
|
||||
|
||||
std::string ReadPString(uint32_t);
|
||||
std::string ReadCString(uint32_t);
|
||||
|
||||
void Print(uint32_t value);
|
||||
void PrintRegisters();
|
||||
|
||||
|
@ -140,6 +143,14 @@ void WriteBreak(int32_t address);
|
|||
void ReadWriteBreak();
|
||||
void ReadWriteBreak(int32_t address);
|
||||
|
||||
|
||||
void PrintError(uint32_t value);
|
||||
void PrintDate(uint32_t value);
|
||||
|
||||
void StackCrawl(void);
|
||||
|
||||
void ApplyTemplate(int32_t address, const std::string &name);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "debugger_internal.h"
|
||||
|
||||
namespace Debug {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
Loader::DebugNameTable SymbolTable;
|
||||
|
||||
std::map<std::string, uint16_t> ErrorTable;
|
||||
std::map<std::string, uint16_t> GlobalTable;
|
||||
std::map<std::string, uint16_t> TrapTable;
|
||||
|
||||
std::unordered_multimap<uint16_t, std::string> ErrorTableInvert;
|
||||
std::unordered_map<uint32_t, std::string> SymbolTableInvert;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef __debug_internal_h__
|
||||
#define __debug_internal_h__
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <toolbox/loader.h>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
extern Loader::DebugNameTable SymbolTable;
|
||||
|
||||
extern std::map<std::string, uint16_t> ErrorTable;
|
||||
extern std::map<std::string, uint16_t> GlobalTable;
|
||||
extern std::map<std::string, uint16_t> TrapTable;
|
||||
|
||||
extern std::unordered_multimap<uint16_t, std::string> ErrorTableInvert;
|
||||
extern std::unordered_map<uint32_t, std::string> SymbolTableInvert;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
#include "intern.h"
|
||||
#include <unordered_map>
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
std::unordered_multimap<unsigned, std::string *> InternTable;
|
||||
|
||||
std::string EmptyString;
|
||||
|
||||
unsigned int DJBHash(const char* begin, size_t length)
|
||||
{
|
||||
unsigned int hash = 5381;
|
||||
|
||||
for(size_t i = 0; i < length; ++i)
|
||||
{
|
||||
hash = ((hash << 5) + hash) + (begin[i]);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Intern {
|
||||
|
||||
const std::string *String(std::string &&str)
|
||||
{
|
||||
size_t size = str.size();
|
||||
if (!size) return &EmptyString;
|
||||
|
||||
unsigned hash = DJBHash(str.data(), size);
|
||||
|
||||
auto range = InternTable.equal_range(hash);
|
||||
auto iter = range.first;
|
||||
auto endit = range.second;
|
||||
|
||||
for( ; iter != endit; ++iter)
|
||||
{
|
||||
// hash matches, make sure the string does.
|
||||
const std::string *s = iter->second;
|
||||
|
||||
if (s->size() == size && std::memcmp(s->data(), str.data(), size) == 0)
|
||||
return s;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
const std::string *String(const char *begin, size_t size)
|
||||
{
|
||||
if (!size) return &EmptyString;
|
||||
|
||||
unsigned hash = DJBHash(begin, size);
|
||||
|
||||
auto range = InternTable.equal_range(hash);
|
||||
auto iter = range.first;
|
||||
auto endit = range.second;
|
||||
|
||||
for( ; iter != endit; ++iter)
|
||||
{
|
||||
// hash matches, make sure the string does.
|
||||
const std::string *s = iter->second;
|
||||
|
||||
if (s->size() == size && std::memcmp(s->data(), begin, size) == 0)
|
||||
return s;
|
||||
}
|
||||
|
||||
// insert it. I suppose this could throw, in which case a string would leak.
|
||||
std::string *s = new std::string(begin, size);
|
||||
InternTable.emplace(std::make_pair(hash, s));
|
||||
return s;
|
||||
}
|
||||
|
||||
const std::string *String(const char *begin, const char *end)
|
||||
{
|
||||
return String(begin, end - begin);
|
||||
}
|
||||
|
||||
|
||||
const std::string *String(const char *cp)
|
||||
{
|
||||
if (!cp || !*cp) return &EmptyString;
|
||||
|
||||
return String(cp, strlen(cp));
|
||||
}
|
||||
|
||||
const std::string *String(const std::string &s)
|
||||
{
|
||||
return String(s.data(), s.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef __intern_h__
|
||||
#define __intern_h__
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Intern {
|
||||
const std::string *String(const std::string &s);
|
||||
const std::string *String(std::string &&s);
|
||||
const std::string *String(const char *);
|
||||
const std::string *String(const char *, size_t size);
|
||||
const std::string *String(const char *, const char *);
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
|
|
96
bin/lexer.rl
96
bin/lexer.rl
|
@ -31,6 +31,7 @@
|
|||
#include <deque>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "debugger.h"
|
||||
|
@ -105,6 +106,21 @@ namespace {
|
|||
# this exits with cs == lexer_en_error.
|
||||
error := any* ${ fbreak; };
|
||||
|
||||
# identifiers.
|
||||
ident := |*
|
||||
|
||||
[ \t\r\n]+;
|
||||
|
||||
[_A-Za-z][_A-Za-z0-9]* {
|
||||
|
||||
std::unique_ptr<std::string> sp(new std::string(ts, te));
|
||||
|
||||
Parse(parser, tkIDENTIFIER, Token::Make(sp.get(), 0), command);
|
||||
Strings.push_back(std::move(sp));
|
||||
};
|
||||
|
||||
*|;
|
||||
|
||||
# semi-colon commands.
|
||||
semi := |*
|
||||
|
||||
|
@ -122,6 +138,18 @@ namespace {
|
|||
Parse(parser, tkSEMIL, 0, command);
|
||||
};
|
||||
|
||||
'date'i {
|
||||
Parse(parser, tkSEMIDATE, 0, command);
|
||||
};
|
||||
|
||||
'error'i {
|
||||
Parse(parser, tkSEMIERROR, 0, command);
|
||||
};
|
||||
|
||||
't'i {
|
||||
Parse(parser, tkSEMIT, 0, command);
|
||||
fgoto ident;
|
||||
};
|
||||
|
||||
|
||||
*|;
|
||||
|
@ -188,6 +216,7 @@ namespace {
|
|||
Parse(parser, tkINTEGER, value, command);
|
||||
};
|
||||
|
||||
# todo -- (\['\]|[^'\]){1,4} ?
|
||||
['] [^']{1,4} ['] {
|
||||
// 4 cc code
|
||||
|
||||
|
@ -242,6 +271,12 @@ namespace {
|
|||
Parse(parser, tkDUMP, 0, command);
|
||||
};
|
||||
|
||||
|
||||
'sc'i | 'stackcrawl'i {
|
||||
Parse(parser, tkSTACKCRAWL, 0, command);
|
||||
};
|
||||
|
||||
|
||||
'h'i | 'help'i {
|
||||
Parse(parser, tkHELP, 0, command);
|
||||
};
|
||||
|
@ -334,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;
|
||||
|
@ -342,28 +377,49 @@ bool ParseLine(const char *iter, Command *command)
|
|||
const char *te;
|
||||
int cs, act;
|
||||
|
||||
for(;;)
|
||||
%% write init;
|
||||
|
||||
|
||||
%% write exec;
|
||||
|
||||
if (cs == lexer_error || cs < lexer_first_final)
|
||||
{
|
||||
if (p == eof)
|
||||
{
|
||||
fprintf(stderr, "Unexpected end of line\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0, l = 2 + (p - iter); i < l; ++i)
|
||||
fputc(' ', stderr);
|
||||
|
||||
%% write init;
|
||||
%% write exec;
|
||||
fprintf(stderr, "^\nunexpected character: `%c'\n", *p);
|
||||
|
||||
if (cs == lexer_error)
|
||||
{
|
||||
fprintf(stderr, "illegal character: `%c'\n", *p);
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
if (cs == lexer_en_error)
|
||||
{
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
if (p == pe)
|
||||
{
|
||||
Parse(parser, tkEOL, 0, command);
|
||||
break;
|
||||
}
|
||||
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (cs == lexer_en_error)
|
||||
{
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cs < lexer_first_final)
|
||||
{
|
||||
fprintf(stderr, "Incomplete command\n");
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (p == pe)
|
||||
{
|
||||
// always true?
|
||||
Parse(parser, tkEOL, 0, command);
|
||||
}
|
||||
|
||||
Parse(parser, 0, 0, command);
|
||||
|
@ -376,4 +432,4 @@ bool ParseLine(const char *iter, Command *command)
|
|||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
|
143
bin/loader.cpp
143
bin/loader.cpp
|
@ -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
|
||||
|
@ -59,6 +59,8 @@
|
|||
#include "loader.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#include <cxx/string_splitter.h>
|
||||
|
||||
|
||||
#define LOADER_LOAD
|
||||
|
||||
|
@ -69,28 +71,6 @@ const uint32_t kGlobalSize = 0x10000;
|
|||
uint8_t *Memory = nullptr;
|
||||
uint32_t MemorySize = 0;
|
||||
|
||||
#if 0
|
||||
uint32_t EmulatedNewPtr(uint32_t size)
|
||||
{
|
||||
if (size & 0x01) size++;
|
||||
|
||||
if (HighWater + size > MemorySize)
|
||||
{
|
||||
fprintf(stderr, "Insufficient Memory!\n");
|
||||
exit(EX_CONFIG);
|
||||
}
|
||||
|
||||
|
||||
uint32_t address = HighWater;
|
||||
|
||||
|
||||
HighWater += size;
|
||||
|
||||
std::memset(Memory + HighWater, 0, size);
|
||||
|
||||
return address;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t ReadByte(const void *data, uint32_t offset)
|
||||
{
|
||||
|
@ -141,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(;;)
|
||||
|
@ -322,7 +302,7 @@ uint32_t load(const char *file)
|
|||
}
|
||||
|
||||
ReleaseResource(h);
|
||||
}
|
||||
}
|
||||
|
||||
// now link the segment 0 jump table...
|
||||
assert(a5);
|
||||
|
@ -413,12 +393,14 @@ void GlobalInit()
|
|||
memoryWriteLong(0xffffffff, MacOS::MinusOne);
|
||||
|
||||
|
||||
// todo -- expects high stack, low heap.
|
||||
// the allocator currently works from the top down,
|
||||
// so put stack at top of memory?
|
||||
|
||||
// 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -427,7 +409,7 @@ void CreateStack()
|
|||
// allocate stack, set A7...
|
||||
|
||||
uint32_t address;
|
||||
uint16_t error;
|
||||
//uint16_t error;
|
||||
|
||||
#if 0
|
||||
Flags.stackSize = (Flags.stackSize + 3) & ~0x03;
|
||||
|
@ -584,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;
|
||||
|
@ -601,7 +583,7 @@ void MidInstructionExceptionFunc()
|
|||
}
|
||||
|
||||
|
||||
#define MPW_VERSION "0.7.2"
|
||||
#define MPW_VERSION "0.8.3"
|
||||
void help()
|
||||
{
|
||||
printf("MPW " MPW_VERSION "\n");
|
||||
|
@ -642,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;
|
||||
|
@ -670,10 +652,8 @@ bool file_exists(const std::string & name)
|
|||
return ::stat(name.c_str(), &st) == 0 && S_ISREG(st.st_mode);
|
||||
}
|
||||
|
||||
std::string find_exe(const std::string &name)
|
||||
std::string old_find_exe(const std::string &name)
|
||||
{
|
||||
// TODO -- use the environment variable for directories.
|
||||
|
||||
if (file_exists(name)) return name;
|
||||
|
||||
// if name is a path, then it doesn't exist.
|
||||
|
@ -694,6 +674,47 @@ std::string find_exe(const std::string &name)
|
|||
}
|
||||
|
||||
|
||||
// this needs to run *after* the MPW environment variables are loaded.
|
||||
std::string find_exe(const std::string &name)
|
||||
{
|
||||
|
||||
// if this is an absolute or relative name, return as-is.
|
||||
|
||||
if (name.find(':') != name.npos) {
|
||||
std::string path = ToolBox::MacToUnix(name);
|
||||
if (file_exists(path)) return path;
|
||||
return "";
|
||||
}
|
||||
|
||||
if (name.find('/') != name.npos) {
|
||||
if (file_exists(name)) return name;
|
||||
return "";
|
||||
}
|
||||
|
||||
// otherwise, check the Commands variable for locations.
|
||||
std::string commands = MPW::GetEnv("Commands");
|
||||
if (commands.empty()) return old_find_exe(name);
|
||||
|
||||
|
||||
// string is , separated, possibly in MacOS format.
|
||||
|
||||
for (auto iter = string_splitter(commands, ','); iter; ++iter)
|
||||
{
|
||||
if (iter->empty()) continue;
|
||||
std::string path = *iter;
|
||||
|
||||
// convert to unix.
|
||||
path = ToolBox::MacToUnix(path);
|
||||
// should always have a length...
|
||||
if (path.length() && path.back() != '/') path.push_back('/');
|
||||
path.append(name);
|
||||
if (file_exists(path)) return path;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void MainLoop()
|
||||
{
|
||||
#if 0
|
||||
|
@ -730,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)
|
||||
{
|
||||
|
@ -763,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' },
|
||||
|
@ -783,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 }
|
||||
};
|
||||
|
||||
|
@ -814,7 +837,7 @@ int main(int argc, char **argv)
|
|||
case kTraceMPW:
|
||||
Flags.traceMPW = true;
|
||||
break;
|
||||
|
||||
|
||||
case kMemoryStats:
|
||||
Flags.memoryStats = true;
|
||||
break;
|
||||
|
@ -823,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);
|
||||
|
@ -892,14 +918,17 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
std::string command(argv[0]); // InitMPW updates argv...
|
||||
|
||||
MPW::InitEnvironment(defines);
|
||||
|
||||
std::string command(argv[0]); // InitMPW updates argv...
|
||||
command = find_exe(command);
|
||||
if (command.empty())
|
||||
{
|
||||
std::string mpw = MPW::RootDir();
|
||||
fprintf(stderr, "Unable to find command %s\n", argv[0]);
|
||||
fprintf(stderr, "$MPW = %s\n", mpw.c_str());
|
||||
fprintf(stderr, "$Commands = %s\n", MPW::GetEnv("Commands").c_str());
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
argv[0] = ::strdup(command.c_str()); // hmm.. could setenv(mpw_command) instead.
|
||||
|
@ -914,12 +943,11 @@ int main(int argc, char **argv)
|
|||
// for pre-fetch.
|
||||
memorySetMemory(Memory, MemorySize);
|
||||
|
||||
// should we subtract memory from the top
|
||||
// for the stack vs allocating it?
|
||||
|
||||
MM::Init(Memory, MemorySize - Flags.stackSize, kGlobalSize);
|
||||
MM::Init(Memory, MemorySize, kGlobalSize, Flags.stackSize);
|
||||
OS::Init();
|
||||
MPW::Init(argc, argv, defines);
|
||||
ToolBox::Init();
|
||||
MPW::Init(argc, argv);
|
||||
|
||||
|
||||
cpuStartup();
|
||||
|
@ -929,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();
|
||||
|
||||
|
@ -949,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
|
||||
|
@ -976,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;
|
||||
|
||||
|
@ -162,6 +163,10 @@ stmt ::= LIST expr(a) EOL.
|
|||
Debug::List(a.intValue);
|
||||
}
|
||||
|
||||
stmt ::= STACKCRAWL EOL.
|
||||
{
|
||||
Debug::StackCrawl();
|
||||
}
|
||||
|
||||
stmt ::= expr(a) SEMI SEMIH EOL.
|
||||
{
|
||||
|
@ -200,6 +205,29 @@ stmt ::= expr(a) COLON expr(b) SEMI SEMIL EOL.
|
|||
Debug::List(a.intValue, b.intValue);
|
||||
}
|
||||
|
||||
stmt ::= expr(a) SEMI SEMIDATE EOL.
|
||||
{
|
||||
Debug::PrintDate(a.intValue);
|
||||
}
|
||||
|
||||
stmt ::= expr(a) SEMI SEMIERROR EOL.
|
||||
{
|
||||
Debug::PrintError(a.intValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
stmt ::= expr(a) SEMI SEMIT IDENTIFIER(b) EOL.
|
||||
{
|
||||
Debug::ApplyTemplate(a.intValue, *b.stringValue);
|
||||
}
|
||||
|
||||
|
||||
stmt ::= expr SEMI SEMIT error EOL.
|
||||
{
|
||||
fprintf(stderr, "usage: expression ; t TemplateName\n");
|
||||
}
|
||||
|
||||
|
||||
stmt ::= DREGISTER(a) EQ expr(b) EOL.
|
||||
{
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
#include "template.h"
|
||||
#include "debugger.h"
|
||||
#include "debugger_internal.h"
|
||||
#include "loader.h" // Flags.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <toolbox/toolbox.h>
|
||||
|
||||
|
||||
namespace Debug {
|
||||
|
||||
using namespace Debug::Internal;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
unsigned CalcOneSize(FieldEntry *e)
|
||||
{
|
||||
unsigned s = (e->type & 0x0f00) >> 8;
|
||||
|
||||
if (!s) {
|
||||
// struct or pointer...
|
||||
if (e->type & 0x8000) s = 4;
|
||||
else if (e->tmpl) s = e->tmpl->struct_size;
|
||||
}
|
||||
|
||||
if (e->count) s *= e->count;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
unsigned CalcSize(FieldEntry *e)
|
||||
{
|
||||
unsigned size = 0;
|
||||
|
||||
while (e)
|
||||
{
|
||||
size += CalcOneSize(e);
|
||||
e = e->next;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
FieldEntry *Reverse(FieldEntry *e)
|
||||
{
|
||||
if (!e) return e;
|
||||
|
||||
// reverse the order...
|
||||
FieldEntry *prev;
|
||||
FieldEntry *next;
|
||||
|
||||
prev = nullptr;
|
||||
for(;;)
|
||||
{
|
||||
next = e->next;
|
||||
e->next = prev;
|
||||
|
||||
prev = e;
|
||||
e = next;
|
||||
if (!e) return prev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool ValidPointer(uint32_t value)
|
||||
{
|
||||
return value && value < Flags.memorySize;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CreateTypedef(const std::string *name, int type, TemplateParseInfo *info)
|
||||
{
|
||||
// check if it's an existing typedef...
|
||||
|
||||
auto &Templates = *info->templates;
|
||||
auto &Types = *info->types;
|
||||
|
||||
|
||||
auto iter = Types.find(*name);
|
||||
if (iter != Types.end())
|
||||
{
|
||||
if (iter->second == type) return; // ok, just a duplicate.
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Templates.find(*name) != Templates.end())
|
||||
{
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Types.emplace(std::make_pair(*name, type));
|
||||
}
|
||||
|
||||
|
||||
void CreateTemplate(const std::string *name, FieldEntry *firstField, TemplateParseInfo *info)
|
||||
{
|
||||
auto &Templates = *info->templates;
|
||||
auto &Types = *info->types;
|
||||
|
||||
// check if it exists...
|
||||
|
||||
if (Templates.find(*name) != Templates.end())
|
||||
{
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (Types.find(*name) != Types.end())
|
||||
{
|
||||
fprintf(stderr, "Template Error: line %d - redefining %s\n",
|
||||
info->LineNumber, name->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
firstField = Reverse(firstField);
|
||||
firstField->struct_size = CalcSize(firstField);
|
||||
|
||||
Templates.emplace(std::make_pair(*name, firstField));
|
||||
}
|
||||
|
||||
void CleanupString(std::string &s)
|
||||
{
|
||||
// replace non-printables.
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](char c){
|
||||
return isprint(c) ? c : '.';
|
||||
});
|
||||
|
||||
if (s.size() > 40) {
|
||||
s.resize(37);
|
||||
s.append("...");
|
||||
}
|
||||
}
|
||||
void PrettyPrint(uint32_t value, unsigned type)
|
||||
{
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case kOSType:
|
||||
// print 4-cc code
|
||||
fputc(' ', stdout);
|
||||
fputs(ToolBox::TypeToString(value).c_str(), stdout);
|
||||
return;
|
||||
|
||||
case kOSErr:
|
||||
// print value + short name
|
||||
{
|
||||
printf(" %-6d", (int16_t)value);
|
||||
auto iter = ErrorTableInvert.find(value);
|
||||
if (iter != ErrorTableInvert.end()) printf(" %s", iter->second.c_str());
|
||||
}
|
||||
return;
|
||||
|
||||
case kPStringPtr:
|
||||
// read the string...
|
||||
if (ValidPointer(value))
|
||||
{
|
||||
std::string tmp = ReadPString(value);
|
||||
CleanupString(tmp);
|
||||
printf(" '%s'", tmp.c_str());
|
||||
}
|
||||
return;
|
||||
|
||||
case kCStringPtr:
|
||||
// read the string...
|
||||
if (ValidPointer(value))
|
||||
{
|
||||
std::string tmp = ReadCString(value);
|
||||
CleanupString(tmp);
|
||||
printf(" '%s'", tmp.c_str());
|
||||
}
|
||||
return;
|
||||
return;
|
||||
|
||||
case kBoolean:
|
||||
fputc(' ', stdout);
|
||||
fputs(value ? "true" : "false", stdout);
|
||||
return;
|
||||
|
||||
case kHandle:
|
||||
// print address, size, locked stats.
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// int/signed int - print base 10.
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ApplyTemplate(uint32_t address, FieldEntry *e, unsigned indent)
|
||||
{
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!e) return;
|
||||
|
||||
for( ; e ; e = e->next)
|
||||
{
|
||||
|
||||
bool nonl = false;
|
||||
unsigned count = e->count;
|
||||
unsigned type = e->type;
|
||||
unsigned s = (type & 0x0f00) >> 8;
|
||||
|
||||
for (unsigned i = 0; i < indent; ++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.)
|
||||
switch(s)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
uint8_t value = ReadByte(address + offset);
|
||||
printf(" %02x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
uint16_t value = ReadWord(address + offset);
|
||||
printf(" %04x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
uint32_t value = ReadLong(address + offset);
|
||||
printf("%08x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0:
|
||||
// either a pointer or a struct
|
||||
if (type & 0x8000) {
|
||||
// pointer.
|
||||
uint32_t value = ReadLong(address + offset);
|
||||
printf("%08x", value);
|
||||
PrettyPrint(value, type);
|
||||
break;
|
||||
}
|
||||
if (type == 0) {
|
||||
// struct ... recurse.
|
||||
fputc('\n', stdout);
|
||||
nonl = true;
|
||||
ApplyTemplate(address + offset, e->tmpl, indent + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nonl) fputc('\n', stdout);
|
||||
offset += CalcOneSize(e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef __debug_template_h__
|
||||
#define __debug_template_h__
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
|
||||
enum {
|
||||
|
||||
// 0x8000 = pointer
|
||||
// 0x1000 = unsigned
|
||||
// 0x0f00 = size
|
||||
// 0-255 - type
|
||||
|
||||
kSInt64 = 0x0800,
|
||||
kUInt64 = 0x1800,
|
||||
|
||||
kSInt32 = 0x0400,
|
||||
kUInt32 = 0x1400,
|
||||
|
||||
kSInt16 = 0x0200,
|
||||
kUInt16 = 0x1200,
|
||||
|
||||
kSInt8 = 0x0100,
|
||||
kUInt8 = 0x1100,
|
||||
|
||||
kStruct = 0x0000,
|
||||
kStructPtr = 0x8000,
|
||||
|
||||
// ptrs are a special case where size = 0
|
||||
//kVoid = 0x0001,
|
||||
kVoidPtr = 0x8001,
|
||||
|
||||
// these exist for display purposes.
|
||||
kCStringPtr = 0x8002,
|
||||
kPStringPtr = 0x8003,
|
||||
|
||||
kOSType = 0x00404,
|
||||
kBoolean = 0x0105,
|
||||
kOSErr = 0x0206,
|
||||
kHandle = 0x04007,
|
||||
|
||||
};
|
||||
|
||||
inline unsigned MakePtr(unsigned type) { return type | 0x8000; }
|
||||
inline unsigned MakeType(unsigned size, bool sign, bool ptr) {
|
||||
unsigned rv = size << 8;
|
||||
if (!sign) rv |= 0x0100;
|
||||
if (ptr) rv |= 0x8000;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct FieldEntry;
|
||||
typedef FieldEntry *Template;
|
||||
|
||||
struct FieldEntry {
|
||||
std::string *name;
|
||||
unsigned type;
|
||||
unsigned count;
|
||||
Template tmpl;
|
||||
FieldEntry *next;
|
||||
unsigned struct_size; // only populated for head entry.
|
||||
};
|
||||
|
||||
struct TemplateParseInfo {
|
||||
std::unordered_map<std::string, Template> *templates;
|
||||
std::unordered_map<std::string, unsigned> *types;
|
||||
int LineNumber;
|
||||
};
|
||||
|
||||
|
||||
void CreateTypedef(const std::string *name, int type, TemplateParseInfo *);
|
||||
void CreateTemplate(const std::string *name, FieldEntry *firstField, TemplateParseInfo *);
|
||||
|
||||
|
||||
bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::string, Template> &);
|
||||
|
||||
|
||||
void ApplyTemplate(uint32_t address, FieldEntry *e, unsigned indent = 0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,255 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "template_parser.h"
|
||||
#include "template.h"
|
||||
#include "intern.h"
|
||||
|
||||
namespace {
|
||||
|
||||
int tox(char c)
|
||||
{
|
||||
c |= 0x20; // lowercase it.
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||
return 0;
|
||||
}
|
||||
uint32_t scan10(const char *begin, const char *end)
|
||||
{
|
||||
return std::accumulate(begin, end, 0,
|
||||
[](uint32_t value, char c){
|
||||
return value * 10 + c - '0';
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t scan16(const char *begin, const char *end)
|
||||
{
|
||||
return std::accumulate(begin, end, 0,
|
||||
[](uint32_t value, char c){
|
||||
return (value << 4) + tox(c);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void *TemplateParseAlloc(void *(*mallocProc)(size_t));
|
||||
void TemplateParseFree(void *p, void (*freeProc)(void*));
|
||||
|
||||
void TemplateParse(void *yyp, int yymajor, void *yyminor, Debug::TemplateParseInfo *);
|
||||
|
||||
|
||||
void TemplateParse(void *yyp, int yymajor, int yyminor, Debug::TemplateParseInfo *info)
|
||||
{
|
||||
TemplateParse(yyp, yymajor, (void *)(ptrdiff_t)yyminor, info);
|
||||
}
|
||||
|
||||
void TemplateParse(void *yyp, int yymajor, const std::string *yyminor, Debug::TemplateParseInfo *info)
|
||||
{
|
||||
TemplateParse(yyp, yymajor, (void *)yyminor, info);
|
||||
}
|
||||
|
||||
#define TemplateParse(a,b,c) TemplateParse(a,b,c, &info)
|
||||
|
||||
%%{
|
||||
machine lexer;
|
||||
|
||||
# this exits with cs == lexer_en_error.
|
||||
error := any* ${ fbreak; };
|
||||
|
||||
block_comment := |*
|
||||
[\n\r] { info.LineNumber++; };
|
||||
'*/' { fgoto main; };
|
||||
any ;
|
||||
*|;
|
||||
|
||||
main := |*
|
||||
|
||||
[\n\r] { info.LineNumber++; };
|
||||
[ \t]+;
|
||||
|
||||
'//' [^\r\n]* ;
|
||||
'/*' { fgoto block_comment; };
|
||||
|
||||
';' { TemplateParse(parser, tkSEMI, 0); };
|
||||
'{' { TemplateParse(parser, tkLBRACE, 0); };
|
||||
'}' { TemplateParse(parser, tkRBRACE, 0); };
|
||||
'[' { TemplateParse(parser, tkLBRACKET, 0); };
|
||||
']' { TemplateParse(parser, tkRBRACKET, 0); };
|
||||
'*' { TemplateParse(parser, tkSTAR, 0); };
|
||||
|
||||
'struct' { TemplateParse(parser, tkSTRUCT, 0); };
|
||||
'typedef' { TemplateParse(parser, tkTYPEDEF, 0); };
|
||||
|
||||
|
||||
'int' { TemplateParse(parser, tkINT, 0); };
|
||||
'long' { TemplateParse(parser, tkLONG, 0); };
|
||||
'short' { TemplateParse(parser, tkSHORT, 0); };
|
||||
'volatile' { TemplateParse(parser, tkVOLATILE, 0); };
|
||||
#'const' { TemplateParse(parser, tkCONST, 0); };
|
||||
'char' { TemplateParse(parser, tkCHAR, 0); };
|
||||
#'bool' { TemplateParse(parser, tkBOOL, 0); };
|
||||
'void' { TemplateParse(parser, tkVOID, 0); };
|
||||
|
||||
'signed' { TemplateParse(parser, tkSIGNED, 0); };
|
||||
'unsigned' { TemplateParse(parser, tkUNSIGNED, 0); };
|
||||
|
||||
'int64_t' { TemplateParse(parser, tkTYPECODE, kSInt64); };
|
||||
'uint64_t' { TemplateParse(parser, tkTYPECODE, kUInt64); };
|
||||
|
||||
'int32_t' { TemplateParse(parser, tkTYPECODE, kSInt32); };
|
||||
'uint32_t' { TemplateParse(parser, tkTYPECODE, kUInt32); };
|
||||
|
||||
'int16_t' { TemplateParse(parser, tkTYPECODE, kSInt16); };
|
||||
'uint16_t' { TemplateParse(parser, tkTYPECODE, kUInt16); };
|
||||
|
||||
'int8_t' { TemplateParse(parser, tkTYPECODE, kSInt8); };
|
||||
'uint8_t' { TemplateParse(parser, tkTYPECODE, kUInt8); };
|
||||
|
||||
|
||||
'StringPtr' { TemplateParse(parser, tkTYPECODE, kPStringPtr); };
|
||||
'CStringPtr' { TemplateParse(parser, tkTYPECODE, kCStringPtr); };
|
||||
'Ptr' { TemplateParse(parser, tkTYPECODE, kVoidPtr); };
|
||||
'OSType' { TemplateParse(parser, tkTYPECODE, kOSType); };
|
||||
'OSErr' { TemplateParse(parser, tkTYPECODE, kOSErr); };
|
||||
'Boolean' { TemplateParse(parser, tkTYPECODE, kBoolean); };
|
||||
'Handle' { TemplateParse(parser, tkTYPECODE, kHandle); };
|
||||
|
||||
|
||||
# numbers. negative numbers are not allowed.
|
||||
|
||||
'0x'i xdigit+ {
|
||||
// hexadecimal
|
||||
uint32_t value = scan16(ts + 2, te);
|
||||
TemplateParse(parser, tkINTEGER, value);
|
||||
};
|
||||
|
||||
digit+ {
|
||||
uint32_t value = scan10(ts, te);
|
||||
TemplateParse(parser, tkINTEGER, value);
|
||||
};
|
||||
|
||||
# identifier ... but also need to check if it's a type.
|
||||
[A-Za-z_][A-Za-z0-9_]* {
|
||||
|
||||
// intern the string.
|
||||
|
||||
const std::string *name = Intern::String(ts, te);
|
||||
bool ok = false;
|
||||
|
||||
if (!ok) {
|
||||
auto iter = Types.find(*name);
|
||||
if (iter != Types.end())
|
||||
{
|
||||
TemplateParse(parser, tkTYPECODE, iter->second);
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
auto iter = Templates.find(*name);
|
||||
if (iter != Templates.end())
|
||||
{
|
||||
TemplateParse(parser, tkTEMPLATE, iter->second);
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
TemplateParse(parser, tkIDENTIFIER, name);
|
||||
}
|
||||
};
|
||||
|
||||
*|;
|
||||
|
||||
}%%
|
||||
|
||||
namespace Debug {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::string, Template> &Templates)
|
||||
{
|
||||
%% write data;
|
||||
|
||||
void *parser;
|
||||
|
||||
int fd;
|
||||
struct stat st;
|
||||
char *buffer;
|
||||
|
||||
std::unordered_map<std::string, unsigned> Types;
|
||||
TemplateParseInfo info;
|
||||
|
||||
info.LineNumber = 1;
|
||||
info.templates = &Templates;
|
||||
info.types = &Types;
|
||||
|
||||
// simple types are handled via the lexer so no need to populate them here.
|
||||
|
||||
|
||||
|
||||
if (stat(filename.c_str(), &st) < 0) return false;
|
||||
if (st.st_size == 0) return false;
|
||||
|
||||
fd = open(filename.c_str(), O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("Error opening template file: ");
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer = (char *)mmap(nullptr, st.st_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, 0);
|
||||
if (buffer == MAP_FAILED) {
|
||||
perror("Error mapping template file: ");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
|
||||
|
||||
|
||||
parser = TemplateParseAlloc(malloc);
|
||||
|
||||
const char *p = buffer;
|
||||
const char *pe = buffer + st.st_size;
|
||||
const char *eof = pe;
|
||||
const char *ts;
|
||||
const char *te;
|
||||
int cs, act;
|
||||
|
||||
%% write init;
|
||||
%% write exec;
|
||||
|
||||
if (cs == lexer_error || cs < lexer_first_final)
|
||||
{
|
||||
if (p == eof)
|
||||
fprintf(stderr, "Template error: line %d - unexpected EOF\n", info.LineNumber);
|
||||
else
|
||||
fprintf(stderr, "Template error: line %d - illegal character: `%c'\n", info.LineNumber, *p);
|
||||
TemplateParseFree(parser, free);
|
||||
munmap(buffer, st.st_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TemplateParse(parser, 0, 0);
|
||||
TemplateParseFree(parser, free);
|
||||
|
||||
munmap(buffer, st.st_size);
|
||||
|
||||
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
|
|
@ -0,0 +1,129 @@
|
|||
%token_prefix tk
|
||||
%name TemplateParse
|
||||
%extra_argument { Debug::TemplateParseInfo *info }
|
||||
|
||||
|
||||
%include {
|
||||
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "template.h"
|
||||
|
||||
using namespace Debug;
|
||||
}
|
||||
|
||||
%type struct_fields { FieldEntry * }
|
||||
%type struct_field { FieldEntry * }
|
||||
|
||||
start ::= templates.
|
||||
|
||||
templates ::= templates struct.
|
||||
templates ::= templates typedef.
|
||||
templates ::= .
|
||||
|
||||
// typedeffing arrays or pointers is not allowed.
|
||||
|
||||
typedef ::= TYPEDEF type(a) IDENTIFIER(b). {
|
||||
CreateTypedef((std::string *)b, a, info);
|
||||
}
|
||||
|
||||
struct ::= STRUCT IDENTIFIER(a) LBRACE struct_fields(b) RBRACE SEMI.
|
||||
{
|
||||
CreateTemplate((std::string *)a, b, info);
|
||||
}
|
||||
|
||||
struct_fields(rhs) ::= struct_fields(a) struct_field(b). {
|
||||
// reverse order?
|
||||
b->next = a;
|
||||
rhs = b;
|
||||
}
|
||||
|
||||
struct_fields(rhs) ::= struct_field(a). {
|
||||
rhs = a;
|
||||
}
|
||||
|
||||
struct_field(rhs) ::= type(a) IDENTIFIER(b) array_count(c) SEMI.
|
||||
{
|
||||
FieldEntry *e = (FieldEntry *)calloc(sizeof(FieldEntry), 1);
|
||||
|
||||
e->name = (std::string *)b;
|
||||
e->type = a;
|
||||
e->count = c;
|
||||
rhs = e;
|
||||
}
|
||||
|
||||
struct_field(rhs) ::= opt_volatile TEMPLATE(a) opt_star(star) IDENTIFIER(b) array_count(c) SEMI. {
|
||||
FieldEntry *e = (FieldEntry *)calloc(sizeof(FieldEntry), 1);
|
||||
|
||||
e->name = (std::string *)b;
|
||||
e->type = star ? kStructPtr : kStruct;
|
||||
e->tmpl = (Template)a;
|
||||
e->count = c;
|
||||
|
||||
rhs = e;
|
||||
}
|
||||
|
||||
%type array_count { int }
|
||||
array_count(rhs) ::= . { rhs = 0; }
|
||||
array_count(rhs) ::= LBRACKET INTEGER(a) RBRACKET. {
|
||||
int i = (int)(ptrdiff_t)a;
|
||||
if (i == 0) {
|
||||
fprintf(stderr, "Template error: line %u: 0-sized arrays are not allowed.\n",
|
||||
info->LineNumber);
|
||||
i = 1;
|
||||
}
|
||||
rhs = i;
|
||||
}
|
||||
|
||||
%type type { int }
|
||||
type(rhs) ::= opt_volatile typecode(a). { rhs = a; }
|
||||
|
||||
// this is an expected error...
|
||||
type(rhs) ::= opt_volatile IDENTIFIER(xxx). {
|
||||
|
||||
// ugh, Lemon will blindly replace text within a string.
|
||||
fprintf(stderr, "Template error: line %u: %s is not a known type.\n",
|
||||
info->LineNumber, ((std::string *)xxx)->c_str());
|
||||
|
||||
rhs = 'i';
|
||||
}
|
||||
|
||||
|
||||
opt_volatile ::= .
|
||||
opt_volatile ::= VOLATILE.
|
||||
|
||||
|
||||
%type typecode { int }
|
||||
typecode(rhs) ::= SIGNED. { rhs = kSInt32; }
|
||||
typecode(rhs) ::= UNSIGNED. {rhs = kUInt32; }
|
||||
|
||||
typecode(rhs) ::= opt_signed CHAR. { rhs = kSInt8; }
|
||||
typecode(rhs) ::= UNSIGNED CHAR. { rhs = kUInt8; }
|
||||
|
||||
typecode(rhs) ::= opt_signed SHORT. { rhs = kSInt16; }
|
||||
typecode(rhs) ::= UNSIGNED SHORT. { rhs = kUInt16; }
|
||||
|
||||
typecode(rhs) ::= opt_signed LONG opt_int. { rhs = kSInt32; }
|
||||
typecode(rhs) ::= UNSIGNED LONG opt_int. { rhs = kUInt32; }
|
||||
|
||||
typecode(rhs) ::= opt_signed LONG LONG. { rhs = kSInt64; }
|
||||
typecode(rhs) ::= UNSIGNED LONG LONG. { rhs = kUInt64; }
|
||||
|
||||
typecode(rhs) ::= TYPECODE(a). { rhs = (int)(ptrdiff_t)a; }
|
||||
|
||||
/* pointers are not fully supported yet */
|
||||
typecode(rhs) ::= VOID STAR. { rhs = kVoidPtr; }
|
||||
|
||||
opt_signed ::= .
|
||||
opt_signed ::= SIGNED.
|
||||
|
||||
opt_int ::= .
|
||||
opt_int ::= INT.
|
||||
|
||||
%type opt_star { int }
|
||||
opt_star(rhs) ::= . { rhs = 0; }
|
||||
opt_star(rhs) ::= STAR. { rhs = 1; }
|
||||
|
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#ifndef __string_splitter__
|
||||
#define __string_splitter__
|
||||
|
||||
#include <string>
|
||||
|
||||
class string_splitter {
|
||||
public:
|
||||
string_splitter(const std::string &str, char sep) :
|
||||
_parent(str), _sep(sep)
|
||||
{
|
||||
_begin = 0;
|
||||
_end = _parent.find(_sep);
|
||||
_str = _parent.substr(_begin, _end);
|
||||
// _begin is 0, _end is either npos or offset from 0,
|
||||
// so no need to calculate a count.
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return _begin != npos;
|
||||
}
|
||||
|
||||
string_splitter &operator++() {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::string &operator *() const {
|
||||
return _str;
|
||||
}
|
||||
|
||||
const std::string *operator ->() const {
|
||||
return &_str;
|
||||
}
|
||||
|
||||
private:
|
||||
void increment() {
|
||||
_str.clear();
|
||||
if (_begin == npos) return;
|
||||
if (_end == npos) { _begin = _end; return; }
|
||||
|
||||
_begin = _end + 1;
|
||||
_end = _parent.find(_sep, _begin);
|
||||
auto count = _end == npos ? _end : _end - _begin;
|
||||
_str = _parent.substr(_begin, count);
|
||||
}
|
||||
|
||||
const static auto npos = std::string::npos;
|
||||
std::string _str;
|
||||
const std::string &_parent;
|
||||
char _sep;
|
||||
std::string::size_type _begin = 0;
|
||||
std::string::size_type _end = 0;
|
||||
};
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: %s sep string\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
if (strlen(argv[1]) != 1) {
|
||||
fprintf(stderr, "Separator must be a single character\n");
|
||||
return 1;
|
||||
}
|
||||
char sep = argv[1][0];
|
||||
std::string str(argv[2]);
|
||||
|
||||
for (auto iter = string_splitter(str, sep); iter; ++iter) {
|
||||
printf("%s\n", iter->c_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#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})
|
|
@ -933,6 +933,8 @@ namespace MacOS {
|
|||
case EDQUOT: return dskFulErr;
|
||||
case ENOSPC: return dskFulErr;
|
||||
|
||||
case ENOTEMPTY: return fBsyErr;
|
||||
|
||||
|
||||
default:
|
||||
return ioErr;
|
||||
|
|
|
@ -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})
|
|
@ -33,7 +33,7 @@ struct mplite_link {
|
|||
|
||||
/*
|
||||
** Assuming mplite_t.zPool is divided up into an array of mplite_link_t
|
||||
** structures, return a pointer to the idx-th such lik.
|
||||
** structures, return a pointer to the idx-th such link.
|
||||
*/
|
||||
#define mplite_getlink(handle, idx) ((mplite_link_t *) \
|
||||
(&handle->zPool[(idx) * handle->szAtom]))
|
||||
|
@ -49,7 +49,6 @@ static int mplite_logarithm(const int iValue);
|
|||
static int mplite_size(const mplite_t *handle, const void *p);
|
||||
static void mplite_link(mplite_t *handle, const int i, const int iLogsize);
|
||||
static void mplite_unlink(mplite_t *handle, const int i, const int iLogsize);
|
||||
static int mplite_unlink_first(mplite_t *handle, const int iLogsize);
|
||||
static void *mplite_malloc_unsafe(mplite_t *handle, const int nByte);
|
||||
static void mplite_free_unsafe(mplite_t *handle, const void *pOld);
|
||||
|
||||
|
@ -308,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 = ((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;
|
||||
}
|
||||
|
||||
|
@ -368,31 +365,12 @@ static void mplite_unlink(mplite_t *handle, const int i, const int iLogsize)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Find the first entry on the freelist iLogsize. Unlink that
|
||||
** entry and return its index.
|
||||
*/
|
||||
static int mplite_unlink_first(mplite_t *handle, const int iLogsize)
|
||||
{
|
||||
int i;
|
||||
int iFirst;
|
||||
|
||||
assert(iLogsize >= 0 && iLogsize <= MPLITE_LOGMAX);
|
||||
i = iFirst = handle->aiFreelist[iLogsize];
|
||||
assert(iFirst >= 0);
|
||||
while (i > 0) {
|
||||
if (i < iFirst) iFirst = i;
|
||||
i = mplite_getlink(handle, i)->next;
|
||||
}
|
||||
mplite_unlink(handle, iFirst, iLogsize);
|
||||
return iFirst;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a block of memory of at least nBytes in size.
|
||||
** Return NULL if unable. Return NULL if nBytes==0.
|
||||
**
|
||||
** The caller guarantees that nByte positive.
|
||||
** The caller guarantees that nByte is positive.
|
||||
**
|
||||
** The caller has obtained a lock prior to invoking this
|
||||
** routine so there is never any chance that two or more
|
||||
|
@ -408,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++) {
|
||||
|
@ -430,13 +404,16 @@ static void *mplite_malloc_unsafe(mplite_t *handle, const int nByte)
|
|||
** block. If not, then split a block of the next larger power of
|
||||
** two in order to create a new free block of size iLogsize.
|
||||
*/
|
||||
for (iBin = iLogsize; handle->aiFreelist[iBin] < 0 && iBin <= MPLITE_LOGMAX;
|
||||
for (iBin = iLogsize; iBin <= MPLITE_LOGMAX && handle->aiFreelist[iBin] < 0;
|
||||
iBin++) {
|
||||
}
|
||||
if (iBin > MPLITE_LOGMAX) {
|
||||
return NULL;
|
||||
}
|
||||
i = mplite_unlink_first(handle, iBin);
|
||||
|
||||
i = handle->aiFreelist[iBin];
|
||||
mplite_unlink(handle, i, iBin);
|
||||
|
||||
while (iBin > iLogsize) {
|
||||
int newSize;
|
||||
|
||||
|
@ -460,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];
|
||||
}
|
||||
|
@ -475,7 +458,7 @@ static void mplite_free_unsafe(mplite_t *handle, const void *pOld)
|
|||
/* Set iBlock to the index of the block pointed to by pOld in
|
||||
** the array of handle->szAtom byte blocks pointed to by handle->zPool.
|
||||
*/
|
||||
iBlock = ((uint8_t *) pOld - handle->zPool) / handle->szAtom;
|
||||
iBlock = (int)((uint8_t *) pOld - handle->zPool) / handle->szAtom;
|
||||
|
||||
/* Check that the pointer pOld points to a valid, non-free block. */
|
||||
assert(iBlock >= 0 && iBlock < handle->nBlock);
|
||||
|
@ -500,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++;
|
||||
|
@ -520,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,10 +17,10 @@
|
|||
*
|
||||
* 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 coalesed into the single larger block.
|
||||
* then the two blocks are coalesced into the single larger block.
|
||||
*
|
||||
* 3. New memory is allocated from the first available free 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
|
||||
{
|
||||
|
@ -82,6 +165,20 @@ namespace {
|
|||
%%{
|
||||
machine variables;
|
||||
|
||||
coalesce_colon := |*
|
||||
|
||||
':' {
|
||||
if (rv.length() && rv.back() != ':')
|
||||
rv.push_back(':');
|
||||
|
||||
fgoto main;
|
||||
};
|
||||
any {
|
||||
fhold;
|
||||
fgoto main;
|
||||
};
|
||||
*|;
|
||||
|
||||
main := |*
|
||||
|
||||
'{' [A-Za-z0-9_]+ '}' {
|
||||
|
@ -90,15 +187,23 @@ namespace {
|
|||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
|
||||
fgoto coalesce_colon;
|
||||
};
|
||||
|
||||
# backwards compatibility.
|
||||
'${' [A-Za-z0-9_]+ '}' {
|
||||
|
||||
std::string name(ts + 2, te - 1);
|
||||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
if (pathname) {
|
||||
rv.append(ts, te);
|
||||
} else {
|
||||
std::string name(ts + 2, te - 1);
|
||||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
|
||||
fgoto coalesce_colon;
|
||||
}
|
||||
};
|
||||
|
||||
# backwards compatibility.
|
||||
|
@ -112,6 +217,8 @@ namespace {
|
|||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
|
||||
fgoto coalesce_colon;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -259,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)
|
||||
{
|
||||
|
@ -284,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.
|
||||
|
||||
|
|
76
mpw/mpw.cpp
76
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);
|
||||
|
@ -176,7 +177,37 @@ namespace MPW
|
|||
return path; // unknown.
|
||||
}
|
||||
|
||||
uint16_t Init(int argc, char **argv, const std::vector<std::string> &defines)
|
||||
uint16_t InitEnvironment(const std::vector<std::string> &defines)
|
||||
{
|
||||
void EnvLoadFile(const std::string &envfile);
|
||||
void EnvLoadArray(const std::vector<std::string> &data);
|
||||
void EnvLoadEnv();
|
||||
|
||||
|
||||
std::string m(RootDir());
|
||||
if (!m.empty())
|
||||
{
|
||||
std::string mm = ToolBox::UnixToMac(m);
|
||||
if (mm.back() != ':') mm.push_back(':');
|
||||
|
||||
Environment.emplace(std::string("MPW"), mm);
|
||||
}
|
||||
|
||||
EnvLoadEnv(); // should do this first since it could set MPW??
|
||||
|
||||
if (defines.size())
|
||||
EnvLoadArray(defines);
|
||||
|
||||
if (!m.empty())
|
||||
{
|
||||
std::string path(RootDirPathForFile("Environment.text"));
|
||||
EnvLoadFile(path);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t Init(int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
FDTable.resize(16);
|
||||
|
@ -195,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;
|
||||
|
@ -211,7 +242,7 @@ namespace MPW
|
|||
argv[0] = basename(argv[0]);
|
||||
|
||||
|
||||
// 0x0910 CurApName
|
||||
// 0x0910 CurApName
|
||||
{
|
||||
char str32[32];
|
||||
|
||||
|
@ -274,33 +305,10 @@ namespace MPW
|
|||
|
||||
}
|
||||
|
||||
// environment,
|
||||
// just use $MPW and synthesize the other ones.
|
||||
// environment
|
||||
{
|
||||
void EnvLoadFile(const std::string &envfile);
|
||||
void EnvLoadArray(const std::vector<std::string> &data);
|
||||
|
||||
std::string m(RootDir());
|
||||
if (!m.empty())
|
||||
{
|
||||
std::string mm = ToolBox::UnixToMac(m);
|
||||
if (mm.back() != ':') mm.push_back(':');
|
||||
|
||||
Environment.emplace(std::string("MPW"), mm);
|
||||
}
|
||||
Environment.emplace(std::string("Command"), command);
|
||||
|
||||
|
||||
if (defines.size())
|
||||
EnvLoadArray(defines);
|
||||
|
||||
if (!m.empty())
|
||||
{
|
||||
|
||||
std::string path(RootDirPathForFile("Environment.text"));
|
||||
EnvLoadFile(path);
|
||||
}
|
||||
|
||||
std::deque<std::string> e;
|
||||
|
||||
for (const auto &iter : Environment)
|
||||
|
@ -367,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 " " " " " " */
|
||||
|
@ -101,7 +101,8 @@ namespace MPW {
|
|||
|
||||
|
||||
// should add argc/argv/envp...
|
||||
uint16_t Init(int argc, char **argv, const std::vector<std::string> &defines);
|
||||
uint16_t InitEnvironment(const std::vector<std::string> &defines);
|
||||
uint16_t Init(int argc, char **argv);
|
||||
|
||||
uint32_t ExitStatus();
|
||||
|
||||
|
@ -121,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
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
# ignore built-in rules, don't delete intermediate .o files.
|
||||
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
.SUFFIXES:
|
||||
.SECONDARY:
|
||||
|
||||
MPWFLAGS = -DMPWVersion=3.2
|
||||
MPW ?= mpw
|
||||
|
||||
LIBS = \
|
||||
{Libraries}Stubs.o \
|
||||
{CLibraries}StdCLib.o \
|
||||
{Libraries}Interface.o \
|
||||
{Libraries}Runtime.o \
|
||||
{Libraries}ToolLibs.o
|
||||
|
||||
PPC_LIBS = {SharedLibraries}InterfaceLib \
|
||||
{SharedLibraries}StdCLib \
|
||||
{PPCLibraries}StdCRuntime.o \
|
||||
{PPCLibraries}PPCCRuntime.o
|
||||
|
||||
LDFLAGS = -w -c 'MPS ' -t MPST \
|
||||
-sn STDIO=Main -sn INTENV=Main -sn %A5Init=Main
|
||||
|
||||
SCFLAGS = -p
|
||||
|
||||
TARGETS = test_new_handle test_new_handle_2 test_new_pointer test_volumes \
|
||||
test_createresfile test_hwpriv test_sane
|
||||
|
||||
all : $(TARGETS)
|
||||
|
||||
clean :
|
||||
rm -f $(TARGETS) o/*
|
||||
|
||||
# test_new_handle : o/test_new_handle.o
|
||||
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
# test_new_handle_2 : o/test_new_handle_2.o
|
||||
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
# test_new_pointer : o/test_new_pointer.o
|
||||
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
# 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) $(MPWFLAGS) Link $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
o/%.o : %.c
|
||||
$(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,132 @@
|
|||
#include <Resources.h>
|
||||
#include <Files.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
* Test the three (thanks, Apple) ways to create a resource file.
|
||||
*
|
||||
*/
|
||||
|
||||
ConstStr255Param fname = (ConstStr255Param)"\pxxx-test-resource-xxx";
|
||||
|
||||
|
||||
void test_fspcreateresfile(void)
|
||||
{
|
||||
OSErr err;
|
||||
FSSpec spec;
|
||||
|
||||
err = FSMakeFSSpec(0, 0, fname, &spec);
|
||||
if (err) {
|
||||
|
||||
fprintf(stderr, "FSMakeFSSpec failed: %d\n", err);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
FSpDelete(&spec);
|
||||
FSpCreateResFile(&spec, 'TEST', 'BINA', 0);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "FSpCreateResFile failed (File does not exist): %d\n", err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Verify it doesn't fail if the file/fork already exist.
|
||||
FSpCreateResFile(&spec, 'TEST', 'BINA', 0);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "FSpCreateResFile (File/Fork exist) failed: %d\n", err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
// Verify it doesn't fail if the file exists w/o a resource fork.
|
||||
FSpDelete(&spec);
|
||||
FSpCreate(&spec, 'TEST', 'BINA', 0);
|
||||
FSpCreateResFile(&spec, 'TEST', 'BINA', 0);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "FSpCreateResFile (File exists) failed: %d\n", err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
FSpDelete(&spec);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test_hcreateresfile(void)
|
||||
{
|
||||
OSErr err;
|
||||
|
||||
// will 0, 0 work on real macos?
|
||||
|
||||
HDelete(0, 0, fname);
|
||||
HCreateResFile(0, 0, fname);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "HCreateResFile failed (File does not exist): %d\n", err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Verify it doesn't fail if the file/fork already exist.
|
||||
HCreateResFile(0, 0, fname);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "HCreateResFile (File/Fork exist) failed: %d\n", err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
// Verify it doesn't fail if the file exists w/o a resource fork.
|
||||
HDelete(0, 0, fname);
|
||||
HCreate(0, 0, fname, 'TEST', 'BINA');
|
||||
HCreateResFile(0, 0, fname);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "HCreateResFile (File exists) failed: %d\n", err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
HDelete(0, 0, fname);
|
||||
}
|
||||
|
||||
void test_createresfile(void)
|
||||
{
|
||||
OSErr err;
|
||||
|
||||
FSDelete(fname, 0);
|
||||
CreateResFile(fname);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "CreateResFile failed (File does not exist): %d\n", err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Verify it does fail if the file/fork already exist.
|
||||
CreateResFile(fname);
|
||||
if ( (err = ResError()) != dupFNErr) {
|
||||
fprintf(stderr, "CreateResFile (File/Fork exist) failed: %d\n", err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
// Verify it doesn't fail if the file exists w/o a resource fork.
|
||||
FSDelete(fname, 0);
|
||||
Create(fname, 0, 'TEST', 'BINA');
|
||||
CreateResFile(fname);
|
||||
if ( (err = ResError()) != 0) {
|
||||
fprintf(stderr, "CreateResFile (File exists) failed: %d\n", err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
FSDelete(fname, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
|
||||
test_createresfile();
|
||||
test_hcreateresfile();
|
||||
test_fspcreateresfile();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#include <OSUtils.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
// these are all nops in mpw. Just verify it doesn't crash.
|
||||
|
||||
SwapInstructionCache(1);
|
||||
SwapInstructionCache(0);
|
||||
|
||||
FlushInstructionCache();
|
||||
|
||||
|
||||
SwapDataCache(1);
|
||||
SwapDataCache(0);
|
||||
|
||||
FlushDataCache();
|
||||
FlushCodeCache();
|
||||
|
||||
FlushCodeCacheRange(&main, 4);
|
||||
|
||||
// ? selector 6? listed in OSUtils.a, not listed in pascal or c headers.
|
||||
//FlushExternalCache();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#include <MacMemory.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void test_new_handle(unsigned size)
|
||||
{
|
||||
unsigned long total = 0;
|
||||
unsigned long count = 0;
|
||||
|
||||
for(;;) {
|
||||
|
||||
Handle h = NewHandle(size);
|
||||
if (!h) {
|
||||
fprintf(stdout, "memory error: %d\n", MemError());
|
||||
break;
|
||||
}
|
||||
|
||||
total += size;
|
||||
count++;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%ld handles allocated\n", count);
|
||||
fprintf(stdout, "%ld bytes allocated\n", total);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test_new_handle(1024 * 1024);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
#include <MacMemory.h>
|
||||
#include <stdio.h>
|
||||
|
||||
enum {
|
||||
TimeLM = 0x020C
|
||||
};
|
||||
|
||||
/* arc4random */
|
||||
|
||||
struct {
|
||||
unsigned char i;
|
||||
unsigned char j;
|
||||
unsigned char s[256];
|
||||
} rs;
|
||||
|
||||
void arc4_init(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < 256; n++)
|
||||
rs.s[n] = n;
|
||||
|
||||
rs.i = 0;
|
||||
rs.j = 0;
|
||||
}
|
||||
|
||||
void arc4_addrandom(const unsigned char *dat, int datlen)
|
||||
{
|
||||
int n;
|
||||
unsigned char si;
|
||||
|
||||
rs.i--;
|
||||
for (n = 0; n < 256; n++) {
|
||||
rs.i = (rs.i + 1);
|
||||
si = rs.s[rs.i];
|
||||
rs.j = (rs.j + si + dat[n % datlen]);
|
||||
rs.s[rs.i] = rs.s[rs.j];
|
||||
rs.s[rs.j] = si;
|
||||
}
|
||||
rs.j = rs.i;
|
||||
}
|
||||
|
||||
|
||||
unsigned char arc4_getbyte(void)
|
||||
{
|
||||
unsigned char si, sj;
|
||||
|
||||
rs.i = (rs.i + 1);
|
||||
si = rs.s[rs.i];
|
||||
rs.j = (rs.j + si);
|
||||
sj = rs.s[rs.j];
|
||||
rs.s[rs.i] = sj;
|
||||
rs.s[rs.j] = si;
|
||||
return (rs.s[(si + sj) & 0xff]);
|
||||
}
|
||||
|
||||
unsigned long arc4_get24(void)
|
||||
{
|
||||
unsigned long val;
|
||||
|
||||
val |= arc4_getbyte() << 16;
|
||||
val |= arc4_getbyte() << 8;
|
||||
val |= arc4_getbyte();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void test(void)
|
||||
{
|
||||
|
||||
unsigned i,j;
|
||||
unsigned errors = 0;
|
||||
unsigned success = 0;
|
||||
|
||||
for (i = 0; i < 10000; ++i)
|
||||
{
|
||||
Handle h[5];
|
||||
for (j = 0; j < 5; ++j) {
|
||||
unsigned long size = arc4_get24() >> 3;
|
||||
Handle hh = NewHandle(size);
|
||||
|
||||
if (hh) {
|
||||
success++;
|
||||
} else {
|
||||
fprintf(stdout, "NewHandle failed (%u): %d\n", size, MemError());
|
||||
errors++;
|
||||
}
|
||||
|
||||
h[j] = hh;
|
||||
}
|
||||
|
||||
for (j = 0; j < 5; ++j) {
|
||||
DisposeHandle(h[j]);
|
||||
}
|
||||
|
||||
}
|
||||
fprintf(stdout, "NewHandle failed: %u\n", errors);
|
||||
fprintf(stdout, "NewHandle succeeded: %u\n", success);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
// init with the time.
|
||||
arc4_init();
|
||||
arc4_addrandom((const unsigned char *)TimeLM, 4);
|
||||
|
||||
test();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#include <MacMemory.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void test_new_pointer(unsigned size)
|
||||
{
|
||||
unsigned long total = 0;
|
||||
unsigned long count = 0;
|
||||
|
||||
for(;;) {
|
||||
|
||||
void *p = NewPtr(size);
|
||||
if (!p) {
|
||||
fprintf(stdout, "memory error: %d\n", MemError());
|
||||
break;
|
||||
}
|
||||
|
||||
total += size;
|
||||
count++;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%ld pointers allocated\n", count);
|
||||
fprintf(stdout, "%ld bytes allocated\n", total);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test_new_pointer(1024 * 1024);
|
||||
return 0;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#include <Files.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
*
|
||||
* MacOS/Basilisk:
|
||||
*
|
||||
* GetVol(): vRefNum = -32637
|
||||
* GetVol(MacOS): vRefNum = -32637
|
||||
* HGetVol(): vRefNum = -32637 dirID = 3382
|
||||
* HGetVol(MacOS): vRefNum = -32637 dirID = 3382
|
||||
*
|
||||
*/
|
||||
|
||||
void gv(StringPtr name)
|
||||
{
|
||||
OSErr err;
|
||||
short vRefNum;
|
||||
err = GetVol(name, &vRefNum);
|
||||
|
||||
if (err) fprintf(stdout, "GetVol(%s): Error = %d\n", name ? name + 1 : (StringPtr)"", err);
|
||||
else fprintf(stdout, "GetVol(%s): vRefNum = %d\n", name ? name + 1 : (StringPtr)"", vRefNum);
|
||||
}
|
||||
|
||||
|
||||
void hgv(StringPtr name)
|
||||
{
|
||||
OSErr err;
|
||||
short vRefNum;
|
||||
long dirID;
|
||||
|
||||
err = HGetVol(name, &vRefNum, &dirID);
|
||||
|
||||
if (err) fprintf(stdout, "HGetVol(%s): Error = %d\n", name ? name + 1 : (StringPtr)"", err);
|
||||
else fprintf(stdout, "HGetVol(%s): vRefNum = %d dirID = %d\n",
|
||||
name ? name + 1 : (StringPtr)"", vRefNum, dirID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
gv(NULL);
|
||||
gv((StringPtr)"\pMacOS");
|
||||
|
||||
|
||||
hgv(NULL);
|
||||
hgv((StringPtr)"\pMacOS");
|
||||
|
||||
|
||||
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
|
||||
|
@ -10,39 +12,41 @@ set(TOOLBOX_SRC
|
|||
loader.cpp
|
||||
rm.cpp
|
||||
os.cpp
|
||||
os_internal.cpp
|
||||
os_hfs_dispatch.cpp
|
||||
os_highlevel.cpp
|
||||
os_alias.cpp
|
||||
os_fileinfo.cpp
|
||||
os_gestalt.cpp
|
||||
os_hfs_dispatch.cpp
|
||||
os_highlevel.cpp
|
||||
os_hwpriv.cpp
|
||||
os_internal.cpp
|
||||
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;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue