// Local utility functions MDOUBLE pairwiseGammaDistance::giveInitialGuessOfDistance( const sequence& s1, const sequence& s2, const vector<MDOUBLE> * weights, MDOUBLE* score) const { uniDistribution ud; stochasticProcess uniSp(&ud,_sp.getPijAccelerator()); likeDist ld(uniSp); return (ld.giveDistance(s1,s2,weights,score)); }
static void setup_io() { #asm ld a,84h ; defb 0d3h; ioi ; ld (24h),a ; #endasm }
void ezPrintPattern(unsigned char pat, unsigned char x, unsigned char y) { pat; x; y; _asm // Work out first byte 40, 48, 50 ld a, 6(ix) and #24 ld b, #64 //Never changes form #64 add a,b ld h,a // **** first byte in h *** // Third nybble ld a, 6(ix) and #7 add a,a ld b,a ld a, 5(ix) //and #16 rrc a rrc a rrc a rrc a add a,b rlc a rlc a rlc a rlc a ld b,a // answer in b // Fourth nybble ld a,5(ix) and #15 // answer in a or b // second byte in a ld l,a // *** second byte in l *** ld b, #8 ld a, 4(ix) // Print pattern p_loop: ld (hl),a inc h djnz p_loop _endasm; }
void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rbox, Label& slow_case) { assert_different_registers(Rmark, Roop, Rbox); Label slow_int, done; Address mark_addr(Roop, oopDesc::mark_offset_in_bytes()); assert(mark_addr.disp() == 0, "cas must take a zero displacement"); if (UseBiasedLocking) { // Load the object out of the BasicObjectLock. ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox); verify_oop(Roop); biased_locking_exit(CCR0, Roop, R0, done); } // Test first it it is a fast recursive unlock. ld(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox); cmpdi(CCR0, Rmark, 0); beq(CCR0, done); if (!UseBiasedLocking) { // Load object. ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox); verify_oop(Roop); } // Check if it is still a light weight lock, this is is true if we see // the stack address of the basicLock in the markOop of the object. cmpxchgd(/*flag=*/CCR0, /*current_value=*/R0, /*compare_value=*/Rbox, /*exchange_value=*/Rmark, /*where=*/Roop, MacroAssembler::MemBarRel, MacroAssembler::cmpxchgx_hint_release_lock(), noreg, &slow_int); b(done); bind(slow_int); b(slow_case); // far // Done bind(done); }
void ExchangeRegs() { _asm; push af ld a,(_ActiveRegBank) cpl ld (_ActiveRegBank),a pop af exx ex af,af _endasm; }
void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox, Register Rscratch, Label& slow_case) { assert_different_registers(Rmark, Roop, Rbox, Rscratch); Label done, cas_failed, slow_int; // The following move must be the first instruction of emitted since debug // information may be generated for it. // Load object header. ld(Rmark, oopDesc::mark_offset_in_bytes(), Roop); verify_oop(Roop); // Save object being locked into the BasicObjectLock... std(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox); if (UseBiasedLocking) { biased_locking_enter(CCR0, Roop, Rmark, Rscratch, R0, done, &slow_int); } // ... and mark it unlocked. ori(Rmark, Rmark, markOopDesc::unlocked_value); // Save unlocked object header into the displaced header location on the stack. std(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox); // Compare object markOop with Rmark and if equal exchange Rscratch with object markOop. assert(oopDesc::mark_offset_in_bytes() == 0, "cas must take a zero displacement"); cmpxchgd(/*flag=*/CCR0, /*current_value=*/Rscratch, /*compare_value=*/Rmark, /*exchange_value=*/Rbox, /*where=*/Roop/*+0==mark_offset_in_bytes*/, MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, MacroAssembler::cmpxchgx_hint_acquire_lock(), noreg, &cas_failed, /*check without membar and ldarx first*/true); // If compare/exchange succeeded we found an unlocked object and we now have locked it // hence we are done. b(done); bind(slow_int); b(slow_case); // far bind(cas_failed); // We did not find an unlocked object so see if this is a recursive case. sub(Rscratch, Rscratch, R1_SP); load_const_optimized(R0, (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place)); and_(R0/*==0?*/, Rscratch, R0); std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), Rbox); bne(CCR0, slow_int); bind(done); }
void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register target, Register temp, bool for_compiler_entry) { Label L_no_such_method; assert(method == R19_method, "interpreter calling convention"); assert_different_registers(method, target, temp); if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) { Label run_compiled_code; // JVMTI events, such as single-stepping, are implemented partly by avoiding running // compiled code in threads for which the event is enabled. Check here for // interp_only_mode if these events CAN be enabled. __ verify_thread(); __ lwz(temp, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread); __ cmplwi(CCR0, temp, 0); __ beq(CCR0, run_compiled_code); // Null method test is replicated below in compiled case, // it might be able to address across the verify_thread() __ cmplwi(CCR0, R19_method, 0); __ beq(CCR0, L_no_such_method); __ ld(target, in_bytes(Method::interpreter_entry_offset()), R19_method); __ mtctr(target); __ bctr(); __ BIND(run_compiled_code); } // Compiled case, either static or fall-through from runtime conditional __ cmplwi(CCR0, R19_method, 0); __ beq(CCR0, L_no_such_method); const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() : Method::from_interpreted_offset(); __ ld(target, in_bytes(entry_offset), R19_method); __ mtctr(target); __ bctr(); __ bind(L_no_such_method); assert(StubRoutines::throw_AbstractMethodError_entry() != NULL, "not yet generated!"); __ load_const_optimized(target, StubRoutines::throw_AbstractMethodError_entry()); __ mtctr(target); __ bctr(); }
// // Generate field data. We're not solving any real problem here; // the only purpose of this is to come up with some numbers that couldn't // happen by accident, so we can check if the hdf5 I/O is working. // // New data is a function of prev_checksum (a vector -- one element per // level). // Updates curr_checksum. // void EBRestart::fillData( Vector<LevelData<EBCellFAB>* >& a_ebvector, int a_nlevs, int a_ncomps, const EBRestart::CheckSumVect& a_prev_checksums ) { static int g_i; g_i = 0; for (int lev=0; lev<a_nlevs; ++lev) { LevelData<EBCellFAB>& ld( *a_ebvector[lev] ); DataIterator dit = ld.dataIterator(); for ( dit.begin(); dit.ok(); ++dit ) { EBCellFAB& ebcf( ld[dit] ); // // Single-valued cells // BaseFab<Real>& singFab(ebcf.getSingleValuedFAB()); for ( int i=0; i<singFab.box().numPts()*a_ncomps; ++i ) { long x = (i+a_prev_checksums[lev].sum) % (a_prev_checksums[lev].len_irreg+100); singFab.dataPtr()[i] = x; // singFab.dataPtr()[i] = g_i++; } // // Multivalued cells // Box box( ld.disjointBoxLayout().get(dit) ); box.grow( ld.ghostVect() ); const IntVectSet& irregIVS( ebcf.getEBISBox().boundaryIVS(box) ); const EBGraph& graph( ebcf.getEBISBox().getEBGraph() ); Vector<Real> multidat( a_ncomps ); const IntVectSet& multiIVS( ebcf.getMultiValuedFAB().getIVS() ); for ( VoFIterator it(irregIVS,graph); it.ok(); ++it ) { if ( multiIVS.contains( it().gridIndex() ) ) { for ( int c=0;c<a_ncomps;++c ) { // multidat[c] = 111000 + g_i++; multidat[c] = 111000 + g_i++ + 10*c + a_prev_checksums[lev].sum%71; } ebcf.assign( &multidat[0], it(), Interval(0,a_ncomps-1) ); } } } } }
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() { Argument jni_arg(jni_offset(), false); #ifdef _LP64 FloatRegister Rtmp = F0; __ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); __ store_float_argument(Rtmp, jni_arg); #else Register Rtmp = O0; __ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); __ store_argument(Rtmp, jni_arg); #endif }
/* draw the line */ void scTextline::Draw( APPDrwCtx appMat, const scFlowDir& flowDir, const scMuPoint& transpt ) { if ( !fPara->Marked( scREBREAK | scRETABULATE ) ) { if ( GetCharCount() || Marked( scLASTLINE ) ) { scDrawLine ld( *this, flowDir, appMat, transpt ); ld.Draw(); } Unmark( scREPAINT ); } }
void thread_manager_start() { #asm push af push bc push de push hl push ix ex af,af exx push af push bc push de push hl push iy ex af,af exx ; Now setup the thread table - the main thread is always thread 0 .stack_done ld ix,_threadbase + threads ld (ix + thread_pid),0 ; Fake number ld (ix + thread_priority),1 ; Might as well... ld (ix + thread_nice),0 ld (ix + thread_flags),130 ; System - cannot exit ld hl,0 add hl,sp ld (ix + thread_sp),l ; Store the stack ld (ix + thread_sp+1),h ld hl,(_threadbase + scheduler) ; Setup task options inc hl inc hl inc hl ld c,0 ; Nice adjustment call l_jphl ld (_threadbase + current),ix jp thread_manager_first_entry EXTERN thread_manager_first_entry #endasm }
// ************************************************ // * Plot black pixel * // * * // * x: pixel coord - bounds 0 to 255 * // * y: pixel coord - bounds 0 tp 191 * // * * // ************************************************ void ezPlot(unsigned char x, unsigned char y) { x; y; _asm ld hl,(#23563) ld bc, #4 add hl,bc ld d,4(ix) ld c, #8 add hl,bc ld e,5(ix) ld a,#0xaf sub e ret c ld e,a and a rra scf rra and a rra xor e and #0xf8 xor e ld h,a ld a,d rlca rlca rlca xor e and #0xc7 xor e rlca rlca ld l,a ld a,d and #7 ld b,a inc b ld a,#0xfe loopidge: rrca djnz loopidge ld b,#0xff xor b ld b,a ld a,(hl) or b ld (hl),a //ret _endasm; }
void modCalcVlsr::slotLocation() { LocationDialog ld( this ); if ( ld.exec() == QDialog::Accepted ) { GeoLocation *newGeo = ld.selectedCity(); if ( newGeo ) { geoPlace = newGeo; LocationButton->setText( geoPlace->fullName() ); } } slotCompute(); }
unsigned char io_read(unsigned char addr) { io_addr = addr; __asm push af push bc ld bc, (_io_addr) in a, (c) ld (_io_val), a pop bc pop af __endasm; return io_val; }
byte io_read(byte addr) { io_addr = addr; __asm push af push bc ld bc, (_io_addr) in a, (c) ld (_io_val), a pop bc pop af __endasm; return io_val; }
void vtexchange(void) { /* Swap the pointers over: TRS80 video we switch by copying not flipping hardware pointers */ uint8_t *v = vtbase[0]; vtbase[0] = vtbase[1]; vtbase[1] = v; /* The cursor x/y for current tty are stale in the save area so save them */ vt_save(&ttysave[curtty]); /* Before we flip the memory */ cursor_off(); /* Swap the buffers over */ __asm ld hl, #0xf800 ld de, #_vtbackbuf ld bc, #VT_WIDTH*VT_HEIGHT exchit: push bc ld a, (de) ; Could be optimised but its only 2K ld c, (hl) ; Probably worth doing eventuallly ex de, hl ld (hl), c ld (de), a inc hl inc de pop bc dec bc ld a, b or c jr nz, exchit ret __endasm; /* Cursor back */ cursor_on(ttysave[inputtty].cursory, ttysave[inputtty].cursorx); }
bool store(Application& app, UpdateList const& apply, LedgerDelta* ldPtr, OperationResult const* resPtr) { LedgerHeader lh(app.getLedgerManager().getCurrentLedgerHeader()); LedgerDelta ld(lh, app.getDatabase(), false); if (ldPtr == nullptr) { ldPtr = &ld; } for (auto const& toApply : apply) { auto& current = std::get<0>(toApply); auto& previous = std::get<1>(toApply); if (current && !previous) { current->storeAdd(*ldPtr, app.getDatabase()); } else if (current && previous) { ldPtr->recordEntry(*previous); current->storeChange(*ldPtr, app.getDatabase()); } else if (!current && previous) { ldPtr->recordEntry(*previous); previous->storeDelete(*ldPtr, app.getDatabase()); } else { abort(); } } OperationResult res; if (resPtr == nullptr) { resPtr = &res; } try { app.getInvariantManager().checkOnOperationApply({}, *resPtr, *ldPtr); } catch (InvariantDoesNotHold&) { return false; } return true; }
void main() { ; #asm ipset 3 ; disable interrupts so that the ; periodic ISR doesn't hit the ; watchdog. ld a,0x53 ; set the WD timeout period to 250 ms ioi ld (WDTCR),a #endasm while(1); // now loop. }
/* Define the text window and the graphics window * If can't open graphics window then exit gracefully */ void OpenWindow(void) { #asm ld hl,16384 ld de,16385 ld bc,6143 ld (hl),0 ldir ld (hl),56 ld bc,767 ldir ld a,7 out (254),a ld a,56 ld (23624),a ld a,8 ld (23568),a #endasm puts_cons("\x01\x20\x16\x21\x20 DStar Z88 - C Demo"); puts_cons("Original game By A Von Dollen"); puts_cons(" Converted to ZX By D Morris"); puts_cons(" Keys: Q,A,O,P,SPACE,H,G"); }
bool JoyButtonSave::load(const std::string& sv) { boost::regex ld ("^\\s*\\(joybutton\\)\\s*(\\d+)\\s*(\\[(\\d+)\\])?"); boost::smatch results; if(!boost::regex_match(sv, results, ld)) return false; std::istringstream iss(results[1]); iss >> m_id; if(results.size() > 2) { iss.str(results[2]); iss.seekg(0, std::ios::beg); iss >> m_joyID; }
void modCalcVlsr::slotLocation() { QPointer<LocationDialog> ld( new LocationDialog( this ) ); if ( ld->exec() == QDialog::Accepted && ld ) { GeoLocation *newGeo = ld->selectedCity(); if ( newGeo ) { geoPlace = newGeo; LocationButton->setText( geoPlace->fullName() ); } } delete ld; slotCompute(); }
int instruction_cycle(CPU *cpu) { int halted = 1; (*cpu).ir = (*cpu).mem[(*cpu).pc]; handleInstruction(cpu); switch ((*cpu).opcode){ case 0: halted = 0; printf("Halt!"); break; case 1: ld(cpu); break; case 2: st(cpu); break; case 3: add(cpu); break; case 4: neg(cpu); break; case 5: ldm(cpu); break; case 6: addm(cpu); break; case 7: br(cpu); break; case 8: brp(cpu); break; case 9: io(cpu); break; default: printf("Error:Invalid opcode at address %d,Invalid number: %d",(*cpu).pc,(*cpu).mem[(*cpu).pc]); break; } (*cpu).pc++; return halted; // For Lab 7, we just print a message and halt after the 10th call // //char suffix[][4] = {"", "st","nd","rd","th"}; //printf("Calling instruction_cycle for %d%s time\n", call_nbr, suffix[min(call_nbr,4)]); }
void QOrmChildrens::load(QOrmObject *obj) { if (!isValid()) return; QOrmBasicLoader ld(tab); ld.setQuery(q); ld.bindValue(obj); (obj->*lst).clear(); for(QOrmObject *a : ld.loadAll()) { append(obj, a); fk->writeForeingKey(a, obj); } }
void MethodHandles::verify_klass(MacroAssembler* _masm, Register obj_reg, SystemDictionary::WKID klass_id, Register temp_reg, Register temp2_reg, const char* error_message) { Klass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); KlassHandle klass = SystemDictionary::well_known_klass(klass_id); Label L_ok, L_bad; BLOCK_COMMENT("verify_klass {"); __ verify_oop(obj_reg); __ cmpdi(CCR0, obj_reg, 0); __ beq(CCR0, L_bad); __ load_klass(temp_reg, obj_reg); __ load_const_optimized(temp2_reg, (address) klass_addr); __ ld(temp2_reg, 0, temp2_reg); __ cmpd(CCR0, temp_reg, temp2_reg); __ beq(CCR0, L_ok); __ ld(temp_reg, klass->super_check_offset(), temp_reg); __ cmpd(CCR0, temp_reg, temp2_reg); __ beq(CCR0, L_ok); __ BIND(L_bad); __ stop(error_message); __ BIND(L_ok); BLOCK_COMMENT("} verify_klass"); }
void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm, Register recv, Register method_temp, Register temp2, Register temp3, bool for_compiler_entry) { BLOCK_COMMENT("jump_to_lambda_form {"); // This is the initial entry point of a lazy method handle. // After type checking, it picks up the invoker from the LambdaForm. assert_different_registers(recv, method_temp, temp2); // temp3 is only passed on assert(method_temp == R19_method, "required register for loading method"); // Load the invoker, as MH -> MH.form -> LF.vmentry __ verify_oop(recv); __ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes()), recv, temp2); __ verify_oop(method_temp); __ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes()), method_temp, temp2); __ verify_oop(method_temp); // The following assumes that a Method* is normally compressed in the vmtarget field: __ ld(method_temp, NONZERO(java_lang_invoke_MemberName::vmtarget_offset_in_bytes()), method_temp); if (VerifyMethodHandles && !for_compiler_entry) { // Make sure recv is already on stack. __ ld(temp2, in_bytes(Method::const_offset()), method_temp); __ load_sized_value(temp2, in_bytes(ConstMethod::size_of_parameters_offset()), temp2, sizeof(u2), /*is_signed*/ false); // assert(sizeof(u2) == sizeof(ConstMethod::_size_of_parameters), ""); Label L; __ ld(temp2, __ argument_offset(temp2, temp2, 0), CC_INTERP_ONLY(R17_tos) NOT_CC_INTERP(R15_esp)); __ cmpd(CCR1, temp2, recv); __ beq(CCR1, L); __ stop("receiver not on stack"); __ BIND(L); } jump_from_method_handle(_masm, method_temp, temp2, temp3, for_compiler_entry); BLOCK_COMMENT("} jump_to_lambda_form"); }
void replica_list_directory (saga_tools::common & c, std::string ldn) { // instantiate logical directory saga::replica::logical_directory ld (c.session (), saga::url (ldn)); // read replica entries std::vector <saga::url> entries (ld.list ()); std::vector <saga::url>::const_iterator it; for ( it = entries.begin (); it != entries.end (); ++it ) { std::cout << " " << (*it) << std::endl; } }
void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) { assert_different_registers(obj, klass, len, t1, t2); if (UseBiasedLocking && !len->is_valid()) { ld(t1, in_bytes(Klass::prototype_header_offset()), klass); } else { load_const_optimized(t1, (intx)markOopDesc::prototype()); } std(t1, oopDesc::mark_offset_in_bytes(), obj); store_klass(obj, klass); if (len->is_valid()) { stw(len, arrayOopDesc::length_offset_in_bytes(), obj); } else if (UseCompressedClassPointers) { // Otherwise length is in the class gap. store_klass_gap(obj); } }
LogAndSign<TYPE> ConstantSolver<TYPE>::LogDeterminant() const { if (LinearEquationSolver<TYPE>::IsFailed()) { static const TYPE zero(0); LogAndSign<TYPE> ld(zero); return ld; } const BaseMatrix<TYPE> &m = SimpleSolver<TYPE>::mat; LogAndSign<TYPE> ld; int n = m.Nrows(); for (int i = 1; i <= n; ++i) { ld *= m(i, i); } return ld; }
int main(int argc, char *argv[]) { typedef patl::trie_set<std::string> string_set; typedef patl::levenshtein_distance<string_set, true> leven_dist; // std::ifstream fin(argc > 1 ? argv[1] : "WORD.LST"); if (!fin.is_open()) { printf("Unable to open input file!\n"); return 0; } string_set dict; patl::aux::performance_timer tim; { std::string str; string_set::iterator hint(dict.end()); while (fin >> str) hint = dict.insert(hint, str); } tim.finish(); printf("dict size: %u, loaded in %0.3f sec.\n", dict.size(), tim.get_seconds()); // for (;;) { fseek(stdin, 0, SEEK_END); printf("Input dist & word: "); unsigned dist; char word[256] = ""; if (scanf("%u %s", &dist, word) != 2 || !*word) { printf("\nBye.\n"); break; } leven_dist ld(dict, dist, word); tim.start(); string_set::const_partimator<leven_dist> beg(dict.begin(ld)), end(dict.end(ld)), it(beg); for (; it != end; ++it) ; tim.finish(); for (it = beg; it != end; ++it) printf("%s:%u ", it->c_str(), it.decis().distance()); printf("\n%0.3f msec.\n", tim.get_seconds() * 1000.0); } }
/* Ooops, forgive me this one bit of assembler in the entire program! * This just copies the TI screen onto the OZ map. * * It really is easier to keep this routine in here, change it into * C if you like.. */ void CopyToScreen(void) { #asm LIB swapgfxbk call swapgfxbk call ozscrcpy jp swapgfxbk .ozscrcpy ld de,(base_graphics) ld hl,_tiscr ld c,8 .ozscrcpy1 push hl ld b,16 .ozscrcpy3 push bc push hl ld bc,16 ld a,8 .ozscrcpy2 ex af,af ld a,(hl) ld (de),a inc de add hl,bc ex af,af dec a jr nz,ozscrcpy2 pop hl inc hl pop bc djnz ozscrcpy3 pop hl push bc ld bc,16*8 add hl,bc pop bc dec c jr nz,ozscrcpy1 ;ret #endasm }