text
stringlengths
1
1.05M
; ; saveymm.asm ; ; Copyright (c) Microsoft Corporation. Licensed under the MIT license. ; include ksamd64.inc TITLE saveymm.asm ;VOID SYMCRYPT_CALL SymCryptEnvUmSaveYmmRegistersAsm( __m256i * buffer ); ;VOID SYMCRYPT_CALL SymCryptEnvUmRestoreYmmRegistersAsm( __m256i * buffer ); LEAF_ENTRY SymCryptEnvUmSaveYmmRegistersAsm, _TEXT add rcx, 31 and rcx, NOT 31 vmovaps [rcx+ 0 * 32 ], ymm0 vmovaps [rcx+ 1 * 32 ], ymm1 vmovaps [rcx+ 2 * 32 ], ymm2 vmovaps [rcx+ 3 * 32 ], ymm3 vmovaps [rcx+ 4 * 32 ], ymm4 vmovaps [rcx+ 5 * 32 ], ymm5 vmovaps [rcx+ 6 * 32 ], ymm6 vmovaps [rcx+ 7 * 32 ], ymm7 vmovaps [rcx+ 8 * 32 ], ymm8 vmovaps [rcx+ 9 * 32 ], ymm9 vmovaps [rcx+ 10 * 32 ], ymm10 vmovaps [rcx+ 11 * 32 ], ymm11 vmovaps [rcx+ 12 * 32 ], ymm12 vmovaps [rcx+ 13 * 32 ], ymm13 vmovaps [rcx+ 14 * 32 ], ymm14 vmovaps [rcx+ 15 * 32 ], ymm15 ret LEAF_END SymCryptEnvUmSaveYmmRegistersAsm, _TEXT LEAF_ENTRY SymCryptEnvUmRestoreYmmRegistersAsm, _TEXT add rcx, 31 and rcx, NOT 31 vmovaps ymm0 , [rcx+ 0 * 32 ] vmovaps ymm1 , [rcx+ 1 * 32 ] vmovaps ymm2 , [rcx+ 2 * 32 ] vmovaps ymm3 , [rcx+ 3 * 32 ] vmovaps ymm4 , [rcx+ 4 * 32 ] vmovaps ymm5 , [rcx+ 5 * 32 ] vmovaps ymm6 , [rcx+ 6 * 32 ] vmovaps ymm7 , [rcx+ 7 * 32 ] vmovaps ymm8 , [rcx+ 8 * 32 ] vmovaps ymm9 , [rcx+ 9 * 32 ] vmovaps ymm10, [rcx+ 10 * 32 ] vmovaps ymm11, [rcx+ 11 * 32 ] vmovaps ymm12, [rcx+ 12 * 32 ] vmovaps ymm13, [rcx+ 13 * 32 ] vmovaps ymm14, [rcx+ 14 * 32 ] vmovaps ymm15, [rcx+ 15 * 32 ] ret LEAF_END SymCryptEnvUmRestoreYmmRegistersAsm, _TEXT END
; A305263: a(n) = 680*2^n - 622. ; 58,738,2098,4818,10258,21138,42898,86418,173458,347538,695698,1392018,2784658,5569938,11140498,22281618,44563858,89128338,178257298,356515218,713031058,1426062738,2852126098,5704252818,11408506258,22817013138,45634026898,91268054418,182536109458,365072219538,730144439698,1460288880018,2920577760658,5841155521938,11682311044498,23364622089618,46729244179858,93458488360338,186916976721298,373833953443218,747667906887058,1495335813774738,2990671627550098,5981343255100818,11962686510202258 mov $1,2 pow $1,$0 sub $1,1 mul $1,680 add $1,58 mov $0,$1
; ------------------------------------------------------------------ ; Machine code monitor -- by Yutaka Saito and Mike Saunders ; ; Accepts code in hex format, ORGed to 36864 (4K after where ; this program is loaded) ; ------------------------------------------------------------------ BITS 16 %INCLUDE "arkdev.inc" ORG 32768 ; This line determines where the machine code will ; be generated -- if you change it, you will need to ; ORG the code you enter at the new address CODELOC equ 36864 mov si, helpmsg1 ; Print help text call os_print_string mov si, helpmsg2 call os_print_string mov si, helpmsg3 call os_print_string main_loop: mov si, helpmsg4 call os_print_string .noinput: call os_print_newline mov si, prompt ; Print prompt call os_print_string mov ax, input ; Get hex string call os_input_string mov ax, input call os_string_length cmp ax, 0 je .noinput mov si, input ; Convert to machine code... mov di, run .more: cmp byte [si], '$' ; If char in string is '$', end of code je .done cmp byte [si], ' ' ; If space, move on to next char je .space cmp byte [si], 'r' ; If 'r' entered, re-run existing code je .runprog cmp byte [si], 'x' ; Or if 'x' entered, return to OS jne .noexit call os_print_newline ret .noexit: mov al, [si] and al, 0F0h cmp al, 40h je .H_A_to_F .H_1_to_9: mov al, [si] sub al, 30h mov ah, al sal ah, 4 jmp .H_end .H_A_to_F: mov al, [si] sub al, 37h mov ah, al sal ah, 4 .H_end: inc si mov al, [si] and al, 0F0h cmp al, 40h je .L_A_to_F .L_1_to_9: mov al, [si] sub al, 30h jmp .L_end .L_A_to_F: mov al, [si] sub al, 37h .L_end: or al, ah mov [di], al inc di .space: inc si jmp .more .done: mov byte [di], 0 ; Write terminating zero mov si, run ; Copy machine code to location for execution mov di, CODELOC mov cx, 255 cld rep movsb .runprog: call os_print_newline call CODELOC ; Run program call os_print_newline jmp main_loop input times 255 db 0 ; Code entered by user (in ASCII) run times 255 db 0 ; Translated machine code to execute helpmsg1 db 'ARKOS MACHINE CODE MONITOR', 10, 13, 0 helpmsg2 db '(See the User Handbook for a quick guide)', 13, 10, 13, 10, 0 helpmsg3 db 'Enter instructions in hex, terminated by $ character', 10, 13, 0 helpmsg4 db 'Commands: r = re-run previous code, x = exit', 10, 13, 0 prompt db '= ', 0 ; ------------------------------------------------------------------
; A047234: Numbers that are congruent to {0, 1, 4} mod 6. ; 0,1,4,6,7,10,12,13,16,18,19,22,24,25,28,30,31,34,36,37,40,42,43,46,48,49,52,54,55,58,60,61,64,66,67,70,72,73,76,78,79,82,84,85,88,90,91,94,96,97,100,102,103,106,108,109,112,114,115,118,120,121,124,126,127,130,132,133,136,138,139,142,144,145,148,150,151,154,156,157,160,162,163,166,168,169,172,174,175,178,180,181,184,186,187,190,192,193,196,198 mov $1,$0 mul $0,8 add $1,8 mod $1,3 add $0,$1 sub $0,1 div $0,4
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin developers // Copyright (c) 2009-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "chainparamsbase.h" #include "clientversion.h" #include "fs.h" #include "rpc/client.h" #include "rpc/protocol.h" #include "util.h" #include "utilstrencodings.h" #include <stdio.h> #include <event2/event.h> #include <event2/http.h> #include <event2/buffer.h> #include <event2/keyvalq_struct.h> #include <univalue.h> static const char DEFAULT_RPCCONNECT[] = "127.0.0.1"; static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900; std::string HelpMessageCli() { const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET); std::string strUsage; strUsage += HelpMessageGroup(_("Options:")); strUsage += HelpMessageOpt("-?", _("This help message")); strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), SURGE_CONF_FILENAME)); strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory")); AppendParamsHelpMessages(strUsage); strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), DEFAULT_RPCCONNECT)); strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort())); strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start")); strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcclienttimeout=<n>", strprintf(_("Timeout during HTTP requests (default: %d)"), DEFAULT_HTTP_CLIENT_TIMEOUT)); return strUsage; } ////////////////////////////////////////////////////////////////////////////// // // Start // // // Exception thrown on connection error. This error is used to determine // when to wait if -rpcwait is given. // class CConnectionFailed : public std::runtime_error { public: explicit inline CConnectionFailed(const std::string& msg) : std::runtime_error(msg) { } }; static bool AppInitRPC(int argc, char* argv[]) { // // Parameters // gArgs.ParseParameters(argc, argv); if (argc < 2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version")) { std::string strUsage = _("SURGE Core RPC client version") + " " + FormatFullVersion() + "\n"; if (!gArgs.IsArgSet("-version")) { strUsage += "\n" + _("Usage:") + "\n" + " surge-cli [options] <command> [params] " + _("Send command to SURGE Core") + "\n" + " surge-cli [options] help " + _("List commands") + "\n" + " surge-cli [options] help <command> " + _("Get help for a command") + "\n"; strUsage += "\n" + HelpMessageCli(); } fprintf(stdout, "%s", strUsage.c_str()); return false; } if (!fs::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str()); return false; } try { gArgs.ReadConfigFile(); } catch (const std::exception& e) { fprintf(stderr, "Error reading configuration file: %s\n", e.what()); return false; } // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) try { SelectBaseParams(ChainNameFromCommandLine()); } catch(const std::exception& e) { fprintf(stderr, "Error: %s\n", e.what()); return false; } if (gArgs.GetBoolArg("-rpcssl", false)) { fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n"); return false; } return true; } /** Reply structure for request_done to fill in */ struct HTTPReply { int status; std::string body; }; static void http_request_done(struct evhttp_request *req, void *ctx) { HTTPReply *reply = static_cast<HTTPReply*>(ctx); if (req == NULL) { /* If req is NULL, it means an error occurred while connecting, but * I'm not sure how to find out which one. We also don't really care. */ reply->status = 0; return; } reply->status = evhttp_request_get_response_code(req); struct evbuffer *buf = evhttp_request_get_input_buffer(req); if (buf) { size_t size = evbuffer_get_length(buf); const char *data = (const char*)evbuffer_pullup(buf, size); if (data) reply->body = std::string(data, size); evbuffer_drain(buf, size); } } UniValue CallRPC(const std::string& strMethod, const UniValue& params) { std::string host = gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT); int port = gArgs.GetArg("-rpcport", BaseParams().RPCPort()); // Create event base struct event_base *base = event_base_new(); // TODO RAII if (!base) throw std::runtime_error("cannot create event_base"); // Synchronously look up hostname struct evhttp_connection *evcon = evhttp_connection_base_new(base, NULL, host.c_str(), port); // TODO RAII if (evcon == NULL) throw std::runtime_error("create connection failed"); evhttp_connection_set_timeout(evcon, gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT)); HTTPReply response; struct evhttp_request *req = evhttp_request_new(http_request_done, (void*)&response); // TODO RAII if (req == NULL) throw std::runtime_error("create http request failed"); // Get credentials std::string strRPCUserColonPass; if (gArgs.GetArg("-rpcpassword", "") == "") { // Try fall back to cookie-based authentication if no password is provided if (!GetAuthCookie(&strRPCUserColonPass)) { throw std::runtime_error(strprintf( _("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"), GetConfigFile().string().c_str())); } } else { strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", ""); } struct evkeyvalq *output_headers = evhttp_request_get_output_headers(req); assert(output_headers); evhttp_add_header(output_headers, "Host", host.c_str()); evhttp_add_header(output_headers, "Connection", "close"); evhttp_add_header(output_headers, "Authorization", (std::string("Basic ") + EncodeBase64(strRPCUserColonPass)).c_str()); // Attach request data std::string strRequest = JSONRPCRequestObj(strMethod, params, 1).write() + "\n"; struct evbuffer * output_buffer = evhttp_request_get_output_buffer(req); assert(output_buffer); evbuffer_add(output_buffer, strRequest.data(), strRequest.size()); int r = evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/"); if (r != 0) { evhttp_connection_free(evcon); event_base_free(base); throw CConnectionFailed("send http request failed"); } event_base_dispatch(base); evhttp_connection_free(evcon); event_base_free(base); if (response.status == 0) throw CConnectionFailed("couldn't connect to server"); else if (response.status == HTTP_UNAUTHORIZED) throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)"); else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR) throw std::runtime_error(strprintf("server returned HTTP error %d", response.status)); else if (response.body.empty()) throw std::runtime_error("no response from server"); // Parse reply UniValue valReply(UniValue::VSTR); if (!valReply.read(response.body)) throw std::runtime_error("couldn't parse reply from server"); const UniValue& reply = valReply.get_obj(); if (reply.empty()) throw std::runtime_error("expected reply to have result, error and id properties"); return reply; } int CommandLineRPC(int argc, char* argv[]) { std::string strPrint; int nRet = 0; try { // Skip switches while (argc > 1 && IsSwitchChar(argv[1][0])) { argc--; argv++; } // Method if (argc < 2) throw std::runtime_error("too few parameters"); std::string strMethod = argv[1]; // Parameters default to strings std::vector<std::string> strParams(&argv[2], &argv[argc]); UniValue params = RPCConvertValues(strMethod, strParams); // Execute and handle connection failures with -rpcwait const bool fWait = gArgs.GetBoolArg("-rpcwait", false); do { try { const UniValue reply = CallRPC(strMethod, params); // Parse reply const UniValue& result = find_value(reply, "result"); const UniValue& error = find_value(reply, "error"); if (!error.isNull()) { // Error int code = error["code"].get_int(); if (fWait && code == RPC_IN_WARMUP) throw CConnectionFailed("server in warmup"); strPrint = "error: " + error.write(); nRet = abs(code); } else { // Result if (result.isNull()) strPrint = ""; else if (result.isStr()) strPrint = result.get_str(); else strPrint = result.write(2); } // Connection succeeded, no need to retry. break; } catch (const CConnectionFailed& e) { if (fWait) MilliSleep(1000); else throw; } } while (fWait); } catch (const boost::thread_interrupted&) { throw; } catch (const std::exception& e) { strPrint = std::string("error: ") + e.what(); nRet = EXIT_FAILURE; } catch (...) { PrintExceptionContinue(NULL, "CommandLineRPC()"); throw; } if (strPrint != "") { fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str()); } return nRet; } int main(int argc, char* argv[]) { SetupEnvironment(); if (!SetupNetworking()) { fprintf(stderr, "Error: Initializing networking failed\n"); exit(1); } try { if (!AppInitRPC(argc, argv)) return EXIT_FAILURE; } catch (const std::exception& e) { PrintExceptionContinue(&e, "AppInitRPC()"); return EXIT_FAILURE; } catch (...) { PrintExceptionContinue(NULL, "AppInitRPC()"); return EXIT_FAILURE; } int ret = EXIT_FAILURE; try { ret = CommandLineRPC(argc, argv); } catch (const std::exception& e) { PrintExceptionContinue(&e, "CommandLineRPC()"); } catch (...) { PrintExceptionContinue(NULL, "CommandLineRPC()"); } return ret; }
/*========================================================================= Program: Visualization Toolkit Module: vtkLabelPlacer.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /*------------------------------------------------------------------------- Copyright 2008 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. -------------------------------------------------------------------------*/ #include "vtkLabelPlacer.h" #include "vtkCamera.h" #include "vtkCellArray.h" #include "vtkCoordinate.h" #include "vtkDataArray.h" #include "vtkDoubleArray.h" #include "vtkIdTypeArray.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkLabelHierarchy.h" #include "vtkLabelHierarchyIterator.h" #include "vtkMatrix4x4.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkPoints.h" #include "vtkRenderWindow.h" #include "vtkRenderer.h" #include "vtkSelectVisiblePoints.h" #include "vtkSmartPointer.h" #include "vtkStringArray.h" #include "vtkTimerLog.h" #include <vector> vtkStandardNewMacro(vtkLabelPlacer); vtkCxxSetObjectMacro(vtkLabelPlacer, AnchorTransform, vtkCoordinate); class vtkLabelPlacer::Internal { public: /// A single label's coordinates (adjusted so that the lower left screen coords are <0,0>). struct LabelRect { float x[4]; // xmin, xmax, ymin, ymax }; /// A rectangular tile on the screen. It contains a set of labels that overlap it. struct ScreenTile { std::vector<LabelRect> Labels; ScreenTile() = default; /// Is there space to place the given rectangle in this tile so that it doesn't overlap any /// labels in this tile? bool IsSpotOpen(float& opacity, struct LabelRect& r) { float d0, d1, d2, d3; for (std::vector<LabelRect>::iterator it = this->Labels.begin(); it != this->Labels.end(); ++it) { d0 = it->x[0] - r.x[1]; d1 = r.x[0] - it->x[1]; d2 = it->x[2] - r.x[3]; d3 = r.x[2] - it->x[3]; if (d0 < 0. && d1 < 0. && d2 < 0. && d3 < 0.) return false; d0 = d0 < 0. ? 2. : 0.1 * d0; d1 = d1 < 0. ? 2. : 0.1 * d1; d2 = d2 < 0. ? 2. : 0.1 * d2; d3 = d3 < 0. ? 2. : 0.1 * d3; d0 = d0 < d1 ? d0 : d1; d2 = d2 < d3 ? d2 : d3; if (d0 < 1. && d2 < 1.) { if (d0 < opacity) opacity = d0; if (d2 < opacity) opacity = d2; } } return true; } /// Prepare for the next frame. void Reset() { this->Labels.clear(); } void Insert(const LabelRect& rect) { this->Labels.push_back(rect); } }; std::vector<std::vector<ScreenTile>> Tiles; float ScreenOrigin[2]; float TileSize[2]; int NumTiles[2]; vtkSmartPointer<vtkIdTypeArray> NewLabelsPlaced; vtkSmartPointer<vtkIdTypeArray> LastLabelsPlaced; static int DumpPlaced; Internal(float viewport[4], float tilesize[2]) { this->NewLabelsPlaced = vtkSmartPointer<vtkIdTypeArray>::New(); this->LastLabelsPlaced = vtkSmartPointer<vtkIdTypeArray>::New(); this->ScreenOrigin[0] = viewport[0]; this->ScreenOrigin[1] = viewport[2]; this->TileSize[0] = tilesize[0]; this->TileSize[1] = tilesize[1]; this->NumTiles[0] = static_cast<int>(ceil((viewport[1] - viewport[0]) / tilesize[0])); this->NumTiles[1] = static_cast<int>(ceil((viewport[3] - viewport[2]) / tilesize[1])); this->Tiles.resize(this->NumTiles[0]); for (int i = 0; i < this->NumTiles[0]; ++i) this->Tiles[i].resize(this->NumTiles[1]); } bool PlaceLabel(float& opacity, float x0, float x1, float x2, float x3) { // Translate to origin to simplify bucketing LabelRect r; r.x[0] = x0 - ScreenOrigin[0]; r.x[1] = x1 - ScreenOrigin[0]; r.x[2] = x2 - ScreenOrigin[1]; r.x[3] = x3 - ScreenOrigin[1]; // Determine intersected tiles float rx0 = x0 / TileSize[0]; float rx1 = x1 / TileSize[0]; float ry0 = x2 / TileSize[1]; float ry1 = x3 / TileSize[1]; int tx0 = static_cast<int>(floor(rx0)); int tx1 = static_cast<int>(ceil(rx1)); int ty0 = static_cast<int>(floor(ry0)); int ty1 = static_cast<int>(ceil(ry1)); if (tx0 > NumTiles[0] || tx1 < 0 || ty0 > NumTiles[1] || ty1 < 0) return false; // Don't intersect screen. if (tx0 < 0) { tx0 = 0; rx0 = 0.; } if (ty0 < 0) { ty0 = 0; ry0 = 0.; } if (tx1 >= this->NumTiles[0]) { tx1 = this->NumTiles[0] - 1; rx1 = tx1; } if (ty1 >= this->NumTiles[1]) { ty1 = this->NumTiles[1] - 1; ry1 = ty1; } // Check all applicable tiles for overlap. for (int tx = tx0; tx <= tx1; ++tx) { for (int ty = ty0; ty <= ty1; ++ty) { std::vector<ScreenTile>* trow = &this->Tiles[tx]; // Do this check here for speed, even though we repeat w/ small mod below. if (!(*trow)[ty].IsSpotOpen(opacity, r)) return false; } } // OK, we made it this far... we can place the label. // Add it to each tile it overlaps. for (int tx = tx0; tx <= tx1; ++tx) { for (int ty = ty0; ty <= ty1; ++ty) { this->Tiles[tx][ty].Insert(r); } } return true; } void Reset(float viewport[4], float tileSize[2]) { // Clear out any tiles we get to reuse for (int tx = 0; tx < this->NumTiles[0]; ++tx) for (int ty = 0; ty < this->NumTiles[1]; ++ty) this->Tiles[tx][ty].Reset(); // Set new parameter values in case the viewport changed this->ScreenOrigin[0] = viewport[0]; this->ScreenOrigin[1] = viewport[2]; this->TileSize[0] = tileSize[0]; this->TileSize[1] = tileSize[1]; this->NumTiles[0] = static_cast<int>(ceil((viewport[1] - viewport[0]) / tileSize[0])); this->NumTiles[1] = static_cast<int>(ceil((viewport[3] - viewport[2]) / tileSize[1])); // Allocate new tiles (where required...) this->Tiles.resize(this->NumTiles[0]); for (int i = 0; i < this->NumTiles[0]; ++i) this->Tiles[i].resize(this->NumTiles[1]); // Save labels from the last frame for use later... vtkSmartPointer<vtkIdTypeArray> tmp = this->LastLabelsPlaced; this->LastLabelsPlaced = this->NewLabelsPlaced; this->NewLabelsPlaced = tmp; this->NewLabelsPlaced->Reset(); } }; int vtkLabelPlacer::Internal::DumpPlaced = 0; vtkLabelPlacer::vtkLabelPlacer() { this->Renderer = nullptr; this->Gravity = CenterCenter; this->AnchorTransform = vtkCoordinate::New(); this->AnchorTransform->SetCoordinateSystemToWorld(); this->MaximumLabelFraction = 0.05; // Take up no more than 5% of screen real estate with labels. this->Buckets = nullptr; this->PositionsAsNormals = false; // this->IteratorType = vtkLabelHierarchy::DEPTH_FIRST; // this->IteratorType = vtkLabelHierarchy::FULL_SORT; this->IteratorType = vtkLabelHierarchy::QUEUE; this->VisiblePoints = vtkSelectVisiblePoints::New(); this->VisiblePoints->SetTolerance(0.002); this->LastRendererSize[0] = 0; this->LastRendererSize[1] = 0; this->LastCameraPosition[0] = 0.0; this->LastCameraPosition[1] = 0.0; this->LastCameraPosition[2] = 0.0; this->LastCameraFocalPoint[0] = 0.0; this->LastCameraFocalPoint[1] = 0.0; this->LastCameraFocalPoint[2] = 0.0; this->LastCameraViewUp[0] = 0.0; this->LastCameraViewUp[1] = 0.0; this->LastCameraViewUp[2] = 0.0; this->LastCameraParallelScale = 0.0; this->OutputCoordinateSystem = vtkLabelPlacer::WORLD; this->OutputTraversedBounds = false; this->GeneratePerturbedLabelSpokes = false; this->UseDepthBuffer = false; this->SetNumberOfOutputPorts(4); // this->DebugOn(); } vtkLabelPlacer::~vtkLabelPlacer() { this->AnchorTransform->Delete(); delete this->Buckets; this->VisiblePoints->Delete(); } void vtkLabelPlacer::SetRenderer(vtkRenderer* ren) { // Do not keep a reference count to avoid a reference loop if (this->Renderer != ren) { this->Renderer = ren; this->VisiblePoints->SetRenderer(ren); this->Modified(); } } void vtkLabelPlacer::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "Renderer: " << this->Renderer << "\n"; os << indent << "AnchorTransform: " << this->AnchorTransform << "\n"; os << indent << "Gravity: " << this->Gravity << "\n"; os << indent << "MaximumLabelFraction: " << this->MaximumLabelFraction << "\n"; os << indent << "PositionsAsNormals: " << (this->PositionsAsNormals ? "ON" : "OFF") << "\n"; os << indent << "IteratorType: " << this->IteratorType << "\n"; os << indent << "OutputTraversedBounds: " << (this->OutputTraversedBounds ? "ON" : "OFF") << "\n"; os << indent << "GeneratePerturbedLabelSpokes: " << (this->GeneratePerturbedLabelSpokes ? "ON" : "OFF") << "\n"; os << indent << "UseDepthBuffer: " << (this->UseDepthBuffer ? "ON" : "OFF") << "\n"; os << indent << "OutputCoordinateSystem: " << this->OutputCoordinateSystem << "\n"; } /**\brief Set the default label gravity. * * This method does not allow invalid gravities to be specified. * The default value (CenterCenter) is both vertically and horizontally centered. * Baseline vertical gravity is not yet supported properly since no text is associated with labels * yet. */ void vtkLabelPlacer::SetGravity(int gravity) { if (gravity == this->Gravity) return; if (!(gravity & HorizontalBitMask)) { vtkWarningMacro("Ignoring gravity " << gravity << " with no horizontal bit set"); return; } if (!(gravity & VerticalBitMask)) { vtkWarningMacro("Ignoring gravity " << gravity << " with no vertical bit set"); return; } this->Gravity = gravity; this->Modified(); } vtkMTimeType vtkLabelPlacer::GetMTime() { // Check for minimal changes if (this->Renderer) { const int* sz = this->Renderer->GetSize(); if (this->LastRendererSize[0] != sz[0] || this->LastRendererSize[1] != sz[1]) { this->LastRendererSize[0] = sz[0]; this->LastRendererSize[1] = sz[1]; this->Modified(); } vtkCamera* cam = this->Renderer->GetActiveCamera(); if (cam) { double* pos = cam->GetPosition(); if (this->LastCameraPosition[0] != pos[0] || this->LastCameraPosition[1] != pos[1] || this->LastCameraPosition[2] != pos[2]) { this->LastCameraPosition[0] = pos[0]; this->LastCameraPosition[1] = pos[1]; this->LastCameraPosition[2] = pos[2]; this->Modified(); } double* fp = cam->GetFocalPoint(); if (this->LastCameraFocalPoint[0] != fp[0] || this->LastCameraFocalPoint[1] != fp[1] || this->LastCameraFocalPoint[2] != fp[2]) { this->LastCameraFocalPoint[0] = fp[0]; this->LastCameraFocalPoint[1] = fp[1]; this->LastCameraFocalPoint[2] = fp[2]; this->Modified(); } double* up = cam->GetViewUp(); if (this->LastCameraViewUp[0] != up[0] || this->LastCameraViewUp[1] != up[1] || this->LastCameraViewUp[2] != up[2]) { this->LastCameraViewUp[0] = up[0]; this->LastCameraViewUp[1] = up[1]; this->LastCameraViewUp[2] = up[2]; this->Modified(); } double scale = cam->GetParallelScale(); if (this->LastCameraParallelScale != scale) { this->LastCameraParallelScale = scale; this->Modified(); } } } return Superclass::GetMTime(); } int vtkLabelPlacer::FillInputPortInformation(int vtkNotUsed(port), vtkInformation* info) { info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkLabelHierarchy"); return 1; } int vtkLabelPlacer::RequestData(vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector, vtkInformationVector* outputVector) { if (!this->Renderer) { vtkErrorMacro("No renderer -- can't determine screen space size."); return 0; } if (!this->Renderer->GetRenderWindow()) { vtkErrorMacro("No render window -- can't get window size to query z buffer."); return 0; } // This will trigger if you do something like ResetCamera before the Renderer or // RenderWindow have allocated their appropriate system resources (like creating // an OpenGL context)." Resource allocation must occur before we can use the Z // buffer. if (this->Renderer->GetRenderWindow()->GetNeverRendered()) { vtkDebugMacro("RenderWindow not initialized -- aborting update."); return 1; } vtkCamera* cam = this->Renderer->GetActiveCamera(); if (!cam) { return 1; } vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); vtkInformation* outInfo0 = outputVector->GetInformationObject(0); vtkInformation* outInfo1 = outputVector->GetInformationObject(1); vtkInformation* outInfo2 = outputVector->GetInformationObject(2); vtkInformation* outInfo3 = outputVector->GetInformationObject(3); vtkLabelHierarchy* inData = vtkLabelHierarchy::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData* ouData0 = vtkPolyData::SafeDownCast(outInfo0->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData* ouData1 = vtkPolyData::SafeDownCast(outInfo1->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData* ouData2 = vtkPolyData::SafeDownCast(outInfo2->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData* ouData3 = vtkPolyData::SafeDownCast(outInfo3->Get(vtkDataObject::DATA_OBJECT())); vtkStringArray* nameArr0 = vtkStringArray::New(); nameArr0->SetName("LabelText"); ouData0->GetPointData()->AddArray(nameArr0); nameArr0->Delete(); vtkDoubleArray* opArr0 = vtkDoubleArray::New(); opArr0->SetName("Opacity"); ouData0->GetPointData()->AddArray(opArr0); opArr0->Delete(); vtkIntArray* iconIndexArr1 = vtkIntArray::New(); iconIndexArr1->SetName("IconIndex"); ouData1->GetPointData()->AddArray(iconIndexArr1); iconIndexArr1->Delete(); vtkIntArray* idArr0 = vtkIntArray::New(); idArr0->SetName("ID"); ouData0->GetPointData()->AddArray(idArr0); idArr0->Delete(); vtkStringArray* nameArr = vtkArrayDownCast<vtkStringArray>(inData->GetLabels()); vtkIntArray* iconIndexArr = vtkArrayDownCast<vtkIntArray>(inData->GetIconIndices()); if (!inData) { // vtkErrorMacro( "No input data" ); return 1; } vtkPoints* ipts = inData->GetPoints(); if (!ipts) { return 1; } vtkDataArray* isz = inData->GetPointData()->GetArray("LabelSize"); if (!isz) //|| isz->GetNumberOfComponents() > 2 ) { vtkWarningMacro("Missing or improper label size point array -- output will be empty."); return 1; } // If the renderer size is zero, silently place no labels. const int* renSize = this->Renderer->GetSize(); if (renSize[0] == 0 || renSize[1] == 0) { return 1; } if (!ouData0 || !ouData1) { vtkErrorMacro("No output data."); return 0; } // Prepare both icon and text output datasets vtkPoints* opts0 = ouData0->GetPoints(); if (!opts0) { opts0 = vtkPoints::New(); ouData0->SetPoints(opts0); opts0->FastDelete(); } ouData0->AllocateExact(1024, 1024); vtkPoints* opts1 = ouData1->GetPoints(); if (!opts1) { opts1 = vtkPoints::New(); ouData1->SetPoints(opts1); opts1->FastDelete(); } ouData1->AllocateExact(1024, 1024); vtkPoints* opts2 = ouData2->GetPoints(); if (!opts2) { opts2 = vtkPoints::New(); ouData2->SetPoints(opts2); opts2->FastDelete(); } ouData2->AllocateExact(1024, 1024); vtkPoints* opts3 = ouData3->GetPoints(); vtkCellArray* ocells3 = ouData3->GetLines(); if (!opts3) { opts3 = vtkPoints::New(); ouData3->SetPoints(opts3); opts3->FastDelete(); } if (!ocells3) { ocells3 = vtkCellArray::New(); ouData3->SetLines(ocells3); ocells3->FastDelete(); } ouData3->AllocateExact(1024, 1024); int tvpsz[4]; // tiled viewport size (and origin) // kd-tree bounds on screenspace (as floats... eventually we // should use a median kd-tree -- not naive version) float kdbounds[4]; this->Renderer->GetTiledSizeAndOrigin(tvpsz, tvpsz + 1, tvpsz + 2, tvpsz + 3); kdbounds[0] = tvpsz[2]; kdbounds[1] = tvpsz[0] + tvpsz[2]; kdbounds[2] = tvpsz[3]; kdbounds[3] = tvpsz[1] + tvpsz[3]; float tileSize[2] = { 128., 128. }; // fixed for now if (!this->Buckets || this->Buckets->NumTiles[0] * this->Buckets->TileSize[0] < tvpsz[2] || this->Buckets->NumTiles[1] * this->Buckets->TileSize[1] < tvpsz[3]) { this->Buckets = new Internal(kdbounds, tileSize); } else { this->Buckets->Reset(kdbounds, tileSize); } float* zPtr = nullptr; int placed = 0; int occluded = 0; double ll[3], lr[3], ul[3], ur[3]; ll[2] = lr[2] = ul[2] = ur[2] = 0.; double x[3]; double sz[4]; int* dispx; // Compute frustum for excluding labels that are outside the visible region. double frustumPlanes[24]; vtkLabelHierarchy::GetAnchorFrustumPlanes(frustumPlanes, this->Renderer, this->AnchorTransform); unsigned long allowableLabelArea = static_cast<unsigned long>( ((kdbounds[1] - kdbounds[0]) * (kdbounds[3] - kdbounds[2])) * this->MaximumLabelFraction); (void)allowableLabelArea; unsigned long renderedLabelArea = 0; double camVec[3]; if (this->PositionsAsNormals) { cam->GetViewPlaneNormal(camVec); } vtkLabelHierarchyIterator* inIter = inData->NewIterator( this->IteratorType, this->Renderer, cam, frustumPlanes, this->PositionsAsNormals, tileSize); if (this->OutputTraversedBounds) { inIter->SetTraversedBounds(ouData2); } vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); timer->StartTimer(); inIter->Begin(this->Buckets->LastLabelsPlaced); this->Buckets->NewLabelsPlaced->Initialize(); if (this->UseDepthBuffer) { zPtr = this->VisiblePoints->Initialize(true); } timer->StopTimer(); vtkDebugMacro("Iterator initialization time: " << timer->GetElapsedTime()); timer->StartTimer(); for (; !inIter->IsAtEnd(); inIter->Next()) { // Ignore labels that don't have text or an icon. vtkIdType labelType = inIter->GetType(); int gravity = this->Gravity; if (labelType == 0) { gravity = HorizontalLeftBit | VerticalBaselineBit; } if (labelType < 0 || labelType > 1) { vtkDebugMacro("Arf. Bad label type " << labelType); continue; } inIter->GetPoint(x); if (this->AnchorTransform->GetCoordinateSystem() == VTK_WORLD) { // Cull points behind the camera. Cannot rely on hither-yon planes because the camera // position gets changed during vtkInteractorStyle::Dolly() and RequestData() called from // within ResetCameraClippingRange() before the frustum planes are updated. // Cull points outside hither-yon planes (other planes get tested below) double* eye = cam->GetPosition(); double* dir = cam->GetViewPlaneNormal(); if ((x[0] - eye[0]) * dir[0] + (x[1] - eye[1]) * dir[1] + (x[2] - eye[2]) * dir[2] > 0) { continue; } // Ignore labels pointing the wrong direction (HACK) if (this->PositionsAsNormals) { if (camVec[0] * x[0] + camVec[1] * x[1] + camVec[2] * x[2] < 0.) { continue; } } // Test for occlusion using the z-buffer if (this->UseDepthBuffer && !this->VisiblePoints->IsPointOccluded(x, zPtr)) { occluded++; continue; } } this->AnchorTransform->SetValue(x); dispx = this->AnchorTransform->GetComputedDisplayValue(this->Renderer); inIter->GetSize(sz); if (sz[0] < 0) sz[0] = -sz[0]; if (sz[1] < 0) sz[1] = -sz[1]; // !!!! Commented out a few lines here as sz[2] && sz[3] never are initialized // Move anchor so no "space" characters are included in the layout. // dispx[0] -= static_cast<int>( sz[2] ); // By default, the anchor will be at the text baseline. Adjust if user has selected otherwise. // if ( ( gravity & VerticalBitMask ) != VerticalBaselineBit ) // dispx[1] -= static_cast<int>( sz[3] ); // Without this check things get *really* slow (at least with naive bucket placement tests) // FIXME: Don't count area clipped off by viewport when culling above is fixed. double t1, t2; switch (gravity & HorizontalBitMask) { case HorizontalLeftBit: t1 = dispx[0] < kdbounds[0] ? kdbounds[0] : dispx[0]; t2 = dispx[0] + sz[0]; if (t2 > kdbounds[1]) t2 = kdbounds[1]; ll[0] = ul[0] = t1; lr[0] = ur[0] = t2; break; case HorizontalRightBit: t1 = dispx[0] - sz[0]; if (t1 < kdbounds[0]) t1 = kdbounds[0]; t2 = dispx[0] > kdbounds[1] ? kdbounds[1] : dispx[0]; ll[0] = ul[0] = t1; lr[0] = ur[0] = t2; break; default: case HorizontalCenterBit: t1 = dispx[0] - sz[0] / 2; if (t1 < kdbounds[0]) t1 = kdbounds[0]; t2 = dispx[0] + sz[0] / 2; if (t2 > kdbounds[1]) t2 = kdbounds[1]; ll[0] = ul[0] = t1; lr[0] = ur[0] = t2; break; } if (ll[0] > kdbounds[1] || lr[0] < kdbounds[0]) { continue; // cull label not in frame } switch (gravity & VerticalBitMask) { case VerticalBottomBit: case VerticalBaselineBit: t1 = dispx[1] < kdbounds[2] ? kdbounds[2] : dispx[1]; t2 = dispx[1] + sz[1]; if (t2 > kdbounds[3]) t2 = kdbounds[3]; ll[1] = lr[1] = t1; ul[1] = ur[1] = t2; break; case VerticalTopBit: t1 = dispx[1] - sz[1]; if (t1 < kdbounds[2]) t1 = kdbounds[2]; t2 = dispx[1] > kdbounds[3] ? kdbounds[3] : dispx[1]; ll[1] = lr[1] = t1; ul[1] = ur[1] = t2; break; default: case VerticalCenterBit: t1 = dispx[1] - sz[1] / 2; if (t1 < kdbounds[2]) t1 = kdbounds[2]; t2 = dispx[1] + sz[1] / 2; if (t2 > kdbounds[3]) t2 = kdbounds[3]; ll[1] = lr[1] = t1; ul[1] = ur[1] = t2; break; } if (ll[1] > kdbounds[3] || lr[1] < kdbounds[2]) { continue; // cull label not in frame } if (this->Debug) { vtkDebugMacro("Try: " << inIter->GetLabelId() << " (" << ll[0] << ", " << ll[1] << " " << ur[0] << "," << ur[1] << ")"); if (labelType == 0) { vtkDebugMacro("Area: " << renderedLabelArea << " / " << allowableLabelArea << " \"" << nameArr->GetValue(inIter->GetLabelId()).c_str() << "\""); } else { vtkDebugMacro("Area: " << renderedLabelArea << " / " << allowableLabelArea); } } float opacity = 1.; if (this->Buckets->PlaceLabel(opacity, ll[0], ur[0], ll[1], ur[1])) { renderedLabelArea += static_cast<unsigned long>(sz[0] * sz[1]); vtkIdType conn[4]; OutputCoordinates coordSys = static_cast<OutputCoordinates>(this->OutputCoordinateSystem); if (labelType == 0) { // label is text if (vtkLabelPlacer::Internal::DumpPlaced) { vtkDebugMacro(<< ll[0] << " -- " << ur[0] << ", " << ll[1] << " -- " << ur[1] << ": " << nameArr->GetValue(inIter->GetLabelId()).c_str()); } switch (coordSys) { default: case WORLD: conn[0] = opts0->InsertNextPoint(x); break; case DISPLAY: conn[0] = opts0->InsertNextPoint(dispx[0], dispx[1], 0.); break; } // Store the anchor point in world coordinates ouData0->InsertNextCell(VTK_VERTEX, 1, conn); nameArr0->InsertNextValue(nameArr->GetValue(inIter->GetLabelId())); opArr0->InsertNextValue(opacity); idArr0->InsertNextValue(0); } else { // label is an icon if (vtkLabelPlacer::Internal::DumpPlaced) { vtkDebugMacro(<< ll[0] << " -- " << ur[0] << ", " << ll[1] << " -- " << ur[1] << ": Icon " << iconIndexArr->GetValue(inIter->GetLabelId())); } switch (coordSys) { default: case WORLD: conn[0] = opts1->InsertNextPoint(x); break; case DISPLAY: conn[0] = opts1->InsertNextPoint(dispx[0], dispx[1], 0.); break; } vtkIdType cid = ouData1->InsertNextCell(VTK_VERTEX, 1, conn); (void)cid; vtkDebugMacro(" Point: " << conn[0] << " (" << x[0] << "," << x[1] << "," << x[2] << ") Vertex: " << cid); iconIndexArr1->InsertNextValue(iconIndexArr->GetValue(inIter->GetLabelId())); } // Handle Spokes for perturbed points if (this->GeneratePerturbedLabelSpokes) { // inData->CenterPts // inData-> } // Uncomment to actually store the previous labels. // Currently starting with a clean slate each time. this->Buckets->NewLabelsPlaced->InsertNextValue(inIter->GetLabelId()); vtkDebugMacro("Placed: " << inIter->GetLabelId() << " (" << ll[0] << ", " << ll[1] << " " << ur[0] << "," << ur[1] << ") " << labelType); placed++; } } vtkDebugMacro("------"); // cout << "Not Placed: " << notPlaced << endl; // cout << "Labels Occluded: " << occluded << endl; inIter->Delete(); delete[] zPtr; timer->StopTimer(); vtkDebugMacro("Iteration time: " << timer->GetElapsedTime()); return 1; }
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; WriteMm7.Asm ; ; Abstract: ; ; AsmWriteMm7 function ; ; Notes: ; ;------------------------------------------------------------------------------ SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; AsmWriteMm7 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmWriteMm7) ASM_PFX(AsmWriteMm7): movq mm7, [esp + 4] ret
dnl AMD64 mpn_mod_1s_4p dnl Contributed to the GNU project by Torbjorn Granlund. dnl Copyright 2009 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 3 of the License, or (at dnl your option) any later version. dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl License for more details. dnl You should have received a copy of the GNU Lesser General Public License dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C K8,K9: 3.0 C K10: 3.0 C P4: 14.5 C P6 core2: 5.0 C P6 corei7: 4.3 C P6 atom: 25.0 ASM_START() TEXT ALIGN(16) PROLOGUE(mpn_mod_1s_4p) push %r14 push %r13 push %r12 push %rbp push %rbx mov %rdx, -16(%rsp) mov %rcx, %r14 mov 16(%rcx), %r11 mov 24(%rcx), %rbx mov 32(%rcx), %rbp mov 40(%rcx), %r13 mov 48(%rcx), %r12 xor R32(%r8), R32(%r8) mov R32(%rsi), R32(%rdx) and $3, R32(%rdx) je L(b0) cmp $2, R32(%rdx) jc L(b1) je L(b2) L(b3): lea -24(%rdi,%rsi,8), %rdi mov 8(%rdi), %rax mul %r11 mov (%rdi), %r9 add %rax, %r9 adc %rdx, %r8 mov 16(%rdi), %rax mul %rbx jmp L(m0) ALIGN(8) L(b0): lea -32(%rdi,%rsi,8), %rdi mov 8(%rdi), %rax mul %r11 mov (%rdi), %r9 add %rax, %r9 adc %rdx, %r8 mov 16(%rdi), %rax mul %rbx add %rax, %r9 adc %rdx, %r8 mov 24(%rdi), %rax mul %rbp jmp L(m0) ALIGN(8) L(b1): lea -8(%rdi,%rsi,8), %rdi mov (%rdi), %r9 jmp L(m1) ALIGN(8) L(b2): lea -16(%rdi,%rsi,8), %rdi mov 8(%rdi), %rax mul %r11 mov (%rdi), %r9 jmp L(m0) ALIGN(16) L(top): mov -24(%rdi), %rax mov -32(%rdi), %r10 mul %r11 add %rax, %r10 mov -16(%rdi), %rax mov %rdx, %rcx adc $0, %rcx mul %rbx add %rax, %r10 mov -8(%rdi), %rax adc %rdx, %rcx sub $32, %rdi mul %rbp add %rax, %r10 mov %r9, %rax adc %rdx, %rcx mul %r13 add %rax, %r10 mov %r8, %rax adc %rdx, %rcx mul %r12 mov %r10, %r9 mov %rcx, %r8 L(m0): add %rax, %r9 adc %rdx, %r8 L(m1): sub $4, %rsi ja L(top) L(end): mov 8(%r14), R32(%rsi) mov %r8, %rax mul %r11 mov %rax, %r8 add %r9, %r8 adc $0, %rdx xor R32(%rcx), R32(%rcx) sub R32(%rsi), R32(%rcx) mov %r8, %rdi shr R8(%rcx), %rdi mov R32(%rsi), R32(%rcx) sal R8(%rcx), %rdx or %rdx, %rdi mov %rdi, %rax mulq (%r14) mov -16(%rsp), %rbx mov %rax, %r9 sal R8(%rcx), %r8 inc %rdi add %r8, %r9 adc %rdi, %rdx imul %rbx, %rdx sub %rdx, %r8 lea (%r8,%rbx), %rax cmp %r8, %r9 cmovb %rax, %r8 mov %r8, %rax sub %rbx, %rax cmovb %r8, %rax shr R8(%rcx), %rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 ret EPILOGUE() ALIGN(16) PROLOGUE(mpn_mod_1s_4p_cps) push %r12 bsr %rsi, %rcx push %rbp xor $63, R32(%rcx) mov %rsi, %rbp mov R32(%rcx), R32(%r12) sal R8(%rcx), %rbp push %rbx mov %rdi, %rbx mov %rbp, %rdi CALL( mpn_invert_limb) mov R32(%r12), R32(%rcx) mov $1, R32(%r10) sal R8(%rcx), %r10 mov $64, R32(%rcx) mov %rax, %r9 sub R32(%r12), R32(%rcx) mov %r9, (%rbx) shr R8(%rcx), %rax mov R32(%r12), R32(%rcx) or %rax, %r10 mov %rbp, %rax neg %rax imul %rax, %r10 mov %r10, %rax mul %r9 lea 1(%r10,%rdx), %r8 neg %r8 imul %rbp, %r8 cmp %r8, %rax lea (%r8,%rbp), %rdx cmovb %rdx, %r8 mov %r8, %rax mul %r9 lea 1(%r8,%rdx), %rdi neg %rdi imul %rbp, %rdi cmp %rdi, %rax lea (%rdi,%rbp), %rdx cmovb %rdx, %rdi mov %rdi, %rax mul %r9 lea 1(%rdi,%rdx), %rsi neg %rsi imul %rbp, %rsi cmp %rsi, %rax lea (%rsi,%rbp), %rdx cmovb %rdx, %rsi mov %rsi, %rax mul %r9 lea 1(%rsi,%rdx), %rdx neg %rdx imul %rbp, %rdx cmp %rdx, %rax lea (%rdx,%rbp), %rbp movslq R32(%r12), %rax cmovae %rdx, %rbp shr R8(%rcx), %r10 shr R8(%rcx), %r8 shr R8(%rcx), %rbp shr R8(%rcx), %rdi shr R8(%rcx), %rsi mov %rbp, 48(%rbx) mov %rax, 8(%rbx) mov %r10, 16(%rbx) mov %r8, 24(%rbx) mov %rdi, 32(%rbx) mov %rsi, 40(%rbx) pop %rbx pop %rbp pop %r12 ret EPILOGUE()
//================================================================================================= /*! // \file src/mathtest/dmatdmatsub/M4x4aM4x4b.cpp // \brief Source file for the M4x4aM4x4b dense matrix/dense matrix subtraction math test // // Copyright (C) 2013 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. 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. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // 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 HOLDER 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. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/StaticMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dmatdmatsub/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'M4x4aM4x4b'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Matrix type definitions typedef blaze::StaticMatrix<TypeA,4UL,4UL> M4x4a; typedef blaze::StaticMatrix<TypeB,4UL,4UL> M4x4b; // Creator type definitions typedef blazetest::Creator<M4x4a> CM4x4a; typedef blazetest::Creator<M4x4b> CM4x4b; // Running the tests RUN_DMATDMATSUB_OPERATION_TEST( CM4x4a(), CM4x4b() ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix subtraction:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
SECTION code_driver SECTION code_driver_terminal_output PUBLIC console_01_output_fzx_iterm_msg_bs PUBLIC console_01_output_fzx_iterm_msg_bs_join PUBLIC console_01_output_fzx_iterm_msg_bs_join_pwd EXTERN OTERM_MSG_FZX_PUTC EXTERN asm_fzx_buffer_partition, l_jpix EXTERN l_offset_ix_de, console_01_output_fzx_proc_linefeed console_01_output_fzx_iterm_msg_bs: ; backspace: erase the last char of the edit buffer. ; ; enter : ix = FDSTRUCT.JP * ; de = char *edit_buffer ; bc = int edit_buffer_len > 0 ; ; can use: af, bc, de, hl, ix ; THE ALTERNATIVE HERE IS TO PRINT THE EDIT BUFFER ; FROM THE EDIT (X,Y) COORDINATE USING AN FZX_DRAW ; FUNCTION THAT DOES NOTHING. THE CODE WOULD BE ; SMALL BUT I BELIEVE TOO SLOW. ; THIS CODE 'SIMULATES' THE PRINTING BY MEASURING ; THE PIXEL WIDTH OF THE EDIT BUFFER AND ADVANCING ; THE EDIT (X,Y) COORDINATE BY THE PIXEL WIDTH OF ; CHARS WITHOUT PRINTING THEM. push ix ; save FDSTRUCT.JP * ; determine which char is being erased dec bc ; buflen now excludes last char ld l,e ld h,d add hl,bc ld l,(hl) push hl ; save last char of buffer (char erase) console_01_output_fzx_iterm_msg_bs_join: ; ix = FDSTRUCT.JP * ; de = char *edit_buffer ; bc = edit_buffer_len >= 0 ; stack = FDSTRUCT.JP *, char erase ; set ix = struct fzx_state * push de ld hl,30 call l_offset_ix_de push hl pop ix ; copy edit buffer (x,y) into current (x,y) ld l,(ix-3) ld h,(ix-2) ld (ix+7),l ld (ix+8),h ; y = edit_y ld l,(ix-5) ld h,(ix-4) ld (ix+5),l ld (ix+6),h ; x = edit_x ; compute allowed_width, set up stack ; ix = struct fzx_state * ; bc = int edit_buffer_len >= 0 ; hl = edit_x ; stack = FDSTRUCT.JP *, char erase, char *edit_buffer ld e,(ix+17) ld d,(ix+18) ; de = left_margin sbc hl,de add hl,de jr nc, edit_x_ok ; if edit_x >= left_margin ld l,e ld h,d ; hl = left_margin edit_x_ok: ; ix = struct fzx_state * ; bc = int edit_buffer_len >= 0 ; de = left_margin ; hl = true edit_x ; stack = FDSTRUCT.JP *, char erase, char *edit_buffer pop af push ix push af ; stack = FDSTRUCT.JP *, char erase, struct fzx_state *, char *edit_buffer push hl ; save edit_x ld l,(ix+11) ld h,(ix+12) ; hl = paper.width push hl ; save paper.width or a sbc hl,de ; hl = allowed_width (full line) pop de ; de = paper.width ex (sp),hl ; hl = edit_x ex de,hl sbc hl,de ; hl = allowed_width (first line) ; ix = struct fzx_state * ; bc = int edit_buffer_len >= 0 ; hl = allowed_width (first line) ; carry set if allowed_width (first line) < 0 ; stack = FDSTRUCT.JP *, char erase, struct fzx_state *, char *edit_buffer, allowed_width (full line) ex de,hl ; de = allowed_width (first line) ld l,(ix+3) ld h,(ix+4) push hl pop ix ; ix = struct fzx_font * ; ix = struct fzx_font * ; bc = int edit_buffer_len >= 0 ; de = allowed_width (first line) ; carry set if allowed_width (first line) < 0 ; stack = FDSTRUCT.JP *, char erase, struct fzx_state *, char *edit_buffer, allowed_width (full line) jr nc, begin_first_line begin_second_line: pop hl pop de ; ix = struct fzx_font * ; hl = allowed_width ; de = buf + prefix_len ; bc = remaining buflen ; stack = FDSTRUCT.JP *, char erase, struct fzx_state * jr advance_line begin_first_line: ; ix = struct fzx_font * ; bc = int edit_buffer_len >= 0 ; de = allowed_width (first line) ; stack = FDSTRUCT.JP *, char erase, struct fzx_state *, char *edit_buffer, allowed_width (full line) ex de,hl ; hl = allowed_width (first line) pop af pop de push af partition_loop: ; partition buffer and advance (x,y) coordinate ; ix = struct fzx_font * ; hl = allowed_width ; de = char *buf ; bc = buflen ; stack = FDSTRUCT.JP *, char erase, struct fzx_state *, allowed_width call asm_fzx_buffer_partition jr nc, position_found ; not all chars can fit line ; so advance y coordinate ex de,hl pop hl advance_line: ; ix = struct fzx_font * ; hl = allowed_width ; de = buf + prefix_len ; bc = remaining buflen ; stack = FDSTRUCT.JP *, char erase, struct fzx_state * ex (sp),ix push de push hl call console_01_output_fzx_proc_linefeed pop hl pop de ex (sp),ix push hl jr partition_loop position_found: ; advance x coord in current line ; ix = struct fzx_font * ; de = remaining allowed_width ; stack = FDSTRUCT.JP *, char erase, struct fzx_state *, allowed_width pop bc ; junk item ld c,(ix+1) ld b,0 ; bc = tracking pop ix ; ix = struct fzx_state * ld l,(ix+11) ld h,(ix+12) ; hl = paper.width sbc hl,de ; hl = paper.width - remaining_width add hl,bc ; undo tracking added to remaining_width by fzx_buffer_partition console_01_output_fzx_iterm_msg_bs_join_pwd: pop bc ; ix = struct fzx_state * ; hl = x coord of last char ; c = char erase ; stack = FDSTRUCT.JP * ld (ix+5),l ld (ix+6),h ; store new x coord ; overwrite last char to erase it ; ix = struct fzx_state * ; hl = x coord of last char ; c = char erase ; stack = FDSTRUCT.JP * pop de push de ; de = FDSTRUCT.JP * push hl ; save x coord ld l,(ix+7) ld h,(ix+8) push hl ; save y coord putchar_loop: push de ; save FDSTRUCT.JP * push de ex (sp),ix ; ix = FDSTRUCT.JP * pop hl push hl ; hl = struct fzx_state * push bc ; save char ld a,OTERM_MSG_FZX_PUTC call l_jpix pop bc ; c = char to erase pop ix ; ix = struct fzx_state * jr nc, backspace_done ; can only fail if no fit horizontally dec a jr z, backspace_done ; failed to fit vertically, cannot happen so give up call console_01_output_fzx_proc_linefeed pop de ; de = FDSTRUCT.JP * jr putchar_loop backspace_done: pop de ; de = FDSTRUCT.JP * ; ix = struct fzx_state * ; stack = FDSTRUCT.JP *, x coord, y coord pop hl ld (ix+7),l ld (ix+8),h ; restore y coord of last char pop hl ld (ix+5),l ld (ix+6),h ; restore x coord of last char pop ix ret
// Copyright (C) 2004, 2006 International Business Machines and others. // All Rights Reserved. // This code is published under the Common Public License. // // $Id: IpDefaultIterateInitializer.cpp 759 2006-07-07 03:07:08Z andreasw $ // // Authors: Carl Laird, Andreas Waechter IBM 2004-09-23 #include "IpDefaultIterateInitializer.hpp" namespace Ipopt { #ifdef IP_DEBUG static const Index dbg_verbosity = 0; #endif DefaultIterateInitializer::DefaultIterateInitializer (const SmartPtr<EqMultiplierCalculator>& eq_mult_calculator, const SmartPtr<IterateInitializer>& warm_start_initializer) : IterateInitializer(), eq_mult_calculator_(eq_mult_calculator), warm_start_initializer_(warm_start_initializer) {} void DefaultIterateInitializer::RegisterOptions(SmartPtr<RegisteredOptions> reg_options) { reg_options->AddLowerBoundedNumberOption( "bound_push", "Desired minimum absolute distance from the initial point to bound.", 0.0, true, 0.01, "Determines how much the initial point might have to " "be modified in order to be sufficiently inside " "the bounds (together with \"bound_frac\"). (This is kappa_1 in " "Section 3.6 of implementation paper.)"); reg_options->AddBoundedNumberOption( "bound_frac", "Desired minimum relative distance from the initial point to bound.", 0, true, 0.5, false, 0.01, "Determines how much the initial point might have to " "be modified in order to be sufficiently inside " "the bounds (together with \"bound_push\"). (This is kappa_2 in " "Section 3.6 of implementation paper.)"); reg_options->AddLowerBoundedNumberOption( "constr_mult_init_max", "Maximum allowed least-square guess of constraint multipliers.", 0, false, 1e3, "Determines how large the initial least-square guesses of the constraint " "multipliers are allowed to be (in max-norm). If the guess is larger " "than this value, it is discarded and all constraint multipliers are " "set to zero. This options is also used when initializing the " "restoration phase. By default, \"resto.constr_mult_init_max\" (the one " "used in RestoIterateInitializer) is set to zero."); reg_options->AddLowerBoundedNumberOption( "bound_mult_init_val", "Initial value for the bound multipliers.", 0, true, 1.0, "All dual variables corresponding to bound constraints are " "initialized to this value."); reg_options->SetRegisteringCategory("Warm Start"); reg_options->AddStringOption2( "warm_start_init_point", "Warm-start for initial point", "no", "no", "do not use the warm start initialization", "yes", "use the warm start initialization", "Indicates whether this optimization should use a warm start " "initialization, where values of primal and dual variables are " "given (e.g., from a previous optimization of a related problem.)"); } bool DefaultIterateInitializer::InitializeImpl(const OptionsList& options, const std::string& prefix) { // Check for the algorithm options options.GetNumericValue("bound_push", bound_push_, prefix); options.GetNumericValue("bound_frac", bound_frac_, prefix); options.GetNumericValue("constr_mult_init_max", constr_mult_init_max_, prefix); options.GetNumericValue("bound_mult_init_val", bound_mult_init_val_, prefix); options.GetBoolValue("warm_start_init_point", warm_start_init_point_, prefix); bool retvalue = true; if (IsValid(eq_mult_calculator_)) { retvalue = eq_mult_calculator_->Initialize(Jnlst(), IpNLP(), IpData(), IpCq(), options, prefix); if (!retvalue) { return retvalue; } } if (IsValid(warm_start_initializer_)) { retvalue = warm_start_initializer_->Initialize(Jnlst(), IpNLP(), IpData(), IpCq(), options, prefix); } return retvalue; } bool DefaultIterateInitializer::SetInitialIterates() { DBG_START_METH("DefaultIterateInitializer::SetInitialIterates", dbg_verbosity); if (warm_start_init_point_) { DBG_ASSERT(IsValid(warm_start_initializer_)); return warm_start_initializer_->SetInitialIterates(); } // Get the starting values provided by the NLP and store them // in the ip_data current fields. The following line only requests // intial values for the primal variables x, but later we might // make this more flexible based on user options. ///////////////////////////////////////////////////////////////////// // Initialize primal variables // ///////////////////////////////////////////////////////////////////// IpData().InitializeDataStructures(IpNLP(), true, false, false, false, false); // get a container of the current point. We will modify parts of this // IteratesVector to set the trial point. SmartPtr<IteratesVector> iterates = IpData().curr()->MakeNewContainer(); DBG_PRINT_VECTOR(2, "curr_x", *iterates->x()); // Now we compute the initial values that the algorithm is going to // actually use. We first store them in the trial fields in ip_data. // Push the x iterates sufficiently inside the bounds // Calculate any required shift in x0 and s0 SmartPtr<const Vector> new_x; push_variables(Jnlst(), bound_push_, bound_frac_, "x", *iterates->x(), new_x, *IpNLP().x_L(), *IpNLP().x_U(), *IpNLP().Px_L(), *IpNLP().Px_U()); iterates->Set_x(*new_x); IpData().set_trial(iterates); // Calculate the shift in s... SmartPtr<const Vector> s = IpCq().trial_d(); DBG_PRINT_VECTOR(2, "s", *s); SmartPtr<const Vector> new_s; push_variables(Jnlst(), bound_push_, bound_frac_, "s", *s, new_s, *IpNLP().d_L(), *IpNLP().d_U(), *IpNLP().Pd_L(), *IpNLP().Pd_U()); iterates = IpData().trial()->MakeNewContainer(); iterates->Set_s(*new_s); ///////////////////////////////////////////////////////////////////// // Initialize bound multipliers // ///////////////////////////////////////////////////////////////////// // Initialize the bound multipliers to bound_mult_init_val. iterates->create_new_z_L(); iterates->create_new_z_U(); iterates->create_new_v_L(); iterates->create_new_v_U(); iterates->z_L_NonConst()->Set(bound_mult_init_val_); iterates->z_U_NonConst()->Set(bound_mult_init_val_); iterates->v_L_NonConst()->Set(bound_mult_init_val_); iterates->v_U_NonConst()->Set(bound_mult_init_val_); IpData().set_trial(iterates); ///////////////////////////////////////////////////////////////////// // Initialize equality constraint multipliers // ///////////////////////////////////////////////////////////////////// least_square_mults(Jnlst(), IpNLP(), IpData(), IpCq(), eq_mult_calculator_, constr_mult_init_max_); // upgrade the trial to the current point IpData().AcceptTrialPoint(); return true; } void DefaultIterateInitializer::push_variables( const Journalist& jnlst, Number bound_push, Number bound_frac, std::string name, const Vector& orig_x, SmartPtr<const Vector>& new_x, const Vector& x_L, const Vector& x_U, const Matrix& Px_L, const Matrix& Px_U) { DBG_START_FUN("DefaultIterateInitializer::push_variables", dbg_verbosity); // Calculate any required shift in x0 and s0 const double dbl_min = std::numeric_limits<double>::min(); const double tiny_double = 100.0*dbl_min; SmartPtr<Vector> tmp = orig_x.MakeNew(); SmartPtr<Vector> tmp_l = x_L.MakeNew(); SmartPtr<Vector> tmp_u = x_U.MakeNew(); SmartPtr<Vector> tiny_l = x_L.MakeNew(); tiny_l->Set(tiny_double); // Calculate p_l SmartPtr<Vector> q_l = x_L.MakeNew(); SmartPtr<Vector> p_l = x_L.MakeNew(); DBG_PRINT_VECTOR(2,"orig_x", orig_x); DBG_PRINT_MATRIX(2,"Px_L", Px_L); DBG_PRINT_VECTOR(2, "x_L", x_L); DBG_PRINT_MATRIX(2,"Px_U", Px_U); DBG_PRINT_VECTOR(2, "x_U", x_U); Px_L.MultVector(1.0, x_L, 0.0, *tmp); Px_U.TransMultVector(1.0, *tmp, 0.0, *tmp_u); tmp_u->AddOneVector(1., x_U, -1.); Px_U.MultVector(1.0, *tmp_u, 0.0, *tmp); Px_L.TransMultVector(1.0, *tmp, 0.0, *q_l); q_l->AddOneVector(-1.0, *tiny_l, bound_frac); DBG_PRINT_VECTOR(2, "q_l", *q_l); // At this point, q_l is // bound_frac * Px_L^T Px_U(x_U - Px_U^T Px_L x_L) - tiny_double // i.e., it is bound_frac*(x_U - x_L) for those components that have // two bounds // and - tiny_double for those that have only one or no bounds tmp_l->Set(bound_push); p_l->AddOneVector(bound_push, x_L, 0.); p_l->ElementWiseAbs(); p_l->ElementWiseMax(*tmp_l); // now p_l is bound_push * max(|x_L|,1) q_l->ElementWiseReciprocal(); p_l->ElementWiseReciprocal(); p_l->ElementWiseMax(*q_l); p_l->ElementWiseReciprocal(); // p_l->Axpy(1.0, *tiny_l); we shouldn't need this // At this point, p_l is // min(bound_push * max(|x_L|,1), bound_frac*(x_U-x_L) for components // with two bounds // bound_push * max(|x_L|,1) otherwise // This is the margin we want to the lower bound DBG_PRINT_VECTOR(1, "p_l", *p_l); // Calculate p_u SmartPtr<Vector> q_u = x_U.MakeNew(); SmartPtr<Vector> p_u = x_U.MakeNew(); SmartPtr<Vector> tiny_u = x_U.MakeNew(); tiny_u->Set(tiny_double); Px_U.MultVector(1.0, x_U, 0.0, *tmp); Px_L.TransMultVector(1.0, *tmp, 0.0, *tmp_l); tmp_l->Axpy(-1.0, x_L); Px_L.MultVector(1.0, *tmp_l, 0.0, *tmp); Px_U.TransMultVector(1.0, *tmp, 0.0, *q_u); q_u->AddOneVector(-1.0, *tiny_u, bound_frac); DBG_PRINT_VECTOR(2,"q_u",*q_u); // q_u is now the same as q_l above, but of the same dimension as x_L tmp_u->Set(bound_push); p_u->Copy(x_U); p_u->AddOneVector(bound_push, x_U, 0.); p_u->ElementWiseAbs(); p_u->ElementWiseMax(*tmp_u); DBG_PRINT_VECTOR(2,"p_u",*p_u); q_u->ElementWiseReciprocal(); p_u->ElementWiseReciprocal(); p_u->ElementWiseMax(*q_u); p_u->ElementWiseReciprocal(); p_u->Axpy(1.0, *tiny_u); // At this point, p_l is // min(bound_push * max(|x_U|,1), bound_frac*(x_U-x_L) for components // with two bounds // bound_push * max(|x_U|,1) otherwise // This is the margin we want to the upper bound DBG_PRINT_VECTOR(2,"actual_p_u",*p_u); // Calculate the new x SmartPtr<Vector> delta_x = orig_x.MakeNew(); SmartPtr<Vector> zero_l = x_L.MakeNew(); zero_l->Set(0.0); SmartPtr<Vector> zero_u = x_U.MakeNew(); zero_u->Set(0.0); Px_L.TransMultVector(-1.0, orig_x, 0.0, *tmp_l); tmp_l->AddTwoVectors(1.0, x_L, 1.0, *p_l, 1.); tmp_l->ElementWiseMax(*zero_l); // tmp_l is now max(x_L + p_l - x, 0), i.e., the amount by how // much need to correct the variable Number nrm_l = tmp_l->Amax(); if (nrm_l>0.) { Px_L.MultVector(1.0, *tmp_l, 0.0, *delta_x); } else { delta_x->Set(0.); } Px_U.TransMultVector(1.0, orig_x, 0.0, *tmp_u); tmp_u->AddTwoVectors(-1.0, x_U, 1.0, *p_u, 1.); tmp_u->ElementWiseMax(*zero_u); // tmp_u is now max(x - (x_U-p_u), 0), i.e., the amount by how // much need to correct the variable Number nrm_u = tmp_u->Amax(); if (nrm_u>0.) { Px_U.MultVector(-1.0, *tmp_u, 1.0, *delta_x); } if (nrm_l > 0 || nrm_u > 0) { delta_x->Axpy(1.0, orig_x); new_x = ConstPtr(delta_x); jnlst.Printf(J_DETAILED, J_INITIALIZATION, "Moved initial values of %s sufficiently inside the bounds.\n", name.c_str()); orig_x.Print(jnlst, J_VECTOR, J_INITIALIZATION, "original vars"); new_x->Print(jnlst, J_VECTOR, J_INITIALIZATION, "new vars"); } else { new_x = &orig_x; jnlst.Printf(J_DETAILED, J_INITIALIZATION, "Initial values of %s sufficiently inside the bounds.\n", name.c_str()); } } void DefaultIterateInitializer::least_square_mults( const Journalist& jnlst, IpoptNLP& ip_nlp, IpoptData& ip_data, IpoptCalculatedQuantities& ip_cq, const SmartPtr<EqMultiplierCalculator>& eq_mult_calculator, Number constr_mult_init_max) { DBG_START_FUN("DefaultIterateInitializer::least_square_mults", dbg_verbosity); SmartPtr<IteratesVector> iterates = ip_data.trial()->MakeNewContainer(); iterates->create_new_y_c(); iterates->create_new_y_d(); if (iterates->y_c_NonConst()->Dim()==iterates->x()->Dim()) { // This problem is square, we just set the multipliers to zero iterates->y_c_NonConst()->Set(0.0); iterates->y_d_NonConst()->Set(0.0); ip_data.Append_info_string("s"); } else if (IsValid(eq_mult_calculator) && constr_mult_init_max>0. && iterates->y_c_NonConst()->Dim()+iterates->y_d_NonConst()->Dim()>0) { // First move all the trial data into the current fields, since // those values are needed to compute the initial values for // the multipliers ip_data.CopyTrialToCurrent(); SmartPtr<Vector> y_c = iterates->y_c_NonConst(); SmartPtr<Vector> y_d = iterates->y_d_NonConst(); bool retval = eq_mult_calculator->CalculateMultipliers(*y_c, *y_d); if (!retval) { y_c->Set(0.0); y_d->Set(0.0); } else { /* { ip_data.set_trial(iterates); printf("grad_x = %e grad_s = %e y_c = %e y_d = %e\n", ip_cq.trial_grad_lag_x()->Amax(), ip_cq.trial_grad_lag_s()->Amax(), y_c->Amax(), y_d->Amax()); iterates = ip_data.trial()->MakeNewContainer(); } */ jnlst.Printf(J_DETAILED, J_INITIALIZATION, "Least square estimates max(y_c) = %e, max(y_d) = %e\n", y_c->Amax(), y_d->Amax()); Number yinitnrm = Max(y_c->Amax(), y_d->Amax()); if (yinitnrm > constr_mult_init_max) { y_c->Set(0.0); y_d->Set(0.0); } else { ip_data.Append_info_string("y"); } } } else { iterates->y_c_NonConst()->Set(0.0); iterates->y_d_NonConst()->Set(0.0); } ip_data.set_trial(iterates); DBG_PRINT_VECTOR(2, "y_c", *ip_data.trial()->y_c()); DBG_PRINT_VECTOR(2, "y_d", *ip_data.trial()->y_d()); } } // namespace Ipopt
; A302323: Number of 2Xn 0..1 arrays with every element equal to 0, 1, 2 or 4 horizontally, diagonally or antidiagonally adjacent elements, with upper left element zero. ; Submitted by Jon Maiga ; 2,8,20,52,136,360,960,2576,6944,18784,50944,138432,376704,1026176,2797568,7631104,20824576,56845824,155209728,423848960,1157593088,3161835520,8636760064,23592996864,64451125248,176071467008,481011630080,1314099085312,3590087213056,9808104161280,26795845877760,73206826336256,200003196944384,546415751593984,1492829307142144,4078472937603072,11142570129752064,30442017415233536,83169037651017728,227221835254595584,620781196055412736,1696004963108388864,4633570119304347648,12659145766778961920 mov $1,5 mov $2,2 mov $4,1 lpb $0 sub $0,1 sub $1,1 add $1,$4 mul $1,2 mov $3,$4 mov $4,$2 add $2,$3 mul $2,2 lpe mul $1,4 div $1,8 mov $0,$1 sub $0,1 mul $0,2
#define FIFO_ASM #include "fifo.inc" #include "interrupt.inc" #include "number.inc" #include "util.inc" #include "uart.inc" global fifo_buffer global fifo_start global fifo_free global fifo_size global fifo_data global search_byte global checksum udata fifo_buffer res MAX_FIFO_SIZE ; buffer fifo_start res 1 ; start of the buffer fifo_free res 1 ; last + 1 fifo_size res 1 ; data entries count fifo_data res 1 ; temporary storage search_byte res 1 ; fifo_find local checksum res 1 ; updated in fifo_get_hex high_nibble res 1 ; fifo_get_hex local code ; Queue data from W to FIFO routine fifo_add local no_overflow rselect fifo_data movwf fifo_data ; fifo_data = W incf fifo_size, f ; fifo_size++ movlw MAX_FIFO_SIZE andwf fifo_size, f ; fifo_size &= MAX_FIFO_SIZE bnz no_overflow ; fifo_size != 0 ? reboot no_overflow: rselecti fifo_buffer rmovlf fifo_buffer, FSR ; FSR = fifo_buffer movfw fifo_free addwf FSR, f ; FSR += fifo_free movff fifo_data, INDF ; *FSR = fifo_data incf fifo_free, f ; fifo_free++ movlw MAX_FIFO_SIZE andwf fifo_free, f ; rollover fifo_free fifo_debug 'A' return ; Get data from FIFO to W routine fifo_get local no_data rselect fifo_size no_data: tstf fifo_size ; fifo_size == 0 ? bz no_data ; fifo_size == 0 inline disable_int ; Disable interrupts decf fifo_size, f ; fifo_size-- rselecti fifo_buffer rmovlf fifo_buffer, FSR ; FSR = fifo_buffer movfw fifo_start addwf FSR, f ; FSR += fifo_start movff INDF, fifo_data ; fifo_data = *FSR incf fifo_start, f ; fifo_start++ movlw MAX_FIFO_SIZE andwf fifo_start, f ; rollover fifo_start fifo_debug 'G' movfw fifo_data #if UART_INT == 1 bsf INTCON, GIE ; enable interrupts #endif return ; Get hex byte from FIFO to W and update checksum ; Z is set if checksum is 0 ; locals: high_nibble routine fifo_get_hex ; get high nibble lclcall fifo_get farcall hex_to_number ; W = hex_to_number (W) rselect high_nibble movwf high_nibble ; high_nibble = W swapf high_nibble, f ; high_nibble <<= 4 ; get low nibble lclcall fifo_get farcall hex_to_number ; W = hex_to_number (W) rselect high_nibble iorwf high_nibble, w ; W |= high_nibble addwf checksum, f ; checksum += W return end
/* First we compute all the primes we may need with the sieve of Eratosthenes (once for all testcases). Then we simply perform a DFS on the tree (augmented with a dummy root 0 whose only child is Mr. Alfred) keeping track of the depth and counting the number of employees satisfying the condition. Time complexity: O(N) Space complexity: O(N) (excluding the computation of prime numbers) */ #include <bits/stdc++.h> using namespace std; vector<bool> is_prime; void sieve(int N) { is_prime.assign(N, true); is_prime[0] = is_prime[1] = false; for(int p = 2; p * p < N; ++p) { if(is_prime[p]) { for(int q = p * p; q < N; q += p) { is_prime[q] = false; } } } } int dfs(const vector<vector<int>>& G, int n = 0, int d = -1) { int ans = 0; if(d > 0 and is_prime[n + d]) { ++ans; } for(int x : G[n]) { ans += dfs(G, x, d + 1); } return ans; } void solve() { int N; cin >> N; vector<vector<int>> G(N + 1); for(int n = 1; n <= N; ++n) { int a; cin >> a; G[a].push_back(n); } cout << dfs(G) << '\n'; } int main() { sieve(200200); int T; cin >> T; while(T--) { solve(); } }
; ; ANSI Video handling for the PC6001 ; ; set it up with: ; .text_cols = max columns ; .text_rows = max rows ; ; Display a char in location (ansi_ROW),(ansi_COLUMN) ; A=char to display ; ; ; $Id: f_ansi_char.asm,v 1.3 2016-06-12 16:06:43 dom Exp $ ; SECTION code_clib PUBLIC ansi_CHAR PUBLIC text_cols PUBLIC text_rows EXTERN ansi_ROW EXTERN ansi_COLUMN EXTERN pc6001_attr .text_cols defb 32 .text_rows defb 16 .ansi_CHAR push af ld a,(ansi_ROW) inc a ld l,a ld a,(ansi_COLUMN) inc a ld h,a CALL 11CDh ; L2A - convert location to screen address pop af ld (hl),a ld a,$E0 and h ld h,a ld a,(pc6001_attr) ld (hl),a ret
title "Capture and Restore Context" ;++ ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ; You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt). ; If you do not agree to the terms, do not use the code. ; ; ; Module Name: ; ; capture.asm ; ; Abstract: ; ; This module implements the platform specific code to capture and restore ; the context of the caller. ; ;-- include ksamd64.inc altentry RcConsolidateFrames subttl "Capture Context" ;++ ; ; VOID ; RtlCaptureContext ( ; IN PCONTEXT ContextRecord ; ) ; ; Routine Description: ; ; This function captures the context of the caller in the specified ; context record. ; ; N.B. The stored value of registers rcx and rsp will be a side effect of ; having made this call. All other registers will be stored as they ; were when the call to this function was made. ; ; Arguments: ; ; ContextRecord (rcx) - Supplies a pointer to a context record. ; ; Return Value: ; ; None. ; ;-- CcFrame struct EFlags dd ? ; saved processor flags Fill dd ? ; fill CcFrame ends NESTED_ENTRY RtlCaptureContext, _TEXT$00 rex_push_eflags ; save processor flags END_PROLOGUE mov CxSegCs[rcx], cs ; save segment registers mov CxSegDs[rcx], ds ; mov CxSegEs[rcx], es ; mov CxSegSs[rcx], ss ; mov CxSegFs[rcx], fs ; mov CxSegGs[rcx], gs ; mov CxRax[rcx], rax ; save integer registers mov CxRcx[rcx], rcx ; mov CxRdx[rcx], rdx ; mov CxRbx[rcx], rbx ; lea rax, (sizeof CcFrame) + 8[rsp] ; get previous stack address mov CxRsp[rcx], rax ; mov CxRbp[rcx], rbp ; mov CxRsi[rcx], rsi ; mov CxRdi[rcx], rdi ; mov CxR8[rcx], r8 ; mov CxR9[rcx], r9 ; mov CxR10[rcx], r10 ; mov CxR11[rcx], r11 ; mov CxR12[rcx], r12 ; mov CxR13[rcx], r13 ; mov CxR14[rcx], r14 ; mov CxR15[rcx], r15 ; movdqa CxXmm0[rcx], xmm0 ; save xmm floating registers movdqa CxXmm1[rcx], xmm1 ; movdqa CxXmm2[rcx], xmm2 ; movdqa CxXmm3[rcx], xmm3 ; movdqa CxXmm4[rcx], xmm4 ; movdqa CxXmm5[rcx], xmm5 ; movdqa CxXmm6[rcx], xmm6 ; movdqa CxXmm7[rcx], xmm7 ; movdqa CxXmm8[rcx], xmm8 ; movdqa CxXmm9[rcx], xmm9 ; movdqa CxXmm10[rcx], xmm10 ; movdqa CxXmm11[rcx], xmm11 ; movdqa CxXmm12[rcx], xmm12 ; movdqa CxXmm13[rcx], xmm13 ; movdqa CxXmm14[rcx], xmm14 ; movdqa CxXmm15[rcx], xmm15 ; stmxcsr CxMxCsr[rcx] ; save xmm floating state mov rax, 8[rsp] ; set return address mov CxRip[rcx], rax ; mov eax, Ccframe.EFlags[rsp] ; set processor flags mov CxEFlags[rcx], eax ; mov dword ptr CxContextFlags[rcx], CONTEXT_FULL or CONTEXT_SEGMENTS ; set context flags add rsp, sizeof CcFrame ; deallocate stack frame ret ; return NESTED_END RtlCaptureContext, _TEXT$00 subttl "Restore Context" ;++ ; ; VOID ; RtlRestoreContext ( ; IN PCONTEXT ContextRecord, ; IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL ; ) ; ; Routine Description: ; ; This function restores the context of the caller to the specified ; context. ; ; Arguments: ; ; ContextRecord (rcx) - Supplies a pointer to a context record. ; ; ExceptionRecord (rdx) - Supplies an optional pointer to an exception ; record. ; ; Return Value: ; ; None - there is no return from this function. ; ;-- RcFrame struct Mframe db MachineFrameLength dup (?) ; machine frame Fill dq ? ; fill to 0 mod 16 RcFrame ends NESTED_ENTRY RtlRestoreContext, _TEXT$00 rex_push_reg rbp ; save nonvolatile registers push_reg rsi ; push_reg rdi ; alloc_stack (sizeof RcFrame) ; allocate stack frame set_frame rbp, 0 ; set frame pointer END_PROLOGUE ; ; If an exception record is specified and the exception status is the unwind ; consolidation code and there is at least one parameter, then consolidate ; all the frames that have been unwound and call back to a language specified ; routine. ; test rdx, rdx ; test if exception record specified jz Rc10 ; if z, no exception record specified cmp dword ptr ErExceptionCode[rdx], STATUS_UNWIND_CONSOLIDATE ; check call back jne short Rc05 ; if ne, not C++ unwind cmp dword ptr ErNumberParameters[rdx], 1 ; check number parameters jae Rc20 ; if ae, unwind consolidation ; ; If an exception record is specified and the exception status is long jump, ; then restore the nonvolatile registers to their state at the call to set ; jump before restoring the context record. ; Rc05: cmp dword ptr ErExceptionCode[rdx], STATUS_LONGJUMP ; check for long jump jne Rc10 ; if ne, not a long jump ; ; Long jump unwind. ; ; Copy register values from the jump buffer to the context record. ; mov rax, ErExceptionInformation[rdx] ; get jump buffer address mov r8, JbRbx[rax] ; move nonvolatile integer registers mov CxRbx[rcx], r8 ; to context record mov r8, JbRsp[rax] ; mov CxRsp[rcx], r8 ; mov r8, JbRbp[rax] ; mov CxRbp[rcx], r8 ; mov r8, JbRsi[rax] ; mov CxRsi[rcx], r8 ; mov r8, JbRdi[rax] ; mov CxRdi[rcx], r8 ; mov r8, JbR12[rax] ; mov CxR12[rcx], r8 ; mov r8, JbR13[rax] ; mov CxR13[rcx], r8 ; mov r8, JbR14[rax] ; mov CxR14[rcx], r8 ; mov r8, JbR15[rax] ; mov CxR15[rcx], r8 ; mov r8, JbRip[rax] ; mov CxRip[rcx], r8 ; mov r8d, JbMxCsr[rax] ; move MXCSR to context record mov CxMxCsr[rcx], r8d ; movdqa xmm0, JbXmm6[rax] ; move nonvolatile floating register movdqa CxXmm6[rcx], xmm0 ; to context record movdqa xmm0, JbXmm7[rax] ; movdqa CxXmm7[rcx], xmm0 ; movdqa xmm0, JbXmm8[rax] ; movdqa CxXmm8[rcx], xmm0 ; movdqa xmm0, JbXmm9[rax] ; movdqa CxXmm9[rcx], xmm0 ; movdqa xmm0, JbXmm10[rax] ; movdqa CxXmm10[rcx], xmm0 ; movdqa xmm0, JbXmm11[rax] ; movdqa CxXmm11[rcx], xmm0 ; movdqa xmm0, JbXmm12[rax] ; movdqa CxXmm12[rcx], xmm0 ; movdqa xmm0, JbXmm13[rax] ; movdqa CxXmm13[rcx], xmm0 ; movdqa xmm0, JbXmm14[rax] ; movdqa CxXmm14[rcx], xmm0 ; movdqa xmm0, JbXmm15[rax] ; movdqa CxXmm15[rcx], xmm0 ; ; ; Restore context and continue. ; Rc10: ; movdqa xmm0, CxXmm0[rcx] ; restore floating registers movdqa xmm1, CxXmm1[rcx] ; movdqa xmm2, CxXmm2[rcx] ; movdqa xmm3, CxXmm3[rcx] ; movdqa xmm4, CxXmm4[rcx] ; movdqa xmm5, CxXmm5[rcx] ; movdqa xmm6, CxXmm6[rcx] ; movdqa xmm7, CxXmm7[rcx] ; movdqa xmm8, CxXmm8[rcx] ; movdqa xmm9, CxXmm9[rcx] ; movdqa xmm10, CxXmm10[rcx] ; movdqa xmm11, CxXmm11[rcx] ; movdqa xmm12, CxXmm12[rcx] ; movdqa xmm13, CxXmm13[rcx] ; movdqa xmm14, CxXmm14[rcx] ; movdqa xmm15, CxXmm15[rcx] ; ldmxcsr CxMxCsr[rcx] ; restore MXCSR mov ax, CxSegSs[rcx] ; set SS segment mov MfSegSs[rsp], ax ; mov rax, CxRsp[rcx] ; set stack address mov MfRsp[rsp], rax ; mov eax, CxEFlags[rcx] ; set processor flags mov MfEFlags[rsp], eax ; mov ax, CxSegCs[rcx] ; set CS segment mov MfSegCs[rsp], ax ; mov rax, CxRip[rcx] ; set return address mov MfRip[rsp], rax ; mov rax, CxRax[rcx] ; restore volatile integer registers mov rdx, CxRdx[rcx] ; mov r8, CxR8[rcx] ; mov r9, CxR9[rcx] ; mov r10, CxR10[rcx] ; mov r11, CxR11[rcx] ; cli ; disable interrupts mov rbx, CxRbx[rcx] ; restore nonvolatile integer registers mov rsi, CxRsi[rcx] ; mov rdi, CxRdi[rcx] ; mov rbp, CxRbp[rcx] ; mov r12, CxR12[rcx] ; mov r13, CxR13[rcx] ; mov r14, CxR14[rcx] ; mov r15, CxR15[rcx] ; mov rcx, CxRcx[rcx] ; restore integer register iretq ; return ; ; Frame consoldation and language specific unwind call back. ; Rc20: sub rsp, MachineFrameLength + 8; allocate machine frame mov r8, rsp ; save machine frame address sub rsp, CONTEXT_FRAME_LENGTH ; allocate context frame mov rsi, rcx ; set source copy address mov rdi, rsp ; set destination copy address mov ecx, CONTEXT_FRAME_LENGTH / 8 ; set length of copy rep movsq ; copy context frame mov rax, CxRsp[rsp] ; set destination stack address in mov MfRsp[r8], rax ; machine frame mov rax, CxRip[rsp] ; set destination address in machine mov MfRip[r8], rax ; frame mov rcx, rdx ; set address of exception record jmp RcConsolidateFrames ; consolidate frames - no return NESTED_END RtlRestoreContext, _TEXT$00 subttl "Frame Consolidation" ;++ ; ; The following code is never executed. Its purpose is to provide the dummy ; prologue necessary to consolidate stack frames for unwind call back processing ; at the end of an unwind operation. ; ;-- NESTED_ENTRY RcFrameConsolidation, _TEXT$00 .pushframe ; .allocstack CONTEXT_FRAME_LENGTH ; allocate stack frame .savereg rbx, CxRbx ; save nonvolatile integer registers .savereg rbp, CxRbp ; .savereg rsi, CxRsi ; .savereg rdi, CxRdi ; .savereg r12, CxR12 ; .savereg r13, CxR13 ; .savereg r14, CxR14 ; .savereg r15, CxR15 ; .savexmm128 xmm6, CxXmm6 ; save nonvolatile floating register .savexmm128 xmm7, CxXmm7 ; .savexmm128 xmm8, CxXmm8 ; .savexmm128 xmm9, CxXmm9 ; .savexmm128 xmm10, CxXmm10 ; .savexmm128 xmm11, CxXmm11 ; .savexmm128 xmm12, CxXmm12 ; .savexmm128 xmm13, CxXmm13 ; .savexmm128 xmm14, CxXmm14 ; .savexmm128 xmm15, CxXmm15 ; END_PROLOGUE ;++ ; ; VOID ; RcConsolidateFrames ( ; IN PEXCEPTION_RECORD ExceptionRecord ; ) ; ; Routine Description: ; ; This routine is called at the end of a unwind operation to logically ; remove unwound frames from the stack. This is accomplished by building a ; call frame using a machine frame and a context record and then calling ; the alternate entry of this function. ; ; The following code calls the language call back function specified in the ; exception record. If the function returns, then the destination frame ; context is restored and control transferred to the address returned by the ; language call back function. If control does not return, then another ; exception must be raised. ; ; Arguments: ; ; ExceptionRecord (rdx) - Supplies a pointer to an exception record. ; ; Implicit Arguments: ; ; ContextRecord (rsp) - Supplies a pointer to a context record. ; ; Return Value: ; ; None. ; ;-- ALTERNATE_ENTRY RcConsolidateFrames ; ; At this point all call frames from the dispatching of the an exception to ; a destination language specific handler have been logically unwound and ; consolidated into a single large frame. ; ; The first parameter in the exception record is the address of a callback ; routine that performs language specific operations. This routine is called ; with the specified exception record as a parameter. ; call qword ptr ErExceptionInformation[rcx] ; call back to handler ; ; Restore context and continue. ; mov rcx, rsp ; set address of context record mov CxRip[rcx], rax ; set destination address movdqa xmm0, CxXmm0[rcx] ; restore floating registers movdqa xmm1, CxXmm1[rcx] ; movdqa xmm2, CxXmm2[rcx] ; movdqa xmm3, CxXmm3[rcx] ; movdqa xmm4, CxXmm4[rcx] ; movdqa xmm5, CxXmm5[rcx] ; movdqa xmm6, CxXmm6[rcx] ; movdqa xmm7, CxXmm7[rcx] ; movdqa xmm8, CxXmm8[rcx] ; movdqa xmm9, CxXmm9[rcx] ; movdqa xmm10, CxXmm10[rcx] ; movdqa xmm11, CxXmm11[rcx] ; movdqa xmm12, CxXmm12[rcx] ; movdqa xmm13, CxXmm13[rcx] ; movdqa xmm14, CxXmm14[rcx] ; movdqa xmm15, CxXmm15[rcx] ; ldmxcsr CxMxCsr[rcx] ; restore floating state ; ; Contruct a machine frame of the stack using information from the context ; record. ; ; N.B. The machine frame overlays the parameter area in the context record. ; mov ax, CxSegSs[rcx] ; set SS segment mov MfSegSs[rsp], ax ; mov rax, CxRsp[rcx] ; set stack address mov MfRsp[rsp], rax ; mov eax, CxEFlags[rcx] ; set processor flags mov MfEFlags[rsp], eax ; mov ax, CxSegCs[rcx] ; set CS segment mov MfSegCs[rsp], ax ; mov rax, CxRip[rcx] ; set return address mov MfRip[rsp], rax ; mov rax, CxRax[rcx] ; restore volatile integer registers mov rdx, CxRdx[rcx] ; mov r8, CxR8[rcx] ; mov r9, CxR9[rcx] ; mov r10, CxR10[rcx] ; mov r11, CxR11[rcx] ; cli ; disable interrupts mov rbx, CxRbx[rcx] ; restore nonvolatile integer registers mov rsi, CxRsi[rcx] ; mov rdi, CxRdi[rcx] ; mov rbp, CxRbp[rcx] ; mov r12, CxR12[rcx] ; mov r13, CxR13[rcx] ; mov r14, CxR14[rcx] ; mov r15, CxR15[rcx] ; mov rcx, CxRcx[rcx] ; restore integer register iretq ; return NESTED_END RcFrameConsolidation, _TEXT$00 end
#include "mathoperation.h" MathOperation::MathOperation() { } MathOperation::MathOperation(int elements) { max = elements; } MathOperation::MathOperation(int elements, cv::Mat& mat) { max = elements; values.assign(mat.datastart, mat.dataend); } double MathOperation::CalculateMean() { double sum = 0; for(int i = 0; i < max; i++) { sum += values[i]; } return (sum / max); } double MathOperation::CalculateVariane() { mean = CalculateMean(); double temp = 0; for(int i = 0; i < max; i++) { temp += (values[i] - mean) * (values[i] - mean) ; } return temp / max; } double MathOperation::GetStandardDeviation() { return sqrt(CalculateVariane()); } double MathOperation::ceil0( const double& value ) { double result = std::ceil( std::fabs( value ) ); return (value < 0.0) ? -result : result; } double MathOperation::roundhalfup( const double& value ) { return std::floor( value +0.5 ); } double MathOperation::roundhalfup0( const double& value ) { double result = roundhalfup( std::fabs( value ) ); return (value < 0.0) ? -result : result; } double MathOperation::roundhalfeven(const double& value) { const double& epsilon = EPSILON; if (value < 0.0) return -roundhalfeven(-value); double ipart; std::modf( value, &ipart ); double temp = fabs(value -(ipart +0.5)); if (temp < epsilon) { if (std::fmod( ipart, 2.0 ) < epsilon) return ipart; return ceil0( ipart +0.5 ); } return roundhalfup0( value ); } MathOperation::~MathOperation() { }
; A255108: Number of length n+1 0..2 arrays with at most one downstep in every n consecutive neighbor pairs. ; 9,26,66,147,294,540,927,1507,2343,3510,5096,7203,9948,13464,17901,23427,30229,38514,48510,60467,74658,91380,110955,133731,160083,190414,225156,264771,309752,360624,417945,482307,554337,634698,724090,823251,932958,1054028,1187319,1333731,1494207,1669734,1861344,2070115,2297172,2543688,2810885,3100035,3412461,3749538,4112694,4503411,4923226,5373732,5856579,6373475,6926187,7516542,8146428,8817795,9532656,10293088,11101233,11959299,12869561,13834362,14856114,15937299,17080470,18288252,19563343,20908515,22326615,23820566,25393368,27048099,28787916,30616056,32535837,34550659,36664005,38879442,41200622,43631283,46175250,48836436,51618843,54526563,57563779,60734766,64043892,67495619,71094504,74845200,78752457,82821123,87056145,91462570,96045546,100810323 add $0,1 lpb $0 mov $2,$0 sub $0,1 seq $2,252814 ; Number of n X 2 nonnegative integer arrays with upper left 0 and every value within 2 of its city block distance from the upper left and every value increasing by 0 or 1 with every step right or down. add $1,$2 lpe add $1,3 mov $0,$1
; A064650: a(n) = floor(a(n-1)/2) + a(n-2) with a(0)=1, a(1)=2. ; 1,2,2,3,3,4,5,6,8,10,13,16,21,26,34,43,55,70,90,115,147,188,241,308,395,505,647,828,1061,1358,1740,2228,2854,3655,4681,5995,7678,9834,12595,16131,20660,26461,33890,43406,55593,71202,91194,116799,149593,191595,245390,314290,402535,515557,660313,845713,1083169,1387297,1776817,2275705,2914669,3733039,4781188,6123633,7843004,10045135,12865571,16477920,21104531,27030185,34619623,44339996,56789621,72734806,93157024,119313318,152813683,195720159,250673762,321057040,411202282,526658181,674531372,863923867,1106493305,1417170519,1815078564,2324709801,2977433464,3813426533,4884146730,6255499898,8011896679,10261448237,13142620797,16832758635,21559000114,27612258692,35365129460,45294823422,58012541171,74301094007,95163088174,121882638094,156104407221,199934841704,256071828073,327970755740,420057205943,537999358711,689056885298,882527801360,1130320785978,1447688194349,1854164883152,2374770635925,3041550201114,3895545736482,4989323069355,6390207271159,8184426704934,10482420623626,13425637016747,17195239131999,22023256582746,28206867423372,36126690294432,46270212570588,59261796579726,75901110860451,97212352009951,124507286865426,159465995442664,204240284586758,261586137736043,335033353454779,429102814463432,549584760686495,703895194806679,901532358089834,1154661373851596,1478863045015632,1894092896359412,2425909493195338,3107047642957081,3979433314673878,5096764300294020,6527815464820888,8360672032704464 mov $2,$0 mov $0,1 add $0,$2 mov $3,1 mov $4,2 lpb $0,1 sub $0,1 mov $1,$3 div $3,2 add $3,$4 mov $4,$1 lpe
; A117573: Expansion of (1+2x^2)/((1-x)(1-x^2)(1-x^3)). ; 1,1,4,5,8,11,15,18,24,28,34,40,47,53,62,69,78,87,97,106,118,128,140,152,165,177,192,205,220,235,251,266,284,300,318,336,355,373,394,413,434,455,477,498,522,544,568,592,617,641,668 mov $1,9 add $1,$0 add $1,$0 sub $0,1 div $1,6 lpb $0 add $1,$0 trn $0,2 add $1,1 lpe mov $0,$1
// Copyright (c) 2015-2016 The Youngseokcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "reverselock.h" #include "test/test_youngseokcoin.h" #include <boost/test/unit_test.hpp> BOOST_FIXTURE_TEST_SUITE(reverselock_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(reverselock_basics) { boost::mutex mutex; boost::unique_lock<boost::mutex> lock(mutex); BOOST_CHECK(lock.owns_lock()); { reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock); BOOST_CHECK(!lock.owns_lock()); } BOOST_CHECK(lock.owns_lock()); } BOOST_AUTO_TEST_CASE(reverselock_errors) { boost::mutex mutex; boost::unique_lock<boost::mutex> lock(mutex); // Make sure trying to reverse lock an unlocked lock fails lock.unlock(); BOOST_CHECK(!lock.owns_lock()); bool failed = false; try { reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock); } catch(...) { failed = true; } BOOST_CHECK(failed); BOOST_CHECK(!lock.owns_lock()); // Locking the original lock after it has been taken by a reverse lock // makes no sense. Ensure that the original lock no longer owns the lock // after giving it to a reverse one. lock.lock(); BOOST_CHECK(lock.owns_lock()); { reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock); BOOST_CHECK(!lock.owns_lock()); } BOOST_CHECK(failed); BOOST_CHECK(lock.owns_lock()); } BOOST_AUTO_TEST_SUITE_END()
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01 TITLE D:\Projects\TaintAnalysis\AntiTaint\Epilog\src\func-alloca.c .686P .XMM include listing.inc .model flat INCLUDELIB MSVCRT INCLUDELIB OLDNAMES _DATA SEGMENT $SG3709 DB '%d', 00H _DATA ENDS PUBLIC _func EXTRN __imp__printf:PROC EXTRN __imp__gets:PROC EXTRN __imp__scanf:PROC EXTRN __alloca_probe_16:PROC ; Function compile flags: /Odtpy ; File d:\projects\taintanalysis\antitaint\epilog\src\func-alloca.c _TEXT SEGMENT tv68 = -12 ; size = 4 _sz$ = -8 ; size = 4 _buf$ = -4 ; size = 4 _func PROC ; 10 : { push ebp mov ebp, esp sub esp, 12 ; 0000000cH ; 11 : int sz; ; 12 : char *buf; ; 13 : scanf("%d", &sz); lea eax, DWORD PTR _sz$[ebp] push eax push OFFSET $SG3709 call DWORD PTR __imp__scanf add esp, 8 ; 14 : buf = (char*)alloca(sz); mov eax, DWORD PTR _sz$[ebp] call __alloca_probe_16 mov DWORD PTR tv68[ebp], esp mov ecx, DWORD PTR tv68[ebp] mov DWORD PTR _buf$[ebp], ecx ; 15 : gets(buf); mov edx, DWORD PTR _buf$[ebp] push edx call DWORD PTR __imp__gets add esp, 4 ; 16 : printf(buf); mov eax, DWORD PTR _buf$[ebp] push eax call DWORD PTR __imp__printf add esp, 4 ; 17 : } lea esp, DWORD PTR [ebp-12] mov esp, ebp pop ebp ret 0 _func ENDP _TEXT ENDS PUBLIC _main ; Function compile flags: /Odtpy _TEXT SEGMENT _main PROC ; 20 : { push ebp mov ebp, esp ; 21 : func(); call _func ; 22 : return 0; xor eax, eax ; 23 : } pop ebp ret 0 _main ENDP _TEXT ENDS END
.data .text ld $0 10 ld $1 20 push $0 move $1 $0 pop $1 ld $v0 2 syscall
; A047560: Numbers that are congruent to {0, 2, 3, 6, 7} mod 8. ; 0,2,3,6,7,8,10,11,14,15,16,18,19,22,23,24,26,27,30,31,32,34,35,38,39,40,42,43,46,47,48,50,51,54,55,56,58,59,62,63,64,66,67,70,71,72,74,75,78,79,80,82,83,86,87,88,90,91,94,95,96,98,99,102,103,104,106,107,110,111,112,114,115,118,119,120,122,123,126,127,128,130,131,134,135,136,138,139,142,143,144,146,147,150,151,152,154,155,158,159,160,162,163,166,167,168,170,171,174,175,176,178,179,182,183,184,186,187,190,191,192,194,195,198,199,200,202,203,206,207,208,210,211,214,215,216,218,219,222,223,224,226,227,230,231,232,234,235,238,239,240,242,243,246,247,248,250,251,254,255,256,258,259,262,263,264,266,267,270,271,272,274,275,278,279,280,282,283,286,287,288,290,291,294,295,296,298,299,302,303,304,306,307,310,311,312,314,315,318,319,320,322,323,326,327,328,330,331,334,335,336,338,339,342,343,344,346,347,350,351,352,354,355,358,359,360,362,363,366,367,368,370,371,374,375,376,378,379,382,383,384,386,387,390,391,392,394,395,398,399 mov $1,$0 mov $2,1 mov $4,1 lpb $0,1 add $1,$2 mov $3,3 sub $3,$2 mov $2,$3 add $3,$1 mov $0,$3 add $4,4 trn $0,$4 lpe
db "GRIPPER@" ; species name db "This feared" next "#MON is said to" next "travel to unknown" page "worlds. Some think" next "that it takes lost" next "spirits with it.@"
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r15 push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x446e, %rsi lea addresses_normal_ht+0x1b8fe, %rdi clflush (%rsi) nop nop nop nop xor %rdx, %rdx mov $117, %rcx rep movsw nop nop nop nop xor %r10, %r10 lea addresses_WT_ht+0x1d8e, %rsi lea addresses_WC_ht+0x97ee, %rdi nop nop xor $16905, %r10 mov $35, %rcx rep movsb nop nop nop nop and $37536, %rdx lea addresses_D_ht+0x1d1ee, %r11 clflush (%r11) nop nop sub $5696, %rdi movups (%r11), %xmm0 vpextrq $1, %xmm0, %rdx nop nop and %r11, %r11 lea addresses_D_ht+0x141da, %rdi and $54007, %r15 mov (%rdi), %cx nop nop nop nop add $55025, %rsi lea addresses_A_ht+0x1ec6e, %r11 nop nop xor $7589, %r15 mov (%r11), %r10d nop nop nop nop nop and %r11, %r11 lea addresses_normal_ht+0xe562, %r10 nop nop xor $53729, %r15 movups (%r10), %xmm3 vpextrq $0, %xmm3, %rdi xor $59115, %rsi lea addresses_WC_ht+0x15d0e, %rdi nop nop dec %rdx movl $0x61626364, (%rdi) nop sub %rcx, %rcx lea addresses_normal_ht+0x12b0b, %rsi lea addresses_D_ht+0x18c6e, %rdi nop nop nop dec %r14 mov $24, %rcx rep movsl nop nop nop nop nop inc %rsi lea addresses_A_ht+0x1e56e, %r14 nop xor $14520, %rsi movw $0x6162, (%r14) nop nop nop nop nop xor %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r15 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r15 push %rcx push %rdx // Faulty Load lea addresses_US+0x546e, %r15 nop nop nop nop nop cmp $65218, %r13 mov (%r15), %dx lea oracles, %r15 and $0xff, %rdx shlq $12, %rdx mov (%r15,%rdx,1), %rdx pop %rdx pop %rcx pop %r15 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}} {'src': {'same': True, 'congruent': 7, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}} {'00': 75} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
//swap: funcdecl , , swap:// Words: 0 addi $sp, 6 // Words: 1 move $sp, $rr // Words: 2 addi $0, -1 // Words: 3 swn $ra, $sp, $rr // Words: 4 addi $rr, -1 // Words: 5 swn $s0, $sp, $rr // Words: 6 addi $rr, -1 // Words: 7 swn $s1, $sp, $rr //: formal a, , // Words: 8 addi $0, -4 // Words: 9 swn $a0, $sp, $rr //: formal b, , // Words: 10 addi $0, -5 // Words: 11 swn $a1, $sp, $rr //: load *tmp, , a // Words: 12 // Words: 13 ldi $k0, -4 // Words: 14 lwn $t0, $sp, $k0 //: u* *tmp, , *tmp // Words: 15 lwn $t0, $0, $t0 //: store tmp, , *tmp // Words: 16 // Words: 17 ldi $k0, -6 // Words: 18 swn $t0, $sp, $k0 //: load *tmp, , b // Words: 19 // Words: 20 ldi $k0, -5 // Words: 21 lwn $t0, $sp, $k0 //: u* *tmp, , *tmp // Words: 22 lwn $t0, $0, $t0 //: load *tmp2, , a // Words: 23 // Words: 24 ldi $k0, -4 // Words: 25 lwn $t1, $sp, $k0 //: storeadd *tmp, , *tmp2 // Words: 26 swn $t0, $0, $t1 //: move *tmp, , *tmp // Words: 27 move $t0, $t0 //: load *tmp, , tmp // Words: 28 // Words: 29 ldi $k0, -6 // Words: 30 lwn $t0, $sp, $k0 //: load *tmp2, , b // Words: 31 // Words: 32 ldi $k0, -5 // Words: 33 lwn $t1, $sp, $k0 //: storeadd *tmp, , *tmp2 // Words: 34 swn $t0, $0, $t1 //: move *tmp, , *tmp // Words: 35 move $t0, $t0 //: funcend , , // Words: 36 addi $0, -1 // Words: 37 lwn $ra, $sp, $rr // Words: 38 addi $rr, -1 // Words: 39 lwn $s0, $sp, $rr // Words: 40 addi $rr, -1 // Words: 41 lwn $s1, $sp, $rr // Words: 42 addi $sp -6 // Words: 43 move $sp, $rr // Words: 44 jr $ra //main: funcdecl , , main:// Words: 45 addi $sp, 5 move $sp, $rr addi $0, -1 swn $ra, $sp, $rr addi $rr, -1 swn $s0, $sp, $rr addi $rr, -1 swn $s1, $sp, $rr //: loadi *tmp, , 5 // Words: 53 // Words: 54 ldi $t0, 5 //: store x, , *tmp // Words: 55 // Words: 56 ldi $k0, -4 // Words: 57 swn $t0, $sp, $k0 //: loadi *tmp, , 10 // Words: 58 // Words: 59 ldi $t0, 10 //: store y, , *tmp // Words: 60 // Words: 61 ldi $k0, -5 // Words: 62 swn $t0, $sp, $k0 //: u& *tmp, , x // Words: 63 addi $sp, -4 // Words: 64 move $t0, $rr //: param *tmp, , // Words: 65 move $a0, $t0 //: u& *tmp, , y // Words: 66 addi $sp, -5 // Words: 67 move $t0, $rr //: param *tmp, , // Words: 68 move $a1, $t0 //: funccall , , swap // Words: 69 jal swap //: assembly wp $s0, 0, , // Words: 70 // Words: 71 ldi $k0, -4 // Words: 72 lwn $s0, $sp, $k0 // Words: 73 wp $s0, 0 //: loadi *tmp, , 0 // Words: 74 // Words: 75 ldi $t0, 0 //: jr , *tmp, // Words: 76 move $v, $t0 // Words: 77 addi $0, -1 // Words: 78 lwn $ra, $sp, $rr // Words: 79 addi $rr, -1 // Words: 80 lwn $s0, $sp, $rr // Words: 81 addi $rr, -1 // Words: 82 lwn $s1, $sp, $rr // Words: 83 addi $sp -5 // Words: 84 move $sp, $rr // Words: 85 jr $ra
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WC_ht+0xc938, %r10 nop nop xor $54036, %r12 vmovups (%r10), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r9 add $13157, %rax lea addresses_D_ht+0xcb58, %rsi lea addresses_A_ht+0xc104, %rdi clflush (%rsi) dec %r13 mov $40, %rcx rep movsb nop nop nop inc %rdi lea addresses_WC_ht+0x1ce5f, %rsi lea addresses_D_ht+0x1cb58, %rdi nop and %r9, %r9 mov $110, %rcx rep movsw nop nop nop nop nop inc %r12 lea addresses_UC_ht+0x3f58, %rsi lea addresses_WT_ht+0xc58, %rdi nop nop nop nop nop dec %r13 mov $43, %rcx rep movsb nop nop nop nop inc %r10 lea addresses_D_ht+0x14598, %r10 nop nop nop inc %rcx movw $0x6162, (%r10) nop nop nop nop xor $41868, %r12 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %rbp push %rbx push %rdx // Faulty Load lea addresses_US+0x17f58, %r12 nop nop add $31635, %rdx vmovups (%r12), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %rbx lea oracles, %rbp and $0xff, %rbx shlq $12, %rbx mov (%rbp,%rbx,1), %rbx pop %rdx pop %rbx pop %rbp pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}} {'00': 116} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Copyright 2022 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "mojo_service_manager/daemon/mojo_error_util.h" #include <string> #include <utility> namespace chromeos { namespace mojo_service_manager { class NullInterface {}; void ResetMojoReceiverPipeWithReason( mojo::ScopedMessagePipeHandle receiver_pipe, mojom::ErrorCode error, const std::string& message) { // The pipe can be casted to a receiver with an arbitrary interface type, // because we don't actually use the interface. mojo::PendingReceiver<NullInterface> receiver{std::move(receiver_pipe)}; receiver.ResetWithReason(static_cast<uint32_t>(error), message); } } // namespace mojo_service_manager } // namespace chromeos
STACK SEGMENT USE16 STACK DB 200 DUP(0) STACK ENDS DATA SEGMENT USE16 BUF1 DB 0,1,2,3,4,5,6,7,8,9 BUF2 DB 10 DUP(0) BUF3 DB 10 DUP(0) BUF4 DB 10 DUP(0) DATA ENDS CODE SEGMENT USE16 ASSUME CS:CODE,DS:DATA,SS:STACK START: MOV AX,DATA MOV DS,AX MOV SI,OFFSET BUF1 MOV DI,OFFSET BUF1 MOV BX,OFFSET BUF1 MOV BP,OFFSET BUF1 MOV CX,10 LOPA: MOV AL,[SI] MOV [DI],AL INC AL MOV [BX],AL ADD AL,3 MOV DS:[BP],AL INC SI INC DI INC BP INC BX DEC CX JNZ LOPA MOV AH,4CH INT 21H CODE ENDS END START
; This is a comment MOV NF #1 MOV AX #3 MOV BX #'H' INT MOV BX #'E' INT MOV BX #'L' INT MOV BX #'L' INT MOV BX #'O' INT MOV BX #'_' INT MOV BX #'A' INT MOV BX #'S' INT MOV BX #'S' INT MOV BX #'E' INT MOV BX #'M' INT MOV BX #'B' INT MOV BX #'L' INT MOV BX #'E' INT MOV BX #'R' INT
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/apigateway/model/DeleteUsagePlanKeyRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::APIGateway::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; DeleteUsagePlanKeyRequest::DeleteUsagePlanKeyRequest() : m_usagePlanIdHasBeenSet(false), m_keyIdHasBeenSet(false) { } Aws::String DeleteUsagePlanKeyRequest::SerializePayload() const { return {}; }
// Time: O(n) // Space: O(n) class Solution { public: int distributeCandies(vector<int>& candies) { unordered_set<int> lookup; for (const auto& candy: candies) { lookup.emplace(candy); } return min(lookup.size(), candies.size() / 2); } };
; A017209: a(n) = 9*n+4. ; 4,13,22,31,40,49,58,67,76,85,94,103,112,121,130,139,148,157,166,175,184,193,202,211,220,229,238,247,256,265,274,283,292,301,310,319,328,337,346,355,364,373,382,391,400,409,418,427,436,445,454,463,472,481,490,499,508,517,526,535,544,553,562,571,580,589,598,607,616,625,634,643,652,661,670,679,688,697,706,715,724,733,742,751,760,769,778,787,796,805,814,823,832,841,850,859,868,877,886,895 mul $0,9 add $0,4
db 0 ; species ID placeholder db 75, 91, 70, 97, 40, 80 ; hp atk def spd sat sdf db NORMAL, NORMAL ; type db 90 ; catch rate db 116 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 15 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/raticate/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_GROUND, EGG_GROUND ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, ROAR, TOXIC, ROCK_SMASH, DARK_PULSE, SUNNY_DAY, STONE_EDGE, SNORE, BLIZZARD, HYPER_BEAM, ICY_WIND, PROTECT, POISON_FANG, IRON_HEAD, THUNDER, EARTHQUAKE, RETURN, DIG, SHADOW_BALL, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SWIFT, PURSUIT, REST, ATTRACT, THIEF, CUT, STRENGTH, THUNDERBOLT, ICE_BEAM ; end
<% from pwnlib.shellcraft.mips.linux import syscall %> <%page args="path"/> <%docstring> Invokes the syscall chroot. See 'man 2 chroot' for more information. Arguments: path(char): path </%docstring> ${syscall('SYS_chroot', path)}
; --------------------------------------------------------------------------- ; Animation script - springs ; --------------------------------------------------------------------------- Ani_Spring: dc.w byte_DD02-Ani_Spring dc.w byte_DD0E-Ani_Spring byte_DD02: dc.b 0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, afRoutine byte_DD0E: dc.b 0, 4, 3, 3, 5, 5, 5, 5, 5, 5, 3, afRoutine even
_stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 81 ec 30 02 00 00 sub $0x230,%esp int fd, i; char path[] = "stressfs0"; c: c7 84 24 1e 02 00 00 movl $0x65727473,0x21e(%esp) 13: 73 74 72 65 17: c7 84 24 22 02 00 00 movl $0x73667373,0x222(%esp) 1e: 73 73 66 73 22: 66 c7 84 24 26 02 00 movw $0x30,0x226(%esp) 29: 00 30 00 char data[512]; printf(1, "stressfs starting\n"); 2c: c7 44 24 04 63 09 00 movl $0x963,0x4(%esp) 33: 00 34: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b: e8 5f 05 00 00 call 59f <printf> memset(data, 'a', sizeof(data)); 40: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 47: 00 48: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) 4f: 00 50: 8d 44 24 1e lea 0x1e(%esp),%eax 54: 89 04 24 mov %eax,(%esp) 57: e8 17 02 00 00 call 273 <memset> for(i = 0; i < 4; i++) 5c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 63: 00 00 00 00 67: eb 11 jmp 7a <main+0x7a> if(fork() > 0) 69: e8 a2 03 00 00 call 410 <fork> 6e: 85 c0 test %eax,%eax 70: 7f 14 jg 86 <main+0x86> char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); for(i = 0; i < 4; i++) 72: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 79: 01 7a: 83 bc 24 2c 02 00 00 cmpl $0x3,0x22c(%esp) 81: 03 82: 7e e5 jle 69 <main+0x69> 84: eb 01 jmp 87 <main+0x87> if(fork() > 0) break; 86: 90 nop printf(1, "write %d\n", i); 87: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax 8e: 89 44 24 08 mov %eax,0x8(%esp) 92: c7 44 24 04 76 09 00 movl $0x976,0x4(%esp) 99: 00 9a: c7 04 24 01 00 00 00 movl $0x1,(%esp) a1: e8 f9 04 00 00 call 59f <printf> path[8] += i; a6: 0f b6 84 24 26 02 00 movzbl 0x226(%esp),%eax ad: 00 ae: 89 c2 mov %eax,%edx b0: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax b7: 01 d0 add %edx,%eax b9: 88 84 24 26 02 00 00 mov %al,0x226(%esp) fd = open(path, O_CREATE | O_RDWR); c0: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) c7: 00 c8: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax cf: 89 04 24 mov %eax,(%esp) d2: e8 81 03 00 00 call 458 <open> d7: 89 84 24 28 02 00 00 mov %eax,0x228(%esp) for(i = 0; i < 20; i++) de: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) e5: 00 00 00 00 e9: eb 27 jmp 112 <main+0x112> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); eb: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) f2: 00 f3: 8d 44 24 1e lea 0x1e(%esp),%eax f7: 89 44 24 04 mov %eax,0x4(%esp) fb: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 102: 89 04 24 mov %eax,(%esp) 105: e8 2e 03 00 00 call 438 <write> printf(1, "write %d\n", i); path[8] += i; fd = open(path, O_CREATE | O_RDWR); for(i = 0; i < 20; i++) 10a: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 111: 01 112: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp) 119: 13 11a: 7e cf jle eb <main+0xeb> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); close(fd); 11c: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 123: 89 04 24 mov %eax,(%esp) 126: e8 15 03 00 00 call 440 <close> printf(1, "read\n"); 12b: c7 44 24 04 80 09 00 movl $0x980,0x4(%esp) 132: 00 133: c7 04 24 01 00 00 00 movl $0x1,(%esp) 13a: e8 60 04 00 00 call 59f <printf> fd = open(path, O_RDONLY); 13f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 146: 00 147: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax 14e: 89 04 24 mov %eax,(%esp) 151: e8 02 03 00 00 call 458 <open> 156: 89 84 24 28 02 00 00 mov %eax,0x228(%esp) for (i = 0; i < 20; i++) 15d: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 164: 00 00 00 00 168: eb 27 jmp 191 <main+0x191> read(fd, data, sizeof(data)); 16a: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 171: 00 172: 8d 44 24 1e lea 0x1e(%esp),%eax 176: 89 44 24 04 mov %eax,0x4(%esp) 17a: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 181: 89 04 24 mov %eax,(%esp) 184: e8 a7 02 00 00 call 430 <read> close(fd); printf(1, "read\n"); fd = open(path, O_RDONLY); for (i = 0; i < 20; i++) 189: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 190: 01 191: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp) 198: 13 199: 7e cf jle 16a <main+0x16a> read(fd, data, sizeof(data)); close(fd); 19b: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 1a2: 89 04 24 mov %eax,(%esp) 1a5: e8 96 02 00 00 call 440 <close> wait(); 1aa: e8 71 02 00 00 call 420 <wait> exit(); 1af: e8 64 02 00 00 call 418 <exit> 000001b4 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1b4: 55 push %ebp 1b5: 89 e5 mov %esp,%ebp 1b7: 57 push %edi 1b8: 53 push %ebx asm volatile("cld; rep stosb" : 1b9: 8b 4d 08 mov 0x8(%ebp),%ecx 1bc: 8b 55 10 mov 0x10(%ebp),%edx 1bf: 8b 45 0c mov 0xc(%ebp),%eax 1c2: 89 cb mov %ecx,%ebx 1c4: 89 df mov %ebx,%edi 1c6: 89 d1 mov %edx,%ecx 1c8: fc cld 1c9: f3 aa rep stos %al,%es:(%edi) 1cb: 89 ca mov %ecx,%edx 1cd: 89 fb mov %edi,%ebx 1cf: 89 5d 08 mov %ebx,0x8(%ebp) 1d2: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 1d5: 5b pop %ebx 1d6: 5f pop %edi 1d7: 5d pop %ebp 1d8: c3 ret 000001d9 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1d9: 55 push %ebp 1da: 89 e5 mov %esp,%ebp 1dc: 83 ec 10 sub $0x10,%esp char *os; os = s; 1df: 8b 45 08 mov 0x8(%ebp),%eax 1e2: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 1e5: 90 nop 1e6: 8b 45 0c mov 0xc(%ebp),%eax 1e9: 0f b6 10 movzbl (%eax),%edx 1ec: 8b 45 08 mov 0x8(%ebp),%eax 1ef: 88 10 mov %dl,(%eax) 1f1: 8b 45 08 mov 0x8(%ebp),%eax 1f4: 0f b6 00 movzbl (%eax),%eax 1f7: 84 c0 test %al,%al 1f9: 0f 95 c0 setne %al 1fc: 83 45 08 01 addl $0x1,0x8(%ebp) 200: 83 45 0c 01 addl $0x1,0xc(%ebp) 204: 84 c0 test %al,%al 206: 75 de jne 1e6 <strcpy+0xd> ; return os; 208: 8b 45 fc mov -0x4(%ebp),%eax } 20b: c9 leave 20c: c3 ret 0000020d <strcmp>: int strcmp(const char *p, const char *q) { 20d: 55 push %ebp 20e: 89 e5 mov %esp,%ebp while(*p && *p == *q) 210: eb 08 jmp 21a <strcmp+0xd> p++, q++; 212: 83 45 08 01 addl $0x1,0x8(%ebp) 216: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 21a: 8b 45 08 mov 0x8(%ebp),%eax 21d: 0f b6 00 movzbl (%eax),%eax 220: 84 c0 test %al,%al 222: 74 10 je 234 <strcmp+0x27> 224: 8b 45 08 mov 0x8(%ebp),%eax 227: 0f b6 10 movzbl (%eax),%edx 22a: 8b 45 0c mov 0xc(%ebp),%eax 22d: 0f b6 00 movzbl (%eax),%eax 230: 38 c2 cmp %al,%dl 232: 74 de je 212 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 234: 8b 45 08 mov 0x8(%ebp),%eax 237: 0f b6 00 movzbl (%eax),%eax 23a: 0f b6 d0 movzbl %al,%edx 23d: 8b 45 0c mov 0xc(%ebp),%eax 240: 0f b6 00 movzbl (%eax),%eax 243: 0f b6 c0 movzbl %al,%eax 246: 89 d1 mov %edx,%ecx 248: 29 c1 sub %eax,%ecx 24a: 89 c8 mov %ecx,%eax } 24c: 5d pop %ebp 24d: c3 ret 0000024e <strlen>: uint strlen(char *s) { 24e: 55 push %ebp 24f: 89 e5 mov %esp,%ebp 251: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 254: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 25b: eb 04 jmp 261 <strlen+0x13> 25d: 83 45 fc 01 addl $0x1,-0x4(%ebp) 261: 8b 45 fc mov -0x4(%ebp),%eax 264: 03 45 08 add 0x8(%ebp),%eax 267: 0f b6 00 movzbl (%eax),%eax 26a: 84 c0 test %al,%al 26c: 75 ef jne 25d <strlen+0xf> ; return n; 26e: 8b 45 fc mov -0x4(%ebp),%eax } 271: c9 leave 272: c3 ret 00000273 <memset>: void* memset(void *dst, int c, uint n) { 273: 55 push %ebp 274: 89 e5 mov %esp,%ebp 276: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 279: 8b 45 10 mov 0x10(%ebp),%eax 27c: 89 44 24 08 mov %eax,0x8(%esp) 280: 8b 45 0c mov 0xc(%ebp),%eax 283: 89 44 24 04 mov %eax,0x4(%esp) 287: 8b 45 08 mov 0x8(%ebp),%eax 28a: 89 04 24 mov %eax,(%esp) 28d: e8 22 ff ff ff call 1b4 <stosb> return dst; 292: 8b 45 08 mov 0x8(%ebp),%eax } 295: c9 leave 296: c3 ret 00000297 <strchr>: char* strchr(const char *s, char c) { 297: 55 push %ebp 298: 89 e5 mov %esp,%ebp 29a: 83 ec 04 sub $0x4,%esp 29d: 8b 45 0c mov 0xc(%ebp),%eax 2a0: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 2a3: eb 14 jmp 2b9 <strchr+0x22> if(*s == c) 2a5: 8b 45 08 mov 0x8(%ebp),%eax 2a8: 0f b6 00 movzbl (%eax),%eax 2ab: 3a 45 fc cmp -0x4(%ebp),%al 2ae: 75 05 jne 2b5 <strchr+0x1e> return (char*)s; 2b0: 8b 45 08 mov 0x8(%ebp),%eax 2b3: eb 13 jmp 2c8 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 2b5: 83 45 08 01 addl $0x1,0x8(%ebp) 2b9: 8b 45 08 mov 0x8(%ebp),%eax 2bc: 0f b6 00 movzbl (%eax),%eax 2bf: 84 c0 test %al,%al 2c1: 75 e2 jne 2a5 <strchr+0xe> if(*s == c) return (char*)s; return 0; 2c3: b8 00 00 00 00 mov $0x0,%eax } 2c8: c9 leave 2c9: c3 ret 000002ca <gets>: char* gets(char *buf, int max) { 2ca: 55 push %ebp 2cb: 89 e5 mov %esp,%ebp 2cd: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 2d0: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2d7: eb 44 jmp 31d <gets+0x53> cc = read(0, &c, 1); 2d9: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2e0: 00 2e1: 8d 45 ef lea -0x11(%ebp),%eax 2e4: 89 44 24 04 mov %eax,0x4(%esp) 2e8: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2ef: e8 3c 01 00 00 call 430 <read> 2f4: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 2f7: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2fb: 7e 2d jle 32a <gets+0x60> break; buf[i++] = c; 2fd: 8b 45 f4 mov -0xc(%ebp),%eax 300: 03 45 08 add 0x8(%ebp),%eax 303: 0f b6 55 ef movzbl -0x11(%ebp),%edx 307: 88 10 mov %dl,(%eax) 309: 83 45 f4 01 addl $0x1,-0xc(%ebp) if(c == '\n' || c == '\r') 30d: 0f b6 45 ef movzbl -0x11(%ebp),%eax 311: 3c 0a cmp $0xa,%al 313: 74 16 je 32b <gets+0x61> 315: 0f b6 45 ef movzbl -0x11(%ebp),%eax 319: 3c 0d cmp $0xd,%al 31b: 74 0e je 32b <gets+0x61> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 31d: 8b 45 f4 mov -0xc(%ebp),%eax 320: 83 c0 01 add $0x1,%eax 323: 3b 45 0c cmp 0xc(%ebp),%eax 326: 7c b1 jl 2d9 <gets+0xf> 328: eb 01 jmp 32b <gets+0x61> cc = read(0, &c, 1); if(cc < 1) break; 32a: 90 nop buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 32b: 8b 45 f4 mov -0xc(%ebp),%eax 32e: 03 45 08 add 0x8(%ebp),%eax 331: c6 00 00 movb $0x0,(%eax) return buf; 334: 8b 45 08 mov 0x8(%ebp),%eax } 337: c9 leave 338: c3 ret 00000339 <stat>: int stat(char *n, struct stat *st) { 339: 55 push %ebp 33a: 89 e5 mov %esp,%ebp 33c: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 33f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 346: 00 347: 8b 45 08 mov 0x8(%ebp),%eax 34a: 89 04 24 mov %eax,(%esp) 34d: e8 06 01 00 00 call 458 <open> 352: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 355: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 359: 79 07 jns 362 <stat+0x29> return -1; 35b: b8 ff ff ff ff mov $0xffffffff,%eax 360: eb 23 jmp 385 <stat+0x4c> r = fstat(fd, st); 362: 8b 45 0c mov 0xc(%ebp),%eax 365: 89 44 24 04 mov %eax,0x4(%esp) 369: 8b 45 f4 mov -0xc(%ebp),%eax 36c: 89 04 24 mov %eax,(%esp) 36f: e8 fc 00 00 00 call 470 <fstat> 374: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 377: 8b 45 f4 mov -0xc(%ebp),%eax 37a: 89 04 24 mov %eax,(%esp) 37d: e8 be 00 00 00 call 440 <close> return r; 382: 8b 45 f0 mov -0x10(%ebp),%eax } 385: c9 leave 386: c3 ret 00000387 <atoi>: int atoi(const char *s) { 387: 55 push %ebp 388: 89 e5 mov %esp,%ebp 38a: 83 ec 10 sub $0x10,%esp int n; n = 0; 38d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 394: eb 23 jmp 3b9 <atoi+0x32> n = n*10 + *s++ - '0'; 396: 8b 55 fc mov -0x4(%ebp),%edx 399: 89 d0 mov %edx,%eax 39b: c1 e0 02 shl $0x2,%eax 39e: 01 d0 add %edx,%eax 3a0: 01 c0 add %eax,%eax 3a2: 89 c2 mov %eax,%edx 3a4: 8b 45 08 mov 0x8(%ebp),%eax 3a7: 0f b6 00 movzbl (%eax),%eax 3aa: 0f be c0 movsbl %al,%eax 3ad: 01 d0 add %edx,%eax 3af: 83 e8 30 sub $0x30,%eax 3b2: 89 45 fc mov %eax,-0x4(%ebp) 3b5: 83 45 08 01 addl $0x1,0x8(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3b9: 8b 45 08 mov 0x8(%ebp),%eax 3bc: 0f b6 00 movzbl (%eax),%eax 3bf: 3c 2f cmp $0x2f,%al 3c1: 7e 0a jle 3cd <atoi+0x46> 3c3: 8b 45 08 mov 0x8(%ebp),%eax 3c6: 0f b6 00 movzbl (%eax),%eax 3c9: 3c 39 cmp $0x39,%al 3cb: 7e c9 jle 396 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3cd: 8b 45 fc mov -0x4(%ebp),%eax } 3d0: c9 leave 3d1: c3 ret 000003d2 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3d2: 55 push %ebp 3d3: 89 e5 mov %esp,%ebp 3d5: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 3d8: 8b 45 08 mov 0x8(%ebp),%eax 3db: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 3de: 8b 45 0c mov 0xc(%ebp),%eax 3e1: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 3e4: eb 13 jmp 3f9 <memmove+0x27> *dst++ = *src++; 3e6: 8b 45 f8 mov -0x8(%ebp),%eax 3e9: 0f b6 10 movzbl (%eax),%edx 3ec: 8b 45 fc mov -0x4(%ebp),%eax 3ef: 88 10 mov %dl,(%eax) 3f1: 83 45 fc 01 addl $0x1,-0x4(%ebp) 3f5: 83 45 f8 01 addl $0x1,-0x8(%ebp) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 3f9: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 3fd: 0f 9f c0 setg %al 400: 83 6d 10 01 subl $0x1,0x10(%ebp) 404: 84 c0 test %al,%al 406: 75 de jne 3e6 <memmove+0x14> *dst++ = *src++; return vdst; 408: 8b 45 08 mov 0x8(%ebp),%eax } 40b: c9 leave 40c: c3 ret 40d: 90 nop 40e: 90 nop 40f: 90 nop 00000410 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 410: b8 01 00 00 00 mov $0x1,%eax 415: cd 40 int $0x40 417: c3 ret 00000418 <exit>: SYSCALL(exit) 418: b8 02 00 00 00 mov $0x2,%eax 41d: cd 40 int $0x40 41f: c3 ret 00000420 <wait>: SYSCALL(wait) 420: b8 03 00 00 00 mov $0x3,%eax 425: cd 40 int $0x40 427: c3 ret 00000428 <pipe>: SYSCALL(pipe) 428: b8 04 00 00 00 mov $0x4,%eax 42d: cd 40 int $0x40 42f: c3 ret 00000430 <read>: SYSCALL(read) 430: b8 05 00 00 00 mov $0x5,%eax 435: cd 40 int $0x40 437: c3 ret 00000438 <write>: SYSCALL(write) 438: b8 12 00 00 00 mov $0x12,%eax 43d: cd 40 int $0x40 43f: c3 ret 00000440 <close>: SYSCALL(close) 440: b8 17 00 00 00 mov $0x17,%eax 445: cd 40 int $0x40 447: c3 ret 00000448 <kill>: SYSCALL(kill) 448: b8 06 00 00 00 mov $0x6,%eax 44d: cd 40 int $0x40 44f: c3 ret 00000450 <exec>: SYSCALL(exec) 450: b8 07 00 00 00 mov $0x7,%eax 455: cd 40 int $0x40 457: c3 ret 00000458 <open>: SYSCALL(open) 458: b8 11 00 00 00 mov $0x11,%eax 45d: cd 40 int $0x40 45f: c3 ret 00000460 <mknod>: SYSCALL(mknod) 460: b8 13 00 00 00 mov $0x13,%eax 465: cd 40 int $0x40 467: c3 ret 00000468 <unlink>: SYSCALL(unlink) 468: b8 14 00 00 00 mov $0x14,%eax 46d: cd 40 int $0x40 46f: c3 ret 00000470 <fstat>: SYSCALL(fstat) 470: b8 08 00 00 00 mov $0x8,%eax 475: cd 40 int $0x40 477: c3 ret 00000478 <link>: SYSCALL(link) 478: b8 15 00 00 00 mov $0x15,%eax 47d: cd 40 int $0x40 47f: c3 ret 00000480 <mkdir>: SYSCALL(mkdir) 480: b8 16 00 00 00 mov $0x16,%eax 485: cd 40 int $0x40 487: c3 ret 00000488 <chdir>: SYSCALL(chdir) 488: b8 09 00 00 00 mov $0x9,%eax 48d: cd 40 int $0x40 48f: c3 ret 00000490 <dup>: SYSCALL(dup) 490: b8 0a 00 00 00 mov $0xa,%eax 495: cd 40 int $0x40 497: c3 ret 00000498 <getpid>: SYSCALL(getpid) 498: b8 0b 00 00 00 mov $0xb,%eax 49d: cd 40 int $0x40 49f: c3 ret 000004a0 <sbrk>: SYSCALL(sbrk) 4a0: b8 0c 00 00 00 mov $0xc,%eax 4a5: cd 40 int $0x40 4a7: c3 ret 000004a8 <sleep>: SYSCALL(sleep) 4a8: b8 0d 00 00 00 mov $0xd,%eax 4ad: cd 40 int $0x40 4af: c3 ret 000004b0 <uptime>: SYSCALL(uptime) 4b0: b8 0e 00 00 00 mov $0xe,%eax 4b5: cd 40 int $0x40 4b7: c3 ret 000004b8 <procstat>: # Modificado declaramos una nueva llamada al sistema SYSCALL(procstat) 4b8: b8 0f 00 00 00 mov $0xf,%eax 4bd: cd 40 int $0x40 4bf: c3 ret 000004c0 <set_priority>: # Modificado declaramos una nueva llamada al sistema SYSCALL(set_priority) 4c0: b8 10 00 00 00 mov $0x10,%eax 4c5: cd 40 int $0x40 4c7: c3 ret 000004c8 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 4c8: 55 push %ebp 4c9: 89 e5 mov %esp,%ebp 4cb: 83 ec 28 sub $0x28,%esp 4ce: 8b 45 0c mov 0xc(%ebp),%eax 4d1: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 4d4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4db: 00 4dc: 8d 45 f4 lea -0xc(%ebp),%eax 4df: 89 44 24 04 mov %eax,0x4(%esp) 4e3: 8b 45 08 mov 0x8(%ebp),%eax 4e6: 89 04 24 mov %eax,(%esp) 4e9: e8 4a ff ff ff call 438 <write> } 4ee: c9 leave 4ef: c3 ret 000004f0 <printint>: static void printint(int fd, int xx, int base, int sgn) { 4f0: 55 push %ebp 4f1: 89 e5 mov %esp,%ebp 4f3: 83 ec 48 sub $0x48,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 4f6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 4fd: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 501: 74 17 je 51a <printint+0x2a> 503: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 507: 79 11 jns 51a <printint+0x2a> neg = 1; 509: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 510: 8b 45 0c mov 0xc(%ebp),%eax 513: f7 d8 neg %eax 515: 89 45 ec mov %eax,-0x14(%ebp) 518: eb 06 jmp 520 <printint+0x30> } else { x = xx; 51a: 8b 45 0c mov 0xc(%ebp),%eax 51d: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 520: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 527: 8b 4d 10 mov 0x10(%ebp),%ecx 52a: 8b 45 ec mov -0x14(%ebp),%eax 52d: ba 00 00 00 00 mov $0x0,%edx 532: f7 f1 div %ecx 534: 89 d0 mov %edx,%eax 536: 0f b6 90 cc 0b 00 00 movzbl 0xbcc(%eax),%edx 53d: 8d 45 dc lea -0x24(%ebp),%eax 540: 03 45 f4 add -0xc(%ebp),%eax 543: 88 10 mov %dl,(%eax) 545: 83 45 f4 01 addl $0x1,-0xc(%ebp) }while((x /= base) != 0); 549: 8b 55 10 mov 0x10(%ebp),%edx 54c: 89 55 d4 mov %edx,-0x2c(%ebp) 54f: 8b 45 ec mov -0x14(%ebp),%eax 552: ba 00 00 00 00 mov $0x0,%edx 557: f7 75 d4 divl -0x2c(%ebp) 55a: 89 45 ec mov %eax,-0x14(%ebp) 55d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 561: 75 c4 jne 527 <printint+0x37> if(neg) 563: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 567: 74 2a je 593 <printint+0xa3> buf[i++] = '-'; 569: 8d 45 dc lea -0x24(%ebp),%eax 56c: 03 45 f4 add -0xc(%ebp),%eax 56f: c6 00 2d movb $0x2d,(%eax) 572: 83 45 f4 01 addl $0x1,-0xc(%ebp) while(--i >= 0) 576: eb 1b jmp 593 <printint+0xa3> putc(fd, buf[i]); 578: 8d 45 dc lea -0x24(%ebp),%eax 57b: 03 45 f4 add -0xc(%ebp),%eax 57e: 0f b6 00 movzbl (%eax),%eax 581: 0f be c0 movsbl %al,%eax 584: 89 44 24 04 mov %eax,0x4(%esp) 588: 8b 45 08 mov 0x8(%ebp),%eax 58b: 89 04 24 mov %eax,(%esp) 58e: e8 35 ff ff ff call 4c8 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 593: 83 6d f4 01 subl $0x1,-0xc(%ebp) 597: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 59b: 79 db jns 578 <printint+0x88> putc(fd, buf[i]); } 59d: c9 leave 59e: c3 ret 0000059f <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 59f: 55 push %ebp 5a0: 89 e5 mov %esp,%ebp 5a2: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5a5: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 5ac: 8d 45 0c lea 0xc(%ebp),%eax 5af: 83 c0 04 add $0x4,%eax 5b2: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 5b5: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 5bc: e9 7d 01 00 00 jmp 73e <printf+0x19f> c = fmt[i] & 0xff; 5c1: 8b 55 0c mov 0xc(%ebp),%edx 5c4: 8b 45 f0 mov -0x10(%ebp),%eax 5c7: 01 d0 add %edx,%eax 5c9: 0f b6 00 movzbl (%eax),%eax 5cc: 0f be c0 movsbl %al,%eax 5cf: 25 ff 00 00 00 and $0xff,%eax 5d4: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 5d7: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 5db: 75 2c jne 609 <printf+0x6a> if(c == '%'){ 5dd: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 5e1: 75 0c jne 5ef <printf+0x50> state = '%'; 5e3: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 5ea: e9 4b 01 00 00 jmp 73a <printf+0x19b> } else { putc(fd, c); 5ef: 8b 45 e4 mov -0x1c(%ebp),%eax 5f2: 0f be c0 movsbl %al,%eax 5f5: 89 44 24 04 mov %eax,0x4(%esp) 5f9: 8b 45 08 mov 0x8(%ebp),%eax 5fc: 89 04 24 mov %eax,(%esp) 5ff: e8 c4 fe ff ff call 4c8 <putc> 604: e9 31 01 00 00 jmp 73a <printf+0x19b> } } else if(state == '%'){ 609: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 60d: 0f 85 27 01 00 00 jne 73a <printf+0x19b> if(c == 'd'){ 613: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 617: 75 2d jne 646 <printf+0xa7> printint(fd, *ap, 10, 1); 619: 8b 45 e8 mov -0x18(%ebp),%eax 61c: 8b 00 mov (%eax),%eax 61e: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 625: 00 626: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 62d: 00 62e: 89 44 24 04 mov %eax,0x4(%esp) 632: 8b 45 08 mov 0x8(%ebp),%eax 635: 89 04 24 mov %eax,(%esp) 638: e8 b3 fe ff ff call 4f0 <printint> ap++; 63d: 83 45 e8 04 addl $0x4,-0x18(%ebp) 641: e9 ed 00 00 00 jmp 733 <printf+0x194> } else if(c == 'x' || c == 'p'){ 646: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 64a: 74 06 je 652 <printf+0xb3> 64c: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 650: 75 2d jne 67f <printf+0xe0> printint(fd, *ap, 16, 0); 652: 8b 45 e8 mov -0x18(%ebp),%eax 655: 8b 00 mov (%eax),%eax 657: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 65e: 00 65f: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 666: 00 667: 89 44 24 04 mov %eax,0x4(%esp) 66b: 8b 45 08 mov 0x8(%ebp),%eax 66e: 89 04 24 mov %eax,(%esp) 671: e8 7a fe ff ff call 4f0 <printint> ap++; 676: 83 45 e8 04 addl $0x4,-0x18(%ebp) 67a: e9 b4 00 00 00 jmp 733 <printf+0x194> } else if(c == 's'){ 67f: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 683: 75 46 jne 6cb <printf+0x12c> s = (char*)*ap; 685: 8b 45 e8 mov -0x18(%ebp),%eax 688: 8b 00 mov (%eax),%eax 68a: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 68d: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 691: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 695: 75 27 jne 6be <printf+0x11f> s = "(null)"; 697: c7 45 f4 86 09 00 00 movl $0x986,-0xc(%ebp) while(*s != 0){ 69e: eb 1e jmp 6be <printf+0x11f> putc(fd, *s); 6a0: 8b 45 f4 mov -0xc(%ebp),%eax 6a3: 0f b6 00 movzbl (%eax),%eax 6a6: 0f be c0 movsbl %al,%eax 6a9: 89 44 24 04 mov %eax,0x4(%esp) 6ad: 8b 45 08 mov 0x8(%ebp),%eax 6b0: 89 04 24 mov %eax,(%esp) 6b3: e8 10 fe ff ff call 4c8 <putc> s++; 6b8: 83 45 f4 01 addl $0x1,-0xc(%ebp) 6bc: eb 01 jmp 6bf <printf+0x120> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6be: 90 nop 6bf: 8b 45 f4 mov -0xc(%ebp),%eax 6c2: 0f b6 00 movzbl (%eax),%eax 6c5: 84 c0 test %al,%al 6c7: 75 d7 jne 6a0 <printf+0x101> 6c9: eb 68 jmp 733 <printf+0x194> putc(fd, *s); s++; } } else if(c == 'c'){ 6cb: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 6cf: 75 1d jne 6ee <printf+0x14f> putc(fd, *ap); 6d1: 8b 45 e8 mov -0x18(%ebp),%eax 6d4: 8b 00 mov (%eax),%eax 6d6: 0f be c0 movsbl %al,%eax 6d9: 89 44 24 04 mov %eax,0x4(%esp) 6dd: 8b 45 08 mov 0x8(%ebp),%eax 6e0: 89 04 24 mov %eax,(%esp) 6e3: e8 e0 fd ff ff call 4c8 <putc> ap++; 6e8: 83 45 e8 04 addl $0x4,-0x18(%ebp) 6ec: eb 45 jmp 733 <printf+0x194> } else if(c == '%'){ 6ee: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 6f2: 75 17 jne 70b <printf+0x16c> putc(fd, c); 6f4: 8b 45 e4 mov -0x1c(%ebp),%eax 6f7: 0f be c0 movsbl %al,%eax 6fa: 89 44 24 04 mov %eax,0x4(%esp) 6fe: 8b 45 08 mov 0x8(%ebp),%eax 701: 89 04 24 mov %eax,(%esp) 704: e8 bf fd ff ff call 4c8 <putc> 709: eb 28 jmp 733 <printf+0x194> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 70b: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 712: 00 713: 8b 45 08 mov 0x8(%ebp),%eax 716: 89 04 24 mov %eax,(%esp) 719: e8 aa fd ff ff call 4c8 <putc> putc(fd, c); 71e: 8b 45 e4 mov -0x1c(%ebp),%eax 721: 0f be c0 movsbl %al,%eax 724: 89 44 24 04 mov %eax,0x4(%esp) 728: 8b 45 08 mov 0x8(%ebp),%eax 72b: 89 04 24 mov %eax,(%esp) 72e: e8 95 fd ff ff call 4c8 <putc> } state = 0; 733: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 73a: 83 45 f0 01 addl $0x1,-0x10(%ebp) 73e: 8b 55 0c mov 0xc(%ebp),%edx 741: 8b 45 f0 mov -0x10(%ebp),%eax 744: 01 d0 add %edx,%eax 746: 0f b6 00 movzbl (%eax),%eax 749: 84 c0 test %al,%al 74b: 0f 85 70 fe ff ff jne 5c1 <printf+0x22> putc(fd, c); } state = 0; } } } 751: c9 leave 752: c3 ret 753: 90 nop 00000754 <free>: static Header base; static Header *freep; void free(void *ap) { 754: 55 push %ebp 755: 89 e5 mov %esp,%ebp 757: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 75a: 8b 45 08 mov 0x8(%ebp),%eax 75d: 83 e8 08 sub $0x8,%eax 760: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 763: a1 e8 0b 00 00 mov 0xbe8,%eax 768: 89 45 fc mov %eax,-0x4(%ebp) 76b: eb 24 jmp 791 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 76d: 8b 45 fc mov -0x4(%ebp),%eax 770: 8b 00 mov (%eax),%eax 772: 3b 45 fc cmp -0x4(%ebp),%eax 775: 77 12 ja 789 <free+0x35> 777: 8b 45 f8 mov -0x8(%ebp),%eax 77a: 3b 45 fc cmp -0x4(%ebp),%eax 77d: 77 24 ja 7a3 <free+0x4f> 77f: 8b 45 fc mov -0x4(%ebp),%eax 782: 8b 00 mov (%eax),%eax 784: 3b 45 f8 cmp -0x8(%ebp),%eax 787: 77 1a ja 7a3 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 789: 8b 45 fc mov -0x4(%ebp),%eax 78c: 8b 00 mov (%eax),%eax 78e: 89 45 fc mov %eax,-0x4(%ebp) 791: 8b 45 f8 mov -0x8(%ebp),%eax 794: 3b 45 fc cmp -0x4(%ebp),%eax 797: 76 d4 jbe 76d <free+0x19> 799: 8b 45 fc mov -0x4(%ebp),%eax 79c: 8b 00 mov (%eax),%eax 79e: 3b 45 f8 cmp -0x8(%ebp),%eax 7a1: 76 ca jbe 76d <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7a3: 8b 45 f8 mov -0x8(%ebp),%eax 7a6: 8b 40 04 mov 0x4(%eax),%eax 7a9: c1 e0 03 shl $0x3,%eax 7ac: 89 c2 mov %eax,%edx 7ae: 03 55 f8 add -0x8(%ebp),%edx 7b1: 8b 45 fc mov -0x4(%ebp),%eax 7b4: 8b 00 mov (%eax),%eax 7b6: 39 c2 cmp %eax,%edx 7b8: 75 24 jne 7de <free+0x8a> bp->s.size += p->s.ptr->s.size; 7ba: 8b 45 f8 mov -0x8(%ebp),%eax 7bd: 8b 50 04 mov 0x4(%eax),%edx 7c0: 8b 45 fc mov -0x4(%ebp),%eax 7c3: 8b 00 mov (%eax),%eax 7c5: 8b 40 04 mov 0x4(%eax),%eax 7c8: 01 c2 add %eax,%edx 7ca: 8b 45 f8 mov -0x8(%ebp),%eax 7cd: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 7d0: 8b 45 fc mov -0x4(%ebp),%eax 7d3: 8b 00 mov (%eax),%eax 7d5: 8b 10 mov (%eax),%edx 7d7: 8b 45 f8 mov -0x8(%ebp),%eax 7da: 89 10 mov %edx,(%eax) 7dc: eb 0a jmp 7e8 <free+0x94> } else bp->s.ptr = p->s.ptr; 7de: 8b 45 fc mov -0x4(%ebp),%eax 7e1: 8b 10 mov (%eax),%edx 7e3: 8b 45 f8 mov -0x8(%ebp),%eax 7e6: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 7e8: 8b 45 fc mov -0x4(%ebp),%eax 7eb: 8b 40 04 mov 0x4(%eax),%eax 7ee: c1 e0 03 shl $0x3,%eax 7f1: 03 45 fc add -0x4(%ebp),%eax 7f4: 3b 45 f8 cmp -0x8(%ebp),%eax 7f7: 75 20 jne 819 <free+0xc5> p->s.size += bp->s.size; 7f9: 8b 45 fc mov -0x4(%ebp),%eax 7fc: 8b 50 04 mov 0x4(%eax),%edx 7ff: 8b 45 f8 mov -0x8(%ebp),%eax 802: 8b 40 04 mov 0x4(%eax),%eax 805: 01 c2 add %eax,%edx 807: 8b 45 fc mov -0x4(%ebp),%eax 80a: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 80d: 8b 45 f8 mov -0x8(%ebp),%eax 810: 8b 10 mov (%eax),%edx 812: 8b 45 fc mov -0x4(%ebp),%eax 815: 89 10 mov %edx,(%eax) 817: eb 08 jmp 821 <free+0xcd> } else p->s.ptr = bp; 819: 8b 45 fc mov -0x4(%ebp),%eax 81c: 8b 55 f8 mov -0x8(%ebp),%edx 81f: 89 10 mov %edx,(%eax) freep = p; 821: 8b 45 fc mov -0x4(%ebp),%eax 824: a3 e8 0b 00 00 mov %eax,0xbe8 } 829: c9 leave 82a: c3 ret 0000082b <morecore>: static Header* morecore(uint nu) { 82b: 55 push %ebp 82c: 89 e5 mov %esp,%ebp 82e: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 831: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 838: 77 07 ja 841 <morecore+0x16> nu = 4096; 83a: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 841: 8b 45 08 mov 0x8(%ebp),%eax 844: c1 e0 03 shl $0x3,%eax 847: 89 04 24 mov %eax,(%esp) 84a: e8 51 fc ff ff call 4a0 <sbrk> 84f: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 852: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 856: 75 07 jne 85f <morecore+0x34> return 0; 858: b8 00 00 00 00 mov $0x0,%eax 85d: eb 22 jmp 881 <morecore+0x56> hp = (Header*)p; 85f: 8b 45 f4 mov -0xc(%ebp),%eax 862: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 865: 8b 45 f0 mov -0x10(%ebp),%eax 868: 8b 55 08 mov 0x8(%ebp),%edx 86b: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 86e: 8b 45 f0 mov -0x10(%ebp),%eax 871: 83 c0 08 add $0x8,%eax 874: 89 04 24 mov %eax,(%esp) 877: e8 d8 fe ff ff call 754 <free> return freep; 87c: a1 e8 0b 00 00 mov 0xbe8,%eax } 881: c9 leave 882: c3 ret 00000883 <malloc>: void* malloc(uint nbytes) { 883: 55 push %ebp 884: 89 e5 mov %esp,%ebp 886: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 889: 8b 45 08 mov 0x8(%ebp),%eax 88c: 83 c0 07 add $0x7,%eax 88f: c1 e8 03 shr $0x3,%eax 892: 83 c0 01 add $0x1,%eax 895: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 898: a1 e8 0b 00 00 mov 0xbe8,%eax 89d: 89 45 f0 mov %eax,-0x10(%ebp) 8a0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8a4: 75 23 jne 8c9 <malloc+0x46> base.s.ptr = freep = prevp = &base; 8a6: c7 45 f0 e0 0b 00 00 movl $0xbe0,-0x10(%ebp) 8ad: 8b 45 f0 mov -0x10(%ebp),%eax 8b0: a3 e8 0b 00 00 mov %eax,0xbe8 8b5: a1 e8 0b 00 00 mov 0xbe8,%eax 8ba: a3 e0 0b 00 00 mov %eax,0xbe0 base.s.size = 0; 8bf: c7 05 e4 0b 00 00 00 movl $0x0,0xbe4 8c6: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8c9: 8b 45 f0 mov -0x10(%ebp),%eax 8cc: 8b 00 mov (%eax),%eax 8ce: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 8d1: 8b 45 f4 mov -0xc(%ebp),%eax 8d4: 8b 40 04 mov 0x4(%eax),%eax 8d7: 3b 45 ec cmp -0x14(%ebp),%eax 8da: 72 4d jb 929 <malloc+0xa6> if(p->s.size == nunits) 8dc: 8b 45 f4 mov -0xc(%ebp),%eax 8df: 8b 40 04 mov 0x4(%eax),%eax 8e2: 3b 45 ec cmp -0x14(%ebp),%eax 8e5: 75 0c jne 8f3 <malloc+0x70> prevp->s.ptr = p->s.ptr; 8e7: 8b 45 f4 mov -0xc(%ebp),%eax 8ea: 8b 10 mov (%eax),%edx 8ec: 8b 45 f0 mov -0x10(%ebp),%eax 8ef: 89 10 mov %edx,(%eax) 8f1: eb 26 jmp 919 <malloc+0x96> else { p->s.size -= nunits; 8f3: 8b 45 f4 mov -0xc(%ebp),%eax 8f6: 8b 40 04 mov 0x4(%eax),%eax 8f9: 89 c2 mov %eax,%edx 8fb: 2b 55 ec sub -0x14(%ebp),%edx 8fe: 8b 45 f4 mov -0xc(%ebp),%eax 901: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 904: 8b 45 f4 mov -0xc(%ebp),%eax 907: 8b 40 04 mov 0x4(%eax),%eax 90a: c1 e0 03 shl $0x3,%eax 90d: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 910: 8b 45 f4 mov -0xc(%ebp),%eax 913: 8b 55 ec mov -0x14(%ebp),%edx 916: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 919: 8b 45 f0 mov -0x10(%ebp),%eax 91c: a3 e8 0b 00 00 mov %eax,0xbe8 return (void*)(p + 1); 921: 8b 45 f4 mov -0xc(%ebp),%eax 924: 83 c0 08 add $0x8,%eax 927: eb 38 jmp 961 <malloc+0xde> } if(p == freep) 929: a1 e8 0b 00 00 mov 0xbe8,%eax 92e: 39 45 f4 cmp %eax,-0xc(%ebp) 931: 75 1b jne 94e <malloc+0xcb> if((p = morecore(nunits)) == 0) 933: 8b 45 ec mov -0x14(%ebp),%eax 936: 89 04 24 mov %eax,(%esp) 939: e8 ed fe ff ff call 82b <morecore> 93e: 89 45 f4 mov %eax,-0xc(%ebp) 941: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 945: 75 07 jne 94e <malloc+0xcb> return 0; 947: b8 00 00 00 00 mov $0x0,%eax 94c: eb 13 jmp 961 <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 94e: 8b 45 f4 mov -0xc(%ebp),%eax 951: 89 45 f0 mov %eax,-0x10(%ebp) 954: 8b 45 f4 mov -0xc(%ebp),%eax 957: 8b 00 mov (%eax),%eax 959: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 95c: e9 70 ff ff ff jmp 8d1 <malloc+0x4e> } 961: c9 leave 962: c3 ret
; A115836: Self-describing sequence. The n-th integer of the sequence indicates how many integers of the sequence are strictly < 2n. ; Submitted by Jamie Morken(s2) ; 1,2,4,5,6,8,10,11,12,13,14,16,18,20,22,23,24,25,26,27,28,29,30,32,34,36,38,40,42,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,95,96,97,98,99,100,101 mov $1,$0 add $1,1 seq $1,60973 ; a(2*n+1) = a(n+1)+a(n), a(2*n) = 2*a(n), with a(1)=0 and a(2)=1. add $0,$1
%include "reg_sizes.asm" %include "lz0a_const.asm" %include "data_struct2.asm" %ifidn __OUTPUT_FORMAT__, win64 %define arg1 rcx %define arg2 rdx %define arg3 r8 %define hash rsi %define next_in rdi %else %define arg1 rdi %define arg2 rsi %define arg3 rdx %define hash r8 %define next_in rcx %endif %define stream arg1 %define level_buf arg1 %define matches_next arg2 %define f_i_end arg3 %define f_i rax %define file_start rbp %define tmp r9 %define encode_size r10 %define prev_len r11 %define prev_dist r12 %define hash_table level_buf + _hash_map_hash_table %define datas ymm0 %define datas_lookup ymm1 %define yhashes ymm2 %define ydists ymm3 %define ydists_lookup ymm4 %define ydownconvert_qd ymm5 %define ydists2 ymm5 %define yscatter ymm5 %define ytmp2 ymm5 %define ylens1 ymm6 %define ylens2 ymm7 %define ylookup ymm8 %define ylookup2 ymm9 %define yindex ymm10 %define yrot_left ymm11 %define yshift_finish ymm11 %define yqword_shuf ymm11 %define yhash_prod ymm11 %define ycode ymm11 %define ytmp3 ymm11 %define yones ymm12 %define ydatas_perm2 ymm13 %define yincrement ymm14 %define ytmp ymm15 %define ydist_extra ymm15 %ifidn __OUTPUT_FORMAT__, win64 %define stack_size 10*16 + 4 * 8 + 8 %define func(x) proc_frame x %macro FUNC_SAVE 0 alloc_stack stack_size vmovdqa [rsp + 0*16], xmm6 vmovdqa [rsp + 1*16], xmm7 vmovdqa [rsp + 2*16], xmm8 vmovdqa [rsp + 3*16], xmm9 vmovdqa [rsp + 4*16], xmm10 vmovdqa [rsp + 5*16], xmm11 vmovdqa [rsp + 6*16], xmm12 vmovdqa [rsp + 7*16], xmm13 vmovdqu [rsp + 8*16], xmm14 vmovdqa [rsp + 9*16], xmm15 save_reg rsi, 10*16 + 0*8 save_reg rdi, 10*16 + 1*8 save_reg rbp, 10*16 + 2*8 save_reg r12, 10*16 + 3*8 end_prolog %endm %macro FUNC_RESTORE 0 vmovdqa xmm6, [rsp + 0*16] vmovdqa xmm7, [rsp + 1*16] vmovdqa xmm8, [rsp + 2*16] vmovdqa xmm9, [rsp + 3*16] vmovdqa xmm10, [rsp + 4*16] vmovdqa xmm11, [rsp + 5*16] vmovdqa xmm12, [rsp + 6*16] vmovdqa xmm13, [rsp + 7*16] vmovdqa xmm14, [rsp + 8*16] vmovdqa xmm15, [rsp + 9*16] mov rsi, [rsp + 10*16 + 0*8] mov rdi, [rsp + 10*16 + 1*8] mov rbp, [rsp + 10*16 + 2*8] mov r12, [rsp + 10*16 + 3*8] add rsp, stack_size %endm %else %define func(x) x: %macro FUNC_SAVE 0 push rbp push r12 %endm %macro FUNC_RESTORE 0 pop r12 pop rbp %endm %endif %define VECT_SIZE 8 %define HASH_BYTES 2 global gen_icf_map_lh1_04 func(gen_icf_map_lh1_04) FUNC_SAVE mov file_start, [stream + _next_in] mov f_i %+ d, dword [stream + _total_in] sub file_start, f_i add f_i_end, f_i cmp f_i, f_i_end jge end_main ;; Prep for main loop mov level_buf, [stream + _level_buf] sub f_i_end, LA vmovdqu yincrement, [increment] vmovdqu yones, [ones] vmovdqu ydatas_perm2, [datas_perm2] xor prev_len, prev_len xor prev_dist, prev_dist ;; Process first byte vmovd yhashes %+ x, dword [f_i + file_start] vmovdqu yhash_prod, [hash_prod] vpmaddwd yhashes, yhashes, yhash_prod vpmaddwd yhashes, yhashes, yhash_prod vpand yhashes, yhashes, [hash_mask] vmovd hash %+ d, yhashes %+ x mov word [hash_table + HASH_BYTES * hash], f_i %+ w add f_i, 1 cmp f_i, f_i_end jg end_main ;;hash vmovdqu datas, [f_i + file_start] vpermq yhashes, datas, 0x44 vpshufb yhashes, yhashes, [datas_shuf] vmovdqu yhash_prod, [hash_prod] vpmaddwd yhashes, yhashes, yhash_prod vpmaddwd yhashes, yhashes, yhash_prod vpand yhashes, yhashes, [hash_mask] vpermq ylookup, datas, 0x44 vmovdqu yqword_shuf, [qword_shuf] vpshufb ylookup, ylookup, yqword_shuf vpermd ylookup2, ydatas_perm2, datas vpshufb ylookup2, ylookup2, yqword_shuf ;;gather/scatter hashes vpcmpeqq ytmp, ytmp, ytmp vpgatherdd ydists_lookup, [hash_table + HASH_BYTES * yhashes], ytmp vmovd yindex %+ x, f_i %+ d vpbroadcastd yindex, yindex %+ x vpaddd yindex, yindex, yincrement vpand yscatter, ydists_lookup, [upper_word] vpand ytmp, yindex, [low_word] vpor yscatter, yscatter, ytmp vmovd tmp %+ d, yhashes %+ x vmovd [hash_table + HASH_BYTES * tmp], yscatter %+ x vpextrd tmp %+ d, yhashes %+ x, 1 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 1 vpextrd tmp %+ d, yhashes %+ x, 2 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 2 vpextrd tmp %+ d,yhashes %+ x, 3 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 3 vextracti128 yscatter %+ x, yscatter, 1 vextracti128 yhashes %+ x, yhashes, 1 vmovd tmp %+ d, yhashes %+ x vmovd [hash_table + HASH_BYTES * tmp], yscatter %+ x vpextrd tmp %+ d, yhashes %+ x, 1 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 1 vpextrd tmp %+ d, yhashes %+ x, 2 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 2 vpextrd tmp %+ d,yhashes %+ x, 3 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 3 ;; Compute hash for next loop vmovdqu datas, [f_i + file_start + VECT_SIZE] vpermq yhashes, datas, 0x44 vpshufb yhashes, yhashes, [datas_shuf] vmovdqu yhash_prod, [hash_prod] vpmaddwd yhashes, yhashes, yhash_prod vpmaddwd yhashes, yhashes, yhash_prod vpand yhashes, yhashes, [hash_mask] vmovdqu datas_lookup, [f_i + file_start + 2 * VECT_SIZE] sub f_i_end, VECT_SIZE cmp f_i, f_i_end jg loop1_end loop1: lea next_in, [f_i + file_start] ;; Calculate look back dists vpaddd ydists, ydists_lookup, yones vpsubd ydists, yindex, ydists vpand ydists, ydists, [dist_mask] vpaddd ydists, ydists, yones vpsubd ydists, yincrement, ydists ;;gather/scatter hashes add f_i, VECT_SIZE vpcmpeqq ytmp, ytmp, ytmp vpgatherdd ydists_lookup, [hash_table + HASH_BYTES * yhashes], ytmp vmovd yindex %+ x, f_i %+ d vpbroadcastd yindex, yindex %+ x vpaddd yindex, yindex, yincrement vpand yscatter, ydists_lookup, [upper_word] vpand ytmp, yindex, [low_word] vpor yscatter, yscatter, ytmp vmovd tmp %+ d, yhashes %+ x vmovd [hash_table + HASH_BYTES * tmp], yscatter %+ x vpextrd tmp %+ d, yhashes %+ x, 1 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 1 vpextrd tmp %+ d, yhashes %+ x, 2 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 2 vpextrd tmp %+ d,yhashes %+ x, 3 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 3 vextracti128 yscatter %+ x, yscatter, 1 vextracti128 yhashes %+ x, yhashes, 1 vmovd tmp %+ d, yhashes %+ x vmovd [hash_table + HASH_BYTES * tmp], yscatter %+ x vpextrd tmp %+ d, yhashes %+ x, 1 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 1 vpextrd tmp %+ d, yhashes %+ x, 2 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 2 vpextrd tmp %+ d,yhashes %+ x, 3 vpextrd [hash_table + HASH_BYTES * tmp], yscatter %+ x, 3 ;; Compute hash for next loop vpermq yhashes, datas_lookup, 0x44 vpshufb yhashes, yhashes, [datas_shuf] vmovdqu yhash_prod, [hash_prod] vpmaddwd yhashes, yhashes, yhash_prod vpmaddwd yhashes, yhashes, yhash_prod vpand yhashes, yhashes, [hash_mask] ;;lookup old codes vextracti128 ydists2 %+ x, ydists, 1 vpcmpeqq ytmp, ytmp, ytmp vpgatherdq ylens1, [next_in + ydists %+ x], ytmp vpcmpeqq ytmp, ytmp, ytmp vpgatherdq ylens2, [next_in + ydists2 %+ x], ytmp ;; Calculate dist_icf_code vpaddd ydists, ydists, yones vpsubd ydists, yincrement, ydists vpslld ydist_extra, ydists, 12 vpor ydist_extra, ydists, ydist_extra vpand ydist_extra, ydist_extra, [low_nibble] vpshufb ydist_extra, ydist_extra, [nibble_order] vmovdqu ytmp2, [bit_index] vpshufb ydist_extra, ytmp2, ydist_extra vpxor ytmp2, ytmp2, ytmp2 vpcmpgtb ytmp2, ydist_extra, ytmp2 vpsrld ytmp3, ytmp2, 8 vpandn ytmp2, ytmp3, ytmp2 vpsrld ytmp3, ytmp2, 16 vpandn ytmp2, ytmp3, ytmp2 vpsrld ytmp3, ytmp2, 24 vpandn ytmp2, ytmp3, ytmp2 vpaddb ydist_extra, [base_offset] vpand ydist_extra, ydist_extra, ytmp2 vpsrlq ytmp2, ydist_extra, 32 vpxor ytmp3, ytmp3, ytmp3 vpsadbw ydist_extra, ydist_extra, ytmp3 vpsadbw ytmp2, ytmp2, ytmp3 vpsubd ydist_extra, ydist_extra, ytmp2 vpsllq ytmp2, ytmp2, 32 vpor ydist_extra, ydist_extra, ytmp2 vpcmpgtb ytmp3, ydist_extra, ytmp3 vpand ydist_extra, ydist_extra, ytmp3 vmovdqu yones, yones vpsllvd ycode, yones, ydist_extra vpsubd ycode, ycode, yones vpcmpgtd ytmp2, ydists, yones vpand ycode, ydists, ycode vpand ycode, ycode, ytmp2 vpsrlvd ydists, ydists, ydist_extra vpslld ydist_extra, ydist_extra, 1 vpaddd ydists, ydists, ydist_extra vpslld ycode, ycode, EXTRA_BITS_OFFSET - DIST_OFFSET vpaddd ydists, ydists, ycode ;; Setup ydists for combining with ylens vpslld ydists, ydists, DIST_OFFSET ;; xor current data with lookback dist vpxor ylens1, ylens1, ylookup vpxor ylens2, ylens2, ylookup2 ;; Setup registers for next loop vpermq ylookup, datas, 0x44 vmovdqu yqword_shuf, [qword_shuf] vpshufb ylookup, ylookup, yqword_shuf vpermd ylookup2, ydatas_perm2, datas vpshufb ylookup2, ylookup2, yqword_shuf ;; Compute match length vpxor ytmp, ytmp, ytmp vpcmpeqb ylens1, ylens1, ytmp vpcmpeqb ylens2, ylens2, ytmp vmovdqu yshift_finish, [shift_finish] vpand ylens1, ylens1, yshift_finish vpand ylens2, ylens2, yshift_finish vpsadbw ylens1, ylens1, ytmp vpsadbw ylens2, ylens2, ytmp vmovdqu ydownconvert_qd, [downconvert_qd] vpshufb ylens1, ylens1, ydownconvert_qd vextracti128 ytmp %+ x, ylens1, 1 vpor ylens1, ylens1, ytmp vpshufb ylens2, ylens2, ydownconvert_qd vextracti128 ytmp %+ x, ylens2, 1 vpor ylens2, ylens2, ytmp vinserti128 ylens1, ylens1, ylens2 %+ x, 1 vpsrld ylens2, ylens1, 4 vpand ylens1, ylens1, [low_nibble] vmovdqu ytmp, [match_cnt_perm] vpshufb ylens1, ytmp, ylens1 vpshufb ylens2, ytmp, ylens2 vpcmpeqb ytmp, ylens1, [match_cnt_low_max] vpand ylens2, ylens2, ytmp vpaddd ylens1, ylens1, ylens2 ;; Preload for next loops vmovdqu datas, datas_lookup vmovdqu datas_lookup, [f_i + file_start + 2 * VECT_SIZE] ;; Zero out matches which should not be taken vmovdqu yrot_left, [drot_left] vpermd ylens2, yrot_left, ylens1 vpermd ydists, yrot_left, ydists vpinsrd ytmp %+ x, ylens2 %+ x, prev_len %+ d, 0 vmovd prev_len %+ d, ylens2 %+ x vinserti128 ylens2, ylens2, ytmp %+ x, 0 vpinsrd ytmp %+ x, ydists %+ x, prev_dist %+ d, 0 vmovd prev_dist %+ d, ydists %+ x vinserti128 ydists, ydists, ytmp %+ x, 0 vpcmpgtd ytmp, ylens2, [shortest_matches] vpcmpgtd ytmp2, ylens1, ylens2 vpcmpeqd ytmp3, ytmp3, ytmp3 vpxor ytmp, ytmp, ytmp3 vpor ytmp, ytmp, ytmp2 vpandn ylens1, ytmp, ylens2 ;; Update zdists to match ylens1 vpaddd ydists, ydists, ylens1 vpaddd ydists, ydists, [twofiftyfour] vpmovzxbd ytmp3, [f_i + file_start - VECT_SIZE - 1] vpaddd ytmp3, [null_dist_syms] vpand ytmp3, ytmp3, ytmp vpandn ydists, ytmp, ydists vpor ydists, ydists, ytmp3 ;;Store ydists vmovdqu [matches_next], ydists add matches_next, ICF_CODE_BYTES * VECT_SIZE cmp f_i, f_i_end jle loop1 loop1_end: lea next_in, [f_i + file_start] ;; Calculate look back dists vpaddd ydists, ydists_lookup, yones vpsubd ydists, yindex, ydists vpand ydists, ydists, [dist_mask] vpaddd ydists, ydists, yones vpsubd ydists, yincrement, ydists ;;lookup old codes vextracti128 ydists2 %+ x, ydists, 1 vpcmpeqq ytmp, ytmp, ytmp vpgatherdq ylens1, [next_in + ydists %+ x], ytmp vpcmpeqq ytmp, ytmp, ytmp vpgatherdq ylens2, [next_in + ydists2 %+ x], ytmp ;; Calculate dist_icf_code vpaddd ydists, ydists, yones vpsubd ydists, yincrement, ydists vpslld ydist_extra, ydists, 12 vpor ydist_extra, ydists, ydist_extra vpand ydist_extra, ydist_extra, [low_nibble] vpshufb ydist_extra, ydist_extra, [nibble_order] vmovdqu ytmp2, [bit_index] vpshufb ydist_extra, ytmp2, ydist_extra vpxor ytmp2, ytmp2, ytmp2 vpcmpgtb ytmp2, ydist_extra, ytmp2 vpsrld ytmp3, ytmp2, 8 vpandn ytmp2, ytmp3, ytmp2 vpsrld ytmp3, ytmp2, 16 vpandn ytmp2, ytmp3, ytmp2 vpsrld ytmp3, ytmp2, 24 vpandn ytmp2, ytmp3, ytmp2 vpaddb ydist_extra, [base_offset] vpand ydist_extra, ydist_extra, ytmp2 vpsrlq ytmp2, ydist_extra, 32 vpxor ytmp3, ytmp3, ytmp3 vpsadbw ydist_extra, ydist_extra, ytmp3 vpsadbw ytmp2, ytmp2, ytmp3 vpsubd ydist_extra, ydist_extra, ytmp2 vpsllq ytmp2, ytmp2, 32 vpor ydist_extra, ydist_extra, ytmp2 vpcmpgtb ytmp3, ydist_extra, ytmp3 vpand ydist_extra, ydist_extra, ytmp3 vpsllvd ycode, yones, ydist_extra vpsubd ycode, ycode, yones vpcmpgtd ytmp2, ydists, yones vpand ycode, ydists, ycode vpand ycode, ycode, ytmp2 vpsrlvd ydists, ydists, ydist_extra vpslld ydist_extra, ydist_extra, 1 vpaddd ydists, ydists, ydist_extra vpslld ycode, ycode, EXTRA_BITS_OFFSET - DIST_OFFSET vpaddd ydists, ydists, ycode ;; Setup ydists for combining with ylens vpslld ydists, ydists, DIST_OFFSET ;; xor current data with lookback dist vpxor ylens1, ylens1, ylookup vpxor ylens2, ylens2, ylookup2 ;; Compute match length vpxor ytmp, ytmp, ytmp vpcmpeqb ylens1, ylens1, ytmp vpcmpeqb ylens2, ylens2, ytmp vmovdqu yshift_finish, [shift_finish] vpand ylens1, ylens1, yshift_finish vpand ylens2, ylens2, yshift_finish vpsadbw ylens1, ylens1, ytmp vpsadbw ylens2, ylens2, ytmp vmovdqu ydownconvert_qd, [downconvert_qd] vpshufb ylens1, ylens1, ydownconvert_qd vextracti128 ytmp %+ x, ylens1, 1 vpor ylens1, ylens1, ytmp vpshufb ylens2, ylens2, ydownconvert_qd vextracti128 ytmp %+ x, ylens2, 1 vpor ylens2, ylens2, ytmp vinserti128 ylens1, ylens1, ylens2 %+ x, 1 vpsrld ylens2, ylens1, 4 vpand ylens1, ylens1, [low_nibble] vmovdqu ytmp, [match_cnt_perm] vpshufb ylens1, ytmp, ylens1 vpshufb ylens2, ytmp, ylens2 vpcmpeqb ytmp, ylens1, [match_cnt_low_max] vpand ylens2, ylens2, ytmp vpaddd ylens1, ylens1, ylens2 ;; Zero out matches which should not be taken vmovdqu yrot_left, [drot_left] vpermd ylens2, yrot_left, ylens1 vpermd ydists, yrot_left, ydists vpinsrd ytmp %+ x, ylens2 %+ x, prev_len %+ d, 0 vinserti128 ylens2, ylens2, ytmp %+ x, 0 vpinsrd ytmp %+ x, ydists %+ x, prev_dist %+ d, 0 vinserti128 ydists, ydists, ytmp %+ x, 0 vpcmpgtd ytmp, ylens2, [shortest_matches] vpcmpgtd ytmp2, ylens1, ylens2 vpcmpeqd ytmp3, ytmp3, ytmp3 vpxor ytmp, ytmp, ytmp3 vpor ytmp, ytmp, ytmp2 vpandn ylens1, ytmp, ylens2 ;; Update zdists to match ylens1 vpaddd ydists, ydists, ylens1 vpaddd ydists, ydists, [twofiftyfour] vpmovzxbd ytmp3, [f_i + file_start - 1] vpaddd ytmp3, [null_dist_syms] vpand ytmp3, ytmp3, ytmp vpandn ydists, ytmp, ydists vpor ydists, ydists, ytmp3 ;;Store ydists vmovdqu [matches_next], ydists end_main: FUNC_RESTORE ret endproc_frame section .data align 32 datas_perm2: dd 0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4 drot_left: dd 0x7, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 datas_shuf: db 0x0, 0x1, 0x2, 0x3 db 0x1, 0x2, 0x3, 0x4 db 0x2, 0x3, 0x4, 0x5 db 0x3, 0x4, 0x5, 0x6 db 0x4, 0x5, 0x6, 0x7 db 0x5, 0x6, 0x7, 0x8 db 0x6, 0x7, 0x8, 0x9 db 0x7, 0x8, 0x9, 0xa bswap_shuf: db 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 db 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08 db 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 db 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08 qword_shuf: db 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 db 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 db 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9 db 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa %define PROD1 0xE84B %define PROD2 0x97B1 hash_prod: dw PROD1, PROD2, PROD1, PROD2, PROD1, PROD2, PROD1, PROD2 dw PROD1, PROD2, PROD1, PROD2, PROD1, PROD2, PROD1, PROD2 null_dist_syms: dd LIT, LIT, LIT, LIT, LIT, LIT, LIT, LIT increment: dd 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 ones: dd 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 twofiftyfour: dd 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe dist_mask: dd D-1, D-1, D-1, D-1, D-1, D-1, D-1, D-1 hash_mask: dd HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK dd HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK shortest_matches: dd MIN_DEF_MATCH, MIN_DEF_MATCH, MIN_DEF_MATCH, MIN_DEF_MATCH dd MIN_DEF_MATCH, MIN_DEF_MATCH, MIN_DEF_MATCH, MIN_DEF_MATCH upper_word: dw 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff dw 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff dw 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff dw 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff low_word: dw 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000 dw 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000 dw 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000 dw 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000 shift_finish: db 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 db 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 db 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 db 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 downconvert_qd: db 0x00, 0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff db 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff db 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff db 0x00, 0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff low_nibble: db 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f db 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f db 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f db 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f match_cnt_perm: db 0x0, 0x1, 0x0, 0x2, 0x0, 0x1, 0x0, 0x3, 0x0, 0x1, 0x0, 0x2, 0x0, 0x1, 0x0, 0x4 db 0x0, 0x1, 0x0, 0x2, 0x0, 0x1, 0x0, 0x3, 0x0, 0x1, 0x0, 0x2, 0x0, 0x1, 0x0, 0x4 match_cnt_low_max: dd 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4 bit_index: db 0x0, 0x1, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3 db 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4 db 0x0, 0x1, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3 db 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4 base_offset: db -0x2, 0x2, 0x6, 0xa, -0x2, 0x2, 0x6, 0xa db -0x2, 0x2, 0x6, 0xa, -0x2, 0x2, 0x6, 0xa db -0x2, 0x2, 0x6, 0xa, -0x2, 0x2, 0x6, 0xa db -0x2, 0x2, 0x6, 0xa, -0x2, 0x2, 0x6, 0xa nibble_order: db 0x0, 0x2, 0x1, 0x3, 0x4, 0x6, 0x5, 0x7 db 0x8, 0xa, 0x9, 0xb, 0xc, 0xe, 0xd, 0xf db 0x0, 0x2, 0x1, 0x3, 0x4, 0x6, 0x5, 0x7 db 0x8, 0xa, 0x9, 0xb, 0xc, 0xe, 0xd, 0xf
; A110556: a(n) = binomial(2*n-1,n)*(-1)^n for n>0; a(0) = 1. ; 1,-1,3,-10,35,-126,462,-1716,6435,-24310,92378,-352716,1352078,-5200300,20058300,-77558760,300540195,-1166803110,4537567650,-17672631900,68923264410,-269128937220,1052049481860,-4116715363800,16123801841550,-63205303218876,247959266474052,-973469712824056,3824345300380220 sub $1,$0 bin $1,$0
; ; Copyright (c) 2014 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" ;Note: tap3 and tap4 have to be applied and added after other taps to avoid ;overflow. %macro HIGH_GET_FILTERS_4 0 mov rdx, arg(5) ;filter ptr mov rcx, 0x00000040 movdqa xmm7, [rdx] ;load filters pshuflw xmm0, xmm7, 0b ;k0 pshuflw xmm1, xmm7, 01010101b ;k1 pshuflw xmm2, xmm7, 10101010b ;k2 pshuflw xmm3, xmm7, 11111111b ;k3 psrldq xmm7, 8 pshuflw xmm4, xmm7, 0b ;k4 pshuflw xmm5, xmm7, 01010101b ;k5 pshuflw xmm6, xmm7, 10101010b ;k6 pshuflw xmm7, xmm7, 11111111b ;k7 punpcklwd xmm0, xmm6 punpcklwd xmm2, xmm5 punpcklwd xmm3, xmm4 punpcklwd xmm1, xmm7 movdqa k0k6, xmm0 movdqa k2k5, xmm2 movdqa k3k4, xmm3 movdqa k1k7, xmm1 movq xmm6, rcx pshufd xmm6, xmm6, 0 movdqa krd, xmm6 ;Compute max and min values of a pixel mov rdx, 0x00010001 movsxd rcx, DWORD PTR arg(6) ;bd movq xmm0, rdx movq xmm1, rcx pshufd xmm0, xmm0, 0b movdqa xmm2, xmm0 psllw xmm0, xmm1 psubw xmm0, xmm2 pxor xmm1, xmm1 movdqa max, xmm0 ;max value (for clamping) movdqa min, xmm1 ;min value (for clamping) %endm %macro HIGH_APPLY_FILTER_4 1 punpcklwd xmm0, xmm6 ;two row in one register punpcklwd xmm1, xmm7 punpcklwd xmm2, xmm5 punpcklwd xmm3, xmm4 pmaddwd xmm0, k0k6 ;multiply the filter factors pmaddwd xmm1, k1k7 pmaddwd xmm2, k2k5 pmaddwd xmm3, k3k4 paddd xmm0, xmm1 ;sum paddd xmm0, xmm2 paddd xmm0, xmm3 paddd xmm0, krd ;rounding psrad xmm0, 7 ;shift packssdw xmm0, xmm0 ;pack to word ;clamp the values pminsw xmm0, max pmaxsw xmm0, min %if %1 movq xmm1, [rdi] pavgw xmm0, xmm1 %endif movq [rdi], xmm0 %endm %macro HIGH_GET_FILTERS 0 mov rdx, arg(5) ;filter ptr mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr mov rcx, 0x00000040 movdqa xmm7, [rdx] ;load filters pshuflw xmm0, xmm7, 0b ;k0 pshuflw xmm1, xmm7, 01010101b ;k1 pshuflw xmm2, xmm7, 10101010b ;k2 pshuflw xmm3, xmm7, 11111111b ;k3 pshufhw xmm4, xmm7, 0b ;k4 pshufhw xmm5, xmm7, 01010101b ;k5 pshufhw xmm6, xmm7, 10101010b ;k6 pshufhw xmm7, xmm7, 11111111b ;k7 punpcklqdq xmm2, xmm2 punpcklqdq xmm3, xmm3 punpcklwd xmm0, xmm1 punpckhwd xmm6, xmm7 punpckhwd xmm2, xmm5 punpckhwd xmm3, xmm4 movdqa k0k1, xmm0 ;store filter factors on stack movdqa k6k7, xmm6 movdqa k2k5, xmm2 movdqa k3k4, xmm3 movq xmm6, rcx pshufd xmm6, xmm6, 0 movdqa krd, xmm6 ;rounding ;Compute max and min values of a pixel mov rdx, 0x00010001 movsxd rcx, DWORD PTR arg(6) ;bd movq xmm0, rdx movq xmm1, rcx pshufd xmm0, xmm0, 0b movdqa xmm2, xmm0 psllw xmm0, xmm1 psubw xmm0, xmm2 pxor xmm1, xmm1 movdqa max, xmm0 ;max value (for clamping) movdqa min, xmm1 ;min value (for clamping) %endm %macro LOAD_VERT_8 1 movdqu xmm0, [rsi + %1] ;0 movdqu xmm1, [rsi + rax + %1] ;1 movdqu xmm6, [rsi + rdx * 2 + %1] ;6 lea rsi, [rsi + rax] movdqu xmm7, [rsi + rdx * 2 + %1] ;7 movdqu xmm2, [rsi + rax + %1] ;2 movdqu xmm3, [rsi + rax * 2 + %1] ;3 movdqu xmm4, [rsi + rdx + %1] ;4 movdqu xmm5, [rsi + rax * 4 + %1] ;5 %endm %macro HIGH_APPLY_FILTER_8 2 movdqu temp, xmm4 movdqa xmm4, xmm0 punpcklwd xmm0, xmm1 punpckhwd xmm4, xmm1 movdqa xmm1, xmm6 punpcklwd xmm6, xmm7 punpckhwd xmm1, xmm7 movdqa xmm7, xmm2 punpcklwd xmm2, xmm5 punpckhwd xmm7, xmm5 movdqu xmm5, temp movdqu temp, xmm4 movdqa xmm4, xmm3 punpcklwd xmm3, xmm5 punpckhwd xmm4, xmm5 movdqu xmm5, temp pmaddwd xmm0, k0k1 pmaddwd xmm5, k0k1 pmaddwd xmm6, k6k7 pmaddwd xmm1, k6k7 pmaddwd xmm2, k2k5 pmaddwd xmm7, k2k5 pmaddwd xmm3, k3k4 pmaddwd xmm4, k3k4 paddd xmm0, xmm6 paddd xmm0, xmm2 paddd xmm0, xmm3 paddd xmm5, xmm1 paddd xmm5, xmm7 paddd xmm5, xmm4 paddd xmm0, krd ;rounding paddd xmm5, krd psrad xmm0, 7 ;shift psrad xmm5, 7 packssdw xmm0, xmm5 ;pack back to word ;clamp the values pminsw xmm0, max pmaxsw xmm0, min %if %1 movdqu xmm1, [rdi + %2] pavgw xmm0, xmm1 %endif movdqu [rdi + %2], xmm0 %endm SECTION .text ;void vpx_highbd_filter_block1d4_v8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pitch, ; unsigned char *output_ptr, ; unsigned int out_pitch, ; unsigned int output_height, ; short *filter ;) global sym(vpx_highbd_filter_block1d4_v8_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_v8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movq xmm0, [rsi] ;load src: row 0 movq xmm1, [rsi + rax] ;1 movq xmm6, [rsi + rdx * 2] ;6 lea rsi, [rsi + rax] movq xmm7, [rsi + rdx * 2] ;7 movq xmm2, [rsi + rax] ;2 movq xmm3, [rsi + rax * 2] ;3 movq xmm4, [rsi + rdx] ;4 movq xmm5, [rsi + rax * 4] ;5 HIGH_APPLY_FILTER_4 0 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d8_v8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pitch, ; unsigned char *output_ptr, ; unsigned int out_pitch, ; unsigned int output_height, ; short *filter ;) global sym(vpx_highbd_filter_block1d8_v8_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_v8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 0, 0 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d16_v8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pitch, ; unsigned char *output_ptr, ; unsigned int out_pitch, ; unsigned int output_height, ; short *filter ;) global sym(vpx_highbd_filter_block1d16_v8_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_v8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 0, 0 sub rsi, rax LOAD_VERT_8 16 HIGH_APPLY_FILTER_8 0, 16 add rdi, rbx dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d4_v8_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_v8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movq xmm0, [rsi] ;load src: row 0 movq xmm1, [rsi + rax] ;1 movq xmm6, [rsi + rdx * 2] ;6 lea rsi, [rsi + rax] movq xmm7, [rsi + rdx * 2] ;7 movq xmm2, [rsi + rax] ;2 movq xmm3, [rsi + rax * 2] ;3 movq xmm4, [rsi + rdx] ;4 movq xmm5, [rsi + rax * 4] ;5 HIGH_APPLY_FILTER_4 1 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d8_v8_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_v8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 1, 0 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d16_v8_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_v8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 1, 0 sub rsi, rax LOAD_VERT_8 16 HIGH_APPLY_FILTER_8 1, 16 add rdi, rbx dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d4_h8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pixels_per_line, ; unsigned char *output_ptr, ; unsigned int output_pitch, ; unsigned int output_height, ; short *filter ;) global sym(vpx_highbd_filter_block1d4_h8_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_h8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm4, [rsi + 2] movdqa xmm1, xmm0 movdqa xmm6, xmm4 movdqa xmm7, xmm4 movdqa xmm2, xmm0 movdqa xmm3, xmm0 movdqa xmm5, xmm4 psrldq xmm1, 2 psrldq xmm6, 4 psrldq xmm7, 6 psrldq xmm2, 4 psrldq xmm3, 6 psrldq xmm5, 2 HIGH_APPLY_FILTER_4 0 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d8_h8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pixels_per_line, ; unsigned char *output_ptr, ; unsigned int output_pitch, ; unsigned int output_height, ; short *filter ;) global sym(vpx_highbd_filter_block1d8_h8_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_h8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 0, 0 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d16_h8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pixels_per_line, ; unsigned char *output_ptr, ; unsigned int output_pitch, ; unsigned int output_height, ; short *filter ;) global sym(vpx_highbd_filter_block1d16_h8_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_h8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 0, 0 movdqu xmm0, [rsi + 10] ;load src movdqu xmm1, [rsi + 12] movdqu xmm2, [rsi + 14] movdqu xmm3, [rsi + 16] movdqu xmm4, [rsi + 18] movdqu xmm5, [rsi + 20] movdqu xmm6, [rsi + 22] movdqu xmm7, [rsi + 24] HIGH_APPLY_FILTER_8 0, 16 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d4_h8_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_h8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm4, [rsi + 2] movdqa xmm1, xmm0 movdqa xmm6, xmm4 movdqa xmm7, xmm4 movdqa xmm2, xmm0 movdqa xmm3, xmm0 movdqa xmm5, xmm4 psrldq xmm1, 2 psrldq xmm6, 4 psrldq xmm7, 6 psrldq xmm2, 4 psrldq xmm3, 6 psrldq xmm5, 2 HIGH_APPLY_FILTER_4 1 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d8_h8_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_h8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 1, 0 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d16_h8_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_h8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 1, 0 movdqu xmm0, [rsi + 10] ;load src movdqu xmm1, [rsi + 12] movdqu xmm2, [rsi + 14] movdqu xmm3, [rsi + 16] movdqu xmm4, [rsi + 18] movdqu xmm5, [rsi + 20] movdqu xmm6, [rsi + 22] movdqu xmm7, [rsi + 24] HIGH_APPLY_FILTER_8 1, 16 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret
;;; ;;; This is Suggested Project 7.9.2.7 ;;; This is to find the sum of squares from 1 to N ;;; Pg. 138 for the problem ;;; Pg. 24 for Registers; Pg. 48 for Data Types ;;; Pg. 102 Multiple registers SECTION .data SUCCESS: equ 0 ; Default success value SYS_EXIT: equ 60 ; Default system exit value ;; Variables used by the project N: equ 1000000 ; Sum of squares from 1 to N SUM: dq 0 ; Sum SECTION .text ; Code Section global _start ; Standard start _start: ;; Sum of squares from 1 to N mov rcx, N ; Puting N in rcx for loop command mov rbx, 1 ; Starting number is 1 sumOfSquares: mov rax, rbx ; i into rax mul rax ; i * i add qword [SUM], rax ; sum += i^2 inc rbx ; i++ loop sumOfSquares ; Loop until rcx is zero ; Done, terminate program last: mov rax, SYS_EXIT ; Call code for exit mov rdi, SUCCESS ; Exit with success syscall
; A074509: a(n) = 1^n + 3^n + 7^n. ; 3,11,59,371,2483,17051,118379,825731,5771363,40373291,282534299,1977503891,13841818643,96890604731,678227855819,4747575858851,33232973616323,232630643127371,1628413985330939,11398896347634611 mov $1,3 pow $1,$0 mov $2,7 pow $2,$0 add $1,$2 add $1,1 mov $0,$1
; A053838: a(n) = (sum of digits of n written in base 3) modulo 3. ; 0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0 lpb $0,1 add $1,$0 div $0,3 lpe mod $1,3
/** * Copyright(c) [2017] <Frzifus> All Rights Reserved. * Distributed under MIT license. * See file LICENSE for detail at LICENSE file. */ #include <iostream> #include <unordered_map> #include <SFML/Graphics.hpp> #include "./resources/global.h" #include "./screen/screen_digits.h" #include "./screen/screen_interface.h" #include "./screen/screens.h" int main() { Config::ConfParser config; Resources::Global globalRes; try { globalRes.Init(); } catch (std::exception &ex) { std::cerr << "Ouch! That hurts, because: " << ex.what() << "!\n"; return EXIT_FAILURE; } bool missingConfig = !config.LoadConfig(); if (missingConfig) { std::clog << "Configuration file does not exist\n"; } // Add config to globalRes globalRes.AddConfig(&config); // Window creation sf::RenderWindow window( sf::VideoMode(config.ResolutionWidth(), config.ResolutionHeight()), "rpic-desktop"); //, sf::Style::Fullscreen); // set framelimit window.setFramerateLimit(config.FrameLimit()); // configure cursor window.setMouseCursorVisible(config.MouseCursorVisable()); // configure Vsync window.setVerticalSyncEnabled(config.VSync()); // Screens preparations std::unordered_map<Screen::Digits, Screen::ScreenInterface *> screens; Screen::Digits screen = Screen::Digits::HOME_SCREEN; Screen::Home homeScreen; screens[Screen::Digits::HOME_SCREEN] = &homeScreen; Screen::Config configScreen; screens[Screen::Digits::CONFIG_SCREEN] = &configScreen; Screen::Playground playgroundScreen; screens[Screen::Digits::PLAYGROUND_SCREEN] = &playgroundScreen; Screen::ScreenInterface::global_res = &globalRes; // FIXME: This seems evil since it implies that somewhere there's a while // true. while (screen != Screen::Digits::CLOSE) { auto currentScreen = screens[screen]; screen = currentScreen->Run(window); } }
; int isalpha(int c) SECTION code_clib SECTION code_ctype PUBLIC isalpha EXTERN asm_isalpha, error_zc IF __CLASSIC && __CPU_GBZ80__ PUBLIC _isalpha _isalpha: ld hl,sp+2 ld a,(hl+) ld h,(hl) ld l,a ENDIF isalpha: inc h dec h jp nz, error_zc ld a,l call asm_isalpha ld l,h IF __CPU_GBZ80__ ld d,h ld e,l ENDIF ret c inc l IF __CPU_GBZ80__ inc e ENDIF ret ; SDCC bridge for Classic IF __CLASSIC && !__CPU_GBZ80__ PUBLIC _isalpha defc _isalpha = isalpha ENDIF
; A320897: a(n) = Sum_{k=1..n} k^2 * tau(k)^2, where tau is A000005. ; 1,17,53,197,297,873,1069,2093,2822,4422,4906,10090,10766,13902,17502,23902,25058,36722,38166,52566,59622,67366,69482,106346,111971,122787,134451,162675,166039,223639,227483,264347,281771,300267,319867,424843,430319,453423 mov $4,$0 add $4,1 mov $6,$0 lpb $4,1 mov $0,$6 sub $4,1 sub $0,$4 mov $3,$0 cal $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. add $3,1 mul $3,$0 mov $2,$3 mul $3,2 mul $3,$2 mov $5,$3 sub $5,2 div $5,2 add $5,1 add $1,$5 lpe
; Options: ; ; CRT_ORG_CODE = start address ; CRT_ORG_BSS = address for bss variables ; CRT_MODEL = 0 (RAM), 1 = (ROM, code copied), 2 = (ROM, code compressed) ; ; djm 18/5/99 ; MODULE zxn_crt0 ;-------- ; Include zcc_opt.def to find out some info ;-------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main ; main() is always external to crt0 code PUBLIC cleanup ; jp'd to by exit() PUBLIC l_dcal ; jp(hl) PUBLIC call_rom3 ; Interposer PUBLIC __SYSVAR_BORDCR defc __SYSVAR_BORDCR = 23624 PUBLIC _FRAMES IF startup != 2 defc _FRAMES = 23672 ; Timer ENDIF ; We default to the 64 column terminal driver ; Check whether to default to 32 column display defc CONSOLE_ROWS = 24 IF !DEFINED_CLIB_ZX_CONIO32 defc CLIB_ZX_CONIO32 = 0 defc CONSOLE_COLUMNS = 64 ELSE defc CONSOLE_COLUMNS = 32 ENDIF PUBLIC __CLIB_ZX_CONIO32 defc __CLIB_ZX_CONIO32 = CLIB_ZX_CONIO32 IF !CLIB_FGETC_CONS_DELAY defc CLIB_FGETC_CONS_DELAY = 100 ENDIF defc CRT_KEY_DEL = 12 defc __CPU_CLOCK = 3500000 IF __ESXDOS_DOT_COMMAND INCLUDE "target/zxn/classic/dot_crt0.asm" ELSE INCLUDE "target/zxn/classic/ram_crt0.asm" ENDIF ; Runtime selection IF NEED_fzxterminal PUBLIC fputc_cons PUBLIC _fputc_cons PUBLIC _fgets_cons_erase_character PUBLIC fgets_cons_erase_character EXTERN fputc_cons_fzx EXTERN fgets_cons_erase_character_fzx defc DEFINED_fputc_cons = 1 defc fputc_cons = fputc_cons_fzx defc _fputc_cons = fputc_cons_fzx defc fgets_cons_erase_character = fgets_cons_erase_character_fzx defc _fgets_cons_erase_character = fgets_cons_erase_character_fzx ENDIF INCLUDE "crt/classic/crt_runtime_selection.asm" PUBLIC __CLIB_TILES_PALETTE_SET_INDEX IFDEF CLIB_TILES_PALETTE_SET_INDEX defc __CLIB_TILES_PALETTE_SET_INDEX = CLIB_TILES_PALETTE_SET_INDEX ELSE defc __CLIB_TILES_PALETTE_SET_INDEX = 1 ENDIF
;/* ; * FreeRTOS Kernel V10.4.1 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in ; * the Software without restriction, including without limitation the rights to ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ; * the Software, and to permit persons to whom the Software is furnished to do so, ; * subject to the following conditions: ; * ; * The above copyright notice and this permission notice shall be included in all ; * copies or substantial portions of the Software. ; * ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ; * ; * https://www.FreeRTOS.org ; * https://github.com/FreeRTOS ; * ; * 1 tab == 4 spaces! ; */ ; * The definition of the "register test" tasks, as described at the top of ; * main.c .include data_model.h .global xTaskIncrementTick .global vTaskSwitchContext .global vPortSetupTimerInterrupt .global pxCurrentTCB .global usCriticalNesting .def vPortPreemptiveTickISR .def vPortCooperativeTickISR .def vPortYield .def xPortStartScheduler ;----------------------------------------------------------- portSAVE_CONTEXT .macro ;Save the remaining registers. pushm_x #12, r15 mov.w &usCriticalNesting, r14 push_x r14 mov_x &pxCurrentTCB, r12 mov_x sp, 0( r12 ) .endm ;----------------------------------------------------------- portRESTORE_CONTEXT .macro mov_x &pxCurrentTCB, r12 mov_x @r12, sp pop_x r15 mov.w r15, &usCriticalNesting popm_x #12, r15 nop pop.w sr nop ret_x .endm ;----------------------------------------------------------- ;* ;* The RTOS tick ISR. ;* ;* If the cooperative scheduler is in use this simply increments the tick ;* count. ;* ;* If the preemptive scheduler is in use a context switch can also occur. ;*/ .text .align 2 vPortPreemptiveTickISR: .asmfunc ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs ;to save it manually before it gets modified (interrupts get disabled). push.w sr portSAVE_CONTEXT call_x #xTaskIncrementTick call_x #vTaskSwitchContext portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- .align 2 vPortCooperativeTickISR: .asmfunc ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs ;to save it manually before it gets modified (interrupts get disabled). push.w sr portSAVE_CONTEXT call_x #xTaskIncrementTick portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- ; ; Manual context switch called by the portYIELD() macro. ; .align 2 vPortYield: .asmfunc ; The sr needs saving before it is modified. push.w sr ; Now the SR is stacked we can disable interrupts. dint nop ; Save the context of the current task. portSAVE_CONTEXT ; Select the next task to run. call_x #vTaskSwitchContext ; Restore the context of the new task. portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- ; ; Start off the scheduler by initialising the RTOS tick timer, then restoring ; the context of the first task. ; .align 2 xPortStartScheduler: .asmfunc ; Setup the hardware to generate the tick. Interrupts are disabled ; when this function is called. call_x #vPortSetupTimerInterrupt ; Restore the context of the first task that is going to run. portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- .end
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 5, 0x90 SWP_BYTE: pByteSwp: .byte 3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12 .p2align 5, 0x90 .globl h9_UpdateSHA256 .type h9_UpdateSHA256, @function h9_UpdateSHA256: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(52), %esp .Lsha256_block_loopgas_1: movl (8)(%ebp), %eax vmovdqu (%eax), %xmm0 vmovdqu (16)(%eax), %xmm1 vmovdqu %xmm0, (%esp) vmovdqu %xmm1, (16)(%esp) movl (12)(%ebp), %eax movl (20)(%ebp), %ebx call .L__0000gas_1 .L__0000gas_1: pop %ecx sub $(.L__0000gas_1-SWP_BYTE), %ecx movdqa ((pByteSwp-SWP_BYTE))(%ecx), %xmm6 vmovdqu (%eax), %xmm0 vmovdqu (16)(%eax), %xmm1 vmovdqu (32)(%eax), %xmm2 vmovdqu (48)(%eax), %xmm3 mov (16)(%esp), %eax mov (%esp), %edx vpshufb %xmm6, %xmm0, %xmm0 vpaddd (%ebx), %xmm0, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (20)(%esp), %edi xor (24)(%esp), %edi and %eax, %edi xor (24)(%esp), %edi mov (28)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (4)(%esp), %esi movl (8)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (12)(%esp), %eax mov %edx, (28)(%esp) mov %eax, (12)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (16)(%esp), %edi xor (20)(%esp), %edi and %eax, %edi xor (20)(%esp), %edi mov (24)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (%esp), %esi movl (4)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (8)(%esp), %eax mov %edx, (24)(%esp) mov %eax, (8)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (12)(%esp), %edi xor (16)(%esp), %edi and %eax, %edi xor (16)(%esp), %edi mov (20)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (28)(%esp), %esi movl (%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (4)(%esp), %eax mov %edx, (20)(%esp) mov %eax, (4)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (8)(%esp), %edi xor (12)(%esp), %edi and %eax, %edi xor (12)(%esp), %edi mov (16)(%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (24)(%esp), %esi movl (28)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (%esp), %eax mov %edx, (16)(%esp) mov %eax, (%esp) vpshufb %xmm6, %xmm1, %xmm1 vpaddd (16)(%ebx), %xmm1, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (4)(%esp), %edi xor (8)(%esp), %edi and %eax, %edi xor (8)(%esp), %edi mov (12)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (20)(%esp), %esi movl (24)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (28)(%esp), %eax mov %edx, (12)(%esp) mov %eax, (28)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (%esp), %edi xor (4)(%esp), %edi and %eax, %edi xor (4)(%esp), %edi mov (8)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (16)(%esp), %esi movl (20)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (24)(%esp), %eax mov %edx, (8)(%esp) mov %eax, (24)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (28)(%esp), %edi xor (%esp), %edi and %eax, %edi xor (%esp), %edi mov (4)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (12)(%esp), %esi movl (16)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (20)(%esp), %eax mov %edx, (4)(%esp) mov %eax, (20)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (24)(%esp), %edi xor (28)(%esp), %edi and %eax, %edi xor (28)(%esp), %edi mov (%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (8)(%esp), %esi movl (12)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (16)(%esp), %eax mov %edx, (%esp) mov %eax, (16)(%esp) vpshufb %xmm6, %xmm2, %xmm2 vpaddd (32)(%ebx), %xmm2, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (20)(%esp), %edi xor (24)(%esp), %edi and %eax, %edi xor (24)(%esp), %edi mov (28)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (4)(%esp), %esi movl (8)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (12)(%esp), %eax mov %edx, (28)(%esp) mov %eax, (12)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (16)(%esp), %edi xor (20)(%esp), %edi and %eax, %edi xor (20)(%esp), %edi mov (24)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (%esp), %esi movl (4)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (8)(%esp), %eax mov %edx, (24)(%esp) mov %eax, (8)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (12)(%esp), %edi xor (16)(%esp), %edi and %eax, %edi xor (16)(%esp), %edi mov (20)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (28)(%esp), %esi movl (%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (4)(%esp), %eax mov %edx, (20)(%esp) mov %eax, (4)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (8)(%esp), %edi xor (12)(%esp), %edi and %eax, %edi xor (12)(%esp), %edi mov (16)(%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (24)(%esp), %esi movl (28)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (%esp), %eax mov %edx, (16)(%esp) mov %eax, (%esp) vpshufb %xmm6, %xmm3, %xmm3 vpaddd (48)(%ebx), %xmm3, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (4)(%esp), %edi xor (8)(%esp), %edi and %eax, %edi xor (8)(%esp), %edi mov (12)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (20)(%esp), %esi movl (24)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (28)(%esp), %eax mov %edx, (12)(%esp) mov %eax, (28)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (%esp), %edi xor (4)(%esp), %edi and %eax, %edi xor (4)(%esp), %edi mov (8)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (16)(%esp), %esi movl (20)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (24)(%esp), %eax mov %edx, (8)(%esp) mov %eax, (24)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (28)(%esp), %edi xor (%esp), %edi and %eax, %edi xor (%esp), %edi mov (4)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (12)(%esp), %esi movl (16)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (20)(%esp), %eax mov %edx, (4)(%esp) mov %eax, (20)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (24)(%esp), %edi xor (28)(%esp), %edi and %eax, %edi xor (28)(%esp), %edi mov (%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (8)(%esp), %esi movl (12)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (16)(%esp), %eax mov %edx, (%esp) mov %eax, (16)(%esp) movl $(48), (48)(%esp) .Lloop_16_63gas_1: add $(64), %ebx vpshufd $(250), %xmm3, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpshufd $(165), %xmm0, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpshufd $(80), %xmm0, %xmm7 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(165), %xmm2, %xmm6 vpaddd %xmm4, %xmm7, %xmm7 vpaddd %xmm6, %xmm7, %xmm7 vpshufd $(160), %xmm7, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpalignr $(12), %xmm0, %xmm1, %xmm6 vpshufd $(80), %xmm6, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpalignr $(12), %xmm2, %xmm3, %xmm6 vpshufd $(250), %xmm0, %xmm0 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(80), %xmm6, %xmm6 vpaddd %xmm4, %xmm0, %xmm0 vpaddd %xmm6, %xmm0, %xmm0 vpshufd $(136), %xmm7, %xmm7 vpshufd $(136), %xmm0, %xmm0 vpalignr $(8), %xmm7, %xmm0, %xmm0 vpaddd (%ebx), %xmm0, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (20)(%esp), %edi xor (24)(%esp), %edi and %eax, %edi xor (24)(%esp), %edi mov (28)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (4)(%esp), %esi movl (8)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (12)(%esp), %eax mov %edx, (28)(%esp) mov %eax, (12)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (16)(%esp), %edi xor (20)(%esp), %edi and %eax, %edi xor (20)(%esp), %edi mov (24)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (%esp), %esi movl (4)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (8)(%esp), %eax mov %edx, (24)(%esp) mov %eax, (8)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (12)(%esp), %edi xor (16)(%esp), %edi and %eax, %edi xor (16)(%esp), %edi mov (20)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (28)(%esp), %esi movl (%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (4)(%esp), %eax mov %edx, (20)(%esp) mov %eax, (4)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (8)(%esp), %edi xor (12)(%esp), %edi and %eax, %edi xor (12)(%esp), %edi mov (16)(%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (24)(%esp), %esi movl (28)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (%esp), %eax mov %edx, (16)(%esp) mov %eax, (%esp) vpshufd $(250), %xmm0, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpshufd $(165), %xmm1, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpshufd $(80), %xmm1, %xmm7 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(165), %xmm3, %xmm6 vpaddd %xmm4, %xmm7, %xmm7 vpaddd %xmm6, %xmm7, %xmm7 vpshufd $(160), %xmm7, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpalignr $(12), %xmm1, %xmm2, %xmm6 vpshufd $(80), %xmm6, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpalignr $(12), %xmm3, %xmm0, %xmm6 vpshufd $(250), %xmm1, %xmm1 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(80), %xmm6, %xmm6 vpaddd %xmm4, %xmm1, %xmm1 vpaddd %xmm6, %xmm1, %xmm1 vpshufd $(136), %xmm7, %xmm7 vpshufd $(136), %xmm1, %xmm1 vpalignr $(8), %xmm7, %xmm1, %xmm1 vpaddd (16)(%ebx), %xmm1, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (4)(%esp), %edi xor (8)(%esp), %edi and %eax, %edi xor (8)(%esp), %edi mov (12)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (20)(%esp), %esi movl (24)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (28)(%esp), %eax mov %edx, (12)(%esp) mov %eax, (28)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (%esp), %edi xor (4)(%esp), %edi and %eax, %edi xor (4)(%esp), %edi mov (8)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (16)(%esp), %esi movl (20)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (24)(%esp), %eax mov %edx, (8)(%esp) mov %eax, (24)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (28)(%esp), %edi xor (%esp), %edi and %eax, %edi xor (%esp), %edi mov (4)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (12)(%esp), %esi movl (16)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (20)(%esp), %eax mov %edx, (4)(%esp) mov %eax, (20)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (24)(%esp), %edi xor (28)(%esp), %edi and %eax, %edi xor (28)(%esp), %edi mov (%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (8)(%esp), %esi movl (12)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (16)(%esp), %eax mov %edx, (%esp) mov %eax, (16)(%esp) vpshufd $(250), %xmm1, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpshufd $(165), %xmm2, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpshufd $(80), %xmm2, %xmm7 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(165), %xmm0, %xmm6 vpaddd %xmm4, %xmm7, %xmm7 vpaddd %xmm6, %xmm7, %xmm7 vpshufd $(160), %xmm7, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpalignr $(12), %xmm2, %xmm3, %xmm6 vpshufd $(80), %xmm6, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpalignr $(12), %xmm0, %xmm1, %xmm6 vpshufd $(250), %xmm2, %xmm2 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(80), %xmm6, %xmm6 vpaddd %xmm4, %xmm2, %xmm2 vpaddd %xmm6, %xmm2, %xmm2 vpshufd $(136), %xmm7, %xmm7 vpshufd $(136), %xmm2, %xmm2 vpalignr $(8), %xmm7, %xmm2, %xmm2 vpaddd (32)(%ebx), %xmm2, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (20)(%esp), %edi xor (24)(%esp), %edi and %eax, %edi xor (24)(%esp), %edi mov (28)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (4)(%esp), %esi movl (8)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (12)(%esp), %eax mov %edx, (28)(%esp) mov %eax, (12)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (16)(%esp), %edi xor (20)(%esp), %edi and %eax, %edi xor (20)(%esp), %edi mov (24)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (%esp), %esi movl (4)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (8)(%esp), %eax mov %edx, (24)(%esp) mov %eax, (8)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (12)(%esp), %edi xor (16)(%esp), %edi and %eax, %edi xor (16)(%esp), %edi mov (20)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (28)(%esp), %esi movl (%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (4)(%esp), %eax mov %edx, (20)(%esp) mov %eax, (4)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (8)(%esp), %edi xor (12)(%esp), %edi and %eax, %edi xor (12)(%esp), %edi mov (16)(%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (24)(%esp), %esi movl (28)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (%esp), %eax mov %edx, (16)(%esp) mov %eax, (%esp) vpshufd $(250), %xmm2, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpshufd $(165), %xmm3, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpshufd $(80), %xmm3, %xmm7 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(165), %xmm1, %xmm6 vpaddd %xmm4, %xmm7, %xmm7 vpaddd %xmm6, %xmm7, %xmm7 vpshufd $(160), %xmm7, %xmm6 vpsrld $(10), %xmm6, %xmm4 vpsrlq $(17), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpsrlq $(2), %xmm6, %xmm6 vpxor %xmm6, %xmm4, %xmm4 vpalignr $(12), %xmm3, %xmm0, %xmm6 vpshufd $(80), %xmm6, %xmm6 vpsrld $(3), %xmm6, %xmm5 vpsrlq $(7), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpsrlq $(11), %xmm6, %xmm6 vpxor %xmm6, %xmm5, %xmm5 vpalignr $(12), %xmm1, %xmm2, %xmm6 vpshufd $(250), %xmm3, %xmm3 vpaddd %xmm5, %xmm4, %xmm4 vpshufd $(80), %xmm6, %xmm6 vpaddd %xmm4, %xmm3, %xmm3 vpaddd %xmm6, %xmm3, %xmm3 vpshufd $(136), %xmm7, %xmm7 vpshufd $(136), %xmm3, %xmm3 vpalignr $(8), %xmm7, %xmm3, %xmm3 vpaddd (48)(%ebx), %xmm3, %xmm7 vmovdqu %xmm7, (32)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (4)(%esp), %edi xor (8)(%esp), %edi and %eax, %edi xor (8)(%esp), %edi mov (12)(%esp), %eax add %esi, %eax add %edi, %eax addl (32)(%esp), %eax movl (20)(%esp), %esi movl (24)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (28)(%esp), %eax mov %edx, (12)(%esp) mov %eax, (28)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (%esp), %edi xor (4)(%esp), %edi and %eax, %edi xor (4)(%esp), %edi mov (8)(%esp), %eax add %esi, %eax add %edi, %eax addl (36)(%esp), %eax movl (16)(%esp), %esi movl (20)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (24)(%esp), %eax mov %edx, (8)(%esp) mov %eax, (24)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (28)(%esp), %edi xor (%esp), %edi and %eax, %edi xor (%esp), %edi mov (4)(%esp), %eax add %esi, %eax add %edi, %eax addl (40)(%esp), %eax movl (12)(%esp), %esi movl (16)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (20)(%esp), %eax mov %edx, (4)(%esp) mov %eax, (20)(%esp) mov %eax, %esi shrd $(6), %esi, %esi mov %eax, %ecx shrd $(11), %ecx, %ecx xor %ecx, %esi shrd $(14), %ecx, %ecx xor %ecx, %esi mov (24)(%esp), %edi xor (28)(%esp), %edi and %eax, %edi xor (28)(%esp), %edi mov (%esp), %eax add %esi, %eax add %edi, %eax addl (44)(%esp), %eax movl (8)(%esp), %esi movl (12)(%esp), %ecx mov %edx, %edi xor %ecx, %edi xor %esi, %ecx and %ecx, %edi xor %esi, %ecx xor %ecx, %edi mov %edx, %esi shrd $(2), %esi, %esi mov %edx, %ecx shrd $(13), %ecx, %ecx xor %ecx, %esi shrd $(9), %ecx, %ecx xor %ecx, %esi lea (%edi,%esi), %edx add %eax, %edx add (16)(%esp), %eax mov %edx, (%esp) mov %eax, (16)(%esp) subl $(16), (48)(%esp) jg .Lloop_16_63gas_1 movl (8)(%ebp), %eax vmovdqu (%esp), %xmm0 vmovdqu (16)(%esp), %xmm1 vmovdqu (%eax), %xmm7 vpaddd %xmm0, %xmm7, %xmm7 vmovdqu %xmm7, (%eax) vmovdqu (16)(%eax), %xmm7 vpaddd %xmm1, %xmm7, %xmm7 vmovdqu %xmm7, (16)(%eax) addl $(64), (12)(%ebp) subl $(64), (16)(%ebp) jg .Lsha256_block_loopgas_1 add $(52), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe1: .size h9_UpdateSHA256, .Lfe1-(h9_UpdateSHA256)
; ================================================================== ; This bootloader was borrowed from the MikeOS project. MikeOS had borrowed this bootloader from E Dehling. ; It scans the FAT12 floppy for KERNEL.BIN (the PongOS kernel), loads it and executes it. ; ================================================================== BITS 16 jmp short bootloader_start ; Jump past disk description section nop ; Pad out before disk description ; ------------------------------------------------------------------ ; Disk description table, to make it a valid floppy ; Note: some of these values are hard-coded in the source! ; Values are those used by IBM for 1.44 MB, 3.5" diskette OEMLabel db "EditBOOT" ; Disk label BytesPerSector dw 512 ; Bytes per sector SectorsPerCluster db 1 ; Sectors per cluster ReservedForBoot dw 1 ; Reserved sectors for boot record NumberOfFats db 2 ; Number of copies of the FAT RootDirEntries dw 224 ; Number of entries in root dir ; (224 * 32 = 7168 = 14 sectors to read) LogicalSectors dw 2880 ; Number of logical sectors MediumByte db 0F0h ; Medium descriptor byte SectorsPerFat dw 9 ; Sectors per FAT SectorsPerTrack dw 18 ; Sectors per track (36/cylinder) Sides dw 2 ; Number of sides/heads HiddenSectors dd 0 ; Number of hidden sectors LargeSectors dd 0 ; Number of LBA sectors DriveNo dw 0 ; Drive No: 0 Signature db 41 ; Drive signature: 41 for floppy VolumeID dd 00000000h ; Volume ID: any number VolumeLabel db "PongOS " ; Volume Label: any 11 chars FileSystem db "FAT12 " ; File system type: don't change! ; ------------------------------------------------------------------ ; Main bootloader code bootloader_start: mov ax, 07C0h ; Set up 4K of stack space above buffer add ax, 544 ; 8k buffer = 512 paragraphs + 32 paragraphs (loader) cli ; Disable interrupts while changing stack mov ss, ax mov sp, 4096 sti ; Restore interrupts mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax ; NOTE: A few early BIOSes are reported to improperly set DL mov byte [bootdev], dl ; Save boot device number mov eax, 0 ; Needed for some older BIOSes ; First, we need to load the root directory from the disk. Technical details: ; Start of root = ReservedForBoot + NumberOfFats * SectorsPerFat = logical 19 ; Number of root = RootDirEntries * 32 bytes/entry / 512 bytes/sector = 14 ; Start of user data = (start of root) + (number of root) = logical 33 floppy_ok: ; Ready to read first block of data mov ax, 19 ; Root dir starts at logical sector 19 call l2hts mov si, buffer ; Set ES:BX to point to our buffer (see end of code) mov bx, ds mov es, bx mov bx, si mov ah, 2 ; Params for int 13h: read floppy sectors mov al, 14 ; And read 14 of them pusha ; Prepare to enter loop read_root_dir: popa ; In case registers are altered by int 13h pusha stc ; A few BIOSes do not set properly on error int 13h ; Read sectors using BIOS jnc search_dir ; If read went OK, skip ahead call reset_floppy ; Otherwise, reset floppy controller and try again jnc read_root_dir ; Floppy reset OK? jmp reboot ; If not, fatal double error search_dir: popa mov ax, ds ; Root dir is now in [buffer] mov es, ax ; Set DI to this info mov di, buffer mov cx, word [RootDirEntries] ; Search all (224) entries mov ax, 0 ; Searching at offset 0 next_root_entry: xchg cx, dx ; We use CX in the inner loop... mov si, kern_filename ; Start searching for kernel filename mov cx, 11 rep cmpsb je found_file_to_load ; Pointer DI will be at offset 11 add ax, 32 ; Bump searched entries by 1 (32 bytes per entry) mov di, buffer ; Point to next entry add di, ax xchg dx, cx ; Get the original CX back loop next_root_entry mov si, file_not_found ; If kernel is not found, bail out call print_string jmp reboot found_file_to_load: ; Fetch cluster and load FAT into RAM mov ax, word [es:di+0Fh] ; Offset 11 + 15 = 26, contains 1st cluster mov word [cluster], ax mov ax, 1 ; Sector 1 = first sector of first FAT call l2hts mov di, buffer ; ES:BX points to our buffer mov bx, di mov ah, 2 ; int 13h params: read (FAT) sectors mov al, 9 ; All 9 sectors of 1st FAT pusha ; Prepare to enter loop read_fat: popa ; In case registers are altered by int 13h pusha stc int 13h ; Read sectors using the BIOS jnc read_fat_ok ; If read went OK, skip ahead call reset_floppy ; Otherwise, reset floppy controller and try again jnc read_fat ; Floppy reset OK? mov si, disk_error ; If not, print error message and reboot call print_string jmp reboot ; Fatal double error read_fat_ok: popa mov ax, 2000h ; Segment where we'll load the kernel mov es, ax mov bx, 0 mov ah, 2 ; int 13h floppy read params mov al, 1 push ax ; Save in case we (or int calls) lose it ; Now we must load the FAT from the disk. Here's how we find out where it starts: ; FAT cluster 0 = media descriptor = 0F0h ; FAT cluster 1 = filler cluster = 0FFh ; Cluster start = ((cluster number) - 2) * SectorsPerCluster + (start of user) ; = (cluster number) + 31 load_file_sector: mov ax, word [cluster] ; Convert sector to logical add ax, 31 call l2hts ; Make appropriate params for int 13h mov ax, 2000h ; Set buffer past what we've already read mov es, ax mov bx, word [pointer] pop ax ; Save in case we (or int calls) lose it push ax stc int 13h jnc calculate_next_cluster ; If there's no error... call reset_floppy ; Otherwise, reset floppy and retry jmp load_file_sector ; In the FAT, cluster values are stored in 12 bits, so we have to ; do a bit of maths to work out whether we're dealing with a byte ; and 4 bits of the next byte -- or the last 4 bits of one byte ; and then the subsequent byte! calculate_next_cluster: mov ax, [cluster] mov dx, 0 mov bx, 3 mul bx mov bx, 2 div bx ; DX = [cluster] mod 2 mov si, buffer add si, ax ; AX = word in FAT for the 12 bit entry mov ax, word [ds:si] or dx, dx ; If DX = 0 [cluster] is even; if DX = 1 then it's odd jz even ; If [cluster] is even, drop last 4 bits of word ; with next cluster; if odd, drop first 4 bits odd: shr ax, 4 ; Shift out first 4 bits (they belong to another entry) jmp short next_cluster_cont even: and ax, 0FFFh ; Mask out final 4 bits next_cluster_cont: mov word [cluster], ax ; Store cluster cmp ax, 0FF8h ; FF8h = end of file marker in FAT12 jae end add word [pointer], 512 ; Increase buffer pointer 1 sector length jmp load_file_sector end: ; We've got the file to load! pop ax ; Clean up the stack (AX was pushed earlier) mov dl, byte [bootdev] ; Provide kernel with boot device info jmp 2000h:0000h ; Jump to entry point of loaded kernel! ; ------------------------------------------------------------------ ; BOOTLOADER SUBROUTINES reboot: mov ax, 0 int 16h ; Wait for keystroke mov ax, 0 int 19h ; Reboot the system print_string: ; Output string in SI to screen pusha mov ah, 0Eh ; int 10h teletype function .repeat: lodsb ; Get char from string cmp al, 0 je .done ; If char is zero, end of string int 10h ; Otherwise, print it jmp short .repeat .done: popa ret reset_floppy: ; IN: [bootdev] = boot device; OUT: carry set on error push ax push dx mov ax, 0 mov dl, byte [bootdev] stc int 13h pop dx pop ax ret l2hts: ; Calculate head, track and sector settings for int 13h ; IN: logical sector in AX, OUT: correct registers for int 13h push bx push ax mov bx, ax ; Save logical sector mov dx, 0 ; First the sector div word [SectorsPerTrack] add dl, 01h ; Physical sectors start at 1 mov cl, dl ; Sectors belong in CL for int 13h mov ax, bx mov dx, 0 ; Now calculate the head div word [SectorsPerTrack] mov dx, 0 div word [Sides] mov dh, dl ; Head/side mov ch, al ; Track pop ax pop bx mov dl, byte [bootdev] ; Set correct device ret ; ------------------------------------------------------------------ ; STRINGS AND VARIABLES kern_filename db "KERNEL BIN" disk_error db "Floppy error! Press any key...", 0 file_not_found db "KERNEL.BIN not found!", 0 file_found db "found",0 bootdev db 0 ; Boot device number cluster dw 0 ; Cluster of the file we want to load pointer dw 0 ; Pointer into Buffer, for loading kernel ; ------------------------------------------------------------------ ; END OF BOOT SECTOR AND BUFFER START times 510-($-$$) db 0 ; Pad remainder of boot sector with zeros dw 0AA55h ; Boot signature (DO NOT CHANGE!) buffer: ; Disk buffer begins (8k after this, stack starts) ; ==================================================================
; A267812: Decimal representation of the n-th iteration of the "Rule 217" elementary cellular automaton starting with a single ON (black) cell. ; 1,1,27,119,495,2015,8127,32639,130815,523775,2096127,8386559,33550335,134209535,536854527,2147450879,8589869055,34359607295,137438691327,549755289599,2199022206975,8796090925055,35184367894527,140737479966719,562949936644095,2251799780130815,9007199187632127,36028796884746239,144115187807420415,576460751766552575,2305843008139952127,9223372034707292159,36893488143124135935,147573952581086478335,590295810341525782527,2361183241400462868479,9444732965670570950655,37778931862819722756095,151115727451553768931327,604462909806764831539199,2417851639228158837784575,9671406556914834374393855,38685626227663735544086527,154742504910663738269368319,618970019642672545263517695,2475880078570725365426159615,9903520314282971830448816127,39614081257132028059283619839,158456325028528393712111190015,633825300114114137798398181375,2535301200456457677093499568127,10141204801825832960173811957759,40564819207303336344294875201535,162259276829213354384378755547135,649037107316853435551913531670527,2596148429267413778236451145646079,10384593717069655185003398620512255,41538374868278620884128782557904895,166153499473114483824745506383331327,664613997892457935875442777836748799 mov $1,$0 add $0,1 pow $1,2 add $1,1 mod $1,$0 pow $1,$0 bin $1,2 trn $1,2 mov $0,$1 add $0,1
.global s_prepare_buffers s_prepare_buffers: push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_normal_ht+0xa2b1, %rsi lea addresses_WT_ht+0xa9a4, %rdi nop nop nop sub %r8, %r8 mov $38, %rcx rep movsb cmp %rbp, %rbp pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r8 push %rax push %rcx push %rdx push %rsi // Store lea addresses_D+0x4071, %r14 nop nop nop nop and %r12, %r12 movb $0x51, (%r14) nop nop inc %rdx // Store lea addresses_PSE+0xcdf1, %r8 nop nop cmp %rcx, %rcx mov $0x5152535455565758, %rdx movq %rdx, %xmm7 movups %xmm7, (%r8) nop nop nop and $24448, %rcx // Store lea addresses_PSE+0x6171, %rax nop nop nop and %r12, %r12 mov $0x5152535455565758, %rcx movq %rcx, %xmm7 movntdq %xmm7, (%rax) // Exception!!! mov (0), %rdx nop nop nop nop cmp %r8, %r8 // Store lea addresses_RW+0xaa91, %rdx nop nop and $30819, %rax movw $0x5152, (%rdx) // Exception!!! nop nop nop nop mov (0), %rax xor %r14, %r14 // Store lea addresses_RW+0x1b425, %rax clflush (%rax) nop nop nop inc %rsi movl $0x51525354, (%rax) dec %r14 // Load mov $0x715e80000000a71, %r12 nop nop and %r8, %r8 mov (%r12), %cx inc %r14 // Faulty Load lea addresses_A+0x15971, %r14 nop nop nop nop nop cmp $59985, %rsi vmovaps (%r14), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %r12 lea oracles, %r14 and $0xff, %r12 shlq $12, %r12 mov (%r14,%r12,1), %r12 pop %rsi pop %rdx pop %rcx pop %rax pop %r8 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 2, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 16, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_NC', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'00': 1} 00 */
#include <stdlib.h> #include <vector> int* pint(int x) { int* i = (int*)malloc(sizeof(int)); *i = x; return i; } int main() { for (int i = 0; i < 1000000; i++) { std::vector<int*> v; v.push_back(pint(1)); v.push_back(pint(2)); v.push_back(pint(3)); v.push_back(pint(4)); v.push_back(pint(5)); } }
; GetSGBLayout arguments (see engine/gfx/cgb_layouts.asm and engine/gfx/sgb_layouts.asm) const_def const SCGB_BATTLE_GRAYSCALE const SCGB_BATTLE_COLORS const SCGB_POKEGEAR_PALS const SCGB_STATS_SCREEN_HP_PALS const SCGB_POKEDEX const SCGB_SLOT_MACHINE const SCGB_BETA_TITLE_SCREEN const SCGB_GS_INTRO const SCGB_DIPLOMA const SCGB_MAPPALS const SCGB_PARTY_MENU const SCGB_EVOLUTION const SCGB_GS_TITLE_SCREEN const SCGB_0D const SCGB_MOVE_LIST const SCGB_BETA_PIKACHU_MINIGAME const SCGB_POKEDEX_SEARCH_OPTION const SCGB_BETA_POKER const SCGB_POKEPIC const SCGB_MAGNET_TRAIN const SCGB_PACKPALS const SCGB_TRAINER_CARD const SCGB_POKEDEX_UNOWN_MODE const SCGB_BILLS_PC const SCGB_UNOWN_PUZZLE const SCGB_GAMEFREAK_LOGO const SCGB_PLAYER_OR_MON_FRONTPIC_PALS const SCGB_TRADE_TUBE const SCGB_TRAINER_OR_MON_FRONTPIC_PALS const SCGB_MYSTERY_GIFT const SCGB_1E const SCGB_MINING_GAME const SCGB_INTRO_BOTH_PLAYER_PALS const SCGB_INTRO_SANDGEM const SCGB_CHOOSE_STARTER const SCGB_CHOOSE_STARTER_POKEPIC SCGB_PARTY_MENU_HP_PALS EQU -4 SCGB_RAM EQU -1 ; PredefPals indexes (see gfx/sgb/predef.pal) ; GetPredefPal arguments (see engine/gfx/color.asm) const_def const PREDEFPAL_00 const PREDEFPAL_PALLET const PREDEFPAL_VIRIDIAN const PREDEFPAL_PEWTER const PREDEFPAL_CERULEAN const PREDEFPAL_LAVENDER const PREDEFPAL_VERMILION const PREDEFPAL_CELADON const PREDEFPAL_FUCHSIA const PREDEFPAL_CINNABAR const PREDEFPAL_SAFFRON const PREDEFPAL_INDIGO const PREDEFPAL_NEW_BARK const PREDEFPAL_CHERRYGROVE const PREDEFPAL_VIOLET const PREDEFPAL_AZALEA const PREDEFPAL_GOLDENROD const PREDEFPAL_ECRUTEAK const PREDEFPAL_OLIVINE const PREDEFPAL_CIANWOOD const PREDEFPAL_MAHOGANY const PREDEFPAL_BLACKTHORN const PREDEFPAL_LAKE_OF_RAGE const PREDEFPAL_SILVER_CAVE const PREDEFPAL_DUNGEONS const PREDEFPAL_NITE const PREDEFPAL_BLACKOUT const PREDEFPAL_DIPLOMA ; RB_MEWMON const PREDEFPAL_TRADE_TUBE ; RB_BLUEMON const PREDEFPAL_POKEDEX ; RB_REDMON const PREDEFPAL_RB_CYANMON const PREDEFPAL_RB_PURPLEMON const PREDEFPAL_RB_BROWNMON const PREDEFPAL_RB_GREENMON const PREDEFPAL_RB_PINKMON const PREDEFPAL_RB_YELLOWMON const PREDEFPAL_CGB_BADGE ; RB_GREYMON const PREDEFPAL_BETA_SHINY_MEWMON const PREDEFPAL_BETA_SHINY_BLUEMON const PREDEFPAL_BETA_SHINY_REDMON const PREDEFPAL_BETA_SHINY_CYANMON const PREDEFPAL_BETA_SHINY_PURPLEMON const PREDEFPAL_BETA_SHINY_BROWNMON const PREDEFPAL_BETA_SHINY_GREENMON const PREDEFPAL_BETA_SHINY_PINKMON const PREDEFPAL_BETA_SHINY_YELLOWMON const PREDEFPAL_PARTY_ICON ; BETA_SHINY_GREYMON const PREDEFPAL_HP_GREEN const PREDEFPAL_HP_YELLOW const PREDEFPAL_HP_RED const PREDEFPAL_POKEGEAR const PREDEFPAL_BETA_LOGO_1 const PREDEFPAL_BETA_LOGO_2 const PREDEFPAL_GS_INTRO_GAMEFREAK_LOGO const PREDEFPAL_GS_INTRO_SHELLDER_LAPRAS const PREDEFPAL_BETA_INTRO_LAPRAS const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB const PREDEFPAL_GS_INTRO_STARTERS_TRANSITION const PREDEFPAL_BETA_INTRO_VENUSAUR const PREDEFPAL_PACK ; GS_INTRO_CHARIZARD const PREDEFPAL_SLOT_MACHINE_0 const PREDEFPAL_SLOT_MACHINE_1 const PREDEFPAL_SLOT_MACHINE_2 const PREDEFPAL_SLOT_MACHINE_3 const PREDEFPAL_BETA_POKER_0 const PREDEFPAL_BETA_POKER_1 const PREDEFPAL_BETA_POKER_2 const PREDEFPAL_BETA_POKER_3 const PREDEFPAL_BETA_RADIO const PREDEFPAL_BETA_POKEGEAR const PREDEFPAL_47 const PREDEFPAL_GS_TITLE_SCREEN_0 const PREDEFPAL_GS_TITLE_SCREEN_1 const PREDEFPAL_GS_TITLE_SCREEN_2 const PREDEFPAL_GS_TITLE_SCREEN_3 const PREDEFPAL_UNOWN_PUZZLE const PREDEFPAL_GAMEFREAK_LOGO_OB const PREDEFPAL_GAMEFREAK_LOGO_BG ; SGB system command codes ; http://gbdev.gg8.se/wiki/articles/SGB_Functions#SGB_System_Command_Table const_def const SGB_PAL01 const SGB_PAL23 const SGB_PAL03 const SGB_PAL12 const SGB_ATTR_BLK const SGB_ATTR_LIN const SGB_ATTR_DIV const SGB_ATTR_CHR const SGB_SOUND const SGB_SOU_TRN const SGB_PAL_SET const SGB_PAL_TRN const SGB_ATRC_EN const SGB_TEST_EN const SGB_ICON_EN const SGB_DATA_SND const SGB_DATA_TRN const SGB_MLT_REG const SGB_JUMP const SGB_CHR_TRN const SGB_PCT_TRN const SGB_ATTR_TRN const SGB_ATTR_SET const SGB_MASK_EN const SGB_OBJ_TRN PALPACKET_LENGTH EQU $10
section sprite xdef mes_cd_play mes_cd_play dc.w $0220,4,0,0,0,0 dc.l 0,0,0,0 dc.l sp_ex-* sp_ex dc.l sp_btn-* dc.l sp_btn_cur-* dc.l 0,0,0 sp_btn incbin 'win1_util_sprite_cd_play_spr' sp_btn_cur incbin 'win1_util_sprite_cd_play2_spr' end
; A228220: Number of second differences of arrays of length 5 of numbers in 0..n. ; Submitted by Jamie Morken(s2) ; 31,199,625,1429,2731,4651,7309,10825,15319,20911,27721,35869,45475,56659,69541,84241,100879,119575,140449,163621,189211,217339,248125,281689,318151,357631,400249,446125,495379,548131,604501,664609,728575,796519,868561,944821,1025419,1110475,1200109,1294441,1393591,1497679,1606825,1721149,1840771,1965811,2096389,2232625,2374639,2522551,2676481,2836549,3002875,3175579,3354781,3540601,3733159,3932575,4138969,4352461,4573171,4801219,5036725,5279809,5530591,5789191,6055729,6330325,6613099,6904171 mov $2,$0 add $0,1 add $2,$0 mul $2,2 add $2,3 add $0,$2 bin $2,2 mul $0,$2 div $0,2 add $0,1
; A101853: a(n) = n*(20+15*n+n^2)/6. ; 6,18,37,64,100,146,203,272,354,450,561,688,832,994,1175,1376,1598,1842,2109,2400,2716,3058,3427,3824,4250,4706,5193,5712,6264,6850,7471,8128,8822,9554,10325,11136,11988,12882,13819,14800,15826,16898,18017,19184,20400,21666,22983,24352,25774,27250,28781,30368,32012,33714,35475,37296,39178,41122,43129,45200,47336,49538,51807,54144,56550,59026,61573,64192,66884,69650,72491,75408,78402,81474,84625,87856,91168,94562,98039,101600,105246,108978,112797,116704,120700,124786,128963,133232,137594,142050,146601,151248,155992,160834,165775,170816,175958,181202,186549,192000,197556,203218,208987,214864,220850,226946,233153,239472,245904,252450,259111,265888,272782,279794,286925,294176,301548,309042,316659,324400,332266,340258,348377,356624,365000,373506,382143,390912,399814,408850,418021,427328,436772,446354,456075,465936,475938,486082,496369,506800,517376,528098,538967,549984,561150,572466,583933,595552,607324,619250,631331,643568,655962,668514,681225,694096,707128,720322,733679,747200,760886,774738,788757,802944,817300,831826,846523,861392,876434,891650,907041,922608,938352,954274,970375,986656,1003118,1019762,1036589,1053600,1070796,1088178,1105747,1123504,1141450,1159586,1177913,1196432,1215144,1234050,1253151,1272448,1291942,1311634,1331525,1351616,1371908,1392402,1413099,1434000,1455106,1476418,1497937,1519664,1541600,1563746,1586103,1608672,1631454,1654450,1677661,1701088,1724732,1748594,1772675,1796976,1821498,1846242,1871209,1896400,1921816,1947458,1973327,1999424,2025750,2052306,2079093,2106112,2133364,2160850,2188571,2216528,2244722,2273154,2301825,2330736,2359888,2389282,2418919,2448800,2478926,2509298,2539917,2570784,2601900,2633266,2664883,2696752,2728874,2761250 mov $1,$0 sub $0,1 pow $1,2 add $1,$0 mov $2,6 add $2,$0 bin $2,3 add $1,$2 sub $1,3
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r15 push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0xd78, %rsi lea addresses_WT_ht+0x4fc0, %rdi nop sub %r15, %r15 mov $6, %rcx rep movsw nop nop nop cmp $17990, %rsi lea addresses_normal_ht+0x9dc0, %r12 nop nop cmp %r11, %r11 mov (%r12), %di nop nop nop cmp %rsi, %rsi lea addresses_A_ht+0x155c0, %r12 nop nop nop nop inc %rbx movw $0x6162, (%r12) nop nop sub $30573, %r15 lea addresses_WC_ht+0x1c5c0, %r15 nop nop and $39255, %rsi movb $0x61, (%r15) nop nop nop nop add $9635, %r12 lea addresses_A_ht+0x145c0, %rsi lea addresses_A_ht+0x39c0, %rdi nop xor %rbx, %rbx mov $27, %rcx rep movsw dec %r12 lea addresses_normal_ht+0xea08, %rsi lea addresses_WT_ht+0x6cc0, %rdi nop nop nop nop nop sub $700, %r13 mov $99, %rcx rep movsq xor $39164, %rsi lea addresses_WC_ht+0x151c0, %rsi lea addresses_A_ht+0x8dc0, %rdi clflush (%rsi) nop nop nop nop and %r13, %r13 mov $24, %rcx rep movsq nop nop nop add $51048, %rdi lea addresses_WT_ht+0x6d60, %rcx nop xor %rsi, %rsi movups (%rcx), %xmm6 vpextrq $1, %xmm6, %rbx nop nop nop nop add %r11, %r11 lea addresses_normal_ht+0x16570, %rsi lea addresses_normal_ht+0xb536, %rdi nop nop nop nop and %r11, %r11 mov $118, %rcx rep movsl nop and $61459, %r13 lea addresses_UC_ht+0x17940, %r11 nop add $22767, %r12 mov (%r11), %esi nop nop nop nop and %r11, %r11 lea addresses_UC_ht+0x17f40, %r13 nop and %rcx, %rcx and $0xffffffffffffffc0, %r13 vmovntdqa (%r13), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $1, %xmm2, %rsi nop nop nop add %r11, %r11 lea addresses_normal_ht+0x460, %r11 clflush (%r11) nop nop nop nop nop inc %rcx movw $0x6162, (%r11) and %rcx, %rcx lea addresses_WC_ht+0x149c0, %r11 nop nop nop nop and $32944, %rdi movups (%r11), %xmm2 vpextrq $0, %xmm2, %r12 nop nop nop nop nop xor $57033, %r13 lea addresses_WC_ht+0x9a58, %rsi lea addresses_normal_ht+0x3cc0, %rdi nop nop nop nop cmp $56159, %r12 mov $122, %rcx rep movsw nop nop inc %r12 pop %rsi pop %rdi pop %rcx pop %rbx pop %r15 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r8 push %rdi push %rsi // Store lea addresses_WC+0x173c0, %r15 add $43757, %rsi mov $0x5152535455565758, %r12 movq %r12, %xmm6 vmovups %ymm6, (%r15) nop add $20338, %r15 // Store lea addresses_A+0x5940, %r11 nop nop nop cmp %r12, %r12 mov $0x5152535455565758, %rsi movq %rsi, %xmm0 vmovups %ymm0, (%r11) nop nop nop nop nop add %r12, %r12 // Faulty Load lea addresses_WC+0x7dc0, %r12 nop xor $52763, %rsi movups (%r12), %xmm6 vpextrq $1, %xmm6, %rdi lea oracles, %r15 and $0xff, %rdi shlq $12, %rdi mov (%r15,%rdi,1), %rdi pop %rsi pop %rdi pop %r8 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC'}} {'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': True, 'type': 'addresses_A_ht'}} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 6, 'same': True, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 32, 'NT': True, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_normal_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/*========================================================================= Program: Visualization Toolkit Module: vtkIOPostgreSQL_AutoInit.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkPostgreSQLDatabase.h" #include <vtksys/SystemTools.hxx> #include <string> // Registration of PostgreSQL dynamically with the vtkSQLDatabase factory method. vtkSQLDatabase * PostgreSQLCreateFunction(const char* URL) { std::string urlstr(URL ? URL : ""); std::string protocol, unused; vtkPostgreSQLDatabase *db = 0; if (vtksys::SystemTools::ParseURLProtocol(urlstr, protocol, unused) && protocol == "psql") { db = vtkPostgreSQLDatabase::New(); db->ParseURL(URL); } return db; } static unsigned int vtkIOPostgreSQLCount; struct VTKIOPOSTGRESQL_EXPORT vtkIOPostgreSQL_AutoInit { vtkIOPostgreSQL_AutoInit(); ~vtkIOPostgreSQL_AutoInit(); }; VTKIOPOSTGRESQL_EXPORT void vtkIOPostgreSQL_AutoInit_Construct() { if (++vtkIOPostgreSQLCount == 1) { vtkSQLDatabase::RegisterCreateFromURLCallback(PostgreSQLCreateFunction); } }
; A017068: a(n) = (8*n)^4. ; 0,4096,65536,331776,1048576,2560000,5308416,9834496,16777216,26873856,40960000,59969536,84934656,116985856,157351936,207360000,268435456,342102016,429981696,533794816,655360000,796594176,959512576,1146228736,1358954496,1600000000,1871773696,2176782336,2517630976,2897022976,3317760000,3782742016,4294967296,4857532416,5473632256,6146560000,6879707136,7676563456,8540717056,9475854336,10485760000,11574317056,12745506816,14003408896,15352201216,16796160000,18339659776,19987173376,21743271936,23612624896,25600000000,27710263296,29948379136,32319410176,34828517376,37480960000,40282095616,43237380096,46352367616,49632710656,53084160000,56712564736,60523872256,64524128256,68719476736,73116160000,77720518656,82538991616,87578116096,92844527616,98344960000,104086245376,110075314176,116319195136,122825015296,129600000000,136651472896,143986855936,151613669376,159539531776,167772160000,176319369216,185189072896,194389282816,203928109056,213813760000,224054542336,234658861056,245635219456,256992219136,268738560000,280883040256,293434556416,306402103296,319794774016,333621760000,347892350976,362615934976,377801998336,393460125696,409600000000,426231402496,443364212736,461008408576,479174066176,497871360000,517110562816,536902045696,557256278016,578183827456,599695360000,621801639936,644513529856,667841990656,691798081536,716392960000,741637881856,767544201216,794123370496,821386940416,849346560000,878013976576,907401035776,937519681536,968381956096,1000000000000,1032386052096,1065552449536,1099511627776,1134276120576,1169858560000,1206271676416,1243528298496,1281641353216,1320623865856,1360488960000,1401249857536,1442919878656,1485512441856,1529041063936,1573519360000,1618961043456,1665379926016,1712789917696,1761205026816,1810639360000,1861107122176,1912622616576,1965200244736,2018854506496,2073600000000,2129451421696,2186423566336,2244531326976,2303789694976,2364213760000,2425818710016,2488619831296,2552632508416,2617872224256,2684354560000,2752095195136,2821109907456,2891414573056,2963025166336,3035957760000,3110228525056,3185853730816,3262849744896,3341233033216,3421020160000,3502227787776,3584872677376,3668971687936,3754541776896,3841600000000,3930163511296,4020249563136,4111875506176,4205058789376,4299816960000,4396167663616,4494128644096,4593717743616,4694952902656,4797852160000,4902433652736,5008715616256,5116716384256,5226454388736,5337948160000,5451216326656,5566277615616,5683150852096,5801854959616,5922408960000,6044831973376,6169143218176,6295362011136,6423507767296,6553600000000,6685658320896,6819702439936,6955752165376,7093827403776,7233948160000,7376134537216,7520406736896,7666785058816,7815289901056,7965941760000,8118761230336,8273769005056,8430985875456,8590432731136,8752130560000,8916100448256,9082363580416,9250941239296,9421854806016,9595125760000,9770775678976,9948826238976,10129299214336,10312216477696,10497600000000,10685471850496,10875854196736,11068769304576,11264239538176,11462287360000,11662935330816,11866206109696,12072122454016,12280707219456,12491983360000,12705973927936,12922702073856,13142191046656,13364464193536,13589544960000,13817456889856,14048223625216,14281868906496,14518416572416,14757890560000,15000314904576,15245713739776,15494111297536,15745531908096 mul $0,8 mov $1,$0 pow $1,4
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosSetFHandState DOS wrapper ; ; (c) osFree Project 2022, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ;*/ .8086 ; Helpers INCLUDE helpers.inc INCLUDE dos.inc INCLUDE bseerr.inc _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @PROLOG DOSSETFHANDSTATE @START DOSSETFHANDSTATE XOR AX,AX EXIT: @EPILOG DOSSETFHANDSTATE _TEXT ENDS END
; A299090: Number of "digits" in the binary representation of the multiset of prime factors of n. ; 0,1,1,2,1,1,1,2,2,1,1,2,1,1,1,3,1,2,1,2,1,1,1,2,2,1,2,2,1,1,1,3,1,1,1,2,1,1,1,2,1,1,1,2,2,1,1,3,2,2,1,2,1,2,1,2,1,1,1,2,1,1,2,3,1,1,1,2,1,1,1,2,1,1,2,2,1,1,1,3,3,1,1,2,1,1,1,2,1,2,1,2,1,1,1,3,1,2,2,2 lpb $0 seq $0,188 ; (1) Number of solutions to x^2 == 0 (mod n). (2) Also square root of largest square dividing n. (3) Also max_{ d divides n } gcd(d, n/d). sub $0,1 add $1,7 lpe div $1,7 mov $0,$1
#include "Common.Application.h" #include "Common.Data.Properties.h" #include "json.hpp" #include <SDL.h> #include "Visuals.Layouts.h" namespace visuals::Sublayout { struct InternalSublayout { std::string name; }; static std::vector<InternalSublayout> internalSublayouts; static void DrawInternalSublayout(const std::shared_ptr<common::Application::Renderer>& renderer, size_t index) { auto& sublayout = internalSublayouts[index]; visuals::Layouts::Draw(renderer, sublayout.name); } std::function<void(const std::shared_ptr<common::Application::Renderer>&)> Internalize(const std::string& layoutName, const nlohmann::json& model) { size_t index = internalSublayouts.size(); internalSublayouts.push_back( { model[common::data::Properties::NAME] }); return [index](const std::shared_ptr<common::Application::Renderer>& renderer) { DrawInternalSublayout(renderer, index); }; } }
; ; Generic game device library - Galaksija port ; Stefano Bodrato - 2017 ; ; $Id: joystick.asm $ ; SECTION code_clib PUBLIC joystick PUBLIC _joystick EXTERN getk .joystick ._joystick ;__FASTALL__ : joystick no. in HL ld a,l dec a jp z,arrows ld e,0 ld hl,$200E ld a,(hl) cpl rrca rl e ; fire2 ld l,$0D ld a,(hl) cpl rrca rl e ;fire1 ld l,17 ;U ld a,(hl) cpl rrca rl e ld l,1 ;D ld a,(hl) cpl rrca rl e ld l,15 ;L ld a,(hl) cpl rrca rl e ld l,16 ;R ld a,(hl) cpl rrca rl e ld h,0 ld l,e ret .arrows ; MOVE_RIGHT 1 ; MOVE_LEFT 2 ; MOVE_DOWN 4 ; MOVE_UP 8 ; MOVE_FIRE 16 ld e,0 ld hl,$201F ld a,(hl); space cpl rrca rl e ; fire ld l,27 ; $2000 + 27..30: UDLR ld b,4 .jloop ld a,(hl) cpl rrca rl e inc hl djnz jloop ld h,0 ld l,e ret
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "BlueprintFieldNodeSpawner.h" #include "UObject/Package.h" #define LOCTEXT_NAMESPACE "BlueprintFieldNodeSpawner" //------------------------------------------------------------------------------ UBlueprintFieldNodeSpawner* UBlueprintFieldNodeSpawner::Create(TSubclassOf<UK2Node> NodeClass, UField const* const Field, UObject* Outer/* = nullptr*/) { if (Outer == nullptr) { Outer = GetTransientPackage(); } UBlueprintFieldNodeSpawner* NodeSpawner = NewObject<UBlueprintFieldNodeSpawner>(Outer); NodeSpawner->Field = Field; NodeSpawner->NodeClass = NodeClass; return NodeSpawner; } //------------------------------------------------------------------------------ UBlueprintFieldNodeSpawner::UBlueprintFieldNodeSpawner(FObjectInitializer const& ObjectInitializer) : Super(ObjectInitializer) , Field(nullptr) { } //------------------------------------------------------------------------------ FBlueprintNodeSignature UBlueprintFieldNodeSpawner::GetSpawnerSignature() const { FBlueprintNodeSignature SpawnerSignature(NodeClass); SpawnerSignature.AddSubObject(Field); return SpawnerSignature; } //------------------------------------------------------------------------------ UEdGraphNode* UBlueprintFieldNodeSpawner::Invoke(UEdGraph* ParentGraph, FBindingSet const& Bindings, FVector2D const Location) const { auto PostSpawnSetupLambda = [](UEdGraphNode* NewNode, bool bIsTemplateNode, UField const* InField, FSetNodeFieldDelegate SetFieldDelegate, FCustomizeNodeDelegate UserDelegate) { SetFieldDelegate.ExecuteIfBound(NewNode, InField); UserDelegate.ExecuteIfBound(NewNode, bIsTemplateNode); }; FCustomizeNodeDelegate PostSpawnSetupDelegate = FCustomizeNodeDelegate::CreateStatic(PostSpawnSetupLambda, GetField(), SetNodeFieldDelegate, CustomizeNodeDelegate); return Super::SpawnNode<UEdGraphNode>(NodeClass, ParentGraph, Bindings, Location, PostSpawnSetupDelegate); } //------------------------------------------------------------------------------ UField const* UBlueprintFieldNodeSpawner::GetField() const { return Field; } #undef LOCTEXT_NAMESPACE
; MoveEffectsPointers indexes (see data/moves/effects_pointers.asm) const_def const EFFECT_NORMAL_HIT const EFFECT_SLEEP const EFFECT_POISON_HIT const EFFECT_LEECH_HIT const EFFECT_BURN_HIT const EFFECT_FREEZE_HIT const EFFECT_PARALYZE_HIT const EFFECT_SELFDESTRUCT const EFFECT_DREAM_EATER const EFFECT_MIRROR_MOVE const EFFECT_ATTACK_UP const EFFECT_DEFENSE_UP const EFFECT_SPEED_UP const EFFECT_SP_ATK_UP const EFFECT_SP_DEF_UP const EFFECT_ACCURACY_UP const EFFECT_EVASION_UP const EFFECT_ALWAYS_HIT const EFFECT_ATTACK_DOWN const EFFECT_DEFENSE_DOWN const EFFECT_SPEED_DOWN const EFFECT_SP_ATK_DOWN const EFFECT_SP_DEF_DOWN const EFFECT_ACCURACY_DOWN const EFFECT_EVASION_DOWN const EFFECT_RESET_STATS const EFFECT_BIDE const EFFECT_RAMPAGE const EFFECT_FORCE_SWITCH const EFFECT_MULTI_HIT const EFFECT_CONVERSION const EFFECT_FLINCH_HIT const EFFECT_HEAL const EFFECT_TOXIC const EFFECT_PAY_DAY const EFFECT_LIGHT_SCREEN const EFFECT_TRI_ATTACK const EFFECT_UNUSED_25 const EFFECT_OHKO const EFFECT_RAZOR_WIND const EFFECT_SUPER_FANG const EFFECT_STATIC_DAMAGE const EFFECT_TRAP_TARGET const EFFECT_UNUSED_2B const EFFECT_DOUBLE_HIT const EFFECT_JUMP_KICK const EFFECT_MIST const EFFECT_FOCUS_ENERGY const EFFECT_RECOIL_HIT const EFFECT_CONFUSE const EFFECT_ATTACK_UP_2 const EFFECT_DEFENSE_UP_2 const EFFECT_SPEED_UP_2 const EFFECT_SP_ATK_UP_2 const EFFECT_SP_DEF_UP_2 const EFFECT_ACCURACY_UP_2 const EFFECT_EVASION_UP_2 const EFFECT_TRANSFORM const EFFECT_ATTACK_DOWN_2 const EFFECT_DEFENSE_DOWN_2 const EFFECT_SPEED_DOWN_2 const EFFECT_SP_ATK_DOWN_2 const EFFECT_SP_DEF_DOWN_2 const EFFECT_ACCURACY_DOWN_2 const EFFECT_EVASION_DOWN_2 const EFFECT_REFLECT const EFFECT_POISON const EFFECT_PARALYZE const EFFECT_ATTACK_DOWN_HIT const EFFECT_DEFENSE_DOWN_HIT const EFFECT_SPEED_DOWN_HIT const EFFECT_SP_ATK_DOWN_HIT const EFFECT_SP_DEF_DOWN_HIT const EFFECT_ACCURACY_DOWN_HIT const EFFECT_EVASION_DOWN_HIT const EFFECT_SKY_ATTACK const EFFECT_CONFUSE_HIT const EFFECT_POISON_MULTI_HIT const EFFECT_UNUSED_4E const EFFECT_SUBSTITUTE const EFFECT_HYPER_BEAM const EFFECT_RAGE const EFFECT_MIMIC const EFFECT_METRONOME const EFFECT_LEECH_SEED const EFFECT_SPLASH const EFFECT_DISABLE const EFFECT_LEVEL_DAMAGE const EFFECT_PSYWAVE const EFFECT_COUNTER const EFFECT_ENCORE const EFFECT_PAIN_SPLIT const EFFECT_SNORE const EFFECT_CONVERSION2 const EFFECT_LOCK_ON const EFFECT_SKETCH const EFFECT_DEFROST_OPPONENT const EFFECT_SLEEP_TALK const EFFECT_DESTINY_BOND const EFFECT_REVERSAL const EFFECT_SPITE const EFFECT_FALSE_SWIPE const EFFECT_HEAL_BELL const EFFECT_PRIORITY_HIT const EFFECT_TRIPLE_KICK const EFFECT_THIEF const EFFECT_MEAN_LOOK const EFFECT_NIGHTMARE const EFFECT_FLAME_WHEEL const EFFECT_CURSE const EFFECT_UNUSED_6E const EFFECT_PROTECT const EFFECT_SPIKES const EFFECT_FORESIGHT const EFFECT_PERISH_SONG const EFFECT_SANDSTORM const EFFECT_ENDURE const EFFECT_ROLLOUT const EFFECT_SWAGGER const EFFECT_FURY_CUTTER const EFFECT_ATTRACT const EFFECT_RETURN const EFFECT_PRESENT const EFFECT_FRUSTRATION const EFFECT_SAFEGUARD const EFFECT_SACRED_FIRE const EFFECT_MAGNITUDE const EFFECT_BATON_PASS const EFFECT_PURSUIT const EFFECT_RAPID_SPIN const EFFECT_UNUSED_82 const EFFECT_UNUSED_83 const EFFECT_MORNING_SUN const EFFECT_SYNTHESIS const EFFECT_MOONLIGHT const EFFECT_HIDDEN_POWER const EFFECT_RAIN_DANCE const EFFECT_SUNNY_DAY const EFFECT_DEFENSE_UP_HIT const EFFECT_ATTACK_UP_HIT const EFFECT_ALL_UP_HIT const EFFECT_FAKE_OUT const EFFECT_BELLY_DRUM const EFFECT_PSYCH_UP const EFFECT_MIRROR_COAT const EFFECT_SKULL_BASH const EFFECT_TWISTER const EFFECT_EARTHQUAKE const EFFECT_FUTURE_SIGHT const EFFECT_GUST const EFFECT_STOMP const EFFECT_SOLARBEAM const EFFECT_THUNDER const EFFECT_TELEPORT const EFFECT_BEAT_UP const EFFECT_FLY const EFFECT_DEFENSE_CURL
incsrc legacy.asm ; Translation patch fixes made by RobertOfNormandy ORG $819847 ; load menu, different values on either side of screen ; high byte = y position, low byte = x position ; this is the position on the right side of the screen ldx #$0217 bra storeMenuPos ; this is the position on the left side ldx #$0201 storeMenuPos: stx $0c1b LDY #table_suspend ; a0acb9 ; fix unit table names org $81a7ce ldx #$1408 ; character select highlighting org $818285 ldy #$0006 ; character select highlighting org $81864B ldy #$0006 ; fix save slot titles: add 0x20 to each ; slot 1: ORG $84BF58 ldx #$0020 ; slot two: ORG $84BF6F ldx #$0054 ; slot three: ORG $84BF86 ldx #$0088 ; Map battle messages (LvlUp, GotItm, Broken weapon) ORG $82C51A db $1B, $20, $91, $20, $55, $20, $5F, $20, $34, $20, $59, $20, $DF, $20 db $0B, $20, $81, $20, $45, $20, $4F, $20, $24, $20, $49, $20, $CF, $20 db $16, $20, $58, $20, $5D, $20, $18, $20, $5D, $20, $56, $20, $DF, $20 db $06, $20, $48, $20, $4D, $20, $08, $20, $4D, $20, $46, $20, $CF, $20 db $11, $20, $5B, $20, $58, $20, $54, $20, $3E, $20, $57, $20, $DF, $20 db $01, $20, $4B, $20, $48, $20, $44, $20, $2E, $20, $47, $20, $CF, $20 ; Set the width of the box for titles on the opening of each chapter. ORG $84E5B0 db $04, $06, $06, $06, $03, $07, $05, $05, $04, $05, $05, $05, $06, $05, $06, $05 db $06, $04, $05, $04, $07, $06, $06, $05, $06, $03, $06, $04, $06, $04, $03, $06 db $03, $06, $05, $07, $06, $07, $06, $04, $06, $07, $00, $20, $10, $10, $10, $28 db $08, $18, $18, $20, $18, $18, $18, $10, $18, $10, $18, $10, $20, $18, $20, $08 db $10, $10, $18, $10, $28, $10, $20, $10, $20, $28, $10, $28, $10, $18, $08, $10 db $08, $10, $20, $10, $08, $08 ; These are all to do with either text highlighting in various menus, or positioning in theitem popup menu ; I accidentally deleted my notes so I forget what's what, though. ORG $818479 LDX #$00A6 ORG $819847 LDX #$0216 bra skip1 LDX #$0202 skip1: ORG $81A887 ldy #$0006 ORG $81AF71 ldy #$000C ORG $81AF7C ldy #$0007 ORG $81AF9E ldy #$0005 ORG $81AFA6 ldy #$0007 ORG $81ECB9 ldx #$0E11 ; this section is for the "item owner" in the supply list ORG $819239 LDY #table_charnames ; a00080 PLA ; 68 JSL loadMenuText ; 2200806e txa clc adc #$0000 ; move the slot number closer to the unit name to fix the number overflowing the boundary. tax pla JSL $81D6AC txa sec sbc #$0004 ; this needs to be reduced as well tax LDY #table_itemDiscarding ; a016cf LDA #$0001 ; a90100 JSL loadMenuText ; 2200806e ORG $81926D LDY #table_itemDiscarding ; a016cf LDA #$0002 ; a90200 JSL loadMenuText ; 2200806e
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r14 push %r15 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1b068, %r10 nop nop nop nop nop add $82, %r13 mov (%r10), %rbp nop nop nop nop cmp %rdx, %rdx lea addresses_WC_ht+0x18f32, %r15 nop sub $5550, %r14 movb (%r15), %r10b nop nop and %r13, %r13 lea addresses_WC_ht+0x17edc, %r10 nop nop nop nop sub %r11, %r11 vmovups (%r10), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %r15 nop nop nop add %rdx, %rdx lea addresses_WC_ht+0x8502, %r14 nop nop nop nop nop and %r13, %r13 mov $0x6162636465666768, %rdx movq %rdx, %xmm6 and $0xffffffffffffffc0, %r14 movntdq %xmm6, (%r14) nop nop sub $40203, %r13 lea addresses_A_ht+0x882, %r15 nop nop nop xor %r11, %r11 movw $0x6162, (%r15) nop nop cmp $30846, %r13 lea addresses_UC_ht+0x74a2, %r11 nop nop nop nop nop sub $32036, %r14 mov $0x6162636465666768, %rdx movq %rdx, (%r11) cmp $29959, %rdx lea addresses_WC_ht+0x11a2, %r13 nop nop nop nop nop dec %r15 mov (%r13), %edx nop nop nop and $21261, %rdx lea addresses_UC_ht+0x16a1a, %rsi lea addresses_WC_ht+0x12ca2, %rdi clflush (%rsi) sub %r14, %r14 mov $114, %rcx rep movsq nop inc %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r15 pop %r14 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %rax push %rcx push %rdi push %rdx // Faulty Load mov $0xca2, %r11 nop inc %rax movaps (%r11), %xmm3 vpextrq $1, %xmm3, %rdx lea oracles, %r14 and $0xff, %rdx shlq $12, %rdx mov (%r14,%rdx,1), %rdx pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': True, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': True, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}} {'08': 3, '48': 14, 'ec': 3, 'ff': 1, '00': 21808} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
global userspace_jump extern hl_esp extern hl_eip userspace_jump: mov ax, 0x23 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov eax, dword [hl_esp] push 0x23 push eax pushf ; Enable interrupts sti push 0x1B push dword [hl_eip] iret
_loader_kbd_start: ; ; loader_kbd.asm - This file implements the keyboard driver ; KBD_BUFFER_CAPACITY equ 64 ; The following defines the status word KBD_CTRL_ON equ 01h KBD_SHIFT_ON equ 02h KBD_ALT_ON equ 04h KBD_CAPS_LOCK equ 08h KBD_NUM_LOCK equ 10h ; This flag will be cleared if it is present when an interrupt happens ; The correspinding scan code in the buffer, however, will have it set KBD_EXTENDED_ON equ 20h ; This is not set by the ISR, but when we try to convert a scan code ; to a char, and the scan code is not a char, we just set this flag in ; the status byte (i.e. AH) KBD_UNPRINTABLE equ 40h ; Whether a key is down or up. AND with this and if NE then ; we know it is up - NOTE it is a mask NOT a scancode KBD_KEY_UP equ 80h ; This is the scan code for backspace key KBD_KEY_BKSP equ 0eh KBD_EXTENDED_ARROW_LEFT equ 4bh KBD_EXTENDED_ARROW_RIGHT equ 4dh KBD_EXTENDED_ARROW_UP equ 48h KBD_EXTENDED_ARROW_DOWN equ 50h ; This function intializes the keyboard interrupt kbd_init: push es push bx cli ; Make ES ponits to the first segment push word 0 pop es ; This is the offset of INT 9h mov bx, 9h * 4 mov ax, cs ; Install the offset on lower address and CS segment on higher address mov [es:bx + 2], ax mov word [es:bx], kbd_isr sti pop bx pop es retn ; This is the keyboard interrupt handler ; We pre-process the scan code in the following manner: ; 1. Bytes following 224h is extended key. We will save their scan code ; with extended bit. ; 2. If the lower 7 bits are shift, ctrl, alt then we update the status ; word ; 3. Otherwise we ignore the scan code with bit 7 set (UP key) ; 4. For ordinary keys, we add the scan code of the key in lower ; byte, and the status word in higher byte ; Note that for (1), we cannot do it in one call, because they are sent via 2 ; interupts. We just set the extended flag, and clear it after we have ; received the second byte in a later interrupt kbd_isr: pusha push ds push es ; Reload DS with system segment mov ax, SYS_DS mov ds, ax ; Read from port 0x60 in al, 60h ; Next we process the key and update the current status ; E0H = extended key cmp al, 0e0h je .process_extended_flag ; LEFT SHIFT cmp al, 2ah je .process_shift_down ; RIGHT SHIFT cmp al, 36h je .process_shift_down cmp al, 0aah je .process_shift_up cmp al, 0b6h je .process_shift_up ; Left ctrl cmp al, 1dh je .process_ctrl_down cmp al, 9dh je .process_ctrl_up ; Left ALT cmp al, 38h je .process_alt_down cmp al, 0b8h je .process_alt_up ; CAPS LOCK; Note that for this we just toggle its bit using XOR ; Also we ignore the UP of this key cmp al, 3ah je .process_caps_lock ; CAPS LOCK UP cmp al, 0bah je .finish_interrupt ; NUM LOCK DOWN cmp al, 45h je .process_num_lock ; NUM LOCK UP cmp al, 0c5h je .finish_interrupt test al, KBD_KEY_UP je .process_other_down jmp .process_other_up .process_extended_flag: or byte [kbd_status], KBD_EXTENDED_ON ; Note that since we set the flag on in this interupr, ; we just clear it in the next interrupt, so we should skip ; the part that clears the EXTENDED flag jmp .finish_interrrupt_with_extend_flag .process_shift_down: or byte [kbd_status], KBD_SHIFT_ON jmp .finish_interrupt .process_shift_up: ; Mask off the shift bit and byte [kbd_status], ~KBD_SHIFT_ON jmp .finish_interrupt .process_ctrl_down: or byte [kbd_status], KBD_CTRL_ON jmp .finish_interrupt .process_ctrl_up: and byte [kbd_status], ~KBD_CTRL_ON jmp .finish_interrupt .process_alt_down: or byte [kbd_status], KBD_ALT_ON jmp .finish_interrupt .process_alt_up: and byte [kbd_status], ~KBD_ALT_ON jmp .finish_interrupt .process_caps_lock: xor byte [kbd_status], KBD_CAPS_LOCK jmp .finish_interrupt .process_num_lock: xor byte [kbd_status], KBD_NUM_LOCK jmp .finish_interrupt .process_other_down: ; Use DX to hold the value mov dx, ax mov ax, [kbd_scan_code_buffer_size] cmp ax, KBD_BUFFER_CAPACITY je .full_buffer inc ax mov [kbd_scan_code_buffer_size], ax ; If head cannot be written into, we wrap back to index = 0 ; Otherwise just use head mov ax, [kbd_scan_code_head] cmp ax, KBD_BUFFER_CAPACITY jne .put_buffer xor ax, ax .put_buffer: ; Compute the target address in the buffer in BX ; BX = base + index * 2 ; because each entry is 2 byte mov bx, kbd_scan_code_buffer shl ax, 1 add bx, ax ; Move the head to the next location and store it back shr ax, 1 inc ax mov [kbd_scan_code_head], ax ; Restore AX saved in DX mov ax, dx ; We know DL is the scan code unchanged, and CL is the ; old status bit ; BX is the address to write ; Read the most up-to-date status into DH mov ah, [kbd_status] mov [bx], ax ; Just return .process_other_up: .finish_interrupt: ; Mask off the extended key bit and byte [kbd_status], ~KBD_EXTENDED_ON .finish_interrrupt_with_extend_flag: ; Reset keyboard by reading and writing into 0x61h in al, 61h or al, 80h out 61h, al in al, 61h and al, 7fh out 61h, al ; Send EOI to the PIC mov al, 20h out 20h, al jmp .return .full_buffer: ; Clear the buffer when it overflows mov word [kbd_scan_code_head], 0 mov word [kbd_scan_code_tail], 0 mov word [kbd_scan_code_buffer_size], 0 mov byte [kbd_status], 0 .return: pop es pop ds ; Note that SP is ignored popa iret ; This function is non-blocking ; It returns a scan code from the buffer in AL; If the buffer is empty it ; returns 0 in AX. AH is the status bit when the key is pushed down ; This function is non-blocking. If you need a blocking version, just check ; returned AL value and then loop until it is non-zero kbd_getscancode: ; Must ensure atomicity of this operation cli push bx mov ax, [kbd_scan_code_buffer_size] test ax, ax ; Note that when we do this jump, AX is already zero je .return dec ax mov [kbd_scan_code_buffer_size], ax mov ax, [kbd_scan_code_tail] ; If the tail points to an unreadable location ; we just wrap back and perform the read cmp ax, KBD_BUFFER_CAPACITY jne .fetch_code xor ax, ax .fetch_code: ; BX = base + AX * 2 mov bx, kbd_scan_code_buffer shl ax, 1 add bx, ax ; Increment and write back the index first shr ax, 1 inc ax mov [kbd_scan_code_tail], ax ; Read the scan code mov ax, word [bx] .return: pop bx sti retn ; Flush the keyboard buffer ; This function is always executed atomically kbd_flush: cli mov word [kbd_scan_code_head], 0 mov word [kbd_scan_code_tail], 0 mov word [kbd_scan_code_buffer_size], 0 mov byte [kbd_status], 0 sti retn ; This function converts a AH:AL scan code and its status byte ; to a printable character. AH is not affected. ; If the scan code does not represent a printable char, then we set ; KBD_UNPRINTABLE bit in the status byte (i.e. AH) kbd_tochar: push bx ; Do not support extended keys and control sequence test ah, KBD_EXTENDED_ON jne .return_not_a_char test ah, KBD_CTRL_ON jne .return_not_a_char ; If shift is on we use the other table test ah, KBD_SHIFT_ON jne .use_shift_table mov bx, kbd_unshifted_scan_code_map jmp .translate .use_shift_table: mov bx, kbd_shifted_scan_code_map ; Before entering this part, BX must hold the address of the table .translate: movzx dx, al add bx, dx mov bl, byte [bx] test bl, bl je .return_not_a_char mov al, bl ; Check whether caps lock for letters is on; If not just ; return. Otherwise, we check first whether it is [a, z], ; and if it is, we then convert it to capital test ah, KBD_CAPS_LOCK je .return ; Then test whether it is a character cmp al, 'a' jb .return cmp al, 'z' ja .return and al, 0DFh .return: pop bx retn ; This branch sets the unprintable flag and return .return_not_a_char: or ah, KBD_UNPRINTABLE jmp .return ; This function blocks on the keyboard and receives printable characters. ; The received characters are put into a given buffer, until ENTER or ; CTRL+C is pressed. The former ends this process, and returns with status ; flag indicating that the function returns normally. Otherwise, we return ; status indicating that the process was interrupted ; If the number of characters exceeds the given length, then we stop ; putting anything into the buffer, but the function does not return. ; ; Note: ; (1) This function does not append '\n' at the end. But it appends '\0' ; and the buffer should be long enough to hold the '\0' ; (2) Returns 0 if exited normally; Otherwise interrupted (CTRL+C) ; (3) TAB is ignored; SPACE works as always ; (4) You can use BACKSPACE to go back one character (until the buffer is ; empty). You can also use LEFT and RIGHT arrow keys to move between ; characters. Existing characters will be shifted if you type. ; (5) CTRL+C Interrupts the process and this function returns 0xFFFF ; Otherwise it returns the actual number of bytes ; [SP + 0] Whether to echo back; 0 means echo, 1 means not ; [SP + 2] Length of the buffer (also the max. character count, ; including '\0') ; [SP + 4] Offset of the buffer ; [SP + 6] Segment of the buffer kbd_getinput: push bp mov bp, sp push es push bx push si push di ; Load ES with the target buffer segment mov ax, [bp + 10] mov es, ax ; ES:BX is the offset of the buffer. It always points to the next ; character location mov bx, [bp + 8] ; SI is the address also, but it denotes the current cursor position mov si, bx .next_scancode: call kbd_getscancode test ax, ax je .next_scancode ; If CTRL is on then process CTRL test ah, KBD_CTRL_ON jne .process_ctrl test ah, KBD_EXTENDED_ON jne .process_extended ; If it is ENTER we simply return cmp al, 1ch je .normal_return ; If it is backspace we need to move back cmp al, KBD_KEY_BKSP je .process_bksp ; Translate the scan code to a printable character call kbd_tochar ; Ignore unprintable characters, including TAB test ah, KBD_UNPRINTABLE jne .next_scancode ; Compute the length of (the current string + 1) and the ; the buffer length. If they equal just ignore everything mov dx, bx sub dx, [bp + 8] inc dx cmp dx, [bp + 6] je .next_scancode ; If the cursor is currently not at the end of the input, we need to shift ; the memory buffer right, and then refresh the latter part cmp si, bx jne .shift_right ; Otherwise, put the char into the buffer and move the pointer mov [es:bx], al inc bx ; Also need to change the cursor position inc si ; Then test echo back flag before printing it (if non-zero then do not print) mov dx, [bp + 4] test dx, dx jne .next_scancode mov ah, [video_print_attr] call putchar jmp .next_scancode .process_bksp: ; If we are already at the beginning of the buffer just ignore this cmp bx, [bp + 8] je .next_scancode cmp bx, si jne .shift_left dec bx dec si ; Print BKSP character mov al, KBD_KEY_BKSP call putchar jmp .next_scancode .process_extended: cmp al, KBD_EXTENDED_ARROW_LEFT je .process_left_arrow cmp al, KBD_EXTENDED_ARROW_RIGHT je .process_right_arrow jmp .next_scancode .process_left_arrow: ; If we are already at the beginning of the line, then ignore cmp si, [bp + 8] je .next_scancode call video_clearcursor call video_move_to_prev_char call video_putcursor ; Also decrement SI to reflect the fact dec si jmp .next_scancode .process_right_arrow: ; If we are already on the last location then ignore it cmp si, bx je .next_scancode call video_clearcursor call video_move_to_next_char call video_putcursor inc si jmp .next_scancode .process_ctrl: ; CTRL + C (note that this is raw scan code) cmp al, 2eh je .ctrl_c_return ; By default just ignore it jmp .next_scancode .ctrl_c_return: ; Set AX = 0xFFFF xor ax, ax dec ax jmp .return ; This branch handles the backspace in the middle of the input ; buffer. We just shift everything on and after the location pointed to by SI .shift_left: mov dx, bx sub dx, si push word 1 push dx push es push si call memshift_tolow add sp, 8 dec bx dec si ; Check ECHO flag mov dx, [bp + 4] test dx, dx jne .next_scancode call video_clearcursor call video_move_to_prev_char mov di, si .shift_left_loop_body: cmp di, bx je .shift_left_after_loop mov al, [es:di] mov ah, [video_print_attr] mov cx, di sub cx, si call video_raw_put inc di jmp .shift_left_loop_body .shift_left_after_loop: ; Clear the last character also mov ax, 0700h mov cx, di sub cx, si call video_raw_put call video_putcursor jmp .next_scancode ; Before entering this, AL contains the scan code .shift_right: ; DX = the # of chars need to shift mov dx, bx sub dx, si ; Protect AX mov di, ax ; Amount, length, segment and offset push word 1 push dx push es push si call memshift_tohigh add sp, 8 ; AL is the scan code mov ax, di mov [es:si], al ; Also increase the length of the buffer inc bx ; After inserting the data, check whether each is allowed; if not ; continue with the next char mov dx, [bp + 4] test dx, dx jne .next_scancode ; Use DI as loop var to print mov di, si .shift_right_loop_body: cmp di, bx je .shift_right_after_loop_body mov al, [es:di] mov ah, [video_print_attr] call putchar inc di jmp .shift_right_loop_body ; Move the cursor back to the new location .shift_right_after_loop_body: ; Cursor also moves right by one together with the char inc si call video_clearcursor ; This is the difference we need to move the cursor mov di, bx sub di, si neg di push di call video_move_cursor ; Clear stack pop ax call video_putcursor jmp .next_scancode .normal_return: ; Terminate the string mov byte [es:bx], 0 ; Compute the actual number we have read mov ax, bx sub ax, [bp + 10] .return: ; Protect return value mov di, ax ; First we need to movre cursor to the end of the input call video_clearcursor mov ax, bx sub ax, si push ax call video_move_cursor pop ax call video_putcursor ; Then print a new line mov al, 0ah call putchar ; Restore value mov ax, di pop di pop si pop bx pop es mov sp, bp pop bp retn ; This is the scan code buffer (128 byte, 64 entries currently) kbd_scan_code_buffer: times KBD_BUFFER_CAPACITY dw 0 ; This always points to the next location to push new code kbd_scan_code_head: dw 0 ; This always points to the oldest valid code kbd_scan_code_tail: dw 0 kbd_scan_code_buffer_size: dw 0 ; This status byte is updated kbd_status: db 0 ; Only the first 127 entries are useful ; We currently only have 64 entries; In the future this table can be extended to ; support more kbd_unshifted_scan_code_map: ; 0 1 2 3 4 5 6 7 8 9 A B C D E F db 00h, 00h, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 00h, 00h ; 0 db 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 00h, 00h, 'a', 's' ; 1 db 'd', 'f', 'g', 'h', 'j', 'k', 'l', 3bh, 27h, '`', 00h, 5ch, 'z', 'x', 'c', 'v' ; 2 db 'b', 'n', 'm', ',', '.', '/', 00h, 00h, 00h, 20h, 00h, 00h, 00h, 00h, 00h, 00h ; 3 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 4 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 5 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 6 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 7 kbd_shifted_scan_code_map: ; 0 1 2 3 4 5 6 7 8 9 A B C D E F db 00h, 00h, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 00h, 00h ; 0 db 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 00h, 00h, 'A', 'S' ; 1 db 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 22h, '~', 00h, '|', 'Z', 'X', 'C', 'V' ; 2 db 'B', 'N', 'M', '<', '>', '?', 00h, 00h, 00h, 20h, 00h, 00h, 00h, 00h, 00h, 00h ; 3 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 4 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 5 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 6 ;db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; 7
; ; Z88 Graphics Functions ; Written around the Interlogic Standard Library ; ; Wide resolution (int type parameters) and CALLEE conversion by Stefano Bodrato, 2018 ; ; ; $Id: w_drawr_callee.asm $ ; ; ----- void __CALLEE__ drawr_callee(int x, int y) SECTION code_graphics PUBLIC drawr_callee PUBLIC _drawr_callee PUBLIC ASMDISP_DRAWR_CALLEE EXTERN swapgfxbk ;EXTERN swapgfxbk1 ; EXTERN __gfx_color EXTERN w_line_r EXTERN w_plotpixel EXTERN __graphics_end .drawr_callee ._drawr_callee pop af ; pop bc pop de pop hl push af .asmentry ; ld a,c ; ld (__gfx_color),a push ix call swapgfxbk ld ix,w_plotpixel call w_line_r jp __graphics_end DEFC ASMDISP_DRAWR_CALLEE = asmentry - drawr_callee
; ; Copyright (c) 2016, Alliance for Open Media. All rights reserved ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License ; was not distributed with this source code in the LICENSE file, you can ; obtain it at www.aomedia.org/license/software. If the Alliance for Open ; Media Patent License 1.0 was not distributed with this source code in the ; PATENTS file, you can obtain it at www.aomedia.org/license/patent. ; ; %include "aom_ports/x86_abi_support.asm" ; tabulate_ssim - sums sum_s,sum_r,sum_sq_s,sum_sq_r, sum_sxr %macro TABULATE_SSIM 0 paddusw xmm15, xmm3 ; sum_s paddusw xmm14, xmm4 ; sum_r movdqa xmm1, xmm3 pmaddwd xmm1, xmm1 paddd xmm13, xmm1 ; sum_sq_s movdqa xmm2, xmm4 pmaddwd xmm2, xmm2 paddd xmm12, xmm2 ; sum_sq_r pmaddwd xmm3, xmm4 paddd xmm11, xmm3 ; sum_sxr %endmacro ; Sum across the register %1 starting with q words %macro SUM_ACROSS_Q 1 movdqa xmm2,%1 punpckldq %1,xmm0 punpckhdq xmm2,xmm0 paddq %1,xmm2 movdqa xmm2,%1 punpcklqdq %1,xmm0 punpckhqdq xmm2,xmm0 paddq %1,xmm2 %endmacro ; Sum across the register %1 starting with q words %macro SUM_ACROSS_W 1 movdqa xmm1, %1 punpcklwd %1,xmm0 punpckhwd xmm1,xmm0 paddd %1, xmm1 SUM_ACROSS_Q %1 %endmacro ;void ssim_parms_sse2( ; unsigned char *s, ; int sp, ; unsigned char *r, ; int rp ; unsigned long *sum_s, ; unsigned long *sum_r, ; unsigned long *sum_sq_s, ; unsigned long *sum_sq_r, ; unsigned long *sum_sxr); ; ; TODO: Use parm passing through structure, probably don't need the pxors ; ( calling app will initialize to 0 ) could easily fit everything in sse2 ; without too much hastle, and can probably do better estimates with psadw ; or pavgb At this point this is just meant to be first pass for calculating ; all the parms needed for 16x16 ssim so we can play with dssim as distortion ; in mode selection code. global sym(av1_ssim_parms_16x16_sse2) PRIVATE sym(av1_ssim_parms_16x16_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 9 SAVE_XMM 15 push rsi push rdi ; end prolog mov rsi, arg(0) ;s mov rcx, arg(1) ;sp mov rdi, arg(2) ;r mov rax, arg(3) ;rp pxor xmm0, xmm0 pxor xmm15,xmm15 ;sum_s pxor xmm14,xmm14 ;sum_r pxor xmm13,xmm13 ;sum_sq_s pxor xmm12,xmm12 ;sum_sq_r pxor xmm11,xmm11 ;sum_sxr mov rdx, 16 ;row counter .NextRow: ;grab source and reference pixels movdqu xmm5, [rsi] movdqu xmm6, [rdi] movdqa xmm3, xmm5 movdqa xmm4, xmm6 punpckhbw xmm3, xmm0 ; high_s punpckhbw xmm4, xmm0 ; high_r TABULATE_SSIM movdqa xmm3, xmm5 movdqa xmm4, xmm6 punpcklbw xmm3, xmm0 ; low_s punpcklbw xmm4, xmm0 ; low_r TABULATE_SSIM add rsi, rcx ; next s row add rdi, rax ; next r row dec rdx ; counter jnz .NextRow SUM_ACROSS_W xmm15 SUM_ACROSS_W xmm14 SUM_ACROSS_Q xmm13 SUM_ACROSS_Q xmm12 SUM_ACROSS_Q xmm11 mov rdi,arg(4) movd [rdi], xmm15; mov rdi,arg(5) movd [rdi], xmm14; mov rdi,arg(6) movd [rdi], xmm13; mov rdi,arg(7) movd [rdi], xmm12; mov rdi,arg(8) movd [rdi], xmm11; ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void ssim_parms_sse2( ; unsigned char *s, ; int sp, ; unsigned char *r, ; int rp ; unsigned long *sum_s, ; unsigned long *sum_r, ; unsigned long *sum_sq_s, ; unsigned long *sum_sq_r, ; unsigned long *sum_sxr); ; ; TODO: Use parm passing through structure, probably don't need the pxors ; ( calling app will initialize to 0 ) could easily fit everything in sse2 ; without too much hastle, and can probably do better estimates with psadw ; or pavgb At this point this is just meant to be first pass for calculating ; all the parms needed for 16x16 ssim so we can play with dssim as distortion ; in mode selection code. global sym(av1_ssim_parms_8x8_sse2) PRIVATE sym(av1_ssim_parms_8x8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 9 SAVE_XMM 15 push rsi push rdi ; end prolog mov rsi, arg(0) ;s mov rcx, arg(1) ;sp mov rdi, arg(2) ;r mov rax, arg(3) ;rp pxor xmm0, xmm0 pxor xmm15,xmm15 ;sum_s pxor xmm14,xmm14 ;sum_r pxor xmm13,xmm13 ;sum_sq_s pxor xmm12,xmm12 ;sum_sq_r pxor xmm11,xmm11 ;sum_sxr mov rdx, 8 ;row counter .NextRow: ;grab source and reference pixels movq xmm3, [rsi] movq xmm4, [rdi] punpcklbw xmm3, xmm0 ; low_s punpcklbw xmm4, xmm0 ; low_r TABULATE_SSIM add rsi, rcx ; next s row add rdi, rax ; next r row dec rdx ; counter jnz .NextRow SUM_ACROSS_W xmm15 SUM_ACROSS_W xmm14 SUM_ACROSS_Q xmm13 SUM_ACROSS_Q xmm12 SUM_ACROSS_Q xmm11 mov rdi,arg(4) movd [rdi], xmm15; mov rdi,arg(5) movd [rdi], xmm14; mov rdi,arg(6) movd [rdi], xmm13; mov rdi,arg(7) movd [rdi], xmm12; mov rdi,arg(8) movd [rdi], xmm11; ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret
############################################################################### # File : lw.asm # Project : MIPS32 MUX # Author: : Grant Ayers (ayers@cs.stanford.edu) # # Standards/Formatting: # MIPS gas, soft tab, 80 column # # Description: # Test the functionality of the 'lw' instruction. # ############################################################################### .section .test, "x" .balign 4 .set noreorder .global test .ent test test: lui $s0, 0xbfff # Load the base address 0xbffffff0 ori $s0, 0xfff0 ori $s1, $0, 1 # Prepare the 'done' status #### Test code start #### lui $t0, 0xbfc0 # Load a valid address (last word in 2KB starting ori $t0, 0x07fc # from 0xbfc00000) sw $0, 0($t0) ori $t1, $0, 1 sw $t1, 0($t0) lw $v0, 0($t0) #### Test code end #### sw $v0, 8($s0) # Set the test result sw $s1, 4($s0) # Set 'done' $done: jr $ra nop .end test
; A208176: a(n) = F(n+1)^2, if n>=0 is even (F=A000045) and a(n) = (L(2n+2)+8)/5, if n is odd (L=A000204). ; 1,3,4,11,25,66,169,443,1156,3027,7921,20738,54289,142131,372100,974171,2550409,6677058,17480761,45765227,119814916,313679523,821223649,2149991426,5628750625,14736260451,38580030724,101003831723,264431464441,692290561602,1812440220361,4745030099483,12422650078084,32522920134771,85146110326225,222915410843906,583600122205489,1527884955772563,4000054745112196,10472279279564027,27416783093579881,71778070001175618,187917426909946969,491974210728665291,1288005205276048900,3372041405099481411,8828119010022395329,23112315624967704578,60508827864880718401,158414167969674450627,414733676044142633476,1085786860162753449803,2842626904444117715929,7442093853169599697986,19483654655064681378025,51008870112024444436091,133542955681008651930244,349619996931001511354643,915317035111995882133681,2396331108404986135046402,6273676290102962523005521,16424697761903901433970163,43000416995608741778904964,112576553224922323902744731,294729242679158229929329225,771611174812552365885242946,2020104281758498867726399609,5288701670462944237293955883,13846000729630333844155468036,36249300518428057295172448227,94901900825653838041361876641,248456401958533456828913181698,650467305049946532445377668449,1702945513191306140507219823651,4458369234523971889076281802500,11672162190380609526721625583851,30558117336617856691088594949049,80002189819472960546544159263298,209448452121801024948543882840841,548343166545930114299087489259227,1435581047515989317948718584936836,3758399976002037839547068265551283,9839618880490124200692486211717009,25760456665468334762530390369599746,67441751115914880086898684897082225,176564796682276305498165664321646931,462252638930914036407598308067858564 add $0,2 lpb $0 sub $0,1 sub $1,$4 trn $1,5 add $2,$1 add $1,$2 add $1,6 mov $3,2 sub $3,$4 mov $4,$3 lpe sub $1,5 mov $0,$1
; Troy's HBC-56 - TMS9918 Console mode test ; ; Copyright (c) 2021 Troy Schrapel ; ; This code is licensed under the MIT license ; ; https://github.com/visrealm/hbc-56 ; !src "hbc56kernel.inc" hbc56Meta: +setHbcMetaTitle "CONSOLE TEST" rts hbc56Main: sei jsr kbInit jsr tmsModeText +tmsUpdateFont TMS_TEXT_MODE_FONT +tmsSetColorFgBg TMS_LT_GREEN, TMS_BLACK +tmsEnableOutput cli +tmsEnableInterrupts +consoleEnableCursor .consoleLoop: jsr kbReadAscii bcc .consoleLoop ; output 'A' to console jsr tmsConsoleOut jmp .consoleLoop TMS_TEXT_MODE_FONT: !src "gfx/fonts/tms9918font2subset.asm"
IF DEF(@) PRINTT "defined\n" ELSE PRINTT "not defined\n" ENDC
; A155110: a(n) = 8*Fibonacci(2n+1). ; 8,16,40,104,272,712,1864,4880,12776,33448,87568,229256,600200,1571344,4113832,10770152,28196624,73819720,193262536,505967888,1324641128,3467955496,9079225360,23769720584,62229936392,162920088592,426530329384,1116670899560,2923482369296,7653776208328,20037846255688,52459762558736,137341441420520,359564561702824,941352243687952,2464492169361032,6452124264395144,16891880623824400,44223517607078056,115778672197409768,303112498985151248,793558824758043976,2077563975288980680,5439133101108898064 mov $1,8 lpb $0 sub $0,1 add $2,$1 add $1,$2 lpe mov $0,$1
; A023475: n-33. ; -33,-32,-31,-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 sub $0,33
;; ;; WCRT - Win32API CRT ;; ;; math sinf ;; ;; Copyright (c) 2003-2004 by Joergen Ibsen / Jibz ;; All Rights Reserved ;; ;; http://www.ibsensoftware.com/ ;; ;; This software is provided 'as-is', without any express ;; or implied warranty. In no event will the authors be ;; held liable for any damages arising from the use of ;; this software. ;; ;; Permission is granted to anyone to use this software ;; for any purpose, including commercial applications, ;; and to alter it and redistribute it freely, subject to ;; the following restrictions: ;; ;; 1. The origin of this software must not be ;; misrepresented; you must not claim that you ;; wrote the original software. If you use this ;; software in a product, an acknowledgment in ;; the product documentation would be appreciated ;; but is not required. ;; ;; 2. Altered source versions must be plainly marked ;; as such, and must not be misrepresented as ;; being the original software. ;; ;; 3. This notice may not be removed or altered from ;; any source distribution. ;; .386 .model flat,c option casemap:none public sinf .code ; ============================================================= sinf: ; float sinf(float x) _x$ = 4 fld real4 ptr [esp + _x$] fsin ret ; ============================================================= end
; UI for the CHIP4504 Operating System ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; os_draw_block -- Render block of specified colour ; IN: BL/DL/DH/SI/DI = colour/start X pos/start Y pos/width/finish Y pos [SECTION .text] %define ITEMS_PER_PAGE 8 %define STARTING_PAGE 8 os_draw_block: pusha .more: call os_move_cursor mov ah, 0x09 mov bh, 0 mov cx, si mov al, ' ' int 10h inc dh mov ax, 0 mov al, dh cmp ax, di jne .more popa ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; os_draw_back ; AX - Up text, BX - Bottom text os_draw_back: pusha call os_clear_screen push bx push ax mov bl, 0x70 mov dl, 0 mov dh, 1 mov si, 80 mov di, 24 call os_draw_block mov bl, 0x0F mov dl, 0 mov dh, 0 mov si, 80 mov di, 1 call os_draw_block mov bl, 0x0F mov dl, 0 mov dh, 24 mov si, 80 mov di, 25 call os_draw_block mov dl, 0 mov dh, 0 call os_move_cursor pop ax mov si, ax call os_print_string mov dl, 0 mov dh, 24 call os_move_cursor pop ax mov si, ax call os_print_string popa ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; os_prepare_UI: mov ax, UI_top_string mov bx, UI_bottom_string call os_draw_back ret [SECTION .data] UI_top_string: db '[CHIP4504 Operating System (C) Benderx2, http://github.com/Benderx2/]', 0 UI_bottom_string: db '[Running on x86-16, Version: ', VERSION_STRING, ' ]', 0 [SECTION .text] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; os_gen_file_list ; Generate a file list. ; Whenever a file is selected and ENTER is pressed, SI is returned as the file name. os_gen_file_list: pusha mov byte [.current_y], 8 mov word [.no_of_entries], 0 mov word [.no_of_pages], 1 mov word [.current_page], 1 mov ax, file_list call os_list_files mov cx, 1 mov si, file_list .count: lodsb cmp al, 0 je .done cmp al, ',' jne .count inc cx jmp .count .done: mov word [.no_of_entries], cx xor dx, dx mov ax, word [.no_of_entries] cmp ax, 8 jle .one_page_only mov cx, ITEMS_PER_PAGE div cx cmp dx, 0 je .no_remainder add ax, 1 .no_remainder: mov word [.no_of_pages], ax jmp .display_files .one_page_only: mov word [.no_of_pages], 1 .display_files: mov bl, 0x1F mov dl, 24 mov dh, 2 mov si, 32 mov di, 22 call os_draw_block mov bl, 0xF0 mov dl, 25 mov dh, 7 mov si, 30 mov di, 20 call os_draw_block mov dh, 3 mov dl, 25 call os_move_cursor mov si, .list_help_1 call os_print_string mov dh, 4 mov dl, 25 call os_move_cursor mov si, .list_help_2 call os_print_string mov dh, 5 mov dl, 25 call os_move_cursor mov si, .list_help_3 call os_print_string call os_hide_cursor ; get current page xor dx, dx mov ax, 8 mov cx, word [.current_page] dec cx mul cx ; got the starting point, now to find it where the name begins in the file list mov si, file_list mov cx, ax .find_start_of_name: cmp cx, 0 je .done_find lodsb cmp al, ',' je .found_sep cmp al, 0 je .found_sep jmp .find_start_of_name .found_sep: dec cx jmp .find_start_of_name .done_find: ; SI = Start of file list. mov cx, ITEMS_PER_PAGE .loop_begin: mov di, .temp_file_name mov dl, 30 mov dh, byte [.current_y] call os_move_cursor .name_loop: mov al, byte [si] inc si cmp cx, 0 je .listing_complete cmp al, 0 je .listing_complete cmp al, ',' je .name_complete mov byte [di], al inc di jmp .name_loop .name_complete: mov byte [di], 0 push si mov si, .temp_file_name call os_print_string pop si add byte [.current_y], 1 dec cx jmp .loop_begin .listing_complete: mov byte [di], 0 mov si, .temp_file_name call os_print_string .begin_poll: mov byte [.current_y], 8 .polling: mov dl, 25 mov dh, 20 call os_move_cursor mov si, .first_page_string call os_print_string mov ax, word [.current_page] call os_int_to_string mov si, ax call os_print_string mov si, .second_page_string call os_print_string mov ax, word [.no_of_pages] call os_int_to_string mov si, ax call os_print_string mov dl, 26 mov dh, byte [.current_y] call os_move_cursor mov cx, 1 mov bh, 0 mov bl, 0xF4 mov ah, 0x09 mov al, '$' int 0x10 call os_wait_for_key cmp al, 'w' je .go_up cmp al, 's' je .go_down cmp al, 'd' je .go_next cmp al, 'a' je .go_previous cmp al, 13 je .go_enter jmp .polling .go_up: mov al, byte [.current_y] sub al, STARTING_PAGE cmp al, 0 je .polling call .remove_cur dec byte [.current_y] jmp .polling .go_down: xor bx, bx mov bl, byte [.current_y] sub bl, STARTING_PAGE ; End of Page? cmp bl, 7 je .polling ; Is this the last entry? mov ax, word [.current_page] sub ax, 1 mov cx, ITEMS_PER_PAGE mul cx add ax, bx inc ax cmp ax, word [.no_of_entries] je .polling call .remove_cur inc byte [.current_y] jmp .polling .go_previous: mov ax, word [.current_page] cmp ax, 1 je .polling dec word [.current_page] mov byte [.current_y], 8 jmp .display_files .go_next: mov ax, word [.current_page] mov bx, word [.no_of_pages] cmp ax, bx je .polling inc word [.current_page] mov byte [.current_y], 8 jmp .display_files .go_enter: ; Get shit mate xor dx, dx xor bx, bx mov ax, word [.current_page] dec ax mov bl, byte [.current_y] sub bl, STARTING_PAGE mov cx, 8 mul cx add ax, bx mov dx, ax ; Got the index! Now to find the file .find_filename: mov si, file_list .find_fileloop: cmp dx, 0 je .found_file_name lodsb cmp al, 0 je .wtf_err cmp al, ',' je .found_sep2 jmp .find_fileloop .wtf_err: call os_clear_screen mov ah, 0x0E mov al, 'E' int 0x10 cli hlt jmp $ .found_sep2: dec dx jmp .find_fileloop .found_file_name: mov di, .temp_file_name ; Fetch until 0 or ',' .store_loop: lodsb cmp al, 0 je .done_fetch cmp al, ',' je .done_fetch stosb jmp .store_loop .done_fetch: mov al, 0 stosb popa mov si, .temp_file_name ret .remove_cur: pusha ; remove cursor at last position mov dl, 26 mov dh, byte [.current_y] call os_move_cursor mov ah, 0x0E mov al, ' ' int 0x10 popa ret [SECTION .data] .current_page: dw 1 .no_of_pages: dw 1 .no_of_entries: dw 0 .temp_file_name: times 14 db 0 .current_y: db 8 .first_page_string: db 'Page ', 0 .second_page_string: db ' of ', 0 .list_help_1: db 'ENTER - Select File', 0 .list_help_2: db 'W/S - Up/down', 0 .list_help_3: db 'A/D - Next/Previous', 0 [SECTION .text]
; A244953: a(n) = Sum_{i=0..n} (-i mod 4). ; 0,3,5,6,6,9,11,12,12,15,17,18,18,21,23,24,24,27,29,30,30,33,35,36,36,39,41,42,42,45,47,48,48,51,53,54,54,57,59,60,60,63,65,66,66,69,71,72,72,75,77,78,78,81,83,84,84,87,89,90,90,93,95,96,96,99,101,102,102,105,107,108,108,111,113,114,114,117,119,120,120,123,125,126,126,129,131,132,132,135,137,138,138,141,143,144,144,147,149,150 lpb $0 mov $2,$0 sub $0,1 seq $2,158459 ; Period 4: repeat [0, 3, 2, 1]. add $1,$2 lpe mov $0,$1
#include <inttypes.h> #include <memory> #include <new> #include <string> #include <utility> #include <vector> #include "WAVM/IR/IR.h" #include "WAVM/IR/Module.h" #include "WAVM/IR/Types.h" #include "WAVM/Inline/BasicTypes.h" #include "WAVM/Inline/Serialization.h" #include "WAVM/Logging/Logging.h" using namespace WAVM; using namespace WAVM::IR; using namespace WAVM::Serialization; enum class NameSubsectionType : U8 { module = 0, function = 1, local = 2, label = 3, type = 4, table = 5, memory = 6, global = 7, invalid = 0xff }; static void deserializeNameMap(InputStream& stream, std::vector<std::string>& outNames, Uptr maxNames) { Uptr numNames = 0; serializeVarUInt32(stream, numNames); for(Uptr serializedNameIndex = 0; serializedNameIndex < numNames; ++serializedNameIndex) { Uptr nameIndex = 0; serializeVarUInt32(stream, nameIndex); std::string nameString; serialize(stream, nameString); if(nameIndex >= maxNames) { throw FatalSerializationException("out-of-bounds name index"); } if(nameIndex >= outNames.size()) { outNames.resize(nameIndex + 1); } outNames[nameIndex] = std::move(nameString); } } static void serializeNameMap(OutputStream& stream, const std::vector<std::string>& outNames) { Uptr numNames = 0; for(Uptr nameIndex = 0; nameIndex < outNames.size(); ++nameIndex) { if(outNames[nameIndex].size()) { ++numNames; } } serializeVarUInt32(stream, numNames); for(Uptr nameIndex = 0; nameIndex < outNames.size(); ++nameIndex) { if(outNames[nameIndex].size()) { serializeVarUInt32(stream, nameIndex); std::string nameString = outNames[nameIndex]; serialize(stream, nameString); } } } static void deserializeNameSubsection(const Module& module, DisassemblyNames& outNames, InputStream& stream) { U8 subsectionType = (U8)NameSubsectionType::invalid; serializeVarUInt7(stream, subsectionType); U32 numSubsectionBytes = 0; serializeVarUInt32(stream, numSubsectionBytes); MemoryInputStream substream(stream.advance(numSubsectionBytes), numSubsectionBytes); switch((NameSubsectionType)subsectionType) { case NameSubsectionType::module: { serialize(substream, outNames.moduleName); break; } case NameSubsectionType::function: { U32 numFunctionNames = 0; serializeVarUInt32(substream, numFunctionNames); for(Uptr functionNameIndex = 0; functionNameIndex < numFunctionNames; ++functionNameIndex) { U32 functionIndex = 0; serializeVarUInt32(substream, functionIndex); std::string functionName; serialize(substream, functionName); if(functionIndex < outNames.functions.size()) { outNames.functions[functionIndex].name = std::move(functionName); } } break; } case NameSubsectionType::local: { U32 numFunctionLocalNameMaps = 0; serializeVarUInt32(substream, numFunctionLocalNameMaps); for(Uptr functionNameIndex = 0; functionNameIndex < numFunctionLocalNameMaps; ++functionNameIndex) { U32 functionIndex = 0; serializeVarUInt32(substream, functionIndex); if(functionIndex < outNames.functions.size()) { deserializeNameMap(substream, outNames.functions[functionIndex].locals, outNames.functions[functionIndex].locals.size()); } else { Log::printf(Log::debug, "Invalid WASM binary local name section function index: %u >= %" PRIuPTR "\n", functionIndex, Uptr(outNames.functions.size())); break; } } break; } case NameSubsectionType::label: { if(!module.featureSpec.extendedNamesSection) { throw FatalSerializationException( "label name subsection requires extendedNamesSection feature"); } U32 numFunctionLabelNameMaps = 0; serializeVarUInt32(substream, numFunctionLabelNameMaps); for(Uptr functionNameIndex = 0; functionNameIndex < numFunctionLabelNameMaps; ++functionNameIndex) { U32 functionIndex = 0; serializeVarUInt32(substream, functionIndex); if(functionIndex < outNames.functions.size()) { deserializeNameMap(substream, outNames.functions[functionIndex].labels, module.featureSpec.maxLabelsPerFunction); } else { Log::printf(Log::debug, "Invalid WASM binary label name section function index: %u >= %" PRIuPTR "\n", functionIndex, Uptr(outNames.functions.size())); break; } } break; } case NameSubsectionType::type: if(!module.featureSpec.extendedNamesSection) { throw FatalSerializationException( "type name subsection requires extendedNamesSection feature"); } deserializeNameMap(substream, outNames.types, outNames.types.size()); break; case NameSubsectionType::table: if(!module.featureSpec.extendedNamesSection) { throw FatalSerializationException( "table name subsection requires extendedNamesSection feature"); } deserializeNameMap(substream, outNames.tables, outNames.tables.size()); break; case NameSubsectionType::memory: if(!module.featureSpec.extendedNamesSection) { throw FatalSerializationException( "memory name subsection requires extendedNamesSection feature"); } deserializeNameMap(substream, outNames.memories, outNames.memories.size()); break; case NameSubsectionType::global: if(!module.featureSpec.extendedNamesSection) { throw FatalSerializationException( "global name subsection requires extendedNamesSection feature"); } deserializeNameMap(substream, outNames.globals, outNames.globals.size()); break; default: Log::printf(Log::debug, "Unknown WASM binary name subsection type: %u\n", subsectionType); break; }; } void IR::getDisassemblyNames(const Module& module, DisassemblyNames& outNames) { // Fill in the output with the correct number of blank names. for(const auto& functionImport : module.functions.imports) { DisassemblyNames::Function functionNames; functionNames.locals.resize(module.types[functionImport.type.index].params().size()); outNames.functions.push_back(std::move(functionNames)); } for(Uptr functionDefIndex = 0; functionDefIndex < module.functions.defs.size(); ++functionDefIndex) { const FunctionDef& functionDef = module.functions.defs[functionDefIndex]; DisassemblyNames::Function functionNames; functionNames.locals.insert(functionNames.locals.begin(), module.types[functionDef.type.index].params().size() + functionDef.nonParameterLocalTypes.size(), ""); outNames.functions.push_back(std::move(functionNames)); } outNames.types.insert(outNames.types.end(), module.types.size(), ""); outNames.tables.insert(outNames.tables.end(), module.tables.size(), ""); outNames.memories.insert(outNames.memories.end(), module.memories.size(), ""); outNames.globals.insert(outNames.globals.end(), module.globals.size(), ""); outNames.exceptionTypes.insert(outNames.exceptionTypes.end(), module.exceptionTypes.size(), ""); // Deserialize the name section, if it is present. Uptr userSectionIndex = 0; if(findUserSection(module, "name", userSectionIndex)) { try { const UserSection& nameSection = module.userSections[userSectionIndex]; MemoryInputStream stream(nameSection.data.data(), nameSection.data.size()); while(stream.capacity()) { deserializeNameSubsection(module, outNames, stream); }; } catch(FatalSerializationException exception) { Log::printf( Log::debug, "FatalSerializationException while deserializing WASM user name section: %s\n", exception.message.c_str()); } catch(std::bad_alloc) { Log::printf( Log::debug, "Memory allocation failed while deserializing WASM user name section. Input is " "likely malformed."); } } } template<typename SerializeBody> void serializeNameSubsection(OutputStream& stream, NameSubsectionType type, SerializeBody serializeBody) { ArrayOutputStream subsectionStream; serializeBody(subsectionStream); serialize(stream, *(U8*)&type); std::vector<U8> bytes = subsectionStream.getBytes(); serialize(stream, bytes); } void IR::setDisassemblyNames(Module& module, const DisassemblyNames& names) { // Replace an existing name section if one is present, or create a new section. Uptr userSectionIndex = 0; if(!findUserSection(module, "name", userSectionIndex)) { userSectionIndex = module.userSections.size(); module.userSections.push_back({"name", {}}); } ArrayOutputStream stream; // Module name serializeNameSubsection( stream, NameSubsectionType::module, [&names](OutputStream& subsectionStream) { std::string moduleName = names.moduleName; serialize(subsectionStream, moduleName); }); // Function names serializeNameSubsection( stream, NameSubsectionType::function, [&names](OutputStream& subsectionStream) { Uptr numFunctionNames = names.functions.size(); serializeVarUInt32(subsectionStream, numFunctionNames); for(Uptr functionIndex = 0; functionIndex < names.functions.size(); ++functionIndex) { serializeVarUInt32(subsectionStream, functionIndex); std::string functionName = names.functions[functionIndex].name; serialize(subsectionStream, functionName); } }); // Local names. serializeNameSubsection( stream, NameSubsectionType::local, [&names](OutputStream& subsectionStream) { Uptr numFunctionNames = names.functions.size(); serializeVarUInt32(subsectionStream, numFunctionNames); for(Uptr functionIndex = 0; functionIndex < names.functions.size(); ++functionIndex) { serializeVarUInt32(subsectionStream, functionIndex); serializeNameMap(subsectionStream, names.functions[functionIndex].locals); } }); if(module.featureSpec.extendedNamesSection) { // Label names. serializeNameSubsection( stream, NameSubsectionType::label, [&names](OutputStream& subsectionStream) { Uptr numFunctionNames = names.functions.size(); serializeVarUInt32(subsectionStream, numFunctionNames); for(Uptr functionIndex = 0; functionIndex < names.functions.size(); ++functionIndex) { serializeVarUInt32(subsectionStream, functionIndex); serializeNameMap(subsectionStream, names.functions[functionIndex].labels); } }); // Type names serializeNameSubsection( stream, NameSubsectionType::type, [&names](OutputStream& subsectionStream) { serializeNameMap(subsectionStream, names.types); }); // Table names serializeNameSubsection( stream, NameSubsectionType::table, [&names](OutputStream& subsectionStream) { serializeNameMap(subsectionStream, names.tables); }); // Memory names serializeNameSubsection( stream, NameSubsectionType::memory, [&names](OutputStream& subsectionStream) { serializeNameMap(subsectionStream, names.memories); }); // Global names serializeNameSubsection( stream, NameSubsectionType::global, [&names](OutputStream& subsectionStream) { serializeNameMap(subsectionStream, names.globals); }); } module.userSections[userSectionIndex].data = stream.getBytes(); }
; vvvvv ; ^^^^^ ;# log10(2^n) = y ;# 10^y = 2^n ;# log10(2^n)=n*log10(2) ;# 10^(n*log10(2)) = 2^n ;# m*2^n = m*10^(n*log10(2)) = m*10^(int+mod) = m * 10^int * 10^mod = m * 10^mod * Eint = 1 .. 1.9 10^mod * Eint = 1.0 .. 19.99 Eint ORG 0x8000 ; === b e g i n === ld (Stop+1), SP ; 4:20 init storing the original SP value when the "bye" word is used ld L, 0x1A ; 2:7 init Upper screen call 0x1605 ; 3:17 init Open channel ld HL, 60000 ; 3:10 init Init Return address stack exx ; 1:4 init ld hl, stack_test push hl push DE ; 1:11 push2(0x4000,49) ld DE, 0x4000 ; 3:10 push2(0x4000,49) push HL ; 1:11 push2(0x4000,49) ld HL, 49 ; 3:10 push2(0x4000,49) sfor101: ; sfor 101 ( index -- index ) ex DE, HL ; 1:4 swap ( b a -- a b ) push DE ; 1:11 push(0x4100) ex DE, HL ; 1:4 push(0x4100) ld HL, 0x4100 ; 3:10 push(0x4100) ld B, D ; 1:4 f/ ld C, E ; 1:4 f/ call fDiv ; 3:17 f/ HL = BC/HL pop DE ; 1:10 f/ ex DE, HL ; 1:4 swap ( b a -- a b ) ld A, H ; 1:4 snext 101 or L ; 1:4 snext 101 dec HL ; 1:6 snext 101 index-- jp nz, sfor101 ; 3:10 snext 101 snext101: ; snext 101 ex DE, HL ; 1:4 sfor unloop 101 pop DE ; 1:10 sfor unloop 101 call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(0x4000,0x4100) ld DE, 0x4000 ; 3:10 push2(0x4000,0x4100) push HL ; 1:11 push2(0x4000,0x4100) ld HL, 0x4100 ; 3:10 push2(0x4000,0x4100) call fAdd ; 3:17 f+ pop DE ; 1:10 f+ call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(0x4000,0x4100) ld DE, 0x4000 ; 3:10 push2(0x4000,0x4100) push HL ; 1:11 push2(0x4000,0x4100) ld HL, 0x4100 ; 3:10 push2(0x4000,0x4100) call fSub ; 3:17 f- pop DE ; 1:10 f- call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(0,0) ld DE, 0 ; 3:10 push2(0,0) push HL ; 1:11 push2(0,0) ld HL, 0 ; 3:10 push2(0,0) call fIld ; 3:17 s>f call fDot ; 3:17 f. ld A, ' ' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fIld ; 3:17 s>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(-3,3) ld DE, -3 ; 3:10 push2(-3,3) push HL ; 1:11 push2(-3,3) ld HL, 3 ; 3:10 push2(-3,3) call fIld ; 3:17 s>f call fDot ; 3:17 f. ld A, ' ' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fIld ; 3:17 s>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(-503,503) ld DE, -503 ; 3:10 push2(-503,503) push HL ; 1:11 push2(-503,503) ld HL, 503 ; 3:10 push2(-503,503) call fIld ; 3:17 s>f call fDot ; 3:17 f. ld A, ' ' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fIld ; 3:17 s>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(-512,512) ld DE, -512 ; 3:10 push2(-512,512) push HL ; 1:11 push2(-512,512) ld HL, 512 ; 3:10 push2(-512,512) call fIld ; 3:17 s>f call fDot ; 3:17 f. ld A, ' ' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fIld ; 3:17 s>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x7FFF ) ex DE, HL ; 1:4 push(0x7FFF ) ld HL, 0x7FFF ; 3:10 push(0x7FFF ) sfor102: ; sfor 102 ( index -- index ) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fIld ; 3:17 s>f push DE ; 1:11 push(20224) ex DE, HL ; 1:4 push(20224) ld HL, 20224 ; 3:10 push(20224) or A ; 1:4 <> sbc HL, DE ; 2:15 <> jr z, $+5 ; 2:7/12 <> ld HL, 0xFFFF ; 3:10 <> pop DE ; 1:10 <> ld A, H ; 1:4 if or L ; 1:4 if ex DE, HL ; 1:4 if pop DE ; 1:10 if jp z, else101 ; 3:10 if push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . jp snext102 ; 3:10 sfor leave 102 else101 EQU $ ; = endif endif101: ld A, H ; 1:4 snext 102 or L ; 1:4 snext 102 dec HL ; 1:6 snext 102 index-- jp nz, sfor102 ; 3:10 snext 102 snext102: ; snext 102 ex DE, HL ; 1:4 sfor unloop 102 pop DE ; 1:10 sfor unloop 102 ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x0000 ) ex DE, HL ; 1:4 push(0x0000 ) ld HL, 0x0000 ; 3:10 push(0x0000 ) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x3c9a) ex DE, HL ; 1:4 push(0x3c9a) ld HL, 0x3c9a ; 3:10 push(0x3c9a) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string102 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x3f00) ex DE, HL ; 1:4 push(0x3f00) ld HL, 0x3f00 ; 3:10 push(0x3f00) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string103 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x3f9a) ex DE, HL ; 1:4 push(0x3f9a) ld HL, 0x3f9a ; 3:10 push(0x3f9a) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string104 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x4000) ex DE, HL ; 1:4 push(0x4000) ld HL, 0x4000 ; 3:10 push(0x4000) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string105 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x4080) ex DE, HL ; 1:4 push(0x4080) ld HL, 0x4080 ; 3:10 push(0x4080) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string106 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0xbc9a) ex DE, HL ; 1:4 push(0xbc9a) ld HL, 0xbc9a ; 3:10 push(0xbc9a) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string107 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0xbf00) ex DE, HL ; 1:4 push(0xbf00) ld HL, 0xbf00 ; 3:10 push(0xbf00) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string108 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0xbf9a) ex DE, HL ; 1:4 push(0xbf9a) ld HL, 0xbf9a ; 3:10 push(0xbf9a) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string109 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0xc000) ex DE, HL ; 1:4 push(0xc000) ld HL, 0xc000 ; 3:10 push(0xc000) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string110 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0xc080) ex DE, HL ; 1:4 push(0xc080) ld HL, 0xc080 ; 3:10 push(0xc080) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string101 ; 3:10 print_z Address of null-terminated string101 == string111 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fsin call fSin ; 3:17 fsin HL = sin(HL) pop DE ; 1:10 fsin call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(5) ex DE, HL ; 1:4 push(5) ld HL, 5 ; 3:10 push(5) call fIld ; 3:17 s>f call fSqrt ; 3:17 fsqrt push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string112 ; 3:10 print_z Address of null-terminated string112 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fexp call fExp ; 3:17 fexp HL = e^HL pop DE ; 1:10 fexp call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(5) ex DE, HL ; 1:4 push(5) ld HL, 5 ; 3:10 push(5) call fIld ; 3:17 s>f call fSqrt ; 3:17 fsqrt push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string113 ; 3:10 print_z Address of null-terminated string113 call PRINT_STRING_Z ; 3:17 print_z push DE ; 1:11 fln call fLn ; 3:17 fln HL = ln(HL) pop DE ; 1:10 fln call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push2(5,3) ld DE, 5 ; 3:10 push2(5,3) push HL ; 1:11 push2(5,3) ld HL, 3 ; 3:10 push2(5,3) call fIld ; 3:17 s>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string114 ; 3:10 print_z Address of null-terminated string114 call PRINT_STRING_Z ; 3:17 print_z ex DE, HL ; 1:4 swap ( b a -- a b ) call fIld ; 3:17 s>f call fSqrt ; 3:17 fsqrt push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. ld BC, string115 ; 3:10 print_z Address of null-terminated string115 call PRINT_STRING_Z ; 3:17 print_z ld B, D ; 1:4 fmod ld C, E ; 1:4 fmod call fMod ; 3:17 fmod HL = BC % HL pop DE ; 1:10 fmod call fDot ; 3:17 f. ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(3) ex DE, HL ; 1:4 push(3) ld HL, 3 ; 3:10 push(3) call test ; 3:17 scall ex DE, HL ; 1:4 drop pop DE ; 1:10 drop ( a -- ) push DE ; 1:11 push(5) ex DE, HL ; 1:4 push(5) ld HL, 5 ; 3:10 push(5) call test ; 3:17 scall ex DE, HL ; 1:4 drop pop DE ; 1:10 drop ( a -- ) push DE ; 1:11 push(7) ex DE, HL ; 1:4 push(7) ld HL, 7 ; 3:10 push(7) call test ; 3:17 scall ex DE, HL ; 1:4 drop pop DE ; 1:10 drop ( a -- ) push DE ; 1:11 push(8) ex DE, HL ; 1:4 push(8) ld HL, 8 ; 3:10 push(8) call test ; 3:17 scall ex DE, HL ; 1:4 drop pop DE ; 1:10 drop ( a -- ) push DE ; 1:11 push(15) ex DE, HL ; 1:4 push(15) ld HL, 15 ; 3:10 push(15) call test ; 3:17 scall ex DE, HL ; 1:4 drop pop DE ; 1:10 drop ( a -- ) ld BC, 0 ; 3:10 xdo(65535,0 ) 103 ld (idx103),BC ; 4:20 xdo(65535,0 ) 103 xdo103: ; xdo(65535,0 ) 103 push DE ; 1:11 index xi 103 ex DE, HL ; 1:4 index xi 103 ld HL, (idx103) ; 3:16 index xi 103 idx always points to a 16-bit index push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) ld A, H ; 1:4 fnegate xor 0x80 ; 2:7 fnegate ld H, A ; 1:4 fnegate call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . call fSqrt ; 3:17 fsqrt call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push HL ; 1:11 777 +xloop 103 idx103 EQU $+1 ; 777 +xloop 103 ld HL, 0x0000 ; 3:10 777 +xloop 103 ld BC, 777 ; 3:10 777 +xloop 103 BC = step add HL, BC ; 1:11 777 +xloop 103 HL = index+step ld (idx103), HL ; 3:16 777 +xloop 103 save index ld A, low 65534 ; 2:7 777 +xloop 103 sub L ; 1:4 777 +xloop 103 ld L, A ; 1:4 777 +xloop 103 ld A, high 65534 ; 2:7 777 +xloop 103 sbc A, H ; 1:4 777 +xloop 103 ld H, A ; 1:4 777 +xloop 103 HL = stop-(index+step) add HL, BC ; 1:11 777 +xloop 103 HL = stop-index pop HL ; 1:10 777 +xloop 103 jp nc, xdo103 ; 3:10 777 +xloop 103 positive step xleave103: ; 777 +xloop 103 xexit103: ; 777 +xloop 103 push DE ; 1:11 push(32736 ) ex DE, HL ; 1:4 push(32736 ) ld HL, 32736 ; 3:10 push(32736 ) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(32737 ) ex DE, HL ; 1:4 push(32737 ) ld HL, 32737 ; 3:10 push(32737 ) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x7FFF) ex DE, HL ; 1:4 push(0x7FFF) ld HL, 0x7FFF ; 3:10 push(0x7FFF) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x8000) ex DE, HL ; 1:4 push(0x8000) ld HL, 0x8000 ; 3:10 push(0x8000) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(32736 ) ex DE, HL ; 1:4 push(32736 ) ld HL, 32736 ; 3:10 push(32736 ) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f ld A, H ; 1:4 fnegate xor 0x80 ; 2:7 fnegate ld H, A ; 1:4 fnegate push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(32737 ) ex DE, HL ; 1:4 push(32737 ) ld HL, 32737 ; 3:10 push(32737 ) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f ld A, H ; 1:4 fnegate xor 0x80 ; 2:7 fnegate ld H, A ; 1:4 fnegate push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x7FFF) ex DE, HL ; 1:4 push(0x7FFF) ld HL, 0x7FFF ; 3:10 push(0x7FFF) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f ld A, H ; 1:4 fnegate xor 0x80 ; 2:7 fnegate ld H, A ; 1:4 fnegate push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x8000) ex DE, HL ; 1:4 push(0x8000) ld HL, 0x8000 ; 3:10 push(0x8000) push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A call fWld ; 3:17 u>f ld A, H ; 1:4 fnegate xor 0x80 ; 2:7 fnegate ld H, A ; 1:4 fnegate push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_U16 ; 3:17 . call fIst ; 3:17 f>s call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A push DE ; 1:11 push(0x8000) ex DE, HL ; 1:4 push(0x8000) ld HL, 0x8000 ; 3:10 push(0x8000) call fIld ; 3:17 s>f push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fWst ; 3:17 f>u call PRINT_U16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A ld BC, string116 ; 3:10 print_z Address of null-terminated string116 call PRINT_STRING_Z ; 3:17 print_z exx push HL exx pop HL push HL ; 1:11 dup . x3 x1 x2 x1 call PRINT_U16 ; 3:17 . ex DE, HL ; 1:4 dup . x3 x2 x1 ret ; --- the beginning of a data stack function --- test: ; call fIld ; 3:17 s>f call fSqrt ; 3:17 fsqrt push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fFrac ; 3:17 ffrac ld A, ':' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call fDot ; 3:17 f. call fIst ; 3:17 f>s push DE ; 1:11 dup ld D, H ; 1:4 dup ld E, L ; 1:4 dup ( a -- a a ) call PRINT_S16 ; 3:17 . ld A, 0x0D ; 2:7 cr Pollutes: AF, DE', BC' rst 0x10 ; 1:11 cr with 48K ROM in, this will print char in A test_end: ret ; 1:10 s; ; --------- end of data stack function --------- ; --- the beginning of a data stack function --- stack_test: ; ld BC, string117 ; 3:10 print_z Address of null-terminated string117 call PRINT_STRING_Z ; 3:17 print_z Stop: ; stop ld SP, 0x0000 ; 3:10 stop restoring the original SP value when the "bye" word is used ld HL, 0x2758 ; 3:10 stop exx ; 1:4 stop ret ; 1:10 stop ; ===== e n d ===== stack_test_end: ret ; 1:10 s; ; --------- end of data stack function --------- ; Remainder after division ; In: BC dividend, HL modulus ; Out: HL = BC % HL = BC - int(BC/HL) * HL = frac(BC/HL) * HL => does not return correct results with larger exponent difference ; Pollutes: AF, BC, DE ; ***************************************** fMod ; * ; ***************************************** res 7, H ; 2:8 HL = abs(HL), exp HL will be used for the result ld A, B ; 1:4 and 0x80 ; 2:7 sign mask ld D, A ; 1:4 Result sign only xor B ; 1:4 sub H ; 1:4 jr c, fMod_HL_GR ; 2:12/7 ld E, A ; 1:4 diff exp ld A, C ; 1:4 jr nz, fMod_Sub ; 2:12/7 cp L ; 1:4 jr z, fMod_FPmin ; 2:12/7 jr c, fMod_HL_GR ; 2:12/7 fMod_Sub: ; BC_mantis - HL_mantis sub L ; 1:4 jr z, fMod_FPmin ; 2:7/11 fpmin jr nc, fMod_NORM ; 2:7/11 ; fMod_Add_HALF: dec E ; 1:4 jp m, fMod_STOP ; 3:10 add A, A ; 1:4 jr nc, fMod_X ; 2:7/11 add A, L ; 1:4 jr c, fMod_Sub ; 2:7/11 db 0x06 ; ld B, $85 fMod_X: add A, L ; 1:4 fMod_NORM: add A, A ; 1:4 dec E ; 1:4 jr nc, fMod_NORM ; 2:7/11 jp p, fMod_Sub ; 3:10 E >= 0 ld L, A ; 1:4 ld A, H ; 1:4 add A, E ; 1:4 xor D ; 1:4 ld H, A ; 1:4 xor D ; 1:4 ret p ; 1:5/11 ; fall ; Input: D = sign only fMod_UNDERFLOW: ld H, D ; 1:4 ld L, 0x00 ; 2:7 scf ; 1:4 carry = error ret ; 1:10 fMod_STOP: add A, L ; 1:4 ld L, A ; 1:4 ld A, H ; 1:4 xor D ; 1:4 ld H, A ; 1:4 ret ; 1:10 fMod_HL_GR: or A ; 1:4 ld H, B ; 1:4 ld L, C ; 1:4 ret ; 1:10 fMod_FPmin: ; RET with reset carry ld L, 0x00 ; 2:7 ld H, D ; 1:4 ret ; 1:10 ; Fractional part, remainder after division by 1 ; In: HL any floating-point number ; Out: HL fractional part, with sign intact ; Pollutes: AF, B ; ***************************************** fFrac ; * ; ***************************************** ld A, H ; 1:4 and 0x7F ; 2:7 delete sign cp 0x48 ; 2:7 bias + mant bits jr nc, fFrac_ZERO ; 2:7/12 Already integer sub 0x40 ; 2:7 bias ret c ; 1:5/11 Pure fraction inc A ; 1:4 2^0*1.xxx > 1 ld B, A ; 1:4 ld A, L ; 2:7 fFrac_Loop: ; odmazani mantisy pred plovouci radovou carkou dec H ; 1:4 add A, A ; 1:4 djnz fFrac_Loop ; 2:13/8 ld L, A ; 1:4 ret c ; 1:11/5 jr z, fFrac_ZERO ; 2:7/12 fFrac_Norm: ; normalizace cisla dec H ; 1:4 add A, A ; 1:4 jr nc, fFrac_Norm ; 2:12/7 ld L, A ; 1:4 ret ; 1:10 fFrac_ZERO: ld HL, 0x0000 ; 3:10 fpmin ret ; 1:10 ; ( f1 -- f2 ) ; (2^+3 * mantisa)^0.5 = 2^+1 * 2^+0.5 * mantisa^0.5 = 2^+1 * 2^+0.5 ... ; ***************************************** fSqrt ; * ; ***************************************** ld A, H ; 1:4 and 0x7F ; 2:7 abs(HL) add A, 0x40 ; 2:7 rra ; 1:4 A = (exp-bias)/2 + bias = (exp+bias)/2 ; carry => out = out * 2^0.5 ld H, SQR_TAB/256; 2:7 jr nc, fSqrt1 ; 2:12/7 inc H ; 1:4 or A ; 1:4 RET with reset carry fSqrt1: ld L, (HL) ; 1:7 ld H, A ; 1:4 ret ; 1:10 ; Load Integer. Convert signed 16-bit integer into floating-point number ; In: HL = Integer to convert ; Out: HL = floating point representation ; Pollutes: AF ; ***************************************** fIld ; * ; ***************************************** bit 7, H ; 2:8 jr z, fWld ; 2:7/12 xor A ; 1:4 sub L ; 1:4 ld L, A ; 1:4 sbc A, H ; 1:4 sub L ; 1:4 ld H, A ; 1:4 ld A, 0xD0 ; 2:7 sign+bias+16 jr nz, fWld_NORM ; 2:7/12 ld H, 0xC8 ; 2:7 sign+bias+8 ld A, L ; 1:4 jp fWld_B_NORM ; 3:10 ; Load Word. Convert unsigned 16-bit integer into floating-point number ; In: HL = Word to convert ; Out: HL = floating point representation ; Pollutes: AF ; ***************************************** fWld ; * ; ***************************************** ld A, H ; 1:4 HL = xxxx xxxx xxxx xxxx or A ; 1:4 jr z, fWld_B ; 2:12/7 ld A, 0x50 ; 2:7 bias+16 fWld_NORM: add HL, HL ; 1:11 dec A ; 1:4 jp nc, fWld_NORM ; 3:10 sla L ; 2:8 rounding ld L, H ; 1:4 ld H, A ; 1:4 ret nc ; 1:11/5 ccf ; 1:4 ret z ; 1:11/5 inc L ; 1:4 rounding up ret nz ; 1:11/5 inc H ; 1:4 exp++ ret ; 1:10 fWld_B: ; HL = 0000 0000 xxxx xxxx or L ; 1:4 ret z ; 1:5/11 ld H, 0x48 ; 2:7 bias+8 fWld_B_NORM: dec H ; 1:4 add A, A ; 1:4 jr nc, fWld_B_NORM; 2:12/7 ld L, A ; 1:4 ret ; 1:10 ; Store Integer. Convert value of a floating-point number into signed 16-bit integer. ; In: HL = floating point to convert ; Out: HL = Int representation, ??? carry if overflow ; Pollutes: AF, B ; ***************************************** fIst ; * ; ***************************************** ld A, H ; 1:4 cp 0x4F ; 2:7 jr c, fWst ; 2:7/12 add A, A ; 1:4 jr nc, fIst_OVER_P; 2:7/11 rrca ; 1:4 add A, 0xB1 ; 2:7 jr c, fIst_OVER_N; 2:7/12 call fWst ; 3:17 xor A ; 1:4 sub L ; 1:4 ld L, A ; 1:4 sbc A, H ; 1:4 sub L ; 1:4 ld H, A ; 1:4 ret ; 1:10 fIst_OVER_N: ld HL, 0x8000 ; 3:10 ret ; 1:10 fIst_OVER_P: ld HL, 0x7FFF ; 3:10 scf ; 1:4 ret ; 1:10 ; Store Word. Convert absolute value of a floating-point number into unsigned 16-bit integer. ; In: HL = floating point to convert ; Out: HL = Word representation, set carry if overflow ; Pollutes: AF, B ; ***************************************** fWst ; * ; ***************************************** ld A, H ; 1:4 and 0x7F ; 2:7 exp mask cp 0x50 ; 2:7 bias + 0x10 jr nc, fWst_OVER ; 2:7/12 sub 0x3F ; 2:7 bias - 1 jr c, fWst_ZERO ; 2:7/12 ; A = 0..16 if 0 ld B, A ; 1:4 ld A, L ; 1:4 ld HL, 0x0000 ; 3:10 jr z, fWst_Round ; 2:7/12 scf ; 1:4 adc HL, HL ; 2:15 add A, A ; 1:4 djnz $-3 ; 2:13/8 ret nc ; 1:11/5 fWst_Round: or A ; 1:4 ret z ; 1:11/5 inc HL ; 1:6 ret ; 1:10 else ld H, 0x01 ; 2:7 sub 0x09 ; 2:7 jr nc, fWst256Plus; 2:7 dec HL ; 1:6 rounding ( 0.5000 down => 0.4999 down ) srl H ; 2:8 rr L ; 2:8 inc A ; 1:4 jr z, $+7 ; 2:12/7 srl L ; 2:8 inc A ; 1:4 jr nz, $-3 ; 2:12/7 ret nc ; 1:11/5 inc L ; 1:4 or A ; 1:4 ret ; 1:10 fWst256Plus: ret z ; 1:5/11 ld B, A ; 1:4 add HL, HL ; 1:11 djnz $-1 ; 2:13/8 ret ; 1:10 endif fWst_OVER: ld HL, 0xFFFF ; 3:10 scf ; 1:4 ret ; 1:10 RET with carry fWst_ZERO: xor A ; 1:4 ld H, A ; 1:4 ld L, A ; 1:4 ret ; 1:10 RET with carry ; continue from @ ld B, D ; 1:4 fmod ld C, E ; 1:4 fmod call fMod ; 3:17 fmod HL = BC % HL pop DE ; 1:10 fmod (if it was included) ; Subtract two floating-point numbers ; In: HL, DE numbers to subtract, no restrictions ; Out: HL = DE - HL ; Pollutes: AF, B, DE ; ***************************************** fSub ; * ; ***************************************** ld A, H ; 1:4 xor 0x80 ; 2:7 sign mask ld H, A ; 1:4 HL = -HL ; continue ; Add two floating-point numbers ; In: HL, DE numbers to add, no restrictions ; Out: HL = DE + HL ; Pollutes: AF, B, DE ; ***************************************** fAdd ; * ; ***************************************** ld A, H ; 1:4 xor D ; 1:4 jp m, fAdd_OP_SGN; 3:10 ; continue ; Add two floating point numbers with the same sign ; In: HL, DE numbers to add, no restrictions ; Out: HL = DE + HL, if ( 1 && overflow ) set carry ; Pollutes: AF, B, DE ; -------------- HL + DE --------------- ; HL = (+DE) + (+HL) ; HL = (-DE) + (-HL) ; ***************************************** fAddP ; * ; ***************************************** ld A, H ; 1:4 sub D ; 1:4 jr nc, fAdd_HL_GR ; 2:7/12 ex DE, HL ; 1:4 neg ; 2:8 fAdd_HL_GR: and 0x7F ; 2:7 exp mask jr z, fAdd_Eq_Exp; 2:12/7 neresime zaokrouhlovani cp 0x0A ; 2:7 pri posunu o NEUKLADANY_BIT+BITS_MANTIS uz mantisy nemaji prekryt, ale jeste se muze zaokrouhlovat ret nc ; 1:11/5 HL + DE = HL, ret with reset carry ; Out: A = --( E | 1 0000 0000 ) >> A ld B, A ; 1:4 ld A, E ; 1:4 dec A ; 1:4 cp 0xFF ; 2:7 db 0x1E ; 2:7 ld E, $B7 fAdd_Loop: or A ; 1:4 rra ; 1:4 djnz fAdd_Loop ; 2:13/8 jr c, fAdd1 ; 2:12/7 add A, L ; 1:4 soucet mantis jr nc, fAdd0_OkExp; 2:12/7 fAdd_Exp_PLUS: ; A = 10 mmmm mmmr, r = rounding bit adc A, B ; 1:4 rounding rra ; 1:4 A = 01 cmmm mmmm ld L, A ; 1:4 ld A, H ; 1:4 inc H ; 1:4 xor H ; 1:4 ret with reset carry ret p ; 1:11/5 jr fAdd_OVERFLOW ; 2:12 fAdd0_OkExp: ; A = 01 mmmm mmmm 0 ld L, A ; 1:4 ret ; 1:10 fAdd1: add A, L ; 1:4 soucet mantis jr c, fAdd_Exp_PLUS; 2:12/7 fAdd1_OkExp: ; A = 01 mmmm mmmm 1, reset carry ld L, A ; 1:4 ld A, H ; 1:4 inc HL ; 1:6 xor H ; 1:4 ret with reset carry ret p ; 1:11/5 jr fAdd_OVERFLOW ; 2:12 fAdd_Eq_Exp: ; HL exp = DE exp ld A, L ; 1:4 1 mmmm mmmm add A, E ; 1:4 +1 mmmm mmmm ; 1m mmmm mmmm rra ; 1:4 sign in && shift ld L, A ; 1:4 ld A, H ; 1:4 inc H ; 1:4 xor H ; 1:4 ret with reset carry ret p ; 1:11/5 ; fall ; In: H = s111 1111 + 1 ; Out: HL = +-max fAdd_OVERFLOW: dec H ; 1:4 ld L, $FF ; 2:7 scf ; 1:4 carry = error ret ; 1:10 ; Subtraction two floating-point numbers with the same signs ; In: HL,DE numbers to add, no restrictions ; Out: HL = DE + HL, if ( 1 && underflow ) set carry ; Pollutes: AF, BC, DE ; -------------- HL - DE --------------- ; HL = (+DE) - (+HL) = (+DE) + (-HL) ; HL = (-DE) - (-HL) = (-DE) + (+HL) ; ***************************************** fSubP ; * ; ***************************************** ld A, D ; 1:4 xor 0x80 ; 2:7 sign mask ld D, A ; 1:4 ; Add two floating-point numbers with the opposite signs ; In: HL, DE numbers to add, no restrictions ; Out: HL = HL + DE ; Pollutes: AF, B, DE ; -------------- HL + DE --------------- ; HL = (+DE) + (-HL) ; HL = (-DE) + (+HL) fAdd_OP_SGN: ld A, H ; 1:4 sub D ; 1:4 jp m, fSub_HL_GR ; 3:10 ex DE, HL ; 1:4 ld A, H ; 1:4 sub D ; 1:4 fSub_HL_GR: and 0x7F ; 2:7 exp mask jr z, fSub_Eq_Exp; 2:12/7 cp 0x0A ; 2:7 pri posunu vetsim nez o MANT_BITS + NEUKLADANY_BIT + ZAOKROUHLOVACI_BIT uz mantisy nemaji prekryt jr nc, fSub_TOOBIG; 2:12/7 HL - DE = HL ; Out: E = ( E | 1 0000 0000 ) >> A ld B, A ; 1:4 ld A, E ; 1:4 rra ; 1:4 1mmm mmmm m dec B ; 1:4 jr z, fSub_NOLoop; 2:12/7 dec B ; 1:4 jr z, fSub_LAST ; 2:12/7 fSub_Loop: or A ; 1:4 rra ; 1:4 djnz fSub_Loop ; 2:13/8 fSub_LAST: rl B ; 2:8 B = rounding 0.25 rra ; 1:4 fSub_NOLoop: ; carry = rounding 0.5 ld E, A ; 1:4 ld A, L ; 1:4 jr c, fSub1 ; 2:12/7 sub E ; 1:4 jr nc, fSub0_OkExp; 2:12/7 fSub_Norm_RESET: or A ; 1:4 fSub_Norm: ; normalizace cisla dec H ; 1:4 exp-- adc A, A ; 1:4 jr nc, fSub_Norm ; 2:7/12 sub B ; 1:4 ld L, A ; 1:4 ld A, D ; 1:4 xor H ; 1:4 ret m ; 1:11/5 RET with reset carry jr fSub_UNDER ; 2:12 fSub0_OkExp: ; reset carry ld L, A ; 1:4 ret nz ; 1:11/5 sub B ; 1:4 exp--? => rounding 0.25 => 0.5 ret z ; 1:11/5 dec HL ; 1:6 ld A, D ; 1:4 xor H ; 1:4 ret m ; 1:11/5 RET with reset carry jr fSub_UNDER ; 2:12 fSub1: sbc A, E ; 1:4 rounding half down jr c, fSub_Norm ; 2:12/7 carry => need half up ld L, A ; 1:4 ret ; 1:10 fSub_Eq_Exp: ld A, L ; 1:4 sub E ; 1:4 jr z, fSub_UNDER ; 2:12/7 (HL_exp = DE_exp && HL_mant = DE_mant) => HL = -DE jr nc, fSub_EqNorm; 2:12/7 ex DE, HL ; 1:4 neg ; 2:8 fSub_EqNorm: ; normalizace cisla dec H ; 1:4 exp-- add A, A ; 1:4 musime posouvat minimalne jednou, protoze NEUKLADANY_BIT byl vynulovan jr nc, fSub_EqNorm; 2:7/12 ld L, A ; 1:4 ld A, D ; 1:4 xor H ; 1:4 ret m ; 1:11/5 fSub_UNDER: ld L, 0x00 ; 2:7 ld A, D ; 1:4 cpl ; 1:4 and 0x80 ; 2:7 sign mask ld H, A ; 1:4 scf ; 1:4 carry = error ret ; 1:10 fSub_TOOBIG: ret nz ; 1:11/5 HL_exp - DE_exp > 7+1+1 => HL - DE = HL ld A, L ; 1:4 or A ; 1:4 ret nz ; 1:11/5 HL_mant > 1.0 => HL - DE = HL dec L ; 1:4 dec H ; 1:4 HL_exp = 8 + 1 + DE_exp => HL_exp >= 9 => not underflow ret ; 1:10 ; logaritmus naturalis ; Input: HL ; Output: HL = ln(abs(HL)) +- lowest bit (with exponent -1($7E) the error is bigger...) ; ln(2^e*m) = ln(2^e) + ln(m) = e*ln(2) + ln(m) = ln2_exp[e] + ln_m[m] ; Pollutes: AF, B, DE ; ***************************************** fLn ; * ; ***************************************** ; fixes input errors with exponent equal to -1 ld A, H ; 1:4 add A, A ; 1:4 xor 2*0x3F ; 2:7 jr z, fLn_FIX ; 2:12/7 ld A, H ; 1:4 save ld H, high Ln_M ; 2:7 Ln_M[] ld E, (HL) ; 1:7 inc H ; 1:4 hi Ln_M[] ld D, (HL) ; 1:7 add A, A ; 1:4 sign out, HL = abs(HL) ld L, A ; 1:4 cp 0x80 ; 2:7 2*bias jr z, fLn_NO_Add ; 2:7/11 inc H ; 1:4 Ln2_Exp[] ld A, (HL) ; 1:7 inc L ; 1:4 ld H, (HL) ; 1:7 ld L, A ; 1:4 ld A, D ; 1:4 or E ; 1:4 jp nz, fAdd ; 3:10 HL = HL + DE = +-Ln2_Exp[] + Ln_M[] ret ; 1:10 fLn_FIX: ld H, high Ln_FIX; 2:7 ld E, (HL) ; 1:7 inc H ; 1:4 ld D, (HL) ; 1:7 fLn_NO_Add: ex DE, HL ; 1:4 ret ; 1:10 ; Natural exponential function ; Input: HL ; Output: HL = exp(HL)) +- lowest 2 bit ; e^((2^e)*m) = ; e^((2^e)*(m1+m0.5+m0.25+m0.125+m0.0.0625)) ; m1 => b1 = 1, m0.5 => b0.5 = 0 or 1, m0.25 => b0.25 = 0 or 1, ... ; e^( b1* (2^e) + b0.5* (2^e-1) + b0.25* (2^e-2) + b0.125* (2^e-3) + b0.0625* (2^e-4) + ... ) = ; b1*e^(2^e) * b0.5*e^(2^e-1) * b0.25*e^(2^e-2) * b0.125*e^(2^e-3) * b0.0625*e^(2^e-4) * ... ; Pollutes: AF, BC, DE ; ***************************************** fExp ; * ; ***************************************** ld D, EXP_TAB/256; 2:7 ld A, H ; 1:4 add A, A ; 1:4 ld E, A ; 1:4 jr nc, $+3 ; 2:7/11 inc D ; 1:4 cp 2*0x37 ; 2:7 jr c, fExp_ONE ; 2:7/11 cp 2*0x46 ; 2:7 jr nc, fExp_FLOW ; 2:7/11 ld A, L ; 1:4 fraction ex DE, HL ; 1:4 inc L ; 1:4 ld D, (HL) ; 1:7 dec L ; 1:4 ld E, (HL) ; 1:7 fExp_0_BIT: jr z, fExp_EXIT ; 2:7/11 fExp_Loop: dec L ; 1:4 exp-- ld B, (HL) ; 1:7 dec L ; 1:4 add A, A ; 1:4 jr nc, fExp_0_BIT ; 2:7/11 ld C, (HL) ; 1:7 push HL ; 1:11 push AF ; 1:11 call fMul ; 3:17 HL = BC * DE pop AF ; 1:10 ex DE, HL ; 1:4 pop HL ; 1:10 jp fExp_Loop ; 3:10 fExp_ONE: ld DE, 0x4000 ; 3:10 bias*256 fExp_EXIT: ex DE, HL ; 1:4 ret ; 1:10 fExp_FLOW: ld A, H ; 1:4 add A, A ; 1:4 sign out jr c, fExp_UNDER ; 2:7/11 fExp_OVER: ; scf ; 1:4 ld HL, 0x7FFF ; 3:10 fpmax ret ; 1:10 fExp_UNDER: ld HL, 0x0000 ; 3:10 fpmin ret ; 1:10 ; Input: BC, HL with a mantissa equal to 1.0 (eeee eeee s000 0000) ; Output: HL = BC / HL = BC / (1.0 * 2^HL_exp) = BC * 1.0 * 2^-HL_exp, if ( overflow or underflow ) set carry ; Pollutes: AF, BC, DE ;# if ( 1.m = 1.0 ) => 1/(2^x * 1.0) = 1/2^x * 1/1.0 = 2^-x * 1.0 ;# New_sign = BC_sign ^ HL_sign ;# New_exp = (BC_exp - bias) + ( bias - HL_exp ) + bias = bias + BC_exp - HL_exp ;# New_mant = BC_mant * 1.0 = BC_mant ; ***************************************** fDiv_POW2 ; * ; ***************************************** ld A, B ; 1:4 BC_exp sub H ; 1:4 -HL_exp add A, 0x40 ; 2:7 bias ld L, A ; 1:4 xor H ; 1:4 xor sign xor B ; 1:4 xor sign jp m, fDiv_FLOW ; 3:10 ld H, L ; 1:4 ld L, C ; 1:4 ret ; 1:10 fDiv_FLOW: bit 6, L ; 2:8 sign+(0x00..0x3F)=overflow, sign+(0x41..0x7F)=underflow jr z, fDiv_OVER ; 2:12/7 fDiv_UNDER: ld A, L ; 1:4 cpl ; 1:4 and 0x80 ; 2:7 sign mask ld H, A ; 1:4 ld L, 0x00 ; 2:7 scf ; 1:4 carry = error ret ; 1:10 fDiv_OVER: ld A, L ; 1:4 cpl ; 1:4 or 0x7F ; 2:7 exp mask ld H, A ; 1:4 ld L, 0xFF ; 2:7 scf ; 1:4 carry = error ret ; 1:10 ; --------------------------------------------- ; Input: BC , HL ; Output: HL = BC / HL => DE = 1 / HL => HL = BC * DE ; if ( 1.m = 1.0 ) => 1/(2^x * 1.0) = 1/2^x * 1/1.0 = 2^-x * 1.0 ; if ( 1.m > 1.0 ) => 1/(2^x * 1.m) = 1/2^x * 1/1.m = 2^-x * 0.9999 .. 0.5001 => 2^(-x-1) * 1.0002 .. 1.9998 ; Pollutes: AF, BC, DE ; ***************************************** fDiv ; * ; ***************************************** ld A, L ; 1:4 or A ; 1:4 jr z, fDiv_POW2 ; 2:12/7 ld A, H ; 1:4 NegE - 1 = (0 - (E - bias)) + bias - 1 = 2*bias - E - 1 = 128 - E - 1 = 127 - E xor 0x7F ; 2:7 NegE = 127 - E = 0x7F - E = 0x7F ld A, E ; 1:4 xor xor L ; 1:4 xor ld L, A ; 1:4 xor ld A, D ; 1:4 xor xor H ; 1:4 xor ld H, A ; 1:4 xor pop DE ; 1:10 xor E ld D, A ; 1:4 ld H, DIVTAB/256 ; 2:7 ld E, (HL) ; 1:7 ; continues with fMul (HL = BC * DE), DE = 1 / HL ; Floating-point multiplication ; In: DE, BC multiplicands ; Out: HL = BC * DE, if ( 1 && (overflow || underflow )) set carry; ; Pollutes: AF, BC, DE ; SEEE EEEE MMMM MMMM ; Sign 0 .. 1 = 0??? ???? ???? ???? .. 1??? ???? ???? ???? ; Exp -64 .. 63 = ?000 0000 ???? ???? .. ?111 1111 ???? ????; (Bias 64 = 0x40) ; Mantis 1.0 .. 1.99609375 = ???? ???? 0000 0000 .. ???? ??? 1111 1111 = 1.0000 0000 .. 1.1111 1111 ; use POW2TAB ; ***************************************** fMul ; * ; ***************************************** ld A, B ; 1:4 add A, D ; 1:4 sub 0x40 ; 2:7 HL_exp = (BC_exp-bias + DE_exp-bias) + bias = BC_exp + DE_exp - bias ld H, A ; 1:4 seee eeee xor B ; 1:4 xor D ; 1:4 jp m, fMul_FLOW ; 3:10 ld B, H ; 1:4 seee eeee fMul_HOPE: ld A, C ; 1:4 sub E ; 1:4 jr nc, fMul_DIFF ; 2:12/7 ld A, E ; 1:4 sub C ; 1:4 fMul_DIFF: ld L, A ; 1:4 L = a - b ld A, E ; 1:4 ld H, Tab_AmB/256; 2:7 ld E, (HL) ; 1:7 inc H ; 1:4 ld D, (HL) ; 1:7 add A, C ; 1:4 ld L, A ; 1:4 L = a + b sbc A, A ; 1:4 add A, A ; 1:4 add A, Tab_ApB/256; 2:7 ld H, A ; 1:4 ld A, (HL) ; 1:4 add A, E ; 1:4 ld E, A ; 1:4 for rounding inc H ; 1:4 ld A, (HL) ; 1:4 adc A, D ; 1:4 ld H, A ; 1:4 ld L, E ; 1:4 jp p, fMul_NOADD ; 3:10 (ApB)+(AmB) >= 0x4000 => pricti: 0x00 ; (ApB)+(AmB) >= 0x8000 => pricti: 0x20 ld DE, 0x0020 ; 3:10 add HL, DE ; 1:11 add HL, HL ; 1:11 ld L, H ; 1:4 ld H, B ; 1:4 inc H ; 1:4 ld A, B ; 1:4 xor H ; 1:4 ret p ; 1:11/5 ; In: B sign fMul_OVER: ld A, B ; 1:4 fMul_OVER_A: or 0x7F ; 2:7 exp_mask ld H, A ; 1:4 ld L, 0xFF ; 2:7 scf ; 1:4 carry = error ret ; 1:10 fMul_NOADD: add HL, HL ; 1:11 add HL, HL ; 1:11 ld L, H ; 1:4 ld H, B ; 1:4 or A ; 1:4 ret ; 1:10 fMul_FLOW: ld A, H ; 1:4 cpl ; 1:4 real sign bit 6, H ; 2:8 sign+(0x00..0x3E)=overflow, sign+(0x40..0x7F)=underflow jr z, fMul_OVER_A; 2:12/7 add A, A ; 1:4 sign out jr nz, fMul_UNDER ; 2:12/7 rra ; 1:4 ld B, A ; 1:4 s000 0000 call fMul_HOPE ; 3:17 exp+1 ld A, H ; 1:4 dec H ; 1:4 exp-1 xor H ; 1:4 ret p ; 1:11/5 xor H ; 1:4 sign add A, A ; 1:4 sign out fMul_UNDER: ld HL, 0x0100 ; 3:10 rr H ; 2:8 sign in, set carry ret ; 1:10 ; Trigonometric function sine ; Input: HL -π/2..π/2 ; Output: HL = sin(HL) ; Pollutes: AF, DE ; ***************************************** fSin ; * ; ***************************************** ld A, H ; 1:4 and 0x7F ; 2:7 abs(HL) sub 0x3F ; 2:7 jr nc, fSin_3F40 ; 2:12/7 add A, 0x02 ; 2:7 jr c, fSin_3D3E ; 2:12/7 inc A ; 1:4 ret nz ; 1:5/11 ld A, 0x71 ; 2:7 sub L ; 1:4 ret nc ; 1:5/11 or A ; 1:4 reset carry dec L ; 1:4 ret ; 1:10 fSin_3D3E: ld D, SinTab_3D3E/256; 2:7 rra ; 1:4 ld A, L ; 1:4 rra ; 1:4 ld E, A ; 1:4 ld A, (DE) ; 1:7 jr c, $+6 ; 2:12/7 rra ; 1:4 rra ; 1:4 rra ; 1:4 rra ; 1:4 or 0xF0 ; 2:7 rl E ; 2:8 jr nc, fSin_OK ; 2:12/7 jp p, fSin_OK ; 3:10 sub 0x08 ; 2:7 fSin_OK: ld E, A ; 1:4 ld D, 0xFF ; 2:7 add HL, DE ; 1:11 or A ; 1:4 reset carry ret ; 1:10 fSin_3F40: add A, high SinTab_3F ; 2:7 ex DE, HL ; 1:4 ld H, A ; 1:4 ld L, E ; 1:4 ld L, (HL) ; 1:7 ld H, 0xFF ; 2:7 add HL, DE ; 1:11 or A ; 1:4 reset carry ret ; 1:10 fDot: push DE ; 1:11 ld A, H ; 1:4 add A, A ; 1:4 ld E, L ; 1:4 mantisa rr E ; 2:8 bit 7 = sign ld BC, 0x0000 ; 3:10 ld D, B ; 1:4 rr D ; 2:8 bit 7 = bit 0 L mantissa rrca ; 1:4 add A, 0x41 ; 2:7 new exponent call 0x2AB6 ; 3:17 Ulozenie floating point cisla (A E D C B) v na vrchol zasobnika kalkulacky call 0x2DE3 ; 3:17 Vypis vrcholu zasobnika kalkukacky pop DE ; 1:10 pop HL ; 1:10 ret ex (SP),HL ; 1:19 ex DE, HL ; 1:4 ret ; 1:10 ; Align to 256-byte page boundary DEFS (($ + 0xFF) / 0x100) * 0x100 - $ ; y = (x-0x3D00)/2 ; z = SinTab[y] // 512*nibble ; if ( x & 1 == 0 ) z >>= 4 ; z |= 0xf0 ; if ( y >= 0xc0 ) z -= 8 ; Sin[x] = res = x + 0xff00 + z ; hi = 0xff SinTab_3D3E: ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff ; 0_ 0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff 0_ db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff ; 1_ 0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff 1_ db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee ; 2_ 0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ff,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee 2_ db 0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee ; 3_ 0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0ee 3_ db 0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd ; 4_ 0ee,0ee,0ee,0ee,0ee,0ee,0ee,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd 4_ db 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xcc ; 5_ 0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0cc 5_ db 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc ; 6_ 0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc 6_ db 0xcc,0xcc,0xcb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb ; 7_ 0cc,0cc,0cb,0bb,0bb,0bb,0bb,0bb,0bb,0bb,0bb,0bb,0bb,0bb,0bb,0bb 7_ ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0xbc,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdc,0xcc,0xcc,0xcc ; 0_ 0bc,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dd,0dc,0cc,0cc,0cc 0_ db 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb ; 1_ 0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0cc,0bb,0bb,0bb,0bb,0bb,0bb,0bb 1_ db 0xbb,0xbb,0xbb,0xba,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x99,0x99,0x99 ; 2_ 0bb,0bb,0bb,0ba,0aa,0aa,0aa,0aa,0aa,0aa,0aa,0aa,0aa,099,099,099 2_ db 0x99,0x99,0x99,0x99,0x99,0x98,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x77,0x77,0x77 ; 3_ 099,099,099,099,099,098,088,088,088,088,088,088,088,077,077,0ff 3_ db 0xff,0xff,0xff,0xff,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xdd,0xdd,0xdd,0xdd,0xdd ; 4_ 0ff,0ff,0ff,0ff,0ee,0ee,0ee,0ee,0ee,0ee,0ee,0dd,0dd,0dd,0dd,0dd 4_ db 0xdd,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xbb,0xbb,0xbb,0xbb,0xbb,0xba,0xaa,0xaa,0xaa ; 5_ 0dd,0cc,0cc,0cc,0cc,0cc,0cc,0bb,0bb,0bb,0bb,0bb,0ba,0aa,0aa,0aa 5_ db 0xaa,0xaa,0x99,0x99,0x99,0x99,0x99,0x88,0x88,0x88,0x88,0x88,0x77,0x77,0x77,0x77 ; 6_ 0aa,0aa,099,099,099,099,099,088,088,088,088,088,077,077,077,077 6_ db 0x77,0x66,0x66,0x66,0x66,0x65,0x55,0x55,0x55,0x54,0x44,0x44,0x44,0x44,0x33,0x33 ; 7_ 077,066,066,066,066,065,055,055,055,054,044,044,044,044,033,033 7_ ; hi = 0xff SinTab_3F: ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0xeb,0xec,0xec,0xed,0xee,0xef,0xef,0xf0,0xf1,0xf2,0xf2,0xf3,0xf4,0xf4,0xf4,0xf4 ; 0_ ffeb,ffec,ffec,ffed,ffee,ffef,ffef,fff0,fff1,fff2,fff2,fff3,fff4,fff4,fff4,fff4 0_ db 0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,0xf1,0xf1 ; 1_ fff3,fff3,fff3,fff3,fff3,fff3,fff3,fff2,fff2,fff2,fff2,fff2,fff2,fff2,fff1,fff1 1_ db 0xf1,0xf1,0xf1,0xf1,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xef,0xef,0xef,0xef,0xef,0xef ; 2_ fff1,fff1,fff1,fff1,fff0,fff0,fff0,fff0,fff0,fff0,ffef,ffef,ffef,ffef,ffef,ffef 2_ db 0xee,0xee,0xee,0xee,0xee,0xee,0xed,0xed,0xed,0xed,0xed,0xed,0xec,0xec,0xec,0xec ; 3_ ffee,ffee,ffee,ffee,ffee,ffee,ffed,ffed,ffed,ffed,ffed,ffed,ffec,ffec,ffec,ffec 3_ db 0xec,0xeb,0xeb,0xeb,0xeb,0xeb,0xea,0xea,0xea,0xea,0xea,0xe9,0xe9,0xe9,0xe9,0xe9 ; 4_ ffec,ffeb,ffeb,ffeb,ffeb,ffeb,ffea,ffea,ffea,ffea,ffea,ffe9,ffe9,ffe9,ffe9,ffe9 4_ db 0xe8,0xe8,0xe8,0xe8,0xe8,0xe7,0xe7,0xe7,0xe7,0xe6,0xe6,0xe6,0xe6,0xe6,0xe5,0xe5 ; 5_ ffe8,ffe8,ffe8,ffe8,ffe8,ffe7,ffe7,ffe7,ffe7,ffe6,ffe6,ffe6,ffe6,ffe6,ffe5,ffe5 5_ db 0xe5,0xe5,0xe4,0xe4,0xe4,0xe4,0xe4,0xe3,0xe3,0xe3,0xe3,0xe2,0xe2,0xe2,0xe2,0xe1 ; 6_ ffe5,ffe5,ffe4,ffe4,ffe4,ffe4,ffe4,ffe3,ffe3,ffe3,ffe3,ffe2,ffe2,ffe2,ffe2,ffe1 6_ db 0xe1,0xe1,0xe1,0xe0,0xe0,0xe0,0xe0,0xdf,0xdf,0xdf,0xdf,0xde,0xde,0xde,0xde,0xdd ; 7_ ffe1,ffe1,ffe1,ffe0,ffe0,ffe0,ffe0,ffdf,ffdf,ffdf,ffdf,ffde,ffde,ffde,ffde,ffdd 7_ db 0xdd,0xdd,0xdc,0xdc,0xdc,0xdc,0xdb,0xdb,0xdb,0xdb,0xda,0xda,0xda,0xd9,0xd9,0xd9 ; 8_ ffdd,ffdd,ffdc,ffdc,ffdc,ffdc,ffdb,ffdb,ffdb,ffdb,ffda,ffda,ffda,ffd9,ffd9,ffd9 8_ db 0xd9,0xd8,0xd8,0xd8,0xd7,0xd7,0xd7,0xd6,0xd6,0xd6,0xd6,0xd5,0xd5,0xd5,0xd4,0xd4 ; 9_ ffd9,ffd8,ffd8,ffd8,ffd7,ffd7,ffd7,ffd6,ffd6,ffd6,ffd6,ffd5,ffd5,ffd5,ffd4,ffd4 9_ db 0xd4,0xd3,0xd3,0xd3,0xd2,0xd2,0xd2,0xd1,0xd1,0xd1,0xd1,0xd0,0xd0,0xd0,0xcf,0xcf ; A_ ffd4,ffd3,ffd3,ffd3,ffd2,ffd2,ffd2,ffd1,ffd1,ffd1,ffd1,ffd0,ffd0,ffd0,ffcf,ffcf A_ db 0xcf,0xce,0xce,0xce,0xcd,0xcd,0xcc,0xcc,0xcc,0xcb,0xcb,0xcb,0xca,0xca,0xca,0xc9 ; B_ ffcf,ffce,ffce,ffce,ffcd,ffcd,ffcc,ffcc,ffcc,ffcb,ffcb,ffcb,ffca,ffca,ffca,ffc9 B_ db 0xc9,0xc9,0xc8,0xc8,0xc8,0xc7,0xc7,0xc6,0xc6,0xc6,0xc5,0xc5,0xc5,0xc4,0xc4,0xc3 ; C_ ffc9,ffc9,ffc8,ffc8,ffc8,ffc7,ffc7,ffc6,ffc6,ffc6,ffc5,ffc5,ffc5,ffc4,ffc4,ffc3 C_ db 0xc3,0xc3,0xc2,0xc2,0xc1,0xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbe,0xbe,0xbe,0xbd ; D_ ffc3,ffc3,ffc2,ffc2,ffc1,ffc1,ffc1,ffc0,ffc0,ffc0,ffbf,ffbf,ffbe,ffbe,ffbe,ffbd D_ db 0xbd,0xbc,0xbc,0xbb,0xbb,0xbb,0xba,0xba,0xb9,0xb9,0xb9,0xb8,0xb8,0xb7,0xb7,0xb6 ; E_ ffbd,ffbc,ffbc,ffbb,ffbb,ffbb,ffba,ffba,ffb9,ffb9,ffb9,ffb8,ffb8,ffb7,ffb7,ffb6 E_ db 0xb6,0xb6,0xb5,0xb5,0xb4,0xb4,0xb3,0xb3,0xb2,0xb2,0xb2,0xb1,0xb1,0xb0,0xb0,0xaf ; F_ ffb6,ffb6,ffb5,ffb5,ffb4,ffb4,ffb3,ffb3,ffb2,ffb2,ffb2,ffb1,ffb1,ffb0,ffb0,ffaf F_ ; hi = 0xff SinTab_40: ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf ; 0_ ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf 0_ db 0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xae,0xae,0xae,0xae ; 1_ ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffaf,ffae,ffae,ffae,ffae 1_ db 0xae,0xae,0xae,0xae,0xad,0xad,0xad,0xad,0xad,0xac,0xac,0xac,0xac,0xac,0xab,0xab ; 2_ ffae,ffae,ffae,ffae,ffad,ffad,ffad,ffad,ffad,ffac,ffac,ffac,ffac,ffac,ffab,ffab 2_ db 0xab,0xab,0xaa,0xaa,0xaa,0xa9,0xa9,0xa9,0xa9,0xa8,0xa8,0xa8,0xa7,0xa7,0xa7,0xa6 ; 3_ ffab,ffab,ffaa,ffaa,ffaa,ffa9,ffa9,ffa9,ffa9,ffa8,ffa8,ffa8,ffa7,ffa7,ffa7,ffa6 3_ db 0xa6,0xa6,0xa5,0xa5,0xa4,0xa4,0xa4,0xa3,0xa3,0xa2,0xa2,0xa1,0xa1,0xa0,0xa0,0xa0 ; 4_ ffa6,ffa6,ffa5,ffa5,ffa4,ffa4,ffa4,ffa3,ffa3,ffa2,ffa2,ffa1,ffa1,ffa0,ffa0,ffa0 4_ db 0x9f,0x9f,0x9e,0x9e,0x9d,0x9c,0x9c,0x9b,0x9b,0x9a,0x9a,0x99,0x99,0x98,0x97,0x97 ; 5_ ff9f,ff9f,ff9e,ff9e,ff9d,ff9c,ff9c,ff9b,ff9b,ff9a,ff9a,ff99,ff99,ff98,ff97,ff97 5_ db 0x96,0x96,0x95,0x94,0x94,0x93,0x92,0x92,0x91,0x90,0x90,0x8f,0x8e,0x8e,0x8d,0x8c ; 6_ ff96,ff96,ff95,ff94,ff94,ff93,ff92,ff92,ff91,ff90,ff90,ff8f,ff8e,ff8e,ff8d,ff8c 6_ db 0x8b,0x8b,0x8a,0x89,0x88,0x88,0x87,0x86,0x85,0x85,0x84,0x83,0x82,0x81,0x80,0x80 ; 7_ ff8b,ff8b,ff8a,ff89,ff88,ff88,ff87,ff86,ff85,ff85,ff84,ff83,ff82,ff81,ff80,ff80 7_ db 0x7f,0x7e,0x7d,0x7c,0x7b,0x7a,0x79,0x79,0x78,0x77,0x76,0x75,0x74,0x73,0x72,0x71 ; 8_ ff7f,ff7e,ff7d,ff7c,ff7b,ff7a,ff79,ff79,ff78,ff77,ff76,ff75,ff74,ff73,ff72,ff71 8_ db 0x70,0x6f,0x6e,0x6d,0x6c,0x6b,0x6a,0x69,0x68,0x67,0x66,0x65,0x64,0x63,0x61,0x60 ; 9_ ff70,ff6f,ff6e,ff6d,ff6c,ff6b,ff6a,ff69,ff68,ff67,ff66,ff65,ff64,ff63,ff61,ff60 9_ db 0x5f,0x5e,0x5d,0x5c,0x5b,0x5a,0x58,0x57,0x56,0x55,0x54,0x53,0x51,0x50,0x4f,0x4e ; A_ ff5f,ff5e,ff5d,ff5c,ff5b,ff5a,ff58,ff57,ff56,ff55,ff54,ff53,ff51,ff50,ff4f,ff4e A_ db 0x4d,0x4b,0x4a,0x49,0x48,0x46,0x45,0x44,0x42,0x41,0x40,0x3e,0x3d,0x3c,0x3a,0x39 ; B_ ff4d,ff4b,ff4a,ff49,ff48,ff46,ff45,ff44,ff42,ff41,ff40,ff3e,ff3d,ff3c,ff3a,ff39 B_ db 0x38,0x36,0x35,0x34,0x32,0x31,0x30,0x2e,0x2d,0x2b,0x2a,0x28,0x27,0x26,0x24,0x23 ; C_ ff38,ff36,ff35,ff34,ff32,ff31,ff30,ff2e,ff2d,ff2b,ff2a,ff28,ff27,ff26,ff24,ff23 C_ db 0x21,0x20,0x1e,0x1d,0x1b,0x1a,0x18,0x17,0x15,0x14,0x12,0x10,0x0f,0x0d,0x0c,0x0a ; D_ ff21,ff20,ff1e,ff1d,ff1b,ff1a,ff18,ff17,ff15,ff14,ff12,ff10,ff0f,ff0d,ff0c,ff0a D_ db 0x08,0x07,0x05,0x04,0x02,0x00,0xff,0xfd,0xfb,0xfa,0xf8,0xf6,0xf5,0xf3,0xf1,0xf0 ; E_ ff08,ff07,ff05,ff04,ff02,ff00,feff,fefd,fefb,fefa,fef8,fef6,fef5,fef3,fef1,fef0 E_ db 0xee,0xec,0xeb,0xe9,0xe7,0xe5,0xe4,0xe2,0xe0,0xde,0xdc,0xdb,0xd9,0xd7,0xd5,0xd3 ; F_ feee,feec,feeb,fee9,fee7,fee5,fee4,fee2,fee0,fede,fedc,fedb,fed9,fed7,fed5,fed3 F_ ; Align to 256-byte page boundary DEFS (($ + 0xFF) / 0x100) * 0x100 - $ ; e^((2^e)*m) = ; e^((2^e)*(m1+m0.5+m0.25+m0.125+m0.0.0625)) ; m1 => b1 = 1, m0.5 => b0.5 = 0 or 1, m0.25 => b0.25 = 0 or 1, ... ; e^( b1* (2^e) + b0.5* (2^e-1) + b0.25* (2^e-2) + b0.125* (2^e-3) + b0.0625* (2^e-4) + ... ) = ; b1*e^(2^e) * b0.5*e^(2^e-1) * b0.25*e^(2^e-2) * b0.125*e^(2^e-3) * b0.0625*e^(2^e-4) * ... EXP_TAB: ; plus ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000 ; 0_ dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000 ; 1_ dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000 ; 2_ dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4001,0x4001,0x4002,0x4004,0x4008,0x4011,0x4022,0x4049,0x40a6 ; 3_ dw 0x415c,0x42d9,0x45b5,0x4b75,0x570f,0x6e1f,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff ; 4_ dw 0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff ; 5_ dw 0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff ; 6_ dw 0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff,0x7fff ; 7_ ; minus ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000 ; 0_ dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000 ; 1_ dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000 ; 2_ dw 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x3fff,0x3ffe,0x3ffc,0x3ff8,0x3ff0,0x3fe1,0x3fc4,0x3f8f,0x3f37 ; 3_ dw 0x3e79,0x3d15,0x3a2c,0x3460,0x28e3,0x11c8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 ; 4_ dw 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 ; 5_ dw 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 ; 6_ dw 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 ; 7_ ; rozdíl: má být mínus jest, nemohu se splést... ; nepřesnost: 2963 (4.521179 %) ; chyb: 399 (0.608826 %) ; Align to 256-byte page boundary DEFS (($ + 0xFF) / 0x100) * 0x100 - $ ; #define MAX_NUMBER 255 ; #define TOP_BIT 0x8000 ; #define PRICTI 0x3F ; #define POSUN_VPRAVO 7 ; #define POCET_BITU 8 ; # 1000 0000 0... .... ; # 11 1111 ; # 765 4321 0... .... ; # neni presne: 31568 (48.168945%), preteceni: 31568, podteceni: 0 ; # neni zaokrouhleno: 0 (0.000000%), preteceni: 0, podteceni: 0 ; # sum(tab _dif[]): -130, sum(abs(tab _dif[])): 192 ; # (( 256 + a ) * ( 256 + b )) >> 6 = (tab _plus[a+b] - tab _minus[a-b]) >> 6 = (1m mmmm mmm.) or (01 mmmm mmmm) ; # 0 <= a <= 255, 0 <= b <= 255 ; tab _minus je zvyseno o 0xFE0, a tab _plus zase snizeno o 0xFE0 ; (ApB)+(AmB) >= 0x8000 => pricti: 0x20 ; (ApB)+(AmB) >= 0x4000 => pricti: 0x0 ;Tab_AmB_lo: ; 0xFE0 - tab _minus[i] Tab_AmB: ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0xe0,0xe0,0xdf,0xe0,0xde,0xdf,0xdd,0xdd,0xdc,0xdb,0xda,0xd8,0xd7,0xd5,0xd4,0xd1 ; 0_ fe0,fe0,fdf,fe0,fde,fdf,fdd,fdd,fdc,fdb,fda,fd8,fd7,fd5,fd4,fd1 0_ db 0xd1,0xce,0xcc,0xcb,0xc7,0xc4,0xc2,0xc0,0xbc,0xb9,0xb6,0xb4,0xaf,0xab,0xa8,0xa4 ; 1_ fd1,fce,fcc,fcb,fc7,fc4,fc2,fc0,fbc,fb9,fb6,fb4,faf,fab,fa8,fa4 1_ db 0xa0,0x9c,0x98,0x92,0x8f,0x8c,0x86,0x82,0x7c,0x77,0x72,0x6c,0x67,0x61,0x5b,0x55 ; 2_ fa0,f9c,f98,f92,f8f,f8c,f86,f82,f7c,f77,f72,f6c,f67,f61,f5b,f55 2_ db 0x51,0x4b,0x44,0x3e,0x37,0x31,0x2a,0x23,0x1c,0x14,0x0e,0x06,0xff,0xf7,0xf0,0xe8 ; 3_ f51,f4b,f44,f3e,f37,f31,f2a,f23,f1c,f14,f0e,f06,eff,ef7,ef0,ee8 3_ db 0xe0,0xd7,0xd0,0xc8,0xbf,0xb6,0xae,0xa5,0x9c,0x91,0x8a,0x81,0x77,0x6d,0x64,0x59 ; 4_ ee0,ed7,ed0,ec8,ebf,eb6,eae,ea5,e9c,e91,e8a,e81,e77,e6d,e64,e59 4_ db 0x51,0x45,0x3b,0x33,0x27,0x1c,0x12,0x07,0xfc,0xf2,0xe6,0xda,0xcf,0xc3,0xb8,0xab ; 5_ e51,e45,e3b,e33,e27,e1c,e12,e07,dfc,df2,de6,dda,dcf,dc3,db8,dab 5_ db 0xa0,0x92,0x88,0x7c,0x6f,0x62,0x56,0x4a,0x3c,0x2f,0x22,0x13,0x07,0xfa,0xec,0xde ; 6_ da0,d92,d88,d7c,d6f,d62,d56,d4a,d3c,d2f,d22,d13,d07,cfa,cec,cde 6_ db 0xd1,0xc2,0xb4,0xa6,0x97,0x89,0x7a,0x6a,0x5c,0x4d,0x3e,0x2e,0x1e,0x0f,0x00,0xf0 ; 7_ cd1,cc2,cb4,ca6,c97,c89,c7a,c6a,c5c,c4d,c3e,c2e,c1e,c0f,c00,bf0 7_ db 0xe0,0xd0,0xc0,0xb1,0x9e,0x8e,0x7e,0x6d,0x5c,0x4c,0x3a,0x29,0x17,0x05,0xf4,0xe2 ; 8_ be0,bd0,bc0,bb1,b9e,b8e,b7e,b6d,b5c,b4c,b3a,b29,b17,b05,af4,ae2 8_ db 0xd1,0xbf,0xac,0x99,0x87,0x75,0x62,0x4f,0x3c,0x29,0x16,0x03,0xef,0xdc,0xc8,0xb5 ; 9_ ad1,abf,aac,a99,a87,a75,a62,a4f,a3c,a29,a16,a03,9ef,9dc,9c8,9b5 9_ db 0xa0,0x8d,0x78,0x64,0x4f,0x3b,0x26,0x11,0xfc,0xe7,0xd2,0xbd,0xa7,0x91,0x7b,0x66 ; A_ 9a0,98d,978,964,94f,93b,926,911,8fc,8e7,8d2,8bd,8a7,891,87b,866 A_ db 0x51,0x3a,0x24,0x0e,0xf7,0xe1,0xca,0xb4,0x9c,0x85,0x6e,0x56,0x3f,0x28,0x10,0xf8 ; B_ 851,83a,824,80e,7f7,7e1,7ca,7b4,79c,785,76e,756,73f,728,710,6f8 B_ db 0xe0,0xc8,0xb0,0x98,0x7f,0x67,0x4e,0x35,0x1c,0x03,0xea,0xd1,0xb7,0x9e,0x84,0x69 ; C_ 6e0,6c8,6b0,698,67f,667,64e,635,61c,603,5ea,5d1,5b7,59e,584,569 C_ db 0x50,0x36,0x1c,0x02,0xe7,0xcd,0xb2,0x97,0x7c,0x61,0x46,0x2b,0x0f,0xf4,0xd8,0xbc ; D_ 550,536,51c,502,4e7,4cd,4b2,497,47c,461,446,42b,40f,3f4,3d8,3bc D_ db 0xa0,0x84,0x68,0x4c,0x2f,0x14,0xf6,0xd9,0xbc,0x9f,0x82,0x65,0x47,0x2a,0x0c,0xee ; E_ 3a0,384,368,34c,32f,314,2f6,2d9,2bc,29f,282,265,247,22a,20c,1ee E_ db 0xd0,0xb2,0x94,0x76,0x57,0x39,0x1a,0xfb,0xdc,0xbd,0x9e,0x7f,0x5f,0x40,0x20,0x00 ; F_ 1d0,1b2,194,176,157,139,11a, fb, dc, bd, 9e, 7f, 5f, 40, 20, 00 F_ ;Tab_AmB_hi: ; 0xFE0 - tab _minus[i] ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f ; 0_ db 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f ; 1_ db 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f ; 2_ db 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0e,0x0e,0x0e,0x0e ; 3_ db 0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e ; 4_ db 0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d ; 5_ db 0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0c,0x0c,0x0c ; 6_ db 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0b ; 7_ db 0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0a,0x0a ; 8_ db 0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x09 ; 9_ db 0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08 ; A_ db 0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x06 ; B_ db 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x05,0x05,0x05,0x05,0x05 ; C_ db 0x05,0x05,0x05,0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x03,0x03,0x03 ; D_ db 0x03,0x03,0x03,0x03,0x03,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01 ; E_ db 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; F_ Tab_ApB_lo_1: ; tab _plus[i] - 0xFE0 ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x3f,0x9f,0x00,0x5f,0xc0,0x20,0x82,0xe2,0x43,0xa4,0x05,0x66,0xc8,0x2a,0x8b,0xec ; 0_ 803f,809f,8100,815f,81c0,8220,8282,82e2,8343,83a4,8405,8466,84c8,852a,858b,85ec 0_ db 0x4f,0xb2,0x13,0x77,0xd8,0x3b,0x9d,0x00,0x63,0xc7,0x29,0x8c,0xf0,0x53,0xb7,0x1c ; 1_ 864f,86b2,8713,8777,87d8,883b,889d,8900,8963,89c7,8a29,8a8c,8af0,8b53,8bb7,8c1c 1_ db 0x7f,0xe3,0x47,0xab,0x10,0x76,0xd9,0x3e,0xa3,0x09,0x6d,0xd2,0x38,0x9e,0x04,0x69 ; 2_ 8c7f,8ce3,8d47,8dab,8e10,8e76,8ed9,8f3e,8fa3,9009,906d,90d2,9138,919e,9204,9269 2_ db 0xcf,0x35,0x9b,0x02,0x68,0xcf,0x35,0x9d,0x03,0x6a,0xd1,0x38,0xa0,0x09,0x6f,0xd7 ; 3_ 92cf,9335,939b,9402,9468,94cf,9535,959d,9603,966a,96d1,9738,97a0,9809,986f,98d7 3_ db 0x3f,0xa7,0x0f,0x78,0xe0,0x48,0xb1,0x1b,0x83,0xec,0x55,0xbe,0x28,0x92,0xfb,0x65 ; 4_ 993f,99a7,9a0f,9a78,9ae0,9b48,9bb1,9c1b,9c83,9cec,9d55,9dbe,9e28,9e92,9efb,9f65 4_ db 0xcf,0x39,0xa4,0x0f,0x78,0xe2,0x4d,0xb8,0x23,0x8f,0xf9,0x64,0xd0,0x3c,0xa7,0x13 ; 5_ 9fcf,a039,a0a4,a10f,a178,a1e2,a24d,a2b8,a323,a38f,a3f9,a464,a4d0,a53c,a5a7,a613 5_ db 0x7f,0xeb,0x57,0xc4,0x30,0x9d,0x09,0x76,0xe3,0x51,0xbd,0x2a,0x98,0x07,0x73,0xe1 ; 6_ a67f,a6eb,a757,a7c4,a830,a89d,a909,a976,a9e3,aa51,aabd,ab2a,ab98,ac07,ac73,ace1 6_ db 0x4f,0xbd,0x2b,0x9b,0x08,0x76,0xe5,0x53,0xc3,0x32,0xa1,0x10,0x81,0xf0,0x5f,0xcf ; 7_ ad4f,adbd,ae2b,ae9b,af08,af76,afe5,b053,b0c3,b132,b1a1,b210,b281,b2f0,b35f,b3cf 7_ db 0x3f,0xaf,0x1f,0x8f,0x01,0x70,0xe1,0x52,0xc3,0x35,0xa5,0x16,0x88,0xf9,0x6b,0xdd ; 8_ b43f,b4af,b51f,b58f,b601,b670,b6e1,b752,b7c3,b835,b8a5,b916,b988,b9f9,ba6b,badd 8_ db 0x4f,0xc1,0x33,0xa5,0x18,0x8b,0xfd,0x70,0xe3,0x56,0xc9,0x3d,0xb0,0x23,0x97,0x0b ; 9_ bb4f,bbc1,bc33,bca5,bd18,bd8b,bdfd,be70,bee3,bf56,bfc9,c03d,c0b0,c123,c197,c20b 9_ db 0x7f,0xf4,0x67,0xdb,0x50,0xc4,0x39,0xae,0x23,0x98,0x0d,0x83,0xf8,0x6d,0xe4,0x5a ; A_ c27f,c2f4,c367,c3db,c450,c4c4,c539,c5ae,c623,c698,c70d,c783,c7f8,c86d,c8e4,c95a A_ db 0xcf,0x45,0xbb,0x31,0xa8,0x1e,0x95,0x0c,0x83,0xfa,0x71,0xe9,0x60,0xd7,0x4f,0xc7 ; B_ c9cf,ca45,cabb,cb31,cba8,cc1e,cc95,cd0c,cd83,cdfa,ce71,cee9,cf60,cfd7,d04f,d0c7 B_ db 0x3f,0xb7,0x2f,0xa7,0x20,0x98,0x11,0x8b,0x03,0x7c,0xf5,0x6e,0xe8,0x61,0xdb,0x55 ; C_ d13f,d1b7,d22f,d2a7,d320,d398,d411,d48b,d503,d57c,d5f5,d66e,d6e8,d761,d7db,d855 C_ db 0xcf,0x49,0xc3,0x3d,0xb8,0x32,0xad,0x28,0xa3,0x1e,0x99,0x14,0x90,0x0b,0x87,0x03 ; D_ d8cf,d949,d9c3,da3d,dab8,db32,dbad,dc28,dca3,dd1e,dd99,de14,de90,df0b,df87,e003 D_ db 0x7f,0xfb,0x77,0xf3,0x70,0xec,0x69,0xe6,0x63,0xe0,0x5d,0xda,0x58,0xd5,0x53,0xd1 ; E_ e07f,e0fb,e177,e1f3,e270,e2ec,e369,e3e6,e463,e4e0,e55d,e5da,e658,e6d5,e753,e7d1 E_ db 0x4f,0xcd,0x4b,0xc9,0x48,0xc6,0x45,0xc4,0x43,0xc2,0x41,0xc0,0x40,0xbf,0x3f,0x00 ; F_ e84f,e8cd,e94b,e9c9,ea48,eac6,eb45,ebc4,ec43,ecc2,ed41,edc0,ee40,eebf,ef3f, 00 F_ ;Tab_ApB_hi_1: ; tab _plus[i] - 0xFE0 ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x80,0x80,0x81,0x81,0x81,0x82,0x82,0x82,0x83,0x83,0x84,0x84,0x84,0x85,0x85,0x85 ; 0_ db 0x86,0x86,0x87,0x87,0x87,0x88,0x88,0x89,0x89,0x89,0x8a,0x8a,0x8a,0x8b,0x8b,0x8c ; 1_ db 0x8c,0x8c,0x8d,0x8d,0x8e,0x8e,0x8e,0x8f,0x8f,0x90,0x90,0x90,0x91,0x91,0x92,0x92 ; 2_ db 0x92,0x93,0x93,0x94,0x94,0x94,0x95,0x95,0x96,0x96,0x96,0x97,0x97,0x98,0x98,0x98 ; 3_ db 0x99,0x99,0x9a,0x9a,0x9a,0x9b,0x9b,0x9c,0x9c,0x9c,0x9d,0x9d,0x9e,0x9e,0x9e,0x9f ; 4_ db 0x9f,0xa0,0xa0,0xa1,0xa1,0xa1,0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4,0xa5,0xa5,0xa6 ; 5_ db 0xa6,0xa6,0xa7,0xa7,0xa8,0xa8,0xa9,0xa9,0xa9,0xaa,0xaa,0xab,0xab,0xac,0xac,0xac ; 6_ db 0xad,0xad,0xae,0xae,0xaf,0xaf,0xaf,0xb0,0xb0,0xb1,0xb1,0xb2,0xb2,0xb2,0xb3,0xb3 ; 7_ db 0xb4,0xb4,0xb5,0xb5,0xb6,0xb6,0xb6,0xb7,0xb7,0xb8,0xb8,0xb9,0xb9,0xb9,0xba,0xba ; 8_ db 0xbb,0xbb,0xbc,0xbc,0xbd,0xbd,0xbd,0xbe,0xbe,0xbf,0xbf,0xc0,0xc0,0xc1,0xc1,0xc2 ; 9_ db 0xc2,0xc2,0xc3,0xc3,0xc4,0xc4,0xc5,0xc5,0xc6,0xc6,0xc7,0xc7,0xc7,0xc8,0xc8,0xc9 ; A_ db 0xc9,0xca,0xca,0xcb,0xcb,0xcc,0xcc,0xcd,0xcd,0xcd,0xce,0xce,0xcf,0xcf,0xd0,0xd0 ; B_ db 0xd1,0xd1,0xd2,0xd2,0xd3,0xd3,0xd4,0xd4,0xd5,0xd5,0xd5,0xd6,0xd6,0xd7,0xd7,0xd8 ; C_ db 0xd8,0xd9,0xd9,0xda,0xda,0xdb,0xdb,0xdc,0xdc,0xdd,0xdd,0xde,0xde,0xdf,0xdf,0xe0 ; D_ db 0xe0,0xe0,0xe1,0xe1,0xe2,0xe2,0xe3,0xe3,0xe4,0xe4,0xe5,0xe5,0xe6,0xe6,0xe7,0xe7 ; E_ db 0xe8,0xe8,0xe9,0xe9,0xea,0xea,0xeb,0xeb,0xec,0xec,0xed,0xed,0xee,0xee,0xef,0x00 ; F_ ;Tab_ApB_lo_0: ; tab _plus[i] - 0xFE0 Tab_ApB: ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x3f,0x7f,0xbf,0xff,0x40,0x80,0xc1,0x02,0x43,0x84,0xc5,0x06,0x48,0x89,0xcb,0x0d ; 0_ 303f,307f,30bf,30ff,3140,3180,31c1,3202,3243,3284,32c5,3306,3348,3389,33cb,340d 0_ db 0x4f,0x91,0xd3,0x15,0x58,0x9a,0xdd,0x20,0x63,0xa6,0xe9,0x2c,0x70,0xb3,0xf7,0x3c ; 1_ 344f,3491,34d3,3515,3558,359a,35dd,3620,3663,36a6,36e9,372c,3770,37b3,37f7,383c 1_ db 0x7f,0xc3,0x07,0x4b,0x90,0xd5,0x19,0x5e,0xa3,0xe8,0x2d,0x72,0xb8,0xfd,0x44,0x89 ; 2_ 387f,38c3,3907,394b,3990,39d5,3a19,3a5e,3aa3,3ae8,3b2d,3b72,3bb8,3bfd,3c44,3c89 2_ db 0xcf,0x15,0x5b,0xa1,0xe8,0x2f,0x75,0xbc,0x03,0x4a,0x91,0xd8,0x21,0x68,0xb0,0xf7 ; 3_ 3ccf,3d15,3d5b,3da1,3de8,3e2f,3e75,3ebc,3f03,3f4a,3f91,3fd8,4021,4068,40b0,40f7 3_ db 0x3f,0x87,0xcf,0x18,0x61,0xa9,0xf1,0x3a,0x83,0xcb,0x15,0x5f,0xa8,0xf2,0x3b,0x85 ; 4_ 413f,4187,41cf,4218,4261,42a9,42f1,433a,4383,43cb,4415,445f,44a8,44f2,453b,4585 4_ db 0xcf,0x19,0x64,0xaf,0xf8,0x42,0x8d,0xd8,0x23,0x6f,0xb9,0x04,0x50,0x9c,0xe7,0x33 ; 5_ 45cf,4619,4664,46af,46f8,4742,478d,47d8,4823,486f,48b9,4904,4950,499c,49e7,4a33 5_ db 0x7f,0xcb,0x17,0x64,0xb0,0xfd,0x49,0x96,0xe3,0x30,0x7d,0xca,0x18,0x67,0xb3,0x01 ; 6_ 4a7f,4acb,4b17,4b64,4bb0,4bfd,4c49,4c96,4ce3,4d30,4d7d,4dca,4e18,4e67,4eb3,4f01 6_ db 0x4f,0x9e,0xeb,0x3b,0x88,0xd6,0x25,0x73,0xc3,0x13,0x62,0xb0,0x00,0x4f,0xa0,0xef ; 7_ 4f4f,4f9e,4feb,503b,5088,50d6,5125,5173,51c3,5213,5262,52b0,5300,534f,53a0,53ef 7_ db 0x3f,0x8f,0xe0,0x30,0x80,0xd1,0x22,0x72,0xc3,0x15,0x65,0xb6,0x08,0x59,0xab,0xfd ; 8_ 543f,548f,54e0,5530,5580,55d1,5622,5672,56c3,5715,5765,57b6,5808,5859,58ab,58fd 8_ db 0x4f,0xa1,0xf3,0x45,0x98,0xec,0x3d,0x90,0xe3,0x35,0x89,0xdd,0x30,0x83,0xd7,0x2d ; 9_ 594f,59a1,59f3,5a45,5a98,5aec,5b3d,5b90,5be3,5c35,5c89,5cdd,5d30,5d83,5dd7,5e2d 9_ db 0x7f,0xd4,0x27,0x7c,0xd0,0x25,0x79,0xcd,0x23,0x78,0xcd,0x23,0x78,0xcc,0x24,0x7a ; A_ 5e7f,5ed4,5f27,5f7c,5fd0,6025,6079,60cd,6123,6178,61cd,6223,6278,62cc,6324,637a A_ db 0xcf,0x26,0x7b,0xd2,0x28,0x7e,0xd5,0x2e,0x83,0xda,0x31,0x89,0xe1,0x37,0x8f,0xe8 ; B_ 63cf,6426,647b,64d2,6528,657e,65d5,662e,6683,66da,6731,6789,67e1,6837,688f,68e8 B_ db 0x3f,0x97,0xef,0x48,0xa1,0xf9,0x51,0xab,0x03,0x5c,0xb5,0x0e,0x68,0xc1,0x1b,0x74 ; C_ 693f,6997,69ef,6a48,6aa1,6af9,6b51,6bab,6c03,6c5c,6cb5,6d0e,6d68,6dc1,6e1b,6e74 C_ db 0xcf,0x2a,0x84,0xde,0x38,0x93,0xed,0x48,0xa3,0xff,0x59,0xb5,0x10,0x6b,0xc7,0x23 ; D_ 6ecf,6f2a,6f84,6fde,7038,7093,70ed,7148,71a3,71ff,7259,72b5,7310,736b,73c7,7423 D_ db 0x7f,0xdb,0x37,0x93,0xf0,0x4f,0xa9,0x07,0x63,0xc0,0x1d,0x7b,0xd8,0x35,0x93,0xf1 ; E_ 747f,74db,7537,7593,75f0,764f,76a9,7707,7763,77c0,781d,787b,78d8,7935,7993,79f1 E_ db 0x4f,0xac,0x0b,0x69,0xc8,0x27,0x85,0xe4,0x43,0xa2,0x02,0x60,0xc0,0x1f,0x80,0xe0 ; F_ 7a4f,7aac,7b0b,7b69,7bc8,7c27,7c85,7ce4,7d43,7da2,7e02,7e60,7ec0,7f1f,7f80,7fe0 F_ ;Tab_ApB_hi_0: ; tab _plus[i] - 0xFE0 ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x30,0x30,0x30,0x30,0x31,0x31,0x31,0x32,0x32,0x32,0x32,0x33,0x33,0x33,0x33,0x34 ; 0_ db 0x34,0x34,0x34,0x35,0x35,0x35,0x35,0x36,0x36,0x36,0x36,0x37,0x37,0x37,0x37,0x38 ; 1_ db 0x38,0x38,0x39,0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3b,0x3c,0x3c ; 2_ db 0x3c,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x3f,0x40,0x40,0x40,0x40 ; 3_ db 0x41,0x41,0x41,0x42,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x44,0x45,0x45 ; 4_ db 0x45,0x46,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4a ; 5_ db 0x4a,0x4a,0x4b,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f ; 6_ db 0x4f,0x4f,0x4f,0x50,0x50,0x50,0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x53 ; 7_ db 0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58,0x58 ; 8_ db 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e ; 9_ db 0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60,0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63 ; A_ db 0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68 ; B_ db 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e ; C_ db 0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70,0x71,0x71,0x71,0x72,0x72,0x73,0x73,0x73,0x74 ; D_ db 0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79,0x79,0x79 ; E_ db 0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f ; F_ ; nic nemusi: 25482(38.882446%), musi pricitat 0x20: 40054(61.117554%), pretece pricteni: 0 ; neni presne: 0 (0.000000%), chyb: 0, sum: 65536 ; Align to 256-byte page boundary DEFS (($ + 0xFF) / 0x100) * 0x100 - $ ; mantisa = 1 ; 1 / ( 2**exp * mantisa ) = 2**(-exp) * 1 ; // mantisa = 1.01 .. 1.99 ; 1 / ( 2**exp * mantisa ) = 2**(-exp-1) * 2*1/mantisa DIVTAB: ; lo ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x00,0xfe,0xfc,0xfa,0xf8,0xf6,0xf4,0xf2,0xf0,0xef,0xed,0xeb,0xe9,0xe7,0xe5,0xe4 ; 0_ 00,fe,fc,fa,f8,f6,f4,f2,f0,ef,ed,eb,e9,e7,e5,e4 0_ db 0xe2,0xe0,0xde,0xdd,0xdb,0xd9,0xd7,0xd6,0xd4,0xd2,0xd1,0xcf,0xce,0xcc,0xca,0xc9 ; 1_ e2,e0,de,dd,db,d9,d7,d6,d4,d2,d1,cf,ce,cc,ca,c9 1_ db 0xc7,0xc6,0xc4,0xc2,0xc1,0xbf,0xbe,0xbc,0xbb,0xb9,0xb8,0xb6,0xb5,0xb3,0xb2,0xb1 ; 2_ c7,c6,c4,c2,c1,bf,be,bc,bb,b9,b8,b6,b5,b3,b2,b1 2_ db 0xaf,0xae,0xac,0xab,0xaa,0xa8,0xa7,0xa5,0xa4,0xa3,0xa1,0xa0,0x9f,0x9d,0x9c,0x9b ; 3_ af,ae,ac,ab,aa,a8,a7,a5,a4,a3,a1,a0,9f,9d,9c,9b 3_ db 0x9a,0x98,0x97,0x96,0x95,0x93,0x92,0x91,0x90,0x8e,0x8d,0x8c,0x8b,0x8a,0x88,0x87 ; 4_ 9a,98,97,96,95,93,92,91,90,8e,8d,8c,8b,8a,88,87 4_ db 0x86,0x85,0x84,0x83,0x82,0x80,0x7f,0x7e,0x7d,0x7c,0x7b,0x7a,0x79,0x78,0x76,0x75 ; 5_ 86,85,84,83,82,80,7f,7e,7d,7c,7b,7a,79,78,76,75 5_ db 0x74,0x73,0x72,0x71,0x70,0x6f,0x6e,0x6d,0x6c,0x6b,0x6a,0x69,0x68,0x67,0x66,0x65 ; 6_ 74,73,72,71,70,6f,6e,6d,6c,6b,6a,69,68,67,66,65 6_ db 0x64,0x63,0x62,0x61,0x60,0x5f,0x5e,0x5e,0x5d,0x5c,0x5b,0x5a,0x59,0x58,0x57,0x56 ; 7_ 64,63,62,61,60,5f,5e,5e,5d,5c,5b,5a,59,58,57,56 7_ db 0x55,0x54,0x54,0x53,0x52,0x51,0x50,0x4f,0x4e,0x4e,0x4d,0x4c,0x4b,0x4a,0x49,0x49 ; 8_ 55,54,54,53,52,51,50,4f,4e,4e,4d,4c,4b,4a,49,49 8_ db 0x48,0x47,0x46,0x45,0x44,0x44,0x43,0x42,0x41,0x40,0x40,0x3f,0x3e,0x3d,0x3d,0x3c ; 9_ 48,47,46,45,44,44,43,42,41,40,40,3f,3e,3d,3d,3c 9_ db 0x3b,0x3a,0x3a,0x39,0x38,0x37,0x37,0x36,0x35,0x34,0x34,0x33,0x32,0x32,0x31,0x30 ; A_ 3b,3a,3a,39,38,37,37,36,35,34,34,33,32,32,31,30 A_ db 0x2f,0x2f,0x2e,0x2d,0x2d,0x2c,0x2b,0x2b,0x2a,0x29,0x29,0x28,0x27,0x27,0x26,0x25 ; B_ 2f,2f,2e,2d,2d,2c,2b,2b,2a,29,29,28,27,27,26,25 B_ db 0x25,0x24,0x23,0x23,0x22,0x21,0x21,0x20,0x1f,0x1f,0x1e,0x1e,0x1d,0x1c,0x1c,0x1b ; C_ 25,24,23,23,22,21,21,20,1f,1f,1e,1e,1d,1c,1c,1b C_ db 0x1a,0x1a,0x19,0x19,0x18,0x17,0x17,0x16,0x16,0x15,0x15,0x14,0x13,0x13,0x12,0x12 ; D_ 1a,1a,19,19,18,17,17,16,16,15,15,14,13,13,12,12 D_ db 0x11,0x10,0x10,0x0f,0x0f,0x0e,0x0e,0x0d,0x0d,0x0c,0x0b,0x0b,0x0a,0x0a,0x09,0x09 ; E_ 11,10,10,0f,0f,0e,0e,0d,0d,0c,0b,0b,0a,0a,09,09 E_ db 0x08,0x08,0x07,0x07,0x06,0x06,0x05,0x05,0x04,0x04,0x03,0x03,0x02,0x02,0x01,0x01 ; F_ 08,08,07,07,06,06,05,05,04,04,03,03,02,02,01,01 F_ ; sum: 4294967296, rozdíl: má být mínus jest, nemohu se splést... ; nepřesnost o 1: 863749376 (20.111%) ; nepřesnost o 2: 0 (0.000%) ; nepřesnost o 3: 0 (0.000%) ; chyb: 0 (0.000%) ; Align to 256-byte page boundary DEFS (($ + 0xFF) / 0x100) * 0x100 - $ ; Mantissas of square roots ; (2**-3 * mantisa)**0.5 = 2**-1 * mantisa**0.5 * 2**-0.5 = 2**-2 * 2**0.5 ; (2**-2 * mantisa)**0.5 = 2**-1 * mantisa**0.5 ; (2**-1 * mantisa)**0.5 = 2**+0 * mantisa**0.5 * 2**-0.5 = 2**-1 * 2**0.5 ; (2**+0 * mantisa)**0.5 = 2**+0 * mantisa**0.5 ; (2**+1 * mantisa)**0.5 = 2**+0 * mantisa**0.5 * 2**0.5 ; (2**+2 * mantisa)**0.5 = 2**+1 * mantisa**0.5 ; (2**+3 * mantisa)**0.5 = 2**+1 * mantisa**0.5 * 2**0.5 ; exp = 2*e ; (2**exp * mantisa)**0.5 = 2**e * mantisa**0.5 ; exp = 2*e+1 ; (2**exp * mantisa)**0.5 = 2**e * mantisa**0.5 * 2**0.5 SQR_TAB: ; lo exp=2*x ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07 ; 0_ 00,00,01,01,02,02,03,03,04,04,05,05,06,06,07,07 0_ db 0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f ; 1_ 08,08,09,09,0a,0a,0b,0b,0c,0c,0d,0d,0e,0e,0f,0f 1_ db 0x10,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17 ; 2_ 10,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17 2_ db 0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1e ; 3_ 17,17,18,18,19,19,1a,1a,1b,1b,1c,1c,1c,1d,1d,1e 3_ db 0x1e,0x1f,0x1f,0x20,0x20,0x20,0x21,0x21,0x22,0x22,0x23,0x23,0x24,0x24,0x24,0x25 ; 4_ 1e,1f,1f,20,20,20,21,21,22,22,23,23,24,24,24,25 4_ db 0x25,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2c ; 5_ 25,26,26,27,27,27,28,28,29,29,2a,2a,2a,2b,2b,2c 5_ db 0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2f,0x2f,0x30,0x30,0x30,0x31,0x31,0x32,0x32,0x33 ; 6_ 2c,2d,2d,2d,2e,2e,2f,2f,30,30,30,31,31,32,32,33 6_ db 0x33,0x33,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x39,0x39 ; 7_ 33,33,34,34,35,35,35,36,36,37,37,37,38,38,39,39 7_ db 0x3a,0x3a,0x3a,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x40 ; 8_ 3a,3a,3a,3b,3b,3c,3c,3c,3d,3d,3e,3e,3e,3f,3f,40 8_ db 0x40,0x40,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x46,0x46 ; 9_ 40,40,41,41,42,42,42,43,43,44,44,44,45,45,46,46 9_ db 0x46,0x47,0x47,0x48,0x48,0x48,0x49,0x49,0x49,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c ; A_ 46,47,47,48,48,48,49,49,49,4a,4a,4b,4b,4b,4c,4c A_ db 0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x50,0x50,0x50,0x51,0x51,0x52,0x52,0x52 ; B_ 4d,4d,4d,4e,4e,4e,4f,4f,50,50,50,51,51,52,52,52 B_ db 0x53,0x53,0x53,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x58,0x58,0x58 ; C_ 53,53,53,54,54,55,55,55,56,56,56,57,57,58,58,58 C_ db 0x59,0x59,0x59,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e ; D_ 59,59,59,5a,5a,5b,5b,5b,5c,5c,5c,5d,5d,5d,5e,5e D_ db 0x5f,0x5f,0x5f,0x60,0x60,0x60,0x61,0x61,0x61,0x62,0x62,0x63,0x63,0x63,0x64,0x64 ; E_ 5f,5f,5f,60,60,60,61,61,61,62,62,63,63,63,64,64 E_ db 0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x68,0x68,0x68,0x69,0x69,0x69,0x6a ; F_ 64,65,65,65,66,66,66,67,67,68,68,68,69,69,69,6a F_ ; lo exp=2*x+1 ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x6a,0x6b,0x6b,0x6c,0x6d,0x6e,0x6e,0x6f,0x70,0x70,0x71,0x72,0x72,0x73,0x74,0x74 ; 0_ 6a,6b,6b,6c,6d,6e,6e,6f,70,70,71,72,72,73,74,74 0_ db 0x75,0x76,0x77,0x77,0x78,0x79,0x79,0x7a,0x7b,0x7b,0x7c,0x7d,0x7d,0x7e,0x7f,0x7f ; 1_ 75,76,77,77,78,79,79,7a,7b,7b,7c,7d,7d,7e,7f,7f 1_ db 0x80,0x81,0x81,0x82,0x83,0x83,0x84,0x85,0x85,0x86,0x87,0x87,0x88,0x89,0x89,0x8a ; 2_ 80,81,81,82,83,83,84,85,85,86,87,87,88,89,89,8a 2_ db 0x8b,0x8b,0x8c,0x8c,0x8d,0x8e,0x8e,0x8f,0x90,0x90,0x91,0x92,0x92,0x93,0x94,0x94 ; 3_ 8b,8b,8c,8c,8d,8e,8e,8f,90,90,91,92,92,93,94,94 3_ db 0x95,0x95,0x96,0x97,0x97,0x98,0x99,0x99,0x9a,0x9a,0x9b,0x9c,0x9c,0x9d,0x9e,0x9e ; 4_ 95,95,96,97,97,98,99,99,9a,9a,9b,9c,9c,9d,9e,9e 4_ db 0x9f,0x9f,0xa0,0xa1,0xa1,0xa2,0xa2,0xa3,0xa4,0xa4,0xa5,0xa6,0xa6,0xa7,0xa7,0xa8 ; 5_ 9f,9f,a0,a1,a1,a2,a2,a3,a4,a4,a5,a6,a6,a7,a7,a8 5_ db 0xa9,0xa9,0xaa,0xaa,0xab,0xac,0xac,0xad,0xad,0xae,0xaf,0xaf,0xb0,0xb0,0xb1,0xb1 ; 6_ a9,a9,aa,aa,ab,ac,ac,ad,ad,ae,af,af,b0,b0,b1,b1 6_ db 0xb2,0xb3,0xb3,0xb4,0xb4,0xb5,0xb6,0xb6,0xb7,0xb7,0xb8,0xb9,0xb9,0xba,0xba,0xbb ; 7_ b2,b3,b3,b4,b4,b5,b6,b6,b7,b7,b8,b9,b9,ba,ba,bb 7_ db 0xbb,0xbc,0xbd,0xbd,0xbe,0xbe,0xbf,0xbf,0xc0,0xc1,0xc1,0xc2,0xc2,0xc3,0xc3,0xc4 ; 8_ bb,bc,bd,bd,be,be,bf,bf,c0,c1,c1,c2,c2,c3,c3,c4 8_ db 0xc5,0xc5,0xc6,0xc6,0xc7,0xc7,0xc8,0xc8,0xc9,0xca,0xca,0xcb,0xcb,0xcc,0xcc,0xcd ; 9_ c5,c5,c6,c6,c7,c7,c8,c8,c9,ca,ca,cb,cb,cc,cc,cd 9_ db 0xce,0xce,0xcf,0xcf,0xd0,0xd0,0xd1,0xd1,0xd2,0xd2,0xd3,0xd4,0xd4,0xd5,0xd5,0xd6 ; A_ ce,ce,cf,cf,d0,d0,d1,d1,d2,d2,d3,d4,d4,d5,d5,d6 A_ db 0xd6,0xd7,0xd7,0xd8,0xd8,0xd9,0xda,0xda,0xdb,0xdb,0xdc,0xdc,0xdd,0xdd,0xde,0xde ; B_ d6,d7,d7,d8,d8,d9,da,da,db,db,dc,dc,dd,dd,de,de B_ db 0xdf,0xdf,0xe0,0xe1,0xe1,0xe2,0xe2,0xe3,0xe3,0xe4,0xe4,0xe5,0xe5,0xe6,0xe6,0xe7 ; C_ df,df,e0,e1,e1,e2,e2,e3,e3,e4,e4,e5,e5,e6,e6,e7 C_ db 0xe7,0xe8,0xe8,0xe9,0xea,0xea,0xeb,0xeb,0xec,0xec,0xed,0xed,0xee,0xee,0xef,0xef ; D_ e7,e8,e8,e9,ea,ea,eb,eb,ec,ec,ed,ed,ee,ee,ef,ef D_ db 0xf0,0xf0,0xf1,0xf1,0xf2,0xf2,0xf3,0xf3,0xf4,0xf4,0xf5,0xf5,0xf6,0xf6,0xf7,0xf7 ; E_ f0,f0,f1,f1,f2,f2,f3,f3,f4,f4,f5,f5,f6,f6,f7,f7 E_ db 0xf8,0xf8,0xf9,0xf9,0xfa,0xfa,0xfb,0xfb,0xfc,0xfc,0xfd,0xfd,0xfe,0xfe,0xff,0xff ; F_ f8,f8,f9,f9,fa,fa,fb,fb,fc,fc,fd,fd,fe,fe,ff,ff F_ ; Align to 256-byte page boundary DEFS (($ + 0xFF) / 0x100) * 0x100 - $ ; ln(2^exp*man) = ln(2^exp) + ln(man) = ln(2)*exp + ln(man) = ln2_exp[e] + ln_m[m] Ln_M: ; lo ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x00,0xff,0xfe,0x7e,0xfc,0x3d,0x7c,0xba,0xf8,0x1b,0x3a,0x59,0x77,0x96,0xb4,0xd2 ; 0_ 0000,37ff,38fe,397e,39fc,3a3d,3a7c,3aba,3af8,3b1b,3b3a,3b59,3b77,3b96,3bb4,3bd2 0_ db 0xf1,0x07,0x16,0x25,0x34,0x43,0x52,0x60,0x6f,0x7e,0x8c,0x9b,0xa9,0xb8,0xc6,0xd4 ; 1_ 3bf1,3c07,3c16,3c25,3c34,3c43,3c52,3c60,3c6f,3c7e,3c8c,3c9b,3ca9,3cb8,3cc6,3cd4 1_ db 0xe2,0xf1,0xff,0x06,0x0d,0x14,0x1b,0x22,0x29,0x30,0x37,0x3e,0x45,0x4c,0x52,0x59 ; 2_ 3ce2,3cf1,3cff,3d06,3d0d,3d14,3d1b,3d22,3d29,3d30,3d37,3d3e,3d45,3d4c,3d52,3d59 2_ db 0x60,0x67,0x6d,0x74,0x7b,0x81,0x88,0x8f,0x95,0x9c,0xa2,0xa9,0xaf,0xb6,0xbc,0xc3 ; 3_ 3d60,3d67,3d6d,3d74,3d7b,3d81,3d88,3d8f,3d95,3d9c,3da2,3da9,3daf,3db6,3dbc,3dc3 3_ db 0xc9,0xcf,0xd6,0xdc,0xe2,0xe9,0xef,0xf5,0xfc,0x01,0x04,0x07,0x0a,0x0d,0x10,0x13 ; 4_ 3dc9,3dcf,3dd6,3ddc,3de2,3de9,3def,3df5,3dfc,3e01,3e04,3e07,3e0a,3e0d,3e10,3e13 4_ db 0x16,0x1a,0x1d,0x20,0x23,0x26,0x29,0x2c,0x2f,0x32,0x34,0x37,0x3a,0x3d,0x40,0x43 ; 5_ 3e16,3e1a,3e1d,3e20,3e23,3e26,3e29,3e2c,3e2f,3e32,3e34,3e37,3e3a,3e3d,3e40,3e43 5_ db 0x46,0x49,0x4c,0x4f,0x52,0x55,0x57,0x5a,0x5d,0x60,0x63,0x66,0x68,0x6b,0x6e,0x71 ; 6_ 3e46,3e49,3e4c,3e4f,3e52,3e55,3e57,3e5a,3e5d,3e60,3e63,3e66,3e68,3e6b,3e6e,3e71 6_ db 0x74,0x76,0x79,0x7c,0x7f,0x81,0x84,0x87,0x8a,0x8c,0x8f,0x92,0x94,0x97,0x9a,0x9d ; 7_ 3e74,3e76,3e79,3e7c,3e7f,3e81,3e84,3e87,3e8a,3e8c,3e8f,3e92,3e94,3e97,3e9a,3e9d 7_ db 0x9f,0xa2,0xa5,0xa7,0xaa,0xac,0xaf,0xb2,0xb4,0xb7,0xba,0xbc,0xbf,0xc1,0xc4,0xc6 ; 8_ 3e9f,3ea2,3ea5,3ea7,3eaa,3eac,3eaf,3eb2,3eb4,3eb7,3eba,3ebc,3ebf,3ec1,3ec4,3ec6 8_ db 0xc9,0xcc,0xce,0xd1,0xd3,0xd6,0xd8,0xdb,0xdd,0xe0,0xe2,0xe5,0xe7,0xea,0xec,0xef ; 9_ 3ec9,3ecc,3ece,3ed1,3ed3,3ed6,3ed8,3edb,3edd,3ee0,3ee2,3ee5,3ee7,3eea,3eec,3eef 9_ db 0xf1,0xf4,0xf6,0xf9,0xfb,0xfd,0x00,0x01,0x02,0x04,0x05,0x06,0x07,0x08,0x0a,0x0b ; A_ 3ef1,3ef4,3ef6,3ef9,3efb,3efd,3f00,3f01,3f02,3f04,3f05,3f06,3f07,3f08,3f0a,3f0b A_ db 0x0c,0x0d,0x0e,0x0f,0x11,0x12,0x13,0x14,0x15,0x16,0x18,0x19,0x1a,0x1b,0x1c,0x1d ; B_ 3f0c,3f0d,3f0e,3f0f,3f11,3f12,3f13,3f14,3f15,3f16,3f18,3f19,3f1a,3f1b,3f1c,3f1d B_ db 0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f ; C_ 3f1f,3f20,3f21,3f22,3f23,3f24,3f25,3f26,3f28,3f29,3f2a,3f2b,3f2c,3f2d,3f2e,3f2f C_ db 0x30,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3e,0x3f,0x40,0x41 ; D_ 3f30,3f32,3f33,3f34,3f35,3f36,3f37,3f38,3f39,3f3a,3f3b,3f3c,3f3e,3f3f,3f40,3f41 D_ db 0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x50,0x51,0x52 ; E_ 3f42,3f43,3f44,3f45,3f46,3f47,3f48,3f49,3f4a,3f4b,3f4c,3f4d,3f4e,3f50,3f51,3f52 E_ db 0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x61,0x62 ; F_ 3f53,3f54,3f55,3f56,3f57,3f58,3f59,3f5a,3f5b,3f5c,3f5d,3f5e,3f5f,3f60,3f61,3f62 F_ ; hi ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x00,0x37,0x38,0x39,0x39,0x3a,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3b,0x3b,0x3b,0x3b ; 0_ db 0x3b,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c ; 1_ db 0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d ; 2_ db 0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d ; 3_ db 0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e ; 4_ db 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e ; 5_ db 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e ; 6_ db 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e ; 7_ db 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e ; 8_ db 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e ; 9_ db 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f ; A_ db 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f ; B_ db 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f ; C_ db 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f ; D_ db 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f ; E_ db 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f ; F_ ; Numbers with exponent -1 ($3f) have lower result accuracy Ln2_Exp: dw 0xc563 ; -64*ln(2) = -44.3614 dw 0xc55d ; -63*ln(2) = -43.6683 dw 0xc558 ; -62*ln(2) = -42.9751 dw 0xc552 ; -61*ln(2) = -42.2820 dw 0xc54d ; -60*ln(2) = -41.5888 dw 0xc547 ; -59*ln(2) = -40.8957 dw 0xc542 ; -58*ln(2) = -40.2025 dw 0xc53c ; -57*ln(2) = -39.5094 dw 0xc537 ; -56*ln(2) = -38.8162 dw 0xc531 ; -55*ln(2) = -38.1231 dw 0xc52b ; -54*ln(2) = -37.4299 dw 0xc526 ; -53*ln(2) = -36.7368 dw 0xc520 ; -52*ln(2) = -36.0437 dw 0xc51b ; -51*ln(2) = -35.3505 dw 0xc515 ; -50*ln(2) = -34.6574 dw 0xc510 ; -49*ln(2) = -33.9642 dw 0xc50a ; -48*ln(2) = -33.2711 dw 0xc505 ; -47*ln(2) = -32.5779 dw 0xc4fe ; -46*ln(2) = -31.8848 dw 0xc4f3 ; -45*ln(2) = -31.1916 dw 0xc4e8 ; -44*ln(2) = -30.4985 dw 0xc4dd ; -43*ln(2) = -29.8053 dw 0xc4d2 ; -42*ln(2) = -29.1122 dw 0xc4c7 ; -41*ln(2) = -28.4190 dw 0xc4bc ; -40*ln(2) = -27.7259 dw 0xc4b1 ; -39*ln(2) = -27.0327 dw 0xc4a5 ; -38*ln(2) = -26.3396 dw 0xc49a ; -37*ln(2) = -25.6464 dw 0xc48f ; -36*ln(2) = -24.9533 dw 0xc484 ; -35*ln(2) = -24.2602 dw 0xc479 ; -34*ln(2) = -23.5670 dw 0xc46e ; -33*ln(2) = -22.8739 dw 0xc463 ; -32*ln(2) = -22.1807 dw 0xc458 ; -31*ln(2) = -21.4876 dw 0xc44d ; -30*ln(2) = -20.7944 dw 0xc442 ; -29*ln(2) = -20.1013 dw 0xc437 ; -28*ln(2) = -19.4081 dw 0xc42b ; -27*ln(2) = -18.7150 dw 0xc420 ; -26*ln(2) = -18.0218 dw 0xc415 ; -25*ln(2) = -17.3287 dw 0xc40a ; -24*ln(2) = -16.6355 dw 0xc3fe ; -23*ln(2) = -15.9424 dw 0xc3e8 ; -22*ln(2) = -15.2492 dw 0xc3d2 ; -21*ln(2) = -14.5561 dw 0xc3bc ; -20*ln(2) = -13.8629 dw 0xc3a5 ; -19*ln(2) = -13.1698 dw 0xc38f ; -18*ln(2) = -12.4766 dw 0xc379 ; -17*ln(2) = -11.7835 dw 0xc363 ; -16*ln(2) = -11.0904 dw 0xc34d ; -15*ln(2) = -10.3972 dw 0xc337 ; -14*ln(2) = -9.7041 dw 0xc320 ; -13*ln(2) = -9.0109 dw 0xc30a ; -12*ln(2) = -8.3178 dw 0xc2e8 ; -11*ln(2) = -7.6246 dw 0xc2bc ; -10*ln(2) = -6.9315 dw 0xc28f ; -9*ln(2) = -6.2383 dw 0xc263 ; -8*ln(2) = -5.5452 dw 0xc237 ; -7*ln(2) = -4.8520 dw 0xc20a ; -6*ln(2) = -4.1589 dw 0xc1bc ; -5*ln(2) = -3.4657 dw 0xc163 ; -4*ln(2) = -2.7726 dw 0xc10a ; -3*ln(2) = -2.0794 dw 0xc063 ; -2*ln(2) = -1.3863 dw 0xbf63 ; -1*ln(2) = -0.6931 dw 0x0000 ; 0*ln(2) = 0.0000 dw 0x3f63 ; 1*ln(2) = 0.6931 dw 0x4063 ; 2*ln(2) = 1.3863 dw 0x410a ; 3*ln(2) = 2.0794 dw 0x4163 ; 4*ln(2) = 2.7726 dw 0x41bc ; 5*ln(2) = 3.4657 dw 0x420a ; 6*ln(2) = 4.1589 dw 0x4237 ; 7*ln(2) = 4.8520 dw 0x4263 ; 8*ln(2) = 5.5452 dw 0x428f ; 9*ln(2) = 6.2383 dw 0x42bc ; 10*ln(2) = 6.9315 dw 0x42e8 ; 11*ln(2) = 7.6246 dw 0x430a ; 12*ln(2) = 8.3178 dw 0x4320 ; 13*ln(2) = 9.0109 dw 0x4337 ; 14*ln(2) = 9.7041 dw 0x434d ; 15*ln(2) = 10.3972 dw 0x4363 ; 16*ln(2) = 11.0904 dw 0x4379 ; 17*ln(2) = 11.7835 dw 0x438f ; 18*ln(2) = 12.4766 dw 0x43a5 ; 19*ln(2) = 13.1698 dw 0x43bc ; 20*ln(2) = 13.8629 dw 0x43d2 ; 21*ln(2) = 14.5561 dw 0x43e8 ; 22*ln(2) = 15.2492 dw 0x43fe ; 23*ln(2) = 15.9424 dw 0x440a ; 24*ln(2) = 16.6355 dw 0x4415 ; 25*ln(2) = 17.3287 dw 0x4420 ; 26*ln(2) = 18.0218 dw 0x442b ; 27*ln(2) = 18.7150 dw 0x4437 ; 28*ln(2) = 19.4081 dw 0x4442 ; 29*ln(2) = 20.1013 dw 0x444d ; 30*ln(2) = 20.7944 dw 0x4458 ; 31*ln(2) = 21.4876 dw 0x4463 ; 32*ln(2) = 22.1807 dw 0x446e ; 33*ln(2) = 22.8739 dw 0x4479 ; 34*ln(2) = 23.5670 dw 0x4484 ; 35*ln(2) = 24.2602 dw 0x448f ; 36*ln(2) = 24.9533 dw 0x449a ; 37*ln(2) = 25.6464 dw 0x44a5 ; 38*ln(2) = 26.3396 dw 0x44b1 ; 39*ln(2) = 27.0327 dw 0x44bc ; 40*ln(2) = 27.7259 dw 0x44c7 ; 41*ln(2) = 28.4190 dw 0x44d2 ; 42*ln(2) = 29.1122 dw 0x44dd ; 43*ln(2) = 29.8053 dw 0x44e8 ; 44*ln(2) = 30.4985 dw 0x44f3 ; 45*ln(2) = 31.1916 dw 0x44fe ; 46*ln(2) = 31.8848 dw 0x4505 ; 47*ln(2) = 32.5779 dw 0x450a ; 48*ln(2) = 33.2711 dw 0x4510 ; 49*ln(2) = 33.9642 dw 0x4515 ; 50*ln(2) = 34.6574 dw 0x451b ; 51*ln(2) = 35.3505 dw 0x4520 ; 52*ln(2) = 36.0437 dw 0x4526 ; 53*ln(2) = 36.7368 dw 0x452b ; 54*ln(2) = 37.4299 dw 0x4531 ; 55*ln(2) = 38.1231 dw 0x4537 ; 56*ln(2) = 38.8162 dw 0x453c ; 57*ln(2) = 39.5094 dw 0x4542 ; 58*ln(2) = 40.2025 dw 0x4547 ; 59*ln(2) = 40.8957 dw 0x454d ; 60*ln(2) = 41.5888 dw 0x4552 ; 61*ln(2) = 42.2820 dw 0x4558 ; 62*ln(2) = 42.9751 dw 0x455d ; 63*ln(2) = 43.6683 ; rozdíl: má být mínus jest, nemohu se splést... ; nepřesnost: 7888 (24.0723 %) ; chyb: 49 (0.1495 %) Ln_FIX: ; lo ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0x63,0x61,0x5f,0x5d,0x5b,0x59,0x57,0x55,0x53,0x51,0x4f,0x4d,0x4b,0x4a,0x48,0x46 ; 0_ bf63,bf61,bf5f,bf5d,bf5b,bf59,bf57,bf55,bf53,bf51,bf4f,bf4d,bf4b,bf4a,bf48,bf46 0_ db 0x44,0x42,0x40,0x3e,0x3c,0x3b,0x39,0x37,0x35,0x33,0x31,0x30,0x2e,0x2c,0x2a,0x28 ; 1_ bf44,bf42,bf40,bf3e,bf3c,bf3b,bf39,bf37,bf35,bf33,bf31,bf30,bf2e,bf2c,bf2a,bf28 1_ db 0x27,0x25,0x23,0x21,0x20,0x1e,0x1c,0x1a,0x19,0x17,0x15,0x13,0x12,0x10,0x0e,0x0d ; 2_ bf27,bf25,bf23,bf21,bf20,bf1e,bf1c,bf1a,bf19,bf17,bf15,bf13,bf12,bf10,bf0e,bf0d 2_ db 0x0b,0x09,0x08,0x06,0x04,0x03,0x01,0xfe,0xfb,0xf8,0xf5,0xf1,0xee,0xeb,0xe8,0xe4 ; 3_ bf0b,bf09,bf08,bf06,bf04,bf03,bf01,befe,befb,bef8,bef5,bef1,beee,beeb,bee8,bee4 3_ db 0xe1,0xde,0xdb,0xd8,0xd5,0xd1,0xce,0xcb,0xc8,0xc5,0xc2,0xbf,0xbc,0xb9,0xb5,0xb2 ; 4_ bee1,bede,bedb,bed8,bed5,bed1,bece,becb,bec8,bec5,bec2,bebf,bebc,beb9,beb5,beb2 4_ db 0xaf,0xac,0xa9,0xa6,0xa3,0xa0,0x9d,0x9a,0x97,0x94,0x91,0x8e,0x8b,0x88,0x86,0x83 ; 5_ beaf,beac,bea9,bea6,bea3,bea0,be9d,be9a,be97,be94,be91,be8e,be8b,be88,be86,be83 5_ db 0x80,0x7d,0x7a,0x77,0x74,0x71,0x6e,0x6c,0x69,0x66,0x63,0x60,0x5d,0x5b,0x58,0x55 ; 6_ be80,be7d,be7a,be77,be74,be71,be6e,be6c,be69,be66,be63,be60,be5d,be5b,be58,be55 6_ db 0x52,0x4f,0x4d,0x4a,0x47,0x44,0x42,0x3f,0x3c,0x39,0x37,0x34,0x31,0x2f,0x2c,0x29 ; 7_ be52,be4f,be4d,be4a,be47,be44,be42,be3f,be3c,be39,be37,be34,be31,be2f,be2c,be29 7_ db 0x27,0x24,0x21,0x1f,0x1c,0x19,0x17,0x14,0x11,0x0f,0x0c,0x0a,0x07,0x04,0x02,0xff ; 8_ be27,be24,be21,be1f,be1c,be19,be17,be14,be11,be0f,be0c,be0a,be07,be04,be02,bdff 8_ db 0xfa,0xf4,0xef,0xea,0xe5,0xe0,0xdb,0xd6,0xd1,0xcc,0xc7,0xc2,0xbd,0xb8,0xb3,0xae ; 9_ bdfa,bdf4,bdef,bdea,bde5,bde0,bddb,bdd6,bdd1,bdcc,bdc7,bdc2,bdbd,bdb8,bdb3,bdae 9_ db 0xa9,0xa4,0x9f,0x9b,0x96,0x91,0x8c,0x87,0x82,0x7d,0x79,0x74,0x6f,0x6a,0x65,0x61 ; A_ bda9,bda4,bd9f,bd9b,bd96,bd91,bd8c,bd87,bd82,bd7d,bd79,bd74,bd6f,bd6a,bd65,bd61 A_ db 0x5c,0x57,0x52,0x4e,0x49,0x44,0x40,0x3b,0x36,0x32,0x2d,0x28,0x24,0x1f,0x1b,0x16 ; B_ bd5c,bd57,bd52,bd4e,bd49,bd44,bd40,bd3b,bd36,bd32,bd2d,bd28,bd24,bd1f,bd1b,bd16 B_ db 0x11,0x0d,0x08,0x04,0xff,0xf5,0xec,0xe3,0xda,0xd1,0xc9,0xc0,0xb7,0xae,0xa5,0x9c ; C_ bd11,bd0d,bd08,bd04,bcff,bcf5,bcec,bce3,bcda,bcd1,bcc9,bcc0,bcb7,bcae,bca5,bc9c C_ db 0x93,0x8a,0x82,0x79,0x70,0x67,0x5f,0x56,0x4d,0x45,0x3c,0x33,0x2b,0x22,0x19,0x11 ; D_ bc93,bc8a,bc82,bc79,bc70,bc67,bc5f,bc56,bc4d,bc45,bc3c,bc33,bc2b,bc22,bc19,bc11 D_ db 0x08,0x00,0xef,0xde,0xcd,0xbc,0xab,0x9a,0x89,0x79,0x68,0x57,0x46,0x36,0x25,0x15 ; E_ bc08,bc00,bbef,bbde,bbcd,bbbc,bbab,bb9a,bb89,bb79,bb68,bb57,bb46,bb36,bb25,bb15 E_ db 0x04,0xe7,0xc6,0xa5,0x85,0x64,0x43,0x23,0x02,0xc3,0x82,0x42,0x01,0x81,0x01,0x00 ; F_ bb04,bae7,bac6,baa5,ba85,ba64,ba43,ba23,ba02,b9c3,b982,b942,b901,b881,b801,b700 F_ ; hi ; _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F db 0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf ; 0_ db 0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf ; 1_ db 0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf ; 2_ db 0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe ; 3_ db 0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe ; 4_ db 0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe ; 5_ db 0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe ; 6_ db 0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe ; 7_ db 0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbe,0xbd ; 8_ db 0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd ; 9_ db 0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd ; A_ db 0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd ; B_ db 0xbd,0xbd,0xbd,0xbd,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc ; C_ db 0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc,0xbc ; D_ db 0xbc,0xbc,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb ; E_ db 0xbb,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb9,0xb9,0xb9,0xb9,0xb8,0xb8,0xb7 ; F_ ; Input: HL ; Output: Print space and signed decimal number in HL ; Pollutes: AF, BC, DE, HL = DE, DE = (SP) PRINT_S16: ld A, H ; 1:4 add A, A ; 1:4 jr nc, PRINT_U16 ; 2:7/12 xor A ; 1:4 neg sub L ; 1:4 neg ld L, A ; 1:4 neg sbc A, H ; 1:4 neg sub L ; 1:4 neg ld H, A ; 1:4 neg ld A, ' ' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A ld A, '-' ; 2:7 putchar Pollutes: AF, DE', BC' db 0x01 ; 3:10 ld BC, ** ; fall to print_u16 ; Input: HL ; Output: Print space and unsigned decimal number in HL ; Pollutes: AF, AF', BC, DE, HL = DE, DE = (SP) PRINT_U16: ld A, ' ' ; 2:7 putchar Pollutes: AF, DE', BC' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A ; Input: HL ; Output: Print unsigned decimal number in HL ; Pollutes: AF, BC, DE, HL = DE, DE = (SP) PRINT_U16_ONLY: call BIN2DEC ; 3:17 pop BC ; 1:10 ret ex DE, HL ; 1:4 pop DE ; 1:10 push BC ; 1:10 ret ret ; 1:10 ; Input: HL = number ; Output: print number ; Pollutes: AF, HL, BC BIN2DEC: xor A ; 1:4 A=0 => 103, A='0' => 00103 ld BC, -10000 ; 3:10 call BIN2DEC_CHAR+2 ; 3:17 ld BC, -1000 ; 3:10 call BIN2DEC_CHAR ; 3:17 ld BC, -100 ; 3:10 call BIN2DEC_CHAR ; 3:17 ld C, -10 ; 2:7 call BIN2DEC_CHAR ; 3:17 ld A, L ; 1:4 add A,'0' ; 2:7 rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A ret ; 1:10 BIN2DEC_CHAR: and 0xF0 ; 2:7 '0'..'9' => '0', unchanged 0 add HL, BC ; 1:11 inc A ; 1:4 jr c, $-2 ; 2:7/12 sbc HL, BC ; 2:15 dec A ; 1:4 ret z ; 1:5/11 or '0' ; 2:7 0 => '0', unchanged '0'..'9' rst 0x10 ; 1:11 putchar with ZX 48K ROM in, this will print char in A ret ; 1:10; Print C-style stringZ ; In: BC = addr ; Out: BC = addr zero rst 0x10 ; 1:11 print_string_z putchar with ZX 48K ROM in, this will print char in A inc BC ; 1:6 print_string_z PRINT_STRING_Z: ; print_string_z ld A,(BC) ; 1:7 print_string_z or A ; 1:4 print_string_z jp nz, $-4 ; 3:10 print_string_z ret ; 1:10 print_string_z STRING_SECTION: string117: db 0xD, "Data stack OK!", 0xD, 0x00 size117 EQU $ - string117 string116: db "RAS:", 0x00 size116 EQU $ - string116 string115: db ": a%b -> ", 0x00 size115 EQU $ - string115 string114: db " % ", 0x00 size114 EQU $ - string114 string113: db ": ln -> ", 0x00 size113 EQU $ - string113 string112: db ": exp -> ", 0x00 size112 EQU $ - string112 string101: db ": sin -> ", 0x00 size101 EQU $ - string101
; A212158: ((prime(n)- 1)/2)!, n >= 2. ; Submitted by Jamie Morken(s3) ; 1,2,6,120,720,40320,362880,39916800,87178291200,1307674368000,6402373705728000,2432902008176640000,51090942171709440000,25852016738884976640000,403291461126605635584000000,8841761993739701954543616000000 seq $0,5097 ; (Odd primes - 1)/2. seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).
org 00100000h jmp start _main proc push ebp mov ebp,esp sub esp,65 _main_t0 equ dword ptr [ebp-8] _main_t1 equ dword ptr [ebp-16] _main_t2 equ dword ptr [ebp-20] _main_t3 equ dword ptr [ebp-24] _main_t4 equ dword ptr [ebp-28] _main_t5 equ dword ptr [ebp-32] _main_t6 equ dword ptr [ebp-36] _main_t7 equ dword ptr [ebp-40] _main_t8 equ dword ptr [ebp-44] _main_t9 equ dword ptr [ebp-48] _main_t10 equ dword ptr [ebp-52] _main_t11 equ dword ptr [ebp-56] _main_t12 equ dword ptr [ebp-60] _main_t13 equ dword ptr [ebp-64] _main_t14 equ byte ptr [ebp-65] _main_i equ dword ptr [ebp-4] mov eax,0 mov _main_i,eax mov _main_t0,eax _main_c equ dword ptr [ebp-12] mov eax,2 mov _main_c,eax mov _main_t1,eax _main_1: mov al,1 cbw mov _main_t2,eax mov eax,_main_i mov ebx,_main_t2 add eax,ebx mov _main_t3,eax mov eax,_main_t3 mov _main_i,eax mov _main_t4,eax mov eax,_main_i mov _main_t5,eax inc eax mov _main_i,eax mov eax,_main_i inc eax mov _main_t6,eax mov al,1 cbw mov _main_t7,eax mov eax,_main_i mov ebx,_main_t7 sub eax,ebx mov _main_t8,eax mov eax,_main_t8 mov _main_i,eax mov _main_t9,eax mov eax,_main_i mov _main_t10,eax dec eax mov _main_i,eax mov eax,_main_i dec eax mov _main_t11,eax mov eax,_main_i neg eax mov _main_t12,eax mov eax,_main_t12 mov _main_i,eax mov _main_t13,eax mov eax,_main_i mov ebx,_main_c cmp eax,ebx jl _main_3 mov al,0 jmp short _main_4 _main_3: mov al,1 _main_4: mov _main_t14,al mov al,_main_t14 cmp al,0 je _main_2 jmp _main_1 _main_2: _main_0: mov esp,ebp pop ebp ret _main endp init proc ret init endp start: mov esp,00200000h call init call _main hlt
lda {c2},x sta {c1} lda {c2}+1,x sta {c1}+1
subttl emfmul.asm - Multiplication page ;******************************************************************************* ; Copyright (c) Microsoft Corporation 1991 ; All Rights Reserved ; ;emfmul.asm - long double multiply ; by Tim Paterson ; ;Purpose: ; Long double multiplication. ;Inputs: ; ebx:esi = op1 mantissa ; ecx = op1 sign in bit 15, exponent in high half ; edi = pointer to op2 and result location ; [Result] = edi ; ; Exponents are unbiased. Denormals have been normalized using ; this expanded exponent range. Neither operand is allowed to be zero. ;Outputs: ; Jumps to [RoundMode] to round and store result. ; ;Revision History: ; ; [] 09/05/91 TP Initial 32-bit version. ; ;******************************************************************************* ;Dispatch table for multiply ; ;One operand has been loaded into ecx:ebx:esi ("source"), the other is ;pointed to by edi ("dest"). ; ;Tag of source is shifted. Tag values are as follows: .erre TAG_SNGL eq 0 ;SINGLE: low 32 bits are zero .erre TAG_VALID eq 1 .erre TAG_ZERO eq 2 .erre TAG_SPCL eq 3 ;NAN, Infinity, Denormal, Empty ;Any special case routines not found in this file are in emarith.asm tFmulDisp label dword ;Source (reg) Dest (*[di]) dd MulSingle ;single single dd MulDouble ;single double dd XorDestSign ;single zero dd MulSpclDest ;single special dd MulDouble ;double single dd MulDouble ;double double dd XorDestSign ;double zero dd MulSpclDest ;double special dd XorSourceSign ;zero single dd XorSourceSign ;zero double dd XorDestSign ;zero zero dd MulSpclDest ;zero special dd MulSpclSource ;special single dd MulSpclSource ;special double dd MulSpclSource ;special zero dd TwoOpBothSpcl ;special special dd XorDestSign ;Two infinities EM_ENTRY eFIMUL16 eFIMUL16: push offset MulSetResult jmp Load16Int ;Returns to MulSetResult EM_ENTRY eFIMUL32 eFIMUL32: push offset MulSetResult jmp Load32Int ;Returns to MulSetResult EM_ENTRY eFMUL32 eFMUL32: push offset MulSetResult jmp Load32Real ;Returns to MulSetResult EM_ENTRY eFMUL64 eFMUL64: push offset MulSetResult jmp Load64Real ;Returns to MulSetResult EM_ENTRY eFMULPreg eFMULPreg: push offset PopWhenDone EM_ENTRY eFMULreg eFMULreg: xchg esi,edi EM_ENTRY eFMULtop eFMULtop: mov ecx,EMSEG:[esi].ExpSgn mov ebx,EMSEG:[esi].lManHi mov esi,EMSEG:[esi].lManLo MulSetResult: mov ebp,offset tFmulDisp mov EMSEG:[Result],edi ;Save result pointer mov al,cl or al,EMSEG:[edi].bTag cmp al,bTAG_VALID .erre bTAG_VALID eq 1 .erre bTAG_SNGL eq 0 jz MulDouble ja TwoOpResultSet ;.erre MulSingle eq $ ;Fall into MulSingle ;********* MulSingle: ;********* mov edx,EMSEG:[edi].ExpSgn mov eax,EMSEG:[edi].lManHi ;op1 mantissa in ebx:esi, exponent in high ecx, sign in ch bit 7 ;op2 high mantissa in eax, exponent in high edx, sign in dh bit 7 xor ch,dh ;Compute result sign xor dx,dx ;Clear out sign and tag add ecx,edx ;Result exponent .erre TexpBias eq 0 ;Exponents not biased jo SMulBigUnderflow ;Multiplying two denormals ContSmul: ;Value in ecx is correct exponent if result is not normalized. ;If result comes out normalized, 1 will be added. mul ebx ;Compute product mov ebx,edx mov esi,eax xor eax,eax ;Extend with zero ;Result in ebx:esi:eax ;ecx = exponent minus one in high half, sign in ch or ebx,ebx ;Check for normalization jns ShiftOneBit ;In emfadd.asm add ecx,1 shl 16 ;Adjust exponent jmp EMSEG:[RoundMode] SMulBigUnderflow: or EMSEG:[CURerr],Underflow add ecx,Underbias shl 16 ;Fix up exponent test EMSEG:[CWmask],Underflow ;Is exception masked? jz ContSmul ;No, continue with multiply UnderflowZero: or EMSEG:[CURerr],Precision SignedZero: and ecx,bSign shl 8 ;Preserve sign bit xor ebx,ebx mov esi,ebx mov cl,bTAG_ZERO jmp EMSEG:[ZeroVector] ;******************************************************************************* DMulBigUnderflow: ;Overflow flag set could only occur with denormals (true exp < -32768) or EMSEG:[CURerr],Underflow test EMSEG:[CWmask],Underflow ;Is exception masked? jnz UnderflowZero ;Yes, return zero add ecx,Underbias shl 16 ;Fix up exponent jmp ContDmul ;Continue with multiply PolyMulToZero: ret ;Return the zero in registers PolyMulDouble: ;This entry point is used by polynomial evaluator. ;It checks the operand in registers for zero. cmp cl,bTAG_ZERO ;Adding to zero? jz PolyMulToZero ;********* MulDouble: ;********* mov eax,EMSEG:[edi].ExpSgn mov edx,EMSEG:[edi].lManHi mov edi,EMSEG:[edi].lManLo MulDoubleReg: ;Entry point used by transcendentals ;op1 mantissa in ebx:esi, exponent in high ecx, sign in ch bit 7 ;op2 mantissa in edx:edi, exponent in high eax, sign in ah bit 7 xor ch,ah ;Compute result sign xor ax,ax ;Clear out sign and tag add ecx,eax ;Result exponent .erre TexpBias eq 0 ;Exponents not biased jo DMulBigUnderflow ;Multiplying two denormals ContDmul: ;Value in ecx is correct exponent if result is not normalized. ;If result comes out normalized, 1 will be added. mov ebp,edx ;edx is used by MUL instruction ;Generate and sum partial products, from least to most significant mov eax,edi mul esi ;Lowest partial product add eax,-1 ;CY set IFF eax<>0 sbb cl,cl ;Sticky bit: 0 if zero, -1 if nz xchg edi,edx ;Save high result ;First product: cl reflects low dword non-zero (sticky bit), edi has high dword mov eax,ebx mul edx add edi,eax adc edx,0 ;Sum first results xchg edx,esi ;High result to esi ;Second product: accumulated in esi:edi:cl mov eax,ebp ;Next mult. to eax mul edx add edi,eax ;Sum low results adc esi,edx ;Sum high results mov eax,ebx mov ebx,0 ;Preserve CY flag adc ebx,ebx ;Keep carry out of high sum ;Third product: accumulated in ebx:esi:edi:cl mul ebp add esi,eax adc ebx,edx mov eax,edi or al,cl ;Collapse sticky bits into eax ;Result in ebx:esi:eax ;ecx = exponent minus one in high half, sign in ch MulDivNorm: or ebx,ebx ;Check for normalization jns ShiftOneBit ;In emfadd.asm add ecx,1 shl 16 ;Adjust exponent jmp EMSEG:[RoundMode]
#include "implicitscaleoffset.h" namespace anl { CImplicitScaleOffset::CImplicitScaleOffset(double scale, double offset):m_source(0), m_scale(scale), m_offset(offset){} CImplicitScaleOffset::~CImplicitScaleOffset(){} void CImplicitScaleOffset::setSource(CImplicitModuleBase *b){m_source.set(b);} void CImplicitScaleOffset::setSource(double v){m_source.set(v);} void CImplicitScaleOffset::setScale(double scale) { m_scale.set(scale); } void CImplicitScaleOffset::setOffset(double offset) { m_offset.set(offset); } void CImplicitScaleOffset::setScale(CImplicitModuleBase *scale) { m_scale.set(scale); } void CImplicitScaleOffset::setOffset(CImplicitModuleBase *offset) { m_offset.set(offset); } double CImplicitScaleOffset::get(double x, double y) { return m_source.get(x,y)*m_scale.get(x,y)+m_offset.get(x,y); } double CImplicitScaleOffset::get(double x, double y, double z) { return m_source.get(x,y,z)*m_scale.get(x,y,z)+m_offset.get(x,y,z); } double CImplicitScaleOffset::get(double x, double y, double z, double w) { return m_source.get(x,y,z,w)*m_scale.get(x,y,z,w)+m_offset.get(x,y,z,w); } double CImplicitScaleOffset::get(double x, double y, double z, double w, double u, double v) { return m_source.get(x,y,z,w,u,v)*m_scale.get(x,y,z,w,u,v)+m_offset.get(x,y,z,w,u,v); } };
TITLE Test Floating-point output (asmMain.asm) ; Test the printf and scanf functions from the C library. INCLUDE Irvine32.inc TAB = 9 .code asmMain PROC C ;---------- test the printf function -------------- ; Do not pass REAL4 variables to printf using INVOKE! .data formatTwo BYTE "%.2f",TAB,"%.3f",0dh,0ah,0 val1 REAL8 456.789 val2 REAL8 864.231 .code INVOKE printf, ADDR formatTwo, val1, val2 ;--------- test the scanf function ------------- .data strSingle BYTE "%f",0 strDouble BYTE "%lf",0 float1 REAL4 1234.567 double1 REAL8 1234567.890123 .code ; Input a float, then a double: ; INVOKE scanf, ADDR strSingle, ADDR float1 ; INVOKE scanf, ADDR strDouble, ADDR double1 ; -------------------------------------------------------- ; Passing a single - precision value to printf is tricky ; because it expects the argument to be a double. ; The following code emulates code generated by Visual C++. ; It may not make much sense until you read Chapter 17. .data valStr BYTE "float1 = %.3f", 0dh, 0ah, 0 .code fld float1; load float1 onto FPU stack sub esp, 8; reserve runtime stack space fstp qword ptr[esp]; put on runtime stack as a double push OFFSET valStr call printf add esp, 12 ; ---------------------------------------------------------- ; Call our own C function for printing single - precision. ; Pass the number and the desired precision. ; INVOKE printSingle, float1, 3 ; call Crlf ret asmMain ENDP END
; ****************************************************************************************************************** ; Simple Test program , keyboard and display ; ****************************************************************************************************************** cpu sc/mp org 0x0000 nop ldi 0 xpah p1 ldi 0 loop: xae lde xpal p1 lde xri 0x7F st @1(p1) xpal p1 jp loop ldi 0x8 xpah p2 ldi 0 xpal p1 echo: ld 0(p2) jp echo ani 0x3F st @1(p1) release: ld 0(p2) ani 0x80 jnz release jmp echo wait: jmp wait
/* Created by efreyu on 17.05.2020. */ #include <gtest/gtest.h> #include "rapidjson/document.h" int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } TEST(TestJsonDeps, IncludeJsonTest) { const char json[] = " { \"test\" : \"row\", \"t\" : true , \"f\" : false } "; rapidjson::Document document; document.Parse(json); ASSERT_TRUE(document.IsObject()); ASSERT_FALSE(document.HasMember("false")); ASSERT_TRUE(document.HasMember("test")); ASSERT_TRUE(document.HasMember("t")); ASSERT_TRUE(document.HasMember("f")); ASSERT_TRUE(document["test"].IsString()); EXPECT_EQ(document["test"], "row"); }
; A234319: Smallest sum of n-th powers of k+1 consecutive positive integers that equals the sum of n-th powers of the next k consecutive integers, or -n if none. ; 0,3,25,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-34,-35,-36,-37,-38,-39,-40,-41,-42,-43,-44,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54 mov $4,$0 sub $0,3 trn $1,$0 div $1,-5 sub $1,$0 mov $2,3 mov $3,$4 sub $3,3 add $2,$3 mov $5,-5 lpb $0,1 add $2,$0 add $2,1 add $0,$2 sub $0,1 div $0,2 mov $5,$2 mul $2,2 add $5,1 add $2,$5 mov $1,$2 sub $5,$2 mov $2,$0 pow $5,2 lpe add $1,$5 add $1,2
; char __CALLEE__ *strcmp_callee(char *s1, char *s2) ; compare strings s1 and s2 ; ; Apr 25 1999 djm - Previously would return non ; zero if the two strings matched (it ignored ; the \0 at the end!) ; ; Jan 12 2002 Graham R. Cobb - Rewritten, ; previously strcmp("A","AB") would return 0. ; ; Mar 24 2002 Graham R. Cobb - Fix to above. ; Make sure positive return really is > 0 (not = 0) ; ; Jun 09 2002 Benjamin Green - Use CPI and ; rearrange loop slightly ; ; Dec 30 2006 aralbrec - Stop using cpi as that ; is slower than cp (hl) + inc hl combination! PUBLIC strcmp_callee PUBLIC strcmp1 .strcmp_callee pop hl pop de ex (sp),hl ; enter : hl = char *s1 ; de = char *s2 ; exit : if s1==s2 : hl = 0, Z flag set ; if s1<<s2 : hl < 0, NC+NZ flag set ; if s1>>s2 : hl > 0, C+NZ flag set ; uses : af, de, hl .asmentry .strcmp1 ld a,(de) cp (hl) ; compare with s1 jr nz,strcmp2 inc de inc hl and a ; check for end of strings jp nz, strcmp1 ld l,a ; both strings ended simultaneously ld h,a ; it's a match! ret .strcmp2 ; strings are different ld h,$80 ret nc dec h ret
db "FAIRY@" ; species name dw 200, 170 ; height, weight db "Though rarely" next "seen, it becomes" next "easier to spot," page "for some reason," next "on the night of a " next "full moon.@"
.data 0x0000 # 数据定义的首地址 buf: .word 0x00000055, 0x000000AA # 定义数据 .text 0x0000 # 代码段定义开始 start:ori $at,$zero,1 #寄存器初始化 ori $v0,$zero,2 ori $v1,$zero,3 ori $a0,$zero,4 ori $a1,$zero,5 ori $a2,$zero,6 ori $a3,$zero,7 ori $t0,$zero,8 ori $t1,$zero,9 ori $t2,$zero,10 ori $t3,$zero,11 ori $t4,$zero,12 ori $t5,$zero,13 ori $t6,$zero,14 ori $t7,$zero,15 ori $s0,$zero,16 ori $s1,$zero,17 ori $s2,$zero,18 ori $s3,$zero,19 ori $s4,$zero,20 ori $s5,$zero,21 ori $s6,$zero,22 ori $s7,$zero,23 ori $t8,$zero,24 ori $t9,$zero,25 ori $i0,$zero,26 ori $i1,$zero,27 ori $s9,$zero,28 ori $sp,$zero,29 ori $s8,$zero,30 ori $ra,$zero,31 lw $v0,buf($zero) #ori $v0,$zero,0x55 ori $a0,$zero,4 ori $a1,$zero,5 lw $v1,buf($a0) # buf+4 add $at,$v0,$v1 sw $at,8($zero) subu $a0,$v1,$v0 slt $a0,$v0,$at and $at,$v1,$a3 or $a2,$v0,$at xor $a3,$v0,$v1 nor $a2,$a1,$at lop: beq $v1,$v0,lop lop1: sub $v0,$v0,$a1 bne $a1,$v0,lop1 beq $at,$at,lop2 lop2: jal subp j next subp: jr $ra next: addi $v0,$zero,0x99 ori $v1,$zero,0x77 sll $v1,$v0,4 srl $v1,$v0,4 srlv $v1,$v0,$at lui $a2,0x9988 sra $a3,$a2,4 addi $v0,$zero,0 addi $v1,$zero,2 sub $at,$v0,$v1 j start
/* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "scrypt_test" #include <UniquePtr.h> #include <utils/Log.h> #include <gtest/gtest.h> #include <fstream> #include <iostream> extern "C" { #include <crypto_scrypt.h> } namespace android { typedef struct scrypt_test_setting_t { const char *pw, *salt; uint32_t Nfactor, rfactor, pfactor; } scrypt_test_setting; static const scrypt_test_setting post_settings[] = { {"", "", 16, 1, 1}, {"password", "NaCl", 1024, 8, 16}, {"pleaseletmein", "SodiumChloride", 16384, 8, 1}, {0, 0, 0, 0, 0} }; static const uint8_t post_vectors[][64] = { {0x77,0xd6,0x57,0x62,0x38,0x65,0x7b,0x20,0x3b,0x19,0xca,0x42,0xc1,0x8a,0x04,0x97, 0xf1,0x6b,0x48,0x44,0xe3,0x07,0x4a,0xe8,0xdf,0xdf,0xfa,0x3f,0xed,0xe2,0x14,0x42, 0xfc,0xd0,0x06,0x9d,0xed,0x09,0x48,0xf8,0x32,0x6a,0x75,0x3a,0x0f,0xc8,0x1f,0x17, 0xe8,0xd3,0xe0,0xfb,0x2e,0x0d,0x36,0x28,0xcf,0x35,0xe2,0x0c,0x38,0xd1,0x89,0x06}, {0xfd,0xba,0xbe,0x1c,0x9d,0x34,0x72,0x00,0x78,0x56,0xe7,0x19,0x0d,0x01,0xe9,0xfe, 0x7c,0x6a,0xd7,0xcb,0xc8,0x23,0x78,0x30,0xe7,0x73,0x76,0x63,0x4b,0x37,0x31,0x62, 0x2e,0xaf,0x30,0xd9,0x2e,0x22,0xa3,0x88,0x6f,0xf1,0x09,0x27,0x9d,0x98,0x30,0xda, 0xc7,0x27,0xaf,0xb9,0x4a,0x83,0xee,0x6d,0x83,0x60,0xcb,0xdf,0xa2,0xcc,0x06,0x40}, {0x70,0x23,0xbd,0xcb,0x3a,0xfd,0x73,0x48,0x46,0x1c,0x06,0xcd,0x81,0xfd,0x38,0xeb, 0xfd,0xa8,0xfb,0xba,0x90,0x4f,0x8e,0x3e,0xa9,0xb5,0x43,0xf6,0x54,0x5d,0xa1,0xf2, 0xd5,0x43,0x29,0x55,0x61,0x3f,0x0f,0xcf,0x62,0xd4,0x97,0x05,0x24,0x2a,0x9a,0xf9, 0xe6,0x1e,0x85,0xdc,0x0d,0x65,0x1e,0x40,0xdf,0xcf,0x01,0x7b,0x45,0x57,0x58,0x87}, }; class ScryptTest : public ::testing::Test { }; TEST_F(ScryptTest, TestVectors) { int i; for (i = 0; post_settings[i].pw != NULL; i++) { uint8_t output[64]; scrypt_test_setting_t s = post_settings[i]; ASSERT_EQ(0, crypto_scrypt((const uint8_t*) s.pw, strlen(s.pw), (const uint8_t*) s.salt, strlen(s.salt), s.Nfactor, s.rfactor, s.pfactor, output, sizeof(output))) << "scrypt call should succeed for " << i << "; error=" << strerror(errno); ASSERT_EQ(0, memcmp(post_vectors[i], output, sizeof(output))) << "Should match expected output"; } } }
; A104531: Expansion of (1+sqrt(1-4*x))/(5*sqrt(1-4*x)-3). ; Submitted by Christian Krause ; 1,4,24,148,920,5736,35808,223668,1397496,8732920,54575888,341082504,2131706864,13322959888,83267756400,520420803060,3252620324280,20328841669080,127055130786960,794094089779800,4963086293860560,31019282772508080,193870492861908480,1211690488904364360,7573065212592663600,47331656288800000176,295822846943053599648,1848892775026731925648,11555579774383523619296,72222373326149070870240,451389832286189476287632,2821186447973697724705396,17632415285290974740181816,110202595477534527249088152 mov $2,4 mov $3,$0 mul $3,2 mov $4,1 mov $5,5 lpb $3 mul $2,$3 div $2,$4 sub $3,1 add $4,1 trn $5,$2 mul $2,2 div $5,2 add $5,$2 lpe mov $0,$5 div $0,5
; A090300: a(n) = 14*a(n-1) + a(n-2), starting with a(0) = 2 and a(1) = 14. ; Submitted by Jon Maiga ; 2,14,198,2786,39202,551614,7761798,109216786,1536796802,21624372014,304278004998,4281516441986,60245508192802,847718631141214,11928306344169798,167844007449518386,2361744410637427202,33232265756373499214,467613464999866416198,6579820775754503325986,92585104325562912980002,1302771281333635285046014,18331383042996456903624198,257942133883284031935784786,3629521257408972904004611202,51071239737608904688000341614,718626877583933638536009393798,10111847525912679844192131854786 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 mul $2,7 add $3,$2 lpe mov $0,$3 mul $0,2