text
stringlengths
1
1.05M
; A170110: Number of reduced words of length n in Coxeter group on 5 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I. ; 1,5,20,80,320,1280,5120,20480,81920,327680,1310720,5242880,20971520,83886080,335544320,1342177280,5368709120,21474836480,85899345920,343597383680,1374389534720,5497558138880,21990232555520,87960930222080 mov $1,4 pow $1,$0 mul $1,5 div $1,4
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #include "ProjectTargetPlatformEditorPrivatePCH.h" #include "IProjectManager.h" #define LOCTEXT_NAMESPACE "SProjectTargetPlatformSettings" BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION void SProjectTargetPlatformSettings::Construct(const FArguments& InArgs) { // Create and sort a list of vanilla platforms that are game targets (sort by display name) // We show all of the platforms regardless of whether we have an SDK installed for them or not for(const PlatformInfo::FPlatformInfo& PlatformInfo : PlatformInfo::EnumeratePlatformInfoArray()) { if(PlatformInfo.IsVanilla() && PlatformInfo.PlatformType == PlatformInfo::EPlatformType::Game) { // @todo AllDesktop: Re-enable here if (PlatformInfo.PlatformInfoName != TEXT("AllDesktop")) { AvailablePlatforms.Add(&PlatformInfo); } } } AvailablePlatforms.Sort([](const PlatformInfo::FPlatformInfo& One, const PlatformInfo::FPlatformInfo& Two) -> bool { return One.DisplayName.CompareTo(Two.DisplayName) < 0; }); // Generate a widget for each platform TSharedRef<SVerticalBox> PlatformsListBox = SNew(SVerticalBox); for(const PlatformInfo::FPlatformInfo* AvailablePlatform : AvailablePlatforms) { PlatformsListBox->AddSlot() .AutoHeight() [ MakePlatformRow(AvailablePlatform->DisplayName, AvailablePlatform->PlatformInfoName, FEditorStyle::GetBrush(AvailablePlatform->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal))) ]; } ChildSlot [ SNew(SVerticalBox) +SVerticalBox::Slot() .AutoHeight() [ SNew(SBorder) .BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) .Padding(5.0f) [ SNew(SVerticalBox) +SVerticalBox::Slot() .AutoHeight() [ MakePlatformRow(LOCTEXT("AllPlatforms", "All Platforms"), NAME_None, FEditorStyle::GetBrush("Launcher.Platform.AllPlatforms")) ] +SVerticalBox::Slot() .AutoHeight() .Padding(FMargin(0.0f, 1.0f)) [ SNew(SSeparator) ] +SVerticalBox::Slot() .AutoHeight() [ PlatformsListBox ] ] ] +SVerticalBox::Slot() .AutoHeight() .Padding(FMargin(0.0f, 5.0f)) [ SNew(SBorder) .BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) .Padding(5.0f) [ SNew(STextBlock) .AutoWrapText(true) .Text(LOCTEXT("PlatformsListDescription", "Select the supported platforms for your project. Attempting to package, run, or cook your project on an unsupported platform will result in a warning.")) ] ] ]; } END_SLATE_FUNCTION_BUILD_OPTIMIZATION TSharedRef<SWidget> SProjectTargetPlatformSettings::MakePlatformRow(const FText& DisplayName, const FName PlatformName, const FSlateBrush* Icon) const { return SNew(SHorizontalBox) +SHorizontalBox::Slot() .AutoWidth() .Padding(FMargin(5.0f, 0.0f)) [ SNew(SCheckBox) .IsChecked(this, &SProjectTargetPlatformSettings::HandlePlatformCheckBoxIsChecked, PlatformName) .IsEnabled(this, &SProjectTargetPlatformSettings::HandlePlatformCheckBoxIsEnabled, PlatformName) .OnCheckStateChanged(this, &SProjectTargetPlatformSettings::HandlePlatformCheckBoxStateChanged, PlatformName) ] +SHorizontalBox::Slot() .AutoWidth() .Padding(FMargin(5.0f, 2.0f)) .HAlign(HAlign_Center) .VAlign(VAlign_Center) [ SNew(SBox) .WidthOverride(20) .HeightOverride(20) [ SNew(SImage) .Image(Icon) ] ] +SHorizontalBox::Slot() .AutoWidth() .Padding(FMargin(5.0f, 0.0f)) .VAlign(VAlign_Center) [ SNew(STextBlock) .Text(DisplayName) ]; } ECheckBoxState SProjectTargetPlatformSettings::HandlePlatformCheckBoxIsChecked(const FName PlatformName) const { FProjectStatus ProjectStatus; if(IProjectManager::Get().QueryStatusForCurrentProject(ProjectStatus)) { if(PlatformName.IsNone()) { // None is "All Platforms" return (ProjectStatus.SupportsAllPlatforms()) ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; } else { return (ProjectStatus.IsTargetPlatformSupported(PlatformName)) ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; } } return ECheckBoxState::Unchecked; } bool SProjectTargetPlatformSettings::HandlePlatformCheckBoxIsEnabled(const FName PlatformName) const { FProjectStatus ProjectStatus; if(IProjectManager::Get().QueryStatusForCurrentProject(ProjectStatus)) { if(PlatformName.IsNone()) { // None is "All Platforms" return true; } else { // Individual platforms are only enabled when we're not supporting "All Platforms" return !ProjectStatus.SupportsAllPlatforms(); } } return false; } void SProjectTargetPlatformSettings::HandlePlatformCheckBoxStateChanged(ECheckBoxState InState, const FName PlatformName) const { if(PlatformName.IsNone()) { // None is "All Platforms" if(InState == ECheckBoxState::Checked) { FGameProjectGenerationModule::Get().ClearSupportedTargetPlatforms(); } else { // We've deselected "All Platforms", so manually select every available platform for(const PlatformInfo::FPlatformInfo* AvailablePlatform : AvailablePlatforms) { FGameProjectGenerationModule::Get().UpdateSupportedTargetPlatforms(AvailablePlatform->TargetPlatformName, true); } } } else { FGameProjectGenerationModule::Get().UpdateSupportedTargetPlatforms(PlatformName, InState == ECheckBoxState::Checked); } } #undef LOCTEXT_NAMESPACE
; A142567: Primes congruent to 37 mod 53. ; Submitted by Jon Maiga ; 37,461,673,991,1097,1627,1733,2687,3217,3323,3853,5231,5443,5867,6079,6397,7351,7457,7669,8093,8623,8941,10531,11273,11909,12227,12757,13499,13711,14029,14347,14771,14983,15619,15937,16361,16573,17209,18269,18481,18587,19541,19753,20071,20177,20389,20707,21661,21767,22721,23039,23251,23357,23887,23993,24841,25583,26113,26431,27067,27809,28657,29399,29611,29717,30671,31307,32261,32579,33427,33533,33851,34381,34487,35759,36607,36713,37243,37561,37879,38197,38303,38833,40423,40529,40847,41801 mov $1,18 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $2,2 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,53 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 mul $0,2 sub $0,105
#include "Controllino.h" #include <iostream> #include <string> #include "serial.h" #include "Util.h" #include "Log.h" #include "modbus.h" Controllino::Controllino() noexcept : DeviceBase("Controllino") { } Controllino::~Controllino() { } bool ParseIO(const std::string &str, Controllino::AreaName &port, uint32_t &io) { bool success = false; // IO examples: A3, IN0, if ((str.size() == 2) || (str.size() == 3)) { uint32_t begin_at = 1U; if ((str[0] == 'I') && (str[1] == 'N')) { begin_at = 2; success = true; port = Controllino::PORT_IN; } else if (str[0] == 'A') { success = true; port = Controllino::PORT_A; } else if (str[0] == 'D') { success = true; port = Controllino::PORT_D; } else if (str[0] == 'R') { success = true; port = Controllino::PORT_R; } if (success) { std::string io_num = str.substr(begin_at); io = Util::FromString<std::uint32_t>(io_num); } } return success; } bool Controllino::Execute(const std::vector<Value> &args, Value &ret) { (void) ret; if (args.size() > 0) { // First argument is the command if (args[0].GetType() == Value::STRING) { std::string cmd = args[0].GetString(); if ((cmd == std::string("INIT")) && (args.size() >= 2)) { Initialize(); } else if (cmd == std::string("SET_DIGITAL")) { if (args.size() >= 2) { ret = RequestIO(SET_DIGITAL, args[1].GetString()); } else { SetError("IO write need extra argument with an IO name, eg: 3A, IN0..."); } } else if (cmd == std::string("CLEAR_DIGITAL")) { if (args.size() >= 2) { ret = RequestIO(CLEAR_DIGITAL, args[1].GetString()); } else { SetError("IO read need extra argument with an IO name, eg: 3A, IN0..."); } } else if (cmd == std::string("GET_DIGITAL")) { if (args.size() >= 2) { ret = RequestIO(GET_DIGITAL, args[1].GetString()); } else { SetError("IO read need extra argument with an IO name, eg: 3A, IN0..."); } } else if (cmd == std::string("GET_ANALOG")) { if (args.size() >= 2) { ret = RequestIO(GET_ANALOG, args[1].GetString()); } else { SetError("IO read need extra argument with an IO name, eg: 3A, IN0..."); } } else if (cmd == std::string("READ_FIRMWARE")) { ret = ReadRequest(66, 2); } else if (cmd == std::string("WRITE_COMMAND")) { if (args.size() >= 2) { std::uint16_t cmd = static_cast<uint16_t>(args[1].GetInteger()); uint8_t cmdBuff[2]; cmdBuff[0] = (cmd >> 8) & 0xFFU; cmdBuff[1] = cmd & 0xFFU; ret = WriteRequest(68, &cmdBuff[0], 1); } else { SetError("Commands need extra integer argument with the order."); } } else if (cmd == std::string("READ_COMMAND")) { ret = ReadRequest(68, 1); } } } return !HasError(); } void Controllino::AutoTest() { (void) ReadRequest(66, 2); } struct RegisterSet { Controllino::AreaName port; uint16_t start_addr; uint16_t size; uint8_t access; }; static const std::vector<RegisterSet> gMapping { { Controllino::PORT_D, 0U, 12, Controllino::SET_DIGITAL | Controllino::CLEAR_DIGITAL }, { Controllino::PORT_D, 12U, 12, Controllino::GET_DIGITAL }, { Controllino::PORT_R, 24U, 10, Controllino::SET_DIGITAL | Controllino::CLEAR_DIGITAL }, { Controllino::PORT_R, 34U, 10, Controllino::GET_DIGITAL }, { Controllino::PORT_A, 44U, 10, Controllino::GET_ANALOG }, { Controllino::PORT_IN, 54U, 2, Controllino::GET_DIGITAL }, { Controllino::PORT_A, 56U, 10, Controllino::GET_DIGITAL } }; bool Controllino::IsAllowed(RequestType req, Controllino::AreaName port, std::uint32_t io_num, uint16_t &read_addr) { bool success = false; for (auto const &reg : gMapping) { if ((reg.port == port) && ((reg.access & req) == req)) { if (io_num < reg.size) { read_addr = static_cast<uint16_t>(reg.start_addr + io_num); success = true; } } } return success; } Value Controllino::RequestIO(RequestType req, const std::string &io) { Controllino::AreaName port; std::uint32_t io_num = 0U; Value retValue; if (ParseIO(io, port, io_num)) { uint16_t address = 0U; if (IsAllowed(req, port, io_num, address)) { if ((req == SET_DIGITAL) || (req == CLEAR_DIGITAL)) { uint16_t bool_val = 0U; if (req == SET_DIGITAL) { bool_val = 1U; } uint8_t cmdBuff[2]; cmdBuff[0] = (bool_val >> 8) & 0xFFU; cmdBuff[1] = bool_val & 0xFFU; retValue = WriteRequest(address, &cmdBuff[0], 1); } else { retValue = ReadRequest(address, 1); } } else { SetError("Forbidden access to this register (read/write access)"); } } else { SetError("Cannot parse IO name: " + io); } return retValue; } Value Controllino::ReadRequest(uint16_t start_addr, std::uint16_t size) { Value retValue; IProcessEngine *engine = GetProcessEngine(); if (engine != nullptr) { IModbusMaster *modbus = engine->GetModbusChannel(GetConnectionChannel()); if (modbus != nullptr) { int32_t req_size = modbus->BuildFunc3Packet(MODBUS_RTU, mSlaveAddress, start_addr, size); if (req_size > 0) { if (modbus->ModbusRequest(static_cast<std::uint32_t>(req_size), mSlaveAddress, 4)) { if (size == 1) { uint16_t value = modbus->GetUint16Be(0); retValue = Value(static_cast<std::int32_t>(value)); } else { uint32_t readValue = modbus->GetUint32Be(0); retValue = Value(static_cast<std::int32_t>(readValue)); } } else { SetError(modbus->GetModbusError()); } } else { SetError("Modbus request error: " + std::to_string(req_size)); } } else { SetError("Cannot find modbus channel ID: " + GetConnectionChannel()); } } else { SetError("Cannot communicate with process engine"); } return retValue; } Value Controllino::WriteRequest(std::uint16_t start_addr, uint8_t *data, std::uint16_t size) { Value retValue; IProcessEngine *engine = GetProcessEngine(); if (engine != nullptr) { IModbusMaster *modbus = engine->GetModbusChannel(GetConnectionChannel()); if (modbus != nullptr) { int32_t req_size = modbus->BuildFunc16Packet(MODBUS_RTU, data, mSlaveAddress, start_addr, size); if (req_size > 0) { if (modbus->ModbusRequest(static_cast<std::uint32_t>(req_size), mSlaveAddress, 4)) { uint16_t value = modbus->GetUint16Be(0); retValue = Value(static_cast<std::int32_t>(value)); } else { SetError(modbus->GetModbusError()); } } else { SetError("Modbus request error: " + std::to_string(req_size)); } } else { SetError("Cannot find modbus channel ID: " + GetConnectionChannel()); } } else { SetError("Cannot communicate with process engine"); } return retValue; } void Controllino::Initialize() { uint32_t addr = Util::FromString<uint32_t>(GetDeviceOptions()); mSlaveAddress = static_cast<uint8_t>(addr); } void Controllino::Stop() { }
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <valarray> // template<class T> class valarray; // template<class T> valarray<T> operator/(const valarray<T>& x, const T& y); #include <valarray> #include <cassert> int main() { { typedef int T; T a1[] = {6, 12, 18, 24, 30}; T a2[] = {1, 2, 3, 4, 5}; const unsigned N = sizeof(a1)/sizeof(a1[0]); std::valarray<T> v1(a1, N); std::valarray<T> v2 = v1 / 6; assert(v1.size() == v2.size()); for (int i = 0; i < v2.size(); ++i) assert(v2[i] == a2[i]); } }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SELECT CRT0 FROM -STARTUP=N COMMANDLINE OPTION ;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INCLUDE "zcc_opt.def" IFNDEF startup ; startup undefined so select a default defc startup = 0 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; user supplied crt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF startup = -1 INCLUDE "crt.asm" ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cp/m native console ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF startup = 0 IFNDEF __CRTDEF defc __CRTDEF = 0 ENDIF IFNDEF __MMAP defc __MMAP = 0 ENDIF ; stdin = cpm_00_input_cons (bdos function 10) ; stdout = cpm_00_output_cons (bdos function 2) ; stderr = dup(stdout) ; stdrdr = cpm_00_input_reader (bdos function 3) ; stdpun = cpm_00_output_punch (bdos function 4) ; stdlst = cpm_00_output_list (bdos function 5) INCLUDE "startup/cpm_crt_0.asm" ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cp/m z88dk console (one window) ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF startup = 4 IFNDEF __CRTDEF defc __CRTDEF = 0 ENDIF IFNDEF __MMAP defc __MMAP = 0 ENDIF ; stdin = cpm_01_input_kbd_dcio (bdos function 6) ; stdout = cpm_01_output_dcio (bdos function 6) ; stderr = dup(stdout) ; stdrdr = cpm_00_input_reader (bdos function 3) ; stdpun = cpm_00_output_punch (bdos function 4) ; stdlst = cpm_00_output_list (bdos function 5) INCLUDE "startup/cpm_crt_4.asm" ENDIF
# handler section .text vector0: push 0 push 0 jmp __alltraps vector1: push 0 push 1 jmp __alltraps vector2: push 0 push 2 jmp __alltraps vector3: push 0 push 3 jmp __alltraps vector4: push 0 push 4 jmp __alltraps vector5: push 0 push 5 jmp __alltraps vector6: push 0 push 6 jmp __alltraps vector7: push 0 push 7 jmp __alltraps vector8: push 8 jmp __alltraps vector9: push 9 jmp __alltraps vector10: push 10 jmp __alltraps vector11: push 11 jmp __alltraps vector12: push 12 jmp __alltraps vector13: push 13 jmp __alltraps vector14: push 14 jmp __alltraps vector15: push 0 push 15 jmp __alltraps vector16: push 0 push 16 jmp __alltraps vector17: push 17 jmp __alltraps vector18: push 0 push 18 jmp __alltraps vector19: push 0 push 19 jmp __alltraps vector20: push 0 push 20 jmp __alltraps vector21: push 0 push 21 jmp __alltraps vector22: push 0 push 22 jmp __alltraps vector23: push 0 push 23 jmp __alltraps vector24: push 0 push 24 jmp __alltraps vector25: push 0 push 25 jmp __alltraps vector26: push 0 push 26 jmp __alltraps vector27: push 0 push 27 jmp __alltraps vector28: push 0 push 28 jmp __alltraps vector29: push 0 push 29 jmp __alltraps vector30: push 0 push 30 jmp __alltraps vector31: push 0 push 31 jmp __alltraps vector32: push 0 push 32 jmp __alltraps vector33: push 0 push 33 jmp __alltraps vector34: push 0 push 34 jmp __alltraps vector35: push 0 push 35 jmp __alltraps vector36: push 0 push 36 jmp __alltraps vector37: push 0 push 37 jmp __alltraps vector38: push 0 push 38 jmp __alltraps vector39: push 0 push 39 jmp __alltraps vector40: push 0 push 40 jmp __alltraps vector41: push 0 push 41 jmp __alltraps vector42: push 0 push 42 jmp __alltraps vector43: push 0 push 43 jmp __alltraps vector44: push 0 push 44 jmp __alltraps vector45: push 0 push 45 jmp __alltraps vector46: push 0 push 46 jmp __alltraps vector47: push 0 push 47 jmp __alltraps vector48: push 0 push 48 jmp __alltraps vector49: push 0 push 49 jmp __alltraps vector50: push 0 push 50 jmp __alltraps vector51: push 0 push 51 jmp __alltraps vector52: push 0 push 52 jmp __alltraps vector53: push 0 push 53 jmp __alltraps vector54: push 0 push 54 jmp __alltraps vector55: push 0 push 55 jmp __alltraps vector56: push 0 push 56 jmp __alltraps vector57: push 0 push 57 jmp __alltraps vector58: push 0 push 58 jmp __alltraps vector59: push 0 push 59 jmp __alltraps vector60: push 0 push 60 jmp __alltraps vector61: push 0 push 61 jmp __alltraps vector62: push 0 push 62 jmp __alltraps vector63: push 0 push 63 jmp __alltraps vector64: push 0 push 64 jmp __alltraps vector65: push 0 push 65 jmp __alltraps vector66: push 0 push 66 jmp __alltraps vector67: push 0 push 67 jmp __alltraps vector68: push 0 push 68 jmp __alltraps vector69: push 0 push 69 jmp __alltraps vector70: push 0 push 70 jmp __alltraps vector71: push 0 push 71 jmp __alltraps vector72: push 0 push 72 jmp __alltraps vector73: push 0 push 73 jmp __alltraps vector74: push 0 push 74 jmp __alltraps vector75: push 0 push 75 jmp __alltraps vector76: push 0 push 76 jmp __alltraps vector77: push 0 push 77 jmp __alltraps vector78: push 0 push 78 jmp __alltraps vector79: push 0 push 79 jmp __alltraps vector80: push 0 push 80 jmp __alltraps vector81: push 0 push 81 jmp __alltraps vector82: push 0 push 82 jmp __alltraps vector83: push 0 push 83 jmp __alltraps vector84: push 0 push 84 jmp __alltraps vector85: push 0 push 85 jmp __alltraps vector86: push 0 push 86 jmp __alltraps vector87: push 0 push 87 jmp __alltraps vector88: push 0 push 88 jmp __alltraps vector89: push 0 push 89 jmp __alltraps vector90: push 0 push 90 jmp __alltraps vector91: push 0 push 91 jmp __alltraps vector92: push 0 push 92 jmp __alltraps vector93: push 0 push 93 jmp __alltraps vector94: push 0 push 94 jmp __alltraps vector95: push 0 push 95 jmp __alltraps vector96: push 0 push 96 jmp __alltraps vector97: push 0 push 97 jmp __alltraps vector98: push 0 push 98 jmp __alltraps vector99: push 0 push 99 jmp __alltraps vector100: push 0 push 100 jmp __alltraps vector101: push 0 push 101 jmp __alltraps vector102: push 0 push 102 jmp __alltraps vector103: push 0 push 103 jmp __alltraps vector104: push 0 push 104 jmp __alltraps vector105: push 0 push 105 jmp __alltraps vector106: push 0 push 106 jmp __alltraps vector107: push 0 push 107 jmp __alltraps vector108: push 0 push 108 jmp __alltraps vector109: push 0 push 109 jmp __alltraps vector110: push 0 push 110 jmp __alltraps vector111: push 0 push 111 jmp __alltraps vector112: push 0 push 112 jmp __alltraps vector113: push 0 push 113 jmp __alltraps vector114: push 0 push 114 jmp __alltraps vector115: push 0 push 115 jmp __alltraps vector116: push 0 push 116 jmp __alltraps vector117: push 0 push 117 jmp __alltraps vector118: push 0 push 118 jmp __alltraps vector119: push 0 push 119 jmp __alltraps vector120: push 0 push 120 jmp __alltraps vector121: push 0 push 121 jmp __alltraps vector122: push 0 push 122 jmp __alltraps vector123: push 0 push 123 jmp __alltraps vector124: push 0 push 124 jmp __alltraps vector125: push 0 push 125 jmp __alltraps vector126: push 0 push 126 jmp __alltraps vector127: push 0 push 127 jmp __alltraps vector128: push 0 push 128 jmp __alltraps vector129: push 0 push 129 jmp __alltraps vector130: push 0 push 130 jmp __alltraps vector131: push 0 push 131 jmp __alltraps vector132: push 0 push 132 jmp __alltraps vector133: push 0 push 133 jmp __alltraps vector134: push 0 push 134 jmp __alltraps vector135: push 0 push 135 jmp __alltraps vector136: push 0 push 136 jmp __alltraps vector137: push 0 push 137 jmp __alltraps vector138: push 0 push 138 jmp __alltraps vector139: push 0 push 139 jmp __alltraps vector140: push 0 push 140 jmp __alltraps vector141: push 0 push 141 jmp __alltraps vector142: push 0 push 142 jmp __alltraps vector143: push 0 push 143 jmp __alltraps vector144: push 0 push 144 jmp __alltraps vector145: push 0 push 145 jmp __alltraps vector146: push 0 push 146 jmp __alltraps vector147: push 0 push 147 jmp __alltraps vector148: push 0 push 148 jmp __alltraps vector149: push 0 push 149 jmp __alltraps vector150: push 0 push 150 jmp __alltraps vector151: push 0 push 151 jmp __alltraps vector152: push 0 push 152 jmp __alltraps vector153: push 0 push 153 jmp __alltraps vector154: push 0 push 154 jmp __alltraps vector155: push 0 push 155 jmp __alltraps vector156: push 0 push 156 jmp __alltraps vector157: push 0 push 157 jmp __alltraps vector158: push 0 push 158 jmp __alltraps vector159: push 0 push 159 jmp __alltraps vector160: push 0 push 160 jmp __alltraps vector161: push 0 push 161 jmp __alltraps vector162: push 0 push 162 jmp __alltraps vector163: push 0 push 163 jmp __alltraps vector164: push 0 push 164 jmp __alltraps vector165: push 0 push 165 jmp __alltraps vector166: push 0 push 166 jmp __alltraps vector167: push 0 push 167 jmp __alltraps vector168: push 0 push 168 jmp __alltraps vector169: push 0 push 169 jmp __alltraps vector170: push 0 push 170 jmp __alltraps vector171: push 0 push 171 jmp __alltraps vector172: push 0 push 172 jmp __alltraps vector173: push 0 push 173 jmp __alltraps vector174: push 0 push 174 jmp __alltraps vector175: push 0 push 175 jmp __alltraps vector176: push 0 push 176 jmp __alltraps vector177: push 0 push 177 jmp __alltraps vector178: push 0 push 178 jmp __alltraps vector179: push 0 push 179 jmp __alltraps vector180: push 0 push 180 jmp __alltraps vector181: push 0 push 181 jmp __alltraps vector182: push 0 push 182 jmp __alltraps vector183: push 0 push 183 jmp __alltraps vector184: push 0 push 184 jmp __alltraps vector185: push 0 push 185 jmp __alltraps vector186: push 0 push 186 jmp __alltraps vector187: push 0 push 187 jmp __alltraps vector188: push 0 push 188 jmp __alltraps vector189: push 0 push 189 jmp __alltraps vector190: push 0 push 190 jmp __alltraps vector191: push 0 push 191 jmp __alltraps vector192: push 0 push 192 jmp __alltraps vector193: push 0 push 193 jmp __alltraps vector194: push 0 push 194 jmp __alltraps vector195: push 0 push 195 jmp __alltraps vector196: push 0 push 196 jmp __alltraps vector197: push 0 push 197 jmp __alltraps vector198: push 0 push 198 jmp __alltraps vector199: push 0 push 199 jmp __alltraps vector200: push 0 push 200 jmp __alltraps vector201: push 0 push 201 jmp __alltraps vector202: push 0 push 202 jmp __alltraps vector203: push 0 push 203 jmp __alltraps vector204: push 0 push 204 jmp __alltraps vector205: push 0 push 205 jmp __alltraps vector206: push 0 push 206 jmp __alltraps vector207: push 0 push 207 jmp __alltraps vector208: push 0 push 208 jmp __alltraps vector209: push 0 push 209 jmp __alltraps vector210: push 0 push 210 jmp __alltraps vector211: push 0 push 211 jmp __alltraps vector212: push 0 push 212 jmp __alltraps vector213: push 0 push 213 jmp __alltraps vector214: push 0 push 214 jmp __alltraps vector215: push 0 push 215 jmp __alltraps vector216: push 0 push 216 jmp __alltraps vector217: push 0 push 217 jmp __alltraps vector218: push 0 push 218 jmp __alltraps vector219: push 0 push 219 jmp __alltraps vector220: push 0 push 220 jmp __alltraps vector221: push 0 push 221 jmp __alltraps vector222: push 0 push 222 jmp __alltraps vector223: push 0 push 223 jmp __alltraps vector224: push 0 push 224 jmp __alltraps vector225: push 0 push 225 jmp __alltraps vector226: push 0 push 226 jmp __alltraps vector227: push 0 push 227 jmp __alltraps vector228: push 0 push 228 jmp __alltraps vector229: push 0 push 229 jmp __alltraps vector230: push 0 push 230 jmp __alltraps vector231: push 0 push 231 jmp __alltraps vector232: push 0 push 232 jmp __alltraps vector233: push 0 push 233 jmp __alltraps vector234: push 0 push 234 jmp __alltraps vector235: push 0 push 235 jmp __alltraps vector236: push 0 push 236 jmp __alltraps vector237: push 0 push 237 jmp __alltraps vector238: push 0 push 238 jmp __alltraps vector239: push 0 push 239 jmp __alltraps vector240: push 0 push 240 jmp __alltraps vector241: push 0 push 241 jmp __alltraps vector242: push 0 push 242 jmp __alltraps vector243: push 0 push 243 jmp __alltraps vector244: push 0 push 244 jmp __alltraps vector245: push 0 push 245 jmp __alltraps vector246: push 0 push 246 jmp __alltraps vector247: push 0 push 247 jmp __alltraps vector248: push 0 push 248 jmp __alltraps vector249: push 0 push 249 jmp __alltraps vector250: push 0 push 250 jmp __alltraps vector251: push 0 push 251 jmp __alltraps vector252: push 0 push 252 jmp __alltraps vector253: push 0 push 253 jmp __alltraps vector254: push 0 push 254 jmp __alltraps vector255: push 0 push 255 jmp __alltraps __alltraps: push rax push rcx push rdx push rdi push rsi push r8 push r9 push r10 push r11 push rbx push rbp push r12 push r13 push r14 push r15 mov rdi, rsp ; extern fn rust_trap(rsp) -> rsp extern rust_trap call rust_trap mov rsp, rax pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop r11 pop r10 pop r9 pop r8 pop rsi pop rdi pop rdx pop rcx pop rax ; pop trap_num, error_code add rsp, 16 iretq # vector table .rodata global __vectors __vectors: dq vector0 dq vector1 dq vector2 dq vector3 dq vector4 dq vector5 dq vector6 dq vector7 dq vector8 dq vector9 dq vector10 dq vector11 dq vector12 dq vector13 dq vector14 dq vector15 dq vector16 dq vector17 dq vector18 dq vector19 dq vector20 dq vector21 dq vector22 dq vector23 dq vector24 dq vector25 dq vector26 dq vector27 dq vector28 dq vector29 dq vector30 dq vector31 dq vector32 dq vector33 dq vector34 dq vector35 dq vector36 dq vector37 dq vector38 dq vector39 dq vector40 dq vector41 dq vector42 dq vector43 dq vector44 dq vector45 dq vector46 dq vector47 dq vector48 dq vector49 dq vector50 dq vector51 dq vector52 dq vector53 dq vector54 dq vector55 dq vector56 dq vector57 dq vector58 dq vector59 dq vector60 dq vector61 dq vector62 dq vector63 dq vector64 dq vector65 dq vector66 dq vector67 dq vector68 dq vector69 dq vector70 dq vector71 dq vector72 dq vector73 dq vector74 dq vector75 dq vector76 dq vector77 dq vector78 dq vector79 dq vector80 dq vector81 dq vector82 dq vector83 dq vector84 dq vector85 dq vector86 dq vector87 dq vector88 dq vector89 dq vector90 dq vector91 dq vector92 dq vector93 dq vector94 dq vector95 dq vector96 dq vector97 dq vector98 dq vector99 dq vector100 dq vector101 dq vector102 dq vector103 dq vector104 dq vector105 dq vector106 dq vector107 dq vector108 dq vector109 dq vector110 dq vector111 dq vector112 dq vector113 dq vector114 dq vector115 dq vector116 dq vector117 dq vector118 dq vector119 dq vector120 dq vector121 dq vector122 dq vector123 dq vector124 dq vector125 dq vector126 dq vector127 dq vector128 dq vector129 dq vector130 dq vector131 dq vector132 dq vector133 dq vector134 dq vector135 dq vector136 dq vector137 dq vector138 dq vector139 dq vector140 dq vector141 dq vector142 dq vector143 dq vector144 dq vector145 dq vector146 dq vector147 dq vector148 dq vector149 dq vector150 dq vector151 dq vector152 dq vector153 dq vector154 dq vector155 dq vector156 dq vector157 dq vector158 dq vector159 dq vector160 dq vector161 dq vector162 dq vector163 dq vector164 dq vector165 dq vector166 dq vector167 dq vector168 dq vector169 dq vector170 dq vector171 dq vector172 dq vector173 dq vector174 dq vector175 dq vector176 dq vector177 dq vector178 dq vector179 dq vector180 dq vector181 dq vector182 dq vector183 dq vector184 dq vector185 dq vector186 dq vector187 dq vector188 dq vector189 dq vector190 dq vector191 dq vector192 dq vector193 dq vector194 dq vector195 dq vector196 dq vector197 dq vector198 dq vector199 dq vector200 dq vector201 dq vector202 dq vector203 dq vector204 dq vector205 dq vector206 dq vector207 dq vector208 dq vector209 dq vector210 dq vector211 dq vector212 dq vector213 dq vector214 dq vector215 dq vector216 dq vector217 dq vector218 dq vector219 dq vector220 dq vector221 dq vector222 dq vector223 dq vector224 dq vector225 dq vector226 dq vector227 dq vector228 dq vector229 dq vector230 dq vector231 dq vector232 dq vector233 dq vector234 dq vector235 dq vector236 dq vector237 dq vector238 dq vector239 dq vector240 dq vector241 dq vector242 dq vector243 dq vector244 dq vector245 dq vector246 dq vector247 dq vector248 dq vector249 dq vector250 dq vector251 dq vector252 dq vector253 dq vector254 dq vector255
STRING equs "OK" WRAPPER equs "TRIN" PRINTT "{S{WRAPPER}G}\n" PRINTT "{S{WRAPPER}G"
<% from pwnlib.shellcraft.i386.linux import syscall %> <%page args="epfd, op, fd, event"/> <%docstring> Invokes the syscall epoll_ctl. See 'man 2 epoll_ctl' for more information. Arguments: epfd(int): epfd op(int): op fd(int): fd event(epoll_event): event </%docstring> ${syscall('SYS_epoll_ctl', epfd, op, fd, event)}
; A208138: Number of n X 4 0..1 arrays avoiding 0 0 1 and 0 1 1 horizontally and 0 0 1 and 1 0 1 vertically. ; 9,81,324,900,2025,3969,7056,11664,18225,27225,39204,54756,74529,99225,129600,166464,210681,263169,324900,396900,480249,576081,685584,810000,950625,1108809,1285956,1483524,1703025,1946025,2214144,2509056,2832489,3186225,3572100,3992004,4447881,4941729,5475600,6051600,6671889,7338681,8054244,8820900,9641025,10517049,11451456,12446784,13505625,14630625,15824484,17089956,18429849,19847025,21344400,22924944,24591681,26347689,28196100,30140100,32182929,34327881,36578304,38937600,41409225,43996689,46703556,49533444,52490025,55577025,58798224,62157456,65658609,69305625,73102500,77053284,81162081,85433049,89870400,94478400,99261369,104223681,109369764,114704100,120231225,125955729,131882256,138015504,144360225,150921225,157703364,164711556,171950769,179426025,187142400,195105024,203319081,211789809,220522500,229522500,238795209,248346081,258180624,268304400,278723025,289442169,300467556,311804964,323460225,335439225,347747904,360392256,373378329,386712225,400400100,414448164,428862681,443649969,458816400,474368400,490312449,506655081,523402884,540562500,558140625,576144009,594579456,613453824,632774025,652547025,672779844,693479556,714653289,736308225,758451600,781090704,804232881,827885529,852056100,876752100,901981089,927750681,954068544,980942400,1008380025,1036389249,1064977956,1094154084,1123925625,1154300625,1185287184,1216893456,1249127649,1281998025,1315512900,1349680644,1384509681,1420008489,1456185600,1493049600,1530609129,1568872881,1607849604,1647548100,1687977225,1729145889,1771063056,1813737744,1857179025,1901396025,1946397924,1992193956,2038793409,2086205625,2134440000,2183505984,2233413081,2284170849,2335788900,2388276900,2441644569,2495901681,2551058064,2607123600,2664108225,2722021929,2780874756,2840676804,2901438225,2963169225,3025880064,3089581056,3154282569,3219995025,3286728900,3354494724,3423303081,3493164609,3564090000,3636090000,3709175409,3783357081,3858645924,3935052900,4012589025,4091265369,4171093056,4252083264,4334247225,4417596225 mov $1,-3 bin $1,$0 pow $1,2 mul $1,9
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WT_ht+0xe2ac, %r9 nop nop nop nop cmp %r11, %r11 mov (%r9), %di nop nop nop nop dec %rcx lea addresses_UC_ht+0x448c, %r8 cmp %r13, %r13 mov (%r8), %eax nop cmp $2581, %rdi lea addresses_WT_ht+0x54cc, %r11 nop nop nop nop xor %rax, %rax movw $0x6162, (%r11) nop nop inc %r11 lea addresses_normal_ht+0x1e50c, %r8 cmp $37352, %r11 mov $0x6162636465666768, %r13 movq %r13, %xmm3 and $0xffffffffffffffc0, %r8 movntdq %xmm3, (%r8) nop nop nop cmp %r13, %r13 lea addresses_normal_ht+0xa86c, %r11 xor $21415, %rcx mov (%r11), %eax nop nop nop nop nop add $25127, %r11 lea addresses_WC_ht+0x6534, %r9 nop nop nop nop sub %rcx, %rcx mov $0x6162636465666768, %r8 movq %r8, %xmm6 movups %xmm6, (%r9) nop nop and %r13, %r13 lea addresses_D_ht+0xc64, %rdi lfence mov $0x6162636465666768, %r8 movq %r8, %xmm5 vmovups %ymm5, (%rdi) nop nop nop add %r8, %r8 lea addresses_A_ht+0x228c, %r8 sub %r9, %r9 movb $0x61, (%r8) nop nop nop nop nop add %r11, %r11 lea addresses_UC_ht+0x17fcc, %rsi lea addresses_UC_ht+0x15c3c, %rdi nop nop cmp $49244, %r9 mov $77, %rcx rep movsb nop nop nop nop nop add %r11, %r11 lea addresses_WC_ht+0x95bc, %r11 nop nop nop nop sub $3441, %r9 mov (%r11), %r8d nop nop nop nop nop cmp %r11, %r11 lea addresses_A_ht+0x1a4cc, %rax nop nop cmp %r8, %r8 movb $0x61, (%rax) nop and $58890, %r8 lea addresses_UC_ht+0x9bdc, %rsi lea addresses_WT_ht+0xe18c, %rdi nop nop nop nop nop cmp %r9, %r9 mov $5, %rcx rep movsl nop add %r13, %r13 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r14 push %r15 push %rax push %rsi // Store lea addresses_normal+0x1ce8c, %rsi nop add $14431, %rax movl $0x51525354, (%rsi) nop nop nop nop nop xor %r11, %r11 // Store lea addresses_normal+0x1460c, %r12 sub $19411, %r13 movw $0x5152, (%r12) xor %r11, %r11 // Store lea addresses_normal+0x6cb4, %r11 nop nop nop sub %r15, %r15 mov $0x5152535455565758, %rax movq %rax, %xmm1 vmovups %ymm1, (%r11) add %r11, %r11 // Load lea addresses_PSE+0x259c, %r12 nop nop nop sub %rsi, %rsi movups (%r12), %xmm6 vpextrq $0, %xmm6, %rax nop and $45895, %r15 // Faulty Load mov $0xa7b5b0000000e8c, %rsi nop nop nop nop nop inc %r15 vmovups (%rsi), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %r14 lea oracles, %r13 and $0xff, %r14 shlq $12, %r14 mov (%r13,%r14,1), %r14 pop %rsi pop %rax pop %r15 pop %r14 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 1}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': True, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': True, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': True, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 8}} {'25': 1321, 'ff': 74, '00': 20426, '33': 8} 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 25 25 00 25 00 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 25 00 00 00 00 25 00 00 00 00 00 00 00 00 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 25 25 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 25 00 00 25 00 00 00 00 00 00 00 25 00 00 00 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 25 00 25 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 25 00 25 25 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 25 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
.data .text addi $t0, $zero, 2000 addi $t1, $zero, 10 mult $t0, $t1 #two-register multiplication of 2000 and 10 #the results are large, so the product is stored in lo and hi regs mflo $s0 mfhi $s1 #not used here #display result li $v0, 1 add $a0, $zero, $s0 syscall
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_A_ht+0x1bcfd, %rax nop nop add $59740, %r9 mov (%rax), %r13 nop nop add %r8, %r8 lea addresses_D_ht+0xacd5, %rsi lea addresses_WT_ht+0x1eadd, %rdi clflush (%rdi) nop nop nop dec %r15 mov $25, %rcx rep movsq nop sub %rax, %rax lea addresses_D_ht+0x154fd, %rsi nop nop nop nop nop inc %r15 movl $0x61626364, (%rsi) nop nop nop nop nop sub $40465, %r8 lea addresses_A_ht+0x8919, %rsi nop nop nop and $39869, %r8 mov $0x6162636465666768, %r13 movq %r13, %xmm5 movups %xmm5, (%rsi) nop nop nop cmp $806, %r15 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %r9 push %rax push %rcx push %rdi push %rsi // Store lea addresses_WT+0x19104, %rdi nop nop nop nop and %r15, %r15 movl $0x51525354, (%rdi) nop nop cmp %rax, %rax // Store lea addresses_UC+0x16c01, %r10 clflush (%r10) nop nop nop nop sub %r12, %r12 mov $0x5152535455565758, %rsi movq %rsi, (%r10) nop xor $20645, %rax // Store lea addresses_UC+0x34fd, %r15 nop nop nop nop nop sub $4562, %rdi mov $0x5152535455565758, %rax movq %rax, %xmm0 vmovups %ymm0, (%r15) nop nop nop nop and $19462, %r12 // Load lea addresses_UC+0x70fd, %rdi nop nop nop nop nop cmp %rax, %rax mov (%rdi), %r10w cmp %r15, %r15 // Store lea addresses_RW+0x178fd, %rax nop nop nop nop nop add $44404, %r10 mov $0x5152535455565758, %rdi movq %rdi, (%rax) xor $62019, %rcx // REPMOV lea addresses_PSE+0xd1bd, %rsi mov $0x29c5ea00000008fd, %rdi and %r9, %r9 mov $12, %rcx rep movsw nop sub $36457, %rcx // Faulty Load lea addresses_PSE+0x74fd, %r9 nop nop add %r10, %r10 mov (%r9), %di lea oracles, %rcx and $0xff, %rdi shlq $12, %rdi mov (%rcx,%rdi,1), %rdi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 32, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 10, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_PSE', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_NC', 'congruent': 10, 'same': False}, 'OP': 'REPM'} [Faulty Load] {'src': {'type': 'addresses_PSE', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 8, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
segment .rdata, align=16 correct dq 0000800000008000h, 0000800000008000h round dq 0000200000002000h, 0000200000002000h round1 dq 0000020000000200h, 0000020000000200h round2 dq 0002000000020000h, 0002000000020000h segment .text %include "a_triblt.inc" extern _kVDCubicInterpTableFX14_075_MMX ;-------------------------------------------------------------------------- global _vdasm_triblt_span_bicubic_mip_linear_sse2 _vdasm_triblt_span_bicubic_mip_linear_sse2: ;parameters %define .p_texinfo 20 ;aligned frame %define .af_vtemp0 0 %define .af_mipbase 16 %define .af_prevesp 20 %define .afsize 24 push ebp lea ebp, [esp-12] push edi push esi push ebx sub esp, .afsize and esp, -16 mov [esp + .af_prevesp], ebp mov ebx, [ebp + .p_texinfo] mov ebp, [ebx + texinfo.dst] mov esi, [ebx + texinfo.w] shl esi, 2 add ebp,esi neg esi mov edi, [ebx + texinfo.src] mov [esp + .af_mipbase], ebx pxor xmm7, xmm7 .xloop: ;registers: ; eax base texel address ; ebx first mip info ; ecx horizontal filter ; edx vertical filter ; esi horizontal count ; edi mipspan ; ebp destination %macro .SETUPADDR 1 ;compute mipmap index and UV movd xmm0, [edi + mipspan.u] movd xmm1, [edi + mipspan.v] punpckldq xmm0, xmm1 mov ebx, [edi + mipspan.lambda] shr ebx, 4 and ebx, byte -16 add ebx, mipmap_size*%1 movd xmm2, ebx add ebx, [esp + .af_mipbase] psrlq xmm2, 4 psrad xmm0, xmm2 paddd xmm0, [correct] pshufd xmm1, xmm0, 01010101b ;compute horizontal filters movd ecx, xmm0 shr ecx, 4 and ecx, 0ff0h add ecx, _kVDCubicInterpTableFX14_075_MMX ;compute vertical filter movd edx, xmm1 and edx, 0ff00h shr edx, 4 add edx, _kVDCubicInterpTableFX14_075_MMX ;compute texel address movd xmm1, [ebx + mipmap.uvmul] psrld xmm0, 16 packssdw xmm0, xmm0 pmaddwd xmm0, xmm1 movd eax, xmm0 add eax, [ebx + mipmap.bits] %endmacro %macro .HCUBIC 4 movd %1, dword [eax] movd %3, dword [eax+4] movd %2, dword [eax+8] movd %4, dword [eax+12] punpcklbw %1, %3 punpcklbw %2, %4 punpcklbw %1, xmm7 punpcklbw %2, xmm7 movdqa %3, [ecx] pshufd %4, %3, 11101110b pshufd %3, %3, 01000100b pmaddwd %1, %3 pmaddwd %2, %4 paddd %1, %2 %endmacro %macro .VCUBIC 1 .HCUBIC xmm0, xmm4, xmm5, xmm6 add eax, %1 .HCUBIC xmm1, xmm4, xmm5, xmm6 add eax, %1 .HCUBIC xmm2, xmm4, xmm5, xmm6 add eax, %1 .HCUBIC xmm3, xmm4, xmm5, xmm6 movq xmm4, [round1] paddd xmm0, xmm4 paddd xmm1, xmm4 psrad xmm0, 10 paddd xmm2, xmm4 psrad xmm1, 10 packssdw xmm0, xmm0 paddd xmm3, xmm4 psrad xmm2, 10 packssdw xmm1, xmm1 movdqa xmm5, [edx] psrad xmm3, 10 punpcklwd xmm0, xmm1 packssdw xmm2, xmm2 packssdw xmm3, xmm3 pshufd xmm4, xmm5, 01000100b pmaddwd xmm0, xmm4 punpcklwd xmm2, xmm3 pshufd xmm5, xmm5, 11101110b pmaddwd xmm2, xmm5 paddd xmm0, xmm2 paddd xmm0, [round2] psrad xmm0, 18 packssdw xmm0, xmm0 %endmacro ;fetch mipmap 1 .SETUPADDR 0 .VCUBIC [ebx+mipmap.pitch] movq [esp + .af_vtemp0], xmm0 ;fetch mipmap 2 .SETUPADDR 1 .VCUBIC [ebx+mipmap.pitch] ;blend mips movq xmm1, [esp + .af_vtemp0] psubw xmm0, xmm1 movd xmm3, [edi+mipspan.lambda] pshuflw xmm3, xmm3, 0 psllw xmm3, 8 psrlq xmm3, 1 paddw xmm0, xmm0 pmulhw xmm0, xmm3 paddw xmm0, xmm1 packuswb xmm0, xmm0 movd dword [ebp+esi], xmm0 add edi, mipspan_size add esi,4 jnc .xloop mov esp, [esp + .af_prevesp] pop ebx pop esi pop edi pop ebp ret end
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r15 push %rbp push %rcx push %rdx lea addresses_WC_ht+0xa6f4, %r13 clflush (%r13) nop nop nop xor %rcx, %rcx mov (%r13), %r15 nop xor %rbp, %rbp lea addresses_A_ht+0x13754, %rbp nop nop nop nop nop add $25168, %r12 mov $0x6162636465666768, %rdx movq %rdx, %xmm0 movups %xmm0, (%rbp) nop nop nop nop cmp $62265, %r15 lea addresses_D_ht+0x274, %r15 nop nop nop nop nop sub $1010, %r11 and $0xffffffffffffffc0, %r15 movaps (%r15), %xmm0 vpextrq $1, %xmm0, %rbp nop nop nop nop add %r13, %r13 lea addresses_UC_ht+0x13ef4, %r12 nop nop add $43829, %rbp movl $0x61626364, (%r12) nop nop nop xor %rdx, %rdx lea addresses_WC_ht+0x27b4, %rbp nop nop cmp %r15, %r15 vmovups (%rbp), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rdx nop and %r15, %r15 pop %rdx pop %rcx pop %rbp pop %r15 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r9 push %rax push %rbp push %rdx push %rsi // Store lea addresses_WC+0x1aea4, %rsi and %r10, %r10 mov $0x5152535455565758, %rdx movq %rdx, (%rsi) nop nop nop nop inc %r9 // Store lea addresses_D+0x31f4, %rbp and %rax, %rax mov $0x5152535455565758, %r14 movq %r14, %xmm4 vmovups %ymm4, (%rbp) nop nop nop nop xor %rbp, %rbp // Store lea addresses_RW+0x62f4, %rsi nop nop inc %r14 movw $0x5152, (%rsi) nop nop inc %rax // Store lea addresses_RW+0xb6f4, %r14 inc %rsi movl $0x51525354, (%r14) cmp %rsi, %rsi // Store lea addresses_WC+0x2ef4, %rax nop nop nop nop nop cmp $25491, %r10 mov $0x5152535455565758, %r14 movq %r14, %xmm3 movups %xmm3, (%rax) nop nop nop nop and $44493, %rdx // Load lea addresses_RW+0xb6f4, %rdx clflush (%rdx) nop sub %rsi, %rsi movb (%rdx), %r14b nop sub %r14, %r14 // Store mov $0xef4, %r14 nop nop nop inc %rax movl $0x51525354, (%r14) nop nop nop nop xor $13001, %r10 // Store lea addresses_RW+0xb6f4, %rsi nop nop nop add %rdx, %rdx movl $0x51525354, (%rsi) and %r14, %r14 // Faulty Load lea addresses_RW+0xb6f4, %rdx nop nop sub %r10, %r10 mov (%rdx), %si lea oracles, %rdx and $0xff, %rsi shlq $12, %rsi mov (%rdx,%rsi,1), %rsi pop %rsi pop %rdx pop %rbp pop %rax pop %r9 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC', 'congruent': 2}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC', 'congruent': 9}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_P', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 0}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 11}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 4}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 7}} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 11}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 6}} {'54': 21829} 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 */
; A245346: Sum of digits of n in fractional base 10/3. ; 0,1,2,3,4,5,6,7,8,9,3,4,5,6,7,8,9,10,11,12,6,7,8,9,10,11,12,13,14,15,9,10,11,12,13,14,15,16,17,18,5,6,7,8,9,10,11,12,13,14,8,9,10,11,12,13,14,15,16,17,11,12,13,14,15,16,17,18,19,20,7,8,9 lpb $0 mov $2,$0 div $0,10 mul $0,3 mod $2,10 add $1,$2 lpe mov $0,$1
; A207069: Number of 2 X n 0..1 arrays avoiding 0 0 1 and 0 1 0 horizontally and 0 0 1 and 1 0 1 vertically. ; 4,16,36,81,196,441,961,2116,4624,10000,21609,46656,100489,216225,465124,1000000,2149156,4618201,9922500,21316689,45792289,98366724,211295296,453860416,974875729,2093977600,4497714225,9660727521,20750402500,44569965456,95732072836,205623250849,441658601476,948638988361,2037582098721,4376522576196,9400331472016,20190967086096,43368164873401,93150448496704,200077771663225,429746872133569,923052920549796,1982624519395584,4258477354140100,9146779491607209,19646358980320900,42198395700195361 add $0,2 seq $0,38718 ; Number of permutations P of {1,2,...,n} such that P(1)=1 and |P^-1(i+1)-P^-1(i)| equals 1 or 2 for i=1,2,...,n-1. pow $0,2
; A292046: The list of distinct values of A072464. ; 1,3,6,7,11,12,13,14,16,17,18,19,20,21,22,23,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113 mov $1,$0 lpb $1 seq $1,70939 ; Length of binary representation of n. add $0,$1 sub $1,1 lpe add $0,1
.global s_prepare_buffers s_prepare_buffers: push %r8 push %r9 push %rax push %rbp push %rbx push %rdi push %rdx lea addresses_D_ht+0x74c6, %rbx nop nop nop nop sub %rbp, %rbp movb (%rbx), %r9b nop nop nop and $27840, %r9 lea addresses_UC_ht+0x17cc6, %rdx nop xor %rax, %rax mov (%rdx), %bp sub %rax, %rax lea addresses_WT_ht+0x50c6, %r8 nop cmp %r9, %r9 movl $0x61626364, (%r8) nop nop nop nop nop sub $11476, %rbp lea addresses_WT_ht+0xecc6, %r9 nop nop nop nop xor $10998, %rdi movb (%r9), %bl nop nop nop cmp %r9, %r9 pop %rdx pop %rdi pop %rbx pop %rbp pop %rax pop %r9 pop %r8 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r9 push %rbx push %rdi push %rsi // Store lea addresses_normal+0x16c9e, %r13 clflush (%r13) nop add %r12, %r12 movb $0x51, (%r13) nop nop nop nop nop cmp %rdi, %rdi // Store lea addresses_D+0x1cb3c, %rsi nop nop nop nop xor %r13, %r13 mov $0x5152535455565758, %r9 movq %r9, %xmm6 vmovups %ymm6, (%rsi) // Exception!!! nop nop nop nop mov (0), %rsi nop add %rsi, %rsi // Store lea addresses_WT+0x1cd16, %rdi nop nop nop nop and $16697, %rsi mov $0x5152535455565758, %r9 movq %r9, (%rdi) nop nop nop add $19750, %rdi // Faulty Load lea addresses_normal+0x15cc6, %rsi nop nop nop nop nop xor %r13, %r13 vmovups (%rsi), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %rbx lea oracles, %rdi and $0xff, %rbx shlq $12, %rbx mov (%rdi,%rbx,1), %rbx pop %rsi pop %rdi pop %rbx pop %r9 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_normal', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'34': 13851} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
; A017110: a(n) = (8*n+3)^10. ; 59049,25937424601,6131066257801,205891132094649,2758547353515625,21611482313284249,119042423827613001,511116753300641401,1822837804551761449,5631351470947265625,15516041187205853449,38941611811810745401,90438207500880449001,196715135728956532249,404555773570791015625,792594609605189126649,1488377021731616101801,2692452204196940400601,4711653532607691047049,8004182490046884765625,13239635967018160063849,21377706189197971362201,33769941616283277616201,52289689788971837545849,79496153175699228515625,118839380482575369225049,174913992535407978606601,253770507618165375615801,363294289954110647868649,513663400740527822265625,717897987691852588770249,992515310305509690315001,1358306067936240628319401,1841249380144573175455449,2473585567569732666015625,3295067800663118480459449,4354415726901861885367401,5710996358479337764047001,7436759805837217107346249,9618459881658113759765625,12360192178975492163652649,15786284949774657045043801,20044580980751735469518601,25310151684662980796181049,31789487802830871103515625,39725214450772735983309849,49401381738478419529024201,61149385863482168213854201,75354579412446914492199849,92463633619402804697265625,112992719519952587477991049,137536579314570730951388601,166778563814477267272573801,201501716594357766775242649,242600990421323914541015625,291096686672861294547856249,348149213801988574756617001,415075266459351724951597401,493365532643394582186749449,584704042224979400634765625,690989276385774377822665449,814357163924275931995589401,957206097023388110011245001,1122224105942936326061760249,1312418339203244062978515625,1531147003165845604229778649,1782153922498441700301585801,2069605890837224702290236601,2398132989034601512560915049,2772872056708023101572265625,3199513511389984715762155849,3684351718424187648066286201,4234339123862247954529692201,4857144371993096171902453849,5561214638787231316416015625,6355842422464168617446357049,7251237042597649955815770601,8258601109663365229397131801,9390212237711958252794216649,10659510283919858707509765625,12081190410135888488510542249,13671302273206532936786519001,15447355662831141299710475401,17428432917974022716065643449,19635308465447330474853515625,22090575837180674640752471449,24818782535914467768701411401,27846573132597986739862043001,31202840992643922135499774249,34918889042392681418447265625,39028600001675809908107504649,43568616523242490508745727801,48578531695030075776442554601,54101090376822890581865249049,60182401858757016738291015625,66872164345396328911416601849,74223901785730590303743148201,82295213586433833406065130201,91148037763074441926148307849,100848928101691211234384765625 mul $0,8 add $0,3 pow $0,10
#ifndef BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP #define BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP // Boost.Geometry - extensions-gis-projections (based on PROJ4) // This file is automatically generated. DO NOT EDIT. // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2017. // Modifications copyright (c) 2017, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // This file is converted from PROJ4, http://trac.osgeo.org/proj // PROJ4 is originally written by Gerald Evenden (then of the USGS) // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels // Last updated version of proj: 4.9.1 // Original copyright notice: // 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. #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> #include <boost/geometry/srs/projections/impl/factory_entry.hpp> namespace boost { namespace geometry { namespace srs { namespace par4 { struct denoy {}; }} //namespace srs::par4 namespace projections { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace denoy { static const double C0 = 0.95; //static const double C1 = -.08333333333333333333; //static const double C3 = .00166666666666666666; static const double D1 = 0.9; static const double D5 = 0.03; template <typename T> inline T C1() { return -.0833333333333333333333333333333; } template <typename T> inline T C3() { return .0016666666666666666666666666666; } // template class, using CRTP to implement forward/inverse template <typename CalculationType, typename Parameters> struct base_denoy_spheroid : public base_t_f<base_denoy_spheroid<CalculationType, Parameters>, CalculationType, Parameters> { typedef CalculationType geographic_type; typedef CalculationType cartesian_type; inline base_denoy_spheroid(const Parameters& par) : base_t_f<base_denoy_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(*this, par) {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { static const CalculationType C1 = denoy::C1<CalculationType>(); static const CalculationType C3 = denoy::C3<CalculationType>(); xy_y = lp_lat; xy_x = lp_lon; lp_lon = fabs(lp_lon); xy_x *= cos((C0 + lp_lon * (C1 + lp_lon * lp_lon * C3)) * (lp_lat * (D1 + D5 * lp_lat * lp_lat * lp_lat * lp_lat))); } static inline std::string get_name() { return "denoy_spheroid"; } }; // Denoyer Semi-Elliptical template <typename Parameters> inline void setup_denoy(Parameters& par) { par.es = 0.; } }} // namespace detail::denoy #endif // doxygen /*! \brief Denoyer Semi-Elliptical projection \ingroup projections \tparam Geographic latlong point type \tparam Cartesian xy point type \tparam Parameters parameter type \par Projection characteristics - Pseudocylindrical - no inverse - Spheroid \par Example \image html ex_denoy.gif */ template <typename CalculationType, typename Parameters> struct denoy_spheroid : public detail::denoy::base_denoy_spheroid<CalculationType, Parameters> { inline denoy_spheroid(const Parameters& par) : detail::denoy::base_denoy_spheroid<CalculationType, Parameters>(par) { detail::denoy::setup_denoy(this->m_par); } }; #ifndef DOXYGEN_NO_DETAIL namespace detail { // Static projection BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::denoy, denoy_spheroid, denoy_spheroid) // Factory entry(s) template <typename CalculationType, typename Parameters> class denoy_entry : public detail::factory_entry<CalculationType, Parameters> { public : virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const { return new base_v_f<denoy_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); } }; template <typename CalculationType, typename Parameters> inline void denoy_init(detail::base_factory<CalculationType, Parameters>& factory) { factory.add_to_factory("denoy", new denoy_entry<CalculationType, Parameters>); } } // namespace detail #endif // doxygen } // namespace projections }} // namespace boost::geometry #endif // BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
############################################################################### # 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. ############################################################################### .text .p2align 5, 0x90 .globl _g9_cpAdd_BNU _g9_cpAdd_BNU: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (12)(%ebp), %eax movl (16)(%ebp), %ebx movl (8)(%ebp), %edx movl (20)(%ebp), %edi shl $(2), %edi xor %ecx, %ecx pandn %mm0, %mm0 .p2align 5, 0x90 .Lmain_loopgas_1: movd (%ecx,%eax), %mm1 movd (%ebx,%ecx), %mm2 paddq %mm1, %mm0 paddq %mm2, %mm0 movd %mm0, (%edx,%ecx) pshufw $(254), %mm0, %mm0 add $(4), %ecx cmp %edi, %ecx jl .Lmain_loopgas_1 movd %mm0, %eax emms pop %edi pop %esi pop %ebx pop %ebp ret
.global s_prepare_buffers s_prepare_buffers: push %r13 push %rcx push %rdi push %rsi lea addresses_A_ht+0x16aa9, %rsi lea addresses_normal_ht+0x156a9, %rdi nop nop nop nop mfence mov $30, %rcx rep movsl nop nop xor $62355, %rsi pop %rsi pop %rdi pop %rcx pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %r8 push %rax push %rbx push %rsi // Store mov $0x70440900000002a9, %r10 nop nop nop add $30919, %rsi movl $0x51525354, (%r10) nop nop cmp $21021, %r15 // Store mov $0x70440900000002a9, %rbx nop nop nop nop cmp %r8, %r8 movb $0x51, (%rbx) nop nop and $39438, %rbx // Load lea addresses_A+0x1df49, %r10 nop nop nop inc %r8 movups (%r10), %xmm2 vpextrq $1, %xmm2, %rsi nop nop add $10177, %r10 // Store lea addresses_RW+0x14c81, %r10 cmp $63191, %rsi mov $0x5152535455565758, %rbx movq %rbx, %xmm4 vmovups %ymm4, (%r10) nop nop and $55062, %r15 // Store lea addresses_A+0x1d069, %r10 sub $37195, %rbx mov $0x5152535455565758, %r8 movq %r8, %xmm7 vmovups %ymm7, (%r10) nop nop nop add $24581, %r14 // Faulty Load mov $0x70440900000002a9, %r10 add $48419, %r15 mov (%r10), %bx lea oracles, %rax and $0xff, %rbx shlq $12, %rbx mov (%rax,%rbx,1), %rbx pop %rsi pop %rbx pop %rax pop %r8 pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_NC', 'congruent': 0}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_NC', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': True, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_NC', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A', 'congruent': 5}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_RW', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 2}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_NC', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': True, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 11, 'type': 'addresses_A_ht'}} {'00': 1, '51': 5} 51 51 00 51 51 51 */
; ; Sharp OZ family functions ; ; ported from the OZ-7xx SDK by by Alexander R. Pruss ; by Stefano Bodrato - Oct. 2003 ; ; ; display blanking control functions ; LCDStatus is 0c024h in the OS; ; ; ; ------ ; $Id: ozblankscreen.asm,v 1.1 2003/10/21 17:15:21 stefano Exp $ ; XLIB ozblankscreen LIB ozunblankscreen LIB ozsetlcdstate XREF s_blanked XREF s_ozlcdstatus XREF s_init_unblank ozblankscreen: ld hl,ozunblankscreen ; was ozslow ld (s_init_unblank+1),hl ld a,1 ld (s_blanked),a ld hl,(s_ozlcdstatus) ld a,l or 40h and 7fh ld l,a push hl call ozsetlcdstate pop hl ret
#include "gal/opengl/object_impl/gal_texture_sampler_impl_gl.h" namespace gal { bool GALTextureSamplerImplGL::Create(GALPlatform* gal_platform, const GALTexture& texture) { // TODO(colintan): Replace this with something better static int unit_counter = 0; // TODO(colintan): Check that GALTexture returns a valid GLuint GLuint gl_tex = texture.GetImpl().GetGLId(); ++unit_counter; tex_unit_ = unit_counter; glActiveTexture(GL_TEXTURE0 + tex_unit_); if (texture.GetType() == TextureType::Texture2D) { glBindTexture(GL_TEXTURE_2D, gl_tex); } else { return false; } return true; } void GALTextureSamplerImplGL::Destroy() { } } // namespace
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0xc556, %rsi lea addresses_D_ht+0x15d56, %rdi nop cmp $52293, %r10 mov $7, %rcx rep movsq nop nop cmp %rdx, %rdx lea addresses_WC_ht+0xf06, %rsi lea addresses_WT_ht+0x2b7c, %rdi nop nop xor %rdx, %rdx mov $94, %rcx rep movsw add %rsi, %rsi lea addresses_WC_ht+0x16b56, %rbp nop nop xor $64092, %rdx movw $0x6162, (%rbp) nop nop nop xor $14274, %rsi lea addresses_A_ht+0xb556, %rdx sub %r13, %r13 mov $0x6162636465666768, %rdi movq %rdi, (%rdx) nop nop nop nop sub %rsi, %rsi lea addresses_normal_ht+0xc956, %rsi lea addresses_WC_ht+0x18676, %rdi nop nop nop nop nop and $54134, %rax mov $31, %rcx rep movsl nop inc %r13 lea addresses_D_ht+0x3556, %rsi lea addresses_UC_ht+0x7956, %rdi nop and %r13, %r13 mov $98, %rcx rep movsb nop nop nop and $27015, %rdx lea addresses_WC_ht+0xd43e, %rsi lea addresses_WT_ht+0x5fc2, %rdi add %r13, %r13 mov $101, %rcx rep movsw nop and $43591, %rbp lea addresses_normal_ht+0x19156, %r13 nop nop sub %rdx, %rdx movw $0x6162, (%r13) nop nop nop xor %rcx, %rcx lea addresses_A_ht+0x13c56, %rdx clflush (%rdx) cmp $26566, %rbp mov $0x6162636465666768, %rsi movq %rsi, (%rdx) nop nop nop nop nop sub %rdi, %rdi lea addresses_WC_ht+0x1ebb8, %rsi lea addresses_normal_ht+0x19f56, %rdi clflush (%rdi) nop and $37786, %rax mov $65, %rcx rep movsl add %rax, %rax lea addresses_A_ht+0x9c66, %rbp sub $34458, %r13 movb (%rbp), %al sub $54940, %r13 lea addresses_normal_ht+0x9da4, %r10 nop nop nop sub $4560, %rsi and $0xffffffffffffffc0, %r10 movaps (%r10), %xmm0 vpextrq $0, %xmm0, %rax nop nop nop nop add %rax, %rax lea addresses_D_ht+0x105d6, %rax nop nop and %rdx, %rdx mov (%rax), %r13d xor %r10, %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r9 push %rbp push %rcx push %rdx push %rsi // Faulty Load lea addresses_A+0x15556, %rsi nop nop nop nop nop add %r9, %r9 mov (%rsi), %rdx lea oracles, %r12 and $0xff, %rdx shlq $12, %rdx mov (%r12,%rdx,1), %rdx pop %rsi pop %rdx pop %rcx pop %rbp pop %r9 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 9}, 'dst': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': True, 'AVXalign': True, 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'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 */
#include <pbcopper/cli2/internal/PositionalArgumentTranslator.h> #include <sstream> #include <pbcopper/cli2/PositionalArgument.h> #include <pbcopper/cli2/internal/PositionalArgumentData.h> #include <pbcopper/json/JSON.h> using Json = PacBio::JSON::Json; using PositionalArgument = PacBio::CLI_v2::PositionalArgument; using PositionalArgumentData = PacBio::CLI_v2::internal::PositionalArgumentData; namespace { struct MissingPosArgFieldException : public std::runtime_error { MissingPosArgFieldException(const std::string& field, const std::string& posArgText) : std::runtime_error("") { std::ostringstream msg; msg << "[pbcopper] command line argument ERROR: required field: \"" << field << "\" is missing or empty in positional argument definition:\n" << posArgText << '\n'; msg_ = msg.str(); } const char* what() const noexcept override { return msg_.c_str(); } std::string msg_; }; void Validate(const PositionalArgument& posArg, const PositionalArgumentData& result) { // required argument data fields if (result.name.empty()) { throw MissingPosArgFieldException("name", posArg.text); } if (result.description.empty()) { throw MissingPosArgFieldException("description", posArg.text); } } } // namespace namespace PacBio { namespace CLI_v2 { namespace internal { std::string PositionalArgumentTranslator::PositionalArgName(const PositionalArgument& posArg) { const Json root = Json::parse(posArg.text); std::string result = root["name"]; return result; } PositionalArgumentData PositionalArgumentTranslator::Translate(const PositionalArgument& posArg) { PositionalArgumentData result; try { const Json root = Json::parse(posArg.text); // name auto name = root.find("name"); if (name != root.cend()) { result.name = name->get<std::string>(); } // description const auto description = root.find("description"); if (description != root.cend()) { result.description = description->get<std::string>(); } // type const auto type = root.find("type"); if (type != root.cend()) { result.type = ValueType(type->get<std::string>()); } // required const auto required = root.find("required"); if (required != root.cend()) { result.required = *required; } } catch (std::exception& e) { std::ostringstream msg; msg << "[pbcopper] command line argument ERROR: cannot parse definition:\n" << posArg.text << '\n' << "with JSON error: " << e.what() << '\n'; throw std::runtime_error{msg.str()}; } Validate(posArg, result); return result; } std::vector<PositionalArgumentData> PositionalArgumentTranslator::Translate( const std::vector<PositionalArgument>& posArgs) { std::vector<PositionalArgumentData> result; for (const auto& posArg : posArgs) { result.emplace_back(Translate(posArg)); } return result; } } // namespace internal } // namespace CLI_v2 } // namespace PacBio
; A258387: a(n) = (n+1)^n + n^(n-1). ; 3,11,73,689,8401,125425,2214801,45143873,1043046721,26937424601,768945795289,24041093493169,817012858376625,29986640798644769,1182114430632237601,49814113380273715457,2234572751614363400449,106313261857649938064809,5347007350297911241532841,283461309446951548637196401 mov $1,$0 mov $2,2 add $2,$0 add $0,1 pow $2,$0 pow $0,$1 add $0,$2
#include "uritests.h" #include "../guiutil.h" #include "../walletmodel.h" #include <QUrl> void URITests::uriTests() { SendCoinsRecipient rv; QUrl uri; uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?req-dontexist=")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?dontexist=")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 0); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?label=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString("Wikipedia Example Address")); QVERIFY(rv.amount == 0); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=0.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100000); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=1.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100100000); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=100&label=Wikipedia Example")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.amount == 10000000000LL); QVERIFY(rv.label == QString("Wikipedia Example")); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?message=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(GUIUtil::parseBitcoinURI("americs://LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?message=Wikipedia Example Address", &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); // We currently don't implement the message parameter (ok, yea, we break spec...) uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?req-message=Wikipedia Example Address")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=1,000&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("americs:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=1,000.0&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); }
/* * Copyright (C) 2012 Open Source Robotics Foundation * * 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. * */ #ifndef _GAZEBO_RTSHADERSYSTEM_HH_ #define _GAZEBO_RTSHADERSYSTEM_HH_ #include <list> #include <string> #include "gazebo/rendering/ogre_gazebo.h" #include "gazebo/gazebo_config.h" #include "gazebo/rendering/Camera.hh" #include "gazebo/common/SingletonT.hh" #include "gazebo/util/system.hh" /// \brief Explicit instantiation for typed SingletonT. GZ_SINGLETON_DECLARE(GZ_RENDERING_VISIBLE, gazebo, rendering, RTShaderSystem) namespace gazebo { namespace rendering { class RTShaderSystemPrivate; /// \addtogroup gazebo_rendering /// \{ /// \class RTShaderSystem RTShaderSystem.hh rendering/rendering.hh /// \brief Implements Ogre's Run-Time Shader system. /// /// This class allows Gazebo to generate per-pixel shaders for every /// material at run-time. class GZ_RENDERING_VISIBLE RTShaderSystem : public SingletonT<RTShaderSystem> { /// \enum LightingModel. /// \brief The type of lighting. public: enum LightingModel { /// \brief Per-Vertex lighting: best performance. SSLM_PerVertexLighting, /// \brief Per-Pixel lighting: best look. SSLM_PerPixelLighting, /// \brief Normal Map lighting: lighting calculations have /// been stored in a light map (texture) using tangent space. SSLM_NormalMapLightingTangentSpace, /// \brief Normal Map lighting: lighting calculations have /// been stored in a light map (texture) using object space. SSLM_NormalMapLightingObjectSpace }; /// \brief Constructor. private: RTShaderSystem(); /// \brief Destructor. private: virtual ~RTShaderSystem(); /// \brief Init the run time shader system. public: void Init(); /// \brief Finalize the shader system public: void Fini(); /// \brief Add a scene manager /// \param[in] _scene The scene to process public: void AddScene(ScenePtr _scene); /// \brief Remove a scene /// \param[in] The scene to remove public: void RemoveScene(ScenePtr _scene); /// \brief Remove a scene /// \param[in] Name of the scene to remove. public: void RemoveScene(const std::string &_scene); /// \brief Queue a call to update the shaders. public: void UpdateShaders(); /// \brief Set a viewport to use shaders. /// \param[in] _viewport The viewport to add. /// \param[in] _scene The scene that the viewport uses. public: static void AttachViewport(Ogre::Viewport *_viewport, ScenePtr _scene); /// \brief Set a viewport to not use shaders. /// \param[in] _viewport The viewport to remove. /// \param[in] _scene The scene that the viewport uses. public: static void DetachViewport(Ogre::Viewport *_viewport, ScenePtr _scene); /// \brief Set the lighting model to per pixel or per vertex. /// \param[in] _set True means to use per-pixel shaders. public: void SetPerPixelLighting(bool _set); /// \brief Generate shaders for an entity /// \param[in] _vis The visual to generate shaders for. public: void GenerateShaders(const VisualPtr &_vis); /// \brief Apply shadows to a scene. /// \param[in] _scene The scene to receive shadows. public: void ApplyShadows(ScenePtr _scene); /// \brief Remove shadows from a scene. /// \param[in] _scene The scene to remove shadows from. public: void RemoveShadows(ScenePtr _scene); /// \brief Get the Ogre PSSM Shadows camera setup. /// \return The Ogre PSSM Shadows camera setup. public: Ogre::PSSMShadowCameraSetup *GetPSSMShadowCameraSetup() const; /// \brief Update the RT shaders. This should not be called frequently. public: void Update(); /// \brief Set the shadow texture size. /// \param[in] _size Size of shadow texture to set to. This must be a /// power of 2. The default size is 1024. /// \return True if size is set successfully, false otherwise. public: bool SetShadowTextureSize(const unsigned int _size); /// \brief Get the shadow texture size. /// \return Size of the shadow texture. The default size is 1024. public: unsigned int ShadowTextureSize() const; /// \brief Set the shadow clip distances. /// \param[in] _near Near clip distance. /// \param[in] _far Far clip distance. public: void SetShadowClipDist(const double _near, const double _far); /// \brief Get the shadow near clip distance. /// \return Near clip distance. public: double ShadowNearClip() const; /// \brief Get the shadow far clip distance. /// \return Far clip distance. public: double ShadowFarClip() const; /// \brief Set the PSSM lambda value for determining how linear or /// logarithmic choice of split points will be. /// \param[in] _lambda PSSM split point lambda. public: void SetShadowSplitLambda(const double _lambda); /// \brief Get the PSSM split point lambda value. /// \return PSSM split point lambda. public: double ShadowSplitLambda() const; /// \brief Set the overlap between PSSM shadow maps. /// \param[in] _padding PSSM split point overlap. public: void SetShadowSplitPadding(const double _padding); /// \brief Get the PSSM split point overlap. /// \return PSSM split point overlap. public: double ShadowSplitPadding() const; /// \brief Get paths for the shader system /// \param[out] _coreLibsPath Path to the core libraries. /// \param[out] _cachePath Path to where the generated shaders are /// stored. private: bool GetPaths(std::string &_coreLibsPath, std::string &_cachePath); /// \brief Update the shaders for a visual. /// \param[in] _vis Pointer to the visual to update. private: void UpdateShaders(VisualPtr _vis); /// \brief Re-apply shadows. Call this if a shadow paramenter is changed. private: void ReapplyShadows(); /// \brief Make the RTShader system a singleton. private: friend class SingletonT<RTShaderSystem>; /// \internal /// \brief Pointer to private data. private: RTShaderSystemPrivate *dataPtr; }; /// \} } } #endif
; A110507: Number of nodes in the smallest cubic graph with crossing number n. ; Submitted by Christian Krause ; 4,6,10,14,16,18,20,22,24,26,28,28 add $0,1 pow $0,2 add $0,1 mov $2,5 lpb $0 mul $0,7 div $0,8 add $1,$2 lpe div $1,10 mov $0,$1 add $0,1 mul $0,2
; A188031: [nr]-[nr-kr]-[kr], where r=(1+sqrt(5))/2, k=11, [ ]=floor. ; Submitted by Jamie Morken(s4) ; 1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,0 add $0,1 seq $0,83368 ; A Fibbinary system represents a number as a sum of distinct Fibonacci numbers (instead of distinct powers of two). Using representations without adjacent zeros, a(n) = the highest bit-position which changes going from n-1 to n. seq $0,213818 ; Antidiagonal sums of the convolution array A213773. sub $0,2 div $0,2 mod $0,2
org 0x7c00 bits 16 mov ax, 0 mov ds, ax cli mov cx, 0 ; inicializa quantidade de letras como 0 read: mov ax, 0 ; leitura do teclado int 0x16 cmp al, 13 ; checa se a tecla enter foi apertada je lineBreak mov ah, 0x0e ; printa na tela o que foi lido int 0x10 push ax ; coloca o valor lido na pilha inc cx ; incrementa a quantidade de letras jmp read lineBreak: ; faz a quebra de linha mov ah, 0x02 mov dh, 1 int 0x10 invert: pop ax ; retira um elemento da pilha int 0x10 ; printa o elemento dec cx ; decrementa a quantidade de letras jz end ; se dx for zero, acaba o programa jmp invert ; senão faz outra iteração do laço end: hlt times 510 - ($-$$) db 0 dw 0XAA55
; DRAW XOR SPRITE 1 BYTE DEFINITION ROTATED ; 04.2006 aralbrec, Sprite Pack v3.0 ; sinclair spectrum version INCLUDE "clib_target_cfg.asm" SECTION code_temp_sp1 PUBLIC _SP1_DRAW_XOR1 EXTERN _SP1_DRAW_XOR1NR EXTERN SP1RETSPRDRAW ; following data segment copied into struct sp1_cs ld hl,0 ld ix,0 call _SP1_DRAW_XOR1 ; following draw code called by way of SP1UpdateNow ; ; a = hor rot table ; bc = graphic disp ; hl = graphic def ptr ; ix = left graphic def ptr ; ; 51 + 166*4 - 6 + 10 = 719 cycles _SP1_DRAW_XOR1: cp SP1V_ROTTBL/256 jp z, _SP1_DRAW_XOR1NR add hl,bc add ix,bc ex de,hl ld h,a ; h = shift table ; de = sprite def (graph only) ; ix = left sprite def _SP1XOr1Rotate: ; 0 ld bc,(SP1V_PIXELBUFFER+0) ld a,(de) inc de ld l,a ld a,(hl) inc h ld l,(ix+0) or (hl) xor c ld (SP1V_PIXELBUFFER+0),a ld l,(ix+1) ld c,(hl) dec h ld a,(de) inc de ld l,a ld a,c or (hl) xor b ld (SP1V_PIXELBUFFER+1),a ; 1 ld bc,(SP1V_PIXELBUFFER+2) ld a,(de) inc de ld l,a ld a,(hl) inc h ld l,(ix+2) or (hl) xor c ld (SP1V_PIXELBUFFER+2),a ld l,(ix+3) ld c,(hl) dec h ld a,(de) inc de ld l,a ld a,c or (hl) xor b ld (SP1V_PIXELBUFFER+3),a ; 2 ld bc,(SP1V_PIXELBUFFER+4) ld a,(de) inc de ld l,a ld a,(hl) inc h ld l,(ix+4) or (hl) xor c ld (SP1V_PIXELBUFFER+4),a ld l,(ix+5) ld c,(hl) dec h ld a,(de) inc de ld l,a ld a,c or (hl) xor b ld (SP1V_PIXELBUFFER+5),a ; 3 ld bc,(SP1V_PIXELBUFFER+6) ld a,(de) inc de ld l,a ld a,(hl) inc h ld l,(ix+6) or (hl) xor c ld (SP1V_PIXELBUFFER+6),a ld l,(ix+7) ld c,(hl) dec h ld a,(de) ld l,a ld a,c or (hl) xor b ld (SP1V_PIXELBUFFER+7),a jp SP1RETSPRDRAW
org 0x7e00 jmp 0x0000:start data: ; dados da interface console texto_menu_console db 'PLAYSTATION 6', 0 ; texto console texto_menu_pong db 'P - JOGAR PONG', 0 ; texto jogar Pong console texto_menu_space db 'S - JOGAR SPACE INVADERS', 0 ; texto jogar Space Invaders console texto_menu_snake db 'T - JOGAR SNAKE', 0 ; texto jogar Snake console ; dados do Snake ; Constantes ; tela_largura dw 140h ; janela feita com al = 13h (320x200) ; tela_altura dw 0c8h ; condicao_tela equ 100 cor_de_fundo db 14 cor_da_cobra db 2 ; TIMER equ 046Ch ; Nº de ticks desde a meia-noite, 18.2 ticks equivalem a 1 segundo array_cobra_x equ 1000h array_cobra_y equ 2000h UP equ 0 DOWN equ 1 LEFT equ 2 RIGHT equ 3 ; Variáveis cobra_x: dw 0A0h cobra_y: dw 064h comprimento_da_cobra: dw 5 largura_da_cobra: dw 2 win_points: dw 15 points dw 0 objeto_x: dw 30 objeto_y: dw 20 cor_do_objeto: db 4 direcao: db 4 ; Mensagens snake_texto_main_menu db 'BEM-VINDO AO SNAKE GAME', 0 snake_instrucoes1 db 'COMA AS FRUTAS PARA', 0 snake_instrucoes2 db 'CRESCER E ZERAR O JOGO', 0 snake_texto_jogar db 'JOGAR - PRESSIONE T', 0 snake_texto_sair_jogo db 'SAIR - PRESSIONE N', 0 snake_texto_controle db 'USE A/W/S/D PARA SE MOVER', 0 snake_texto_reset db 'RESET COM R', 0 snake_good_luck db 'BOA SORTE!', 0 snake_fim db 'GAME OVER', 0 snake_parabens db 'PARABENS!', 0 snake_ganhou db 'VOCE GANHOU O JOGO', 0 snake_return db 'APERTE E PARA RETORNAR', 0 ; dados do Space Invaders ======================================================= ; Variáveis de Vídeo -------- 320 * 200 = 64000 = 0FA00h space_sprites equ 0FA00h alien1 equ 0FA00h alien2 equ 0FA04h ; 4 bytes jogador equ 0FA08h ; 4 bytes barreiras_array equ 0FA0Ch ; 5 * 4 = 20 bytes aliens_array equ 0FA20h ; 4 bytes jogador_x equ 0FA24h tiros_array equ 0FA25h ; 4 * 2(coordenadas) = 8 bytes. 2 Primeiros Byte = Tiro do jogador alien_y equ 0FA2Dh+32 alien_x equ 0FA2Eh+32 aliens_num equ 0FA2Fh+32 ; Aliens vivos aliens_direcao equ 0FA30h+32 ; Direção dos aliens move_timer equ 0FA31h+32 ; Numero de Loops para que os aliens se movam muda_alien equ 0FA33h+32 ; Muda o sprite do alien ; Outras variáveis ---------- dist_barreiras equ 0FA34h+32 num_barreiras equ 0FA35h+32 cur_moves equ 0FA36h+32 jogador_pt_tiro equ 0FA37h+32 ; Constantes ---------------- TIMER equ 046Ch ; Nº de ticks desde a meia-noite BARREIRA_X equ 25 BARREIRA_Y equ 80 JOGADOR_Y equ 93 LARGURA_TELA equ 320 ALTURA_TELA equ 200 ALTURA_SPRITE equ 4 LARGURA_SPRITE equ 8 ; Largura em Bits LARGURA_SPRITE_P equ 16 ; Largura em Pixels DIST_BARREIRAS equ 25 ; Cores --------------------- COR_ALIEN equ 02h COR_JOGADOR equ 0Fh COR_TELA equ 00h ; cor preta COR_BARREIRA equ 06h COR_TIRO_ALIEN equ 21h COR_TIRO_PLAYER equ 35h ; Textos ------------------- space_texto_main_menu db 'BEM-VINDO AO SPACE INVADERS' ,0 space_instrucoes1 db 'DERROTE OS ALIENS', 0 space_instrucoes2 db 'ANTES QUE ELES CHEGUEM ATE VOCE',0 space_texto_jogar db 'JOGAR - PRESSIONE S',0 space_texto_sair_jogo db 'SAIR - PRESSIONE N', 0 space_texto_controle db 'USE L_SHIFT/R_SHIFT PARA SE MOVER', 0 space_texto_tiro db 'ATIRE COM SPACE BAR', 0 space_texto_reset db 'RESET COM R', 0 space_fases db 'BOA SORTE NAS 3 FASES!', 0 space_fase1 db 'FASE 1', 0 space_fase2 db 'FASE 2', 0 space_fase3 db 'FASE 3', 0 space_fim db 'GAME OVER',0 space_parabens db 'PARABENS!',0 ; dados do Pong ================================================================= ; dados de game status game_status db 1 ; game_status = 1 - jogando | game_status = 0 - nao ta jogando winner_status db 0 ; status do vencedor | 1 -> jogador 1, 2 -> jogador 2 tela_atual db 0 ; Status da tela atual | 0-> menu, 1 -> jogo ; dados da tela tela_largura dw 140h ; janela feita com al = 13h (320x200) tela_altura dw 0c8h margem_erro dw 6 ; margem de erro para a bola não atravessar a tela ; dados do tempo tempo_aux dw 0 ; variável usado para checar se o tempo passou ; dados da interface texto_jogador_um db '0' ; texto da pontuação do jogador 1 texto_jogador_dois db '0' ; texto da pontuação do jogador 2 texto_game_over db 'GAME OVER', 0 ; texto game over texto_vencedor_1 db 'PLAYER 1 VENCEU', 0 ; texto vencedor 1 texto_vencedor_2 db 'PLAYER 2 VENCEU', 0 ; texto vencedor 2 texto_restart db 'RESTART - pressione R', 0 ; texto restart texto_return_main_menu db 'MENU - pressione M', 0 ; texto retornar para o main menu texto_main_menu db 'MENU PRINCIPAL', 0 ; texto main menu texto_jogar db 'JOGAR - pressione P', 0 ; texto jogar texto_sair_jogo db 'Pressione N para sair de jogo', 0 ; texto sair do jogo texto_jogador_1 db 'JOGADOR 1', 0 ; texto jogador 1 texto_inst_jogador_1 db 'W/S move cima/baixo', 0 ; texto inst jogador 1 texto_jogador_2 db 'JOGADOR 2', 0 ; texto jogador 2 texto_inst_jogador_2 db 'O/L move cima/baixo', 0 ; texto inst jogador 2 ; dados da bola bola_size dw 5 ; tamanho da bola bola_cor db 15 ; cor da bola bola_origem_X dw 0A0h ; posicao X original da bola (meio da tela) bola_origem_Y dw 064h ; posição Y original da bola (meio da tela) bola_X dw 0A0h ; posição X da bola bola_Y dw 064h ; posição Y da bola bola_vel_X dw 06h ; velocidade X da bola bola_vel_Y dw 03h ; velocidade Y da bola ; dados das barras barra_esquerda_pontos db 0 ; pontuação do primeiro jogador (esquerda) barra_esquerda_X dw 0Ah ; posição X da barra esquerda barra_esquerda_Y dw 0Ah ; posição Y da barra esquerda barra_esquerda_cor db 15 barra_direita_pontos db 0 ; pontuação do segundo jogador (direita) barra_direita_X dw 132h ; posição X da barra direita barra_direita_Y dw 0A0h ; posição Y da barra direita barra_direita_cor db 15 barra_largura dw 5 ; largura da barra barra_altura dw 30 ; altura da barra barra_vel dw 06h ; velocidade vertical da barra ; printa um objeto passando os parrametros ; (coordX, coordY, largura, altura, cor) %macro print_obj 5 .loop1: .loop2: mov ah, 0Ch ; escrevendo um pixel mov al, %5 ; escolhendo a cor (branca) mov bh, 00h ; escolhendo a pagina int 10h inc cx mov ax, cx sub ax, %1 cmp ax, %3 jne .loop2 mov cx, %1 inc dx mov ax, dx sub ax, %2 cmp ax, %4 jne .loop1 %endmacro ; printa uma string passando os parametros ; (linha, coluna, * string) %macro print_string 3 mov ah, 02h ; escolher a posição do cursor mov bh, 00h ; escolher a pagina mov dh, %1 ; escolher a linha mov dl, %2 ; escolher a coluna int 10h mov si, %3 ; pega o texto call prints ; print o texto %endmacro print_boundaries: print_top: mov cx, 0 mov dx, 0 print_obj 0, 0, [tela_largura], 1, [cor_do_objeto] print_bottom: mov cx, 0 mov dx, 0C7h print_obj 0, 0C7h, [tela_largura], 1, [cor_do_objeto] print_left: mov cx, 0 mov dx, 0 print_obj 0, 0, 1, [tela_altura], [cor_do_objeto] print_right: mov cx, 13Fh mov dx, 0 print_obj 13Fh, 0, 1, [tela_altura], [cor_do_objeto] ret jogar_pong: mov al, 1 mov [game_status], al xor al, al mov [tela_atual], al jmp pong_loop menu_console: call limpar_tela print_string 04h, 06h, texto_menu_console print_string 0Ah, 06h, texto_menu_pong print_string 0Ch, 06h, texto_menu_space print_string 0Eh, 06h, texto_menu_snake .espera_tecla: ; espera por um caracter mov ah, 00h int 16h ; salva o caracter em al cmp al, 'p' je jogar_pong cmp al, 'P' je jogar_pong cmp al, 's' je prep_jogar_space cmp al, 'S' je prep_jogar_space cmp al, 't' je setup_snake cmp al, 'T' je setup_snake jmp .espera_tecla jmp menu_console reset_cor: mov al, 1 mov [bola_cor], al ret mudar_cor: mov al, [bola_cor] inc al mov [bola_cor], al mov ah, 16 cmp [bola_cor], ah jge reset_cor ret print_UI: ; desenhar os pontos do jogador esquerdo mov ah, 02h ; escolher a posição do cursor mov bh, 00h ; escolher a pagina mov dh, 04h ; escolher a linha mov dl, 06h ; escolher a coluna int 10h mov ah, 0Eh ; escrever caracter mov al, [texto_jogador_um] ; escolher caracter mov bl, [barra_esquerda_cor] ; escolher cor (branco) int 10h ; desenhar os pontos do jogador direito mov ah, 02h ; escolher a posição do cursor mov dh, 04h ; escolher a linha mov dl, 21h ; escolher a coluna int 10h mov ah, 0Eh ; escrever caracter mov al, [texto_jogador_dois] ; escolher caracter mov bl, [barra_direita_cor] ; escolher cor (branco) int 10h ret atualiza_texto_jogador_um: xor ax, ax mov al, [barra_esquerda_pontos] add al, 48 mov [texto_jogador_um], al ret atualiza_texto_jogador_dois: xor ax, ax mov al, [barra_direita_pontos] add al, 48 mov [texto_jogador_dois], al ret print_barra_direita: ; define as coordenadas iniciais da barra direita mov cx, [barra_direita_X] mov dx, [barra_direita_Y] ; desenha a barra direita print_obj [barra_direita_X], [barra_direita_Y], [barra_largura], [barra_altura], [barra_direita_cor] ret print_barra_esquerda: ; define as coordenadas iniciais da barra esquerda mov cx, [barra_esquerda_X] mov dx, [barra_esquerda_Y] ; desenha a barra esquerda print_obj [barra_esquerda_X], [barra_esquerda_Y], [barra_largura], [barra_altura], [barra_esquerda_cor] ret print_bola: ; define as coordenadas iniciais da bola mov cx, [bola_X] mov dx, [bola_Y] ; desenha a bola print_obj [bola_X], [bola_Y], [bola_size], [bola_size], [bola_cor] ret prints: ; print o texto de game over .loop: lodsb ; bota character em al cmp al, 0 je .endloop call putchar jmp .loop .endloop: ret putchar: mov ah, 0x0e mov bh, 00h mov bl, 15 int 10h ret print_game_over_menu: call limpar_tela print_string 04h, 06h, texto_game_over ; print texto game over ; mostra o vencedor mov ah, 02h ; escolher a posição do cursor mov bh, 00h ; escolher a pagina mov dh, 06h ; escolher a linha mov dl, 06h ; escolher a coluna int 10h mov al, 01h ; compara o status de vencedor cmp [winner_status], al je vencedor_um ; se for 1 o jogador 1 venceu jne vencedor_dois ; se não, o jogador 2 venceu vencedor_um: mov si, texto_vencedor_1 ; pega o texto de vencedor 1 jmp print_vencedor vencedor_dois: mov si, texto_vencedor_2 ; pega o texto de vencedor 2 jmp print_vencedor print_vencedor: ; print o texto de vencedor call prints print_string 08h, 06h, texto_restart ; print texto restart print_string 0Ah, 06h, texto_return_main_menu ; print texto return main menu ; espera por um caracter mov ah, 00h int 16h ; salva o caracter em al cmp al, 'r' je restart_game cmp al, 'R' je restart_game cmp al, 'm' je sair_para_menu cmp al, 'M' je sair_para_menu ret restart_game: mov al, 01h mov [game_status], al ; game_status = 1 | retorna o jogo ret sair_para_menu: mov al, 00h mov [game_status], al ; game_status = 0 | o jogo para mov [tela_atual], al print_main_menu: call limpar_tela print_string 04h, 06h, texto_main_menu ; print texto main menu print_string 06h, 06h, texto_jogar ; print texto jogar print_string 08h, 06h, texto_sair_jogo ; print texto sair do jogo print_string 0Eh, 06h, texto_jogador_1 ; print texto jogador 1 print_string 10h, 08h, texto_inst_jogador_1 ; print texto inst jogador 1 print_string 12h, 06h, texto_jogador_2 ; print texto jogador 2 print_string 14h, 08h, texto_inst_jogador_2 ; print texto int jogador 2 .espera_tecla: ; espera por um caracter mov ah, 00h int 16h ; salva o caracter em al cmp al, 'p' je jogar cmp al, 'P' je jogar cmp al, 'n' je end cmp al, 'N' je end jmp .espera_tecla jogar: mov al, 1 mov [game_status], al mov [tela_atual], al ret limpar_tela: ; chama o modo vídeo mov ah, 00h ; set video mode mov al, 13h ; escolhe o video mode int 10h ; executa ; chama o fundo preto mov ah, 0Bh ; setando a configuracao mov bh, 00h ; para a cor de fundo mov bl, 00h ; escholhendo preto int 10h ret inv_vel_X: ; inverte a velocidade em X mov ax, [bola_vel_X] neg ax mov [bola_vel_X], ax call mudar_cor ret inv_vel_Y: ; inverte a velocidade em Y caso bata na parede mov ax, [bola_vel_Y] neg ax mov [bola_vel_Y], ax call mudar_cor ret inv_vel_Y_gol: ; inverte a velocidade em Y caso haja gol mov ax, [bola_vel_Y] neg ax mov [bola_vel_Y], ax jmp pass reset_bola: ; a bola volta para a posição X de origem mov ax, [bola_origem_X] mov [bola_X], ax ; a bola volta para a posicao Y de origem mov ax, [bola_origem_Y] mov [bola_Y], ax ; a barra esquerda volta para a posicao inicial mov ax, 0Ah mov [barra_esquerda_X], ax mov [barra_esquerda_Y], ax ; a barra direita volta para a posicao inicial mov ax, 132h mov [barra_direita_X], ax mov ax, 0A0h mov [barra_direita_Y], ax xor ax, ax cmp [bola_vel_X], ax jl teste_inv_1 jg teste_inv_2 ; serve para o jogo reiniciar de modo que os jogadores sempre consigam pegar a primeira bola ; se V_X < 0 && V_Y < 0, inverte teste_inv_1: xor ax, ax cmp [bola_vel_Y], ax jl inv_vel_Y_gol jmp pass ; se V_X > 0 && V_Y > 0, inverte teste_inv_2: xor ax, ax cmp [bola_vel_Y], ax jg inv_vel_Y_gol jmp pass pass: call inv_vel_X ret pontuar_jogador_um: mov al, [barra_esquerda_pontos] ; pontua o jogador um inc al mov [barra_esquerda_pontos], al call reset_bola ; bola volta para o início call atualiza_texto_jogador_um ; Atualiza a pontuação na tela do jogador 1 ; checa se o jogador dois fez 5 pontos mov al, [barra_esquerda_pontos] cmp al, 05h je game_over ret pontuar_jogador_dois: mov al, [barra_direita_pontos] ; pontua jogador dois inc al mov [barra_direita_pontos], al call reset_bola ; bola volta para o início call atualiza_texto_jogador_dois ; Atualiza a pontuação na tela do jogador 2 ; checa se o jogador dois fez 5 pontos mov al, [barra_direita_pontos] cmp al, 05h je game_over ret game_over: ; quando um jogador fizer 5 pontos mov al, 05h cmp [barra_esquerda_pontos], al ; se o jogador 1 fez 5 pontos je jogador_um_venceu ; o jogador 1 ganhou jne jogador_dois_venceu ; se não, o jogador 2 ganhou jogador_um_venceu: mov byte[winner_status], 01h ; winner_status = 1 jmp continua_game_over ; pula para o resto do game over jogador_dois_venceu: mov byte[winner_status], 02h ; winner status = 2 jmp continua_game_over ; pula para o resto do game over continua_game_over: mov byte [barra_esquerda_pontos], 00h ; zera os pontos do primeiro jogador mov byte [barra_direita_pontos], 00h ; zera os pontos do segundo jogador call atualiza_texto_jogador_um ; atualiza o texto do jogador 1 call atualiza_texto_jogador_dois ; atualiza o texto do jogador 2 xor al, al mov [game_status], al ; game status = 0 -> o jogo acabou ret mover_bola: ; movendo a bola em X mov ax, [bola_vel_X] add [bola_X], ax ; se bola_X < margem_erro(6) ; entao, a bola volta para o inicio mov ax, [margem_erro] cmp [bola_X], ax jl pontuar_jogador_dois ; se bola_X > (tela_largura - bola_size - margem de erro) ; entao, a bola volta para o inicio mov ax, [tela_largura] sub ax, [bola_size] sub ax, [margem_erro] cmp [bola_X], ax jg pontuar_jogador_um ; movendo a bola em Y mov ax, [bola_vel_Y] add [bola_Y], ax ; se bola_Y < margem_erro ; entao, inverte a velocidade Y mov ax, [margem_erro] cmp [bola_Y], ax jl inv_vel_Y ; se bola_Y > tela_largura - bola_size - margem_erro ; entao, inverte vel Y mov ax, [tela_altura] sub ax, [bola_size] sub ax, [margem_erro] cmp [bola_Y], ax jg inv_vel_Y ; checa se a bola colide com a barra direita ; bola_x + bola_size > barra_direita_X mov ax, [bola_X] add ax, [bola_size] cmp ax, [barra_direita_X] jng check_colisao_barra_esquerda ; se não tem colidao com a barra direta, checamos a barra esquerda ; bola_x < barra_direita_X + barra_largura mov ax, [barra_direita_X] add ax, [barra_largura] cmp [bola_X], ax jnl check_colisao_barra_esquerda ; se não tem colidao com a barra direta, checamos a barra esquerda ; bola_Y + bola_size > barra_direita_Y mov ax, [bola_Y] add ax, [bola_size] cmp ax, [barra_direita_Y] jng check_colisao_barra_esquerda ; se não tem colidao com a barra direta, checamos a barra esquerda ; bola_Y < barra_direita_Y + barra_altura mov ax, [barra_direita_Y] add ax, [barra_altura] cmp [bola_Y], ax jnl check_colisao_barra_esquerda ; se não tem colidao com a barra direta, checamos a barra esquerda ; se chegar até aqui, houve colisão com a barra direita ; inverte a velocidade da bola na direção X mov al, [bola_cor] ; muda a cor da barra direita mov [barra_direita_cor], al mov ax, [bola_vel_X] neg ax mov [bola_vel_X], ax ret check_colisao_barra_esquerda: ; checa se a bola colide com a barra esquerda mov ax, [bola_X] add ax, [bola_size] cmp ax, [barra_esquerda_X] jng exit_check_colisao_barra ; se não tem colidao com a barra direta, checamos a barra esquerda ; bola_x < barra_esquerda_X + barra_largura mov ax, [barra_esquerda_X] add ax, [barra_largura] cmp [bola_X], ax jnl exit_check_colisao_barra ; se não tem colidao com a barra direta, checamos a barra esquerda ; bola_Y + bola_size > barra_esquerda_Y mov ax, [bola_Y] add ax, [bola_size] cmp ax, [barra_esquerda_Y] jng exit_check_colisao_barra ; se não tem colidao com a barra direta, checamos a barra esquerda ; bola_Y < barra_esquerda_Y + barra_altura mov ax, [barra_esquerda_Y] add ax, [barra_altura] cmp [bola_Y], ax jnl exit_check_colisao_barra ; se não tem colidao com a barra direta, checamos a barra esquerda ; se chegar até aqui, houve colisão com a barra esquerda ; inverte a velocidade da bola na direção X mov al, [bola_cor] ; muda a cor da barra esquerda mov [barra_esquerda_cor], al mov ax, [bola_vel_X] neg ax mov [bola_vel_X], ax ret exit_check_colisao_barra: ret mover_barras: ; move as barras verticalmente ; barra esquerda ; checar de alguma tecla foi pressionada(se nao, checa a outra barra) mov ah, 01h int 16h jz check_mov_barra_direita ; zf = 1 -> jz pula se for 1 ; checar qual tecla foi pressionada (AL = ASCII character) mov ah, 00h int 16h ; se foi 'w' ou 'W' move para cima cmp al, 77h ; 'w' je mover_barra_esquerda_cima cmp al, 57h ; 'W' je mover_barra_esquerda_cima ; se foi 's' ou 'S' move para baixo cmp al, 73h ; 's' je mover_barra_esquerda_baixo cmp al, 53h ; 'S' je mover_barra_esquerda_baixo jmp check_mov_barra_direita ret mover_barra_esquerda_cima: ; move a barra esquerda para cima mov ax, [barra_vel] sub [barra_esquerda_Y], ax ; checa se o movimento é valido mov ax, [margem_erro] cmp [barra_esquerda_Y], ax jl fix_barra_esquerda_cima jmp check_mov_barra_direita ret fix_barra_esquerda_cima: ; conserta o movimento caso não seja válido mov ax, [margem_erro] mov [barra_esquerda_Y], ax jmp check_mov_barra_direita mover_barra_esquerda_baixo: ; move a barra esquerda para baixo mov ax, [barra_vel] add [barra_esquerda_Y], ax ; checa se o movimento é valido mov ax, [tela_altura] sub ax, [margem_erro] sub ax, [barra_altura] cmp [barra_esquerda_Y], ax jg fix_barra_esquerda_baixo jmp check_mov_barra_direita ret fix_barra_esquerda_baixo: ; conserta o movimento caso não seja válido mov ax, [tela_altura] sub ax, [margem_erro] sub ax, [barra_altura] mov [barra_esquerda_Y], ax jmp check_mov_barra_direita ; barra direita check_mov_barra_direita: ; se foi 'o' ou 'O' move para cima cmp al, 6Fh ; 'o' je mover_barra_direita_cima cmp al, 4Fh ; 'O' je mover_barra_direita_cima ; se foi 'l' or 'L' move para baixo cmp al, 6Ch ; 'l' je mover_barra_direita_baixo cmp al, 4Ch ; 'L' je mover_barra_direita_baixo jmp exit_mov_barra mover_barra_direita_cima: ; move a barra direita para cima mov ax, [barra_vel] sub [barra_direita_Y], ax ; checa se o movimento é válido mov ax, [margem_erro] cmp [barra_direita_Y], ax jl fix_barra_direita_cima ret fix_barra_direita_cima: mov ax, [margem_erro] mov [barra_direita_Y], ax ret mover_barra_direita_baixo: ; move a barra direita para baixo mov ax, [barra_vel] add [barra_direita_Y], ax ; checa se o movimento é válido mov ax, [tela_altura] sub ax, [margem_erro] sub ax, [barra_altura] cmp [barra_direita_Y], ax jg fix_barra_direita_baixo ret fix_barra_direita_baixo: ; conserta o movimento caso não seja válido mov ax, [tela_altura] sub ax, [margem_erro] sub ax, [barra_altura] mov [barra_direita_Y], ax ret exit_mov_barra: ret pong_loop: ; gera a sensação de movimento xor al , al cmp [tela_atual], al ; se a tela atual for a de menu je mostra_main_menu ; mostra o menu cmp [game_status], al ; se o jogo acabar je mostra_game_over ; mostra a tela de game over mov ah, 00h ; get system time int 1ah ; cx:dx = numero de ticks de clock desde a meia noite cmp dx, [tempo_aux] ; verifica se o tempo passou (provavelmente 1/100 s) je pong_loop ; o tempo passou mov [tempo_aux], dx ; atualiza o tempo call limpar_tela ; da update na tela para nao deixar "rastro" call mover_bola ; muda as coordenadas da bola call print_bola ; desenha a bola call mover_barras ; move e checa os movimentos validos das barras call print_barra_esquerda ; desenha a barra direita call print_barra_direita ; desenha a barra esquerda call print_UI jmp pong_loop mostra_game_over: call print_game_over_menu jmp pong_loop mostra_main_menu: call print_main_menu jmp pong_loop end: ; Menu do console call menu_console ; Space Invaders ==================================================== ; Talvez dê bug com o sp e o bp %macro space_limpa_tela 0 xor ax, ax mov al, COR_TELA xor di, di mov cx, LARGURA_TELA*ALTURA_TELA ; Tamanho da tela rep stosb %endmacro %macro temporizador_delay 1 mov ax, [CS:TIMER] add ax, %1 ; Incremento em um segundo .wait: cmp [CS:TIMER], ax ; Checo se já se passou um segundo jl .wait %endmacro prep_jogar_space: push 1 ; Primeira fase jmp jogar_space jogar_space: ; Prepara a tela para o jogo --------------------------- xor ax, ax xor bx, bx xor cx, cx mov ax, 0013h ; Modo de vídeo int 10h push 0A000h pop es ; Movendo o ponteiro es para o primeiro pixel da tela pop ax push ax cmp ax, 1 jle print_fase_1 cmp ax, 2 je print_fase_2 cmp ax, 3 je print_fase_3 cmp ax, 4 jge space_ganhou print_fase_1: call space_printa_menu cmp al, 1 je start jmp continua_inic_space print_fase_2: space_limpa_tela print_string 0Ah, 11h, space_fase2 temporizador_delay 30 jmp continua_inic_space print_fase_3: space_limpa_tela print_string 0Ah, 11h, space_fase3 temporizador_delay 30 jmp continua_inic_space continua_inic_space: ; Movendo os sprites iniciais para a memória mov di, space_sprites mov si, space_sprites_bitmaps mov cl, 6 rep movsw lodsd ; Salva 5 barreiras na memoria mov cl, 5 rep stosd ;; Variáveis Iniciais mov cl, 5 ; Array de Aliens e X do Jogador rep movsb xor ax, ax ; Array de Tiros mov cl, 20 rep stosw mov cl, 10 ; Outras variaveis apos o array de tiros rep movsb push es pop ds ; DS = ES pop ax cmp ax, 2 je fase_2 cmp ax, 3 je fase_3 volta_fases: push ax jmp space_loop space_passa_de_fase: pop cx jmp space_prox_fase space_prox_fase: pop ax inc ax push ax xor ax,ax mov ds,ax jmp jogar_space fase_2: mov byte [num_barreiras], 3 mov byte [dist_barreiras], 50 mov byte [move_timer], 15 jmp volta_fases fase_3: mov byte [num_barreiras], 2 mov byte [dist_barreiras], 100 mov byte [move_timer], 12 jmp volta_fases space_printa_menu: pusha space_limpa_tela print_string 02h, 07h, space_texto_main_menu print_string 07h, 0Ch, space_instrucoes1 print_string 09h, 05h, space_instrucoes2 print_string 0Bh, 09h, space_fases print_string 0Fh, 05h, space_texto_jogar print_string 11h, 05h, space_texto_sair_jogo print_string 13h, 05h, space_texto_controle print_string 15h, 05h, space_texto_tiro print_string 17h, 05h, space_texto_reset .espera_tecla: mov ah, 00h int 16h cmp al, 's' je .jogar cmp al, 'S' je .jogar cmp al, 'n' je .end cmp al, 'N' je .end jmp .espera_tecla .jogar: popa space_limpa_tela print_string 0Ah, 11h, space_fase1 temporizador_delay 30 mov al,0 ret .end: popa mov al,1 ret space_loop: ; Loop principal do jogo -------------------------------- space_limpa_tela ; Pinta a tela com a cor em al ; Desenhar Aliens ------------------------------ mov si, aliens_array mov bl, COR_ALIEN mov al, [alien_y] ; AL = alien_y, AH = alien_x mov ah, [alien_x] mov cl, 4 ; Numero de linhas cmp byte [muda_alien], 0 ; Booleano para mudar o sprite do alien jg desenha_linha_aliens ; Se não, use o sprite normal add di, 4 ; Se sim, use o sprite alternativo desenha_linha_aliens: pusha ; Salvando os registradores mov cl, 8 ; 8 colunas .checa_alien: pusha dec cx bt [si],cx ; Verifica se o bit está "ligado" (resultado no registrador de carry) jnc .prox_alien ; Se não (alien morreu), não desenhe mov si,di ; Sprite atual do alien em SI call space_desenha_sprite .prox_alien: popa ; Retorna os registradores para suas posições iniciais add ah, LARGURA_SPRITE + 4 ; 4 Pixels de distância, ah guarda o x .muda_cor: inc bl cmp bl, 8 je .muda_cor cmp bl, COR_TELA je .muda_cor cmp bl, COR_BARREIRA je .muda_cor cmp bl, COR_JOGADOR je .muda_cor cmp bl, COR_TIRO_ALIEN je .muda_cor cmp bl, COR_TIRO_PLAYER je .muda_cor loop .checa_alien ; Loop roda "CL" vezes popa add al, ALTURA_SPRITE + 2 ; 2 Pixels de distância, al guarda o y inc si loop desenha_linha_aliens ; Loop roda "CL" vezes (por isso o popa) ; Desenhar Jogador ----------------------------- mov ah, [jogador_x] mov al, JOGADOR_Y mov si, jogador mov bl, COR_JOGADOR call space_desenha_sprite ; Desenhar Barreiras --------------------------- mov ah, BARREIRA_X mov al, BARREIRA_Y mov si, barreiras_array mov bl, COR_BARREIRA mov cl, [num_barreiras] desenha_barreiras: pusha call space_desenha_sprite popa add ah, [dist_barreiras] add si, ALTURA_SPRITE loop desenha_barreiras ; Checar se o tiro acertou algo ---------------- mov si, tiros_array mov cl, 20 get_prox_tiro: push cx lodsw ; Y/X em AL e AH cmp al, 0 jnz check_tiro prox_tiro: pop cx loop get_prox_tiro jmp cria_tiro_aliens check_tiro: call space_posicao_na_tela mov al, [di] ; Acertou Jogador cmp al, COR_JOGADOR je space_game_over xor bx,bx ; Acertou Barreira cmp al, COR_BARREIRA jne .check_acertou_alien mov bx, barreiras_array mov ah, BARREIRA_X + LARGURA_SPRITE .check_barreira_loop: cmp dh, ah ; DX salva a posição x e y do tiro ja .prox_barreira sub ah, LARGURA_SPRITE ; Valor X inicial da barreira sub dh, ah ; Subtract from shot X pusha sub dl, BARREIRA_Y ; Tira a diferença para o primeiro pixel da barreira add bl, dl ; BX agora aponta para a linha do pixel atingido mov al, 7 sub al, dh ; cbw ; AH = 0 btr [bx], ax ; BIT TESTE e RESETA o pixel mov byte [si-2], 0 ; Reseta o valor de Y do tiro para 0 popa jmp prox_tiro .prox_barreira: add ah, [dist_barreiras] add bl, ALTURA_SPRITE ; Proxima barreira no array jmp .check_barreira_loop ; Acertou Alien .check_acertou_alien: cmp cl,17 ; É o tiro do player? jl desenha_tiro cmp al, COR_TIRO_ALIEN je desenha_tiro cmp al, COR_TELA je desenha_tiro mov bx, aliens_array mov al, [alien_y] mov ah, [alien_x] add al, ALTURA_SPRITE ; Fundo do sprite .get_linha_alien: cmp dl, al ; Compara y_tiro com o y da linha atual jg .prox_linha mov cl, 8 ; Numero de aliens/linha add ah, LARGURA_SPRITE ; Lado direito do sprite atual .get_alien: dec cx cmp dh, ah ja .prox_alien ; Alien certo btr [bx], cx ; Reseta o bit no array de aliens mov byte [si-2], 0 ; Reseta o valor Y do tiro dec byte [aliens_num] ; aliens_num - 1 jz space_passa_de_fase ; Ultimo alien morreu, você passou de fase! jmp prox_tiro .prox_alien: add ah, LARGURA_SPRITE + 4 jmp .get_alien .prox_linha: add al, ALTURA_SPRITE + 2 inc bx jmp .get_linha_alien ; Desenhar Tiros ------------------------------ desenha_tiro: mov bh, COR_TIRO_PLAYER mov al,[si-2] ; Shaenanigans, acontece que por conta de um lodsw [...] ; [..] si é movido 2 bytes (word) dec ax ; Mover para cima (tiro do player) cmp cl,17 ; Se cl == 4, significa que o loop de checar os tiros está na posição 4 (player) jge .desenha ; Se sim, desenhe mov bh, COR_TIRO_ALIEN ; Se não, tiro do alien add ax,2 ; ax = ax - 1 ali em cima, adiciona 2 pra virar ax + 2 (move pra baixo) cmp al, ALTURA_TELA/2 ; Escala, comparando se atingiu a tela cmovge ax, bx ; Se sim, zera AX .desenha: mov byte [si-2],al mov bl, bh xchg ax, bx ; Cor em AX mov [di+LARGURA_TELA], ax ; Desenha 2 pixels 1 linha abaixo (mvoe) stosw ; desenha 2 pixels na linha atual jmp prox_tiro ; Criar Tiros dos Aliens ---------------------- cria_tiro_aliens: mov si, tiros_array add si, 8 ; Primeiro tiro alien mov cl, 16 .checa_tiro: mov di, si ; Carregar os valores de X e Y lodsw ; AX = Y/X cmp al, 0 ; Y = 0? Já foi atirado jg .prox_tiro ; PSEUDO - RANDOM mov ax, [CS:TIMER] imul ax, ax, 57667 add ax, 27337 and ax, 7h ; 0 - 7 imul ax, ax,LARGURA_SPRITE + 4 ; X que o tiro vai sair xchg ah,al ; AL = Y add ax, [alien_y] pusha call space_posicao_na_tela cmp byte [di], COR_TELA je .reset popa stosw ; Move pra o array de tiros jmp move_alien .reset: popa .prox_tiro: loop .checa_tiro ; Mover Aliens -------------------------------- move_alien: mov di, alien_x inc byte [cur_moves] mov al, [cur_moves] cmp al, [move_timer] jl space_get_input neg byte [muda_alien] mov byte [cur_moves], 0 mov al, [aliens_direcao] add byte [di],al jg .checa_direita mov byte [di],0 jmp .move_baixo .checa_direita: mov al, 68 cmp [di], al ; Bateu no lado direito? jle space_get_input ; Não stosb ; Sim dec di .move_baixo: neg byte [aliens_direcao] ; Move na direção x oposta dec di add byte [di], 4 ; Adiciona no alien_y 5 pixels para baixo cmp byte [di], BARREIRA_Y ; Eles acertaram a barreira? jg space_game_over ; Se sim, game_over dec byte [move_timer] ; Se não, aumenta a velocidade cmp byte [move_timer], 2 jne space_get_input add byte [move_timer], 1 ; Pegar Input do Jogador ---------------------- space_get_input: mov si, jogador_x mov ah, 02h int 16h cmp al,1 je .move_right cmp al,2 je .move_left .resto: mov ah, 01h int 16h jz .fim mov ah, 00h int 16h cmp al,'r' je .reset cmp al,'R' je .reset cmp al, ' ' ; Barra de espaço je .shoot jmp .fim .move_left: sub byte[si], 1 jmp .resto .move_right: add byte[si], 1 jmp .resto .shoot: lodsb ; X do jogador -> AL mov ah, al add ah, 3 ; Mais ou menos no meio da nave mov al, JOGADOR_Y - 1 ; Logo acima do jogador mov si, tiros_array add si, [jogador_pt_tiro] mov [si], ax add byte [jogador_pt_tiro],2 cmp byte [jogador_pt_tiro],8 jne .fim mov byte [jogador_pt_tiro],0 jmp .fim .reset: xor ax,ax mov ds, ax push 1 jmp jogar_space .fim: temporizador_delay 1 jmp space_loop space_game_over: ; Fim de Jogo e Reset space_limpa_tela xor ax,ax mov ds,ax print_string 0Ah,0Fh, space_fim temporizador_delay 30 push 1 jmp jogar_space space_ganhou: space_limpa_tela xor ax,ax mov ds,ax print_string 0Ah,0Fh, space_parabens temporizador_delay 30 push 1 jmp jogar_space ; Desenha um sprite na tela ; Registradores: ; SI -> Endereço do sprite ; AL -> Posição Y ; AH -> Posição X ; BL -> Cor space_desenha_sprite: ; Desenha um bloco de 4 pixels, por pixel call space_posicao_na_tela ; Recebe a posição em DI mov cl, ALTURA_SPRITE ; Loop para desenhar .prox_linha: push cx lodsb ; AL = Prox Byte a ser desenhado (Já incrementa SI) mov dx,ax ; DX recebe AX mov cl, LARGURA_SPRITE ; Segundo loop para desenhar .prox_pixel: mov ax, [COR_TELA] ; Se o bit for setado, printe a cor da tela dec cx bt dx, cx ; Compara bitwise na posição cx cmovc ax, bx ; Se o bit for 1, pinte o pixel com a cor em BL mov ah, al ; Copia a cor mov [di + LARGURA_TELA], ax ; Colore o pixel stosw ; Move o ponteiro jnz .prox_pixel ; Se ainda houverem pixels para pintar na linha, loop add di, LARGURA_TELA * 2 - LARGURA_SPRITE_P ; Move o ponteiro pra pra proxima linha pop cx loop .prox_linha ret ; Devolve a posição X/Y em DI ; Registradores: ; AL -> Posição Y ; AH -> Posição X space_posicao_na_tela: mov dx, ax ; Salva os valores de posição em DX cbw imul di, ax, LARGURA_TELA * 2 ; A tela é um vetor que cresce na direção x, então para cada "Y" temos LARGURA TELA_PIXELS mov al, dh ; AX = Y (Antigo AH que agora é 0) shl ax, 1 ; AX = AX * 2 (Escala) add di, ax ; DI agora terá exatamente o pixel onde o sprite deve ser desenhado ret space_sprites_bitmaps: db 10011001b ; Alien 1 bitmap db 01011010b db 00111100b db 01000010b db 00011000b ; Alien 2 bitmap db 01011010b db 10111101b db 00100100b db 00011000b ; Jogador bitmap db 00111100b db 00100100b db 01100110b db 00111100b ; Barreira bitmap db 01111110b db 11100111b db 11100111b dw 0FFFFh ; Alien array dw 0FFFFh db 75 ; player_x dw 230Ah ; alien_y e alien x | 10 = Y, 35 = X db 20h ; num de aliens = 32 db 0FBh ; Direção = -5 dw 18 ; 18 Ticks para mover os aliens db 1 ; Muda o alien - entre 1 e -1 db 25 ; Distancia barreiars db 5 ; Num Barreiras db 0 db 0 ;Snake ---------------------------------------------------------------- print_instrucoes_snake: call limpar_tela print_string 02h, 06h, snake_texto_main_menu ; print texto main menu print_string 06h, 06h, snake_instrucoes1 ; print texto inst print_string 08h, 06h, snake_instrucoes2 ; print texto inst continuação print_string 0Eh, 06h, snake_texto_jogar ; print texto jogar print_string 10h, 06h, snake_texto_sair_jogo ; print texto sair do jogo print_string 12h, 08h, snake_texto_controle ; print texto controles .espera_tecla: ; espera por um caracter mov ah, 00h int 16h ; salva o caracter em al cmp al, 't' je .end_espera cmp al, 'T' je .end_espera cmp al, 'n' je end cmp al, 'N' je end jmp .espera_tecla .end_espera: ret print_cobra: ; Desenhar cobra mov cx, [cobra_x] mov dx, [cobra_y] xor si, si ; indice do array .loop: ;Interando sobre o array cobra e printando as coordenadas principais mov cx, [array_cobra_x + si] mov dx, [array_cobra_y + si] mov ah, 0Ch mov al, 0Ah mov bh, 00h int 10h ;Preenchendo o corpo da cobra inc cx int 10h inc dx dec cx int 10h inc cx int 10h inc si inc si mov dx, [comprimento_da_cobra] add dx, [comprimento_da_cobra] cmp si, dx jne .loop ret reset_cor_objeto: mov al, 1 mov [cor_do_objeto], al ret jump_grey: mov al, 9 mov [cor_do_objeto], al ret mudar_cor_objeto: mov al, [cor_do_objeto] inc al mov [cor_do_objeto], al ; Selecionar cores de 1-15, menos 7 e 8 que são cinza mov ah, 16 cmp [cor_do_objeto], ah jge reset_cor_objeto mov ah, 7 cmp [cor_do_objeto], ah je jump_grey ret print_objeto: ; Desenhar objeto mov cx, [objeto_x] mov dx, [objeto_y] print_obj [objeto_x], [objeto_y], 3, 3, [cor_do_objeto] ret setar_variaveis_snake: mov word [cobra_x], 0A0h mov word [cobra_y], 064h mov word [comprimento_da_cobra], 5 mov word [largura_da_cobra], 5 mov word [direcao], 4 mov word [points], 0 ret setup_snake: call print_instrucoes_snake call limpar_tela call setar_variaveis_snake ; Colocar as coordenadas iniciais da cobra no array que ; armazena as coordenadas de todos os segmentos mov ax, [cobra_x] mov word [array_cobra_x], ax mov ax, [cobra_y] mov word [array_cobra_y], ax snake_loop: call limpar_tela mov ax, 00h ; setar o fundo a cada iteracao call print_cobra call print_objeto call print_boundaries mov al, [direcao] cmp al, UP je move_up mov al, [direcao] cmp al, DOWN je move_down mov al, [direcao] cmp al, LEFT je move_left mov al, [direcao] cmp al, RIGHT je move_right jmp update_snake move_up: sub word [cobra_y], 2 jmp update_snake move_down: add word [cobra_y], 2 jmp update_snake move_left: sub word [cobra_x], 2 jmp update_snake move_right: add word [cobra_x], 2 jmp update_snake update_snake: ; atualizar a posicao da cobra de acordo com o input do usuario imul bx, [comprimento_da_cobra], 2 ; cada elemento do array tem 2 bytes .update_loop: ; Gera a sensação de movimento percorrendo o corpo da cobra mov ax, [array_cobra_x - 2 + bx] mov word [array_cobra_x + bx], ax mov ax, [array_cobra_y - 2 + bx] mov word [array_cobra_y + bx], ax dec bx dec bx jnz .update_loop ; Atualiza os valores da cabeca da cobra no array mov ax, [cobra_x] mov word [array_cobra_x], ax mov ax, [cobra_y] mov word [array_cobra_y], ax ; Condicoes para perder ; Bater na borda cmp word [cobra_y], -1 ; Borda superior jle game_over_snake mov bx, [tela_altura] cmp word [cobra_y], bx ; Borda inferior je game_over_snake cmp word [cobra_x], -1 ; Esquerda da tela jle game_over_snake mov bx, [tela_largura] cmp word [cobra_x], bx ; Direita da tela jge game_over_snake ; Bater na propria cobra cmp word [comprimento_da_cobra], 5 ; So tem o segmento inicial je input_cobra mov bx, 2 ; Index do array, comeca no segundo elemento do array mov cx, [comprimento_da_cobra] ; Contador de loop check_hit_snake_loop: ; Checar se a cobra bateu nela mesma mov ax, [cobra_x] cmp ax, [array_cobra_x + bx] jne .increment mov ax, [cobra_y] cmp ax, [array_cobra_y + bx] je game_over_snake .increment: inc bx inc bx loop check_hit_snake_loop input_cobra: mov bl, [direcao] ; Salvar a direcao atual mov ah, 1 int 16h ; Pegar o status do teclado jz checar_objeto ; Se nenhuma tecla foi pressionada, so segue xor ah, ah int 16h cmp al, 'w' je w_pressed cmp al, 's' je s_pressed cmp al, 'a' je a_pressed cmp al, 'd' je d_pressed jmp checar_objeto w_pressed: mov bl, UP jmp checar_objeto s_pressed: mov bl, DOWN jmp checar_objeto a_pressed: mov bl, LEFT jmp checar_objeto d_pressed: mov bl, RIGHT checar_objeto: mov byte [direcao], bl ; Atualizar posicao ; Checar de existe sobreposicao entre do objeto e da cobra com uma margem de erro mov ax, [objeto_x] add ax, 3 cmp ax, [cobra_x] jng delay_loop mov ax, [cobra_x] add ax, [largura_da_cobra] cmp [objeto_x], ax jnl delay_loop mov ax, [objeto_y] add ax, 3 cmp ax, [cobra_y] jng delay_loop mov ax, [cobra_y] add ax, [comprimento_da_cobra] cmp [objeto_y], ax jnl delay_loop ; Se bateu no objeto, incrementa o tamanho da cobra ; E aumenta a pontuação add word [comprimento_da_cobra], 2 inc word [points] mov ax, [points] cmp ax, [win_points] jge game_won_snake ; Nao ganhou, entao gere outro objeto call mudar_cor_objeto proximo_objeto: ; Pegar uma posicao pseudoaleatoria para o objeto aparecer a seguir xor ah, ah int 1ah ; Pegar os ticks de relogio desde a meia-noite mov ax, dx xor dx, dx mov cx, [tela_largura] div cx ; (dx/ax) / cx; ax = quociente, dx = resto mov word [objeto_x], dx xor ah, ah int 1ah ; Pegar os ticks de relogio desde a meia-noite mov ax, dx xor dx, dx mov cx, [tela_altura] div cx mov word [objeto_y], dx ; Checar se o objeto foi gerado "dentro" da cobra xor bx, bx ; index do array mov cx, [comprimento_da_cobra] ; contador do loop .check_loop: mov ax, [objeto_x] cmp ax, [array_cobra_x + bx] jne .increment mov ax, [objeto_y] cmp ax, [array_cobra_y + bx] je proximo_objeto .increment: inc bx inc bx loop .check_loop delay_loop: ; Para não ficar piscando freneticamente mov bx, [TIMER] add bx, 2 .delay: cmp [TIMER], bx jl .delay jmp snake_loop game_won_snake: call limpar_tela print_string 06h, 08h, snake_parabens ; print texto ganhou print_string 08h, 08h, snake_ganhou print_string 12h, 08h, snake_return xor ah, ah int 16h cmp al, 'e' je menu_console jmp game_won_snake game_over_snake: call limpar_tela print_string 06h, 08h, snake_fim ; print texto perdeu print_string 08h, 08h, snake_return xor ah, ah int 16h cmp al, 'e' je menu_console jmp game_over_snake start: xor ax, ax mov ds, ax call limpar_tela ; executa a configuração de video inicial jmp menu_console times 63*512-($-$$) db 0 jmp $ dw 0xaa55
/********** This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA **********/ // "liveMedia" // Copyright (c) 1996-2008 Live Networks, Inc. All rights reserved. // A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s // on demand, from a MPEG-4 video file. // Implementation #include "MPEG4VideoFileServerMediaSubsession.hh" #include "MPEG4ESVideoRTPSink.hh" #include "ByteStreamFileSource.hh" #include "MPEG4VideoStreamFramer.hh" MPEG4VideoFileServerMediaSubsession* MPEG4VideoFileServerMediaSubsession::createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource) { return new MPEG4VideoFileServerMediaSubsession(env, fileName, reuseFirstSource); } MPEG4VideoFileServerMediaSubsession ::MPEG4VideoFileServerMediaSubsession(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource) : FileServerMediaSubsession(env, fileName, reuseFirstSource), fDoneFlag(0) { } MPEG4VideoFileServerMediaSubsession ::~MPEG4VideoFileServerMediaSubsession() { } static void afterPlayingDummy(void* clientData) { MPEG4VideoFileServerMediaSubsession* subsess = (MPEG4VideoFileServerMediaSubsession*)clientData; subsess->afterPlayingDummy1(); } void MPEG4VideoFileServerMediaSubsession::afterPlayingDummy1() { // Unschedule any pending 'checking' task: envir().taskScheduler().unscheduleDelayedTask(nextTask()); // Signal the event loop that we're done: setDoneFlag(); } static void checkForAuxSDPLine(void* clientData) { MPEG4VideoFileServerMediaSubsession* subsess = (MPEG4VideoFileServerMediaSubsession*)clientData; subsess->checkForAuxSDPLine1(); } void MPEG4VideoFileServerMediaSubsession::checkForAuxSDPLine1() { if (fDummyRTPSink->auxSDPLine() != NULL) { // Signal the event loop that we're done: setDoneFlag(); } else { // try again after a brief delay: int uSecsToDelay = 100000; // 100 ms nextTask() = envir().taskScheduler().scheduleDelayedTask(uSecsToDelay, (TaskFunc*)checkForAuxSDPLine, this); } } char const* MPEG4VideoFileServerMediaSubsession ::getAuxSDPLine(RTPSink* rtpSink, FramedSource* inputSource) { // Note: For MPEG-4 video files, the 'config' information isn't known // until we start reading the file. This means that "rtpSink"s // "auxSDPLine()" will be NULL initially, and we need to start reading // data from our file until this changes. fDummyRTPSink = rtpSink; // Start reading the file: fDummyRTPSink->startPlaying(*inputSource, afterPlayingDummy, this); // Check whether the sink's 'auxSDPLine()' is ready: checkForAuxSDPLine(this); envir().taskScheduler().doEventLoop(&fDoneFlag); char const* auxSDPLine = fDummyRTPSink->auxSDPLine(); return auxSDPLine; } FramedSource* MPEG4VideoFileServerMediaSubsession ::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) { estBitrate = 500; // kbps, estimate // Create the video source: ByteStreamFileSource* fileSource = ByteStreamFileSource::createNew(envir(), fFileName); if (fileSource == NULL) return NULL; fFileSize = fileSource->fileSize(); // Create a framer for the Video Elementary Stream: return MPEG4VideoStreamFramer::createNew(envir(), fileSource); } RTPSink* MPEG4VideoFileServerMediaSubsession ::createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource* /*inputSource*/) { return MPEG4ESVideoRTPSink::createNew(envir(), rtpGroupsock, rtpPayloadTypeIfDynamic); }
section sprite xdef mes_cd_prev mes_cd_prev 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_prev_spr' sp_btn_cur incbin 'win1_util_sprite_cd_prev2_spr' end
// Copyright 2018 The Chromium 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 "chrome/browser/ash/login/quick_unlock/auth_token.h" #include "base/bind.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "chromeos/login/auth/user_context.h" namespace chromeos { namespace quick_unlock { const int AuthToken::kTokenExpirationSeconds = 5 * 60; AuthToken::AuthToken(const chromeos::UserContext& user_context) : identifier_(base::UnguessableToken::Create()), creation_time_(base::TimeTicks::Now()), user_context_(std::make_unique<chromeos::UserContext>(user_context)) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::BindOnce(&AuthToken::Reset, weak_factory_.GetWeakPtr()), base::TimeDelta::FromSeconds(kTokenExpirationSeconds)); } AuthToken::~AuthToken() = default; absl::optional<std::string> AuthToken::Identifier() const { if (!user_context_) return absl::nullopt; return identifier_.ToString(); } absl::optional<base::TimeDelta> AuthToken::GetAge() const { if (!user_context_) return absl::nullopt; return base::TimeTicks::Now() - creation_time_; } void AuthToken::Reset() { if (user_context_) user_context_->ClearSecrets(); user_context_.reset(); } } // namespace quick_unlock } // namespace chromeos
; struct sp1_update __CALLEE__ *sp1_GetUpdateStruct_callee(uchar row, uchar col) ; 02.2008 aralbrec, Sprite Pack v3.0 ; zx81 hi-res version INCLUDE "zx81hr/customize.asm" SECTION code_sprite_sp1 PUBLIC sp1_GetUpdateStruct_callee PUBLIC ASMDISP_SP1_GETUPDATESTRUCT_CALLEE .sp1_GetUpdateStruct_callee pop hl pop de ex (sp),hl ld d,l .asmentry ; Return struct_sp1_update for row,col coordinate given ; 9 * (SP1V_DISPWIDTH * ROW + COL) + SP1V_UPDATEARRAY ; ; enter : d = row coord ; e = col coord ; exit : hl = struct update * ; uses : af, de, hl .SP1GetUpdateStruct ld l,d ld h,0 ld a,d ld d,h cp SP1V_DISPHEIGHT jp c, nohtadj dec h .nohtadj IF SP1V_DISPWIDTH=16 add hl,hl add hl,hl add hl,hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de ; hl = 16 * ROW + COL ENDIF IF SP1V_DISPWIDTH=24 add hl,hl add hl,hl add hl,hl push hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de pop de add hl,de ; hl = 24 * ROW + COL ENDIF IF SP1V_DISPWIDTH=32 add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de ; hl = 32 * ROW + COL ENDIF IF SP1V_DISPWIDTH=40 add hl,hl add hl,hl add hl,hl push hl add hl,hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de pop de add hl,de ; hl = 40 * ROW + COL ENDIF IF SP1V_DISPWIDTH=48 add hl,hl add hl,hl add hl,hl add hl,hl push hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de pop de add hl,de ; hl = 48 * ROW + COL ENDIF IF SP1V_DISPWIDTH=56 add hl,hl add hl,hl add hl,hl push hl add hl,hl push hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de pop de add hl,de pop de add hl,de ; hl = 56 * ROW + COL ENDIF IF SP1V_DISPWIDTH=64 add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl ld a,e cp SP1V_DISPWIDTH jp c, nowiadj dec d .nowiadj add hl,de ; hl = 64 * ROW + COL ENDIF ld d,h ld e,l add hl,hl add hl,hl add hl,hl add hl,de ; hl = 9 * (SP1V_DISPWIDTH * ROW + COL) ld de,SP1V_UPDATEARRAY add hl,de ret DEFC ASMDISP_SP1_GETUPDATESTRUCT_CALLEE = asmentry - sp1_GetUpdateStruct_callee
SECTION code_fp_am9511 PUBLIC tan_fastcall EXTERN asm_am9511_tan_fastcall defc tan_fastcall = asm_am9511_tan_fastcall ; SDCC bridge for Classic IF __CLASSIC PUBLIC _tan_fastcall defc _tan_fastcall = asm_am9511_tan_fastcall ENDIF
.MACRO joypad_event lda \3 ; read joypad bit #\1 bne + stz LKS_STDCTRL + \2 bra ++ +: lda LKS_STDCTRL + \2 cmp #$00 bne + lda #01 sta LKS_STDCTRL + \2 bra ++ +: lda #02 sta LKS_STDCTRL + \2 ++: .ENDM .DEFINE _A $00 .DEFINE _B $01 .DEFINE _Y $02 .DEFINE _X $03 .DEFINE _L $04 .DEFINE _R $05 .DEFINE _START $06 .DEFINE _SELECT $07 .DEFINE _RIGHT $08 .DEFINE _LEFT $09 .DEFINE _DOWN $0A .DEFINE _UP $0B .DEFINE _J1C $0C .DEFINE _J2C $1C .DEFINE _STDCONTROL1L $0E .DEFINE _STDCONTROL1H $0F .DEFINE _J1 $00 .DEFINE _J2 $10 .DEFINE _J3 $20 .DEFINE _J4 $30 .DEFINE LKS_DOWN $01 .DEFINE LKS_DOWNS $02 .DEFINE LKS_UP $03
; A256646: 26-gonal pyramidal numbers: a(n) = n*(n+1)*(8*n-7)/2. ; 0,1,27,102,250,495,861,1372,2052,2925,4015,5346,6942,8827,11025,13560,16456,19737,23427,27550,32130,37191,42757,48852,55500,62725,70551,79002,88102,97875,108345,119536,131472,144177,157675,171990,187146,203167,220077,237900,256660,276381,297087,318802,341550,365355,390241,416232,443352,471625,501075,531726,563602,596727,631125,666820,703836,742197,781927,823050,865590,909571,955017,1001952,1050400,1100385,1151931,1205062,1259802,1316175,1374205,1433916,1495332,1558477,1623375,1690050,1758526 add $0,1 mov $1,$0 bin $0,2 mul $1,8 sub $1,15 mul $0,$1
#include <iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; }
// This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. #include "stdafx.h" #include "afxmenutearoffmanager.h" #include "afxcontrolbarutil.h" #include "afxmenuimages.h" #include "afxpopupmenubar.h" #include "afxcolormenubutton.h" #include "afxcolordialog.h" #include "afxcolorbar.h" #include "afxsettingsstore.h" #include "afxcolorpopupmenu.h" #include "afxglobals.h" #include "afxvisualmanager.h" #ifdef _DEBUG #define new DEBUG_NEW #endif static const int SEPARATOR_SIZE = 2; CMap<UINT,UINT,COLORREF, COLORREF> CMFCColorMenuButton::m_ColorsByID; UINT AFX_WM_GETDOCUMENTCOLORS = ::RegisterWindowMessage(_T("TOOLBAR__GETDOCUMENTCOLORS")); IMPLEMENT_SERIAL(CMFCColorMenuButton, CMFCToolBarMenuButton, VERSIONABLE_SCHEMA | 1) // Construction/Destruction CMFCColorMenuButton::CMFCColorMenuButton() { Initialize(); } CMFCColorMenuButton::CMFCColorMenuButton(UINT uiCmdID, LPCTSTR lpszText, CPalette* pPalette) : CMFCToolBarMenuButton(uiCmdID, NULL, afxCommandManager->GetCmdImage(uiCmdID, FALSE), lpszText) { Initialize(); CMFCColorBar::InitColors(pPalette, m_Colors); m_Color = GetColorByCmdID(uiCmdID); } void CMFCColorMenuButton::Initialize() { m_Color = (COLORREF) -1; // Default(automatic) color m_colorAutomatic = 0; m_nColumns = -1; m_nVertDockColumns = -1; m_nHorzDockRows = -1; m_bIsAutomaticButton = FALSE; m_bIsOtherButton = FALSE; m_bIsDocumentColors = FALSE; m_bStdColorDlg = FALSE; } CMFCColorMenuButton::~CMFCColorMenuButton() { } void CMFCColorMenuButton::EnableAutomaticButton(LPCTSTR lpszLabel, COLORREF colorAutomatic, BOOL bEnable) { m_bIsAutomaticButton = bEnable; if (bEnable) { ENSURE(lpszLabel != NULL); m_strAutomaticButtonLabel = lpszLabel; m_colorAutomatic = colorAutomatic; } } void CMFCColorMenuButton::EnableOtherButton(LPCTSTR lpszLabel, BOOL bAltColorDlg, BOOL bEnable) { m_bIsOtherButton = bEnable; if (bEnable) { ENSURE(lpszLabel != NULL); m_strOtherButtonLabel = lpszLabel; m_bStdColorDlg = !bAltColorDlg; } } void CMFCColorMenuButton::EnableDocumentColors(LPCTSTR lpszLabel, BOOL bEnable) { m_bIsDocumentColors = bEnable; if (bEnable) { ENSURE(lpszLabel != NULL); m_strDocumentColorsLabel = lpszLabel; } } void CMFCColorMenuButton::EnableTearOff(UINT uiID, int nVertDockColumns, int nHorzDockRows) { if (g_pTearOffMenuManager != NULL && g_pTearOffMenuManager->IsDynamicID(uiID)) { ASSERT(FALSE); // SHould be static ID! uiID = 0; } m_uiTearOffBarID = uiID; m_nVertDockColumns = nVertDockColumns; m_nHorzDockRows = nHorzDockRows; } void CMFCColorMenuButton::OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz, BOOL bCustomizeMode, BOOL bHighlight, BOOL bDrawBorder, BOOL bGrayDisabledButtons) { ASSERT_VALID(this); ASSERT_VALID(pDC); CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); if (!IsDrawImage() || pImages == NULL) { return; } CPalette* pOldPalette = NULL; if (GetGlobalData()->m_nBitsPerPixel == 8) // 256 colors { if (m_Palette.GetSafeHandle() == NULL) { // Palette not created yet; create it now CMFCColorBar::CreatePalette(m_Colors, m_Palette); } ENSURE(m_Palette.GetSafeHandle() != NULL); pOldPalette = pDC->SelectPalette(&m_Palette, FALSE); pDC->RealizePalette(); } else if (m_Palette.GetSafeHandle() != NULL) { ::DeleteObject(m_Palette.Detach()); ENSURE(m_Palette.GetSafeHandle() == NULL); } ENSURE(pImages != NULL); CRect rectColor = pImages->GetLastImageRect(); const int nColorBoxSize = CMFCToolBar::IsLargeIcons() && !m_bMenuMode ? 10 : 5; rectColor.top = rectColor.bottom - nColorBoxSize; rectColor.OffsetRect(0, 1); // Draw color bar: BOOL bDrawImageShadow = bHighlight && !bCustomizeMode && CMFCVisualManager::GetInstance()->IsShadowHighlightedImage() && !GetGlobalData()->IsHighContrastMode() && ((m_nStyle & TBBS_PRESSED) == 0) && ((m_nStyle & TBBS_CHECKED) == 0) && ((m_nStyle & TBBS_DISABLED) == 0); if (bDrawImageShadow) { CBrush brShadow(GetGlobalData()->clrBarShadow); pDC->FillRect(rectColor, &brShadow); rectColor.OffsetRect(-1, -1); } COLORREF color = (m_nStyle & TBBS_DISABLED) ? GetGlobalData()->clrBarShadow : (m_Color == (COLORREF)-1 ? m_colorAutomatic : m_Color); CBrush br(PALETTERGB( GetRValue(color), GetGValue(color), GetBValue(color))); CBrush* pOldBrush = pDC->SelectObject(&br); CPen* pOldPen = (CPen*) pDC->SelectStockObject(NULL_PEN); pDC->Rectangle(&rectColor); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); if (CMFCVisualManager::GetInstance()->IsMenuFlatLook()) { if (color == GetGlobalData()->clrBarFace) { pDC->Draw3dRect(rectColor, GetGlobalData()->clrBarDkShadow, GetGlobalData()->clrBarDkShadow); } } else { pDC->Draw3dRect(rectColor, GetGlobalData()->clrBarShadow, GetGlobalData()->clrBarLight); } if (pOldPalette != NULL) { pDC->SelectPalette(pOldPalette, FALSE); } } int CMFCColorMenuButton::OnDrawOnCustomizeList(CDC* pDC, const CRect& rect, BOOL bSelected) { int nID = m_nID; m_nID = 0; // Force draw right arrow CRect rectColor = rect; rectColor.DeflateRect(1, 0); int iRes = CMFCToolBarMenuButton::OnDrawOnCustomizeList(pDC, rect, bSelected); m_nID = nID; return iRes; } void CMFCColorMenuButton::SetColor(COLORREF clr, BOOL bNotify) { m_Color = clr; m_ColorsByID.SetAt(m_nID, m_Color); if (m_pWndParent->GetSafeHwnd() != NULL) { m_pWndParent->InvalidateRect(m_rect); } if (bNotify) { CObList listButtons; if (CMFCToolBar::GetCommandButtons(m_nID, listButtons) > 0) { for (POSITION pos = listButtons.GetHeadPosition(); pos != NULL;) { CMFCColorMenuButton* pOther = DYNAMIC_DOWNCAST(CMFCColorMenuButton, listButtons.GetNext(pos)); if (pOther != NULL && pOther != this) { pOther->SetColor(clr, FALSE); } } } const CObList& lstToolBars = CMFCToolBar::GetAllToolbars(); for (POSITION pos = lstToolBars.GetHeadPosition(); pos != NULL;) { CMFCColorBar* pColorBar = DYNAMIC_DOWNCAST(CMFCColorBar, lstToolBars.GetNext(pos)); if (pColorBar != NULL && pColorBar->m_nCommandID == m_nID) { pColorBar->SetColor(clr); } } } } void CMFCColorMenuButton::OnChangeParentWnd(CWnd* pWndParent) { CMFCToolBarButton::OnChangeParentWnd(pWndParent); if (pWndParent != NULL) { if (pWndParent->IsKindOf(RUNTIME_CLASS(CMFCMenuBar))) { m_bText = TRUE; } if (pWndParent->IsKindOf(RUNTIME_CLASS(CMFCPopupMenuBar))) { m_bMenuMode = TRUE; m_bText = TRUE; } else { m_bMenuMode = FALSE; } } m_bDrawDownArrow = TRUE; m_pWndParent = pWndParent; } void CMFCColorMenuButton::Serialize(CArchive& ar) { CMFCToolBarMenuButton::Serialize(ar); if (ar.IsLoading()) { int nColorsCount; ar >> nColorsCount; m_Colors.SetSize(nColorsCount); for (int i = 0; i < nColorsCount; i++) { COLORREF color; ar >> color; m_Colors [i] = color; } ar >> m_nColumns; ar >> m_nVertDockColumns; ar >> m_nHorzDockRows; ar >> m_bIsAutomaticButton; ar >> m_bIsOtherButton; ar >> m_bIsDocumentColors; ar >> m_strAutomaticButtonLabel; ar >> m_strOtherButtonLabel; ar >> m_strDocumentColorsLabel; ar >> m_colorAutomatic; ar >> m_bStdColorDlg; // Synchromize color with another buttons with the same ID: CObList listButtons; if (CMFCToolBar::GetCommandButtons(m_nID, listButtons) > 0) { for (POSITION pos = listButtons.GetHeadPosition(); pos != NULL;) { CMFCColorMenuButton* pOther = DYNAMIC_DOWNCAST(CMFCColorMenuButton, listButtons.GetNext(pos)); if (pOther != NULL && pOther != this && pOther->m_Color != (COLORREF) -1) { m_Color = pOther->m_Color; } } } } else { ar <<(int) m_Colors.GetSize(); for (int i = 0; i < m_Colors.GetSize(); i++) { ar << m_Colors [i]; } ar << m_nColumns; ar << m_nVertDockColumns; ar << m_nHorzDockRows; ar << m_bIsAutomaticButton; ar << m_bIsOtherButton; ar << m_bIsDocumentColors; ar << m_strAutomaticButtonLabel; ar << m_strOtherButtonLabel; ar << m_strDocumentColorsLabel; ar << m_colorAutomatic; ar << m_bStdColorDlg; } } void CMFCColorMenuButton::CopyFrom(const CMFCToolBarButton& s) { CMFCToolBarMenuButton::CopyFrom(s); const CMFCColorMenuButton& src = (const CMFCColorMenuButton&) s; m_Color = src.m_Color; m_ColorsByID.SetAt(m_nID, m_Color); // Just to be happy :-) m_Colors.SetSize(src.m_Colors.GetSize()); for (int i = 0; i < m_Colors.GetSize(); i++) { m_Colors [i] = src.m_Colors [i]; } m_bIsAutomaticButton = src.m_bIsAutomaticButton; m_colorAutomatic = src.m_colorAutomatic; m_bIsOtherButton = src.m_bIsOtherButton; m_bIsDocumentColors = src.m_bIsDocumentColors; m_strAutomaticButtonLabel = src.m_strAutomaticButtonLabel; m_strOtherButtonLabel = src.m_strOtherButtonLabel; m_strDocumentColorsLabel = src.m_strDocumentColorsLabel; m_nColumns = src.m_nColumns; m_nVertDockColumns = src.m_nVertDockColumns; m_nHorzDockRows = src.m_nHorzDockRows; m_bStdColorDlg = src.m_bStdColorDlg; } BOOL CMFCColorMenuButton::OpenColorDialog(const COLORREF colorDefault, COLORREF& colorRes) { BOOL bResult = FALSE; if (m_bStdColorDlg) { CColorDialog dlg(colorDefault, CC_FULLOPEN | CC_ANYCOLOR); if (dlg.DoModal() == IDOK) { colorRes = dlg.GetColor(); bResult = TRUE; } } else { CMFCColorDialog dlg(colorDefault); if (dlg.DoModal() == IDOK) { colorRes = dlg.GetColor(); bResult = TRUE; } } return bResult; } CMFCPopupMenu* CMFCColorMenuButton::CreatePopupMenu() { CList<COLORREF,COLORREF> lstDocColors; if (m_bIsDocumentColors && m_pWndParent != NULL) { CFrameWnd* pOwner = AFXGetTopLevelFrame(m_pWndParent); ASSERT_VALID(pOwner); // Fill document colors list: pOwner->SendMessage(AFX_WM_GETDOCUMENTCOLORS, (WPARAM) m_nID, (LPARAM) &lstDocColors); } return new CMFCColorPopupMenu(m_Colors, m_Color, (m_bIsAutomaticButton ?(LPCTSTR) m_strAutomaticButtonLabel : NULL), (m_bIsOtherButton ?(LPCTSTR) m_strOtherButtonLabel : NULL), (m_bIsDocumentColors ?(LPCTSTR) m_strDocumentColorsLabel : NULL), lstDocColors, m_nColumns, m_nHorzDockRows, m_nVertDockColumns, m_colorAutomatic, m_nID, m_bStdColorDlg); } void __stdcall CMFCColorMenuButton::SetColorName(COLORREF color, const CString& strName) { CMFCColorBar::m_ColorNames.SetAt(color, strName); } COLORREF __stdcall CMFCColorMenuButton::GetColorByCmdID(UINT uiCmdID) { COLORREF color = (COLORREF)-1; m_ColorsByID.Lookup(uiCmdID, color); return color; }
//////////////////////////////////////////////////////////////////////////////// // This file is distributed under the University of Illinois/NCSA Open Source // License. See LICENSE file in top directory for details. // // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. // // File developed by: // Ken Esler, kpesler@gmail.com, // University of Illinois at Urbana-Champaign // Miguel Morales, moralessilva2@llnl.gov, // Lawrence Livermore National Laboratory // Jeongnim Kim, jeongnim.kim@gmail.com, // University of Illinois at Urbana-Champaign // Jeremy McMinnis, jmcminis@gmail.com, // University of Illinois at Urbana-Champaign // Mark A. Berrill, berrillma@ornl.gov, // Oak Ridge National Laboratory // Alfredo A. Correa, correaa@llnl.gov // Lawrence Livermore National Laboratory // Miguel A. Morales, moralessilva2@llnl.gov // Lawrence Livermore National Laboratory // // File created by: // Jeongnim Kim, jeongnim.kim@gmail.com, // University of Illinois at Urbana-Champaign //////////////////////////////////////////////////////////////////////////////// #ifndef AFQMC_BLAS_CPU_H #define AFQMC_BLAS_CPU_H // generic header for blas routines #include "AFQMC/Numerics/detail/CPU/Blasf.h" #include "AFQMC/config.0.h" #if defined(HAVE_MKL) inline CBLAS_TRANSPOSE cblas_operation(char Op) { if(Op=='N') return CblasNoTrans; else if(Op=='T') return CblasTrans; else if(Op=='H' || Op=='C') return CblasConjTrans; else throw std::runtime_error("unknown cblas_peration option"); } #endif namespace ma { /* static const int INCX = 1; static const int INCY = 1; static const char UPLO = 'L'; static const char TRANS = 'T'; static const char NOTRANS = 'N'; static const float sone = 1.0; static const float szero = 0.0; static const double done = 1.0; static const double dzero = 0.0; static const std::complex<float> cone = std::complex<float>(1.0,0.0); static const std::complex<float> czero = std::complex<float>(0.0,0.0); static const std::complex<double> zone = std::complex<double>(1.0,0.0); static const std::complex<double> zzero = std::complex<double>(0.0,0.0); */ inline static void axpy(int n, double x, const double *a, double *b) { daxpy(n, x, a, INCX, b, INCY); } inline static void axpy(int n, double x, const double *a, int incx, double *b, int incy) { daxpy(n, x, a, incx, b, incy); } inline static void axpy(int n, const double *a, double *b) { daxpy(n, done, a, INCX, b, INCY); } inline static void axpy(int n, float x, const float *a, int incx, float *b, int incy) { saxpy(n, x, a, incx, b, incy); } inline static void axpy(int n, const std::complex<float> x, const std::complex<float> *a, int incx, std::complex<float> *b, int incy) { caxpy(n, x, a, incx, b, incy); } inline static void axpy(int n, const std::complex<double> x, const std::complex<double> *a, int incx, std::complex<double> *b, int incy) { zaxpy(n, x, a, incx, b, incy); } inline static void axpy(int n, const float x, const float *a, int incx, double *b, int incy) { for (int i = 0; i < n; ++i, a+=incx, b+=incy) (*b) += static_cast<double>(x*(*a)); } inline static void axpy(int n, const std::complex<float> x, const std::complex<float> *a, int incx, std::complex<double> *b, int incy) { for (int i = 0; i < n; ++i, a+=incx, b+=incy) (*b) += static_cast<std::complex<double>>(x*(*a)); } inline static double norm2(int n, const double *a, int incx = 1) { return dnrm2(n, a, incx); } inline static double norm2(int n, const std::complex<double> *a, int incx = 1) { return dznrm2(n, a, incx); } inline static float norm2(int n, const float *a, int incx = 1) { return snrm2(n, a, incx); } inline static void scal(int n, float alpha, float *x, int incx = 1) { sscal(n, alpha, x, incx); } inline static void scal(int n, std::complex<float> alpha, std::complex<float> *x, int incx = 1) { cscal(n, alpha, x, incx); } inline static void scal(int n, double alpha, double *x, int incx = 1) { dscal(n, alpha, x, incx); } inline static void scal(int n, std::complex<double> alpha, std::complex<double> *x, int incx = 1) { zscal(n, alpha, x, incx); } inline static void scal(int n, double alpha, std::complex<double> *x, int incx = 1) { zdscal(n, alpha, x, incx); } inline static void scal(int n, float alpha, std::complex<float> *x, int incx = 1) { csscal(n, alpha, x, incx); } // inline static // void gemv(char trans, int n, int m, const double* amat, const double* x, // double* y) { // dgemv(trans, n, m, done, amat, n, x, INCX, dzero, y, INCY); //} inline static void gemv(int n, int m, const double *restrict amat, const double *restrict x, double *restrict y) { dgemv(NOTRANS, m, n, done, amat, m, x, INCX, dzero, y, INCY); } inline static void gemv(int n, int m, const float *restrict amat, const float *restrict x, float *restrict y) { sgemv(NOTRANS, m, n, done, amat, m, x, INCX, dzero, y, INCY); } inline static void gemv_trans(int n, int m, const double *restrict amat, const double *restrict x, double *restrict y) { dgemv(TRANS, m, n, done, amat, m, x, INCX, dzero, y, INCY); } inline static void gemv_trans(int n, int m, const float *restrict amat, const float *restrict x, float *restrict y) { sgemv(TRANS, m, n, done, amat, m, x, INCX, dzero, y, INCY); } inline static void gemv_trans(int n, int m, const std::complex<double> *restrict amat, const std::complex<double> *restrict x, std::complex<double> *restrict y) { zgemv(TRANS, m, n, done, amat, m, x, INCX, dzero, y, INCY); } inline static void gemv_trans(int n, int m, const std::complex<float> *restrict amat, const std::complex<float> *restrict x, std::complex<float> *restrict y) { cgemv(TRANS, m, n, done, amat, m, x, INCX, dzero, y, INCY); } inline static void gemv(int n, int m, const std::complex<double> *restrict amat, const std::complex<double> *restrict x, std::complex<double> *restrict y) { zgemv(NOTRANS, m, n, zone, amat, m, x, INCX, zzero, y, INCY); } inline static void gemv(char trans_in, int n, int m, double alpha, const double *restrict amat, int lda, const double *x, int incx, double beta, double *y, int incy) { dgemv(trans_in, n, m, alpha, amat, lda, x, incx, beta, y, incy); } inline static void gemv(char trans_in, int n, int m, float alpha, const float *restrict amat, int lda, const float *x, int incx, float beta, float *y, int incy) { sgemv(trans_in, n, m, alpha, amat, lda, x, incx, beta, y, incy); } inline static void gemv(char trans_in, int n, int m, const std::complex<double> &alpha, const std::complex<double> *restrict amat, int lda, const std::complex<double> *restrict x, int incx, const std::complex<double> &beta, std::complex<double> *y, int incy) { zgemv(trans_in, n, m, alpha, amat, lda, x, incx, beta, y, incy); } inline static void gemv(char trans_in, int n, int m, const std::complex<float> &alpha, const std::complex<float> *restrict amat, int lda, const std::complex<float> *restrict x, int incx, const std::complex<float> &beta, std::complex<float> *y, int incy) { cgemv(trans_in, n, m, alpha, amat, lda, x, incx, beta, y, incy); } #if defined(HAVE_MKL) inline static void gemv(char trans_in, int n, int m, const double &alpha, const double *restrict amat, int lda, const std::complex<double> *restrict x, int incx, const double &beta, std::complex<double> *y, int incy) { dzgemv(trans_in, n, m, std::complex<double>(alpha), amat, lda, x, incx, std::complex<double>(beta), y, incy); } inline static void gemv(char trans_in, int n, int m, const float &alpha, const float *restrict amat, int lda, const std::complex<float> *restrict x, int incx, const float &beta, std::complex<float> *y, int incy) { scgemv(trans_in, n, m, std::complex<float>(alpha), amat, lda, x, incx, std::complex<float>(beta), y, incy); } #else inline static void gemv(char trans_in, int n, int m, const double &alpha, const double *restrict amat, int lda, const std::complex<double> *restrict x, int incx, const double &beta, std::complex<double> *y, int incy) { // A * x --(Fortran)--> A^T * x --> X * A, where X is the interpretation of x as a 2 row matrix // A^T * x --(Fortran)--> A * x --> X * A^T, where X is the interpretation of x as a 2 row matrix if(trans_in == 'n' || trans_in == 'N') dgemm('N','T',2,n,m,alpha,reinterpret_cast<double const*>(x),2*incx,amat,lda, beta,reinterpret_cast<double*>(y),2*incy); else if(trans_in == 't' || trans_in == 'T') dgemm('N','N',2,n,m,alpha,reinterpret_cast<double const*>(x),2*incx,amat,lda, beta,reinterpret_cast<double*>(y),2*incy); else { print_stacktrace throw std::runtime_error("Error: Incorrect trans_in. \n"); } } inline static void gemv(char trans_in, int n, int m, const float &alpha, const float *restrict amat, int lda, const std::complex<float> *restrict x, int incx, const float &beta, std::complex<float> *y, int incy) { // A * x --(Fortran)--> A^T * x --> X * A, where X is the interpretation of x as a 2 row matrix // A^T * x --(Fortran)--> A * x --> X * A^T, where X is the interpretation of x as a 2 row matrix if(trans_in == 'n' || trans_in == 'N') sgemm('N','T',2,n,m,alpha,reinterpret_cast<float const*>(x),2*incx,amat,lda, beta,reinterpret_cast<float*>(y),2*incy); else if(trans_in == 't' || trans_in == 'T') sgemm('N','N',2,n,m,alpha,reinterpret_cast<float const*>(x),2*incx,amat,lda, beta,reinterpret_cast<float*>(y),2*incy); else { print_stacktrace throw std::runtime_error("Error: Incorrect trans_in. \n"); } } #endif inline static void gemm(char Atrans, char Btrans, int M, int N, int K, double alpha, const double *A, int lda, const double *restrict B, int ldb, double beta, double *restrict C, int ldc) { dgemm(Atrans, Btrans, M, N, K, alpha, A, lda, B, ldb, beta, C, ldc); } inline static void gemm(char Atrans, char Btrans, int M, int N, int K, float alpha, const float *A, int lda, const float *restrict B, int ldb, float beta, float *restrict C, int ldc) { sgemm(Atrans, Btrans, M, N, K, alpha, A, lda, B, ldb, beta, C, ldc); } inline static void gemm(char Atrans, char Btrans, int M, int N, int K, std::complex<double> alpha, const std::complex<double> *A, int lda, const std::complex<double> *restrict B, int ldb, std::complex<double> beta, std::complex<double> *restrict C, int ldc) { zgemm(Atrans, Btrans, M, N, K, alpha, A, lda, B, ldb, beta, C, ldc); } inline static void gemm(char Atrans, char Btrans, int M, int N, int K, std::complex<float> alpha, const std::complex<float> *A, int lda, const std::complex<float> *restrict B, int ldb, std::complex<float> beta, std::complex<float> *restrict C, int ldc) { cgemm(Atrans, Btrans, M, N, K, alpha, A, lda, B, ldb, beta, C, ldc); } inline static void gemm(char Atrans, char Btrans, int M, int N, int K, double alpha, const std::complex<double> *A, int lda, const double *restrict B, int ldb, double beta, std::complex<double> *restrict C, int ldc) { assert(Atrans=='n' || Atrans=='N'); dgemm(Atrans, Btrans, 2*M, N, K, alpha, reinterpret_cast<double const*>(A), 2*lda, B, ldb, beta, reinterpret_cast<double*>(C), 2*ldc); } inline static void gemm(char Atrans, char Btrans, int M, int N, int K, float alpha, const std::complex<float> *A, int lda, const float *restrict B, int ldb, float beta, std::complex<float> *restrict C, int ldc) { assert(Atrans=='n' || Atrans=='N'); sgemm(Atrans, Btrans, 2*M, N, K, alpha, reinterpret_cast<float const*>(A), 2*lda, B, ldb, beta, reinterpret_cast<float*>(C), 2*ldc); } template <typename T> inline static T dot(int n, const T *restrict a, const T *restrict b) { T res = T(0); for (int i = 0; i < n; ++i) res += a[i] * b[i]; return res; } template <typename T> inline static std::complex<T> dot(int n, const std::complex<T> *restrict a, const T *restrict b) { std::complex<T> res = T(0); for (int i = 0; i < n; ++i) res += a[i] * b[i]; return res; } template <typename T> inline static std::complex<T> dot(int n, const std::complex<T> *restrict a, const std::complex<T> *restrict b) { std::complex<T> res = 0.0; for (int i = 0; i < n; ++i) res += a[i] * b[i]; return res; } template <typename T> inline static std::complex<T> dot(int n, const T *restrict a, const std::complex<T> *restrict b) { std::complex<T> res = 0.0; for (int i = 0; i < n; ++i) res += a[i] * b[i]; return res; } template<typename T> inline static T dot(int n, const T* restrict a, int incx, const T* restrict b, int incy) { T res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; return res; } template<typename T> inline static std::complex<T> dot(int n, const std::complex<T>* restrict a, int incx, const T* restrict b, int incy) { std::complex<T> res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; return res; } template<typename T> inline static std::complex<T> dot(int n, const T* restrict a, int incx, const std::complex<T>* restrict b, int incy) { std::complex<T> res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; return res; } template<typename T> std::complex<T> dot(int n, const std::complex<T>* a, int incx, const std::complex<T>* b, int incy) { std::complex<T> res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; return res; } template <typename T> inline static void copy(int n, const T *restrict a, T *restrict b) { memcpy(b, a, sizeof(T) * n); } /** copy using memcpy(target,source,size) * @param target starting address of the targe * @param source starting address of the source * @param number of elements to copy */ template <typename T> inline static void copy(T *restrict target, const T *restrict source, int n) { memcpy(target, source, sizeof(T) * n); } template <typename T> inline static void copy(int n, const std::complex<T> *restrict a, T *restrict b) { for (int i = 0; i < n; ++i) b[i] = a[i].real(); } template <typename T> inline static void copy(int n, const T *restrict a, std::complex<T> *restrict b) { for (int i = 0; i < n; ++i) b[i] = a[i]; } template <typename T> inline static void copy(int n, const T *restrict x, int incx, T *restrict y, int incy) { const int xmax = incx * n; for (int ic = 0, jc = 0; ic < xmax; ic += incx, jc += incy) y[jc] = x[ic]; } inline static void ger(int m, int n, double alpha, const double *x, int incx, const double *y, int incy, double *a, int lda) { dger(&m, &n, &alpha, x, &incx, y, &incy, a, &lda); } inline static void ger(int m, int n, float alpha, const float *x, int incx, const float *y, int incy, float *a, int lda) { sger(&m, &n, &alpha, x, &incx, y, &incy, a, &lda); } inline static void ger(int m, int n, const std::complex<double> &alpha, const std::complex<double> *x, int incx, const std::complex<double> *y, int incy, std::complex<double> *a, int lda) { zgeru(&m, &n, &alpha, x, &incx, y, &incy, a, &lda); } inline static void ger(int m, int n, const std::complex<float> &alpha, const std::complex<float> *x, int incx, const std::complex<float> *y, int incy, std::complex<float> *a, int lda) { cgeru(&m, &n, &alpha, x, &incx, y, &incy, a, &lda); } // Blas extensions // C = alpha*op(A) + beta*op(B) // unoptimized implementation // assumes fortran ordering template<typename T> inline static void geam(char Atrans, char Btrans, int m, int n, T const alpha, T const* A, int lda, T const beta, T const* B, int ldb, T* C, int ldc) { if(n==0 || m==0) return; assert(ldc >= m); // Special cases // S1. set C to zero if(alpha == T(0) && beta == T(0)) { T zero(0); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = zero; return; } // S2. if(alpha == T(1) && beta == T(0)) { if( std::distance<T const*>(A,C) > 0 ) { if(Atrans == 'N' || Atrans == 'n') assert( std::distance<T const*>(A,C) >= n*lda ); else assert( std::distance<T const*>(A,C) >= m*lda ); } else { assert( std::distance<T const*>(C,A) >= n*ldc ); } if(Atrans == 'N' || Atrans == 'n') { assert(lda >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = A[ i + j*lda ]; } else if(Atrans == 'T' || Atrans == 't') { assert(lda >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = A[ j + i*lda ]; } else if(Atrans == 'C' || Atrans == 'c') { assert(lda >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = ma::conj(A[ j + i*lda ]); } else { throw std::runtime_error("Error: Invalid Atrans in geam."); } return; } if(alpha == T(0) && beta == T(1)) { if( std::distance<T const*>(B,C) > 0 ) { if(Btrans == 'N' || Btrans == 'n') assert( std::distance<T const*>(B,C) >= n*ldb ); else assert( std::distance<T const*>(B,C) >= m*ldb ); } else { assert( std::distance<T const*>(C,B) >= n*ldc ); } if(Btrans == 'N' || Btrans == 'n') { assert(ldb >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = B[ i + j*ldb ]; } else if(Btrans == 'T' || Btrans == 't') { assert(ldb >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = B[ j + i*ldb ]; } else if(Btrans == 'C' || Btrans == 'c') { assert(ldb >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = ma::conj(B[ j + i*ldb ]); } else { throw std::runtime_error("Error: Invalid Btrans in geam."); } return; } // Check for in-place modes // I1. A==C, lda==ldc, Atrans=='N' if( std::distance<T const*>(A,C) == 0 ) { if( (lda != ldc) || ((Atrans != 'N') && (Atrans != 'n')) ) throw std::runtime_error("Error: In-place mode requires Op(A)='N' and lda=ldc."); if( std::distance<T const*>(B,C) > 0 ) { if(Btrans == 'N' || Btrans == 'n') assert( std::distance<T const*>(B,C) >= n*ldb ); else assert( std::distance<T const*>(B,C) >= m*ldb ); } else { assert( std::distance<T const*>(C,B) >= n*ldc ); } if(Btrans == 'N' || Btrans == 'n') { assert(ldb >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*C[ i + j*ldc ] + beta*B[ i + j*ldb ]; } else if(Btrans == 'T' || Btrans == 't') { assert(ldb >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*C[ i + j*ldc ] + beta*B[ j + i*ldb ]; } else if(Btrans == 'C' || Btrans == 'c') { assert(ldb >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*C[ i + j*ldc ] + beta*ma::conj(B[ j + i*ldb ]); } else { throw std::runtime_error("Error: Invalid Btrans in geam."); } return; } // I2. B==C, ldb==ldc, Btrans=='N' if( std::distance<T const*>(B,C) == 0 ) { if( (ldb != ldc) || ((Btrans != 'N') && (Btrans != 'n')) ) throw std::runtime_error("Error: In-place mode requires Op(B)='N' and ldb=ldc."); if( std::distance<T const*>(A,C) > 0 ) { if(Atrans == 'N' || Atrans == 'n') assert( std::distance<T const*>(A,C) >= n*lda ); else assert( std::distance<T const*>(A,C) >= m*lda ); } else { assert( std::distance<T const*>(C,A) >= n*ldc ); } if(Atrans == 'N' || Atrans == 'n') { assert(lda >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = beta*C[ i + j*ldc ] + alpha*A[ i + j*lda ]; } else if(Atrans == 'T' || Atrans == 't') { assert(lda >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = beta*C[ i + j*ldc ] + alpha*A[ j + i*lda ]; } else if(Atrans == 'C' || Atrans == 'c') { assert(lda >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = beta*C[ i + j*ldc ] + alpha*ma::conj(A[ j + i*lda ]); } else { throw std::runtime_error("Error: Invalid Atrans in geam."); } return; } // check that C does not overlap A or B if( std::distance<T const*>(A,C) > 0 ) { if(Atrans == 'N' || Atrans == 'n') assert( std::distance<T const*>(A,C) >= n*lda ); else assert( std::distance<T const*>(A,C) >= m*lda ); } else { assert( std::distance<T const*>(C,A) >= n*ldc ); } if( std::distance<T const*>(B,C) > 0 ) { if(Btrans == 'N' || Btrans == 'n') assert( std::distance<T const*>(B,C) >= n*ldb ); else assert( std::distance<T const*>(B,C) >= m*ldb ); } else { assert( std::distance<T const*>(C,B) >= n*ldc ); } // Generic case if(Atrans == 'N' || Atrans == 'n') { assert(lda >= m); if(Btrans == 'N' || Btrans == 'n') { assert(ldb >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*A[ i + j*lda ] + beta*B[ i + j*ldb ]; } else if(Btrans == 'T' || Btrans == 't') { assert(ldb >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*A[ i + j*lda ] + beta*B[ j + i*ldb ]; } else if(Btrans == 'C' || Btrans == 'c') { assert(ldb >= n); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*A[ i + j*lda ] + beta*ma::conj(B[ j + i*ldb ]); } else { throw std::runtime_error("Error: Invalid Btrans in geam."); } } else if(Atrans == 'T' || Atrans == 't') { assert(lda >= n); if(Btrans == 'N' || Btrans == 'n') { assert(ldb >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*A[ j + i*lda ] + beta*B[ i + j*ldb ]; } else if(Btrans == 'T' || Btrans == 't') { assert(ldb >= n); for(int i=0; i<m; i++) for(int j=0; j<n; j++) C[ i + j*ldc ] = alpha*A[ j + i*lda ] + beta*B[ j + i*ldb ]; } else if(Btrans == 'C' || Btrans == 'c') { assert(ldb >= n); for(int i=0; i<m; i++) for(int j=0; j<n; j++) C[ i + j*ldc ] = alpha*A[ j + i*lda ] + beta*ma::conj(B[ j + i*ldb ]); } else { throw std::runtime_error("Error: Invalid Btrans in geam."); } } else if(Atrans == 'C' || Atrans == 'c') { assert(lda >= n); if(Btrans == 'N' || Btrans == 'n') { assert(ldb >= m); for(int j=0; j<n; j++) for(int i=0; i<m; i++) C[ i + j*ldc ] = alpha*ma::conj(A[ j + i*lda ]) + beta*B[ i + j*ldb ]; } else if(Btrans == 'T' || Btrans == 't') { assert(ldb >= n); for(int i=0; i<m; i++) for(int j=0; j<n; j++) C[ i + j*ldc ] = alpha*ma::conj(A[ j + i*lda ]) + beta*B[ j + i*ldb ]; } else if(Btrans == 'C' || Btrans == 'c') { assert(ldb >= n); for(int i=0; i<m; i++) for(int j=0; j<n; j++) C[ i + j*ldc ] = alpha*ma::conj(A[ j + i*lda ]) + beta*ma::conj(B[ j + i*ldb ]); } else { throw std::runtime_error("Error: Invalid Btrans in geam."); } } else { throw std::runtime_error("Error: Invalid Atrans in geam."); } } template<typename T> inline static void zero_complex_part(int n, T* x) { } template<typename T> inline static void zero_complex_part(int n, std::complex<T>* x) { for(int i=0; i<n; ++i, ++x) *x = std::complex<T>(real(*x),0.0); } template<typename T> inline static void set1D(int n, T const alpha, T* x, int incx) { for(int i=0; i<n; i++, x+=incx) *x = alpha; } // y = beta*y + alpha * dot(a,b) template<typename T, typename Q> inline static void adotpby(int n, T const alpha, const T* restrict a, int incx, const T* restrict b, int incy, Q const beta, Q* result) { T res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; *result = beta*(*result) + static_cast<Q>(alpha*res); } /* template<typename T, typename Q> inline static void adotpby(int n, Q const alpha, const std::complex<T>* restrict a, int incx, const T* restrict b, int incy, Q const beta, std::complex<T>* result) { std::complex<T> res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; *result = beta*(*result) + alpha*res; } template<typename T, typename Q> inline static void adotpby(int n, Q const alpha, const T* restrict a, int incx, const std::complex<T>* restrict b, int incy, Q const beta, std::complex<T>* result) { std::complex<T> res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; *result = beta*(*result) + alpha*res; } template<typename T, typename Q> inline static void adotpby(int n, Q const alpha, const std::complex<T>* restrict a, int incx, const std::complex<T>* restrict b, int incy, Q const beta, std::complex<T>* result) { std::complex<T> res=T(0); for(int i=0, ia=0, ib=0; i<n; ++i, ia+=incx, ib+=incy) res += a[ia]*b[ib]; *result = beta*(*result) + alpha*res; } */ template<typename T> inline static void axty(int n, T const alpha, T const* x, int incx, T * y, int incy) { for(int i=0; i<n; i++) y[i*incy] *= alpha*x[i*incx]; } // implements z[i][j] = beta * z[i][j] + alpha * conj(y[i][j]) * x[i] template<typename T> inline static void acAxpbB(int m, int n, T const alpha, T const* A, int lda, T const* x, int incx, T const beta, T * B, int ldb) { for(int j=0; j<n; j++) { auto Bj = B+j*ldb; auto Aj = A+j*lda; for(int i=0; i<m; i++) Bj[i] = beta*Bj[i] + alpha * ma::conj(Aj[i]) * x[i*incx]; } } // y[i] = y[i] + alpha*A[i][i] template<typename T> inline static void adiagApy(int n, T const alpha, T const* A, int lda, T * y, int incy) { for(int i=0; i<n; i++) y[i*incy] += alpha*A[i*lda + i]; } template<typename T> inline static T sum(int n, T const* x, int incx) { T res(0); for(int i=0; i<n; i++) res += x[i*incx]; return res; } // assume Fortran ordering like all blas calls template<typename T> inline static T sum(int m, int n, T const* A, int lda) { T res(0); for(int i=0; i<n; i++) for(int j=0; j<m; j++) res += A[i*lda+j]; return res; } // assume Fortran ordering like all blas calls template<typename T> void set_identity(int m, int n, T* A, int lda) { for(int i=0; i<n; i++) for(int j=0; j<m; j++) A[i*lda+j] = ((i==j)?1:0); } template<typename T> void set_identity_strided(int nbatch, int stride, int m, int n, T* A, int lda) { for(int b=0, b0=0; b<nbatch; b++, b0+=stride) set_identity(m,n,A+b0,lda); } #ifdef HAVE_MKL inline static void gemm_batch (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE* transa_array, const CBLAS_TRANSPOSE* transb_array, const int* m_array, const int* n_array, const int* k_array, const float *alpha_array, const void **a_array, const int* lda_array, const void **b_array, const int* ldb_array, const void *beta_array, void **c_array, const int* ldc_array, const int group_count, const int* group_size) { cblas_sgemm_batch(Layout,transa_array,transb_array,m_array,n_array,k_array, alpha_array,a_array,lda_array,b_array,ldb_array,beta_array, c_array,ldc_array,group_count,group_size); } inline static void gemm_batch (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE* transa_array, const CBLAS_TRANSPOSE* transb_array, const int* m_array, const int* n_array, const int* k_array, const double *alpha_array, const void **a_array, const int* lda_array, const void **b_array, const int* ldb_array, const void *beta_array, void **c_array, const int* ldc_array, const int group_count, const int* group_size) { cblas_dgemm_batch(Layout,transa_array,transb_array,m_array,n_array,k_array, alpha_array,a_array,lda_array,b_array,ldb_array,beta_array, c_array,ldc_array,group_count,group_size); } inline static void gemm_batch (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE* transa_array, const CBLAS_TRANSPOSE* transb_array, const int* m_array, const int* n_array, const int* k_array, const std::complex<float> *alpha_array, const void **a_array, const int* lda_array, const void **b_array, const int* ldb_array, const void *beta_array, void **c_array, const int* ldc_array, const int group_count, const int* group_size) { cblas_cgemm_batch(Layout,transa_array,transb_array,m_array,n_array,k_array, alpha_array,a_array,lda_array,b_array,ldb_array,beta_array, c_array,ldc_array,group_count,group_size); } inline static void gemm_batch (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE* transa_array, const CBLAS_TRANSPOSE* transb_array, const int* m_array, const int* n_array, const int* k_array, const std::complex<double> *alpha_array, const void **a_array, const int* lda_array, const void **b_array, const int* ldb_array, const void *beta_array, void **c_array, const int* ldc_array, const int group_count, const int* group_size) { cblas_zgemm_batch(Layout,transa_array,transb_array,m_array,n_array,k_array, alpha_array,a_array,lda_array,b_array,ldb_array,beta_array, c_array,ldc_array,group_count,group_size); } #endif template<typename T> inline static void gemmStridedBatched(char Atrans, char Btrans, int M, int N, int K, T alpha, const T *A, int lda, int strideA, const T *restrict B, int ldb, int strideB, T beta, T *restrict C, int ldc, int strideC, int batchSize) { #ifdef HAVE_MKL // MKL has batched gemm, but with pointer interface. Translate here std::vector<const void*> Aptrs(batchSize); std::vector<const void*> Bptrs(batchSize); std::vector<void*> Cptrs(batchSize); for(int i=0; i<batchSize; i++) { Aptrs[i] = static_cast<const void*>(A+i*strideA); Bptrs[i] = static_cast<const void*>(B+i*strideB); Cptrs[i] = static_cast<void*>(C+i*strideC); } CBLAS_TRANSPOSE opA(cblas_operation(Atrans)); CBLAS_TRANSPOSE opB(cblas_operation(Btrans)); // Expect arrays of size group_count. // This is 1 in strided case, so passing pointers to everything gemm_batch(CblasColMajor,&opA,&opB,&M,&N,&K, &alpha,Aptrs.data(),&lda,Bptrs.data(),&ldb, &beta,Cptrs.data(),&ldc,1,&batchSize); #else // No batched gemm, :-( gemm loop for(int i=0; i<batchSize; i++) gemm(Atrans,Btrans,M,N,K,alpha,A+i*strideA,lda,B+i*strideB,ldb,beta,C+i*strideC,ldc); #endif } template<typename T> inline static void gemmBatched(char Atrans, char Btrans, int M, int N, int K, T alpha, T ** A, int lda, T ** B, int ldb, T beta, T ** C, int ldc, int batchSize) { #ifdef HAVE_MKL CBLAS_TRANSPOSE opA(cblas_operation(Atrans)); CBLAS_TRANSPOSE opB(cblas_operation(Btrans)); gemm_batch(CblasColMajor,&opA,&opB,&M,&N,&K, &alpha,(const void**)A,&lda,(const void**)B,&ldb, &beta,(void**)C,&ldc,1,&batchSize); #else // No batched gemm, :-( gemm loop for(int i=0; i<batchSize; i++) gemm(Atrans,Btrans,M,N,K,alpha,A[i],lda,B[i],ldb,beta,C[i],ldc); #endif } } /* #include "mpi3/shared_window.hpp" // temporary namespace boost { namespace mpi3 { namespace intranode { template<typename T, typename Q> auto dot(int const n, array_ptr<T> x, int const incx, array_ptr<Q> y, int const incy) { using ma::dot; return dot(n,to_address(x),incx,to_address(y),incy); } } // intranode } // mpi3 } // boost */ #endif
bits 64 default rel section .text global pal_execute_rdtscp pal_execute_rdtscp : push rbx rdtscp shl rdx, 32 or rax, rdx mov rdi, rax xor rax, rax xor rbx, rbx xor rcx, rcx xor rdx, rdx cpuid mov rax, rdi pop rbx ret
; A067016: Start with a(0)=1, a(1)=4, a(2)=3, a(3)=2; for n>=3, a(n+1) = max_i (a(i)+a(n-i)). ; 1,4,3,2,7,8,11,12,15,16,19,20,23,24,27,28,31,32,35,36,39,40,43,44,47,48,51,52,55,56,59,60,63,64,67,68,71,72,75,76,79,80,83,84,87,88,91,92,95,96,99,100,103,104,107,108,111,112,115,116,119,120,123,124,127,128,131,132,135,136,139,140,143,144,147,148,151,152,155,156,159,160,163,164,167,168,171,172,175,176,179,180,183,184,187,188,191,192,195,196,199,200,203,204,207,208,211,212,215,216,219,220,223,224,227,228,231,232,235,236,239,240,243,244,247,248,251,252,255,256,259,260,263,264,267,268,271,272,275,276,279,280,283,284,287,288,291,292,295,296,299,300,303,304,307,308,311,312,315,316,319,320,323,324,327,328,331,332,335,336,339,340,343,344,347,348,351,352,355,356,359,360,363,364,367,368,371,372,375,376,379,380,383,384,387,388,391,392,395,396,399,400,403,404,407,408,411,412,415,416,419,420,423,424,427,428,431,432,435,436,439,440,443,444,447,448,451,452,455,456,459,460,463,464,467,468,471,472,475,476,479,480,483,484,487,488,491,492,495,496 mov $3,$0 sub $0,2 mov $1,2 div $3,2 trn $3,1 mov $4,$3 add $3,$0 mov $2,$3 sub $4,$3 add $1,$4 lpb $0,1 mov $0,1 add $1,$2 add $1,$2 lpe add $1,1
// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) // Copyright 2008-2016 National ICT Australia (NICTA) // // 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. // ------------------------------------------------------------------------ //! \addtogroup op_misc //! @{ class op_real : public traits_op_passthru { public: template<typename T1> inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_real>& X); template<typename T1> inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_real>& X); }; class op_imag : public traits_op_passthru { public: template<typename T1> inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_imag>& X); template<typename T1> inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_imag>& X); }; class op_abs : public traits_op_passthru { public: template<typename T1> inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_abs>& X); template<typename T1> inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_abs>& X); }; class op_arg : public traits_op_passthru { public: template<typename T1> inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_arg>& X); template<typename T1> inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_arg>& X); }; //! @}
; A059556: Beatty sequence for 1 + 1/gamma. ; Submitted by Jamie Morken(s4) ; 2,5,8,10,13,16,19,21,24,27,30,32,35,38,40,43,46,49,51,54,57,60,62,65,68,71,73,76,79,81,84,87,90,92,95,98,101,103,106,109,112,114,117,120,122,125,128,131,133,136,139,142,144,147,150,153,155,158,161,163,166,169,172,174,177,180,183,185,188,191,194,196,199,202,204,207,210,213,215,218,221,224,226,229,232,234,237,240,243,245,248,251,254,256,259,262,265,267,270,273 mov $4,$0 add $4,1 mov $7,$0 lpb $4 mov $0,$7 sub $4,1 sub $0,$4 mov $9,2 mov $10,0 mov $11,$0 lpb $9 mov $0,$11 mov $5,0 sub $9,1 add $0,$9 trn $0,1 add $0,1 mov $2,1 mov $3,$0 mul $3,4 lpb $3 add $5,$2 add $5,$2 add $1,$5 add $2,$1 mul $1,2 sub $3,1 lpe mov $1,4 mul $5,3 add $1,$5 div $2,$0 mul $2,2 div $1,$2 mov $0,$1 mov $8,$9 mul $8,$1 add $10,$8 lpe min $11,1 mul $11,$0 mov $0,$10 sub $0,$11 add $0,2 add $6,$0 lpe mov $0,$6
; A185170: a(n) = floor( (2*n^2 - 6*n + 9) / 5). ; 1,1,1,1,3,5,9,13,17,23,29,37,45,53,63,73,85,97,109,123,137,153,169,185,203,221,241,261,281,303,325,349,373,397,423,449,477,505,533,563,593,625,657,689,723,757,793,829,865,903,941,981,1021,1061,1103,1145,1189,1233,1277,1323,1369,1417,1465,1513,1563,1613,1665,1717,1769,1823,1877,1933,1989,2045,2103,2161,2221,2281,2341,2403,2465,2529,2593,2657,2723,2789,2857,2925,2993,3063,3133,3205,3277,3349,3423,3497,3573,3649,3725,3803,3881,3961,4041,4121,4203,4285,4369,4453,4537,4623,4709,4797,4885,4973,5063,5153,5245,5337,5429,5523,5617,5713,5809,5905,6003,6101,6201,6301,6401,6503,6605,6709,6813,6917,7023,7129,7237,7345,7453,7563,7673,7785,7897,8009,8123,8237,8353,8469,8585,8703,8821,8941,9061,9181,9303,9425,9549,9673,9797,9923,10049,10177,10305,10433,10563,10693,10825,10957,11089,11223,11357,11493,11629,11765,11903,12041,12181,12321,12461,12603,12745,12889,13033,13177,13323,13469,13617,13765,13913,14063,14213,14365,14517,14669,14823,14977,15133,15289,15445,15603,15761,15921,16081,16241,16403,16565,16729,16893,17057,17223,17389,17557,17725,17893,18063,18233,18405,18577,18749,18923,19097,19273,19449,19625,19803,19981,20161,20341,20521,20703,20885,21069,21253,21437,21623,21809,21997,22185,22373,22563,22753,22945,23137,23329,23523,23717,23913,24109,24305,24503 sub $0,1 mov $2,$0 sub $0,1 mul $0,$2 div $0,5 mov $1,$0 mul $1,2 add $1,1
pragma_embed-profiler-output := true mov 0 mov 1 profiler start, one instruction nop profiler stop, one instruction profiler start, loop test mov 4 loop: dec jnz @loop profiler stop, loop test hlt
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0xd2ea, %r8 clflush (%r8) dec %r13 mov (%r8), %r10d nop nop nop nop nop dec %rsi lea addresses_D_ht+0x52c8, %rbx xor %r8, %r8 mov $0x6162636465666768, %r12 movq %r12, %xmm0 vmovups %ymm0, (%rbx) nop nop nop nop xor $11484, %r8 lea addresses_A_ht+0x16d8f, %r12 nop sub %rbp, %rbp movb (%r12), %r8b and %rsi, %rsi lea addresses_WC_ht+0x108d0, %r10 nop nop nop sub $9588, %rsi mov $0x6162636465666768, %rbx movq %rbx, (%r10) nop nop nop add %rsi, %rsi lea addresses_WC_ht+0xb8e8, %r13 and %r8, %r8 vmovups (%r13), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %rbx nop dec %r8 lea addresses_WT_ht+0x2728, %rsi lea addresses_WC_ht+0x1db28, %rdi nop and %r13, %r13 mov $123, %rcx rep movsq nop nop sub %r13, %r13 lea addresses_D_ht+0x53a8, %rsi clflush (%rsi) nop nop nop nop nop inc %r13 movb $0x61, (%rsi) nop nop add $5760, %rbx lea addresses_A_ht+0x9d28, %rbx add $33229, %rbp mov (%rbx), %r10d nop nop inc %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r9 push %rcx push %rdi push %rsi // REPMOV lea addresses_A+0x18528, %rsi lea addresses_normal+0x1dc28, %rdi nop xor $14780, %r9 mov $7, %rcx rep movsw nop nop nop xor $59605, %rsi // Store lea addresses_UC+0x6528, %r9 nop nop nop nop sub %r12, %r12 movl $0x51525354, (%r9) nop nop add $39756, %r13 // Store mov $0x64e2240000000d28, %rcx dec %r12 movw $0x5152, (%rcx) nop nop sub $18601, %r12 // Load lea addresses_D+0x19428, %rcx nop nop nop nop cmp $41756, %r13 mov (%rcx), %r12 nop nop sub $16472, %rdi // Store mov $0x64e2240000000d28, %r12 nop nop nop add %r13, %r13 movw $0x5152, (%r12) nop sub $2148, %rcx // Load lea addresses_D+0x11928, %r9 nop nop nop nop nop inc %rdi mov (%r9), %r12w nop nop nop nop cmp $33995, %r12 // Store lea addresses_D+0xc528, %rdi cmp %rsi, %rsi movb $0x51, (%rdi) nop nop nop dec %r9 // Faulty Load mov $0x64e2240000000d28, %rdi nop nop nop sub %r10, %r10 vmovups (%rdi), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %r9 lea oracles, %r13 and $0xff, %r9 shlq $12, %r9 mov (%r13,%r9,1), %r9 pop %rsi pop %rdi pop %rcx pop %r9 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_A'}, 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_normal'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_NC'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 8, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_NC'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': True, 'size': 8, 'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 8, 'same': True, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'00': 32, '52': 218} 52 52 52 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 00 00 52 52 52 00 52 52 52 52 52 00 52 52 52 52 52 52 52 52 52 00 00 52 52 52 52 00 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 00 52 52 52 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 00 52 52 52 52 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 52 00 00 52 52 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 00 52 52 00 52 00 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 00 52 52 52 52 00 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 52 52 52 52 52 52 52 00 52 52 52 52 52 52 00 52 52 52 52 52 52 52 52 52 52 52 52 52 52 00 52 52 00 52 00 52 52 52 52 52 00 52 52 52 00 52 52 */
;*********************************************************** ; UTN-2014-Rutinas de Interrupcion ;*********************************************************** ;*********************************************************** ; Author : Fernandez Marcelo Joaquin ; Date : 23th May 2014 ;*********************************************************** [BITS 64] ;http://sourceforge.net/p/nasm/mailman/nasm-users/thread/4DFE094A.9020105@computer.org/ %assign i 0 %rep 30 irsMSG_%+i: db "SALTO_EXCEPCION_N_" irsMSG2_%+i:db 0,0,0,0,0,0,0,0,0,0 int_%+i: push rdi mov edi,irsMSG_%+i mov esi,10 ; esi (segundo argumento) char columna mov edx,3 ; edx (tercer argumento) char fila mov ecx,111b ; ECX (cuarto arguemto) char color call Print mov edi,i ;valor de la excepcion mov esi,irsMSG2_%+i ;puntero a char call my_itoa ;llamo a mi super funcion itoa mov edi,irsMSG2_%+i mov esi,28 ; esi (segundo argumento) char columna mov edx,3 ; edx (tercer argumento) char fila mov ecx,111b ; ECX (cuarto arguemto) char color call Print ;hago que imprima el numero ;pop rdi hlt ;por enunciado me pide que haltee ;iret ret %assign i i+1 %endrep
// push constant 111 @111 D=A // store the current address as a value @SP // >> push constant value (111) onto stack << A=M // move to top of stack M=D // write value of D to current location @SP // increment stack pointer M=M+1 // push constant 333 @333 D=A // store the current address as a value @SP // >> push constant value (333) onto stack << A=M // move to top of stack M=D // write value of D to current location @SP // increment stack pointer M=M+1 // push constant 888 @888 D=A // store the current address as a value @SP // >> push constant value (888) onto stack << A=M // move to top of stack M=D // write value of D to current location // pop static 8 @SP // move to top of stack (already points to the correct spot) A=M // move to top of stack D=M // store the top stack value into D @StaticTest.8 // go to static slot M=D // and store the value there // pop static 3 @SP // move stack pointer back to the value to be popped M=M-1 A=M // move to top of stack D=M // store the top stack value into D @StaticTest.3 // go to static slot M=D // and store the value there // pop static 1 @SP // move stack pointer back to the value to be popped M=M-1 A=M // move to top of stack D=M // store the top stack value into D @StaticTest.1 // go to static slot M=D // and store the value there // push static 3 @StaticTest.3 // go to static slot D=M // store the static value in D @SP // >> push it onto the stack << A=M // move to top of stack M=D // write value of D to current location @SP // increment stack pointer M=M+1 // push static 1 @StaticTest.1 // go to static slot D=M // store the static value in D @SP // >> push it onto the stack << A=M // move to top of stack M=D // write value of D to current location // sub @SP // move to top of stack (already points to the correct spot) A=M // PREPARE Y (pop Y into D) D=M // store the top stack value into D @SP // "pop" X M=M-1 A=M // PREPARE X (prep X "into" M – but don't pop just yet!) M=M-D // perform binary operation: sub @SP // increment stack pointer M=M+1 // push static 8 @StaticTest.8 // go to static slot D=M // store the static value in D @SP // >> push it onto the stack << A=M // move to top of stack M=D // write value of D to current location // add @SP // move to top of stack (already points to the correct spot) A=M // PREPARE Y (pop Y into D) D=M // store the top stack value into D @SP // "pop" X M=M-1 A=M // PREPARE X (prep X "into" M – but don't pop just yet!) M=M+D // perform binary operation: add @SP // increment stack pointer M=M+1 (INFINITE_LOOP) @INFINITE_LOOP 0;JMP
/* ********************************************************************************************************* * uC/Probe Communication * * Copyright 2007-2020 Silicon Laboratories Inc. www.silabs.com * * SPDX-License-Identifier: APACHE-2.0 * * This software is subject to an open source license and is distributed by * Silicon Laboratories Inc. pursuant to the terms of the Apache License, * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. * ********************************************************************************************************* */ /* ********************************************************************************************************* * * uC/Probe * * Communication: RS-232 * Port for the Freescale M52233DEMO * * Filename : probe_rs232a.asm * Version : V2.30 ********************************************************************************************************* */ #include <os_cpu_i.asm> /* ;************************************************************************************************* ; PUBLIC DECLARATIONS ;************************************************************************************************* */ PUBLIC ProbeRS232_RxTxISR /* ;************************************************************************************************** ; EXTERNAL DECLARATIONS ;************************************************************************************************** */ EXTERN OSIntNesting EXTERN OSIntExit EXTERN OSTCBCur EXTERN ProbeRS232_RxTxISRHandler RSEG CODE:CODE:NOROOT(2) /* Align to power 2, 4 bytes. */ /* ;******************************************************************************************* ; uC/Probe's Rx/Tx ISR ; ; Description : This function services uC/Probe's receive and transmit interrupts ; ; Arguments : none ;******************************************************************************************* */ ProbeRS232_RxTxISR: MOVE.W #0x2700,SR /* Disable interrupts */ LEA (-60, A7),A7 /* Save processor registers onto stack */ MOVEM.L D0-D7/A0-A6,(A7) OS_EMAC_SAVE /* Save the EMAC registers */ MOVEQ.L #0,D0 /* OSIntNesting++ */ MOVE.B (OSIntNesting),D0 ADDQ.L #1,D0 MOVE.B D0,(OSIntNesting) CMPI.L #1, D0 /* if (OSIntNesting == 1) */ BNE.W ProbeRS232_RxTxISR_1 MOVEA.L (OSTCBCur), A1 /* OSTCBCur-<OSTCBStkPtr = SP */ MOVE.L A7,(A1) ProbeRS232_RxTxISR_1: /* ProbeRS232_RxTxISRHandler() */ JSR (ProbeRS232_RxTxISRHandler) JSR (OSIntExit) /* Exit the ISR */ OS_EMAC_RESTORE /* Restore the EMAC registers */ MOVEM.L (A7),D0-D7/A0-A6 /* Restore processor registers from stack */ LEA (60, A7), A7 RTE /* Return to task or nested ISR */ END
; A081006: a(n) = Fibonacci(4n) - 1, or Fibonacci(2n+1)*Lucas(2n-1). ; 2,20,143,986,6764,46367,317810,2178308,14930351,102334154,701408732,4807526975,32951280098,225851433716,1548008755919,10610209857722,72723460248140,498454011879263,3416454622906706,23416728348467684 mul $0,2 add $0,1 lpb $0 sub $0,1 add $1,1 add $2,$1 add $1,$2 lpe
#include "raw_pixel_area.hpp" #include "pixel_format.hpp" #include <functional> #include <map> #include <cassert> #include <cstring> using namespace ::std; using namespace ::atlas2d; using namespace ::atlas2d::details; namespace { struct row_selector; /// The generic row fetcher using row_fetcher = std::function<void(unsigned char*, row_selector const&)>; /// Selector for a raw pixels row struct row_selector { int row_index = 0; size dims; int bpp = 0; unsigned char* raw_pixels = nullptr; row_selector& set_raw_pixels(unsigned char* arg) { raw_pixels = arg; return *this; } row_selector& set_bpp(int arg) { bpp = arg; return *this; } row_selector& set_row_index(int arg) { row_index = arg; return *this; } row_selector& set_dims(size arg) { dims = std::move(arg); return *this; } }; void read_row_rotated0(unsigned char* dst, row_selector const& src) { size_t index = src.dims.width * src.bpp * src.row_index; memcpy(dst, &src.raw_pixels[index], src.dims.width * src.bpp); } void read_row_rotated90(unsigned char* dst, row_selector const& src) { // read right edge of the image as the row for(int i = 0; i < src.dims.height; ++i) { size_t src_index = ((i + 1) * src.dims.width - 1 - src.row_index) * src.bpp; memcpy(&dst[i * src.bpp], &src.raw_pixels[src_index], src.bpp); } } void read_row_rotated180(unsigned char* dst, row_selector const& src) { // read starts from the bottom edge of the image in reverse order for(int i = 0; i < src.dims.width; ++i) { size_t src_index = ((src.dims.height - src.row_index) * src.dims.width - 1 - i) * src.bpp; memcpy(&dst[i * src.bpp], &src.raw_pixels[src_index], src.bpp); } } void read_row_rotated270(unsigned char* dst, row_selector const& src) { // read starts from the left bottom edge of the image for(int i = 0; i < src.dims.height; ++i) { size_t src_index = ((src.dims.height - 1 - i) * src.dims.width + src.row_index) * src.bpp; memcpy(&dst[i * src.bpp], &src.raw_pixels[src_index], src.bpp); } } /// Fetcher's dispatch table std::map<raw_pixel_area::rotation, row_fetcher> fetcher_table = { {raw_pixel_area::rotate_0_degree, &read_row_rotated0}, {raw_pixel_area::rotate_90_degree, &read_row_rotated90}, {raw_pixel_area::rotate_180_degree, &read_row_rotated180}, {raw_pixel_area::rotate_270_degree, &read_row_rotated270}, }; } struct raw_pixel_area_impl::pimpl { raw_area_props* props; size orig_dims; ///< Original dimensions of the area row_fetcher fetcher; ///< Pixel row fetcher int bpp = 0; ///< Bytes per pixel }; raw_pixel_area_impl::raw_pixel_area_impl(): _pimpl(new pimpl) { ;; } raw_pixel_area_impl::~raw_pixel_area_impl() { ;; } void raw_pixel_area_impl::init_props_storage(raw_area_props* props) { _pimpl->props = props; } void raw_pixel_area_impl::reset() { assert(_pimpl->props && "Invalid props storage!"); auto props = _pimpl->props; _pimpl->bpp = pixel_format_details(props->format).bpp; _pimpl->orig_dims = props->dimensions; _pimpl->fetcher = &read_row_rotated0; } size raw_pixel_area_impl::get_dimensions() const { assert(_pimpl->props && "Invalid props storage!"); return _pimpl->props->dimensions; } void raw_pixel_area_impl::set_rotator(rotation r) { assert(_pimpl->props && "Invalid props storage!"); _pimpl->fetcher = fetcher_table.find(r)->second; _pimpl->props->dimensions = _pimpl->orig_dims; if(r == rotate_90_degree || r == rotate_270_degree) { _pimpl->props->dimensions.width = _pimpl->orig_dims.height; _pimpl->props->dimensions.height = _pimpl->orig_dims.width; } } pixel_format raw_pixel_area_impl::get_pixel_format() const { return _pimpl->props->format; } unsigned char* raw_pixel_area_impl::get_raw_pixels() const { return _pimpl->props->data.get(); } void raw_pixel_area_impl::read_row(unsigned char* dst, int row) const { _pimpl->fetcher(dst, row_selector() .set_row_index(row) .set_bpp(_pimpl->bpp) .set_raw_pixels(get_raw_pixels()) .set_dims(_pimpl->orig_dims) ); }
;******************************************************************************* ; Program: MC6809E ; Version: 1.20 ; Written: July 15, 1990 ; Updated: Friday, August 12, 1994 7:52 pm ; Author : Tony G. Papadimitriou ; Purpose: This is an enhanced version of the MC6809E emulator program ; originally written in Turbo Pascal. Because it is completely ; written in Assembly language there should be a dramatic speed ; improvement over the Pascal version. ; Note : This program requires DOS 3.x or later to run properly. ; The program will abort if a lower version is found. ; Include: This file requires the following INCLUDE files to assemble ; properly: DOS.INC BIOS.INC KBD.INC (originally supplied by Borland) ; LOADER.ASM OPCODES1.ASM OPCODES2.ASM OS9.ASM (supplied by ; Tony G. Papadimitriou) ; History: 940811 - Started 386 code optimization for speed ; The following optimizations were initiated: ; 386 intructions that are shorter and run faster ; Consecutive ClearFlag macros optimized to single ANDs ; Consecutive SetFlag macros optimized to single ORs ; Where possible, operations performed directly on 6809 memory ;******************************************************************************* IDEAL %TITLE "MC6809E Emulator ver. 1.20 (80386 Assembly Language)" MODEL COMPACT STACK 4096 P386 include "dos.inc" include "bios.inc" include "kbd.inc" CarryMask = 01h OverflowMask = 02h ZeroMask = 04h NegativeMask = 08h IRQMask = 10h HalfCarryMask = 20h FIRQMask = 40h EntireFlagMask = 80h ;******************************************************************************* ; Macro : GetByte ; Purpose: Get a byte in AL from the 6809 memory pointed by ES:SI macro GetByte mov al,[es:si] endm GetByte ;******************************************************************************* ; Macro : GetWord ; Purpose: Get a word in AX from the 6809 memory pointed by ES:SI macro GetWord mov ax,[es:si] xchg ah,al endm GetWord ;******************************************************************************* ; Macro : PutByte ; Purpose: Put a byte in AL to the 6809 memory pointed by ES:SI macro PutByte mov [es:si],al endm PutByte ;******************************************************************************* ; Macro : PutWord ; Purpose: Put a word in AX to the 6809 memory pointed by ES:SI macro PutWord xchg ah,al mov [es:si],ax endm PutWord ;******************************************************************************* ; Macro : CCarry ; Purpose: Clear Carry Flag macro CCarry pushf and [CC],11111110b popf endm CCarry ;******************************************************************************* ; Macro : COverflow ; Purpose: Clear Overflow Flag macro COverflow pushf and [CC],11111101b popf endm COverflow ;******************************************************************************* ; Macro : CZero ; Purpose: Clear Zero Flag macro CZero pushf and [CC],11111011b popf endm CZero ;******************************************************************************* ; Macro : CNegative ; Purpose: Clear Negative Flag macro CNegative pushf and [CC],11110111b popf endm CNegative ;******************************************************************************* ; Macro : CIRQ ; Purpose: Clear IRQ Flag macro CIRQ pushf and [CC],11101111b popf endm CIRQ ;******************************************************************************* ; Macro : CHalfCarry ; Purpose: Clear Half Carry Flag macro CHalfCarry pushf and [CC],11011111b popf endm CHalfCarry ;******************************************************************************* ; Macro : CFIRQ ; Purpose: Clear Fast IRQ Flag macro CFIRQ pushf and [CC],10111111b popf endm CFIRQ ;******************************************************************************* ; Macro : CEntireFlag ; Purpose: Clear Entire Flag Flag macro CEntireFlag pushf and [CC],01111111b popf endm CEntireFlag ;******************************************************************************* ; Macro : SCarry ; Purpose: Set Carry Flag macro SCarry pushf or [CC],00000001b popf endm SCarry ;******************************************************************************* ; Macro : SOverflow ; Purpose: Set Overflow Flag macro SOverflow pushf or [CC],00000010b popf endm SOverflow ;******************************************************************************* ; Macro : SZero ; Purpose: Set Zero Flag macro SZero pushf or [CC],00000100b popf endm SZero ;******************************************************************************* ; Macro : SNegative ; Purpose: Set Negative Flag macro SNegative pushf or [CC],00001000b popf endm SNegative ;******************************************************************************* ; Macro : SIRQ ; Purpose: Set IRQ Flag macro SIRQ pushf or [CC],00010000b popf endm SIRQ ;******************************************************************************* ; Macro : SHalfCarry ; Purpose: Set Half Carry Flag macro SHalfCarry pushf or [CC],00100000b popf endm SHalfCarry ;******************************************************************************* ; Macro : SFIRQ ; Purpose: Set Fast IRQ Flag macro SFIRQ pushf or [CC],01000000b popf endm SFIRQ ;******************************************************************************* ; Macro : SEntireFlag ; Purpose: Set Entire Flag Flag macro SEntireFlag pushf or [CC],10000000b popf endm SEntireFlag FARDATA ; 64K of emulator's main memory Memory equ 0 db 0FF00h dup(?) Ports equ 0FF00h db 00100h dup(?) ;******************************************************************************* ; The following table is used to determine the entry point of each routine ;******************************************************************************* DATASEG OpCodeAll dw mcNEG ; 00 -- NEGate dw mcERROR ; 01 -- none dw mcERROR ; 02 -- none dw mcCOM ; 03 -- COMplement dw mcLSR ; 04 -- Logical Shift Right dw mcERROR ; 05 -- none dw mcROR ; 06 -- ROtate Right dw mcASR ; 07 -- Arithmetic Shift Right dw mcASL ; 08 -- Arithmetic Shift Left (LSL) dw mcROL ; 09 -- ROtate Left dw mcDEC ; 0A -- DECrement dw mcERROR ; 0B -- none dw mcINC ; 0C -- INCrement dw mcTST ; 0D -- TeST dw mcJMP ; 0E -- JuMP dw mcCLR ; 0F -- CLeaR dw mcCASE10 ; 10 -- special case dw mcCASE11 ; 11 -- special case dw mcNOP ; 12 -- No OPeration dw mcSYNC ; 13 -- SYNChronize dw mcERROR ; 14 -- none dw mcERROR ; 15 -- none dw mcBRA ; 16 -- Long BRanch Always dw mcBSR ; 17 -- Long Branch to SubRoutine dw mcERROR ; 18 -- none dw mcDAA ; 19 -- Decimal Addition Adjust dw mcORCC ; 1A -- OR Condition Codes dw mcERROR ; 1B -- none dw mcANDCC ; 1C -- AND Condition Codes dw mcSEX ; 1D -- Sign EXtend dw mcEXG ; 1E -- EXGhange dw mcTFR ; 1F -- TransFeR dw mcBRA ; 20 -- BRanch Always dw mcBRN ; 21 -- BRanch Never dw mcBHI ; 22 -- BRanch if HIgher dw mcBLS ; 23 -- BRanch if Less or Same dw mcBHS ; 24 -- BRanch if Higher or Same dw mcBLO ; 25 -- BRanch if LOwer dw mcBNE ; 26 -- BRanch if Not Equal dw mcBEQ ; 27 -- BRanch if EQual dw mcBVC ; 28 -- BRanch if oVerflow bit Clear dw mcBVS ; 29 -- BRanch if oVerflow bit Set dw mcBPL ; 2A -- BRanch on PLus sign dw mcBMI ; 2B -- BRanch on MInus sign dw mcBGE ; 2C -- BRanch if Greater than or Equal dw mcBLT ; 2D -- BRanch if Less Than dw mcBGT ; 2E -- BRanch if Greater Than dw mcBLE ; 2F -- BRanch if Less than or Equal dw mcLEAX ; 30 -- Load Effective Address into X dw mcLEAY ; 31 -- Load Effective Address into Y dw mcLEAS ; 32 -- Load Effective Address into S dw mcLEAU ; 33 -- Load Effective Address into U dw mcPSHS ; 34 -- PuSH onto System stack dw mcPULS ; 35 -- PULl from System stack dw mcPSHU ; 36 -- PuSH onto User stack dw mcPULU ; 37 -- PULl from User stack dw mcERROR ; 38 -- none dw mcRTS ; 39 -- ReTurn from Subroutine dw mcABX ; 3A -- Add B to X dw mcRTI ; 3B -- ReTurn from Interrupt dw mcCWAI ; 3C -- Clear flags and WAit for Interrupt dw mcMUL ; 3D -- MULtiply dw mcERROR ; 3E -- none dw mcSWI ; 3F -- SoftWare Interrupt dw mcNEG ; 40 -- NEGate dw mcERROR ; 41 -- none dw mcERROR ; 42 -- none dw mcCOM ; 43 -- COMplement dw mcLSR ; 44 -- Logical Shift Right dw mcERROR ; 45 -- none dw mcROR ; 46 -- ROtate Right dw mcASR ; 47 -- Arithmetic Shift Right dw mcASL ; 48 -- Arithmetic Shift Left (LSL) dw mcROL ; 49 -- ROtate Left dw mcDEC ; 4A -- DECrement dw mcERROR ; 4B -- none dw mcINC ; 4C -- INCrement dw mcTST ; 4D -- TeST dw mcERROR ; 4E -- none dw mcCLR ; 4F -- CLeaR dw mcNEG ; 50 -- NEGate dw mcERROR ; 51 -- none dw mcERROR ; 52 -- none dw mcCOM ; 53 -- COMplement dw mcLSR ; 54 -- Logical Shift Right dw mcERROR ; 55 -- none dw mcROR ; 56 -- ROtate Right dw mcASR ; 57 -- Arithmetic Shift Right dw mcASL ; 58 -- Arithmetic Shift Left (LSL) dw mcROL ; 59 -- ROtate Left dw mcDEC ; 5A -- DECrement dw mcERROR ; 5B -- none dw mcINC ; 5C -- INCrement dw mcTST ; 5D -- TeST dw mcERROR ; 5E -- none dw mcCLR ; 5F -- CLeaR dw mcNEG ; 60 -- NEGate dw mcERROR ; 61 -- none dw mcERROR ; 62 -- none dw mcCOM ; 63 -- COMplement dw mcLSR ; 64 -- Logical Shift Right dw mcERROR ; 65 -- none dw mcROR ; 66 -- ROtate Right dw mcASR ; 67 -- Arithmetic Shift Right dw mcASL ; 68 -- Arithmetic Shift Left (LSL) dw mcROL ; 69 -- ROtate Left dw mcDEC ; 6A -- DECrement dw mcERROR ; 6B -- none dw mcINC ; 6C -- INCrement dw mcTST ; 6D -- TeST dw mcJMP ; 6E -- JuMP dw mcCLR ; 6F -- CLeaR dw mcNEG ; 70 -- NEGate dw mcERROR ; 71 -- none dw mcERROR ; 72 -- none dw mcCOM ; 73 -- COMplement dw mcLSR ; 74 -- Logical Shift Right dw mcERROR ; 75 -- none dw mcROR ; 76 -- ROtate Right dw mcASR ; 77 -- Arithmetic Shift Right dw mcASL ; 78 -- Arithmetic Shift Left (LSL) dw mcROL ; 79 -- ROtate Left dw mcDEC ; 7A -- DECrement dw mcERROR ; 7B -- none dw mcINC ; 7C -- INCrement dw mcTST ; 7D -- TeST dw mcJMP ; 7E -- JuMP dw mcCLR ; 7F -- CLeaR dw mcSUBA ; 80 -- SUBtract A dw mcCMPA ; 81 -- CoMPare with A dw mcSBCA ; 82 -- SuBtract with Carry from A dw mcSUBD ; 83 -- SUBtract from D dw mcANDA ; 84 -- AND A dw mcBITA ; 85 -- BIT test A dw mcLDA ; 86 -- LoaD A dw mcERROR ; 87 -- none dw mcEORA ; 88 -- Exclusive OR A dw mcADCA ; 89 -- ADd with Carry to A dw mcORA ; 8A -- OR A dw mcADDA ; 8B -- ADD to A dw mcCMPX ; 8C -- CoMPare with X dw mcBSR ; 8D -- Branch to SubRoutine dw mcLDX ; 8E -- LoaD X dw mcERROR ; 8F -- none dw mcSUBA ; 90 -- SUBtract A dw mcCMPA ; 91 -- CoMPare with A dw mcSBCA ; 92 -- SuBtract with Carry from A dw mcSUBD ; 93 -- SUBtract from D dw mcANDA ; 94 -- AND A dw mcBITA ; 95 -- BIT test A dw mcLDA ; 96 -- LoaD A dw mcSTA ; 97 -- STore A dw mcEORA ; 98 -- Exclusive OR A dw mcADCA ; 99 -- ADd with Carry to A dw mcORA ; 9A -- OR A dw mcADDA ; 9B -- ADD to A dw mcCMPX ; 9C -- CoMPare with X dw mcJSR ; 9D -- Jump to SubRoutine dw mcLDX ; 9E -- LoaD X dw mcSTX ; 9F -- STore X dw mcSUBA ; A0 -- SUBtract A dw mcCMPA ; A1 -- CoMPare with A dw mcSBCA ; A2 -- SuBtract with Carry from A dw mcSUBD ; A3 -- SUBtract from D dw mcANDA ; A4 -- AND A dw mcBITA ; A5 -- BIT test A dw mcLDA ; A6 -- LoaD A dw mcSTA ; A7 -- STore A dw mcEORA ; A8 -- Exclusive OR A dw mcADCA ; A9 -- ADd with Carry to A dw mcORA ; AA -- OR A dw mcADDA ; AB -- ADD to A dw mcCMPX ; AC -- CoMPare with X dw mcJSR ; AD -- Jump to SubRoutine dw mcLDX ; AE -- LoaD X dw mcSTX ; AF -- STore X dw mcSUBA ; B0 -- SUBtract A dw mcCMPA ; B1 -- CoMPare with A dw mcSBCA ; B2 -- SuBtract with Carry from A dw mcSUBD ; B3 -- SUBtract from D dw mcANDA ; B4 -- AND A dw mcBITA ; B5 -- BIT test A dw mcLDA ; B6 -- LoaD A dw mcSTA ; B7 -- STore A dw mcEORA ; B8 -- Exclusive OR A dw mcADCA ; B9 -- ADd with Carry to A dw mcORA ; BA -- OR A dw mcADDA ; BB -- ADD to A dw mcCMPX ; BC -- CoMPare with X dw mcJSR ; BD -- Jump to SubRoutine dw mcLDX ; BE -- LoaD X dw mcSTX ; BF -- STore X dw mcSUBB ; C0 -- SUBtract B dw mcCMPB ; C1 -- CoMPare with B dw mcSBCB ; C2 -- SuBtract with Carry from B dw mcADDD ; C3 -- ADD to D dw mcANDB ; C4 -- AND B dw mcBITB ; C5 -- BIT test B dw mcLDB ; C6 -- LoaD B dw mcERROR ; C7 -- none dw mcEORB ; C8 -- Exclusive OR B dw mcADCB ; C9 -- ADd with Carry to B dw mcORB ; CA -- OR B dw mcADDB ; CB -- ADD to B dw mcLDD ; CC -- LoaD D dw mcERROR ; CD -- none dw mcLDU ; CE -- LoaD U dw mcERROR ; CF -- none dw mcSUBB ; D0 -- SUBtract B dw mcCMPB ; D1 -- CoMPare with B dw mcSBCB ; D2 -- SuBtract with Carry from B dw mcADDD ; D3 -- ADD to D dw mcANDB ; D4 -- AND B dw mcBITB ; D5 -- BIT test B dw mcLDB ; D6 -- LoaD B dw mcSTB ; D7 -- STore B dw mcEORB ; D8 -- Exclusive OR B dw mcADCB ; D9 -- ADd with Carry to B dw mcORB ; DA -- OR B dw mcADDB ; DB -- ADD to B dw mcLDD ; DC -- LoaD D dw mcSTD ; DD -- STore D dw mcLDU ; DE -- LoaD U dw mcSTU ; DF -- STore U dw mcSUBB ; E0 -- SUBtract B dw mcCMPB ; E1 -- CoMPare with B dw mcSBCB ; E2 -- SuBtract with Carry from B dw mcADDD ; E3 -- ADD to D dw mcANDB ; E4 -- AND B dw mcBITB ; E5 -- BIT test B dw mcLDB ; E6 -- LoaD B dw mcSTB ; E7 -- STore B dw mcEORB ; E8 -- Exclusive OR B dw mcADCB ; E9 -- ADd with Carry to B dw mcORB ; EA -- OR B dw mcADDB ; EB -- ADD to B dw mcLDD ; EC -- LoaD D dw mcSTD ; ED -- STore D dw mcLDU ; EE -- LoaD U dw mcSTU ; EF -- STore U dw mcSUBB ; F0 -- SUBtract B dw mcCMPB ; F1 -- CoMPare with B dw mcSBCB ; F2 -- SuBtract with Carry from B dw mcADDD ; F3 -- ADD to D dw mcANDB ; F4 -- AND B dw mcBITB ; F5 -- BIT test B dw mcLDB ; F6 -- LoaD B dw mcSTB ; F7 -- STore B dw mcEORB ; F8 -- Exclusive OR B dw mcADCB ; F9 -- ADd with Carry to B dw mcORB ; FA -- OR B dw mcADDB ; FB -- ADD to B dw mcLDD ; FC -- LoaD D dw mcSTD ; FD -- STore D dw mcLDU ; FE -- LoaD U dw mcSTU ; FF -- STore U OpCode10 dw 33 dup(mcERROR) ; 00 -> 20 -- none dw mcBRN ; 21 -- Long BRaNch dw mcBHI ; 22 -- Long BRanch if HIgher dw mcBLS ; 23 -- Long BRanch if Less or Same dw mcBHS ; 24 -- Long BRanch if Higher or Same dw mcBLO ; 25 -- Long BRanch if LOwer dw mcBNE ; 26 -- Long BRanch if Not Equal dw mcBEQ ; 27 -- Long BRanch if EQual dw mcBVC ; 28 -- Long BRanch if oVerflow bit Clear dw mcBVS ; 29 -- Long BRanch if oVerflow bit Set dw mcBPL ; 2A -- Long BRanch on PLus sign dw mcBMI ; 2B -- Long BRanch on MInus sign dw mcBGE ; 2C -- Long BRanch if Greater than or Equal dw mcBLT ; 2D -- Long BRanch if Less Than dw mcBGT ; 2E -- Long BRanch if Greater Than dw mcBLE ; 2F -- Long BRanch if Less than or Equal dw 15 dup(mcERROR) ; 30 -> 3E -- none dw mcSWI2 ; 3F -- SoftWare Interrupt 2 dw 67 dup(mcERROR) ; 40 -> 82 -- none dw mcCMPD ; 83 -- CoMPare with D dw 8 dup(mcERROR) ; 84 -> 8B -- none dw mcCMPY ; 8C -- CoMPare with Y dw mcERROR ; 8D -- none dw mcLDY ; 8E -- LoaD Y dw mcERROR ; 8F -- none dw 3 dup(mcERROR) ; 90 -> 92 none dw mcCMPD ; 93 -- CoMPare with D dw 8 dup(mcERROR) ; 94 -> 9B -- none dw mcCMPY ; 9C -- CoMPare with Y dw mcERROR ; 9D -- none dw mcLDY ; 9E -- LoaD Y dw mcSTY ; 9F -- STore Y dw 3 dup(mcERROR) ; A0 -> A2 none dw mcCMPD ; A3 -- CoMPare with D dw 8 dup(mcERROR) ; A4 -> AB -- none dw mcCMPY ; AC -- CoMPare with Y dw mcERROR ; AD -- none dw mcLDY ; AE -- LoaD Y dw mcSTY ; AF -- STore Y dw 3 dup(mcERROR) ; B0 -> B2 none dw mcCMPD ; B3 -- CoMPare with D dw 8 dup(mcERROR) ; B4 -> BB -- none dw mcCMPY ; BC -- CoMPare with Y dw mcERROR ; BD -- none dw mcLDY ; BE -- LoaD Y dw mcSTY ; BF -- STore Y dw 14 dup(mcERROR) ; C0 -> CD -- none dw mcLDS ; CE -- LoaD S dw mcERROR ; CF -- none dw 14 dup(mcERROR) ; D0 -> DD -- none dw mcLDS ; DE -- LoaD S dw mcSTS ; DF -- STore S dw 14 dup(mcERROR) ; E0 -> ED -- none dw mcLDS ; EE -- LoaD S dw mcSTS ; EF -- STore S dw 14 dup(mcERROR) ; F0 -> FD -- none dw mcLDS ; FE -- LoaD S dw mcSTS ; FF -- STore S OpCode11 dw 131 dup(mcERROR) ; 00 -> 82 -- none dw mcCMPU ; 83 -- CoMPare with U dw 8 dup(mcERROR) ; 84 -> 8B -- none dw mcCMPS ; 8C -- CoMPare with S dw 6 dup(mcERROR) ; 8D -> 92 -- none dw mcCMPU ; 93 -- CoMPare with U dw 8 dup(mcERROR) ; 94 -> 9B -- none dw mcCMPS ; 9C -- CoMPare with S dw 6 dup(mcERROR) ; 9D -> A2 -- none dw mcCMPU ; A3 -- CoMPare with U dw 8 dup(mcERROR) ; A4 -> AB -- none dw mcCMPS ; AC -- CoMPare with S dw 6 dup(mcERROR) ; AD -> B2 -- none dw mcCMPU ; B3 -- CoMPare U dw 8 dup(mcERROR) ; B4 -> BB -- none dw mcCMPS ; BC -- CoMPare with S dw 67 dup(mcERROR) ; BD -> FF -- none ;******************************************************************************* ; Messages used by the Emulator ;******************************************************************************* Copyright db "Motorola 6809E Emulator ver. 1.20 " db "(Limited OS-9 Level One Ver. 2.00 Emulator)",RETURN,LINEFEED db "Copyright (c) 1990-2022 by Tony G. Papadimitriou. " db "All Rights Reserved.",RETURN,LINEFEED db "(Assembled on: ",??date,")",RETURN,LINEFEED db RETURN,LINEFEED CprghtLen = $ - Copyright LMsg db "Loading file",RETURN,LINEFEED LMsgLen = $ - LMsg EMsgG db "ERROR: " EMsgGLen = $ - EMsgG EMsg db "Unknown error code was returned by MS-DOS",RETURN,LINEFEED EMsgLen = $ - EMsg EMsg0 db "Usage: MC6809E progname.s19",RETURN,LINEFEED EMsg0Len = $ - EMsg0 EMsg1 db "Invalid Motorola S19 file format",RETURN,LINEFEED EMsg1Len = $ - EMsg1 EMsg2 db "File not found",RETURN,LINEFEED EMsg2Len = $ - EMsg2 EMsg3 db "Path not found",RETURN,LINEFEED EMsg3Len = $ - EMsg3 EMsg4 db "MS-DOS reported an invalid DOS function",RETURN,LINEFEED EMsg4Len = $ - EMsg4 EMsg5 db "Can't open file, no file handles available",RETURN,LINEFEED EMsg5Len = $ - EMsg5 EMsg6 db "Access to file was denied",RETURN,LINEFEED EMsg6Len = $ - EMsg6 EMsg7 db "Internal error. Please contact tonyp@ars.ath.forthnet.gr",RETURN,LINEFEED EMsg7Len = $ - EMsg7 EMsg8 db "Bad CRC while loading file, cannot run program",RETURN,LINEFEED EMsg8Len = $ - EMsg8 EMsg9 db "*** Invalid opcode encountered ***",RETURN,LINEFEED EMsg9Len = $ - EMsg9 EMsg10 db "Incorrect DOS version. Must use DOS 3.x or greater",RETURN,LINEFEED EMsg10Len = $ - EMsg10 ;******************************************************************************* ; General Variables ;******************************************************************************* PSP dw ? ; holds Program Segment Prefix OS9_On db 1 ; flag to indicate OS9 emulation ;******************************************************************************* ; Variables used by the Emulator ;******************************************************************************* ; ; Global variables (other than the 6809 registers) ; OpCode db ? ; Last OpCode fetched Paged db ? ; Paged OpCode $10, or $11 PostCode db ? ; post-opcode for indexed etc. Register db ? ; Register used as indexed (X,Y,U,S) RegCont dw ? ; Contents of register EffAdd dw ? ; Last calculated effective address Timer dw ? ; Allows breakpoint setting ; ; Define the 6809 registers ; DPR db ? ; Direct Page Register CC db ? ; Condition Codes (flags) label XYUS word X dw ? ; primary index register Y dw ? ; secondary index register U dw ? ; User stack register S dw ? ; System stack register PC dw ? ; Program Counter label D word ; 16-bit accumulator (pair A,B) B db ? ; secondary 8-bit Accumulator (low D) A db ? ; primary 8-bit Accumulator (high D) CODESEG ;******************************************************************************* ; Routine: Init6809 ; Purpose: Call the various functions of the program ; Input : None ; Output : None proc Init6809 mov ax,@data ; initialize DS mov ds,ax mov ah,DOS_GET_PSP ; get Program Segment Prefix int DOS_FUNCTION mov [PSP],bx ; save PSP for later call ClrScr call ShwCprght call CheckVersion cmp ax,0 ; wrong version? jne @@errors ; yes, report the problem call ClearMemory call Restart call LoadProgram ; load programs passed as parameters jc @@errors ; on carry set, we got errors cmp ax,0 jne @@errors ; or if AX <> 0, we got errors call ClrScr mov ax,[ExecAddr] ; get the execution address mov [PC],ax ; into the PC register mov [Timer],0 ; if Timer<>0 break in Timer cycles call Emulator ; else call the emulator cmp ax,0 ; did we have errors? jne @@errors ; yes, take care of them mov al,0 ; no errors jmp short @@exit ; and then exit program @@errors: call Errors ; display error message (AX=error code) @@exit: mov ah,DOS_TERMINATE_EXE int DOS_FUNCTION endp Init6809 ;******************************************************************************* ; Routine: ClrScr ; Purpose: Clear the display and home the cursor ; Input : None ; Output : None proc ClrScr push ax ; save registers push bx push cx push dx push bp mov ah,INT10_SCROLL_UP mov al,0 ; entire window/screen mov cx,0 ; start of screen mov dx,0FFFFh ; end of screen (maximum possible) mov bh,7 ; character attribute normal int VIDEO_SERVICE mov ah,2 ; BIOS set cursor location function mov dx,0 ; cursor coordinates (top left) mov bh,0 ; current video page int VIDEO_SERVICE pop bp ; restore registers pop dx pop cx pop bx pop ax ret endp ClrScr ;******************************************************************************* ; Routine: ShwCprght ; Purpose: Display the program copyright message ; Input : DS must point to the segment where the copyright is located ; Output : None proc ShwCprght mov dx,offset Copyright mov cx,CprghtLen call Write ret endp ShwCprght ;******************************************************************************* ; Routine: CheckVersion ; Purpose: Check the DOS version ; Input : None ; Output : If DOS version is < 3.x then AX = 131 (error code) else AX = 0 proc CheckVersion push bx push cx mov ah,DOS_GET_DOS_VERSION int DOS_FUNCTION cmp al,3 ; major = 3 ? jl @@error ; if less, get error code cmp ah,0 ; minor = 0 ? jl @@error ; if less, get error code mov ax,0 ; no error code jmp short @@exit @@error: mov ax,131 ; Invalid DOS version error code @@exit: pop cx pop bx ret endp CheckVersion ;******************************************************************************* ; Routine: ClearMemory ; Purpose: Fill 6809 segment with zeros ; Input : None ; Output : None proc ClearMemory push es ; save registers mov ax,@fardata mov es,ax mov di,0 mov cx,0FFFFh ; 65535 bytes mov ax,0 ; initialization value rep stosb stosb ; one more for the last byte pop es ret endp ClearMemory ;******************************************************************************* ; Routine: Restart ; Purpose: Initialize the 6809 registers ; Input : None ; Output : None proc Restart push ax ; save registers push bx mov ax,@fardata mov es,ax mov ax,0 mov [D],ax mov [X],ax mov [Y],ax mov [U],ax mov [S],ax mov [U],ax mov [CC],01010000b mov [DPR],al mov bx,0FFFEh mov ax,[word es:Memory+bx] xchg ah,al mov [PC],ax pop bx pop ax ret endp Restart ;******************************************************************************* include "loader.asm" ;******************************************************************************* ;******************************************************************************* ; Routine: Errors ; Purpose: Display an error message based on the code in AX ; Input : AX holds the error code ; Output : None proc Errors cmp ax,0 ; do we have an error? jne @@skip ; error, go on and print it mov dx,offset EMsg0 ; usage message mov cx,EMsg0Len call Write jmp @@exit @@skip: ;call Beep ; beep on error mov dx,offset EMsgG mov cx,EMsgGLen call Write cmp ax,128 ; Invalid S format? jne @@2 mov dx,offset EMsg1 mov cx,EMsg1Len call Write jmp @@exit @@2: cmp ax,2 ; File not found? jne @@3 mov dx,offset EMsg2 mov cx,EMsg2Len call Write jmp @@exit @@3: cmp ax,3 ; Path not found? jne @@4 mov dx,offset EMsg3 mov cx,EMsg3Len call Write jmp @@exit @@4: cmp ax,1 ; Invalid DOS function? jne @@5 mov dx,offset EMsg4 mov cx,EMsg4Len call Write jmp short @@exit @@5: cmp ax,4 ; No handles available? jne @@6 mov dx,offset EMsg5 mov cx,EMsg5Len call Write jmp short @@exit @@6: cmp ax,5 ; Access denied? jne @@7 mov dx,offset EMsg6 mov dx,EMsg6Len call Write jmp short @@exit @@7: cmp ax,0Ch ; Invalid access code, internal jne @@8 mov dx,offset EMsg7 mov cx,EMsg7Len call Write jmp short @@exit @@8: cmp ax,129 ; Bad CRC while loading jne @@9 mov dx,offset EMsg8 mov cx,EMsg8Len call Write jmp short @@exit @@9: cmp ax,130 ; Invalid opcode jne @@10 mov dx,offset EMsg9 mov cx,EMsg9Len call Write jmp short @@exit @@10: cmp ax,131 ; Invalid DOS version jne @@11 mov dx,offset EMsg10 mov cx,EMsg10Len call Write jmp short @@exit @@11: ; ************* add more errors here if needed *********** @@unknown: mov dx,offset EMsg ; unknown error mov cx,EMsgLen call Write @@exit: mov ax,0 ; reset error code ret endp Errors ;******************************************************************************* ; Routine: DirMode ; Purpose: Calculate the effective address assuming direct mode ; Input : None ; Output : SI holds the effective address in the ES segment (6809) proc DirMode push ax mov ah,[DPR] mov si,[PC] GetByte inc [PC] mov si,ax pop ax ret endp DirMode ;******************************************************************************* ; Routine: RelMode ; Purpose: Calculate the effective address assuming relative mode ; Input : None ; Output : SI holds the effective address in the ES segment (6809) proc RelMode mov si,[PC] ret endp RelMode ;******************************************************************************* ; Routine: IndMode ; Purpose: Calculate the effective address assuming indexed mode ; Input : None ; Output : SI holds the effective address in the ES segment (6809) proc IndMode push ax push bx push cx mov si,[PC] ; get post-opcode GetByte inc [PC] mov ah,al ; get a copy in AH cmp al,10011111b ; special case (extended indirect) je @@ExtIndH and al,10011111b ; remove the register info from AL mov [PostCode],al ; and save it for later and ah,01100000b ; and figure out the register from AH mov cl,5 shr ah,cl ; a number from 0 to 3 (X,Y,U,S) mov [Register],ah ; save it for later shl ah,1 ; multiply by two (size of XYUS) xchg ah,al cbw mov bx,offset XYUS ; point to XYUS registers add bx,ax mov bx,[bx] ; get contents of register mov [RegCont],bx ; and save for later mov al,[PostCode] ; get postbyte and al,11101111b ; turn off indirect bit for now cmp al,10000100b ; is it no offset? je @@noffset test al,80h ; is it 5-bit offset? jz @@5bit cmp al,10001000b ; is it 8-bit offset? je @@8bit cmp al,10001001b ; is it 16-bit offset? je @@16bit cmp al,10000110b ; is it accumulator A offset? je @@AoffH cmp al,10000101b ; is it accumulator B offset? je @@BoffH cmp al,10001011b ; is it accumulator D offset? je @@DoffH cmp al,10000000b ; is it auto increment by 1? je @@Inc1H cmp al,10000001b ; is it auto increment by 2? je @@Inc2H cmp al,10000010b ; is it auto decrement by 1? je @@Dec1H cmp al,10000011b ; is it auto decrement by 2? je @@Dec2H cmp al,10001100b ; is it 8-bit PCR? je @@8PCRH cmp al,10001101b ; is it 16-bit PCR? je @@16PCRH mov al,[PostCode] jmp @@Invalid ; post byte is invalid @@ExtIndH: jmp @@ExtInd @@AoffH: jmp @@Aoffset @@BoffH: jmp @@Boffset @@DoffH: jmp @@Doffset @@Inc1H: jmp @@Inc1 @@Inc2H: jmp @@Inc2 @@Dec1H: jmp @@Dec1 @@Dec2H: jmp @@Dec2 @@8PCRH: jmp @@8PCR @@16PCRH: jmp @@16PCR @@noffset: mov si,[RegCont] jmp @@Indirec @@5bit: mov si,[RegCont] mov al,[PostCode] shl al,1 ; "sign-extend" 5-bit offset shl al,1 shl al,1 sar al,1 sar al,1 sar al,1 cbw add si,ax jmp @@exit @@8bit: mov si,[PC] ; get offset and bump up PC by 1 GetByte inc [PC] cbw mov si,[RegCont] add si,ax jmp @@Indirec @@16bit: mov si,[PC] ; get offset and bump up PC by 2 GetWord inc [PC] inc [PC] mov si,[RegCont] add si,ax jmp @@Indirec @@Aoffset: mov al,[A] jmp short @@L1 @@Boffset: mov al,[B] @@L1: mov si,[RegCont] cbw add si,ax jmp @@Indirec @@Doffset: mov si,[RegCont] mov ax,[D] add si,ax jmp @@Indirec @@Inc1: mov si,[RegCont] mov bx,offset XYUS mov al,[Register] shl al,1 cbw add bx,ax inc [word bx] ; post increment register by 1 jmp @@exit @@Inc2: mov si,[RegCont] mov bx,offset XYUS mov al,[Register] shl al,1 cbw add bx,ax inc [word bx] ; post increment register by 2 inc [word bx] jmp short @@Indirec @@Dec1: mov bx,offset XYUS mov al,[Register] shl al,1 cbw add bx,ax dec [word bx] ; post decrement register by 1 mov si,[word bx] jmp short @@exit @@Dec2: mov bx,offset XYUS mov al,[Register] shl al,1 cbw add bx,ax dec [word bx] ; post decrement register by 2 dec [word bx] mov si,[word bx] jmp short @@Indirec @@8PCR: mov si,[PC] ; get offset and bump up PC by 1 GetByte inc [PC] cbw mov si,[PC] add si,ax jmp short @@Indirec @@16PCR: mov si,[PC] ; get offset and bump up PC by 2 GetWord inc [PC] inc [PC] mov si,[PC] add si,ax jmp short @@Indirec @@ExtInd: mov si,[PC] GetByte inc [PC] mov ah,al mov si,[PC] GetByte inc [PC] mov si,ax mov si,[si] jmp short @@exit @@Indirec: mov al,[PostCode] test al,00010000b ; is the indirect bit on? jz @@exit ; no, get out GetWord mov si,ax jmp short @@exit @@Invalid: call Beep ; for now just beep @@exit: pop cx pop bx pop ax ret endp IndMode ;******************************************************************************* ; Routine: ExtMode ; Purpose: Calculate the effective address assuming extended mode ; Input : None ; Output : SI holds the effective address in the ES segment (6809) proc ExtMode push ax mov si,[PC] GetWord inc [PC] inc [PC] mov si,ax pop ax ret endp ExtMode ;******************************************************************************* ; Routine: ImmMode ; Purpose: Calculate the effective address assuming immediate mode ; Input : None ; Output : SI holds the effective address in the ES segment (6809) proc ImmMode mov si,[PC] ret endp ImmMode ;******************************************************************************* ; Routine: GetEffAddr ; Purpose: Get the effective address based on the MSN of the OpCode ; Input : None ; Output : SI holds the effective address in the ES segment (6809) proc GetEffAddr push ax mov al,[OpCode] shr al,1 ; move MSN to LSN shr al,1 ; making MSN = 0 shr al,1 shr al,1 cmp al,0 ; is it DIRECT mode? je @@direct cmp al,1 ; is it special mode 1 (relative)? je @@mode1 cmp al,2 ; is it RELATIVE mode? je @@relativ cmp al,3 ; is it special mode 3 (indexed)? je @@mode3 cmp al,6 ; is it INDEXED mode? je @@indexed cmp al,7 ; is it EXTENDED mode? je @@extend cmp al,8 ; is it IMMEDIATE mode? je @@immed cmp al,9 ; is it DIRECT mode? je @@direct cmp al,10 ; is it INDEXED mode? je @@indexed cmp al,11 ; is it EXTENDED mode? je @@extend cmp al,12 ; is it IMMEDIATE mode? je @@immed cmp al,13 ; is it DIRECT mode? je @@direct cmp al,14 ; is it INDEXED mode? je @@indexed cmp al,15 ; is it EXTENDED mode? je @@extend jmp short @@exit ; other modes are done separately @@direct: call DirMode jmp short @@exit @@mode1: mov al,[OpCode] ; make sure it's a legal one cmp al,16h ; is it LBRA? je @@relativ cmp al,17h ; is it LBSR je @@relativ jmp short @@exit @@relativ: call RelMode jmp short @@exit @@mode3: mov al,[OpCode] ; make sure it's a legal one test al,11000000b ; 2 high bits are zero? jnz @@exit @@indexed: call IndMode jmp short @@exit @@extend: call ExtMode jmp short @@exit @@immed: call ImmMode @@exit: pop ax ret endp GetEffAddr ;******************************************************************************* ; Routine: Emulator ; Purpose: Perform the Fetch/Decode/Execute cycle until special key is pressed ; : Special key should be one with extended code ; : Currently the special key F10 ; Input : None ; Output : None proc Emulator @@L0: cmp [Timer],0 ; check for breakpoints (Timer<>0) je @@L1 ; no breakpoints, go on dec [Timer] ; breakpoint, count down time cmp [Timer],0 ; are we done counting? jne @@L1 ; no, go on jmp @@EXIT ; exit because of breakpoint @@L1: mov ah,0Bh ; check for key pressed int 21h cmp al,0 ; is there a key waiting? je @@L2 ; no key waiting, go on mov ah,08h ; read key int 21h cmp al,0 ; is it an extended key? je @@L1A ; if so, go get second character jmp short @@L2 ; key can be ignored @@L1A: mov ah,08h ; read character int 21h cmp al,68 ; is it the special key <F10> ? je @@EXIT ; yes, exit @@L2: mov si,[PC] GetByte ; fetch the instruction OpCode inc [PC] mov [OpCode],al mov [Paged],al mov ah,0 mov bx,offset OpCodeAll shl ax,1 ; multiply by 2 (size of entries) add bx,ax call [word bx] ; call routine through table (indirect) jmp short @@L0 ; repeat loop for ever! @@EXIT: xor ax,ax ; no errors ret endp Emulator ;******************************************************************************* ; Routine: mcCASE10 ; Purpose: Preprocess instruction prefix 10h ; Input : None ; Output : None proc mcCASE10 mov si,[PC] GetByte ; fetch additional OpCode inc [PC] mov [OpCode],al mov ah,0 mov bx,offset OpCode10 shl ax,1 ; multiply by 2 (size of entries) add bx,ax jmp [word bx] ; go to routine through table (indirect) endp mcCASE10 ;******************************************************************************* ; Routine: mcCASE11 ; Purpose: Preprocess instruction prefix 11h ; Input : None ; Output : None proc mcCASE11 mov si,[PC] GetByte ; fetch additional OpCode inc [PC] mov [OpCode],al mov ah,0 mov bx,offset OpCode11 shl ax,1 ; multiply by 2 (size of entries) add bx,ax jmp [word bx] ; go to routine through table (indirect) endp mcCASE11 ;******************************************************************************* ; OPCODE ROUTINES ;******************************************************************************* include "opcodes1.asm" ; in separate files :-) include "opcodes2.asm" include "os9.asm" ; OS-9 emulation routines ;******************************************************************************* ; S U B R O U T I N E S ;******************************************************************************* ;******************************************************************************* ; Routine: Write ; Purpose: Write a string to standard output ; Input : DS:DX points to string to print ; : CX holds string's length ; Output : None proc Write push ax ; save registers push bx mov ah,DOS_WRITE_TO_HANDLE mov bx,STDOUT int DOS_FUNCTION pop bx ; restore registers pop ax ret endp Write ;******************************************************************************* ; Routine: Beep ; Purpose: Sound the beeper ; Input : None ; Output : None proc Beep push ax ; save registers push bx mov ah,INT10_WRITE_TTY mov al,BELL mov bx,0 int VIDEO_SERVICE pop bx ; restore registers pop ax ret endp Beep ;******************************************************************************* end Init6809 ;*******************************************************************************
; A017171: a(n) = (9*n)^11. ; 0,31381059609,64268410079232,5559060566555523,131621703842267136,1532278301220703125,11384956040305711104,62050608388552823487,269561249468963094528,984770902183611232881,3138105960900000000000,8953382542587164451099,23316389970546096340992,56239892154164025151533,127079645979756182501376,271438504226343896484375,552061438912436417593344,1075488420943298174695497,2016810807672035804940288,3655587758352853102936371,6426841007923200000000000,10992079124206967022251589,18336527447218512795850752,29900179809133802678274543,47751966659678405306351616,74818276426792144775390625,115179299131727923510339584,174449211009120179071170507,260259114966540661762818048,382864924217801243807760861,555906056655552300000000000,797344928059979319406571079,1130621826892669783231168512,1586064857271688421018834553,2202600286091874661776377856,3029814862722305834326171875,4130428534112329328517709824,5583243494552763872208758517,7486643729106643154813687808,9962728175433694563518616351,13162170384226713600000000000,17269908148850843900874319569,22511778046375868461571254272,29162222232616955908481341563,37553208211903514205902340096,48084516708184142230517578125,61235568249106027885106264064,77578975691490042023332369527,97796027719021374067408109568,122694327386105632949003612841,153227830122070312500000000000,190519547304842441752783207059,235887204621778787349175468032,290872169017591458452425905573,357271984146678126737757198336,437176881962263889213818359375,533010667451475275290251362304,647576404628932868625869313537,784107364798056947318294243328,946323732846672542860142060331,1138495604030571110400000000000,1365512842385582953099747743549,1632962412666837646144657569792,1947213840615891587090802236583,2315513501476187716057433112576,2746088484090040290602197265625,3248260827692417886246573164544,3832572980745893676320153300547,4510925385916159307318021849088,5296727152648625743048300468821,6205060838855282348700000000000,7252862426039827902277855239039,8459117637862050464804269719552,9845075820754696052932493644593,11434482676844060410283537442816,13253833214176948070526123046875,15332646357210405181058432630784,17703762741766936677696968440557,20403667303288206466086126286848,23472838355327186004146948548311,26956124946896309452800000000000,30903154382632612361920641803529,35368771888846528308990606477312,40413514511486699264653341039603,46104121438977778609297928749056,52514083053871981186303564453125,59724231132399525700569787521024,67823372730410836936813413243567,76908970417978397093687992516608,87087871653173678051412515208801,98477090218361123288100000000000,111204642779864405740650828347019,125410443774169145108697628803072,141247261971041156494915846931613,158881742216171606063784692791296,178495496013322905416814990234375,200286264768555774090051808395264,224469159687083881075489084619577,251277982486744336279559399098368,280966631271107788718223484560291 pow $0,11 mul $0,31381059609
; A249124: Position of 2*n^6 in the ordered union of {h^6, h >= 1} and {2*k^6, k >= 1}. ; 2,4,6,8,10,12,14,16,19,21,23,25,27,29,31,33,36,38,40,42,44,46,48,50,53,55,57,59,61,63,65,67,70,72,74,76,78,80,82,84,87,89,91,93,95,97,99,101,104,106,108,110,112,114,116,118,120,123,125,127,129,131 mov $2,2 add $2,$0 add $0,$2 mov $4,2 mul $4,$0 mov $5,$0 sub $5,1 lpb $0,1 trn $3,$0 mov $0,$3 mov $1,$5 mul $4,3 mov $5,$4 div $5,98 add $5,$1 mov $1,$5 lpe add $1,1
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r8 push %rax push %rcx push %rdi push %rsi lea addresses_UC_ht+0xbfb7, %r8 nop nop nop nop sub $21348, %rdi movl $0x61626364, (%r8) nop nop nop xor %r8, %r8 lea addresses_WC_ht+0x143b7, %rdi nop and %r13, %r13 movb (%rdi), %al nop nop nop add $49873, %r13 lea addresses_normal_ht+0x17177, %rsi lea addresses_normal_ht+0xfbb6, %rdi nop nop sub $5519, %r11 mov $115, %rcx rep movsl nop nop nop nop sub $9447, %r12 lea addresses_UC_ht+0xadb7, %r11 nop nop nop nop and %r12, %r12 movups (%r11), %xmm7 vpextrq $1, %xmm7, %rcx nop nop nop add $41408, %rax lea addresses_A_ht+0x15fb7, %rsi lea addresses_WC_ht+0x18fb7, %rdi nop nop nop sub %r13, %r13 mov $22, %rcx rep movsl nop nop nop nop nop cmp $29831, %rdi lea addresses_A_ht+0x1d437, %r13 xor %rsi, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm3 vmovups %ymm3, (%r13) nop nop nop dec %rcx lea addresses_D_ht+0xb7b7, %rcx nop nop nop nop sub $35995, %r11 mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop nop nop nop add %rdi, %rdi lea addresses_A_ht+0xfb7, %rsi lea addresses_A_ht+0x10eb7, %rdi clflush (%rdi) nop add %r13, %r13 mov $100, %rcx rep movsb nop nop nop and %rdi, %rdi lea addresses_A_ht+0x1c702, %rsi nop nop inc %rax mov (%rsi), %r13 nop nop and %rdi, %rdi lea addresses_A_ht+0xfa37, %rsi xor %r11, %r11 mov (%rsi), %r13d nop nop nop xor $16162, %r11 lea addresses_UC_ht+0x165f7, %rcx nop nop nop nop inc %rsi mov $0x6162636465666768, %r12 movq %r12, %xmm1 vmovups %ymm1, (%rcx) and $45245, %rsi lea addresses_normal_ht+0x14139, %rdi nop nop sub $12988, %r8 vmovups (%rdi), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %rax nop nop nop cmp %r12, %r12 lea addresses_D_ht+0x71b7, %rsi lea addresses_WT_ht+0xaa3b, %rdi nop nop xor $48009, %r13 mov $126, %rcx rep movsq nop cmp $9416, %r8 lea addresses_D_ht+0x54ef, %rsi lea addresses_normal_ht+0x1975f, %rdi nop nop nop nop and $60179, %r12 mov $83, %rcx rep movsb cmp $7895, %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r9 push %rbp push %rcx push %rdi push %rsi // Load lea addresses_normal+0x6fbf, %r11 nop nop and $11241, %rsi mov (%r11), %r12 nop nop nop and $3144, %r12 // REPMOV lea addresses_D+0x12b57, %rsi lea addresses_normal+0x1b7, %rdi and $27908, %r9 mov $39, %rcx rep movsl nop dec %r9 // Faulty Load lea addresses_WT+0x167b7, %r9 nop nop nop nop cmp %r11, %r11 mov (%r9), %r12 lea oracles, %r11 and $0xff, %r12 shlq $12, %r12 mov (%r11,%r12,1), %r12 pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_D'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_normal'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': True, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': True, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, '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 */
<% from pwnlib.shellcraft.powerpc.linux import syscall %> <%page args="clock_id, tp"/> <%docstring> Invokes the syscall clock_gettime. See 'man 2 clock_gettime' for more information. Arguments: clock_id(clockid_t): clock_id tp(timespec): tp </%docstring> ${syscall('SYS_clock_gettime', clock_id, tp)}
// Copyright 2019 The IREE Authors // // Licensed under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "iree/compiler/Dialect/HAL/IR/HALTypes.h" #include "iree/compiler/Dialect/HAL/IR/HALDialect.h" #include "iree/compiler/Dialect/HAL/IR/HALOps.h" #include "iree/compiler/Dialect/Util/IR/UtilOps.h" #include "llvm/ADT/StringExtras.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" #include "mlir/IR/DialectImplementation.h" // clang-format off: must be included after all LLVM/MLIR headers. #define GET_ATTRDEF_CLASSES #include "iree/compiler/Dialect/HAL/IR/HALAttrs.cpp.inc" // IWYU pragma: keep #include "iree/compiler/Dialect/HAL/IR/HALEnums.cpp.inc" // IWYU pragma: keep #include "iree/compiler/Dialect/HAL/IR/HALStructs.cpp.inc" // IWYU pragma: keep // clang-format on namespace mlir { namespace iree_compiler { namespace IREE { namespace HAL { //===----------------------------------------------------------------------===// // Enum utilities //===----------------------------------------------------------------------===// template <typename AttrType> static LogicalResult parseEnumAttr(DialectAsmParser &parser, StringRef attrName, AttrType &attr) { Attribute genericAttr; auto loc = parser.getCurrentLocation(); if (failed(parser.parseAttribute(genericAttr, parser.getBuilder().getNoneType()))) { return parser.emitError(loc) << "failed to parse '" << attrName << "' enum string value"; } auto stringAttr = genericAttr.dyn_cast<StringAttr>(); if (!stringAttr) { return parser.emitError(loc) << "expected " << attrName << " attribute specified as string"; } auto symbolized = symbolizeEnum<typename AttrType::ValueType>(stringAttr.getValue()); if (!symbolized.hasValue()) { return parser.emitError(loc) << "failed to parse '" << attrName << "' enum value"; } attr = AttrType::get(parser.getBuilder().getContext(), symbolized.getValue()); return success(); } template <typename AttrType> static LogicalResult parseOptionalEnumAttr(DialectAsmParser &parser, StringRef attrName, AttrType &attr) { if (succeeded(parser.parseOptionalQuestion())) { // Special case `?` to indicate any/none/undefined/etc. attr = AttrType::get(parser.getBuilder().getContext(), 0); return success(); } return parseEnumAttr<AttrType>(parser, attrName, attr); } static LogicalResult parseMemoryType(DialectAsmParser &parser, Attribute &attr) { if (succeeded(parser.parseOptionalQuestion())) { attr = parser.getBuilder().getI32IntegerAttr(0); return success(); } std::string fullString; if (succeeded(parser.parseOptionalString(&fullString))) { auto symbolized = symbolizeEnum<MemoryTypeBitfield>(fullString); if (!symbolized.hasValue()) { return parser.emitError(parser.getCurrentLocation()) << "failed to parse memory type enum value"; } attr = parser.getBuilder().getI32IntegerAttr( static_cast<int32_t>(symbolized.getValue())); return success(); } StringRef shortString; if (failed(parser.parseKeyword(&shortString))) { return parser.emitError(parser.getCurrentLocation()) << "failed to find memory type short string"; } MemoryTypeBitfield memoryType = MemoryTypeBitfield::None; for (char c : shortString) { switch (c) { case 'T': memoryType = memoryType | MemoryTypeBitfield::Transient; break; case 'h': memoryType = memoryType | MemoryTypeBitfield::HostVisible; break; case 'H': memoryType = memoryType | MemoryTypeBitfield::HostLocal; break; case 'c': memoryType = memoryType | MemoryTypeBitfield::HostCoherent; break; case 'C': memoryType = memoryType | MemoryTypeBitfield::HostCached; break; case 'd': memoryType = memoryType | MemoryTypeBitfield::DeviceVisible; break; case 'D': memoryType = memoryType | MemoryTypeBitfield::DeviceLocal; break; default: return parser.emitError(parser.getCurrentLocation()) << "unknown memory type short-form char: " << c; } } attr = parser.getBuilder().getI32IntegerAttr(static_cast<int32_t>(memoryType)); return success(); } static void printMemoryType(DialectAsmPrinter &printer, MemoryTypeBitfield memoryType) { if (memoryType == MemoryTypeBitfield::None) { printer << '?'; return; } if (allEnumBitsSet(memoryType, MemoryTypeBitfield::Transient)) { printer << 't'; } if (allEnumBitsSet(memoryType, MemoryTypeBitfield::HostLocal)) { printer << 'H'; } else if (allEnumBitsSet(memoryType, MemoryTypeBitfield::HostVisible)) { printer << 'h'; } if (allEnumBitsSet(memoryType, MemoryTypeBitfield::HostCoherent)) { printer << 'c'; } if (allEnumBitsSet(memoryType, MemoryTypeBitfield::HostCached)) { printer << 'C'; } if (allEnumBitsSet(memoryType, MemoryTypeBitfield::DeviceLocal)) { printer << 'D'; } else if (allEnumBitsSet(memoryType, MemoryTypeBitfield::DeviceVisible)) { printer << 'd'; } } static LogicalResult parseMemoryAccess(DialectAsmParser &parser, Attribute &attr) { if (succeeded(parser.parseOptionalQuestion())) { attr = parser.getBuilder().getI32IntegerAttr(0); return success(); } std::string fullString; if (succeeded(parser.parseOptionalString(&fullString))) { auto symbolized = symbolizeEnum<MemoryAccessBitfield>(fullString); if (!symbolized.hasValue()) { return parser.emitError(parser.getCurrentLocation()) << "failed to parse memory access enum value"; } attr = parser.getBuilder().getI32IntegerAttr( static_cast<int32_t>(symbolized.getValue())); return success(); } StringRef shortString; if (failed(parser.parseKeyword(&shortString))) { return parser.emitError(parser.getCurrentLocation()) << "failed to find memory access short string"; } MemoryAccessBitfield memoryAccess = MemoryAccessBitfield::None; for (char c : shortString) { switch (c) { case 'R': memoryAccess = memoryAccess | MemoryAccessBitfield::Read; break; case 'W': memoryAccess = memoryAccess | MemoryAccessBitfield::Write; break; case 'D': memoryAccess = memoryAccess | MemoryAccessBitfield::Discard; break; case 'A': memoryAccess = memoryAccess | MemoryAccessBitfield::MayAlias; break; default: return parser.emitError(parser.getCurrentLocation()) << "unknown memory access short-form char: " << c; } } attr = parser.getBuilder().getI32IntegerAttr(static_cast<int32_t>(memoryAccess)); return success(); } static void printMemoryAccess(DialectAsmPrinter &printer, MemoryAccessBitfield memoryAccess) { if (memoryAccess == MemoryAccessBitfield::None) { printer << '?'; return; } if (allEnumBitsSet(memoryAccess, MemoryAccessBitfield::Read)) { printer << 'R'; } if (allEnumBitsSet(memoryAccess, MemoryAccessBitfield::Discard)) { printer << 'D'; } if (allEnumBitsSet(memoryAccess, MemoryAccessBitfield::Write)) { printer << 'W'; } if (allEnumBitsSet(memoryAccess, MemoryAccessBitfield::MayAlias)) { printer << 'A'; } } static LogicalResult parseBufferUsage(DialectAsmParser &parser, Attribute &attr) { if (succeeded(parser.parseOptionalQuestion())) { attr = parser.getBuilder().getI32IntegerAttr(0); return success(); } std::string fullString; if (succeeded(parser.parseOptionalString(&fullString))) { auto symbolized = symbolizeEnum<BufferUsageBitfield>(fullString); if (!symbolized.hasValue()) { return parser.emitError(parser.getCurrentLocation()) << "failed to parse buffer usage enum value"; } attr = parser.getBuilder().getI32IntegerAttr( static_cast<int32_t>(symbolized.getValue())); return success(); } StringRef shortString; if (failed(parser.parseKeyword(&shortString))) { return parser.emitError(parser.getCurrentLocation()) << "failed to find buffer usage short string"; } BufferUsageBitfield usage = BufferUsageBitfield::None; for (char c : shortString) { switch (c) { case 'C': usage = usage | BufferUsageBitfield::Constant; break; case 'T': usage = usage | BufferUsageBitfield::Transfer; break; case 'M': usage = usage | BufferUsageBitfield::Mapping; break; case 'D': usage = usage | BufferUsageBitfield::Dispatch; break; default: return parser.emitError(parser.getCurrentLocation()) << "unknown buffer usage short-form char: " << c; } } attr = parser.getBuilder().getI32IntegerAttr(static_cast<int32_t>(usage)); return success(); } static void printBufferUsage(DialectAsmPrinter &printer, BufferUsageBitfield usage) { if (usage == BufferUsageBitfield::None) { printer << '?'; return; } if (allEnumBitsSet(usage, BufferUsageBitfield::Constant)) { printer << 'C'; } if (allEnumBitsSet(usage, BufferUsageBitfield::Transfer)) { printer << 'T'; } if (allEnumBitsSet(usage, BufferUsageBitfield::Mapping)) { printer << 'M'; } if (allEnumBitsSet(usage, BufferUsageBitfield::Dispatch)) { printer << 'D'; } } //===----------------------------------------------------------------------===// // Element types //===----------------------------------------------------------------------===// // Keep these in sync with iree/hal/api.h namespace { enum class NumericalType : uint32_t { kUnknown = 0x00, kIntegerSigned = 0x01, kIntegerUnsigned = 0x02, // TODO(benvanik): specialize with semantics from APFloat. kFloatIEEE = 0x03, }; constexpr inline int32_t makeElementTypeValue(NumericalType numericalType, int32_t bitCount) { return (static_cast<uint32_t>(numericalType) << 24) | bitCount; } } // namespace llvm::Optional<int32_t> getElementTypeValue(Type type) { if (auto intType = type.dyn_cast_or_null<IntegerType>()) { // TODO(benvanik): add signed/unsigned check when landed in MLIR. return makeElementTypeValue(NumericalType::kIntegerSigned, intType.getWidth()); } else if (auto floatType = type.dyn_cast_or_null<FloatType>()) { switch (APFloat::SemanticsToEnum(floatType.getFloatSemantics())) { case APFloat::S_IEEEhalf: case APFloat::S_IEEEsingle: case APFloat::S_IEEEdouble: case APFloat::S_IEEEquad: return makeElementTypeValue(NumericalType::kFloatIEEE, floatType.getWidth()); default: return llvm::None; } } return llvm::None; } IntegerAttr getElementTypeAttr(Type type) { auto elementType = getElementTypeValue(type); if (!elementType) return {}; return IntegerAttr::get(IntegerType::get(type.getContext(), 32), elementType.getValue()); } size_t getElementBitCount(IntegerAttr elementType) { return static_cast<size_t>((elementType.getValue().getZExtValue()) & 0xFF); } Value getElementBitCount(Location loc, Value elementType, OpBuilder &builder) { return builder.createOrFold<AndOp>( loc, builder.createOrFold<IndexCastOp>(loc, builder.getIndexType(), elementType), builder.createOrFold<ConstantIndexOp>(loc, 0xFF)); } size_t getElementByteCount(IntegerAttr elementType) { return (getElementBitCount(elementType) + 8 - 1) / 8; } Value getElementByteCount(Location loc, Value elementType, OpBuilder &builder) { auto c1 = builder.createOrFold<ConstantIndexOp>(loc, 1); auto c8 = builder.createOrFold<ConstantIndexOp>(loc, 8); auto bitCount = getElementBitCount(loc, elementType, builder); return builder.createOrFold<UnsignedDivIOp>( loc, builder.createOrFold<SubIOp>( loc, builder.createOrFold<AddIOp>(loc, bitCount, c8), c1), c8); } llvm::Optional<int32_t> getEncodingTypeValue(Attribute attr) { // TODO(#6762): encoding attribute handling/mapping to enums. assert(!attr && "encoding types other than default not yet supported"); // Default to IREE_HAL_ENCODING_TYPE_DENSE_ROW_MAJOR for now. return 1; } IntegerAttr getEncodingTypeAttr(Attribute attr, MLIRContext *context) { auto encodingType = getEncodingTypeValue(attr); if (!encodingType) return {}; return IntegerAttr::get(IntegerType::get(context, 32), encodingType.getValue()); } //===----------------------------------------------------------------------===// // Size-aware type utils //===----------------------------------------------------------------------===// // Returns the SSA value containing the size of the given |value|. static Value lookupValueSize(Value value) { assert(value.getType().isa<IREE::Util::SizeAwareTypeInterface>()); auto definingOp = value.getDefiningOp(); if (!definingOp) { return {}; // Not yet implemented. } // Skip do-not-optimize ops. if (auto dnoOp = dyn_cast<IREE::Util::DoNotOptimizeOp>(definingOp)) { return lookupValueSize(dnoOp.getOperand(0)); } // Query size from the size-aware op that defined the value, as it knows how // to get/build the right value. unsigned resultIndex = -1; for (unsigned i = 0; i < definingOp->getNumResults(); ++i) { if (definingOp->getResult(i) == value) { resultIndex = i; break; } } assert(resultIndex != -1 && "result not in results"); auto sizeAwareOp = dyn_cast<IREE::Util::SizeAwareOpInterface>(definingOp); if (!sizeAwareOp) return {}; return sizeAwareOp.getResultSize(resultIndex); } //===----------------------------------------------------------------------===// // Object types //===----------------------------------------------------------------------===// Value BufferType::inferSizeFromValue(Location loc, Value value, OpBuilder &builder) const { return builder.createOrFold<BufferLengthOp>(loc, builder.getIndexType(), value); } Value BufferViewType::inferSizeFromValue(Location loc, Value value, OpBuilder &builder) const { return builder.createOrFold<BufferViewByteLengthOp>(loc, value); } //===----------------------------------------------------------------------===// // Struct types //===----------------------------------------------------------------------===// BufferConstraintsAttr intersectBufferConstraints(BufferConstraintsAttr lhs, BufferConstraintsAttr rhs) { if (!lhs) return rhs; if (!rhs) return lhs; Builder b(lhs.getContext()); return BufferConstraintsAttr::get( b.getIndexAttr(std::min(lhs.max_allocation_size().getSExtValue(), rhs.max_allocation_size().getSExtValue())), b.getIndexAttr( std::max(lhs.min_buffer_offset_alignment().getSExtValue(), rhs.min_buffer_offset_alignment().getSExtValue())), b.getIndexAttr(std::min(lhs.max_buffer_range().getSExtValue(), rhs.max_buffer_range().getSExtValue())), b.getIndexAttr( std::max(lhs.min_buffer_range_alignment().getSExtValue(), rhs.min_buffer_range_alignment().getSExtValue()))); } // TODO(benvanik): runtime buffer constraint queries from the allocator. // We can add folders for those when the allocator is strongly-typed with // #hal.buffer_constraints and otherwise leave them for runtime queries. BufferConstraintsAdaptor::BufferConstraintsAdaptor(Location loc, Value allocator) : loc_(loc), allocator_(allocator) { // Picked to represent what we kind of want on CPU today. uint64_t maxAllocationSize = 1 * 1024 * 1024 * 1024ull; uint64_t minBufferOffsetAlignment = 16ull; uint64_t maxBufferRange = 1 * 1024 * 1024 * 1024ull; uint64_t minBufferRangeAlignment = 16ull; Builder b(loc.getContext()); bufferConstraints_ = BufferConstraintsAttr::get( b.getIndexAttr(maxAllocationSize), b.getIndexAttr(minBufferOffsetAlignment), b.getIndexAttr(maxBufferRange), b.getIndexAttr(minBufferRangeAlignment)); } Value BufferConstraintsAdaptor::getMaxAllocationSize(OpBuilder &builder) { return builder.createOrFold<mlir::ConstantOp>( loc_, bufferConstraints_.max_allocation_sizeAttr()); } Value BufferConstraintsAdaptor::getMinBufferOffsetAlignment( OpBuilder &builder) { return builder.createOrFold<mlir::ConstantOp>( loc_, bufferConstraints_.min_buffer_offset_alignmentAttr()); } Value BufferConstraintsAdaptor::getMaxBufferRange(OpBuilder &builder) { return builder.createOrFold<mlir::ConstantOp>( loc_, bufferConstraints_.max_buffer_rangeAttr()); } Value BufferConstraintsAdaptor::getMinBufferRangeAlignment(OpBuilder &builder) { return builder.createOrFold<mlir::ConstantOp>( loc_, bufferConstraints_.min_buffer_range_alignmentAttr()); } //===----------------------------------------------------------------------===// // Attribute printing and parsing //===----------------------------------------------------------------------===// // static Attribute BufferConstraintsAttr::parse(DialectAsmParser &p) { auto b = p.getBuilder(); if (failed(p.parseLess())) return {}; IntegerAttr maxAllocationSizeAttr; IntegerAttr minBufferOffsetAlignmentAttr; IntegerAttr maxBufferRangeAttr; IntegerAttr minBufferRangeAlignmentAttr; if (failed(p.parseKeyword("max_allocation_size")) || failed(p.parseEqual()) || failed(p.parseAttribute(maxAllocationSizeAttr, b.getIndexType())) || failed(p.parseComma()) || failed(p.parseKeyword("min_buffer_offset_alignment")) || failed(p.parseEqual()) || failed( p.parseAttribute(minBufferOffsetAlignmentAttr, b.getIndexType())) || failed(p.parseComma()) || failed(p.parseKeyword("max_buffer_range")) || failed(p.parseEqual()) || failed(p.parseAttribute(maxBufferRangeAttr, b.getIndexType())) || failed(p.parseComma()) || failed(p.parseKeyword("min_buffer_range_alignment")) || failed(p.parseEqual()) || failed(p.parseAttribute(minBufferRangeAlignmentAttr, b.getIndexType()))) { return {}; } if (failed(p.parseGreater())) return {}; return BufferConstraintsAttr::get( maxAllocationSizeAttr, minBufferOffsetAlignmentAttr, maxBufferRangeAttr, minBufferRangeAlignmentAttr); } void BufferConstraintsAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getKindName() << "<"; os << "max_allocation_size = " << max_allocation_size() << ", "; os << "min_buffer_offset_alignment = " << min_buffer_offset_alignment() << ", "; os << "max_buffer_range = " << max_buffer_range() << ", "; os << "min_buffer_range_alignment = " << min_buffer_range_alignment(); os << ">"; } // static Attribute DescriptorSetLayoutBindingAttr::parse(DialectAsmParser &p) { auto b = p.getBuilder(); IntegerAttr bindingAttr; DescriptorTypeAttr typeAttr; MemoryAccessBitfieldAttr accessAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(bindingAttr, b.getIntegerType(32))) || failed(p.parseComma()) || failed(parseEnumAttr(p, "type", typeAttr)) || failed(p.parseComma()) || failed(parseMemoryAccess(p, accessAttr)) || failed(p.parseGreater())) { return {}; } return get(bindingAttr, typeAttr, accessAttr); } void DescriptorSetLayoutBindingAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getKindName() << "<"; os << binding() << ", "; os << "\"" << stringifyDescriptorType(type()) << "\", "; printMemoryAccess(p, access()); os << ">"; } //===----------------------------------------------------------------------===// // #hal.device.target //===----------------------------------------------------------------------===// // static DeviceTargetAttr DeviceTargetAttr::get(MLIRContext *context, StringRef deviceID) { // TODO(benvanik): query default configuration from the target backend. return get(context, StringAttr::get(context, deviceID), DictionaryAttr::get(context)); } // static Attribute DeviceTargetAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { auto b = p.getBuilder(); StringAttr deviceIDAttr; DictionaryAttr configAttr; // `<"device-id"` if (failed(p.parseLess()) || failed(p.parseAttribute(deviceIDAttr))) { return {}; } // `, {config}` if (succeeded(p.parseOptionalComma()) && failed(p.parseAttribute(configAttr))) { return {}; } // `>` if (failed(p.parseGreater())) { return {}; } return get(b.getContext(), deviceIDAttr, configAttr); } void DeviceTargetAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getMnemonic() << "<"; p.printAttribute(getDeviceID()); auto configAttr = getConfiguration(); if (configAttr && !configAttr.empty()) { os << ", "; p.printAttribute(configAttr); } os << ">"; } std::string DeviceTargetAttr::getSymbolNameFragment() { auto deviceName = getDeviceID().getValue().lower(); std::replace(deviceName.begin(), deviceName.end(), '-', '_'); return deviceName; } Attribute DeviceTargetAttr::getMatchExpression() { return DeviceMatchIDAttr::get(*this); } BufferConstraintsAttr DeviceTargetAttr::getBufferConstraints() { BufferConstraintsAttr constraintsAttr; auto configAttr = getConfiguration(); if (configAttr) { constraintsAttr = configAttr.getAs<BufferConstraintsAttr>("buffer_constraints"); } return constraintsAttr ? constraintsAttr : getDefaultHostBufferConstraints(getContext()); } SmallVector<ExecutableTargetAttr, 4> DeviceTargetAttr::getExecutableTargets() { SmallVector<ExecutableTargetAttr, 4> resultAttrs; auto configAttr = getConfiguration(); if (configAttr) { auto targetsAttr = configAttr.getAs<ArrayAttr>("executable_targets"); if (targetsAttr) { for (auto attr : targetsAttr.getValue()) { resultAttrs.push_back(attr.dyn_cast<ExecutableTargetAttr>()); } } } return resultAttrs; } // static SmallVector<IREE::HAL::DeviceTargetAttr, 4> DeviceTargetAttr::lookup( Operation *op) { auto attrId = mlir::Identifier::get("hal.device.targets", op->getContext()); while (op) { auto targetsAttr = op->getAttrOfType<ArrayAttr>(attrId); if (targetsAttr) { SmallVector<IREE::HAL::DeviceTargetAttr, 4> result; for (auto targetAttr : targetsAttr) { result.push_back(targetAttr.cast<IREE::HAL::DeviceTargetAttr>()); } return result; } op = op->getParentOp(); } return {}; // No devices found; let caller decide what to do. } // static BufferConstraintsAttr DeviceTargetAttr::getDefaultHostBufferConstraints( MLIRContext *context) { // Picked to represent what we kind of want on CPU today. uint64_t maxAllocationSize = 1 * 1024 * 1024 * 1024ull; uint64_t minBufferOffsetAlignment = 16ull; uint64_t maxBufferRange = 1 * 1024 * 1024 * 1024ull; uint64_t minBufferRangeAlignment = 16ull; Builder b(context); return BufferConstraintsAttr::get(b.getIndexAttr(maxAllocationSize), b.getIndexAttr(minBufferOffsetAlignment), b.getIndexAttr(maxBufferRange), b.getIndexAttr(minBufferRangeAlignment)); } // static BufferConstraintsAttr DeviceTargetAttr::lookupConservativeBufferConstraints( Operation *op) { BufferConstraintsAttr resultAttr = {}; for (auto targetAttr : IREE::HAL::DeviceTargetAttr::lookup(op)) { auto configAttr = targetAttr.getConfiguration(); if (!configAttr) continue; auto targetConstraintsAttr = configAttr.getAs<BufferConstraintsAttr>("buffer_constraints"); if (!targetConstraintsAttr) continue; resultAttr = intersectBufferConstraints(resultAttr, targetConstraintsAttr); } return resultAttr ? resultAttr : getDefaultHostBufferConstraints(op->getContext()); } // static SmallVector<ExecutableTargetAttr, 4> DeviceTargetAttr::lookupExecutableTargets( Operation *op) { SmallVector<ExecutableTargetAttr, 4> resultAttrs; for (auto deviceTargetAttr : lookup(op)) { for (auto executableTargetAttr : deviceTargetAttr.getExecutableTargets()) { if (!llvm::is_contained(resultAttrs, executableTargetAttr)) { resultAttrs.push_back(executableTargetAttr); } } } return resultAttrs; } //===----------------------------------------------------------------------===// // #hal.executable.target //===----------------------------------------------------------------------===// // static ExecutableTargetAttr ExecutableTargetAttr::get(MLIRContext *context, StringRef backend, StringRef format) { return get(context, StringAttr::get(context, backend), StringAttr::get(context, format), DictionaryAttr::get(context)); } // static Attribute ExecutableTargetAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { auto b = p.getBuilder(); StringAttr backendAttr; StringAttr formatAttr; DictionaryAttr configurationAttr; // `<"backend", "format"` if (failed(p.parseLess()) || failed(p.parseAttribute(backendAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(formatAttr))) { return {}; } // `, {config}` if (succeeded(p.parseOptionalComma()) && failed(p.parseAttribute(configurationAttr))) { return {}; } // `>` if (failed(p.parseGreater())) { return {}; } return get(b.getContext(), backendAttr, formatAttr, configurationAttr); } void ExecutableTargetAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getMnemonic() << "<"; p.printAttribute(getBackend()); os << ", "; p.printAttribute(getFormat()); auto config = getConfiguration(); if (config && !config.empty()) { os << ", "; p.printAttribute(config); } os << ">"; } std::string ExecutableTargetAttr::getSymbolNameFragment() { auto format = getFormat().getValue().lower(); std::replace(format.begin(), format.end(), '-', '_'); return format; } Attribute ExecutableTargetAttr::getMatchExpression() { return DeviceMatchExecutableFormatAttr::get(getContext(), getFormat()); } //===----------------------------------------------------------------------===// // #hal.match.* //===----------------------------------------------------------------------===// Value MatchAlwaysAttr::buildConditionExpression(Location loc, Value value, OpBuilder builder) const { // #hal.match.always -> true return builder.createOrFold<ConstantIntOp>(loc, /*value=*/1, /*width=*/1); } static ArrayAttr parseMultiMatchAttrArray(DialectAsmParser &p) { auto b = p.getBuilder(); SmallVector<Attribute, 4> conditionAttrs; if (failed(p.parseLess()) || failed(p.parseLSquare())) { return {}; } do { Attribute conditionAttr; if (failed(p.parseAttribute(conditionAttr))) { return {}; } conditionAttrs.push_back(conditionAttr); } while (succeeded(p.parseOptionalComma())); if (failed(p.parseRSquare()) || failed(p.parseGreater())) { return {}; } return b.getArrayAttr(conditionAttrs); } static void printMultiMatchAttrList(ArrayAttr conditionAttrs, DialectAsmPrinter &p) { auto &os = p.getStream(); os << "<["; interleaveComma(conditionAttrs, os, [&](Attribute condition) { os << condition; }); os << "]>"; } // static Attribute MatchAnyAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { return get(context, parseMultiMatchAttrArray(p)); } void MatchAnyAttr::print(DialectAsmPrinter &p) const { p << getMnemonic(); printMultiMatchAttrList(getConditions(), p); } Value MatchAnyAttr::buildConditionExpression(Location loc, Value value, OpBuilder builder) const { // #hal.match.any<[a, b, c]> -> or(or(a, b), c) if (getConditions().empty()) { // Empty returns false (no conditions match). return builder.create<ConstantIntOp>(loc, /*value=*/0, /*width=*/1); } auto conditionValues = llvm::map_range(getConditions(), [&](MatchAttrInterface attr) { return attr.buildConditionExpression(loc, value, builder); }); Value resultValue; for (auto conditionValue : conditionValues) { resultValue = resultValue ? builder.createOrFold<OrOp>(loc, resultValue, conditionValue) : conditionValue; } return resultValue; } // static Attribute MatchAllAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { return get(context, parseMultiMatchAttrArray(p)); } void MatchAllAttr::print(DialectAsmPrinter &p) const { p << getMnemonic(); printMultiMatchAttrList(getConditions(), p); } Value MatchAllAttr::buildConditionExpression(Location loc, Value value, OpBuilder builder) const { // #hal.match.all<[a, b, c]> -> and(and(a, b), c) if (getConditions().empty()) { // Empty returns true (all 0 conditions match). return builder.create<ConstantIntOp>(loc, /*value=*/1, /*width=*/1); } auto conditionValues = llvm::map_range(getConditions(), [&](MatchAttrInterface attr) { return attr.buildConditionExpression(loc, value, builder); }); Value resultValue; for (auto conditionValue : conditionValues) { resultValue = resultValue ? builder.createOrFold<AndOp>(loc, resultValue, conditionValue) : conditionValue; } return resultValue; } // static Attribute DeviceMatchIDAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { StringAttr patternAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(patternAttr)) || failed(p.parseGreater())) { return {}; } return get(context, patternAttr); } void DeviceMatchIDAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getMnemonic() << "<"; p.printAttribute(getPattern()); os << ">"; } Value DeviceMatchIDAttr::buildConditionExpression(Location loc, Value device, OpBuilder builder) const { auto i1Type = builder.getI1Type(); return builder .create<IREE::HAL::DeviceQueryOp>( loc, i1Type, i1Type, device, builder.getStringAttr("hal.device.id"), getPattern(), builder.getZeroAttr(i1Type)) .value(); } // static Attribute DeviceMatchFeatureAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { StringAttr patternAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(patternAttr)) || failed(p.parseGreater())) { return {}; } return get(context, patternAttr); } void DeviceMatchFeatureAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getMnemonic() << "<"; p.printAttribute(getPattern()); os << ">"; } Value DeviceMatchFeatureAttr::buildConditionExpression( Location loc, Value device, OpBuilder builder) const { auto i1Type = builder.getI1Type(); return builder .create<IREE::HAL::DeviceQueryOp>( loc, i1Type, i1Type, device, builder.getStringAttr("hal.device.feature"), getPattern(), builder.getZeroAttr(i1Type)) .value(); } // static Attribute DeviceMatchArchitectureAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { StringAttr patternAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(patternAttr)) || failed(p.parseGreater())) { return {}; } return get(context, patternAttr); } void DeviceMatchArchitectureAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getMnemonic() << "<"; p.printAttribute(getPattern()); os << ">"; } Value DeviceMatchArchitectureAttr::buildConditionExpression( Location loc, Value device, OpBuilder builder) const { auto i1Type = builder.getI1Type(); return builder .create<IREE::HAL::DeviceQueryOp>( loc, i1Type, i1Type, device, builder.getStringAttr("hal.device.architecture"), getPattern(), builder.getZeroAttr(i1Type)) .value(); } // static Attribute DeviceMatchExecutableFormatAttr::parse(MLIRContext *context, DialectAsmParser &p, Type type) { StringAttr patternAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(patternAttr)) || failed(p.parseGreater())) { return {}; } return get(context, patternAttr); } void DeviceMatchExecutableFormatAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getMnemonic() << "<"; p.printAttribute(getPattern()); os << ">"; } Value DeviceMatchExecutableFormatAttr::buildConditionExpression( Location loc, Value device, OpBuilder builder) const { auto i1Type = builder.getI1Type(); return builder .create<IREE::HAL::DeviceQueryOp>( loc, i1Type, i1Type, device, builder.getStringAttr("hal.executable.format"), getPattern(), builder.getZeroAttr(i1Type)) .value(); } //===----------------------------------------------------------------------===// // Experimental interface plumbing //===----------------------------------------------------------------------===// // static Attribute ExConstantStorageAttr::parse(DialectAsmParser &p) { StringAttr bindingAttr; StringAttr storageAttr; IntegerAttr offsetAttr; IntegerAttr lengthAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(bindingAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(storageAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(offsetAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(lengthAttr)) || failed(p.parseGreater())) { return {}; } return get(bindingAttr, storageAttr, offsetAttr, lengthAttr); } void ExConstantStorageAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getKindName() << "<"; p.printAttribute(bindingAttr()); os << ", "; p.printAttribute(storageAttr()); os << ", "; p.printAttribute(offsetAttr()); os << ", "; p.printAttribute(lengthAttr()); os << ">"; } // static Attribute ExPushConstantAttr::parse(DialectAsmParser &p) { IntegerAttr ordinalAttr; IntegerAttr operandAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(ordinalAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(operandAttr)) || failed(p.parseGreater())) { return {}; } return get(ordinalAttr, operandAttr); } void ExPushConstantAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getKindName() << "<"; p.printAttribute(ordinalAttr()); os << ", "; p.printAttribute(operandAttr()); os << ">"; } // static Attribute ExOperandBufferAttr::parse(DialectAsmParser &p) { StringAttr bindingAttr; IntegerAttr operandAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(bindingAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(operandAttr)) || failed(p.parseGreater())) { return {}; } return get(bindingAttr, operandAttr); } void ExOperandBufferAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getKindName() << "<"; p.printAttribute(bindingAttr()); os << ", "; p.printAttribute(operandAttr()); os << ">"; } // static Attribute ExResultBufferAttr::parse(DialectAsmParser &p) { StringAttr bindingAttr; IntegerAttr resultAttr; if (failed(p.parseLess()) || failed(p.parseAttribute(bindingAttr)) || failed(p.parseComma()) || failed(p.parseAttribute(resultAttr)) || failed(p.parseGreater())) { return {}; } return get(bindingAttr, resultAttr); } void ExResultBufferAttr::print(DialectAsmPrinter &p) const { auto &os = p.getStream(); os << getKindName() << "<"; p.printAttribute(bindingAttr()); os << ", "; p.printAttribute(resultAttr()); os << ">"; } //===----------------------------------------------------------------------===// // Dialect registration //===----------------------------------------------------------------------===// #include "iree/compiler/Dialect/HAL/IR/HALAttrInterfaces.cpp.inc" #include "iree/compiler/Dialect/HAL/IR/HALOpInterfaces.cpp.inc" #include "iree/compiler/Dialect/HAL/IR/HALTypeInterfaces.cpp.inc" void HALDialect::registerAttributes() { addAttributes<BufferConstraintsAttr, DescriptorSetLayoutBindingAttr, // Experimental: ExConstantStorageAttr, ExPushConstantAttr, ExOperandBufferAttr, ExResultBufferAttr>(); addAttributes< #define GET_ATTRDEF_LIST #include "iree/compiler/Dialect/HAL/IR/HALAttrs.cpp.inc" // IWYU pragma: keep >(); } void HALDialect::registerTypes() { addTypes<AllocatorType, BufferType, BufferViewType, CommandBufferType, DescriptorSetType, DescriptorSetLayoutType, DeviceType, EventType, ExecutableType, ExecutableLayoutType, RingBufferType, SemaphoreType>(); } //===----------------------------------------------------------------------===// // Attribute printing and parsing //===----------------------------------------------------------------------===// Attribute HALDialect::parseAttribute(DialectAsmParser &parser, Type type) const { StringRef mnemonic; if (failed(parser.parseKeyword(&mnemonic))) return {}; Attribute genAttr; OptionalParseResult parseResult = generatedAttributeParser(getContext(), parser, mnemonic, type, genAttr); if (parseResult.hasValue()) return genAttr; if (mnemonic == BufferConstraintsAttr::getKindName()) { return BufferConstraintsAttr::parse(parser); } else if (mnemonic == DescriptorSetLayoutBindingAttr::getKindName()) { return DescriptorSetLayoutBindingAttr::parse(parser); } else if (mnemonic == ExConstantStorageAttr::getKindName()) { return ExConstantStorageAttr::parse(parser); } else if (mnemonic == ExPushConstantAttr::getKindName()) { return ExPushConstantAttr::parse(parser); } else if (mnemonic == ExOperandBufferAttr::getKindName()) { return ExOperandBufferAttr::parse(parser); } else if (mnemonic == ExResultBufferAttr::getKindName()) { return ExResultBufferAttr::parse(parser); } parser.emitError(parser.getNameLoc()) << "unknown HAL attribute: " << mnemonic; return {}; } void HALDialect::printAttribute(Attribute attr, DialectAsmPrinter &p) const { TypeSwitch<Attribute>(attr) .Case<BufferConstraintsAttr, DescriptorSetLayoutBindingAttr, // Experimental: ExConstantStorageAttr, ExPushConstantAttr, ExOperandBufferAttr, ExResultBufferAttr>([&](auto typedAttr) { typedAttr.print(p); }) .Default([&](Attribute) { if (failed(generatedAttributePrinter(attr, p))) { llvm_unreachable("unhandled HAL attribute kind"); } }); } //===----------------------------------------------------------------------===// // Type printing and parsing //===----------------------------------------------------------------------===// Type HALDialect::parseType(DialectAsmParser &parser) const { StringRef typeKind; if (parser.parseKeyword(&typeKind)) return {}; auto type = llvm::StringSwitch<Type>(typeKind) .Case("allocator", AllocatorType::get(getContext())) .Case("buffer", BufferType::get(getContext())) .Case("buffer_view", BufferViewType::get(getContext())) .Case("command_buffer", CommandBufferType::get(getContext())) .Case("descriptor_set", DescriptorSetType::get(getContext())) .Case("descriptor_set_layout", DescriptorSetLayoutType::get(getContext())) .Case("device", DeviceType::get(getContext())) .Case("event", EventType::get(getContext())) .Case("executable", ExecutableType::get(getContext())) .Case("executable_layout", ExecutableLayoutType::get(getContext())) .Case("ring_buffer", RingBufferType::get(getContext())) .Case("semaphore", SemaphoreType::get(getContext())) .Default(nullptr); if (!type) { parser.emitError(parser.getCurrentLocation()) << "unknown HAL type: " << typeKind; } return type; } void HALDialect::printType(Type type, DialectAsmPrinter &p) const { if (type.isa<AllocatorType>()) { p << "allocator"; } else if (type.isa<BufferType>()) { p << "buffer"; } else if (type.isa<BufferViewType>()) { p << "buffer_view"; } else if (type.isa<CommandBufferType>()) { p << "command_buffer"; } else if (type.isa<DescriptorSetType>()) { p << "descriptor_set"; } else if (type.isa<DescriptorSetLayoutType>()) { p << "descriptor_set_layout"; } else if (type.isa<DeviceType>()) { p << "device"; } else if (type.isa<EventType>()) { p << "event"; } else if (type.isa<ExecutableType>()) { p << "executable"; } else if (type.isa<ExecutableLayoutType>()) { p << "executable_layout"; } else if (type.isa<RingBufferType>()) { p << "ring_buffer"; } else if (type.isa<SemaphoreType>()) { p << "semaphore"; } else { llvm_unreachable("unknown HAL type"); } } } // namespace HAL } // namespace IREE } // namespace iree_compiler } // namespace mlir
; ; PIC非対応の場合は、printf関数は、'call printf'で呼び出せる ; この場合は、gccでリンケージするときに -no-pie オプションを追加する ; ; $ nasm -f elf64 use_c_printf_no_pic.asm ; $ gcc use_c_printf_no_pic.o -no-pie -o pri ; $ ./pri ; extern printf section .data fmt: db "x=%d", 0x0A, 0 section .text global main main: mov rdi, fmt mov rsi, 198 xor rax, rax call printf ; sys_exit mov rax, 60 mov rdi, 1 syscall
; A163414: a(n) = 16*a(n-1) - 62*a(n-2) for n>1, a(0)=1, a(1)=12. ; Submitted by Jon Maiga ; 1,12,130,1336,13316,130224,1257992,12053984,114868240,1090544832,10326886432,97616403328,921595494464,8693310905088,81954053824640,772279585078784,7275322024132864,68523818111241216,645311124283621888,6076501265640994816,57214730544671360000,538692610245000081408,5071768470150376982528,47749353687216026673152,449540013846133053853696,4232180292930735207923712,39843403828431513987850240,375099283093198640914333696,3531297492128424387382624256,33244604322276474461433298944 mov $1,4 mov $3,1 lpb $0 sub $0,1 mov $2,$3 mul $2,2 mul $3,8 add $3,$1 mul $1,8 add $1,$2 lpe mov $0,$3
; ; Old School Computer Architecture - SD Card driver ; Taken from the OSCA Bootcode by Phil Ruston 2011 ; Port by Stefano Bodrato, 2012 ; ; int sd_write_sector(struct SD_INFO descriptor, long sector, unsigned char *address); ; ; sd_card_info and card_select must be accessible, ; a good place to put them is in the vars declared in the CRT0 stub ; ; on exit: 0 if all OK or error code ; ; $Id: sd_write_block_2gb_callee.asm,v 1.4 2015/01/19 01:33:07 pauloscustodio Exp $ ; PUBLIC sd_write_block_2gb_callee PUBLIC ASMDISP_SD_WRITE_BLOCK_2GB_CALLEE EXTERN sd_card_info EXTERN card_select EXTERN sd_write_sector_main EXTERN sd_deselect_card EXTERN sd_set_sector_addr_regs EXTERN sd_send_command_current_args EXTERN sd_send_eight_clocks EXTERN sd_send_byte EXTERN sd_get_byte INCLUDE "sdcard.def" sd_write_block_2gb_callee: pop af ; ret addr pop hl ; dst addr exx pop hl ; sector pos lsb pop de ; sector pos msb pop ix ; SD_INFO struct push af .asmentry IF SDHC_SUPPORT ld a,(sd_card_info) and $10 ld a,sd_error_too_big jr nz,write_end ; if SDHC card, linear addressing is not supported ENDIF ; ptr to MMC mask to be used to select port ld a,(ix+1) ; or any other hw dependent reference to current slot ld (card_select), a ld a,(ix+2) ld (sd_card_info), a sub a ; reset carry flag call sd_set_sector_addr_regs ld a,CMD24 ; Send CMD24 write sector command call sd_send_command_current_args ld a,sd_error_bad_command_response jr nz, write_end call sd_send_eight_clocks ; wait 8 clocks before proceding ld a,$fe call sd_send_byte ; send $FE = packet header code ;.............................................................................................. exx call sd_write_sector_main ;............................................................................................. call sd_get_byte ; get packet response and $1f srl a cp $02 jr z,sd_wr_ok sd_write_fail: ld a,sd_error_write_failed jr write_end sd_wr_ok: ld bc,65535 ; read bytes until $ff is received sd_wcbsy: call sd_get_byte ; until that time, card is busy cp $ff jr nz,sd_busy xor a ; A = 0, all OK jr write_end sd_busy: dec bc ld a,b or c jr nz,sd_wcbsy sd_card_busy_timeout: ld a,sd_error_write_timeout write_end: call sd_deselect_card ; Routines always deselect card on return ; or a ; If A = 0 on SD routine exit, ZF set on return: No error ld h,0 ld l,a ret DEFC ASMDISP_SD_WRITE_BLOCK_2GB_CALLEE = # asmentry - sd_write_block_2gb_callee
// Test array index pointer rewriting // 16bit array with 8bit index // Commodore 64 PRG executable file .file [name="index-pointer-rewrite-1.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$0801] .segmentdef Code [start=$80d] .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) .segment Code main: { ldx #0 __b1: // for(char i=0;i<NUM_ENTITIES;i++) cpx #$19 bcc __b2 // } rts __b2: // entities[i] = 7 txa asl tay lda #7 sta entities,y lda #0 sta entities+1,y // for(char i=0;i<NUM_ENTITIES;i++) inx jmp __b1 } .segment Data entities: .fill 2*$19, 0
#include "dicomtest_pch.h" #include "CppUnitTestFramework.hpp" #include "dicom/data/ST.h" #include "dicom_test/data/detail/constants.h" using namespace dicom; using namespace dicom::data; namespace { struct STTest {}; } namespace dicom_test::data { TEST_CASE(STTest, Constructors) { // ST() ST st0; REQUIRE(st0.Validity() == ValidityType::Valid); REQUIRE(st0.Value().Empty()); // ST(encoded_string&&) ST st1("Valid value"); REQUIRE(st1.Value() == "Valid value"); REQUIRE(st1.Validity() == ValidityType::Valid); // ST(const encoded_string&) encoded_string value("Valid value"); ST st2(value); REQUIRE(st2.Value() == "Valid value"); REQUIRE(st2.Validity() == ValidityType::Valid); // ST(const ST&) ST st3(st1); REQUIRE(st3.Value() == "Valid value"); REQUIRE(st3.Validity() == ValidityType::Valid); REQUIRE(st1.Value() == "Valid value"); REQUIRE(st1.Validity() == ValidityType::Valid); // ST(ST&&) ST st5(std::move(st2)); REQUIRE(st5.Value() == "Valid value"); REQUIRE(st5.Validity() == ValidityType::Valid); REQUIRE(st2.Value().Empty()); REQUIRE(st2.Validity() == ValidityType::Deinitialized); } //------------------------------------------------------------------------------------------------------------ TEST_CASE(STTest, Construction_Valid) { ST st_single("Valid value 1"); REQUIRE(st_single.Value() == "Valid value 1"); REQUIRE(st_single.Validity() == ValidityType::Valid); ST st_mustiple("Value 1\\2nd Value"); REQUIRE(st_mustiple.Value() == "Value 1\\2nd Value"); REQUIRE(st_mustiple.Validity() == ValidityType::Valid); ST st_empty1(" "); // REQUIRE(st_empty1.Value() == L""); REQUIRE(st_empty1.Validity() == ValidityType::Valid); ST st_empty2(""); REQUIRE(st_empty2.Value() == ""); REQUIRE(st_empty2.Validity() == ValidityType::Valid); ST st_trim_right(" a "); // REQUIRE(st_trim_right.Value() == L" a"); REQUIRE(st_trim_right.Validity() == ValidityType::Valid); } //------------------------------------------------------------------------------------------------------------ TEST_CASE(STTest, Construction_Overlong) { std::string value(1025, 'a'); ST st{ encoded_string(value) }; REQUIRE(st.Validity() == ValidityType::Acceptable); REQUIRE(st.Value().Parsed() == value); } //------------------------------------------------------------------------------------------------------------ TEST_CASE(STTest, Construction_InvalidCharacters) { std::string str("Invalid "); for (char c : detail::InvalidControlChars) { str[7] = c; ST st{ encoded_string(str) }; REQUIRE(st.Value().Parsed() == str); REQUIRE(st.Validity() == ValidityType::Invalid); } } //------------------------------------------------------------------------------------------------------------ TEST_CASE(STTest, Equality) { ST st1("Valid 1"); ST st2("Valid 2"); REQUIRE(st1 == &st1); REQUIRE(st1 != &st2); REQUIRE(st2 != &st1); REQUIRE(st1 < &st2); REQUIRE(st1 <= &st2); REQUIRE(st2 > &st1); REQUIRE(st2 >= &st1); } //------------------------------------------------------------------------------------------------------------ TEST_CASE(STTest, Empty) { ST st1; REQUIRE(st1.Empty()); ST st2("Valid"); REQUIRE(!st2.Empty()); ST st3(""); REQUIRE(st3.Empty()); // ST st4(" "); // REQUIRE(st4.Empty()); ST st5("\\"); REQUIRE(!st5.Empty()); } //------------------------------------------------------------------------------------------------------------ TEST_CASE(STTest, Copy) { ST st_orig("Valid value"); std::unique_ptr<VR> vr_copy(st_orig.Copy()); REQUIRE(static_cast<bool>(vr_copy)); auto st_copy = dynamic_cast<ST*>(vr_copy.get()); REQUIRE(st_copy != nullptr); REQUIRE(st_orig.Value() == st_copy->Value()); REQUIRE(st_orig == st_copy); } }
OUTPUT "labels_syntax_and_find.bin" MODULE mod1 : ORG $3130 label: dec hl .local: inc l dw label dw .local dw label.local dw mod1.label.local dw @mod1.label.local ; global one! dw @label dw @label.local dw @unique dw unique ; mod1 unique dw mod1unique dw mod1.mod1unique dw @mod1.mod1unique mod1unique: ; mod2 unique dw '!!'+mod2unique ; should be error, searching only: mod1.mod2unique, @mod2unique dw mod2.mod2unique dw @mod2.mod2unique ; mod1 nested dw nested.label dw nested.label.local dw mod1.nested.label.local dw @mod1.nested.label.local dw '!!'+nest1unique ; should be error dw nested.nest1unique dw mod1.nested.nest1unique dw @mod1.nested.nest1unique ; mod2 nested dw mod2.nested.label dw @mod2.nested.label dw mod2.nested.label.local dw @mod2.nested.label.local dw '!!'+nested.nest2unique ; should be error dw mod2.nested.nest2unique dw @mod2.nested.nest2unique MODULE nested label: dec l .local: cpl nest1unique: ENDMODULE ENDMODULE MODULE mod2 : ORG $3332 label: add hl,hl .local: daa dw label dw .local dw label.local dw mod2.label.local dw @mod2.label.local ; global one! dw @label dw @label.local dw @unique dw unique ; mod2 unique dw mod2unique dw mod2.mod2unique dw @mod2.mod2unique mod2unique: ; mod1 unique dw '!!'+mod1unique ; should be error, searching only: mod2.mod1unique, @mod1unique dw mod1.mod1unique dw @mod1.mod1unique ; mod2 nested dw nested.label dw nested.label.local dw mod2.nested.label.local dw @mod2.nested.label.local dw '!!'+nest2unique ; should be error dw nested.nest2unique dw mod2.nested.nest2unique dw @mod2.nested.nest2unique ; mod1 nested dw mod1.nested.label dw @mod1.nested.label dw mod1.nested.label.local dw @mod1.nested.label.local dw '!!'+nested.nest1unique ; should be error dw mod1.nested.nest1unique dw @mod1.nested.nest1unique MODULE nested label: inc h .local: dec h nest2unique: ENDMODULE ENDMODULE ORG $3534 label: dec hl .local: inc l dw label dw .local dw label.local dw @label.local dw mod1.label.local dw @mod1.label.local dw mod2.label.local dw @mod2.label.local ; uniques dw unique dw @unique dw '!!'+mod1unique ; should be error dw mod1.mod1unique dw @mod1.mod1unique dw mod1.nested.nest1unique dw @mod1.nested.nest1unique dw '!!'+mod2unique ; should be error dw mod2.mod2unique dw @mod2.mod2unique dw mod2.nested.nest2unique dw @mod2.nested.nest2unique ; nested dw '!!'+nested.label ; should be error dw '!!'+nested.label.local ; should be error dw mod1.nested.label dw @mod1.nested.label dw mod2.nested.label.local dw @mod2.nested.label.local unique: dec l ..invalidLabelName: @.invalidLabelName: .@invalidLabelName: .1nvalidLabelName: @1nvalidLabelName: .@1nvalidLabelName: @.1nvalidLabelName: 1nvalidLabelName: jr nz,1B Inv&lidL&belN&me: 100 equ should not work 101 = should not work 102 defl should not work 103: equ should not work 104: = should not work 105: defl should not work
// Copyright 2017 The Chromium 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 "content/renderer/content_security_policy_util.h" #include "services/network/public/cpp/content_security_policy/content_security_policy.h" #include "services/network/public/mojom/content_security_policy.mojom.h" namespace content { namespace { std::vector<std::string> BuildVectorOfStrings( const blink::WebVector<blink::WebString>& list_in) { std::vector<std::string> list_out; for (const auto& element : list_in) list_out.emplace_back(element.Utf8()); return list_out; } network::mojom::CSPSourcePtr BuildCSPSource(const blink::WebCSPSource& source) { return network::mojom::CSPSource::New( source.scheme.Utf8(), source.host.Utf8(), source.port, source.path.Utf8(), source.is_host_wildcard, source.is_port_wildcard); } network::mojom::CSPHashSourcePtr BuildCSPHashSource( const blink::WebCSPHashSource& hash_source) { std::vector<uint8_t> hash_value; hash_value.reserve(hash_source.value.size()); for (uint8_t el : hash_source.value) hash_value.emplace_back(el); return network::mojom::CSPHashSource::New(hash_source.algorithm, std::move(hash_value)); } network::mojom::CSPSourceListPtr BuildCSPSourceList( const blink::WebCSPSourceList& source_list) { std::vector<network::mojom::CSPSourcePtr> sources; for (const auto& source : source_list.sources) sources.push_back(BuildCSPSource(source)); std::vector<network::mojom::CSPHashSourcePtr> hashes; for (const auto& hash : source_list.hashes) hashes.push_back(BuildCSPHashSource(hash)); return network::mojom::CSPSourceList::New( std::move(sources), BuildVectorOfStrings(source_list.nonces), std::move(hashes), source_list.allow_self, source_list.allow_star, source_list.allow_response_redirects, source_list.allow_inline, source_list.allow_eval, source_list.allow_wasm_eval, source_list.allow_wasm_unsafe_eval, source_list.allow_dynamic, source_list.allow_unsafe_hashes, source_list.report_sample); } blink::WebVector<blink::WebString> ToWebVectorOfWebStrings( std::vector<std::string> list_in) { blink::WebVector<blink::WebString> list_out(list_in.size()); size_t i = 0; for (auto& element : list_in) list_out[i++] = blink::WebString::FromUTF8(std::move(element)); return list_out; } blink::WebCSPSource ToWebCSPSource(network::mojom::CSPSourcePtr source) { return {blink::WebString::FromUTF8(std::move(source->scheme)), blink::WebString::FromUTF8(std::move(source->host)), source->port, blink::WebString::FromUTF8(std::move(source->path)), source->is_host_wildcard, source->is_port_wildcard}; } blink::WebCSPHashSource ToWebCSPHashSource( network::mojom::CSPHashSourcePtr hash_source) { return {hash_source->algorithm, std::move(hash_source->value)}; } blink::WebCSPSourceList ToWebCSPSourceList( network::mojom::CSPSourceListPtr source_list) { blink::WebVector<blink::WebCSPSource> sources(source_list->sources.size()); for (size_t i = 0; i < sources.size(); ++i) sources[i] = ToWebCSPSource(std::move(source_list->sources[i])); blink::WebVector<blink::WebCSPHashSource> hashes(source_list->hashes.size()); for (size_t i = 0; i < hashes.size(); ++i) hashes[i] = ToWebCSPHashSource(std::move(source_list->hashes[i])); return {std::move(sources), ToWebVectorOfWebStrings(std::move(source_list->nonces)), std::move(hashes), source_list->allow_self, source_list->allow_star, source_list->allow_response_redirects, source_list->allow_inline, source_list->allow_eval, source_list->allow_wasm_eval, source_list->allow_wasm_unsafe_eval, source_list->allow_dynamic, source_list->allow_unsafe_hashes, source_list->report_sample}; } absl::optional<blink::WebCSPTrustedTypes> ToOptionalWebCSPTrustedTypes( network::mojom::CSPTrustedTypesPtr trusted_types) { if (!trusted_types) return absl::nullopt; return blink::WebCSPTrustedTypes{ ToWebVectorOfWebStrings(std::move(trusted_types->list)), trusted_types->allow_any, trusted_types->allow_duplicates}; } blink::WebContentSecurityPolicyHeader ToWebContentSecurityPolicyHeader( network::mojom::ContentSecurityPolicyHeaderPtr header) { return {blink::WebString::FromUTF8(std::move(header->header_value)), header->type, header->source}; } } // namespace network::mojom::ContentSecurityPolicyPtr BuildContentSecurityPolicy( const blink::WebContentSecurityPolicy& policy_in) { base::flat_map<network::mojom::CSPDirectiveName, std::string> raw_directives; for (const auto& directive : policy_in.raw_directives) { raw_directives[directive.name] = directive.value.Utf8(); } base::flat_map<network::mojom::CSPDirectiveName, network::mojom::CSPSourceListPtr> directives; for (const auto& directive : policy_in.directives) { directives[directive.name] = BuildCSPSourceList(directive.source_list); } return network::mojom::ContentSecurityPolicy::New( BuildCSPSource(policy_in.self_origin), std::move(raw_directives), std::move(directives), policy_in.upgrade_insecure_requests, policy_in.treat_as_public_address, policy_in.block_all_mixed_content, policy_in.sandbox, network::mojom::ContentSecurityPolicyHeader::New( policy_in.header.header_value.Utf8(), policy_in.header.type, policy_in.header.source), policy_in.use_reporting_api, BuildVectorOfStrings(policy_in.report_endpoints), policy_in.require_trusted_types_for, policy_in.trusted_types ? network::mojom::CSPTrustedTypes::New( BuildVectorOfStrings(policy_in.trusted_types->list), policy_in.trusted_types->allow_any, policy_in.trusted_types->allow_duplicates) : nullptr, BuildVectorOfStrings(policy_in.parsing_errors)); } blink::WebContentSecurityPolicy ToWebContentSecurityPolicy( network::mojom::ContentSecurityPolicyPtr policy_in) { blink::WebVector<blink::WebContentSecurityPolicyDirective> directives( policy_in->directives.size()); size_t i = 0; for (auto& directive : policy_in->directives) { directives[i++] = {directive.first, ToWebCSPSourceList(std::move(directive.second))}; } blink::WebVector<blink::WebContentSecurityPolicyRawDirective> raw_directives( policy_in->raw_directives.size()); i = 0; for (auto& directive : policy_in->raw_directives) { raw_directives[i++] = {directive.first, blink::WebString::FromUTF8( std::move(directive.second))}; } return {ToWebCSPSource(std::move(policy_in->self_origin)), std::move(raw_directives), std::move(directives), policy_in->upgrade_insecure_requests, policy_in->treat_as_public_address, policy_in->block_all_mixed_content, policy_in->sandbox, ToWebContentSecurityPolicyHeader(std::move(policy_in->header)), policy_in->use_reporting_api, ToWebVectorOfWebStrings(std::move(policy_in->report_endpoints)), policy_in->require_trusted_types_for, ToOptionalWebCSPTrustedTypes(std::move(policy_in->trusted_types)), ToWebVectorOfWebStrings(std::move(policy_in->parsing_errors))}; } blink::WebVector<blink::WebContentSecurityPolicy> ToWebContentSecurityPolicies( std::vector<network::mojom::ContentSecurityPolicyPtr> list_in) { blink::WebVector<blink::WebContentSecurityPolicy> list_out(list_in.size()); size_t i = 0; for (auto& element : list_in) list_out[i++] = ToWebContentSecurityPolicy(std::move(element)); return list_out; } } // namespace content
; A261671: If n even, a(n) = 6n+3, otherwise a(n) = n. ; 3,1,15,3,27,5,39,7,51,9,63,11,75,13,87,15,99,17,111,19,123,21,135,23,147,25,159,27,171,29,183,31,195,33,207,35,219,37,231,39,243,41,255,43,267,45,279,47,291,49,303,51,315,53,327,55,339,57,351,59,363,61,375,63,387,65,399,67,411,69,423,71,435,73,447,75,459,77,471,79,483,81,495,83,507,85,519,87,531,89,543,91,555,93,567,95,579,97,591,99 mov $1,$0 mul $0,2 mov $2,-2 bin $2,$1 add $0,$2 dif $0,2 mul $0,2 add $0,1
#pragma once #include "pch.h" #include <regex> #include "./built_in_functions.h" #include "../rbac/role_manager.h" #include "./util.h" #include "../exception/illegal_argument_exception.h" #include "../ip_parser/parser/CIDR.h" #include "../ip_parser/parser/IP.h" #include "../ip_parser/parser/parseCIDR.h" #include "../ip_parser/parser/parseIP.h" using namespace std; // KeyMatch determines whether key1 matches the pattern of key2 (similar to RESTful path), key2 can contain a *. // For example, "/foo/bar" matches "/foo/*" ReturnType KeyMatch(Scope scope) { string key1 = GetString(scope, 0); string key2 = GetString(scope, 1); size_t pos = key2.find("*"); if (pos == string :: npos) { PushBooleanValue(scope, key1 == key2); return RETURN_RESULT; } if (key1.length() > pos) { PushBooleanValue(scope, key1.substr(0, pos) == key2.substr(0, pos)); return RETURN_RESULT; } PushBooleanValue(scope, key1 == key2.substr(0, pos)); return RETURN_RESULT; } // KeyMatch2 determines whether key1 matches the pattern of key2 (similar to RESTful path), key2 can contain a *. // For example, "/foo/bar" matches "/foo/*", "/resource1" matches "/:resource" ReturnType KeyMatch2(Scope scope) { string key1 = GetString(scope, 0); string key2 = GetString(scope, 1); vector<string> key1_arr = Split(key1, "/"); vector<string> key2_arr = Split(key2, "/"); bool res = true; for(int i=0;i<key2_arr.size();i++){ if(i >= key1_arr.size()){ res = false; break; } if(key1_arr[i] != key2_arr[i]){ int index1 = key2_arr[i].find("*"); int index2 = key2_arr[i].find(":"); if(index1 != string::npos){ if(index1==0){ res = true; break; } else if(key1_arr[i].compare(key2_arr[i].substr(0, index1))) { res = false; break; } else continue; } if(index2==0){ if(key1_arr[i]=="" || !key2_arr[i].substr(1).compare("")){ res = false; break; } else continue; } res = false; break; }else continue; } if(key2_arr.size() < key1_arr.size()) if(key2_arr[key2_arr.size()-1] != "*") res = false; PushBooleanValue(scope, res); return RETURN_RESULT; } // KeyMatch3 determines whether key1 matches the pattern of key2 (similar to RESTful path), key2 can contain a *. // For example, "/foo/bar" matches "/foo/*", "/resource1" matches "/{resource}" ReturnType KeyMatch3(Scope scope) { string key1 = GetString(scope, 0); string key2 = GetString(scope, 1); vector<string> key1_arr = Split(key1, "/"); vector<string> key2_arr = Split(key2, "/"); bool res = true; for(int i=0;i<key2_arr.size();i++){ if(i >= key1_arr.size()){ res = false; break; } if(key1_arr[i] != key2_arr[i]){ int index1 = key2_arr[i].find("*"); int index2 = key2_arr[i].find("{"); int index3 = key2_arr[i].find("}"); if(index1 != string::npos){ if(index1==0){ res = true; break; } else if(key1_arr[i].compare(key2_arr[i].substr(0, index1))) { res = false; break; } else continue; } if(index2==0 && index3 > 0 && index3 != string::npos){ if(key1_arr[i]=="" || !key2_arr[i].substr(1, key2_arr[i].length()-2).compare("")){ res = false; break; } else continue; } res = false; break; }else continue; } if(key2_arr.size() < key1_arr.size()) if(key2_arr[key2_arr.size()-1] != "*") res = false; PushBooleanValue(scope, res); return RETURN_RESULT; } // RegexMatch determines whether key1 matches the pattern of key2 in regular expression. ReturnType RegexMatch(Scope scope) { string key1 = GetString(scope, 0); string key2 = GetString(scope, 1); regex regex_s(key2); PushBooleanValue(scope, regex_match(key1, regex_s)); return RETURN_RESULT; } // IPMatch determines whether IP address ip1 matches the pattern of IP address ip2, ip2 can be an IP address or a CIDR pattern. // For example, "192.168.2.123" matches "192.168.2.0/24" ReturnType IPMatch(Scope scope) { string ip1 = GetString(scope, 0); string ip2 = GetString(scope, 1); IP objIP1 = parseIP(ip1); if (objIP1.isLegal == false) throw IllegalArgumentException("invalid argument: ip1 in IPMatch() function is not an IP address."); CIDR objCIDR = parseCIDR(ip2); if (objCIDR.ip.isLegal == false) { IP objIP2 = parseIP(ip2); if (objIP2.isLegal == false) throw IllegalArgumentException("invalid argument: ip1 in IPMatch() function is not an IP address."); PushBooleanValue(scope, objIP1.Equal(objIP2)); return RETURN_RESULT; } PushBooleanValue(scope, objCIDR.net.contains(objIP1)); return RETURN_RESULT; } // GFunction is the method of the g(_, _) function. ReturnType GFunction(Scope scope) { RoleManager *rm; rm = (RoleManager*)GetPointer(scope, 0); string name1 = GetString(scope, 1); string name2 = GetString(scope, 2); int len = Size(scope); if(rm == NULL) PushBooleanValue(scope, name1 == name2); else if (len == 2) { vector<string> domain; bool res = rm->HasLink(name1, name2, domain); PushBooleanValue(scope, res); } else { vector<string> domain{GetString(scope, 2)}; bool res = rm->HasLink(name1, name2, domain); PushBooleanValue(scope, res); } return RETURN_RESULT; }
/* * Copyright (c) 2021, suncloudsmoon and the noob-kernel contributors. * * 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. * * 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. */ #include "../include/debugmode.hpp" #include "../include/lib/mem.hpp" #include "../include/kernel/coreutil.hpp" #include "../include/lib/io.hpp" #include "../include/lib/str.hpp" #include "../include/lib/math.hpp" /* * Command used to test this kernel: * qemu-system-i386 -kernel bin/noob_kernel.bin */ // NOTE: the entry function must be called noob_start(): defined in boot.asm /* * General Rules: * Except for some definitions, the C++ standard lib should not be used * When the C++ standard lib is used, a comment must follow it */ // Required stuff by GCC extern "C" { #ifdef __GNUC__ void __stack_chk_fail_local() { } void __cxa_guard_acquire() { } void __cxa_guard_release() { } #endif } class A { public: A() { a = 5; } int getA() { return a; } private: int a; }; extern "C" { void noob_start() { core::clear_screen(); A *test_malloc = new A(); delete test_malloc; // nlib::printf("A is %d!", test_malloc->getA()); nlib::printf("Success!\n"); // nlib::printf("ceil(5) is %c!", nlib::to_char(nlib::ceil(5))); } }
// Copyright (c) 2012 The Chromium 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 "content/browser/renderer_host/media/audio_input_device_manager.h" #include <memory> #include "base/bind.h" #include "base/metrics/histogram_macros.h" #include "build/build_config.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/media_stream_request.h" #include "media/audio/audio_input_ipc.h" #include "media/audio/audio_manager_base.h" #include "media/base/audio_parameters.h" #include "media/base/channel_layout.h" #if defined(OS_CHROMEOS) #include "chromeos/audio/cras_audio_handler.h" #endif namespace content { const int AudioInputDeviceManager::kFakeOpenSessionId = 1; namespace { // Starting id for the first capture session. const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; } AudioInputDeviceManager::AudioInputDeviceManager( media::AudioManager* audio_manager) : listener_(NULL), next_capture_session_id_(kFirstSessionId), use_fake_device_(false), #if defined(OS_CHROMEOS) keyboard_mic_streams_count_(0), #endif audio_manager_(audio_manager) { } AudioInputDeviceManager::~AudioInputDeviceManager() { } const StreamDeviceInfo* AudioInputDeviceManager::GetOpenedDeviceInfoById( int session_id) { DCHECK_CURRENTLY_ON(BrowserThread::IO); StreamDeviceList::iterator device = GetDevice(session_id); if (device == devices_.end()) return NULL; return &(*device); } void AudioInputDeviceManager::Register( MediaStreamProviderListener* listener, const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(!listener_); DCHECK(!device_task_runner_.get()); listener_ = listener; device_task_runner_ = device_task_runner; } void AudioInputDeviceManager::Unregister() { DCHECK(listener_); listener_ = NULL; } void AudioInputDeviceManager::EnumerateDevices(MediaStreamType stream_type) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(listener_); device_task_runner_->PostTask( FROM_HERE, base::Bind(&AudioInputDeviceManager::EnumerateOnDeviceThread, this, stream_type)); } int AudioInputDeviceManager::Open(const StreamDeviceInfo& device) { DCHECK_CURRENTLY_ON(BrowserThread::IO); // Generate a new id for this device. int session_id = next_capture_session_id_++; device_task_runner_->PostTask( FROM_HERE, base::Bind(&AudioInputDeviceManager::OpenOnDeviceThread, this, session_id, device)); return session_id; } void AudioInputDeviceManager::Close(int session_id) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(listener_); StreamDeviceList::iterator device = GetDevice(session_id); if (device == devices_.end()) return; const MediaStreamType stream_type = device->device.type; if (session_id != kFakeOpenSessionId) devices_.erase(device); // Post a callback through the listener on IO thread since // MediaStreamManager is expecting the callback asynchronously. BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&AudioInputDeviceManager::ClosedOnIOThread, this, stream_type, session_id)); } void AudioInputDeviceManager::UseFakeDevice() { DCHECK_CURRENTLY_ON(BrowserThread::IO); use_fake_device_ = true; } bool AudioInputDeviceManager::ShouldUseFakeDevice() const { DCHECK_CURRENTLY_ON(BrowserThread::IO); return use_fake_device_; } #if defined(OS_CHROMEOS) void AudioInputDeviceManager::RegisterKeyboardMicStream( const base::Closure& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); ++keyboard_mic_streams_count_; if (keyboard_mic_streams_count_ == 1) { BrowserThread::PostTaskAndReply( BrowserThread::UI, FROM_HERE, base::Bind( &AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread, this, true), callback); } else { callback.Run(); } } void AudioInputDeviceManager::UnregisterKeyboardMicStream() { DCHECK_CURRENTLY_ON(BrowserThread::IO); --keyboard_mic_streams_count_; DCHECK_GE(keyboard_mic_streams_count_, 0); if (keyboard_mic_streams_count_ == 0) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( &AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread, this, false)); } } #endif void AudioInputDeviceManager::EnumerateOnDeviceThread( MediaStreamType stream_type) { SCOPED_UMA_HISTOGRAM_TIMER( "Media.AudioInputDeviceManager.EnumerateOnDeviceThreadTime"); DCHECK(IsOnDeviceThread()); DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, stream_type); media::AudioDeviceNames device_names; if (use_fake_device_) { // Use the fake devices. GetFakeDeviceNames(&device_names); } else { // Enumerate the devices on the OS. // AudioManager is guaranteed to outlive MediaStreamManager in // BrowserMainloop. audio_manager_->GetAudioInputDeviceNames(&device_names); } std::unique_ptr<StreamDeviceInfoArray> devices(new StreamDeviceInfoArray()); for (media::AudioDeviceNames::iterator it = device_names.begin(); it != device_names.end(); ++it) { // Add device information to device vector. devices->push_back(StreamDeviceInfo( stream_type, it->device_name, it->unique_id)); } // Return the device list through the listener by posting a task on // IO thread since MediaStreamManager handles the callback asynchronously. BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&AudioInputDeviceManager::DevicesEnumeratedOnIOThread, this, stream_type, base::Passed(&devices))); } void AudioInputDeviceManager::OpenOnDeviceThread( int session_id, const StreamDeviceInfo& info) { SCOPED_UMA_HISTOGRAM_TIMER( "Media.AudioInputDeviceManager.OpenOnDeviceThreadTime"); DCHECK(IsOnDeviceThread()); StreamDeviceInfo out(info.device.type, info.device.name, info.device.id, 0, 0, 0); out.session_id = session_id; MediaStreamDevice::AudioDeviceParameters& input_params = out.device.input; if (use_fake_device_) { // Don't need to query the hardware information if using fake device. input_params.sample_rate = 44100; input_params.channel_layout = media::CHANNEL_LAYOUT_STEREO; } else { // Get the preferred sample rate and channel configuration for the // audio device. media::AudioParameters params = audio_manager_->GetInputStreamParameters(info.device.id); input_params.sample_rate = params.sample_rate(); input_params.channel_layout = params.channel_layout(); input_params.frames_per_buffer = params.frames_per_buffer(); input_params.effects = params.effects(); input_params.mic_positions = params.mic_positions(); // Add preferred output device information if a matching output device // exists. out.device.matched_output_device_id = audio_manager_->GetAssociatedOutputDeviceID(info.device.id); if (!out.device.matched_output_device_id.empty()) { params = audio_manager_->GetOutputStreamParameters( out.device.matched_output_device_id); MediaStreamDevice::AudioDeviceParameters& matched_output_params = out.device.matched_output; matched_output_params.sample_rate = params.sample_rate(); matched_output_params.channel_layout = params.channel_layout(); matched_output_params.frames_per_buffer = params.frames_per_buffer(); } } // Return the |session_id| through the listener by posting a task on // IO thread since MediaStreamManager handles the callback asynchronously. BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&AudioInputDeviceManager::OpenedOnIOThread, this, session_id, out)); } void AudioInputDeviceManager::DevicesEnumeratedOnIOThread( MediaStreamType stream_type, std::unique_ptr<StreamDeviceInfoArray> devices) { DCHECK_CURRENTLY_ON(BrowserThread::IO); // Ensure that |devices| gets deleted on exit. if (listener_) listener_->DevicesEnumerated(stream_type, *devices); } void AudioInputDeviceManager::OpenedOnIOThread(int session_id, const StreamDeviceInfo& info) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_EQ(session_id, info.session_id); DCHECK(GetDevice(session_id) == devices_.end()); devices_.push_back(info); if (listener_) listener_->Opened(info.device.type, session_id); } void AudioInputDeviceManager::ClosedOnIOThread(MediaStreamType stream_type, int session_id) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (listener_) listener_->Closed(stream_type, session_id); } bool AudioInputDeviceManager::IsOnDeviceThread() const { return device_task_runner_->BelongsToCurrentThread(); } AudioInputDeviceManager::StreamDeviceList::iterator AudioInputDeviceManager::GetDevice(int session_id) { for (StreamDeviceList::iterator i(devices_.begin()); i != devices_.end(); ++i) { if (i->session_id == session_id) return i; } return devices_.end(); } void AudioInputDeviceManager::GetFakeDeviceNames( media::AudioDeviceNames* device_names) { static const char kFakeDeviceName1[] = "Fake Audio 1"; static const char kFakeDeviceId1[] = "fake_audio_1"; static const char kFakeDeviceName2[] = "Fake Audio 2"; static const char kFakeDeviceId2[] = "fake_audio_2"; DCHECK(device_names->empty()); DCHECK(use_fake_device_); device_names->push_back(media::AudioDeviceName(kFakeDeviceName1, kFakeDeviceId1)); device_names->push_back(media::AudioDeviceName(kFakeDeviceName2, kFakeDeviceId2)); } #if defined(OS_CHROMEOS) void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( bool active) { DCHECK_CURRENTLY_ON(BrowserThread::UI); chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); } #endif } // namespace content
user/_grep: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <matchstar>: return 0; } // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { 0: 7179 addi sp,sp,-48 2: f406 sd ra,40(sp) 4: f022 sd s0,32(sp) 6: ec26 sd s1,24(sp) 8: e84a sd s2,16(sp) a: e44e sd s3,8(sp) c: e052 sd s4,0(sp) e: 1800 addi s0,sp,48 10: 892a mv s2,a0 12: 89ae mv s3,a1 14: 84b2 mv s1,a2 do{ // a * matches zero or more instances if(matchhere(re, text)) return 1; }while(*text!='\0' && (*text++==c || c=='.')); 16: 02e00a13 li s4,46 if(matchhere(re, text)) 1a: 85a6 mv a1,s1 1c: 854e mv a0,s3 1e: 00000097 auipc ra,0x0 22: 030080e7 jalr 48(ra) # 4e <matchhere> 26: e919 bnez a0,3c <matchstar+0x3c> }while(*text!='\0' && (*text++==c || c=='.')); 28: 0004c783 lbu a5,0(s1) 2c: cb89 beqz a5,3e <matchstar+0x3e> 2e: 0485 addi s1,s1,1 30: 2781 sext.w a5,a5 32: ff2784e3 beq a5,s2,1a <matchstar+0x1a> 36: ff4902e3 beq s2,s4,1a <matchstar+0x1a> 3a: a011 j 3e <matchstar+0x3e> return 1; 3c: 4505 li a0,1 return 0; } 3e: 70a2 ld ra,40(sp) 40: 7402 ld s0,32(sp) 42: 64e2 ld s1,24(sp) 44: 6942 ld s2,16(sp) 46: 69a2 ld s3,8(sp) 48: 6a02 ld s4,0(sp) 4a: 6145 addi sp,sp,48 4c: 8082 ret 000000000000004e <matchhere>: if(re[0] == '\0') 4e: 00054703 lbu a4,0(a0) 52: cb3d beqz a4,c8 <matchhere+0x7a> { 54: 1141 addi sp,sp,-16 56: e406 sd ra,8(sp) 58: e022 sd s0,0(sp) 5a: 0800 addi s0,sp,16 5c: 87aa mv a5,a0 if(re[1] == '*') 5e: 00154683 lbu a3,1(a0) 62: 02a00613 li a2,42 66: 02c68563 beq a3,a2,90 <matchhere+0x42> if(re[0] == '$' && re[1] == '\0') 6a: 02400613 li a2,36 6e: 02c70a63 beq a4,a2,a2 <matchhere+0x54> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 72: 0005c683 lbu a3,0(a1) return 0; 76: 4501 li a0,0 if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 78: ca81 beqz a3,88 <matchhere+0x3a> 7a: 02e00613 li a2,46 7e: 02c70d63 beq a4,a2,b8 <matchhere+0x6a> return 0; 82: 4501 li a0,0 if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 84: 02d70a63 beq a4,a3,b8 <matchhere+0x6a> } 88: 60a2 ld ra,8(sp) 8a: 6402 ld s0,0(sp) 8c: 0141 addi sp,sp,16 8e: 8082 ret return matchstar(re[0], re+2, text); 90: 862e mv a2,a1 92: 00250593 addi a1,a0,2 96: 853a mv a0,a4 98: 00000097 auipc ra,0x0 9c: f68080e7 jalr -152(ra) # 0 <matchstar> a0: b7e5 j 88 <matchhere+0x3a> if(re[0] == '$' && re[1] == '\0') a2: c691 beqz a3,ae <matchhere+0x60> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) a4: 0005c683 lbu a3,0(a1) a8: fee9 bnez a3,82 <matchhere+0x34> return 0; aa: 4501 li a0,0 ac: bff1 j 88 <matchhere+0x3a> return *text == '\0'; ae: 0005c503 lbu a0,0(a1) b2: 00153513 seqz a0,a0 b6: bfc9 j 88 <matchhere+0x3a> return matchhere(re+1, text+1); b8: 0585 addi a1,a1,1 ba: 00178513 addi a0,a5,1 be: 00000097 auipc ra,0x0 c2: f90080e7 jalr -112(ra) # 4e <matchhere> c6: b7c9 j 88 <matchhere+0x3a> return 1; c8: 4505 li a0,1 } ca: 8082 ret 00000000000000cc <match>: { cc: 1101 addi sp,sp,-32 ce: ec06 sd ra,24(sp) d0: e822 sd s0,16(sp) d2: e426 sd s1,8(sp) d4: e04a sd s2,0(sp) d6: 1000 addi s0,sp,32 d8: 892a mv s2,a0 da: 84ae mv s1,a1 if(re[0] == '^') dc: 00054703 lbu a4,0(a0) e0: 05e00793 li a5,94 e4: 00f70e63 beq a4,a5,100 <match+0x34> if(matchhere(re, text)) e8: 85a6 mv a1,s1 ea: 854a mv a0,s2 ec: 00000097 auipc ra,0x0 f0: f62080e7 jalr -158(ra) # 4e <matchhere> f4: ed01 bnez a0,10c <match+0x40> }while(*text++ != '\0'); f6: 0485 addi s1,s1,1 f8: fff4c783 lbu a5,-1(s1) fc: f7f5 bnez a5,e8 <match+0x1c> fe: a801 j 10e <match+0x42> return matchhere(re+1, text); 100: 0505 addi a0,a0,1 102: 00000097 auipc ra,0x0 106: f4c080e7 jalr -180(ra) # 4e <matchhere> 10a: a011 j 10e <match+0x42> return 1; 10c: 4505 li a0,1 } 10e: 60e2 ld ra,24(sp) 110: 6442 ld s0,16(sp) 112: 64a2 ld s1,8(sp) 114: 6902 ld s2,0(sp) 116: 6105 addi sp,sp,32 118: 8082 ret 000000000000011a <grep>: { 11a: 711d addi sp,sp,-96 11c: ec86 sd ra,88(sp) 11e: e8a2 sd s0,80(sp) 120: e4a6 sd s1,72(sp) 122: e0ca sd s2,64(sp) 124: fc4e sd s3,56(sp) 126: f852 sd s4,48(sp) 128: f456 sd s5,40(sp) 12a: f05a sd s6,32(sp) 12c: ec5e sd s7,24(sp) 12e: e862 sd s8,16(sp) 130: e466 sd s9,8(sp) 132: e06a sd s10,0(sp) 134: 1080 addi s0,sp,96 136: 89aa mv s3,a0 138: 8bae mv s7,a1 m = 0; 13a: 4a01 li s4,0 while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ 13c: 3ff00c13 li s8,1023 140: 00001b17 auipc s6,0x1 144: 968b0b13 addi s6,s6,-1688 # aa8 <buf> p = buf; 148: 8d5a mv s10,s6 *q = '\n'; 14a: 4aa9 li s5,10 p = buf; 14c: 8cda mv s9,s6 while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ 14e: a099 j 194 <grep+0x7a> *q = '\n'; 150: 01548023 sb s5,0(s1) write(1, p, q+1 - p); 154: 00148613 addi a2,s1,1 158: 4126063b subw a2,a2,s2 15c: 85ca mv a1,s2 15e: 4505 li a0,1 160: 00000097 auipc ra,0x0 164: 3e4080e7 jalr 996(ra) # 544 <write> p = q+1; 168: 00148913 addi s2,s1,1 while((q = strchr(p, '\n')) != 0){ 16c: 45a9 li a1,10 16e: 854a mv a0,s2 170: 00000097 auipc ra,0x0 174: 1d6080e7 jalr 470(ra) # 346 <strchr> 178: 84aa mv s1,a0 17a: c919 beqz a0,190 <grep+0x76> *q = 0; 17c: 00048023 sb zero,0(s1) if(match(pattern, p)){ 180: 85ca mv a1,s2 182: 854e mv a0,s3 184: 00000097 auipc ra,0x0 188: f48080e7 jalr -184(ra) # cc <match> 18c: dd71 beqz a0,168 <grep+0x4e> 18e: b7c9 j 150 <grep+0x36> if(m > 0){ 190: 03404563 bgtz s4,1ba <grep+0xa0> while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ 194: 414c063b subw a2,s8,s4 198: 014b05b3 add a1,s6,s4 19c: 855e mv a0,s7 19e: 00000097 auipc ra,0x0 1a2: 39e080e7 jalr 926(ra) # 53c <read> 1a6: 02a05663 blez a0,1d2 <grep+0xb8> m += n; 1aa: 00aa0a3b addw s4,s4,a0 buf[m] = '\0'; 1ae: 014b07b3 add a5,s6,s4 1b2: 00078023 sb zero,0(a5) p = buf; 1b6: 8966 mv s2,s9 while((q = strchr(p, '\n')) != 0){ 1b8: bf55 j 16c <grep+0x52> m -= p - buf; 1ba: 416907b3 sub a5,s2,s6 1be: 40fa0a3b subw s4,s4,a5 memmove(buf, p, m); 1c2: 8652 mv a2,s4 1c4: 85ca mv a1,s2 1c6: 856a mv a0,s10 1c8: 00000097 auipc ra,0x0 1cc: 2a6080e7 jalr 678(ra) # 46e <memmove> 1d0: b7d1 j 194 <grep+0x7a> } 1d2: 60e6 ld ra,88(sp) 1d4: 6446 ld s0,80(sp) 1d6: 64a6 ld s1,72(sp) 1d8: 6906 ld s2,64(sp) 1da: 79e2 ld s3,56(sp) 1dc: 7a42 ld s4,48(sp) 1de: 7aa2 ld s5,40(sp) 1e0: 7b02 ld s6,32(sp) 1e2: 6be2 ld s7,24(sp) 1e4: 6c42 ld s8,16(sp) 1e6: 6ca2 ld s9,8(sp) 1e8: 6d02 ld s10,0(sp) 1ea: 6125 addi sp,sp,96 1ec: 8082 ret 00000000000001ee <main>: { 1ee: 7139 addi sp,sp,-64 1f0: fc06 sd ra,56(sp) 1f2: f822 sd s0,48(sp) 1f4: f426 sd s1,40(sp) 1f6: f04a sd s2,32(sp) 1f8: ec4e sd s3,24(sp) 1fa: e852 sd s4,16(sp) 1fc: e456 sd s5,8(sp) 1fe: 0080 addi s0,sp,64 if(argc <= 1){ 200: 4785 li a5,1 202: 04a7de63 bge a5,a0,25e <main+0x70> pattern = argv[1]; 206: 0085ba03 ld s4,8(a1) if(argc <= 2){ 20a: 4789 li a5,2 20c: 06a7d763 bge a5,a0,27a <main+0x8c> 210: 01058913 addi s2,a1,16 214: ffd5099b addiw s3,a0,-3 218: 1982 slli s3,s3,0x20 21a: 0209d993 srli s3,s3,0x20 21e: 098e slli s3,s3,0x3 220: 05e1 addi a1,a1,24 222: 99ae add s3,s3,a1 if((fd = open(argv[i], 0)) < 0){ 224: 4581 li a1,0 226: 00093503 ld a0,0(s2) 22a: 00000097 auipc ra,0x0 22e: 33a080e7 jalr 826(ra) # 564 <open> 232: 84aa mv s1,a0 234: 04054e63 bltz a0,290 <main+0xa2> grep(pattern, fd); 238: 85aa mv a1,a0 23a: 8552 mv a0,s4 23c: 00000097 auipc ra,0x0 240: ede080e7 jalr -290(ra) # 11a <grep> close(fd); 244: 8526 mv a0,s1 246: 00000097 auipc ra,0x0 24a: 306080e7 jalr 774(ra) # 54c <close> for(i = 2; i < argc; i++){ 24e: 0921 addi s2,s2,8 250: fd391ae3 bne s2,s3,224 <main+0x36> exit(0); 254: 4501 li a0,0 256: 00000097 auipc ra,0x0 25a: 2ce080e7 jalr 718(ra) # 524 <exit> fprintf(2, "usage: grep pattern [file ...]\n"); 25e: 00000597 auipc a1,0x0 262: 7ea58593 addi a1,a1,2026 # a48 <malloc+0xe6> 266: 4509 li a0,2 268: 00000097 auipc ra,0x0 26c: 60e080e7 jalr 1550(ra) # 876 <fprintf> exit(1); 270: 4505 li a0,1 272: 00000097 auipc ra,0x0 276: 2b2080e7 jalr 690(ra) # 524 <exit> grep(pattern, 0); 27a: 4581 li a1,0 27c: 8552 mv a0,s4 27e: 00000097 auipc ra,0x0 282: e9c080e7 jalr -356(ra) # 11a <grep> exit(0); 286: 4501 li a0,0 288: 00000097 auipc ra,0x0 28c: 29c080e7 jalr 668(ra) # 524 <exit> printf("grep: cannot open %s\n", argv[i]); 290: 00093583 ld a1,0(s2) 294: 00000517 auipc a0,0x0 298: 7d450513 addi a0,a0,2004 # a68 <malloc+0x106> 29c: 00000097 auipc ra,0x0 2a0: 608080e7 jalr 1544(ra) # 8a4 <printf> exit(1); 2a4: 4505 li a0,1 2a6: 00000097 auipc ra,0x0 2aa: 27e080e7 jalr 638(ra) # 524 <exit> 00000000000002ae <strcpy>: #include "kernel/fcntl.h" #include "user/user.h" char* strcpy(char *s, const char *t) { 2ae: 1141 addi sp,sp,-16 2b0: e422 sd s0,8(sp) 2b2: 0800 addi s0,sp,16 char *os; os = s; while((*s++ = *t++) != 0) 2b4: 87aa mv a5,a0 2b6: 0585 addi a1,a1,1 2b8: 0785 addi a5,a5,1 2ba: fff5c703 lbu a4,-1(a1) 2be: fee78fa3 sb a4,-1(a5) 2c2: fb75 bnez a4,2b6 <strcpy+0x8> ; return os; } 2c4: 6422 ld s0,8(sp) 2c6: 0141 addi sp,sp,16 2c8: 8082 ret 00000000000002ca <strcmp>: int strcmp(const char *p, const char *q) { 2ca: 1141 addi sp,sp,-16 2cc: e422 sd s0,8(sp) 2ce: 0800 addi s0,sp,16 while(*p && *p == *q) 2d0: 00054783 lbu a5,0(a0) 2d4: cb91 beqz a5,2e8 <strcmp+0x1e> 2d6: 0005c703 lbu a4,0(a1) 2da: 00f71763 bne a4,a5,2e8 <strcmp+0x1e> p++, q++; 2de: 0505 addi a0,a0,1 2e0: 0585 addi a1,a1,1 while(*p && *p == *q) 2e2: 00054783 lbu a5,0(a0) 2e6: fbe5 bnez a5,2d6 <strcmp+0xc> return (uchar)*p - (uchar)*q; 2e8: 0005c503 lbu a0,0(a1) } 2ec: 40a7853b subw a0,a5,a0 2f0: 6422 ld s0,8(sp) 2f2: 0141 addi sp,sp,16 2f4: 8082 ret 00000000000002f6 <strlen>: uint strlen(const char *s) { 2f6: 1141 addi sp,sp,-16 2f8: e422 sd s0,8(sp) 2fa: 0800 addi s0,sp,16 int n; for(n = 0; s[n]; n++) 2fc: 00054783 lbu a5,0(a0) 300: cf91 beqz a5,31c <strlen+0x26> 302: 0505 addi a0,a0,1 304: 87aa mv a5,a0 306: 4685 li a3,1 308: 9e89 subw a3,a3,a0 30a: 00f6853b addw a0,a3,a5 30e: 0785 addi a5,a5,1 310: fff7c703 lbu a4,-1(a5) 314: fb7d bnez a4,30a <strlen+0x14> ; return n; } 316: 6422 ld s0,8(sp) 318: 0141 addi sp,sp,16 31a: 8082 ret for(n = 0; s[n]; n++) 31c: 4501 li a0,0 31e: bfe5 j 316 <strlen+0x20> 0000000000000320 <memset>: void* memset(void *dst, int c, uint n) { 320: 1141 addi sp,sp,-16 322: e422 sd s0,8(sp) 324: 0800 addi s0,sp,16 char *cdst = (char *) dst; int i; for(i = 0; i < n; i++){ 326: ce09 beqz a2,340 <memset+0x20> 328: 87aa mv a5,a0 32a: fff6071b addiw a4,a2,-1 32e: 1702 slli a4,a4,0x20 330: 9301 srli a4,a4,0x20 332: 0705 addi a4,a4,1 334: 972a add a4,a4,a0 cdst[i] = c; 336: 00b78023 sb a1,0(a5) for(i = 0; i < n; i++){ 33a: 0785 addi a5,a5,1 33c: fee79de3 bne a5,a4,336 <memset+0x16> } return dst; } 340: 6422 ld s0,8(sp) 342: 0141 addi sp,sp,16 344: 8082 ret 0000000000000346 <strchr>: char* strchr(const char *s, char c) { 346: 1141 addi sp,sp,-16 348: e422 sd s0,8(sp) 34a: 0800 addi s0,sp,16 for(; *s; s++) 34c: 00054783 lbu a5,0(a0) 350: cb99 beqz a5,366 <strchr+0x20> if(*s == c) 352: 00f58763 beq a1,a5,360 <strchr+0x1a> for(; *s; s++) 356: 0505 addi a0,a0,1 358: 00054783 lbu a5,0(a0) 35c: fbfd bnez a5,352 <strchr+0xc> return (char*)s; return 0; 35e: 4501 li a0,0 } 360: 6422 ld s0,8(sp) 362: 0141 addi sp,sp,16 364: 8082 ret return 0; 366: 4501 li a0,0 368: bfe5 j 360 <strchr+0x1a> 000000000000036a <gets>: char* gets(char *buf, int max) { 36a: 711d addi sp,sp,-96 36c: ec86 sd ra,88(sp) 36e: e8a2 sd s0,80(sp) 370: e4a6 sd s1,72(sp) 372: e0ca sd s2,64(sp) 374: fc4e sd s3,56(sp) 376: f852 sd s4,48(sp) 378: f456 sd s5,40(sp) 37a: f05a sd s6,32(sp) 37c: ec5e sd s7,24(sp) 37e: 1080 addi s0,sp,96 380: 8baa mv s7,a0 382: 8a2e mv s4,a1 int i, cc; char c; for(i=0; i+1 < max; ){ 384: 892a mv s2,a0 386: 4481 li s1,0 cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 388: 4aa9 li s5,10 38a: 4b35 li s6,13 for(i=0; i+1 < max; ){ 38c: 89a6 mv s3,s1 38e: 2485 addiw s1,s1,1 390: 0344d863 bge s1,s4,3c0 <gets+0x56> cc = read(0, &c, 1); 394: 4605 li a2,1 396: faf40593 addi a1,s0,-81 39a: 4501 li a0,0 39c: 00000097 auipc ra,0x0 3a0: 1a0080e7 jalr 416(ra) # 53c <read> if(cc < 1) 3a4: 00a05e63 blez a0,3c0 <gets+0x56> buf[i++] = c; 3a8: faf44783 lbu a5,-81(s0) 3ac: 00f90023 sb a5,0(s2) if(c == '\n' || c == '\r') 3b0: 01578763 beq a5,s5,3be <gets+0x54> 3b4: 0905 addi s2,s2,1 3b6: fd679be3 bne a5,s6,38c <gets+0x22> for(i=0; i+1 < max; ){ 3ba: 89a6 mv s3,s1 3bc: a011 j 3c0 <gets+0x56> 3be: 89a6 mv s3,s1 break; } buf[i] = '\0'; 3c0: 99de add s3,s3,s7 3c2: 00098023 sb zero,0(s3) return buf; } 3c6: 855e mv a0,s7 3c8: 60e6 ld ra,88(sp) 3ca: 6446 ld s0,80(sp) 3cc: 64a6 ld s1,72(sp) 3ce: 6906 ld s2,64(sp) 3d0: 79e2 ld s3,56(sp) 3d2: 7a42 ld s4,48(sp) 3d4: 7aa2 ld s5,40(sp) 3d6: 7b02 ld s6,32(sp) 3d8: 6be2 ld s7,24(sp) 3da: 6125 addi sp,sp,96 3dc: 8082 ret 00000000000003de <stat>: int stat(const char *n, struct stat *st) { 3de: 1101 addi sp,sp,-32 3e0: ec06 sd ra,24(sp) 3e2: e822 sd s0,16(sp) 3e4: e426 sd s1,8(sp) 3e6: e04a sd s2,0(sp) 3e8: 1000 addi s0,sp,32 3ea: 892e mv s2,a1 int fd; int r; fd = open(n, O_RDONLY); 3ec: 4581 li a1,0 3ee: 00000097 auipc ra,0x0 3f2: 176080e7 jalr 374(ra) # 564 <open> if(fd < 0) 3f6: 02054563 bltz a0,420 <stat+0x42> 3fa: 84aa mv s1,a0 return -1; r = fstat(fd, st); 3fc: 85ca mv a1,s2 3fe: 00000097 auipc ra,0x0 402: 17e080e7 jalr 382(ra) # 57c <fstat> 406: 892a mv s2,a0 close(fd); 408: 8526 mv a0,s1 40a: 00000097 auipc ra,0x0 40e: 142080e7 jalr 322(ra) # 54c <close> return r; } 412: 854a mv a0,s2 414: 60e2 ld ra,24(sp) 416: 6442 ld s0,16(sp) 418: 64a2 ld s1,8(sp) 41a: 6902 ld s2,0(sp) 41c: 6105 addi sp,sp,32 41e: 8082 ret return -1; 420: 597d li s2,-1 422: bfc5 j 412 <stat+0x34> 0000000000000424 <atoi>: int atoi(const char *s) { 424: 1141 addi sp,sp,-16 426: e422 sd s0,8(sp) 428: 0800 addi s0,sp,16 int n; n = 0; while('0' <= *s && *s <= '9') 42a: 00054603 lbu a2,0(a0) 42e: fd06079b addiw a5,a2,-48 432: 0ff7f793 andi a5,a5,255 436: 4725 li a4,9 438: 02f76963 bltu a4,a5,46a <atoi+0x46> 43c: 86aa mv a3,a0 n = 0; 43e: 4501 li a0,0 while('0' <= *s && *s <= '9') 440: 45a5 li a1,9 n = n*10 + *s++ - '0'; 442: 0685 addi a3,a3,1 444: 0025179b slliw a5,a0,0x2 448: 9fa9 addw a5,a5,a0 44a: 0017979b slliw a5,a5,0x1 44e: 9fb1 addw a5,a5,a2 450: fd07851b addiw a0,a5,-48 while('0' <= *s && *s <= '9') 454: 0006c603 lbu a2,0(a3) 458: fd06071b addiw a4,a2,-48 45c: 0ff77713 andi a4,a4,255 460: fee5f1e3 bgeu a1,a4,442 <atoi+0x1e> return n; } 464: 6422 ld s0,8(sp) 466: 0141 addi sp,sp,16 468: 8082 ret n = 0; 46a: 4501 li a0,0 46c: bfe5 j 464 <atoi+0x40> 000000000000046e <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 46e: 1141 addi sp,sp,-16 470: e422 sd s0,8(sp) 472: 0800 addi s0,sp,16 char *dst; const char *src; dst = vdst; src = vsrc; if (src > dst) { 474: 02b57663 bgeu a0,a1,4a0 <memmove+0x32> while(n-- > 0) 478: 02c05163 blez a2,49a <memmove+0x2c> 47c: fff6079b addiw a5,a2,-1 480: 1782 slli a5,a5,0x20 482: 9381 srli a5,a5,0x20 484: 0785 addi a5,a5,1 486: 97aa add a5,a5,a0 dst = vdst; 488: 872a mv a4,a0 *dst++ = *src++; 48a: 0585 addi a1,a1,1 48c: 0705 addi a4,a4,1 48e: fff5c683 lbu a3,-1(a1) 492: fed70fa3 sb a3,-1(a4) while(n-- > 0) 496: fee79ae3 bne a5,a4,48a <memmove+0x1c> src += n; while(n-- > 0) *--dst = *--src; } return vdst; } 49a: 6422 ld s0,8(sp) 49c: 0141 addi sp,sp,16 49e: 8082 ret dst += n; 4a0: 00c50733 add a4,a0,a2 src += n; 4a4: 95b2 add a1,a1,a2 while(n-- > 0) 4a6: fec05ae3 blez a2,49a <memmove+0x2c> 4aa: fff6079b addiw a5,a2,-1 4ae: 1782 slli a5,a5,0x20 4b0: 9381 srli a5,a5,0x20 4b2: fff7c793 not a5,a5 4b6: 97ba add a5,a5,a4 *--dst = *--src; 4b8: 15fd addi a1,a1,-1 4ba: 177d addi a4,a4,-1 4bc: 0005c683 lbu a3,0(a1) 4c0: 00d70023 sb a3,0(a4) while(n-- > 0) 4c4: fee79ae3 bne a5,a4,4b8 <memmove+0x4a> 4c8: bfc9 j 49a <memmove+0x2c> 00000000000004ca <memcmp>: int memcmp(const void *s1, const void *s2, uint n) { 4ca: 1141 addi sp,sp,-16 4cc: e422 sd s0,8(sp) 4ce: 0800 addi s0,sp,16 const char *p1 = s1, *p2 = s2; while (n-- > 0) { 4d0: ca05 beqz a2,500 <memcmp+0x36> 4d2: fff6069b addiw a3,a2,-1 4d6: 1682 slli a3,a3,0x20 4d8: 9281 srli a3,a3,0x20 4da: 0685 addi a3,a3,1 4dc: 96aa add a3,a3,a0 if (*p1 != *p2) { 4de: 00054783 lbu a5,0(a0) 4e2: 0005c703 lbu a4,0(a1) 4e6: 00e79863 bne a5,a4,4f6 <memcmp+0x2c> return *p1 - *p2; } p1++; 4ea: 0505 addi a0,a0,1 p2++; 4ec: 0585 addi a1,a1,1 while (n-- > 0) { 4ee: fed518e3 bne a0,a3,4de <memcmp+0x14> } return 0; 4f2: 4501 li a0,0 4f4: a019 j 4fa <memcmp+0x30> return *p1 - *p2; 4f6: 40e7853b subw a0,a5,a4 } 4fa: 6422 ld s0,8(sp) 4fc: 0141 addi sp,sp,16 4fe: 8082 ret return 0; 500: 4501 li a0,0 502: bfe5 j 4fa <memcmp+0x30> 0000000000000504 <memcpy>: void * memcpy(void *dst, const void *src, uint n) { 504: 1141 addi sp,sp,-16 506: e406 sd ra,8(sp) 508: e022 sd s0,0(sp) 50a: 0800 addi s0,sp,16 return memmove(dst, src, n); 50c: 00000097 auipc ra,0x0 510: f62080e7 jalr -158(ra) # 46e <memmove> } 514: 60a2 ld ra,8(sp) 516: 6402 ld s0,0(sp) 518: 0141 addi sp,sp,16 51a: 8082 ret 000000000000051c <fork>: # generated by usys.pl - do not edit #include "kernel/syscall.h" .global fork fork: li a7, SYS_fork 51c: 4885 li a7,1 ecall 51e: 00000073 ecall ret 522: 8082 ret 0000000000000524 <exit>: .global exit exit: li a7, SYS_exit 524: 4889 li a7,2 ecall 526: 00000073 ecall ret 52a: 8082 ret 000000000000052c <wait>: .global wait wait: li a7, SYS_wait 52c: 488d li a7,3 ecall 52e: 00000073 ecall ret 532: 8082 ret 0000000000000534 <pipe>: .global pipe pipe: li a7, SYS_pipe 534: 4891 li a7,4 ecall 536: 00000073 ecall ret 53a: 8082 ret 000000000000053c <read>: .global read read: li a7, SYS_read 53c: 4895 li a7,5 ecall 53e: 00000073 ecall ret 542: 8082 ret 0000000000000544 <write>: .global write write: li a7, SYS_write 544: 48c1 li a7,16 ecall 546: 00000073 ecall ret 54a: 8082 ret 000000000000054c <close>: .global close close: li a7, SYS_close 54c: 48d5 li a7,21 ecall 54e: 00000073 ecall ret 552: 8082 ret 0000000000000554 <kill>: .global kill kill: li a7, SYS_kill 554: 4899 li a7,6 ecall 556: 00000073 ecall ret 55a: 8082 ret 000000000000055c <exec>: .global exec exec: li a7, SYS_exec 55c: 489d li a7,7 ecall 55e: 00000073 ecall ret 562: 8082 ret 0000000000000564 <open>: .global open open: li a7, SYS_open 564: 48bd li a7,15 ecall 566: 00000073 ecall ret 56a: 8082 ret 000000000000056c <mknod>: .global mknod mknod: li a7, SYS_mknod 56c: 48c5 li a7,17 ecall 56e: 00000073 ecall ret 572: 8082 ret 0000000000000574 <unlink>: .global unlink unlink: li a7, SYS_unlink 574: 48c9 li a7,18 ecall 576: 00000073 ecall ret 57a: 8082 ret 000000000000057c <fstat>: .global fstat fstat: li a7, SYS_fstat 57c: 48a1 li a7,8 ecall 57e: 00000073 ecall ret 582: 8082 ret 0000000000000584 <link>: .global link link: li a7, SYS_link 584: 48cd li a7,19 ecall 586: 00000073 ecall ret 58a: 8082 ret 000000000000058c <mkdir>: .global mkdir mkdir: li a7, SYS_mkdir 58c: 48d1 li a7,20 ecall 58e: 00000073 ecall ret 592: 8082 ret 0000000000000594 <chdir>: .global chdir chdir: li a7, SYS_chdir 594: 48a5 li a7,9 ecall 596: 00000073 ecall ret 59a: 8082 ret 000000000000059c <dup>: .global dup dup: li a7, SYS_dup 59c: 48a9 li a7,10 ecall 59e: 00000073 ecall ret 5a2: 8082 ret 00000000000005a4 <getpid>: .global getpid getpid: li a7, SYS_getpid 5a4: 48ad li a7,11 ecall 5a6: 00000073 ecall ret 5aa: 8082 ret 00000000000005ac <sbrk>: .global sbrk sbrk: li a7, SYS_sbrk 5ac: 48b1 li a7,12 ecall 5ae: 00000073 ecall ret 5b2: 8082 ret 00000000000005b4 <sleep>: .global sleep sleep: li a7, SYS_sleep 5b4: 48b5 li a7,13 ecall 5b6: 00000073 ecall ret 5ba: 8082 ret 00000000000005bc <uptime>: .global uptime uptime: li a7, SYS_uptime 5bc: 48b9 li a7,14 ecall 5be: 00000073 ecall ret 5c2: 8082 ret 00000000000005c4 <ntas>: .global ntas ntas: li a7, SYS_ntas 5c4: 48d9 li a7,22 ecall 5c6: 00000073 ecall ret 5ca: 8082 ret 00000000000005cc <putc>: static char digits[] = "0123456789ABCDEF"; static void putc(int fd, char c) { 5cc: 1101 addi sp,sp,-32 5ce: ec06 sd ra,24(sp) 5d0: e822 sd s0,16(sp) 5d2: 1000 addi s0,sp,32 5d4: feb407a3 sb a1,-17(s0) write(fd, &c, 1); 5d8: 4605 li a2,1 5da: fef40593 addi a1,s0,-17 5de: 00000097 auipc ra,0x0 5e2: f66080e7 jalr -154(ra) # 544 <write> } 5e6: 60e2 ld ra,24(sp) 5e8: 6442 ld s0,16(sp) 5ea: 6105 addi sp,sp,32 5ec: 8082 ret 00000000000005ee <printint>: static void printint(int fd, int xx, int base, int sgn) { 5ee: 7139 addi sp,sp,-64 5f0: fc06 sd ra,56(sp) 5f2: f822 sd s0,48(sp) 5f4: f426 sd s1,40(sp) 5f6: f04a sd s2,32(sp) 5f8: ec4e sd s3,24(sp) 5fa: 0080 addi s0,sp,64 5fc: 84aa mv s1,a0 char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 5fe: c299 beqz a3,604 <printint+0x16> 600: 0805c863 bltz a1,690 <printint+0xa2> neg = 1; x = -xx; } else { x = xx; 604: 2581 sext.w a1,a1 neg = 0; 606: 4881 li a7,0 608: fc040693 addi a3,s0,-64 } i = 0; 60c: 4701 li a4,0 do{ buf[i++] = digits[x % base]; 60e: 2601 sext.w a2,a2 610: 00000517 auipc a0,0x0 614: 47850513 addi a0,a0,1144 # a88 <digits> 618: 883a mv a6,a4 61a: 2705 addiw a4,a4,1 61c: 02c5f7bb remuw a5,a1,a2 620: 1782 slli a5,a5,0x20 622: 9381 srli a5,a5,0x20 624: 97aa add a5,a5,a0 626: 0007c783 lbu a5,0(a5) 62a: 00f68023 sb a5,0(a3) }while((x /= base) != 0); 62e: 0005879b sext.w a5,a1 632: 02c5d5bb divuw a1,a1,a2 636: 0685 addi a3,a3,1 638: fec7f0e3 bgeu a5,a2,618 <printint+0x2a> if(neg) 63c: 00088b63 beqz a7,652 <printint+0x64> buf[i++] = '-'; 640: fd040793 addi a5,s0,-48 644: 973e add a4,a4,a5 646: 02d00793 li a5,45 64a: fef70823 sb a5,-16(a4) 64e: 0028071b addiw a4,a6,2 while(--i >= 0) 652: 02e05863 blez a4,682 <printint+0x94> 656: fc040793 addi a5,s0,-64 65a: 00e78933 add s2,a5,a4 65e: fff78993 addi s3,a5,-1 662: 99ba add s3,s3,a4 664: 377d addiw a4,a4,-1 666: 1702 slli a4,a4,0x20 668: 9301 srli a4,a4,0x20 66a: 40e989b3 sub s3,s3,a4 putc(fd, buf[i]); 66e: fff94583 lbu a1,-1(s2) 672: 8526 mv a0,s1 674: 00000097 auipc ra,0x0 678: f58080e7 jalr -168(ra) # 5cc <putc> while(--i >= 0) 67c: 197d addi s2,s2,-1 67e: ff3918e3 bne s2,s3,66e <printint+0x80> } 682: 70e2 ld ra,56(sp) 684: 7442 ld s0,48(sp) 686: 74a2 ld s1,40(sp) 688: 7902 ld s2,32(sp) 68a: 69e2 ld s3,24(sp) 68c: 6121 addi sp,sp,64 68e: 8082 ret x = -xx; 690: 40b005bb negw a1,a1 neg = 1; 694: 4885 li a7,1 x = -xx; 696: bf8d j 608 <printint+0x1a> 0000000000000698 <vprintf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void vprintf(int fd, const char *fmt, va_list ap) { 698: 7119 addi sp,sp,-128 69a: fc86 sd ra,120(sp) 69c: f8a2 sd s0,112(sp) 69e: f4a6 sd s1,104(sp) 6a0: f0ca sd s2,96(sp) 6a2: ecce sd s3,88(sp) 6a4: e8d2 sd s4,80(sp) 6a6: e4d6 sd s5,72(sp) 6a8: e0da sd s6,64(sp) 6aa: fc5e sd s7,56(sp) 6ac: f862 sd s8,48(sp) 6ae: f466 sd s9,40(sp) 6b0: f06a sd s10,32(sp) 6b2: ec6e sd s11,24(sp) 6b4: 0100 addi s0,sp,128 char *s; int c, i, state; state = 0; for(i = 0; fmt[i]; i++){ 6b6: 0005c903 lbu s2,0(a1) 6ba: 18090f63 beqz s2,858 <vprintf+0x1c0> 6be: 8aaa mv s5,a0 6c0: 8b32 mv s6,a2 6c2: 00158493 addi s1,a1,1 state = 0; 6c6: 4981 li s3,0 if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 6c8: 02500a13 li s4,37 if(c == 'd'){ 6cc: 06400c13 li s8,100 printint(fd, va_arg(ap, int), 10, 1); } else if(c == 'l') { 6d0: 06c00c93 li s9,108 printint(fd, va_arg(ap, uint64), 10, 0); } else if(c == 'x') { 6d4: 07800d13 li s10,120 printint(fd, va_arg(ap, int), 16, 0); } else if(c == 'p') { 6d8: 07000d93 li s11,112 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 6dc: 00000b97 auipc s7,0x0 6e0: 3acb8b93 addi s7,s7,940 # a88 <digits> 6e4: a839 j 702 <vprintf+0x6a> putc(fd, c); 6e6: 85ca mv a1,s2 6e8: 8556 mv a0,s5 6ea: 00000097 auipc ra,0x0 6ee: ee2080e7 jalr -286(ra) # 5cc <putc> 6f2: a019 j 6f8 <vprintf+0x60> } else if(state == '%'){ 6f4: 01498f63 beq s3,s4,712 <vprintf+0x7a> for(i = 0; fmt[i]; i++){ 6f8: 0485 addi s1,s1,1 6fa: fff4c903 lbu s2,-1(s1) 6fe: 14090d63 beqz s2,858 <vprintf+0x1c0> c = fmt[i] & 0xff; 702: 0009079b sext.w a5,s2 if(state == 0){ 706: fe0997e3 bnez s3,6f4 <vprintf+0x5c> if(c == '%'){ 70a: fd479ee3 bne a5,s4,6e6 <vprintf+0x4e> state = '%'; 70e: 89be mv s3,a5 710: b7e5 j 6f8 <vprintf+0x60> if(c == 'd'){ 712: 05878063 beq a5,s8,752 <vprintf+0xba> } else if(c == 'l') { 716: 05978c63 beq a5,s9,76e <vprintf+0xd6> } else if(c == 'x') { 71a: 07a78863 beq a5,s10,78a <vprintf+0xf2> } else if(c == 'p') { 71e: 09b78463 beq a5,s11,7a6 <vprintf+0x10e> printptr(fd, va_arg(ap, uint64)); } else if(c == 's'){ 722: 07300713 li a4,115 726: 0ce78663 beq a5,a4,7f2 <vprintf+0x15a> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 72a: 06300713 li a4,99 72e: 0ee78e63 beq a5,a4,82a <vprintf+0x192> putc(fd, va_arg(ap, uint)); } else if(c == '%'){ 732: 11478863 beq a5,s4,842 <vprintf+0x1aa> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 736: 85d2 mv a1,s4 738: 8556 mv a0,s5 73a: 00000097 auipc ra,0x0 73e: e92080e7 jalr -366(ra) # 5cc <putc> putc(fd, c); 742: 85ca mv a1,s2 744: 8556 mv a0,s5 746: 00000097 auipc ra,0x0 74a: e86080e7 jalr -378(ra) # 5cc <putc> } state = 0; 74e: 4981 li s3,0 750: b765 j 6f8 <vprintf+0x60> printint(fd, va_arg(ap, int), 10, 1); 752: 008b0913 addi s2,s6,8 756: 4685 li a3,1 758: 4629 li a2,10 75a: 000b2583 lw a1,0(s6) 75e: 8556 mv a0,s5 760: 00000097 auipc ra,0x0 764: e8e080e7 jalr -370(ra) # 5ee <printint> 768: 8b4a mv s6,s2 state = 0; 76a: 4981 li s3,0 76c: b771 j 6f8 <vprintf+0x60> printint(fd, va_arg(ap, uint64), 10, 0); 76e: 008b0913 addi s2,s6,8 772: 4681 li a3,0 774: 4629 li a2,10 776: 000b2583 lw a1,0(s6) 77a: 8556 mv a0,s5 77c: 00000097 auipc ra,0x0 780: e72080e7 jalr -398(ra) # 5ee <printint> 784: 8b4a mv s6,s2 state = 0; 786: 4981 li s3,0 788: bf85 j 6f8 <vprintf+0x60> printint(fd, va_arg(ap, int), 16, 0); 78a: 008b0913 addi s2,s6,8 78e: 4681 li a3,0 790: 4641 li a2,16 792: 000b2583 lw a1,0(s6) 796: 8556 mv a0,s5 798: 00000097 auipc ra,0x0 79c: e56080e7 jalr -426(ra) # 5ee <printint> 7a0: 8b4a mv s6,s2 state = 0; 7a2: 4981 li s3,0 7a4: bf91 j 6f8 <vprintf+0x60> printptr(fd, va_arg(ap, uint64)); 7a6: 008b0793 addi a5,s6,8 7aa: f8f43423 sd a5,-120(s0) 7ae: 000b3983 ld s3,0(s6) putc(fd, '0'); 7b2: 03000593 li a1,48 7b6: 8556 mv a0,s5 7b8: 00000097 auipc ra,0x0 7bc: e14080e7 jalr -492(ra) # 5cc <putc> putc(fd, 'x'); 7c0: 85ea mv a1,s10 7c2: 8556 mv a0,s5 7c4: 00000097 auipc ra,0x0 7c8: e08080e7 jalr -504(ra) # 5cc <putc> 7cc: 4941 li s2,16 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 7ce: 03c9d793 srli a5,s3,0x3c 7d2: 97de add a5,a5,s7 7d4: 0007c583 lbu a1,0(a5) 7d8: 8556 mv a0,s5 7da: 00000097 auipc ra,0x0 7de: df2080e7 jalr -526(ra) # 5cc <putc> for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4) 7e2: 0992 slli s3,s3,0x4 7e4: 397d addiw s2,s2,-1 7e6: fe0914e3 bnez s2,7ce <vprintf+0x136> printptr(fd, va_arg(ap, uint64)); 7ea: f8843b03 ld s6,-120(s0) state = 0; 7ee: 4981 li s3,0 7f0: b721 j 6f8 <vprintf+0x60> s = va_arg(ap, char*); 7f2: 008b0993 addi s3,s6,8 7f6: 000b3903 ld s2,0(s6) if(s == 0) 7fa: 02090163 beqz s2,81c <vprintf+0x184> while(*s != 0){ 7fe: 00094583 lbu a1,0(s2) 802: c9a1 beqz a1,852 <vprintf+0x1ba> putc(fd, *s); 804: 8556 mv a0,s5 806: 00000097 auipc ra,0x0 80a: dc6080e7 jalr -570(ra) # 5cc <putc> s++; 80e: 0905 addi s2,s2,1 while(*s != 0){ 810: 00094583 lbu a1,0(s2) 814: f9e5 bnez a1,804 <vprintf+0x16c> s = va_arg(ap, char*); 816: 8b4e mv s6,s3 state = 0; 818: 4981 li s3,0 81a: bdf9 j 6f8 <vprintf+0x60> s = "(null)"; 81c: 00000917 auipc s2,0x0 820: 26490913 addi s2,s2,612 # a80 <malloc+0x11e> while(*s != 0){ 824: 02800593 li a1,40 828: bff1 j 804 <vprintf+0x16c> putc(fd, va_arg(ap, uint)); 82a: 008b0913 addi s2,s6,8 82e: 000b4583 lbu a1,0(s6) 832: 8556 mv a0,s5 834: 00000097 auipc ra,0x0 838: d98080e7 jalr -616(ra) # 5cc <putc> 83c: 8b4a mv s6,s2 state = 0; 83e: 4981 li s3,0 840: bd65 j 6f8 <vprintf+0x60> putc(fd, c); 842: 85d2 mv a1,s4 844: 8556 mv a0,s5 846: 00000097 auipc ra,0x0 84a: d86080e7 jalr -634(ra) # 5cc <putc> state = 0; 84e: 4981 li s3,0 850: b565 j 6f8 <vprintf+0x60> s = va_arg(ap, char*); 852: 8b4e mv s6,s3 state = 0; 854: 4981 li s3,0 856: b54d j 6f8 <vprintf+0x60> } } } 858: 70e6 ld ra,120(sp) 85a: 7446 ld s0,112(sp) 85c: 74a6 ld s1,104(sp) 85e: 7906 ld s2,96(sp) 860: 69e6 ld s3,88(sp) 862: 6a46 ld s4,80(sp) 864: 6aa6 ld s5,72(sp) 866: 6b06 ld s6,64(sp) 868: 7be2 ld s7,56(sp) 86a: 7c42 ld s8,48(sp) 86c: 7ca2 ld s9,40(sp) 86e: 7d02 ld s10,32(sp) 870: 6de2 ld s11,24(sp) 872: 6109 addi sp,sp,128 874: 8082 ret 0000000000000876 <fprintf>: void fprintf(int fd, const char *fmt, ...) { 876: 715d addi sp,sp,-80 878: ec06 sd ra,24(sp) 87a: e822 sd s0,16(sp) 87c: 1000 addi s0,sp,32 87e: e010 sd a2,0(s0) 880: e414 sd a3,8(s0) 882: e818 sd a4,16(s0) 884: ec1c sd a5,24(s0) 886: 03043023 sd a6,32(s0) 88a: 03143423 sd a7,40(s0) va_list ap; va_start(ap, fmt); 88e: fe843423 sd s0,-24(s0) vprintf(fd, fmt, ap); 892: 8622 mv a2,s0 894: 00000097 auipc ra,0x0 898: e04080e7 jalr -508(ra) # 698 <vprintf> } 89c: 60e2 ld ra,24(sp) 89e: 6442 ld s0,16(sp) 8a0: 6161 addi sp,sp,80 8a2: 8082 ret 00000000000008a4 <printf>: void printf(const char *fmt, ...) { 8a4: 711d addi sp,sp,-96 8a6: ec06 sd ra,24(sp) 8a8: e822 sd s0,16(sp) 8aa: 1000 addi s0,sp,32 8ac: e40c sd a1,8(s0) 8ae: e810 sd a2,16(s0) 8b0: ec14 sd a3,24(s0) 8b2: f018 sd a4,32(s0) 8b4: f41c sd a5,40(s0) 8b6: 03043823 sd a6,48(s0) 8ba: 03143c23 sd a7,56(s0) va_list ap; va_start(ap, fmt); 8be: 00840613 addi a2,s0,8 8c2: fec43423 sd a2,-24(s0) vprintf(1, fmt, ap); 8c6: 85aa mv a1,a0 8c8: 4505 li a0,1 8ca: 00000097 auipc ra,0x0 8ce: dce080e7 jalr -562(ra) # 698 <vprintf> } 8d2: 60e2 ld ra,24(sp) 8d4: 6442 ld s0,16(sp) 8d6: 6125 addi sp,sp,96 8d8: 8082 ret 00000000000008da <free>: static Header base; static Header *freep; void free(void *ap) { 8da: 1141 addi sp,sp,-16 8dc: e422 sd s0,8(sp) 8de: 0800 addi s0,sp,16 Header *bp, *p; bp = (Header*)ap - 1; 8e0: ff050693 addi a3,a0,-16 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8e4: 00000797 auipc a5,0x0 8e8: 1bc7b783 ld a5,444(a5) # aa0 <freep> 8ec: a805 j 91c <free+0x42> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 8ee: 4618 lw a4,8(a2) 8f0: 9db9 addw a1,a1,a4 8f2: feb52c23 sw a1,-8(a0) bp->s.ptr = p->s.ptr->s.ptr; 8f6: 6398 ld a4,0(a5) 8f8: 6318 ld a4,0(a4) 8fa: fee53823 sd a4,-16(a0) 8fe: a091 j 942 <free+0x68> } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 900: ff852703 lw a4,-8(a0) 904: 9e39 addw a2,a2,a4 906: c790 sw a2,8(a5) p->s.ptr = bp->s.ptr; 908: ff053703 ld a4,-16(a0) 90c: e398 sd a4,0(a5) 90e: a099 j 954 <free+0x7a> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 910: 6398 ld a4,0(a5) 912: 00e7e463 bltu a5,a4,91a <free+0x40> 916: 00e6ea63 bltu a3,a4,92a <free+0x50> { 91a: 87ba mv a5,a4 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 91c: fed7fae3 bgeu a5,a3,910 <free+0x36> 920: 6398 ld a4,0(a5) 922: 00e6e463 bltu a3,a4,92a <free+0x50> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 926: fee7eae3 bltu a5,a4,91a <free+0x40> if(bp + bp->s.size == p->s.ptr){ 92a: ff852583 lw a1,-8(a0) 92e: 6390 ld a2,0(a5) 930: 02059713 slli a4,a1,0x20 934: 9301 srli a4,a4,0x20 936: 0712 slli a4,a4,0x4 938: 9736 add a4,a4,a3 93a: fae60ae3 beq a2,a4,8ee <free+0x14> bp->s.ptr = p->s.ptr; 93e: fec53823 sd a2,-16(a0) if(p + p->s.size == bp){ 942: 4790 lw a2,8(a5) 944: 02061713 slli a4,a2,0x20 948: 9301 srli a4,a4,0x20 94a: 0712 slli a4,a4,0x4 94c: 973e add a4,a4,a5 94e: fae689e3 beq a3,a4,900 <free+0x26> } else p->s.ptr = bp; 952: e394 sd a3,0(a5) freep = p; 954: 00000717 auipc a4,0x0 958: 14f73623 sd a5,332(a4) # aa0 <freep> } 95c: 6422 ld s0,8(sp) 95e: 0141 addi sp,sp,16 960: 8082 ret 0000000000000962 <malloc>: return freep; } void* malloc(uint nbytes) { 962: 7139 addi sp,sp,-64 964: fc06 sd ra,56(sp) 966: f822 sd s0,48(sp) 968: f426 sd s1,40(sp) 96a: f04a sd s2,32(sp) 96c: ec4e sd s3,24(sp) 96e: e852 sd s4,16(sp) 970: e456 sd s5,8(sp) 972: e05a sd s6,0(sp) 974: 0080 addi s0,sp,64 Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 976: 02051493 slli s1,a0,0x20 97a: 9081 srli s1,s1,0x20 97c: 04bd addi s1,s1,15 97e: 8091 srli s1,s1,0x4 980: 0014899b addiw s3,s1,1 984: 0485 addi s1,s1,1 if((prevp = freep) == 0){ 986: 00000517 auipc a0,0x0 98a: 11a53503 ld a0,282(a0) # aa0 <freep> 98e: c515 beqz a0,9ba <malloc+0x58> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 990: 611c ld a5,0(a0) if(p->s.size >= nunits){ 992: 4798 lw a4,8(a5) 994: 02977f63 bgeu a4,s1,9d2 <malloc+0x70> 998: 8a4e mv s4,s3 99a: 0009871b sext.w a4,s3 99e: 6685 lui a3,0x1 9a0: 00d77363 bgeu a4,a3,9a6 <malloc+0x44> 9a4: 6a05 lui s4,0x1 9a6: 000a0b1b sext.w s6,s4 p = sbrk(nu * sizeof(Header)); 9aa: 004a1a1b slliw s4,s4,0x4 p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 9ae: 00000917 auipc s2,0x0 9b2: 0f290913 addi s2,s2,242 # aa0 <freep> if(p == (char*)-1) 9b6: 5afd li s5,-1 9b8: a88d j a2a <malloc+0xc8> base.s.ptr = freep = prevp = &base; 9ba: 00000797 auipc a5,0x0 9be: 4ee78793 addi a5,a5,1262 # ea8 <base> 9c2: 00000717 auipc a4,0x0 9c6: 0cf73f23 sd a5,222(a4) # aa0 <freep> 9ca: e39c sd a5,0(a5) base.s.size = 0; 9cc: 0007a423 sw zero,8(a5) if(p->s.size >= nunits){ 9d0: b7e1 j 998 <malloc+0x36> if(p->s.size == nunits) 9d2: 02e48b63 beq s1,a4,a08 <malloc+0xa6> p->s.size -= nunits; 9d6: 4137073b subw a4,a4,s3 9da: c798 sw a4,8(a5) p += p->s.size; 9dc: 1702 slli a4,a4,0x20 9de: 9301 srli a4,a4,0x20 9e0: 0712 slli a4,a4,0x4 9e2: 97ba add a5,a5,a4 p->s.size = nunits; 9e4: 0137a423 sw s3,8(a5) freep = prevp; 9e8: 00000717 auipc a4,0x0 9ec: 0aa73c23 sd a0,184(a4) # aa0 <freep> return (void*)(p + 1); 9f0: 01078513 addi a0,a5,16 if((p = morecore(nunits)) == 0) return 0; } } 9f4: 70e2 ld ra,56(sp) 9f6: 7442 ld s0,48(sp) 9f8: 74a2 ld s1,40(sp) 9fa: 7902 ld s2,32(sp) 9fc: 69e2 ld s3,24(sp) 9fe: 6a42 ld s4,16(sp) a00: 6aa2 ld s5,8(sp) a02: 6b02 ld s6,0(sp) a04: 6121 addi sp,sp,64 a06: 8082 ret prevp->s.ptr = p->s.ptr; a08: 6398 ld a4,0(a5) a0a: e118 sd a4,0(a0) a0c: bff1 j 9e8 <malloc+0x86> hp->s.size = nu; a0e: 01652423 sw s6,8(a0) free((void*)(hp + 1)); a12: 0541 addi a0,a0,16 a14: 00000097 auipc ra,0x0 a18: ec6080e7 jalr -314(ra) # 8da <free> return freep; a1c: 00093503 ld a0,0(s2) if((p = morecore(nunits)) == 0) a20: d971 beqz a0,9f4 <malloc+0x92> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ a22: 611c ld a5,0(a0) if(p->s.size >= nunits){ a24: 4798 lw a4,8(a5) a26: fa9776e3 bgeu a4,s1,9d2 <malloc+0x70> if(p == freep) a2a: 00093703 ld a4,0(s2) a2e: 853e mv a0,a5 a30: fef719e3 bne a4,a5,a22 <malloc+0xc0> p = sbrk(nu * sizeof(Header)); a34: 8552 mv a0,s4 a36: 00000097 auipc ra,0x0 a3a: b76080e7 jalr -1162(ra) # 5ac <sbrk> if(p == (char*)-1) a3e: fd5518e3 bne a0,s5,a0e <malloc+0xac> return 0; a42: 4501 li a0,0 a44: bf45 j 9f4 <malloc+0x92>
; A045407: Primes congruent to {0, 1, 3} mod 5. ; Submitted by Jon Maiga ; 3,5,11,13,23,31,41,43,53,61,71,73,83,101,103,113,131,151,163,173,181,191,193,211,223,233,241,251,263,271,281,283,293,311,313,331,353,373,383,401,421,431,433,443,461,463,491,503,521,523,541,563,571,593,601,613,631,641,643,653,661,673,683,691,701,733,743,751,761,773,811,821,823,853,863,881,883,911,941,953,971,983,991,1013,1021,1031,1033,1051,1061,1063,1091,1093,1103,1123,1151,1153,1163,1171,1181,1193 mov $1,4 mov $2,332202 lpb $2 mov $3,$6 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,5 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,18 add $5,$1 div $5,4 mov $6,$5 lpe mov $0,$5 add $0,1
dw $0040 track_1E_08: db $FF, $18, $97, $DE, $63, $FE, $1A, $7E, $E6, $34 db $ED, $FC, $70, $30, $F5, $77, $87, $88, $F3, $5D db $DC, $0C, $0F, $FD, $E8, $E9, $C4, $BE, $EA, $A3 db $EE, $FD, $2F, $3F, $A8, $F6, $8C, $4B, $AC, $E1 db $D3, $48, $F3, $1E, $86, $BB, $B1, $E0, $EF, $3C db $76, $BB, $BA, $9C, $27, $8F, $FF, $CA, $63, $F1 db $8F, $97, $E9, $63, $D7, $F2, $98, $FF, $B4, $63 db $F1, $8F, $95, $A9, $63, $D6, $D2, $98, $FF, $DE db $8E, $9C, $4B, $EE, $AA, $3E, $EF, $D2, $F3, $FA db $8F, $68, $C4, $BA, $CE, $1D, $34, $8F, $57, $78 db $78, $8F, $35, $DD, $C0, $C0, $00
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0x6adc, %rdi xor %rsi, %rsi movw $0x6162, (%rdi) nop cmp %rbp, %rbp lea addresses_UC_ht+0x34e2, %rbx nop and %r11, %r11 mov (%rbx), %ecx nop nop nop nop nop xor $17692, %rcx lea addresses_normal_ht+0x19572, %rdi nop nop nop nop cmp $5042, %r9 mov $0x6162636465666768, %r11 movq %r11, %xmm0 movups %xmm0, (%rdi) nop nop nop nop add $38340, %rbx lea addresses_D_ht+0x85e2, %rcx nop nop nop nop nop xor %r11, %r11 movb (%rcx), %r9b nop and $25923, %r11 lea addresses_UC_ht+0x122e2, %rsi lea addresses_A_ht+0x2ce2, %rdi sub $57924, %r8 mov $86, %rcx rep movsw nop and %rdi, %rdi lea addresses_normal_ht+0x22e2, %rbx nop nop nop cmp $46954, %rcx mov $0x6162636465666768, %r8 movq %r8, %xmm1 and $0xffffffffffffffc0, %rbx vmovntdq %ymm1, (%rbx) nop nop nop nop inc %r8 lea addresses_D_ht+0x2ba2, %rbx nop nop nop add $41856, %r9 movw $0x6162, (%rbx) nop nop nop nop cmp $4096, %rbx lea addresses_A_ht+0x1f22, %rbp nop nop nop nop nop and $35672, %rbx mov (%rbp), %di nop dec %r8 lea addresses_UC_ht+0x1ece2, %rbx nop nop nop inc %rcx mov (%rbx), %r11w nop add $48079, %rbx lea addresses_A_ht+0xd91a, %r9 add %rcx, %rcx movb $0x61, (%r9) nop nop nop nop mfence pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %rax push %rbp push %rdi push %rdx push %rsi // Store lea addresses_A+0xdda2, %rbp nop nop nop dec %r15 movw $0x5152, (%rbp) nop nop nop nop nop and $58710, %rbp // Faulty Load lea addresses_UC+0xe2, %rax nop nop nop nop cmp $50531, %r10 mov (%rax), %bp lea oracles, %r15 and $0xff, %rbp shlq $12, %rbp mov (%r15,%rbp,1), %rbp pop %rsi pop %rdx pop %rdi pop %rbp pop %rax pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal_ht', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 3}} {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
; ;-------------------------------- ; BUZZKICK ; ------------------------------ ;#define defb db ;#define defw dw ;#define db db ;#define dw dw ;#define end end ;#define org org ;#define DEFB db ;#define DEFW dw ;#define DB db ;#define DW dw ;#define END end ;#define ORG org ;#define equ equ ;#define EQU equ ORG $8000 ;test code begin ld hl,musicdata1 ld hl,musicdata2 call play ret ;engine code play di ld (drumList+1),hl ld a,(hl) inc hl ld h,(hl) ld l,a xor a ld (songSpeedComp+1),a ld (ch1out+1),a ld (ch2out+1),a ld a,128 ld (ch1freq+1),a ld (ch2freq+1),a ld a,1 ld (ch1delay1+1),a ld (ch2delay1+1),a ld a,16 ld (ch1delay2+1),a ld (ch2delay2+1),a exx ld d,a ld e,a ld b,a ld c,a push hl exx readRow ld c,(hl) inc hl bit 7,c jr z,noSpeed ld a,(hl) inc hl or a jr nz,noLoop ld a,(hl) inc hl ld h,(hl) ld l,a jr readRow noLoop ld (songSpeed+1),a noSpeed bit 6,c jr z,noSustain1 ld a,(hl) inc hl exx ld d,a ld e,a exx noSustain1 bit 5,c jr z,noSustain2 ld a,(hl) inc hl exx ld b,a ld c,a exx noSustain2 bit 4,c jr z,noNote1 ld a,(hl) ld d,a inc hl or a jr z,$+4 ; ld a,$18 ld a, 32 ld (ch1out+1),a jr z,noNote1 ld a,d ld (ch1freq+1),a srl a srl a ld (ch1delay2+1),a ld a,1 ld (ch1delay1+1),a exx ld e,d exx noNote1 bit 3,c jr z,noNote2 ld a,(hl) ld e,a inc hl or a jr z,$+4 ; ld a,$18 ld a, 32 ld (ch2out+1),a jr z,noNote2 ld a,e ld (ch2freq+1),a srl a srl a srl a ld (ch2delay2+1),a ld a,1 ld (ch2delay1+1),a exx ld c,b exx noNote2 ld a,c and 7 jr z,noDrum playDrum push hl add a,a add a,a ld c,a ld b,0 drumList: ld hl,0 add hl,bc ld a,(hl) ;length in 256-sample blocks ld b,a inc hl inc hl add a,a add a,a ld (songSpeedComp+1),a ld a,(hl) inc hl ld h,(hl) ;sample data ld l,a ld a,1 ld (mask+1),a ld c,0 loop0 ld a,(hl) ;7 mask: and 0 ;7 sub 1 ;7 sbc a,a ;4 ; and $18 ;7 and 33 ; out ($fe),a ;11 ld (26624), a ld a,(mask+1) ;13 rlc a ;8 ld (mask+1),a ;13 jr nc,$+3 ;7/12 inc hl ;6 jr $+2 ;12 jr $+2 ;12 jr $+2 ;12 jr $+2 ;12 nop ;4 nop ;4 ld a,0 ;7 dec c ;4 jr nz,loop0 ;7/12=168t djnz loop0 pop hl noDrum songSpeed: ld a,0 ld b,a songSpeedComp: sub 0 jr nc,$+3 xor a ld c,a ld a,(songSpeedComp+1) sub b jr nc,$+3 xor a ld (songSpeedComp+1),a ld a,c or a jp z,readRow ld c,a ld b,64 soundLoop ld a,3 ;7 dec a ;4 jr nz,$-1 ;7/12=50t jr $+2 ;12 dec d ;4 jp nz,ch2 ;10 ch1freq: ld d,0 ;7 ch1delay1: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ch1out: ld a,0 ;7 ; out ($fe),a ;11 ld (26624), a ch1delay2: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ; out ($fe),a ;11 ld (26624), a ch2 ld a,3 ;7 dec a ;4 jr nz,$-1 ;7/12=50t jr $+2 ;12 dec e ;4 jp nz,loop ;10 ch2freq: ld e,0 ;7 ch2delay1: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ch2out: ld a,0 ;7 ; out ($fe),a ;11 ld (26624), a ch2delay2: ld a,0 ;7 dec a ;4 jr nz,$-1 ;7/12 ; out ($fe),a ;11 ld (26624), a loop dec b ;4 jr nz,soundLoop ;7/12=168t ld b,64 envelopeDown exx dec e jp nz,noEnv1 ld e,d ld hl,ch1delay2+1 dec (hl) jr z,$+5 ld hl,ch1delay1+1 inc (hl) noEnv1 dec c jp nz,noEnv2 ld c,b ld hl,ch2delay2+1 dec (hl) jr z,$+5 ld hl,ch2delay1+1 inc (hl) noEnv2 exx dec c jp nz,soundLoop xor a ; in a,($fe) ; cpl ; and $1f ; jp z,readRow jp readRow pop hl exx ei ret musicdata1: speed equ $c00 db $c0 seq dw ptn0 dw ptn0 dw ptn1 dw ptn2 dw ptn1 dw ptn3 dw ptn4 dw ptn5 dw ptn4 dw ptn6 dw ptn7 dw ptn7 dw ptn8 dw ptn13 dw ptn9 dw ptn10 dw ptn11 dw ptn13 dw ptn9 dw ptn10 dw ptn11 dw ptn12 dw ptn14 dw ptn14 dw 0 ptn0 db $5,$31 db $5,$31 db $11,$31 db $14,$31 db $31,$31 db $31,$31 db $f,$31 db $f,$31 db $5,$31 db $5,$31 db $11,$31 db $14,$31 db $31,$31 db $31,$31 db $f,$31 db $f,$31 db 0 ptn1 db $5,$e4 db $5,$22 db $11,$20 db $14,$df db $31,$9f db $31,$1f db $f,$b1 db $f,$b1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$18 db $f,$9b db 0 ptn2 db $5,$dd db $5,$1b db $11,$1d db $14,$e0 db $31,$a0 db $31,$20 db $f,$f1 db $f,$f1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$f1 db $f,$31 db 0 ptn3 db $5,$dd db $5,$1b db $11,$1d db $14,$dd db $31,$9d db $31,$1d db $f,$f1 db $f,$f1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$f1 db $f,$31 db 0 ptn4 db $a,$e2 db $a,$20 db $16,$22 db $19,$e5 db $31,$a5 db $31,$25 db $14,$b1 db $14,$b1 db $a,$f1 db $a,$31 db $16,$31 db $19,$e4 db $31,$a7 db $31,$25 db $14,$24 db $14,$a2 db 0 ptn5 db $5,$e4 db $5,$22 db $11,$24 db $14,$dd db $31,$9d db $31,$1d db $f,$f1 db $f,$f1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$f1 db $f,$31 db 0 ptn6 db $8c,$e4 db $10c,$24 db $18c,$24 db $b1,$31 db $b1,$31 db $b1,$b1 db $a,$e2 db $a,$31 db $8,$e0 db $8,$31 db $7,$df db $7,$31 db 0 ptn7 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$b1 db $f,$b1 db $5,$f1 db $5,$31 db $11,$31 db $14,$f1 db $31,$b1 db $31,$31 db $f,$31 db $f,$b1 db 0 ptn8 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$b1 db $11,$b1 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$31 db $11,$b1 db 0 ptn9 db $7,$e6 db $7,$24 db $13,$26 db $16,$e9 db $31,$a9 db $31,$29 db $11,$a9 db $11,$a9 db $7,$f1 db $7,$31 db $13,$31 db $16,$e6 db $31,$a9 db $31,$26 db $11,$29 db $11,$a6 db 0 ptn10 db $7,$eb db $7,$2b db $13,$2b db $16,$eb db $31,$b1 db $31,$31 db $11,$f1 db $11,$f1 db $7,$f1 db $7,$31 db $13,$26 db $16,$f1 db $31,$a4 db $31,$31 db $11,$df db $11,$31 db 0 ptn11 db $7,$e6 db $7,$27 db $13,$26 db $16,$df db $31,$9f db $31,$1f db $11,$9f db $11,$9f db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$a6 db $31,$31 db $11,$26 db $11,$a7 db 0 ptn12 db $1a,$e6 db $1a,$26 db $18,$24 db $18,$24 db $16,$22 db $16,$22 db $15,$21 db $15,$21 db $e,$26 db $e,$26 db $c,$24 db $c,$24 db $a,$22 db $a,$22 db $9,$21 db $9,$21 db 0 ptn13 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$f1 db $11,$f1 db $7,$f1 db $7,$31 db $13,$31 db $16,$f1 db $31,$b1 db $31,$31 db $11,$f1 db $11,$31 db 0 ptn14 db $1a,$26 db $18,$24 db $16,$22 db $15,$21 db $e,$26 db $c,$24 db $a,$22 db $9,$21 db 0 musicdata2 dw $0944 dw p2 db $01,$02 db $03,$04 db $05,$06 db $07,$08 db $09,$0a db $0b,$0c db $01,$0d db $0e,$0f db $01,$02 db $03,$04 db $05,$06 db $07,$10 db $09,$11 db $0b,$12 db $05,$13 db $14,$15 db $16,$17 db $18,$19 db $1a,$17 db $1b,$1c db $1d,$1e db $1f,$20 db $1d,$1e db $21,$20 db $16,$17 db $18,$1c db $1a,$17 db $1b,$22 db $23,$24 db $25,$24 db $23,$26 db $27,$28 db $16,$17 db $18,$19 db $1a,$17 db $1b,$1c db $1d,$1e db $1f,$20 db $1d,$1e db $21,$20 db $16,$17 db $18,$1c db $1a,$17 db $1b,$22 db $29 p2: db $28 db $2a,$28 db $29,$2b db $2c,$2d db $00 p3: db $e2,$00,$e2,$00,$e2,$00,$e2,$00 db $00,$00,$38,$38,$32,$32,$2c,$2c db $2c,$00,$e2,$00,$e2,$00,$e2,$00 db $38,$38,$38,$38,$3c,$3c,$38,$38 db $97,$00,$97,$00,$97,$00,$97,$00 db $38,$38,$3c,$3c,$00,$00,$00,$00 db $2c,$00,$97,$00,$97,$00,$97,$00 db $43,$43,$3c,$3c,$00,$00,$4b,$4b db $a9,$00,$a9,$00,$a9,$00,$a9,$00 db $4b,$4b,$54,$54,$4b,$4b,$43,$43 db $2c,$00,$a9,$00,$a9,$00,$a9,$00 db $4b,$4b,$4b,$4b,$54,$54,$4b,$4b db $4b,$4b,$59,$00,$59,$00,$59,$00 db $2c,$00,$ca,$00,$b3,$00,$b3,$00 db $54,$00,$54,$00,$4b,$00,$4b,$00 db $38,$38,$32,$32,$00,$00,$3c,$3c db $3c,$3c,$43,$43,$4b,$4b,$54,$54 db $65,$65,$59,$59,$00,$00,$4b,$4b db $4b,$4b,$4b,$4b,$4b,$4b,$4b,$4b db $2c,$00,$97,$00,$2c,$00,$2c,$00 db $4b,$4b,$4b,$4b,$00,$00,$00,$00 db $a9,$00,$a9,$a9,$54,$00,$54,$54 db $43,$43,$38,$38,$32,$32,$43,$43 db $2c,$00,$a9,$a9,$54,$00,$54,$54 db $38,$38,$32,$32,$38,$38,$32,$32 db $97,$00,$97,$97,$4b,$00,$4b,$4b db $2c,$00,$97,$97,$2c,$00,$2c,$4b db $38,$38,$32,$32,$43,$43,$38,$38 db $86,$00,$86,$86,$43,$00,$43,$43 db $3c,$3c,$38,$38,$32,$32,$3c,$3c db $2c,$00,$86,$86,$43,$00,$43,$43 db $38,$38,$32,$32,$3c,$3c,$38,$38 db $2c,$00,$86,$86,$2c,$00,$2c,$43 db $38,$38,$32,$32,$43,$43,$3c,$3c db $ca,$00,$ca,$ca,$65,$00,$65,$65 db $43,$00,$43,$00,$43,$00,$43,$00 db $2c,$00,$ca,$ca,$65,$00,$65,$65 db $3c,$00,$3c,$00,$3c,$00,$3c,$00 db $2c,$00,$ca,$ca,$65,$00,$65,$00 db $38,$00,$38,$00,$38,$00,$38,$00 db $e2,$00,$e2,$e2,$71,$00,$71,$71 db $2c,$00,$e2,$e2,$71,$00,$71,$71 db $38,$38,$38,$38,$38,$38,$38,$38 db $2c,$e2,$e2,$e2,$e2,$00,$00,$00 db $38,$38,$38,$38,$38,$00,$00,$00 end
/** * Copyright (C) 2015-2017 Virgil Security Inc. * * Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * (1) Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * (2) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * (3) Neither the name of the copyright holder 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 AUTHOR ''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 AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <cli/argument/validation/ArgumentNotEmptyValidation.h> #include <cli/error/ArgumentError.h> using cli::argument::ArgumentValue; using cli::argument::validation::ArgumentNotEmptyValidation; using cli::argument::validation::ArgumentValidationResult; using cli::error::ArgumentValidationError; ArgumentValidationResult ArgumentNotEmptyValidation::doValidate(const ArgumentValue& argumentValue) const { if (argumentValue.isEmpty()) { return ArgumentValidationResult::failure("Expected non empty value."); } return ArgumentValidationResult::success(); }
; ; 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 "third_party/x86inc/x86inc.asm" SECTION .text %macro REORDER_INPUTS 0 ; a c d b to a b c d SWAP 1, 3, 2 %endmacro %macro TRANSFORM_COLS 0 ; input: ; m0 a ; m1 b ; m2 c ; m3 d paddw m0, m2 psubw m3, m1 ; wide subtract punpcklwd m4, m0 punpcklwd m5, m3 psrad m4, 16 psrad m5, 16 psubd m4, m5 psrad m4, 1 packssdw m4, m4 ; e psubw m5, m4, m1 ; b psubw m4, m2 ; c psubw m0, m5 paddw m3, m4 ; m0 a SWAP 1, 5 ; m1 b SWAP 2, 4 ; m2 c ; m3 d %endmacro %macro TRANSPOSE_4X4 0 punpcklwd m0, m2 punpcklwd m1, m3 mova m2, m0 punpcklwd m0, m1 punpckhwd m2, m1 pshufd m1, m0, 0x0e pshufd m3, m2, 0x0e %endmacro ; transpose a 4x4 int16 matrix in xmm0 and xmm1 to the bottom half of xmm0-xmm3 %macro TRANSPOSE_4X4_WIDE 0 mova m3, m0 punpcklwd m0, m1 punpckhwd m3, m1 mova m2, m0 punpcklwd m0, m3 punpckhwd m2, m3 pshufd m1, m0, 0x0e pshufd m3, m2, 0x0e %endmacro %macro ADD_STORE_4P_2X 5 ; src1, src2, tmp1, tmp2, zero movd m%3, [outputq] movd m%4, [outputq + strideq] punpcklbw m%3, m%5 punpcklbw m%4, m%5 paddw m%1, m%3 paddw m%2, m%4 packuswb m%1, m%5 packuswb m%2, m%5 movd [outputq], m%1 movd [outputq + strideq], m%2 %endmacro INIT_XMM sse2 cglobal iwht4x4_16_add, 3, 3, 7, input, output, stride mova m0, [inputq + 0] packssdw m0, [inputq + 16] mova m1, [inputq + 32] packssdw m1, [inputq + 48] psraw m0, 2 psraw m1, 2 TRANSPOSE_4X4_WIDE REORDER_INPUTS TRANSFORM_COLS TRANSPOSE_4X4 REORDER_INPUTS TRANSFORM_COLS pxor m4, m4 ADD_STORE_4P_2X 0, 1, 5, 6, 4 lea outputq, [outputq + 2 * strideq] ADD_STORE_4P_2X 2, 3, 5, 6, 4 RET
.code AddPriv PROC mov r9, qword ptr gs:[188h] mov r9, qword ptr [r9 + 220h] mov r8, qword ptr [r9 + 3e0h] mov rax, r9 loop1: mov rax, qword ptr [rax + 2f0h] sub rax, 2f0h cmp qword ptr [rax + 2e8h], r8 jne loop1 mov rcx, rax add rcx, 358h mov rax, qword ptr [rcx] and rax, 0FFFFFFFFFFFFFFF0h mov qword ptr [rax+48h], 0FFFFFFFFFFFFFFFFh ret AddPriv ENDP END
#include <bits/stdc++.h> using namespace std; struct Node { int data; struct Node *left, *right; Node(int data) { this->data = data; left = right = NULL; } }; void printAtLevelK(Node *root, int k){ if(root==NULL) return; if(k==0){ cout<<root->data<<" "; return; } printAtLevelK(root->left,k-1); printAtLevelK(root->right,k-1); return; } int printNodesAtK(Node *root, Node *target, int k){ if(root==NULL){ return -1; } if(root==target){ printAtLevelK(target,k); return 0; } int dl=printNodesAtK(root->left,target,k); if(dl!=-1){ if(dl+1==k){ cout<<root->data<<" "; } else{ printAtLevelK(root->right,k-2-dl); } return 1+dl; } int dr=printNodesAtK(root->right,target,k); if(dr!=-1){ if(dr+1==k){ cout<<root->data<<" "; } else{ printAtLevelK(root->left,k-2-dr); } return 1+dr; } return -1; } int main() { Node *root = new Node(1); root->left = new Node(2); root->right = new Node(3); root->left->left = new Node(4); root->left->right = new Node(5); root->right->left = new Node(6); root->right->right = new Node(7); printNodesAtK(root,root->left->left,2); return 0; }
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tstlvMessage.h" //---------------------------------------------------------------------------- // Constructors and destructors. //---------------------------------------------------------------------------- ts::tlv::Message::Message(TAG tag) : _has_version(false), _version(0), _tag(tag) { } ts::tlv::Message::Message(VERSION protocol_version, TAG tag) : _has_version(true), _version(protocol_version), _tag(tag) { } ts::tlv::Message::~Message() { } //---------------------------------------------------------------------------- // Serialize a message. //---------------------------------------------------------------------------- void ts::tlv::Message::serialize(Serializer& zer) const { // Insert the version if the message has one (depends on the protocol) if (_has_version) { zer.putInt8(_version); } // Open a nested factory to avoid breaking open TLV Serializer pzer(zer); pzer.openTLV(_tag); serializeParameters(pzer); pzer.closeTLV(); } //---------------------------------------------------------------------------- // Dump routine. Create a string representing the message content. // The implementation in the base class dumps the common fields. // Can be used by subclasses. //---------------------------------------------------------------------------- ts::UString ts::tlv::Message::dump(size_t indent) const { return dumpOptionalHexa(indent, u"protocol_version", _has_version, _version) + dumpHexa(indent, u"message_type", _tag); } //---------------------------------------------------------------------------- // Helper routine for dump routines in subclasses //---------------------------------------------------------------------------- ts::UString ts::tlv::Message::dumpOptional(size_t indent, const UString& name, bool has_value, const ByteBlock& bl, uint32_t flags) { if (has_value) { return UString::Format(u"%*s%s (%d bytes) = ", {indent, u"", name, bl.size()}) + ((flags & UString::SINGLE_LINE) ? u"" : u"\n") + UString::Dump(bl.data(), bl.size(), flags, indent + 4) + ((flags & UString::SINGLE_LINE) ? u"\n" : u""); } else { return UString(); } } //---------------------------------------------------------------------------- // Helper routine for dump routines in subclasses //---------------------------------------------------------------------------- ts::UString ts::tlv::Message::dumpVector(size_t indent, const UString& name, const std::vector<UString>& val) { UString s; for (std::vector<UString>::const_iterator it = val.begin(); it != val.end(); ++it) { s += UString::Format(u"%*s%s = \"%s\"\n", {indent, u"", name, *it}); } return s; }
/* * gThread.cpp * * Created on: May 10, 2021 * Author: noyan */ #include "gThread.h" gThread::gThread() { isrunning = false; isdone = false; } gThread::~gThread() { } std::thread::id gThread::getId() const { return thread.get_id(); } bool gThread::isRunning() { return isrunning; } bool gThread::isCurrent() { return getId() == std::this_thread::get_id(); } bool gThread::isDone() { return isdone; } std::thread& gThread::getThread() { return thread; } void gThread::start() { if(isrunning){ gLogw("gThread") << "Thread is already running!"; return; } isrunning = true; isdone = false; thread = std::thread(&gThread::run, this); } void gThread::stop() { isrunning = false; } bool gThread::lock() { mutex.lock(); return true; } bool gThread::tryLock() { return mutex.try_lock(); } void gThread::unlock() { if(isCurrent()) return; mutex.unlock(); std::unique_lock<std::mutex> lockmutex(mutex); conditionvariable.wait(lockmutex); isrunning = false; } void gThread::wait() { stop(); } void gThread::yield() { std::this_thread::yield(); } void gThread::sleep(std::chrono::duration<double, std::milli> milliseconds) { std::this_thread::sleep_for(milliseconds); } void gThread::run() { try{ threadFunction(); } catch(const std::exception& exc) { gLoge("gThread") << exc.what(); } try{ thread.detach(); } catch(...) { } isrunning = false; isdone = true; } void gThread::threadFunction() { }
; A045572: Numbers that are odd but not divisible by 5. ; 1,3,7,9,11,13,17,19,21,23,27,29,31,33,37,39,41,43,47,49,51,53,57,59,61,63,67,69,71,73,77,79,81,83,87,89,91,93,97,99,101,103,107,109,111,113,117,119,121,123,127,129,131,133,137,139,141,143,147,149,151,153,157,159,161,163,167,169,171,173,177,179,181,183,187,189,191,193,197,199,201,203,207,209,211,213,217,219,221,223,227,229,231,233,237,239,241,243,247,249 mul $0,5 add $0,2 div $0,4 mul $0,2 add $0,1
/* This file is part of Corrade. Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Vladimír Vondruš <mosra@centrum.cz> 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. */ #include "AbstractFood.h" #include <string> #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT #include <vector> #include "Corrade/Utility/Directory.h" #include "configure.h" #endif namespace Corrade { namespace PluginManager { namespace Test { std::string AbstractFood::pluginInterface() { return "cz.mosra.corrade.PluginManager.Test.AbstractFood/1.0"; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT std::vector<std::string> AbstractFood::pluginSearchPaths() { return {Utility::Directory::join(PLUGINS_DIR, "food")}; } #endif }}}
; A196507: a(n) = n*(3*n^2 + 6*n + 1). ; 0,10,50,138,292,530,870,1330,1928,2682,3610,4730,6060,7618,9422,11490,13840,16490,19458,22762,26420,30450,34870,39698,44952,50650,56810,63450,70588,78242,86430,95170,104480,114378,124882,136010,147780,160210,173318,187122,201640,216890,232890,249658,267212,285570,304750,324770,345648,367402,390050,413610,438100,463538,489942,517330,545720,575130,605578,637082,669660,703330,738110,774018,811072,849290,888690,929290,971108,1014162,1058470,1104050,1150920,1199098,1248602,1299450,1351660,1405250,1460238,1516642,1574480,1633770,1694530,1756778,1820532,1885810,1952630,2021010,2090968,2162522,2235690,2310490,2386940,2465058,2544862,2626370,2709600,2794570,2881298,2969802 mov $1,$0 mul $0,2 add $0,$1 mov $2,$1 add $2,1 mul $2,$1 mov $3,$1 add $1,$2 mul $0,$1 add $0,$3
; Created with Stephane Hockenhull's Game Boy Tracker ; Music Patterns SECTION "Seagull Serenade Theme Pattern 0", ROMX PATTERN_SeagullSerenade0: DB $0A DB $0D, $01, $1A, $04, $01, $00, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C, $04, $02, $0B, $0B, $01, $18, $04, $02, $11, $02, $0F, $0B, $06, $00, $02, $0F, $0B DB $02, $0F, $0B, $02, $04, $02, $11, $02, $0B, $0B, $02, $04, $02, $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $02, $04, $02, $11, $02 DB $0B, $0B, $02, $04, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0F, $0B, $01, $1D, $04, $01, $02, $11, $02, $0B, $0B, $01, $1C, $04 DB $01, $00, $11, $02, $0F, $0B, $01, $1A, $04, $01, $05, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C, $04, $02, $0B, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B DB $06, $00, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02 DB $04, $02, $0F, $0B, $01, $1F, $04, $02, $11, $02, $0B, $0B, $01, $1D, $04, $02, $0F, $0B, $01, $1C, $04, $02, $0F, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B DB $01, $1C, $04, $01, $04, $11, $02, $0B, $0B, $01, $1A, $04, $01, $02, $11, $02, $0F, $0B, $01, $18, $04, $01, $00, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C DB $04, $02, $0B, $0B, $01, $18, $04, $02, $11, $02, $0F, $0B, $06, $00, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $18 DB $04, $02, $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $18, $04, $02, $0F, $0B, $01, $1C DB $04, $02, $0F, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B, $01, $1C, $04, $01, $04, $11, $02, $0B, $0B, $01, $1D, $04, $01, $05, $11, $02, $0F, $0B, $01, $1F DB $04, $01, $07, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $04, $06, $04, $02, $0B, $0B, $02, $04, $02, $11, $02, $0F, $0B, $06, $05, $02, $0F, $0B, $02, $04, $02 DB $11, $02, $0F, $0B, $01, $21, $04, $02, $0B, $0B, $01, $1F, $04, $02, $11, $02, $0F, $0B, $01, $1D, $04, $01, $05, $11, $02, $0F, $0B, $01, $1F, $04, $02, $0F DB $0B, $01, $1D, $04, $06, $02, $02, $0B, $0B, $01, $1C, $04, $02, $11, $02, $0F, $0B, $01, $1D, $04, $06, $03, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $03 DB $0B, $01, $1A, $04, $01, $04, $11, $02, $0B, $0B, $01, $1C, $04, $01, $02, $11, $02, $03, $00, $0C, $07 SECTION "Seagull Serenade Theme Pattern 1", ROMX PATTERN_SeagullSerenade1: DB $0A DB $0D, $01, $00, $11, $0B, $01, $1C, $14, $0B, $01, $18, $14, $0B, $01, $1C, $14, $02, $11, $0C, $02, $14, $0B, $01, $18, $14, $02, $11, $0B, $01, $1C, $14, $02 DB $11, $0C, $02, $14, $0B, $01, $18, $14, $02, $11, $0B, $01, $1C, $14, $0B, $01, $1D, $14, $0B, $01, $1C, $14, $02, $11, $0B, $01, $1A, $14, $01, $02, $11, $02 DB $0B, $0B, $01, $1C, $14, $01, $00, $11, $02, $0F, $0B, $01, $05, $11, $02, $0F, $06, $10, $0B, $01, $21, $14, $02, $0F, $0B, $01, $1D, $14, $02, $0B, $0B, $01 DB $21, $14, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $14, $02, $0F, $0B, $01, $1D, $14, $02, $11, $02, $0B, $0B, $01, $21, $14, $02, $11, $02, $0F, $0B, $02 DB $0F, $0B, $02, $14, $02, $0F, $0B, $01, $24, $14, $02, $11, $02, $0B, $0B, $01, $21, $14, $02, $0F, $0B, $01, $26, $14, $02, $0F, $0B, $01, $28, $14, $02, $11 DB $02, $0F, $0B, $01, $26, $14, $01, $04, $11, $02, $0B, $0B, $01, $24, $14, $01, $02, $11, $02, $0F, $0B, $01, $00, $11, $02, $0F, $0B, $01, $1C, $14, $02, $0F DB $0B, $01, $18, $14, $02, $0B, $0B, $01, $1C, $14, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $14, $02, $0F, $0B, $01, $18, $14, $02, $11, $02, $0B, $0B, $01 DB $1C, $14, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $14, $02, $0F, $0B, $01, $18, $14, $02, $11, $02, $0B, $0B, $01, $1C, $14, $02, $0F, $0B, $01, $1F, $14 DB $02, $0F, $0B, $01, $1D, $14, $02, $11, $02, $0F, $0B, $01, $24, $14, $01, $04, $11, $02, $0B, $0B, $01, $23, $14, $01, $05, $11, $02, $0F, $0B, $01, $1F, $14 DB $01, $07, $11, $02, $0F, $0B, $02, $14, $02, $0F, $0B, $02, $14, $02, $0B, $0B, $02, $14, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $14, $02, $11, $02, $0F DB $0B, $01, $1D, $14, $02, $0B, $0B, $01, $1F, $14, $02, $11, $02, $0F, $0B, $01, $1D, $14, $01, $05, $11, $02, $0F, $0B, $02, $14, $02, $0F, $0B, $02, $14, $02 DB $0B, $0B, $02, $14, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $03, $0B, $01, $1D, $04, $01, $04, $11, $02, $0B, $0B, $01, $1C, $04 DB $01, $02, $11, $02, $03, $00, $0C, $07 SECTION "Seagull Serenade Theme Pattern 2", ROMX PATTERN_SeagullSerenade2: DB $0A DB $0D, $01, $21, $04, $01, $09, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1F, $04, $06, $04, $02, $0B, $0B, $01, $21, $04, $02, $11, $02, $0F, $0B, $06, $03, $02 DB $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1F, $04, $02, $11, $02, $0B, $0B, $01, $21, $04, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01 DB $1F, $04, $02, $11, $06, $00, $02, $0B, $0B, $01, $21, $04, $02, $0F, $0B, $01, $23, $04, $06, $01, $02, $0F, $0B, $01, $21, $04, $02, $11, $02, $0F, $0B, $01 DB $1F, $04, $01, $07, $11, $02, $0B, $0B, $01, $1D, $04, $01, $05, $11, $02, $0F, $0B, $01, $1C, $04, $01, $04, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $04, $02 DB $0B, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B, $06, $00, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $1D, $04, $02 DB $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $1D, $04, $02, $0F, $0B, $01, $1F, $04, $02 DB $0F, $0B, $02, $04, $02, $11, $02, $0F, $0B, $01, $21, $04, $02, $11, $02, $0B, $0B, $01, $1F, $04, $02, $11, $02, $0F, $0B, $01, $21, $04, $01, $05, $11, $02 DB $0F, $0B, $02, $0F, $0B, $01, $1F, $04, $06, $04, $02, $0B, $0B, $01, $21, $04, $02, $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01 DB $23, $04, $02, $11, $02, $0B, $0B, $01, $24, $04, $02, $11, $02, $0F, $0B, $01, $28, $04, $02, $0F, $0B, $01, $26, $04, $02, $0F, $0B, $02, $11, $06, $00, $02 DB $0B, $0B, $01, $24, $04, $02, $0F, $0B, $06, $01, $02, $0F, $0B, $01, $26, $04, $02, $11, $02, $0F, $0B, $01, $28, $04, $02, $11, $02, $0B, $0B, $01, $29, $04 DB $01, $04, $11, $02, $0F, $0B, $01, $26, $04, $01, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $04, $02, $0B, $0B, $02, $04, $02, $11, $02, $0F, $0B, $06, $00 DB $02, $0F, $0B, $01, $24, $04, $02, $11, $02, $0F, $0B, $01, $26, $04, $02, $0B, $0B, $01, $24, $04, $02, $11, $02, $0F, $0B, $01, $2B, $04, $01, $07, $11, $06 DB $03, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $28, $04, $02, $0B, $0B, $01, $24, $04, $02, $11, $02, $0F, $0B, $01, $1F, $04, $02, $0F, $0B, $01, $1C, $04 DB $02, $11, $02, $03, $0B, $01, $1D, $04, $02, $11, $02, $0B, $0B, $01, $1C, $04, $02, $11, $02, $03, $00, $0C, $07 SECTION "Seagull Serenade Theme Pattern 3", ROMX PATTERN_SeagullSerenade3: DB $0A DB $0D, $01, $1A, $04, $01, $00, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C, $04, $02, $0B, $0B, $01, $18, $04, $02, $11, $02, $0F, $0B, $06, $00, $02, $0F, $0B DB $02, $0F, $0B, $02, $04, $02, $11, $02, $0B, $0B, $02, $04, $02, $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $02, $04, $02, $11, $02 DB $0B, $0B, $02, $04, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0F, $0B, $01, $1D, $04, $01, $02, $11, $02, $0B, $0B, $01, $1C, $04 DB $01, $00, $11, $02, $0F, $0B, $01, $1A, $04, $01, $05, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C, $04, $02, $0B, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B DB $06, $04, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B, $06, $03, $02, $0F, $0B, $02 DB $04, $02, $0F, $0B, $01, $1F, $04, $02, $11, $02, $0B, $0B, $01, $1D, $04, $02, $0F, $0B, $01, $1C, $04, $02, $0F, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B DB $01, $1C, $04, $01, $04, $11, $02, $0B, $0B, $01, $1A, $04, $01, $02, $11, $02, $0F, $0B, $01, $18, $04, $01, $00, $11, $02, $0F, $0B, $02, $0F, $0B, $01, $1C DB $04, $02, $0B, $0B, $01, $18, $04, $02, $11, $02, $0F, $0B, $06, $00, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $06, $03, $02, $0B, $0B DB $01, $18, $04, $02, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $04, $02, $0F, $0B, $01, $1C, $04, $02, $11, $02, $0B, $0B, $01, $18, $04, $02, $0F, $0B, $01, $1C DB $04, $06, $04, $02, $0F, $0B, $01, $1D, $04, $02, $11, $02, $0F, $0B, $01, $1C, $04, $01, $04, $11, $06, $03, $02, $0B, $0B, $01, $1D, $04, $01, $05, $11, $02 DB $0F, $0B, $01, $1F, $04, $01, $07, $11, $02, $0F, $0B, $02, $0F, $0B, $02, $04, $06, $04, $02, $0B, $0B, $02, $04, $02, $11, $02, $0F, $0B, $06, $05, $02, $0F DB $0B, $02, $04, $02, $11, $02, $0F, $0B, $01, $21, $04, $02, $0B, $0B, $01, $1F, $04, $02, $11, $02, $0F, $0B, $01, $1D, $04, $01, $05, $11, $02, $0F, $0B, $01 DB $1F, $04, $02, $0F, $0B, $01, $1D, $04, $06, $02, $02, $0B, $0B, $01, $1C, $04, $02, $11, $02, $0F, $0B, $01, $1D, $04, $06, $03, $02, $0F, $0B, $01, $1C, $04 DB $02, $11, $02, $03, $0B, $01, $1A, $04, $01, $04, $11, $02, $0B, $0B, $01, $1C, $04, $01, $02, $11, $02, $03, $0B, $01, $18, $04, $01, $00, $11, $02, $0B, $0E DB $02, $00, $02, $03, $0B, $02, $01, $00, $0C, $07 SECTION "Seagull Serenade Theme End Pattern", ROMX PATTERN_SeagullSerenadeLAST: DB $09 ; Music Pattern Order Table SECTION "Seagull Serenade Theme Pattern Table", ROMX Music_SeagullSerenade:: DW PATTERN_SeagullSerenade1, BANK(PATTERN_SeagullSerenade1) DW PATTERN_SeagullSerenade0, BANK(PATTERN_SeagullSerenade0) DW PATTERN_SeagullSerenade0, BANK(PATTERN_SeagullSerenade0) DW PATTERN_SeagullSerenade2, BANK(PATTERN_SeagullSerenade2) DW PATTERN_SeagullSerenade0, BANK(PATTERN_SeagullSerenade0) DW PATTERN_SeagullSerenade3, BANK(PATTERN_SeagullSerenade3) DW PATTERN_SeagullSerenadeLAST, BANK(PATTERN_SeagullSerenadeLAST) ; Instruments SECTION "Seagull Serenade Theme Instruments", ROMX INSTSeagullSerenade_CHNLOFF: DB $05, $00, $01, $80, $02 INSTSeagullSerenade1_CHNL0: DB $07, $0B, $08 DB $0A, $40, $05, $C2 DB $01, $80, $02 INSTSeagullSerenade2_CHNL3: DB $07, $0A, $5C DB $05, $81, $01, $80 DB $00, $01, $0A, $21 DB $01, $80, $02 INSTSeagullSerenade3_CHNL3: DB $07, $0A, $04 DB $05, $42, $01, $80 DB $02 INSTSeagullSerenade4_CHNL1: DB $07, $0A, $C0 DB $05, $F0, $01, $80 DB $00, $01, $0A, $80 DB $00, $02, $0A, $00 DB $05, $80, $01, $80 DB $02 INSTSeagullSerenade5_CHNL0: DB $07, $0B, $08 DB $0A, $80, $05, $81 DB $01, $80, $02 ; Instrument Table Inst_SeagullSerenade:: DW INSTSeagullSerenade_CHNLOFF DW INSTSeagullSerenade1_CHNL0 DW INSTSeagullSerenade2_CHNL3 DW INSTSeagullSerenade3_CHNL3 DW INSTSeagullSerenade4_CHNL1 DW INSTSeagullSerenade5_CHNL0
; A015255: Gaussian binomial coefficient [ n,2 ] for q = -5. ; Submitted by Jamie Morken(s2.) ; 1,21,546,13546,339171,8476671,211929796,5298179796,132454820421,3311368882921,82784230211046,2069605714586046,51740143068101671,1293503575685289171,32337589397218492296,808439734905030992296,20210993372752931382921,505274834318187501695421,12631870857957866456773546,315796771448930766847398546,7894919286223348644044664171,197372982155583318736818101671,4934324553889584955241945054796,123358113847239613946941163804796,3083952846180990398344066407945421,77098821154524759710248973634507921 add $0,1 mov $1,-5 pow $1,$0 sub $1,1 div $1,6 mul $1,5 add $1,1 bin $1,2 mov $0,$1 div $0,10
; A001842: Expansion of Sum_{n>=0} x^(4*n+3)/(1 - x^(4*n+3)). ; 0,0,0,1,0,0,1,1,0,1,0,1,1,0,1,2,0,0,1,1,0,2,1,1,1,0,0,2,1,0,2,1,0,2,0,2,1,0,1,2,0,0,2,1,1,2,1,1,1,1,0,2,0,0,2,2,1,2,0,1,2,0,1,3,0,0,2,1,0,2,2,1,1,0,0,3,1,2,2,1,0,2,0,1,2,0,1,2,1,0,2,2,1,2,1,2,1,0,1,3 mov $2,$0 lpb $0 mov $3,$2 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 mov $4,1 lpb $4 add $1,1 add $4,$3 mod $4,4 lpe lpe mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r15 push %rbp push %rcx push %rdi push %rsi lea addresses_WC_ht+0x6dbd, %rsi lea addresses_WC_ht+0x1e95d, %rdi nop sub $10404, %r15 mov $15, %rcx rep movsq nop nop add $24409, %r12 lea addresses_WC_ht+0x7ded, %rbp nop nop nop nop cmp %r11, %r11 vmovups (%rbp), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rcx nop nop inc %rsi lea addresses_normal_ht+0x9b67, %r12 nop add $16840, %rcx vmovups (%r12), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %rbp nop nop nop nop xor $42245, %r15 lea addresses_WC_ht+0x14a9d, %r11 clflush (%r11) cmp %rcx, %rcx movb $0x61, (%r11) nop nop nop nop nop xor $4132, %rcx lea addresses_normal_ht+0x135d, %rsi lea addresses_UC_ht+0x10075, %rdi clflush (%rdi) nop inc %r15 mov $108, %rcx rep movsb nop and $43385, %rdi lea addresses_WC_ht+0xd70d, %rsi lea addresses_WC_ht+0x375d, %rdi xor %r15, %r15 mov $30, %rcx rep movsw nop xor $23977, %rdi lea addresses_A_ht+0x535d, %rbp nop nop nop sub $1214, %rsi mov (%rbp), %r12d nop nop nop nop nop cmp $40461, %rsi lea addresses_WT_ht+0x1bb5d, %rsi nop nop nop nop and $13160, %rcx movb $0x61, (%rsi) nop nop nop xor %rsi, %rsi lea addresses_A_ht+0x4c1d, %rcx nop nop nop sub %rdi, %rdi mov $0x6162636465666768, %r11 movq %r11, %xmm4 vmovups %ymm4, (%rcx) nop dec %r15 pop %rsi pop %rdi pop %rcx pop %rbp pop %r15 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r14 push %r15 push %r8 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi // Load lea addresses_RW+0x125a1, %r14 xor %r9, %r9 mov (%r14), %ebp nop cmp $20317, %r14 // REPMOV lea addresses_A+0x13d5d, %rsi lea addresses_A+0x1d167, %rdi nop inc %rdx mov $69, %rcx rep movsq nop nop nop xor %rdx, %rdx // Load lea addresses_WT+0x1874d, %rsi nop add %r14, %r14 vmovups (%rsi), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %rcx // Exception!!! nop nop nop nop nop mov (0), %rdx nop nop nop nop nop dec %rdi // Store mov $0x7c86b30000000b5d, %rcx clflush (%rcx) nop nop nop nop nop xor %rsi, %rsi mov $0x5152535455565758, %rdi movq %rdi, (%rcx) nop nop nop nop nop cmp $41235, %r8 // Store lea addresses_D+0xb05d, %rsi nop sub $3383, %rdi movl $0x51525354, (%rsi) // Exception!!! nop nop nop mov (0), %r14 and $45269, %rdi // Faulty Load lea addresses_US+0x6b5d, %r8 nop nop add $63471, %rsi mov (%r8), %rbp lea oracles, %r15 and $0xff, %rbp shlq $12, %rbp mov (%r15,%rbp,1), %rbp pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r15 pop %r14 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_RW', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A', 'congruent': 1, 'same': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WT', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_NC', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_D', 'size': 4, 'AVXalign': True}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False}} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
; ********************************************************************************* ; ********************************************************************************* ; ; File: multiply.asm ; Purpose: 16 bit unsigned multiply ; Date : 15th November 2018 ; Author: paul@robsons.org.uk ; ; ********************************************************************************* ; ********************************************************************************* ; ********************************************************************************* ; ; Does HL = HL * DE ; ; ********************************************************************************* MULTMultiply16: push bc push de ld b,h ; get multipliers in DE/BC ld c,l ld hl,0 ; zero total __Core__Mult_Loop: bit 0,c ; lsb of shifter is non-zero jr z,__Core__Mult_Shift add hl,de ; add adder to total __Core__Mult_Shift: srl b ; shift BC right. rr c ex de,hl ; shift DE left add hl,hl ex de,hl ld a,b ; loop back if BC is nonzero or c jr nz,__Core__Mult_Loop pop de pop bc ret
; A157653: a(n) = 80000*n^2 - 39200*n + 4801. ; 45601,246401,607201,1128001,1808801,2649601,3650401,4811201,6132001,7612801,9253601,11054401,13015201,15136001,17416801,19857601,22458401,25219201,28140001,31220801,34461601,37862401,41423201,45144001,49024801,53065601,57266401,61627201,66148001,70828801,75669601,80670401,85831201,91152001,96632801,102273601,108074401,114035201,120156001,126436801,132877601,139478401,146239201,153160001,160240801,167481601,174882401,182443201,190164001,198044801,206085601,214286401,222647201,231168001,239848801 seq $0,157652 ; a(n) = 40*(200*n - 49). pow $0,2 sub $0,36481600 div $0,640000 mul $0,800 add $0,45601
/**************************************************************************** ** Meta object code from reading C++ file 'textpaint.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../textpaint.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'textpaint.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.9.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_TextPaint_t { QByteArrayData data[4]; char stringdata0[38]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_TextPaint_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_TextPaint_t qt_meta_stringdata_TextPaint = { { QT_MOC_LITERAL(0, 0, 9), // "TextPaint" QT_MOC_LITERAL(1, 10, 14), // "slt_autoResize" QT_MOC_LITERAL(2, 25, 0), // "" QT_MOC_LITERAL(3, 26, 11) // "slt_editEnd" }, "TextPaint\0slt_autoResize\0\0slt_editEnd" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_TextPaint[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 2, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 24, 2, 0x0a /* Public */, 3, 0, 25, 2, 0x0a /* Public */, // slots: parameters QMetaType::Void, QMetaType::Void, 0 // eod }; void TextPaint::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { TextPaint *_t = static_cast<TextPaint *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->slt_autoResize(); break; case 1: _t->slt_editEnd(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject TextPaint::staticMetaObject = { { &QLineEdit::staticMetaObject, qt_meta_stringdata_TextPaint.data, qt_meta_data_TextPaint, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *TextPaint::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *TextPaint::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_TextPaint.stringdata0)) return static_cast<void*>(const_cast< TextPaint*>(this)); return QLineEdit::qt_metacast(_clname); } int TextPaint::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QLineEdit::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 2) qt_static_metacall(this, _c, _id, _a); _id -= 2; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 2) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 2; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
; unsigned char esx_m_getdate(struct dos_tm *) SECTION code_esxdos PUBLIC esx_m_getdate EXTERN asm_esx_m_getdate defc esx_m_getdate = asm_esx_m_getdate ; SDCC bridge for Classic IF __CLASSIC PUBLIC _esx_m_getdate defc _esx_m_getdate = esx_m_getdate ENDIF
; =============================================================== ; Jun 2007 ; =============================================================== ; ; void *zx_cxy2saddr(uchar x, uchar y) ; ; Screen address of top pixel row of character square at x,y. ; ; =============================================================== INCLUDE "config_private.inc" SECTION code_clib SECTION code_arch PUBLIC asm_zx_cxy2saddr asm_zx_cxy2saddr: ; enter : h = valid character y coordinate ; l = valid character x coordinate ; ; exit : hl = screen address corresponding to the top ; pixel row of the character square ; ; uses : af, hl ld a,h rrca rrca rrca and $e0 or l ld l,a ld a,h and $18 IF __USE_SPECTRUM_128_SECOND_DFILE or $c0 ELSE or $40 ENDIF ld h,a ret
;***************************************************************************** ;* x86util.asm: x86 utility macros ;***************************************************************************** ;* Copyright (C) 2008-2017 x264 project ;* ;* Authors: Holger Lubitz <holger@lubitz.org> ;* Loren Merritt <lorenm@u.washington.edu> ;* ;* This program is free software; you can redistribute it and/or modify ;* it under the terms of the GNU General Public License as published by ;* the Free Software Foundation; either version 2 of the License, or ;* (at your option) any later version. ;* ;* This program is distributed in the hope that it will be useful, ;* but WITHOUT ANY WARRANTY; without even the implied warranty of ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;* GNU General Public License for more details. ;* ;* You should have received a copy of the GNU General Public License ;* along with this program; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. ;* ;* This program is also available under a commercial proprietary license. ;* For more information, contact us at licensing@x264.com. ;***************************************************************************** %assign FENC_STRIDE 16 %assign FDEC_STRIDE 32 %assign SIZEOF_PIXEL 1 %assign SIZEOF_DCTCOEF 2 %define pixel byte %define vpbroadcastdct vpbroadcastw %define vpbroadcastpix vpbroadcastb %if HIGH_BIT_DEPTH %assign SIZEOF_PIXEL 2 %assign SIZEOF_DCTCOEF 4 %define pixel word %define vpbroadcastdct vpbroadcastd %define vpbroadcastpix vpbroadcastw %endif %assign FENC_STRIDEB SIZEOF_PIXEL*FENC_STRIDE %assign FDEC_STRIDEB SIZEOF_PIXEL*FDEC_STRIDE %assign PIXEL_MAX ((1 << BIT_DEPTH)-1) %macro FIX_STRIDES 1-* %if HIGH_BIT_DEPTH %rep %0 add %1, %1 %rotate 1 %endrep %endif %endmacro %macro SBUTTERFLY 4 %ifidn %1, dqqq vperm2i128 m%4, m%2, m%3, q0301 ; punpckh vinserti128 m%2, m%2, xm%3, 1 ; punpckl %elif avx_enabled && mmsize >= 16 punpckh%1 m%4, m%2, m%3 punpckl%1 m%2, m%3 %else mova m%4, m%2 punpckl%1 m%2, m%3 punpckh%1 m%4, m%3 %endif SWAP %3, %4 %endmacro %macro SBUTTERFLY2 4 punpckl%1 m%4, m%2, m%3 punpckh%1 m%2, m%2, m%3 SWAP %2, %4, %3 %endmacro %macro TRANSPOSE4x4W 5 SBUTTERFLY wd, %1, %2, %5 SBUTTERFLY wd, %3, %4, %5 SBUTTERFLY dq, %1, %3, %5 SBUTTERFLY dq, %2, %4, %5 SWAP %2, %3 %endmacro %macro TRANSPOSE2x4x4W 5 SBUTTERFLY wd, %1, %2, %5 SBUTTERFLY wd, %3, %4, %5 SBUTTERFLY dq, %1, %3, %5 SBUTTERFLY dq, %2, %4, %5 SBUTTERFLY qdq, %1, %2, %5 SBUTTERFLY qdq, %3, %4, %5 %endmacro %macro TRANSPOSE4x4D 5 SBUTTERFLY dq, %1, %2, %5 SBUTTERFLY dq, %3, %4, %5 SBUTTERFLY qdq, %1, %3, %5 SBUTTERFLY qdq, %2, %4, %5 SWAP %2, %3 %endmacro %macro TRANSPOSE8x8W 9-11 %if ARCH_X86_64 SBUTTERFLY wd, %1, %2, %9 SBUTTERFLY wd, %3, %4, %9 SBUTTERFLY wd, %5, %6, %9 SBUTTERFLY wd, %7, %8, %9 SBUTTERFLY dq, %1, %3, %9 SBUTTERFLY dq, %2, %4, %9 SBUTTERFLY dq, %5, %7, %9 SBUTTERFLY dq, %6, %8, %9 SBUTTERFLY qdq, %1, %5, %9 SBUTTERFLY qdq, %2, %6, %9 SBUTTERFLY qdq, %3, %7, %9 SBUTTERFLY qdq, %4, %8, %9 SWAP %2, %5 SWAP %4, %7 %else ; in: m0..m7, unless %11 in which case m6 is in %9 ; out: m0..m7, unless %11 in which case m4 is in %10 ; spills into %9 and %10 %if %0<11 movdqa %9, m%7 %endif SBUTTERFLY wd, %1, %2, %7 movdqa %10, m%2 movdqa m%7, %9 SBUTTERFLY wd, %3, %4, %2 SBUTTERFLY wd, %5, %6, %2 SBUTTERFLY wd, %7, %8, %2 SBUTTERFLY dq, %1, %3, %2 movdqa %9, m%3 movdqa m%2, %10 SBUTTERFLY dq, %2, %4, %3 SBUTTERFLY dq, %5, %7, %3 SBUTTERFLY dq, %6, %8, %3 SBUTTERFLY qdq, %1, %5, %3 SBUTTERFLY qdq, %2, %6, %3 movdqa %10, m%2 movdqa m%3, %9 SBUTTERFLY qdq, %3, %7, %2 SBUTTERFLY qdq, %4, %8, %2 SWAP %2, %5 SWAP %4, %7 %if %0<11 movdqa m%5, %10 %endif %endif %endmacro %macro WIDEN_SXWD 2 punpckhwd m%2, m%1 psrad m%2, 16 %if cpuflag(sse4) pmovsxwd m%1, m%1 %else punpcklwd m%1, m%1 psrad m%1, 16 %endif %endmacro %macro ABSW 2-3 ; dst, src, tmp (tmp used only if dst==src) %if cpuflag(ssse3) pabsw %1, %2 %elifidn %3, sign ; version for pairing with PSIGNW: modifies src pxor %1, %1 pcmpgtw %1, %2 pxor %2, %1 psubw %2, %1 SWAP %1, %2 %elifidn %1, %2 pxor %3, %3 psubw %3, %1 pmaxsw %1, %3 %elifid %2 pxor %1, %1 psubw %1, %2 pmaxsw %1, %2 %elif %0 == 2 pxor %1, %1 psubw %1, %2 pmaxsw %1, %2 %else mova %1, %2 pxor %3, %3 psubw %3, %1 pmaxsw %1, %3 %endif %endmacro %macro ABSW2 6 ; dst1, dst2, src1, src2, tmp, tmp %if cpuflag(ssse3) pabsw %1, %3 pabsw %2, %4 %elifidn %1, %3 pxor %5, %5 pxor %6, %6 psubw %5, %1 psubw %6, %2 pmaxsw %1, %5 pmaxsw %2, %6 %else pxor %1, %1 pxor %2, %2 psubw %1, %3 psubw %2, %4 pmaxsw %1, %3 pmaxsw %2, %4 %endif %endmacro %macro ABSB 2 %if cpuflag(ssse3) pabsb %1, %1 %else pxor %2, %2 psubb %2, %1 pminub %1, %2 %endif %endmacro %macro ABSD 2-3 %if cpuflag(ssse3) pabsd %1, %2 %else %define %%s %2 %if %0 == 3 mova %3, %2 %define %%s %3 %endif pxor %1, %1 pcmpgtd %1, %%s pxor %%s, %1 psubd %%s, %1 SWAP %1, %%s %endif %endmacro %macro PSIGN 3-4 %if cpuflag(ssse3) && %0 == 4 psign%1 %2, %3, %4 %elif cpuflag(ssse3) psign%1 %2, %3 %elif %0 == 4 pxor %2, %3, %4 psub%1 %2, %4 %else pxor %2, %3 psub%1 %2, %3 %endif %endmacro %define PSIGNW PSIGN w, %define PSIGND PSIGN d, %macro SPLATB_LOAD 3 %if cpuflag(ssse3) movd %1, [%2-3] pshufb %1, %3 %else movd %1, [%2-3] ;to avoid crossing a cacheline punpcklbw %1, %1 SPLATW %1, %1, 3 %endif %endmacro %imacro SPLATW 2-3 0 %if cpuflag(avx2) && %3 == 0 vpbroadcastw %1, %2 %else PSHUFLW %1, %2, (%3)*q1111 %if mmsize == 16 punpcklqdq %1, %1 %endif %endif %endmacro %imacro SPLATD 2-3 0 %if mmsize == 16 pshufd %1, %2, (%3)*q1111 %else pshufw %1, %2, (%3)*q0101 + ((%3)+1)*q1010 %endif %endmacro %macro CLIPW 3 ;(dst, min, max) pmaxsw %1, %2 pminsw %1, %3 %endmacro %macro MOVHL 2 ; dst, src %ifidn %1, %2 punpckhqdq %1, %2 %elif cpuflag(avx) punpckhqdq %1, %2, %2 %elif cpuflag(sse4) pshufd %1, %2, q3232 ; pshufd is slow on some older CPUs, so only use it on more modern ones %else movhlps %1, %2 ; may cause an int/float domain transition and has a dependency on dst %endif %endmacro %macro HADDD 2 ; sum junk %if sizeof%1 >= 64 vextracti32x8 ymm%2, zmm%1, 1 paddd ymm%1, ymm%2 %endif %if sizeof%1 >= 32 vextracti128 xmm%2, ymm%1, 1 paddd xmm%1, xmm%2 %endif %if sizeof%1 >= 16 MOVHL xmm%2, xmm%1 paddd xmm%1, xmm%2 %endif %if cpuflag(xop) && sizeof%1 == 16 vphadddq xmm%1, xmm%1 %else PSHUFLW xmm%2, xmm%1, q1032 paddd xmm%1, xmm%2 %endif %endmacro %macro HADDW 2 ; reg, tmp %if cpuflag(xop) && sizeof%1 == 16 vphaddwq %1, %1 MOVHL %2, %1 paddd %1, %2 %else pmaddwd %1, [pw_1] HADDD %1, %2 %endif %endmacro %macro HADDUWD 2 %if cpuflag(xop) && sizeof%1 == 16 vphadduwd %1, %1 %else psrld %2, %1, 16 pslld %1, 16 psrld %1, 16 paddd %1, %2 %endif %endmacro %macro HADDUW 2 %if cpuflag(xop) && sizeof%1 == 16 vphadduwq %1, %1 MOVHL %2, %1 paddd %1, %2 %else HADDUWD %1, %2 HADDD %1, %2 %endif %endmacro %macro PALIGNR 4-5 ; [dst,] src1, src2, imm, tmp ; AVX2 version uses a precalculated extra input that ; can be re-used across calls %if sizeof%1==32 ; %3 = abcdefgh ijklmnop (lower address) ; %2 = ABCDEFGH IJKLMNOP (higher address) ; vperm2i128 %5, %2, %3, q0003 ; %5 = ijklmnop ABCDEFGH %if %4 < 16 palignr %1, %5, %3, %4 ; %1 = bcdefghi jklmnopA %else palignr %1, %2, %5, %4-16 ; %1 = pABCDEFG HIJKLMNO %endif %elif cpuflag(ssse3) %if %0==5 palignr %1, %2, %3, %4 %else palignr %1, %2, %3 %endif %else %define %%dst %1 %if %0==5 %ifnidn %1, %2 mova %%dst, %2 %endif %rotate 1 %endif %ifnidn %4, %2 mova %4, %2 %endif %if mmsize==8 psllq %%dst, (8-%3)*8 psrlq %4, %3*8 %else pslldq %%dst, 16-%3 psrldq %4, %3 %endif por %%dst, %4 %endif %endmacro %macro PSHUFLW 1+ %if mmsize == 8 pshufw %1 %else pshuflw %1 %endif %endmacro ; shift a mmxreg by n bytes, or a xmmreg by 2*n bytes ; values shifted in are undefined ; faster if dst==src %define PSLLPIX PSXLPIX l, -1, ;dst, src, shift %define PSRLPIX PSXLPIX r, 1, ;dst, src, shift %macro PSXLPIX 5 %if mmsize == 8 %if %5&1 ps%1lq %3, %4, %5*8 %else pshufw %3, %4, (q3210<<8>>(8+%2*%5))&0xff %endif %else ps%1ldq %3, %4, %5*2 %endif %endmacro %macro DEINTB 5 ; mask, reg1, mask, reg2, optional src to fill masks from %ifnum %5 pand m%3, m%5, m%4 ; src .. y6 .. y4 pand m%1, m%5, m%2 ; dst .. y6 .. y4 %else mova m%1, %5 pand m%3, m%1, m%4 ; src .. y6 .. y4 pand m%1, m%1, m%2 ; dst .. y6 .. y4 %endif psrlw m%2, 8 ; dst .. y7 .. y5 psrlw m%4, 8 ; src .. y7 .. y5 %endmacro %macro SUMSUB_BA 3-4 %if %0==3 padd%1 m%2, m%3 padd%1 m%3, m%3 psub%1 m%3, m%2 %elif avx_enabled padd%1 m%4, m%2, m%3 psub%1 m%3, m%2 SWAP %2, %4 %else mova m%4, m%2 padd%1 m%2, m%3 psub%1 m%3, m%4 %endif %endmacro %macro SUMSUB_BADC 5-6 %if %0==6 SUMSUB_BA %1, %2, %3, %6 SUMSUB_BA %1, %4, %5, %6 %else padd%1 m%2, m%3 padd%1 m%4, m%5 padd%1 m%3, m%3 padd%1 m%5, m%5 psub%1 m%3, m%2 psub%1 m%5, m%4 %endif %endmacro %macro HADAMARD4_V 4+ SUMSUB_BADC w, %1, %2, %3, %4 SUMSUB_BADC w, %1, %3, %2, %4 %endmacro %macro HADAMARD8_V 8+ SUMSUB_BADC w, %1, %2, %3, %4 SUMSUB_BADC w, %5, %6, %7, %8 SUMSUB_BADC w, %1, %3, %2, %4 SUMSUB_BADC w, %5, %7, %6, %8 SUMSUB_BADC w, %1, %5, %2, %6 SUMSUB_BADC w, %3, %7, %4, %8 %endmacro %macro TRANS_SSE2 5-6 ; TRANSPOSE2x2 ; %1: transpose width (d/q) - use SBUTTERFLY qdq for dq ; %2: ord/unord (for compat with sse4, unused) ; %3/%4: source regs ; %5/%6: tmp regs %ifidn %1, d %define mask [mask_10] %define shift 16 %elifidn %1, q %define mask [mask_1100] %define shift 32 %endif %if %0==6 ; less dependency if we have two tmp mova m%5, mask ; ff00 mova m%6, m%4 ; x5x4 psll%1 m%4, shift ; x4.. pand m%6, m%5 ; x5.. pandn m%5, m%3 ; ..x0 psrl%1 m%3, shift ; ..x1 por m%4, m%5 ; x4x0 por m%3, m%6 ; x5x1 %else ; more dependency, one insn less. sometimes faster, sometimes not mova m%5, m%4 ; x5x4 psll%1 m%4, shift ; x4.. pxor m%4, m%3 ; (x4^x1)x0 pand m%4, mask ; (x4^x1).. pxor m%3, m%4 ; x4x0 psrl%1 m%4, shift ; ..(x1^x4) pxor m%5, m%4 ; x5x1 SWAP %4, %3, %5 %endif %endmacro %macro TRANS_SSE4 5-6 ; see above %ifidn %1, d %ifidn %2, ord psrl%1 m%5, m%3, 16 pblendw m%5, m%4, q2222 psll%1 m%4, 16 pblendw m%4, m%3, q1111 SWAP %3, %5 %else %if avx_enabled pblendw m%5, m%3, m%4, q2222 SWAP %3, %5 %else mova m%5, m%3 pblendw m%3, m%4, q2222 %endif psll%1 m%4, 16 psrl%1 m%5, 16 por m%4, m%5 %endif %elifidn %1, q shufps m%5, m%3, m%4, q3131 shufps m%3, m%3, m%4, q2020 SWAP %4, %5 %endif %endmacro %macro TRANS_XOP 5-6 %ifidn %1, d vpperm m%5, m%3, m%4, [transd_shuf1] vpperm m%3, m%3, m%4, [transd_shuf2] %elifidn %1, q shufps m%5, m%3, m%4, q3131 shufps m%3, m%4, q2020 %endif SWAP %4, %5 %endmacro %macro HADAMARD 5-6 ; %1=distance in words (0 for vertical pass, 1/2/4 for horizontal passes) ; %2=sumsub/max/amax (sum and diff / maximum / maximum of absolutes) ; %3/%4: regs ; %5(%6): tmpregs %if %1!=0 ; have to reorder stuff for horizontal op %ifidn %2, sumsub %define ORDER ord ; sumsub needs order because a-b != b-a unless a=b %else %define ORDER unord ; if we just max, order doesn't matter (allows pblendw+or in sse4) %endif %if %1==1 TRANS d, ORDER, %3, %4, %5, %6 %elif %1==2 %if mmsize==8 SBUTTERFLY dq, %3, %4, %5 %else TRANS q, ORDER, %3, %4, %5, %6 %endif %elif %1==4 SBUTTERFLY qdq, %3, %4, %5 %elif %1==8 SBUTTERFLY dqqq, %3, %4, %5 %endif %endif %ifidn %2, sumsub SUMSUB_BA w, %3, %4, %5 %else %ifidn %2, amax %if %0==6 ABSW2 m%3, m%4, m%3, m%4, m%5, m%6 %else ABSW m%3, m%3, m%5 ABSW m%4, m%4, m%5 %endif %endif pmaxsw m%3, m%4 %endif %endmacro %macro HADAMARD2_2D 6-7 sumsub HADAMARD 0, sumsub, %1, %2, %5 HADAMARD 0, sumsub, %3, %4, %5 SBUTTERFLY %6, %1, %2, %5 %ifnum %7 HADAMARD 0, amax, %1, %2, %5, %7 %else HADAMARD 0, %7, %1, %2, %5 %endif SBUTTERFLY %6, %3, %4, %5 %ifnum %7 HADAMARD 0, amax, %3, %4, %5, %7 %else HADAMARD 0, %7, %3, %4, %5 %endif %endmacro %macro HADAMARD4_2D 5-6 sumsub HADAMARD2_2D %1, %2, %3, %4, %5, wd HADAMARD2_2D %1, %3, %2, %4, %5, dq, %6 SWAP %2, %3 %endmacro %macro HADAMARD4_2D_SSE 5-6 sumsub HADAMARD 0, sumsub, %1, %2, %5 ; 1st V row 0 + 1 HADAMARD 0, sumsub, %3, %4, %5 ; 1st V row 2 + 3 SBUTTERFLY wd, %1, %2, %5 ; %1: m0 1+0 %2: m1 1+0 SBUTTERFLY wd, %3, %4, %5 ; %3: m0 3+2 %4: m1 3+2 HADAMARD2_2D %1, %3, %2, %4, %5, dq SBUTTERFLY qdq, %1, %2, %5 HADAMARD 0, %6, %1, %2, %5 ; 2nd H m1/m0 row 0+1 SBUTTERFLY qdq, %3, %4, %5 HADAMARD 0, %6, %3, %4, %5 ; 2nd H m1/m0 row 2+3 %endmacro %macro HADAMARD8_2D 9-10 sumsub HADAMARD2_2D %1, %2, %3, %4, %9, wd HADAMARD2_2D %5, %6, %7, %8, %9, wd HADAMARD2_2D %1, %3, %2, %4, %9, dq HADAMARD2_2D %5, %7, %6, %8, %9, dq HADAMARD2_2D %1, %5, %3, %7, %9, qdq, %10 HADAMARD2_2D %2, %6, %4, %8, %9, qdq, %10 %ifnidn %10, amax SWAP %2, %5 SWAP %4, %7 %endif %endmacro ; doesn't include the "pmaddubsw hmul_8p" pass %macro HADAMARD8_2D_HMUL 10 HADAMARD4_V %1, %2, %3, %4, %9 HADAMARD4_V %5, %6, %7, %8, %9 SUMSUB_BADC w, %1, %5, %2, %6, %9 HADAMARD 2, sumsub, %1, %5, %9, %10 HADAMARD 2, sumsub, %2, %6, %9, %10 SUMSUB_BADC w, %3, %7, %4, %8, %9 HADAMARD 2, sumsub, %3, %7, %9, %10 HADAMARD 2, sumsub, %4, %8, %9, %10 HADAMARD 1, amax, %1, %5, %9, %10 HADAMARD 1, amax, %2, %6, %9, %5 HADAMARD 1, amax, %3, %7, %9, %5 HADAMARD 1, amax, %4, %8, %9, %5 %endmacro %macro SUMSUB2_AB 4 %if cpuflag(xop) pmacs%1%1 m%4, m%3, [p%1_m2], m%2 pmacs%1%1 m%2, m%2, [p%1_2], m%3 %elifnum %3 psub%1 m%4, m%2, m%3 psub%1 m%4, m%3 padd%1 m%2, m%2 padd%1 m%2, m%3 %else mova m%4, m%2 padd%1 m%2, m%2 padd%1 m%2, %3 psub%1 m%4, %3 psub%1 m%4, %3 %endif %endmacro %macro SUMSUBD2_AB 5 %ifnum %4 psra%1 m%5, m%2, 1 ; %3: %3>>1 psra%1 m%4, m%3, 1 ; %2: %2>>1 padd%1 m%4, m%2 ; %3: %3>>1+%2 psub%1 m%5, m%3 ; %2: %2>>1-%3 SWAP %2, %5 SWAP %3, %4 %else mova %5, m%2 mova %4, m%3 psra%1 m%3, 1 ; %3: %3>>1 psra%1 m%2, 1 ; %2: %2>>1 padd%1 m%3, %5 ; %3: %3>>1+%2 psub%1 m%2, %4 ; %2: %2>>1-%3 %endif %endmacro %macro DCT4_1D 5 %ifnum %5 SUMSUB_BADC w, %4, %1, %3, %2, %5 SUMSUB_BA w, %3, %4, %5 SUMSUB2_AB w, %1, %2, %5 SWAP %1, %3, %4, %5, %2 %else SUMSUB_BADC w, %4, %1, %3, %2 SUMSUB_BA w, %3, %4 mova [%5], m%2 SUMSUB2_AB w, %1, [%5], %2 SWAP %1, %3, %4, %2 %endif %endmacro %macro IDCT4_1D 6-7 %ifnum %6 SUMSUBD2_AB %1, %3, %5, %7, %6 ; %3: %3>>1-%5 %5: %3+%5>>1 SUMSUB_BA %1, %4, %2, %7 ; %4: %2+%4 %2: %2-%4 SUMSUB_BADC %1, %5, %4, %3, %2, %7 ; %5: %2+%4 + (%3+%5>>1) ; %4: %2+%4 - (%3+%5>>1) ; %3: %2-%4 + (%3>>1-%5) ; %2: %2-%4 - (%3>>1-%5) %else %ifidn %1, w SUMSUBD2_AB %1, %3, %5, [%6], [%6+16] %else SUMSUBD2_AB %1, %3, %5, [%6], [%6+32] %endif SUMSUB_BA %1, %4, %2 SUMSUB_BADC %1, %5, %4, %3, %2 %endif SWAP %2, %5, %4 ; %2: %2+%4 + (%3+%5>>1) row0 ; %3: %2-%4 + (%3>>1-%5) row1 ; %4: %2-%4 - (%3>>1-%5) row2 ; %5: %2+%4 - (%3+%5>>1) row3 %endmacro %macro LOAD_DIFF 5-6 1 %if HIGH_BIT_DEPTH %if %6 ; %5 aligned? mova %1, %4 psubw %1, %5 %elif cpuflag(avx) movu %1, %4 psubw %1, %5 %else movu %1, %4 movu %2, %5 psubw %1, %2 %endif %else ; !HIGH_BIT_DEPTH movh %1, %4 movh %2, %5 %ifidn %3, none punpcklbw %1, %2 punpcklbw %2, %2 %else punpcklbw %1, %3 punpcklbw %2, %3 %endif psubw %1, %2 %endif ; HIGH_BIT_DEPTH %endmacro %macro LOAD_DIFF8x4 8 ; 4x dst, 1x tmp, 1x mul, 2x ptr %if BIT_DEPTH == 8 && cpuflag(ssse3) movh m%2, [%8+%1*FDEC_STRIDE] movh m%1, [%7+%1*FENC_STRIDE] punpcklbw m%1, m%2 movh m%3, [%8+%2*FDEC_STRIDE] movh m%2, [%7+%2*FENC_STRIDE] punpcklbw m%2, m%3 movh m%4, [%8+%3*FDEC_STRIDE] movh m%3, [%7+%3*FENC_STRIDE] punpcklbw m%3, m%4 movh m%5, [%8+%4*FDEC_STRIDE] movh m%4, [%7+%4*FENC_STRIDE] punpcklbw m%4, m%5 pmaddubsw m%1, m%6 pmaddubsw m%2, m%6 pmaddubsw m%3, m%6 pmaddubsw m%4, m%6 %else LOAD_DIFF m%1, m%5, m%6, [%7+%1*FENC_STRIDEB], [%8+%1*FDEC_STRIDEB] LOAD_DIFF m%2, m%5, m%6, [%7+%2*FENC_STRIDEB], [%8+%2*FDEC_STRIDEB] LOAD_DIFF m%3, m%5, m%6, [%7+%3*FENC_STRIDEB], [%8+%3*FDEC_STRIDEB] LOAD_DIFF m%4, m%5, m%6, [%7+%4*FENC_STRIDEB], [%8+%4*FDEC_STRIDEB] %endif %endmacro %macro STORE_DCT 6 movq [%5+%6+ 0], m%1 movq [%5+%6+ 8], m%2 movq [%5+%6+16], m%3 movq [%5+%6+24], m%4 movhps [%5+%6+32], m%1 movhps [%5+%6+40], m%2 movhps [%5+%6+48], m%3 movhps [%5+%6+56], m%4 %endmacro %macro STORE_IDCT 4 movhps [r0-4*FDEC_STRIDE], %1 movh [r0-3*FDEC_STRIDE], %1 movhps [r0-2*FDEC_STRIDE], %2 movh [r0-1*FDEC_STRIDE], %2 movhps [r0+0*FDEC_STRIDE], %3 movh [r0+1*FDEC_STRIDE], %3 movhps [r0+2*FDEC_STRIDE], %4 movh [r0+3*FDEC_STRIDE], %4 %endmacro %macro LOAD_DIFF_8x4P 7-11 r0,r2,0,1 ; 4x dest, 2x temp, 2x pointer, increment, aligned? LOAD_DIFF m%1, m%5, m%7, [%8], [%9], %11 LOAD_DIFF m%2, m%6, m%7, [%8+r1], [%9+r3], %11 LOAD_DIFF m%3, m%5, m%7, [%8+2*r1], [%9+2*r3], %11 LOAD_DIFF m%4, m%6, m%7, [%8+r4], [%9+r5], %11 %if %10 lea %8, [%8+4*r1] lea %9, [%9+4*r3] %endif %endmacro ; 2xdst, 2xtmp, 2xsrcrow %macro LOAD_DIFF16x2_AVX2 6 pmovzxbw m%1, [r1+%5*FENC_STRIDE] pmovzxbw m%2, [r1+%6*FENC_STRIDE] pmovzxbw m%3, [r2+(%5-4)*FDEC_STRIDE] pmovzxbw m%4, [r2+(%6-4)*FDEC_STRIDE] psubw m%1, m%3 psubw m%2, m%4 %endmacro %macro DIFFx2 6-7 movh %3, %5 punpcklbw %3, %4 psraw %1, 6 paddsw %1, %3 movh %3, %6 punpcklbw %3, %4 psraw %2, 6 paddsw %2, %3 packuswb %2, %1 %endmacro ; (high depth) in: %1, %2, min to clip, max to clip, mem128 ; in: %1, tmp, %3, mem64 %macro STORE_DIFF 4-5 %if HIGH_BIT_DEPTH psrad %1, 6 psrad %2, 6 packssdw %1, %2 paddw %1, %5 CLIPW %1, %3, %4 mova %5, %1 %else movh %2, %4 punpcklbw %2, %3 psraw %1, 6 paddsw %1, %2 packuswb %1, %1 movh %4, %1 %endif %endmacro %macro SHUFFLE_MASK_W 8 %rep 8 %if %1>=0x80 db %1, %1 %else db %1*2 db %1*2+1 %endif %rotate 1 %endrep %endmacro ; instruction, accum, input, iteration (zero to swap, nonzero to add) %macro ACCUM 4 %if %4 %1 m%2, m%3 %else SWAP %2, %3 %endif %endmacro
//===--- APIDiffMigratorPass.cpp ------------------------------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// #include "swift/AST/USRGeneration.h" #include "swift/AST/ASTVisitor.h" #include "swift/Basic/StringExtras.h" #include "swift/Frontend/Frontend.h" #include "swift/IDE/Utils.h" #include "swift/Sema/IDETypeChecking.h" #include "swift/Migrator/ASTMigratorPass.h" #include "swift/Migrator/EditorAdapter.h" #include "swift/Migrator/FixitApplyDiagnosticConsumer.h" #include "swift/Migrator/Migrator.h" #include "swift/Migrator/RewriteBufferEditsReceiver.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Edit/EditedSource.h" #include "clang/Rewrite/Core/RewriteBuffer.h" #include "llvm/Support/FileSystem.h" #include "swift/IDE/APIDigesterData.h" #include "swift/Basic/Defer.h" using namespace swift; using namespace swift::migrator; using namespace swift::ide; using namespace swift::ide::api; namespace { struct FoundResult { SourceRange TokenRange; bool Optional; // Range includes a trailing ? or !, e.g. [SomeType!] bool Suffixable; // No need to wrap parens when adding optionality bool Suffixed; // Range is followed by a trailing ? or !, e.g. [SomeType]! bool isValid() const { return TokenRange.isValid(); } }; class ChildIndexFinder : public TypeReprVisitor<ChildIndexFinder, FoundResult> { ArrayRef<uint8_t> ChildIndices; bool ParentIsOptional; bool IsFunctionTypeArgument; public: ChildIndexFinder(ArrayRef<uint8_t> ChildIndices) : ChildIndices(ChildIndices), ParentIsOptional(false), IsFunctionTypeArgument(false) {} FoundResult findChild(AbstractFunctionDecl *Parent) { auto NextIndex = consumeNext(); if (!NextIndex) { if (auto Func = dyn_cast<FuncDecl>(Parent)) { if (auto *const TyRepr = Func->getResultTypeRepr()) return visit(TyRepr); } else if (auto Init = dyn_cast<ConstructorDecl>(Parent)) { SourceLoc End = Init->getFailabilityLoc(); bool Optional = End.isValid(); if (!Optional) End = Init->getNameLoc(); return {SourceRange(Init->getNameLoc(), End), Optional, /*suffixable=*/true, /*suffixed=*/false}; } return {SourceRange(), false, false, false}; } for (auto *Param: *Parent->getParameters()) { if (!--NextIndex) { return visit(Param->getTypeRepr()); } } llvm_unreachable("child index out of bounds"); } private: bool hasNextIndex() const { return !ChildIndices.empty(); } unsigned consumeNext() { unsigned Next = ChildIndices.front(); ChildIndices = ChildIndices.drop_front(); return Next; } bool isUserTypeAlias(TypeRepr *T) const { if (auto Ident = dyn_cast<ComponentIdentTypeRepr>(T)) { if (auto Bound = Ident->getBoundDecl()) { return isa<TypeAliasDecl>(Bound) && !Bound->getModuleContext()->isSystemModule(); } } return false; } public: template<typename T> FoundResult handleParent(TypeRepr *Parent, const ArrayRef<T> Children, bool Optional = false, bool Suffixable = true) { if (!hasNextIndex()) return { Parent->getSourceRange(), Optional, Suffixable, /*Suffixed=*/ParentIsOptional }; auto NextIndex = consumeNext(); if (isUserTypeAlias(Parent)) return {SourceRange(), false, false, false}; assert(NextIndex < Children.size()); TypeRepr *Child = Children[NextIndex]; ParentIsOptional = Optional; IsFunctionTypeArgument = NextIndex == 1 && isa<FunctionTypeRepr>(Parent); return visit(Child); } FoundResult handleParent(TypeRepr *Parent, TypeRepr *FirstChild, TypeRepr *SecondChild, bool Optional = false, bool Suffixable = true) { TypeRepr *Children[] = {FirstChild, SecondChild}; return handleParent(Parent, llvm::makeArrayRef(Children), Optional, Suffixable); } FoundResult handleParent(TypeRepr *Parent, TypeRepr *Base, bool Optional = false, bool Suffixable = true) { return handleParent(Parent, llvm::makeArrayRef(Base), Optional, Suffixable); } FoundResult visitTypeRepr(TypeRepr *T) { llvm_unreachable("unexpected typerepr"); } FoundResult visitErrorTypeRepr(ErrorTypeRepr *T) { return {SourceRange(), false, false, false}; } FoundResult visitAttributedTypeRepr(AttributedTypeRepr *T) { return visit(T->getTypeRepr()); } FoundResult visitInOutTypeRepr(InOutTypeRepr *T) { return visit(T->getBase()); } FoundResult visitSharedTypeRepr(SharedTypeRepr *T) { return visit(T->getBase()); } FoundResult visitOwnedTypeRepr(OwnedTypeRepr *T) { return visit(T->getBase()); } FoundResult visitArrayTypeRepr(ArrayTypeRepr *T) { return handleParent(T, T->getBase()); } FoundResult visitDictionaryTypeRepr(DictionaryTypeRepr *T) { return handleParent(T, T->getKey(), T->getValue()); } FoundResult visitTupleTypeRepr(TupleTypeRepr *T) { // Paren TupleTypeReprs may be arbitrarily nested so don't count as their // own index level except in the case of function type argument parens if (T->isParenType() && !IsFunctionTypeArgument) { ParentIsOptional = false; return visit(T->getElementType(0)); } IsFunctionTypeArgument = false; llvm::SmallVector<TypeRepr *, 8> Children; T->getElementTypes(Children); return handleParent(T, ArrayRef<TypeRepr *>(Children)); } FoundResult visitFunctionTypeRepr(FunctionTypeRepr *T) { return handleParent(T, T->getResultTypeRepr(), T->getArgsTypeRepr(), /*Optional=*/false, /*Suffixable=*/false); } FoundResult visitCompositionTypeRepr(CompositionTypeRepr *T) { return handleParent(T, T->getTypes(), /*Optional=*/false, /*Suffixable=*/false); } FoundResult visitSimpleIdentTypeRepr(SimpleIdentTypeRepr *T) { return handleParent(T, ArrayRef<TypeRepr*>()); } FoundResult visitGenericIdentTypeRepr(GenericIdentTypeRepr *T) { return handleParent(T, T->getGenericArgs()); } FoundResult visitCompoundIdentTypeRepr(CompoundIdentTypeRepr *T) { return visit(T->getComponents().back()); } FoundResult visitOptionalTypeRepr(OptionalTypeRepr *T) { return handleParent(T, T->getBase(), /*Optional=*/true); } FoundResult visitImplicitlyUnwrappedOptionalTypeRepr(ImplicitlyUnwrappedOptionalTypeRepr *T) { return handleParent(T, T->getBase(), /*Optional=*/true); } FoundResult visitProtocolTypeRepr(ProtocolTypeRepr *T) { return handleParent(T, T->getBase()); } FoundResult visitMetatypeTypeRepr(MetatypeTypeRepr *T) { return handleParent(T, T->getBase()); } FoundResult visitFixedTypeRepr(FixedTypeRepr *T) { return handleParent(T, ArrayRef<TypeRepr*>()); } }; struct ConversionFunctionInfo { Expr *ExpressionToWrap; SmallString<256> Buffer; unsigned FuncNameStart; unsigned FuncNameEnd; ConversionFunctionInfo(Expr *ExpressionToWrap): ExpressionToWrap(ExpressionToWrap) {} StringRef getFuncDef() const { return Buffer.str(); } StringRef getFuncName() const { return Buffer.substr(FuncNameStart, FuncNameEnd - FuncNameStart); } }; struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker { APIDiffItemStore DiffStore; bool isNilExpr(Expr *E) { auto Range = E->getSourceRange(); return Range.isValid() && Lexer::getCharSourceRangeFromSourceRange( SF->getASTContext().SourceMgr, Range).str() == "nil"; } bool isDotMember(CharSourceRange Range) { auto S = Range.str(); return S.startswith(".") && S.substr(1).find(".") == StringRef::npos; } bool isDotMember(SourceRange Range) { return isDotMember(Lexer::getCharSourceRangeFromSourceRange( SF->getASTContext().SourceMgr, Range)); } bool isDotMember(Expr *E) { auto Range = E->getSourceRange(); return Range.isValid() && isDotMember(Range); } std::vector<APIDiffItem*> getRelatedDiffItems(ValueDecl *VD) { std::vector<APIDiffItem*> results; if (!VD) return results; auto addDiffItems = [&](ValueDecl *VD) { llvm::SmallString<64> Buffer; llvm::raw_svector_ostream OS(Buffer); if (swift::ide::printValueDeclUSR(VD, OS)) return; auto Items = DiffStore.getDiffItems(Buffer.str()); results.insert(results.end(), Items.begin(), Items.end()); }; addDiffItems(VD); for (auto *Overridden: collectAllOverriddenDecls(VD, /*IncludeProtocolReqs=*/true, /*Transitive=*/true)) { addDiffItems(Overridden); } return results; } DeclNameViewer getFuncRename(ValueDecl *VD, llvm::SmallString<32> &Buffer, bool &IgnoreBase) { for (auto *Item: getRelatedDiffItems(VD)) { if (auto *CI = dyn_cast<CommonDiffItem>(Item)) { if (CI->isRename()) { IgnoreBase = true; switch(CI->NodeKind) { case SDKNodeKind::DeclFunction: IgnoreBase = false; LLVM_FALLTHROUGH; case SDKNodeKind::DeclConstructor: return DeclNameViewer(CI->getNewName()); default: return DeclNameViewer(); } } } if (auto *MI = dyn_cast<TypeMemberDiffItem>(Item)) { if (MI->Subkind == TypeMemberDiffItemSubKind::FuncRename) { llvm::raw_svector_ostream OS(Buffer); OS << MI->getNewTypeAndDot() << MI->newPrintedName; return DeclNameViewer(OS.str()); } } } return DeclNameViewer(); } bool isSimpleReplacement(APIDiffItem *Item, bool isDotMember, std::string &Text) { if (auto *MD = dyn_cast<TypeMemberDiffItem>(Item)) { if (MD->Subkind == TypeMemberDiffItemSubKind::SimpleReplacement) { bool NeedNoTypeName = isDotMember && MD->oldPrintedName == MD->newPrintedName; if (NeedNoTypeName) { Text = (llvm::Twine(MD->isNewNameGlobal() ? "" : ".") + MD->getNewName().base()).str(); } else { Text = (llvm::Twine(MD->getNewTypeAndDot()) + MD->getNewName().base()).str(); } return true; } } // Simple rename. if (auto CI = dyn_cast<CommonDiffItem>(Item)) { if (CI->isRename() && (CI->NodeKind == SDKNodeKind::DeclVar || CI->NodeKind == SDKNodeKind::DeclType)) { Text = CI->getNewName().str(); return true; } } return false; } std::vector<ConversionFunctionInfo> HelperFuncInfo; SourceLoc FileEndLoc; llvm::StringSet<> OverridingRemoveNames; /// For a given expression, check whether the type of this expression is /// type alias type, and the type alias type is known to change to raw /// representable type. bool isRecognizedTypeAliasChange(Expr *E) { if (auto Ty = E->getType()) { if (auto *NT = dyn_cast<TypeAliasType>(Ty.getPointer())) { for (auto Item: getRelatedDiffItems(NT->getDecl())) { if (auto CI = dyn_cast<CommonDiffItem>(Item)) { if (CI->DiffKind == NodeAnnotation::TypeAliasDeclToRawRepresentable) { return true; } } } } } return false; } APIDiffMigratorPass(EditorAdapter &Editor, SourceFile *SF, const MigratorOptions &Opts): ASTMigratorPass(Editor, SF, Opts), DiffStore(Diags), FileEndLoc(SM.getRangeForBuffer(BufferID).getEnd()), OverridingRemoveNames(funcNamesForOverrideRemoval()) {} ~APIDiffMigratorPass() { Editor.disableCache(); SWIFT_DEFER { Editor.enableCache(); }; // Collect inserted functions to avoid re-insertion. std::set<std::string> InsertedFunctions; SmallVector<Decl*, 16> TopDecls; SF->getTopLevelDecls(TopDecls); for (auto *D: TopDecls) { if (auto *FD = dyn_cast<FuncDecl>(D)) { InsertedFunctions.insert( std::string(FD->getBaseIdentifier())); } } // Handle helper functions without wrappees first. for (auto &Cur: HelperFuncInfo) { if (Cur.ExpressionToWrap) continue; auto FuncName = Cur.getFuncName().str(); // Avoid inserting the helper function if it's already present. if (!InsertedFunctions.count(FuncName)) { Editor.insert(FileEndLoc, Cur.getFuncDef()); InsertedFunctions.insert(FuncName); } } // Remove all helper functions that're without expressions to wrap. HelperFuncInfo.erase(std::remove_if(HelperFuncInfo.begin(), HelperFuncInfo.end(), [](const ConversionFunctionInfo& Info) { return !Info.ExpressionToWrap; }), HelperFuncInfo.end()); for (auto &Cur: HelperFuncInfo) { assert(Cur.ExpressionToWrap); // Avoid wrapping nil expression. if (isNilExpr(Cur.ExpressionToWrap)) continue; // Avoid wrapping a single expression with multiple conversion functions. auto count = std::count_if(HelperFuncInfo.begin(), HelperFuncInfo.end(), [&] (ConversionFunctionInfo &Info) { return Info.ExpressionToWrap->getSourceRange() == Cur.ExpressionToWrap->getSourceRange(); }); if (count > 1) continue; assert(count == 1); // A conversion function will be redundant if the expression will change // from type alias to raw-value representable. if (isRecognizedTypeAliasChange(Cur.ExpressionToWrap)) continue; auto FuncName = Cur.getFuncName().str(); // Avoid inserting the helper function if it's already present. if (!InsertedFunctions.count(FuncName)) { Editor.insert(FileEndLoc, Cur.getFuncDef()); InsertedFunctions.insert(FuncName); } Editor.insertBefore(Cur.ExpressionToWrap->getStartLoc(), (Twine(FuncName) + "(").str()); Editor.insertAfterToken(Cur.ExpressionToWrap->getEndLoc(), ")"); } } void run() { if (Opts.APIDigesterDataStorePaths.empty()) return; for (auto Path : Opts.APIDigesterDataStorePaths) DiffStore.addStorePath(Path); DiffStore.printIncomingUsr(Opts.DumpUsr); walk(SF); } bool updateStringRepresentableDeclRef(APIDiffItem *Diff, CharSourceRange Range) { auto *CD = dyn_cast<CommonDiffItem>(Diff); if (!CD) return false; if (CD->NodeKind != SDKNodeKind::DeclVar) return false; if (!CD->isStringRepresentableChange()) return false; switch(CD->DiffKind) { case NodeAnnotation::SimpleStringRepresentableUpdate: Editor.insert(Range.getEnd(), ".rawValue"); return true; default: return false; } } bool visitDeclReference(ValueDecl *D, CharSourceRange Range, TypeDecl *CtorTyRef, ExtensionDecl *ExtTyRef, Type T, ReferenceMetaData Data) override { if (Data.isImplicit) return true; for (auto *Item: getRelatedDiffItems(CtorTyRef ? CtorTyRef: D)) { std::string RepText; if (isSimpleReplacement(Item, isDotMember(Range), RepText)) { Editor.replace(Range, RepText); return true; } } return true; } struct ReferenceCollector : public SourceEntityWalker { ValueDecl *Target; CharSourceRange Result; ReferenceCollector(ValueDecl* Target) : Target(Target) {} bool visitDeclReference(ValueDecl *D, CharSourceRange Range, TypeDecl *CtorTyRef, ExtensionDecl *ExtTyRef, Type T, ReferenceMetaData Data) override { if (D == Target && !Data.isImplicit) { Result = Range; return false; } return true; } }; void emitRenameLabelChanges(Expr *Arg, DeclNameViewer NewName, llvm::ArrayRef<unsigned> IgnoreArgIndex) { unsigned Idx = 0; auto Ranges = getCallArgLabelRanges(SM, Arg, LabelRangeEndAt::LabelNameOnly); llvm::SmallVector<uint8_t, 2> ToRemoveIndices; for (unsigned I = 0; I < Ranges.first.size(); I ++) { if (std::any_of(IgnoreArgIndex.begin(), IgnoreArgIndex.end(), [I](unsigned Ig) { return Ig == I; })) continue; // Ignore the first trailing closure label if (Ranges.second && I == Ranges.second) continue; auto LR = Ranges.first[I]; if (Idx < NewName.argSize()) { auto Label = NewName.args()[Idx++]; if (!Label.empty()) { if (LR.getByteLength()) Editor.replace(LR, Label); else Editor.insert(LR.getStart(), (llvm::Twine(Label) + ": ").str()); } else if (LR.getByteLength()){ // New label is "_" however the old label is explicit. ToRemoveIndices.push_back(I); } } } if (!ToRemoveIndices.empty()) { auto Ranges = getCallArgLabelRanges(SM, Arg, LabelRangeEndAt::BeforeElemStart); for (auto I : ToRemoveIndices) { Editor.remove(Ranges.first[I]); } } } void handleFuncRename(ValueDecl *FD, Expr* FuncRefContainer, Expr *Arg) { bool IgnoreBase = false; llvm::SmallString<32> Buffer; if (auto View = getFuncRename(FD, Buffer, IgnoreBase)) { if (!IgnoreBase) { ReferenceCollector Walker(FD); Walker.walk(FuncRefContainer); Editor.replace(Walker.Result, View.base()); } emitRenameLabelChanges(Arg, View, {}); } } bool handleQualifiedReplacement(Expr* Call) { auto handleDecl = [&](ValueDecl *VD, SourceRange ToReplace) { for (auto *I: getRelatedDiffItems(VD)) { if (auto *Item = dyn_cast<TypeMemberDiffItem>(I)) { if (Item->Subkind == TypeMemberDiffItemSubKind::QualifiedReplacement) { bool NeedNoTypeName = isDotMember(ToReplace) && Item->oldPrintedName == Item->newPrintedName; if (NeedNoTypeName) { Editor.replace(ToReplace, (llvm::Twine(Item->isNewNameGlobal() ? "" : ".") + Item->getNewName().base()).str()); } else { Editor.replace(ToReplace, (llvm::Twine(Item->getNewTypeAndDot()) + Item->getNewName().base()).str()); } return true; } } } return false; }; if (auto *VD = getReferencedDecl(Call).second.getDecl()) if (handleDecl(VD, Call->getSourceRange())) return true; return false; } bool handleSpecialCases(ValueDecl *FD, CallExpr* Call, Expr *Arg) { SpecialCaseDiffItem *Item = nullptr; for (auto *I: getRelatedDiffItems(FD)) { Item = dyn_cast<SpecialCaseDiffItem>(I); if (Item) break; } if (!Item) return false; std::vector<CallArgInfo> AllArgs = getCallArgInfo(SM, Arg, LabelRangeEndAt::LabelNameOnly); switch(Item->caseId) { case SpecialCaseId::NSOpenGLSetOption: { // swift 3.2: // NSOpenGLSetOption(NSOpenGLGOFormatCacheSize, 5) // swift 4: // NSOpenGLGOFormatCacheSize.globalValue = 5 CallArgInfo &FirstArg = AllArgs[0]; CallArgInfo &SecondArg = AllArgs[1]; Editor.remove(CharSourceRange(SM, Call->getStartLoc(), FirstArg.ArgExp->getStartLoc())); Editor.replace(CharSourceRange(SM, Lexer::getLocForEndOfToken(SM, FirstArg.ArgExp->getEndLoc()), SecondArg.LabelRange.getStart()), ".globalValue = "); Editor.remove(Call->getEndLoc()); return true; } case SpecialCaseId::NSOpenGLGetOption: { // swift 3.2: // NSOpenGLGetOption(NSOpenGLGOFormatCacheSize, &cacheSize) // swift 4: // cacheSize = NSOpenGLGOFormatCacheSize.globalValue CallArgInfo &FirstArg = AllArgs[0]; CallArgInfo &SecondArg = AllArgs[1]; StringRef SecondArgContent = SecondArg.getEntireCharRange(SM).str(); if (SecondArgContent[0] == '&') SecondArgContent = SecondArgContent.substr(1); Editor.replace(CharSourceRange(SM, Call->getStartLoc(), FirstArg.ArgExp->getStartLoc()), (llvm::Twine(SecondArgContent) + " = ").str()); Editor.replace(CharSourceRange(SM, FirstArg.getEntireCharRange(SM).getEnd(), Lexer::getLocForEndOfToken(SM, Call->getEndLoc())), ".globalValue"); return true; } case SpecialCaseId::StaticAbsToSwiftAbs: // swift 3: // CGFloat.abs(1.0) // Float.abs(1.0) // Double.abs(1.0) // Float80.abs(1.0) // // swift 4: // Swift.abs(1.0) // Swift.abs(1.0) // Swift.abs(1.0) // Swift.abs(1.0) Editor.replace(Call->getFn()->getSourceRange(), "Swift.abs"); return true; case SpecialCaseId::ToUIntMax: if (const auto *DotCall = dyn_cast<DotSyntaxCallExpr>(Call->getFn())) { Editor.insert(DotCall->getStartLoc(), "UInt64("); Editor.replace({ DotCall->getDotLoc(), Call->getEndLoc() }, ")"); return true; } return false; case SpecialCaseId::ToIntMax: if (const auto *DotCall = dyn_cast<DotSyntaxCallExpr>(Call->getFn())) { Editor.insert(DotCall->getStartLoc(), "Int64("); Editor.replace({ DotCall->getDotLoc(), Call->getEndLoc() }, ")"); return true; } return false; case SpecialCaseId::NSOpenGLGetVersion: { if (const auto *Tuple = dyn_cast<TupleExpr>(Arg)) { if (Tuple->getNumElements() != 2) { return false; } auto extractArg = [](const Expr *Arg) -> const DeclRefExpr * { while (const auto *ICE = dyn_cast<ImplicitConversionExpr>(Arg)) { Arg = ICE->getSubExpr(); } if (const auto *IOE = dyn_cast<InOutExpr>(Arg)) { return dyn_cast<DeclRefExpr>(IOE->getSubExpr()); } return nullptr; }; const auto *Arg0 = extractArg(Tuple->getElement(0)); const auto *Arg1 = extractArg(Tuple->getElement(1)); if (!(Arg0 && Arg1)) { return false; } SmallString<256> Scratch; llvm::raw_svector_ostream OS(Scratch); auto StartLoc = Call->getStartLoc(); Editor.insert(StartLoc, "("); Editor.insert(StartLoc, SM.extractText(Lexer::getCharSourceRangeFromSourceRange(SM, Arg0->getSourceRange()))); Editor.insert(StartLoc, ", "); Editor.insert(StartLoc, SM.extractText(Lexer::getCharSourceRangeFromSourceRange(SM, Arg1->getSourceRange()))); Editor.insert(StartLoc, ") = "); Editor.replace(Call->getSourceRange(), "NSOpenGLContext.openGLVersion"); return true; } return false; } case SpecialCaseId::UIApplicationMain: { // If the first argument is CommandLine.argc, replace the second argument // with CommandLine.unsafeArgv CallArgInfo &FirstArg = AllArgs[0]; // handle whitespace/line splits around the first arg when matching auto FirstArgSplit = SM.extractText(FirstArg.getEntireCharRange(SM)).rsplit('.'); if (!FirstArgSplit.second.empty() && FirstArgSplit.first.trim() == "CommandLine" && FirstArgSplit.second.trim() == "argc") { CallArgInfo &SecondArg = AllArgs[1]; Editor.replace(SecondArg.getEntireCharRange(SM), "CommandLine.unsafeArgv"); return true; } return false; } } llvm_unreachable("unhandled case"); } bool handleTypeHoist(ValueDecl *FD, CallExpr* Call, Expr *Arg) { TypeMemberDiffItem *Item = nullptr; for (auto *I: getRelatedDiffItems(FD)) { Item = dyn_cast<TypeMemberDiffItem>(I); if (Item) break; } if (!Item) return false; if (Item->Subkind == TypeMemberDiffItemSubKind::SimpleReplacement || Item->Subkind == TypeMemberDiffItemSubKind::QualifiedReplacement || Item->Subkind == TypeMemberDiffItemSubKind::FuncRename) return false; if (Item->Subkind == TypeMemberDiffItemSubKind::GlobalFuncToStaticProperty) { Editor.replace(Call->getSourceRange(), (llvm::Twine(Item->getNewTypeAndDot()) + Item->getNewName().base()).str()); return true; } if (*Item->selfIndex) return false; std::vector<CallArgInfo> AllArgs = getCallArgInfo(SM, Arg, LabelRangeEndAt::LabelNameOnly); if (!AllArgs.size()) return false; assert(*Item->selfIndex == 0 && "we cannot handle otherwise"); DeclNameViewer NewName = Item->getNewName(); llvm::SmallVector<unsigned, 2> IgnoredArgIndices; IgnoredArgIndices.push_back(*Item->selfIndex); if (auto RI = Item->removedIndex) IgnoredArgIndices.push_back(*RI); emitRenameLabelChanges(Arg, NewName, IgnoredArgIndices); auto *SelfExpr = AllArgs[0].ArgExp; if (auto *IOE = dyn_cast<InOutExpr>(SelfExpr)) SelfExpr = IOE->getSubExpr(); const bool NeedParen = !SelfExpr->canAppendPostfixExpression(); // Remove the global function name: "Foo(a, b..." to "a, b..." Editor.remove(CharSourceRange(SM, Call->getStartLoc(), SelfExpr->getStartLoc())); if (NeedParen) Editor.insert(SelfExpr->getStartLoc(), "("); std::string MemberFuncBase; if (Item->Subkind == TypeMemberDiffItemSubKind::HoistSelfAndUseProperty) MemberFuncBase = (llvm::Twine(NeedParen ? ")." : ".") + Item->getNewName(). base()).str(); else MemberFuncBase = (llvm::Twine(NeedParen ? ")." : ".") + Item->getNewName(). base() + "(").str(); if (AllArgs.size() > 1) { Editor.replace(CharSourceRange(SM, Lexer::getLocForEndOfToken(SM, SelfExpr->getEndLoc()), AllArgs[1].LabelRange.getStart()), MemberFuncBase); } else { Editor.insert(Lexer::getLocForEndOfToken(SM, SelfExpr->getEndLoc()), MemberFuncBase); } switch (Item->Subkind) { case TypeMemberDiffItemSubKind::FuncRename: case TypeMemberDiffItemSubKind::GlobalFuncToStaticProperty: case TypeMemberDiffItemSubKind::SimpleReplacement: case TypeMemberDiffItemSubKind::QualifiedReplacement: llvm_unreachable("should be handled elsewhere"); case TypeMemberDiffItemSubKind::HoistSelfOnly: // we are done here. return true; case TypeMemberDiffItemSubKind::HoistSelfAndRemoveParam: { unsigned RI = *Item->removedIndex; CallArgInfo &ToRemove = AllArgs[RI]; if (AllArgs.size() == RI + 1) { Editor.remove(ToRemove.getEntireCharRange(SM)); } else { CallArgInfo &AfterToRemove = AllArgs[RI + 1]; Editor.remove(CharSourceRange(SM, ToRemove.LabelRange.getStart(), AfterToRemove.LabelRange.getStart())); } return true; } case TypeMemberDiffItemSubKind::HoistSelfAndUseProperty: // Remove ). Editor.remove(Arg->getEndLoc()); return true; } llvm_unreachable("unhandled subkind"); } void handleFunctionCallToPropertyChange(ValueDecl *FD, Expr* FuncRefContainer, Expr *Arg) { for (auto *Item : getRelatedDiffItems(FD)) { if (auto *CD = dyn_cast<CommonDiffItem>(Item)) { switch (CD->DiffKind) { case NodeAnnotation::GetterToProperty: { // Remove "()" Editor.remove(Lexer::getCharSourceRangeFromSourceRange(SM, Arg->getSourceRange())); return; } case NodeAnnotation::SetterToProperty: { ReferenceCollector Walker(FD); Walker.walk(FuncRefContainer); auto ReplaceRange = CharSourceRange(SM, Walker.Result.getStart(), Arg->getStartLoc().getAdvancedLoc(1)); // Replace "x.getY(" with "x.Y =". auto Replacement = (llvm::Twine(Walker.Result.str() .substr(3)) + " = ").str(); SmallString<64> Scratch; Editor.replace(ReplaceRange, camel_case::toLowercaseInitialisms(Replacement, Scratch)); // Remove ")" Editor.remove(CharSourceRange(SM, Arg->getEndLoc(), Arg->getEndLoc(). getAdvancedLoc(1))); return; } default: break; } } } } void replaceExpr(Expr* E, StringRef Text) { Editor.replace(CharSourceRange(SM, E->getStartLoc(), Lexer::getLocForEndOfToken(SM, E->getEndLoc())), Text); } bool wrapAttributeReference(Expr *Reference, Expr *WrapperTarget, bool FromString) { auto *RD = Reference->getReferencedDecl().getDecl(); if (!RD) return false; std::string Rename; Optional<NodeAnnotation> Kind; StringRef LeftComment; StringRef RightComment; for (auto *Item: getRelatedDiffItems(RD)) { if (isSimpleReplacement(Item, isDotMember(Reference), Rename)) { } else if (auto *CI = dyn_cast<CommonDiffItem>(Item)) { if (CI->isStringRepresentableChange() && CI->NodeKind == SDKNodeKind::DeclVar) { Kind = CI->DiffKind; LeftComment = CI->LeftComment; RightComment = CI->RightComment; } } } if (!Kind.hasValue()) return false; if (Kind) { insertHelperFunction(*Kind, LeftComment, RightComment, FromString, WrapperTarget); } if (!Rename.empty()) { replaceExpr(Reference, Rename); } return true; } bool handleAssignDestMigration(Expr *E) { auto *ASE = dyn_cast<AssignExpr>(E); if (!ASE || !ASE->getDest() || !ASE->getSrc()) return false; auto *Dest = ASE->getDest(); auto Src = ASE->getSrc(); if (wrapAttributeReference(Dest, Src, true)) { // We should handle the assignment source here since we won't visit // the children with present changes. handleAttributeReference(Src); return true; } return false; } bool handleAttributeReference(Expr *E) { return wrapAttributeReference(E, E, false); } ConversionFunctionInfo &insertHelperFunction(NodeAnnotation Anno, StringRef RawType, StringRef NewType, bool FromString, Expr *Wrappee) { HelperFuncInfo.emplace_back(Wrappee); ConversionFunctionInfo &Info = HelperFuncInfo.back(); llvm::raw_svector_ostream OS(Info.Buffer); OS << "\n"; OS << "// Helper function inserted by Swift 4.2 migrator.\n"; OS << "fileprivate func "; Info.FuncNameStart = Info.Buffer.size(); OS << (FromString ? "convertTo" : "convertFrom"); SmallVector<std::string, 8> Segs; StringRef guard = "\tguard let input = input else { return nil }\n"; switch(Anno) { case NodeAnnotation::OptionalArrayMemberUpdate: Segs = {"Optional", "Array", (Twine("[") + RawType + "]?").str()}; Segs.push_back((Twine("[") + NewType +"]?").str()); Segs.push_back((Twine(guard) + "\treturn input.map { key in " + NewType +"(key) }").str()); Segs.push_back((Twine(guard) + "\treturn input.map { key in key.rawValue }").str()); break; case NodeAnnotation::OptionalDictionaryKeyUpdate: Segs = {"Optional", "Dictionary", (Twine("[") + RawType + ": Any]?").str()}; Segs.push_back((Twine("[") + NewType +": Any]?").str()); Segs.push_back((Twine(guard) + "\treturn Dictionary(uniqueKeysWithValues: input.map" " { key, value in (" + NewType + "(rawValue: key), value)})").str()); Segs.push_back((Twine(guard) + "\treturn Dictionary(uniqueKeysWithValues: input.map" " {key, value in (key.rawValue, value)})").str()); break; case NodeAnnotation::ArrayMemberUpdate: Segs = {"", "Array", (Twine("[") + RawType + "]").str()}; Segs.push_back((Twine("[") + NewType +"]").str()); Segs.push_back((Twine("\treturn input.map { key in ") + NewType +"(key) }").str()); Segs.push_back("\treturn input.map { key in key.rawValue }"); break; case NodeAnnotation::DictionaryKeyUpdate: Segs = {"", "Dictionary", (Twine("[") + RawType + ": Any]").str()}; Segs.push_back((Twine("[") + NewType +": Any]").str()); Segs.push_back((Twine("\treturn Dictionary(uniqueKeysWithValues: input.map" " { key, value in (") + NewType + "(rawValue: key), value)})").str()); Segs.push_back("\treturn Dictionary(uniqueKeysWithValues: input.map" " {key, value in (key.rawValue, value)})"); break; case NodeAnnotation::SimpleStringRepresentableUpdate: Segs = {"", "", RawType.str()}; Segs.push_back(NewType.str()); Segs.push_back((Twine("\treturn ") + NewType + "(rawValue: input)").str()); Segs.push_back("\treturn input.rawValue"); break; case NodeAnnotation::SimpleOptionalStringRepresentableUpdate: Segs = {"Optional", "", (Twine(RawType) +"?").str()}; Segs.push_back((Twine(NewType) +"?").str()); Segs.push_back((Twine(guard) + "\treturn " + NewType + "(rawValue: input)").str()); Segs.push_back((Twine(guard) + "\treturn input.rawValue").str()); break; default: llvm_unreachable("shouldn't handle this key."); } assert(Segs.size() == 6); OS << Segs[0]; SmallVector<StringRef, 4> Parts; NewType.split(Parts, '.'); for (auto P: Parts) OS << P; OS << Segs[1]; Info.FuncNameEnd = Info.Buffer.size(); if (FromString) { OS << "(_ input: " << Segs[2] << ") -> " << Segs[3] << " {\n"; OS << Segs[4] << "\n}\n"; } else { OS << "(_ input: " << Segs[3] << ") -> " << Segs[2] << " {\n"; OS << Segs[5] << "\n}\n"; } return Info; } void handleStringRepresentableArg(ValueDecl *FD, Expr *Arg, Expr *Call) { NodeAnnotation Kind; StringRef RawType; StringRef NewAttributeType; uint8_t ArgIdx; for (auto Item: getRelatedDiffItems(FD)) { if (auto *CI = dyn_cast<CommonDiffItem>(Item)) { if (CI->isStringRepresentableChange()) { Kind = CI->DiffKind; RawType = CI->LeftComment; NewAttributeType = CI->RightComment; assert(CI->getChildIndices().size() == 1); ArgIdx = CI->getChildIndices().front(); break; } } } if (NewAttributeType.empty()) return; Expr *WrapTarget = Call; bool FromString = false; if (ArgIdx) { ArgIdx --; FromString = true; auto AllArgs = getCallArgInfo(SM, Arg, LabelRangeEndAt::LabelNameOnly); if (AllArgs.size() <= ArgIdx) return; WrapTarget = AllArgs[ArgIdx].ArgExp; } assert(WrapTarget); insertHelperFunction(Kind, RawType, NewAttributeType, FromString, WrapTarget); } bool hasRevertRawRepresentableChange(ValueDecl *VD) { for (auto Item: getRelatedDiffItems(VD)) { if (auto *CI = dyn_cast<CommonDiffItem>(Item)) { if (CI->DiffKind == NodeAnnotation::RevertTypeAliasDeclToRawRepresentable) return true; } } return false; } bool handleRevertRawRepresentable(Expr *E) { // Change attribute.rawValue to attribute if (auto *MRE = dyn_cast<MemberRefExpr>(E)) { auto Found = false; if (auto *Base = MRE->getBase()) { if (hasRevertRawRepresentableChange(Base->getType()->getAnyNominal())) { Found = true; } } if (!Found) return false; auto NL = MRE->getNameLoc().getStartLoc(); auto DL = MRE->getDotLoc(); if (NL.isInvalid() || DL.isInvalid()) return false; CharSourceRange Range = Lexer::getCharSourceRangeFromSourceRange(SM, {DL, NL}); if (Range.str() == ".rawValue") { Editor.remove(Range); return true; } } // Change attribute(rawValue: "value") to "value" // Change attribute("value") to "value" if (auto *CE = dyn_cast<CallExpr>(E)) { auto Found = false; if (auto *CRC = dyn_cast<ConstructorRefCallExpr>(CE->getFn())) { if (auto *TE = dyn_cast<TypeExpr>(CRC->getBase())) { if (hasRevertRawRepresentableChange(TE->getInstanceType()->getAnyNominal())) Found = true; } } if (!Found) return false; std::vector<CallArgInfo> AllArgs = getCallArgInfo(SM, CE->getArg(), LabelRangeEndAt::LabelNameOnly); if (AllArgs.size() == 1) { auto Label = AllArgs.front().LabelRange.str(); if (Label == "rawValue" || Label.empty()) { Editor.replace(CE->getSourceRange(), Lexer::getCharSourceRangeFromSourceRange(SM, AllArgs.front().ArgExp->getSourceRange()).str()); return true; } } } return false; } void handleResultTypeChange(ValueDecl *FD, Expr *Call) { Optional<NodeAnnotation> ChangeKind; // look for related change item for the function decl. for (auto Item: getRelatedDiffItems(FD)) { if (auto *CI = dyn_cast<CommonDiffItem>(Item)) { // check if the function's return type has been changed from nonnull // to nullable. if (CI->DiffKind == NodeAnnotation::WrapOptional && CI->getChildIndices().size() == 1 && CI->getChildIndices().front() == 0) { ChangeKind = NodeAnnotation::WrapOptional; break; } } } if (!ChangeKind.hasValue()) return; // If a function's return type has been changed from nonnull to nullable, // append ! to the original call expression. if (*ChangeKind == NodeAnnotation::WrapOptional) { Editor.insertAfterToken(Call->getSourceRange().End, "!"); } } // If a property has changed from nonnull to nullable, we should add ! to the // reference of the property. bool handlePropertyTypeChange(Expr *E) { if (auto MRE = dyn_cast<MemberRefExpr>(E)) { if (auto *VD = MRE->getMember().getDecl()) { for (auto *I: getRelatedDiffItems(VD)) { if (auto *Item = dyn_cast<CommonDiffItem>(I)) { if (Item->DiffKind == NodeAnnotation::WrapOptional && Item->NodeKind == SDKNodeKind::DeclVar) { Editor.insertAfterToken(E->getEndLoc(), "!"); return true; } } } } } return false; } bool walkToExprPre(Expr *E) override { if (E->getSourceRange().isInvalid()) return false; if (handleRevertRawRepresentable(E)) { // The name may also change, so we should keep visiting. return true; } if (handleQualifiedReplacement(E)) return false; if (handleAssignDestMigration(E)) return false; if (handleAttributeReference(E)) return false; if (handlePropertyTypeChange(E)) return false; if (auto *CE = dyn_cast<CallExpr>(E)) { auto Fn = CE->getFn(); auto Args = CE->getArg(); if (auto *DRE = dyn_cast<DeclRefExpr>(Fn)) { if (auto *VD = DRE->getDecl()) { if (VD->getNumCurryLevels() == 1) { handleFuncRename(VD, Fn, Args); handleTypeHoist(VD, CE, Args); handleSpecialCases(VD, CE, Args); handleStringRepresentableArg(VD, Args, CE); handleResultTypeChange(VD, CE); } } } if (auto *SelfApply = dyn_cast<ApplyExpr>(Fn)) { if (auto VD = SelfApply->getFn()->getReferencedDecl().getDecl()) { if (VD->getNumCurryLevels() == 2) { handleFuncRename(VD, SelfApply->getFn(), Args); handleFunctionCallToPropertyChange(VD, SelfApply->getFn(), Args); handleSpecialCases(VD, CE, Args); handleStringRepresentableArg(VD, Args, CE); handleResultTypeChange(VD, CE); } } } } return true; } static void collectParameters(AbstractFunctionDecl *AFD, SmallVectorImpl<ParamDecl*> &Results) { for (auto PD : *AFD->getParameters()) { Results.push_back(PD); } } void handleFuncDeclRename(AbstractFunctionDecl *AFD, CharSourceRange NameRange) { bool IgnoreBase = false; llvm::SmallString<32> Buffer; if (auto View = getFuncRename(AFD, Buffer, IgnoreBase)) { if (!IgnoreBase) Editor.replace(NameRange, View.base()); unsigned Index = 0; SmallVector<ParamDecl*, 4> Params; collectParameters(AFD, Params); for (auto *PD: Params) { if (Index == View.argSize()) break; StringRef NewArg = View.args()[Index++]; auto ArgLoc = PD->getArgumentNameLoc(); // Represent empty label with underscore. if (NewArg.empty()) NewArg = "_"; // If the argument name is not specified, add the argument name before // the parameter name. if (ArgLoc.isInvalid()) Editor.insertBefore(PD->getNameLoc(), (llvm::Twine(NewArg) + " ").str()); else { // Otherwise, replace the argument name directly. Editor.replaceToken(ArgLoc, NewArg); } } } } bool typeReplacementMayNeedParens(StringRef Replacement) const { return Replacement.contains('&') || Replacement.contains("->"); } void handleOverridingTypeChange(AbstractFunctionDecl *AFD, CommonDiffItem *DiffItem) { assert(AFD); assert(DiffItem->isTypeChange()); ChildIndexFinder Finder(DiffItem->getChildIndices()); auto Result = Finder.findChild(AFD); if (!Result.isValid()) return; switch (DiffItem->DiffKind) { case ide::api::NodeAnnotation::WrapOptional: if (Result.Suffixable) { Editor.insertAfterToken(Result.TokenRange.End, "?"); } else { Editor.insertWrap("(", Result.TokenRange, ")?"); } break; case ide::api::NodeAnnotation::WrapImplicitOptional: if (Result.Suffixable) { Editor.insertAfterToken(Result.TokenRange.End, "!"); } else { Editor.insertWrap("(", Result.TokenRange, (")!")); } break; case ide::api::NodeAnnotation::UnwrapOptional: if (Result.Optional) Editor.remove(Result.TokenRange.End); break; case ide::api::NodeAnnotation::ImplicitOptionalToOptional: if (Result.Optional) Editor.replace(Result.TokenRange.End, "?"); break; case ide::api::NodeAnnotation::TypeRewritten: Editor.replace(Result.TokenRange, DiffItem->RightComment); if (Result.Suffixed && typeReplacementMayNeedParens(DiffItem->RightComment)) { Editor.insertBefore(Result.TokenRange.Start, "("); Editor.insertAfterToken(Result.TokenRange.End, ")"); } break; default: break; } } void handleOverridingPropertyChange(AbstractFunctionDecl *AFD, CommonDiffItem *DiffItem) { assert(AFD); assert(DiffItem->isToPropertyChange()); auto FD = dyn_cast<FuncDecl>(AFD); if (!FD) return; switch (DiffItem->DiffKind) { case NodeAnnotation::GetterToProperty: { auto FuncLoc = FD->getFuncLoc(); auto ReturnTyLoc = FD->getResultTypeSourceRange().Start; auto NameLoc = FD->getNameLoc(); if (FuncLoc.isInvalid() || ReturnTyLoc.isInvalid() || NameLoc.isInvalid()) break; // Replace "func" with "var" Editor.replaceToken(FuncLoc, "var"); // Replace "() -> " with ": " Editor.replace(CharSourceRange(SM, Lexer::getLocForEndOfToken(SM, NameLoc), ReturnTyLoc), ": "); break; } case NodeAnnotation::SetterToProperty: { // FIXME: we should migrate this case too. break; } default: llvm_unreachable("should not be handled here."); } } // When users override a SDK function whose parameter types have been changed, // we should introduce a local variable in the body of the function definition // to shadow the changed parameter. Also, a proper conversion function should // be defined to bridge the parameter to the local variable. void handleLocalParameterBridge(AbstractFunctionDecl *AFD, CommonDiffItem *DiffItem) { assert(AFD); assert(DiffItem->isStringRepresentableChange()); // We only handle top-level parameter type change. if (DiffItem->getChildIndices().size() != 1) return; auto Idx = DiffItem->getChildIndices().front(); // We don't handle return type change. if (Idx == 0) return; Idx --; SmallVector<ParamDecl*, 4> Params; collectParameters(AFD, Params); if (Params.size() <= Idx) return; // Get the internal name of the changed paramter. auto VariableName = Params[Idx]->getParameterName().str(); // Insert the helper function to convert the type back to raw types. auto &Info = insertHelperFunction(DiffItem->DiffKind, DiffItem->LeftComment, DiffItem->RightComment, /*From String*/false, /*No expression to wrap*/nullptr); auto BL = AFD->getBodySourceRange().Start; if (BL.isValid()) { // Insert the local variable declaration after the opening brace. Editor.insertAfterToken(BL, (llvm::Twine("\n// Local variable inserted by Swift 4.2 migrator.") + "\nlet " + VariableName + " = " + Info.getFuncName() + "(" + VariableName + ")\n").str()); } } llvm::StringSet<> funcNamesForOverrideRemoval() { llvm::StringSet<> Results; Results.insert("c:objc(cs)NSObject(im)application:delegateHandlesKey:"); Results.insert("c:objc(cs)NSObject(im)changeColor:"); Results.insert("c:objc(cs)NSObject(im)controlTextDidBeginEditing:"); Results.insert("c:objc(cs)NSObject(im)controlTextDidEndEditing:"); Results.insert("c:objc(cs)NSObject(im)controlTextDidChange:"); Results.insert("c:objc(cs)NSObject(im)changeFont:"); Results.insert("c:objc(cs)NSObject(im)validModesForFontPanel:"); Results.insert("c:objc(cs)NSObject(im)discardEditing"); Results.insert("c:objc(cs)NSObject(im)commitEditing"); Results.insert("c:objc(cs)NSObject(im)commitEditingWithDelegate:didCommitSelector:contextInfo:"); Results.insert("c:objc(cs)NSObject(im)commitEditingAndReturnError:"); Results.insert("c:objc(cs)NSObject(im)objectDidBeginEditing:"); Results.insert("c:objc(cs)NSObject(im)objectDidEndEditing:"); Results.insert("c:objc(cs)NSObject(im)validateMenuItem:"); Results.insert("c:objc(cs)NSObject(im)pasteboard:provideDataForType:"); Results.insert("c:objc(cs)NSObject(im)pasteboardChangedOwner:"); Results.insert("c:objc(cs)NSObject(im)validateToolbarItem:"); Results.insert("c:objc(cs)NSObject(im)layer:shouldInheritContentsScale:fromWindow:"); Results.insert("c:objc(cs)NSObject(im)view:stringForToolTip:point:userData:"); return Results; } SourceLoc shouldRemoveOverride(AbstractFunctionDecl *AFD) { if (AFD->getKind() != DeclKind::Func) return SourceLoc(); SourceLoc OverrideLoc; // Get the location of override keyword. if (auto *Override = AFD->getAttrs().getAttribute<OverrideAttr>()) { if (Override->getRange().isValid()) { OverrideLoc = Override->getLocation(); } } if (OverrideLoc.isInvalid()) return SourceLoc(); auto *OD = AFD->getOverriddenDecl(); llvm::SmallString<64> Buffer; llvm::raw_svector_ostream OS(Buffer); if (swift::ide::printValueDeclUSR(OD, OS)) return SourceLoc(); return OverridingRemoveNames.contains(OS.str()) ? OverrideLoc : SourceLoc(); } struct SuperRemoval: public ASTWalker { EditorAdapter &Editor; llvm::StringSet<> &USRs; SuperRemoval(EditorAdapter &Editor, llvm::StringSet<> &USRs): Editor(Editor), USRs(USRs) {} bool isSuperExpr(Expr *E) { if (E->isImplicit()) return false; // Check if the expression is super.foo(). if (auto *CE = dyn_cast<CallExpr>(E)) { if (auto *DSC = dyn_cast<DotSyntaxCallExpr>(CE->getFn())) { if (!isa<SuperRefExpr>(DSC->getBase())) return false; llvm::SmallString<64> Buffer; llvm::raw_svector_ostream OS(Buffer); auto *RD = DSC->getFn()->getReferencedDecl().getDecl(); if (swift::ide::printValueDeclUSR(RD, OS)) return false; return USRs.contains(OS.str()); } } // We should handle try super.foo() too. if (auto *TE = dyn_cast<AnyTryExpr>(E)) { return isSuperExpr(TE->getSubExpr()); } return false; } std::pair<bool, Stmt*> walkToStmtPre(Stmt *S) override { if (auto *BS = dyn_cast<BraceStmt>(S)) { for(auto Ele: BS->getElements()) { if (Ele.is<Expr*>() && isSuperExpr(Ele.get<Expr*>())) { Editor.remove(Ele.getSourceRange()); } } } // We only handle top-level expressions, so avoid visiting further. return {false, S}; } }; bool walkToDeclPre(Decl *D, CharSourceRange Range) override { if (D->isImplicit()) return true; if (auto *AFD = dyn_cast<AbstractFunctionDecl>(D)) { handleFuncDeclRename(AFD, Range); for (auto *Item: getRelatedDiffItems(AFD)) { if (auto *DiffItem = dyn_cast<CommonDiffItem>(Item)) { if (DiffItem->isTypeChange()) handleOverridingTypeChange(AFD, DiffItem); else if (DiffItem->isToPropertyChange()) handleOverridingPropertyChange(AFD, DiffItem); else if (DiffItem->isStringRepresentableChange()) handleLocalParameterBridge(AFD, DiffItem); } } auto OverrideLoc = shouldRemoveOverride(AFD); if (OverrideLoc.isValid()) { // Remove override keyword. Editor.remove(OverrideLoc); // Remove super-dot call. SuperRemoval Removal(Editor, OverridingRemoveNames); D->walk(Removal); } } // Handle property overriding migration. if (auto *VD = dyn_cast<VarDecl>(D)) { for (auto *Item: getRelatedDiffItems(VD)) { if (auto *CD = dyn_cast<CommonDiffItem>(Item)) { // If the overriden property has been renamed, we should rename // this property decl as well. if (CD->isRename() && VD->getNameLoc().isValid()) { Editor.replaceToken(VD->getNameLoc(), CD->getNewName()); } } } } return true; } }; } // end anonymous namespace void migrator::runAPIDiffMigratorPass(EditorAdapter &Editor, SourceFile *SF, const MigratorOptions &Opts) { APIDiffMigratorPass { Editor, SF, Opts }.run(); }
; You may customize this and other start-up templates; ; The location of this template is c:\emu8086\inc\0_com_template.txt org 100h K1 EQU 1 K2 EQU 2 K3 EQU 3 MOV AX, K1 ADD AX, K2 ADD AX, K3 ADD BX, AX ret