void Inifinitlooptest::insertAdressNOperation(short adress, short operation) { lastAdresses[count]=adress; lastOperation[count]=operation; countUp(); }
PointersOTE* __fastcall ObjectMemory::shallowCopy(PointersOTE* ote) { ASSERT(!ote->isBytes()); // A pointer object is a bit more tricky to copy (but not much) VariantObject* obj = ote->m_location; BehaviorOTE* classPointer = ote->m_oteClass; PointersOTE* copyPointer; MWORD size; if (ote->heapSpace() == OTEFlags::VirtualSpace) { Interpreter::resizeActiveProcess(); //size = obj->PointerSize(); size = ote->pointersSize(); VirtualObject* pVObj = reinterpret_cast<VirtualObject*>(obj); VirtualObjectHeader* pBase = pVObj->getHeader(); unsigned maxByteSize = pBase->getMaxAllocation(); unsigned currentTotalByteSize = pBase->getCurrentAllocation(); VirtualOTE* virtualCopy = ObjectMemory::newVirtualObject(classPointer, currentTotalByteSize / sizeof(MWORD), maxByteSize / sizeof(MWORD)); if (!virtualCopy) return nullptr; pVObj = virtualCopy->m_location; pBase = pVObj->getHeader(); ASSERT(pBase->getMaxAllocation() == maxByteSize); ASSERT(pBase->getCurrentAllocation() == currentTotalByteSize); virtualCopy->setSize(ote->getSize()); copyPointer = reinterpret_cast<PointersOTE*>(virtualCopy); } else { //size = obj->PointerSize(); size = ote->pointersSize(); copyPointer = newPointerObject(classPointer, size); } // Now copy over all the fields VariantObject* copy = copyPointer->m_location; ASSERT(copyPointer->pointersSize() == size); for (unsigned i = 0; i<size; i++) { copy->m_fields[i] = obj->m_fields[i]; countUp(obj->m_fields[i]); } return copyPointer; }
int main(int argc, char *argv[]) { if (argc < 2) { printf("USAGE: <starting number>\n"); exit(1); } int start = strtol(argv[1], NULL, 10); countUp(start); }
void Countimer::run() { // timer is running only if is not completed or not stopped. if (_isCounterCompleted || _isStopped) return; if (millis() - _previousMillis >= _interval) { if (_countType == COUNT_DOWN) { countDown(); } else if (_countType == COUNT_UP) { countUp(); } else { _callback(); } _previousMillis = millis(); } }
int main() { // test the program printf("countUp(10): %i\n", countUp(10)); printf("countUp(1): %i\n", countUp(1)); }
int countUp(int start) { if ( start == 0 ) return 0; return start + countUp(start-1); }
void main() { OSCCON.IRCF2=1;//8Hz OSCCON.IRCF1=1;//... OSCCON.IRCF0=1;//... ANSEL = 0b00000000;///GP0~5をデジタル利用に設定 GPIO = 0b00000000;///GPIOの中身を空に TRISIO = 0b00001111;///GP0~3を入力、4,5を出力 CMCON0 = 0b00000111;///コンパレータを使わない /*OPTION_REG = 0b00000111;///プリスケーラ1:256 INTCON = 0b10100100;///割り込み設定*/ OPTION_REG.NOT_GPPU= 0;///ピンのプルアップ使用(スイッチ入力用) WPU = 0b00000011;///GP0,1をプルアップ lcdOnEnable();///lcd起動 lcdClear(); clockReload(); while(1) {///1tick = 10ms(100回で1秒) if(count==100&&mode==0) { countUp(0,1); clockReload(); count=0; } else if(mode==2) { if(count==100) { countUp(0,1); count=0; } stopWatchReload(); ///stopwatch } else if(mode==1) { count=0; } //////////////////////////button if(Button(&GPIO,0,0,0)) { button1++; } else { if(300>button1&&button1>5) { if(mode==0) { mode=2; swMode=0; sw_down=0; sw_sec=0; sw_min=0; stopWatchReload(); ///stopwatch } else if(mode==1) { countUp(mode1At,0); clockReload(); } else if(mode==2) { mode=0; swMode=0; clockReload(); } button1 = 0; button2 = 0; if(lcdIsOn==0) { lcdOn(); } } else if(button1>=300) { if(mode==0) { mode=1; singleHeight(); button1 = 0; button2 = 0; if(lcdIsOn==0) { lcdOn(); } mode1At=0; clockReload(); } } button1 = 0; } if(Button(&GPIO,1,0,0)) { button2++; } else { if(button2>5) { if(mode==0) { last = 0; } else if(mode==1) { mode1At++; if(mode1At==3) { mode1At=0; mode=0; doubleHeight(); } clockReload(); } else if(mode==2) { swMode++; if(swMode==2) { swMode=0; } else { sw_down=0; sw_sec=0; sw_min=0; } ///stopwatch } button1 = 0; button2 = 0; if(lcdIsOn==0) { lcdOn(); } } button2 = 0; } ////////////////////////////// if(last==1000) { lcdOff(); last = 0; } Delay_ms(10); count++; if(lcdIsOn==1&&mode==0) { last++; } else { last=0; } } }
int main(void) { init(); // call the function above // Set/Reset Variables int upButtonFlag = FALSE; int downButtonFlag = FALSE; while(TRUE){ // Pressing UP_BUTTON (ACTIVE_LOW) if(UP_BUTTON == LOW && upButtonFlag == FALSE) { countUp(); upButtonFlag = TRUE; __delay_ms(100); } // Releasing UP_BUTTON if(UP_BUTTON == HIGH && upButtonFlag == TRUE) { upButtonFlag = FALSE; __delay_ms(100); } // Pressing DOWN_BUTTON (ACTIVE_LOW) if(DOWN_BUTTON == LOW && downButtonFlag == FALSE) { countDown(); downButtonFlag = TRUE; __delay_ms(100); } // Releasing DOWN_BUTTON if(DOWN_BUTTON == HIGH && downButtonFlag == TRUE) { downButtonFlag = FALSE; __delay_ms(100); } // Dispay Patterns if(count == 0) { zeroDisplay(); } if(count == 1) { oneDisplay(); } if(count == 2) { twoDisplay(); } if(count == 3) { threeDisplay(); } if(count == 4) { fourDisplay(); } if(count == 5) { fiveDisplay(); } if(count == 6) { sixDisplay(); } if(count == 7) { sevenDisplay(); } if(count == 8) { eightDisplay(); } if(count == 9) { nineDisplay(); } } }
OTE* ObjectMemory::CopyElements(OTE* oteObj, MWORD startingAt, MWORD count) { // Note that startingAt is expected to be a zero-based index ASSERT(startingAt >= 0); OTE* oteSlice; if (oteObj->isBytes()) { BytesOTE* oteBytes = reinterpret_cast<BytesOTE*>(oteObj); size_t elementSize = ObjectMemory::GetBytesElementSize(oteBytes); if (count == 0 || ((startingAt + count) * elementSize <= oteBytes->bytesSize())) { MWORD objectSize = elementSize * count; if (oteBytes->m_flags.m_weakOrZ) { // TODO: Allocate the correct number of null term bytes based on the encoding auto newBytes = static_cast<VariantByteObject*>(allocObject(objectSize + NULLTERMSIZE, oteSlice)); // When copying strings, the slices has the same string class (oteSlice->m_oteClass = oteBytes->m_oteClass)->countUp(); memcpy(newBytes->m_fields, oteBytes->m_location->m_fields + (startingAt * elementSize), objectSize); *reinterpret_cast<NULLTERMTYPE*>(&newBytes->m_fields[objectSize]) = 0; oteSlice->beNullTerminated(); return oteSlice; } else { VariantByteObject* newBytes = static_cast<VariantByteObject*>(allocObject(objectSize, oteSlice)); // When copying bytes, the slice is always a ByteArray oteSlice->m_oteClass = Pointers.ClassByteArray; oteSlice->beBytes(); memcpy(newBytes->m_fields, oteBytes->m_location->m_fields + (startingAt * elementSize), objectSize); return oteSlice; } } } else { // Pointers PointersOTE* otePointers = reinterpret_cast<PointersOTE*>(oteObj); BehaviorOTE* oteClass = otePointers->m_oteClass; InstanceSpecification instSpec = oteClass->m_location->m_instanceSpec; if (instSpec.m_indexable) { startingAt += instSpec.m_fixedFields; if (count == 0 || (startingAt + count) <= otePointers->pointersSize()) { MWORD objectSize = SizeOfPointers(count); auto pSlice = static_cast<VariantObject*>(allocObject(objectSize, oteSlice)); // When copying pointers, the slice is always an Array oteSlice->m_oteClass = Pointers.ClassArray; VariantObject* pSrc = otePointers->m_location; for (MWORD i = 0; i < count; i++) { countUp(pSlice->m_fields[i] = pSrc->m_fields[startingAt + i]); } return oteSlice; } } } return nullptr; }