text
stringlengths
1
1.05M
%ifdef CONFIG { "RegData": { "RBX": "0x0000000000000003", "RCX": "0x0000000000000002", "RDX": "0x0000000000000001", "RSI": "0x0000000000000000", "R8": "0x0", "R9": "0x0", "R10": "0x1", "R11": "0x1" } } %endif mov rbx, 0x0000000000000001 mov rcx, 0x0000000000000001 mov rdx, 0x8000000000000000 mov rsi, 0x8000000000000000 stc rcl rbx, 1 lahf mov r8w, ax shr r8, 8 and r8, 1 ; We only care about carry flag here clc rcl rcx, 1 lahf mov r9w, ax shr r9, 8 and r9, 1 ; We only care about carry flag here stc rcl rdx, 1 lahf mov r10w, ax shr r10, 8 and r10, 1 ; We only care about carry flag here clc rcl rsi, 1 lahf mov r11w, ax shr r11, 8 and r11, 1 ; We only care about carry flag here hlt
;***************************************************************************** ; GCAM.ASM -- DSP-BASED CCD CONTROLLER PROGRAM ; ; This version slightly modified by Michael Lesser from ; original code by Greg Burley for operation of the ; ITL guider. ; ; Last change 02Feb09 RAT - dual readout missing data, V and H skips fixed ; revised flush code 31 oct 2007 RAT ;***************************************************************************** PAGE 110,60,1,1 TABS 4 ;***************************************************************************** ; SYS= 0=DEFAULT 1=GCAM 2=GCAM16 ; 3=GCAM16 (w/FIBER) 4=GCAM16 CCD57 5= ;***************************************************************************** ; DEFINITIONS & POINTERS ;***************************************************************************** START EQU $000100 ; program start location SEQ EQU $000006 ; seq fragment length DZ EQU $001000 ; DAC zero volt offset WS EQU $073FE1 ; periph wait states WS1 EQU $073FE1 ; 1 PERIPH 1 SRAM 31 EPROM WS3 EQU $077FE1 ; 3 PERIPH 1 SRAM 31 EPROM WS5 EQU $07BFE1 ; 5 PERIPH 1 SRAM 31 EPROM ;***************************************************************************** ; COMPILE-TIME OPTIONS ;***************************************************************************** IF (SYS==1) ; GCAM -- CCD47-20 14-BIT VERSION EQU $1 ; RDMODE EQU $0 ; HOLD_P EQU $020A ; P clock timing $20A=40us HOLD_FT EQU $007C ; FT clock timing $7C=10us xfer HOLD_FL EQU $007C ; FL clock timimg HOLD_S EQU $0005 ; S clock timing HOLD_RG EQU $0006 ; RG timing HOLD_PL EQU $1F40 ; pre-line settling (1F40=100us) HOLD_FF EQU $0020 ; FF clock timimg HOLD_IPC EQU $0FA0 ; IPC clock timing ($FA0=50us) HOLD_SIG EQU $000F ; preamp settling time HOLD_ADC EQU $000F ; pre-sample settling INIT_NROWS EQU $213 ; $213=(1030/2)+16 INIT_NCOLS EQU $238 ; $238=(1072/2)+32 INIT_NFT EQU $406 ; $406=1030 INIT_NFLUSH EQU $430 ; $430=1072 INIT_NCH EQU $1 ; INIT_VBIN EQU $2 ; INIT_HBIN EQU $2 ; INIT_VSKIP EQU $0 ; INIT_HSKIP EQU $0 ; INIT_GAIN EQU $0 ; 0=LOW 1=HIGH INIT_USEC EQU $C8 ; INIT_OPCH EQU $1 ; 1=CH_A 2=CH_B INIT_SCLKS EQU $1 ; 1=LEFT 2=RIGHT INIT_LINK EQU $0 ; 0=wire 1=single_fiber ENDIF IF (SYS==2) ; GCAM16 -- CCD47-20 16-BIT VERSION EQU $1 ; RDMODE EQU $0 ; HOLD_P EQU $020A ; P clock timing $20A=40us HOLD_FT EQU $007C ; FT clock timing $7C=10us xfer HOLD_FL EQU $007C ; FL clock timimg HOLD_S EQU $0005 ; S clock timing HOLD_RG EQU $0006 ; RG timing HOLD_PL EQU $1F40 ; pre-line settling (1F40=100us) HOLD_FF EQU $0020 ; FF clock timimg HOLD_IPC EQU $1F40 ; IPC clock timing ($1F40=100us) HOLD_SIG EQU $000F ; preamp settling time HOLD_ADC EQU $000F ; pre-sample settling INIT_NROWS EQU $213 ; $213=(1030/2)+16 INIT_NCOLS EQU $238 ; $238=(1072/2)+32 INIT_NFT EQU $406 ; $406=1030 INIT_NFLUSH EQU $430 ; $430=1072 INIT_NCH EQU $1 ; INIT_VBIN EQU $2 ; INIT_HBIN EQU $2 ; INIT_VSKIP EQU $0 ; INIT_HSKIP EQU $0 ; INIT_GAIN EQU $0 ; 0=LOW 1=HIGH INIT_USEC EQU $C8 ; INIT_OPCH EQU $1 ; 1=CH_A 2=CH_B INIT_SCLKS EQU $1 ; 1=LEFT 2=RIGHT INIT_PID EQU $0 ; FLAG $0=OFF $1=ON INIT_LINK EQU $0 ; 0=wire 1=single_fiber ENDIF IF (SYS==3) ; GCAM16 w/FIBER CCD47-20 16-BIT VERSION EQU $1 ; RDMODE EQU $0 ; HOLD_P EQU $020A ; P clock timing $20A=40us HOLD_FT EQU $007C ; FT clock timing $7C=10us xfer HOLD_FL EQU $007C ; FL clock timimg HOLD_S EQU $0005 ; S clock timing HOLD_RG EQU $0006 ; RG timing HOLD_PL EQU $1F40 ; pre-line settling (1F40=100us) HOLD_FF EQU $0020 ; FF clock timimg HOLD_IPC EQU $1F40 ; IPC clock timing ($1F40=100us) HOLD_SIG EQU $000F ; preamp settling time HOLD_ADC EQU $000F ; pre-sample settling INIT_NROWS EQU $213 ; $213=(1030/2)+16 INIT_NCOLS EQU $238 ; $238=(1072/2)+32 INIT_NFT EQU $406 ; $406=1030 INIT_NFLUSH EQU $430 ; $430=1072 INIT_NCH EQU $1 ; INIT_VBIN EQU $2 ; INIT_HBIN EQU $2 ; INIT_VSKIP EQU $0 ; INIT_HSKIP EQU $0 ; INIT_GAIN EQU $0 ; 0=LOW 1=HIGH INIT_USEC EQU $C8 ; INIT_OPCH EQU $1 ; 1=CH_A 2=CH_B INIT_SCLKS EQU $1 ; 1=LEFT 2=RIGHT INIT_PID EQU $0 ; FLAG $0=OFF $1=ON INIT_LINK EQU $1 ; 0=wire 1=single_fiber ENDIF IF (SYS==4) ; CCD57 -- 16-BIT VERSION EQU $1 ; RDMODE EQU $0 ; HOLD_P EQU $020A ; P clock timing $20A=40us HOLD_FT EQU $007C ; FT clock timing $7C=10us xfer HOLD_FL EQU $007C ; FL clock timimg HOLD_S EQU $0005 ; S clock timing HOLD_RG EQU $0006 ; RG timing HOLD_PL EQU $1F40 ; pre-line settling (1F40=100us) HOLD_FF EQU $0020 ; FF clock timimg HOLD_IPC EQU $1F40 ; IPC clock timing ($1F40=100us) HOLD_SIG EQU $000F ; preamp settling time (was F) HOLD_ADC EQU $000F ; pre-sample settling INIT_NROWS EQU $210 ; $210=528 INIT_NCOLS EQU $230 ; $230=536+24 INIT_NFT EQU $210 ; $210=528 INIT_NFLUSH EQU $230 ; $230=536+24 INIT_NCH EQU $1 ; INIT_VBIN EQU $1 ; INIT_HBIN EQU $1 ; INIT_VSKIP EQU $8 ; MPL INIT_HSKIP EQU $18 ; MPL INIT_GAIN EQU $1 ; 0=LOW 1=HIGH guider = 0 MPL INIT_USEC EQU $C8 ; normally $C8 INIT_OPCH EQU $2 ; 1=CH_A 2=CH_B INIT_SCLKS EQU $2 ; 1=LEFT 2=RIGHT INIT_PID EQU $0 ; FLAG $0=OFF $1=ON INIT_LINK EQU $0 ; 0=wire 1=single_fiber ENDIF ;***************************************************************************** ; EXTERNAL PERIPHERAL DEFINITIONS (GUIDER CAMERA) ;***************************************************************************** SEQREG EQU $FFFF80 ; external CCD clock register ADC_A EQU $FFFF81 ; A/D converter #1 ADC_B EQU $FFFF82 ; A/D converter #2 TXREG EQU $FFFF85 ; Transmit Data Register RXREG EQU $FFFF86 ; Receive Data register SIG_AB EQU $FFFF88 ; bias voltages A+B CLK_AB EQU $FFFF90 ; clock voltages A+B TEC_REG EQU $FFFF8A ; TEC register ;***************************************************************************** ; INTERNAL PERIPHERAL DEFINITIONS (DSP563000) ;***************************************************************************** IPRC EQU $FFFFFF ; Interrupt priority register (core) IPRP EQU $FFFFFE ; Interrupt priority register (periph) PCTL EQU $FFFFFD ; PLL control register BCR EQU $FFFFFB ; Bus control register (wait states) AAR0 EQU $FFFFF9 ; Address attribute register 0 AAR1 EQU $FFFFF8 ; Address attribute register 1 AAR2 EQU $FFFFF7 ; Address attribute register 2 AAR3 EQU $FFFFF6 ; Address attribute register 3 IDR EQU $FFFFF5 ; ID Register PDRB EQU $FFFFC9 ; Port B (HOST) GPIO data PRRB EQU $FFFFC8 ; Port B (HOST) GPIO direction PCRB EQU $FFFFC4 ; Port B (HOST) control register PCRC EQU $FFFFBF ; Port C (ESSI_0) control register PRRC EQU $FFFFBE ; Port C (ESSI_0) direction PDRC EQU $FFFFBD ; Port C (ESSI_0) data TXD EQU $FFFFBC ; ESSI0 Transmit Data Register 0 RXD EQU $FFFFB8 ; ESSI0 Receive Data Register SSISR EQU $FFFFB7 ; ESSI0 Status Register CRB EQU $FFFFB6 ; ESSI0 Control Register B CRA EQU $FFFFB5 ; ESSI0 Control Register A PCRD EQU $FFFFAF ; Port D (ESSI_1) control register PRRD EQU $FFFFAE ; Port D (ESSI_1) direction PDRD EQU $FFFFAD ; Port D (ESSI_1) data PCRE EQU $FFFF9F ; Port E (SCI) control register PRRE EQU $FFFF9E ; Port E (SCI) data direction PDRE EQU $FFFF9D ; Port E (SCI) data TCSR0 EQU $FFFF8F ; TIMER0 Control/Status Register TLR0 EQU $FFFF8E ; TIMER0 Load Reg TCPR0 EQU $FFFF8D ; TIMER0 Compare Register TCR0 EQU $FFFF8C ; TIMER0 Count Register TCSR1 EQU $FFFF8B ; TIMER1 Control/Status Register TLR1 EQU $FFFF8A ; TIMER1 Load Reg TCPR1 EQU $FFFF89 ; TIMER1 Compare Register TCR1 EQU $FFFF88 ; TIMER1 Count Register TCSR2 EQU $FFFF87 ; TIMER2 Control/Status Register TLR2 EQU $FFFF86 ; TIMER2 Load Reg TCPR2 EQU $FFFF85 ; TIMER2 Compare Register TCR2 EQU $FFFF84 ; TIMER2 Count Register TPLR EQU $FFFF83 ; TIMER Prescaler Load Register TPCR EQU $FFFF82 ; TIMER Prescalar Count Register DSR0 EQU $FFFFEF ; DMA source address DDR0 EQU $FFFFEE ; DMA dest address DCO0 EQU $FFFFED ; DMA counter DCR0 EQU $FFFFEC ; DMA control register ;***************************************************************************** ; REGISTER DEFINITIONS (GUIDER CAMERA) ;***************************************************************************** CMD EQU $000000 ; command word/flags from host OPFLAGS EQU $000001 ; operational flags NROWS EQU $000002 ; number of rows to read NCOLS EQU $000003 ; number of columns to read NFT EQU $000004 ; number of rows for frame transfer NFLUSH EQU $000005 ; number of columns to flush NCH EQU $000006 ; number of output channels (amps) NPIX EQU $000007 ; (not used) VBIN EQU $000008 ; vertical (parallel) binning HBIN EQU $000009 ; horizontal (serial) binning VSKIP EQU $00000A ; V prescan or offset (rows) HSKIP EQU $00000B ; H prescan or offset (columns) VSUB EQU $00000C ; V subraster size HSUB EQU $00000D ; H subraster size NEXP EQU $00000E ; number of exposures (not used) NSHUFFLE EQU $00000F ; (not used) EXP_TIME EQU $000010 ; CCD integration time(r) TEMP EQU $000011 ; Temperature sensor reading(s) GAIN EQU $000012 ; Sig_proc gain USEC EQU $000013 ; Sig_proc sample time OPCH EQU $000014 ; Output channel HDIR EQU $000015 ; serial clock direction LINK EQU $000016 ; 0=wire 1=single_fiber SCLKS EQU $000030 ; serial clocks SCLKS_FL EQU $000031 ; serial clocks flush INT_X EQU $000032 ; reset and integrate clocks NDMA EQU $000033 ; (not used) VBIAS EQU $000018 ; bias voltages VCLK EQU $000020 ; clock voltages TEC EQU $00001A ; TEC current PIX EQU $000300 ; start address for data storage ;***************************************************************************** ; SEQUENCE FRAGMENT STARTING ADDRESSES (& OTHER POINTERS) ;***************************************************************************** MPP EQU $0040 ; MPP/hold state IPCLKS EQU $0042 ; input clamp TCLKS EQU $0044 ; Temperature monitor clocks PCLKS_FT EQU $0048 ; parallel frame transfer PCLKS_RD EQU $0050 ; parallel read-out transfer PCLKS_FL EQU $0058 ; parallel flush transfer INT_L EQU $0060 ; reset and first integration $0060 INT_H EQU $0068 ; second integration and A/D $0068 SCLKS_R EQU $0070 ; serial clocks shift right SCLKS_FLR EQU $0080 ; serial clocks flush right SCLKS_L EQU $0078 ; serial clocks shift left SCLKS_FLL EQU $0088 ; serial clocks flush left SCLKS_B EQU $0090 ; serial clocks both SCLKS_FLB EQU $0098 ; serial clocks flush both SCLKS_FF EQU $00A0 ; serial clocks fast flush ;******************************************************************************* ; INITIALIZE X MEMORY AND DEFINE PERIPHERALS ;******************************************************************************* ORG X:CMD ; CCD control information DC $0 ; CMD/FLAGS DC $0 ; OPFLAGS DC INIT_NROWS ; NROWS DC INIT_NCOLS ; NCOLS DC INIT_NFT ; NFT DC INIT_NFLUSH ; NFLUSH DC INIT_NCH ; NCH DC $1 ; NPIX (not used) DC INIT_VBIN ; VBIN DC INIT_HBIN ; HBIN DC INIT_VSKIP ; VSKIP ($0) DC INIT_HSKIP ; HSKIP ($0) DC $0 ; VSUB DC $0 ; HSUB DC $1 ; NEXP (not used) DC $0 ; (not used) ORG X:EXP_TIME DC $3E8 ; EXP_TIME DC $0 ; TEMP DC INIT_GAIN ; GAIN DC INIT_USEC ; USEC SAMPLE TIME DC INIT_OPCH ; OUTPUT CHANNEL DC INIT_SCLKS ; HORIZ DIRECTION DC INIT_LINK ; SERIAL LINK IF (SYS==1) ; GCAM ORG X:VBIAS DC (DZ+0800) ; OFFSET_R (5mV/DN) DC (DZ+0800) ; OFFSET_L DC (DZ+0010) ; TEC DC (DZ-1200) ; OG voltage DC (DZ+0100) ; SPARE (10 mV/DN) DC (DZ+0800) ; RD DC (DZ+2000) ; OD_R DC (DZ+2000) ; OD_L ORG X:VCLK DC (DZ-0000) ; IPC- [V0] voltage (5mV/DN) DC (DZ+1000) ; IPC+ [V1] DC (DZ-1800) ; RG- [V2] DC (DZ+0600) ; RG+ [V3] DC (DZ-1600) ; S- [V4] DC (DZ+0400) ; S+ [V5] DC (DZ-1800) ; DG- [V6] DC (DZ+0600) ; DG+ [V7] DC (DZ-1800) ; TG- [V8] DC (DZ+0600) ; TG+ [V9] DC (DZ-1800) ; P1- [V10] DC (DZ+0600) ; P1+ [V11] DC (DZ-1800) ; P2- [V12] DC (DZ+0600) ; P2+ [V13] DC (DZ-1800) ; P3- [V14] DC (DZ+0600) ; P3+ [V15] ENDIF IF (SYS==2||SYS==3||SYS==4) ; GCAM16 ORG X:VBIAS DC (DZ-0050) ; OFFSET_R (5mV/DN) DC (DZ-0050) ; OFFSET_L DC (DZ+0010) ; TEC DC (DZ-0920) ; OG voltage -1260 -0860 !!! -0920 DC (DZ+0100) ; SPARE (10 mV/DN) DC (DZ+0870) ; RD 0870 DC (DZ+2070) ; OD_R +2070 -RAT DC (DZ+2070) ; OD_L +2070 ORG X:VCLK DC (DZ+1000) ; IPC- [V0] voltage (5mV/DN) -0000 !!! DC (DZ+0200) ; IPC+ [V1] +1000 17 Mar 06 DC (DZ-1900) ; RG- [V2] -1900 DC (DZ+0500) ; RG+ [V3] +0500 DC (DZ-1900) ; S- [V4] -1900 DC (DZ+0300) ; S+ [V5] +0300 DC (DZ-1900) ; DG- [V6] -1900 DC (DZ+0500) ; DG+ [V7] +0500 DC (DZ-1900) ; TG- [V8] -1900 DC (DZ+0500) ; TG+ [V9] +0500 DC (DZ-1800) ; P1- [V10] -1800 DC (DZ+1000) ; P1+ [V11] +1000 DC (DZ-1800) ; P2- [V12] -1800 DC (DZ+1000) ; P2+ [V13] +1000 DC (DZ-1800) ; P3- [V14] -1800 DC (DZ+1000) ; P3+ [V15] +1000 ENDIF ;***************************************************************************** ; INITIALIZE X MEMORY ;***************************************************************************** ; R2L _______________ ________________ R1L ; R3L ______________ || _______________ R3R ; DG _____________ |||| ______________ R2R ; SPARE ____________ |||||| _____________ R1R ; ST1 ___________ |||||||| ____________ RG ; ST2 __________ |||||||||| ___________ IPC ; ST3 _________ |||||||||||| __________ FINT+ ; IM1 ________ |||||||||||||| _________ FINT- ; IM2 _______ |||||||||||||||| ________ FRST ; IM3 ______ |||||||||||||||||| _______ CONVST ; |||||||||||||||||||| IF (RDMODE==0) ; MPP clocking mode ORG X:MPP ; reset/hold state DC %000000000000011011000011 ORG X:IPCLKS ; input clamp DC %000000000000011011000011 DC %000000000000011011000011 -RAT ; ORG X:IPCLKS ; input clamp ; DC %000000000000011011010011 ; DC %000000000000011011000011 ORG X:TCLKS ; read temp monitor DC %000000000000011011000010 DC %000000000000011011000011 ORG X:PCLKS_FT ; frame transfer P1-P2-P3-P1 DC %000001101100011011000011 DC %000001001000011011000011 DC %000011011000011011000011 DC %000010010000011011000011 DC %000010110100011011000011 DC %000000100100011011000011 ; ORG X:PCLKS_RD ; parallel transfer P1-P2-P3-P1 ; DC %000000000100011011010011 ; DC %000000001100011011010011 ; DC %000000001000011011000011 ; DC %000000011000011011000011 ; DC %000000010000011011000011 ; DC %000000000000011011000011 ORG X:PCLKS_RD ; parallel transfer P1-P2-P3-P1 -RAT DC %000000000100011011000011 DC %000000001100011011000011 DC %000000001000011011000011 DC %000000011000011011000011 DC %000000010000011011000011 DC %000000000000011011000011 ORG X:PCLKS_FL ; parallel flush P1-P2-P3-P1 DC %000001101101011011000011 ; 01 Nov 07 - RAT DC %000001001001111111100011 DC %000011011001111111100011 DC %000010010001111111100011 DC %000010110101111111100011 DC %000000100101011011000011 ORG X:INT_L ; reset and first integration DC %000000000000001001100011 ; RG ON FRST ON DC %000000000000001001000011 ; RG OFF DC %000000000000001001000001 ; FRST OFF DC %000000000000001001001001 ; FINT+ ON DC %000000000000001001000001 ; FINT+ OFF ORG X:INT_H ; second integration and A to D DC %000000000000001001000101 ; FINT- ON DC %000000000000001001000001 ; FINT- OFF DC %000000000000001001000000 ; /CONVST ON DC %000000000000001001000001 ; /CONVST OFF DC %000000000000001001100011 ; FRST ON RG ON ORG X:SCLKS_R ; serial shift (right) S1-S2-S3-S1 DC %000000000000011011000001 DC %000000000000010010000001 DC %000000000000110110000001 DC %000000000000100100000001 DC %000000000000101101000001 DC %000000000000001001000001 ORG X:SCLKS_FLR ; serial flush (right) S1-S2-S3-S1 DC %000000000000011011100011 DC %000000000000010010100011 DC %000000000000110110100011 DC %000000000000100100100011 DC %000000000000101101100011 DC %000000000000001001100011 ORG X:SCLKS_L ; serial shift (left) S1-S3-S2-S1 DC %000000000000101101000001 DC %000000000000100100000001 DC %000000000000110110000001 DC %000000000000010010000001 DC %000000000000011011000001 DC %000000000000001001000001 ORG X:SCLKS_FLL ; serial flush (left) S1-S3-S2-S1 DC %000000000000101101100011 DC %000000000000100100100011 DC %000000000000110110100011 DC %000000000000010010100011 DC %000000000000011011100011 DC %000000000000001001100011 ORG X:SCLKS_B ; serial shift (both) DC %000000000000101011000001 DC %000000000000100010000001 DC %000000000000110110000001 DC %000000000000010100000001 DC %000000000000011101000001 DC %000000000000001001000001 ORG X:SCLKS_FLB ; serial flush (both) DC %000000000000101011100011 DC %000000000000100010100011 DC %000000000000110110100011 DC %000000000000010100100011 DC %000000000000011101100011 DC %000000000000001001100011 ORG X:SCLKS_FF ; serial flush (fast) DG DC %000000000001011011100011 DC %000000000001000000100011 DC %000000000000000000100011 DC %000000000000011011100011 DC %000000000000011011100011 ; dummy code DC %000000000000011011100011 ; dummy code ENDIF IF (RDMODE==1) ; exp't clocking mode ORG X:MPP ; reset/hold state DC %000000000000011011000011 ORG X:IPCLKS ; input clamp DC %000000000000011011010011 DC %000000000000011011000011 ORG X:TCLKS ; read temp monitor DC %000000000000011011000010 DC %000000000000011011000011 ORG X:PCLKS_FT ; frame transfer P1-P2-P3-P1 DC %000001101100011011000011 DC %000001001000011011000011 DC %000011011000011011000011 DC %000010010000011011000011 DC %000010110100011011000011 DC %000000100100011011000011 ORG X:PCLKS_RD ; parallel transfer P1-P2-P3-P1 DC %000000000100011011010011 DC %000000001100011011010011 DC %000000001000011011000011 DC %000000011000011011000011 DC %000000010000011011000011 DC %000000000000011011000011 ORG X:PCLKS_FL ; parallel flush P1-P2-P3-P1 DC %000001101101011011000011 DC %000001001001011011000011 DC %000011011001011011000011 DC %000010010001011011000011 DC %000010110101011011000011 DC %000000100101011011000011 ORG X:INT_L ; reset and first integration DC %000000000000011011100011 ; RG ON FRST ON DC %000000000000011011000011 ; RG OFF DC %000000000000011011000001 ; FRST OFF DC %000000000000011011001001 ; FINT+ ON DC %000000000000011011000001 ; FINT+ OFF ORG X:INT_H ; second integration and A to D DC %000000000000011011000101 ; FINT- ON DC %000000000000011011000001 ; FINT- OFF DC %000000000000011011000000 ; /CONVST ON DC %000000000000011011000001 ; /CONVST OFF DC %000000000000011011100011 ; FRST ON RG ON ORG X:SCLKS_R ; serial shift (right) S2-S3-S1-S2 DC %000000000000010010000001 DC %000000000000110110000001 DC %000000000000100100000001 DC %000000000000101101000001 DC %000000000000001001000001 DC %000000000000011011000001 ORG X:SCLKS_FLR ; serial flush (right) S2-S3-S1-S2 DC %000000000000010010100011 DC %000000000000110110100011 DC %000000000000100100100011 DC %000000000000101101100011 DC %000000000000001001100011 DC %000000000000011011100011 ORG X:SCLKS_L ; serial shift (left) S1-S3-S2-S1 DC %000000000000001001000001 DC %000000000000101101000001 DC %000000000000100100000001 DC %000000000000110110000001 DC %000000000000010010000001 DC %000000000000011011000001 ORG X:SCLKS_FLL ; serial flush (left) S1-S3-S2-S1 DC %000000000000001001100011 DC %000000000000101101100011 DC %000000000000100100100011 DC %000000000000110110100011 DC %000000000000010010100011 DC %000000000000011011100011 ORG X:SCLKS_B ; serial shift (both) DC %000000000000001010000001 DC %000000000000101110000001 DC %000000000000100100000001 DC %000000000000110101000001 DC %000000000000010001000001 DC %000000000000011011000001 ORG X:SCLKS_FLB ; serial flush (both) DC %000000000000001010100011 DC %000000000000101110100011 DC %000000000000100100100011 DC %000000000000110101100011 DC %000000000000010001100011 DC %000000000000011011100011 ORG X:SCLKS_FF ; serial flush (fast) DG DC %000000000001011011100011 DC %000000000001000000100011 DC %000000000000000000100011 DC %000000000000011011100011 DC %000000000000011011100011 ; dummy code DC %000000000000011011100011 ; dummy code ENDIF ;******************************************************************************* ; GENERAL COMMENTS ;******************************************************************************* ; Hardware RESET causes download from serial port (code in EPROM) ; R0 is a pointer to sequence fragments ; R1 is a pointer used by send/receive routines ; R2 is a pointer to the current data location ; See dspdvr.h for command and opflag definitions ;******************************************************************************* ; INITIALIZE INTERRUPT VECTORS ;******************************************************************************* ORG P:$0000 JMP START ;******************************************************************************* ; MAIN PROGRAM ;******************************************************************************* ORG P:START SET_MODE ORI #$3,MR ; mask all interrupts MOVEP #$FFFC21,X:AAR3 ; PERIPH $FFF000--$FFFFFF MOVEP #$D00909,X:AAR1 ; EEPROM $D00000--$D07FFF 32K MOVEP #$000811,X:AAR0 ; SRAM X $000000--$00FFFF 64K MOVEP #WS,X:BCR ; Set periph wait states MOVE #SEQ-1,M0 ; Set sequencer address modulus PORTB_SETUP MOVEP #>$1,X:PCRB ; set PB[15..0] GPIO PORTD_SETUP MOVEP #>$0,X:PCRD ; GPIO PD0=TM PD1=GAIN MOVEP #>$3,X:PRRD ; PD2=/ENRX PD3=/ENTX MOVEP #>$0,X:PDRD ; PD4=RXRDY SSI_SETUP MOVEP #>$032070,X:CRB ; async, LSB, enable TE RE MOVEP #>$140803,X:CRA ; 10 Mbps, 16 bit word MOVEP #>$3F,X:PCRC ; enable ESSI PORTE_SETUP MOVEP #$0,X:PCRE ; enable GPIO, disable SCI MOVEP #>$1,X:PRRE ; PE0=SHUTTER MOVEP #>$0,X:PDRE ; SET_TIMER MOVEP #$300A10,X:TCSR0 ; Pulse mode, no prescale MOVEP #$0,X:TLR0 ; timer reload value MOVEP X:USEC,X:TCPR0 ; timer compare value MOVEP #$308A10,X:TCSR1 ; Pulse mode, prescaled MOVEP #$0,X:TLR1 ; timer reload value MOVEP X:EXP_TIME,X:TCPR1 ; timer compare value MOVEP #>$9C3F,X:TPLR ; timer prescale ($9C3F=1ms 80MHz) DMA_SETUP MOVEP #PIX,X:DSR0 ; set DMA source MOVEP #$0,X:DCO0 ; set DMA counter FIBER JCLR #$0,X:LINK,RS485 ; set up optical MOVEP #>TXREG,X:DDR0 ; set DMA destination MOVEP #>$080255,X:DCR0 ; DMA word xfer, /IRQA, src+1 RS485 JSET #$0,X:LINK,ENDDP ; set up RS485 MOVEP #>TXD,X:DDR0 ; DMA destination MOVEP #>$085A51,X:DCR0 ; DMA word xfer, TDE0, src+1 ENDDP NOP ; INIT_SETUP JSR MPPHOLD ; JSR SET_GAIN ; JSR SET_DACS ; JSR SET_SCLKS ; WAIT_CMD JCLR #$0,X:LINK,WAITB ; check for cmd ready JCLR #$4,X:PDRD,ECHO ; fiber link (single-fiber) WAITB JSET #$0,X:LINK,ENDW ; JCLR #7,X:SSISR,ECHO ; wire link ENDW NOP ; JSR READ16 ; wait for command word MOVE A1,X:CMD ; cmd in X:CMD JSR CMD_FIX ; interpret command word ECHO JCLR #$1,X:CMD,GET ; test for DSP_ECHO command JSR READ16 ; JSR WRITE16 ; BCLR #$1,X:CMD ; GET JCLR #$2,X:CMD,PUT ; test for DSP_GET command JSR MEM_SEND ; BCLR #$2,X:CMD ; PUT JCLR #$3,X:CMD,EXP_START ; test for DSP_PUT command JSR MEM_LOAD ; BCLR #$3,X:CMD ; EXP_START JCLR #$6,X:CMD,FASTFLUSH ; test for EXPOSE command JSR MPPHOLD ; MOVE #PIX,R2 ; set data pointer MOVEP X:EXP_TIME,X:TCPR1 ; timer compare value BSET #$F,X:OPFLAGS ; set exp_in_progress flag BCLR #$6,X:CMD ; JCLR #$1,X:OPFLAGS,FASTFLUSH ; check for AUTO_FLUSH BSET #$4,X:CMD ; FASTFLUSH JCLR #$4,X:CMD,BEAM_ON ; test for FLUSH command JSR FLUSHFRAME ; fast FLUSH JSR FLUSHFRAME ; fast FLUSH JSR FLUSHLINE ; clear serial register BCLR #$4,X:CMD ; BEAM_ON JCLR #$5,X:CMD,EXPOSE ; test for open shutter BSET #$0,X:PDRE ; set SHUTTER BCLR #$5,X:CMD ; EXPOSE JCLR #$F,X:OPFLAGS,BEAM_OFF ; check exp_in_progress flag JSR MPPHOLD ; JSR M_TIMER ; BCLR #$F,X:OPFLAGS ; clear exp_in_progress flag OPT_A JCLR #$2,X:OPFLAGS,OPT_B ; check for AUTO_SHUTTER BSET #$7,X:CMD ; prep to close shutter OPT_B JCLR #$4,X:OPFLAGS,BEAM_OFF ; check for AUTO_READ BSET #$8,X:CMD ; prep for full readout BEAM_OFF JCLR #$7,X:CMD,READ_CCD ; test for shutter close BCLR #$0,X:PDRE ; clear SHUTTER BCLR #$7,X:CMD ; READ_CCD JCLR #$8,X:CMD,AUTO_WIPE ; test for READCCD command JSR FRAME ; frame transfer ; JSR IPC_CLAMP ; discharge ac coupling cap JSR FLUSHROWS ; vskip DO X:NROWS,END_READ ; read the array JSR FLUSHLINE ; JSR PARALLEL ; JSR FLUSHPIX ; hskip BSET #$0,X:OPFLAGS ; set first pixel flag JSR READPIX ; BCLR #$0,X:OPFLAGS ; clear first pixel flag JSR READLINE ; END_READ NOP ; BCLR #$8,X:CMD ; AUTO_WIPE JCLR #$9,X:CMD,HH_DACS ; test for AUTOWIPE command ; BSET #$E,X:OPFLAGS ; ; BSET #$5,X:OPFLAGS ; ; JSR FL_CLOCKS ; flush one parallel row ; JSR READLINE ; ; BCLR #$9,X:CMD ; HH_DACS JCLR #$A,X:CMD,HH_TEMP ; test for HH_SYNC command JSR SET_DACS ; BCLR #$A,X:CMD ; HH_TEMP JCLR #$B,X:CMD,HH_TEC ; test for HH_TEMP command JSR TEMP_READ ; perform housekeeping chores BCLR #$B,X:CMD ; HH_TEC JCLR #$C,X:CMD,HH_OTHER ; test for HH_TEC command JSR TEMP_SET ; set the TEC value BCLR #$C,X:CMD ; HH_OTHER JCLR #$D,X:CMD,END_CODE ; test for HH_OTHER command JSR SET_GAIN ; JSR SET_SCLKS ; JSR SET_USEC ; BCLR #$D,X:CMD ; END_CODE JCLR #$5,X:OPFLAGS,WAIT_CMD ; check for AUTO_WIPE BSET #$9,X:CMD ; JMP WAIT_CMD ; Get next command ;***************************************************************************** ; HOLD (MPP MODE) ;***************************************************************************** MPPHOLD MOVEP X:MPP,Y:<<SEQREG ; RTS ; ;***************************************************************************** ; INPUT CLAMP ;***************************************************************************** IPC_CLAMP MOVEP X:IPCLKS,Y:<<SEQREG ; MOVE #>HOLD_IPC,X0 ; REP X0 ; $1F4O=100 us NOP ; MOVEP X:(IPCLKS+1),Y:<<SEQREG ; NOP ; RTS ; ;***************************************************************************** ; FLUSHLINE (FAST FLUSH) ;***************************************************************************** FLUSHLINE MOVE #SCLKS_FF,R0 ; initialize pointer DO #SEQ,ENDFF ; MOVEP X:(R0)+,Y:<<SEQREG ; REP #HOLD_FF ; NOP ; ENDFF RTS ; ;***************************************************************************** ; FLUSHPIX (HSKIP) ;***************************************************************************** FLUSHPIX DO X:HSKIP,ENDFP ; MOVE X:SCLKS_FL,R0 ; initialize pointer DO #SEQ,ENDHCLK ; MOVEP X:(R0)+,Y:<<SEQREG ; REP #HOLD_S ; NOP ; ENDHCLK NOP ; ENDFP RTS ; ;***************************************************************************** ; FLUSHROWS (VSKIP) ;***************************************************************************** FLUSHROWS DO X:VSKIP,ENDVSKIP ; MOVE #PCLKS_RD,R0 ; initialize pointer DO #SEQ,ENDVCLK ; MOVEP X:(R0)+,Y:<<SEQREG ; REP #HOLD_FL ; NOP ; ENDVCLK NOP ; ENDVSKIP RTS ; ;***************************************************************************** ; FLUSHFRAME ;***************************************************************************** FLUSHFRAME DO X:NFT,ENDFLFR ; FL_CLOCKS MOVE #PCLKS_FL,R0 ; initialize pointer DO #SEQ,ENDFLCLK ; MOVEP X:(R0)+,Y:<<SEQREG ; REP #HOLD_FL ; NOP ; ENDFLCLK NOP ; ENDFLFR RTS ; ;***************************************************************************** ; PARALLEL TRANSFER (READOUT) ;***************************************************************************** PARALLEL DO X:VBIN,ENDPT ; P_CLOCKS MOVE #PCLKS_RD,R0 ; initialize pointer DO #SEQ,ENDPCLK ; MOVEP X:(R0)+,Y:<<SEQREG ; MOVE #>HOLD_P,X0 ; REP X0 ; $317=10us per phase NOP ; ENDPCLK NOP ; ENDPT RTS ; ;***************************************************************************** ; PARALLEL TRANSFER (FRAME TRANSFER) ;***************************************************************************** FRAME MOVEP X:(PCLKS_FT),Y:<<SEQREG ; 100 us CCD47 pause MOVE #>$1F40,X0 ; REP X0 ; $1F40=100 usec NOP ; DO X:NFT,ENDFT ; FT_CLOCKS MOVE #PCLKS_FT,R0 ; initialize seq pointer DO #SEQ,ENDFTCLK ; MOVEP X:(R0)+,Y:<<SEQREG ; REP #HOLD_FT ; NOP ; ENDFTCLK NOP ; ENDFT RTS ; ;***************************************************************************** ; READLINE SUBROUTINE ;***************************************************************************** READLINE DO X:NCOLS,ENDRL ; READPIX MOVEP X:(INT_L),Y:<<SEQREG ; FRST=ON RG=ON DUP HOLD_RG ; macro NOP ; ENDM ; end macro MOVEP X:(INT_L+1),Y:<<SEQREG ; RG=OFF MOVEP X:(INT_L+2),Y:<<SEQREG ; FRST=OFF REP #HOLD_SIG ; preamp settling time ; REP #$F ; preamp settling was NOP ; INT1 MOVEP X:(INT_L+3),Y:<<SEQREG ; FINT+=ON SLEEP1 MOVE X:USEC,X0 ; sleep USEC * 12.5ns REP X0 ; NOP ; MOVEP X:(INT_L+4),Y:<<SEQREG ; FINT+=OFF SERIAL MOVE X:SCLKS,R0 ; serial transfer DO X:HBIN,ENDSCLK ; S_CLOCKS DUP SEQ ; macro MOVEP X:(R0)+,Y:<<SEQREG ; DUP HOLD_S ; macro NOP ; ENDM ; ENDM ; ENDSCLK REP #HOLD_SIG ; preamp settling time NOP ; (adjust with o'scope) GET_DATA MOVEP #WS5,X:BCR ; NOP ; NOP ; MOVEP Y:<<ADC_A,A ; read ADC MOVEP Y:<<ADC_B,B ; read ADC MOVEP #WS,X:BCR ; NOP ; INT2 MOVEP X:(INT_H),Y:<<SEQREG ; FINT-=ON SLEEP2 MOVE X:USEC,X0 ; sleep USEC * 20ns REP X0 ; NOP ; MOVEP X:(INT_H+1),Y:<<SEQREG ; FINT-=OFF IF (SYS==1) DATA_MASK AND #>$3FFF,A ; keep only 14-bits AND #>$3FFF,B ; BCHG #$D,A1 ; 2complement to binary BCHG #$D,B1 ; ENDIF MOVE A1,Y:(PIX) ; MOVE B1,Y:(PIX+1) ; REP #HOLD_ADC ; settling time NOP ; (adjust for best noise) CONVST MOVEP X:(INT_H+2),Y:<<SEQREG ; /CONVST=ON MOVEP N5,X:DSR0 ; set DMA source NOP ; NOP ; MOVEP X:(INT_H+3),Y:<<SEQREG ; /CONVST=OFF MIN 40 NS MOVEP X:(INT_H+4),Y:<<SEQREG ; FRST=ON JSET #$0,X:OPFLAGS,ENDCHK ; check for first pixel BSET #$17,X:DCR0 ; enable DMA ENDCHK NOP ; ENDRL RTS ; ;******************************************************************************* ; READ AND WRITE 16-BIT AND 24-BIT DATA ;******************************************************************************* READ16 JCLR #$0,X:LINK,RD16B ; check RS485 or fiber JCLR #$4,X:PDRD,* ; wait for data in RXREG MOVE Y:RXREG,A ; bits 15..0 AND #>$FFFF,A ; RD16B JSET #$0,X:LINK,ENDRD16 ; check RS485 or fiber JCLR #7,X:SSISR,* ; wait for RDRF to go high MOVE X:RXD,A1 ; read from ESSI NOP ; ENDRD16 RTS ; 16-bit word in A1 WRITE16 JCLR #$0,X:LINK,WR16B ; check RS485 or fiber MOVE A1,Y:TXREG ; write bits 15..0 WR16B JSET #$0,X:LINK,ENDWR16 ; JCLR #6,X:SSISR,* ; wait for TDE MOVE A1,X:TXD ; ENDWR16 RTS ; READ24 JCLR #$0,X:LINK,RD24B ; check RS485 or fiber JCLR #$4,X:PDRD,* ; wait for data in RXREG MOVE Y:RXREG,A ; bits 15..0 AND #>$FFFF,A ; ASR #$10,A,A ; shift right 16 bits JCLR #$4,X:PDRD,* ; wait for data in RXREG MOVE Y:RXREG,A1 ; bits 15..0 ASL #$10,A,A ; shift left 16 bits RD24B JSET #$0,X:LINK,ENDRD24 ; JCLR #7,X:SSISR,* ; wait for RDRF to go high MOVE X:RXD,A ; read from ESSI ASR #$10,A,A ; shift right 16 bits JCLR #7,X:SSISR,* ; wait for RDRF to go high MOVE X:RXD,A1 ; ASL #$10,A,A ; shift left 16 bits ENDRD24 RTS ; 24-bit word in A1 WRITE24 JCLR #$0,X:LINK,WR24B ; check RS485 or fiber MOVE A1,Y:TXREG ; send bits 15..0 ASR #$10,A,A ; right shift 16 bits REP #$10 ; wait for data sent NOP ; MOVE A1,Y:TXREG ; send bits 23..16 WR24B JSET #$0,X:LINK,ENDWR24 ; JCLR #6,X:SSISR,* ; wait for TDE MOVE A1,X:TXD ; send bits 15..0 ASR #$10,A,A ; right shift 16 bits NOP ; wait for flag update JCLR #6,X:SSISR,* ; wait for TDE MOVE A1,X:TXD ; send bits 23..16 ENDWR24 RTS ; ;***************************************************************************** ; LOAD NEW DATA VIA SSI PORT ;***************************************************************************** MEM_LOAD JSR READ24 ; get memspace/address MOVE A1,R1 ; load address into R1 MOVE A1,X0 ; store memspace code JSR READ24 ; get data BCLR #$17,R1 ; clear memspace bit X_LOAD JSET #$17,X0,Y_LOAD ; MOVE A1,X:(R1) ; load x memory Y_LOAD JCLR #$17,X0,END_LOAD ; MOVE A1,Y:(R1) ; load y memory END_LOAD RTS ; ;***************************************************************************** ; SEND MEMORY CONTENTS VIA SSI PORT ;***************************************************************************** MEM_SEND JSR READ24 ; get memspace/address MOVE A1,R1 ; load address into R1 MOVE A1,X0 ; save memspace code BCLR #$17,R1 ; clear memspace bit X_SEND JSET #$17,X0,Y_SEND ; MOVE X:(R1),A1 ; send x memory Y_SEND JCLR #$17,X0,WRITE24 ; MOVE Y:(R1),A1 ; send y memory SEND24 JSR WRITE24 ; NOP ; RTS ; ;***************************************************************************** ; SET DAC VOLTAGES DEFAULTS: OD=20V RD=8V OG=ABG=-6V ; PCLKS=+3V -9V SCLKS=+2V -8V RG=+3V -9V ;***************************************************************************** SET_DACS JSR SET_VBIAS ; JSR SET_VCLKS ; RTS ; SET_VBIAS MOVEP #WS5,X:BCR ; add wait states MOVE #VBIAS,R3 ; bias voltages MOVE #SIG_AB,R4 ; bias DAC registers DO #$8,ENDSETB ; set bias voltages MOVE X:(R3)+,X0 ; MOVE X0,Y:(R4)+ ; ENDSETB MOVEP #WS,X:BCR ; RTS ; SET_VCLKS MOVEP #WS5,X:BCR ; add wait states MOVE #VCLK,R3 ; clock voltages MOVE #CLK_AB,R4 ; clock DAC registers DO #$10,ENDSETV ; set clock voltages MOVE X:(R3)+,X0 ; MOVE X0,Y:(R4)+ ; ENDSETV MOVEP #WS,X:BCR ; re-set wait states RTS ;***************************************************************************** ; TEMP MONITOR ADC START AND CONVERT ;***************************************************************************** TEMP_READ BSET #$0,X:PDRD ; turn on temp sensor ; ------------------------------------------------------------------- ; test - 30 oct 07 RAT ; set OFFSET_R to zero during idle periods. MOVEP #WS5,X:BCR ; add wait states MOVE #DZ+0200,X0 ; temperature bias voltage (OFFSET_R is first) MOVE #SIG_AB,R4 ; bias DAC registers NOP ; -RAT 5 sep 08 NOP ; -RAT 5 sep 08 MOVE X0,Y:(R4) ; MOVEP #WS,X:BCR ; re-set wait states ;-------------------------------------------------------------------- MOVEP #$20,X:TCPR1 ; set timer compare value JSR M_TIMER ; wait for output to settle MOVEP #WS3,X:BCR ; set wait states for ADC MOVEP X:TCLKS,Y:<<SEQREG ; assert /CONVST REP #$4 ; NOP ; MOVEP X:(TCLKS+1),Y:<<SEQREG ; deassert /CONVST and wait REP #$50 ; NOP ; MOVEP Y:<<ADC_B,A1 ; read ADC2 MOVE #>$3FFF,X1 ; prepare 14-bit mask AND X1,A1 ; get 14 LSBs BCLR #$0,X:PDRD ; turn off temp sensor BCHG #$D,A1 ; 2complement to binary MOVEP #WS,X:BCR ; re-set wait states MOVE A1,X:TEMP ; RTS ; TEMP_SET MOVEP #WS5,X:BCR ; add wait states NOP ; ; ------------------------------------------------------------------- ; test - 23 oct 07 RAT ; restore OFFSET_R value during imaging MOVE #VBIAS,R3 ; bias voltages (OFFSET_R is first) MOVE #SIG_AB,R4 ; bias DAC registers NOP ; -RAT 5 sep 08 MOVE X:(R3),X0 ; MOVE X0,Y:(R4) ; ;-------------------------------------------------------------------- MOVEP X:TEC,Y:<<TEC_REG ; set TEC DAC MOVEP #WS,X:BCR ; re-set wait states RTS ;***************************************************************************** ; MILLISECOND AND MICROSECOND TIMER MODULE ;***************************************************************************** U_TIMER BSET #$0,X:TCSR0 ; start timer BTST #$0,X:TCSR0 ; delay for flag update JCLR #$15,X:TCSR0,* ; wait for TCF flag BCLR #$0,X:TCSR0 ; stop timer, clear flag RTS ; flags update during RTS M_TIMER BSET #$0,X:TCSR1 ; start timer BTST #$0,X:TCSR0 ; delay for flag update JCLR #$15,X:TCSR1,* ; wait for TCF flag BCLR #$0,X:TCSR1 ; stop timer, clear flag RTS ; flags update during RTS ;***************************************************************************** ; SIGNAL-PROCESSING GAIN MODULE ;***************************************************************************** SET_GAIN JSET #$0,X:GAIN,HI_GAIN ; BCLR #$1,X:PDRD ; set gain=0 HI_GAIN JCLR #$0,X:GAIN,END_GAIN ; BSET #$1,X:PDRD ; set gain=1 END_GAIN RTS ; ;***************************************************************************** ; SIGNAL-PROCESSING DUAL-SLOPE TIME MODULE ;***************************************************************************** SET_USEC MOVEP X:USEC,X:TCPR0 ; timer compare value END_USEC RTS ; ;***************************************************************************** ; SELECT SERIAL CLOCK SEQUENCE (IE OUTPUT AMPLIFIER) ;***************************************************************************** SET_SCLKS MOVE X:OPCH,A ; 0x1=right 0x2=left RIGHT_AMP MOVE #>$1,X0 ; 0x3=both 0x4=all CMP X0,A ; JNE LEFT_AMP ; MOVE #>SCLKS_R,Y0 ; serial clock sequences MOVE #>SCLKS_FLR,Y1 ; serial flush sequences MOVE #PIX+1,N5 ; pointer to start of data MOVEP #>$0,X:DCO0 ; DMA counter LEFT_AMP MOVE #>$2,X0 ; CMP X0,A ; JNE BOTH_AMP ; MOVE #>SCLKS_L,Y0 ; MOVE #>SCLKS_FLL,Y1 ; MOVE #PIX,N5 ; MOVEP #>$0,X:DCO0 ; BOTH_AMP MOVE #>$3,X0 ; CMP X0,A ; JNE END_AMP ; MOVE #>SCLKS_B,Y0 ; MOVE #>SCLKS_FLB,Y1 ; MOVE #PIX,N5 ; MOVEP #>$1,X:DCO0 ; END_AMP MOVE Y0,X:SCLKS ; MOVE Y1,X:SCLKS_FL ; RTS ; ;***************************************************************************** ; CMD.ASM -- ROUTINE TO INTERPRET AN 8-BIT COMMAND + COMPLEMENT ;***************************************************************************** ; Each command word is sent as two bytes -- the LSB has the command ; and the MSB has the complement. CMD_FIX MOVE X:CMD,A ; extract cmd[7..0] AND #>$FF,A ; and put in X1 MOVE A1,X1 ; MOVE X:CMD,A ; extract cmd[15..8] LSR #$8,A ; complement NOT A #>$1,B ; and put in A1 AND #>$FF,A ; ASL X1,B,B ; CMP X1,A ; compare X1 and A1 JEQ CMD_OK ; CMD_NG CLR B ; cmd word no good NOP ; CMD_OK MOVE B1,X:CMD ; cmd word OK NOP ; END_CMD RTS ; END
; float sqrt(float x) SECTION code_clib SECTION code_fp_math48 PUBLIC cm48_sdccix_sqrt EXTERN cm48_sdccix_sqrt_fastcall cm48_sdccix_sqrt: pop af pop hl pop de push de push hl push af jp cm48_sdccix_sqrt_fastcall
/*****************************************************************************************[Main.cc] The MIT License (MIT) Copyright (c) 2014, Sam Bayless Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson Copyright (c) 2007-2010, Niklas Sorensson 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 <cstddef> #include <gmpxx.h> #include <fstream> #include <errno.h> #include <stdio.h> #include <fcntl.h> #include <signal.h> #include <zlib.h> #include <sstream> #include <string> #include "monosat/utils/System.h" #include "monosat/utils/ParseUtils.h" #include "monosat/utils/Options.h" #include "monosat/graph/GraphParser.h" #include "monosat/routing/FlowRouterParser.h" #include "monosat/fsm/FSMParser.h" #include "monosat/core/Dimacs.h" #include "monosat/core/AssumptionParser.h" #include "monosat/core/Solver.h" #include "monosat/core/Config.h" #include <unistd.h> #include <sys/time.h> #include <algorithm> #include <sstream> #include <algorithm> #include <iterator> #include "simp/SimpSolver.h" #include "pb/PbParser.h" #include "bv/BVParser.h" #include "amo/AMOTheory.h" #include "amo/AMOParser.h" #include "core/Optimize.h" #include "core/Config.h" #include "pb/Config_pb.h" #include "monosat/Version.h" using namespace Monosat; using namespace std; //================================================================================================= void printStats(Solver& solver){ double cpu_time = cpuTime(); double mem_used = memUsedPeak(); solver.printStats(3); if(mem_used != 0) printf("Memory used : %.2f MB\n", mem_used); printf("CPU time : %g s\n", cpu_time); } static SimpSolver* solver; // Terminate by notifying the solver and back out gracefully. This is mainly to have a test-case // for this feature of the Solver as it may take longer than an immediate call to '_exit()'. static void SIGINT_interrupt(int signum){ solver->interrupt(); printf("\n"); printf("*** INTERRUPTED ***\n"); if(opt_verb > 0){ printStats(*solver); printf("\n"); printf("*** INTERRUPTED ***\n"); } fflush(stdout); _exit(1); } // Note that '_exit()' rather than 'exit()' has to be used. The reason is that 'exit()' calls // destructors and may cause deadlocks if a malloc/free function happens to be running (these // functions are guarded by locks for multithreaded use). static void SIGINT_exit(int signum){ printf("\n"); printf("*** INTERRUPTED ***\n"); /* if (opt_verb > 0){ printStats(*solver); printf("\n"); printf("*** INTERRUPTED ***\n"); }*/ fflush(stdout); _exit(1); } //Select which algorithms to apply for graph solvers, by parsing command line arguments and defaults. void selectAlgorithms(){ mincutalg = MinCutAlg::ALG_EDMONSKARP; if(!strcasecmp(opt_maxflow_alg, "edmondskarp-adj")){ mincutalg = MinCutAlg::ALG_EDKARP_ADJ; }else if(!strcasecmp(opt_maxflow_alg, "edmondskarp")){ mincutalg = MinCutAlg::ALG_EDMONSKARP; }else if(!strcasecmp(opt_maxflow_alg, "edmondskarp-dynamic")){ mincutalg = MinCutAlg::ALG_EDKARP_DYN; }else if(!strcasecmp(opt_maxflow_alg, "dinics")){ //Dinitz is also commonly spelled 'dinics' or 'Dinits', so accept those too... mincutalg = MinCutAlg::ALG_DINITZ; }else if(!strcasecmp(opt_maxflow_alg, "dinics-linkcut")){ mincutalg = MinCutAlg::ALG_DINITZ_LINKCUT; }else if(!strcasecmp(opt_maxflow_alg, "dinitz")){ mincutalg = MinCutAlg::ALG_DINITZ; }else if(!strcasecmp(opt_maxflow_alg, "dinitz-linkcut")){ mincutalg = MinCutAlg::ALG_DINITZ_LINKCUT; }else if(!strcasecmp(opt_maxflow_alg, "dinits")){ //Dinitz is also commonly spelled 'dinics' or 'Dinits', so accept those too... mincutalg = MinCutAlg::ALG_DINITZ; }else if(!strcasecmp(opt_maxflow_alg, "dinits-linkcut")){ mincutalg = MinCutAlg::ALG_DINITZ_LINKCUT; }else if(!strcasecmp(opt_maxflow_alg, "kohli-torr")){ mincutalg = MinCutAlg::ALG_KOHLI_TORR; }else{ fprintf(stderr, "Error: unknown max-flow/min-cut algorithm %s, aborting\n", ((string) opt_maxflow_alg).c_str()); exit(1); } componentsalg = ComponentsAlg::ALG_DISJOINT_SETS; if(!strcasecmp(opt_components_alg, "disjoint-sets")){ componentsalg = ComponentsAlg::ALG_DISJOINT_SETS; }else{ fprintf(stderr, "Error: unknown connectivity algorithm %s, aborting\n", ((string) opt_components_alg).c_str()); exit(1); } cyclealg = CycleAlg::ALG_DFS_CYCLE; if(!strcasecmp(opt_cycle_alg, "dfs")){ cyclealg = CycleAlg::ALG_DFS_CYCLE; }else if(!strcasecmp(opt_cycle_alg, "pk")){ cyclealg = CycleAlg::ALG_PK_CYCLE; }else{ fprintf(stderr, "Error: unknown cycle detection algorithm %s, aborting\n", ((string) opt_cycle_alg).c_str()); exit(1); } mstalg = MinSpanAlg::ALG_KRUSKAL; if(!strcasecmp(opt_mst_alg, "kruskal")){ mstalg = MinSpanAlg::ALG_KRUSKAL; }else if(!strcasecmp(opt_mst_alg, "prim")){ mstalg = MinSpanAlg::ALG_PRIM; }else if(!strcasecmp(opt_mst_alg, "spira-pan")){ mstalg = MinSpanAlg::ALG_SPIRA_PAN; }else{ fprintf(stderr, "Error: unknown minimum spanning tree algorithm %s, aborting\n", ((string) opt_mst_alg).c_str()); exit(1); } reachalg = ReachAlg::ALG_BFS; if(!strcasecmp(opt_reach_alg, "dijkstra")){ reachalg = ReachAlg::ALG_DIJKSTRA; }else if(!strcasecmp(opt_reach_alg, "bfs")){ reachalg = ReachAlg::ALG_BFS; }else if(!strcasecmp(opt_reach_alg, "dfs")){ reachalg = ReachAlg::ALG_DFS; }else if(!strcasecmp(opt_reach_alg, "cnf")){ reachalg = ReachAlg::ALG_SAT; }else if(!strcasecmp(opt_reach_alg, "ramal-reps")){ reachalg = ReachAlg::ALG_RAMAL_REPS; }else if(!strcasecmp(opt_reach_alg, "ramal-reps-batch")){ reachalg = ReachAlg::ALG_RAMAL_REPS_BATCHED; }else if(!strcasecmp(opt_reach_alg, "ramal-reps-batch2")){ reachalg = ReachAlg::ALG_RAMAL_REPS_BATCHED2; }else{ fprintf(stderr, "Error: unknown reachability algorithm %s, aborting\n", ((string) opt_reach_alg).c_str()); exit(1); } distalg = DistAlg::ALG_DISTANCE; if(!strcasecmp(opt_dist_alg, "dijkstra")){ distalg = DistAlg::ALG_DIJKSTRA; }else if(!strcasecmp(opt_dist_alg, "bfs")){ distalg = DistAlg::ALG_DISTANCE; }else if(!strcasecmp(opt_dist_alg, "cnf")){ distalg = DistAlg::ALG_SAT; }else if(!strcasecmp(opt_dist_alg, "ramal-reps")){ distalg = DistAlg::ALG_RAMAL_REPS; }else if(!strcasecmp(opt_dist_alg, "ramal-reps-batch")){ distalg = DistAlg::ALG_RAMAL_REPS_BATCHED; }else if(!strcasecmp(opt_dist_alg, "ramal-reps-batch2")){ distalg = DistAlg::ALG_RAMAL_REPS_BATCHED2; }else{ fprintf(stderr, "Error: unknown distance algorithm %s, aborting\n", ((string) opt_dist_alg).c_str()); exit(1); } undirectedalg = ConnectivityAlg::ALG_BFS; if(!strcasecmp(opt_con_alg, "dijkstra")){ undirectedalg = ConnectivityAlg::ALG_DIJKSTRA; }else if(!strcasecmp(opt_con_alg, "bfs")){ undirectedalg = ConnectivityAlg::ALG_BFS; }else if(!strcasecmp(opt_con_alg, "dfs")){ undirectedalg = ConnectivityAlg::ALG_DFS; }else if(!strcasecmp(opt_con_alg, "cnf")){ undirectedalg = ConnectivityAlg::ALG_SAT; }else if(!strcasecmp(opt_con_alg, "thorup")){ undirectedalg = ConnectivityAlg::ALG_THORUP; }/*else if (!strcasecmp(opt_con_alg,"ramal-reps")){ undirectedalg = ConnectivityAlg::ALG_RAMAL_REPS; } */else{ fprintf(stderr, "Error: unknown undirected reachability algorithm %s, aborting\n", ((string) opt_reach_alg).c_str()); exit(1); } allpairsalg = AllPairsAlg::ALG_DIJKSTRA_ALLPAIRS; if(!strcasecmp(opt_allpairs_alg, "floyd-warshall")){ allpairsalg = AllPairsAlg::ALG_FLOYDWARSHALL; }else if(!strcasecmp(opt_allpairs_alg, "dijkstra")){ allpairsalg = AllPairsAlg::ALG_DIJKSTRA_ALLPAIRS; }else{ fprintf(stderr, "Error: unknown allpairs reachability algorithm %s, aborting\n", ((string) opt_allpairs_alg).c_str()); exit(1); } undirected_allpairsalg = AllPairsConnectivityAlg::ALG_DIJKSTRA_ALLPAIRS; if(!strcasecmp(opt_undir_allpairs_alg, "floyd-warshall")){ undirected_allpairsalg = AllPairsConnectivityAlg::ALG_FLOYDWARSHALL; }else if(!strcasecmp(opt_undir_allpairs_alg, "dijkstra")){ undirected_allpairsalg = AllPairsConnectivityAlg::ALG_DIJKSTRA_ALLPAIRS; }else if(!strcasecmp(opt_undir_allpairs_alg, "thorup")){ undirected_allpairsalg = AllPairsConnectivityAlg::ALG_THORUP; }else{ fprintf(stderr, "Error: unknown undirected allpairs reachability algorithm %s, aborting\n", ((string) opt_allpairs_alg).c_str()); exit(1); } } void processSymbols(std::vector<std::pair<int, std::string>>& symbols, vec<Lit>& assume, const char* assume_str, const char* opt_assume_symbols, bool using_symbols_asp = false){ if(opt_verb > 2){ for(int i = 0; i < symbols.size(); i++){ int v = symbols[i].first; string s = symbols[i].second; std::cout << "Symbol: " << (v + 1) << " = " << s << "\n"; } } if(strlen(assume_str)){ std::ifstream infile(assume_str); std::string symbol; std::unordered_map<std::string, int> symbol_table; if(using_symbols_asp){ for(int i = 0; i < symbols.size(); i++){ int var = symbols[i].first; string symbol = symbols[i].second; symbol_table[symbol] = var; } } while(std::getline(infile, symbol)){ std::stringstream trimmer; trimmer << symbol; symbol.clear(); trimmer >> symbol; if(symbol.length() > 0){ bool neg = false; if(symbol[0] == '-'){ neg = true; symbol.erase(0, 1); } if(symbol.size() > 0){ if(symbol_table.count(symbol) == 0){ printf("PARSE ERROR! Unknown symbol: %s\n", symbol.c_str()), exit(3); }else{ int v = symbol_table[symbol]; Lit l = mkLit(v, neg); assume.push(l); if(opt_verb > 2){ if(neg) printf("Assume not %s (%d)\n", symbol.c_str(), dimacs(l)); else printf("Assume %s = (%d)\n", symbol.c_str(), dimacs(l)); } } }else{ printf("PARSE ERROR! Empty symbol!\n"), exit(3); } } } if(assume.size() == 0){ printf("Warning: no assumptions read from %s\n", assume_str); } } if(strlen(opt_assume_symbols) > 0){ std::ifstream infile(opt_assume_symbols); std::string line; std::unordered_map<string, int> symbolmap; for(auto p : symbols){ symbolmap[p.second] = p.first; } while(std::getline(infile, line)){ if(line[0] == '%') continue; std::istringstream iss(line); string s1; string s2; string symbol; bool sign = true; iss >> s1 >> s2; if(s1.compare(":-")){ assert(false); fprintf(stderr, "Bad assumption: %s\n", line.c_str()); exit(1); }else if(!s2.compare("not")){ //Then this is a _true_ assumption (yes, its intentionally backward...) iss >> symbol; sign = false; }else{ symbol = s2; } if(symbol.back() != '.'){ assert(false); fprintf(stderr, "Bad assumption: %s\n", line.c_str()); exit(1); } symbol.pop_back(); if(!symbolmap.count(symbol)){ assert(false); fprintf(stderr, "Unmapped assumption symbol: %s\n", symbol.c_str()); exit(1); } int var = symbolmap[symbol]; assert(var >= 0); Lit a = mkLit(var, sign); assume.push(a); } } } void processPriority(SimpSolver& S, const char* priority_file){ if(strlen(priority_file) > 0){ FILE* f = fopen(priority_file, "r"); if(f){ char* line = NULL; int v = 0; int p = 0; int total_read = 0; while(fscanf(f, " %d %d ", &v, &p) == 2){ if(v < 1 || v > S.nVars()){ fprintf(stderr, "Bad priority line: %d %d", v, p); exit(1); } v--; total_read++; S.setDecisionPriority(v, p); } if(total_read == 0){ fprintf(stderr, "Warning: read no priorities from priority file!"); } fclose(f); }else{ fprintf(stderr, "Failed to read priority file!\n"); } } } void processDecidable(SimpSolver& S, string dstr){ vec<int> decidable; if(dstr.length() > 0){ std::replace(dstr.begin(), dstr.end(), '\'', ' '); std::replace(dstr.begin(), dstr.end(), '\"', ' '); std::replace(dstr.begin(), dstr.end(), ',', ' '); istringstream iss(dstr); do{ string sub; iss >> sub; if(sub.length() == 0) continue; //int value = atoi(sub.c_str()); const char* s = sub.c_str(); char* p = NULL; long value = strtol(s, &p, 10); if(*p){ // conversion failed because the input wasn't a number }else{ decidable.push(value); } }while(iss); }else{ //default to all theories decidable for(int i = 0; i < S.theories.size(); i++){ decidable.push(i); } } if(opt_verb > 0 && decidable.size()){ printf("Decidable theories: "); } S.decision_heuristics.clear(); for(int i = 0; i < decidable.size(); i++){ int t = decidable[i]; if(t < 0 || t >= S.theories.size()){ fprintf(stderr, "Cannot set theory %d to be decidable, because there is no such theory\n", t); fflush(stderr); exit(1); } if(opt_verb > 0){ printf("%d, ", t); } S.decision_heuristics.push(S.theories[t]); } if(opt_verb > 0 && decidable.size()){ printf("\n"); } if(opt_decide_theories_reverse){ vec<Heuristic*> v; for(int i = S.decision_heuristics.size() - 1; i >= 0; i--){ v.push(S.decision_heuristics[i]); } S.decision_heuristics.clear(); for(Heuristic* t:v) S.decision_heuristics.push(t); } } int main(int argc, char** argv){ try{ setUsageHelp( "USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n"); // Extra options: IntOption cpu_lim("MAIN", "cpu-lim", "Limit on CPU time allowed in seconds.\n", INT32_MAX, IntRange(0, INT32_MAX)); IntOption mem_lim("MAIN", "mem-lim", "Limit on memory usage in megabytes.\n", INT32_MAX, IntRange(0, INT32_MAX)); StringOption opt_assume("MAIN", "assume", "Specify a file of assumptions, with one literal or symbol per line", ""); StringOption opt_decidable("MAIN", "decidable-theories", "Specify which graphs should make decisions on their own, in comma delimited format", ""); IntOption opt_min_decision_var("MAIN", "min-decision-var", "Restrict decisions to variables >= this one", 1); IntOption opt_max_decision_var("MAIN", "max-decision-var", "Restrict decisions to variables <= this one (ignore if 0)", 0); IntOption opt_min_priority_decision_var("MAIN", "min-priority-var", "Make decisions on variables in the range min-priority-var..max-priority-var first", 1); IntOption opt_max_priority_decision_var("MAIN", "max-priority-var", "Make decisions on variables in the range min-priority-var..max-priority-var first (set max-priority-var to 0 to set it to infinite)", 0); StringOption opt_symbols_asp("MAIN", "symbols-asp", "Whether to read symbol lines (\"c var <variable number> <name>\") from the gnf, and write their assignments in Answer Set Programming format", ""); StringOption opt_assume_symbols("MAIN", "assume-symbols", "read in symbols (in the format produced by the 'symbols' option) and treat them as assumptions", ""); BoolOption opt_id_graph("GRAPH", "print-vars", "Identify the variables in the graph, then quit\n", false); BoolOption opt_witness("MAIN", "witness", "print solution", false); StringOption opt_witness_file("MAIN", "witness-file", "write witness to file", ""); StringOption opt_theory_witness_file("MAIN", "theory-witness-file", "write witness for theories to file", ""); BoolOption opb("PB", "opb", "Parse the input as pseudo-boolean constraints in .opb format", false); BoolOption opt_ignore_solve_statements("MAIN", "ignore-solves", "Ignore any solve statements in the GNF", false); IntOption opt_conflict_limit("MAIN", "conflict-limit", "", 0, IntRange(0, INT32_MAX)); parseOptions(argc, argv, true); if(opt_show_version_and_quit){ printf("MonoSAT, Version %s\n", MONOSAT_VERSION_STR); return 0; } Monosat::opt_record = strlen(opt_record_file) > 0; if(strlen(opt_debug_learnt_clauses) > 0){ opt_write_learnt_clauses = fopen(opt_debug_learnt_clauses, "w"); }else{ opt_write_learnt_clauses = nullptr; } if(opt_adaptive_conflict_mincut == 1){ opt_conflict_min_cut = true; opt_conflict_min_cut_maxflow = true; } bool using_symbols_asp = strlen((const char*) opt_symbols_asp) > 0; if(opt_csv){ opt_verb = 0; } #if defined(__linux__) fpu_control_t oldcw, newcw; _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); if(opt_verb > 0) fprintf(stderr, "WARNING: for repeatability, setting FPU to use double precision\n"); #endif //Select which algorithms to apply for graph theory solvers, by parsing command line arguments and defaults. selectAlgorithms(); double initial_time = rtime(0); // Use signal handlers that forcibly quit until the solver will be able to respond to // interrupts: #if not defined(__MINGW32__) signal(SIGINT, SIGINT_exit); signal(SIGXCPU, SIGINT_exit); // Set limit on CPU-time: if (cpu_lim != INT32_MAX) { rlimit rl; getrlimit(RLIMIT_CPU, &rl); if (rl.rlim_max == RLIM_INFINITY || (rlim_t) cpu_lim < rl.rlim_max) { rl.rlim_cur = cpu_lim; if (setrlimit(RLIMIT_CPU, &rl) == -1) fprintf(stderr, "WARNING! Could not set resource limit: CPU-time.\n"); } } // Set limit on virtual memory: if (mem_lim != INT32_MAX) { rlim_t new_mem_lim = (rlim_t) mem_lim * 1024 * 1024; rlimit rl; getrlimit(RLIMIT_AS, &rl); if (rl.rlim_max == RLIM_INFINITY || new_mem_lim < rl.rlim_max) { rl.rlim_cur = new_mem_lim; if (setrlimit(RLIMIT_AS, &rl) == -1) fprintf(stderr, "WARNING! Could not set resource limit: Virtual memory.\n"); } } #endif const char* error; SimpSolver S; solver = &S; S.min_decision_var = opt_min_decision_var - 1; S.max_decision_var = opt_max_decision_var - 1; S.min_priority_var = opt_min_priority_decision_var - 1; S.max_priority_var = opt_max_priority_decision_var - 1; S.setPBSolver(new PB::PbSolver(S)); if(opt_min_decision_var > 1 || opt_max_decision_var > 0){ printf( "Decision variables restricted to the range (%d..%d), which means a result of satisfiable may not be trustworthy.\n", (uint) opt_min_decision_var, (uint) opt_max_decision_var); } if(!opt_pre) S.eliminate(true); gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb"); if(in == NULL) printf("ERROR! Could not open file: %s\n", argc == 1 ? "<stdin>" : argv[1]), exit(1); if(opt_verb > 0){ printf("============================[ Problem Statistics ]=============================\n"); printf("| |\n"); } Dimacs<StreamBuffer, SimpSolver> parser; BVParser<char*, SimpSolver> bvParser; parser.addParser(&bvParser); SymbolParser<char*, SimpSolver> symbolParser; parser.addParser(&symbolParser); GraphParser<char*, SimpSolver> graphParser(true, bvParser.theory); parser.addParser(&graphParser); FlowRouterParser<char*, SimpSolver> flowRouterParser(&graphParser); parser.addParser(&flowRouterParser); PBParser<char*, SimpSolver> pbParser(S); parser.addParser(&pbParser); FSMParser<char*, SimpSolver> fsmParser; parser.addParser(&fsmParser); AMOParser<char*, SimpSolver> amo; parser.addParser(&amo); // Change to signal-handlers that will only notify the solver and allow it to terminate // voluntarily: #if not defined(__MINGW32__) signal(SIGINT, SIGINT_interrupt); signal(SIGXCPU, SIGINT_interrupt); #endif vec<Lit> assume; StreamBuffer strm(in); if(opt_parser_immediate_mode){ Monosat::BVTheorySolver<int64_t>* bv = new Monosat::BVTheorySolver<int64_t>(&S);//temporary! } bool found_optimal = true; while(S.okay() && parser.parse(strm, S)){ if(*strm == EOF){ //Don't run solves from the last line of the file, in order to support pre-processing and other options below. //(This is not a great way to deal with preprocessing...) break; } if(!opt_ignore_solve_statements){ S.preprocess();//do this _even_ if sat based preprocessing is disabled! Some of the theory solvers depend on a preprocessing call being made! if(!opt_remap_vars){ fprintf(stderr, "Warning: Solver will give completely bogus answers if 'solve' statements are processed while variable remapping is disabled (e.g., -no-remap-vars)\n\n"); } optimize_and_solve(S, parser.assumptions, parser.objectives, false, found_optimal); }else{ parser.assumptions.clear(); } } gzclose(in); if(opt_ignore_solve_statements){ parser.assumptions.clear(); } //processPriority(S,(const char *) opt_priority); //processDecidable(S , (const char*) opt_decidable); for(Lit l:assume) parser.assumptions.push(l); double before_pre_processing = rtime(0); double parsing_time = before_pre_processing - initial_time; if(opt_verb > 0){ printf("Parsing time = %f\n", parsing_time); } S.preprocess();//do this _even_ if sat based preprocessing is disabled! Some of the theory solvers depend on a preprocessing call being made! if(opt_pre){ if(opt_verb > 0){ printf("simplify:\n"); fflush(stdout); } // Assumptions must be temporarily frozen to run variable elimination: for(int i = 0; i < parser.assumptions.size(); i++){ Var v = var(parser.assumptions[i]); // If an assumption has been eliminated, remember it. assert(!S.isEliminated(v)); if(!S.isFrozen(v)){ // Freeze and store. S.setFrozen(v, true); } } S.eliminate(true); //in principle, should unfreeze these lits after solving... } fflush(stdout); //exit(0); double after_preprocessing = rtime(0); double preprocessing_time = after_preprocessing - before_pre_processing; if(opt_verb > 0 && opt_pre){ printf("Preprocessing time = %f\n", preprocessing_time); } if(opt_verb > 0){ printf("solving:\n"); fflush(stdout); } lbool ret = optimize_and_solve(S, parser.assumptions, parser.objectives, false, found_optimal); double solving_time = rtime(0) - after_preprocessing; if(opt_verb > 0){ printf("Solving time = %f\n", solving_time); if(!found_optimal){ printf("Warning: Gave up before proving solution optimal.\n"); } } if(ret == l_True){ if(strlen(opt_witness_file) > 0){ FILE* f = fopen(opt_witness_file, "w"); if(f){ fprintf(f, "v "); for(int v = 0; v < S.nVars(); v++){ if(parser.hasMappedVar(v)){ if(S.model[v] == l_True){ fprintf(f, "%d ", (parser.unmap(v) + 1)); }else if(S.model[v] == l_False){ fprintf(f, "%d ", -(parser.unmap(v) + 1)); } } } fprintf(f, "0\n"); fclose(f); }else{ fprintf(stderr, "Failed to write witness to file!\n"); } } if(strlen(opt_theory_witness_file) > 0){ std::cout << "Writing witness to file " << (const char*) opt_theory_witness_file << "\n"; std::ofstream theory_out(opt_theory_witness_file, ios::out); S.writeTheoryWitness(theory_out); /*for (auto p : symbols) { Var v = p.first; string & s = p.second; if (S.model[v] == l_True) { theory_out<< "var "<< s <<"\n"; } else if (S.model[v] == l_False) { //theory_out<< "-"<< s <<"\n"; } else { //this is unassigned } }*/ } if(opt_witness){ printf("v "); for(int v = 0; v < S.nVars() && v < S.model.size(); v++){ if(parser.hasMappedVar(v)){ Var uv = parser.unmap(v); assert (uv >= 0); if(uv < 0 || uv > 10000){ int a = 1; int b = parser.unmap(v); } if(S.model[v] == l_True){ printf("%d ", (uv + 1)); }else if(S.model[v] == l_False){ printf("%d ", -(uv + 1)); } } } printf("0\n"); } /*if (using_symbols_asp) { FILE * sfile = fopen(opt_symbols_asp, "w"); fprintf(sfile, "%% Generated by monosat\n"); for (auto p : symbols) { Var v = p.first; string & s = p.second; if (S.model[v] == l_True) { fprintf(sfile, ":- not %s.\n", s.c_str()); //cout<<":- not "<< s<<".\n"; } else if (S.model[v] == l_False) { fprintf(sfile, ":- %s.\n", s.c_str()); //cout<<":- "<<s<<".\n"; } else { //this is unassigned int a = 1; } } fflush(sfile); fclose(sfile); }*/ /*if (opb) { printf("v "); for (auto p : symbols) { Var v = p.first; std::string & s = p.second; if (S.model[v] == l_True) { printf("%s ", s.c_str()); //cout<<":- not "<< s<<".\n"; } else if (S.model[v] == l_False) { printf("-%s ", s.c_str()); //cout<<":- "<<s<<".\n"; } } printf("\n"); } */ if(opt_verb > 2){ for(int i = 0; i < S.theories.size(); i++) S.theories[i]->printSolution(); } if(!opt_csv) printf("s SATISFIABLE\n"); }else if(ret == l_False){ printf("s UNSATISFIABLE\n"); }else{ printf("UNKNOWN\n"); } if(opt_verb > 1){ printStats(S); } fflush(stdout); return (ret == l_True ? 10 : ret == l_False ? 20 : 0); }catch(parse_error& e){ std::cerr << "Parsing error:\n" << e.what(); exit(1); }catch(OutOfMemoryException&){ printf("===============================================================================\n"); printf("Out of memory exception\n"); printf("INDETERMINATE\n"); exit(0); } }
/* keyviserver - A key value store server based on keyvi. * * Copyright 2019 Hendrik Muhs<hendrik.muhs@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * IndexImpl.cpp * * Created on: Mar 12, 2019 * Author: hendrik */ #include "keyvi_server/service/index_impl.h" #include <memory> #include <string> #include <brpc/closure_guard.h> #include <brpc/controller.h> #include <google/protobuf/map.h> namespace keyvi_server { namespace service { IndexImpl::IndexImpl(const keyvi_server::core::data_backend_t &backend) : backend_(backend) {} IndexImpl::~IndexImpl() {} void IndexImpl::Info(google::protobuf::RpcController *cntl_base, const InfoRequest *request, InfoResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); (*response->mutable_info())["version"] = "0.0.1"; } void IndexImpl::Delete(google::protobuf::RpcController *cntl_base, const DeleteRequest *request, EmptyBodyResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); backend_->GetIndex().Delete(request->key()); } void IndexImpl::Contains(google::protobuf::RpcController *cntl_base, const ContainsRequest *request, ContainsResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); response->set_contains(backend_->GetIndex().Contains(request->key())); } void IndexImpl::Get(google::protobuf::RpcController *cntl_base, const GetRequest *request, StringValueResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); keyvi::dictionary::Match match = backend_->GetIndex()[request->key()]; response->set_value(match.GetValueAsString()); } void IndexImpl::GetFuzzy(google::protobuf::RpcController *cntl_base, const GetFuzzyRequest *request, GetFuzzyResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); auto matches = backend_->GetIndex().GetFuzzy(request->key(), request->max_edit_distance(), request->min_exact_prefix()); for (auto m : matches) { Match *match = response->add_matches(); match->set_matched_string(m.GetMatchedString()); match->set_value(m.GetValueAsString()); } } void IndexImpl::GetNear(google::protobuf::RpcController *cntl_base, const GetNearRequest *request, GetNearResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); auto matches = backend_->GetIndex().GetNear(request->key(), request->min_exact_prefix(), request->greedy()); for (auto m : matches) { Match *match = response->add_matches(); match->set_matched_string(m.GetMatchedString()); match->set_value(m.GetValueAsString()); } } void IndexImpl::GetRaw(google::protobuf::RpcController *cntl_base, const GetRawRequest *request, StringValueResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); keyvi::dictionary::Match match = backend_->GetIndex()[request->key()]; response->set_value(match.GetRawValueAsString()); } void IndexImpl::Set(google::protobuf::RpcController *cntl_base, const SetRequest *request, EmptyBodyResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); backend_->GetIndex().Set(request->key(), request->value()); } void IndexImpl::MSet(google::protobuf::RpcController *cntl_base, const MSetRequest *request, EmptyBodyResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); std::shared_ptr<google::protobuf::Map<std::string, std::string>> key_values = std::make_shared<google::protobuf::Map<std::string, std::string>>(); // hack: cast to remove const and use map from request MSetRequest *request_m = const_cast<MSetRequest *>(request); (*request_m->mutable_key_values()).swap(*key_values.get()); backend_->GetIndex().MSet(key_values); } void IndexImpl::Flush(google::protobuf::RpcController *cntl_base, const FlushRequest *request, EmptyBodyResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); backend_->GetIndex().Flush(request->asynchronous()); } void IndexImpl::ForceMerge(google::protobuf::RpcController *cntl_base, const ForceMergeRequest *request, EmptyBodyResponse *response, google::protobuf::Closure *done) { brpc::ClosureGuard done_guard(done); brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base); backend_->GetIndex().ForceMerge(request->max_segments()); } } // namespace service } // namespace keyvi_server
; A122795: Connell (5,3)-sum sequence (partial sums of the (5,3)-Connell sequence) ; 1,3,10,22,39,57,80,108,141,179,222,270,319,373,432,496,565,639,718,802,891,985,1080,1180,1285,1395,1510,1630,1755,1885,2020,2160,2305,2455,2610,2766,2927,3093,3264,3440,3621,3807,3998,4194,4395,4601,4812,5028,5249,5475,5706,5938,6175,6417,6664,6916,7173,7435,7702,7974,8251,8533,8820,9112,9409,9711,10018,10330,10647,10969 lpb $0 mov $2,$0 sub $0,1 seq $2,45929 ; Generalized Connell sequence C_{5,3}. add $1,$2 lpe add $1,1 mov $0,$1
// MIT License // // Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #include <iostream> #include <chrono> #include <vector> #include <limits> #include <string> #include <cstdio> #include <cstdlib> // Google Benchmark #include "benchmark/benchmark.h" // CmdParser #include "cmdparser.hpp" #include "benchmark_utils.hpp" // HIP API #include <hip/hip_runtime.h> // rocPRIM #include <rocprim/rocprim.hpp> #define HIP_CHECK(condition) \ { \ hipError_t error = condition; \ if(error != hipSuccess){ \ std::cout << "HIP error: " << error << " line: " << __LINE__ << std::endl; \ exit(error); \ } \ } #ifndef DEFAULT_N const size_t DEFAULT_N = 1024 * 1024 * 32; #endif template< bool AllReduce, class T, unsigned int WarpSize, unsigned int Trials > __global__ void warp_reduce_kernel(const T * d_input, T * d_output) { const unsigned int i = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; auto value = d_input[i]; using wreduce_t = rocprim::warp_reduce<T, WarpSize, AllReduce>; __shared__ typename wreduce_t::storage_type storage; #pragma nounroll for(unsigned int trial = 0; trial < Trials; trial++) { wreduce_t().reduce(value, value, storage); } d_output[i] = value; } template< class T, class Flag, unsigned int WarpSize, unsigned int Trials > __global__ void segmented_warp_reduce_kernel(const T* d_input, Flag* d_flags, T* d_output) { const unsigned int i = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; auto value = d_input[i]; auto flag = d_flags[i]; using wreduce_t = rocprim::warp_reduce<T, WarpSize>; __shared__ typename wreduce_t::storage_type storage; #pragma nounroll for(unsigned int trial = 0; trial < Trials; trial++) { wreduce_t().head_segmented_reduce(value, value, flag, storage); } d_output[i] = value; } template< bool AllReduce, bool Segmented, unsigned int WarpSize, unsigned int BlockSize, unsigned int Trials, class T, class Flag > inline auto execute_warp_reduce_kernel(T* input, T* output, Flag* /* flags */, size_t size, hipStream_t stream) -> typename std::enable_if<!Segmented>::type { hipLaunchKernelGGL( HIP_KERNEL_NAME(warp_reduce_kernel<AllReduce, T, WarpSize, Trials>), dim3(size/BlockSize), dim3(BlockSize), 0, stream, input, output ); HIP_CHECK(hipPeekAtLastError()); } template< bool AllReduce, bool Segmented, unsigned int WarpSize, unsigned int BlockSize, unsigned int Trials, class T, class Flag > inline auto execute_warp_reduce_kernel(T* input, T* output, Flag* flags, size_t size, hipStream_t stream) -> typename std::enable_if<Segmented>::type { hipLaunchKernelGGL( HIP_KERNEL_NAME(segmented_warp_reduce_kernel<T, Flag, WarpSize, Trials>), dim3(size/BlockSize), dim3(BlockSize), 0, stream, input, flags, output ); HIP_CHECK(hipPeekAtLastError()); } template< bool AllReduce, bool Segmented, class T, unsigned int WarpSize, unsigned int BlockSize, unsigned int Trials = 100 > void run_benchmark(benchmark::State& state, hipStream_t stream, size_t N) { using flag_type = unsigned char; const auto size = BlockSize * ((N + BlockSize - 1)/BlockSize); std::vector<T> input = get_random_data<T>(size, T(0), T(10)); std::vector<flag_type> flags = get_random_data<flag_type>(size, 0, 1); T * d_input; flag_type * d_flags; T * d_output; HIP_CHECK(hipMalloc(&d_input, size * sizeof(T))); HIP_CHECK(hipMalloc(&d_flags, size * sizeof(flag_type))); HIP_CHECK(hipMalloc(&d_output, size * sizeof(T))); HIP_CHECK( hipMemcpy( d_input, input.data(), size * sizeof(T), hipMemcpyHostToDevice ) ); HIP_CHECK( hipMemcpy( d_flags, flags.data(), size * sizeof(flag_type), hipMemcpyHostToDevice ) ); HIP_CHECK(hipDeviceSynchronize()); for(auto _ : state) { auto start = std::chrono::high_resolution_clock::now(); execute_warp_reduce_kernel<AllReduce, Segmented, WarpSize, BlockSize, Trials>( d_input, d_output, d_flags, size, stream ); HIP_CHECK(hipDeviceSynchronize()); auto end = std::chrono::high_resolution_clock::now(); auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>(end - start); state.SetIterationTime(elapsed_seconds.count()); } state.SetBytesProcessed(state.iterations() * Trials * size * sizeof(T)); state.SetItemsProcessed(state.iterations() * Trials * size); HIP_CHECK(hipFree(d_input)); HIP_CHECK(hipFree(d_output)); HIP_CHECK(hipFree(d_flags)); } #define CREATE_BENCHMARK(T, WS, BS) \ benchmark::RegisterBenchmark( \ (std::string("warp_reduce<" #T ", " #WS ", " #BS ">.") + name).c_str(), \ run_benchmark<AllReduce, Segmented, T, WS, BS>, \ stream, size \ ) #define BENCHMARK_TYPE(type) \ CREATE_BENCHMARK(type, 32, 64), \ CREATE_BENCHMARK(type, 37, 64), \ CREATE_BENCHMARK(type, 61, 64), \ CREATE_BENCHMARK(type, 64, 64) template<bool AllReduce, bool Segmented> void add_benchmarks(const std::string& name, std::vector<benchmark::internal::Benchmark*>& benchmarks, hipStream_t stream, size_t size) { std::vector<benchmark::internal::Benchmark*> bs = { BENCHMARK_TYPE(int), BENCHMARK_TYPE(float), BENCHMARK_TYPE(double), BENCHMARK_TYPE(int8_t), BENCHMARK_TYPE(uint8_t), BENCHMARK_TYPE(rocprim::half) }; benchmarks.insert(benchmarks.end(), bs.begin(), bs.end()); } int main(int argc, char *argv[]) { cli::Parser parser(argc, argv); parser.set_optional<size_t>("size", "size", DEFAULT_N, "number of values"); parser.set_optional<int>("trials", "trials", -1, "number of iterations"); parser.run_and_exit_if_error(); // Parse argv benchmark::Initialize(&argc, argv); const size_t size = parser.get<size_t>("size"); const int trials = parser.get<int>("trials"); // HIP hipStream_t stream = 0; // default hipDeviceProp_t devProp; int device_id = 0; HIP_CHECK(hipGetDevice(&device_id)); HIP_CHECK(hipGetDeviceProperties(&devProp, device_id)); std::cout << "[HIP] Device name: " << devProp.name << std::endl; // Add benchmarks std::vector<benchmark::internal::Benchmark*> benchmarks; add_benchmarks<false, false>("reduce", benchmarks, stream, size); add_benchmarks<true, false>("all_reduce", benchmarks, stream, size); add_benchmarks<false, true>("segmented_reduce", benchmarks, stream, size); // Use manual timing for(auto& b : benchmarks) { b->UseManualTime(); b->Unit(benchmark::kMillisecond); } // Force number of iterations if(trials > 0) { for(auto& b : benchmarks) { b->Iterations(trials); } } // Run benchmarks benchmark::RunSpecifiedBenchmarks(); return 0; }
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/message_center/message_center_tray.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/observer_list.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_tray_delegate.h" #include "ui/message_center/message_center_types.h" #include "ui/message_center/notification_blocker.h" #include "ui/strings/grit/ui_strings.h" namespace message_center { namespace { // Menu constants const int kTogglePermissionCommand = 0; #if defined(OS_CHROMEOS) const int kShowSettingsCommand = 1; #endif // The model of the context menu for a notification card. class NotificationMenuModel : public ui::SimpleMenuModel, public ui::SimpleMenuModel::Delegate { public: NotificationMenuModel(MessageCenterTray* tray, const NotifierId& notifier_id, const base::string16& display_source); ~NotificationMenuModel() override; // Overridden from ui::SimpleMenuModel::Delegate: bool IsCommandIdChecked(int command_id) const override; bool IsCommandIdEnabled(int command_id) const override; bool GetAcceleratorForCommandId(int command_id, ui::Accelerator* accelerator) override; void ExecuteCommand(int command_id, int event_flags) override; private: MessageCenterTray* tray_; NotifierId notifier_id_; DISALLOW_COPY_AND_ASSIGN(NotificationMenuModel); }; NotificationMenuModel::NotificationMenuModel( MessageCenterTray* tray, const NotifierId& notifier_id, const base::string16& display_source) : ui::SimpleMenuModel(this), tray_(tray), notifier_id_(notifier_id) { if (!display_source.empty()) { AddItem(kTogglePermissionCommand, l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_NOTIFIER_DISABLE, display_source)); } #ifdef OS_CHROMEOS // Add settings menu item. AddItem(kShowSettingsCommand, l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_SETTINGS)); #endif } NotificationMenuModel::~NotificationMenuModel() { } bool NotificationMenuModel::IsCommandIdChecked(int command_id) const { return false; } bool NotificationMenuModel::IsCommandIdEnabled(int command_id) const { return tray_->delegate()->IsContextMenuEnabled(); } bool NotificationMenuModel::GetAcceleratorForCommandId( int command_id, ui::Accelerator* accelerator) { return false; } void NotificationMenuModel::ExecuteCommand(int command_id, int event_flags) { switch (command_id) { case kTogglePermissionCommand: tray_->message_center()->DisableNotificationsByNotifier(notifier_id_); break; #ifdef OS_CHROMEOS case kShowSettingsCommand: tray_->ShowNotifierSettingsBubble(); break; #endif default: NOTREACHED(); } } } // namespace MessageCenterTray::MessageCenterTray( MessageCenterTrayDelegate* delegate, message_center::MessageCenter* message_center) : message_center_(message_center), message_center_visible_(false), popups_visible_(false), delegate_(delegate) { message_center_->AddObserver(this); } MessageCenterTray::~MessageCenterTray() { message_center_->RemoveObserver(this); } bool MessageCenterTray::ShowMessageCenterBubble() { if (message_center_visible_) return true; HidePopupBubbleInternal(); message_center_visible_ = delegate_->ShowMessageCenter(); if (message_center_visible_) { message_center_->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); NotifyMessageCenterTrayChanged(); } return message_center_visible_; } bool MessageCenterTray::HideMessageCenterBubble() { if (!message_center_visible_) return false; delegate_->HideMessageCenter(); MarkMessageCenterHidden(); return true; } void MessageCenterTray::MarkMessageCenterHidden() { if (!message_center_visible_) return; message_center_visible_ = false; message_center_->SetVisibility(message_center::VISIBILITY_TRANSIENT); // Some notifications (like system ones) should appear as popups again // after the message center is closed. if (message_center_->HasPopupNotifications()) { ShowPopupBubble(); return; } NotifyMessageCenterTrayChanged(); } void MessageCenterTray::ShowPopupBubble() { if (message_center_visible_) return; if (popups_visible_) { NotifyMessageCenterTrayChanged(); return; } if (!message_center_->HasPopupNotifications()) return; popups_visible_ = delegate_->ShowPopups(); NotifyMessageCenterTrayChanged(); } bool MessageCenterTray::HidePopupBubble() { if (!popups_visible_) return false; HidePopupBubbleInternal(); NotifyMessageCenterTrayChanged(); return true; } void MessageCenterTray::HidePopupBubbleInternal() { if (!popups_visible_) return; delegate_->HidePopups(); popups_visible_ = false; } void MessageCenterTray::ShowNotifierSettingsBubble() { if (popups_visible_) HidePopupBubbleInternal(); message_center_visible_ = delegate_->ShowNotifierSettings(); message_center_->SetVisibility(message_center::VISIBILITY_SETTINGS); NotifyMessageCenterTrayChanged(); } std::unique_ptr<ui::MenuModel> MessageCenterTray::CreateNotificationMenuModel( const NotifierId& notifier_id, const base::string16& display_source) { #if !defined(OS_CHROMEOS) // Only web pages are configurable on non-chromeos platforms. if (notifier_id.type != NotifierId::WEB_PAGE) { return nullptr; } #endif return base::WrapUnique( new NotificationMenuModel(this, notifier_id, display_source)); } void MessageCenterTray::OnNotificationAdded( const std::string& notification_id) { OnMessageCenterChanged(); } void MessageCenterTray::OnNotificationRemoved( const std::string& notification_id, bool by_user) { OnMessageCenterChanged(); } void MessageCenterTray::OnNotificationUpdated( const std::string& notification_id) { OnMessageCenterChanged(); } void MessageCenterTray::OnNotificationClicked( const std::string& notification_id) { if (popups_visible_) OnMessageCenterChanged(); } void MessageCenterTray::OnNotificationButtonClicked( const std::string& notification_id, int button_index) { if (popups_visible_) OnMessageCenterChanged(); } void MessageCenterTray::OnNotificationDisplayed( const std::string& notification_id, const DisplaySource source) { NotifyMessageCenterTrayChanged(); } void MessageCenterTray::OnQuietModeChanged(bool in_quiet_mode) { NotifyMessageCenterTrayChanged(); } void MessageCenterTray::OnBlockingStateChanged(NotificationBlocker* blocker) { OnMessageCenterChanged(); } void MessageCenterTray::OnMessageCenterChanged() { if (message_center_visible_ && message_center_->NotificationCount() == 0) HideMessageCenterBubble(); if (popups_visible_ && !message_center_->HasPopupNotifications()) HidePopupBubbleInternal(); else if (!popups_visible_ && message_center_->HasPopupNotifications()) ShowPopupBubble(); NotifyMessageCenterTrayChanged(); } void MessageCenterTray::NotifyMessageCenterTrayChanged() { delegate_->OnMessageCenterTrayChanged(); } } // namespace message_center
;******************************************************************************* ;* TMS320C55x C/C++ Codegen PC v4.4.1 * ;* Date/Time created: Sat Oct 06 06:38:24 2018 * ;******************************************************************************* .compiler_opts --hll_source=on --mem_model:code=flat --mem_model:data=large --object_format=coff --silicon_core_3_3 --symdebug:dwarf .mmregs .cpl_on .arms_on .c54cm_off .asg AR6, FP .asg XAR6, XFP .asg DPH, MDP .model call=c55_std .model mem=large .noremark 5002 ; code respects overwrite rules ;******************************************************************************* ;* GLOBAL FILE PARAMETERS * ;* * ;* Architecture : TMS320C55x * ;* Optimizing for : Speed * ;* Memory : Large Model (23-Bit Data Pointers) * ;* Calls : Normal Library ASM calls * ;* Debug Info : Standard TI Debug Information * ;******************************************************************************* $C$DW$CU .dwtag DW_TAG_compile_unit .dwattr $C$DW$CU, DW_AT_name("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$CU, DW_AT_producer("TMS320C55x C/C++ Codegen PC v4.4.1 Copyright (c) 1996-2012 Texas Instruments Incorporated") .dwattr $C$DW$CU, DW_AT_TI_version(0x01) .dwattr $C$DW$CU, DW_AT_comp_dir("F:\eZdsp_DBG\tmp1\c55x-sim2\foo\Debug") ; F:\t\cc5p5\ccsv5\tools\compiler\c5500_4.4.1\bin\acp55.exe -@f:\\AppData\\Local\\Temp\\2092012 .sect ".text" .align 4 .global _WDTIM_open $C$DW$1 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_open") .dwattr $C$DW$1, DW_AT_low_pc(_WDTIM_open) .dwattr $C$DW$1, DW_AT_high_pc(0x00) .dwattr $C$DW$1, DW_AT_TI_symbol_name("_WDTIM_open") .dwattr $C$DW$1, DW_AT_external .dwattr $C$DW$1, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$1, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$1, DW_AT_TI_begin_line(0x48) .dwattr $C$DW$1, DW_AT_TI_begin_column(0x0f) .dwattr $C$DW$1, DW_AT_TI_max_frame_size(0x0a) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 75,column 1,is_stmt,address _WDTIM_open .dwfde $C$DW$CIE, _WDTIM_open $C$DW$2 .dwtag DW_TAG_formal_parameter, DW_AT_name("wdtNum") .dwattr $C$DW$2, DW_AT_TI_symbol_name("_wdtNum") .dwattr $C$DW$2, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$2, DW_AT_location[DW_OP_reg12] $C$DW$3 .dwtag DW_TAG_formal_parameter, DW_AT_name("wdtObj") .dwattr $C$DW$3, DW_AT_TI_symbol_name("_wdtObj") .dwattr $C$DW$3, DW_AT_type(*$C$DW$T$35) .dwattr $C$DW$3, DW_AT_location[DW_OP_reg17] $C$DW$4 .dwtag DW_TAG_formal_parameter, DW_AT_name("status") .dwattr $C$DW$4, DW_AT_TI_symbol_name("_status") .dwattr $C$DW$4, DW_AT_type(*$C$DW$T$39) .dwattr $C$DW$4, DW_AT_location[DW_OP_reg19] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_open * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,XAR1,AR3,XAR3,SP,TC1,* ;* M40,SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 10 words * ;* (1 return address/alignment) * ;* (9 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_open: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-9, SP .dwcfi cfa_offset, 10 $C$DW$5 .dwtag DW_TAG_variable, DW_AT_name("wdtNum") .dwattr $C$DW$5, DW_AT_TI_symbol_name("_wdtNum") .dwattr $C$DW$5, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$5, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$6 .dwtag DW_TAG_variable, DW_AT_name("wdtObj") .dwattr $C$DW$6, DW_AT_TI_symbol_name("_wdtObj") .dwattr $C$DW$6, DW_AT_type(*$C$DW$T$35) .dwattr $C$DW$6, DW_AT_location[DW_OP_bregx 0x24 2] $C$DW$7 .dwtag DW_TAG_variable, DW_AT_name("status") .dwattr $C$DW$7, DW_AT_TI_symbol_name("_status") .dwattr $C$DW$7, DW_AT_type(*$C$DW$T$39) .dwattr $C$DW$7, DW_AT_location[DW_OP_bregx 0x24 4] $C$DW$8 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$8, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$8, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$8, DW_AT_location[DW_OP_bregx 0x24 6] $C$DW$9 .dwtag DW_TAG_variable, DW_AT_name("sysRegs") .dwattr $C$DW$9, DW_AT_TI_symbol_name("_sysRegs") .dwattr $C$DW$9, DW_AT_type(*$C$DW$T$45) .dwattr $C$DW$9, DW_AT_location[DW_OP_bregx 0x24 8] MOV XAR1, dbl(*SP(#4)) MOV XAR0, dbl(*SP(#2)) MOV T0, *SP(#0) ; |75| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 79,column 2,is_stmt MOV dbl(*SP(#4)), XAR3 MOV #0, *AR3 ; |79| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 80,column 2,is_stmt MOV #0, AC0 ; |80| MOV AC0, dbl(*SP(#6)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 82,column 2,is_stmt MOV dbl(*SP(#2)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |82| CMPU AC1 != AC0, TC1 ; |82| BCC $C$L1,TC1 ; |82| ; branchcc occurs ; |82| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 84,column 3,is_stmt MOV dbl(*SP(#4)), XAR3 MOV #-5, *AR3 ; |84| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 85,column 3,is_stmt MOV dbl(*SP(#6)), XAR0 B $C$L8 ; |85| ; branch occurs ; |85| $C$L1: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 88,column 2,is_stmt MOV *SP(#0), AR1 ; |88| BCC $C$L2,AR1 < #0 ; |88| ; branchcc occurs ; |88| BCC $C$L3,AR1 <= #0 ; |88| ; branchcc occurs ; |88| $C$L2: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 90,column 3,is_stmt MOV dbl(*SP(#4)), XAR3 MOV #-6, *AR3 ; |90| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 91,column 3,is_stmt MOV dbl(*SP(#6)), XAR0 B $C$L8 ; |91| ; branch occurs ; |91| $C$L3: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 94,column 2,is_stmt MOV XAR3, dbl(*SP(#6)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 96,column 2,is_stmt MOV #7168, *SP(#8) ; |96| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 98,column 2,is_stmt B $C$L6 ; |98| ; branch occurs ; |98| $C$L4: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 101,column 4,is_stmt MOV dbl(*SP(#6)), XAR3 MOV AR1, *AR3 ; |101| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 102,column 4,is_stmt MOV dbl(*SP(#6)), XAR3 MOV #6272, *AR3(short(#1)) ; |102| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 103,column 4,is_stmt MOV *SP(#8), AR3 ; |103| MOV port(*AR3(short(#2))), AR1 ; |103| BCLR @#13, AR1 ; |103| MOV AR1, port(*AR3(short(#2))) ; |103| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 105,column 9,is_stmt B $C$L7 ; |105| ; branch occurs ; |105| $C$L5: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 108,column 4,is_stmt MOV dbl(*SP(#4)), XAR3 MOV #-6, *AR3 ; |108| B $C$L7 ; |108| ; branch occurs ; |108| $C$L6: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 98,column 2,is_stmt MOV *SP(#0), AR1 ; |98| BCC $C$L4,AR1 == #0 ; |98| ; branchcc occurs ; |98| B $C$L5 ; |98| ; branch occurs ; |98| $C$L7: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 111,column 2,is_stmt MOV dbl(*SP(#6)), XAR0 $C$L8: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 112,column 1,is_stmt AADD #9, SP .dwcfi cfa_offset, 1 $C$DW$10 .dwtag DW_TAG_TI_branch .dwattr $C$DW$10, DW_AT_low_pc(0x00) .dwattr $C$DW$10, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$1, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$1, DW_AT_TI_end_line(0x70) .dwattr $C$DW$1, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$1 .sect ".text" .align 4 .global _WDTIM_start $C$DW$11 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_start") .dwattr $C$DW$11, DW_AT_low_pc(_WDTIM_start) .dwattr $C$DW$11, DW_AT_high_pc(0x00) .dwattr $C$DW$11, DW_AT_TI_symbol_name("_WDTIM_start") .dwattr $C$DW$11, DW_AT_external .dwattr $C$DW$11, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$11, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$11, DW_AT_TI_begin_line(0x97) .dwattr $C$DW$11, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$11, DW_AT_TI_max_frame_size(0x04) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 152,column 1,is_stmt,address _WDTIM_start .dwfde $C$DW$CIE, _WDTIM_start $C$DW$12 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$12, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$12, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$12, DW_AT_location[DW_OP_reg17] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_start * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,AR3,XAR3,SP,TC1,M40, * ;* SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 4 words * ;* (1 return address/alignment) * ;* (3 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_start: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-3, SP .dwcfi cfa_offset, 4 $C$DW$13 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$13, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$13, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$13, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$14 .dwtag DW_TAG_variable, DW_AT_name("regs") .dwattr $C$DW$14, DW_AT_TI_symbol_name("_regs") .dwattr $C$DW$14, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$14, DW_AT_location[DW_OP_bregx 0x24 2] MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 155,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |155| CMPU AC1 != AC0, TC1 ; |155| BCC $C$L9,TC1 ; |155| ; branchcc occurs ; |155| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 157,column 3,is_stmt MOV #-5, T0 B $C$L10 ; |157| ; branch occurs ; |157| $C$L9: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 160,column 2,is_stmt MOV *AR3(short(#1)), AR1 ; |160| MOV AR1, *SP(#2) ; |160| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 162,column 2,is_stmt MOV AR1, AR3 AMOV #8, T0 MOV #30583, port(*AR3(T0)) ; |162| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 163,column 2,is_stmt MOV *SP(#2), AR3 ; |163| MOV #52428, port(*AR3(T0)) ; |163| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 164,column 2,is_stmt MOV *SP(#2), AR3 ; |164| MOV #56797, port(*AR3(T0)) ; |164| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 166,column 2,is_stmt MOV *SP(#2), AR3 ; |166| AMOV #10, T0 MOV port(*AR3(T0)), AR1 ; |166| BCLR @#0, AR1 ; |166| BSET @#0, AR1 ; |166| MOV AR1, port(*AR3(T0)) ; |166| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 168,column 2,is_stmt MOV #0, T0 $C$L10: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 169,column 1,is_stmt AADD #3, SP .dwcfi cfa_offset, 1 $C$DW$15 .dwtag DW_TAG_TI_branch .dwattr $C$DW$15, DW_AT_low_pc(0x00) .dwattr $C$DW$15, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$11, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$11, DW_AT_TI_end_line(0xa9) .dwattr $C$DW$11, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$11 .sect ".text" .align 4 .global _WDTIM_stop $C$DW$16 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_stop") .dwattr $C$DW$16, DW_AT_low_pc(_WDTIM_stop) .dwattr $C$DW$16, DW_AT_high_pc(0x00) .dwattr $C$DW$16, DW_AT_TI_symbol_name("_WDTIM_stop") .dwattr $C$DW$16, DW_AT_external .dwattr $C$DW$16, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$16, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$16, DW_AT_TI_begin_line(0xd0) .dwattr $C$DW$16, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$16, DW_AT_TI_max_frame_size(0x04) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 209,column 1,is_stmt,address _WDTIM_stop .dwfde $C$DW$CIE, _WDTIM_stop $C$DW$17 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$17, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$17, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$17, DW_AT_location[DW_OP_reg17] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_stop * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,AR3,XAR3,SP,TC1,M40, * ;* SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 4 words * ;* (1 return address/alignment) * ;* (3 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_stop: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-3, SP .dwcfi cfa_offset, 4 $C$DW$18 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$18, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$18, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$18, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$19 .dwtag DW_TAG_variable, DW_AT_name("regs") .dwattr $C$DW$19, DW_AT_TI_symbol_name("_regs") .dwattr $C$DW$19, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$19, DW_AT_location[DW_OP_bregx 0x24 2] MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 212,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |212| CMPU AC1 != AC0, TC1 ; |212| BCC $C$L11,TC1 ; |212| ; branchcc occurs ; |212| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 214,column 3,is_stmt MOV #-5, T0 B $C$L12 ; |214| ; branch occurs ; |214| $C$L11: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 217,column 2,is_stmt MOV *AR3(short(#1)), AR1 ; |217| MOV AR1, *SP(#2) ; |217| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 219,column 2,is_stmt MOV AR1, AR3 AMOV #8, T0 MOV #30583, port(*AR3(T0)) ; |219| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 220,column 2,is_stmt MOV *SP(#2), AR3 ; |220| MOV #52428, port(*AR3(T0)) ; |220| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 221,column 2,is_stmt MOV *SP(#2), AR3 ; |221| MOV #56797, port(*AR3(T0)) ; |221| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 223,column 2,is_stmt MOV *SP(#2), AR3 ; |223| AMOV #10, T0 MOV port(*AR3(T0)), AR1 ; |223| BCLR @#0, AR1 ; |223| MOV AR1, port(*AR3(T0)) ; |223| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 225,column 2,is_stmt MOV #0, T0 $C$L12: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 226,column 1,is_stmt AADD #3, SP .dwcfi cfa_offset, 1 $C$DW$20 .dwtag DW_TAG_TI_branch .dwattr $C$DW$20, DW_AT_low_pc(0x00) .dwattr $C$DW$20, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$16, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$16, DW_AT_TI_end_line(0xe2) .dwattr $C$DW$16, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$16 .sect ".text" .align 4 .global _WDTIM_getCnt $C$DW$21 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_getCnt") .dwattr $C$DW$21, DW_AT_low_pc(_WDTIM_getCnt) .dwattr $C$DW$21, DW_AT_high_pc(0x00) .dwattr $C$DW$21, DW_AT_TI_symbol_name("_WDTIM_getCnt") .dwattr $C$DW$21, DW_AT_external .dwattr $C$DW$21, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$21, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$21, DW_AT_TI_begin_line(0x10a) .dwattr $C$DW$21, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$21, DW_AT_TI_max_frame_size(0x06) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 267,column 1,is_stmt,address _WDTIM_getCnt .dwfde $C$DW$CIE, _WDTIM_getCnt $C$DW$22 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$22, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$22, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$22, DW_AT_location[DW_OP_reg17] $C$DW$23 .dwtag DW_TAG_formal_parameter, DW_AT_name("timeCnt") .dwattr $C$DW$23, DW_AT_TI_symbol_name("_timeCnt") .dwattr $C$DW$23, DW_AT_type(*$C$DW$T$48) .dwattr $C$DW$23, DW_AT_location[DW_OP_reg19] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_getCnt * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,XAR1,AR3,XAR3,SP,TC1,* ;* M40,SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 6 words * ;* (1 return address/alignment) * ;* (5 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_getCnt: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-5, SP .dwcfi cfa_offset, 6 $C$DW$24 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$24, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$24, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$24, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$25 .dwtag DW_TAG_variable, DW_AT_name("timeCnt") .dwattr $C$DW$25, DW_AT_TI_symbol_name("_timeCnt") .dwattr $C$DW$25, DW_AT_type(*$C$DW$T$48) .dwattr $C$DW$25, DW_AT_location[DW_OP_bregx 0x24 2] $C$DW$26 .dwtag DW_TAG_variable, DW_AT_name("regs") .dwattr $C$DW$26, DW_AT_TI_symbol_name("_regs") .dwattr $C$DW$26, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$26, DW_AT_location[DW_OP_bregx 0x24 4] MOV XAR1, dbl(*SP(#2)) MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 270,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |270| CMPU AC1 != AC0, TC1 ; |270| BCC $C$L13,TC1 ; |270| ; branchcc occurs ; |270| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 272,column 3,is_stmt MOV #-5, T0 B $C$L14 ; |272| ; branch occurs ; |272| $C$L13: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 275,column 2,is_stmt MOV *AR3(short(#1)), AR1 ; |275| MOV AR1, *SP(#4) ; |275| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 277,column 2,is_stmt MOV AR1, AR3 MOV uns(port(*AR3(short(#2)))), AC0 ; |277| MOV dbl(*SP(#2)), XAR3 MOV AC0, dbl(*AR3) ; |277| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 279,column 2,is_stmt MOV #0, T0 $C$L14: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 280,column 1,is_stmt AADD #5, SP .dwcfi cfa_offset, 1 $C$DW$27 .dwtag DW_TAG_TI_branch .dwattr $C$DW$27, DW_AT_low_pc(0x00) .dwattr $C$DW$27, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$21, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$21, DW_AT_TI_end_line(0x118) .dwattr $C$DW$21, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$21 .sect ".text" .align 4 .global _WDTIM_close $C$DW$28 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_close") .dwattr $C$DW$28, DW_AT_low_pc(_WDTIM_close) .dwattr $C$DW$28, DW_AT_high_pc(0x00) .dwattr $C$DW$28, DW_AT_TI_symbol_name("_WDTIM_close") .dwattr $C$DW$28, DW_AT_external .dwattr $C$DW$28, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$28, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$28, DW_AT_TI_begin_line(0x13d) .dwattr $C$DW$28, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$28, DW_AT_TI_max_frame_size(0x04) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 318,column 1,is_stmt,address _WDTIM_close .dwfde $C$DW$CIE, _WDTIM_close $C$DW$29 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$29, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$29, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$29, DW_AT_location[DW_OP_reg17] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_close * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,AR3,XAR3,SP,TC1,M40, * ;* SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 4 words * ;* (1 return address/alignment) * ;* (3 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_close: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-3, SP .dwcfi cfa_offset, 4 $C$DW$30 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$30, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$30, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$30, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$31 .dwtag DW_TAG_variable, DW_AT_name("sysRegs") .dwattr $C$DW$31, DW_AT_TI_symbol_name("_sysRegs") .dwattr $C$DW$31, DW_AT_type(*$C$DW$T$45) .dwattr $C$DW$31, DW_AT_location[DW_OP_bregx 0x24 2] MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 322,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |322| CMPU AC1 != AC0, TC1 ; |322| BCC $C$L15,TC1 ; |322| ; branchcc occurs ; |322| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 324,column 3,is_stmt MOV #-5, T0 B $C$L19 ; |324| ; branch occurs ; |324| $C$L15: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 326,column 2,is_stmt MOV #7168, *SP(#2) ; |326| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 328,column 2,is_stmt B $C$L17 ; |328| ; branch occurs ; |328| $C$L16: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 331,column 4,is_stmt MOV *SP(#2), AR3 ; |331| MOV port(*AR3(short(#2))), AR1 ; |331| BCLR @#13, AR1 ; |331| BSET @#13, AR1 ; |331| MOV AR1, port(*AR3(short(#2))) ; |331| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 333,column 9,is_stmt B $C$L18 ; |333| ; branch occurs ; |333| $C$L17: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 328,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV *AR3, AR1 ; |328| BCC $C$L16,AR1 == #0 ; |328| ; branchcc occurs ; |328| $C$L18: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 336,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV #0, *AR3(short(#1)) ; |336| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 337,column 2,is_stmt MOV #0, AC0 ; |337| MOV AC0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 339,column 2,is_stmt MOV #0, T0 $C$L19: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 340,column 1,is_stmt AADD #3, SP .dwcfi cfa_offset, 1 $C$DW$32 .dwtag DW_TAG_TI_branch .dwattr $C$DW$32, DW_AT_low_pc(0x00) .dwattr $C$DW$32, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$28, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$28, DW_AT_TI_end_line(0x154) .dwattr $C$DW$28, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$28 .sect ".text" .align 4 .global _WDTIM_service $C$DW$33 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_service") .dwattr $C$DW$33, DW_AT_low_pc(_WDTIM_service) .dwattr $C$DW$33, DW_AT_high_pc(0x00) .dwattr $C$DW$33, DW_AT_TI_symbol_name("_WDTIM_service") .dwattr $C$DW$33, DW_AT_external .dwattr $C$DW$33, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$33, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$33, DW_AT_TI_begin_line(0x17b) .dwattr $C$DW$33, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$33, DW_AT_TI_max_frame_size(0x04) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 380,column 1,is_stmt,address _WDTIM_service .dwfde $C$DW$CIE, _WDTIM_service $C$DW$34 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$34, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$34, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$34, DW_AT_location[DW_OP_reg17] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_service * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,AR3,XAR3,SP,TC1,M40, * ;* SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 4 words * ;* (1 return address/alignment) * ;* (3 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_service: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-3, SP .dwcfi cfa_offset, 4 $C$DW$35 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$35, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$35, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$35, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$36 .dwtag DW_TAG_variable, DW_AT_name("regs") .dwattr $C$DW$36, DW_AT_TI_symbol_name("_regs") .dwattr $C$DW$36, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$36, DW_AT_location[DW_OP_bregx 0x24 2] MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 383,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |383| CMPU AC1 != AC0, TC1 ; |383| BCC $C$L20,TC1 ; |383| ; branchcc occurs ; |383| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 385,column 3,is_stmt MOV #-5, T0 B $C$L21 ; |385| ; branch occurs ; |385| $C$L20: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 388,column 2,is_stmt MOV *AR3(short(#1)), AR1 ; |388| MOV AR1, *SP(#2) ; |388| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 390,column 2,is_stmt MOV AR1, AR3 MOV #21845, port(*AR3) ; |390| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 391,column 2,is_stmt MOV *SP(#2), AR3 ; |391| MOV #43690, port(*AR3) ; |391| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 393,column 2,is_stmt MOV *SP(#2), AR3 ; |393| MOV #1, port(*AR3(short(#2))) ; |393| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 395,column 2,is_stmt MOV #0, T0 $C$L21: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 396,column 1,is_stmt AADD #3, SP .dwcfi cfa_offset, 1 $C$DW$37 .dwtag DW_TAG_TI_branch .dwattr $C$DW$37, DW_AT_low_pc(0x00) .dwattr $C$DW$37, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$33, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$33, DW_AT_TI_end_line(0x18c) .dwattr $C$DW$33, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$33 .sect ".text" .align 4 .global _WDTIM_config $C$DW$38 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_config") .dwattr $C$DW$38, DW_AT_low_pc(_WDTIM_config) .dwattr $C$DW$38, DW_AT_high_pc(0x00) .dwattr $C$DW$38, DW_AT_TI_symbol_name("_WDTIM_config") .dwattr $C$DW$38, DW_AT_external .dwattr $C$DW$38, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$38, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$38, DW_AT_TI_begin_line(0x1b6) .dwattr $C$DW$38, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$38, DW_AT_TI_max_frame_size(0x06) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 440,column 1,is_stmt,address _WDTIM_config .dwfde $C$DW$CIE, _WDTIM_config $C$DW$39 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$39, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$39, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$39, DW_AT_location[DW_OP_reg17] $C$DW$40 .dwtag DW_TAG_formal_parameter, DW_AT_name("hwConfig") .dwattr $C$DW$40, DW_AT_TI_symbol_name("_hwConfig") .dwattr $C$DW$40, DW_AT_type(*$C$DW$T$42) .dwattr $C$DW$40, DW_AT_location[DW_OP_reg19] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_config * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,XAR1,AR3,XAR3,SP,TC1,* ;* M40,SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 6 words * ;* (1 return address/alignment) * ;* (5 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_config: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-5, SP .dwcfi cfa_offset, 6 $C$DW$41 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$41, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$41, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$41, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$42 .dwtag DW_TAG_variable, DW_AT_name("hwConfig") .dwattr $C$DW$42, DW_AT_TI_symbol_name("_hwConfig") .dwattr $C$DW$42, DW_AT_type(*$C$DW$T$42) .dwattr $C$DW$42, DW_AT_location[DW_OP_bregx 0x24 2] $C$DW$43 .dwtag DW_TAG_variable, DW_AT_name("regs") .dwattr $C$DW$43, DW_AT_TI_symbol_name("_regs") .dwattr $C$DW$43, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$43, DW_AT_location[DW_OP_bregx 0x24 4] MOV XAR1, dbl(*SP(#2)) MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 443,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |443| CMPU AC1 != AC0, TC1 ; |443| BCC $C$L22,TC1 ; |443| ; branchcc occurs ; |443| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 445,column 3,is_stmt MOV #-5, T0 B $C$L24 ; |445| ; branch occurs ; |445| $C$L22: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 448,column 2,is_stmt MOV dbl(*SP(#2)), XAR3 MOV XAR3, AC0 CMPU AC1 != AC0, TC1 ; |448| BCC $C$L23,TC1 ; |448| ; branchcc occurs ; |448| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 450,column 3,is_stmt MOV #-6, T0 B $C$L24 ; |450| ; branch occurs ; |450| $C$L23: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 453,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV *AR3(short(#1)), AR1 ; |453| MOV AR1, *SP(#4) ; |453| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 456,column 2,is_stmt MOV AR1, AR3 MOV #26214, port(*AR3(short(#4))) ; |456| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 457,column 2,is_stmt MOV *SP(#4), AR3 ; |457| MOV #48059, port(*AR3(short(#4))) ; |457| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 459,column 2,is_stmt MOV dbl(*SP(#2)), XAR3 MOV *AR3, AR1 ; |459| MOV *SP(#4), AR3 ; |459| MOV AR1, port(*AR3(short(#6))) ; |459| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 462,column 2,is_stmt MOV *SP(#4), AR3 ; |462| AMOV #12, T0 MOV #23130, port(*AR3(T0)) ; |462| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 463,column 2,is_stmt MOV *SP(#4), AR3 ; |463| MOV #42405, port(*AR3(T0)) ; |463| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 465,column 2,is_stmt MOV dbl(*SP(#2)), XAR3 MOV *AR3(short(#1)), AR1 ; |465| MOV *SP(#4), AR3 ; |465| AMOV #14, T0 MOV AR1, port(*AR3(T0)) ; |465| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 467,column 2,is_stmt MOV #0, T0 $C$L24: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 468,column 1,is_stmt AADD #5, SP .dwcfi cfa_offset, 1 $C$DW$44 .dwtag DW_TAG_TI_branch .dwattr $C$DW$44, DW_AT_low_pc(0x00) .dwattr $C$DW$44, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$38, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$38, DW_AT_TI_end_line(0x1d4) .dwattr $C$DW$38, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$38 .sect ".text" .align 4 .global _WDTIM_getConfig $C$DW$45 .dwtag DW_TAG_subprogram, DW_AT_name("WDTIM_getConfig") .dwattr $C$DW$45, DW_AT_low_pc(_WDTIM_getConfig) .dwattr $C$DW$45, DW_AT_high_pc(0x00) .dwattr $C$DW$45, DW_AT_TI_symbol_name("_WDTIM_getConfig") .dwattr $C$DW$45, DW_AT_external .dwattr $C$DW$45, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$45, DW_AT_TI_begin_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$45, DW_AT_TI_begin_line(0x1fe) .dwattr $C$DW$45, DW_AT_TI_begin_column(0x0c) .dwattr $C$DW$45, DW_AT_TI_max_frame_size(0x06) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 512,column 1,is_stmt,address _WDTIM_getConfig .dwfde $C$DW$CIE, _WDTIM_getConfig $C$DW$46 .dwtag DW_TAG_formal_parameter, DW_AT_name("hWdt") .dwattr $C$DW$46, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$46, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$46, DW_AT_location[DW_OP_reg17] $C$DW$47 .dwtag DW_TAG_formal_parameter, DW_AT_name("getConfig") .dwattr $C$DW$47, DW_AT_TI_symbol_name("_getConfig") .dwattr $C$DW$47, DW_AT_type(*$C$DW$T$42) .dwattr $C$DW$47, DW_AT_location[DW_OP_reg19] ;******************************************************************************* ;* FUNCTION NAME: WDTIM_getConfig * ;* * ;* Function Uses Regs : AC0,AC0,AC1,AC1,T0,AR0,XAR0,AR1,XAR1,AR2,XAR2,AR3, * ;* XAR3,SP,TC1,M40,SATA,SATD,RDM,FRCT,SMUL * ;* Stack Frame : Compact (No Frame Pointer, w/ debug) * ;* Total Frame Size : 6 words * ;* (1 return address/alignment) * ;* (5 local values) * ;* Min System Stack : 1 word * ;******************************************************************************* _WDTIM_getConfig: .dwcfi cfa_offset, 1 .dwcfi save_reg_to_mem, 91, -1 AADD #-5, SP .dwcfi cfa_offset, 6 $C$DW$48 .dwtag DW_TAG_variable, DW_AT_name("hWdt") .dwattr $C$DW$48, DW_AT_TI_symbol_name("_hWdt") .dwattr $C$DW$48, DW_AT_type(*$C$DW$T$36) .dwattr $C$DW$48, DW_AT_location[DW_OP_bregx 0x24 0] $C$DW$49 .dwtag DW_TAG_variable, DW_AT_name("getConfig") .dwattr $C$DW$49, DW_AT_TI_symbol_name("_getConfig") .dwattr $C$DW$49, DW_AT_type(*$C$DW$T$42) .dwattr $C$DW$49, DW_AT_location[DW_OP_bregx 0x24 2] $C$DW$50 .dwtag DW_TAG_variable, DW_AT_name("regs") .dwattr $C$DW$50, DW_AT_TI_symbol_name("_regs") .dwattr $C$DW$50, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$50, DW_AT_location[DW_OP_bregx 0x24 4] MOV XAR1, dbl(*SP(#2)) MOV XAR0, dbl(*SP(#0)) .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 515,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV XAR3, AC0 || MOV #0, AC1 ; |515| CMPU AC1 != AC0, TC1 ; |515| BCC $C$L25,TC1 ; |515| ; branchcc occurs ; |515| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 517,column 3,is_stmt MOV #-5, T0 B $C$L27 ; |517| ; branch occurs ; |517| $C$L25: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 520,column 2,is_stmt MOV dbl(*SP(#2)), XAR3 MOV XAR3, AC0 CMPU AC1 != AC0, TC1 ; |520| BCC $C$L26,TC1 ; |520| ; branchcc occurs ; |520| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 522,column 3,is_stmt MOV #-6, T0 B $C$L27 ; |522| ; branch occurs ; |522| $C$L26: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 525,column 2,is_stmt MOV dbl(*SP(#0)), XAR3 MOV *AR3(short(#1)), AR1 ; |525| MOV AR1, *SP(#4) ; |525| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 527,column 2,is_stmt MOV AR1, AR3 MOV dbl(*SP(#2)), XAR2 MOV port(*AR3(short(#6))), AR1 ; |527| MOV AR1, *AR2 ; |527| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 528,column 2,is_stmt MOV *SP(#4), AR3 ; |528| AMOV #14, T0 MOV port(*AR3(T0)), AR1 ; |528| MOV dbl(*SP(#2)), XAR3 MOV AR1, *AR3(short(#1)) ; |528| .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 530,column 2,is_stmt MOV #0, T0 $C$L27: .dwpsn file "../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c",line 531,column 1,is_stmt AADD #5, SP .dwcfi cfa_offset, 1 $C$DW$51 .dwtag DW_TAG_TI_branch .dwattr $C$DW$51, DW_AT_low_pc(0x00) .dwattr $C$DW$51, DW_AT_TI_return RET ; return occurs .dwattr $C$DW$45, DW_AT_TI_end_file("../c5535_bsl_revc/ezdsp5535_v1/c55xx_csl/src/csl_wdt.c") .dwattr $C$DW$45, DW_AT_TI_end_line(0x213) .dwattr $C$DW$45, DW_AT_TI_end_column(0x01) .dwendentry .dwendtag $C$DW$45 ;******************************************************************************* ;* TYPE INFORMATION * ;******************************************************************************* $C$DW$T$22 .dwtag DW_TAG_enumeration_type .dwattr $C$DW$T$22, DW_AT_byte_size(0x01) $C$DW$52 .dwtag DW_TAG_enumerator, DW_AT_name("WDT_INST_0"), DW_AT_const_value(0x00) $C$DW$53 .dwtag DW_TAG_enumerator, DW_AT_name("WDT_INST_INVALID"), DW_AT_const_value(0x01) .dwendtag $C$DW$T$22 $C$DW$T$23 .dwtag DW_TAG_typedef, DW_AT_name("WDT_Instance") .dwattr $C$DW$T$23, DW_AT_type(*$C$DW$T$22) .dwattr $C$DW$T$23, DW_AT_language(DW_LANG_C) $C$DW$T$21 .dwtag DW_TAG_structure_type .dwattr $C$DW$T$21, DW_AT_byte_size(0x0f) $C$DW$54 .dwtag DW_TAG_member .dwattr $C$DW$54, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$54, DW_AT_name("WDKCKLK") .dwattr $C$DW$54, DW_AT_TI_symbol_name("_WDKCKLK") .dwattr $C$DW$54, DW_AT_data_member_location[DW_OP_plus_uconst 0x0] .dwattr $C$DW$54, DW_AT_accessibility(DW_ACCESS_public) $C$DW$55 .dwtag DW_TAG_member .dwattr $C$DW$55, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$55, DW_AT_name("RSVD0") .dwattr $C$DW$55, DW_AT_TI_symbol_name("_RSVD0") .dwattr $C$DW$55, DW_AT_data_member_location[DW_OP_plus_uconst 0x1] .dwattr $C$DW$55, DW_AT_accessibility(DW_ACCESS_public) $C$DW$56 .dwtag DW_TAG_member .dwattr $C$DW$56, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$56, DW_AT_name("WDKICK") .dwattr $C$DW$56, DW_AT_TI_symbol_name("_WDKICK") .dwattr $C$DW$56, DW_AT_data_member_location[DW_OP_plus_uconst 0x2] .dwattr $C$DW$56, DW_AT_accessibility(DW_ACCESS_public) $C$DW$57 .dwtag DW_TAG_member .dwattr $C$DW$57, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$57, DW_AT_name("RSVD1") .dwattr $C$DW$57, DW_AT_TI_symbol_name("_RSVD1") .dwattr $C$DW$57, DW_AT_data_member_location[DW_OP_plus_uconst 0x3] .dwattr $C$DW$57, DW_AT_accessibility(DW_ACCESS_public) $C$DW$58 .dwtag DW_TAG_member .dwattr $C$DW$58, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$58, DW_AT_name("WDSVLR") .dwattr $C$DW$58, DW_AT_TI_symbol_name("_WDSVLR") .dwattr $C$DW$58, DW_AT_data_member_location[DW_OP_plus_uconst 0x4] .dwattr $C$DW$58, DW_AT_accessibility(DW_ACCESS_public) $C$DW$59 .dwtag DW_TAG_member .dwattr $C$DW$59, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$59, DW_AT_name("RSVD2") .dwattr $C$DW$59, DW_AT_TI_symbol_name("_RSVD2") .dwattr $C$DW$59, DW_AT_data_member_location[DW_OP_plus_uconst 0x5] .dwattr $C$DW$59, DW_AT_accessibility(DW_ACCESS_public) $C$DW$60 .dwtag DW_TAG_member .dwattr $C$DW$60, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$60, DW_AT_name("WDSVR") .dwattr $C$DW$60, DW_AT_TI_symbol_name("_WDSVR") .dwattr $C$DW$60, DW_AT_data_member_location[DW_OP_plus_uconst 0x6] .dwattr $C$DW$60, DW_AT_accessibility(DW_ACCESS_public) $C$DW$61 .dwtag DW_TAG_member .dwattr $C$DW$61, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$61, DW_AT_name("RSVD3") .dwattr $C$DW$61, DW_AT_TI_symbol_name("_RSVD3") .dwattr $C$DW$61, DW_AT_data_member_location[DW_OP_plus_uconst 0x7] .dwattr $C$DW$61, DW_AT_accessibility(DW_ACCESS_public) $C$DW$62 .dwtag DW_TAG_member .dwattr $C$DW$62, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$62, DW_AT_name("WDENLOK") .dwattr $C$DW$62, DW_AT_TI_symbol_name("_WDENLOK") .dwattr $C$DW$62, DW_AT_data_member_location[DW_OP_plus_uconst 0x8] .dwattr $C$DW$62, DW_AT_accessibility(DW_ACCESS_public) $C$DW$63 .dwtag DW_TAG_member .dwattr $C$DW$63, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$63, DW_AT_name("RSVD4") .dwattr $C$DW$63, DW_AT_TI_symbol_name("_RSVD4") .dwattr $C$DW$63, DW_AT_data_member_location[DW_OP_plus_uconst 0x9] .dwattr $C$DW$63, DW_AT_accessibility(DW_ACCESS_public) $C$DW$64 .dwtag DW_TAG_member .dwattr $C$DW$64, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$64, DW_AT_name("WDEN") .dwattr $C$DW$64, DW_AT_TI_symbol_name("_WDEN") .dwattr $C$DW$64, DW_AT_data_member_location[DW_OP_plus_uconst 0xa] .dwattr $C$DW$64, DW_AT_accessibility(DW_ACCESS_public) $C$DW$65 .dwtag DW_TAG_member .dwattr $C$DW$65, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$65, DW_AT_name("RSVD5") .dwattr $C$DW$65, DW_AT_TI_symbol_name("_RSVD5") .dwattr $C$DW$65, DW_AT_data_member_location[DW_OP_plus_uconst 0xb] .dwattr $C$DW$65, DW_AT_accessibility(DW_ACCESS_public) $C$DW$66 .dwtag DW_TAG_member .dwattr $C$DW$66, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$66, DW_AT_name("WDPSLR") .dwattr $C$DW$66, DW_AT_TI_symbol_name("_WDPSLR") .dwattr $C$DW$66, DW_AT_data_member_location[DW_OP_plus_uconst 0xc] .dwattr $C$DW$66, DW_AT_accessibility(DW_ACCESS_public) $C$DW$67 .dwtag DW_TAG_member .dwattr $C$DW$67, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$67, DW_AT_name("RSVD6") .dwattr $C$DW$67, DW_AT_TI_symbol_name("_RSVD6") .dwattr $C$DW$67, DW_AT_data_member_location[DW_OP_plus_uconst 0xd] .dwattr $C$DW$67, DW_AT_accessibility(DW_ACCESS_public) $C$DW$68 .dwtag DW_TAG_member .dwattr $C$DW$68, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$68, DW_AT_name("WDPS") .dwattr $C$DW$68, DW_AT_TI_symbol_name("_WDPS") .dwattr $C$DW$68, DW_AT_data_member_location[DW_OP_plus_uconst 0xe] .dwattr $C$DW$68, DW_AT_accessibility(DW_ACCESS_public) .dwendtag $C$DW$T$21 $C$DW$T$24 .dwtag DW_TAG_typedef, DW_AT_name("CSL_WdtRegs") .dwattr $C$DW$T$24, DW_AT_type(*$C$DW$T$21) .dwattr $C$DW$T$24, DW_AT_language(DW_LANG_C) $C$DW$69 .dwtag DW_TAG_TI_far_type .dwattr $C$DW$69, DW_AT_type(*$C$DW$T$24) $C$DW$70 .dwtag DW_TAG_TI_ioport_type .dwattr $C$DW$70, DW_AT_type(*$C$DW$69) $C$DW$T$25 .dwtag DW_TAG_volatile_type .dwattr $C$DW$T$25, DW_AT_type(*$C$DW$70) $C$DW$T$26 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$26, DW_AT_type(*$C$DW$T$25) .dwattr $C$DW$T$26, DW_AT_address_class(0x10) $C$DW$T$27 .dwtag DW_TAG_typedef, DW_AT_name("CSL_WdtRegsOvly") .dwattr $C$DW$T$27, DW_AT_type(*$C$DW$T$26) .dwattr $C$DW$T$27, DW_AT_language(DW_LANG_C) $C$DW$T$28 .dwtag DW_TAG_structure_type .dwattr $C$DW$T$28, DW_AT_byte_size(0x02) $C$DW$71 .dwtag DW_TAG_member .dwattr $C$DW$71, DW_AT_type(*$C$DW$T$23) .dwattr $C$DW$71, DW_AT_name("wdtInstance") .dwattr $C$DW$71, DW_AT_TI_symbol_name("_wdtInstance") .dwattr $C$DW$71, DW_AT_data_member_location[DW_OP_plus_uconst 0x0] .dwattr $C$DW$71, DW_AT_accessibility(DW_ACCESS_public) $C$DW$72 .dwtag DW_TAG_member .dwattr $C$DW$72, DW_AT_type(*$C$DW$T$27) .dwattr $C$DW$72, DW_AT_name("hwRegs") .dwattr $C$DW$72, DW_AT_TI_symbol_name("_hwRegs") .dwattr $C$DW$72, DW_AT_data_member_location[DW_OP_plus_uconst 0x1] .dwattr $C$DW$72, DW_AT_accessibility(DW_ACCESS_public) .dwendtag $C$DW$T$28 $C$DW$T$34 .dwtag DW_TAG_typedef, DW_AT_name("CSL_WdtObj") .dwattr $C$DW$T$34, DW_AT_type(*$C$DW$T$28) .dwattr $C$DW$T$34, DW_AT_language(DW_LANG_C) $C$DW$T$35 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$35, DW_AT_type(*$C$DW$T$34) .dwattr $C$DW$T$35, DW_AT_address_class(0x17) $C$DW$T$36 .dwtag DW_TAG_typedef, DW_AT_name("CSL_WdtHandle") .dwattr $C$DW$T$36, DW_AT_type(*$C$DW$T$35) .dwattr $C$DW$T$36, DW_AT_language(DW_LANG_C) $C$DW$T$29 .dwtag DW_TAG_structure_type .dwattr $C$DW$T$29, DW_AT_byte_size(0x02) $C$DW$73 .dwtag DW_TAG_member .dwattr $C$DW$73, DW_AT_type(*$C$DW$T$19) .dwattr $C$DW$73, DW_AT_name("counter") .dwattr $C$DW$73, DW_AT_TI_symbol_name("_counter") .dwattr $C$DW$73, DW_AT_data_member_location[DW_OP_plus_uconst 0x0] .dwattr $C$DW$73, DW_AT_accessibility(DW_ACCESS_public) $C$DW$74 .dwtag DW_TAG_member .dwattr $C$DW$74, DW_AT_type(*$C$DW$T$19) .dwattr $C$DW$74, DW_AT_name("prescale") .dwattr $C$DW$74, DW_AT_TI_symbol_name("_prescale") .dwattr $C$DW$74, DW_AT_data_member_location[DW_OP_plus_uconst 0x1] .dwattr $C$DW$74, DW_AT_accessibility(DW_ACCESS_public) .dwendtag $C$DW$T$29 $C$DW$T$41 .dwtag DW_TAG_typedef, DW_AT_name("WDTIM_Config") .dwattr $C$DW$T$41, DW_AT_type(*$C$DW$T$29) .dwattr $C$DW$T$41, DW_AT_language(DW_LANG_C) $C$DW$T$42 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$42, DW_AT_type(*$C$DW$T$41) .dwattr $C$DW$T$42, DW_AT_address_class(0x17) $C$DW$T$33 .dwtag DW_TAG_structure_type .dwattr $C$DW$T$33, DW_AT_byte_size(0x48) $C$DW$75 .dwtag DW_TAG_member .dwattr $C$DW$75, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$75, DW_AT_name("EBSR") .dwattr $C$DW$75, DW_AT_TI_symbol_name("_EBSR") .dwattr $C$DW$75, DW_AT_data_member_location[DW_OP_plus_uconst 0x0] .dwattr $C$DW$75, DW_AT_accessibility(DW_ACCESS_public) $C$DW$76 .dwtag DW_TAG_member .dwattr $C$DW$76, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$76, DW_AT_name("RSVD0") .dwattr $C$DW$76, DW_AT_TI_symbol_name("_RSVD0") .dwattr $C$DW$76, DW_AT_data_member_location[DW_OP_plus_uconst 0x1] .dwattr $C$DW$76, DW_AT_accessibility(DW_ACCESS_public) $C$DW$77 .dwtag DW_TAG_member .dwattr $C$DW$77, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$77, DW_AT_name("PCGCR1") .dwattr $C$DW$77, DW_AT_TI_symbol_name("_PCGCR1") .dwattr $C$DW$77, DW_AT_data_member_location[DW_OP_plus_uconst 0x2] .dwattr $C$DW$77, DW_AT_accessibility(DW_ACCESS_public) $C$DW$78 .dwtag DW_TAG_member .dwattr $C$DW$78, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$78, DW_AT_name("PCGCR2") .dwattr $C$DW$78, DW_AT_TI_symbol_name("_PCGCR2") .dwattr $C$DW$78, DW_AT_data_member_location[DW_OP_plus_uconst 0x3] .dwattr $C$DW$78, DW_AT_accessibility(DW_ACCESS_public) $C$DW$79 .dwtag DW_TAG_member .dwattr $C$DW$79, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$79, DW_AT_name("PSRCR") .dwattr $C$DW$79, DW_AT_TI_symbol_name("_PSRCR") .dwattr $C$DW$79, DW_AT_data_member_location[DW_OP_plus_uconst 0x4] .dwattr $C$DW$79, DW_AT_accessibility(DW_ACCESS_public) $C$DW$80 .dwtag DW_TAG_member .dwattr $C$DW$80, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$80, DW_AT_name("PRCR") .dwattr $C$DW$80, DW_AT_TI_symbol_name("_PRCR") .dwattr $C$DW$80, DW_AT_data_member_location[DW_OP_plus_uconst 0x5] .dwattr $C$DW$80, DW_AT_accessibility(DW_ACCESS_public) $C$DW$81 .dwtag DW_TAG_member .dwattr $C$DW$81, DW_AT_type(*$C$DW$T$30) .dwattr $C$DW$81, DW_AT_name("RSVD1") .dwattr $C$DW$81, DW_AT_TI_symbol_name("_RSVD1") .dwattr $C$DW$81, DW_AT_data_member_location[DW_OP_plus_uconst 0x6] .dwattr $C$DW$81, DW_AT_accessibility(DW_ACCESS_public) $C$DW$82 .dwtag DW_TAG_member .dwattr $C$DW$82, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$82, DW_AT_name("TIAFR") .dwattr $C$DW$82, DW_AT_TI_symbol_name("_TIAFR") .dwattr $C$DW$82, DW_AT_data_member_location[DW_OP_plus_uconst 0x14] .dwattr $C$DW$82, DW_AT_accessibility(DW_ACCESS_public) $C$DW$83 .dwtag DW_TAG_member .dwattr $C$DW$83, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$83, DW_AT_name("RSVD2") .dwattr $C$DW$83, DW_AT_TI_symbol_name("_RSVD2") .dwattr $C$DW$83, DW_AT_data_member_location[DW_OP_plus_uconst 0x15] .dwattr $C$DW$83, DW_AT_accessibility(DW_ACCESS_public) $C$DW$84 .dwtag DW_TAG_member .dwattr $C$DW$84, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$84, DW_AT_name("ODSCR") .dwattr $C$DW$84, DW_AT_TI_symbol_name("_ODSCR") .dwattr $C$DW$84, DW_AT_data_member_location[DW_OP_plus_uconst 0x16] .dwattr $C$DW$84, DW_AT_accessibility(DW_ACCESS_public) $C$DW$85 .dwtag DW_TAG_member .dwattr $C$DW$85, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$85, DW_AT_name("PDINHIBR1") .dwattr $C$DW$85, DW_AT_TI_symbol_name("_PDINHIBR1") .dwattr $C$DW$85, DW_AT_data_member_location[DW_OP_plus_uconst 0x17] .dwattr $C$DW$85, DW_AT_accessibility(DW_ACCESS_public) $C$DW$86 .dwtag DW_TAG_member .dwattr $C$DW$86, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$86, DW_AT_name("PDINHIBR2") .dwattr $C$DW$86, DW_AT_TI_symbol_name("_PDINHIBR2") .dwattr $C$DW$86, DW_AT_data_member_location[DW_OP_plus_uconst 0x18] .dwattr $C$DW$86, DW_AT_accessibility(DW_ACCESS_public) $C$DW$87 .dwtag DW_TAG_member .dwattr $C$DW$87, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$87, DW_AT_name("PDINHIBR3") .dwattr $C$DW$87, DW_AT_TI_symbol_name("_PDINHIBR3") .dwattr $C$DW$87, DW_AT_data_member_location[DW_OP_plus_uconst 0x19] .dwattr $C$DW$87, DW_AT_accessibility(DW_ACCESS_public) $C$DW$88 .dwtag DW_TAG_member .dwattr $C$DW$88, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$88, DW_AT_name("DMA0CESR1") .dwattr $C$DW$88, DW_AT_TI_symbol_name("_DMA0CESR1") .dwattr $C$DW$88, DW_AT_data_member_location[DW_OP_plus_uconst 0x1a] .dwattr $C$DW$88, DW_AT_accessibility(DW_ACCESS_public) $C$DW$89 .dwtag DW_TAG_member .dwattr $C$DW$89, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$89, DW_AT_name("DMA0CESR2") .dwattr $C$DW$89, DW_AT_TI_symbol_name("_DMA0CESR2") .dwattr $C$DW$89, DW_AT_data_member_location[DW_OP_plus_uconst 0x1b] .dwattr $C$DW$89, DW_AT_accessibility(DW_ACCESS_public) $C$DW$90 .dwtag DW_TAG_member .dwattr $C$DW$90, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$90, DW_AT_name("DMA1CESR1") .dwattr $C$DW$90, DW_AT_TI_symbol_name("_DMA1CESR1") .dwattr $C$DW$90, DW_AT_data_member_location[DW_OP_plus_uconst 0x1c] .dwattr $C$DW$90, DW_AT_accessibility(DW_ACCESS_public) $C$DW$91 .dwtag DW_TAG_member .dwattr $C$DW$91, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$91, DW_AT_name("DMA1CESR2") .dwattr $C$DW$91, DW_AT_TI_symbol_name("_DMA1CESR2") .dwattr $C$DW$91, DW_AT_data_member_location[DW_OP_plus_uconst 0x1d] .dwattr $C$DW$91, DW_AT_accessibility(DW_ACCESS_public) $C$DW$92 .dwtag DW_TAG_member .dwattr $C$DW$92, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$92, DW_AT_name("SDRAMCCR") .dwattr $C$DW$92, DW_AT_TI_symbol_name("_SDRAMCCR") .dwattr $C$DW$92, DW_AT_data_member_location[DW_OP_plus_uconst 0x1e] .dwattr $C$DW$92, DW_AT_accessibility(DW_ACCESS_public) $C$DW$93 .dwtag DW_TAG_member .dwattr $C$DW$93, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$93, DW_AT_name("CCR2") .dwattr $C$DW$93, DW_AT_TI_symbol_name("_CCR2") .dwattr $C$DW$93, DW_AT_data_member_location[DW_OP_plus_uconst 0x1f] .dwattr $C$DW$93, DW_AT_accessibility(DW_ACCESS_public) $C$DW$94 .dwtag DW_TAG_member .dwattr $C$DW$94, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$94, DW_AT_name("CGCR1") .dwattr $C$DW$94, DW_AT_TI_symbol_name("_CGCR1") .dwattr $C$DW$94, DW_AT_data_member_location[DW_OP_plus_uconst 0x20] .dwattr $C$DW$94, DW_AT_accessibility(DW_ACCESS_public) $C$DW$95 .dwtag DW_TAG_member .dwattr $C$DW$95, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$95, DW_AT_name("CGICR") .dwattr $C$DW$95, DW_AT_TI_symbol_name("_CGICR") .dwattr $C$DW$95, DW_AT_data_member_location[DW_OP_plus_uconst 0x21] .dwattr $C$DW$95, DW_AT_accessibility(DW_ACCESS_public) $C$DW$96 .dwtag DW_TAG_member .dwattr $C$DW$96, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$96, DW_AT_name("CGCR2") .dwattr $C$DW$96, DW_AT_TI_symbol_name("_CGCR2") .dwattr $C$DW$96, DW_AT_data_member_location[DW_OP_plus_uconst 0x22] .dwattr $C$DW$96, DW_AT_accessibility(DW_ACCESS_public) $C$DW$97 .dwtag DW_TAG_member .dwattr $C$DW$97, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$97, DW_AT_name("CGOCR") .dwattr $C$DW$97, DW_AT_TI_symbol_name("_CGOCR") .dwattr $C$DW$97, DW_AT_data_member_location[DW_OP_plus_uconst 0x23] .dwattr $C$DW$97, DW_AT_accessibility(DW_ACCESS_public) $C$DW$98 .dwtag DW_TAG_member .dwattr $C$DW$98, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$98, DW_AT_name("CCSSR") .dwattr $C$DW$98, DW_AT_TI_symbol_name("_CCSSR") .dwattr $C$DW$98, DW_AT_data_member_location[DW_OP_plus_uconst 0x24] .dwattr $C$DW$98, DW_AT_accessibility(DW_ACCESS_public) $C$DW$99 .dwtag DW_TAG_member .dwattr $C$DW$99, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$99, DW_AT_name("RSVD3") .dwattr $C$DW$99, DW_AT_TI_symbol_name("_RSVD3") .dwattr $C$DW$99, DW_AT_data_member_location[DW_OP_plus_uconst 0x25] .dwattr $C$DW$99, DW_AT_accessibility(DW_ACCESS_public) $C$DW$100 .dwtag DW_TAG_member .dwattr $C$DW$100, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$100, DW_AT_name("ECDR") .dwattr $C$DW$100, DW_AT_TI_symbol_name("_ECDR") .dwattr $C$DW$100, DW_AT_data_member_location[DW_OP_plus_uconst 0x26] .dwattr $C$DW$100, DW_AT_accessibility(DW_ACCESS_public) $C$DW$101 .dwtag DW_TAG_member .dwattr $C$DW$101, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$101, DW_AT_name("RSVD4") .dwattr $C$DW$101, DW_AT_TI_symbol_name("_RSVD4") .dwattr $C$DW$101, DW_AT_data_member_location[DW_OP_plus_uconst 0x27] .dwattr $C$DW$101, DW_AT_accessibility(DW_ACCESS_public) $C$DW$102 .dwtag DW_TAG_member .dwattr $C$DW$102, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$102, DW_AT_name("RAMSLPMDCNTLR1") .dwattr $C$DW$102, DW_AT_TI_symbol_name("_RAMSLPMDCNTLR1") .dwattr $C$DW$102, DW_AT_data_member_location[DW_OP_plus_uconst 0x28] .dwattr $C$DW$102, DW_AT_accessibility(DW_ACCESS_public) $C$DW$103 .dwtag DW_TAG_member .dwattr $C$DW$103, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$103, DW_AT_name("RSVD5") .dwattr $C$DW$103, DW_AT_TI_symbol_name("_RSVD5") .dwattr $C$DW$103, DW_AT_data_member_location[DW_OP_plus_uconst 0x29] .dwattr $C$DW$103, DW_AT_accessibility(DW_ACCESS_public) $C$DW$104 .dwtag DW_TAG_member .dwattr $C$DW$104, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$104, DW_AT_name("RAMSLPMDCNTLR2") .dwattr $C$DW$104, DW_AT_TI_symbol_name("_RAMSLPMDCNTLR2") .dwattr $C$DW$104, DW_AT_data_member_location[DW_OP_plus_uconst 0x2a] .dwattr $C$DW$104, DW_AT_accessibility(DW_ACCESS_public) $C$DW$105 .dwtag DW_TAG_member .dwattr $C$DW$105, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$105, DW_AT_name("RAMSLPMDCNTLR3") .dwattr $C$DW$105, DW_AT_TI_symbol_name("_RAMSLPMDCNTLR3") .dwattr $C$DW$105, DW_AT_data_member_location[DW_OP_plus_uconst 0x2b] .dwattr $C$DW$105, DW_AT_accessibility(DW_ACCESS_public) $C$DW$106 .dwtag DW_TAG_member .dwattr $C$DW$106, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$106, DW_AT_name("RAMSLPMDCNTLR4") .dwattr $C$DW$106, DW_AT_TI_symbol_name("_RAMSLPMDCNTLR4") .dwattr $C$DW$106, DW_AT_data_member_location[DW_OP_plus_uconst 0x2c] .dwattr $C$DW$106, DW_AT_accessibility(DW_ACCESS_public) $C$DW$107 .dwtag DW_TAG_member .dwattr $C$DW$107, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$107, DW_AT_name("RAMSLPMDCNTLR5") .dwattr $C$DW$107, DW_AT_TI_symbol_name("_RAMSLPMDCNTLR5") .dwattr $C$DW$107, DW_AT_data_member_location[DW_OP_plus_uconst 0x2d] .dwattr $C$DW$107, DW_AT_accessibility(DW_ACCESS_public) $C$DW$108 .dwtag DW_TAG_member .dwattr $C$DW$108, DW_AT_type(*$C$DW$T$31) .dwattr $C$DW$108, DW_AT_name("RSVD6") .dwattr $C$DW$108, DW_AT_TI_symbol_name("_RSVD6") .dwattr $C$DW$108, DW_AT_data_member_location[DW_OP_plus_uconst 0x2e] .dwattr $C$DW$108, DW_AT_accessibility(DW_ACCESS_public) $C$DW$109 .dwtag DW_TAG_member .dwattr $C$DW$109, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$109, DW_AT_name("DMAIFR") .dwattr $C$DW$109, DW_AT_TI_symbol_name("_DMAIFR") .dwattr $C$DW$109, DW_AT_data_member_location[DW_OP_plus_uconst 0x30] .dwattr $C$DW$109, DW_AT_accessibility(DW_ACCESS_public) $C$DW$110 .dwtag DW_TAG_member .dwattr $C$DW$110, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$110, DW_AT_name("DMAIER") .dwattr $C$DW$110, DW_AT_TI_symbol_name("_DMAIER") .dwattr $C$DW$110, DW_AT_data_member_location[DW_OP_plus_uconst 0x31] .dwattr $C$DW$110, DW_AT_accessibility(DW_ACCESS_public) $C$DW$111 .dwtag DW_TAG_member .dwattr $C$DW$111, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$111, DW_AT_name("USBSCR") .dwattr $C$DW$111, DW_AT_TI_symbol_name("_USBSCR") .dwattr $C$DW$111, DW_AT_data_member_location[DW_OP_plus_uconst 0x32] .dwattr $C$DW$111, DW_AT_accessibility(DW_ACCESS_public) $C$DW$112 .dwtag DW_TAG_member .dwattr $C$DW$112, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$112, DW_AT_name("ESCR") .dwattr $C$DW$112, DW_AT_TI_symbol_name("_ESCR") .dwattr $C$DW$112, DW_AT_data_member_location[DW_OP_plus_uconst 0x33] .dwattr $C$DW$112, DW_AT_accessibility(DW_ACCESS_public) $C$DW$113 .dwtag DW_TAG_member .dwattr $C$DW$113, DW_AT_type(*$C$DW$T$31) .dwattr $C$DW$113, DW_AT_name("RSVD7") .dwattr $C$DW$113, DW_AT_TI_symbol_name("_RSVD7") .dwattr $C$DW$113, DW_AT_data_member_location[DW_OP_plus_uconst 0x34] .dwattr $C$DW$113, DW_AT_accessibility(DW_ACCESS_public) $C$DW$114 .dwtag DW_TAG_member .dwattr $C$DW$114, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$114, DW_AT_name("DMA2CESR1") .dwattr $C$DW$114, DW_AT_TI_symbol_name("_DMA2CESR1") .dwattr $C$DW$114, DW_AT_data_member_location[DW_OP_plus_uconst 0x36] .dwattr $C$DW$114, DW_AT_accessibility(DW_ACCESS_public) $C$DW$115 .dwtag DW_TAG_member .dwattr $C$DW$115, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$115, DW_AT_name("DMA2CESR2") .dwattr $C$DW$115, DW_AT_TI_symbol_name("_DMA2CESR2") .dwattr $C$DW$115, DW_AT_data_member_location[DW_OP_plus_uconst 0x37] .dwattr $C$DW$115, DW_AT_accessibility(DW_ACCESS_public) $C$DW$116 .dwtag DW_TAG_member .dwattr $C$DW$116, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$116, DW_AT_name("DMA3CESR1") .dwattr $C$DW$116, DW_AT_TI_symbol_name("_DMA3CESR1") .dwattr $C$DW$116, DW_AT_data_member_location[DW_OP_plus_uconst 0x38] .dwattr $C$DW$116, DW_AT_accessibility(DW_ACCESS_public) $C$DW$117 .dwtag DW_TAG_member .dwattr $C$DW$117, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$117, DW_AT_name("DMA3CESR2") .dwattr $C$DW$117, DW_AT_TI_symbol_name("_DMA3CESR2") .dwattr $C$DW$117, DW_AT_data_member_location[DW_OP_plus_uconst 0x39] .dwattr $C$DW$117, DW_AT_accessibility(DW_ACCESS_public) $C$DW$118 .dwtag DW_TAG_member .dwattr $C$DW$118, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$118, DW_AT_name("CLKSTOP") .dwattr $C$DW$118, DW_AT_TI_symbol_name("_CLKSTOP") .dwattr $C$DW$118, DW_AT_data_member_location[DW_OP_plus_uconst 0x3a] .dwattr $C$DW$118, DW_AT_accessibility(DW_ACCESS_public) $C$DW$119 .dwtag DW_TAG_member .dwattr $C$DW$119, DW_AT_type(*$C$DW$T$32) .dwattr $C$DW$119, DW_AT_name("RSVD8") .dwattr $C$DW$119, DW_AT_TI_symbol_name("_RSVD8") .dwattr $C$DW$119, DW_AT_data_member_location[DW_OP_plus_uconst 0x3b] .dwattr $C$DW$119, DW_AT_accessibility(DW_ACCESS_public) $C$DW$120 .dwtag DW_TAG_member .dwattr $C$DW$120, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$120, DW_AT_name("DIEIDR0") .dwattr $C$DW$120, DW_AT_TI_symbol_name("_DIEIDR0") .dwattr $C$DW$120, DW_AT_data_member_location[DW_OP_plus_uconst 0x40] .dwattr $C$DW$120, DW_AT_accessibility(DW_ACCESS_public) $C$DW$121 .dwtag DW_TAG_member .dwattr $C$DW$121, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$121, DW_AT_name("DIEIDR1") .dwattr $C$DW$121, DW_AT_TI_symbol_name("_DIEIDR1") .dwattr $C$DW$121, DW_AT_data_member_location[DW_OP_plus_uconst 0x41] .dwattr $C$DW$121, DW_AT_accessibility(DW_ACCESS_public) $C$DW$122 .dwtag DW_TAG_member .dwattr $C$DW$122, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$122, DW_AT_name("DIEIDR2") .dwattr $C$DW$122, DW_AT_TI_symbol_name("_DIEIDR2") .dwattr $C$DW$122, DW_AT_data_member_location[DW_OP_plus_uconst 0x42] .dwattr $C$DW$122, DW_AT_accessibility(DW_ACCESS_public) $C$DW$123 .dwtag DW_TAG_member .dwattr $C$DW$123, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$123, DW_AT_name("DIEIDR3") .dwattr $C$DW$123, DW_AT_TI_symbol_name("_DIEIDR3") .dwattr $C$DW$123, DW_AT_data_member_location[DW_OP_plus_uconst 0x43] .dwattr $C$DW$123, DW_AT_accessibility(DW_ACCESS_public) $C$DW$124 .dwtag DW_TAG_member .dwattr $C$DW$124, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$124, DW_AT_name("DIEIDR4") .dwattr $C$DW$124, DW_AT_TI_symbol_name("_DIEIDR4") .dwattr $C$DW$124, DW_AT_data_member_location[DW_OP_plus_uconst 0x44] .dwattr $C$DW$124, DW_AT_accessibility(DW_ACCESS_public) $C$DW$125 .dwtag DW_TAG_member .dwattr $C$DW$125, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$125, DW_AT_name("DIEIDR5") .dwattr $C$DW$125, DW_AT_TI_symbol_name("_DIEIDR5") .dwattr $C$DW$125, DW_AT_data_member_location[DW_OP_plus_uconst 0x45] .dwattr $C$DW$125, DW_AT_accessibility(DW_ACCESS_public) $C$DW$126 .dwtag DW_TAG_member .dwattr $C$DW$126, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$126, DW_AT_name("DIEIDR6") .dwattr $C$DW$126, DW_AT_TI_symbol_name("_DIEIDR6") .dwattr $C$DW$126, DW_AT_data_member_location[DW_OP_plus_uconst 0x46] .dwattr $C$DW$126, DW_AT_accessibility(DW_ACCESS_public) $C$DW$127 .dwtag DW_TAG_member .dwattr $C$DW$127, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$127, DW_AT_name("DIEIDR7") .dwattr $C$DW$127, DW_AT_TI_symbol_name("_DIEIDR7") .dwattr $C$DW$127, DW_AT_data_member_location[DW_OP_plus_uconst 0x47] .dwattr $C$DW$127, DW_AT_accessibility(DW_ACCESS_public) .dwendtag $C$DW$T$33 $C$DW$T$43 .dwtag DW_TAG_typedef, DW_AT_name("CSL_SysRegs") .dwattr $C$DW$T$43, DW_AT_type(*$C$DW$T$33) .dwattr $C$DW$T$43, DW_AT_language(DW_LANG_C) $C$DW$128 .dwtag DW_TAG_TI_far_type .dwattr $C$DW$128, DW_AT_type(*$C$DW$T$43) $C$DW$129 .dwtag DW_TAG_TI_ioport_type .dwattr $C$DW$129, DW_AT_type(*$C$DW$128) $C$DW$T$44 .dwtag DW_TAG_volatile_type .dwattr $C$DW$T$44, DW_AT_type(*$C$DW$129) $C$DW$T$45 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$45, DW_AT_type(*$C$DW$T$44) .dwattr $C$DW$T$45, DW_AT_address_class(0x10) $C$DW$T$4 .dwtag DW_TAG_base_type .dwattr $C$DW$T$4, DW_AT_encoding(DW_ATE_boolean) .dwattr $C$DW$T$4, DW_AT_name("bool") .dwattr $C$DW$T$4, DW_AT_byte_size(0x01) $C$DW$T$5 .dwtag DW_TAG_base_type .dwattr $C$DW$T$5, DW_AT_encoding(DW_ATE_signed_char) .dwattr $C$DW$T$5, DW_AT_name("signed char") .dwattr $C$DW$T$5, DW_AT_byte_size(0x01) $C$DW$T$6 .dwtag DW_TAG_base_type .dwattr $C$DW$T$6, DW_AT_encoding(DW_ATE_unsigned_char) .dwattr $C$DW$T$6, DW_AT_name("unsigned char") .dwattr $C$DW$T$6, DW_AT_byte_size(0x01) $C$DW$T$7 .dwtag DW_TAG_base_type .dwattr $C$DW$T$7, DW_AT_encoding(DW_ATE_signed_char) .dwattr $C$DW$T$7, DW_AT_name("wchar_t") .dwattr $C$DW$T$7, DW_AT_byte_size(0x01) $C$DW$T$8 .dwtag DW_TAG_base_type .dwattr $C$DW$T$8, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$8, DW_AT_name("short") .dwattr $C$DW$T$8, DW_AT_byte_size(0x01) $C$DW$T$37 .dwtag DW_TAG_typedef, DW_AT_name("Int16") .dwattr $C$DW$T$37, DW_AT_type(*$C$DW$T$8) .dwattr $C$DW$T$37, DW_AT_language(DW_LANG_C) $C$DW$T$38 .dwtag DW_TAG_typedef, DW_AT_name("CSL_Status") .dwattr $C$DW$T$38, DW_AT_type(*$C$DW$T$37) .dwattr $C$DW$T$38, DW_AT_language(DW_LANG_C) $C$DW$T$39 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$39, DW_AT_type(*$C$DW$T$38) .dwattr $C$DW$T$39, DW_AT_address_class(0x17) $C$DW$T$9 .dwtag DW_TAG_base_type .dwattr $C$DW$T$9, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$9, DW_AT_name("unsigned short") .dwattr $C$DW$T$9, DW_AT_byte_size(0x01) $C$DW$T$19 .dwtag DW_TAG_typedef, DW_AT_name("Uint16") .dwattr $C$DW$T$19, DW_AT_type(*$C$DW$T$9) .dwattr $C$DW$T$19, DW_AT_language(DW_LANG_C) $C$DW$130 .dwtag DW_TAG_TI_far_type .dwattr $C$DW$130, DW_AT_type(*$C$DW$T$19) $C$DW$T$20 .dwtag DW_TAG_volatile_type .dwattr $C$DW$T$20, DW_AT_type(*$C$DW$130) $C$DW$T$30 .dwtag DW_TAG_array_type .dwattr $C$DW$T$30, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$T$30, DW_AT_language(DW_LANG_C) .dwattr $C$DW$T$30, DW_AT_byte_size(0x0e) $C$DW$131 .dwtag DW_TAG_subrange_type .dwattr $C$DW$131, DW_AT_upper_bound(0x0d) .dwendtag $C$DW$T$30 $C$DW$T$31 .dwtag DW_TAG_array_type .dwattr $C$DW$T$31, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$T$31, DW_AT_language(DW_LANG_C) .dwattr $C$DW$T$31, DW_AT_byte_size(0x02) $C$DW$132 .dwtag DW_TAG_subrange_type .dwattr $C$DW$132, DW_AT_upper_bound(0x01) .dwendtag $C$DW$T$31 $C$DW$T$32 .dwtag DW_TAG_array_type .dwattr $C$DW$T$32, DW_AT_type(*$C$DW$T$20) .dwattr $C$DW$T$32, DW_AT_language(DW_LANG_C) .dwattr $C$DW$T$32, DW_AT_byte_size(0x05) $C$DW$133 .dwtag DW_TAG_subrange_type .dwattr $C$DW$133, DW_AT_upper_bound(0x04) .dwendtag $C$DW$T$32 $C$DW$T$10 .dwtag DW_TAG_base_type .dwattr $C$DW$T$10, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$10, DW_AT_name("int") .dwattr $C$DW$T$10, DW_AT_byte_size(0x01) $C$DW$T$11 .dwtag DW_TAG_base_type .dwattr $C$DW$T$11, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$11, DW_AT_name("unsigned int") .dwattr $C$DW$T$11, DW_AT_byte_size(0x01) $C$DW$T$12 .dwtag DW_TAG_base_type .dwattr $C$DW$T$12, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$12, DW_AT_name("long") .dwattr $C$DW$T$12, DW_AT_byte_size(0x02) $C$DW$T$13 .dwtag DW_TAG_base_type .dwattr $C$DW$T$13, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$13, DW_AT_name("unsigned long") .dwattr $C$DW$T$13, DW_AT_byte_size(0x02) $C$DW$T$47 .dwtag DW_TAG_typedef, DW_AT_name("Uint32") .dwattr $C$DW$T$47, DW_AT_type(*$C$DW$T$13) .dwattr $C$DW$T$47, DW_AT_language(DW_LANG_C) $C$DW$T$48 .dwtag DW_TAG_pointer_type .dwattr $C$DW$T$48, DW_AT_type(*$C$DW$T$47) .dwattr $C$DW$T$48, DW_AT_address_class(0x17) $C$DW$T$14 .dwtag DW_TAG_base_type .dwattr $C$DW$T$14, DW_AT_encoding(DW_ATE_signed) .dwattr $C$DW$T$14, DW_AT_name("long long") .dwattr $C$DW$T$14, DW_AT_byte_size(0x04) .dwattr $C$DW$T$14, DW_AT_bit_size(0x28) .dwattr $C$DW$T$14, DW_AT_bit_offset(0x18) $C$DW$T$15 .dwtag DW_TAG_base_type .dwattr $C$DW$T$15, DW_AT_encoding(DW_ATE_unsigned) .dwattr $C$DW$T$15, DW_AT_name("unsigned long long") .dwattr $C$DW$T$15, DW_AT_byte_size(0x04) .dwattr $C$DW$T$15, DW_AT_bit_size(0x28) .dwattr $C$DW$T$15, DW_AT_bit_offset(0x18) $C$DW$T$16 .dwtag DW_TAG_base_type .dwattr $C$DW$T$16, DW_AT_encoding(DW_ATE_float) .dwattr $C$DW$T$16, DW_AT_name("float") .dwattr $C$DW$T$16, DW_AT_byte_size(0x02) $C$DW$T$17 .dwtag DW_TAG_base_type .dwattr $C$DW$T$17, DW_AT_encoding(DW_ATE_float) .dwattr $C$DW$T$17, DW_AT_name("double") .dwattr $C$DW$T$17, DW_AT_byte_size(0x02) $C$DW$T$18 .dwtag DW_TAG_base_type .dwattr $C$DW$T$18, DW_AT_encoding(DW_ATE_float) .dwattr $C$DW$T$18, DW_AT_name("long double") .dwattr $C$DW$T$18, DW_AT_byte_size(0x02) .dwattr $C$DW$CU, DW_AT_language(DW_LANG_C) ;*************************************************************** ;* DWARF CIE ENTRIES * ;*************************************************************** $C$DW$CIE .dwcie 91 .dwcfi cfa_register, 36 .dwcfi cfa_offset, 0 .dwcfi undefined, 0 .dwcfi undefined, 1 .dwcfi undefined, 2 .dwcfi undefined, 3 .dwcfi undefined, 4 .dwcfi undefined, 5 .dwcfi undefined, 6 .dwcfi undefined, 7 .dwcfi undefined, 8 .dwcfi undefined, 9 .dwcfi undefined, 10 .dwcfi undefined, 11 .dwcfi undefined, 12 .dwcfi undefined, 13 .dwcfi same_value, 14 .dwcfi same_value, 15 .dwcfi undefined, 16 .dwcfi undefined, 17 .dwcfi undefined, 18 .dwcfi undefined, 19 .dwcfi undefined, 20 .dwcfi undefined, 21 .dwcfi undefined, 22 .dwcfi undefined, 23 .dwcfi undefined, 24 .dwcfi undefined, 25 .dwcfi same_value, 26 .dwcfi same_value, 27 .dwcfi same_value, 28 .dwcfi same_value, 29 .dwcfi same_value, 30 .dwcfi same_value, 31 .dwcfi undefined, 32 .dwcfi undefined, 33 .dwcfi undefined, 34 .dwcfi undefined, 35 .dwcfi undefined, 36 .dwcfi undefined, 37 .dwcfi undefined, 38 .dwcfi undefined, 39 .dwcfi undefined, 40 .dwcfi undefined, 41 .dwcfi undefined, 42 .dwcfi undefined, 43 .dwcfi undefined, 44 .dwcfi undefined, 45 .dwcfi undefined, 46 .dwcfi undefined, 47 .dwcfi undefined, 48 .dwcfi undefined, 49 .dwcfi undefined, 50 .dwcfi undefined, 51 .dwcfi undefined, 52 .dwcfi undefined, 53 .dwcfi undefined, 54 .dwcfi undefined, 55 .dwcfi undefined, 56 .dwcfi undefined, 57 .dwcfi undefined, 58 .dwcfi undefined, 59 .dwcfi undefined, 60 .dwcfi undefined, 61 .dwcfi undefined, 62 .dwcfi undefined, 63 .dwcfi undefined, 64 .dwcfi undefined, 65 .dwcfi undefined, 66 .dwcfi undefined, 67 .dwcfi undefined, 68 .dwcfi undefined, 69 .dwcfi undefined, 70 .dwcfi undefined, 71 .dwcfi undefined, 72 .dwcfi undefined, 73 .dwcfi undefined, 74 .dwcfi undefined, 75 .dwcfi undefined, 76 .dwcfi undefined, 77 .dwcfi undefined, 78 .dwcfi undefined, 79 .dwcfi undefined, 80 .dwcfi undefined, 81 .dwcfi undefined, 82 .dwcfi undefined, 83 .dwcfi undefined, 84 .dwcfi undefined, 85 .dwcfi undefined, 86 .dwcfi undefined, 87 .dwcfi undefined, 88 .dwcfi undefined, 89 .dwcfi undefined, 90 .dwcfi undefined, 91 .dwendentry ;*************************************************************** ;* DWARF REGISTER MAP * ;*************************************************************** $C$DW$134 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC0") .dwattr $C$DW$134, DW_AT_location[DW_OP_reg0] $C$DW$135 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC0") .dwattr $C$DW$135, DW_AT_location[DW_OP_reg1] $C$DW$136 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC0_G") .dwattr $C$DW$136, DW_AT_location[DW_OP_reg2] $C$DW$137 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC1") .dwattr $C$DW$137, DW_AT_location[DW_OP_reg3] $C$DW$138 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC1") .dwattr $C$DW$138, DW_AT_location[DW_OP_reg4] $C$DW$139 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC1_G") .dwattr $C$DW$139, DW_AT_location[DW_OP_reg5] $C$DW$140 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC2") .dwattr $C$DW$140, DW_AT_location[DW_OP_reg6] $C$DW$141 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC2") .dwattr $C$DW$141, DW_AT_location[DW_OP_reg7] $C$DW$142 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC2_G") .dwattr $C$DW$142, DW_AT_location[DW_OP_reg8] $C$DW$143 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC3") .dwattr $C$DW$143, DW_AT_location[DW_OP_reg9] $C$DW$144 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC3") .dwattr $C$DW$144, DW_AT_location[DW_OP_reg10] $C$DW$145 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AC3_G") .dwattr $C$DW$145, DW_AT_location[DW_OP_reg11] $C$DW$146 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T0") .dwattr $C$DW$146, DW_AT_location[DW_OP_reg12] $C$DW$147 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T1") .dwattr $C$DW$147, DW_AT_location[DW_OP_reg13] $C$DW$148 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T2") .dwattr $C$DW$148, DW_AT_location[DW_OP_reg14] $C$DW$149 .dwtag DW_TAG_TI_assign_register, DW_AT_name("T3") .dwattr $C$DW$149, DW_AT_location[DW_OP_reg15] $C$DW$150 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR0") .dwattr $C$DW$150, DW_AT_location[DW_OP_reg16] $C$DW$151 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR0") .dwattr $C$DW$151, DW_AT_location[DW_OP_reg17] $C$DW$152 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR1") .dwattr $C$DW$152, DW_AT_location[DW_OP_reg18] $C$DW$153 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR1") .dwattr $C$DW$153, DW_AT_location[DW_OP_reg19] $C$DW$154 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR2") .dwattr $C$DW$154, DW_AT_location[DW_OP_reg20] $C$DW$155 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR2") .dwattr $C$DW$155, DW_AT_location[DW_OP_reg21] $C$DW$156 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR3") .dwattr $C$DW$156, DW_AT_location[DW_OP_reg22] $C$DW$157 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR3") .dwattr $C$DW$157, DW_AT_location[DW_OP_reg23] $C$DW$158 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR4") .dwattr $C$DW$158, DW_AT_location[DW_OP_reg24] $C$DW$159 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR4") .dwattr $C$DW$159, DW_AT_location[DW_OP_reg25] $C$DW$160 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR5") .dwattr $C$DW$160, DW_AT_location[DW_OP_reg26] $C$DW$161 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR5") .dwattr $C$DW$161, DW_AT_location[DW_OP_reg27] $C$DW$162 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR6") .dwattr $C$DW$162, DW_AT_location[DW_OP_reg28] $C$DW$163 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR6") .dwattr $C$DW$163, DW_AT_location[DW_OP_reg29] $C$DW$164 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR7") .dwattr $C$DW$164, DW_AT_location[DW_OP_reg30] $C$DW$165 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XAR7") .dwattr $C$DW$165, DW_AT_location[DW_OP_reg31] $C$DW$166 .dwtag DW_TAG_TI_assign_register, DW_AT_name("FP") .dwattr $C$DW$166, DW_AT_location[DW_OP_regx 0x20] $C$DW$167 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XFP") .dwattr $C$DW$167, DW_AT_location[DW_OP_regx 0x21] $C$DW$168 .dwtag DW_TAG_TI_assign_register, DW_AT_name("PC") .dwattr $C$DW$168, DW_AT_location[DW_OP_regx 0x22] $C$DW$169 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SP") .dwattr $C$DW$169, DW_AT_location[DW_OP_regx 0x23] $C$DW$170 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XSP") .dwattr $C$DW$170, DW_AT_location[DW_OP_regx 0x24] $C$DW$171 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BKC") .dwattr $C$DW$171, DW_AT_location[DW_OP_regx 0x25] $C$DW$172 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BK03") .dwattr $C$DW$172, DW_AT_location[DW_OP_regx 0x26] $C$DW$173 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BK47") .dwattr $C$DW$173, DW_AT_location[DW_OP_regx 0x27] $C$DW$174 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST0") .dwattr $C$DW$174, DW_AT_location[DW_OP_regx 0x28] $C$DW$175 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST1") .dwattr $C$DW$175, DW_AT_location[DW_OP_regx 0x29] $C$DW$176 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST2") .dwattr $C$DW$176, DW_AT_location[DW_OP_regx 0x2a] $C$DW$177 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ST3") .dwattr $C$DW$177, DW_AT_location[DW_OP_regx 0x2b] $C$DW$178 .dwtag DW_TAG_TI_assign_register, DW_AT_name("MDP") .dwattr $C$DW$178, DW_AT_location[DW_OP_regx 0x2c] $C$DW$179 .dwtag DW_TAG_TI_assign_register, DW_AT_name("MDP05") .dwattr $C$DW$179, DW_AT_location[DW_OP_regx 0x2d] $C$DW$180 .dwtag DW_TAG_TI_assign_register, DW_AT_name("MDP67") .dwattr $C$DW$180, DW_AT_location[DW_OP_regx 0x2e] $C$DW$181 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BRC0") .dwattr $C$DW$181, DW_AT_location[DW_OP_regx 0x2f] $C$DW$182 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA0") .dwattr $C$DW$182, DW_AT_location[DW_OP_regx 0x30] $C$DW$183 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA0_H") .dwattr $C$DW$183, DW_AT_location[DW_OP_regx 0x31] $C$DW$184 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA0") .dwattr $C$DW$184, DW_AT_location[DW_OP_regx 0x32] $C$DW$185 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA0_H") .dwattr $C$DW$185, DW_AT_location[DW_OP_regx 0x33] $C$DW$186 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BRS1") .dwattr $C$DW$186, DW_AT_location[DW_OP_regx 0x34] $C$DW$187 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BRC1") .dwattr $C$DW$187, DW_AT_location[DW_OP_regx 0x35] $C$DW$188 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA1") .dwattr $C$DW$188, DW_AT_location[DW_OP_regx 0x36] $C$DW$189 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RSA1_H") .dwattr $C$DW$189, DW_AT_location[DW_OP_regx 0x37] $C$DW$190 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA1") .dwattr $C$DW$190, DW_AT_location[DW_OP_regx 0x38] $C$DW$191 .dwtag DW_TAG_TI_assign_register, DW_AT_name("REA1_H") .dwattr $C$DW$191, DW_AT_location[DW_OP_regx 0x39] $C$DW$192 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CSR") .dwattr $C$DW$192, DW_AT_location[DW_OP_regx 0x3a] $C$DW$193 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RPTC") .dwattr $C$DW$193, DW_AT_location[DW_OP_regx 0x3b] $C$DW$194 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CDP") .dwattr $C$DW$194, DW_AT_location[DW_OP_regx 0x3c] $C$DW$195 .dwtag DW_TAG_TI_assign_register, DW_AT_name("XCDP") .dwattr $C$DW$195, DW_AT_location[DW_OP_regx 0x3d] $C$DW$196 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TRN0") .dwattr $C$DW$196, DW_AT_location[DW_OP_regx 0x3e] $C$DW$197 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TRN1") .dwattr $C$DW$197, DW_AT_location[DW_OP_regx 0x3f] $C$DW$198 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA01") .dwattr $C$DW$198, DW_AT_location[DW_OP_regx 0x40] $C$DW$199 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA23") .dwattr $C$DW$199, DW_AT_location[DW_OP_regx 0x41] $C$DW$200 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA45") .dwattr $C$DW$200, DW_AT_location[DW_OP_regx 0x42] $C$DW$201 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSA67") .dwattr $C$DW$201, DW_AT_location[DW_OP_regx 0x43] $C$DW$202 .dwtag DW_TAG_TI_assign_register, DW_AT_name("BSAC") .dwattr $C$DW$202, DW_AT_location[DW_OP_regx 0x44] $C$DW$203 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CARRY") .dwattr $C$DW$203, DW_AT_location[DW_OP_regx 0x45] $C$DW$204 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TC1") .dwattr $C$DW$204, DW_AT_location[DW_OP_regx 0x46] $C$DW$205 .dwtag DW_TAG_TI_assign_register, DW_AT_name("TC2") .dwattr $C$DW$205, DW_AT_location[DW_OP_regx 0x47] $C$DW$206 .dwtag DW_TAG_TI_assign_register, DW_AT_name("M40") .dwattr $C$DW$206, DW_AT_location[DW_OP_regx 0x48] $C$DW$207 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SXMD") .dwattr $C$DW$207, DW_AT_location[DW_OP_regx 0x49] $C$DW$208 .dwtag DW_TAG_TI_assign_register, DW_AT_name("ARMS") .dwattr $C$DW$208, DW_AT_location[DW_OP_regx 0x4a] $C$DW$209 .dwtag DW_TAG_TI_assign_register, DW_AT_name("C54CM") .dwattr $C$DW$209, DW_AT_location[DW_OP_regx 0x4b] $C$DW$210 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SATA") .dwattr $C$DW$210, DW_AT_location[DW_OP_regx 0x4c] $C$DW$211 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SATD") .dwattr $C$DW$211, DW_AT_location[DW_OP_regx 0x4d] $C$DW$212 .dwtag DW_TAG_TI_assign_register, DW_AT_name("RDM") .dwattr $C$DW$212, DW_AT_location[DW_OP_regx 0x4e] $C$DW$213 .dwtag DW_TAG_TI_assign_register, DW_AT_name("FRCT") .dwattr $C$DW$213, DW_AT_location[DW_OP_regx 0x4f] $C$DW$214 .dwtag DW_TAG_TI_assign_register, DW_AT_name("SMUL") .dwattr $C$DW$214, DW_AT_location[DW_OP_regx 0x50] $C$DW$215 .dwtag DW_TAG_TI_assign_register, DW_AT_name("INTM") .dwattr $C$DW$215, DW_AT_location[DW_OP_regx 0x51] $C$DW$216 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR0LC") .dwattr $C$DW$216, DW_AT_location[DW_OP_regx 0x52] $C$DW$217 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR1LC") .dwattr $C$DW$217, DW_AT_location[DW_OP_regx 0x53] $C$DW$218 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR2LC") .dwattr $C$DW$218, DW_AT_location[DW_OP_regx 0x54] $C$DW$219 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR3LC") .dwattr $C$DW$219, DW_AT_location[DW_OP_regx 0x55] $C$DW$220 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR4LC") .dwattr $C$DW$220, DW_AT_location[DW_OP_regx 0x56] $C$DW$221 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR5LC") .dwattr $C$DW$221, DW_AT_location[DW_OP_regx 0x57] $C$DW$222 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR6LC") .dwattr $C$DW$222, DW_AT_location[DW_OP_regx 0x58] $C$DW$223 .dwtag DW_TAG_TI_assign_register, DW_AT_name("AR7LC") .dwattr $C$DW$223, DW_AT_location[DW_OP_regx 0x59] $C$DW$224 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CDPLC") .dwattr $C$DW$224, DW_AT_location[DW_OP_regx 0x5a] $C$DW$225 .dwtag DW_TAG_TI_assign_register, DW_AT_name("CIE_RETA") .dwattr $C$DW$225, DW_AT_location[DW_OP_regx 0x5b] .dwendtag $C$DW$CU
TITLE NamMgr.asm - Name Table manager ;**************************************************************************** ; Copyright <C> 1985, Microsoft Corporation ;Purpose: ; This module contains the routines necessary to create and manage the ; symbol name table. These routines are: ; ; CopyONamPb ; Copies the ASCII chars of a symbol from mrsCur.tNam.oNam.name ; to [pb]. The length of the string is returned. ; ; CopyONamBd ; Allocates a heap entry for the uninitialized Bd and then ; does a CopyONamPb to Bd.pb. ; ; GetVarNamChar ; Returns a first logical char of name and a flag which ; indicates whether the name starts with 'FN'. ; ; FlagOfONam ; Returns the raw symbol mask of mrsCur.tNam.oNam. This value ; can then be used to determine the various flag settings. ; ; LnOfONam ; If oNam is a line number offset ; THEN AX=mrsCur.tNam.oNam.LnW ; ELSE AX=UNDEFINED ; ; ONamOfPbCb ; Returns the offset of a symbol in mrsCur.tNam. If the symbol ; doesn't exist, then it is added. If a symbol match is found, ; but the case is different, then the new case is used to ; replace the old symbol. ; ; ONamOfPsd ; Returns the offset of a symbol in mrsCur.tNam. If the symbol ; doesn't exist, then it is added. If a symbol match is found, ; but the case is different, then the new case is used to ; replace the old symbol. ; ; ONamOfLn ; Returns the offset of a line number in mrsCur.tNam. If the ; line number doesn't exist, then it is added. ; ; ResetTNamMask ; Resets the all but the selected flag bits in all symbols of ; mrsCur.tNam (the symbol's flags are ANDed with the given ; byte mask). ; ; ResetONamMask ; Resets the maskW selected flag bits of mrsCur.tNam.oNam ; (The symbol's flags are ANDed with the NOT of maskW). ; ; SetONamMask ; Sets the maskW selected flag bits of mrsCur.tNam.oNam ; (The symbol's flags are ORed with maskW). ; ; SetONamSpace ; Sets the 2 "name space" bits of the flags byte to some ; NMSP_ value. Returns 0 if no error, or ER_DD if either of ; those bits were already set. ; ; CheckONamSpace ; Same error checking as SetONamSpace, but doesn't actually ; modify any namespace bits. ; ; TNamInit ; Initializes the symbol table (mrsCur.tNam). ; ; OgNamOfPsd ; Same as ONamOfPsd, but returns an ogNam. ; OgNamOfPbCb ; Same as OgNamOfPbCb, but returns an ogNam. ; CopyOgNamPb ; Same as CopyONamPb, but takes an ogNam instead of an oNam. ; CopyOgNamPbNear ; Same as CopyOgNamPb, but near rather than far interface. ; FpNamOfOgNam ; Given an ogNam, returns a far pointer to the name (in the ; actual table) and the length of the name. ; OgNamOfONam ; Given an oNam for the current module, returns the ogNam ; for this name. ; ONamOfOgNam ; Given an ogNam, returns the oNam for the current module ; for this name. ; CharOfOgNam ; Given an ogNam, returns the first char in the name. ; CbOfOgNam ; Given an ogNam, returns the length of the name. ; BdAppendOgNam ; Given an ogNam and a pBd, appends the name to the end of ; of the bd. ; CmpOgNamIns ; Given two ogNam's, performs a case-insensitive comparison ; of the two names. ; ogNamOfHst ; Same as OgNamOfPbCb, but accepts a hst as input instead of ; a pb and cb. ; hstNamOfOgNam ; Given an ogNam, returns a far pointer to a hst for the name. ; ; IsOgNamOfPbCb ; Given an string, return OgNam of string if it exists, but ; don't add the string if not found in the name table. ; IsONamOfPbCb ; Given an string, return ONam of string if it exists, but ; don't add the string if not found in the name table. ; ; The symbol table is refered to as tNam. It is a large far heap entry (and ; therefore restricted to 64K). The first part of tNam is a table of chain ; pointers that are used to select the chain to be searched. This is actually ; two such tables: the first (and larger one) is for all names except for ; line numbers, while the second is just for line numbers. A hashing function ; is applied to inputs to hash them into a given chain. Unknown symbols are ; added to the end of the appropriate chain. ; ; tNam structure: ; ; |-----------------------| ; | Chain Header Tables | ; |-----------------------| ; | Local variables | ; |-----------------------| ; | symbol chains | ; |-----------------------| ; | unused | ; |-----------------------| ; ; Chain Header Tables: (pointers are NULL if no entries in chain) ; pNameChain0 - first name chain ; pNameChain1 ; pNameChain2 ; . ; . ; pNameChain31 - last name chain ; pNameChain32 - first line number chain ; . ; . ; pNameChain39 - last line number chain ; ; Local Variables: ; CurONamHdr - current tNam 1st char index - used by GetNextONam ; cbUsed - # of bytes allocated to tables & entries ; ; Each element of a symbol chain has the following format: ; ; NextW - ptr to next symbol on chain (NULL if end of chain) ; FlagsB - symbol flag byte ; cbB - # of bytes in the 'name' field ; name - ASCII chars of symbol name (or binary value for line numbers) ; ; Each chain is terminated by a NULL Next. New symbols are added to the ; end of the appropriate chain. A symbol can never be deleted or moved. ; A symbol can't have more than CB_MAX_NAMENTRY chars. Each char in the ; name part of the symbol can be any valid ASCII (0-127) except the ; following: ; <Control Char> < ' > < { > < | > < } > < ~ > <DEL> ; ; Each module name table is limited to 32k. This limitation was imposed ; based on the pcode generated for opAsTypeExp; as of June '87 that's ; the only known reason for the limitation. In the (unlikely) event ; that the 32k limit is ever a problem, this pcode restriction could ; doubtless be removed. ; ; ;**************************************************************************** .xlist NAMMGR_ASM = 1 include version.inc includeOnce architec includeOnce context includeOnce heap includeOnce names includeOnce qbimsgs includeOnce ui includeOnce util .list assumes DS,DATA assumes SS,DATA assumes ES,NOTHING sBegin DATA globalW oRsNam,0 ;[10] used to access appropriate tNam sEnd DATA sBegin CP assumes CS,CP ;*** ;Use_GMrs ;Purpose: ; Added as part of revision [10]. ; ; Set oRsNam to point to the global module so generic routines can be ; used to support the global name table. ; ; NOTE: Not all of the nammgr routines check for a non-zero offset in ; NOTE: oRsNam - - - only those that are currently used in conjunction ; NOTE: with a call to this routine. If you want to use this indirection ; NOTE: mechanism for some nammgr support routine, ensure that it will ; NOTE: access the name table via oRsNam. ;Entry: ; None. ;Exit: ; static oRsNam is an offset to the global name table in the Rs table. ;Preserves: ; AX, BX, DX ;Exceptions: ; none ;*************************************************************************** cProc Use_GMrs,<NEAR,NODATA> cBegin Use_GMrs DbAssertRel grs.GRS_oMrsCur,nz,OMRS_GLOBAL,CP,<Use_GMrs: global mrs is active> sub cx,cx ; assume global mrs is active cmp [grs.GRS_oMrsCur],OMRS_GLOBAL ;[23] is global mrs active? jz Activate_Exit ; brif so mov cx,MRS_bdlNam + OMRS_GLOBAL ;[23] offset in the global mrs ;[23] to the name table. Activate_Exit: mov [oRsNam],cx cEnd Use_GMrs ;*** ;FetchPNam ; Fetch a pointer to desired name table. ; If the static oRsNam is non-zero, it is assumed to contain an ; offset in the Rs table to the desired name table; otherwise, the ; desired name table is assumed to reside in mrsCur. ; ; Added as part of revision [10] to share/consolidate code, and ; to limit access to the mrs to a specific point. ;Purpose: ;Entry: ; none ;Exit: ; es:bx is a pointer to the appropriate bdlNam ;Uses: ; none ;*************************************************************************** cProc FetchPNam,<NEAR,NODATA> cBegin GETRS_SEG es,bx,<SIZE,LOAD> ;[25] NOTE: can trash bx? mov bx,[oRsNam] or bx,bx jz Get_PMrs RS_BASE add,bx jmp short Got_PMrs Get_PMrs: SETSEG_EQ_SS es mov bx,dataOFFSET mrsCur.MRS_bdlNam Got_PMrs: cEnd ;*** ;LnOfONam LnW = LnOfONam ;Purpose: ; If given oNam is a line number offset ; THEN return AX=mrsCur.tNam.oNam.LnW ; ELSE return AX=UNDEFINED ;Register conventions: ; DS - Line# segment ; ES - tNam segment ;Entry: ; oNam on stack ; The following globals are referenced: ; mrsCur.bdlNam => current module's name table ; ;Exit: ; if oNam represents a binary line number, ; AX = line number ; else (oNam represents an alpha name) ; AX = UNDEFINED, DL = 1st letter of name ; ;Uses: ; none ;*************************************************************************** cProc LnOfONam,<PUBLIC,FAR,NODATA> parmW oNam cBegin DbChk ConStatStructs DbChk tNam DbChk oNam,oNam ; sanity check on input oNam GETSEG ES,[mrsCur.MRS_bdlNam_seg],,<LOAD,SIZE> ;[25] mov bx,[oNam] mov ax,ES:NM_NAME[bx] ;return the 16 bit line number mov dx,ax ;dl = 1st letter of alpha name test ES:NM_FLAGS[bx],byte ptr NM_fLineNum ;is it a line # jne LnExit ;brif a line# - AX=line number mov ax,UNDEFINED ;return UNDEFINED for alpha name LnExit: cEnd ;*** ;ONamOfLn oNamW = ONamOfLn ;Purpose: ; To return the Name Table offset of a line number. If the line number ; isn't already in the Name Table, then it is added. Line numbers are ; kept in their own seperate chains in tNam. A '0' is returned in AX to ; indicate an error condition (out of memory, etc). ; ; NOTE: Shares a common exit with ONamOfPbCb, so these must have identical ; entries. ;Entry: ; AX = 16 bit line number ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ; ;Exit: ; AX - Name table offset of LnW ; 0 is returned for error conditions (out of memory) ; DL = tNam.oNam.flags if AX != 0 ; PSW flags set via an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ONamOfLn,<PUBLIC,NEAR,NODATA>,<DI> LocalW pbName ; These locals match those in LocalW cbName ; ONamOfPbCb because we share a LocalW pNamCur ; common exit LocalB fGrowTNam LocalB fDontReplaceNam LocalW lineNum LocalV bdlTmp,<SIZE BDL> cBegin mov [lineNum],ax lea ax,[lineNum] ;parm to ONamOfPbCb (ptr to 'name') mov cx,2 ;parm to ONamOfPbCb (size of 'name') mov di,LineNumHdr1st ;ptr to first line number hash chain mov dl,7 ;only 8 chains for line numbers mov bx,0FFFFH ;ensure we match only the correct number jmp short ONamOf_Common cEnd <nogen> ;*** ;ONamOfPsd oNamW = ONamOfPsd(psdW) ;Purpose: ; To return the Name Table offset of a symbol. If the symbol isn't ; already in the Name Table, then it is added. The symbol's case is ; preserved in tNam , but it is ignored while searching for a match ; (FoO is the same as fOo). If the cases don't match exactly, then the ; new symbol will replace the old one in tNam. A 0 is returned in AX ; to indicate an error condition (out of memory, etc). ; ; NOTE: shares code with and exits via ONamOfPbCb. ;Assumptions: ; )symbols can never be removed from tNam ; )Each char in the name part of the symbol can be any valid ; ASCII (0-127) except the following: ; <Control Char> < ' > < { > < | > < } > < ~ > <DEL> ; )0 < cb < CB_MAX_NAMENTRY ;Entry: ; The stack contains the following parameters (PLM calling convention) ; ParmW - ptr to a string descriptor ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ; ;Exit: ; AX - Name table offset of name in psd ; 0 is returned for error conditions (out of memory) ; DL = tNam.oNam.flags if AX != 0 ; PSW flags set via an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ONamOfPsd,<PUBLIC,NEAR,NODATA> cBegin <nogen> pop dx ;return address to caller pop bx ;psd parm passed by caller mov ax,[bx.BD_pb] ;ptr to string contents mov cx,[bx.BD_cbLogical] ;byte count DbAssertRel cx,be,CB_MAX_NAMENTRY,CP,<ONamOfPsd: psd.cb too large> push dx ;put retval back on stack cEnd <nogen> ;fall into ONamOfPbCb ;*** ;ONamOfPbCb oNamW = ONamOfPbCb ;Purpose: ; To return the Name Table offset of a symbol. If the symbol isn't ; already in the Name Table, then it is added. The symbol's case is ; preserved in tNam , but it is ignored while searching for a match ; (FoO is the same as fOo). If the cases don't match exactly, then the ; new symbol will replace the old one in tNam by default; this replacement ; is suppressed if the Cb input word has it's high bit set. A 0 is ; returned in AX to indicate an error condition (out of memory, etc). ;Assumptions: ; )symbols can never be removed from tNam ; )Each char in the name part of the symbol can be any valid ; ASCII (0-127) except the following: ; <Control Char> < ' > < { > < | > < } > < ~ > <DEL> ; )0 < cb < CB_MAX_NAMENTRY ;Register conventions: ; DS - pbName segment ; ES - tNam segment ; SI - pbName pointer ; DI - tNam pointer ;Entry: ; AX = ptr to ASCII string ; CX = length of ASCII string ; If the high bit is set and the name is found, the existing ; name is NOT to be replaced in the table. ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ; ;Exit: ; AX - Name table offset of PbCb input string ; 0 is returned for error conditions (out of memory). ; Special: when fDontCreateName != 0, ax = 0 indicates that the ; name wasn't found (and was NOT added to the table). ; DL = tNam.oNam.flags if AX != 0 ; PSW flags set via an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ONamOfPbCb,<PUBLIC,NEAR,NODATA>,<DI> ;NOTE: matches entry to ONamOfLn LocalW pbName ;ptr to string containing symbol LocalW cbName ;# of bytes in *pbName LocalW pNamCur LocalB fGrowTNam ;set if tNam needs to be grown ;before exiting LocalB fDontReplaceNam ;FALSE if we should replace name in tbl LocalW lineNum ;line number here, if entry via ONamOfLn LocalV bdlTmp,<SIZE BDL> cBegin mov di,tNam ; not using line # hash table mov bx,0DFDFH-1 ;upper case mask for NextChar loop mov dl,31d ;32 hash chains for names (not line #'s) ONamOf_Common: ;entry from ONamOfLn DbChk tNam push si xor dh,dh mov [fGrowTNam],dh ;assume that tNam doesn't need to grow or ch,ch jns SetReplaceNam ;brif assumption correct and ch,07FH ;reset high bit inc dh ;Don't replace the name in the name ; table if entry found, i.e., leave ; case of existing name as-is. SetReplaceNam: mov [fDontReplaceNam],dh DbChk ConStatStructs mov [pbName],ax ;save input mov [cbName],cx ;save input xchg ax,si ;ptr to Name string in SI push bx ; preserve mask call FetchPNam ; bx points to desired mrs GETSEG ES,PTRRS[bx.BDL_seg],,<SIZE,LOAD> ;[10][6][25] pop bx ; restore mask DbAssertRel cx,be,CB_MAX_NAMENTRY,CP,<ONamOfPbCb: cbName too large> DbAssertRel cx,nz,0,CP,<ONamOfPbCb: cbName is 0> lodsb ;al = 1st byte of symbol to search for dec cx jcxz Mask_Hash dec cx jcxz Grab_Last ;brif just 2 chars xor al,[si] ;hash in second char of name Grab_Last: ;grab last char for use in hash add si,cx ;point to last char in name xor al,[si] ;use last char in name for hash too Mask_Hash: inc bx jnz Mask_Hash2 ;brif not a numeric - - (must not shift) ;NOTE: as long as we just use the low ; 5 bits of this for the hash ; index, we don't need to worry ; about upper vs. lower case ; letters. shr al,1 ;Line numbers tend to end in 0; don't ; use least significant bit to provide ; a more even hash distribution dec bx Mask_Hash2: ;at this point, BX = 0FFFF for Line Number, 0DFDF otherwise xor dh,dh and ax,dx ;get the 1st char hash value by doing ;doing a MOD 32 (or MOD 8 for line #'s). ;This value is the byte index into ;tNam which is used to obtain the ;ptr to the appropriate symbol chain shl ax,1 ;convert to word index add di,ax ;DI = offset to 1st char chain ptr, ;NOTE - this works because tNam ;is a far heap ( ES:0 => tNam ) mov [pNamCur],di ;pass to AddName (if a null chain) mov dx,ES:[di] ;offset of first symbol in chain ;or 0 if no symbols on chain NextName: mov cx,[cbName] ;CX=# of bytes in pbName NextNameCX: ;this label allows the above 'mov cx' ;to be removed from the inner loop of ;NextName mov di,dx or di,di ;test ptr to next symbol je AddName ;brif end of chain encountered mov dx,ES:[di] ;dx=ptr to next symbol in the chain mov [pNamCur],di ;pass to AddName or MapExit cmp ES:NM_SIZE[di],cl ;are both strings the same size? jne NextNameCX ;brif different sizes mov si,[pbName] ;pb of callers name add di,NM_NAME ;DI = ptr to 1st ASCII char of symbol NextChar: lodsb ;AL=next char from pbName mov ah,ES:[di] ;AH=next char from tNam inc di ;bump tNam index and ax,bx ;BX contains 0DFDFH, so this converts ;AH & AL to upper case by resetting ;their respective bit 5's. This ;mapping works because there are ;no control or special chars in the ;symbol names. cmp ah,al ;is pbName[SI]=tNam[DI] jne NextName ;brif chars not the same loop NextChar ;loop till mismatch or all chars tested ; ;We found a case insensitive match - if the names are exactly the same, then ;just quit (typical case?), otherwise, tell the UI that it needs to redraw ;the debug screen, and replace the name in the table cmp [fDontReplaceNam],FALSE ;want to replace the name in the table? jz DoReplaceName ; brif so MapExit1: jmp MapExit ; nope - just exit DoReplaceName: mov di,[pNamCur] ;addr of symbol record that matched mov si,[pbName] ;pb of symbol to add mov cx,[cbName] ;# of bytes in pbName add di,NM_NAME ;offset to 1st byte of new entry name repz cmpsb ;are names exactly the same? jz MapExit1 ; brif so - exit push es ;preserve across call call DrawDebugScrFar ;inform UI pop es mov di,[pNamCur] ;addr of symbol record that matched jmp short CopyString ;copy DS:[pbName] to ES:[DI+NM_NAME] ; ; Add pbName to the end of the current chain AddName: xor ax,ax ;0 for initializing new fields mov [fGrowTNam],TRUE ;tNam needs to grow ; ; make the last entry point to the next empty symbol ; mov di,ES:[cbUsed] ;# of allocated bytes in tNam ;this is also the addr of the next ;available byte since cbLogical is ;greater than cbUsed mov ES:NM_NEXT[di],ax ;NULL ptr for new record inc bx ;is this name for a Line Number? jnz Not_Ln ; brif not mov al,NM_fLineNum ;set flag to recall that this is a Line# Not_Ln: mov ES:[di+NM_FLAGS],al ;initialize flags to OFF state ; ; copy the pb string to [ES:DI.name] CopyString: mov si,[pbName] ;pb of symbol to add mov cx,[cbName] ;# of bytes in pbName mov ES:NM_SIZE[di],cl ;update length field of symbol ;NOTE - this may be redundant add di,NM_NAME ;offset to 1st byte of new entry name rep movsb ;copy from DS:pbName[SI] to ES:tNam[DI] cmp [fGrowTNam],FALSE ;do we need to grow tNam je MapExit ;brif symbol wasn't added - don't need ;to grow tNam ; ; Make sure there will be enough room to add another symbol the next time thru. ; TNam can now be safely grown since the string has been copied and heap ; movement is no longer a problem. ; mov cx,[oRsNam] ;[10] jcxz MrsCur_Okay ; brif want to grow bdl in mrsCur ; We want to grow the bdlNam for the global mrs, but it's not ; active. It must be active because (1) cannot safely grow a bdl ; when it's in a local heap table, and (2) we need to know where ; the owner of the bdl is in case of heap movement, to refresh es. ; Therefore, we active and then deactivate the global mrs. ; NOTE: This assumes that the only reason pMrsNam is non-zero is ; for global mrs support. ; Note: we save both oPrsCur AND oMrsCur here instead of oRsCur ; to protect against the special case where a declared/ref'd ; but not defined prs is active here ... in this special case, ; RsActivate of oRsCur would leave the global mrs active ... push [grs.GRS_oPrsCur] ; save for later restore push [grs.GRS_oMrsCur] ; save for later restore PUSHI ax,OMRS_GLOBAL ;[23] oMrs of global mrs call MrsActivateCP ; activate the global mrs MrsCur_Okay: mov bx,dataOFFSET mrsCur.MRS_bdlNam ; pointer to tNam bdl mov ax,CB_MAX_NAMENTRY+NM_NAME+NM_NAME ; max # of bytes needed to add ;the next symbol plus the ;overhead needed by the ;current symbol. add ax,[cbName] ;plus the _NAME field bytes used by ;the current symbol mov di,[pNamCur] ;addr of last searched name entry push bx ; pass pbdlNam to BdlCheckFree push ax ;pass byte count to BdlCheckFree call BdlCheckFree ;make sure there is enough room in tNam ;to add another symbol xchg ax,si ; save return code across poss. call mov cx,[oRsNam] ;[10] jcxz MrsCur_Okay1 ; brif mrsCur is to be left alone ; The oRs of the context that was active on input is on the top ; of the stack. Activate this again, and then refresh pMrsNam in ; case the mrs table moved and pMrsNam will be used again. mov [oRsNam],0 ; reset so global mrs access in ; MrsActivateCP will be correct call MrsActivateCP ; reactivate input oMrsCur call PrsActivateCP ; reactivate input oMrsCur call Use_GMrs MrsCur_Okay1: sub ax,ax ; in case of error or si,si ; BdlCheckFree return code je ONamOfPbCb_Exit ;brif not enough memory - the current ;name isn't added to tNam - even ;though the _NAME field has been ;updated. mov si,[cbName] ;# of bytes in new symbol add si,NM_NAME ;compensate for header bytes ;SI = # of bytes in new entry call FetchPNam ; bx points to desired mrs mov dx,PTRRS[bx.BDL_cbLogical] ;[10] # of bytes in Name Table add dx,si ; + padding for next symbol js ONamOfPbCb_Exit ;brif table has grown > 32k ; see module header for reason(s) for ; this restriction mov PTRRS[bx.BDL_cbLogical],dx ;[10] GETSEG ES,PTRRS[bx.BDL_seg],,<SIZE,LOAD> ;[14][10][6] ; may have been changed by the ; call to BdlCheckFree ;make the last entry point to the ; next empty symbol mov ax,ES:cbUsed ;# of tNam bytes already used ;this is also the addr of the next ;available byte since cbLogical is ;greater than cbUsed mov ES:[di],ax ;make the last entry point to new entry mov di,ax ;return new oNam to caller add ax,si ;cbUsed + size of new entry mov ES:cbUsed,ax ;# of bytes used by the Name Table mov [pNamCur],di ;return new oNam to caller MapExit: mov bx,[pNamCur] ;return name offset to caller in AX mov dl,ES:NM_FLAGS[bx] ;get the flag byte xchg ax,bx ONamOfPbCb_Exit: pop si or ax,ax ;set flags for callers cEnd ;*** ;TNamInit TNamInit() ;Purpose: ; To initialize the Name Table structure and any other data used by ; the Name Table Manager. A zero is returned in AX if there was not ; enough memory. ;Entry: ; sbToUse - 0 means use any sb for this table. If non-zero, then this ; sb value is to be used. ; mrsCur.bdlNam = current module's name table ;Exit: ; AX = 0 if not enough memory was available ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc TNamInit,<PUBLIC,NEAR,NODATA>,<DI> parmW sbToUse cBegin mov ax,dataOFFSET mrsCur.MRS_bdlNam ; ptr to tNam bdl push ax ; parm to BdlAlloc cCall BdlFree,<ax> ; in case name table is an owner mov ax,NM_INIT_TABLE_SZ ;# of bytes to allocate push ax ;pass low word of cb to BdlAlloc PUSHBDL_TYPE pgtypEBNameTable,ax ; pass sb type for EB version mov cx,[sbToUse] jcxz Use_Any_Sb push cx call BdlAllocSb jmp short TNamInit_Cont Use_Any_Sb: call BdlAlloc ;allocate a large far heap for NamTab TNamInit_Cont: or ax,ax ;check return code je TNIExit ;brif heap wasn't allocated ; ;we now own a far heap entry - initialize it ; GETSEG ES,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] mov cx,mrsCur.MRS_bdlNam_cPhysical ;# of paragraphs in Name Table shl cx,1 ;convert cPara to cBytes shl cx,1 ; (under DOS 5 this already is cBytes) shl cx,1 shl cx,1 mov di,tNam ;di=base addr of tNam ;NOTE - tNam is a far heap sub cx,di ; zero-fill all but initial bytes sub ax,ax ;AX=0 REP STOSB ;Initialize the Name table mov ax,oNamFirst ;offset to 1st usable entry mov ES:cbUsed,ax ;# of bytes currently being used ;by tNam add ax,NM_NAME+CB_MAX_NAMENTRY ; # of bytes currently being used ;by tNam + enough padding to add ;another symbol mov mrsCur.MRS_bdlNam_cbLogical,ax ;total size of tNam TNIExit: cEnd ;*** ;CopyONamPb cbW = CopyONamPb ;Purpose: ; To copy the ASCII chars in a name table entry to the callers buffer. ; The # of ASCII characters copied is returned. ;Assumptions: ; pbW contains room for at least CB_MAX_NAMENTRY chars ;Register conventions: ; DS - tNam segment ; ES - pb segment ; SI - tNam pointer ; DI - pb pointer ;Entry: ; pbBuf - ptr to a buffer ; oNam - symbol's name table offset into mrsCur.tNam ; The following data is referenced: ; if oRsNam is <> 0, then we use that to fetch name table segment, ; else mrsCur.bdlNam contains current module's name table segment. ;Exit: ; AX - # of ASCII chars in mrsCur.tNam.oNam.name ; These chars are copied into the given buffer. ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc CopyONamPb,<PUBLIC,FAR,NODATA>,<SI,DI,DS> parmW pbBuf parmW oNam cBegin DbChk ConStatStructs DbChk tNam DbChk oNam,oNam ; sanity check on input oNam mov si,[oNam] ; SI = tNam.oNam ;NOTE - this works because tNam ;is a far heap ( ES:0 => tNam ) call FetchPNam ; bx points to desired mrs GETSEG DS,PTRRS[bx.BDL_seg],,<SIZE,LOAD> ;[14][10][6] push SS ;callers pb segment pop ES ;ES = callers pb segment mov di,[pbBuf] sub cx,cx ;CX=0 mov cl,NM_SIZE[si] ;# of ASCII bytes in oNam mov ax,cx ;return cbW to caller add si,NM_NAME ;SI = tNam.oNam.name rep movsb ;copy tNam.oNam.nam to pb cEnd ;*** ;CopyONamBd cbW = CopyONamBd(oNamW,pBdW) ;Purpose: ; Use oNam to determine the symbol's size and then use that size to ; allocate a heap entry for pBd. The ASCII chars in the symbol name ; are then copied to the heap entry. pBd must point to an un-initialized ; Bd (ie - Bd doesn't currently own a heap entry)! ;Entry: ; The stack contains the following parameters (PLM calling convention) ; ParmW - symbol's name table offset ; ParmW - ptr to uninitialized Bd ;Exit: ; AX = 0 if Bd allocation was unsucessful ; = mrsCur.tNam.oNam.cb if Bd allocation was sucessful ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc CopyONamBd,<PUBLIC,NEAR,NODATA>,<SI,DI> parmW oNam ;symbol's offset into tNam parmW pBd ;ptr to uninitialized Bd cBegin DbChk ConStatStructs DbChk tNam DbChk oNam,[oNam] ;sanity check on input oNam mov si,[oNam] ;SI = tNam.oNam ;NOTE - this works because tNam ;is a far heap ( ES:0 => tNam ) sub cx,cx ;CX=0 GETSEG ES,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] mov cl,ES:NM_SIZE[si] ;# of ASCII bytes in oNam push cx ;save & pass to BdAlloc mov ax,IT_NO_OWNERS ;pass bdType to BdAlloc cCall BdAlloc,<pBd,cx,ax> ;allocate a Bd to copy oNam to pop cx or ax,ax ;was the allocation sucessful je CopyONamBdExit ;brif unsucessful push DS ;ES = DGROUP (for the 'rep movsb') pop ES GETSEG DS,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] ;refresh - BdAlloc could have moved it assumes DS,NOTHING mov ax,cx ;return mrsCur.tNam.oNam.cbW to caller add si,NM_NAME ;SI = tNam.oNam.name (source ptr) mov di,[pBd] ;ptr to Bd to copy to mov di,ES:[di.BD_pb] ;ptr to buf to copy oNam to (dest ptr) rep movsb ;copy tNam.oNam.nam to pb push ES ;DS = DGROUP (for the 'rep movsb') pop DS assumes DS,DATA CopyONamBdExit: cEnd ;*** ;GetVarNamChar ushort = GetVarNamChar(oNamW) ;Purpose: ; Given an oNam, the logical first char of the name for use in ; determining the default type of a variable by that name (i.e., ; bypass a leading 'FN' in the name). ; For versions supporting DEF FN's, also return a flag indicating ; whether the name starts with 'FN' or not. ;Entry: ; oNamW - symbol's name table offset into mrsCur.tNam ;Exit: ; AL - logical first char of variable name, forced to upper case ; ife FV_QB4LANG ; AH - 0 if name doesn't start with 'FN', non-zero if it does ; endif ;Uses: ; none. ;Preserves: ; DX, ES ;Exceptions: ; none. ;**************************************************************************** cProc GetVarNamChar,<PUBLIC,NEAR,NODATA>,<ES> parmW oNam cBegin DbChk oNam,[oNam] ;sanity check on input oNam DbChk tNam DbChk ConStatStructs GETSEG es,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] mov bx,[oNam] add bx,NM_NAME ;add table start ptr to offset mov al,es:[bx] ;fetch first char of name and al,0DFh ;force to upper case xor ah,ah cmp al,'F' jnz GetVarChar_Exit ;brif doesn't start with 'FN' mov cl,es:[bx-(NM_NAME - NM_SIZE)] ; fetch length of name cmp cl,2 ; long enough to be a DEF FN name? jbe GetVarChar_Exit ; brif not mov cl,es:[bx+1] ;fetch second char of name and cl,0DFh ;force to upper case cmp cl,'N' jnz GetVarChar_Exit ;brif doesn't start with 'FN' mov al,es:[bx+2] ;fetch third char of name and al,0DFh ;force to upper case inc ah ;set "found 'FN'" flag GetVarChar_Exit: cEnd ;*** ;FlagOfONam FlagW = FlagOfONam(oNamW) ;Purpose: ; To get a symbols flag byte from the symbol table. ;Entry: ; The stack contains the following parameters (PLM calling convention) ; ParmW - symbol's name table offset ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ;Exit: ; AX = tNam.oNam.flags ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc FlagOfONam,<PUBLIC,NEAR,NODATA>,<DS> parmW oNam ;symbol's offset into tNam cBegin DbChk oNam,[oNam] ;sanity check on input oNam DbChk tNam DbChk ConStatStructs GETSEG ds,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] mov bx,oNam ;bx = tNam.oNam ;NOTE - this works because tNam ;is a far heap ( DS:0 => tNam ) sub ax,ax ;AH=0 - for returning a ushort mov al,NM_FLAGS[bx] ;get the flag byte cEnd ;*** ;SetONamMask, SetONamSpace, CheckONamSpace ;Purpose: ; To selectively set individual bits in a symbols FLAG byte. ; For SetONamSpace, ; sets the 2 "name space" bits of the flags byte to some ; NMSP_ value. Returns 0 if no error, or ER_DD if either of ; those bits were already set. ; For CheckONamSpace, ; catches the error where a given bit is already set, but ; doesn't actually set the namespace. ;Entry: ; The stack contains the following parameters (PLM calling convention) ; ParmW - symbol's name table offset ; ParmB - mask to be ORed with symbols FLAG byte ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ;Exit: ; tNam.oNam.flags = tNam.oNam.flags OR maskW ; For SetONamSpace, AX = 0 if no error, else AX = ER_DD. ; PSW.Z set if no error ; dl = old value of oNams flags before the new bit was set. ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** PUBLIC CheckONamSpace CheckONamSpace: mov ch,0FFH ; don't set namespace bits SKIP2_PSW PUBLIC SetONamSpace SetONamSpace: mov ch,0 ; do set namespace bits mov cl,0FFH ; do check for errors SKIP2_PSW PUBLIC SetONamMask SetONamMask: xor cx,cx cProc SetONamMaskGen,<NEAR,NODATA>,<DS> parmW oNam ;symbol's offset into tNam parmB orMask ;bit mask - value to be ORed with NM_FLAGS cBegin DbChk ConStatStructs DbChk tNam GETSEG ds,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] mov bx,[oNam] ;bx = tNam.oNam ;NOTE - this works because tNam ;is a far heap ( ES:0 => tNam ) DbChk oNam,bx ;sanity check on input oNam mov dh,[orMask] jcxz NMSP_Okay xor ax,ax ;assume no error for SetONamSpace retval mov dl,NM_FLAGS[bx] ;fetch flags as they were on entry and dl,NMSP_MASK ;had one of the NMSP_ bits been set? jz NMSP_Okay ; brif not cmp dl,dh ;were those bits same as input? jz NMSP_Okay ; brif so mov al,ER_DD xor dh,dh ;don't alter table if error NMSP_Okay: or ch,ch ; want to actually modify flag bits? jnz @F ; brif not - - - exit mov dl,NM_FLAGS[bx] ;return old value in dl or NM_FLAGS[bx],dh ;set all MASKed bits @@: or ax,ax ;set PSW flags cEnd ;*** ;ResetONamMask ResetONamMask ;Purpose: ; To selectively reset individual bits in a symbols FLAG byte. ;Entry: ; AL = mask to be NANDed with symbols FLAG byte ; BX = symbol's name table offset ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ;Exit: ; tNam.oNam.flags = tNam.oNam.flags OR maskW ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ResetONamMask,<PUBLIC,NEAR,NODATA>,<DS> cBegin DbChk ConStatStructs DbChk tNam DbChk oNam,bx ;sanity check on input oNam GETSEG ds,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] not al ;invert the mask or al,NM_fLineNum ;don't let anyone reset this flag and NM_FLAGS[bx],al ;reset all MASKed bits cEnd ;*** ;ResetONamMaskTmp ;Purpose: ; C code access to ResetONamMask ;Entry: ; The stack contains the following parameters (PLM calling convention) ; mask to be NANDed with symbols FLAG byte ; symbol's name table offset ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ;Exit: ; tNam.oNam.flags = tNam.oNam.flags OR maskW ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ResetONamMaskTmp,<PUBLIC,NEAR,NODATA> parmW oNam parmB nandMask cBegin mov al,[nandMask] mov bx,[oNam] call ResetONamMask cEnd ;*** ;ResetTNamMask ResetTNamMask(maskW) ;Purpose: ; Resets the all but the selected flag bits in all symbols of ; mrsCur.tNam (the symbol's flags are ANDed with the given byte mask). ; ; Note that we handle the NMSP_ enumerated bits specially to ensure ; that the NMSP_SUB constant is never changed. ;Entry: ; AL - mask to be ANDed with all symbol FLAG bytes ; The following globals are referenced ; mrsCur.bdlNam => current module's name table ;Exit: ; none. ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ResetTNamMask,<PUBLIC,NEAR,NODATA>,<SI,DS> cBegin DbChk ConStatStructs DbChk tNam GETSEG ds,[mrsCur.MRS_bdlNam_seg],,<SIZE,LOAD> ;[6] xor si,si ;SI=0 - make GetNextONam return ; FirstONam or al,NM_fLineNum+NM_fLineNumLabel ;don't let anyone reset these ;if NMSP_SUB is set for a name, leave it alone, otherwise, allow ;caller to reset either both NMSP_ bits or neither mov ah,al mov cl,NMSP_SUB NextTNamMask: call GetNextONam ;SI = pNextONam je ResetTNamMaskExit ;brif no more oNams test BYTE PTR NM_FLAGS[si],080H jnz NextTNam_Cont ;brif NMSP_Variable or _Constant set ; (need this because NMSP_'s are ; enumerated - - see .errnz's above) or al,cl ;don't mask off NMSP_SUB flag NextTNam_Cont: and NM_FLAGS[si],al ;reset all MASKed bits mov al,ah jmp NextTNamMask ;loop till all oNam's visited ResetTNamMaskExit: cEnd ;*** ;GetNextoNam ;Purpose: ; To get the next oNam in tNam ;Entry: ; DS - tNam segment ; SI - current oNam - if 0 then return 1st oNam ; DS:CurONamHdr - current tNam 1st char index ; ;Exit: ; PSW - IF zero flag set then no more valid oNam's exist ; SI - next oNam ; NextONamHdr - next tNam 1st char index ;Uses: ; dx ;*************************************************************************** PUBLIC GetNextONam GetNextONam: or si,si ;should we initialize jne NextoNam ;brif initialization not desired mov word ptr DS:CurONamHdr,tNam - 2 ;offset of 1st valid chain header-2 NextChain: mov dx,DS:CurONamHdr ;offset of current tNam chain header inc dx ;word ptr to next chain header inc dx cmp dx,LineNumHdrLast ;check for the end of tNam header tbl mov DS:CurONamHdr,dx ;update ja GotNextoNam ;brif all chain headers visited mov si,dx ;start with 1st symbol in cur chain NextoNam: mov si,[si] ;ptr to next symbol in cur hdr chain or si,si ;test for end of cur chain je NextChain ;brif no more symbols in cur hdr chain GotNextoNam: or si,si ;set cond codes for caller ret ;============================================================================= ; ; Global Name Table Support (ogNam support routines) ; ;============================================================================= ;*** ;OgNamOfPsd ;Purpose: ; Same as ONamOfPsd, but returns an ogNam, not an oNam ; ; Added as part of revision [4] ;Entry: ; a psd on the stack ;Exit: ; ax = ogNam or 0 ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc OgNamOfPsd,<PUBLIC,FAR,NODATA> parmW psdName cBegin call Use_GMrs ; point oRsNam to global name table cCall ONamOfPsd,<psdName> ;returns ax = ogNam or 0 for error mov [oRsNam],0 ;[10] reset pointer to default cEnd ;*** ;OgNamOfPbCb ;Purpose: ; Same as ONamOfPbCb, but returns an ogNam, not an oNam ; ; Added as part of revision [4] ;Entry: ; pbName and cbName on stack ;Exit: ; ax = ogNam or 0 ; PSW flags set based on an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc OgNamOfPbCb,<PUBLIC,NEAR,NODATA> parmW pbName parmW cbName cBegin call Use_GMrs ; point oRsNam to global name table mov ax,[pbName] mov cx,[cbName] cCall ONamOfPbCb ;returns ax = ogNam or 0 for error mov [oRsNam],0 ;[10] reset pointer to default cEnd ;*** ;CopyOgNamPb, CopyOgNamPbNear ;Purpose: ; Given an ogNam and a short pointer to a buffer, copy the name to the ; buffer and return the length of the name ; ; Added as part of revision [4] ;Entry: ; CopyOgNamPbNear: ; ax = pDest ; bx = ogNam ; CopyOgNamPb: parameters are on the stack ; pDest ; ogNam ;Exit: ; ax - # of chars in the name, that were copied into the given buffer. ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc CopyOgNamPbNear,<PUBLIC,NEAR,NODATA> cBegin DbChk ogNam,bx call Use_GMrs ; point oRsNam to global name table cCall CopyONamPb,<ax,bx> ; perform copy, return ax = cbName mov [oRsNam],0 ;[10] reset pointer to default cEnd cProc CopyOgNamPb,<PUBLIC,FAR,NODATA> parmW pDest parmW ogNam cBegin mov ax,[pDest] mov bx,[ogNam] cCall CopyOgNamPbNear ;perform copy, return ax = cbName cEnd ;*** ;FpNamOfOgNam ;Purpose: ; Given an ogNam, return a far pointer to, and the length of, the name. ; ; Added as part of revision [4] ;Entry: ; ogNam on stack ;Exit: ; es:bx points to name ; es:dx also points to name (i.e., dx = bx) ; cx = cbName ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc FpNamOfOgNam,<PUBLIC,NEAR,NODATA> parmW ogNam cBegin DbChk ogNam,ogNam lea bx,[mrsCur.MRS_bdlNam] ; assume global mrs active cmp [grs.GRS_oMrsCur],OMRS_GLOBAL ; is global mrs active? jz @F ; brif so GETRS_SEG es,bx,<SIZE,LOAD> mov bx,MRS_bdlNam_seg + OMRS_GLOBAL ; offset in the global mrs ; to the name table. RS_BASE add,bx @@: GETSEG es,PTRRS[bx],,<SIZE,LOAD> mov bx,[ogNam] sub cx,cx mov cl,es:[bx.NM_SIZE] add bx,NM_NAME ;es:bx points to name mov dx,bx ;es:dx also points to name cEnd ;*** ;OgNamOfONam ;Purpose: ; Given an oNam, return the ogNam for this name. ; ; Added as part of revision [4] ;Entry: ; an oNam for the current module on the stack ;Exit: ; ax = ogNam or 0 ; PSW flags set based on an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc OgNamOfONam,<PUBLIC,NEAR,NODATA> parmW oNam localV namTmp,CB_MAX_NAMENTRY ; alloc space for max. name on stack cBegin lea ax,namTmp push ax ;parm1 to OgNamOfPbCb push ax ; parm1 to CopyONamPb push [oNam] ; parm2 to CopyONamPb DbChk oNam,oNam ;[11] call CopyONamPb ;necessary, as OgNamOfPbCb expects ;as DGROUP-relative pointer push ax ;parm2 to OgNamOfPbCb call OgNamOfPbCb cEnd ;*** ;ONamOfOgNam ;Purpose: ; Given an ogNam, return the oNam for this name. ; ; Added as part of revision [4] ;Entry: ; an ogNam ;Exit: ; ax = ogNam or 0 ; PSW flags set based on an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc ONamOfOgNam,<PUBLIC,NEAR,NODATA> parmW ogNam localV namTmp,CB_MAX_NAMENTRY ; alloc space for max. name on stack cBegin lea ax,namTmp push ax ;save across call mov bx,[ogNam] DbChk ogNam,bx call CopyOgNamPbNear ;necessary, as ONamOfPbCb expects ;a DGROUP-relative pointer xchg ax,cx ;cx = cbName pop ax ;ax = pbName call ONamOfPbCb cEnd cProc ONamOfOgNamFar,<PUBLIC,FAR,NODATA> parmW ogNam cBegin cCall ONamOfOgNam,<ogNam> cEnd ;*** ;CharOfOgNam ;Purpose: ; Given an ogNam, return the first char in the name in al ; ; Added as part of revision [4] ;Entry: ; an ogNam ; It is assumed that the global mrs is NOT active on entry ;Exit: ; ax = first char in name ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc CharOfOgNam,<PUBLIC,FAR,NODATA> parmW ogNam cBegin cCall FpNamOfOgNam,<ogNam> ;returns es:dx pointing to name ; and cx = cbName mov bx,dx mov al,es:[bx] cEnd ;*** ;CbOfOgNam ;Purpose: ; Given an ogNam, return the length of the name in ax ; ; Added as part of revision [4] ;Entry: ; an ogNam ; It is assumed that the global mrs is NOT active on entry ;Exit: ; ax = length of the name ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc CbOfOgNam,<PUBLIC,FAR,NODATA> parmW ogNam cBegin cCall FpNamOfOgNam,<ogNam> ;returns es:dx pointing to name ; and cx = cbName xchg ax,cx cEnd ;*** ;BdAppendOgNam ;Purpose: ; Given a pbd and an ogNam, allocate the bd if necessary, and append the ; name to the end of the bd. ; ; Added as part of revision [4] ;Entry: ; pBd ; ogNam ;Exit: ; If not enough memory can be obtained, AX = FALSE ; else pbd->cbLogical is updated, AX = TRUE (non-zero) ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc BdAppendOgNam,<PUBLIC,FAR,NODATA>,<SI> parmW pBd parmW ogNam cBegin cCall CbOfOgNam,<ogNam> ;ax = cbName mov si,[pBd] push si ;parm1 to BdCheckFree push ax ;parm2 to BdCheckFree cmp [si.BD_pb],NULL ;is the bd currently an owner? jnz GrowTheBd ; brif not - grow, don't allocate PUSHI ax,IT_NO_OWNERS call BdAlloc ;allocate buffer of sufficient size mov [si.BD_cbLogical],0 ;to match algorithm in shared code jmp short BdCheck_OM GrowTheBd: call BdCheckFree BdCheck_OM: or ax,ax jz BdAppendOgNam_Exit ;brif error exit mov ax,[si.BD_pb] add ax,[si.BD_cbLogical] ;pointer to where name is to be copied mov bx,[ogNam] cCall CopyOgNamPbNear ;returns ax = cbName add [si.BD_cbLogical],ax ;update logical length of buffer ;The below assertion is to ensure we return a non-zero result DbAssertRel ax,ne,0,CP,<BdAppendOgNam: 0-length name appended?!> BdAppendOgNam_Exit: cEnd ;*** ;CmpOgNamIns ;Purpose: ; Given two ogNam's, perform a case-insensitive comparison on the names. ; NOTE: This routine could easily be generalized to work with any oNam's. ; ; Added as part of revision [4] ;Entry: ; ogNam1 ; ogNam2 ; It is assumed that the global mrs is NOT the current mrs on entry ;Exit: ; if the two ogNam's are the same then ax = 0 ; else if name1 < name2 then ax = FFFF ; else name1 > name2 and ax = 1 ; ; if name1 longer than name2 then dx > 0 ; else if name1 shorter than name2 then dx < 0 ; else name1 same length as name2 and dx = 0 ; ; PSW set based on an OR AX,AX on exit ;Uses: ; none ;Exceptions: ; none ;*************************************************************************** cProc CmpOgNamIns,<PUBLIC,NEAR,NODATA> parmW ogNam1 parmW ogNam2 cBegin DbChk ogNam,ogNam1 DbChk ogNam,ogNam2 push si lea bx,[mrsCur.MRS_bdlNam] ; assume global mrs active cmp [grs.GRS_oMrsCur],OMRS_GLOBAL ; is global mrs active? jz @F ; brif so GETRS_SEG es,bx,<SIZE,LOAD> mov bx,MRS_bdlNam_seg + OMRS_GLOBAL ; offset in the global mrs ; to the name table. RS_BASE add,bx @@: GETSEG ds,PTRRS[bx],,<SIZE,LOAD> assumes DS,NOTHING mov bx,[ogNam1] ;ds:bx = pNam1 mov si,[ogNam2] ;ds:si = pNam2 sub ax,ax mov al,NM_SIZE[bx] ;ax = length of string1 mov cx,ax ; assume string1 is the shorter one sub dx,dx mov dl,NM_SIZE[si] ; dx = length of string2 sub ax,dx ;ax > 0 if string1 longer than string2 jle DoCmp ;brif string1 is not longer than string2 mov cx,dx ;cx = length of shorter string (string2) DoCmp: add bx,NM_NAME ;ds:bx points to 1st byte of string1 add si,NM_NAME ;ds:si points to 1st byte of string2 push ax ;preserve across call call CmpStrIns ;call shared code to do the work pop dx ;dx > 0 if string1 longer than string2 pop si push ss pop ds assumes DS,DATA cEnd sEnd CP END
%ifdef CONFIG { "RegData": { "MM6": ["0x8000000000000000", "0x4000"], "MM7": ["0x8000000000000000", "0xBFFF"] }, "MemoryRegions": { "0x100000000": "4096" } } %endif lea rdx, [rel data] fld tword [rdx + 8 * 0] lea rdx, [rel data2] fld tword [rdx + 8 * 0] fsub st1, st0 hlt align 8 data: dt 1.0 dq 0 data2: dt 2.0 dq 0
%define BE(a) ( ((((a)>>24)&0xFF) << 0) + ((((a)>>16)&0xFF) << 8) + ((((a)>>8)&0xFF) << 16) + ((((a)>>0)&0xFF) << 24) ) ftyp_start: dd BE(ftyp_end - ftyp_start) db "ftyp" db "isom" dd BE(0x00) db "mif1", "miaf" ftyp_end: meta_start: dd BE(meta_end - meta_start) db "meta" dd BE(0) hdlr_start: dd BE(hdlr_end - hdlr_start) db "hdlr" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x00 ; pre_defined(32) db 0x70, 0x69, 0x63, 0x74 ; handler_type(32) ('pict') db 0x00, 0x00, 0x00, 0x00 ; reserved1(32) db 0x00, 0x00, 0x00, 0x00 ; reserved2(32) db 0x00, 0x00, 0x00, 0x00 ; reserved3(32) db 0x00 ; name(8) hdlr_end: pitm_start: dd BE(pitm_end - pitm_start) db "pitm" dd BE(0) db 0x00, 0x00 pitm_end: iinf_start: dd BE(iinf_end - iinf_start) db "iinf" dd BE(0) db 0x00, 0x00 iinf_end: iprp_start: dd BE(iprp_end - iprp_start) db "iprp" ipco_start: dd BE(ipco_end - ipco_start) db "ipco" ispe_start: dd BE(ispe_end - ispe_start) db "ispe" dd 0, 0, 0 ispe_end: ipco_end: iprp_end: meta_end: moov_start: dd BE(moov_end - moov_start) db "moov" mvhd_start: dd BE(mvhd_end - mvhd_start) db "mvhd" mvhd_end: trak_start: dd BE(trak_end - trak_start) db "trak" mdia_start: dd BE(mdia_end - mdia_start) db "mdia" hdlr2_start: dd BE(hdlr2_end - hdlr2_start) db "hdlr" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x00 ; pre_defined(32) dd "thmb" ; handler_type(32) ('thmb') db 0x00, 0x00, 0x00, 0x00 ; reserved1(32) db 0x00, 0x00, 0x00, 0x00 ; reserved2(32) db 0x00, 0x00, 0x00, 0x00 ; reserved3(32) db 0x00 ; name(8) hdlr2_end: minf_start: dd BE(minf_end - minf_start) dd "minf" stbl_start: dd BE(stbl_end - stbl_start) dd "stbl" stss_start: dd BE(stss_end - stss_start) dd "stss" dd BE(0) dd BE(4) dd BE(0), BE(2), BE(6), BE(9) stss_end: stbl_end: minf_end: mdia_end: edts_start: dd BE(edts_end - edts_start) db "edts" elst_start: dd BE(elst_end - elst_start) db "elst" dd 0 ; don't loop dd BE(1) dd BE(0) ; edit_duration dd BE(0) ; media_time db 0, 1 ; media_rate dw BE(0) elst_end: edts_end: trak_end: trak2_start: dd BE(trak2_end - trak2_start) db "trak" mdia2_start: dd BE(mdia2_end - mdia2_start) db "mdia" hdlr22_start: dd BE(hdlr22_end - hdlr22_start) db "hdlr" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x00 ; pre_defined(32) db 0x70, 0x69, 0x63, 0x74 ; handler_type(32) ('pict') db 0x00, 0x00, 0x00, 0x00 ; reserved1(32) db 0x00, 0x00, 0x00, 0x00 ; reserved2(32) db 0x00, 0x00, 0x00, 0x00 ; reserved3(32) db 0x00 ; name(8) hdlr22_end: minf2_start: dd BE(minf2_end - minf2_start) dd "minf" stbl2_start: dd BE(stbl2_end - stbl2_start) dd "stbl" stss2_start: dd BE(stss2_end - stss2_start) dd "stss" dd BE(0) dd BE(4) dd BE(0), BE(2), BE(6), BE(9) stss2_end: stbl2_end: minf2_end: mdia2_end: edts2_start: dd BE(edts2_end - edts2_start) db "edts" elst2_start: dd BE(elst2_end - elst2_start) db "elst" dd BE(1) ; loop dd BE(1) dd BE(0) ; edit_duration dd BE(0) ; media_time db 0, 1 ; media_rate dw BE(0) elst2_end: edts2_end: trak2_end: moov_end:
; double cos (double d); ; ---------------------- ; This function returns the cosine of a real number. ; KNOWN BUGS !!! ; 1. Does not handle exceptions. section .code global _cos _cos push rbp mov rbp, rsp fld tword [rbp+16] fcos ; cos(x) pop rbp ret
; $Id: bit_open.asm,v 1.7 2016-06-16 19:34:00 dom Exp $ ; ; Z88 1 bit sound functions ; ; void bit_open(); ; ; Stefano Bodrato - 28/9/2001 ; Based on the Dominic Morris' code ; SECTION code_clib PUBLIC bit_open PUBLIC _bit_open INCLUDE "interrpt.def" PUBLIC snd_asave EXTERN __snd_tick .bit_open ._bit_open ld (snd_asave),a ld a,($4B0) and 63 ld ($4B0),a out ($B0),a ld (__snd_tick),a ret SECTION bss_clib snd_asave: defb 0
Name: mn_hp_smplay.asm Type: file Size: 97252 Last-Modified: '1993-08-24T11:34:58Z' SHA-1: ABE54A674E062792870E26478B08325FA5CC94E6 Description: null
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2016 Intel Corporation All rights reserved. ; ; 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 Intel Corporation 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. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %include "sha512_job.asm" %include "sha512_mb_mgr_datastruct.asm" %include "reg_sizes.asm" extern sha512_mb_x2_sse default rel %ifidn __OUTPUT_FORMAT__, elf64 ; LINUX register definitions %define arg1 rdi ; rcx %define arg2 rsi ; rdx ; idx needs to be other than arg1, arg2, rbx, r12 %define idx rdx ; rsi %else ; WINDOWS register definitions %define arg1 rcx %define arg2 rdx ; idx needs to be other than arg1, arg2, rbx, r12 %define idx rsi %endif ; Common definitions %define state arg1 %define job arg2 %define len2 arg2 %define unused_lanes rbx %define lane_data rbx %define tmp2 rbx %define job_rax rax %define tmp1 rax %define size_offset rax %define tmp rax %define start_offset rax %define tmp3 arg1 %define extra_blocks arg2 %define p arg2 %define tmp4 r8 %define lens0 r8 %define lens1 r9 %define lens2 r10 %define lens3 r11 ; STACK_SPACE needs to be an odd multiple of 8 _XMM_SAVE_SIZE equ 10*16 _GPR_SAVE_SIZE equ 8*3 _ALIGN_SIZE equ 0 _XMM_SAVE equ 0 _GPR_SAVE equ _XMM_SAVE + _XMM_SAVE_SIZE STACK_SPACE equ _GPR_SAVE + _GPR_SAVE_SIZE + _ALIGN_SIZE %define APPEND(a,b) a %+ b ; SHA512_JOB* sha512_mb_mgr_flush_sse(SHA512_MB_JOB_MGR *state) ; arg 1 : rcx : state global sha512_mb_mgr_flush_sse:function sha512_mb_mgr_flush_sse: sub rsp, STACK_SPACE mov [rsp + _GPR_SAVE + 8*0], rbx mov [rsp + _GPR_SAVE + 8*1], r12 %ifidn __OUTPUT_FORMAT__, win64 mov [rsp + _GPR_SAVE + 8*2], rsi movdqa [rsp + _XMM_SAVE + 16*0], xmm6 movdqa [rsp + _XMM_SAVE + 16*1], xmm7 movdqa [rsp + _XMM_SAVE + 16*2], xmm8 movdqa [rsp + _XMM_SAVE + 16*3], xmm9 movdqa [rsp + _XMM_SAVE + 16*4], xmm10 movdqa [rsp + _XMM_SAVE + 16*5], xmm11 movdqa [rsp + _XMM_SAVE + 16*6], xmm12 movdqa [rsp + _XMM_SAVE + 16*7], xmm13 movdqa [rsp + _XMM_SAVE + 16*8], xmm14 movdqa [rsp + _XMM_SAVE + 16*9], xmm15 %endif mov unused_lanes, [state + _unused_lanes] bt unused_lanes, 16+7 jc return_null ; find a lane with a non-null job xor idx, idx cmp qword [state + _ldata + 1 * _LANE_DATA_size + _job_in_lane], 0 cmovne idx, [one] ; copy idx to empty lanes copy_lane_data: mov tmp, [state + _args + _data_ptr + 8*idx] %assign I 0 %rep 2 cmp qword [state + _ldata + I * _LANE_DATA_size + _job_in_lane], 0 jne APPEND(skip_,I) mov [state + _args + _data_ptr + 8*I], tmp mov dword [state + _lens + 4 + 8*I], 0xFFFFFFFF APPEND(skip_,I): %assign I (I+1) %endrep ; Find min length mov lens0, [state + _lens + 0*8] mov idx, lens0 mov lens1, [state + _lens + 1*8] cmp lens1, idx cmovb idx, lens1 mov len2, idx and idx, 0xF and len2, ~0xFF jz len_is_0 sub lens0, len2 sub lens1, len2 shr len2, 32 mov [state + _lens + 0*8], lens0 mov [state + _lens + 1*8], lens1 ; "state" and "args" are the same address, arg1 ; len is arg2 call sha512_mb_x2_sse ; state and idx are intact len_is_0: ; process completed job "idx" imul lane_data, idx, _LANE_DATA_size lea lane_data, [state + _ldata + lane_data] mov job_rax, [lane_data + _job_in_lane] mov qword [lane_data + _job_in_lane], 0 mov dword [job_rax + _status], STS_COMPLETED mov unused_lanes, [state + _unused_lanes] shl unused_lanes, 8 or unused_lanes, idx mov [state + _unused_lanes], unused_lanes sub dword [state + _num_lanes_inuse], 1 movq xmm0, [state + _args_digest + 8*idx + 0*32] pinsrq xmm0, [state + _args_digest + 8*idx + 1*32], 1 movq xmm1, [state + _args_digest + 8*idx + 2*32] pinsrq xmm1, [state + _args_digest + 8*idx + 3*32], 1 movq xmm2, [state + _args_digest + 8*idx + 4*32] pinsrq xmm2, [state + _args_digest + 8*idx + 5*32], 1 movq xmm3, [state + _args_digest + 8*idx + 6*32] pinsrq xmm3, [state + _args_digest + 8*idx + 7*32], 1 movdqa [job_rax + _result_digest + 0*16], xmm0 movdqa [job_rax + _result_digest + 1*16], xmm1 movdqa [job_rax + _result_digest + 2*16], xmm2 movdqa [job_rax + _result_digest + 3*16], xmm3 return: %ifidn __OUTPUT_FORMAT__, win64 movdqa xmm6, [rsp + _XMM_SAVE + 16*0] movdqa xmm7, [rsp + _XMM_SAVE + 16*1] movdqa xmm8, [rsp + _XMM_SAVE + 16*2] movdqa xmm9, [rsp + _XMM_SAVE + 16*3] movdqa xmm10, [rsp + _XMM_SAVE + 16*4] movdqa xmm11, [rsp + _XMM_SAVE + 16*5] movdqa xmm12, [rsp + _XMM_SAVE + 16*6] movdqa xmm13, [rsp + _XMM_SAVE + 16*7] movdqa xmm14, [rsp + _XMM_SAVE + 16*8] movdqa xmm15, [rsp + _XMM_SAVE + 16*9] mov rsi, [rsp + _GPR_SAVE + 8*2] %endif mov rbx, [rsp + _GPR_SAVE + 8*0] mov r12, [rsp + _GPR_SAVE + 8*1] add rsp, STACK_SPACE ret return_null: xor job_rax, job_rax jmp return section .data align=16 align 16 one: dq 1 two: dq 2 three: dq 3
/*++ Copyright (c) 2012 Microsoft Corporation Module Name: nlsat_evaluator.cpp Abstract: Helper class for computing the infeasible intervals of an arithmetic literal. Author: Leonardo de Moura (leonardo) 2012-01-12. Revision History: --*/ #include "nlsat/nlsat_evaluator.h" #include "nlsat/nlsat_solver.h" namespace nlsat { struct evaluator::imp { solver& m_solver; assignment const & m_assignment; pmanager & m_pm; small_object_allocator & m_allocator; anum_manager & m_am; interval_set_manager m_ism; scoped_anum_vector m_tmp_values; scoped_anum_vector m_add_roots_tmp; scoped_anum_vector m_inf_tmp; // sign tables: light version struct sign_table { anum_manager & m_am; struct section { anum m_root; unsigned m_pos; }; svector<section> m_sections; unsigned_vector m_sorted_sections; // refs to m_sections unsigned_vector m_poly_sections; // refs to m_sections svector<polynomial::sign> m_poly_signs; struct poly_info { unsigned m_num_roots; unsigned m_first_section; // idx in m_poly_sections; unsigned m_first_sign; // idx in m_poly_signs; poly_info(unsigned num, unsigned first_section, unsigned first_sign): m_num_roots(num), m_first_section(first_section), m_first_sign(first_sign) { } }; svector<poly_info> m_info; sign_table(anum_manager & am):m_am(am) {} ~sign_table() { reset(); } void reset() { unsigned sz = m_sections.size(); for (unsigned i = 0; i < sz; i++) m_am.del(m_sections[i].m_root); m_sections.reset(); m_sorted_sections.reset(); m_poly_sections.reset(); m_poly_signs.reset(); m_info.reset(); } unsigned mk_section(anum & v, unsigned pos) { unsigned new_id = m_sections.size(); m_sections.push_back(section()); section & new_s = m_sections.back(); m_am.set(new_s.m_root, v); new_s.m_pos = pos; return new_id; } // Merge the new roots of a polynomial p into m_sections & m_sorted_sections. // Store the section ids for the new roots in p_section_ids unsigned_vector new_sorted_sections; void merge(anum_vector & roots, unsigned_vector & p_section_ids) { new_sorted_sections.reset(); // new m_sorted_sections unsigned i1 = 0; unsigned sz1 = m_sorted_sections.size(); unsigned i2 = 0; unsigned sz2 = roots.size(); unsigned j = 0; while (i1 < sz1 && i2 < sz2) { unsigned s1_id = m_sorted_sections[i1]; section & s1 = m_sections[s1_id]; anum & r2 = roots[i2]; int c = m_am.compare(s1.m_root, r2); if (c == 0) { new_sorted_sections.push_back(s1_id); p_section_ids.push_back(s1_id); s1.m_pos = j; i1++; i2++; } else if (c < 0) { new_sorted_sections.push_back(s1_id); s1.m_pos = j; i1++; } else { // create new section unsigned new_id = mk_section(r2, j); // new_sorted_sections.push_back(new_id); p_section_ids.push_back(new_id); i2++; } j++; } SASSERT(i1 == sz1 || i2 == sz2); while (i1 < sz1) { unsigned s1_id = m_sorted_sections[i1]; section & s1 = m_sections[s1_id]; new_sorted_sections.push_back(s1_id); s1.m_pos = j; i1++; j++; } while (i2 < sz2) { anum & r2 = roots[i2]; // create new section unsigned new_id = mk_section(r2, j); // new_sorted_sections.push_back(new_id); p_section_ids.push_back(new_id); i2++; j++; } m_sorted_sections.swap(new_sorted_sections); } /** \brief Add polynomial with the given roots and signs. */ unsigned_vector p_section_ids; void add(anum_vector & roots, svector<polynomial::sign> & signs) { p_section_ids.reset(); if (!roots.empty()) merge(roots, p_section_ids); unsigned first_sign = m_poly_signs.size(); unsigned first_section = m_poly_sections.size(); unsigned num_poly_signs = signs.size(); // Must normalize signs since we use arithmetic operations such as * // during evaluation. // Without normalization, overflows may happen, and wrong results may be produced. for (unsigned i = 0; i < num_poly_signs; i++) m_poly_signs.push_back(signs[i]); m_poly_sections.append(p_section_ids); m_info.push_back(poly_info(roots.size(), first_section, first_sign)); SASSERT(check_invariant()); } /** \brief Add constant polynomial */ void add_const(polynomial::sign sign) { unsigned first_sign = m_poly_signs.size(); unsigned first_section = m_poly_sections.size(); m_poly_signs.push_back(sign); m_info.push_back(poly_info(0, first_section, first_sign)); } unsigned num_cells() const { return m_sections.size() * 2 + 1; } /** \brief Return true if the given cell is a section (i.e., root) */ bool is_section(unsigned c) const { SASSERT(c < num_cells()); return c % 2 == 1; } /** \brief Return true if the given cell is a sector (i.e., an interval between roots, or (-oo, min-root), or (max-root, +oo)). */ bool is_sector(unsigned c) const { SASSERT(c < num_cells()); return c % 2 == 0; } /** \brief Return the root id associated with the given section. \pre is_section(c) */ unsigned get_root_id(unsigned c) const { SASSERT(is_section(c)); return m_sorted_sections[c/2]; } // Return value of root idx. // If idx == UINT_MAX, it return zero (this is a hack to simplify the infeasible_intervals method anum const & get_root(unsigned idx) const { static anum zero; if (idx == UINT_MAX) return zero; SASSERT(idx < m_sections.size()); return m_sections[idx].m_root; } static unsigned section_id_to_cell_id(unsigned section_id) { return section_id*2 + 1; } // Return the cell_id of the root i of pinfo unsigned cell_id(poly_info const & pinfo, unsigned i) const { return section_id_to_cell_id(m_sections[m_poly_sections[pinfo.m_first_section + i]].m_pos); } // Return the sign idx of pinfo polynomial::sign sign(poly_info const & pinfo, unsigned i) const { return m_poly_signs[pinfo.m_first_sign + i]; } #define LINEAR_SEARCH_THRESHOLD 8 polynomial::sign sign_at(unsigned info_id, unsigned c) const { poly_info const & pinfo = m_info[info_id]; unsigned num_roots = pinfo.m_num_roots; if (num_roots < LINEAR_SEARCH_THRESHOLD) { unsigned i = 0; for (; i < num_roots; i++) { unsigned section_cell_id = cell_id(pinfo, i); if (section_cell_id == c) return polynomial::sign_zero; else if (section_cell_id > c) break; } return sign(pinfo, i); } else { if (num_roots == 0) return sign(pinfo, 0); unsigned root_1_cell_id = cell_id(pinfo, 0); unsigned root_n_cell_id = cell_id(pinfo, num_roots - 1); if (c < root_1_cell_id) return sign(pinfo, 0); else if (c == root_1_cell_id || c == root_n_cell_id) return polynomial::sign_zero; else if (c > root_n_cell_id) return sign(pinfo, num_roots); int low = 0; int high = num_roots-1; while (true) { SASSERT(0 <= low && high < static_cast<int>(num_roots)); SASSERT(cell_id(pinfo, low) < c); SASSERT(c < cell_id(pinfo, high)); if (high == low + 1) { SASSERT(cell_id(pinfo, low) < c); SASSERT(c < cell_id(pinfo, low+1)); return sign(pinfo, low+1); } SASSERT(high > low + 1); int mid = low + ((high - low)/2); SASSERT(low < mid && mid < high); unsigned mid_cell_id = cell_id(pinfo, mid); if (mid_cell_id == c) { return polynomial::sign_zero; } if (c < mid_cell_id) { high = mid; } else { SASSERT(mid_cell_id < c); low = mid; } } } } bool check_invariant() const { SASSERT(m_sections.size() == m_sorted_sections.size()); for (unsigned i = 0; i < m_sorted_sections.size(); i++) { SASSERT(m_sorted_sections[i] < m_sections.size()); SASSERT(m_sections[m_sorted_sections[i]].m_pos == i); } unsigned total_num_sections = 0; unsigned total_num_signs = 0; for (unsigned i = 0; i < m_info.size(); i++) { SASSERT(m_info[i].m_first_section <= m_poly_sections.size()); SASSERT(m_info[i].m_num_roots == 0 || m_info[i].m_first_section < m_poly_sections.size()); SASSERT(m_info[i].m_first_sign < m_poly_signs.size()); total_num_sections += m_info[i].m_num_roots; total_num_signs += m_info[i].m_num_roots + 1; } SASSERT(total_num_sections == m_poly_sections.size()); SASSERT(total_num_signs == m_poly_signs.size()); return true; } // Display sign table for the given variable void display(std::ostream & out) const { out << "sections:\n "; for (unsigned i = 0; i < m_sections.size(); i++) { if (i > 0) out << " < "; m_am.display_decimal(out, m_sections[m_sorted_sections[i]].m_root); } out << "\n"; out << "sign variations:\n"; for (unsigned i = 0; i < m_info.size(); i++) { out << " "; for (unsigned j = 0; j < num_cells(); j++) { if (j > 0) out << " "; auto s = sign_at(i, j); if (s < 0) out << "-"; else if (s == 0) out << "0"; else out << "+"; } out << "\n"; } } // Display sign table for the given variable void display_raw(std::ostream & out) const { out << "sections:\n "; for (unsigned i = 0; i < m_sections.size(); i++) { if (i > 0) out << " < "; m_am.display_decimal(out, m_sections[m_sorted_sections[i]].m_root); } out << "\n"; out << "poly_info:\n"; for (unsigned i = 0; i < m_info.size(); i++) { out << " roots:"; poly_info const & info = m_info[i]; for (unsigned j = 0; j < info.m_num_roots; j++) { out << " "; out << m_poly_sections[info.m_first_section+j]; } out << ", signs:"; for (unsigned j = 0; j < info.m_num_roots+1; j++) { out << " "; int s = m_poly_signs[info.m_first_sign+j]; if (s < 0) out << "-"; else if (s == 0) out << "0"; else out << "+"; } out << "\n"; } } }; sign_table m_sign_table_tmp; imp(solver& s, assignment const & x2v, pmanager & pm, small_object_allocator & allocator): m_solver(s), m_assignment(x2v), m_pm(pm), m_allocator(allocator), m_am(m_assignment.am()), m_ism(m_am, allocator), m_tmp_values(m_am), m_add_roots_tmp(m_am), m_inf_tmp(m_am), m_sign_table_tmp(m_am) { } var max_var(poly const * p) const { return m_pm.max_var(p); } /** \brief Return the sign of the polynomial in the current interpretation. \pre All variables of p are assigned in the current interpretation. */ polynomial::sign eval_sign(poly * p) { // TODO: check if it is useful to cache results SASSERT(m_assignment.is_assigned(max_var(p))); return m_am.eval_sign_at(polynomial_ref(p, m_pm), m_assignment); } bool satisfied(int sign, atom::kind k) { return (sign == 0 && (k == atom::EQ || k == atom::ROOT_EQ || k == atom::ROOT_LE || k == atom::ROOT_GE)) || (sign < 0 && (k == atom::LT || k == atom::ROOT_LT || k == atom::ROOT_LE)) || (sign > 0 && (k == atom::GT || k == atom::ROOT_GT || k == atom::ROOT_GE)); } bool satisfied(int sign, atom::kind k, bool neg) { bool r = satisfied(sign, k); return neg ? !r : r; } bool eval_ineq(ineq_atom * a, bool neg) { SASSERT(m_assignment.is_assigned(a->max_var())); // all variables of a were already assigned... atom::kind k = a->get_kind(); unsigned sz = a->size(); int sign = 1; for (unsigned i = 0; i < sz; i++) { int curr_sign = eval_sign(a->p(i)); if (a->is_even(i) && curr_sign < 0) curr_sign = 1; sign = sign * curr_sign; if (sign == 0) break; } return satisfied(sign, k, neg); } bool eval_root(root_atom * a, bool neg) { SASSERT(m_assignment.is_assigned(a->max_var())); // all variables of a were already assigned... atom::kind k = a->get_kind(); scoped_anum_vector & roots = m_tmp_values; roots.reset(); m_am.isolate_roots(polynomial_ref(a->p(), m_pm), undef_var_assignment(m_assignment, a->x()), roots); TRACE("nlsat_evaluator", m_solver.display(tout << (neg?"!":""), *a); tout << "\n"; if (roots.empty()) { tout << "No roots\n"; } else { tout << "Roots for "; for (unsigned i = 0; i < roots.size(); ++i) { m_am.display_interval(tout, roots[i]); tout << " "; } tout << "\n"; } m_assignment.display(tout); ); SASSERT(a->i() > 0); if (a->i() > roots.size()) { return neg; } int sign = m_am.compare(m_assignment.value(a->x()), roots[a->i() - 1]); return satisfied(sign, k, neg); } bool eval(atom * a, bool neg) { return a->is_ineq_atom() ? eval_ineq(to_ineq_atom(a), neg) : eval_root(to_root_atom(a), neg); } svector<polynomial::sign> m_add_signs_tmp; void add(poly * p, var x, sign_table & t) { SASSERT(m_pm.max_var(p) <= x); if (m_pm.max_var(p) < x) { t.add_const(eval_sign(p)); } else { // isolate roots of p scoped_anum_vector & roots = m_add_roots_tmp; svector<polynomial::sign> & signs = m_add_signs_tmp; roots.reset(); signs.reset(); TRACE("nlsat_evaluator", tout << "x: " << x << " max_var(p): " << m_pm.max_var(p) << "\n";); // Note: I added undef_var_assignment in the following statement, to allow us to obtain the infeasible interval sets // even when the maximal variable is assigned. I need this feature to minimize conflict cores. m_am.isolate_roots(polynomial_ref(p, m_pm), undef_var_assignment(m_assignment, x), roots, signs); t.add(roots, signs); } } // Evaluate the sign of p1^e1*...*pn^en (of atom a) in cell c of table t. polynomial::sign sign_at(ineq_atom * a, sign_table const & t, unsigned c) const { auto sign = polynomial::sign_pos; unsigned num_ps = a->size(); for (unsigned i = 0; i < num_ps; i++) { polynomial::sign curr_sign = t.sign_at(i, c); TRACE("nlsat_evaluator_bug", tout << "sign of i: " << i << " at cell " << c << "\n"; m_pm.display(tout, a->p(i)); tout << "\nsign: " << curr_sign << "\n";); if (a->is_even(i) && curr_sign < 0) curr_sign = polynomial::sign_pos; sign = sign * curr_sign; if (sign == polynomial::sign_zero) break; } return sign; } interval_set_ref infeasible_intervals(ineq_atom * a, bool neg, clause const* cls) { sign_table & table = m_sign_table_tmp; table.reset(); unsigned num_ps = a->size(); var x = a->max_var(); for (unsigned i = 0; i < num_ps; i++) { add(a->p(i), x, table); TRACE("nlsat_evaluator_bug", tout << "table after:\n"; m_pm.display(tout, a->p(i)); tout << "\n"; table.display_raw(tout);); } TRACE("nlsat_evaluator", tout << "sign table for:\n"; for (unsigned i = 0; i < num_ps; i++) { m_pm.display(tout, a->p(i)); tout << "\n"; } table.display(tout);); interval_set_ref result(m_ism); interval_set_ref set(m_ism); literal jst(a->bvar(), neg); atom::kind k = a->get_kind(); anum dummy; bool prev_sat = true; bool prev_inf = true; bool prev_open = true; unsigned prev_root_id = UINT_MAX; unsigned num_cells = table.num_cells(); for (unsigned c = 0; c < num_cells; c++) { TRACE("nlsat_evaluator", tout << "cell: " << c << "\n"; tout << "prev_sat: " << prev_sat << "\n"; tout << "prev_inf: " << prev_inf << "\n"; tout << "prev_open: " << prev_open << "\n"; tout << "prev_root_id: " << prev_root_id << "\n"; tout << "processing cell: " << c << "\n"; tout << "interval_set so far:\n" << result << "\n";); int sign = sign_at(a, table, c); TRACE("nlsat_evaluator", tout << "sign: " << sign << "\n";); if (satisfied(sign, k, neg)) { // current cell is satisfied if (!prev_sat) { SASSERT(c > 0); // add interval bool curr_open; unsigned curr_root_id; if (table.is_section(c)) { curr_open = true; curr_root_id = table.get_root_id(c); } else { SASSERT(table.is_section(c-1)); curr_open = false; curr_root_id = table.get_root_id(c-1); } set = m_ism.mk(prev_open, prev_inf, table.get_root(prev_root_id), curr_open, false, table.get_root(curr_root_id), jst, cls); result = m_ism.mk_union(result, set); prev_sat = true; } } else { // current cell is not satisfied if (prev_sat) { if (c == 0) { if (num_cells == 1) { // (-oo, oo) result = m_ism.mk(true, true, dummy, true, true, dummy, jst, cls); } else { // save -oo as beginning of infeasible interval prev_open = true; prev_inf = true; prev_root_id = UINT_MAX; } } else { SASSERT(c > 0); prev_inf = false; if (table.is_section(c)) { prev_open = false; prev_root_id = table.get_root_id(c); TRACE("nlsat_evaluator", tout << "updated prev_root_id: " << prev_root_id << " using cell: " << c << "\n";); } else { SASSERT(table.is_section(c-1)); prev_open = true; prev_root_id = table.get_root_id(c-1); TRACE("nlsat_evaluator", tout << "updated prev_root_id: " << prev_root_id << " using cell: " << (c - 1) << "\n";); } } prev_sat = false; } if (c == num_cells - 1) { // last cell add interval with (prev, oo) set = m_ism.mk(prev_open, prev_inf, table.get_root(prev_root_id), true, true, dummy, jst, cls); result = m_ism.mk_union(result, set); } } } TRACE("nlsat_evaluator", tout << "interval_set: " << result << "\n";); return result; } interval_set_ref infeasible_intervals(root_atom * a, bool neg, clause const* cls) { atom::kind k = a->get_kind(); unsigned i = a->i(); SASSERT(i > 0); literal jst(a->bvar(), neg); anum dummy; scoped_anum_vector & roots = m_tmp_values; roots.reset(); var x = a->max_var(); // Note: I added undef_var_assignment in the following statement, to allow us to obtain the infeasible interval sets // even when the maximal variable is assigned. I need this feature to minimize conflict cores. m_am.isolate_roots(polynomial_ref(a->p(), m_pm), undef_var_assignment(m_assignment, x), roots); interval_set_ref result(m_ism); if (i > roots.size()) { // p does have sufficient roots // atom is false by definition if (neg) { result = m_ism.mk_empty(); } else { result = m_ism.mk(true, true, dummy, true, true, dummy, jst, cls); // (-oo, oo) } } else { anum const & r_i = roots[i-1]; switch (k) { case atom::ROOT_EQ: if (neg) { result = m_ism.mk(false, false, r_i, false, false, r_i, jst, cls); // [r_i, r_i] } else { interval_set_ref s1(m_ism), s2(m_ism); s1 = m_ism.mk(true, true, dummy, true, false, r_i, jst, cls); // (-oo, r_i) s2 = m_ism.mk(true, false, r_i, true, true, dummy, jst, cls); // (r_i, oo) result = m_ism.mk_union(s1, s2); } break; case atom::ROOT_LT: if (neg) result = m_ism.mk(true, true, dummy, true, false, r_i, jst, cls); // (-oo, r_i) else result = m_ism.mk(false, false, r_i, true, true, dummy, jst, cls); // [r_i, oo) break; case atom::ROOT_GT: if (neg) result = m_ism.mk(true, false, r_i, true, true, dummy, jst, cls); // (r_i, oo) else result = m_ism.mk(true, true, dummy, false, false, r_i, jst, cls); // (-oo, r_i] break; case atom::ROOT_LE: if (neg) result = m_ism.mk(true, true, dummy, false, false, r_i, jst, cls); // (-oo, r_i] else result = m_ism.mk(true, false, r_i, true, true, dummy, jst, cls); // (r_i, oo) break; case atom::ROOT_GE: if (neg) result = m_ism.mk(false, false, r_i, true, true, dummy, jst, cls); // [r_i, oo) else result = m_ism.mk(true, true, dummy, true, false, r_i, jst, cls); // (-oo, r_i) break; default: UNREACHABLE(); break; } } TRACE("nlsat_evaluator", tout << "interval_set: " << result << "\n";); return result; } interval_set_ref infeasible_intervals(atom * a, bool neg, clause const* cls) { return a->is_ineq_atom() ? infeasible_intervals(to_ineq_atom(a), neg, cls) : infeasible_intervals(to_root_atom(a), neg, cls); } }; evaluator::evaluator(solver& s, assignment const & x2v, pmanager & pm, small_object_allocator & allocator) { m_imp = alloc(imp, s, x2v, pm, allocator); } evaluator::~evaluator() { dealloc(m_imp); } interval_set_manager & evaluator::ism() const { return m_imp->m_ism; } bool evaluator::eval(atom * a, bool neg) { return m_imp->eval(a, neg); } interval_set_ref evaluator::infeasible_intervals(atom * a, bool neg, clause const* cls) { return m_imp->infeasible_intervals(a, neg, cls); } void evaluator::push() { // do nothing } void evaluator::pop(unsigned num_scopes) { // do nothing } };
handle_input: .var pra = $dc00 //CIA#1 Port Register A .var prb = $dc01 //CIA#1 Port Register B .var ddra = $dc02 // CIA#1 (Data Direction Register A) .var ddrb = $dc03 // CIA#1 (Data Direction Register B) lda #$FF sta ddra // set data register a to output lda #$00 sta ddrb // set data register b to input ///keyboard matrix scan jsr check_up_keys //check for up key ('w' and 'o' combinations) jsr check_down_keys //check for down key ('s' and 'l') combinations rts check_down_keys: lda #%11011101 sta pra // select third keyboard row lda prb // load column info and #%00100100 //check if 's' and 'l' is pressed beq try_move_down_both lda prb // load column info and #%00000100 //check if 's' is pressed beq try_move_down_r lda prb // load column info and #%00100000 //check if 'l' is pressed beq try_move_down_l rts check_up_keys: lda #%11101101 sta pra // select second and fifth keyboard rows lda prb // load column info and #%01000010 // check if 'w' and 'o' was pressed beq try_move_up_both lda prb // load column info and #%00000010 // check if 'w' was pressed beq try_move_up_l //l is for left lda prb // load column info and #%01000000 // check if 'o' was pressed beq try_move_up_r rts try_move_up_r: //try to move, if no border collision lda $d001 cmp #$33 bcs move_up_r // if position >= $33, then move rts try_move_up_both: jsr try_move_up_r jsr try_move_up_l rts try_move_up_l: lda $d003 cmp #$33 bcs move_up_l // if position >= $33, then move rts move_up_r: dec $d001 //decrease sprite 1 y-coord dec $d001 dec $d001 rts move_up_l: dec $d003 //decrease sprite 1 y-coord dec $d003 dec $d003 rts try_move_down_r: lda #$cf cmp $d001 bcs move_down_r // if position <= $cf, branch rts try_move_down_l: lda #$cf cmp $d003 bcs move_down_l // if position <= $cf, branch rts move_down_r: inc $d001 //decrease sprite 1 y-coord inc $d001 inc $d001 rts try_move_down_both: jsr try_move_down_r jsr try_move_down_l rts move_down_l: inc $d003 //decrease sprite 1 y-coord inc $d003 inc $d003 rts
; A101399: a(0) = 1, a(1) = 2, a(2) = 5; for n >= 3, a(n) = a(n-1) + 2*a(n-2) + a(n-3). ; 1,2,5,10,22,47,101,217,466,1001,2150,4618,9919,21305,45761,98290,211117,453458,973982,2092015,4493437,9651449,20730338,44526673,95638798,205422482,441226751,947710513,2035586497,4372234274,9391117781,20171172826,43325642662,93059106095,199881564245,429325419097,922147653682,1980680056121,4254300782582,9137808548506,19627090169791,42157008049385,90548996937473,194490103206034,417745105130365,897274308479906,1927254621946670,4139548344036847,8891331896410093 mul $0,2 cal $0,97333 ; Sum k=0..n, C(n-k, floor(k/2)). mov $1,$0
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r8 push %rbp push %rbx push %rdi push %rdx lea addresses_normal_ht+0x18030, %rdx nop nop nop nop xor $3881, %rbp mov (%rdx), %r8d and $36891, %rdi lea addresses_WC_ht+0x13f50, %r13 nop and $39119, %r8 movb $0x61, (%r13) nop nop nop sub %rbp, %rbp lea addresses_D_ht+0x10130, %rbp nop nop nop nop cmp %rbx, %rbx movw $0x6162, (%rbp) nop nop nop nop xor $65520, %r8 lea addresses_A_ht+0x9130, %rdi nop nop cmp %rbx, %rbx mov $0x6162636465666768, %rdx movq %rdx, %xmm5 movups %xmm5, (%rdi) nop nop nop inc %rdi pop %rdx pop %rdi pop %rbx pop %rbp pop %r8 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %rax push %rbp push %rcx push %rdx push %rsi // Load lea addresses_PSE+0x18530, %rsi nop nop nop nop nop cmp %rdx, %rdx mov (%rsi), %r13w nop cmp $8159, %r13 // Store lea addresses_WC+0xa130, %rcx sub %rax, %rax mov $0x5152535455565758, %rsi movq %rsi, %xmm5 vmovups %ymm5, (%rcx) nop nop cmp $21671, %rdx // Load lea addresses_A+0x1c530, %rbp sub $36122, %rcx movups (%rbp), %xmm1 vpextrq $0, %xmm1, %rsi nop nop nop dec %rsi // Faulty Load lea addresses_A+0x1c530, %rbp nop nop nop nop and %rcx, %rcx movb (%rbp), %al lea oracles, %r13 and $0xff, %rax shlq $12, %rax mov (%r13,%rax,1), %rax pop %rsi pop %rdx pop %rcx pop %rbp pop %rax pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_PSE', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC', 'size': 32, 'AVXalign': False}} {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_A', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': True, 'congruent': 5, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}} {'35': 21828, '00': 1} 00 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
SECTION "Map_318E", ROM0[$B800] Map_318E_Header: hdr_tileset 17 hdr_dimensions 6, 6 hdr_pointers_a Map_318E_Blocks, Map_318E_TextPointers hdr_pointers_b Map_318E_Script, Map_318E_Objects hdr_pointers_c Map_318E_InitScript, Map_318E_RAMScript hdr_palette $06 hdr_music MUSIC_DUNGEON3, AUDIO_3 hdr_connection NORTH, $0000, 0, 0 hdr_connection SOUTH, $0000, 0, 0 hdr_connection WEST, $0000, 0, 0 hdr_connection EAST, $0000, 0, 0 Map_318E_Objects: hdr_border $19 hdr_warp_count 2 hdr_warp 8, 8, 3, 3, $318F hdr_warp 3, 3, 8, 8, $318D hdr_sign_count 1 hdr_signpost 5, 5, $01 hdr_object_count 0 Map_318E_RAMScript: rs_end Map_318E_Blocks: db $2c,$1d,$1d,$1d,$1d,$2b db $1a,$3e,$01,$01,$01,$18 db $1a,$01,$2a,$01,$01,$18 db $1a,$01,$01,$0d,$04,$18 db $1a,$01,$01,$07,$27,$18 db $19,$15,$15,$15,$15,$19 Map_318E_TextPointers: dw Map_318E_TX1 Map_318E_InitScript: ld c, EVENT_CRACKER_CAVERN_CLEARED call TestEventFlag ret nc ld a, $01 ld [$c737], a ret Map_318E_Script: ret Map_318E_TX1: TX_ASM jp EnhancedTextOnly text "Cracker Cavern" next "Challenge IV" para "The final challenge." next "It should be easy for you" cont "at this point." para "Make the final step forward" next "and reverse-engineer the" cont "transmission protocol" cont "used to send data to the" cont "game server." para "To clear the final challenge," next "please send a packet with" cont "the command ID 0x77." para "The message body should" next "contain three bytes:" cont "0x13, 0x37, 0xCC." para "Once you're done, exit and" next "return back to this map." para "Good luck!" done
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromecast/graphics/cast_focus_client_aura.h" #include <memory> #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/test_window_delegate.h" #include "ui/aura/window.h" #include "ui/platform_window/platform_window_init_properties.h" namespace chromecast { namespace test { namespace { class TestWindow { public: TestWindow() : window_(&delegate_) { window_.Init(ui::LAYER_NOT_DRAWN); window_.Show(); } aura::test::TestWindowDelegate* delegate() { return &delegate_; } aura::Window* window() { return &window_; } private: aura::test::TestWindowDelegate delegate_; aura::Window window_; DISALLOW_COPY_AND_ASSIGN(TestWindow); }; } // namespace using CastFocusClientAuraTest = aura::test::AuraTestBase; TEST_F(CastFocusClientAuraTest, FocusableWindows) { std::unique_ptr<aura::WindowTreeHost> window_tree_host = aura::WindowTreeHost::Create( ui::PlatformWindowInitProperties{gfx::Rect(0, 0, 1280, 720)}); window_tree_host->InitHost(); window_tree_host->Show(); CastFocusClientAura focus_client; std::unique_ptr<TestWindow> test_window(new TestWindow); window_tree_host->window()->AddChild(test_window->window()); // Confirm that we can't add an un-focusable window. test_window->delegate()->set_can_focus(false); focus_client.FocusWindow(test_window->window()); EXPECT_FALSE(focus_client.GetFocusedWindow()); // Confirm that we can add a focusable window. test_window->delegate()->set_can_focus(true); focus_client.FocusWindow(test_window->window()); EXPECT_EQ(test_window->window(), focus_client.GetFocusedWindow()); // Confirm that the focused window loses focus when losing visibility. test_window->window()->Hide(); EXPECT_FALSE(focus_client.GetFocusedWindow()); // Confirm that we find a focusable window when it becomes visible. test_window->window()->Show(); EXPECT_EQ(test_window->window(), focus_client.GetFocusedWindow()); // Confirm that the focused window loses focus when it is destroyed. test_window.reset(); EXPECT_FALSE(focus_client.GetFocusedWindow()); } TEST_F(CastFocusClientAuraTest, ChildFocus) { std::unique_ptr<aura::WindowTreeHost> window_tree_host = aura::WindowTreeHost::Create( ui::PlatformWindowInitProperties{gfx::Rect(0, 0, 1280, 720)}); window_tree_host->InitHost(); window_tree_host->Show(); CastFocusClientAura focus_client; std::unique_ptr<TestWindow> parent(new TestWindow); parent->delegate()->set_can_focus(true); window_tree_host->window()->AddChild(parent->window()); std::unique_ptr<TestWindow> child(new TestWindow); child->delegate()->set_can_focus(true); parent->window()->AddChild(child->window()); // Confirm that the child window has the focus, not its top-level parent // window. focus_client.FocusWindow(child->window()); EXPECT_EQ(child->window(), focus_client.GetFocusedWindow()); // Confirm that removing the child window doesn't focus the parent window // (since we've never requested focus for the parent window). parent->window()->RemoveChild(child->window()); EXPECT_FALSE(focus_client.GetFocusedWindow()); // Confirm that we still have no focused window after re-adding the child // window, because we haven't requested focus. parent->window()->AddChild(child->window()); EXPECT_FALSE(focus_client.GetFocusedWindow()); // Request focus and confirm that the child is focused. focus_client.FocusWindow(child->window()); EXPECT_EQ(child->window(), focus_client.GetFocusedWindow()); } TEST_F(CastFocusClientAuraTest, ZOrder) { std::unique_ptr<aura::WindowTreeHost> window_tree_host = aura::WindowTreeHost::Create( ui::PlatformWindowInitProperties{gfx::Rect(0, 0, 1280, 720)}); window_tree_host->InitHost(); window_tree_host->Show(); CastFocusClientAura focus_client; // Add the window with the lowest z-order. std::unique_ptr<TestWindow> low(new TestWindow); low->delegate()->set_can_focus(true); low->window()->SetId(1); window_tree_host->window()->AddChild(low->window()); focus_client.FocusWindow(low->window()); EXPECT_EQ(low->window(), focus_client.GetFocusedWindow()); // Add the window with the highest z-order, and confirm that it gets focus. std::unique_ptr<TestWindow> high(new TestWindow); high->delegate()->set_can_focus(true); high->window()->SetId(3); window_tree_host->window()->AddChild(high->window()); focus_client.FocusWindow(high->window()); EXPECT_EQ(high->window(), focus_client.GetFocusedWindow()); // Add the window with the middle z-order, and confirm that focus remains with // the highest z-order window. std::unique_ptr<TestWindow> middle(new TestWindow); middle->delegate()->set_can_focus(true); middle->window()->SetId(2); window_tree_host->window()->AddChild(middle->window()); focus_client.FocusWindow(middle->window()); EXPECT_EQ(high->window(), focus_client.GetFocusedWindow()); // Confirm that requesting focus on the lower z-order windows leaves focus on // the highest z-order window. focus_client.FocusWindow(low->window()); EXPECT_EQ(high->window(), focus_client.GetFocusedWindow()); focus_client.FocusWindow(middle->window()); EXPECT_EQ(high->window(), focus_client.GetFocusedWindow()); // Confirm that focus moves to next highest window. high.reset(); EXPECT_EQ(middle->window(), focus_client.GetFocusedWindow()); // Confirm that focus moves to next highest window. middle.reset(); EXPECT_EQ(low->window(), focus_client.GetFocusedWindow()); // Confirm that there is no focused window. low.reset(); EXPECT_FALSE(focus_client.GetFocusedWindow()); } TEST_F(CastFocusClientAuraTest, ZOrderWithChildWindows) { std::unique_ptr<aura::WindowTreeHost> window_tree_host = aura::WindowTreeHost::Create( ui::PlatformWindowInitProperties{gfx::Rect(0, 0, 1280, 720)}); window_tree_host->InitHost(); window_tree_host->Show(); CastFocusClientAura focus_client; // Add the window with the highest z-order. std::unique_ptr<TestWindow> high_parent(new TestWindow); high_parent->window()->SetId(3); std::unique_ptr<TestWindow> high_child(new TestWindow); high_child->delegate()->set_can_focus(true); high_parent->window()->AddChild(high_child->window()); window_tree_host->window()->AddChild(high_parent->window()); focus_client.FocusWindow(high_child->window()); EXPECT_EQ(high_child->window(), focus_client.GetFocusedWindow()); // Add the window with the lowest z-order. std::unique_ptr<TestWindow> low_parent(new TestWindow); low_parent->window()->SetId(1); std::unique_ptr<TestWindow> low_child(new TestWindow); low_child->delegate()->set_can_focus(true); low_parent->window()->AddChild(low_child->window()); window_tree_host->window()->AddChild(low_parent->window()); focus_client.FocusWindow(low_child->window()); // Focus should remain with the child of the highest window. EXPECT_EQ(high_child->window(), focus_client.GetFocusedWindow()); } } // namespace test } // namespace chromecast
#include <stdio.h> #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_scanline_u.h" #include "agg_scanline_p.h" #include "agg_renderer_scanline.h" #include "agg_renderer_primitives.h" #include "agg_conv_curve.h" #include "agg_conv_stroke.h" #include "agg_conv_clip_polygon.h" #include "agg_gsv_text.h" #include "agg_pixfmt_rgb.h" #include "agg_platform_support.h" #include "agg_slider_ctrl.h" #include "agg_cbox_ctrl.h" #include "agg_rbox_ctrl.h" #include "agg_conv_clipper.h" #include "windows.h" enum flip_y_e { flip_y = true }; class spiral { public: spiral(double x, double y, double r1, double r2, double step, double start_angle=0) : m_x(x), m_y(y), m_r1(r1), m_r2(r2), m_step(step), m_start_angle(start_angle), m_angle(start_angle), m_da(agg::deg2rad(4.0)), m_dr(m_step / 90.0) { } void rewind(unsigned) { m_angle = m_start_angle; m_curr_r = m_r1; m_start = true; } unsigned vertex(double* x, double* y) { if(m_curr_r > m_r2) return agg::path_cmd_stop; *x = m_x + cos(m_angle) * m_curr_r; *y = m_y + sin(m_angle) * m_curr_r; m_curr_r += m_dr; m_angle += m_da; if(m_start) { m_start = false; return agg::path_cmd_move_to; } return agg::path_cmd_line_to; } private: double m_x; double m_y; double m_r1; double m_r2; double m_step; double m_start_angle; double m_angle; double m_curr_r; double m_da; double m_dr; bool m_start; }; namespace agg { // A simple counter of points and contours template<class Src> struct conv_poly_counter { unsigned m_contours; unsigned m_points; conv_poly_counter(Src& src) : m_src(&src), m_contours(0), m_points(0) {} void rewind(unsigned path_id) { m_contours = 0; m_points = 0; m_src->rewind(path_id); } unsigned vertex(double* x, double* y) { unsigned cmd = m_src->vertex(x, y); if(is_vertex(cmd)) ++m_points; if(is_move_to(cmd)) ++m_contours; return cmd; } private: Src* m_src; }; } void make_gb_poly(agg::path_storage& ps); void make_arrows(agg::path_storage& ps); class the_application : public agg::platform_support { agg::rbox_ctrl<agg::rgba8> m_polygons; agg::rbox_ctrl<agg::rgba8> m_operation; double m_x; double m_y; virtual void on_key(int x, int y, unsigned key, unsigned flags) { if(key == agg::key_escape) exit(0); } public: the_application(agg::pix_format_e format, bool flip_y) : agg::platform_support(format, flip_y), m_polygons (5.0, 5.0, 5.0+205.0, 110.0, !flip_y), m_operation(555.0, 5.0, 555.0+80.0, 130.0, !flip_y) { m_operation.add_item("None"); m_operation.add_item("OR"); m_operation.add_item("AND"); m_operation.add_item("XOR"); m_operation.add_item("A-B"); m_operation.add_item("B-A"); m_operation.cur_item(2); add_ctrl(m_operation); m_polygons.add_item("Two Simple Paths"); m_polygons.add_item("Closed Stroke"); m_polygons.add_item("Great Britain and Arrows"); m_polygons.add_item("Great Britain and Spiral"); m_polygons.add_item("Spiral and Glyph"); m_polygons.cur_item(3); add_ctrl(m_polygons); } template<class Scanline, class Ras, class Ren, class Clp> void perform_rendering(Scanline &sl, Ras &ras, Ren &ren, Clp &clp) { if(m_operation.cur_item() > 0) { ras.reset(); switch(m_operation.cur_item()) { case 1: clp.operation(agg::clipper_or); break; case 2: clp.operation(agg::clipper_and); break; case 3: clp.operation(agg::clipper_xor); break; case 4: clp.operation(agg::clipper_a_minus_b); break; case 5: clp.operation(agg::clipper_b_minus_a); break; } agg::conv_poly_counter<Clp> counter(clp); start_timer(); counter.rewind(0); double t1 = elapsed_time(); agg::path_storage ps; double x; double y; unsigned cmd; start_timer(); while(!agg::is_stop(cmd = counter.vertex(&x, &y))) { if(agg::is_move_to(cmd)) ps.move_to(x, y); else if(agg::is_line_to(cmd)) ps.line_to(x, y); else if(agg::is_close(cmd)) ps.close_polygon(); } ras.add_path(ps); ren.color(agg::rgba(0.25, 0.9, 0.25, 0.65)); agg::render_scanlines(ras, sl, ren); double t2 = elapsed_time(); agg::conv_stroke<agg::path_storage> stroke(ps); stroke.width(0.4); ras.add_path(stroke); ren.color(agg::rgba(0, 0, 0)); agg::render_scanlines(ras, sl, ren); char buf[100]; sprintf_s(buf, "Contours: %d Points: %d", counter.m_contours, counter.m_points); agg::gsv_text txt; agg::conv_stroke<agg::gsv_text> txt_stroke(txt); txt_stroke.width(1.5); txt_stroke.line_cap(agg::round_cap); txt.size(10.0); txt.start_point(250, 5); txt.text(buf); ras.add_path(txt_stroke); ren.color(agg::rgba(0.0, 0.0, 0.0)); agg::render_scanlines(ras, sl, ren); sprintf_s(buf, "Clipper=%.3fms Render=%.3fms", t1, t2); txt.start_point(250, 20); txt.text(buf); ras.add_path(txt_stroke); ren.color(agg::rgba(0.0, 0.0, 0.0)); agg::render_scanlines(ras, sl, ren); } } template<class Scanline, class Ras> unsigned render_clipper(Scanline& sl, Ras& ras) { agg::pixfmt_bgr24 pf(rbuf_window()); agg::renderer_base<agg::pixfmt_bgr24> rb(pf); agg::renderer_scanline_aa_solid<agg::renderer_base<agg::pixfmt_bgr24> > ren(rb); switch(m_polygons.cur_item()) { case 0: { //------------------------------------ // Two simple paths // agg::path_storage ps1; agg::path_storage ps2; agg::conv_clipper<agg::path_storage, agg::path_storage> clp(ps1, ps2, agg::clipper_or, agg::clipper_non_zero, agg::clipper_non_zero); double x = m_x - initial_width()/2 + 100; double y = m_y - initial_height()/2 + 100; ps1.move_to(x+140, y+145); ps1.line_to(x+225, y+44); ps1.line_to(x+296, y+219); ps1.close_polygon(); ps1.line_to(x+226, y+289); ps1.line_to(x+82, y+292); ps1.move_to(x+220, y+222); ps1.line_to(x+363, y+249); ps1.line_to(x+265, y+331); ps1.move_to(x+242, y+243); ps1.line_to(x+268, y+309); ps1.line_to(x+325, y+261); ps1.move_to(x+259, y+259); ps1.line_to(x+273, y+288); ps1.line_to(x+298, y+266); ps2.move_to(100+32, 100+77); ps2.line_to(100+473, 100+263); ps2.line_to(100+351, 100+290); ps2.line_to(100+354, 100+374); ras.reset(); ras.add_path(ps1); ren.color(agg::rgba(0, 0, 0, 0.1)); agg::render_scanlines(ras, sl, ren); ras.reset(); ras.add_path(ps2); ren.color(agg::rgba(0, 0.6, 0, 0.1)); agg::render_scanlines(ras, sl, ren); perform_rendering(sl, ras, ren, clp); } break; case 1: { //------------------------------------ // Closed stroke // agg::path_storage ps1; agg::path_storage ps2; agg::conv_stroke<agg::path_storage> stroke(ps2); stroke.width(10.0); agg::conv_clipper<agg::path_storage, agg::conv_stroke<agg::path_storage> > clp(ps1, stroke, agg::clipper_or, agg::clipper_non_zero, agg::clipper_non_zero); double x = m_x - initial_width()/2 + 100; double y = m_y - initial_height()/2 + 100; ps1.move_to(x+140, y+145); ps1.line_to(x+225, y+44); ps1.line_to(x+296, y+219); ps1.close_polygon(); ps1.line_to(x+226, y+289); ps1.line_to(x+82, y+292); ps1.move_to(x+220-50, y+222); ps1.line_to(x+265-50, y+331); ps1.line_to(x+363-50, y+249); ps1.close_polygon(agg::path_flags_ccw); ps2.move_to(100+32, 100+77); ps2.line_to(100+473, 100+263); ps2.line_to(100+351, 100+290); ps2.line_to(100+354, 100+374); ps2.close_polygon(); ras.reset(); ras.add_path(ps1); ren.color(agg::rgba(0, 0, 0, 0.1)); agg::render_scanlines(ras, sl, ren); ras.reset(); ras.add_path(stroke); ren.color(agg::rgba(0, 0.6, 0, 0.1)); agg::render_scanlines(ras, sl, ren); perform_rendering(sl, ras, ren, clp); } break; case 2: { //------------------------------------ // Great Britain and Arrows // agg::path_storage gb_poly; agg::path_storage arrows; make_gb_poly(gb_poly); make_arrows(arrows); agg::trans_affine mtx1; agg::trans_affine mtx2; mtx1 *= agg::trans_affine_translation(-1150, -1150); mtx1 *= agg::trans_affine_scaling(2.0); mtx2 = mtx1; mtx2 *= agg::trans_affine_translation(m_x - initial_width()/2, m_y - initial_height()/2); agg::conv_transform<agg::path_storage> trans_gb_poly(gb_poly, mtx1); agg::conv_transform<agg::path_storage> trans_arrows(arrows, mtx2); agg::conv_clipper<agg::conv_transform<agg::path_storage>, agg::conv_transform<agg::path_storage> > clp(trans_gb_poly, trans_arrows, agg::clipper_or, agg::clipper_non_zero, agg::clipper_non_zero); ras.add_path(trans_gb_poly); ren.color(agg::rgba(0.5, 0.5, 0, 0.1)); agg::render_scanlines(ras, sl, ren); agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke_gb_poly(trans_gb_poly); stroke_gb_poly.width(0.1); ras.add_path(stroke_gb_poly); ren.color(agg::rgba(0, 0, 0)); agg::render_scanlines(ras, sl, ren); ras.add_path(trans_arrows); ren.color(agg::rgba(0.0, 0.5, 0.5, 0.1)); agg::render_scanlines(ras, sl, ren); perform_rendering(sl, ras, ren, clp); } break; case 3: { //------------------------------------ // Great Britain and a Spiral // spiral sp(m_x, m_y, 10, 150, 30, 0.0); agg::conv_stroke<spiral> stroke(sp); stroke.width(15.0); agg::path_storage gb_poly; make_gb_poly(gb_poly); agg::trans_affine mtx; mtx *= agg::trans_affine_translation(-1150, -1150); mtx *= agg::trans_affine_scaling(2.0); agg::conv_transform<agg::path_storage> trans_gb_poly(gb_poly, mtx); agg::conv_clipper<agg::conv_transform<agg::path_storage>, agg::conv_stroke<spiral> > clp(trans_gb_poly, stroke, agg::clipper_or, agg::clipper_non_zero, agg::clipper_non_zero); ras.add_path(trans_gb_poly); ren.color(agg::rgba(0.5, 0.5, 0, 0.1)); agg::render_scanlines(ras, sl, ren); agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke_gb_poly(trans_gb_poly); stroke_gb_poly.width(0.1); ras.add_path(stroke_gb_poly); ren.color(agg::rgba(0, 0, 0)); agg::render_scanlines(ras, sl, ren); ras.add_path(stroke); ren.color(agg::rgba(0.0, 0.5, 0.5, 0.1)); agg::render_scanlines(ras, sl, ren); perform_rendering(sl, ras, ren, clp); } break; case 4: { //------------------------------------ // Spiral and glyph // spiral sp(m_x, m_y, 10, 150, 30, 0.0); agg::conv_stroke<spiral> stroke(sp); stroke.width(15.0); agg::path_storage glyph; glyph.move_to(28.47, 6.45); glyph.curve3(21.58, 1.12, 19.82, 0.29); glyph.curve3(17.19, -0.93, 14.21, -0.93); glyph.curve3(9.57, -0.93, 6.57, 2.25); glyph.curve3(3.56, 5.42, 3.56, 10.60); glyph.curve3(3.56, 13.87, 5.03, 16.26); glyph.curve3(7.03, 19.58, 11.99, 22.51); glyph.curve3(16.94, 25.44, 28.47, 29.64); glyph.line_to(28.47, 31.40); glyph.curve3(28.47, 38.09, 26.34, 40.58); glyph.curve3(24.22, 43.07, 20.17, 43.07); glyph.curve3(17.09, 43.07, 15.28, 41.41); glyph.curve3(13.43, 39.75, 13.43, 37.60); glyph.line_to(13.53, 34.77); glyph.curve3(13.53, 32.52, 12.38, 31.30); glyph.curve3(11.23, 30.08, 9.38, 30.08); glyph.curve3(7.57, 30.08, 6.42, 31.35); glyph.curve3(5.27, 32.62, 5.27, 34.81); glyph.curve3(5.27, 39.01, 9.57, 42.53); glyph.curve3(13.87, 46.04, 21.63, 46.04); glyph.curve3(27.59, 46.04, 31.40, 44.04); glyph.curve3(34.28, 42.53, 35.64, 39.31); glyph.curve3(36.52, 37.21, 36.52, 30.71); glyph.line_to(36.52, 15.53); glyph.curve3(36.52, 9.13, 36.77, 7.69); glyph.curve3(37.01, 6.25, 37.57, 5.76); glyph.curve3(38.13, 5.27, 38.87, 5.27); glyph.curve3(39.65, 5.27, 40.23, 5.62); glyph.curve3(41.26, 6.25, 44.19, 9.18); glyph.line_to(44.19, 6.45); glyph.curve3(38.72, -0.88, 33.74, -0.88); glyph.curve3(31.35, -0.88, 29.93, 0.78); glyph.curve3(28.52, 2.44, 28.47, 6.45); glyph.close_polygon(); glyph.move_to(28.47, 9.62); glyph.line_to(28.47, 26.66); glyph.curve3(21.09, 23.73, 18.95, 22.51); glyph.curve3(15.09, 20.36, 13.43, 18.02); glyph.curve3(11.77, 15.67, 11.77, 12.89); glyph.curve3(11.77, 9.38, 13.87, 7.06); glyph.curve3(15.97, 4.74, 18.70, 4.74); glyph.curve3(22.41, 4.74, 28.47, 9.62); glyph.close_polygon(); agg::trans_affine mtx; mtx *= agg::trans_affine_scaling(4.0); mtx *= agg::trans_affine_translation(220, 200); agg::conv_transform<agg::path_storage> trans(glyph, mtx); agg::conv_curve<agg::conv_transform<agg::path_storage> > curve(trans); agg::conv_clipper<agg::conv_stroke<spiral>, agg::conv_curve< agg::conv_transform< agg::path_storage> > > clp(stroke, curve, agg::clipper_or, agg::clipper_non_zero, agg::clipper_non_zero); ras.reset(); ras.add_path(stroke); ren.color(agg::rgba(0, 0, 0, 0.1)); agg::render_scanlines(ras, sl, ren); ras.reset(); ras.add_path(curve); ren.color(agg::rgba(0, 0.6, 0, 0.1)); agg::render_scanlines(ras, sl, ren); perform_rendering(sl, ras, ren, clp); } break; } return 0; } virtual void on_init() { m_x = width() / 2.0; m_y = height() / 2.0; } virtual void on_draw() { typedef agg::renderer_base<agg::pixfmt_bgr24> base_ren_type; agg::pixfmt_bgr24 pf(rbuf_window()); base_ren_type ren_base(pf); ren_base.clear(agg::rgba(1,1,1)); agg::scanline_u8 sl; agg::rasterizer_scanline_aa<> ras; render_clipper(sl, ras); agg::render_ctrl(ras, sl, ren_base, m_polygons); agg::render_ctrl(ras, sl, ren_base, m_operation); } virtual void on_mouse_button_down(int x, int y, unsigned flags) { if(flags & agg::mouse_left) { m_x = x; m_y = y; force_redraw(); } } virtual void on_mouse_move(int x, int y, unsigned flags) { if(flags & agg::mouse_left) { m_x = x; m_y = y; force_redraw(); } } }; int agg_main(int argc, char* argv[]) { the_application app(agg::pix_format_bgr24, flip_y); app.caption("AGG Example. Clipper"); if(app.init(640, 520, agg::window_resize)) { //replace the main window icon with Resource Icon #1 ... HWND w = GetActiveWindow(); HMODULE m = GetModuleHandle(0); //hInstance HANDLE small_ico = LoadImage(m, MAKEINTRESOURCE(1), IMAGE_ICON, 16, 16, 0); HANDLE big_ico = LoadImage(m, MAKEINTRESOURCE(1), IMAGE_ICON, 32, 32, 0); SendMessage(w, WM_SETICON, ICON_SMALL, (LPARAM)small_ico); SendMessage(w, WM_SETICON, ICON_BIG, (LPARAM)big_ico); //main message loop ... return app.run(); } return 0; }
include uXmx86asm.inc option casemap:none ifndef __X64__ .686P .xmm .model flat, c else .X64P .xmm option win64:11 option stackbase:rsp endif option frame:auto .code align 16 uXm_has_SEP proto VECCALL (byte) align 16 uXm_has_SEP proc VECCALL (byte) mov eax, 1 cpuid and edx, bit_SEP cmp edx, bit_SEP ; SEP support by microprocessor .if EQUAL? mov al, true .else mov al, false .endif ret uXm_has_SEP endp end ;.code
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 4.1.4 #12246 (Mac OS X x86_64) ;-------------------------------------------------------- .module scene_6_actors .optsdcc -mgbz80 ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _scene_6_actors .globl ___bank_scene_6_actors ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- .area _DATA ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- .area _INITIALIZED ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area _DABS (ABS) ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area _HOME .area _GSINIT .area _GSFINAL .area _GSINIT ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area _HOME .area _HOME ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area _CODE_255 .area _CODE_255 ___bank_scene_6_actors = 0x00ff _scene_6_actors: .db #0x00 ; 0 .dw #0x0300 .dw #0x0680 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x0f ; 15 .db #0xf8 ; -8 .db #0x07 ; 7 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x07 ; 7 .db #0x01 ; 1 .db #0x00 ; 0 .db #0x00 ; 0 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .byte ___bank_spritesheet_9 .dw _spritesheet_9 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .dw #0x0000 .db #0x00 ; 0 .db #0x01 ; 1 .dw #0x0000 .dw #0x0000 .db #0x00 ; 0 .dw #0x0600 .dw #0x0680 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x0f ; 15 .db #0xf8 ; -8 .db #0x07 ; 7 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x00 ; 0 .db #0x07 ; 7 .db #0x01 ; 1 .db #0x00 ; 0 .db #0x00 ; 0 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .db 0x00 .byte ___bank_spritesheet_9 .dw _spritesheet_9 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .byte #0x00 .dw #0x0000 .dw #0x0000 .db #0x00 ; 0 .db #0x01 ; 1 .dw #0x0000 .dw #0x0000 .area _INITIALIZER .area _CABS (ABS)
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r8 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_A_ht+0x1456f, %rdi nop xor %rbp, %rbp mov $0x6162636465666768, %rsi movq %rsi, (%rdi) nop nop nop nop xor %rcx, %rcx lea addresses_WC_ht+0x26ef, %rsi nop nop nop nop dec %r11 vmovups (%rsi), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r8 nop cmp $10222, %r8 lea addresses_WC_ht+0xad7, %rsi lea addresses_WT_ht+0x426f, %rdi nop nop nop nop and %r9, %r9 mov $99, %rcx rep movsq cmp %rcx, %rcx lea addresses_A_ht+0x12a6f, %r11 nop nop nop nop cmp %r8, %r8 mov $0x6162636465666768, %rbp movq %rbp, %xmm0 vmovups %ymm0, (%r11) nop nop nop nop cmp %rsi, %rsi lea addresses_WT_ht+0x1af1f, %r11 nop nop add %rsi, %rsi mov $0x6162636465666768, %rdi movq %rdi, %xmm7 movups %xmm7, (%r11) nop nop nop cmp %rdi, %rdi lea addresses_WT_ht+0x15ad3, %r8 nop nop add %rbp, %rbp movups (%r8), %xmm0 vpextrq $0, %xmm0, %r9 dec %r8 lea addresses_WT_ht+0x662f, %rbp clflush (%rbp) nop cmp $25963, %rsi vmovups (%rbp), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $0, %xmm4, %rdi nop nop nop nop nop xor $26670, %rbp lea addresses_D_ht+0x12a6f, %r9 nop nop nop dec %rsi movw $0x6162, (%r9) nop nop nop nop nop sub %r8, %r8 lea addresses_D_ht+0x1e82f, %rsi lea addresses_A_ht+0xd2df, %rdi nop nop nop nop nop add %r12, %r12 mov $9, %rcx rep movsq nop sub $16834, %r8 lea addresses_WC_ht+0x1ed56, %rsi add $43254, %r9 mov $0x6162636465666768, %rcx movq %rcx, (%rsi) nop and %rcx, %rcx lea addresses_D_ht+0x1e66f, %rsi nop cmp $26688, %r12 mov (%rsi), %r9 nop nop cmp %r9, %r9 lea addresses_D_ht+0x2e6f, %rcx nop inc %r11 mov (%rcx), %rbp nop xor $38625, %r12 lea addresses_WT_ht+0xf02f, %rsi lea addresses_WC_ht+0xa26f, %rdi nop nop nop sub $60287, %r12 mov $63, %rcx rep movsl and $13752, %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r9 push %rbp push %rbx push %rsi // Faulty Load lea addresses_D+0x1026f, %r10 clflush (%r10) nop nop inc %r9 mov (%r10), %r13w lea oracles, %r10 and $0xff, %r13 shlq $12, %r13 mov (%r10,%r13,1), %r13 pop %rsi pop %rbx pop %rbp pop %r9 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 4}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 6}} {'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 9}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 4}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT_ht', 'congruent': 6}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 10}} {'dst': {'same': True, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}} {'36': 21829} 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 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 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 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 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 */
TITLE UTIL - Handle utilities NAME UTIL ;** Handle related utilities for MSDOS 2.X. ; ; pJFNFromHandle written ; SFFromHandle written ; SFFromSFN written ; JFNFree written ; SFNFree written ; ; Modification history: ; ; Created: MZ 1 April 1983 .xlist .xcref include version.inc include dosseg.inc INCLUDE DOSSYM.INC INCLUDE DEVSYM.INC include pdb.inc include sf.inc include bugtyp.inc .cref .list I_need CurrentPDB,WORD ; current process data block location I_need SFT_Addr,DWORD ; pointer to beginning of table I_Need PROC_ID,WORD ; current process ID I_Need USER_ID,WORD ; current user ID DOSCODE SEGMENT ASSUME SS:DOSDATA,CS:DOSCODE allow_getdseg BREAK <pJFNFromHandle - return pointer to JFN table entry> ;** pJFNFromHandle - Translate Handle to Pointer to JFN ; ; pJFNFromHandle takes a file handle and turns that into a pointer to ; the JFN entry (i.e., to a byte holding the internal file handle #) ; ; NOTE: ; This routine is called from $CREATE_PROCESS_DATA_BLOCK which is called ; at DOSINIT time with SS NOT DOSGROUP ; ; ENTRY (bx) = handle ; EXIT 'C' clear if ok ; (es:di) = address of JFN value ; 'C' set if error ; (ax) = error code ; USES AX, DI, ES, Flags procedure pJFNFromHandle,NEAR ASSUME CS:DOSCODE,SS:NOTHING getdseg <es> ; es -> dosdata MOV ES,CurrentPDB ; get user process data block ASSUME ES:NOTHING CMP BX,ES:PDB_JFN_Length ; is handle greater than allocated JB pjfn10 ; no, get offset fmt TypAccess,LevSFN,<"$p: Illegal JFN %x\n">,<BX> MOV AL,error_invalid_handle ; appropriate error ReturnCarry: STC ; signal error return ; go back pjfn10: LES DI,ES:PDB_JFN_Pointer ; get pointer to beginning of table ADD DI,BX ; add in offset, clear 'C' return EndProc pJFNFromHandle BREAK <SFFromHandle - return pointer (or error) to SF entry from handle> ;--------------------------------------------------------------------------- ; ; Procedure Name : SFFromHandle ; ; SFFromHandle - Given a handle, get JFN and then index into SF table ; ; Input: BX has handle ; Output: Carry Set ; AX has error code ; Carry Reset ; ES:DI has pointer to SF entry ; Registers modified: If error, AX,ES, else ES:DI ; NOTE: ; This routine is called from $CREATE_PROCESS_DATA_BLOCK which is called ; at DOSINIT time with SS NOT DOSGROUP ; ;---------------------------------------------------------------------------- procedure SFFromHandle,NEAR ASSUME CS:DOSCODE,SS:NOTHING CALL pJFNFromHandle ; get jfn pointer retc ; return if error CMP BYTE PTR ES:[DI],-1 ; unused handle JNZ GetSF ; nope, take out SF fmt TypAccess,LevSFN,<"$p: Illegal SFN $x:$x\n">,<ES,DI> MOV AL,error_invalid_handle ; appropriate error jump ReturnCarry ; signal it GetSF: SAVE <BX> ; save handle MOV BL,BYTE PTR ES:[DI] ; get SFN XOR BH,BH ; ignore upper half CALL SFFromSFN ; get real sf spot RESTORE <BX> ; restore return ; say goodbye EndProc SFFromHandle BREAK <SFFromSFN - index into SF table for SFN> ;** SFFromSFN - Get an SF Table entry from an SFN ; ; SFFromSfn uses an SFN to index an entry into the SF table. This ; is more than just a simple index instruction because the SF table ; can be made up of multiple pieces chained together. We follow the ; chain to the right piece and then do the index operation. ; ; NOTE: ; This routine is called from SFFromHandle which is called ; at DOSINIT time with SS NOT DOSGROUP ; ; ENTRY BX has SF index ; EXIT 'C' clear if OK ; ES:DI points to SF entry ; 'C' set if index too large ; USES BX, DI, ES procedure SFFromSFN,NEAR ASSUME SS:NOTHING getdseg <es> ; address DOSDATA LES DI,SFT_Addr ; (es:di) = start of SFT table ASSUME ES:NOTHING sfsfn5: CMP BX,ES:[DI].SFCount ; is handle in this table? JB sfsfn7 ; yes, go grab it SUB BX,ES:[DI].SFCount LES DI,ES:[DI].SFLink ; get next table segment CMP DI,-1 ; end of tables? JNZ sfsfn5 ; no, try again STC ret ; return with error, not found sfsfn7: SAVE <AX> MOV AX,SIZE SF_Entry ; put it in a nice place MUL BL ; (ax) = offset into this SF block ADD DI,AX ; add base of SF block RESTORE <AX> ADD DI,SFTable ; offset into structure, 'C' cleared return ; return with 'C' clear EndProc SFFromSFN BREAK <JFNFree - return a jfn pointer if one is free> ;** JFNFree - Find a Free JFN Slot ; ; ; JFNFree scansthrough the JFN table and returnsa pointer to a free slot ; ; ENTRY (ss) = DOSDATA ; EXIT 'C' clear if OK ; (bx) = new handle ; (es:di) = pointer to JFN slot ; 'C' set if error ; (al) = error code ; USES bx, di, es, flags procedure JFNFree,NEAR DOSASSUME <ss>,"JFNFree" XOR BX,BX ; (bx) = initial JFN to try jfnf1: CALL pJFNFromHandle ; get the appropriate handle JC jfnf5 ; no more handles CMP BYTE PTR ES:[DI],-1 ; free? je jfnfx ; yes, carry is clear INC BX ; no, next handle JMP jfnf1 ; and try again ; Error. 'C' set jfnf5: MOV AL,error_too_many_open_files jfnfx: return ; bye EndProc JFNFree BREAK <SFNFree - Allocate a free SFN> ;** SFNFree - Allocate a Free SFN/SFT ; ; SFNFree scans through the sf table looking for a free entry ; If it finds one it partially allocates it by setting SFT_REF_COUNT = -1 ; ; The problem is that we want to mark the SFT busy so that other threads ; can't allocate the SFT before we're finished marking it up. However, ; we can't just mark it busy because we may get blown out of our open ; by INT24 and leave the thing orphaned. To solve this we mark it ; "allocation in progress" by setting SFT_REF_COUNT = -1. If we see ; an SFT with this value we look to see if it belongs to this user ; and process. If it does belong to us then it must be an orphan ; and we reclaim it. ; ; BUGBUG - improve the performance. I guess it's smaller to call SFFromSFN ; over and over, but we could at least set a high water mark... ; cause an N^2 loop calling slow SFFromSFN is real slow, too slow ; even though this is not a frequently called routine - jgl ; ; ENTRY (ss) = DOSDATA ; EXIT 'C' clear if no error ; (bx) = SFN ; (es:di) = pointer to SFT ; es:[di].SFT_REF_COUNT = -1 ; 'C' set if error ; (al) = error code ; USES bx, di, se, Flags Procedure SFNFree,NEAR DOSASSUME <SS>,"SFNFree" SAVE <ax> xor bx,bx ; (bx) = SFN to consider sfnf5: SAVE <bx> call SFFromSFN ; get the potential handle RESTORE <bx> DLJC sfnf95 ; no more free SFNs cmp es:[DI.sf_Ref_Count],0 ; free? je sfnf20 ; yep, got one cmp es:[DI.sf_ref_count],sf_busy je sfnf10 ; special busy mark sfnf7: inc bx ; try the next one jmp sfnf5 ; The SFT has the special "busy" mark; if it belongs to us then ; it was abandoned during a earlier call and we can use it. ; ; (bx) = SFN ; (es:di) = pointer to SFT ; (TOS) = caller's (ax) sfnf10: mov ax,Proc_ID cmp es:[DI].SF_PID,ax jnz sfnf7 ; can't use this one, try the next ; We have an SFT to allocate ; ; (bx) = SFN ; (es:di) = pointer to SFT ; (TOS) = caller's (ax) sfnf20: mov es:[DI.sf_ref_count],sf_busy ; make sure that this is allocated mov ax,Proc_ID mov es:[DI].SF_PID,ax RESTORE <ax> clc return ; return with no error ;** Error - no more free SFNs ; ; 'C' set ; (TOS) = saved ax sfnf95: pop ax mov al,error_too_many_open_files ret ; return with 'C' and error EndProc SFNFree DOSCODE ENDS END
STAGE_PIT_MOVING_PLATFORM_1_OFFSET = STAGE_ELEMENT_SIZE * 2 STAGE_PIT_MOVING_PLATFORM_2_OFFSET = STAGE_PIT_MOVING_PLATFORM_1_OFFSET + STAGE_ELEMENT_SIZE #define STAGE_PIT_MOVING_PLATFORM_SPRITES $20 #define STAGE_PIT_NB_MOVING_PLATFORM_SPRITES 8 #define STAGE_PIT_PLATFORM_MAX_HEIGHT 88 #define STAGE_PIT_PLATFORM_MIN_HEIGHT 162 #define STAGE_PIT_PLATFORM_LEFTMOST 73 #define STAGE_PIT_PLATFORM_RIGHTMOST 137 stage_pit_netload: .( lda RAINBOW_DATA sta stage_pit_platform1_direction_v lda RAINBOW_DATA sta stage_pit_platform2_direction_v lda RAINBOW_DATA sta stage_pit_platform1_direction_h lda RAINBOW_DATA sta stage_pit_platform2_direction_h lda RAINBOW_DATA sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_TOP lda RAINBOW_DATA sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_LEFT clc adc #38 sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_RIGHT lda RAINBOW_DATA sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_2_OFFSET+STAGE_PLATFORM_OFFSET_TOP lda RAINBOW_DATA sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_2_OFFSET+STAGE_PLATFORM_OFFSET_LEFT ;clc ; useless, last ADC should not overflow (platforms stay on screen) adc #38 sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_2_OFFSET+STAGE_PLATFORM_OFFSET_RIGHT rts .) stage_pit_init: .( ; Generic initialization stuff jsr stage_generic_init ; Set stage's state lda #$ff sta stage_pit_platform1_direction_v lda #$01 sta stage_pit_platform2_direction_v lda #0 sta stage_pit_platform1_direction_h sta stage_pit_platform2_direction_h ; Init moving platform sprites lda #TILE_MOVING_PLATFORM ; sta oam_mirror+STAGE_PIT_MOVING_PLATFORM_SPRITES*4+1 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+1)*4+1 ; Tile number sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+2)*4+1 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+3)*4+1 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+4)*4+1 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+5)*4+1 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+6)*4+1 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+7)*4+1 ; lda #%00000011 ; sta oam_mirror+STAGE_PIT_MOVING_PLATFORM_SPRITES*4+2 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+1)*4+2 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+2)*4+2 ; Attributes sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+3)*4+2 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+4)*4+2 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+5)*4+2 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+6)*4+2 ; sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+7)*4+2 ; ; Place moving platform sprites ; Fallthrough stage_pit_place_platform_sprites .) stage_pit_place_platform_sprites: .( ; Avoid placing sprites in rollback mode lda network_rollback_mode beq do_it rts do_it: ; Y positions lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_TOP clc adc #15 sta oam_mirror+STAGE_PIT_MOVING_PLATFORM_SPRITES*4 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+1)*4 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+2)*4 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+3)*4 lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_2_OFFSET+STAGE_PLATFORM_OFFSET_TOP clc adc #15 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+4)*4 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+5)*4 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+6)*4 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+7)*4 ; X positions lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_LEFT clc adc #7 sta oam_mirror+STAGE_PIT_MOVING_PLATFORM_SPRITES*4+3 adc #8 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+1)*4+3 adc #8 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+2)*4+3 adc #8 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+3)*4+3 lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_2_OFFSET+STAGE_PLATFORM_OFFSET_LEFT adc #7 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+4)*4+3 adc #8 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+5)*4+3 adc #8 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+6)*4+3 adc #8 sta oam_mirror+(STAGE_PIT_MOVING_PLATFORM_SPRITES+7)*4+3 rts .) stage_pit_tick: .( .( ; Change platforms direction ldy #0 ; Y = platform index ldx #0 ; X = platform offset in stage data from first moving platform change_one_platform_direction: jsr apply_platform_waypoint ldx #STAGE_ELEMENT_SIZE iny cpy #2 bne change_one_platform_direction ; Move platforms and players on it ldx #0 ldy #0 lda stage_pit_platform1_direction_v sta tmpfield4 lda stage_pit_platform1_direction_h sta tmpfield5 check_one_player_one_platform: ; Move players that are on platforms move_players_on_platform: tya clc adc #STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET cmp player_a_grounded, x bne next_check lda player_a_y, x clc adc tmpfield4 sta player_a_y, x lda player_a_x, x clc adc tmpfield5 sta player_a_x, x next_check: inx cpx #2 bne move_players_on_platform ; Move platform in stage's data lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_TOP, y clc adc tmpfield4 sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_TOP, y lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_LEFT, y clc adc tmpfield5 sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_LEFT, y lda stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_RIGHT, y clc adc tmpfield5 sta stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_RIGHT, y ; Prepare next platform cpy #STAGE_ELEMENT_SIZE beq end_move_platforms ldy #STAGE_ELEMENT_SIZE ldx #0 lda stage_pit_platform2_direction_v sta tmpfield4 lda stage_pit_platform2_direction_h sta tmpfield5 jmp check_one_player_one_platform end_move_platforms: ; Move platform sprites jmp stage_pit_place_platform_sprites ;rts ; useless, jump to a subroutine .) ; Modify platform's direction if on a waypoint ; register Y - Platform index ; register X - Platform offset in stage data from first moving platform ; ; Overwrites tmpfield1 and tmpfield2 apply_platform_waypoint: .( platform_index = tmpfield1 new_direction_v = tmpfield2 ; Save platform index sty platform_index ; Check if on a waypoint ldy #0 ; Y is the current waypoint index check_one_wp: lda waypoints_v, y cmp stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_TOP, x bne next_wp lda waypoints_h, y cmp stage_data+STAGE_OFFSET_ELEMENTS+STAGE_PIT_MOVING_PLATFORM_1_OFFSET+STAGE_PLATFORM_OFFSET_LEFT, x beq change_direction next_wp: iny cpy #4 bne check_one_wp jmp end ; Apply waypoint's direction to the platform change_direction: lda waypoints_direction_v, y sta new_direction_v lda waypoints_direction_h, y ldy platform_index sta stage_pit_platform1_direction_h, y lda new_direction_v sta stage_pit_platform1_direction_v, y ; Restore register Y and return end: ldy platform_index rts .) waypoints_v: .byt STAGE_PIT_PLATFORM_MAX_HEIGHT, STAGE_PIT_PLATFORM_MAX_HEIGHT, STAGE_PIT_PLATFORM_MIN_HEIGHT, STAGE_PIT_PLATFORM_MIN_HEIGHT waypoints_h: .byt STAGE_PIT_PLATFORM_LEFTMOST, STAGE_PIT_PLATFORM_RIGHTMOST, STAGE_PIT_PLATFORM_RIGHTMOST, STAGE_PIT_PLATFORM_LEFTMOST waypoints_direction_v: .byt $00, $01, $00, $ff waypoints_direction_h: .byt $01, $00, $ff, $00 .)
;------------------------------------------------------------------------------- ; memmsg.nasm - memory manager message handlers. ;------------------------------------------------------------------------------- module taskman.mm.memmsg %include "sys.ah" %include "rmk.ah" %include "errors.ah" %include "cpu/paging.ah" %include "tm/process.ah" %include "tm/memmsg.ah" publicdata MemMsgHandlers externproc PoolChunkAddr, MapArea externproc MM_FindRegion, MM_AllocBlock, MM_FreeBlock externdata ?ProcessPool library $libc importproc _MsgRead, _MsgReply, _MsgError section .data MemMsgHandlers: mMHTabEnt MH_MemMap, MEM_MAP mMHTabEnt MH_MemCtrl, MEM_CTRL mMHTabEnt MH_MemInfo, MEM_INFO mMHTabEnt MH_MemOffset, MEM_OFFSET mMHTabEnt MH_MemDebugInfo, MEM_DEBUG_INFO mMHTabEnt MH_MemSwap, MEM_SWAP mMHTabEnt MH_MemAllocPages, MEM_ALLOCPAGES mMHTabEnt MH_MemFreePages, MEM_FREEPAGES mMHTabEnt 0 section .text ; MEM_MAP handler ; Input: ESI=message information address, ; EBX=rcvid. proc MH_MemMap locauto msgbuf, tMsg_MemMap_size prologue ; Read a message and check its length lea edi,[%$msgbuf] mov ecx,tMemMapRequest_size Ccall _MsgRead, ebx, edi, ecx, 0 test eax,eax clc js .ReplyErr cmp eax,ecx jb .ReplyErr ; Find a linear memory region mov edx,ebx mov eax,[esi+tMsgInfo.PID] mov ebx,?ProcessPool call PoolChunkAddr mov ecx,[edi+tMemMapRequest.Len] call MM_FindRegion jc .NoMem ; Map area mpush edx,edi mov edx,[esi+tProcDesc.PageDir] mov al,PG_PRESENT | PG_USERMODE | PG_WRITABLE mov ah,al mov esi,[edi+tMemMapRequest.Offset] mov edi,ebx call MapArea mpop edi,edx jc .Exit ; Fill in the fields in the reply and return linear address sub ebx,USERAREASTART Ccall _MsgReply, edx, ebx, edi, tMemMapReply_size .Exit: epilogue ret .ReplyErr: Ccall _MsgError, ebx, -ENOMSG jmp .Exit .NoMem: Ccall _MsgError, edx, -ENOMEM jmp .Exit endp ;--------------------------------------------------------------- ; MEM_CTRL handler proc MH_MemCtrl ret endp ;--------------------------------------------------------------- ; MEM_INFO handler proc MH_MemInfo ret endp ;--------------------------------------------------------------- ; MEM_OFFSET handler proc MH_MemOffset ret endp ;--------------------------------------------------------------- ; MEM_DEBUG_INFO handler proc MH_MemDebugInfo ret endp ;--------------------------------------------------------------- ; MEM_SWAP handler proc MH_MemSwap ret endp ;--------------------------------------------------------------- ; MEM_ALLOCPAGES handler. ; Input: ESI=message information address, ; EBX=rcvid. proc MH_MemAllocPages locauto msgbuf, tMsg_MemAllocPages_size prologue ; Read a message and check its length lea edi,[%$msgbuf] mov ecx,tMemAllocPagesRequest_size Ccall _MsgRead, ebx, edi, ecx, 0 test eax,eax clc js .ReplyErr cmp eax,ecx jb .ReplyErr ; Get a PCB address mov edx,ebx mov eax,[esi+tMsgInfo.PID] mov ebx,?ProcessPool call PoolChunkAddr ; Allocate block mov ecx,[edi+tMemAllocPagesRequest.Size] mov al,PG_WRITABLE call MM_AllocBlock jc .NoMem ; Fill in the fields in the reply and return linear address mov [edi+tMemAllocPagesReply.Addr],ebx Ccall _MsgReply, edx, 0, edi, tMemAllocPagesReply_size .Exit epilogue ret .ReplyErr: Ccall _MsgError, ebx, -ENOMSG jmp .Exit .NoMem: Ccall _MsgError, edx, -ENOMEM jmp .Exit endp ;--------------------------------------------------------------- ; MEM_FREEPAGES handler. ; Input: ESI=message information address, ; EBX=rcvid. proc MH_MemFreePages locauto msgbuf, tMsg_MemFreePages_size prologue ; Read a message and check its length lea edi,[%$msgbuf] mov ecx,tMsg_MemFreePages_size Ccall _MsgRead, ebx, edi, ecx, 0 test eax,eax clc js .ReplyErr cmp eax,ecx jb .ReplyErr ; Get a PCB address mov edx,ebx mov eax,[esi+tMsgInfo.PID] mov ebx,?ProcessPool call PoolChunkAddr ; Free block mov ebx,[edi+tMsg_MemFreePages.Addr] call MM_FreeBlock jc .NoMem ; Echo-reply to unblock the sender Ccall _MsgReply, edx, 0, edi, ecx .Exit: epilogue ret .ReplyErr: Ccall _MsgError, ebx, -ENOMSG jmp .Exit .NoMem: Ccall _MsgError, edx, -ENOMEM jmp .Exit endp ;---------------------------------------------------------------
; Test clashing segment properties IDEAL ; defaulting to private SEGMENT SEG1 ENDS SEGMENT SEG1 PUBLIC ENDS SEGMENT SEG1 STACK ENDS SEGMENT SEG1 PRIVATE ENDS SEGMENT SEG1 ENDS ; explicitly private SEGMENT SEG2 PRIVATE ENDS SEGMENT SEG2 PUBLIC ENDS SEGMENT SEG2 STACK ENDS SEGMENT SEG2 PRIVATE ENDS SEGMENT SEG2 ENDS ; public SEGMENT SEG3 PUBLIC ENDS SEGMENT SEG3 PRIVATE ENDS SEGMENT SEG3 STACK ENDS SEGMENT SEG3 PUBLIC ENDS SEGMENT SEG3 ENDS ; stack SEGMENT SEG4 STACK ENDS SEGMENT SEG4 PRIVATE ENDS SEGMENT SEG4 PUBLIC ENDS SEGMENT SEG4 STACK ENDS SEGMENT SEG4 ENDS END
; void *tshc_saddrpup(void *saddr) SECTION code_clib SECTION code_arch PUBLIC tshc_saddrpup EXTERN zx_saddrpup defc tshc_saddrpup = zx_saddrpup ; SDCC bridge for Classic IF __CLASSIC PUBLIC _tshc_saddrpup defc _tshc_saddrpup = tshc_saddrpup ENDIF
// // EVPPKey.cpp // // // Library: Crypto // Package: CryptoCore // Module: EVPPKey // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. // // SPDX-License-Identifier: BSL-1.0 // #include "Poco/Crypto/EVPPKey.h" #include "Poco/Crypto/ECKey.h" #include "Poco/Crypto/RSAKey.h" #include "Poco/NumberFormatter.h" namespace Poco { namespace Crypto { EVPPKey::EVPPKey(const std::string& ecCurveName): _pEVPPKey(0) { newECKey(ecCurveName.c_str()); poco_check_ptr(_pEVPPKey); } EVPPKey::EVPPKey(const char* ecCurveName): _pEVPPKey(0) { newECKey(ecCurveName); poco_check_ptr(_pEVPPKey); } EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey): _pEVPPKey(0) { duplicate(pEVPPKey, &_pEVPPKey); poco_check_ptr(_pEVPPKey); } EVPPKey::EVPPKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase): _pEVPPKey(0) { if (loadKey(&_pEVPPKey, PEM_read_PrivateKey, (EVP_PKEY_get_Key_fn)0, privateKeyFile, privateKeyPassphrase)) { poco_check_ptr(_pEVPPKey); return; // private key is enough } // no private key, this must be public key only, otherwise throw if (!loadKey(&_pEVPPKey, PEM_read_PUBKEY, (EVP_PKEY_get_Key_fn)0, publicKeyFile)) { throw OpenSSLException("ECKeyImpl(const string&, const string&, const string&"); } poco_check_ptr(_pEVPPKey); } EVPPKey::EVPPKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase): _pEVPPKey(0) { if (loadKey(&_pEVPPKey, PEM_read_bio_PrivateKey, (EVP_PKEY_get_Key_fn)0, pPrivateKeyStream, privateKeyPassphrase)) { poco_check_ptr(_pEVPPKey); return; // private key is enough } // no private key, this must be public key only, otherwise throw if (!loadKey(&_pEVPPKey, PEM_read_bio_PUBKEY, (EVP_PKEY_get_Key_fn)0, pPublicKeyStream)) { throw OpenSSLException("ECKeyImpl(istream*, istream*, const string&"); } poco_check_ptr(_pEVPPKey); } EVPPKey::EVPPKey(const EVPPKey& other) { duplicate(other._pEVPPKey, &_pEVPPKey); poco_check_ptr(_pEVPPKey); } EVPPKey& EVPPKey::operator=(const EVPPKey& other) { duplicate(other._pEVPPKey, &_pEVPPKey); poco_check_ptr(_pEVPPKey); return *this; } #ifdef POCO_ENABLE_CPP11 EVPPKey::EVPPKey(EVPPKey&& other): _pEVPPKey(other._pEVPPKey) { other._pEVPPKey = nullptr; poco_check_ptr(_pEVPPKey); } EVPPKey& EVPPKey::operator=(EVPPKey&& other) { _pEVPPKey = other._pEVPPKey; other._pEVPPKey = nullptr; poco_check_ptr(_pEVPPKey); return *this; } #endif // POCO_ENABLE_CPP11 EVPPKey::~EVPPKey() { if (_pEVPPKey) EVP_PKEY_free(_pEVPPKey); } void EVPPKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) const { if (!publicKeyFile.empty() && (publicKeyFile != privateKeyFile)) { BIO* bio = BIO_new(BIO_s_file()); if (!bio) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile); try { if (BIO_write_filename(bio, const_cast<char*>(publicKeyFile.c_str()))) { if (!PEM_write_bio_PUBKEY(bio, _pEVPPKey)) { throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile); } } else throw Poco::CreateFileException("Cannot create public key file"); } catch (...) { BIO_free(bio); throw; } BIO_free(bio); } if (!privateKeyFile.empty()) { BIO* bio = BIO_new(BIO_s_file()); if (!bio) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile); try { if (BIO_write_filename(bio, const_cast<char*>(privateKeyFile.c_str()))) { int rc = 0; if (privateKeyPassphrase.empty()) { rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, 0, 0, 0, 0, 0); } else { rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(), reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), static_cast<int>(privateKeyPassphrase.length()), 0, 0); } if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile); } else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile); } catch (...) { BIO_free(bio); throw; } BIO_free(bio); } } void EVPPKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase) const { if (pPublicKeyStream && (pPublicKeyStream != pPrivateKeyStream)) { BIO* bio = BIO_new(BIO_s_mem()); if (!bio) throw Poco::IOException("Cannot create BIO for writing public key"); if (!PEM_write_bio_PUBKEY(bio, _pEVPPKey)) { BIO_free(bio); throw Poco::WriteFileException("Failed to write public key to stream"); } char* pData; long size = BIO_get_mem_data(bio, &pData); pPublicKeyStream->write(pData, static_cast<std::streamsize>(size)); BIO_free(bio); } if (pPrivateKeyStream) { BIO* bio = BIO_new(BIO_s_mem()); if (!bio) throw Poco::IOException("Cannot create BIO for writing public key"); int rc = 0; if (privateKeyPassphrase.empty()) rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, 0, 0, 0, 0, 0); else rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(), reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), static_cast<int>(privateKeyPassphrase.length()), 0, 0); if (!rc) { BIO_free(bio); throw Poco::FileException("Failed to write private key to stream"); } char* pData; long size = BIO_get_mem_data(bio, &pData); pPrivateKeyStream->write(pData, static_cast<std::streamsize>(size)); BIO_free(bio); } } EVP_PKEY* EVPPKey::duplicate(const EVP_PKEY* pFromKey, EVP_PKEY** pToKey) { if (!pFromKey) throw NullPointerException("EVPPKey::duplicate(): " "provided key pointer is null."); *pToKey = EVP_PKEY_new(); if (!*pToKey) throw NullPointerException("EVPPKey::duplicate(): " "EVP_PKEY_new() returned null."); int keyType = type(pFromKey); switch (keyType) { case EVP_PKEY_RSA: { RSA* pRSA = EVP_PKEY_get1_RSA(const_cast<EVP_PKEY*>(pFromKey)); if (pRSA) { EVP_PKEY_set1_RSA(*pToKey, pRSA); RSA_free(pRSA); } else throw OpenSSLException("EVPPKey::duplicate(): EVP_PKEY_get1_RSA()"); break; } case EVP_PKEY_EC: { EC_KEY* pEC = EVP_PKEY_get1_EC_KEY(const_cast<EVP_PKEY*>(pFromKey)); if (pEC) { EVP_PKEY_set1_EC_KEY(*pToKey, pEC); EC_KEY_free(pEC); int cmp = EVP_PKEY_cmp_parameters(*pToKey, pFromKey); if (cmp < 0) throw OpenSSLException("EVPPKey::duplicate(): EVP_PKEY_cmp_parameters()"); if (0 == cmp) { if(!EVP_PKEY_copy_parameters(*pToKey, pFromKey)) throw OpenSSLException("EVPPKey::duplicate(): EVP_PKEY_copy_parameters()"); } } else throw OpenSSLException(); break; } default: throw NotImplementedException("EVPPKey:duplicate(); Key type: " + NumberFormatter::format(keyType)); } return *pToKey; } void EVPPKey::newECKey(const char* ecCurveName) { int curveID = OBJ_txt2nid(ecCurveName); EC_KEY* pEC = EC_KEY_new_by_curve_name(curveID); if (!pEC) goto err; if (!EC_KEY_generate_key(pEC)) goto err; _pEVPPKey = EVP_PKEY_new(); if (!_pEVPPKey) goto err; if (!EVP_PKEY_set1_EC_KEY(_pEVPPKey, pEC)) goto err; EC_KEY_free(pEC); return; err: throw OpenSSLException("EVPPKey:newECKey()"); } void EVPPKey::setKey(ECKey* pKey) { poco_check_ptr(pKey); poco_check_ptr(pKey->impl()); setKey(pKey->impl()->getECKey()); } void EVPPKey::setKey(RSAKey* pKey) { poco_check_ptr(pKey); poco_check_ptr(pKey->impl()); setKey(pKey->impl()->getRSA()); } int EVPPKey::passCB(char* buf, int size, int, void* pass) { if (pass) { int len = (int)std::strlen((char*)pass); if(len > size) len = size; std::memcpy(buf, pass, len); return len; } return 0; } } } // namespace Poco::Crypto
.data start_Address: .word 0xffff0000 newline: .asciiz "\n" lchar: .asciiz "L" rchar: .asciiz "R" uchar: .asciiz "U" dchar: .asciiz "D" .text .globl_start _start: ########## #1_1 test ########## li $a0, 0xffff0000 li $a1, 5 li $a2, 4 jal clear_board move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ######### #1_2 test ##@###### li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 1 li $t1, 128 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ######### #1_3 test ##@###### li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 0 li $t1, 0 li $t2, 1 addi $sp,$sp, -12 sw $t0, 0($sp) sw $t1, 4($sp) sw $t2, 8 ($sp) jal start_game addi $sp,$sp, 12 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'U' jal user_move move $a0, $v0 li $v0,1 syscall move $a0, $v1 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'D' jal user_move li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'R' jal user_move ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 2 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 0 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 1 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 2 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ######### #1_4 test ##@###### li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal merge_row addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 1 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 3 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ######### #1_5 test ##@###### li $a0, 0xffff0000 li $a1, 4 li $a2, 4 li $a3, 2 li $t0, 1 addi $sp,$sp,-4 sw $t0, 0($sp) jal merge_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 0 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 4 li $a2, 4 li $a3, 1 li $t0, 1 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ####### #1_6 test ######### li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_row addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 1 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ####### #1_7 test ######### li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 1 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 1 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 1 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 0 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 0 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 1 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall ### li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal merge_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 1 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_col addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_row addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall #####fuckmylifecheckcoltest ###lol li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 0 li $t1, 2 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 1 li $t1, 4 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 2 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 3 li $t1, 16 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 0 li $t1, 16 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 1 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 2 li $t1, 4 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 3 li $t1, 2 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 0 li $t1, 2 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 1 li $t1, 4 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 2 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 3 li $t1, 16 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 0 li $t1, 16 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 1 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 2 li $t1, 4 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 3 li $t0, 3 li $t1, 2 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 0 li $t1, 2 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 1 li $t1, 4 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 2 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 4 li $t0, 3 li $t1, 8 addi $sp,$sp,-8 sw $t0, 0($sp) sw $t1, 4($sp) jal place addi $sp,$sp,8 ########### 1.8 test li $a0, 0xffff0000 li $a1, 5 li $a2, 4 jal check_state move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'U' jal user_move move $a0, $v0 li $v0,1 syscall move $a0, $v1 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'L' jal user_move li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'R' jal user_move li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'U' jal user_move move $a0, $v0 li $v0,1 syscall move $a0, $v1 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'U' jal user_move li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'R' jal user_move li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'U' jal user_move li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'D' jal user_move li $v0, 10 syscall move $a0, $v0 li $v0,1 syscall move $a0, $v1 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 1 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal merge_row addi $sp,$sp, 4 li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 2 li $t0, 0 addi $sp,$sp,-4 sw $t0, 0($sp) jal shift_row addi $sp,$sp, 4 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 'U' jal user_move li $v0, 10 syscall li $a0, 0xffff0000 li $a1, 5 li $a2, 4 li $a3, 0 li $t0, 2 li $t1, 1 li $t2, 2 addi $sp,$sp, -12 sw $t0, 0($sp) sw $t1, 4($sp) sw $t2, 8 ($sp) jal start_game addi $sp,$sp, 12 move $a0, $v0 li $v0,1 syscall li $v0, 4 la $a0, newline syscall li $v0, 10 syscall .include "hw4.asm"
;================================================================================ ; New Item Handlers ;-------------------------------------------------------------------------------- ; REMEMBER TO UPDATE THE TABLES IN UTILITIES.ASM! ;-------------------------------------------------------------------------------- ; #$4C - Bomb Capacity (50) ; #$4D - Arrow Capacity (70) ; #$4E - 1/2 Magic ; #$4F - 1/4 Magic ; #$50 - Safe Master Sword ; #$51 - Bomb Capacity (+5) ; #$52 - Bomb Capacity (+10) ; #$53 - Arrow Capacity (+5) ; #$54 - Arrow Capacity (+10) ; #$55 - Programmable Item 1 ; #$56 - Programmable Item 2 ; #$57 - Programmable Item 3 ; #$58 - Upgrade-Only Silver Arrows ; #$59 - Rupoor ; #$5A - Null Item ; #$5B - Red Clock ; #$5C - Blue Clock ; #$5D - Green Clock ; #$5E - Progressive Sword ; #$5F - Progressive Shield ; #$60 - Progressive Armor ; #$61 - Progressive Lifting Glove ; #$62 - RNG Pool Item (Single) ; #$63 - RNG Pool Item (Multi) ; #$6A - Goal Item (Single/Triforce) ; #$6B - Goal Item (Multi/Power Star) ; #$70 - Maps ; #$80 - Compasses ; #$90 - Big Keys ; #$A0 - Small Keys ; #$B0+ - Super Metroid Items ;-------------------------------------------------------------------------------- ;GetAnimatedSpriteGfxFile: ; LDY.b #$32 ; CMP.b #$39 : BCS + ; If tile index >= 0x39, use sprite file 0x32 (Blank file) ; ; LDY.b #$5D ; ; CMP.b #$23 : BEQ + ; If tile index is 0x23 (Pendant)... ; CMP.b #$37 : BCS + ; ...or tile index >= 0x37, use sprite file 0x5D (Pendant, Boots, 20 Rupees) ; ; LDY.b #$5C ; ; CMP.b #$0C : BEQ + ; If tile index is 0x0C (Flute)... ; CMP.b #$24 : BCS + ; ...or tile index >= 24, use sprite file 0x5C (Rupees, Crystal, Heart Piece ... ...) ; ; ; Otherwise, use sprite file 0x5B (Medallions, Mirror, Flippers, Lantern, Compass...) ; LDY.b #$5B ;+ ;JML GetAnimatedSpriteGfxFile_return ;-------------------------------------------------------------------------------- GetAnimatedSpriteGfxFile: CMP.b #$0C : BNE + LDY.b #$5C : JML GetAnimatedSpriteGfxFile_return + CMP.b #$23 : BNE + LDY.b #$5D : JML GetAnimatedSpriteGfxFile_return + CMP.b #$48 : BNE + LDY.b #$60 : JML GetAnimatedSpriteGfxFile_return + CMP.b #$24 : !BGE + LDY.b #$5B : JML GetAnimatedSpriteGfxFile_return + CMP.b #$37 : !BGE + LDY.b #$5C : JML GetAnimatedSpriteGfxFile_return + CMP.b #$39 : !BGE + LDY.b #$5D : JML GetAnimatedSpriteGfxFile_return + CMP.b #$50 : !BLT + LDY.b #$F0 : JML GetAnimatedSpriteGfxFile_return + LDY.b #$32 JML GetAnimatedSpriteGfxFile_return ;-------------------------------------------------------------------------------- GetAnimatedSpriteBufferPointer_table: ; Original data: dw $09C0, $0030, $0060, $0090, $00C0, $0300, $0318, $0330 dw $0348, $0360, $0378, $0390, $0930, $03F0, $0420, $0450 dw $0468, $0600, $0630, $0660, $0690, $06C0, $06F0, $0720 ; disassembly (incorrectly?) says this is $0270 dw $0750, $0768, $0900, $0930, $0960, $0990, $09F0, $0000 dw $00F0, $0A20, $0A50, $0660, $0600, $0618, $0630, $0648 dw $0678, $06D8, $06A8, $0708, $0738, $0768, $0960, $0900 dw $03C0, $0990, $09A8, $09C0, $09D8, $0A08, $0A38, $0600 dw $0630 ; New data: dw $0600, $0630, $0660, $0690 ; 50 Bombs / 70 Arrows / Half Magic / Quarter Magic dw $06C0, $06F0, $0720 ; +5/+10 Bomb Arrows ;#$4x dw $0750 ; +10 Arrows dw $0900 ; Upgrade-Only Silver Arrows dw $09D8 ; Unused dw $0930, $0960, $0990, $09C0 ; Lvl 1/2/3/4 Sword (Freestanding) dw $09F0 ; Null-Item dw $09C0 ; Clock dw $0A20 ; Triforce dw $0A50 ; Power Star ;#$4b dw $0000, $0000, $0000, $0000, $0000 ;#$50 - Super Metroid Item pointers dw $0600, $0630, $0660, $0690, $06C0, $06F0, $0720, $0750 dw $0900, $0930, $0960, $0990, $09C0, $09F0, $0A20, $0A50 dw $0C00, $0C30, $0C60, $0C90, $0CC0, $0CF0, $0D20, $0D50 GetAnimatedSpriteBufferPointer: ;PHB : PHK : PLB LDA.b $00 : ADC.l GetAnimatedSpriteBufferPointer_table, X ;PLB RTL ;-------------------------------------------------------------------------------- macro ProgrammableItemLogic(index) LDA.l ProgrammableItemLogicPointer_<index> : BNE ?jump LDA.l ProgrammableItemLogicPointer_<index>+1 : BNE ?jump LDA.l ProgrammableItemLogicPointer_<index>+2 : BNE ?jump BRA ?end ?jump: JSL.l ProgrammableItemLogicJump_<index> ?end: endmacro macro ValueShift() TAX : LDA.b #$01 ?start: CPX #$00 : BEQ ?end ASL DEX BRA ?start : ?end: endmacro ;-------------------------------------------------------------------------------- !CHALLENGE_TIMER = "$7EF454" !GOAL_COUNTER = "$7EF418" !INVENTORY_SWAP_2 = "$7EF38E" ;-------------------------------------------------------------------------------- ;carry clear if pass ;carry set if caught ;incsrc eventdata.asm ; ProcessEventItems: ; ;STA $FFFFFF ; LDA $00 : PHA ; LDA $01 : PHA ; LDA $02 : PHA ; PHY : PHP ; PHB : LDA.b #$AF : PHA : PLB ; LDA $02D8 ; CMP.b #$E0 : BNE + ; REP #$30 ; set 16-bit accumulator & index registers ; LDA $7EF450 : ASL : TAX ; LDA.l EventDataOffsets, X : !ADD #EventDataTable : STA $00 ; SEP #$20 ; set 8-bit accumulator ; LDA.b #$AF : STA $02 ; JSL.l LoadDialogAddressIndirect ; LDA $7EF450 : INC : STA $7EF450 ; SEP #$10 ; set 8-bit index registers ; LDA GoalItemRequirement : BEQ ++ ; LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER ; CMP GoalItemRequirement : !BLT ++ : JSL.l ActivateGoal : ++ ; LDX.b #$01 : BRA .done ; + ; LDX.b #$00 ; .done ; PLB ; PLP : PLY ; PLA : STA $02 ; PLA : STA $01 ; PLA : STA $00 ; RTS ;-------------------------------------------------------------------------------- AddReceivedItemExpandedGetItem: PHX ;JSR.w ProcessEventItems : CPX.b #$00 : BEQ ++ ; ;JSL.l Main_ShowTextMessage ; LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER ; LDA.b #$01 : STA $7F50A0 ; BRL .done ;++ ;STA $FFFFFF lda.l config_multiworld beq + ; If this is a multiworld item for someone else, skip picking the item up and just play ; the animation, also, write this item to the outgoing queue lda !MULTIWORLD_PICKUP cmp #$01 bne + plx pla : pla : pla ; Align the stack by popping the return value off it (so we can JML instead of RTL) lda $02e9 : cmp #$01 : bne .notChest lda $72 : pha lda $73 : pha .notChest ldy #$01 lda $02d8 : cmp #$20 : bne .notCrystal ldy #$02 .notCrystal tya : sta $02e4 jsl alttp_mw_send_item ; Item ID is already stored in !MULTIWORLD_ITEM phx jml $098763 ; Skip all code that gives Link the item and just show the graphics + LDA $02D8 ; check inventory ;JSL.l FreeDungeonItemNotice CMP.b #$0B : BNE + ; Bow LDA !INVENTORY_SWAP_2 : AND.b #$40 : BEQ ++ LDA.l SilverArrowsUseRestriction : BNE ++ LDA.b #03 : STA $7EF340 ; set bow to silver ++ BRL .done + CMP.b #$4C : BNE + ; 50 bombs ;LDA.b #$07 : STA $7EF370 ; upgrade bombs LDA.b #50 : !SUB.l StartingMaxBombs : STA $7EF370 ; upgrade bombs LDA.b #50 : STA $7EF375 ; fill bombs BRL .done + CMP.b #$4D : BNE + ; 70 arrows ;LDA #$07 : STA $7EF371 ; upgrade arrows LDA.b #70 : !SUB.l StartingMaxArrows : STA $7EF371 ; upgrade arrows LDA.b #70 : STA $7EF376 ; fill arrows BRL .done + CMP.b #$4E : BNE + ; 1/2 magic LDA $7EF37B : CMP #$02 : !BGE ++ INC : STA $7EF37B ; upgrade magic ++ LDA.b #$80 : STA $7EF373 ; fill magic BRL .done + CMP.b #$4F : BNE + ; 1/4 magic LDA.b #$02 : STA $7EF37B ; upgrade magic LDA.b #$80 : STA $7EF373 ; fill magic BRL .done + CMP.b #$50 : BNE + ; Master Sword (Safe) LDA $7EF359 : CMP.b #$02 : !BGE + ; skip if we have a better sword LDA.b #$02 : STA $7EF359 ; set master sword BRL .done + CMP.b #$51 : BNE + ; +5 Bombs LDA $7EF370 : !ADD.b #$05 : STA $7EF370 ; upgrade bombs +5 LDA.l Upgrade5BombsRefill : STA $7EF375 ; fill bombs BRL .done + CMP.b #$52 : BNE + ; +10 Bombs LDA $7EF370 : !ADD.b #$0A : STA $7EF370 ; upgrade bombs +10 LDA.l Upgrade10BombsRefill : STA $7EF375 ; fill bombs BRL .done + CMP.b #$53 : BNE + ; +5 Arrows LDA $7EF371 : !ADD.b #$05 : STA $7EF371 ; upgrade arrows +5 LDA.l Upgrade5ArrowsRefill : STA $7EF376 ; fill arrows BRL .done + CMP.b #$54 : BNE + ; +10 Arrows LDA $7EF371 : !ADD.b #$0A : STA $7EF371 ; upgrade arrows +10 LDA.l Upgrade10ArrowsRefill : STA $7EF376 ; fill arrows BRL .done + CMP.b #$58 : BNE + ; Upgrade-Only Sivler Arrows LDA.l SilverArrowsUseRestriction : BNE +++ LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ +++ LDA $7EF340 : BEQ ++ : CMP.b #$03 : !BGE ++ !ADD.b #$02 : STA $7EF340 ; switch to silver bow ++ +++ LDA.l ArrowMode : BEQ ++ LDA.b #$01 : STA $7EF376 ++ + CMP.b #$59 : BNE + ; 1 Rupoor REP #$20 : LDA $7EF360 : !SUB RupoorDeduction : STA $7EF360 : SEP #$20 ; Take 1 rupee BRL .done + CMP.b #$5A : BNE + ; Null Item BRL .done + CMP.b #$5E : BNE + ; Progressive Sword BRL .done + CMP.b #$5F : BNE + ; Progressive Shield BRL .done + CMP.b #$60 : BNE + ; Progressive Armor BRL .done + CMP.b #$61 : BNE + ; Progressive Lifting Glove BRL .done + CMP.b #$62 : BNE + ; RNG Pool Item (Single) BRL .done + CMP.b #$63 : BNE + ; RNG Pool Item (Multi) BRL .done + CMP.b #$70 : !BLT + : CMP.b #$80 : !BGE + ; Free Map AND #$0F : CMP #$08 : !BGE ++ %ValueShift() ORA $7EF368 : STA $7EF368 ; Map 1 BRL .done ++ !SUB #$08 %ValueShift() BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both ORA $7EF369 : STA $7EF369 ; Map 2 BRL .done + CMP.b #$80 : !BLT + : CMP.b #$90 : !BGE + ; Free Compass AND #$0F : CMP #$08 : !BGE ++ %ValueShift() ORA $7EF364 : STA $7EF364 ; Compass 1 BRL .done ++ !SUB #$08 %ValueShift() BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both ORA $7EF365 : STA $7EF365 ; Compass 2 BRL .done + CMP.b #$90 : !BLT + : CMP.b #$A0 : !BGE + ; Free Big Key AND #$0F : CMP #$08 : !BGE ++ %ValueShift() ORA $7EF366 : STA $7EF366 ; Big Key 1 BRL .done ++ !SUB #$08 %ValueShift() BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both ORA $7EF367 : STA $7EF367 ; Big Key 2 BRL .done + CMP.b #$A0 : !BLT + : CMP.b #$B0 : !BGE + ; Free Small Key AND #$0F : TAX LDA $7EF37C, X : INC : STA $7EF37C, X ; Increment Key Count CPX.b #$00 : BNE ++ STA $7EF37D ; copy HC to sewers ++ : CPX.b #$01 : BNE ++ STA $7EF37C ; copy sewers to HC ++ LDA.l GenericKeys : BEQ + .generic LDA $7EF36F : INC : STA $7EF36F BRL .done .normal TXA : ASL : CMP $040C : BNE ++ LDA $7EF36F : INC : STA $7EF36F ++ BRL .done + .done jsl alttp_receive_sm_item ; Check for SM items PLX LDA $02E9 : CMP.b #$01 ; thing we wrote over RTL ; #$70 - Maps ; #$80 - Compasses ; #$90 - Big Keys ; #$A0 - Small Keys ;-------------------------------------------------------------------------------- !PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ---- !RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" !SINGLE_INDEX_BITMASK_TEMP = "$7F5022" !LOCK_IN = "$7F5090" !ITEM_BUSY = "$7F5091" ;2B:Bottle Already Filled w/ Red Potion ;2C:Bottle Already Filled w/ Green Potion ;2D:Bottle Already Filled w/ Blue Potion ;3C:Bottle Already Filled w/ Bee ;3D:Bottle Already Filled w/ Fairy ;48:Bottle Already Filled w/ Gold Bee AddReceivedItemExpanded: { PHA : PHX ;JSL.l PreItemGet JSR EnableTemporaryCone LDA $02D8 ; Item Value JSR AttemptItemSubstitution STA $02D8 JSR IncrementItemCounters CMP.b #$16 : BNE ++ ; Bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$2B : BNE ++ ; Red Potion w/bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$2C : BNE ++ ; Green Potion w/bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$2D : BNE ++ ; Blue Potion w/bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$3C : BNE ++ ; Bee w/bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$3D : BNE ++ ; Fairy w/bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$48 : BNE ++ ; Gold Bee w/bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done ++ : CMP.b #$4E : BNE ++ ; Progressive Magic LDA $7EF37B : BEQ +++ LDA.b #$4F : STA $02D8 +++ : BRL .done ++ : CMP.b #$5E : BNE ++ ; Progressive Sword LDA $7EF359 : CMP.l ProgressiveSwordLimit : !BLT + LDA.l ProgressiveSwordReplacement : STA $02D8 : BRL .done + : CMP.b #$00 : BNE + ; No Sword LDA.b #$49 : STA $02D8 : BRL .done + : CMP.b #$01 : BNE + ; Fighter Sword LDA.b #$50 : STA $02D8 : BRL .done + : CMP.b #$02 : BNE + ; Master Sword LDA.b #$02 : STA $02D8 : BRL .done + ; Everything Else LDA.b #$03 : STA $02D8 : BRL .done ++ : CMP.b #$5F : BNE ++ ; Progressive Shield LDA !PROGRESSIVE_SHIELD : LSR #6 : CMP.l ProgressiveShieldLimit : !BLT + LDA.l ProgressiveShieldReplacement : STA $02D8 : BRL .done + LDA !PROGRESSIVE_SHIELD : AND.b #$C0 : BNE + ; No Shield LDA.b #$04 : STA $02D8 LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : BRL .done + : CMP.b #$40 : BNE + ; Fighter Shield LDA.b #$05 : STA $02D8 LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : BRA .done + ; Everything Else LDA.b #$06 : STA $02D8 LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : BRA .done ++ : CMP.b #$60 : BNE ++ ; Progressive Armor LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + LDA.l ProgressiveArmorReplacement : STA $02D8 : BRL .done + : CMP.b #$00 : BNE + ; No Armor LDA.b #$22 : STA $02D8 : BRA .done + ; Everything Else LDA.b #$23 : STA $02D8 : BRA .done ++ : CMP.b #$61 : BNE ++ ; Progressive Lifting Glove LDA $7EF354 : BNE + ; No Lift LDA.b #$1B : STA $02D8 : BRA .done + ; Everything Else LDA.b #$1C : STA $02D8 : BRA .done ++ : CMP.b #$62 : BNE ++ ; RNG Item (Single) JSL.l GetRNGItemSingle : STA $02D8 XBA : JSR.w MarkRNGItemSingle LDA #$FF : STA !LOCK_IN ; clear lock-in BRA .done ++ : CMP.b #$63 : BNE ++ ; RNG Item (Multi) JSL.l GetRNGItemMulti : STA $02D8 LDA #$FF : STA !LOCK_IN ; clear lock-in BRA .done ++ .done PLX : PLA PHB : PHK ; we're skipping the corresponding instructions to grab the data bank JML.l AddReceivedItem+2 } ;-------------------------------------------------------------------------------- ;DATA AddReceivedItemExpanded { .y_offsets db -5, -5, -5, -5, -5, -4, -4, -5 db -5, -4, -4, -4, -2, -4, -4, -4 db -4, -4, -4, -4, -4, -4, -4, -4 db -4, -4, -4, -4, -4, -4, -4, -4 db -4, -4, -4, -5, -4, -4, -4, -4 db -4, -4, -2, -4, -4, -4, -4, -4 db -4, -4, -4, -4, -2, -2, -2, -4 db -4, -4, -4, -4, -4, -4, -4, -4 db -4, -4, -2, -2, -4, -2, -4, -4 db -4, -5, -4, -4 ;new db -4, -4, -4, -4 db -5 ; Master Sword (Safe) db -4, -4, -4, -4 ; +5/+10 Bomb Arrows db -4, -4, -4 ; 3x Programmable Item db -4 ; Upgrade-Only Sivler Arrows db -4 ; 1 Rupoor db -4 ; Null Item db -4, -4, -4 ; Red, Blue & Green Clocks db -4, -4, -4, -4 ; Progressive Sword, Shield, Armor & Gloves db -4, -4 ; RNG Single & Multi db -4, -4, -4, -4, -4, -4 ; Unused db -4, -4, -4 ; Goal Item Single, Multi & Alt Multi db -4, -4, -4 ; Unused db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Free Map db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Free Compass db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Free Big Key db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Free Small Key ; $B0 - SM Items db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Unused db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Unused db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Unused db -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 ; Unused .x_offsets db 4, 4, 4, 4, 4, 0, 0, 4 db 4, 4, 4, 4, 5, 0, 0, 0 db 0, 0, 0, 4, 0, 4, 0, 0 db 4, 0, 0, 0, 0, 0, 0, 0 db 0, 0, 0, 0, 4, 0, 0, 0 db 0, 0, 5, 0, 0, 0, 0, 0 db 0, 0, 0, 0, 4, 4, 4, 0 db 0, 0, 0, 0, 0, 0, 0, 0 db 0, 0, 4, 4, 0, 4, 0, 0 db 0, 4, 0, 0 ;new db 0, 0, 0, 0 db 4 ; Master Sword (Safe) db 0, 0, 0, 0 ; +5/+10 Bomb Arrows db 0, 0, 0 ; 3x Programmable Item db 0 ; Upgrade-Only Sivler Arrows db 4 ; 1 Rupoor db 0 ; Null Item db 0, 0, 0 ; Red, Blue & Green Clocks db 0, 0, 0, 0 ; Progressive Sword, Shield, Armor & Gloves db 0, 0 ; RNG Single & Multi db 0, 0, 0, 0, 0, 0 ; Unused db 0, 0, 0 ; Goal Item Single, Multi & Alt Multi db 0, 0, 0 ; Unused db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Free Map db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Free Compass db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Free Big Key ;db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; *EVENT* db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Free Small Key ; $B0 - SM items db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Unused db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Unused db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Unused db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; Unused .item_graphics_indices db $06, $18, $18, $18, $2D, $20, $2E, $09 db $09, $0A, $08, $05, $10, $0B, $2C, $1B db $1A, $1C, $14, $19, $0C, $07, $1D, $2F db $07, $15, $12, $0D, $0D, $0E, $11, $17 db $28, $27, $04, $04, $0F, $16, $03, $13 db $01, $1E, $10, $00, $00, $00, $00, $00 db $00, $30, $22, $21, $24, $24, $24, $23 db $23, $23, $29, $2A, $2C, $2B, $03, $03 db $34, $35, $31, $33, $02, $32, $36, $37 db $2C, $06, $0C, $38 ;new db $39, $3A, $3B, $3C db $18 ; Master Sword (Safe) db $3D, $3E, $3F, $40 ; +5/+10 Bomb Arrows db $00, $00, $00 ; 3x Programmable Item db $41 ; Upgrade-Only Sivler Arrows db $24 ; 1 Rupoor db $47 ; Null Item db $48, $48, $48 ; Red, Blue & Green Clocks db $FF, $FF, $04, $0D ; Progressive Sword, Shield, Armor & Gloves db $FF, $FF ; RNG Single & Multi db $FF, $FF, $FF, $FF, $FF, $FF ; Unused db $49, $4A, $49 ; Goal Item Single, Multi & Alt Multi db $FF, $FF, $FF ; Unused db $21, $21, $21, $21, $21, $21, $21, $21, $21, $21, $21, $21, $21, $21, $21, $21 ; Free Map db $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16 ; Free Compass db $22, $22, $22, $22, $22, $22, $22, $22, $22, $22, $22, $22, $22, $22, $22, $22 ; Free Big Key db $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F ; Free Small Key ;db $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; *EVENT* ;db $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; *EVENT* ;db $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; *EVENT* ;db $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; *EVENT* ; #$B0 - SM Items db $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F ; Super Metroid db $60, $61, $62, $63, $64, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; Super Metroid db $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; Unused db $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49, $49 ; Unused .wide_item_flag db $00, $00, $00, $00, $00, $02, $02, $00 db $00, $00, $00, $00, $00, $02, $02, $02 db $02, $02, $02, $00, $02, $00, $02, $02 db $00, $02, $02, $02, $02, $02, $02, $02 db $02, $02, $02, $02, $00, $02, $02, $02 db $02, $02, $00, $02, $02, $02, $02, $02 db $02, $02, $02, $02, $00, $00, $00, $02 db $02, $02, $02, $02, $02, $02, $02, $02 db $02, $02, $00, $00, $02, $00, $02, $02 db $02, $00, $02, $02 ;new db $02, $02, $02, $02 db $00 ; Master Sword (Safe) db $02, $02, $02, $02 ; +5/+10 Bomb Arrows db $02, $02, $02 ; 3x Programmable Item db $02 ; Upgrade-Only Sivler Arrows db $00 ; 1 Rupoor db $02 ; Null Item db $02, $02, $02 ; Red, Blue & Green Clocks db $02, $02, $02, $02 ; Progressive Sword, Shield, Armor & Gloves db $02, $02 ; RNG Single & Multi db $02, $02, $02, $02, $02, $02 ; Unused db $02, $02, $02 ; Goal Item Single, Multi & Alt Multi db $02, $02, $02 ; Unused db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Free Map db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Free Compass db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Free Big Key db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; Free Small Key ; #$B0 - SM Items db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Unused db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Unused db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Unused db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Unused db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 ; Unused .properties db 5, -1, 5, 5, 5, 5, 5, 1 db 2, 1, 1, 1, 2, 2, 2, 4 db 4, 4, 1, 1, 2, 1, 1, 1 db 2, 1, 2, 1, 4, 4, 2, 1 db 6, 1, 2, 1, 2, 2, 1, 2 db 2, 4, 1, 1, 4, 2, 1, 4 db 2, 2, 4, 4, 4, 2, 1, 4 db 1, 2, 2, 1, 2, 2, 1, 1 db 4, 4, 1, 2, 2, 4, 4, 4 db 2, 5, 2, 1 ;new db 4, 4, 4, 4 db 5 ; Master Sword (Safe) db 4, 4, 4, 4 ; +5/+10 Bomb Arrows db 4, 4, 4 ; 3x Programmable Item db 1 ; Upgrade-Only Sivler Arrows db 3 ; 1 Rupoor db 1 ; Null Item db 1, 2, 4 ; Red, Blue & Green Clocks db $FF, $FF, $FF, $FF ; Progressive Sword, Shield, Armor & Gloves db $FF, $FF ; RNG Single & Multi db 0, 0, 0, 0, 0, 0 ; Unused db 4, 4, 4 ; Goal Item Single, Multi & Alt Multi db 0, 0, 0 ; Unused db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Free Map db 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ; Free Compass db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Free Big Key db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Free Small Key ; #$B0 - SM Items db 1, 5, 1, 2, 2, 4, 2, 2, 2, 1, 4, 1, 2, 2, 2, 4 ; Unused db 1, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Unused db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Unused db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Unused db 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ; Unused ; \item Target SRAM addresses for items you receive .item_target_addr dw $F359, $F359, $F359, $F359, $F35A, $F35A, $F35A, $F345 dw $F346, $F34B, $F342, $F340, $F341, $F344, $F35C, $F347 dw $F348, $F349, $F34A, $F34C, $F34C, $F350, $F35C, $F36B dw $F351, $F352, $F353, $F354, $F354, $F34E, $F356, $F357 dw $F37A, $F34D, $F35B, $F35B, $F36F, $F364, $F36C, $F375 dw $F375, $F344, $F341, $F35C, $F35C, $F35C, $F36D, $F36E dw $F36E, $F375, $F366, $F368, $F360, $F360, $F360, $F374 dw $F374, $F374, $F340, $F340, $F35C, $F35C, $F36C, $F36C dw $F360, $F360, $F372, $F376, $F376, $F373, $F360, $F360 dw $F35C, $F359, $F34C, $F355 ;new dw $F375, $F376, $F373, $F373 dw $F359 ; Master Sword (Safe) dw $F375, $F375, $F376, $F376 ; +5/+10 Bomb Arrows dw $F41A, $F41C, $F41E ; 3x Programmable Item dw $F340 ; Upgrade-Only Sivler Arrows dw $F360 ; 1 Rupoor dw $F36A ; Null Item dw $F454, $F454, $F454 ; Red, Blue & Green Clocks dw $F359, $F35A, $F35B, $F354 ; Progressive Sword, Shield, Armor & Gloves dw $F36A, $F36A ; RNG Single & Multi dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused dw $F36A, $F36A, $F36A ; Goal Item Single, Multi & Alt Multi dw $F36A, $F36A, $F36A ; Unused dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Free Map dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Free Compass dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Free Big Key dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Free Small Key dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused dw $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A, $F36A ; Unused } ; DATA Values to write to the above SRAM locations. { .item_values db $01, $02, $03, $04, $01, $02, $03, $01 db $01, $01, $01, $01, $01, $02, $FF, $01 db $01, $01, $01, $01, $02, $01, $FF, $FF db $01, $01, $02, $01, $02, $01, $01, $01 db $FF, $01, $FF, $02, $FF, $FF, $FF, $FF db $FF, $FF, $02, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FB, $EC, $FF db $FF, $FF, $01, $03, $FF, $FF, $FF, $FF db $9C, $CE, $FF, $01, $0A, $FF, $FF, $FF db $FF, $01, $03, $01 ;new db $32, $46, $80, $80 db $02 ; Master Sword (Safe) db $FF, $FF, $FF, $FF ; +5/+10 Bomb Arrows db $FF, $FF, $FF ; 3x Programmable Item db $FF ; Upgrade-Only Sivler Arrows db $FF ; 1 Rupoor db $FF ; Null Item db $FF, $FF, $FF ; Red, Blue & Green Clocks db $FF, $FF, $FF, $FF ; Progressive Sword, Shield, Armor & Gloves db $FF, $FF ; RNG Single & Multi db $FF, $FF, $FF, $FF, $FF, $FF ; Unused db $FF, $FF, $FF ; Goal Item Single, Multi & Alt Multi db $FF, $FF, $FF ; Unused db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Free Map db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Free Compass db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Free Big Key db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Free Small Key db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Unused db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Unused db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Unused db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Unused db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Unused ;0x00 - Sewer Passage ;0x02 - Hyrule Castle ;0x04 - Eastern Palace ;0x06 - Desert Palace ;0x08 - Hyrule Castle 2 ;0x0A - Swamp Palace ;0x0C - Dark Palace ;0x0E - Misery Mire ;0x10 - Skull Woods ;0x12 - Ice Palace ;0x14 - Tower of Hera ;0x16 - Gargoyle's Domain ;0x18 - Turtle Rock ;0x1A - Ganon's Tower .item_masks ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 dw $0080, $0040, $0020, $0010, $0008, $0004, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000 db $00 dw $0000 ; Caves } ;-------------------------------------------------------------------------------- BottleListExpanded: db $16, $2B, $2C, $2D, $3D, $3C, $48 PotionListExpanded: db $2E, $2F, $30, $FF, $0E ;-------------------------------------------------------------------------------- Link_ReceiveItemAlternatesExpanded: { db -1, -1, -1, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 ; db -1, -1, -1, -1, $44, -1, -1, -1 db -1, -1, $35, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 ; db -1, -1, $46, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 db -1, -1, -1, -1, -1, -1, -1, -1 db -1, -1, -1, -1 db -1, -1, -1, -1 db -1 ; Master Sword (Safe) db -1, -1, -1, -1 ; +5/+10 Bomb Arrows db -1, -1, -1 ; 3x Programmable Item db -1 ; Upgrade-Only Silver Arrows db -1 ; 1 Rupoor db -1 ; Null Item db -1, -1, -1 ; Red, Blue & Green Clocks db -1, -1, -1, -1 ; Progressive Sword, Shield, Armor & Gloves db -1, -1 ; RNG Single & Multi db -1, -1, -1, -1, -1, -1 ; Unused db -1, -1 ; Goal Item Single, Multi & Alt Multi db -1, -1, -1, -1 ; Unused db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Free Map db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Free Compass db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Free Big Key db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Free Small Key db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Unused db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Unused db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Unused db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Unused db -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ; Unused } ;-------------------------------------------------------------------------------- .loadAlternate PHB : PHK : PLB ;TYA : JSR IncrementItemCounters ;LDA Link_ReceiveItemAlternatesExpanded, Y : STA $03 ;TYA : JSR AttemptItemSubstitution : STA $03 ;CPY $03 : BNE + : LDA.b #$FF : STA $03 : + lda.b #$ff : sta $03 PLB RTL ;-------------------------------------------------------------------------------- ;DrawHUDSilverArrows: ; LDA $7EF340 : AND.w #$00FF : BNE + ; LDA !INVENTORY_SWAP_2 : AND.w #$0040 : BEQ + ; LDA.w #$2810 : STA $11C8 ; LDA.w #$2811 : STA $11CA ; LDA.w #$2820 : STA $1208 ; LDA.w #$2821 : STA $120A ; + ; LDA.w #$11CE : STA $00 ; thing we wrote over ;RTL ;-------------------------------------------------------------------------------- ;Return $7EF340 but also draw silver arrows if you have the upgrade even if you don't have the bow CheckHUDSilverArrows: LDA.l ArrowMode : BEQ .normal .rupee_arrows JSL.l DrawHUDArrows LDA $7EF340 RTL .normal LDA $7EF340 : BNE + LDA !INVENTORY_SWAP_2 : AND.b #$40 : BEQ ++ JSL.l DrawHUDArrows ++ LDA $7EF340 + RTL ;-------------------------------------------------------------------------------- DrawHUDArrows: LDA.l ArrowMode : BEQ .normal .rupee_arrows LDA $7EF377 : BEQ .none ; assuming silvers will increment this. if we go with something else, reorder these checks LDA $7EF340 : BNE + LDA !INVENTORY_SWAP_2 : AND.b #$40 : BNE .silver BRA .wooden + CMP.b #03 : !BGE .silver .wooden LDA.b #$A7 : STA $7EC720 ; draw wooden arrow marker LDA.b #$20 : STA $7EC721 LDA.b #$A9 : STA $7EC722 LDA.b #$20 : STA $7EC723 RTL .normal ; in normal arrow mode this function is only ever called for silvers .silver LDA.b #$86 : STA $7EC720 ; draw silver arrow marker LDA.b #$24 : STA $7EC721 LDA.b #$87 : STA $7EC722 LDA.b #$24 : STA $7EC723 RTL .none LDA.b #$7F : STA $7EC720 ; draw no arrow marker LDA.b #$24 : STA $7EC721 LDA.b #$7F : STA $7EC722 LDA.b #$24 : STA $7EC723 RTL ;-------------------------------------------------------------------------------- !RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" !SINGLE_INDEX_BITMASK_TEMP = "$7F5022" !LOCK_IN = "$7F5090" GetRNGItemSingle: PHY LDA !LOCK_IN : CMP.b #$FF : BEQ + : TAX : XBA : LDA.l RNGSingleItemTable, X : RTL : + LDX.b #$00 .single_reroll JSL.l GetRandomInt : AND.b #$7F ; select random value INX : CPX #$7F : !BLT + : LDA.b #$00 : BRA +++ : + ; default to 0 if too many attempts CMP.l RNGSingleTableSize : !BGE .single_reroll +++ STA !SINGLE_INDEX_TEMP ; put our index value here LDX #$00 TAY .recheck TYA JSR.w CheckSingleItem : BEQ .single_unused ; already used LDA !SINGLE_INDEX_TEMP : INC ; increment index CMP.l RNGSingleTableSize : !BLT +++ : LDA.b #$00 : +++ ; rollover index if needed STA !SINGLE_INDEX_TEMP ; store index INX : TAY : TXA : CMP.l RNGSingleTableSize : !BLT .recheck LDA.b #$5A ; everything is gone, default to null item - MAKE THIS AN OPTION FOR THIS AND THE OTHER ONE BRA .single_done .single_unused LDA !SINGLE_INDEX_TEMP .single_done TAX : LDA.l RNGSingleItemTable, X XBA : LDA.l !SINGLE_INDEX_TEMP : STA !LOCK_IN : XBA PLY RTL ;-------------------------------------------------------------------------------- CheckSingleItem: LSR #3 : TAX LDA.l !RNG_ITEM, X : STA !SINGLE_INDEX_BITMASK_TEMP ; load value to temporary PHX LDA !SINGLE_INDEX_TEMP : AND #$07 : TAX ; load 0-7 part into X LDA !SINGLE_INDEX_BITMASK_TEMP --- CPX.b #$00 : BEQ +++ LSR DEX BRA --- +++ PLX AND.b #$01 RTS ;-------------------------------------------------------------------------------- MarkRNGItemSingle: ;STA !SINGLE_INDEX_TEMP LSR #3 : STA !SINGLE_INDEX_OFFSET_TEMP : TAX LDA.l !RNG_ITEM, X STA.l !SINGLE_INDEX_BITMASK_TEMP LDA.l !SINGLE_INDEX_TEMP : AND #$07 : TAX ; load 0-7 part into X LDA.b #01 --- CPX.b #$00 : BEQ +++ ASL DEX BRA --- +++ PHA LDA.l !SINGLE_INDEX_OFFSET_TEMP : TAX PLA ORA.l !SINGLE_INDEX_BITMASK_TEMP STA.l !RNG_ITEM, X RTS ;-------------------------------------------------------------------------------- GetRNGItemMulti: LDA !LOCK_IN : CMP #$FF : BEQ + : TAX : XBA : LDA.l RNGMultiItemTable, X : RTL : + LDX.b #$00 - ; reroll JSL.l GetRandomInt : AND.b #$7F ; select random value INX : CPX #$7F : !BLT + : LDA.b 00 : BRA .done : + ; default to 0 if too many attempts CMP.l RNGMultiTableSize : !BGE - .done STA !LOCK_IN TAX : XBA : LDA.l RNGMultiItemTable, X RTL ;-------------------------------------------------------------------------------- IncrementItemCounters: PHX : PHA LDX.b #$00 - LDA.l ItemSubstitutionRules, X CMP.b #$FF : BEQ .exit CMP 1,s : BNE .noMatch .match PHX TXA : LSR #2 : TAX LDA.l !ITEM_LIMIT_COUNTS, X : INC : STA.l !ITEM_LIMIT_COUNTS, X PLX BEQ .exit .noMatch INX #4 BRA - .exit PLA : PLX RTS ;-------------------------------------------------------------------------------- AttemptItemSubstitution: PHX : PHA LDA.l config_multiworld BEQ + PLA : JSL alttp_multiworld_replace_item ; Replace item from multiworld table if needed BRA .exit + PLA ; PHA ; LDX.b #$00 ; - ; LDA.l ItemSubstitutionRules, X ; CMP.b #$FF : BEQ .exit ; CMP 1,s : BNE .noMatch ; .match ; PHX ; TXA : LSR #2 : TAX ; LDA.l !ITEM_LIMIT_COUNTS, X ; PLX ; CMP.l ItemSubstitutionRules+1, X : !BLT + ; LDA.l ItemSubstitutionRules+2, X : STA 1,s ; + ; BEQ .exit ; .noMatch ; INX #4 ; BRA - .exit PLX RTS AttemptItemSubstitutionLong: ;JSR AttemptItemSubstitution PHA : LDA config_multiworld : BEQ + PLA JSL alttp_multiworld_replace_graphics BRA .end + PLA .end RTL ; ; Enables the light cone temporarily when picking up items in a dark room without the lamp ; EnableTemporaryCone: LDA $7EC005 ; Check if dark room BEQ + LDA $7EF34A ; Check if we have lamp BNE + LDA $7E00A0 CMP #$55 ; Check if we're in secret passage BEQ + LDA #$01 STA $1D ; Enable color math for BG1 STA $0458 ; Set the "Lamp in dark room flag" temporarily JSL $00F568 ; JSL OrientLampBg - Updates BG1 scroll positions for the lamp cone REP #$20 ; Write the scroll positions to the PPU registers LDA $E0 : STA $120 : STA $210D LDA $E6 : STA $124 : STA $210E SEP #$20 + RTS DisableTemporaryCone: PHA LDA $7EC005 ; Check if dark room BEQ + LDA $7EF34A ; Check if we have lamp BNE + LDA #$00 STA $1D STA $458 ; Disable the light cone while picking up an item + PLA CMP #$02 : BEQ + STZ $02E4 + RTL ;-------------------------------------------------------------------------------- CountBottles: LDX.b #$00 LDA $7EF35C : BEQ ++ : INX ++ : LDA $7EF35D : BEQ ++ : INX ++ : LDA $7EF35E : BEQ ++ : INX ++ : LDA $7EF35F : BEQ ++ : INX ++ TXA RTS CountBottlesLong: JSR CountBottles RTL ;-------------------------------------------------------------------------------- ;ActivateGoal: ; STZ $11 ; STZ $B0 ;JML.l StatsFinalPrep ;-------------------------------------------------------------------------------- Decomp_spr_high_extended: cpy #$f0 bcs .extended lda $d033,y : sta $ca lda $d112,y : sta $c9 lda $d1f1,y : sta $c8 jml Decomp_spr_high_extended_return .extended tya and #$0f phx tax lda.l .bank,x : sta $ca lda.l .high,x : sta $c9 lda.l .low,x : sta $c8 plx jml Decomp_spr_high_extended_return .bank db GFX_SM_Items>>16, $00, $00, $00, $00, $00, $00, $00 .high db GFX_SM_Items>>8, $00, $00, $00, $00, $00, $00, $00 .low db GFX_SM_Items, $00, $00, $00, $00, $00, $00, $00
// [2021y-02m-05d] Idrisov Denis R. #include <mygtest/modern.hpp> //============================================================================== //============================================================================== #ifdef TEST_MODERN #define dTEST_COMPONENT example, additional #define dTEST_METHOD method #define dTEST_TAG tdd #define TEST_CASE_NAME old_example #define TEST_NUMBER(n) old_method_##n #include <cassert> #include <stdexcept> //============================================================================== //============================================================================== namespace { template <class callable> void death_test(callable& call) { #ifdef NDEBUG // release (void) call; #else // debug ASSERT_DEATH(call(), ".*"); #endif } void foo() { assert(false); dprint(std::cerr << "INVALID\n"); throw ::std::runtime_error("test"); } }//namespace //============================================================================== //============================================================================== TEST(TEST_CASE_NAME, TEST_NUMBER(000)) { ASSERT_DEATH_DEBUG(foo()); } TEST(TEST_CASE_NAME, TEST_NUMBER(001)) { death_test(foo); } dREGISTER_UNIT_TEST(SampleTest_Method, tools\\ololo\\SampleTest, Method) { dprint(std::cout << "ok\n"); } TEST_COMPONENT(002) { ASSERT_DEATH_DEBUG(foo()); } TEST_COMPONENT(003) { death_test(foo); } _TEST_COMPONENT(004) { // --- check compile } TEST_COMPONENT(005) { #ifdef _VARIADIC_MAX dprint(std::cout << "macro: " << _VARIADIC_MAX << '\n'); #endif } //============================================================================== //============================================================================== #endif // ! TEST_MODERN
# mp_limb_t mulredc5(mp_limb_t * z, const mp_limb_t * x, const mp_limb_t * y, # const mp_limb_t *m, mp_limb_t inv_m); # # Stack: # inv_m ## parameters # m # y # x # z (4*(2k+7))%esp # ??? (1 limb???) # ebp ## pushed registers (4*(2k+5))%esp # edi # esi # ebx # ... ## counter (1 mp_limb_t) (4*(2k+1))%esp # ... ## tmp space (2*k+1 mp_limb_t) include(`config.m4') TEXT GLOBL GSYM_PREFIX`'mulredc5 TYPE(GSYM_PREFIX`'mulredc5,`function') GSYM_PREFIX`'mulredc5: pushl %ebp pushl %edi pushl %esi pushl %ebx subl $48, %esp movl %esp, %edi ### set tmp[0..2k+1[ to 0 movl $0, (%edi) movl $0, 4(%edi) movl $0, 8(%edi) movl $0, 12(%edi) movl $0, 16(%edi) movl $0, 20(%edi) movl $0, 24(%edi) movl $0, 28(%edi) movl $0, 32(%edi) movl $0, 36(%edi) movl $0, 40(%edi) ########################################### movl $5, 44(%esp) .align 32 Loop: ## compute u and store in %ebp movl 72(%esp), %eax movl 76(%esp), %esi movl (%eax), %eax mull (%esi) addl (%edi), %eax mull 84(%esp) movl %eax, %ebp movl 80(%esp), %esi ### addmul1: src[0] is (%esi) ### dst[0] is (%edi) ### mult is %ebp ### k is 5 ### kills %eax, %ebx, %ecx, %edx ### dst[0,k[ += mult*src[0,k[ plus carry put in ecx or ebx movl (%esi), %eax mull %ebp movl %eax, %ebx movl %edx, %ecx movl 4(%esi), %eax mull %ebp addl %ebx, (%edi) movl $0, %ebx adcl %eax, %ecx movl 8(%esi), %eax adcl %edx, %ebx mull %ebp addl %ecx, 4(%edi) movl $0, %ecx adcl %eax, %ebx movl 12(%esi), %eax adcl %edx, %ecx mull %ebp addl %ebx, 8(%edi) movl $0, %ebx adcl %eax, %ecx movl 16(%esi), %eax adcl %edx, %ebx mull %ebp addl %ecx, 12(%edi) adcl %ebx, %eax adcl $0, %edx addl %eax, 16(%edi) adcl $0, %edx ### carry limb is in %edx addl %edx, 20(%edi) adcl $0, 24(%edi) movl 72(%esp), %eax movl (%eax), %ebp movl 76(%esp), %esi ### addmul1: src[0] is (%esi) ### dst[0] is (%edi) ### mult is %ebp ### k is 5 ### kills %eax, %ebx, %ecx, %edx ### dst[0,k[ += mult*src[0,k[ plus carry put in ecx or ebx movl (%esi), %eax mull %ebp movl %eax, %ebx movl %edx, %ecx movl 4(%esi), %eax mull %ebp addl %ebx, (%edi) movl $0, %ebx adcl %eax, %ecx movl 8(%esi), %eax adcl %edx, %ebx mull %ebp addl %ecx, 4(%edi) movl $0, %ecx adcl %eax, %ebx movl 12(%esi), %eax adcl %edx, %ecx mull %ebp addl %ebx, 8(%edi) movl $0, %ebx adcl %eax, %ecx movl 16(%esi), %eax adcl %edx, %ebx mull %ebp addl %ecx, 12(%edi) adcl %ebx, %eax adcl $0, %edx addl %eax, 16(%edi) adcl $0, %edx ### carry limb is in %edx addl %edx, 20(%edi) adcl $0, 24(%edi) addl $4, 72(%esp) addl $4, %edi decl 44(%esp) jnz Loop ########################################### ### Copy result in z movl 68(%esp), %ebx movl (%edi), %eax movl %eax, (%ebx) movl 4(%edi), %eax movl %eax, 4(%ebx) movl 8(%edi), %eax movl %eax, 8(%ebx) movl 12(%edi), %eax movl %eax, 12(%ebx) movl 16(%edi), %eax movl %eax, 16(%ebx) movl 20(%edi), %eax # carry addl $48, %esp popl %ebx popl %esi popl %edi popl %ebp ret
#include "Fl_Multiline_OutputC.h" #ifdef __cplusplus EXPORT { #endif /* Inherited from Fl_Widget */ FL_EXPORT_C(int,Fl_Multiline_Output_handle)(fl_Multiline_Output self, int event){ return (static_cast<Fl_Multiline_Output*>(self))->handle(event); } FL_EXPORT_C(fl_Group,Fl_Multiline_Output_parent)(fl_Multiline_Output multiline_output){ return (fl_Group) (static_cast<Fl_Multiline_Output*>(multiline_output))->parent(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_parent)(fl_Multiline_Output multiline_output,fl_Group grp){ (static_cast<Fl_Multiline_Output*>(multiline_output))->parent((static_cast<Fl_Group*>(grp))); } FL_EXPORT_C(uchar,Fl_Multiline_Output_type)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->type(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_type)(fl_Multiline_Output multiline_output,uchar t){ (static_cast<Fl_Multiline_Output*>(multiline_output))->type(t); } FL_EXPORT_C(int,Fl_Multiline_Output_x)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->x(); } FL_EXPORT_C(int,Fl_Multiline_Output_y)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->y(); } FL_EXPORT_C(int,Fl_Multiline_Output_w)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->w(); } FL_EXPORT_C(int,Fl_Multiline_Output_h)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->h(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_align)(fl_Multiline_Output multiline_output, Fl_Align alignment){ (static_cast<Fl_Multiline_Output*>(multiline_output))->align(alignment); } FL_EXPORT_C(Fl_Align,Fl_Multiline_Output_align)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->align(); } FL_EXPORT_C(Fl_Boxtype,Fl_Multiline_Output_box)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->box(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_box)(fl_Multiline_Output multiline_output,Fl_Boxtype new_box){ (static_cast<Fl_Multiline_Output*>(multiline_output))->box((static_cast<Fl_Boxtype>(new_box))); } FL_EXPORT_C(Fl_Color,Fl_Multiline_Output_color)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->color(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_color)(fl_Multiline_Output multiline_output,Fl_Color bg){ (static_cast<Fl_Multiline_Output*>(multiline_output))->color(bg); } FL_EXPORT_C(void,Fl_Multiline_Output_set_color_with_bg_sel)(fl_Multiline_Output multiline_output,Fl_Color bg,Fl_Color a){ (static_cast<Fl_Multiline_Output*>(multiline_output))->color(bg,a); } FL_EXPORT_C(Fl_Color,Fl_Multiline_Output_selection_color)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->selection_color(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_selection_color)(fl_Multiline_Output multiline_output,Fl_Color a){ (static_cast<Fl_Multiline_Output*>(multiline_output))->selection_color(a); } FL_EXPORT_C(const char*,Fl_Multiline_Output_label)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->label(); } FL_EXPORT_C(void,Fl_Multiline_Output_copy_label)(fl_Multiline_Output multiline_output,const char* new_label){ (static_cast<Fl_Multiline_Output*>(multiline_output))->copy_label(new_label); } FL_EXPORT_C(void,Fl_Multiline_Output_set_label)(fl_Multiline_Output multiline_output,const char* text){ (static_cast<Fl_Multiline_Output*>(multiline_output))->label(text); } FL_EXPORT_C(Fl_Labeltype,Fl_Multiline_Output_labeltype)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->labeltype(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_labeltype)(fl_Multiline_Output multiline_output,Fl_Labeltype a){ (static_cast<Fl_Multiline_Output*>(multiline_output))->labeltype(a); } FL_EXPORT_C(void,Fl_Multiline_Output_set_labelcolor)(fl_Multiline_Output multiline_output,Fl_Color c){ (static_cast<Fl_Multiline_Output*>(multiline_output))->labelcolor(c); } FL_EXPORT_C(Fl_Color ,Fl_Multiline_Output_labelcolor)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->labelcolor(); } FL_EXPORT_C(Fl_Font,Fl_Multiline_Output_labelfont)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->labelfont(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_labelfont)(fl_Multiline_Output multiline_output,Fl_Font c){ (static_cast<Fl_Multiline_Output*>(multiline_output))->labelfont((static_cast<Fl_Font>(c))); } FL_EXPORT_C(Fl_Fontsize,Fl_Multiline_Output_labelsize)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->labelsize(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_labelsize)(fl_Multiline_Output multiline_output,Fl_Fontsize pix){ (static_cast<Fl_Multiline_Output*>(multiline_output))->labelsize((static_cast<Fl_Fontsize>(pix))); } FL_EXPORT_C(fl_Image,Fl_Multiline_Output_image)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->image(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_image)(fl_Multiline_Output multiline_output,fl_Image pix){ (static_cast<Fl_Multiline_Output*>(multiline_output))->image((static_cast<Fl_Image*>(pix))); } FL_EXPORT_C(fl_Image,Fl_Multiline_Output_deimage)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->deimage(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_deimage)(fl_Multiline_Output multiline_output,fl_Image pix){ (static_cast<Fl_Multiline_Output*>(multiline_output))->deimage((static_cast<Fl_Image*>(pix))); } FL_EXPORT_C(const char*,Fl_Multiline_Output_tooltip)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->tooltip(); } FL_EXPORT_C(void,Fl_Multiline_Output_copy_tooltip)(fl_Multiline_Output multiline_output,const char* text){ (static_cast<Fl_Multiline_Output*>(multiline_output))->copy_tooltip(text); } FL_EXPORT_C(void,Fl_Multiline_Output_set_tooltip)(fl_Multiline_Output multiline_output,const char* text){ (static_cast<Fl_Multiline_Output*>(multiline_output))->tooltip(text); } FL_EXPORT_C(void,Fl_Multiline_Output_set_callback_with_user_data)(fl_Multiline_Output multiline_output,fl_Callback* cb,void* p){ Fl_Multiline_Output* castedInput_dow = (static_cast<Fl_Multiline_Output*>(multiline_output)); new C_to_Fl_Callback(castedInput_dow, cb, p); } FL_EXPORT_C(void,Fl_Multiline_Output_set_callback)(fl_Multiline_Output multiline_output,fl_Callback* cb){ Fl_Multiline_Output* castedInput_dow = (static_cast<Fl_Multiline_Output*>(multiline_output)); new C_to_Fl_Callback(castedInput_dow, cb); } FL_EXPORT_C(void*,Fl_Multiline_Output_user_data)(fl_Multiline_Output multiline_output){ C_to_Fl_Callback* stored_cb = (static_cast<C_to_Fl_Callback*>((static_cast<Fl_Multiline_Output*>(multiline_output))->user_data())); if(stored_cb){ return stored_cb->get_user_data(); } else { return (static_cast<Fl_Multiline_Output*>(multiline_output))->user_data(); } } FL_EXPORT_C(void,Fl_Multiline_Output_set_user_data)(fl_Multiline_Output multiline_output,void* v){ C_to_Fl_Callback* stored_cb = (static_cast<C_to_Fl_Callback*>((static_cast<Fl_Multiline_Output*>(multiline_output))->user_data())); if (stored_cb) { stored_cb->set_user_data(v); (static_cast<Fl_Multiline_Output*>(multiline_output))->user_data(stored_cb); } else { (static_cast<Fl_Multiline_Output*>(multiline_output))->user_data(v); } } FL_EXPORT_C(long,Fl_Multiline_Output_argument)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->argument(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_argument)(fl_Multiline_Output multiline_output,long v){ (static_cast<Fl_Multiline_Output*>(multiline_output))->argument(v); } FL_EXPORT_C(Fl_When,Fl_Multiline_Output_when)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->when(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_when)(fl_Multiline_Output multiline_output,uchar i){ (static_cast<Fl_Multiline_Output*>(multiline_output))->when(i); } FL_EXPORT_C(unsigned int,Fl_Multiline_Output_visible)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->visible(); } FL_EXPORT_C(int,Fl_Multiline_Output_visible_r)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->visible_r(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_visible)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->visible(); } FL_EXPORT_C(void,Fl_Multiline_Output_clear_visible)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->clear_visible(); } FL_EXPORT_C(unsigned int,Fl_Multiline_Output_active)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->active(); } FL_EXPORT_C(int,Fl_Multiline_Output_active_r)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->active_r(); } FL_EXPORT_C(void,Fl_Multiline_Output_activate)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->activate(); } FL_EXPORT_C(void,Fl_Multiline_Output_deactivate)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->deactivate(); } FL_EXPORT_C(unsigned int,Fl_Multiline_Output_multiline_output)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->output(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_multiline_output)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->output(); } FL_EXPORT_C(void,Fl_Multiline_Output_clear_multiline_output)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->clear_output(); } FL_EXPORT_C(unsigned int,Fl_Multiline_Output_takesevents)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->takesevents(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_changed)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->changed(); } FL_EXPORT_C(void,Fl_Multiline_Output_clear_changed)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->clear_changed(); } FL_EXPORT_C(int,Fl_Multiline_Output_take_focus)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->take_focus(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_visible_focus)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->set_visible_focus(); } FL_EXPORT_C(void,Fl_Multiline_Output_clear_visible_focus)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->clear_visible_focus(); } FL_EXPORT_C(void,Fl_Multiline_Output_modify_visible_focus)(fl_Multiline_Output multiline_output,int v){ (static_cast<Fl_Multiline_Output*>(multiline_output))->visible_focus(v); } FL_EXPORT_C(unsigned int,Fl_Multiline_Output_visible_focus)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->visible_focus(); } FL_EXPORT_C(void,Fl_Multiline_Output_do_callback)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->do_callback(); } FL_EXPORT_C(void,Fl_Multiline_Output_do_callback_with_widget_and_user_data)(fl_Multiline_Output multiline_output,fl_Widget w,long arg){ (static_cast<Fl_Multiline_Output*>(multiline_output))->do_callback((static_cast<Fl_Widget*>(w)),arg); } FL_EXPORT_C(void,Fl_Multiline_Output_do_callback_with_widget_and_default_user_data)(fl_Multiline_Output multiline_output,fl_Widget w){ (static_cast<Fl_Multiline_Output*>(multiline_output))->do_callback((static_cast<Fl_Widget*>(w))); } FL_EXPORT_C(int,Fl_Multiline_Output_contains)(fl_Multiline_Output multiline_output,fl_Widget w){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->contains((static_cast<Fl_Widget*>(w))); } FL_EXPORT_C(int,Fl_Multiline_Output_inside)(fl_Multiline_Output multiline_output,fl_Widget w){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->inside((static_cast<Fl_Widget*>(w))); } FL_EXPORT_C(void,Fl_Multiline_Output_redraw)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->redraw(); } FL_EXPORT_C(void,Fl_Multiline_Output_redraw_label)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->redraw_label(); } FL_EXPORT_C(uchar,Fl_Multiline_Output_damage)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->damage(); } FL_EXPORT_C(void,Fl_Multiline_Output_clear_damage_with_bitmask)(fl_Multiline_Output multiline_output,uchar c){ (static_cast<Fl_Multiline_Output*>(multiline_output))->clear_damage(c); } FL_EXPORT_C(void,Fl_Multiline_Output_clear_damage)(fl_Multiline_Output multiline_output){ (static_cast<Fl_Multiline_Output*>(multiline_output))->clear_damage(); } FL_EXPORT_C(void,Fl_Multiline_Output_damage_with_text)(fl_Multiline_Output multiline_output,uchar c){ (static_cast<Fl_Multiline_Output*>(multiline_output))->damage(c); } FL_EXPORT_C(void,Fl_Multiline_Output_damage_inside_widget)(fl_Multiline_Output multiline_output,uchar c,int x,int y,int w,int h){ (static_cast<Fl_Multiline_Output*>(multiline_output))->damage(c,x,y,w,h); } FL_EXPORT_C(void,Fl_Multiline_Output_draw_label_with_xywh_alignment)(fl_Multiline_Output multiline_output,int x,int y,int w,int h,Fl_Align alignment){ (static_cast<Fl_Multiline_Output*>(multiline_output))->draw_label(x,y,w,h,alignment); } FL_EXPORT_C(void,Fl_Multiline_Output_measure_label)(fl_Multiline_Output multiline_output,int* ww,int* hh){ (static_cast<Fl_Multiline_Output*>(multiline_output))->measure_label(*ww,*hh); } FL_EXPORT_C(fl_Window, Fl_Multiline_Output_window)(fl_Multiline_Output multiline_output){ return (fl_Window) (static_cast<Fl_Multiline_Output*>(multiline_output))->window(); } FL_EXPORT_C(fl_Window, Fl_Multiline_Output_top_window)(fl_Multiline_Output multiline_output){ return (fl_Window) (static_cast<Fl_Multiline_Output*>(multiline_output))->top_window(); } FL_EXPORT_C(fl_Window , Fl_Multiline_Output_top_window_offset)(fl_Multiline_Output multiline_output, int* xoff, int* yoff){ return (fl_Window) (static_cast<Fl_Multiline_Output*>(multiline_output))->top_window_offset(*xoff,*yoff); } FL_EXPORT_C(fl_Group,Fl_Multiline_Output_as_group)(fl_Multiline_Output multiline_output){ return (fl_Group) (static_cast<Fl_Multiline_Output*>(multiline_output))->as_group(); } FL_EXPORT_C(fl_Gl_Window,Fl_Multiline_Output_as_gl_window)(fl_Multiline_Output multiline_output){ return (fl_Gl_Window) (static_cast<Fl_Multiline_Output*>(multiline_output))->as_gl_window(); } /* Fl_Multiline_Output specific functions */ FL_EXPORT_C(fl_Multiline_Output, Fl_Multiline_Output_New_WithLabel)(int x, int y, int w, int h, const char* label) { Fl_Multiline_Output* multiline_output = new Fl_Multiline_Output(x,y,w,h,label); return (static_cast<fl_Multiline_Output>(multiline_output)); } FL_EXPORT_C(fl_Multiline_Output, Fl_Multiline_Output_New)(int x, int y, int w, int h) { Fl_Multiline_Output* multiline_output = new Fl_Multiline_Output(x,y,w,h,0); return (fl_Multiline_Output)multiline_output; } FL_EXPORT_C(void,Fl_Multiline_Output_Destroy)(fl_Multiline_Output multiline_output){ delete (static_cast<Fl_Multiline_Output*>(multiline_output)); } FL_EXPORT_C(void,Fl_Multiline_Output_resize)(fl_Multiline_Output multiline_output,int X,int Y,int W,int H){ (static_cast<Fl_Multiline_Output*>(multiline_output))->resize(X,Y,W,H); } FL_EXPORT_C(int,Fl_Multiline_Output_set_value)(fl_Multiline_Output multiline_output,const char* text){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->value(text); } FL_EXPORT_C(int,Fl_Multiline_Output_set_value_with_length)(fl_Multiline_Output multiline_output,const char* text,int length){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->value(text,length); } FL_EXPORT_C(int,Fl_Multiline_Output_static_value)(fl_Multiline_Output multiline_output,const char* text){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->static_value(text); } FL_EXPORT_C(int,Fl_Multiline_Output_static_value_with_length)(fl_Multiline_Output multiline_output,const char* text,int length){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->static_value(text,length); } FL_EXPORT_C(const char*,Fl_Multiline_Output_value)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->value(); } FL_EXPORT_C(Fl_Char,Fl_Multiline_Output_index)(fl_Multiline_Output multiline_output,int i){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->index(i); } FL_EXPORT_C(int,Fl_Multiline_Output_size)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->size(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_size)(fl_Multiline_Output multiline_output,int W,int H){ (static_cast<Fl_Multiline_Output*>(multiline_output))->size(W,H); } FL_EXPORT_C(int,Fl_Multiline_Output_maximum_size)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->maximum_size(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_maximum_size)(fl_Multiline_Output multiline_output,int m){ (static_cast<Fl_Multiline_Output*>(multiline_output))->maximum_size(m); } FL_EXPORT_C(int,Fl_Multiline_Output_position)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->position(); } FL_EXPORT_C(int,Fl_Multiline_Output_mark)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->mark(); } FL_EXPORT_C(int,Fl_Multiline_Output_set_position_with_cursor_mark)(fl_Multiline_Output multiline_output,int p,int m){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->position(p,m); } FL_EXPORT_C(int,Fl_Multiline_Output_set_position_n_n)(fl_Multiline_Output multiline_output,int p){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->position(p); } FL_EXPORT_C(int,Fl_Multiline_Output_set_mark)(fl_Multiline_Output multiline_output,int m){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->mark(m); } FL_EXPORT_C(int,Fl_Multiline_Output_replace)(fl_Multiline_Output multiline_output,int b,int e,const char* text){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->replace(b,e,text); } FL_EXPORT_C(int,Fl_Multiline_Output_replace_with_ilen)(fl_Multiline_Output multiline_output,int b,int e,const char* text,int ilen){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->replace(b,e,text,ilen); } FL_EXPORT_C(int,Fl_Multiline_Output_cut)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->cut(); } FL_EXPORT_C(int,Fl_Multiline_Output_cut_bytes)(fl_Multiline_Output multiline_output,int n){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->cut(n); } FL_EXPORT_C(int,Fl_Multiline_Output_cut_range)(fl_Multiline_Output multiline_output,int a,int b){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->cut(a,b); } FL_EXPORT_C(int,Fl_Multiline_Output_insert)(fl_Multiline_Output multiline_output,const char* t){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->insert(t); } FL_EXPORT_C(int,Fl_Multiline_Output_insert_with_length)(fl_Multiline_Output multiline_output,const char* t,int l){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->insert(t,l); } FL_EXPORT_C(int,Fl_Multiline_Output_copy)(fl_Multiline_Output multiline_output,int clipboard){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->copy(clipboard); } FL_EXPORT_C(int,Fl_Multiline_Output_undo)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->undo(); } FL_EXPORT_C(int,Fl_Multiline_Output_copy_cuts)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->copy_cuts(); } FL_EXPORT_C(int,Fl_Multiline_Output_shortcut)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->shortcut(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_shortcut)(fl_Multiline_Output multiline_output,int s){ (static_cast<Fl_Multiline_Output*>(multiline_output))->shortcut(s); } FL_EXPORT_C(Fl_Font,Fl_Multiline_Output_textfont)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->textfont(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_textfont)(fl_Multiline_Output multiline_output,Fl_Font s){ (static_cast<Fl_Multiline_Output*>(multiline_output))->textfont(s); } FL_EXPORT_C(Fl_Fontsize,Fl_Multiline_Output_textsize)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->textsize(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_textsize)(fl_Multiline_Output multiline_output,Fl_Fontsize s){ (static_cast<Fl_Multiline_Output*>(multiline_output))->textsize(s); } FL_EXPORT_C(Fl_Color,Fl_Multiline_Output_textcolor)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->textcolor(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_textcolor)(fl_Multiline_Output multiline_output,Fl_Color n){ (static_cast<Fl_Multiline_Output*>(multiline_output))->textcolor(n); } FL_EXPORT_C(Fl_Color,Fl_Multiline_Output_cursor_color)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->cursor_color(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_cursor_color)(fl_Multiline_Output multiline_output,Fl_Color n){ (static_cast<Fl_Multiline_Output*>(multiline_output))->cursor_color(n); } FL_EXPORT_C(int,Fl_Multiline_Output_input_type)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->input_type(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_input_type)(fl_Multiline_Output multiline_output,int t){ (static_cast<Fl_Multiline_Output*>(multiline_output))->input_type(t); } FL_EXPORT_C(int,Fl_Multiline_Output_readonly)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->readonly(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_readonly)(fl_Multiline_Output multiline_output,int b){ (static_cast<Fl_Multiline_Output*>(multiline_output))->readonly(b); } FL_EXPORT_C(int,Fl_Multiline_Output_wrap)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->wrap(); } FL_EXPORT_C(void,Fl_Multiline_Output_set_wrap)(fl_Multiline_Output multiline_output,int b){ (static_cast<Fl_Multiline_Output*>(multiline_output))->wrap(b); } FL_EXPORT_C(void,Fl_Multiline_Output_tab_nav)(fl_Multiline_Output multiline_output,int val){ (static_cast<Fl_Multiline_Output*>(multiline_output))->tab_nav(val); } FL_EXPORT_C(int,Fl_Multiline_Output_set_tab_nav)(fl_Multiline_Output multiline_output){ return (static_cast<Fl_Multiline_Output*>(multiline_output))->tab_nav(); } #ifdef __cplusplus } #endif
; A163163: a(n) = sigma(n) + tau(n) - n. ; 1,3,3,6,3,10,3,11,7,12,3,22,3,14,13,20,3,27,3,28,15,18,3,44,9,20,17,34,3,50,3,37,19,24,17,64,3,26,21,58,3,62,3,46,39,30,3,86,11,49,25,52,3,74,21,72,27,36,3,120,3,38,47,70,23,86,3,64,31,82,3,135,3,44,55,70,23,98,3,116,45,48,3,152,27,50,37,100,3,156,25,82,39,54,29,168,3,79,63,126 mov $2,$0 seq $0,7503 ; Number of subgroups of dihedral group: sigma(n) + d(n). sub $0,$2 sub $0,1
; int fzx_puts_justified_callee(struct fzx_state *fs, char *s, uint16_t allowed_width) SECTION code_font SECTION code_font_fzx PUBLIC _fzx_puts_justified_callee EXTERN asm_fzx_puts_justified _fzx_puts_justified_callee: pop af pop ix pop hl pop bc push af jp asm_fzx_puts_justified
; A267922: Triangle read by rows giving successive states of cellular automaton generated by "Rule 245" initiated with a single ON (black) cell. ; 1,0,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1 lpb $0 sub $0,3 add $2,2 sub $0,$2 lpe cmp $0,1 add $0,1 mod $0,2
db "MOUSE@" ; species name db "When it is anger-" next "ed, it immediately" next "discharges the" page "energy stored in" next "the pouches in its" next "cheeks.@"
; A279030: Decimal representation of the x-axis, from the left edge to the origin, of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 129", based on the 5-celled von Neumann neighborhood. ; 1,0,5,0,21,0,85,0,341,0,1365,0,5461,0,21845,0,87381,0,349525,0,1398101,0,5592405,0,22369621,0,89478485,0,357913941,0,1431655765,0,5726623061,0,22906492245,0,91625968981,0,366503875925,0,1466015503701,0,5864062014805,0,23456248059221,0,93824992236885,0,375299968947541,0,1501199875790165,0,6004799503160661,0,24019198012642645,0,96076792050570581,0,384307168202282325,0,1537228672809129301,0,6148914691236517205,0,24595658764946068821,0,98382635059784275285,0,393530540239137101141,0,1574122160956548404565,0,6296488643826193618261,0,25185954575304774473045,0,100743818301219097892181,0,402975273204876391568725,0,1611901092819505566274901,0,6447604371278022265099605,0,25790417485112089060398421,0,103161669940448356241593685,0,412646679761793424966374741,0,1650586719047173699865498965,0,6602346876188694799461995861,0,26409387504754779197847983445,0,105637550019019116791391933781,0,422550200076076467165567735125,0 mov $1,$0 gcd $0,2 add $1,$0 pow $0,$1 div $0,3
#include <gtest/gtest.h> #include <pheromones/FunctionListLengthRequestDTO.h> class FunctionListLengthRequestDTOFixture : public testing::Test { public: FunctionListLengthRequestDTO* m_fListResquest; void SetUp() override { m_fListResquest = new FunctionListLengthRequestDTO(); } void TearDown() override { delete m_fListResquest; } }; TEST_F(FunctionListLengthRequestDTOFixture, FunctionListLengthRequestDTO_serialize_valid) { // Given FunctionListLengthRequest fListReq; // Then bool ret = m_fListResquest->serialize(fListReq); // Expect EXPECT_TRUE(ret); }
;--------------------------------------- ; exec - execute application ;--------------------------------------- executeApp ld (appParams+1),hl ex de,hl ld a,(hl) cp #00 jp z,errorPar call checkIsPath call storeHomePath ex af,af' cp #00 call z,exeApp ;call restorePath ; restore start path at exit (ok or error) call initCallBack ret exeApp ld a,flagFile ; file call prepareEntry ;ld hl,entrySearch ;call searchEntry call eSearch jp z,fileNotFound ;ld (fileLength),hl ;ld (fileLength+2),de call storeFileLen call setFileBegin call prepareSize call loadApp ret ;--------------------------------------- runApp call cliInit call prepareSize call loadApp cp #00 jp z,pluginExit jp wrongExit ;--------------------------------------- loadApp ld a,appBank call setVideoPage ld hl,appAddr-4 push hl call load512bytes pop hl ld a,(hl) cp 127 jr nz,wrongApp inc hl ld a,(hl) cp "C" jr nz,wrongApp inc hl ld a,(hl) cp "L" jr nz,wrongApp inc hl ld a,(hl) cp "A" jr nz,wrongApp inc hl appParams ld hl,#0000 push hl call restorePath pop hl jp appAddr wrongApp ld hl,wrongAppMsg call printStr ld a,#ff ; wrong application ret
//================================================================================================= /*! // \file src/mathtest/svecdvecmult/VCbV6a.cpp // \brief Source file for the VCbV6a sparse vector/dense vector multiplication math test // // Copyright (C) 2012-2017 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/CompressedVector.h> #include <blaze/math/StaticVector.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/svecdvecmult/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'VCbV6a'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Vector type definitions typedef blaze::CompressedVector<TypeB> VCb; typedef blaze::StaticVector<TypeA,6UL> V6a; // Creator type definitions typedef blazetest::Creator<VCb> CVCb; typedef blazetest::Creator<V6a> CV6a; // Running the tests for( size_t i=0UL; i<=6UL; ++i ) { RUN_SVECDVECMULT_OPERATION_TEST( CVCb( 6UL, i ), CV6a() ); } } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during sparse vector/dense vector multiplication:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
; A267247: Decimal representation of the n-th iteration of the "Rule 165" elementary cellular automaton starting with a single ON (black) cell. ; Submitted by Jamie Morken(s2) ; 1,2,14,42,254,762,3822,10922,65534,196602,983022,2817962,16711422,50002682,250539758,715827882,4294967294,12884901882,64424509422,184683593642,1095216660222,3277060045562,16419659968238,46913927752362,281470681677822,844403454967802,4222051635101678,12103058920767402,71775015237779198,214759888113040122,1076060070966390510,3074457345618258602,18446744073709551614,55340232221128654842,276701161105643274222,793209995169510719402,4703919738795935661822,14074865728240387881722 mul $0,2 seq $0,219843 ; Rows of A219463 seen as numbers in binary representation. trn $0,1 add $0,1
db 0 ; species ID placeholder db 70, 60, 125, 55, 115, 70 ; hp atk def spd sat sdf db ROCK, WATER ; type db 45 ; catch rate db 199 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F12_5 ; gender ratio db 100 ; unknown 1 db 30 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/omastar/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_WATER_1, EGG_WATER_3 ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, ROCK_SMASH, HIDDEN_POWER, SNORE, BLIZZARD, HYPER_BEAM, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, RETURN, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SANDSTORM, REST, ATTRACT, THIEF, SURF, WHIRLPOOL, ICE_BEAM ; end
; A000201: Lower Wythoff sequence (a Beatty sequence): a(n) = floor(n*phi), where phi = (1+sqrt(5))/2 = A001622. ; Submitted by Christian Krause ; 1,3,4,6,8,9,11,12,14,16,17,19,21,22,24,25,27,29,30,32,33,35,37,38,40,42,43,45,46,48,50,51,53,55,56,58,59,61,63,64,66,67,69,71,72,74,76,77,79,80,82,84,85,87,88,90,92,93,95,97,98,100,101,103,105,106,108,110,111,113,114,116,118,119,121,122,124,126,127,129,131,132,134,135,137,139,140,142,144,145,147,148,150,152,153,155,156,158,160,161 mov $2,$0 add $0,1 mov $1,$0 pow $1,2 lpb $1 add $2,2 trn $1,$2 lpe add $0,$2 sub $0,3 div $0,2 add $0,1
; A185057: a(n) = n^n! (mod 5). ; 0,1,4,4,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1 mov $2,$0 lpb $2 pow $0,2 mod $0,5 div $2,2 sub $2,1 lpe
; A029883: First differences of Thue-Morse sequence A001285. ; 1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,1,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,-1,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,1,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,-1,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,1,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,-1,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,1,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,-1,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,1,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,0,-1,0,1,-1,1,0,-1,0,1,0,-1,1,-1,0,1,-1,1,0,-1,1,-1,0,1,0,-1,0 mov $7,$0 mov $9,2 lpb $9 clr $0,7 mov $0,$7 sub $9,1 add $0,$9 sub $0,1 mov $2,$0 add $2,2 mov $4,$2 add $4,$0 mov $0,$4 lpb $0 div $0,2 add $5,$0 mod $5,2 lpe clr $0,5 add $4,$5 add $0,$4 mov $1,$0 mov $10,$9 lpb $10 mov $8,$1 sub $10,1 lpe lpe lpb $7 mov $7,0 sub $8,$1 lpe mov $1,$8
; nasmfunc.asm ; TAB=4 section .text GLOBAL io_hlt, io_cli, io_sti, io_stihlt GLOBAL io_in8, io_in16, io_in32 GLOBAL io_out8, io_out16, io_out32 GLOBAL io_load_eflags, io_store_eflags GLOBAL load_gdtr, load_idtr GLOBAL asm_irq_handler21, asm_irq_handler2c GLOBAL load_cr0, store_cr0 EXTERN irq_handler21, irq_handler2c io_hlt: ; void io_hlt(void) HLT RET io_cli: ; void io_cli(void) CLI RET io_sti: ; void io_sti(void) STI RET io_stihlt: ; void io_stihlt(void) STI HLT RET io_in8: ; int io_in8(int port) MOV EDX, [ESP+4] MOV EAX, 0 IN AL, DX RET io_in16: ; int io_in16(int port) MOV EDX, [ESP+4] MOV EAX, 0 IN AX, DX RET io_in32: ; int io_in32(int port) MOV EDX, [ESP+4] IN EAX, DX RET io_out8 ; void io_out8(int port, int data) MOV EDX, [ESP+4] MOV EAX, [ESP+8] OUT DX, AL RET io_out16 ; void io_out16(int port, int data) MOV EDX, [ESP+4] MOV EAX, [ESP+8] OUT DX, AX RET io_out32 ; void io_out32(int port, int data) MOV EDX, [ESP+4] MOV EAX, [ESP+8] OUT DX, EAX RET io_load_eflags: ; int io_load_eflags(void) PUSHFD ; push eflags POP EAX RET io_store_eflags: MOV EAX, [ESP+4] PUSH EAX POPFD ; pop eflags RET load_gdtr: ; void load_gdtr(int limit, int addr) MOV AX,[ESP+4] ; limit MOV [ESP+6],AX LGDT [ESP+6] RET load_idtr: ; void load_idtr(int limit, int addr) MOV AX,[ESP+4] ; limit MOV [ESP+6],AX LIDT [ESP+6] RET load_cr0: ; int load_cr0(void) MOV EAX, CR0 RET store_cr0: ; void store_cr0(int cr0) MOV EAX, [ESP+4] MOV CR0, EAX RET asm_irq_handler21: ; void irq_handler21(int *esp) PUSH ES PUSH DS PUSHAD MOV EAX, ESP PUSH EAX MOV AX, SS MOV DS, AX MOV ES, AX CALL irq_handler21 POP EAX POPAD POP DS POP ES IRETD asm_irq_handler2c: ; void irq_handler2c(int *esp) PUSH ES PUSH DS PUSHAD MOV EAX, ESP PUSH EAX MOV AX, SS MOV DS, AX MOV ES, AX CALL irq_handler2c POP EAX POPAD POP DS POP ES IRETD
#ifndef ULMBLAS_LEVEL3_MKERNEL_MGEMM_TCC #define ULMBLAS_LEVEL3_MKERNEL_MGEMM_TCC 1 #include <ulmblas/level3/mkernel/mgemm.h> #include <ulmblas/level3/ukernel/ugemm.h> namespace ulmBLAS { template <typename IndexType, typename T, typename Beta, typename TC> void mgemm(IndexType mc, IndexType nc, IndexType kc, const T &alpha, const T *A_, const T *B_, const Beta &beta, TC *C, IndexType incRowC, IndexType incColC) { const IndexType MR = BlockSizeUGemm<T>::MR; const IndexType NR = BlockSizeUGemm<T>::NR; const IndexType mp = (mc+MR-1) / MR; const IndexType np = (nc+NR-1) / NR; const IndexType mr_ = mc % MR; const IndexType nr_ = nc % NR; IndexType mr, nr; const T *nextA; const T *nextB; for (IndexType j=0; j<np; ++j) { nr = (j!=np-1 || nr_==0) ? NR : nr_; nextB = &B_[j*kc*NR]; for (IndexType i=0; i<mp; ++i) { mr = (i!=mp-1 || mr_==0) ? MR : mr_; nextA = &A_[(i+1)*kc*MR]; if (i==mp-1) { nextA = A_; nextB = &B_[(j+1)*kc*NR]; if (j==np-1) { nextB = B_; } } if (mr==MR && nr==NR) { ugemm(kc, alpha, &A_[i*kc*MR], &B_[j*kc*NR], beta, &C[i*MR*incRowC+j*NR*incColC], incRowC, incColC, nextA, nextB); } else { // Call the buffered micro kernel ugemm(mr, nr, kc, alpha, &A_[i*kc*MR], &B_[j*kc*NR], beta, &C[i*MR*incRowC+j*NR*incColC], incRowC, incColC, nextA, nextB); } } } } } // namespace ulmBLAS #endif // ULMBLAS_LEVEL3_MKERNEL_MGEMM_TCC
; A170014: Number of reduced words of length n in Coxeter group on 5 generators S_i with relations (S_i)^2 = (S_i S_j)^36 = I. ; 1,5,20,80,320,1280,5120,20480,81920,327680,1310720,5242880,20971520,83886080,335544320,1342177280,5368709120,21474836480,85899345920,343597383680,1374389534720,5497558138880,21990232555520,87960930222080 mov $1,4 pow $1,$0 mul $1,5 div $1,4
; A332993: a(1) = 1, for n > 1, a(n) = n + a(A032742(n)). ; 1,3,4,7,6,10,8,15,13,16,12,22,14,22,21,31,18,31,20,36,29,34,24,46,31,40,40,50,30,51,32,63,45,52,43,67,38,58,53,76,42,71,44,78,66,70,48,94,57,81,69,92,54,94,67,106,77,88,60,111,62,94,92,127,79,111,68,120,93,113,72,139,74,112,106,134,89,131,80,156,121,124,84,155,103,130,117,166,90,156,105,162,125,142,115,190,98,155,144,181 mov $1,$0 lpb $1 seq $1,32742 ; a(1) = 1; for n > 1, a(n) = largest proper divisor of n. add $0,$1 sub $1,1 lpe add $0,1
; Assembly for testcls-bytecode.bas ; compiled with mcbasic ; Equates for MC-10 MICROCOLOR BASIC 1.0 ; ; Direct page equates DP_LNUM .equ $E2 ; current line in BASIC DP_TABW .equ $E4 ; current tab width on console DP_LPOS .equ $E6 ; current line position on console DP_LWID .equ $E7 ; current line width of console ; ; Memory equates M_KBUF .equ $4231 ; keystrobe buffer (8 bytes) M_PMSK .equ $423C ; pixel mask for SET, RESET and POINT M_IKEY .equ $427F ; key code for INKEY$ M_CRSR .equ $4280 ; cursor location M_LBUF .equ $42B2 ; line input buffer (130 chars) M_MSTR .equ $4334 ; buffer for small string moves M_CODE .equ $4346 ; start of program space ; ; ROM equates R_BKMSG .equ $E1C1 ; 'BREAK' string location R_ERROR .equ $E238 ; generate error and restore direct mode R_BREAK .equ $E266 ; generate break and restore direct mode R_RESET .equ $E3EE ; setup stack and disable CONT R_SPACE .equ $E7B9 ; emit " " to console R_QUEST .equ $E7BC ; emit "?" to console R_REDO .equ $E7C1 ; emit "?REDO" to console R_EXTRA .equ $E8AB ; emit "?EXTRA IGNORED" to console R_DMODE .equ $F7AA ; display OK prompt and restore direct mode R_KPOLL .equ $F879 ; if key is down, do KEYIN, else set Z CCR flag R_KEYIN .equ $F883 ; poll key for key-down transition set Z otherwise R_PUTC .equ $F9C9 ; write ACCA to console R_MKTAB .equ $FA7B ; setup tabs for console R_GETLN .equ $FAA4 ; get line, returning with X pointing to M_BUF-1 R_SETPX .equ $FB44 ; write pixel character to X R_CLRPX .equ $FB59 ; clear pixel character in X R_MSKPX .equ $FB7C ; get pixel screen location X and mask in R_PMSK R_CLSN .equ $FBC4 ; clear screen with color code in ACCB R_CLS .equ $FBD4 ; clear screen with space character R_SOUND .equ $FFAB ; play sound with pitch in ACCA and duration in ACCB R_MCXID .equ $FFDA ; ID location for MCX BASIC ; direct page registers .org $80 strtcnt .block 1 strbuf .block 2 strend .block 2 strfree .block 2 strstop .block 2 dataptr .block 2 inptptr .block 2 redoptr .block 2 letptr .block 2 .org $a3 r1 .block 5 rend rvseed .block 2 curinst .block 2 nxtinst .block 2 tmp1 .block 2 tmp2 .block 2 tmp3 .block 2 tmp4 .block 2 tmp5 .block 2 argv .block 10 .org M_CODE .module mdmain ldx #program stx nxtinst mainloop ldx nxtinst stx curinst ldab ,x ldx #catalog abx abx ldx ,x jsr 0,x bra mainloop program .byte bytecode_progbegin .byte bytecode_clear LINE_5 ; CLS .byte bytecode_cls LLAST ; END .byte bytecode_progend ; Library Catalog bytecode_clear .equ 0 bytecode_cls .equ 1 bytecode_progbegin .equ 2 bytecode_progend .equ 3 catalog .word clear .word cls .word progbegin .word progend .module mdbcode noargs ldx curinst inx stx nxtinst rts extend ldx curinst inx ldab ,x inx stx nxtinst ldx #symtbl abx abx ldx ,x rts getaddr ldd curinst addd #3 std nxtinst ldx curinst ldx 1,x rts getbyte ldx curinst inx ldab ,x inx stx nxtinst rts getword ldx curinst inx ldd ,x inx inx stx nxtinst rts extbyte ldd curinst addd #3 std nxtinst ldx curinst ldab 2,x pshb ldab 1,x ldx #symtbl abx abx ldx ,x pulb rts extword ldd curinst addd #4 std nxtinst ldx curinst ldd 2,x pshb ldab 1,x ldx #symtbl abx abx ldx ,x pulb rts byteext ldd curinst addd #3 std nxtinst ldx curinst ldab 1,x pshb ldab 2,x ldx #symtbl abx abx ldx ,x pulb rts wordext ldd curinst addd #4 std nxtinst ldx curinst ldd 1,x pshb ldab 3,x ldx #symtbl abx abx ldx ,x pulb rts immstr ldx curinst inx ldab ,x inx pshx abx stx nxtinst pulx rts .module mdprint print _loop ldaa ,x jsr R_PUTC inx decb bne _loop rts clear ; numCalls = 1 .module modclear jsr noargs clra ldx #bss bra _start _again staa ,x inx _start cpx #bes bne _again stx strbuf stx strend inx inx stx strfree ldx #$8FFF stx strstop ldx #startdata stx dataptr rts cls ; numCalls = 1 .module modcls jsr noargs jmp R_CLS progbegin ; numCalls = 1 .module modprogbegin jsr noargs ldx R_MCXID cpx #'h'*256+'C' bne _mcbasic pulx clrb pshb pshb pshb stab strtcnt jmp ,x _reqmsg .text "?MICROCOLOR BASIC ROM REQUIRED" _mcbasic ldx #_reqmsg ldab #30 jsr print pulx rts progend ; numCalls = 1 .module modprogend jsr noargs pulx pula pula pula jsr R_RESET jmp R_DMODE NF_ERROR .equ 0 RG_ERROR .equ 4 OD_ERROR .equ 6 FC_ERROR .equ 8 OV_ERROR .equ 10 OM_ERROR .equ 12 BS_ERROR .equ 16 DD_ERROR .equ 18 LS_ERROR .equ 28 error jmp R_ERROR ; data table startdata enddata ; Bytecode symbol lookup table symtbl ; block started by symbol bss ; Numeric Variables ; String Variables ; Numeric Arrays ; String Arrays ; block ended by symbol bes .end
; A216256: Minimum length of a longest unimodal subsequence of a permutation of n elements. ; 1,2,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17 mul $0,3 lpb $0 add $1,2 sub $0,$1 lpe div $1,2 add $1,1 mov $0,$1
COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: VGA16 Video Driver FILE: vga16Admin.asm AUTHOR: Jim DeFrisco ROUTINES: Name Description ---- ----------- VidScreenOn turn on video VidScreenOff turn off video REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/92 initial version FR 09/97 update for 16 bit devices DESCRIPTION: This file contains routines to implement some of the administrative parts of the driver. $Id: vga16Admin.asm,v 1.2 96/08/05 03:51:55 canavese Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} VidSegment Misc COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidScreenOff %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Disable video output, for a screen saver CALLED BY: GLOBAL PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Disable the video output KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 12/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidScreenOff proc far .enter ; first see if the screen is already blank dec ss:videoEnabled ; is it enabled js tooFar ; oops, called it to often jne done ; someone still wants it off ; now do the disable thing. mov ah, ALT_SELECT ; choose BIOS function number mov bl, VIDEO_SCREEN_ON_OFF ; choose sub-function number mov al, VGA_DISABLE_VIDEO ; disable it this time int VIDEO_BIOS done: .leave ret ; decremented too far, get back to zero tooFar: mov ss:videoEnabled, 0 jmp done VidScreenOff endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidScreenOn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Enable video output, for a screen saver CALLED BY: GLOBAL PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Disable the video output KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 12/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidScreenOn proc far .enter ; first see if the screen is already enabled inc ss:videoEnabled ; check for turn on cmp ss:videoEnabled, 1 ; is it enabled jg done ; yes, don't do it again mov ss:videoEnabled, 1 ; no, make sure it;s one ; enable video signal on card mov ah, ALT_SELECT ; choose BIOS function number mov bl, VIDEO_SCREEN_ON_OFF ; choose sub-function number mov al, VGA_ENABLE_VIDEO ; disable video signal int VIDEO_BIOS done: .leave ret VidScreenOn endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidTestVGA24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Test for 640x480 24bit VESA mode CALLED BY: INTERNAL VidTestDevice PASS: nothing RETURN: ax - DevicePresent enum DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidTestVGA24 proc near mov ax, VM_640x480_24 ; mode to check for call VidTestVESA ret VidTestVGA24 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidTestSVGA24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Test for 800x600 24bit VESA mode CALLED BY: INTERNAL VidTestDevice PASS: nothing RETURN: ax - DevicePresent enum DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidTestSVGA24 proc near mov ax, VM_800x600_24 ; mode to check for call VidTestVESA ret VidTestSVGA24 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidTestUVGA24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Test for 1024x768 24bit VESA mode CALLED BY: INTERNAL VidTestDevice PASS: nothing RETURN: ax - DevicePresent enum DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidTestUVGA24 proc near mov ax, VM_1Kx768_24 ; mode to check for call VidTestVESA ret VidTestUVGA24 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidTestHVGA24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Test for 1280x1024 24bit VESA mode CALLED BY: INTERNAL VidTestDevice PASS: nothing RETURN: ax - DevicePresent enum DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidTestHVGA24 proc near mov ax, VM_1280x1K_24 ; mode to check for call VidTestVESA ret VidTestHVGA24 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidTestVESA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Test for VESA compatible board CALLED BY: INTERNAL VidTestDevice PASS: ax - VESA mode to check for RETURN: ax - DevicePresent enum DESTROYED: nothing PSEUDO CODE/STRATEGY: call VESA inquiry functins KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 09/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidTestVESA proc near uses di, bx, cx .enter push es ; save away the mode number mov ss:[vesaMode], ax ; save it ; allocate fixed block to get vesa info CheckHack <(size VESAInfoBlock) eq (size VESAModeInfo)> mov ax, size VESAInfoBlock mov cx, ALLOC_FIXED call MemAlloc ; use extended BIOS function 0x4f - 0 to determine if this ; is a VESA compatible board, then check the table of ; supported modes to determine if the 640x480x256-color mode ; is supported. mov es, ax clr di ; es:di -> VESAInfoBlock mov ah, VESA_BIOS_EXT ; use VESA bios extensions mov al, VESA_GET_SVGA_INFO ; basic info call int VIDEO_BIOS ; make bios call ; if al = VESA_BIOS_EXT, then there is a VESA compatible board ; there...actually, we need to check for the VESA signature too cmp ax, VESA_BIOS_EXT ; is this a VESA board ? jne notPresent ; no, exit cmp {word} es:[di].VIB_sig, 'VE' ; gimme a VE jne notPresent cmp {word} es:[di].VIB_sig[2], 'SA' ; gimme a SA jne notPresent ; OK, there is a VESA board out there. Check the mode table ; for the correct mode. les di, es:[di].VIB_modes ; get pointer to mode info mov ax, ss:[vesaMode] ; mode to check for checkLoop: cmp es:[di], 0xffff ; at mode table terminator? je notPresent scasw ; check this word jne checkLoop ; nope, on to next mode ; OK, the mode is supported in the BIOS. Now check to see if ; it is supported by the current card/monitor setup. To do ; this, we need to call the GetModeInfo function. call MemDerefES clr di ; es:di -> VESAModeInfo mov cx, ax ; cx = mode number mov ah, VESA_BIOS_EXT ; BIOS mode number mov al, VESA_GET_MODE_INFO ; get info about mode int VIDEO_BIOS ; get mode info ; now see if the current hardware is cool. test es:[di].VMI_modeAttr, mask VMA_SUPPORTED jz notPresent ; passed the acid test. Use it. mov ax, DP_PRESENT ; yep, it's there done: ; free allocated memory block pop es call MemFree .leave ret notPresent: mov ax, DP_NOT_PRESENT ; jmp done VidTestVESA endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidSetVESA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set VESA 64K-color modes CALLED BY: INTERNAL VidSetDevice PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: call VESA set mode function KNOWN BUGS/SIDE EFFECTS/IDEAS: assumes that VidTestVESA has been called and passed. REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 09/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidSetVESA proc near uses ax,bx,cx,dx,ds,si,es .enter ; just use the BIOS extension mov ah, VESA_BIOS_EXT mov al, VESA_SET_MODE mov bx, ss:[vesaMode] ; mode number, clear memory int VIDEO_BIOS segmov es, ss, di ; es -> dgroup lea di, ss:[vesaInfo] ; es:di -> info block mov ah, VESA_BIOS_EXT ; use VESA bios extensions mov al, VESA_GET_SVGA_INFO ; basic info call int VIDEO_BIOS ; make bios call lea di, ss:[modeInfo] ; es:di -> info block mov ah, VESA_BIOS_EXT ; use VESA bios extensions mov al, VESA_GET_MODE_INFO ; get info about mode mov cx, bx ; cx = mode number int VIDEO_BIOS ; make bios call ; since we may be using this driver to support a number of ; other resolutions at 8bits/pixel, copy the information ; that we gleaned from the mode info call and stuff the ; appropriate fields into our own DeviceInfo structure. sub bx, 0x110 ; get number start at 0 mov al, cs:[vesaDtype][bx] mov ss:[DriverTable].VDI_displayType, al shl bx, 1 ; bx = word table index mov ax, cs:[vesaHeight][bx] mov ss:[DriverTable].VDI_pageH, ax mov ax, cs:[vesaWidth][bx] mov ss:[DriverTable].VDI_pageW, ax mov ax, cs:[vesaVres][bx] mov ss:[DriverTable].VDI_vRes, ax mov ax, cs:[vesaHres][bx] mov ss:[DriverTable].VDI_hRes, ax mov ax, ss:[modeInfo].VMI_scanSize ; bytes per scan line mov ss:[DriverTable].VDI_bpScan, ax ; initialize some things about the memory windows. ; first determine the window that we write to mov al, ss:[modeInfo].VMI_winAAttr mov ah, ss:[modeInfo].VMI_winBAttr test ah, mask VWA_SUPPORTED or mask VWA_WRITEABLE jz winAWrite jnp winAWrite ; if two not set... mov bl, VW_WINDOW_B ; bl = write window mov cx, ss:[modeInfo].VMI_winBSeg ; cx = write win addr tryWinARead: test al, mask VWA_SUPPORTED or mask VWA_READABLE jz winBRead jnp winBRead mov bh, VW_WINDOW_A mov dx, ss:[modeInfo].VMI_winASeg storeRWWin: mov {word} ss:[writeWindow], bx ; save results mov ss:[writeSegment], cx mov ss:[readSegment], dx ; calculate the last offset in the window mov bx, ss:[modeInfo].VMI_winSize mov ax, bx xchg al, ah ; *256 shl ax, 1 ; *512 shl ax, 1 ; *1024 dec ax ; last offset mov ss:[curWinEnd], ax ; last offset in 64K ; calculate the window bump when going to the next window. ; It's the size divided by the granularity mov ax, bx ; ax = winSize mov bx, ss:[modeInfo].VMI_winGran ; bx = granularity div bl ; al = #to bump mov ss:[nextWinInc], ax ; set increment mov bl,ss:[modeInfo.VMI_bitsPerPixel] xor bh, bh adc bx, 7 shr bx, 1 shr bx, 1 shr bx, 1 mov ss:[pixelBytes], bx sub bx, 3 mov ss:[pixelRestBytes], bx .leave ret ; window B doesn't exist or is not writeable. Use window A ; and try window B for reading. winAWrite: mov bl, VW_WINDOW_A mov cx, ss:[modeInfo].VMI_winASeg test ah, mask VWA_SUPPORTED or mask VWA_READABLE jz tryWinARead jnp tryWinARead winBRead: mov bh, VW_WINDOW_B mov dx, ss:[modeInfo].VMI_winBSeg jmp storeRWWin VidSetVESA endp vesaDtype label DisplayType byte VGA24_DISPLAY_TYPE byte VGA24_DISPLAY_TYPE byte VGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE byte SVGA24_DISPLAY_TYPE vesaHeight label word word 480, 480, 480, 600, 600, 600, 768, 768, 768, 1024, 1024, 1024 vesaWidth label word word 640, 640, 640, 800, 800, 800, 1024, 1024, 1024, 1280, 1280, 1280 vesaVres label word word 72, 72, 72, 80, 80, 80, 102, 102, 102, 136, 136, 136 vesaHres label word word 72, 72, 72, 80, 80, 80, 102, 102, 102, 136, 136, 136 VidEnds Misc
include 'emu8086.inc' print 'Enter the Fcuking Number: ' mov bh,10 mov ah,1 int 21h mov bl,al mov ah,1 int 21h mov cl,al sub bl,48 sub cl,48 printn "" cmp cl,5 JL yes_less cmp cl,5 JE yes_equal cmp cl,5 JG yes_greater yes_less: sub bh,5 add bh,cl sub bl,1 add bl,48 add bh,48 print "Brother: " mov ah,2 mov dl,bl int 21h printn "" print "Sister: " mov ah,2 mov dl,bh int 21h jmp end yes_equal: mov bh,0 add bl,48 add bh,48 print "Brother: " mov ah,2 mov dl,bl int 21h printn "" print "Sister: " mov ah,2 mov dl,bh int 21h jmp end yes_greater: mov bh,cl sub bh,5 add bl,48 add bh,48 print "Brother: " mov ah,2 mov dl,bl int 21h printn "" print "Sister: " mov ah,2 mov dl,bh int 21h jmp end end: ret
; =============================================================== ; Apr 2014 ; =============================================================== ; ; void rewind(FILE *stream) ; ; Clear any stream error and execute fseek(stream, 0L, SEEK_SET) ; =============================================================== INCLUDE "clib_cfg.asm" SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC asm_rewind EXTERN asm0_rewind_unlocked, __stdio_lock_release asm_rewind: ; enter : ix = FILE * ; ; exit : ix = FILE * ; ; success ; ; hl = 0 ; carry reset ; ; fail ; ; hl = -1 ; carry set, errno set ; ; uses : all except ix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_STDIO & $01 EXTERN __stdio_verify_valid_lock call __stdio_verify_valid_lock ret c ELSE EXTERN __stdio_lock_acquire, error_enolck_mc call __stdio_lock_acquire jp c, error_enolck_mc ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; call asm0_rewind_unlocked jp __stdio_lock_release ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC asm_rewind EXTERN asm_rewind_unlocked defc asm_rewind = asm_rewind_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: Video Drivers FILE: vga16Output.asm AUTHOR: Jim DeFrisco, Oct 7, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/ 7/92 Initial revision FR 9/ 4/97 16bit created DESCRIPTION: Low-level rectangle drawing routines for 16-bit devices $Id: vga16Output.asm,v 1.2 96/08/05 03:51:43 canavese Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawOptRect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a rectangle with draw mode GR_COPY and all bits in the draw mask set CALLED BY: INTERNAL DrawSimpleRect PASS: dx - number of bytes covered by rectangle - 1 cx - pattern index (scan line number AND 7) es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw RETURN: nothing DESTROYED: ax,bx,cx,dx,si,di,bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawOptRect proc near ; check the dither flag and do the right thing test cs:[driverState], mask VS_DITHER LONG jnz BlastDitheredRect ; drawing a solid rectangle. See if it's just one pixel wide, ; and use the quick one... NMEM < mov si, cs:[modeInfo].VMI_scanSize ; optimization > mov ax, cs:[currentColor] ; get current color index tst dx jz oneByteWide ; calculate #bytes in the middle of the line and ; offset to next line inc dx ; total #bytes in line NMEM < cmp di, cs:[lastWinPtr] ; is it in the last line > NMEM < jae firstPartial ; check for complete line > lineLoop: mov cx, dx ; setup count rep stosw ; fill in scan line sub di, dx ; restore line pointer sub di, dx ; 2 byte pixel dec bp ; fewer scans to do jz done NMEM < NextScan di, si ; adj ptr to next scan line > MEM < NextScan di ; adj ptr to next scan line > NMEM < jc lastWinLine ; oops, on last line in win > NMEM < jmp lineLoop > MEM < tst cs:[bm_scansNext] ; if negative, bogus > MEM < jns lineLoop > done: ret ifndef IS_MEM ; first line is already an partial scan firstPartial: clc call SetNextWin ; the current line is no totally in the window, so take it slow lastWinLine: cmp dx, cs:[pixelsLeft] ; if doing less, do normal jb lineLoop mov cx, cs:[pixelsLeft] ; #pixels left in window rep stosw call MidScanNextWin ; goto next window mov cx, dx ; setup remaining count sub cx, cs:[pixelsLeft] jcxz null1 rep stosw ; do remaining part of line null1: dec bp jz done FirstWinScan ; set di to start of next jmp lineLoop endif ; it's only a byte wide. Do it quickly. oneByteWide: mov cx, bp ; get line count in cd oneLoop: mov es:[di], ax ; store the color dec cx ; one less line to do jz done NMEM < NextScan di, si ; always enuf room todo 1 pix > MEM < NextScan di ; always enuf room todo 1 pix > MEM < tst cs:[bm_scansNext] ; > MEM < js done > jmp oneLoop DrawOptRect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BlastDitheredRect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a rectangle in MM_COPY, mask all 1s, dithered. CALLED BY: INTERNAL DrawOptRect PASS: dx - number of words covered by rectangle + 1 cx - pattern index (scan line number AND 7) es:di - buffer address for first left:top of rectangle bp - number of lines to draw RETURN: nothing DESTROYED: ax,bx,cx,dx,si,di,bp PSEUDO CODE/STRATEGY: We have a 4x4 ditherMatrix, so align stuff and copy the four bytes across in the right order. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BlastDitheredRect proc near ; setup some stuff. Get index to point at beginning of ; ditherMatrix scan line (each 4 bytes), get scan size call SetTempDither ; setup tempDither matrix mov bx, cx ; line offset in bx shl bx, 1 ; *4 shl bx, 1 shl bx, 1 and bx, 0x018 ; pointer into tempDither NMEM < mov si, cs:[modeInfo].VMI_scanSize ; optimization > tst dx jz oneByteWide ; calculate #bytes in the middle of the line and ; offset to next line inc dx ; total #bytes in line NMEM < cmp di, cs:[lastWinPtr] ; is it in the last line > NMEM < jae firstPartial ; check for complete line > lineLoop: call BlastDitheredScan ; do a scan line dec bp ; fewer scans to do jz done add bl, 8 ; onto next scan and bl, 0x18 ; limit it to 16 bytes NMEM < NextScan di,si ; adjust ptr to next scan line> NMEM < jc lastWinLine ; oops, on last line in wind.> MEM < NextScan di ; adjust ptr to next scan line> MEM < tst cs:[bm_scansNext] ; > MEM < jns lineLoop > NMEM < jmp lineLoop > done: ret ifndef IS_MEM ; first line is already an partial scan firstPartial: clc call SetNextWin ; the current line is no totally in the window, so take it slow lastWinLine: cmp dx, cs:[pixelsLeft] ; if doing less, do normal jb lineLoop push dx mov dx, cs:[pixelsLeft] call BlastDitheredScan call MidScanNextWin ; goto next window pop dx push dx sub dx, cs:[pixelsLeft] tst dx jz null1 call BlastDitheredScan null1: pop dx dec bp jz done add bl, 8 ; onto next scan and bl, 0x18 ; limit it to 16 bytes FirstWinScan ; set di to start of next jmp lineLoop endif ; it's only a byte wide. Do it quickly. oneByteWide: mov ax, cs:[tempDither][bx] mov es:[di], ax ; store the color dec bp ; one less line to do jz done add bl, 8 and bl, 0x18 NMEM < NextScan di, si ; always enuf room todo 1 pix > MEM < NextScan di ; always enuf room todo 1 pix > MEM < tst cs:[bm_scansNext] ; > MEM < js done > jmp oneByteWide BlastDitheredRect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BlastDitheredScan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Do a single scan line of dither stuff CALLED BY: BlastDitheredRect PASS: bx - offset into tempDither of current scan line dx - #pixels to write es:di - points at starting pixel tempDither - already setup (entries rotated in X so that the first element in each scan is the Nth element in the ditherMatrix scan where N=(left side of rect) AND 7 RETURN: nothing DESTROYED: ax, cx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/21/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BlastDitheredScan proc near uses bp, si .enter mov ax, {word} cs:[tempDither][bx] mov cx, {word} cs:[tempDither][bx+2] mov bp, {word} cs:[tempDither][bx+4] mov si, {word} cs:[tempDither][bx+6] push dx jmp startLine pixLoop: stosw ; first byte mov es:[di], cx inc di inc di mov es:[di], bp inc di inc di mov es:[di], si inc di inc di startLine: sub dx, 4 jns pixLoop ; down to less than 4 pixels on the scan line, do one at a time add dx, 4 jz doneLine stosw dec dx jz doneLine mov es:[di], cx inc di inc di dec dx jz doneLine mov es:[di], bp inc di inc di doneLine: pop dx shl dx, 1 ; 1 pixel = 2 bytes sub di, dx ; restore line pointer shr dx, 1 .leave ret BlastDitheredScan endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetTempDither %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Optimization to setup a temporary dither matrix with the scan lines rotated in x to reflect which pixel we are starting on (enables more efficient drawing routines) CALLED BY: INTERNAL PASS: si - x offset (at least low two bits of it) RETURN: nothing DESTROYED: al, si PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/21/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetTempDither proc near test cs:[driverState], mask VS_DITHER jnz handleDither mov ax,cs:[currentColor] mov word ptr cs:[tempDither],ax mov word ptr cs:[tempDither+2],ax mov word ptr cs:[tempDither+4],ax mov word ptr cs:[tempDither+6],ax mov word ptr cs:[tempDither+8],ax mov word ptr cs:[tempDither+10],ax mov word ptr cs:[tempDither+12],ax mov word ptr cs:[tempDither+14],ax mov word ptr cs:[tempDither+16],ax mov word ptr cs:[tempDither+18],ax mov word ptr cs:[tempDither+20],ax mov word ptr cs:[tempDither+22],ax mov word ptr cs:[tempDither+24],ax mov word ptr cs:[tempDither+26],ax mov word ptr cs:[tempDither+28],ax mov word ptr cs:[tempDither+30],ax done: retn handleDither: push si and si,3 mov ax, si shl ax, 1 mov si, ax mov ax,word ptr cs:[ditherMatrix] mov word ptr cs:[tempDither][si],ax mov ax,word ptr cs:[ditherMatrix+8] mov word ptr cs:[tempDither+8][si],ax mov ax,word ptr cs:[ditherMatrix+16] mov word ptr cs:[tempDither+16][si],ax mov ax,word ptr cs:[ditherMatrix+24] mov word ptr cs:[tempDither+24][si],ax mov si, cs:ditherRotTab[si] mov ax,word ptr cs:[ditherMatrix+2] mov word ptr cs:[tempDither][si],ax mov ax,word ptr cs:[ditherMatrix+10] mov word ptr cs:[tempDither+8][si],ax mov ax,word ptr cs:[ditherMatrix+18] mov word ptr cs:[tempDither+16][si],ax mov ax,word ptr cs:[ditherMatrix+26] mov word ptr cs:[tempDither+24][si],ax mov si, cs:ditherRotTab[si] mov ax,word ptr cs:[ditherMatrix+4] mov word ptr cs:[tempDither][si],ax mov ax,word ptr cs:[ditherMatrix+12] mov word ptr cs:[tempDither+8][si],ax mov ax,word ptr cs:[ditherMatrix+20] mov word ptr cs:[tempDither+16][si],ax mov ax,word ptr cs:[ditherMatrix+28] mov word ptr cs:[tempDither+24][si],ax mov si, cs:ditherRotTab[si] mov ax,word ptr cs:[ditherMatrix+6] mov word ptr cs:[tempDither][si],ax mov ax,word ptr cs:[ditherMatrix+14] mov word ptr cs:[tempDither+8][si],ax mov ax,word ptr cs:[ditherMatrix+22] mov word ptr cs:[tempDither+16][si],ax mov ax,word ptr cs:[ditherMatrix+30] mov word ptr cs:[tempDither+24][si],ax pop si jmp done ditherRotTab dw 2,4,6,0,2,4 SetTempDither endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawNOTRect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a rectangle with draw mode MM_INVERT and all bits in the draw mask set CALLED BY: INTERNAL DrawSimpleRect PASS: dx - number of byte covered by rectangle - 1 es:di - buffer address for first left:top of rectangle bp - number of lines to draw RETURN: nothing DESTROYED: ax, bx, cx, dx, si, di, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawNOTRect proc near push ds NMEM < mov ds, cs:[readSegment] > MEM < segmov ds, es > ; see if we can do it in one byte NMEM < mov si, cs:[modeInfo].VMI_scanSize ; optimization > clr bh tst dx jz oneByteWide ; calculate #bytes to write inc dx ; number of bytes to draw NMEM < cmp di, cs:[lastWinPtr] ; is it in the last line > NMEM < jae firstPartial ; check for complete line > lineLoop: mov cx, dx ; setup count notLoop: mov bx, ds:[di] xor bx, 07FFFh mov es:[di], bx inc di inc di ; 2 byte pixel loop notLoop ; to loop or not to loop... sub di, dx ; restore scan pointer sub di, dx ; 1 pixel = 2 bytes dec bp ; fewer scans to do jz done NMEM < NextScanBoth di,si ; adjust ptr to next scan line> NMEM < jc lastWinLine > MEM < NextScanBoth di ; adjust ptr to next scan line> MEM < segmov ds, es ; make sure they match > MEM < tst cs:[bm_scansNext] ; > MEM < js done > jmp lineLoop done: pop ds ret ; it's only a byte wide. Do it quickly. oneByteWide: mov cx, bp ; get line count in cd oneLoop: mov bx, ds:[di] xor bx, 07FFFh mov es:[di], bx dec cx ; one less line to do jz done NMEM < NextScanBoth di,si > MEM < NextScan di > MEM < segmov ds, es ; make sure they match > MEM < tst cs:[bm_scansNext] ; > MEM < js done > jmp oneLoop ifndef IS_MEM ; first line is already an partial scan firstPartial: clc call SetNextWinSrc clc call SetNextWin ; the current line is no totally in the window, so take it slow lastWinLine: cmp dx, cs:[pixelsLeft] ; if doing less, do normal jb lineLoop mov cx, cs:[pixelsLeft] ; #pixels left in window pixLoop1: mov bx, ds:[di] xor bx, 07FFFh mov es:[di], bx inc di inc di loop pixLoop1 call MidScanNextWinSrc ; goto next window call MidScanNextWin ; goto next window mov cx, dx ; setup remaining count sub cx, cs:[pixelsLeft] jcxz null1 pixLoop2: mov bx, ds:[di] xor bx, 07FFFh mov es:[di], bx inc di inc di loop pixLoop2 null1: dec bp jz done FirstWinScan ; set di to start of next jmp lineLoop endif DrawNOTRect endp ForceRef DrawNOTRect COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawSpecialRect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a rectangle with a special draw mask or draw mode clipping left and right CALLED BY: INTERNAL DrawSimpleRect PASS: dx - number of words covered by rectangle - 1 cx - pattern index es:di - buffer address for first left:top of rectangle bp - number of lines to draw si - low three bits of x position RETURN: nothing DESTROYED: ax, bx, cx, dx, si, di, bp PSEUDO CODE/STRATEGY: REGISTER USAGE: es:di - points into frame buffer si - offset into 8-byte mask buffer al - color bh - one bit set to test mask buffer bl - starting value for bh KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawSpecialRect proc near push ds NMEM < mov ds, cs:[readSegment] > MEM < segmov ds, es > ; check the dither flag and do the right thing test cs:[driverState], mask VS_DITHER LONG jnz SpecialDitheredRect ; setup ah to hold a bit flag to use in testing the mask mov bl, 80h ; bit zero xchg cx, si ; cx = low three bits of x pos and cl, 7 shr bl, cl ; ah = single bit tester mov cx, si ; restore mask buffer index ; check for one byte wide tst dx jz oneByteWide ; calculate #bytes in the line, offset to next line inc dx ; number of bytes ; mov si, cx ; mask index in si NMEM < cmp di, cs:[lastWinPtr] ; is it in the last line > NMEM < LONG jae firstPartial ; check for complete line > lineLoop: push di ; save pointer mov cx, dx ; setup count mov bh, bl ; reload tester pixelLoop: test cs:[maskBuffer][si], bh ; skip this pixel ? jz pixelDone mov ax, ds:[di] ; get screen pixel call cs:[modeRoutine] ; apply mix mode mov es:[di], ax ; store result pixelDone: inc di inc di shr bh, 1 ; testing next pixel jc reloadTester haveTester: loop pixelLoop pop di ; restore scan pointer dec bp ; fewer scans to do jz done inc si ; next scan line and si, 0x7 NMEM < NextScanBoth di ; adjust ptr to next scan line> NMEM < jc lastWinLine > MEM < NextScanBoth di > MEM < segmov ds, es ; update source reg > MEM < tst cs:[bm_scansNext] ; > MEM < jns lineLoop > NMEM < jmp lineLoop > done: pop ds ret reloadTester: mov bh, 80h jmp haveTester oneByteWide: mov si, cx ; mask index in si mov bh, bl ; reload tester oneByteLoop: test cs:[maskBuffer][si], bh ; skip this pixel ? jz lineDone mov ax, ds:[di] ; get screen pixel call cs:[modeRoutine] ; apply mix mode mov es:[di], ax ; store result lineDone: dec bp ; fewer scans to do jz done inc si ; next scan line and si, 0x7 NMEM < NextScanBoth di ; adjust ptr to next scan line> MEM < NextScanBoth di ; adjust ptr to next scan line> MEM < segmov ds, es ; reload source reg > MEM < tst cs:[bm_scansNext] ; > MEM < js done > jmp oneByteLoop ifndef IS_MEM ; first line is already an partial scan firstPartial: clc call SetNextWin clc call SetNextWinSrc ; the current line is no totally in the window, so take it slow lastWinLine: cmp dx, cs:[pixelsLeft] ; if doing less, do normal LONG jb lineLoop mov bh, bl mov cx, cs:[pixelsLeft] ; #pixels left in window pixLoop1: test cs:[maskBuffer][si], bh ; skip this pixel ? jz pixDone1 mov ax, ds:[di] ; get screen pixel call cs:[modeRoutine] ; apply mix mode mov es:[di], ax ; store result pixDone1: inc di inc di shr bh, 1 ; testing next pixel jnc nextPix1 mov bh, 80h nextPix1: loop pixLoop1 call MidScanNextWinSrc ; goto next window call MidScanNextWin ; goto next window mov cx, dx ; setup remaining count sub cx, cs:[pixelsLeft] jcxz null1 pixLoop2: test cs:[maskBuffer][si], bh ; skip this pixel ? jz pixDone2 mov ax, ds:[di] ; get screen pixel call cs:[modeRoutine] ; apply mix mode mov es:[di], ax ; store result pixDone2: inc di inc di shr bh, 1 ; testing next pixel jnc nextPix2 mov bh, 80h nextPix2: loop pixLoop2 null1: dec bp LONG jz done FirstWinScan ; set di to start of next inc si ; next scan line and si, 0x7 jmp lineLoop endif DrawSpecialRect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpecialDitheredRect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a dithered rectangle, some random mix mode, w/draw mask CALLED BY: INTERNAL DrawSpecialRect PASS: dx - number of words covered by rectangle - 1 cx - pattern index es:di - buffer address for first left:top of rectangle bp - number of lines to draw si - low three bits of x position RETURN: nothing DESTROYED: ax, bx, cx, dx, si, di, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpecialDitheredRect proc near ; setup some stuff. Get index to point at beginning of ; ditherMatrix scan line (each 4 bytes), get scan size push si call SetTempDither ; setup tempDither matrix pop si mov bx, cx ; line offset in bx xchg si, cx ; in si too. xoffset in cx shl bx, 1 ; *8 shl bx, 1 shl bx, 1 and bx, 0x018 ; pointer into tempDither and cx, 0x7 ; need low three bits tst dx jz oneByteWide ; calculate #bytes in the middle of the line and ; offset to next line inc dx ; total #bytes in line NMEM < cmp di, cs:[lastWinPtr] ; is it in the last line > NMEM < jae firstPartial ; check for complete line > lineLoop: call BlastDitheredMaskedScan ; do a scan line dec bp ; fewer scans to do jz done add bl, 8 ; onto next scan and bl, 0x18 ; limit it to 16 bytes inc si ; next mask scan and si, 7 NMEM < NextScanBoth di ; adjust ptr to next scan > NMEM < jc lastWinLine ; oops, on last line in wind.> MEM < NextScanBoth di ; adjust ptr to next scan > MEM < segmov ds, es ; make sure they match > MEM < tst cs:[bm_scansNext] ; > MEM < jns lineLoop > NMEM < jmp lineLoop > done: pop ds ; pushed in DrawSpecialRect ret ; it's only a byte wide. Do it quickly. oneByteWide: mov ch, 080h shr ch, cl mov ax, cs:[tempDither][bx] call WriteSpecialPixel dec di dec di dec bp ; one less line to do jz done add bl, 8 and bl, 0x18 inc si and si, 7 NMEM < NextScanBoth di ; always enuf room todo 1 pix > MEM < NextScan di ; always enuf room todo 1 pix > MEM < segmov ds, es ; make sure they match > MEM < tst cs:[bm_scansNext] ; > MEM < js done > jmp oneByteWide ifndef IS_MEM ; first line is already an partial scan firstPartial: clc call SetNextWinSrc clc call SetNextWin ; the current line is no totally in the window, so take it slow lastWinLine: cmp dx, cs:[pixelsLeft] ; if doing less, do normal jb lineLoop push cx push dx mov dx, cs:[pixelsLeft] call BlastDitheredMaskedScan call MidScanNextWinSrc ; goto next window call MidScanNextWin ; goto next window pop dx push dx sub dx, cs:[pixelsLeft] add cx,cs:[pixelsLeft] and cx,0007h tst dx jz null1 call BlastDitheredMaskedScan null1: pop dx pop cx dec bp jz done add bl, 8 ; onto next scan and bl, 0x18 ; limit it to 16 bytes inc si and si, 7 ; limit to size of mask buffer FirstWinScan ; set di to start of next jmp lineLoop endif SpecialDitheredRect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BlastDitheredMaskedScan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a scan line, dithered, with a draw mask CALLED BY: INTERNAL SpecialDitheredRect PASS: bx - offset into tempDither of current scan line dx - #pixels to write cl - low three bits of left side x position es:di - points at starting pixel tempDither - already setup (entries rotated in X so that the first element in each scan is the Nth element in the ditherMatrix scan where N=(left side of rect) AND 7 RETURN: DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BlastDitheredMaskedScan proc near uses bx, cx, bp, si .enter ; setup ch to hold a bit flag to use in testing the mask mov ch, 80h ; bit zero shr ch, cl ; ah = single bit tester mov cl, al ; al gets trashed all the time push dx jmp startLine pixLoop: mov ax, {word} cs:[tempDither][bx] call WriteSpecialPixel mov ax, {word} cs:[tempDither][bx+2] call WriteSpecialPixel mov ax, {word} cs:[tempDither][bx+4] call WriteSpecialPixel mov ax, {word} cs:[tempDither][bx+6] call WriteSpecialPixel startLine: sub dx, 4 jns pixLoop ; down to less than 4 pixels on the scan line, do one at a time add dx, 4 jz doneLine mov ax, {word} cs:[tempDither][bx] call WriteSpecialPixel dec dx jz doneLine mov ax, {word} cs:[tempDither+2][bx] call WriteSpecialPixel dec dx jz doneLine mov ax, {word} cs:[tempDither+4][bx] call WriteSpecialPixel doneLine: pop dx sub di, dx ; restore line pointer sub di, dx .leave ret BlastDitheredMaskedScan endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% WriteSpecialPixel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lots of stuff to do, mask, dither, mix a pixel CALLED BY: BlastDitheredMaskedScan PASS: ch - current mask bit ah - color to use es:di - frame buffer pointer si - mask buffer index RETURN: ch - advanced to next pixel di - points at next pixel DESTROYED: al PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ WriteSpecialPixel proc near test ch, cs:[maskBuffer][si] jz donePix push cs:[currentColor] mov cs:[currentColor], ax mov ax, ds:[di] call cs:[modeRoutine] mov es:[di], ax mov ax, cs:[currentColor] pop cs:[currentColor] donePix: inc di inc di shr ch, 1 jc reloadMask ret reloadMask: mov ch, 0x80 ret WriteSpecialPixel endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MixModeRoutines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Various stub routines to implement mix modes CALLED BY: INTERNAL various low-level drawing routines PASS: ah - color al - screen RETURN: al - destination (byte to write out) DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ModeRoutines proc near ForceRef ModeRoutines ModeCLEAR label near clr ax ModeNOP label near ret ModeCOPY label near mov ax, cs:[currentColor] ret ModeAND label near and ax, cs:[currentColor] ret ModeINVERT label near xor ax, 07FFFh ret ModeXOR label near xor ax, cs:[currentColor] ret ModeSET label near mov ax, 0x7FFF ret ModeOR label near or ax, cs:[currentColor] ret ModeRoutines endp
// Generated by Haxe 4.1.4 #include <hxcpp.h> #include <stdio.h> extern "C" void __hxcpp_main(); extern "C" void __hxcpp_lib_main(); #ifndef INCLUDED_verb_Verb #include <verb/Verb.h> #endif HX_LOCAL_STACK_FRAME(_hx_pos_fe66fde75063e1fc_1___hxcpp_main,"hxcpp","__hxcpp_main",0x10478780,"hxcpp.__hxcpp_main","?",1,0x0000003f) #include <hx/HxcppMain.h> void __hxcpp_main() { { HX_STACKFRAME(&_hx_pos_fe66fde75063e1fc_1___hxcpp_main) HXDLIN( 1) ::verb::Verb_obj::main(); } } void __hxcpp_lib_main() { HX_TOP_OF_STACK ::hx::Boot(); __boot_all(); __hxcpp_main(); }
%include "macros.inc" global _wav_write global _wav_parse segment .text align=16 _wav_write: mov edx, [rsi + 36] cmp edx, 1 je .nbytes2 mov eax, -1 cmp edx, 3 jne .return mov eax, 4 jmp .continue .nbytes2: mov eax, 2 .continue: mov dword [rdi], 0x46464952 mov r8d, [rsi + 8] lea ecx, [r8 + 36] mov [rdi + 4], ecx mov rcx, 0x20746D6645564157 mov [rdi + 8], rcx mov dword [rdi + 16], 16 mov [rdi + 20], dx mov ecx, [rsi + 32] mov [rdi + 22], cx movsd xmm0, [rsi + 16] cvttsd2si rdx, xmm0 mov [rdi + 24], edx cvtsi2sd xmm1, eax cvtsi2sd xmm2, rcx mulsd xmm1, xmm0 mulsd xmm1, xmm2 cvttsd2si rdx, xmm1 mov [rdi + 28], edx imul ecx, eax mov [rdi + 34], ax shl eax, 3 mov [rdi + 34], ax mov dword [rdi + 36], 0x61746164 mov [rdi + 40], r8d xor eax, eax .return: ret align 16 _wav_parse: mov r8d, -1 cmp dword [rsi], 0x46464952 jne .returnR8d mov r8d, -2 cmp dword [rsi + 8], 0x45564157 jne .returnR8d add rsi, 12 jmp .startLoop .loop: add rsi, rax add rsi, 8 .startLoop: mov edx, [rsi] mov eax, [rsi + 4] bswap edx cmp edx, 0x666D7420 je .fmt cmp edx, 0x64617461 jne .loop jmp .match .fmt: lea rcx, [rsi + 8] jmp .loop .match: add rsi, 8 mov [rdi], rsi mov [rdi + 8], rax mov edx, [rcx + 4] cvtsi2sd xmm0, rdx movsd [rdi + 16], xmm0 movzx edx, word [rcx] mov [rdi + 36], edx movzx esi, word [rcx + 2] mov [rdi + 32], esi multizero r8d, edx div esi movzx ecx, word [rcx + 14] shr ecx, 3 xor edx, edx div ecx mov [rdi + 24], rax .returnR8d: mov eax, r8d ret
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; WriteDr4.Asm ; ; Abstract: ; ; AsmWriteDr4 function ; ; Notes: ; ;------------------------------------------------------------------------------ DEFAULT REL SECTION .text ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmWriteDr4 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmWriteDr4) ASM_PFX(AsmWriteDr4): ; ; There's no obvious reason to access this register, since it's aliased to ; DR6 when DE=0 or an exception generated when DE=1 ; DB 0xf, 0x23, 0xe1 mov rax, rcx ret
; A266297: Numbers whose last digit is a square. ; 0,1,4,9,10,11,14,19,20,21,24,29,30,31,34,39,40,41,44,49,50,51,54,59,60,61,64,69,70,71,74,79,80,81,84,89,90,91,94,99,100,101,104,109,110,111,114,119,120,121,124,129,130,131,134,139,140,141,144,149,150,151,154,159,160,161,164,169,170,171,174,179,180,181,184,189,190,191,194,199,200,201,204,209,210,211,214,219,220,221,224,229,230,231,234,239,240,241,244,249,250,251,254,259,260,261,264,269,270,271,274,279,280,281,284,289,290,291,294,299,300,301,304,309,310,311,314,319,320,321,324,329,330,331,334,339,340,341,344,349,350,351,354,359,360,361,364,369,370,371,374,379,380,381,384,389,390,391,394,399,400,401,404,409,410,411,414,419,420,421,424,429,430,431,434,439,440,441,444,449,450,451,454,459,460,461,464,469,470,471,474,479,480,481,484,489,490,491,494,499,500,501,504,509,510,511,514,519,520,521,524,529,530,531,534,539,540,541,544,549,550,551,554,559,560,561,564,569,570,571,574,579,580,581,584,589,590,591,594,599,600,601,604,609,610,611,614,619,620,621 add $0,5 mov $1,$0 div $1,4 mul $1,4 mov $2,$0 lpb $2,1 mov $3,$0 add $3,2 mov $0,$3 sub $2,4 lpe add $1,$0 sub $1,11
.main ADDI r0 0 # r0 = 0 ADDI r14 4 # int i = 4 .L1 ADDI r0 1 # x++ SUBI r14 1 # i-- CMPI r14 0 # i - 0, jump if i >= 0; BGE -4 # jump back 3 lines ADD r1 r0 # r1 should get final value of x, which is 5
; A038408: Coordination sequence for Zeolite Code DFT. ; 1,4,10,21,36,55,79,106,138,175,215,260,309,362,420,482,548,618,693,772,855,943,1034,1130,1231,1335,1444,1557,1674,1796,1922,2052,2186,2325,2468,2615,2767,2922,3082,3247,3415,3588,3765,3946,4132,4322,4516,4714,4917,5124,5335,5551,5770,5994,6223,6455,6692,6933,7178,7428,7682,7940,8202,8469,8740,9015,9295,9578,9866,10159,10455,10756,11061,11370,11684,12002,12324,12650,12981,13316,13655,13999,14346,14698,15055,15415,15780,16149,16522,16900,17282,17668,18058,18453,18852,19255,19663,20074,20490,20911,21335,21764,22197,22634,23076,23522,23972,24426,24885,25348,25815,26287,26762,27242,27727,28215,28708,29205,29706,30212,30722,31236,31754,32277,32804,33335,33871,34410,34954,35503,36055,36612,37173,37738,38308,38882,39460,40042,40629,41220,41815,42415,43018,43626,44239,44855,45476,46101,46730,47364,48002,48644,49290,49941,50596,51255,51919,52586,53258,53935,54615,55300,55989,56682,57380,58082,58788,59498,60213,60932,61655,62383,63114,63850,64591,65335,66084,66837,67594,68356,69122,69892,70666,71445,72228,73015,73807,74602,75402,76207,77015,77828,78645,79466,80292,81122,81956,82794,83637,84484,85335,86191,87050,87914,88783,89655,90532,91413,92298,93188,94082,94980,95882,96789,97700,98615,99535,100458,101386,102319,103255,104196,105141,106090,107044,108002,108964,109930,110901,111876,112855,113839,114826,115818,116815,117815,118820,119829,120842,121860,122882,123908,124938,125973,127012,128055,129103,130154,131210,132271 mov $6,$0 pow $0,2 lpb $0,1 add $0,6 mov $3,$0 add $5,$0 sub $0,$5 add $3,3 mul $3,2 lpe div $3,5 add $3,6 div $3,3 mov $1,$3 sub $1,1 mov $4,$6 mul $4,$6 mov $2,$4 mul $2,2 add $1,$2
;Перекрыть девятую функцию прерывания 21h таким образом, чтобы в выводимой строке маленькие буквы заменялись большими, ; а большие на маленькие. CSEG segment assume cs:CSEG, ds:CSEG, es:CSEG, ss:CSEG org 80h cmdLength db ? ;cmd line lenght cmdLine db ? ;cmd line org 100h Start: jmp init Int_21h_proc proc cmp ah, 09h je itsOkayToBe9h jmp dword ptr cs:[Int_21h_vect] itsOkayToBe9h: push dx push di push si push es push ds pop es mov di, dx mov si, dx veryCoolLoop: lodsb cmp al, '$' je finish cmp al, 'a' je space cmp al, 'e' je space cmp al, 'i' je space cmp al, 'o' je space cmp al, 'u' je space cmp al, 'A' je space cmp al, 'E' je space cmp al, 'I' je space cmp al, 'O' je space cmp al, 'U' je space jmp ignore space: mov al, '' ignore: stosb jmp veryCoolLoop finish: pushf call dword ptr cs:[Int_21h_vect] pop es pop si pop di pop dx iret Int_21h_proc endp installFlag dw 13579 Int_21h_vect dd ? msgAlreadyInstalled db 'Already installed', 13, 10, '$' msgCmdArgsErr db 'Command line arguments are invalid', 13, 10, '$' msgNotInstalled db 'Not installed', 13, 10, '$' msgUninstalled db 'Uninstalled', 13, 10, '$' msgInstalled db 'Installed', 13, 10, '$' init: mov ax, 3521h int 21h mov word ptr Int_21h_vect, bx mov word ptr Int_21h_vect + 2, es cmp cmdLength, 0 je install cmp cmdLength, 3 jne invalidParams cmp cmdLine[0], ' ' jne invalidParams cmp cmdLine[1], '-' jne invalidParams cmp cmdLine[2], 'd' jne invalidParams cmp es:installFlag, 13579 jne notInstalled ;if user wants to unistall handler mov dx, offset msgUninstalled mov ah, 09h int 21h mov ax, 2521h mov ds, word ptr es:Int_21h_vect + 2 mov dx, word ptr es:Int_21h_vect int 21h mov ah, 4ch int 21h invalidParams: mov dx, offset msgCmdArgsErr jmp toEnd alreadyInstalled: mov dx, offset msgAlreadyInstalled jmp toEnd notInstalled: mov dx, offset msgNotInstalled toEnd: mov ah, 09h int 21h mov ah, 4ch int 21h install: cmp es:installFlag, 13579 je alreadyInstalled mov ah, 09h mov dx, offset msgInstalled int 21h ;25h - installing of our handler mov ax, 2521h mov dx, offset Int_21h_proc; in ds:dx should be our handler int 21h ;27h - saving last byte of init label so its stays in memory mov dx, offset Init int 27h mov ah, 35h ;this function return adress of original handler mov al, 21h ;choosing for what interrupt we whant to get int 21h ;now in es:bx adress of 21h handler ;saving of old handler mov word ptr Int_21h_vect, bx mov word ptr Int_21h_vect + 2, es ;25h - installing of our handler mov ah, 25h mov al, 21h mov dx, offset Int_21h_proc; in ds:dx should be our handler int 21h ;27h - saving last byte of init label so its stays in memory mov dx, offset Init int 27h CSEG ends end Start
SECTION code_clib SECTION code_fp_math48 PUBLIC asm_round EXTERN am48_round defc asm_round = am48_round
#pragma comment(linker, "/stack:640000000") #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <iomanip> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; const double EPS = 1e-9; const int INF = 0x7f7f7f7f; const double PI=acos(-1.0); #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) #define MP(x, y) make_pair(x, y) #define SZ(c) (int)c.size() #define PB(x) push_back(x) #define rep(i,n) for(i=1;i<=n;i++) #define repI(i,n) for(i=0;i<n;i++) #define F(i,L,R) for (int i = L; i < R; i++) #define FF(i,L,R) for (int i = L; i <= R; i++) #define FR(i,L,R) for (int i = L; i > R; i--) #define FRF(i,L,R) for (int i = L; i >= R; i--) #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define ALL(p) p.begin(),p.end() #define ALLR(p) p.rbegin(),p.rend() #define SET(p) memset(p, -1, sizeof(p)) #define CLR(p) memset(p, 0, sizeof(p)) #define MEM(p, v) memset(p, v, sizeof(p)) #define CPY(d, s) memcpy(d, s, sizeof(s)) #define getI(a) scanf("%d", &a) #define getII(a,b) scanf("%d%d", &a, &b) #define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c) #define getL(a) scanf("%lld",&a) #define getLL(a,b) scanf("%lld%lld",&a,&b) #define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define getC(n) scanf("%c",&n) #define getF(n) scanf("%lf",&n) #define getS(n) scanf("%s",n) #define vi vector < int > #define vii vector < vector < int > > #define pii pair< int, int > #define psi pair< string, int > #define ff first #define ss second #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define ld long double template< class T > inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); } template< class T > inline T _max(T a, T b) { return (!((a)<(b))?(a):(b)); } template< class T > inline T _min(T a, T b) { return (((a)<(b))?(a):(b)); } template< class T > inline T _swap(T &a, T &b) { a=a^b;b=a^b;a=a^b;} template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); } template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); } //******************DELETE**************** #define shubhashis #ifdef shubhashis #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;} #else #define debug(args...) // Just strip off all debug tokens #endif struct debugger{ template<typename T> debugger& operator , (const T& v){ cerr<<v<<" "; return *this; } }dbg; int bitOn(int N,int pos) { return N=N | (1<<pos); } int bitOff(int N,int pos) { return N=N & ~(1<<pos); } bool bitCheck(int N,int pos) { return (bool)(N & (1<<pos)); } struct data { int x,y; }; map <pii,int> mp; vector <data> vd; bool cmp(const data &a,const data &b) { if(a.x<b.x) return true; else if(a.x==b.x) return a.y<b.y; return false; } bool cmp1(const data &a,const data &b) { if(a.y<b.y) return true; else if(a.y==b.y) return a.x<b.x; return false; } int main() { //READ("in.txt"); //WRITE("out.txt"); int n; while(~getI(n)) { mp.clear(); vd.clear(); for(int i=0;i<n;i++) { int x,y; getII(x,y); //if(mp[pii(x,y)]==0) { mp[pii(x,y)]++;; data d; d.x=x,d.y=y; vd.PB(d); } //else mp[pii(x,y)]++; } ll eki=0; FOREACH(it,mp) { ll k=it->ss; eki += (k*(k-1))/2; } ll cnt=0; sort(ALL(vd),cmp); int len=vd.size(); map <int,int> mpp,mp2; for(int i=0;i<len;i++) { mpp[vd[i].x]++; } FOREACH(it,mpp) { ll k=it->ss; cnt += (k*(k-1))/2; } sort(ALL(vd),cmp1); //ll eki=0; for(int i=0;i<len;i++) { // if(i<len-1 && vd[i].x==vd[i+1].x && vd[i].y==vd[i+1].y) eki++; mp2[vd[i].y]++; } FOREACH(it,mp2) { ll k=it->ss; cnt += (k*(k-1))/2; } cnt -= eki; printf("%I64d\n",cnt); } return 0; }
; A085533: (2n)^(2n+1). ; 0,8,1024,279936,134217728,100000000000,106993205379072,155568095557812224,295147905179352825856,708235345355337676357632,2097152000000000000000000000,7511413302012830262726227918848,32009658644406818986777955348250624 mul $0,2 mov $1,$0 add $1,1 pow $0,$1
; A008123: Coordination sequence T1 for Zeolite Code KFI. ; 1,4,9,17,29,45,64,86,112,141,173,209,249,292,338,388,441,497,557,621,688,758,832,909,989,1073,1161,1252,1346,1444,1545,1649,1757,1869,1984,2102,2224,2349,2477,2609,2745,2884,3026,3172,3321,3473,3629,3789,3952,4118,4288,4461,4637,4817,5001,5188,5378,5572,5769,5969,6173,6381,6592,6806,7024,7245,7469,7697,7929,8164,8402,8644,8889,9137,9389,9645,9904,10166,10432,10701,10973,11249,11529,11812,12098,12388,12681,12977,13277,13581,13888,14198,14512,14829,15149,15473,15801,16132,16466,16804,17145,17489,17837,18189,18544,18902,19264,19629,19997,20369,20745,21124,21506,21892,22281,22673,23069,23469,23872,24278,24688,25101,25517,25937,26361,26788,27218,27652,28089,28529,28973,29421,29872,30326,30784,31245,31709,32177,32649,33124,33602,34084,34569,35057,35549,36045,36544,37046,37552,38061,38573,39089,39609,40132,40658,41188,41721,42257,42797,43341,43888,44438,44992,45549,46109,46673,47241,47812,48386,48964,49545,50129,50717,51309,51904,52502,53104,53709,54317,54929,55545,56164,56786,57412,58041,58673,59309,59949,60592,61238,61888,62541,63197,63857,64521,65188,65858,66532,67209,67889,68573,69261,69952,70646,71344,72045,72749,73457,74169,74884,75602,76324,77049,77777,78509,79245,79984,80726,81472,82221,82973,83729,84489,85252,86018,86788,87561,88337,89117,89901,90688,91478,92272,93069,93869,94673,95481,96292,97106,97924,98745,99569,100397,101229,102064,102902,103744,104589,105437,106289 pow $0,2 lpb $0,1 sub $0,1 add $2,$0 add $0,$2 mov $2,$0 mov $0,0 mov $1,3 trn $2,1 add $1,$2 div $2,7 sub $1,$2 lpe add $1,1
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r8 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0xc560, %r8 clflush (%r8) nop nop nop nop inc %rdi mov (%r8), %rdx nop nop sub %r9, %r9 lea addresses_D_ht+0x33e0, %rcx nop nop sub $29798, %r10 and $0xffffffffffffffc0, %rcx vmovaps (%rcx), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rax nop nop cmp $9737, %rdi lea addresses_A_ht+0x10160, %r10 nop nop nop nop nop cmp %r8, %r8 movb (%r10), %cl nop nop nop nop cmp $48219, %rdi lea addresses_normal_ht+0x5d60, %rcx nop nop nop nop nop and %r8, %r8 mov (%rcx), %r10w nop xor %r8, %r8 lea addresses_WC_ht+0x128c0, %r8 nop add $58644, %rax mov (%r8), %r10w nop nop inc %rdx lea addresses_UC_ht+0x14888, %rdx nop and $46528, %rdi movw $0x6162, (%rdx) nop nop nop inc %rcx lea addresses_WC_ht+0x2f60, %r8 nop nop nop sub %rdi, %rdi mov $0x6162636465666768, %rdx movq %rdx, %xmm3 movups %xmm3, (%r8) nop nop xor $47171, %r9 lea addresses_D_ht+0x75e0, %rax nop nop nop nop nop cmp $63043, %rdi mov $0x6162636465666768, %r9 movq %r9, (%rax) nop add $25996, %r10 lea addresses_WT_ht+0xd460, %r8 nop nop nop nop nop cmp $3642, %rdi mov $0x6162636465666768, %r10 movq %r10, %xmm6 vmovups %ymm6, (%r8) nop nop xor %rdx, %rdx lea addresses_normal_ht+0x1af60, %rsi lea addresses_normal_ht+0x11528, %rdi xor %rax, %rax mov $107, %rcx rep movsb nop nop nop cmp $57562, %r9 lea addresses_normal_ht+0x11ac0, %r9 nop nop nop nop nop xor %rsi, %rsi movb $0x61, (%r9) nop cmp %rax, %rax lea addresses_WC_ht+0x171c8, %rdi nop nop nop nop nop sub $56758, %r10 vmovups (%rdi), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %rcx nop nop inc %rsi lea addresses_UC_ht+0x6760, %rsi lea addresses_WC_ht+0x14750, %rdi nop nop xor $7266, %rdx mov $7, %rcx rep movsb nop nop nop nop add $16196, %rdx lea addresses_normal_ht+0x7b60, %rsi inc %r8 mov (%rsi), %r9 nop nop nop nop nop add %rdx, %rdx lea addresses_normal_ht+0x86e0, %rsi nop nop nop nop and %r10, %r10 mov (%rsi), %dx nop nop nop xor $55688, %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r8 push %rax push %rdi // Faulty Load mov $0x49a4da0000000960, %r13 nop nop nop xor %r14, %r14 movups (%r13), %xmm7 vpextrq $1, %xmm7, %rdi lea oracles, %r13 and $0xff, %rdi shlq $12, %rdi mov (%r13,%rdi,1), %rdi pop %rdi pop %rax pop %r8 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 3, 'size': 2, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 2, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': True, 'NT': False}} {'48': 633, '44': 1412, '46': 13657, '00': 6127} 00 46 00 46 46 00 00 46 48 46 46 46 46 00 46 46 46 00 00 00 46 46 00 46 46 46 00 46 00 46 46 46 00 46 00 00 00 00 46 46 46 46 46 46 00 46 44 46 46 46 46 46 46 46 00 46 46 00 46 46 00 00 46 46 46 46 44 44 46 46 46 46 46 46 44 46 00 46 46 44 00 46 46 46 46 46 00 46 46 46 00 00 00 46 44 46 00 46 00 46 46 00 00 46 46 00 46 46 00 46 46 44 00 46 00 00 00 46 44 00 46 46 46 44 46 44 46 46 46 00 46 46 46 46 46 46 00 00 46 00 46 48 00 46 00 46 46 46 44 00 46 46 46 46 46 46 46 00 00 46 48 46 00 46 00 00 00 46 46 46 46 00 46 46 00 46 46 46 46 46 00 46 46 44 46 46 00 46 00 00 44 46 46 46 00 46 46 46 00 00 46 46 46 46 46 00 00 46 46 46 46 00 46 44 46 44 44 46 44 48 46 00 46 46 46 46 46 00 46 46 00 00 00 46 46 46 46 46 44 46 46 00 00 46 46 46 46 46 46 46 00 44 46 00 46 46 44 46 00 00 46 46 46 00 00 46 46 46 46 46 46 46 46 46 44 00 46 46 00 46 00 46 46 46 46 00 46 46 00 00 46 46 00 48 46 46 00 00 00 00 00 46 46 46 00 46 46 00 46 46 46 00 46 46 46 00 00 46 44 46 46 46 00 46 46 46 44 00 46 46 00 46 00 46 46 46 44 00 44 44 46 46 46 46 00 00 46 46 44 46 44 46 46 46 46 00 00 46 46 46 00 00 46 46 46 44 46 00 46 46 46 46 44 00 46 00 46 46 00 00 00 46 44 00 46 46 46 46 00 00 46 00 46 44 48 44 46 00 00 46 48 46 46 00 46 44 46 48 46 46 46 46 46 00 00 46 46 44 46 46 46 00 46 46 46 46 46 46 46 00 46 46 44 46 46 46 46 46 46 00 46 46 46 00 00 44 00 00 46 00 46 00 48 46 46 48 46 46 46 46 44 00 44 00 00 46 46 00 46 46 46 46 00 46 44 00 00 46 46 46 00 46 44 46 46 00 46 00 00 46 46 00 46 46 00 46 46 00 46 46 00 46 46 00 00 46 46 44 00 44 46 00 46 46 46 00 46 46 44 46 46 48 46 00 00 46 48 46 46 46 46 46 46 00 46 00 46 46 00 00 46 46 00 00 46 46 00 00 00 00 00 46 46 46 00 46 46 46 46 46 00 00 46 46 00 00 00 46 46 46 46 48 00 46 46 46 46 00 46 46 00 46 46 46 00 46 46 46 44 46 46 00 46 46 00 00 48 46 00 46 46 00 46 46 44 46 46 44 00 46 46 46 46 46 44 46 46 46 00 46 46 00 46 46 46 46 46 46 00 46 46 46 46 46 00 46 46 00 46 44 00 46 46 00 46 46 46 46 46 44 46 46 00 46 46 46 46 00 00 46 46 44 00 46 46 46 44 46 46 46 00 46 46 46 46 46 46 46 46 00 46 00 46 46 00 00 00 46 00 00 46 46 44 00 46 46 00 46 46 46 00 46 46 00 46 46 46 46 00 46 46 46 00 46 46 00 46 46 46 46 00 00 00 46 46 00 46 00 46 46 46 44 46 46 46 46 46 00 00 46 46 00 00 00 46 46 00 46 00 46 46 46 00 46 00 46 46 46 46 00 46 46 46 46 00 46 00 46 46 46 46 44 00 46 00 46 44 46 46 44 48 46 00 00 46 46 46 46 46 00 48 00 46 46 46 46 00 00 46 46 00 46 46 44 00 00 46 46 48 00 46 46 00 00 46 46 44 00 46 00 46 46 46 46 00 46 46 46 46 46 46 46 46 46 46 46 46 46 46 00 00 46 46 46 00 46 46 46 46 44 46 46 46 46 00 46 46 44 00 46 46 00 46 00 46 46 46 46 00 00 00 44 00 46 00 00 00 46 46 00 46 00 46 00 00 00 46 46 00 44 00 46 46 00 46 46 44 00 48 46 46 44 46 46 46 44 00 46 46 46 46 00 00 00 46 46 44 46 00 46 46 46 46 00 46 44 00 46 44 46 46 46 44 00 46 00 46 46 00 46 46 46 00 46 46 44 46 46 46 44 00 00 46 46 46 00 46 46 00 46 00 46 46 46 46 46 44 46 00 46 46 46 00 00 46 00 46 46 00 46 46 00 48 46 00 46 46 46 46 46 46 46 00 46 00 00 46 46 46 46 */
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>mlockall(flags) -> str Invokes the syscall mlockall. See 'man 2 mlockall' for more information. Arguments: flags(int): flags Returns: int </%docstring> <%page args="flags=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = [] can_pushstr_array = [] argument_names = ['flags'] argument_values = [flags] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%r' % (name, arg)) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_mlockall']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* mlockall(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
; A021684: Expansion of 1/((1-x)(1-3x)(1-9x)(1-10x)). ; Submitted by Jon Maiga ; 1,23,360,4810,59111,690573,7801990,86089520,933531621,9989073523,105774639620,1110701801430,11583617458531,120125571974873,1239860303429250,12746044308940540,130587414625807841,1334016890279410623,13593453599567226880,138214098268373746850,1402657043143280947551,14211214975584391316773,143773950653255221328510,1452695714609395201500360,14661563018785962553245661,147827083042088991309549323,1489173906108958017888070140,14989866742282204560410121070,150781816553555699353054670171 add $0,2 lpb $0 sub $0,1 add $2,2 mul $2,9 sub $2,9 mul $3,10 add $3,$1 mul $1,3 add $1,$2 lpe mov $0,$3 div $0,9
#include <iostream> #include <cmath> using namespace std; void startup() { cout << "Welcome to Artillery." << endl; cout << "You are in the middle of a war and being charged by thousands of enemies." << endl; cout << "You have one cannon, which you can shoot at any angle." << endl; cout << "You only have 10 cannonballs for this target.." << endl; cout << "Let's begin..." << endl; } int fly_distance(float angel) { float velocity = 200.0; float gravity = 32.2; float time_in_air = (2.0 * velocity * sin(angel)) / gravity; float distance = round((velocity * cos(angel)) * time_in_air); return (int) round(distance); } int new_enemy_distance(){ srand(time(NULL)); int _dis = rand() % 900 + 200; cout << "the enemy is at " << _dis << endl; return _dis; } int fire() { float angel=0; int shot_count=0,hit=0,fly_dis=0; float enemy_distance = 0; enemy_distance = new_enemy_distance(); do{ cout << "What angle?"; cin >> angel; if (cin.fail()) { cin.clear(); cin.ignore(100,'\n'); continue; } angel = (angel * 3.1415)/180.0; fly_dis = fly_distance(angel); shot_count++; if ( abs(enemy_distance-fly_dis) > 1 ) { cout << "you over shot by " << abs(enemy_distance - fly_dis) << endl; }else{ hit = 1; } } while ( hit == 0); cout << "You hit hime !!!" << endl; cout << "It tooke you " << shot_count << "shits" << endl; return 1; } int main(int argc, char *argv[]) { char done; startup(); int killed = 0; do { killed += fire(); cout << "You have killed " << killed << "enemies." << endl; cout << "I see another one, care to shoot again? (Y/N) " << endl; cin >> done; } while (done != 'n'); return 0; }
/** * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "src/runtime/kernel/arm/fp32/ragged_range_fp32.h" #include <vector> #include "nnacl/fp32/ragged_range_fp32.h" #include "src/kernel_registry.h" #include "include/errorcode.h" using mindspore::kernel::KERNEL_ARCH; using mindspore::lite::KernelRegistrar; using mindspore::lite::RET_OK; using mindspore::schema::PrimitiveType_RaggedRange; namespace mindspore::kernel { int RaggedRangeCPUKernel::Prepare() { CHECK_LESS_RETURN(in_tensors_.size(), 3); CHECK_LESS_RETURN(out_tensors_.size(), 2); if (!InferShapeDone()) { return RET_OK; } return ReSize(); } int RaggedRangeCPUKernel::ReSize() { return RET_OK; } int RaggedRangeCPUKernel::Run() { if (in_tensors_[0]->data_type() == kNumberTypeFloat32) { RaggedRangeFp32(static_cast<float *>(in_tensors_.at(0)->data()), static_cast<float *>(in_tensors_.at(1)->data()), static_cast<float *>(in_tensors_.at(2)->data()), static_cast<int *>(out_tensors_.at(0)->data()), static_cast<float *>(out_tensors_.at(1)->data()), reinterpret_cast<RaggedRangeParameter *>(op_parameter_)); } else { RaggedRangeInt(static_cast<int *>(in_tensors_.at(0)->data()), static_cast<int *>(in_tensors_.at(1)->data()), static_cast<int *>(in_tensors_.at(2)->data()), static_cast<int *>(out_tensors_.at(0)->data()), static_cast<int *>(out_tensors_.at(1)->data()), reinterpret_cast<RaggedRangeParameter *>(op_parameter_)); } return RET_OK; } REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_RaggedRange, LiteKernelCreator<RaggedRangeCPUKernel>) REG_KERNEL(kCPU, kNumberTypeInt32, PrimitiveType_RaggedRange, LiteKernelCreator<RaggedRangeCPUKernel>) } // namespace mindspore::kernel
SECTION code_clib SECTION code_fp_math48 PUBLIC asm_dconst_inf, asm_dconst_pinf, asm_dconst_minf EXTERN am48_dconst_inf, am48_dconst_pinf, am48_dconst_minf defc asm_dconst_inf = am48_dconst_inf defc asm_dconst_pinf = am48_dconst_pinf defc asm_dconst_minf = am48_dconst_minf
; A322783: a(n) = 1 - n + (2^(n+2) - (-1)^n)/3. ; 2,3,4,9,18,39,80,165,334,675,1356,2721,5450,10911,21832,43677,87366,174747,349508,699033,1398082,2796183,5592384,11184789,22369598,44739219,89478460,178956945,357913914,715827855,1431655736 mov $2,$0 mov $7,$0 add $7,1 lpb $7,1 mov $0,$2 sub $7,1 sub $0,$7 mov $9,$0 mov $11,2 lpb $11,1 mov $0,$9 sub $11,1 add $0,$11 sub $0,1 add $4,8 div $5,7 add $5,4 mov $8,2 pow $8,$0 trn $0,$4 mul $8,4 add $8,5 add $8,$5 sub $8,2 gcd $0,$8 div $0,3 mov $3,$0 mov $6,$11 lpb $6,1 sub $6,1 mov $10,$3 lpe lpe lpb $9,1 mov $9,0 sub $10,$3 lpe mov $3,$10 sub $3,1 add $1,$3 lpe
; A156189: Denominator of Euler(n, 1/6). ; 1,3,36,108,1296,3888,46656,139968,1679616,5038848,60466176,181398528,2176782336,6530347008,78364164096,235092492288,2821109907456,8463329722368,101559956668416,304679870005248,3656158440062976,10968475320188928,131621703842267136,394865111526801408,4738381338321616896,14215144014964850688,170581728179578208256,511745184538734624768,6140942214464815497216,18422826643394446491648,221073919720733357899776,663221759162200073699328,7958661109946400884391936,23875983329839202653175808,286511799958070431838109696,859535399874211295514329088,10314424798490535546171949056,30943274395471606638515847168,371319292745659279662190166016,1113957878236977838986570498048,13367494538843734067838845976576,40102483616531202203516537929728,481229803398374426442198455156736,1443689410195123279326595365470208,17324272922341479351919144385642496,51972818767024438055757433156927488,623673825204293256669089197883129856 mov $1,$0 gcd $0,2 lpb $1 mul $0,6 sub $1,1 lpe sub $0,2 div $0,2 add $0,1
; A179179: a(n) = phi(n) - omega(n) = A000010(n) - A001221(n). ; Submitted by Jon Maiga ; 1,0,1,1,3,0,5,3,5,2,9,2,11,4,6,7,15,4,17,6,10,8,21,6,19,10,17,10,27,5,29,15,18,14,22,10,35,16,22,14,39,9,41,18,22,20,45,14,41,18,30,22,51,16,38,22,34,26,57,13,59,28,34,31,46,17,65,30,42,21,69,22,71,34,38,34,58,21,77,30,53,38,81,21,62,40,54,38,87,21,70,42,58,44,70,30,95,40,58,38 mov $1,$0 seq $0,322307 ; Number of multisets in the swell of the n-th multiset multisystem. seq $1,10 ; Euler totient function phi(n): count numbers <= n and prime to n. sub $1,$0 mov $0,$1
#include "util.h" #include <fstream> bool file_exists(std::string path) { std::ifstream f(path); return f.good(); }
#include "testing/testing.hpp" #include "coding/byte_stream.hpp" #include "coding/coding_tests/test_polylines.hpp" #include "coding/geometry_coding.hpp" #include "coding/point_to_integer.hpp" #include "coding/pointd_to_pointu.hpp" #include "coding/varint.hpp" #include "coding/writer.hpp" #include "geometry/distance.hpp" #include "geometry/geometry_tests/large_polygon.hpp" #include "geometry/mercator.hpp" #include "geometry/simplification.hpp" #include "base/logging.hpp" using namespace coding; using PU = m2::PointU; namespace { m2::PointU D2U(m2::PointD const & p) { return PointDToPointU(p, POINT_COORD_BITS); } m2::PointU GetMaxPoint() { return D2U(m2::PointD(MercatorBounds::maxX, MercatorBounds::maxY)); } void TestPolylineEncode(string testName, vector<m2::PointU> const & points, m2::PointU const & maxPoint, void (*fnEncode)(InPointsT const & points, m2::PointU const & basePoint, m2::PointU const & maxPoint, OutDeltasT & deltas), void (*fnDecode)(InDeltasT const & deltas, m2::PointU const & basePoint, m2::PointU const & maxPoint, OutPointsT & points)) { size_t const count = points.size(); if (count == 0) return; m2::PointU const basePoint = m2::PointU::Zero(); vector<uint64_t> deltas; deltas.resize(count); OutDeltasT deltasA(deltas); fnEncode(make_read_adapter(points), basePoint, maxPoint, deltasA); vector<m2::PointU> decodedPoints; decodedPoints.resize(count); OutPointsT decodedPointsA(decodedPoints); fnDecode(make_read_adapter(deltas), basePoint, maxPoint, decodedPointsA); TEST_EQUAL(points, decodedPoints, ()); if (points.size() > 10) { vector<char> data; MemWriter<vector<char>> writer(data); for (size_t i = 0; i != deltas.size(); ++i) WriteVarUint(writer, deltas[i]); LOG(LINFO, (testName, points.size(), data.size())); } } vector<m2::PointU> SimplifyPoints(vector<m2::PointU> const & points, double eps) { vector<m2::PointU> simpPoints; typedef m2::DistanceToLineSquare<m2::PointD> DistanceF; DistanceF dist; SimplifyNearOptimal(20, points.begin(), points.end(), eps, dist, AccumulateSkipSmallTrg<DistanceF, m2::PointU>(dist, simpPoints, eps)); return simpPoints; } void TestEncodePolyline(string name, m2::PointU maxPoint, vector<m2::PointU> const & points) { TestPolylineEncode(name + "1", points, maxPoint, &EncodePolylinePrev1, &DecodePolylinePrev1); TestPolylineEncode(name + "2", points, maxPoint, &EncodePolylinePrev2, &DecodePolylinePrev2); TestPolylineEncode(name + "3", points, maxPoint, &EncodePolylinePrev3, &DecodePolylinePrev3); } } // namespace UNIT_TEST(EncodePointDeltaAsUint) { for (int x = -100; x <= 100; ++x) { for (int y = -100; y <= 100; ++y) { PU orig = PU(100 + x, 100 + y); PU pred = PU(100, 100); TEST_EQUAL(orig, DecodePointDeltaFromUint(EncodePointDeltaAsUint(orig, pred), pred), ()); vector<char> data; PushBackByteSink<vector<char>> sink(data); WriteVarUint(sink, EncodePointDeltaAsUint(orig, pred)); size_t expectedSize = 1; if (x >= 8 || x < -8 || y >= 4 || y < -4) expectedSize = 2; if (x >= 64 || x < -64 || y >= 64 || y < -64) expectedSize = 3; TEST_EQUAL(data.size(), expectedSize, (x, y)); } } } UNIT_TEST(PredictPointsInPolyline2) { // Ci = Ci-1 + (Ci-1 + Ci-2) / 2 TEST_EQUAL(PU(5, 5), PredictPointInPolyline(PU(8, 7), PU(4, 4), PU(1, 2)), ()); } UNIT_TEST(PredictPointsInPolyline2_ClampMax) { // Ci = Ci-1 + (Ci-1 + Ci-2) / 2 TEST_EQUAL(PU(4, 4), PredictPointInPolyline(PU(4, 4), PU(4, 4), PU(1, 2)), ()); TEST_EQUAL(PU(5, 5), PredictPointInPolyline(PU(8, 7), PU(4, 4), PU(1, 2)), ()); TEST_EQUAL(PU(5, 5), PredictPointInPolyline(PU(5, 5), PU(4, 4), PU(1, 2)), ()); } UNIT_TEST(PredictPointsInPolyline2_Clamp0) { TEST_EQUAL(PU(4, 0), PredictPointInPolyline(PU(5, 5), PU(4, 1), PU(4, 4)), ()); } /* UNIT_TEST(PredictPointsInPolyline3_Square) { TEST_EQUAL(PU(5, 1), PredictPointInPolyline(PU(6, 6), PU(5, 4), PU(2, 4), PU(2, 1)), ()); TEST_EQUAL(PU(5, 3), PredictPointInPolyline(PU(6, 6), PU(4, 1), PU(2, 2), PU(3, 4)), ()); } UNIT_TEST(PredictPointsInPolyline3_SquareClamp0) { TEST_EQUAL(PU(5, 1), PredictPointInPolyline(PU(6, 6), PU(5, 4), PU(2, 4), PU(2, 1)), ()); TEST_EQUAL(PU(4, 0), PredictPointInPolyline(PU(6, 6), PU(2, 0), PU(3, 2), PU(5, 1)), ()); } UNIT_TEST(PredictPointsInPolyline3_90deg) { TEST_EQUAL(PU(3, 2), PredictPointInPolyline(PU(8, 8), PU(3, 6), PU(1, 6), PU(1, 5)), ()); } */ UNIT_TEST(EncodePolyline) { size_t const kSizes[] = {0, 1, 2, 3, 4, ARRAY_SIZE(LargePolygon::kLargePolygon)}; m2::PointU const maxPoint(1000000000, 1000000000); for (size_t iSize = 0; iSize < ARRAY_SIZE(kSizes); ++iSize) { size_t const polygonSize = kSizes[iSize]; vector<m2::PointU> points; points.reserve(polygonSize); for (size_t i = 0; i < polygonSize; ++i) points.push_back( m2::PointU(static_cast<uint32_t>(LargePolygon::kLargePolygon[i].x * 10000), static_cast<uint32_t>((LargePolygon::kLargePolygon[i].y + 200) * 10000))); TestEncodePolyline("Unsimp", maxPoint, points); TestEncodePolyline("1simp", maxPoint, SimplifyPoints(points, 1)); TestEncodePolyline("2simp", maxPoint, SimplifyPoints(points, 2)); TestEncodePolyline("4simp", maxPoint, SimplifyPoints(points, 4)); TestEncodePolyline("10simp", maxPoint, SimplifyPoints(points, 10)); TestEncodePolyline("100simp", maxPoint, SimplifyPoints(points, 100)); TestEncodePolyline("500simp", maxPoint, SimplifyPoints(points, 500)); TestEncodePolyline("1000simp", maxPoint, SimplifyPoints(points, 1000)); TestEncodePolyline("2000simp", maxPoint, SimplifyPoints(points, 2000)); TestEncodePolyline("4000simp", maxPoint, SimplifyPoints(points, 4000)); } } // see 476c1d1d125f0c2deb8c commit for special decode test UNIT_TEST(DecodeEncodePolyline_DataSet1) { size_t const count = ARRAY_SIZE(geometry_coding_tests::arr1); vector<m2::PointU> points; points.reserve(count); for (size_t i = 0; i < count; ++i) points.push_back(D2U(geometry_coding_tests::arr1[i])); TestPolylineEncode("DataSet1", points, GetMaxPoint(), &EncodePolyline, &DecodePolyline); }
#pragma once #include <cstdint> #include <string> namespace vkBasalt { uint32_t convertToKeySym(std::string key); bool isKeyPressed(uint32_t ks); } // namespace vkBasalt
dnl PowerPC-64 mpn_addmul_1 and mpn_submul_1. dnl Copyright 1999-2001, 2003-2006, 2010-2012 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C mpn_addmul_1 mpn_submul_1 C cycles/limb cycles/limb C POWER3/PPC630 6-18 6-18 C POWER4/PPC970 8 8.3 C POWER5 8 8.25 C POWER6 16.25 16.75 C POWER7 3.77 4.9 C TODO C * Try to reduce the number of needed live registers C * Add support for _1c entry points C INPUT PARAMETERS define(`rp', `r3') define(`up', `r4') define(`n', `r5') define(`vl', `r6') ifdef(`OPERATION_addmul_1',` define(ADDSUBC, adde) define(ADDSUB, addc) define(func, mpn_addmul_1) define(func_nc, mpn_addmul_1c) C FIXME: not really supported define(SM, `') ') ifdef(`OPERATION_submul_1',` define(ADDSUBC, subfe) define(ADDSUB, subfc) define(func, mpn_submul_1) define(func_nc, mpn_submul_1c) C FIXME: not really supported define(SM, `$1') ') MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1) ASM_START() PROLOGUE(func) std r31, -8(r1) rldicl. r0, n, 0,62 C r0 = n & 3, set cr0 std r30, -16(r1) cmpdi cr6, r0, 2 std r29, -24(r1) addi n, n, 3 C compute count... std r28, -32(r1) srdi n, n, 2 C ...for ctr std r27, -40(r1) mtctr n C copy count into ctr beq cr0, L(b00) blt cr6, L(b01) beq cr6, L(b10) L(b11): ld r9, 0(up) ld r28, 0(rp) mulld r0, r9, r6 mulhdu r12, r9, r6 ADDSUB r0, r0, r28 std r0, 0(rp) addi rp, rp, 8 ld r9, 8(up) ld r27, 16(up) addi up, up, 24 SM(` subfe r11, r11, r11 ') b L(bot) ALIGN(16) L(b00): ld r9, 0(up) ld r27, 8(up) ld r28, 0(rp) ld r29, 8(rp) mulld r0, r9, r6 mulhdu r5, r9, r6 mulld r7, r27, r6 mulhdu r8, r27, r6 addc r7, r7, r5 addze r12, r8 ADDSUB r0, r0, r28 std r0, 0(rp) ADDSUBC r7, r7, r29 std r7, 8(rp) addi rp, rp, 16 ld r9, 16(up) ld r27, 24(up) addi up, up, 32 SM(` subfe r11, r11, r11 ') b L(bot) ALIGN(16) L(b01): bdnz L(gt1) ld r9, 0(up) ld r11, 0(rp) mulld r0, r9, r6 mulhdu r8, r9, r6 ADDSUB r0, r0, r11 std r0, 0(rp) SM(` subfe r11, r11, r11 ') SM(` addic r11, r11, 1 ') addze r3, r8 blr L(gt1): ld r9, 0(up) ld r27, 8(up) mulld r0, r9, r6 mulhdu r5, r9, r6 mulld r7, r27, r6 mulhdu r8, r27, r6 ld r9, 16(up) ld r28, 0(rp) ld r29, 8(rp) ld r30, 16(rp) mulld r11, r9, r6 mulhdu r10, r9, r6 addc r7, r7, r5 adde r11, r11, r8 addze r12, r10 ADDSUB r0, r0, r28 std r0, 0(rp) ADDSUBC r7, r7, r29 std r7, 8(rp) ADDSUBC r11, r11, r30 std r11, 16(rp) addi rp, rp, 24 ld r9, 24(up) ld r27, 32(up) addi up, up, 40 SM(` subfe r11, r11, r11 ') b L(bot) L(b10): addic r0, r0, 0 li r12, 0 C cy_limb = 0 ld r9, 0(up) ld r27, 8(up) bdz L(end) addi up, up, 16 ALIGN(16) L(top): mulld r0, r9, r6 mulhdu r5, r9, r6 C 9 mulld r7, r27, r6 mulhdu r8, r27, r6 C 27 ld r9, 0(up) ld r28, 0(rp) ld r27, 8(up) ld r29, 8(rp) adde r0, r0, r12 C 0 12 adde r7, r7, r5 C 5 7 mulld r5, r9, r6 mulhdu r10, r9, r6 C 9 mulld r11, r27, r6 mulhdu r12, r27, r6 C 27 ld r9, 16(up) ld r30, 16(rp) ld r27, 24(up) ld r31, 24(rp) adde r5, r5, r8 C 8 5 adde r11, r11, r10 C 10 11 addze r12, r12 C 12 ADDSUB r0, r0, r28 C 0 28 std r0, 0(rp) C 0 ADDSUBC r7, r7, r29 C 7 29 std r7, 8(rp) C 7 ADDSUBC r5, r5, r30 C 5 30 std r5, 16(rp) C 5 ADDSUBC r11, r11, r31 C 11 31 std r11, 24(rp) C 11 addi up, up, 32 SM(` subfe r11, r11, r11 ') addi rp, rp, 32 L(bot): SM(` addic r11, r11, 1 ') bdnz L(top) L(end): mulld r0, r9, r6 mulhdu r5, r9, r6 mulld r7, r27, r6 mulhdu r8, r27, r6 ld r28, 0(rp) ld r29, 8(rp) adde r0, r0, r12 adde r7, r7, r5 addze r8, r8 ADDSUB r0, r0, r28 std r0, 0(rp) ADDSUBC r7, r7, r29 std r7, 8(rp) SM(` subfe r11, r11, r11 ') SM(` addic r11, r11, 1 ') addze r3, r8 ld r31, -8(r1) ld r30, -16(r1) ld r29, -24(r1) ld r28, -32(r1) ld r27, -40(r1) blr EPILOGUE()
/*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "berryIParameterTypeListener.h" #include "berryParameterTypeEvent.h" #include "berryParameterType.h" namespace berry { void IParameterTypeListener::Events ::AddListener(IParameterTypeListener* l) { if (l == nullptr) return; parameterTypeChanged += Delegate(l, &IParameterTypeListener::ParameterTypeChanged); } void IParameterTypeListener::Events ::RemoveListener(IParameterTypeListener* l) { if (l == nullptr) return; parameterTypeChanged -= Delegate(l, &IParameterTypeListener::ParameterTypeChanged); } IParameterTypeListener::~IParameterTypeListener() { } }
/* * IDEA * (C) 1999-2010,2015 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include <botan/idea.h> #include <botan/loadstor.h> #include <botan/cpuid.h> #include <botan/internal/ct_utils.h> namespace Botan { namespace { /* * Multiplication modulo 65537 */ inline uint16_t mul(uint16_t x, uint16_t y) { const uint32_t P = static_cast<uint32_t>(x) * y; const uint16_t Z_mask = static_cast<uint16_t>(CT::expand_mask(P) & 0xFFFF); const uint32_t P_hi = P >> 16; const uint32_t P_lo = P & 0xFFFF; const uint16_t carry = (P_lo < P_hi); const uint16_t r_1 = static_cast<uint16_t>((P_lo - P_hi) + carry); const uint16_t r_2 = 1 - x - y; return CT::select(Z_mask, r_1, r_2); } /* * Find multiplicative inverses modulo 65537 * * 65537 is prime; thus Fermat's little theorem tells us that * x^65537 == x modulo 65537, which means * x^(65537-2) == x^-1 modulo 65537 since * x^(65537-2) * x == 1 mod 65537 * * Do the exponentiation with a basic square and multiply: all bits are * of exponent are 1 so we always multiply */ uint16_t mul_inv(uint16_t x) { uint16_t y = x; for(size_t i = 0; i != 15; ++i) { y = mul(y, y); // square y = mul(y, x); } return y; } /** * IDEA is involutional, depending only on the key schedule */ void idea_op(const uint8_t in[], uint8_t out[], size_t blocks, const uint16_t K[52]) { const size_t BLOCK_SIZE = 8; CT::poison(in, blocks * 8); CT::poison(out, blocks * 8); CT::poison(K, 52); BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i) { uint16_t X1, X2, X3, X4; load_be(in + BLOCK_SIZE*i, X1, X2, X3, X4); for(size_t j = 0; j != 8; ++j) { X1 = mul(X1, K[6*j+0]); X2 += K[6*j+1]; X3 += K[6*j+2]; X4 = mul(X4, K[6*j+3]); uint16_t T0 = X3; X3 = mul(X3 ^ X1, K[6*j+4]); uint16_t T1 = X2; X2 = mul((X2 ^ X4) + X3, K[6*j+5]); X3 += X2; X1 ^= X2; X4 ^= X3; X2 ^= T0; X3 ^= T1; } X1 = mul(X1, K[48]); X2 += K[50]; X3 += K[49]; X4 = mul(X4, K[51]); store_be(out + BLOCK_SIZE*i, X1, X3, X2, X4); } CT::unpoison(in, blocks * 8); CT::unpoison(out, blocks * 8); CT::unpoison(K, 52); } } size_t IDEA::parallelism() const { #if defined(BOTAN_HAS_IDEA_SSE2) if(CPUID::has_sse2()) { return 8; } #endif return 1; } std::string IDEA::provider() const { #if defined(BOTAN_HAS_IDEA_SSE2) if(CPUID::has_sse2()) { return "sse2"; } #endif return "base"; } /* * IDEA Encryption */ void IDEA::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { verify_key_set(m_EK.empty() == false); #if defined(BOTAN_HAS_IDEA_SSE2) if(CPUID::has_sse2()) { while(blocks >= 8) { sse2_idea_op_8(in, out, m_EK.data()); in += 8 * BLOCK_SIZE; out += 8 * BLOCK_SIZE; blocks -= 8; } } #endif idea_op(in, out, blocks, m_EK.data()); } /* * IDEA Decryption */ void IDEA::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { verify_key_set(m_DK.empty() == false); #if defined(BOTAN_HAS_IDEA_SSE2) if(CPUID::has_sse2()) { while(blocks >= 8) { sse2_idea_op_8(in, out, m_DK.data()); in += 8 * BLOCK_SIZE; out += 8 * BLOCK_SIZE; blocks -= 8; } } #endif idea_op(in, out, blocks, m_DK.data()); } /* * IDEA Key Schedule */ void IDEA::key_schedule(const uint8_t key[], size_t) { m_EK.resize(52); m_DK.resize(52); CT::poison(key, 16); CT::poison(m_EK.data(), 52); CT::poison(m_DK.data(), 52); secure_vector<uint64_t> K(2); K[0] = load_be<uint64_t>(key, 0); K[1] = load_be<uint64_t>(key, 1); for(size_t off = 0; off != 48; off += 8) { for(size_t i = 0; i != 8; ++i) m_EK[off+i] = K[i/4] >> (48-16*(i % 4)); const uint64_t Kx = (K[0] >> 39); const uint64_t Ky = (K[1] >> 39); K[0] = (K[0] << 25) | Ky; K[1] = (K[1] << 25) | Kx; } for(size_t i = 0; i != 4; ++i) m_EK[48+i] = K[i/4] >> (48-16*(i % 4)); m_DK[0] = mul_inv(m_EK[48]); m_DK[1] = -m_EK[49]; m_DK[2] = -m_EK[50]; m_DK[3] = mul_inv(m_EK[51]); for(size_t i = 0; i != 8*6; i += 6) { m_DK[i+4] = m_EK[46-i]; m_DK[i+5] = m_EK[47-i]; m_DK[i+6] = mul_inv(m_EK[42-i]); m_DK[i+7] = -m_EK[44-i]; m_DK[i+8] = -m_EK[43-i]; m_DK[i+9] = mul_inv(m_EK[45-i]); } std::swap(m_DK[49], m_DK[50]); CT::unpoison(key, 16); CT::unpoison(m_EK.data(), 52); CT::unpoison(m_DK.data(), 52); } void IDEA::clear() { zap(m_EK); zap(m_DK); } }
; A099464: Trisection of tribonacci numbers. ; 0,1,7,44,274,1705,10609,66012,410744,2555757,15902591,98950096,615693474,3831006429,23837527729,148323355432,922906855808,5742568741225,35731770264967,222332455004452,1383410902447554,8607945812375585,53560898629395777 mul $0,3 cal $0,73 ; Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) for n >= 3 with a(0) = a(1) = 0 and a(2) = 1. mov $1,$0
; A159917: Fixed point of the morphism 0 -> 01, 1 -> 2, 2 -> 01, starting from a(0) = 0. ; 0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2 add $0,2 cal $0,242082 ; Nim sequence of game on n counters whose legal moves are removing some number of counters in A027941. mov $1,$0
; A279882: a(n) = 2^(prime(n) + 1) - 1. ; 7,15,63,255,4095,16383,262143,1048575,16777215,1073741823,4294967295,274877906943,4398046511103,17592186044415,281474976710655,18014398509481983,1152921504606846975,4611686018427387903,295147905179352825855,4722366482869645213695 seq $0,40 ; The prime numbers. add $0,1 mov $1,2 pow $1,$0 sub $1,1 mov $0,$1
org 0 bits 16 _start: ; Start BIOS Parameter Block jmp short start nop times 33 db 0x0 ; Fake parameters start: jmp 0x7c0:step2 step2: cli ; Clear Interrupts mov ax, 0x7c0 mov ds, ax mov es, ax mov ax, 0x0 mov ss, ax mov sp, 0x7c00 sti ; Enable Interrupts mov ah, 0x2 ; Read Sector Command mov al, 0x1 ; One Sector to Read mov ch, 0x0 ; Cylinder low eight bits mov cl, 0x2 ; Read sector two mov dh, 0 ; Head number mov bx, buffer int 0x13 jc error mov si, buffer call print jmp $ error: mov si, error_message call print jmp $ print: mov bx, 0x0 .loop: lodsb cmp al, 0x0 je .done call print_char jmp .loop .done: ret print_char: mov ah, 0eh int 0x10 ret error_message: db 'Failed to load sector', 0x0 times 510-($ - $$) db 0 dw 0xAA55 buffer:
; A037972: a(n) = n^2*(n+1)*C(2*n-2,n-1)/2. ; 0,1,12,108,800,5250,31752,181104,988416,5212350,26741000,134132856,660284352,3199016548,15288882000,72209880000,337535723520,1563410094390,7182839945160,32761238433000,148450107960000,668693511305820,2995943329133040,13356820221694560,59280701238720000,262011779925187500,1153623194350924752,5061344547268349424,22132807390767737216,96488231928592950600,419438367668597508000,1818436206141309255424,7863877456600891342848,33927370721270178555942,146049037220149055920200,627389564529054717117000,2689778196932308382077632,11510193685140801463875244,49167544430562562816449456,209673520133249010406932000,892718087709728250111680000,3795111975495500365271647620,16110380013271274834495385840,68294720758127305769080482960,289131812383634788406964048000,1222524138151971944125895835000,5162922350944880933768266113120,21778731547620207860994697952640,91767577970204170302968248872960,386264897507324591978006726077500,1624197781510029627549064823250000,6822878066238324138460029939434256,28634372104331440454805166848665472,120064463119416363306642522682218648,502993784450116443737803296660328800 mov $1,$0 seq $0,37966 ; a(n) = n^2*binomial(2*n-2, n-1). add $1,1 mul $1,$0 mov $0,$1 div $0,2
; float __sint2fs_callee(signed int si) SECTION code_fp_math48 PUBLIC cm48_sdcciyp_sint2ds_callee EXTERN am48_double16, cm48_sdcciyp_m482d cm48_sdcciyp_sint2ds_callee: ; signed int to double ; ; enter : stack = signed int si, ret ; ; exit : dehl = sdcc_float(si) ; ; uses : af, bc, de, hl, bc', de', hl' pop af pop hl push af call am48_double16 jp cm48_sdcciyp_m482d
; A008844: Squares of sequence A001653: y^2 such that x^2 - 2*y^2 = -1 for some x. ; 1,25,841,28561,970225,32959081,1119638521,38034750625,1292061882721,43892069261881,1491038293021225,50651409893459761,1720656898084610641,58451683124983302025,1985636569351347658201,67453191674820837076801,2291422880374557112953025,77840924741060121003326041,2644300018315669557000132361,89828359697991704817001174225,3051519929713402294221039791281,103661849250557686298698351729321,3521451354589247931861522919005625,119625684206783871996993080894461921 seq $0,2315 ; NSW numbers: a(n) = 6*a(n-1) - a(n-2); also a(n)^2 - 2*b(n)^2 = -1 with b(n)=A001653(n+1). pow $0,2 div $0,2 add $0,1
#include "GvtCalculator.h" #include "Lp.h" #include "Log.h" #include "GvtRequestMessage.h" #include <spdlog/spdlog.h> GvtCalculator::GvtCalculator() { // Do nothing } GvtCalculator::GvtCalculator(Lp *pLp) : fLp(pLp), fColour(WHITE), fRedTime(ULONG_MAX), fIsAcceptingRequests(true) { fNextLpInRing = (pLp->GetRank() + 1) % pLp->GetSize(); fIsGVTStarter = pLp->GetRank() == 0; } GvtCalculator::~GvtCalculator() { // Do nothing } void GvtCalculator::ProcessMessage(const GvtRequestMessage *pGvtRequestMessage) { // Do nothing if we're not the the GVT starter (root node) if (!fIsGVTStarter) return; // Do nothing if we're not accepting requests for GVT if (!fIsAcceptingRequests) return; //Stop accepting further GVT request messages fIsAcceptingRequests = false; // Set colour to white fColour = WHITE; // Create control message GvtControlMessage *gvtControlMessage = new GvtControlMessage(); gvtControlMessage->SetOrigin(fLp->GetRank()); gvtControlMessage->SetDestination(fNextLpInRing); gvtControlMessage->SetMessageMinimumTime(LONG_MAX); gvtControlMessage->SetRedMessageTime(LONG_MAX); gvtControlMessage->SetMatternCut(FIRST); for (unsigned int nextLp = 0; nextLp < fLp->GetSize(); ++nextLp) { gvtControlMessage->SetMessageCount(nextLp, 0); } // Send control message to next in the ring gvtControlMessage->SendToLp(fLp); // Original GvtRequestMessage will be deleted elsewhere // New GvtControlMessage will be deleted after send } void GvtCalculator::ProcessMessage(const GvtValueMessage *pGvtValueMessage) { // Do nothing if this is the GVT starter, things have already been set if (fIsGVTStarter) return; // If GVT has reached end time, barrier if (pGvtValueMessage->GetGVT() >= fLp->GetEndTime()) { spdlog::info("GvtCalculator::ProcessGvt(rank={0})# GVT value ({1}) is greater or equal to end time ({2}), barrier!", fLp->GetRank(), pGvtValueMessage->GetGVT(), fLp->GetEndTime()); MPI_Barrier(MPI_COMM_WORLD); } // Set GVT at the LP fLp->SetGvt(pGvtValueMessage->GetGVT()); // Set colour to white for the next GVT check fColour = WHITE; } void GvtCalculator::ProcessMessage(const GvtControlMessage *pGvtControlMessage) { switch (pGvtControlMessage->GetMatternCut()) { case FIRST : ProcessFirstCutGvtControl(pGvtControlMessage); break; case SECOND : ProcessSecondCutGvtControl(pGvtControlMessage); break; } } MatternColour GvtCalculator::GetColour() const { return fColour; } void GvtCalculator::SetRedTime(unsigned long pRedTime) { fRedTime = pRedTime; } unsigned long GvtCalculator::GetRedTime() const { return fRedTime; } long GvtCalculator::GetWhiteTransientMessageCounter(unsigned int pRank) const { map<unsigned int, long>::const_iterator writeTransientMessageCounterIterator = fWhiteTransientMessageCounter.find( pRank); if (writeTransientMessageCounterIterator != fWhiteTransientMessageCounter.end()) return writeTransientMessageCounterIterator->second; else return -1; } void GvtCalculator::DecrementWhiteTransientMessageCounter(unsigned int pRank) { fWhiteTransientMessageCounter[pRank] -= 1; } void GvtCalculator::IncrementWhiteTransientMessageCounter(unsigned int pRank) { fWhiteTransientMessageCounter[pRank] += 1; } void GvtCalculator::ProcessFirstCutGvtControl( const GvtControlMessage *pGvtControlMessage) { //if (msg.cut == first) // add sent/received information to msg.transientVector // set msg.Lvt = min(msg.Lvt, this.Lvt) // if (we are the GvtStarter): // if (msg.transientVector parses to 0): // set this.colour = white // create GvtEndMessage // pass on GvtEndMessage to first in ring; // else: // set msg.cut = second // set this.colour = red // pass on message // else: // set this.colour = red // pass on message // Create new GVT control message GvtControlMessage *newGvtControlMessage = new GvtControlMessage(); *newGvtControlMessage = *pGvtControlMessage; // Set message minimum time if LP lvt is smaller if (fLp->GetLvt() < newGvtControlMessage->GetMessageMinimumTime()) newGvtControlMessage->SetMessageMinimumTime(fLp->GetLvt()); // Update transient vector information for (unsigned int lpCounter = 0; lpCounter < fLp->GetSize(); ++lpCounter) { long localCount = GetWhiteTransientMessageCounter(lpCounter); // Note, when lp == thisLp, localCount will be <= 0 long total = newGvtControlMessage->GetMessageCount(lpCounter) + localCount; newGvtControlMessage->SetMessageCount(lpCounter, total); } // Set colour to red fColour = RED; // Set local red time to max fRedTime = LONG_MAX; // For the GVT starter if (fIsGVTStarter) { bool hasWhiteTransientsRemaining = false; for (map<unsigned int, long>::iterator lpIterator = fWhiteTransientMessageCounter.begin(); lpIterator != fWhiteTransientMessageCounter.end(); ++lpIterator) { if (newGvtControlMessage->GetMessageCount(lpIterator->first) > 0) hasWhiteTransientsRemaining = true; } if (!hasWhiteTransientsRemaining) { // No white transients remaining, finish GVT update, just send the value // Set colour to white for next GVT check fColour = WHITE; // Calculate GVT, send round GVT value messages, deal with end time, // and set GVT at LP SendAndSetGvt(newGvtControlMessage); delete newGvtControlMessage; } else { // There are still white transient messages remaining // but we finished the first cut, start the second cut newGvtControlMessage->SetMatternCut(SECOND); newGvtControlMessage->SetDestination(fNextLpInRing); newGvtControlMessage->SendToLp(fLp); } } else { // We're not the GVT starter (root) node, so just continue with // the first cut newGvtControlMessage->SetDestination(fNextLpInRing); newGvtControlMessage->SendToLp(fLp); } } void GvtCalculator::ProcessSecondCutGvtControl( const GvtControlMessage *pGvtControlMessage) { // else if (msg.cut == second): // wait until (msg.transientVector[this] == 0) // set msg.Lvt = min(msg.Lvt, this.Lvt) // set msg.RED = min(msg.RED, this.RED) // set colour = white // if (we are GvtStarter): // create GvtEndMessage // pass on GvtEndMessage to first in ring // else: // pass on message // Copy GVT control message GvtControlMessage *newGvtControlMessage = new GvtControlMessage(); *newGvtControlMessage = *pGvtControlMessage; // Get number of outstanding messages long outstanding = newGvtControlMessage->GetMessageCount(fLp->GetRank()); // Process the still outstanding messages while (outstanding + GetWhiteTransientMessageCounter(fLp->GetRank()) > 0) { fLp->Unlock(); fLp->fMPIInterface->ReceiveWait(); fLp->Lock(); fLp->Receive(); } // All outstanding messages have been processed now // Update message and red times if (fLp->GetLvt() < newGvtControlMessage->GetMessageMinimumTime()) newGvtControlMessage->SetMessageMinimumTime(fLp->GetLvt()); if (fRedTime < newGvtControlMessage->GetRedMessageTime()) newGvtControlMessage->SetRedMessageTime(fRedTime); // Set the message count for this LP to 0 newGvtControlMessage->SetMessageCount(fLp->GetRank(), 0); // Reset colour to white for next GVT check fColour = WHITE; // If we're the GVT starter if (fIsGVTStarter) { // Calculate GVT, send round GVT value messages, deal with end time, and set GVT at LP SendAndSetGvt(newGvtControlMessage); delete newGvtControlMessage; } else { // We're not the start (root) node, so continue with the second cut newGvtControlMessage->SetDestination(fNextLpInRing); newGvtControlMessage->SendToLp(fLp); } } void GvtCalculator::SendAndSetGvt(const GvtControlMessage *pGvtControlMessage) { // Start accepting requests fIsAcceptingRequests = true; // Calculate GVT unsigned long gvt; if (pGvtControlMessage->GetMessageMinimumTime() < pGvtControlMessage->GetRedMessageTime()) gvt = pGvtControlMessage->GetMessageMinimumTime(); else gvt = pGvtControlMessage->GetRedMessageTime(); // Send round GVT value messages for (unsigned int lpCounter = 0; lpCounter < fLp->GetSize(); ++lpCounter) { if (lpCounter != fLp->GetRank()) { GvtValueMessage *gvtValueMessage = new GvtValueMessage(); gvtValueMessage->SetOrigin(fLp->GetRank()); gvtValueMessage->SetDestination(lpCounter); gvtValueMessage->SetGVT(gvt); gvtValueMessage->SendToLp(fLp); } } // If GVT has reached end time if (gvt >= fLp->GetEndTime()) { // Yield all control messages while (!fLp->fSendControlMessageQueue->IsEmpty()) { fLp->Unlock(); sched_yield(); fLp->Lock(); } // And barrier fLp->fMPIInterface->LockMpi(); MPI_Barrier(MPI_COMM_WORLD); fLp->fMPIInterface->UnlockMpi(); } // Set GVT at the Lp fLp->SetGvt(gvt); }
format PE GUI entry start include 'win32a.inc' section '.data' data readable writeable kernel32 dd ? target dd ? section '.text' code readable writeable executable start: mov eax, [fs:0x30] mov eax, [eax+0x0c] mov esi, [eax+0x14] lodsd ; xor esi, eax ; xor eax, esi ; xor esi, eax xchg esi, eax lodsd mov eax, [eax+0x10] mov [kernel32], eax push 0 push 'ss00' sub word[esp+0x2], '0' push 'ddre' push 'rocA' push 'GetP' push esp push [kernel32] call [GetProcAddress] mov [target], eax push [target] call sizeOfFunction push ebx push PAGE_EXECUTE_READWRITE push eax push [target] call [VirtualProtect] push PAGE_EXECUTE_READWRITE push MEM_COMMIT or MEM_RESERVE push shellcode.size push 0 call [VirtualAlloc] mov dword[hook+0x1], eax xor ecx, ecx searchCall: inc ecx mov eax, [target] add eax, ecx mov eax, [eax] cmp ax, 0x15FF jnz searchCall mov ebx, [target] add ebx, ecx mov eax, [ebx] mov [origcode], eax add ebx, 2 mov eax, [ebx] mov [origcode+2], eax mov ebx, [target] add ebx, ecx mov eax, [hook] mov dword[ebx], eax add ebx, 2 mov eax, [hook+0x2] mov dword[ebx], eax mov eax, [target] add eax, ecx mov [retCode+0x1], eax mov esi, shellcode mov edi, [hook+0x1] mov ecx, shellcode.size rep movsb call [target] ret hook: push target ret hook.size = $ - hook shellcode: mov eax, 0 origcode: rb 6 origcode.size = $ - origcode retCode: mov eax, 0x0 add eax, hook.size jmp eax shellcode.size = $ - shellcode sizeOfFunction: push ecx xor ecx, ecx lp: inc ecx mov eax, [esp+0x8] add eax, ecx mov eax, [eax] cmp ax, 0xCCCC jne lp mov eax, ecx pop ecx ret section '.idata' import readable writeable library kernel, 'kernel32.dll' import kernel,\ VirtualProtect, 'VirtualProtect',\ VirtualAlloc, 'VirtualAlloc',\ GetProcAddress, 'GetProcAddress'
.386 .model flat, stdcall option casemap :none ;; ASSEMBLING & LINKING ;; ml.exe main.asm /c ;; link /SUBSYSTEM:CONSOLE main.obj ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ;█▄ ▄█ ▄▄▀█▀▄▀█ ██ ██ █ ▄▀█ ▄▄█ ▄▄██ ;██ ██ ██ █ █▀█ ██ ██ █ █ █ ▄▄█▄▄▀██ ;█▀ ▀█▄██▄██▄██▄▄██▄▄▄█▄▄██▄▄▄█▄▄▄██ ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ includelib kernel32.lib ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ;██ ▄▄▀█▀▄▄▀█ ▄▄▀█ ▄▄█▄ ▄█ ▄▄▀█ ▄▄▀█▄ ▄█ ▄▄██ ;██ ████ ██ █ ██ █▄▄▀██ ██ ▀▀ █ ██ ██ ██▄▄▀██ ;██ ▀▀▄██▄▄██▄██▄█▄▄▄██▄██▄██▄█▄██▄██▄██▄▄▄██ ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ STD_OUT EQU -11 HEAP_ZERO_MEMORY EQU 8 ;; zero the allocated buffer ;;winnt.h GENERIC_READ EQU 80000000h GENERIC_WRITE EQU 40000000h GENERIC_EXECUTE EQU 20000000h GENERIC_ALL EQU 10000000h FILE_SHARED_READ EQU 1h FILE_OPEN_EXISTING EQU 3 FILE_ATTRIBUTE_NORMAL EQU 80h ;;handleapi.h INVALID_HANDLE_VALUE EQU -1 ;;fileapi.h INVALID_FILE_SIZE EQU -1 ;;ffffffffh ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ;██ ▄▄ █ ▄▄▀█▀▄▄▀█▄ ▄█▀▄▄▀█▄ ▄█ ██ █▀▄▄▀█ ▄▄█ ▄▄██ ;██ ▀▀ █ ▀▀▄█ ██ ██ ██ ██ ██ ██ ▀▀ █ ▀▀ █ ▄▄█▄▄▀██ ;██ ████▄█▄▄██▄▄███▄███▄▄███▄██▀▀▀▄█ ████▄▄▄█▄▄▄██ ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ;; === STD === ;; GetStdHandle PROTO STDCALL, fd:DWORD GetModuleHandleA PROTO STDCALL, module:PTR BYTE ExitProcess PROTO STDCALL, code:DWORD ;; === HEAP === ;; GetProcessHeap PROTO STDCALL HeapAlloc PROTO STDCALL, heap:DWORD, \ flags:DWORD, \ bytes:DWORD HeapFree PROTO STDCALL, heap:DWORD, \ flags:DWORD, \ mem:PTR BYTE ;; === FILES === ;; CreateFileA PROTO STDCALL, filename:PTR BYTE, \ desired_access:DWORD, \ share_mode:DWORD, \ security_attributes:PTR DWORD, \ creation_disposition:DWORD, \ flags:DWORD, \ template:DWORD CloseHandle PROTO STDCALL, handle:DWORD GetFileSize PROTO STDCALL, handle:DWORD, \ file_size_highdword:PTR DWORD WriteFile PROTO STDCALL, handle:DWORD, \ buffer:PTR BYTE, \ buffer_length:DWORD, \ written:PTR DWORD, \ overlapped:PTR BYTE ReadFile PROTO STDCALL, handle:DWORD, \ buffer:PTR BYTE, \ buffer_length:DWORD, \ bytes_read:PTR DWORD, \ overlapped:PTR BYTE ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ;█ ▄▀█ ▄▄▀█▄ ▄█ ▄▄▀███ ▄▄█ ▄▄█▀▄▀█▄ ▄██▄██▀▄▄▀█ ▄▄▀██ ;█ █ █ ▀▀ ██ ██ ▀▀ ███▄▄▀█ ▄▄█ █▀██ ███ ▄█ ██ █ ██ ██ ;█▄▄██▄██▄██▄██▄██▄███▄▄▄█▄▄▄██▄███▄██▄▄▄██▄▄██▄██▄██ ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ .data input_path db "../input", 0 ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ;█ ▄▀█ ▄▄▀█▄ ▄█ ▄▄▀█▄ ███ ▄▄█ ▄▄█▀▄▀█▄ ▄██▄██▀▄▄▀█ ▄▄▀██ ;█ █ █ ▀▀ ██ ██ ▀▀ █ ▄███▄▄▀█ ▄▄█ █▀██ ███ ▄█ ██ █ ██ ██ ;█▄▄██▄██▄██▄██▄██▄█▀████▄▄▄█▄▄▄██▄███▄██▄▄▄██▄▄██▄██▄██ ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ .data? ;; unitialized data heap dd ? ;; handle for the heap file dd ? ;; handle for the file file_size dd ? ;; size of the file bytes_read dd ? ;; n bytes from the file read into buffer buffer dd ? ;; ptr to a buffer with the file contents buffer2 dd ? ;; ptr to an array of ints ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ;█▀▄▀█▀▄▄▀█ ▄▀█ ▄▄███ ▄▄█ ▄▄█▀▄▀█▄ ▄██▄██▀▄▄▀█ ▄▄▀██ ;█ █▀█ ██ █ █ █ ▄▄███▄▄▀█ ▄▄█ █▀██ ███ ▄█ ██ █ ██ ██ ;██▄███▄▄██▄▄██▄▄▄███▄▄▄█▄▄▄██▄███▄██▄▄▄██▄▄██▄██▄██ ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ .code solve1 PROC, _entries:PTR DWORD, _n_ints:DWORD push eax push ebx push ecx push edx push edi mov ebx, _entries xor edi, edi outer_loop_1: mov eax, 2020 sub eax, [ebx] mov edx, 0 mov ecx, _entries inner_loop: cmp eax, [ecx] je solve1_found add ecx, 4 inc edx cmp edx, _n_ints je outer_loop_2 jmp inner_loop outer_loop_2: add ebx, 4 inc edi cmp edi, _n_ints je solve1_end jmp outer_loop_1 solve1_found: solve1_end: pop edi pop edx pop ecx pop ebx pop eax ret solve1 ENDP solve2 PROC, _entries:PTR DWORD, _n_ints:DWORD ret solve2 ENDP ;;----------------------------------------------------- ;; procedure to count the number of chars in a string ;; the string should be null terminated but the procedure ;; will also stop counting on \r\n bytes ;; the result is returned in EAX ;;----------------------------------------------------- strlen PROC, _string:PTR BYTE push esi push ebx xor eax, eax ;; char counter mov esi, _string ;; byte address strlen_count_loop: mov bl, BYTE PTR [esi] cmp bl, 0 ;; null terminated string je strlen_count_end cmp bl, 0dh ;; \r byte je strlen_count_end cmp bl, 0ah ;; \n byte je strlen_count_end inc esi inc eax jmp strlen_count_loop strlen_count_end: pop ebx pop esi ret strlen ENDP ;;----------------------------------------------------- ;; procedure to convert a number represented as a string ;; into an integer. The parsing stop whenever the proc ;; encounters a null char or a newline ;; the result is returned in EAX ;;----------------------------------------------------- atoi PROC, _string:PTR BYTE push esi push ebx xor eax, eax ;; stores result mov esi, _string ;; byte address atoi_loop: mov bl, BYTE PTR [esi] cmp bl, 0 ;; null terminated string je atoi_end cmp bl, 0dh ;; \r byte je atoi_end cmp bl, 0ah ;; \n byte je atoi_end imul eax, 10 sub bl, 30h ;; convert ascii digit to number add al, bl inc esi jmp atoi_loop atoi_end: pop ebx pop esi ret atoi ENDP ;;----------------------------------------------------- ;; procedure to count the number of newlines + EOF on ;; a buffer that represents the contents of a file ;; the register values are not saved nor cleaned ;; the result is returned in EAX ;;----------------------------------------------------- count_lines PROC, _buffer:PTR BYTE, _buffer_size:DWORD push ebx push ecx push edx push edi mov edx, _buffer_size ;; max iterations xor eax, eax ;; reset counter mov ecx, _buffer ;; base addr of buffer xor edi, edi ;; clear buffer, index start_counting: cmp edx, 0 ;; are there more bytes to read je end_counting ;; we are finished counting mov bl, BYTE PTR [ecx + edi] ;; read one more byte dec edx ;; one byte less to read inc edi ;; increment the index cmp bl, 0Ah ;; is a newline? jne start_counting ;; loop inc eax ;; newline found jmp start_counting ;; loop end_counting: inc eax ;; + EOF pop edi pop edx pop ecx pop ebx ret count_lines ENDP main: ;; setup the heap invoke GetProcessHeap cmp eax, 0 je exit mov heap, eax ;; open the input file invoke CreateFileA, addr input_path, GENERIC_READ, FILE_SHARED_READ, 0, FILE_OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 cmp eax, INVALID_HANDLE_VALUE je exit mov file, eax ;; get file size to allocate enough bytes invoke GetFileSize, file, 0 cmp eax, INVALID_FILE_SIZE je close_file mov file_size, eax ;; allocate a buffer for the file contents invoke HeapAlloc, heap, HEAP_ZERO_MEMORY, file_size cmp eax, 0 je close_file mov buffer, eax ;; read the file contents into the buffer invoke ReadFile, file, buffer, file_size, addr bytes_read, 0 cmp eax, 0 je free_buffer ;; allocate a buffer for an array of ints invoke count_lines, buffer, bytes_read mov ebx, 4 ;; 4 bytes per integer mul bx invoke HeapAlloc, heap, HEAP_ZERO_MEMORY, eax cmp eax, 0 je free_buffer mov buffer2, eax ;; populate the array of ints with the file contents invoke count_lines, buffer, bytes_read mov ecx, eax ;; number of ints to convert mov edi, buffer mov esi, buffer2 xor ebx, ebx convert_to_int_loop: invoke atoi, edi mov [esi], eax inc ebx add esi, 4 invoke strlen, edi add eax, 2 add edi, eax dec ecx cmp ecx, 0 jg convert_to_int_loop invoke solve1, buffer2, ebx invoke solve2, buffer2, ebx free_buffer2: invoke HeapFree, heap, 0, buffer2 cmp eax, 0 je free_buffer free_buffer: invoke HeapFree, heap, 0, buffer cmp eax, 0 je close_file close_file: invoke CloseHandle, file cmp eax, 0 je exit exit: invoke ExitProcess, 0 end main
; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; Scp Missile Edg Edg Lin Gun Exp Vtx Edg Bounty Face Edg Face Vertices ; Deb Lock Lo Hi x4 Vtx Cnt x6 X1 lo hi x4 Dot Erg Spd hi Hi Q Laser Lo hi Constrictor: DB $F3 DW $2649 DW ConstrictorEdges DB ConstrictorEdgesSize DB $00,$2E DB ConstrictorVertSize /6 DB ConstrictorVertSize DB ConstrictorEdgesCnt DB $18,$00 DB ConstrictorNormalsSize DB $2D,$C8,$37 DW ConstrictorNormals DB $02,$2F DW ConstrictorVertices DB 0,0 ; Type and Tactics ; missiles = 3 DB ShipCanAnger ConstrictorVertices DB $14, $07, $50, $5F, $02, $99 DB $14, $07, $50, $DF, $01, $99 DB $36, $07, $28, $DF, $14, $99 DB $36, $07, $28, $FF, $45, $89 DB $14, $0D, $28, $BF, $56, $88 DB $14, $0D, $28, $3F, $67, $88 DB $36, $07, $28, $7F, $37, $89 DB $36, $07, $28, $5F, $23, $99 DB $14, $0D, $05, $1F, $FF, $FF DB $14, $0D, $05, $9F, $FF, $FF DB $14, $07, $3E, $52, $99, $99 DB $14, $07, $3E, $D2, $99, $99 DB $19, $07, $19, $72, $99, $99 DB $19, $07, $19, $F2, $99, $99 DB $0F, $07, $0F, $6A, $99, $99 DB $0F, $07, $0F, $EA, $99, $99 DB $00, $07, $00, $40, $9F, $01 ConstrictorVertSize equ $ - ConstrictorVertices ConstrictorEdges DB $1F, $09, $00, $04, $1F, $19, $04, $08 DB $1F, $01, $04, $24, $1F, $02, $00, $20 DB $1F, $29, $00, $1C, $1F, $23, $1C, $20 DB $1F, $14, $08, $24, $1F, $49, $08, $0C DB $1F, $39, $18, $1C, $1F, $37, $18, $20 DB $1F, $67, $14, $20, $1F, $56, $10, $24 DB $1F, $45, $0C, $24, $1F, $58, $0C, $10 DB $1F, $68, $10, $14, $1F, $78, $14, $18 DB $1F, $89, $0C, $18, $1F, $06, $20, $24 DB $12, $99, $28, $30, $05, $99, $30, $38 DB $0A, $99, $38, $28, $0A, $99, $2C, $3C DB $05, $99, $34, $3C, $12, $99, $2C, $34 ConstrictorEdgesSize equ $ - ConstrictorEdges ConstrictorEdgesCnt equ ConstrictorEdgesSize/4 ConstrictorNormals DB $1F, $00, $37, $0F, $9F, $18, $4B, $14 DB $1F, $18, $4B, $14, $1F, $2C, $4B, $00 DB $9F, $2C, $4B, $00, $9F, $2C, $4B, $00 DB $1F, $00, $35, $00, $1F, $2C, $4B, $00 DB $3F, $00, $00, $A0, $5F, $00, $1B, $00 ConstrictorNormalsSize equ $ - ConstrictorNormals ConstrictorLen equ $ - Constrictor
#include "pch.h" #include "BrofilerDurangoTestMain.h" #include "Common\DirectXHelper.h" #include "Brofiler.h" using namespace BrofilerDurangoTest; using namespace Windows::Foundation; using namespace Windows::System::Threading; using namespace Concurrency; // Loads and initializes application assets when the application is loaded. BrofilerDurangoTestMain::BrofilerDurangoTestMain(const std::shared_ptr<DX::DeviceResources>& deviceResources) : m_deviceResources(deviceResources) { // Register to be notified if the Device is lost or recreated m_deviceResources->RegisterDeviceNotify(this); // TODO: Replace this with your app's content initialization. m_sceneRenderer = std::unique_ptr<Sample3DSceneRenderer>(new Sample3DSceneRenderer(m_deviceResources)); m_fpsTextRenderer = std::unique_ptr<SampleFpsTextRenderer>(new SampleFpsTextRenderer(m_deviceResources)); // TODO: Change the timer settings if you want something other than the default variable timestep mode. // e.g. for 60 FPS fixed timestep update logic, call: /* m_timer.SetFixedTimeStep(true); m_timer.SetTargetElapsedSeconds(1.0 / 60); */ } BrofilerDurangoTestMain::~BrofilerDurangoTestMain() { // Deregister device notification m_deviceResources->RegisterDeviceNotify(nullptr); } // Updates application state when the window size changes (e.g. device orientation change) void BrofilerDurangoTestMain::CreateWindowSizeDependentResources() { // TODO: Replace this with the size-dependent initialization of your app's content. m_sceneRenderer->CreateWindowSizeDependentResources(); } // Updates the application state once per frame. void BrofilerDurangoTestMain::Update() { BROFILER_CATEGORY("BrofilerDurangoTestMain::Update", Brofiler::Color::SkyBlue); // Update scene objects. m_timer.Tick([&]() { // TODO: Replace this with your app's content update functions. m_sceneRenderer->Update(m_timer); m_fpsTextRenderer->Update(m_timer); }); } // Renders the current frame according to the current application state. // Returns true if the frame was rendered and is ready to be displayed. bool BrofilerDurangoTestMain::Render() { BROFILER_CATEGORY("Render", Brofiler::Color::BurlyWood); // Don't try to render anything before the first Update. if (m_timer.GetFrameCount() == 0) { return false; } auto context = m_deviceResources->GetD3DDeviceContext(); // Reset the viewport to target the whole screen. auto viewport = m_deviceResources->GetScreenViewport(); context->RSSetViewports(1, &viewport); // Reset render targets to the screen. ID3D11RenderTargetView *const targets[1] = { m_deviceResources->GetBackBufferRenderTargetView() }; context->OMSetRenderTargets(1, targets, m_deviceResources->GetDepthStencilView()); // Clear the back buffer and depth stencil view. context->ClearRenderTargetView(m_deviceResources->GetBackBufferRenderTargetView(), DirectX::Colors::CornflowerBlue); context->ClearDepthStencilView(m_deviceResources->GetDepthStencilView(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); // Render the scene objects. // TODO: Replace this with your app's content rendering functions. m_sceneRenderer->Render(); m_fpsTextRenderer->Render(); return true; } // Notifies renderers that device resources need to be released. void BrofilerDurangoTestMain::OnDeviceLost() { m_sceneRenderer->ReleaseDeviceDependentResources(); m_fpsTextRenderer->ReleaseDeviceDependentResources(); } // Notifies renderers that device resources may now be recreated. void BrofilerDurangoTestMain::OnDeviceRestored() { m_sceneRenderer->CreateDeviceDependentResources(); m_fpsTextRenderer->CreateDeviceDependentResources(); CreateWindowSizeDependentResources(); }
; A260637: Sums of seven consecutive squares: a(n) = n^2 + (n+1)^2 + (n+2)^2 + (n+3)^2 + (n+4)^2 + (n+5)^2 + (n+6)^2. ; 28,35,56,91,140,203,280,371,476,595,728,875,1036,1211,1400,1603,1820,2051,2296,2555,2828,3115,3416,3731,4060,4403,4760,5131,5516,5915,6328,6755,7196,7651,8120,8603,9100,9611,10136,10675,11228,11795,12376,12971,13580,14203,14840,15491,16156,16835,17528,18235,18956,19691,20440,21203,21980,22771,23576,24395,25228,26075,26936,27811,28700,29603,30520,31451,32396,33355,34328,35315,36316,37331,38360,39403,40460,41531,42616,43715,44828,45955,47096,48251,49420,50603,51800,53011,54236,55475,56728,57995,59276,60571,61880,63203,64540,65891,67256,68635 pow $0,2 add $0,4 mul $0,7
/* * Copyright 2016 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "app/src/include/firebase/future.h" #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <ctime> #include <functional> #include <vector> #include "app/src/reference_counted_future_impl.h" #include "app/src/semaphore.h" #include "app/src/thread.h" #include "app/src/time.h" #include "gtest/gtest.h" #include "gmock/gmock.h" using ::testing::Eq; using ::testing::IsNull; using ::testing::Ne; using ::testing::NotNull; // Namespace to use to access library components under test. #if !defined(TEST_FIREBASE_NAMESPACE) #define TEST_FIREBASE_NAMESPACE firebase #endif // !defined(TEST_FIREBASE_NAMESPACE) namespace TEST_FIREBASE_NAMESPACE { namespace detail { namespace testing { struct TestResult { int number; std::string text; }; class FutureTest : public ::testing::Test { protected: enum FutureTestFn { kFutureTestFnOne, kFutureTestFnTwo, kFutureTestFnCount }; FutureTest() : future_impl_(kFutureTestFnCount) {} void SetUp() override { handle_ = future_impl_.SafeAlloc<TestResult>(); future_ = MakeFuture(&future_impl_, handle_); } public: ReferenceCountedFutureImpl future_impl_; SafeFutureHandle<TestResult> handle_; Future<TestResult> future_; }; // Some arbitrary result and error values. const int kResultNumber = 8675309; const int kResultError = -1729; const char* const kResultText = "Hello, world!"; // Check that a future can be completed by the same thread. TEST_F(FutureTest, TestFutureCompletesInSameThread) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_impl_.Complete<TestResult>(handle_, 0, [](TestResult* data) { data->number = kResultNumber; data->text = kResultText; }); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); } static void FutureCallback(TestResult* data) { data->number = kResultNumber; data->text = kResultText; } // Check that the future completion can be done with a callback function // instead of a lambda. TEST_F(FutureTest, TestFutureCompletesWithCallback) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_impl_.Complete<TestResult>(handle_, 0, FutureCallback); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); } // Check that the LastResult() futures are properly set and completed. TEST_F(FutureTest, TestLastResult) { const auto handle = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); Future<TestResult> future = static_cast<const Future<TestResult>&>( future_impl_.LastResult(kFutureTestFnOne)); EXPECT_THAT(future.status(), Eq(kFutureStatusPending)); future_impl_.Complete(handle, 0); EXPECT_THAT(future.status(), Eq(kFutureStatusComplete)); } // Check that CompleteWithResult() works (i.e. data copy instead of lambda). TEST_F(FutureTest, TestCompleteWithCopy) { TestResult result; result.number = kResultNumber; result.text = kResultText; future_impl_.CompleteWithResult<TestResult>(handle_, 0, result); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); } // Check that Complete() with a lambda works. TEST_F(FutureTest, TestCompleteWithLambda) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_impl_.Complete<TestResult>(handle_, 0, [](TestResult* data) { data->number = kResultNumber; data->text = kResultText; }); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); } // Check that Complete() with a lambda with a capture works. TEST_F(FutureTest, TestCompleteWithLambdaCapture) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); bool captured = true; future_impl_.Complete<TestResult>(handle_, 0, [&captured](TestResult* data) { data->number = kResultNumber; data->text = kResultText; captured = true; }); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); EXPECT_THAT(captured, Eq(true)); } // Test that the result of a Pending future is null. TEST_F(FutureTest, TestPendingResultIsNull) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future_.result(), IsNull()); EXPECT_THAT(future_.result_void(), IsNull()); } // Check that a future can be completed from another thread. TEST_F(FutureTest, TestFutureCompletesInAnotherThread) { Thread child( [](void* test_void) { FutureTest* test = static_cast<FutureTest*>(test_void); test->future_impl_.Complete<TestResult>(test->handle_, 0, [](TestResult* data) { data->number = kResultNumber; data->text = kResultText; }); }, this); child.Join(); // Blocks until the thread function is done EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); } // Check that the future error can be set. TEST_F(FutureTest, TestSettingErrorValue) { future_impl_.Complete(handle_, kResultError); EXPECT_THAT(future_.error(), Eq(kResultError)); } // Check that the void and typed results match. TEST_F(FutureTest, TestTypedAndVoidMatch) { future_impl_.Complete(handle_, kResultError); EXPECT_THAT(future_.result(), NotNull()); EXPECT_THAT(future_.result_void(), NotNull()); EXPECT_THAT(future_.result(), Eq(future_.result_void())); } TEST_F(FutureTest, TestReleasedBackingData) { FutureHandleId id; { Future<TestResult> future; { SafeFutureHandle<TestResult> handle = future_impl_.SafeAlloc<TestResult>(); EXPECT_TRUE(future_impl_.ValidFuture(handle)); id = handle.get().id(); EXPECT_TRUE(future_impl_.ValidFuture(id)); future = MakeFuture(&future_impl_, handle); EXPECT_TRUE(future_impl_.ValidFuture(handle)); EXPECT_TRUE(future_impl_.ValidFuture(id)); } EXPECT_TRUE(future_impl_.ValidFuture(id)); } EXPECT_FALSE(future_impl_.ValidFuture(id)); } TEST_F(FutureTest, TestDetachFutureHandle) { FutureHandleId id; { Future<TestResult> future; SafeFutureHandle<TestResult> handle = future_impl_.SafeAlloc<TestResult>(); EXPECT_TRUE(future_impl_.ValidFuture(handle)); id = handle.get().id(); EXPECT_TRUE(future_impl_.ValidFuture(id)); future = MakeFuture(&future_impl_, handle); EXPECT_TRUE(future_impl_.ValidFuture(handle)); EXPECT_TRUE(future_impl_.ValidFuture(id)); future = Future<TestResult>(); EXPECT_TRUE(future_impl_.ValidFuture(handle)); EXPECT_TRUE(future_impl_.ValidFuture(id)); handle.Detach(); EXPECT_FALSE(future_impl_.ValidFuture(handle)); EXPECT_FALSE(future_impl_.ValidFuture(id)); } EXPECT_FALSE(future_impl_.ValidFuture(id)); } // Test that a future becomes invalid when you release it. TEST_F(FutureTest, TestReleasedFutureGoesInvalid) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_.Release(); EXPECT_THAT(future_.status(), Eq(kFutureStatusInvalid)); } // Test that an invalid future returns an error. TEST_F(FutureTest, TestReleasedFutureHasError) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_.Release(); EXPECT_THAT(future_.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future_.error(), Ne(0)); } TEST_F(FutureTest, TestCompleteSetsStatusToComplete) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_impl_.Complete<TestResult>(handle_, 0, [](TestResult* data) { data->number = kResultNumber; data->text = kResultText; }); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); } // Can't mock a simple function pointer, so we use these globals to ensure // expectations about the callback running. static int g_callback_times_called = -99; static int g_callback_result_number = -99; static void* g_callback_user_data = nullptr; // Test whether an OnCompletion callback is called when the future is completed // with the templated version of Complete(). TEST_F(FutureTest, TestCallbackCalledWhenSettingResult) { g_callback_times_called = 0; g_callback_result_number = 0; // Set the callback before setting the status to complete. future_.OnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } // Test whether an AddOnCompletion callback is called when the future is // completed with the templated version of Complete(). TEST_F(FutureTest, TestAddCallbackCalledWhenSettingResult) { g_callback_times_called = 0; g_callback_result_number = 0; // Set the callback before setting the status to complete. future_.AddOnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } // Test whether an OnCompletion callback is called when the future is completed // with a lambda with a capture. TEST_F(FutureTest, TestCallbackCalledWithTypedLambdaCapture) { int callback_times_called = 0; int callback_result_number = 0; // Set the callback before setting the status to complete. future_.OnCompletion([&](const Future<TestResult>& result) { callback_times_called++; callback_result_number = result.result()->number; }); // Callback should not be called until it is completed. EXPECT_THAT(callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(callback_times_called, Eq(1)); EXPECT_THAT(callback_result_number, Eq(kResultNumber)); } // Test whether an AddOnCompletion callback is called when the future is // completed with a lambda with a capture. TEST_F(FutureTest, TestAddCallbackCalledWithTypedLambdaCapture) { int callback_times_called = 0; int callback_result_number = 0; // Set the callback before setting the status to complete. future_.AddOnCompletion([&](const Future<TestResult>& result) { callback_times_called++; callback_result_number = result.result()->number; }); // Callback should not be called until it is completed. EXPECT_THAT(callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(callback_times_called, Eq(1)); EXPECT_THAT(callback_result_number, Eq(kResultNumber)); } // Test whether an OnCompletion callback is called when the future is completed // with a lambda with a capture. TEST_F(FutureTest, TestCallbackCalledWithBaseLambdaCapture) { int callback_times_called = 0; // Set the callback before setting the status to complete. static_cast<FutureBase>(future_).OnCompletion( [&](const FutureBase& result) { callback_times_called++; }); // Callback should not be called until it is completed. EXPECT_THAT(callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(callback_times_called, Eq(1)); } // Test whether an AddOnCompletion callback is called when the future is // completed with a lambda with a capture. TEST_F(FutureTest, TestAddCallbackCalledWithBaseLambdaCapture) { int callback_times_called = 0; // Set the callback before setting the status to complete. static_cast<FutureBase>(future_).AddOnCompletion( [&](const FutureBase& result) { callback_times_called++; }); // Callback should not be called until it is completed. EXPECT_THAT(callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(callback_times_called, Eq(1)); } void OnCompletionCallback(const Future<TestResult>& result, void* /*user_data*/) { g_callback_times_called++; g_callback_result_number = result.result()->number; } // Test whether an OnCompletion callback is called when the callback is a // function pointer instead of a lambda. TEST_F(FutureTest, TestCallbackCalledWhenFunctionPointer) { g_callback_times_called = 0; g_callback_result_number = 0; // Set the callback before setting the status to complete. future_.OnCompletion(OnCompletionCallback, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } // Test whether an AddOnCompletion callback is called when the callback is a // function pointer instead of a lambda. TEST_F(FutureTest, TestAddCallbackCalledWhenFunctionPointer) { g_callback_times_called = 0; g_callback_result_number = 0; // Set the callback before setting the status to complete. future_.AddOnCompletion(OnCompletionCallback, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } // Test whether an OnCompletion callback is called when the future is completed // with the non-templated version of Complete(). TEST_F(FutureTest, TestCallbackCalledWhenNotSettingResults) { g_callback_times_called = 0; // Set the callback before setting the status to complete. future_.OnCompletion([](const Future<TestResult>& result, void*) { g_callback_times_called++; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(1)); } // Test whether an AddOnCompletion callback is called when the future is // completed with the non-templated version of Complete(). TEST_F(FutureTest, TestAddCallbackCalledWhenNotSettingResults) { g_callback_times_called = 0; // Set the callback before setting the status to complete. future_.AddOnCompletion([](const Future<TestResult>& result, void*) { g_callback_times_called++; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(1)); } // Test whether an OnCompletion callback is called even if the future was // already completed before OnCompletion() was called. TEST_F(FutureTest, TestCallbackCalledWhenAlreadyComplete) { g_callback_times_called = 0; g_callback_result_number = 0; future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); // Callback should not be called until the callback is set. EXPECT_THAT(g_callback_times_called, Eq(0)); // Set the callback *after* the future was already completed. future_.OnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Ensure the callback was still called. EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } // Test whether an AddOnCompletion callback is called even if the future was // already completed before AddOnCompletion() was set. TEST_F(FutureTest, TestAddCallbackCalledWhenAlreadyComplete) { g_callback_times_called = 0; g_callback_result_number = 0; future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); // Callback should not be called until the callback is set. EXPECT_THAT(g_callback_times_called, Eq(0)); // Set the callback *after* the future was already completed. future_.AddOnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Ensure the callback was still called. EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } TEST_F(FutureTest, TestCallbackCalledFromAnotherThread) { g_callback_times_called = 0; g_callback_result_number = 0; future_.OnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); Thread child( [](void* test_void) { FutureTest* test = static_cast<FutureTest*>(test_void); test->future_impl_.Complete<TestResult>( test->handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); }, this); child.Join(); // Blocks until the thread function is done // Ensure the callback was still called. EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } TEST_F(FutureTest, TestAddCallbackCalledFromAnotherThread) { g_callback_times_called = 0; g_callback_result_number = 0; future_.AddOnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); Thread child( [](void* test_void) { FutureTest* test = static_cast<FutureTest*>(test_void); test->future_impl_.Complete<TestResult>( test->handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); }, this); child.Join(); // Blocks until the fiber function is done // Ensure the callback was still called. EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } TEST_F(FutureTest, TestCallbackUserData) { g_callback_times_called = 0; g_callback_user_data = nullptr; future_.OnCompletion( [](const Future<TestResult>&, void* user_data) { g_callback_times_called++; g_callback_user_data = user_data; }, this); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_user_data, Eq(this)); } TEST_F(FutureTest, TestAddCallbackUserData) { g_callback_times_called = 0; g_callback_user_data = nullptr; future_.AddOnCompletion( [](const Future<TestResult>&, void* user_data) { g_callback_times_called++; g_callback_user_data = user_data; }, this); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_user_data, Eq(this)); } TEST_F(FutureTest, TestCallbackUserDataFromBaseClass) { g_callback_times_called = 0; g_callback_user_data = nullptr; static_cast<FutureBase>(future_).OnCompletion( [](const FutureBase&, void* user_data) { g_callback_times_called++; g_callback_user_data = user_data; }, this); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_user_data, Eq(this)); } TEST_F(FutureTest, TestAddCallbackUserDataFromBaseClass) { g_callback_times_called = 0; g_callback_user_data = nullptr; static_cast<FutureBase>(future_).AddOnCompletion( [](const FutureBase&, void* user_data) { g_callback_times_called++; g_callback_user_data = user_data; }, this); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_user_data, Eq(this)); } TEST_F(FutureTest, TestUntypedCallback) { g_callback_times_called = 0; g_callback_result_number = 0; static_cast<FutureBase>(future_).OnCompletion( [](const FutureBase& untyped_result, void*) { g_callback_times_called++; const Future<TestResult>& typed_result = reinterpret_cast<const Future<TestResult>&>(untyped_result); g_callback_result_number = typed_result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } TEST_F(FutureTest, TestAddUntypedCallback) { g_callback_times_called = 0; g_callback_result_number = 0; static_cast<FutureBase>(future_).AddOnCompletion( [](const FutureBase& untyped_result, void*) { g_callback_times_called++; const Future<TestResult>& typed_result = reinterpret_cast<const Future<TestResult>&>(untyped_result); g_callback_result_number = typed_result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } // Test that you can deal with many simultaneous Futures at once. TEST_F(FutureTest, TestSimultaneousFutures) { const int kMilliseconds = 1000; const int kNumToTest = 100; // Initialize a bunch of futures and threads. std::vector<SafeFutureHandle<TestResult>> handles_; std::vector<Future<TestResult>> futures_; std::vector<Thread*> children_; struct Context { FutureTest* test; SafeFutureHandle<TestResult> handle; int test_number; } thread_context[kNumToTest]; for (int i = 0; i < kNumToTest; i++) { auto handle = future_impl_.SafeAlloc<TestResult>(); handles_.push_back(handle); futures_.push_back(MakeFuture(&future_impl_, handle)); auto* context = &thread_context[i]; context->test = this; context->handle = handle; context->test_number = i; children_.push_back(new Thread( [](void* current_context_void) { Context* current_context = static_cast<Context*>(current_context_void); // Each thread should wait a moment, then set the result and // complete. internal::Sleep(rand() % kMilliseconds); // NOLINT current_context->test->future_impl_.Complete<TestResult>( current_context->handle, 0, [current_context](TestResult* data) { data->number = kResultNumber + current_context->test_number; }); }, context)); } // Give threads time to run. internal::Sleep(kMilliseconds); // Check that each future completed successfully, then clean it up. for (int i = 0; i < kNumToTest; i++) { children_[i]->Join(); EXPECT_THAT(futures_[i].result()->number, Eq(kResultNumber + i)); delete children_[i]; children_[i] = nullptr; } } TEST_F(FutureTest, TestCallbackOnFutureOutOfScope) { g_callback_times_called = 0; g_callback_result_number = 0; // Set the callback before setting the status to complete. future_.OnCompletion( [](const Future<TestResult>& result, void*) { g_callback_times_called++; g_callback_result_number = result.result()->number; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_ = Future<TestResult>(); handle_.Detach(); // The Future we were holding onto is now out of scope. future_impl_.Complete<TestResult>( handle_, 0, [](TestResult* data) { data->number = kResultNumber; }); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_result_number, Eq(kResultNumber)); } TEST_F(FutureTest, TestOverridingHandle) { // Ensure that FutureHandles can't be deallocated while still in use. // Generally, do this by allocating a handle into a function slot, then // allocating another handle into the same slot, and then creating a future // from the first handle. If all goes well it should be fine, but if the // handle was deallocated then making a future from it will fail. { // Basic test, create 2 FutureHandles in the same slot, then make Future // instances from both. SafeFutureHandle<TestResult> handle1 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); SafeFutureHandle<TestResult> handle2 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); Future<TestResult> future1 = MakeFuture(&future_impl_, handle1); EXPECT_EQ(future1.status(), kFutureStatusPending); Future<TestResult> future2 = MakeFuture(&future_impl_, handle2); EXPECT_EQ(future2.status(), kFutureStatusPending); } { // Same as above, but complete the first Future and make sure it doesn't // affect the second. SafeFutureHandle<TestResult> handle1 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); SafeFutureHandle<TestResult> handle2 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); future_impl_.Complete<TestResult>( handle1, 0, [](TestResult* data) { data->number = kResultNumber; }); Future<TestResult> future1 = MakeFuture(&future_impl_, handle1); EXPECT_EQ(future1.status(), kFutureStatusComplete); EXPECT_EQ(future1.result()->number, kResultNumber); Future<TestResult> future2 = MakeFuture(&future_impl_, handle2); EXPECT_EQ(future2.status(), kFutureStatusPending); } { // Complete the second Future and make sure it doesn't affect the first. SafeFutureHandle<TestResult> handle1 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); SafeFutureHandle<TestResult> handle2 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); future_impl_.Complete<TestResult>( handle2, 0, [](TestResult* data) { data->number = kResultNumber; }); Future<TestResult> future1 = MakeFuture(&future_impl_, handle1); EXPECT_EQ(future1.status(), kFutureStatusPending); Future<TestResult> future2 = MakeFuture(&future_impl_, handle2); EXPECT_EQ(future2.status(), kFutureStatusComplete); EXPECT_EQ(future2.result()->number, kResultNumber); } { // Ensure that both Futures can be completed with different result values. SafeFutureHandle<TestResult> handle1 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); SafeFutureHandle<TestResult> handle2 = future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); future_impl_.Complete<TestResult>( handle1, 0, [](TestResult* data) { data->number = kResultNumber; }); future_impl_.Complete<TestResult>( handle2, 0, [](TestResult* data) { data->number = 2 * kResultNumber; }); Future<TestResult> future1 = MakeFuture(&future_impl_, handle1); EXPECT_EQ(future1.status(), kFutureStatusComplete); EXPECT_EQ(future1.result()->number, kResultNumber); Future<TestResult> future2 = MakeFuture(&future_impl_, handle2); EXPECT_EQ(future2.status(), kFutureStatusComplete); EXPECT_EQ(future2.result()->number, 2 * kResultNumber); } } TEST_F(FutureTest, TestHighQps) { const int kNumToTest = 10000; future_ = Future<TestResult>(); std::vector<Thread*> children_; for (int i = 0; i < kNumToTest; i++) { children_.push_back(new Thread( [](void* this_void) { FutureTest* this_ = reinterpret_cast<FutureTest*>(this_void); SafeFutureHandle<TestResult> handle = this_->future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); this_->future_impl_.Complete<TestResult>( handle, 0, [](TestResult* data) { data->number = kResultNumber; }); Future<TestResult> future = MakeFuture(&this_->future_impl_, handle); }, this)); } for (int i = 0; i < kNumToTest; i++) { children_[i]->Join(); delete children_[i]; children_[i] = nullptr; } } // Test that accessing a future as const compiles. TEST_F(FutureTest, TestConstFuture) { g_callback_times_called = 0; const Future<TestResult> const_future = future_; // Set the callback before setting the status to complete. const_future.OnCompletion([](const Future<TestResult>& result, void*) { g_callback_times_called++; }, nullptr); const_future.AddOnCompletion([](const Future<TestResult>& result, void*) { g_callback_times_called++; }, nullptr); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(2)); } // Test that we can remove an AddOnCompletion callback using RemoveOnCompletion. TEST_F(FutureTest, TestAddCompletionCallbackRemoval) { g_callback_times_called = 0; auto callback_handle = future_.AddOnCompletion( [&](const Future<TestResult>&) { ++g_callback_times_called; }); future_.RemoveOnCompletion(callback_handle); future_impl_.Complete(handle_, 0); EXPECT_THAT(g_callback_times_called, Eq(0)); } // Test that multiple callbacks are called in the documented order, // and that OnCompletion() doesn't interfere with AddOnCompletion() // and vice versa. TEST_F(FutureTest, TestCallbackOrdering) { std::vector<int> ordered_results; // Set the callback before setting the status to complete. future_.AddOnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(5); }); future_.AddOnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(4); }); auto callback_handle = future_.AddOnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(3); }); future_.OnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(-3); }); future_.AddOnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(2); }); future_.OnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(-2); }); future_.OnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(-1); }); future_.AddOnCompletion( [&](const Future<TestResult>&) { ordered_results.push_back(1); }); future_.RemoveOnCompletion(callback_handle); // Callback should not be called until it is completed. EXPECT_THAT(ordered_results, Eq(std::vector<int>{})); future_impl_.Complete(handle_, 0); // The last OnCompletionCallback (-1) should get called before AddOnCompletion // callbacks, and the AddOnCompletion callbacks should get called in // the order that they were registered (5, 4, 3, 2, 1), except that callbacks // which have been removed (3) should not be called. EXPECT_THAT(ordered_results, Eq(std::vector<int>{-1, 5, 4, 2, 1})); } // Verify futures are not leaked when copied, using the implicit memory leak // checker. When futures are allocated in the same LastResult function slot, a // new handle should be allocated the old handle should be removed and hence be // invalid. TEST_F(FutureTest, VerifyNotLeakedWhenOverridden) { FutureHandleId id; { SafeFutureHandle<TestResult> last_result_handle; last_result_handle = future_impl_.SafeAlloc<TestResult>(0); EXPECT_THAT(last_result_handle.get(), Ne(SafeFutureHandle<TestResult>::kInvalidHandle.get())); EXPECT_TRUE(future_impl_.ValidFuture(last_result_handle)); id = last_result_handle.get().id(); } { auto new_last_result_handle = future_impl_.SafeAlloc<TestResult>(0); EXPECT_THAT(new_last_result_handle.get(), Ne(SafeFutureHandle<TestResult>::kInvalidHandle.get())); EXPECT_FALSE(future_impl_.ValidFuture(id)); } } // Verify that trying to complete a future twice causes death. TEST_F(FutureTest, VerifyCompletingFutureTwiceAsserts) { EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); future_impl_.Complete(handle_, 0); EXPECT_DEATH(future_impl_.Complete(handle_, 0), "SIGABRT"); } // Verify that IsSafeToDelete() return the correct value. TEST_F(FutureTest, VerifyIsSafeToDelete) { { ReferenceCountedFutureImpl impl(kFutureTestFnCount); EXPECT_TRUE(impl.IsSafeToDelete()); } // Test if a FutureHandle is allocated but no external Future has ever // reference it. // Note: This will result in a warning message "Future with handle x still // exists though its backing API y is being deleted" because there is no // chance to remove the backing at all. { ReferenceCountedFutureImpl impl(kFutureTestFnCount); { auto handle_pending = impl.SafeAlloc<TestResult>(); EXPECT_FALSE(impl.IsSafeToDelete()); impl.Complete(handle_pending, 0); } EXPECT_TRUE(impl.IsSafeToDelete()); } // Test if a FutureHandle is allocated and an external Future has referenced // it. { ReferenceCountedFutureImpl impl(kFutureTestFnCount); { auto handle_complete = impl.SafeAlloc<TestResult>(); EXPECT_FALSE(impl.IsSafeToDelete()); Future<TestResult>* future = new Future<TestResult>(&impl, handle_complete.get()); EXPECT_FALSE(impl.IsSafeToDelete()); delete future; } // This is true because ReferenceCountedFutureImpl::last_results_ never // keeps a copy of this future. That is, the backing will be deleted when // the future above is deleted. EXPECT_TRUE(impl.IsSafeToDelete()); } // Test if a FutureHandle is allocated with function id but no external // Future has ever reference it. { ReferenceCountedFutureImpl impl(kFutureTestFnCount); { auto handle_fn_pending = impl.SafeAlloc<TestResult>(kFutureTestFnOne); EXPECT_FALSE(impl.IsSafeToDelete()); impl.Complete(handle_fn_pending, 0); } EXPECT_TRUE(impl.IsSafeToDelete()); } // Test if a FutureHandle is allocated with function id and an external Future // has referenced it. { ReferenceCountedFutureImpl impl(kFutureTestFnCount); auto handle_fn_complete = impl.SafeAlloc<TestResult>(kFutureTestFnOne); EXPECT_FALSE(impl.IsSafeToDelete()); Future<TestResult>* future = new Future<TestResult>(&impl, handle_fn_complete.get()); EXPECT_FALSE(impl.IsSafeToDelete()); delete future; // This is false because ReferenceCountedFutureImpl::last_results_ keeps // a copy of this future. EXPECT_FALSE(impl.IsSafeToDelete()); impl.Complete(handle_fn_complete, 0); EXPECT_TRUE(impl.IsSafeToDelete()); } // Test that a ReferenceCountedFutureImpl isn't considered for deletion while // it's running a user callback. { ReferenceCountedFutureImpl impl(kFutureTestFnCount); auto handle = impl.SafeAlloc<TestResult>(kFutureTestFnOne); EXPECT_FALSE(impl.IsSafeToDelete()); Future<TestResult> future = MakeFuture(&impl, handle); EXPECT_FALSE(impl.IsSafeToDelete()); Semaphore semaphore(0); future.OnCompletion([&](const Future<TestResult>& future) { EXPECT_FALSE(impl.IsSafeToDelete()); // Because the callback is running. semaphore.Post(); }); future.Release(); EXPECT_FALSE(impl.IsSafeToDelete()); impl.Complete(handle, 0, ""); semaphore.Wait(); // Note: despite the semaphore, the check for `impl.IsSafeToDelete` is racy // (it could be false if the check happens in-between when the semaphore // posts the signal and when user callback actually finishes running), which // necessitates sleeping. const int kSleepTimeMs = 50; int timeout_left = 1000; while (!impl.IsSafeToDelete() && timeout_left >= 0) { timeout_left -= kSleepTimeMs; internal::Sleep(kSleepTimeMs); } EXPECT_TRUE(impl.IsSafeToDelete()); } // Like the test above, but with AddOnCompletion instead of OnCompletion. { ReferenceCountedFutureImpl impl(kFutureTestFnCount); auto handle = impl.SafeAlloc<TestResult>(kFutureTestFnOne); EXPECT_FALSE(impl.IsSafeToDelete()); Future<TestResult> future = MakeFuture(&impl, handle); EXPECT_FALSE(impl.IsSafeToDelete()); Semaphore semaphore(0); future.AddOnCompletion([&](const Future<TestResult>& future) { EXPECT_FALSE(impl.IsSafeToDelete()); // Because the callback is running. semaphore.Post(); }); future.Release(); EXPECT_FALSE(impl.IsSafeToDelete()); impl.Complete(handle, 0, ""); semaphore.Wait(); // Note: despite the semaphore, the check for `impl.IsSafeToDelete` is racy // (it could be false if the check happens in-between when the semaphore // posts the signal and when user callback actually finishes running), which // necessitates sleeping. const int kSleepTimeMs = 50; int timeout_left = 1000; while (!impl.IsSafeToDelete() && timeout_left >= 0) { timeout_left -= kSleepTimeMs; internal::Sleep(kSleepTimeMs); } EXPECT_TRUE(impl.IsSafeToDelete()); } } // Verify that IsReferencedExternally() returns the correct value. TEST_F(FutureTest, VerifyIsReferencedExternally) { { ReferenceCountedFutureImpl impl(kFutureTestFnCount); EXPECT_FALSE(impl.IsReferencedExternally()); } { ReferenceCountedFutureImpl impl(kFutureTestFnCount); { EXPECT_FALSE(impl.IsReferencedExternally()); auto handle = impl.SafeAlloc<TestResult>(); EXPECT_TRUE(impl.IsReferencedExternally()); Future<TestResult>* future = new Future<TestResult>(&impl, handle.get()); EXPECT_TRUE(impl.IsReferencedExternally()); delete future; } EXPECT_FALSE(impl.IsReferencedExternally()); } { ReferenceCountedFutureImpl impl(kFutureTestFnCount); { EXPECT_FALSE(impl.IsReferencedExternally()); auto handle = impl.SafeAlloc<TestResult>(); EXPECT_TRUE(impl.IsReferencedExternally()); Future<TestResult>* future = new Future<TestResult>(&impl, handle.get()); EXPECT_TRUE(impl.IsReferencedExternally()); impl.Complete(handle, 0); EXPECT_TRUE(impl.IsReferencedExternally()); delete future; } EXPECT_FALSE(impl.IsReferencedExternally()); } { ReferenceCountedFutureImpl impl(kFutureTestFnCount); { EXPECT_FALSE(impl.IsReferencedExternally()); auto handle = impl.SafeAlloc<TestResult>(kFutureTestFnOne); EXPECT_TRUE(impl.IsReferencedExternally()); { Future<TestResult>* future = new Future<TestResult>(&impl, handle.get()); delete future; } EXPECT_TRUE(impl.IsReferencedExternally()); handle.Detach(); EXPECT_FALSE(impl.IsReferencedExternally()); } EXPECT_FALSE(impl.IsReferencedExternally()); } } // Verify that when a ReferenceCountedFutureImpl is deleted, any // Futures it gave out are invalidated (rather than crashing). TEST_F(FutureTest, VerifyFutureInvalidatedWhenImplIsDeleted) { Future<TestResult> future_pending, future_complete, future_fn_pending, future_fn_complete, future_invalid; { ReferenceCountedFutureImpl impl(kFutureTestFnCount); // Allocate a variety of futures, completing some of them. SafeFutureHandle<TestResult> handle_pending, handle_complete, handle_fn_pending, handle_fn_complete; handle_pending = impl.SafeAlloc<TestResult>(); future_pending = MakeFuture(&impl, handle_pending); handle_complete = impl.SafeAlloc<TestResult>(); future_complete = MakeFuture(&impl, handle_complete); impl.Complete(handle_complete, 0); handle_fn_pending = impl.SafeAlloc<TestResult>(kFutureTestFnOne); future_fn_pending = MakeFuture(&impl, handle_fn_pending); handle_fn_complete = impl.SafeAlloc<TestResult>(kFutureTestFnTwo); future_fn_complete = MakeFuture(&impl, handle_fn_complete); impl.Complete(handle_fn_complete, 0); EXPECT_THAT(future_invalid.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future_pending.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future_complete.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_fn_pending.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future_fn_complete.status(), Eq(kFutureStatusComplete)); } // Ensure that all different types/statuses of future are now invalid. EXPECT_THAT(future_invalid.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future_pending.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future_complete.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future_fn_pending.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future_fn_complete.status(), Eq(kFutureStatusInvalid)); } // Verify that Future instances are cleaned up properly even if they've // been copied and moved, even between FutureImpls, or released. TEST_F(FutureTest, TestCleaningUpFuturesThatWereCopied) { Future<TestResult> future1, future2, future3; Future<TestResult> copy, move, release; Future<TestResult> move_c, copy_c; // Constructor versions. { ReferenceCountedFutureImpl impl_a(kFutureTestFnCount); { ReferenceCountedFutureImpl impl_b(kFutureTestFnCount); // Allocate a variety of futures, completing some of them. SafeFutureHandle<TestResult> handle1, handle2, handle3; handle1 = impl_a.SafeAlloc<TestResult>(); future1 = MakeFuture(&impl_a, handle1); handle2 = impl_a.SafeAlloc<TestResult>(); future2 = MakeFuture(&impl_a, handle2); handle3 = impl_b.SafeAlloc<TestResult>(); future3 = MakeFuture(&impl_b, handle3); EXPECT_THAT(future1.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future2.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future3.status(), Eq(kFutureStatusPending)); EXPECT_THAT(copy.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(move.status(), Eq(kFutureStatusInvalid)); // Make some copies/moves. copy = future3; move = std::move(future3); EXPECT_THAT(copy.status(), Eq(kFutureStatusPending)); EXPECT_THAT(move.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future3.status(), Eq(kFutureStatusInvalid)); // NOLINT future1 = copy; future2 = move; // actually a copy EXPECT_THAT(future1.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future2.status(), Eq(kFutureStatusPending)); release = copy; EXPECT_THAT(copy.status(), Eq(kFutureStatusPending)); EXPECT_THAT(release.status(), Eq(kFutureStatusPending)); release.Release(); EXPECT_THAT(future1.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future2.status(), Eq(kFutureStatusPending)); EXPECT_THAT(copy.status(), Eq(kFutureStatusPending)); EXPECT_THAT(move.status(), Eq(kFutureStatusPending)); EXPECT_THAT(release.status(), Eq(kFutureStatusInvalid)); // Ensure that the move/copy constructors also work. Future<TestResult> move_constructor(std::move(move)); Future<TestResult> copy_constructor(copy); EXPECT_THAT(copy_constructor.status(), Eq(kFutureStatusPending)); EXPECT_THAT(copy.status(), Eq(kFutureStatusPending)); EXPECT_THAT(move_constructor.status(), Eq(kFutureStatusPending)); move_c = std::move(move_constructor); copy_c = copy_constructor; EXPECT_THAT(copy_c.status(), Eq(kFutureStatusPending)); EXPECT_THAT(copy_constructor.status(), Eq(kFutureStatusPending)); EXPECT_THAT(copy.status(), Eq(kFutureStatusPending)); EXPECT_THAT(move_c.status(), Eq(kFutureStatusPending)); } // Ensure that all Futures are now invalid. EXPECT_THAT(future1.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future2.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(future3.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(copy.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(move.status(), Eq(kFutureStatusInvalid)); // NOLINT EXPECT_THAT(copy_c.status(), Eq(kFutureStatusInvalid)); EXPECT_THAT(move_c.status(), Eq(kFutureStatusInvalid)); } } // Test Wait() method (without callback), with infinite timeout. TEST_F(FutureTest, TestFutureWaitInfinite) { Semaphore semaphore(0); using This = decltype(this); struct ThreadArgs { This test_fixture; Semaphore* semaphore; } args{this, &semaphore}; Thread child( [](ThreadArgs* args_ptr) { args_ptr->semaphore->Wait(); // Wait until main thread is ready. args_ptr->test_fixture->future_impl_.Complete<TestResult>( args_ptr->test_fixture->handle_, 0, [&](TestResult* data) { internal::Sleep(/*milliseconds=*/100); data->number = kResultNumber; data->text = kResultText; }); }, &args); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); semaphore.Post(); // Allow other thread to continue. future_.Wait(FutureBase::kWaitTimeoutInfinite); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); ASSERT_THAT(future_.result(), Ne(nullptr)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); child.Join(); // Clean up. } // Test Wait() method with callback, with infinite timeout. TEST_F(FutureTest, TestFutureWaitWithCallback) { g_callback_times_called = 0; g_callback_user_data = nullptr; future_.OnCompletion( [](const Future<TestResult>&, void* user_data) { g_callback_times_called++; g_callback_user_data = user_data; }, this); // Callback should not be called until it is completed. EXPECT_THAT(g_callback_times_called, Eq(0)); Semaphore semaphore(0); using This = decltype(this); struct ThreadArgs { This test_fixture; Semaphore* semaphore; } args{this, &semaphore}; Thread child( [](ThreadArgs* args_ptr) { args_ptr->semaphore->Wait(); // Wait until main thread is ready. args_ptr->test_fixture->future_impl_.Complete<TestResult>( args_ptr->test_fixture->handle_, 0, [&](TestResult* data) { internal::Sleep(/*milliseconds=*/100); data->number = kResultNumber; data->text = kResultText; }); }, &args); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); semaphore.Post(); // Allow other thread to continue. future_.Wait(FutureBase::kWaitTimeoutInfinite); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); ASSERT_THAT(future_.result(), Ne(nullptr)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); EXPECT_THAT(g_callback_times_called, Eq(1)); EXPECT_THAT(g_callback_user_data, Eq(this)); child.Join(); // Clean up. } // Test Wait() method with lambda callback. TEST_F(FutureTest, TestFutureWaitWithCallbackLambda) { int callback_times_called = 0; future_.OnCompletion( [&](const Future<TestResult>&) { callback_times_called++; }); // Callback should not be called until it is completed. EXPECT_THAT(callback_times_called, Eq(0)); Semaphore semaphore(0); using This = decltype(this); struct ThreadArgs { This test_fixture; Semaphore* semaphore; } args{this, &semaphore}; Thread child( [](ThreadArgs* args_ptr) { args_ptr->semaphore->Wait(); // Wait until main thread is ready. args_ptr->test_fixture->future_impl_.Complete<TestResult>( args_ptr->test_fixture->handle_, 0, [&](TestResult* data) { internal::Sleep(/*milliseconds=*/100); data->number = kResultNumber; data->text = kResultText; }); }, &args); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); semaphore.Post(); // Allow other thread to continue. future_.Wait(FutureBase::kWaitTimeoutInfinite); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); ASSERT_THAT(future_.result(), Ne(nullptr)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); EXPECT_THAT(callback_times_called, Eq(1)); child.Join(); // Clean up. } // Test Await() method, with infinite timeout. TEST_F(FutureTest, TestFutureAwait) { Semaphore semaphore(0); using This = decltype(this); struct ThreadArgs { This test_fixture; Semaphore* semaphore; } args{this, &semaphore}; Thread child( [](ThreadArgs* args_ptr) { args_ptr->semaphore->Wait(); // Wait until main thread is ready. args_ptr->test_fixture->future_impl_.Complete<TestResult>( args_ptr->test_fixture->handle_, 0, [&](TestResult* data) { internal::Sleep(/*milliseconds=*/100); data->number = kResultNumber; data->text = kResultText; }); }, &args); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); semaphore.Post(); // Allow other thread to continue. const TestResult* result = future_.Await(FutureBase::kWaitTimeoutInfinite); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); ASSERT_THAT(future_.result(), Ne(nullptr)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); ASSERT_THAT(result, Ne(nullptr)); EXPECT_THAT(result->number, Eq(kResultNumber)); EXPECT_THAT(result->text, Eq(kResultText)); child.Join(); // Clean up. } // Test Await() method, with finite timeout. TEST_F(FutureTest, TestFutureTimedAwait) { using This = decltype(this); Thread child( [](This test_fixture) { internal::Sleep(/*milliseconds=*/300); test_fixture->future_impl_.Complete<TestResult>( test_fixture->handle_, 0, [](TestResult* data) { data->number = kResultNumber; data->text = kResultText; }); }, this); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); EXPECT_THAT(future_.result(), Eq(nullptr)); const TestResult* result = future_.Await(100); // Wait for 100ms. // Thread should not have completed yet, for another 200ms... EXPECT_THAT(result, Eq(nullptr)); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); result = future_.Await(500); // Wait for 500ms. // Thread should have completed by now. ASSERT_THAT(result, Ne(nullptr)); EXPECT_THAT(result->number, Eq(kResultNumber)); EXPECT_THAT(result->text, Eq(kResultText)); EXPECT_THAT(future_.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future_.result()->number, Eq(kResultNumber)); EXPECT_THAT(future_.result()->text, Eq(kResultText)); child.Join(); // Clean up. } // Helper functions to get memory usage. Linux only. namespace { extern "C" int get_memory_used_kb() { int result = -1; #ifdef __linux__ FILE* file = fopen("/proc/self/status", "r"); char line[128]; while (fgets(line, sizeof(line), file) != nullptr) { if (strncmp(line, "VmSize:", 7) == 0) { const char* nchar = &line[strlen(line) - 1]; bool got_num = false; while (nchar >= line) { if (!got_num) { if (isdigit(*nchar)) { got_num = true; } } else { if (!isdigit(*nchar)) { result = atoi(nchar); // NOLINT break; } } nchar--; } } } fclose(file); #endif // __linux__ return result; } } // namespace TEST_F(FutureTest, MemoryStressTest) { size_t kIterations = 4000000; // 4 million int memory_usage_before = get_memory_used_kb(); for (size_t i = 0; i < kIterations; ++i) { { SafeFutureHandle<TestResult> handle = i % 2 == 0 ? future_impl_.SafeAlloc<TestResult>() : future_impl_.SafeAlloc<TestResult>(kFutureTestFnOne); { Future<TestResult> future = MakeFuture(&future_impl_, handle); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); } if (i % 2 != 0) { FutureBase future = future_impl_.LastResult(kFutureTestFnOne); EXPECT_THAT(future_.status(), Eq(kFutureStatusPending)); } future_impl_.Complete<TestResult>(handle, 0, [i](TestResult* data) { data->number = kResultNumber + i; data->text = kResultText; }); { Future<TestResult> future = MakeFuture(&future_impl_, handle); EXPECT_THAT(future.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future.result()->number, Eq(kResultNumber + i)); EXPECT_THAT(future.result()->text, Eq(kResultText)); } } if (i % 2 != 0) { FutureBase future_base = future_impl_.LastResult(kFutureTestFnOne); Future<TestResult>& future = *static_cast<Future<TestResult>*>(&future_base); EXPECT_THAT(future.status(), Eq(kFutureStatusComplete)); EXPECT_THAT(future.result()->number, Eq(kResultNumber + i)); EXPECT_THAT(future.result()->text, Eq(kResultText)); } } int memory_usage_after = get_memory_used_kb(); if (memory_usage_before != -1 && memory_usage_after != -1) { // Ensure that after creating a few million futures, memory usage has not // changed by more than half a megabyte. const int kMaxAllowedMemoryChange = 512; // in kilobytes EXPECT_NEAR(memory_usage_before, memory_usage_after, kMaxAllowedMemoryChange); } } } // namespace testing } // namespace detail } // namespace TEST_FIREBASE_NAMESPACE