text
stringlengths
1
1.05M
; A251635: Riordan array (1-2*x,x), inverse of Riordan array (1/(1-2*x), x) = A130321. ; Submitted by Jamie Morken(s1.) ; 1,-2,1,0,-2,1,0,0,-2,1,0,0,0,-2,1,0,0,0,0,-2,1,0,0,0,0,0,-2,1,0,0,0,0,0,0,-2,1,0,0,0,0,0,0,0,-2,1,0,0,0,0,0,0,0,0,-2,1,0,0,0,0,0,0,0,0,0,-2,1,0,0,0,0,0,0,0,0,0,0,-2,1,0,0,0,0,0 seq $0,25669 ; Exponent of 7 (value of i) in n-th number of form 7^i*8^j. pow $0,18 add $1,$0 sub $1,3 bin $1,$0 mov $0,$1
SSAnne6Script: call EnableAutoTextBoxDrawing ret SSAnne6TextPointers: dw SSAnne6Text1 dw SSAnne6Text2 dw SSAnne6Text3 dw SSAnne6Text4 dw SSAnne6Text5 dw SSAnne6Text6 dw SSAnne6Text7 SSAnne6Text1: TX_FAR _SSAnne6Text1 db "@" SSAnne6Text2: TX_FAR _SSAnne6Text2 db "@" SSAnne6Text3: TX_FAR _SSAnne6Text3 db "@" SSAnne6Text4: TX_FAR _SSAnne6Text4 db "@" SSAnne6Text5: TX_FAR _SSAnne6Text5 db "@" SSAnne6Text6: TX_FAR _SSAnne6Text6 db "@" SSAnne6Text7: TX_ASM ld hl, SSAnne6Text_61807 call PrintText ld a, [hRandomAdd] bit 7, a jr z, .asm_93eb1 ld hl, SSAnne6Text_6180c jr .asm_63292 .asm_93eb1 bit 4, a jr z, .asm_7436c ld hl, SSAnne6Text_61811 jr .asm_63292 .asm_7436c ld hl, SSAnne6Text_61816 .asm_63292 call PrintText jp TextScriptEnd SSAnne6Text_61807: TX_FAR _SSAnne6Text_61807 db "@" SSAnne6Text_6180c: TX_FAR _SSAnne6Text_6180c db "@" SSAnne6Text_61811: TX_FAR _SSAnne6Text_61811 db "@" SSAnne6Text_61816: TX_FAR _SSAnne6Text_61816 db "@"
TMHMMoves: ; entries correspond to *_TMNUM enums (see constants/item_constants.asm) ; TMs dw DYNAMICPUNCH dw HEADBUTT dw CURSE dw ROLLOUT dw ROAR dw TOXIC dw ZAP_CANNON dw ROCK_SMASH dw PSYCH_UP dw HIDDEN_POWER dw SUNNY_DAY dw SWEET_SCENT dw SNORE dw BLIZZARD dw HYPER_BEAM dw ICY_WIND dw PROTECT dw RAIN_DANCE dw GIGA_DRAIN dw ENDURE dw FRUSTRATION dw SOLARBEAM dw IRON_TAIL dw DRAGONBREATH dw THUNDER dw EARTHQUAKE dw RETURN dw DIG dw PSYCHIC_M dw SHADOW_BALL dw MUD_SLAP dw DOUBLE_TEAM dw ICE_PUNCH dw SWAGGER dw SLEEP_TALK dw SLUDGE_BOMB dw SANDSTORM dw FIRE_BLAST dw SWIFT dw DEFENSE_CURL dw THUNDERPUNCH dw DREAM_EATER dw DETECT dw REST dw ATTRACT dw THIEF dw STEEL_WING dw FIRE_PUNCH dw FURY_CUTTER dw NIGHTMARE ; HMs dw CUT dw FLY dw SURF dw STRENGTH dw FLASH dw WHIRLPOOL dw WATERFALL ; Move tutor dw FLAMETHROWER dw THUNDERBOLT dw ICE_BEAM dw 0 ; end
; Rectangle, Intervals and Points ; 05.2006 aralbrec SECTION code_clib PUBLIC r_IntersectRect16 PUBLIC _r_IntersectRect16 EXTERN RIntersectRect16 ; int r_IntersectRect16(struct r_Rect16 *r1, struct r_Rect16 *r2, struct r_Rect16 *result) .r_IntersectRect16 ._r_IntersectRect16 ld hl,7 add hl,sp ld d,(hl) dec hl ld e,(hl) dec hl push de ld d,(hl) dec hl ld e,(hl) dec hl ld b,(hl) dec hl ld c,(hl) IF __CPU_R2K__ | __CPU_R3K__ push bc pop ix ELSE ld ixl,c ld ixh,b ENDIF ex de,hl ld c,(hl) inc hl ld b,(hl) inc hl ld e,(hl) inc hl ld d,(hl) inc hl ex (sp),hl ld a,(hl) inc hl push hl ld h,(hl) ld l,a ; stack = r2.y, r1.width-1 exx pop hl inc hl pop de ld a,(hl) inc hl ex af,af ld a,(hl) inc hl ld c,(hl) inc hl ld b,(hl) inc hl push bc ld c,(hl) inc hl ld b,(hl) push bc ex de,hl ld e,(hl) inc hl ld d,(hl) inc hl push de ld e,(hl) inc hl ld d,(hl) push de ld d,a ex af,af ld e,a exx call RIntersectRect16 ld hl,0 ret nc inc l ret
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Stubs Written by D Morris - 30/9/98 ; ; ; $Id: w_circle_callee.asm $ ; ; Usage: circle(int x, int y, int radius, int skip); SECTION code_graphics PUBLIC circle_callee PUBLIC _circle_callee PUBLIC ASMDISP_CIRCLE_CALLEE EXTERN w_draw_circle EXTERN w_plotpixel EXTERN swapgfxbk EXTERN __graphics_end .circle_callee ._circle_callee ; de = x0, hl = y0, bc = radius, a = skip pop af ex af,af pop de ; skip ld a,e pop bc ;radius pop hl ; y pop de ; x ex af,af push af ex af,af push ix .asmentry push af call swapgfxbk pop af ld ix,w_plotpixel call w_draw_circle jp __graphics_end DEFC ASMDISP_CIRCLE_CALLEE = asmentry - circle_callee
.size 8000 .text@48 inc a ldff(45), a jp lstatint .text@100 jp lbegin .text@150 lbegin: ld a, ff ldff(45), a ld b, 03 call lwaitly_b ld a, 40 ldff(41), a ld a, 02 ldff(ff), a ei ld a, b inc a inc a ldff(45), a ld c, 0f halt .text@1000 lstatint: nop .text@1063 ldff a, (c) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
[BITS 64] %include "parameters.inc" extern exit global sub_sse128_int section .text sub_sse128_int: push rbp mov rax, ITERATIONS_sub_sse128i lea rbx, [rel sse_iv] movdqa xmm0, [rbx] movdqa xmm1, [rbx] movdqa xmm2, [rbx] movdqa xmm3, [rbx] movdqa xmm4, [rbx] movdqa xmm5, [rbx] movdqa xmm6, [rbx] movdqa xmm7, [rbx] movdqa xmm8, [rbx] movdqa xmm9, [rbx] movdqa xmm10, [rbx] movdqa xmm11, [rbx] movdqa xmm12, [rbx] movdqa xmm13, [rbx] movdqa xmm14, [rbx] movdqa xmm15, [rbx] .loop: psubd xmm0, xmm0 psubd xmm1, xmm1 psubd xmm2, xmm2 psubd xmm3, xmm3 psubd xmm4, xmm4 psubd xmm5, xmm5 psubd xmm6, xmm6 psubd xmm7, xmm7 psubd xmm8, xmm8 psubd xmm9, xmm9 psubd xmm10, xmm10 psubd xmm11, xmm11 psubd xmm12, xmm12 psubd xmm13, xmm13 psubd xmm14, xmm14 psubd xmm15, xmm15 dec rax jnz .loop .exit: lea rdi, [rel format] pop rbp xor rax, rax mov rax, ITERATIONS_sub_sse128i mov rsi, 18 ; 16 psubd + 1 dec + 1 loop mul rsi ret section .data format: db "%lu", 10, 0 align 32 sse_iv: dd 4, 3, 2, 1
; A122970: 29th powers: a(n) = n^29. ; 0,1,536870912,68630377364883,288230376151711744,186264514923095703125,36845653286788892983296,3219905755813179726837607,154742504910672534362390528,4710128697246244834921603689,100000000000000000000000000000,1586309297171491574414436704891,19781359483314150527412524285952,201538126434611150798503956371773,1728673739677471101567216945987584,12783403948858939111232757568359375,83076749736557242056487941267521536,481968572106750915091411825223071697,2528731089327963353099650821015994368 pow $0,29
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r15 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x18a46, %r14 nop nop nop and %rdx, %rdx vmovups (%r14), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rbx nop nop nop nop xor %r13, %r13 lea addresses_UC_ht+0xb796, %r15 nop nop nop nop nop sub %r11, %r11 mov $0x6162636465666768, %rdi movq %rdi, (%r15) nop nop nop nop nop sub $44049, %rbx lea addresses_UC_ht+0x12706, %rdi cmp %rbx, %rbx mov (%rdi), %r11 nop nop nop nop nop add $20843, %r15 lea addresses_UC_ht+0x17046, %rsi lea addresses_normal_ht+0x4b46, %rdi nop nop dec %r15 mov $4, %rcx rep movsq nop nop nop and %r13, %r13 lea addresses_D_ht+0xf586, %rbx nop nop and $22305, %r14 movl $0x61626364, (%rbx) nop nop nop cmp %rbx, %rbx lea addresses_A_ht+0x16b06, %rcx nop nop nop nop nop cmp $47781, %rbx movl $0x61626364, (%rcx) nop nop nop nop nop sub $24900, %rbx lea addresses_A_ht+0xd5c6, %rsi nop nop xor %rcx, %rcx and $0xffffffffffffffc0, %rsi vmovntdqa (%rsi), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdx nop and %r11, %r11 lea addresses_A_ht+0x6056, %r15 nop cmp $39873, %rsi movb $0x61, (%r15) nop nop nop nop sub %rsi, %rsi lea addresses_A_ht+0xf05e, %rdx nop nop nop nop add %rsi, %rsi movl $0x61626364, (%rdx) nop nop nop cmp $37715, %rbx lea addresses_D_ht+0x6186, %rsi lea addresses_WC_ht+0x14848, %rdi clflush (%rdi) nop nop nop dec %r13 mov $97, %rcx rep movsb nop sub %rsi, %rsi lea addresses_A_ht+0x8cc6, %rdx nop sub $62505, %rcx mov $0x6162636465666768, %r13 movq %r13, %xmm3 vmovups %ymm3, (%rdx) nop nop and $14687, %r13 lea addresses_normal_ht+0x118c6, %rdx nop nop nop nop nop dec %r11 mov (%rdx), %si nop nop nop nop nop and $31716, %rbx lea addresses_D_ht+0x8c6, %rbx nop and %rsi, %rsi movb (%rbx), %r14b nop and %rdx, %rdx lea addresses_UC_ht+0x22eb, %rsi lea addresses_A_ht+0x102b2, %rdi nop nop nop nop cmp $32562, %r13 mov $42, %rcx rep movsb nop nop nop nop dec %rcx lea addresses_normal_ht+0x88c6, %rdx nop nop nop nop cmp %r14, %r14 mov (%rdx), %bx nop nop nop nop and $6173, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r15 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %rax push %rbp push %rbx push %rcx // Store lea addresses_UC+0xe306, %rax nop sub %r12, %r12 movb $0x51, (%rax) cmp $40625, %rbp // Store lea addresses_US+0xa190, %r8 nop nop sub $15720, %r13 movw $0x5152, (%r8) nop nop nop cmp $18381, %r8 // Faulty Load lea addresses_D+0x168c6, %rax nop add %r8, %r8 mov (%rax), %rcx lea oracles, %r8 and $0xff, %rcx shlq $12, %rcx mov (%r8,%rcx,1), %rcx pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': True, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 6, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}} {'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 */
/*! @file @author Shin'ichiro Nakaoka */ #include "RobotAccessBar.h" #include "RobotAccessItem.h" #include <cnoid/RootItem> #include <cnoid/ItemTreeView> #include <cnoid/MessageView> #include "gettext.h" using namespace std::placeholders; using namespace cnoid; namespace cnoid { class RobotAccessBarImpl { public: ToolButton* syncToggle; RobotAccessBarImpl(RobotAccessBar* self); void connectToRobots(); void disconnectFromRobots(); void turnOnServos(); void turnOffServos(); void onSendPoseButtonClicked(); void onServoButtonToggled(bool on); }; } namespace { void forEachCheckedRobotAccessItems (std::function<void(RobotAccessItem* item)> func, const char* noTargetMessage) { ItemList<RobotAccessItem> items = ItemTreeView::instance()->checkedItems<RobotAccessItem>(); if(items.empty()){ MessageView::instance()->putln(noTargetMessage); } else { for(size_t i=0; i < items.size(); ++i){ func(items[i].get()); } } } } RobotAccessBar::RobotAccessBar() : ToolBar(N_("RobotAccessBar")) { impl = new RobotAccessBarImpl(this); } RobotAccessBar::~RobotAccessBar() { } RobotAccessBarImpl::RobotAccessBarImpl(RobotAccessBar* self) { self->addButton(_("C"), _("Connect to robots")) ->sigClicked().connect(std::bind(&RobotAccessBarImpl::connectToRobots, this)); self->addButton(_("D"), _("Disconnect from robots")) ->sigClicked().connect(std::bind(&RobotAccessBarImpl::disconnectFromRobots, this)); self->addButton(QIcon(":/RobotAccess/icons/servo-on.png"), _("Turn on servos")) ->sigClicked().connect(std::bind(&RobotAccessBarImpl::turnOnServos, this)); self->addButton(_("OFF"), _("Turn off servos")) ->sigClicked().connect(std::bind(&RobotAccessBarImpl::turnOffServos, this)); self->addButton(QIcon(":/RobotAccess/icons/sendpose.png"), _("Send the current pose of virtual robots to actual robots")) ->sigClicked().connect(std::bind(&RobotAccessBarImpl::onSendPoseButtonClicked, this)); syncToggle = self->addToggleButton(QIcon(":/RobotAccess/icons/syncpose.png"), _("Synchronize the pose of actual robots pose with virtual robots")); } void RobotAccessBarImpl::connectToRobots() { forEachCheckedRobotAccessItems( std::bind(&RobotAccessItem::connectToRobot, _1), _("There are no checked items to connect to robots")); } void RobotAccessBarImpl::disconnectFromRobots() { forEachCheckedRobotAccessItems( std::bind(&RobotAccessItem::disconnectFromRobot, _1), _("There are no checked items to disconnect from robots")); } void RobotAccessBarImpl::turnOnServos() { forEachCheckedRobotAccessItems( std::bind(&RobotAccessItem::activateServos, _1, true), _("There are no checked items to activate servos")); } void RobotAccessBarImpl::turnOffServos() { forEachCheckedRobotAccessItems( std::bind(&RobotAccessItem::activateServos, _1, false), _("There are no checked items to deactivate servos")); } void RobotAccessBarImpl::onSendPoseButtonClicked() { } void RobotAccessBarImpl::onServoButtonToggled(bool on) { }
// Copyright (c) 2012-2018 The Bitcoin Core developers // Copyright (c) 2017 The Raven Core developers // Copyright (c) 2018 The Rito Core developers // Copyright (c) 2020 The Ukcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "noui.h" #include "ui_interface.h" #include "util.h" #include <cstdio> #include <stdint.h> #include <string> static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { bool fSecure = style & CClientUIInterface::SECURE; style &= ~CClientUIInterface::SECURE; std::string strCaption; // Check for usage of predefined caption switch (style) { case CClientUIInterface::MSG_ERROR: strCaption += _("Error"); break; case CClientUIInterface::MSG_WARNING: strCaption += _("Warning"); break; case CClientUIInterface::MSG_INFORMATION: strCaption += _("Information"); break; default: strCaption += caption; // Use supplied caption (can be empty) } if (!fSecure) LogPrintf("%s: %s\n", strCaption, message); fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str()); return false; } static bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style) { return noui_ThreadSafeMessageBox(message, caption, style); } static void noui_InitMessage(const std::string& message) { LogPrintf("init message: %s\n", message); } void noui_connect() { // Connect ukcoind signal handlers uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox); uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestion); uiInterface.InitMessage.connect(noui_InitMessage); }
; A001604: Odd-indexed terms of A124297. ; 11,31,151,911,5951,40051,272611,1863551,12760031,87424711,599129311,4106261531,28144128251,192901135711,1322159893351,9062207833151,62113268013311,425730597768451,2918000731816531,20000274041790911 mov $1,1 lpb $0 sub $0,1 add $1,1 add $2,1 add $1,$2 add $2,$1 lpe add $1,2 pow $1,2 div $1,16 mul $1,20 add $1,11
#include "mex.h" #include "matrix.h" #include <math.h> #include "SphericalTensor.cpp" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { if(nrhs != 1 && nrhs != 2 && nrhs != 3) { printf("\nUsage: Df = STderivUp(f,difftyp,factor)\n\n",nrhs); printf(" Computes Spherical Up-Derivative\n"); printf(" Parameters:\n"); printf(" f - complex-interleaved 3D input image of type REAL \n"); printf(" difftyp - central (0) / forward (-1) / backward (1) (optional)\n"); printf(" factor - multiply result with factor (optional)\n\n"); return; } else if(nlhs>1) { printf("Too many output arguments\n"); return; } int pcnt = 0; const mxArray *Img; Img = prhs[pcnt++]; const int numdim = mxGetNumberOfDimensions(Img); const int *dims = mxGetDimensions(Img); int L = dims[0]/2; if (numdim != 4) return; int diff_type = 0; if (nrhs >= 2) { const mxArray *typ; typ = prhs[pcnt++]; diff_type = (int) *mxGetPr(typ); if (diff_type < -1 || diff_type > 1) diff_type = 0; } REAL factor = 1.0; if (nrhs == 3) { const mxArray *mxFactor = prhs[pcnt++]; if (mxGetClassID(mxFactor) == mxDOUBLE_CLASS) factor = (REAL) *((double*) mxGetData(mxFactor)); else if (mxGetClassID(mxFactor) == mxSINGLE_CLASS) factor = (REAL) *((float*) mxGetData(mxFactor)); else return; } REAL *img = (REAL*) mxGetData(Img); int ndims[4]; ndims[0] = (L + 1)*2; ndims[1] = dims[1]; ndims[2] = dims[2]; ndims[3] = dims[3]; plhs[0] = mxCreateNumericArray(4,ndims,mxGetClassID(Img),mxREAL); REAL *result = (REAL*) mxGetData(plhs[0]); if (diff_type == -1) STderivRealForward(img,&(ndims[1]),L,result,factor); else if (diff_type == 1) STderivRealBackward(img,&(ndims[1]),L,result,factor); else if (diff_type == 0) STderivReal(img,&(ndims[1]),L,result,factor); }
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %rax push %rbp push %rcx push %rdi push %rdx // Load lea addresses_US+0x1fb56, %rax clflush (%rax) nop nop nop and %rbp, %rbp mov (%rax), %r11d nop nop inc %rax // Faulty Load lea addresses_A+0x7c56, %rdx nop nop sub %rdi, %rdi mov (%rdx), %ebp lea oracles, %rdx and $0xff, %rbp shlq $12, %rbp mov (%rdx,%rbp,1), %rbp pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': True, 'size': 4, 'type': 'addresses_US', 'congruent': 8}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A', 'congruent': 0}} <gen_prepare_buffer> {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/// @ref gtx_spline namespace glm { template<typename genType> GLM_FUNC_QUALIFIER genType catmullRom ( genType const& v1, genType const &v2, genType const& v3, genType const &v4, typename genType::value_type const &s ) { typename genType::value_type s2 = pow2(s); typename genType::value_type s3 = pow3(s); typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; typename genType::value_type f4 = s3 - s2; return ( f1 *v1 + f2 *v2 + f3 *v3 + f4 *v4 ) / typename genType::value_type(2); } template<typename genType> GLM_FUNC_QUALIFIER genType hermite ( genType const& v1, genType const &t1, genType const& v2, genType const &t2, typename genType::value_type const &s ) { typename genType::value_type s2 = pow2(s); typename genType::value_type s3 = pow3(s); typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; typename genType::value_type f4 = s3 - s2; return f1 *v1 + f2 *v2 + f3 *t1 + f4 *t2; } template<typename genType> GLM_FUNC_QUALIFIER genType cubic ( genType const& v1, genType const &v2, genType const& v3, genType const &v4, typename genType::value_type const &s ) { return (( v1 *s + v2) * s + v3) * s + v4; } }//namespace glm
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r8 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0xcae, %rdx nop nop nop nop and $1887, %r11 movw $0x6162, (%rdx) nop nop nop xor $23654, %rcx lea addresses_UC_ht+0x38ae, %r9 nop nop nop sub %rbx, %rbx mov $0x6162636465666768, %r8 movq %r8, %xmm3 movups %xmm3, (%r9) nop nop nop cmp %r9, %r9 lea addresses_A_ht+0x94ae, %rbx nop nop nop dec %rcx movl $0x61626364, (%rbx) nop nop nop nop nop sub %rcx, %rcx lea addresses_A_ht+0x1e10e, %rbx clflush (%rbx) nop cmp $8918, %r9 movl $0x61626364, (%rbx) nop nop nop add %r9, %r9 lea addresses_WT_ht+0x1820e, %rsi lea addresses_D_ht+0x1b9be, %rdi nop nop xor %rdx, %rdx mov $118, %rcx rep movsq nop nop nop inc %r11 lea addresses_normal_ht+0xb4ae, %rsi lea addresses_UC_ht+0x8eae, %rdi cmp $10939, %r9 mov $32, %rcx rep movsb xor %r13, %r13 lea addresses_D_ht+0x1632e, %rsi lea addresses_A_ht+0xdc2e, %rdi nop nop nop nop cmp $4753, %r8 mov $68, %rcx rep movsb sub $50372, %rsi lea addresses_A_ht+0x1ecae, %rsi clflush (%rsi) nop nop cmp %r11, %r11 mov (%rsi), %ecx nop and $41472, %r13 lea addresses_WT_ht+0x150ae, %rsi xor $3213, %rbx mov $0x6162636465666768, %r11 movq %r11, (%rsi) and $24875, %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r14 push %rbp push %rbx push %rdi push %rsi // Load lea addresses_normal+0x148ce, %rsi nop nop inc %r12 mov (%rsi), %r13d nop nop nop nop add $35520, %rsi // Store lea addresses_normal+0x1a34e, %rsi sub $63021, %r14 movb $0x51, (%rsi) nop nop xor %rsi, %rsi // Faulty Load lea addresses_WC+0xe4ae, %rbx nop nop nop nop nop and %rdi, %rdi movups (%rbx), %xmm1 vpextrq $1, %xmm1, %rbp lea oracles, %r14 and $0xff, %rbp shlq $12, %rbp mov (%r14,%rbp,1), %rbp pop %rsi pop %rdi pop %rbx pop %rbp pop %r14 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'dst': {'same': True, 'congruent': 5, 'type': 'addresses_UC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 7, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
; A097766: Pell equation solutions (11*a(n))^2 - 122*b(n)^2 = -1 with b(n):=A097767(n), n >= 0. ; Submitted by Christian Krause ; 1,487,236681,115026479,55902632113,27168564180439,13203866289061241,6417051847919582687,3118673994222628124641,1515669144140349348992839,736612085378215560982395113,357991957824668622288095032079,173983354890703572216453203195281,84555552484924111428573968657874487,41093824524318227450714732314523805401,19971514163266173616935931330889911550399,9706114789522836059603411912080182489688513,4717151816193935058793641253339637800077066919,2292526076555462915737650045711151890654964834121 lpb $0 mov $2,$0 sub $0,1 mul $2,2 seq $2,90313 ; a(n) = 22*a(n-1) + a(n-2), starting with a(0) = 2 and a(1) = 22. add $1,$2 lpe mov $0,$1 add $0,1
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1ee3b, %rsi lea addresses_WT_ht+0x9f9f, %rdi nop nop nop nop xor $30765, %r14 mov $36, %rcx rep movsq nop nop nop nop nop sub %rbx, %rbx lea addresses_A_ht+0x2b9f, %rdi sub $41875, %r10 mov $0x6162636465666768, %rsi movq %rsi, (%rdi) nop nop sub $56888, %rcx lea addresses_WC_ht+0x1b69f, %rcx nop nop nop nop cmp $60964, %rsi movb (%rcx), %bl nop nop nop nop cmp %r10, %r10 lea addresses_WC_ht+0x639f, %r10 nop cmp %r15, %r15 mov (%r10), %di nop nop nop add %rcx, %rcx lea addresses_normal_ht+0x1a49f, %rsi lea addresses_WC_ht+0x1b79f, %rdi nop nop nop nop nop inc %rbp mov $80, %rcx rep movsq nop nop nop xor $27306, %rbx lea addresses_normal_ht+0x560f, %rsi lea addresses_WC_ht+0x439f, %rdi nop nop sub $18857, %rbp mov $43, %rcx rep movsb nop nop nop nop nop add $26157, %r15 lea addresses_A_ht+0xdf07, %rsi lea addresses_normal_ht+0xb3b7, %rdi clflush (%rsi) nop nop nop nop nop dec %r15 mov $86, %rcx rep movsq nop nop nop nop nop and %rbx, %rbx lea addresses_normal_ht+0x1db9f, %r14 nop and $40809, %rdi mov $0x6162636465666768, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%r14) nop nop add %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_normal+0xcd4, %r11 nop nop nop nop nop and %r12, %r12 movl $0x51525354, (%r11) nop nop nop add %r12, %r12 // REPMOV lea addresses_PSE+0x1a39f, %rsi mov $0xb9f, %rdi nop nop xor %rbx, %rbx mov $96, %rcx rep movsw nop add %r12, %r12 // Store lea addresses_WT+0xb2df, %rbx and %rbp, %rbp movl $0x51525354, (%rbx) nop nop nop add %rbp, %rbp // Load lea addresses_WC+0x4ca3, %rbp nop nop nop nop nop xor $194, %rbx movb (%rbp), %r11b nop nop nop cmp %rbx, %rbx // Store lea addresses_WT+0x1f9f, %rcx nop nop nop nop dec %r12 movl $0x51525354, (%rcx) inc %r11 // Faulty Load lea addresses_PSE+0x1a39f, %r12 nop nop inc %rbx mov (%r12), %ebp lea oracles, %rdi and $0xff, %rbp shlq $12, %rbp mov (%rdi,%rbp,1), %rbp pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_PSE', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_P', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'33': 281} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
.byte $00, $00, $08, $0D, $09, $00, $00, $00, $00
Sound54_OOZLidPop_Header: smpsHeaderStartSong 2, 1 smpsHeaderVoice Sound54_OOZLidPop_Voices smpsHeaderTempoSFX $01 smpsHeaderChanSFX $02 smpsHeaderSFXChannel cFM5, Sound54_OOZLidPop_FM5, $00, $00 smpsHeaderSFXChannel cPSG3, Sound54_OOZLidPop_PSG3, $00, $06 ; FM5 Data Sound54_OOZLidPop_FM5: smpsSetvoice $00 dc.b nF4, $15 smpsStop ; PSG3 Data Sound54_OOZLidPop_PSG3: smpsPSGform $E7 smpsPSGvoice fTone_04 dc.b nMaxPSG, $03, smpsNoAttack, nAb5, smpsNoAttack, nG5, smpsNoAttack, nFs5, smpsNoAttack, nF5, smpsNoAttack, nE5 dc.b smpsNoAttack, nEb5 smpsStop Sound54_OOZLidPop_Voices: ; Voice $00 ; $07 ; $03, $03, $02, $00, $FF, $6F, $6F, $3F, $12, $11, $14, $0E ; $1A, $03, $0A, $0D, $FF, $FF, $FF, $FF, $03, $07, $07, $80 smpsVcAlgorithm $07 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $00, $02, $03, $03 smpsVcRateScale $00, $01, $01, $03 smpsVcAttackRate $3F, $2F, $2F, $3F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0E, $14, $11, $12 smpsVcDecayRate2 $0D, $0A, $03, $1A smpsVcDecayLevel $0F, $0F, $0F, $0F smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $80, $07, $07, $03
/// @ref gtx_matrix_interpolation /// @file glm/gtx/matrix_interpolation.hpp namespace glm { template<typename T, precision P> GLM_FUNC_QUALIFIER void axisAngle ( tmat4x4 < T, P > const & mat, tvec3 <T, P> &axis, T & angle ) { T epsilon = (T) 0.01; T epsilon2 = (T) 0.1; if(( abs(mat[1][0] - mat[0][1]) < epsilon) && ( abs(mat[2][0] - mat[0][2]) < epsilon) && ( abs(mat[2][1] - mat[1][2]) < epsilon)) { if (( abs(mat[1][0] + mat[0][1]) < epsilon2) && ( abs(mat[2][0] + mat[0][2]) < epsilon2) && ( abs(mat[2][1] + mat[1][2]) < epsilon2) && ( abs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2)) { angle = (T) 0.0; axis. x = (T) 1.0; axis. y = (T) 0.0; axis. z = (T) 0.0; return; } angle = static_cast<T>(3.1415926535897932384626433832795); T xx = (mat[0][0] + (T) 1.0) / (T) 2.0; T yy = (mat[1][1] + (T) 1.0) / (T) 2.0; T zz = (mat[2][2] + (T) 1.0) / (T) 2.0; T xy = (mat[1][0] + mat[0][1]) / (T) 4.0; T xz = (mat[2][0] + mat[0][2]) / (T) 4.0; T yz = (mat[2][1] + mat[1][2]) / (T) 4.0; if((xx > yy) && (xx > zz)) { if (xx<epsilon) { axis. x = (T) 0.0; axis. y = (T) 0.7071; axis. z = (T) 0.7071; } else { axis. x = sqrt(xx); axis. y = xy / axis.x; axis. z = xz / axis.x; } } else if (yy > zz) { if (yy<epsilon) { axis. x = (T) 0.7071; axis. y = (T) 0.0; axis. z = (T) 0.7071; } else { axis. y = sqrt(yy); axis. x = xy / axis.y; axis. z = yz / axis.y; } } else { if (zz<epsilon) { axis. x = (T) 0.7071; axis. y = (T) 0.7071; axis. z = (T) 0.0; } else { axis. z = sqrt(zz); axis. x = xz / axis.z; axis. y = yz / axis.z; } } return; } T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1])); if ( glm::abs(s) < T(0.001)) s = (T) 1.0; angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T) 1.0) / (T) 2.0); axis. x = (mat[1][2] - mat[2][1]) / s; axis. y = (mat[2][0] - mat[0][2]) / s; axis. z = (mat[0][1] - mat[1][0]) / s; } template<typename T, precision P> GLM_FUNC_QUALIFIER tmat4x4<T, P> axisAngleMatrix ( tvec3<T, P> const & axis, T const angle ) { T c = cos(angle); T s = sin(angle); T t = static_cast<T>(1) - c; tvec3 <T, P> n = normalize(axis); return tmat4x4<T, P>( t * n. x *n .x + c, t *n . x *n .y + n. z *s, t * n. x *n .z - n. y *s, T(0), t * n. x *n .y - n. z *s, t * n. y *n .y + c, t *n . y *n .z + n. x *s, T(0), t * n. x *n .z + n. y *s, t * n. y *n .z - n. x *s, t * n. z *n .z + c, T(0), T(0), T(0), T(0), T(1) ); } template<typename T, precision P> GLM_FUNC_QUALIFIER tmat4x4<T, P> extractMatrixRotation ( tmat4x4<T, P> const & mat ) { return tmat4x4<T, P>( mat[0][0], mat[0][1], mat[0][2], 0.0, mat[1][0], mat[1][1], mat[1][2], 0.0, mat[2][0], mat[2][1], mat[2][2], 0.0, 0.0, 0.0, 0.0, 1.0 ); } template<typename T, precision P> GLM_FUNC_QUALIFIER tmat4x4<T, P> interpolate ( tmat4x4<T, P> const & m1, tmat4x4<T, P> const &m2, T const delta ) { tmat4x4<T, P> m1rot = extractMatrixRotation(m1); tmat4x4<T, P> dltRotation = m2 * transpose(m1rot); tvec3 <T, P> dltAxis; T dltAngle; axisAngle(dltRotation, dltAxis, dltAngle ); tmat4x4<T, P> out = axisAngleMatrix(dltAxis, dltAngle * delta) * m1rot; out[3][0] = m1[3][0] + delta *(m2[3][0] - m1[3][0]); out[3][1] = m1[3][1] + delta *(m2[3][1] - m1[3][1]); out[3][2] = m1[3][2] + delta *(m2[3][2] - m1[3][2]); return out; } }//namespace glm
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 009614 move.l D2, (A0)+ [base+ 3C, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ EC, base+ EE, base+ FC, base+ FE, base+16C, base+16E, base+17C, base+17E, base+20C, base+20E, base+21C, base+21E, base+28C, base+28E, base+29C, base+29E, base+2AC, base+2AE, base+2BC, base+2BE, base+32C, base+32E, base+33C, base+33E, base+3CC, base+3CE, base+3DC, base+3DE, base+42E] 009616 addi.w #$10, D3 009690 move.l D2, (A0)+ [base+ 3C, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ EC, base+ EE, base+ FC, base+ FE, base+16C, base+16E, base+17C, base+17E, base+20C, base+20E, base+21C, base+21E, base+28C, base+28E, base+29C, base+29E, base+2AC, base+2AE, base+2BC, base+2BE, base+32C, base+32E, base+33C, base+33E, base+3CC, base+3CE, base+3DC, base+3DE, base+42E] 009692 addi.w #$10, D3 [base+ 40, base+ 50, base+ 52, base+ 60, base+ 62, base+ E0, base+ E2, base+ F0, base+ F2, base+100, base+102, base+170, base+172, base+180, base+182, base+210, base+212, base+220, base+222, base+290, base+292, base+2A0, base+2A2, base+2B0, base+2B2, base+330, base+332, base+340, base+342, base+3C0, base+3C2, base+3D0, base+3D2, base+432] 00A61C move.l D1, (A0)+ 00A61E move.l D1, (A0)+ 00A64E move.l D2, (A0)+ [base+ 3C, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ EC, base+ EE, base+ FC, base+ FE, base+16C, base+16E, base+17C, base+17E, base+20C, base+20E, base+21C, base+21E, base+28C, base+28E, base+29C, base+29E, base+2AC, base+2AE, base+2BC, base+2BE, base+32C, base+32E, base+33C, base+33E, base+3CC, base+3CE, base+3DC, base+3DE, base+42E] 00A650 addi.w #$10, D6 [base+ 40, base+ 50, base+ 52, base+ 60, base+ 62, base+ E0, base+ E2, base+ F0, base+ F2, base+100, base+102, base+170, base+172, base+180, base+182, base+210, base+212, base+220, base+222, base+290, base+292, base+2A0, base+2A2, base+2B0, base+2B2, base+330, base+332, base+340, base+342, base+3C0, base+3C2, base+3D0, base+3D2, base+432] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
SECTION code_fp_math32 PUBLIC cm32_sdcc_frexp_callee EXTERN m32_fsfrexp_callee ; float frexpf(float x, int8_t *pw2); ; Entry: ; Stack: ptr right, float left, ret defc cm32_sdcc_frexp_callee = m32_fsfrexp_callee
; A103177: (7*3^n + 2n + 5)/4. ; Submitted by Christian Krause ; 3,7,18,50,145,429,1280,3832,11487,34451,103342,310014,930029,2790073,8370204,25110596,75331771,225995295,677985866,2033957578,6101872713,18305618117,54916854328,164750562960,494251688855,1482755066539 mov $1,3 pow $1,$0 mul $0,2 mul $1,7 add $0,$1 div $0,4 add $0,2
; ; CPC Maths Routines ; ; August 2003 **_|warp6|_** <kbaccam /at/ free.fr> ; ; $Id: get_para.asm,v 1.4 2016-06-22 19:50:49 dom Exp $ ; SECTION code_fp INCLUDE "cpcfp.def" PUBLIC get_para EXTERN fa .get_para ld hl,4 add hl,sp ld de,fa ;(fa) <- (hl) ld bc,6 ldir ld hl,fa+1 ret
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: Calendar/DayPlan FILE: dayplanMain.asm AUTHOR: Don Reeves, June 28, 1989 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Don 6/89 Initial revision Don 7/17/89 Moved to new UI Don 11/10/89 Modified for spec of 11/9 Don 12/4/89 Use new class & method declarations DESCRIPTION: Defines the "DayPlan" procedures that operate on this class. $Id: dayplanMain.asm,v 1.1 97/04/04 14:47:40 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ include foam.def include timedate.def GeometryCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanViewSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Keep track of the view's size CALLED BY: UI PASS: ES = DGroup DS:*SI = DayPlan instance data CX = Width hint DX = Height hint RETURN: CX = Desired width DX = Desired height DESTROYED: AX, BX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/5/89 Initial version sean 2/3/96 Responder version using fixed values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanViewSize method DayPlanClass, MSG_VIS_RECALC_SIZE .enter ; Store the event view height. Then, depending on what ; view is being shown, store the event view width. ; ; Keep track of the size ; mov ax, MSG_VIS_CONTENT_GET_WIN_SIZE ; get the size of the view mov di, offset DayPlanClass ; ES:DI points to my class call ObjCallSuperNoLock ; call my superclass mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access my instance data clr bx ; set a "all clear" flag xchg ds:[di].DPI_viewWidth, cx ; store the width xchg ds:[di].DPI_viewHeight, dx ; store the height cmp cx, ds:[di].DPI_viewWidth ; compare new & old widths pushf ; save the comparison result cmp dx, ds:[di].DPI_viewHeight ; compare new & old height jge checkWidth ; if greater or equal, do nada ; The screen is now longer. Allocate sufficient buffers... ; mov di, ds:[di].DPI_eventTable ; event table handle => DI mov di, ds:[di] ; dereference the chunk push ds:[di].ETH_screenLast ; save the last offset call BufferEnsureEnough ; make enough buffers pop cx ; EventTable offset => CX mov bx, 1 ; must re-draw the screen ; Now check to see if the width has changed ; checkWidth: popf ; restore comparison results je checkUpdate ; no, so check for update mov ax, MSG_DP_RECALC_HEIGHT ; resize every event call ObjCallInstanceNoLock ; EventTable offset => CX mov bx, 1 ; must re-draw the screen ; Finally, update the screen (if necessary) ; checkUpdate: tst bx ; no changes ?? jz done ; then we're done mov dl, SUF_STEAL_FROM_TOP or SUF_NO_REDRAW or SUF_NO_INVALIDATE mov ax, MSG_DP_SCREEN_UPDATE ; send screen update method call ObjCallInstanceNoLock ; We're done - return the dimmensions ; done:: call VisGetSize ; return the correct size .leave ret DayPlanViewSize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanRecalcHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Recalculate the height of every Event in the DayPlan CALLED BY: GLOBAL (MSG_DP_RECALC_HEIGHT) PASS: ES = DGroup DS:*SI = DayPlan instance data RETURN: CX = Offset to first event on screen DESTROYED: BX, DX, DI, SI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/9/90 Initial version Don 6/28/90 Added update of current event text sean 4/6/95 Bogus dirty corrected %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanRecalcHeight method DayPlanClass, MSG_DP_RECALC_HEIGHT .enter ; These lines cause the program to think that it needs to be saved ; after a view change. For instance, when an event is selected in the ; To Do list, and we change to Calendar view, this code causes the ; program to think that the database is dirty. SeanS 4/6/95 ; ; Force the text of the current event to be updated ; push si ; store the DayPlan chunk ; tst ds:[di].DPI_selectEvent ; get the selected event ; jz setup ; if none, do nothing ; mov cl, DBUF_EVENT ; update the text only ; mov si, ds:[di].DPI_selectEvent ; selected event => SI ; mov ax, MSG_DE_UPDATE ; method to send ; call ObjCallInstanceNoLock ; do it! ; Some set-up work ; setup: mov cx, ds:[di].DPI_viewWidth ; window width => CX sub cx, es:[timeOffset] ; take away offset to time sub cx, es:[timeWidth] ; take away the time width mov si, ds:[di].DPI_eventTable ; get the table handle mov di, ds:[si] ; derference the handle mov bx, size EventTableHeader ; initial offset to BX mov ds:[di].ETH_temp, 0 ; clear the document height jmp midLoop ; Now loop, calculating calcLoop: mov ax, ds:[di][bx].ETE_group mov di, ds:[di][bx].ETE_item call EventCalcHeightFar mov di, ds:[si] ; derference the EventTable mov ds:[di][bx].ETE_size, dx ; store the new size add ds:[di].ETH_temp, dx ; keep track of total size add bx, size EventTableEntry ; go to the next entry midLoop: cmp bx, ds:[di].ETH_last jl calcLoop ; Store the new document size ; mov ax, ds:[di].ETH_temp ; total document height => AX pop si ; DayPlan chunk => SI mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access the instance data mov ds:[di].DPI_docHeight, ax ; store the new document height mov cx, size EventTableHeader ; start update from top .leave ret DayPlanRecalcHeight endp GeometryCode ends DayPlanCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanDraw %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Intercepts the drawing of the DayPlan to display any additional information or to alter the drawing that is done. CALLED BY: UI (MSG_VIS_DRAW) PASS: ES = Segment where DayPlanClass defined DS:DI = DayPlanClass specific instance data DS:*SI = DayPlanClass instance data BP = GState handle RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 5/22/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanDraw method DayPlanClass, MSG_VIS_DRAW .enter ; Complete the drawing ; push bp ; save the GState handle mov di, offset DayPlanClass call ObjCallSuperNoLock ; have superclass draw first pop di ; GState handle => DI ; Check for no events whatsoever ; mov si, ds:[si] ; dereference the handle add si, ds:[si].DayPlan_offset ; access the instance data mov bx, ds:[si].DPI_eventTable ; go to the event table mov bx, ds:[bx] cmp ds:[bx].ETH_last, size EventTableHeader jg done ; if any events, done ; Else display the "No Events" string ; if PZ_PCGEOS mov cx, FID_PIZZA_KANJI ; cx <- FontID mov dx, 16 clr ah ; dx.ah <- pointsize call GrSetFont endif mov ax, ds:[si].DPI_viewWidth ; width => AX clr cx ; string NULL terminated mov si, offset NoEventsString ; chunk handle => SI mov si, ds:[si] ; dereference the chunk call GrTextWidth ; get length of string sub ax, dx ; subtract length of string shr ax, 1 ; divide it by 2 to center mov bx, 5 ; draw near the top call GrDrawText ; write it!! done: .leave ret DayPlanDraw endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanLoadEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load an event into a day plan from the database CALLED BY: Database (MSG_DP_LOAD_EVENT) PASS: CX = Group # of DB event DX = Item # of DB event BP = 0 to calculate insertion point = anything else to blindly insert at the end DS:*SI = DayPlan instance data RETURN: Carry = Set if error (too many events) DESTROYED: BX, DI, SI, ES PSEUDO CODE/STRATEGY: Create an event Stuff the data to: Structure to the DayEvent Time to the TimeText object Event to the EventText object Call for insertion into the event table KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 8/2/89 Initial version Don 9/26/89 Major revision sean 3/19/95 To Do list changes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanLoadEvent method DayPlanClass, MSG_DP_LOAD_EVENT uses ax, cx, dx, bp .enter ; A little set up work ; mov ax, bp sub sp, size EventTableEntry mov bp, sp ; SS:BP points to structure push ax ; save the insert value ; Stuff the EventTableEntry structure ; mov ss:[bp].ETE_group, cx mov ss:[bp].ETE_item, dx ; store the group # item #'s mov ax, cx mov di, dx call GP_DBLockDerefDI ; lock the DB event mov ax, es:[di].ES_timeYear mov ss:[bp].ETE_year, ax ; copy the event year mov ax, {word} es:[di].ES_timeDay mov {word} ss:[bp].ETE_day, ax ; copy the event M/D mov ax, {word} es:[di].ES_timeMinute mov {word} ss:[bp].ETE_minute, ax ; copy the event time mov ax, es:[di].ES_repeatID mov ss:[bp].ETE_repeatID, ax ; copy the repeat ID mov ax, es:[di].ES_dataLength ; length of text => AX RespCheckDB ; EC check db call DBUnlock ; unlock the DB event ; ; Insert the EventTableEntry ; pop dx ; restore insertion indicator cmp ax, INK_DATA_LENGTH ; check for INK (hack, hack) mov ax, MSG_DP_LOAD_INK ; assume we have ink je sendMessage ; if we have ink, jump mov ax, MSG_DP_INSERT_ETE ; insert the event sendMessage: call ObjCallInstanceNoLock jc done ; if too many events - fail ; Do we need to insert it into the screen ?? ; clr bp ; don't know buffer handle mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access instance data test ds:[di].DPI_flags, DP_LOADING ; are we loading ?? jne done ; yes, do nothing (carry clear) push dx ; save the actual event offset mov ax, MSG_DP_SCREEN_UPDATE mov dl, SUF_STEAL_FROM_BOTTOM ; steal from the bottom, if nec call ObjCallInstanceNoLock ; else insert in the screen ; Force the event to be selected ; pop cx ; actual event offset => CX if _TODO ; if showing To Do list, mov di, ds:[si] ; don't force event to be add di, ds:[di].DayPlan_offset ; selected test ds:[di].DPI_prefFlags, PF_TODO jnz done call CalendarIgnoreInput endif sub sp, size ForceSelectArgs mov bp, sp mov ss:[bp].FSA_message, MSG_META_DUMMY mov ss:[bp].FSA_callBack, 0 ; must zero this out mov ax, MSG_DP_FORCE_SELECT call ObjCallInstanceNoLock add sp, size ForceSelectArgs ; SP can't overflow, so CF = 0 ; Clean up done: lahf ; flags => AH add sp, size EventTableEntry ; restore the stack sahf ; restore carry flag .leave ret DayPlanLoadEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanLoadRepeat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load a repeat event CALLED BY: RepeatLoadEvent PASS: CX = RepeatStruct group # DX = RepeatStruct item # SS:BP = EventRangeStruct DS:*SI = DayPlan instance data RETURN: Carry = Set if error (too many events) DESTROYED: BX, DI, SI, ES PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/20/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanLoadRepeat method DayPlanClass, MSG_DP_LOAD_REPEAT uses ax, cx, dx .enter ; A little set up work ; mov bx, bp ; SS:BX points to EventRange sub sp, size EventTableEntry mov bp, sp ; SS:BP points to ETE struct ; Stuff the EventTableEntry structure ; mov ss:[bp].ETE_group, cx mov ss:[bp].ETE_item, dx ; store the group # item #'s mov di, ss:[bx].ERS_startYear mov ss:[bp].ETE_year, di ; store the year mov ax, ss:[bx].ERS_curMonthDay mov {word} ss:[bp].ETE_day, ax ; store the month & day xchg ax, cx ; swap Month/Day & group xchg di, dx ; swap Year, item # and ax, not REPEAT_MASK ; clear the repeat bit call GP_DBLockDerefDI ; lock the DB event mov ax, {word} es:[di].RES_minute mov {word} ss:[bp].ETE_minute, ax ; copy the event time mov ax, es:[di].RES_ID mov ss:[bp].ETE_repeatID, ax ; copy the repeat ID RespCheckDB call DBUnlock ; Insert the EventTableEntry (if necessary) ; call RepeatExistAlready ; look for this repeat event cmc ; invert the carry jnc done ; if found, don't add! clr dx ; calc insertion point mov ax, MSG_DP_INSERT_ETE ; insert the event call ObjCallInstanceNoLock ; insert the event jc done ; if no room, fail ; Do we need to insert it into the screen ?? ; mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access instance data test ds:[di].DPI_flags, DP_LOADING ; are we loading ?? jnz done ; yes, so do nothing mov ax, MSG_DP_SCREEN_UPDATE mov dl, SUF_STEAL_FROM_BOTTOM ; steal from the bottom, if nec call ObjCallInstanceNoLock ; else insert in the screen clc ; clear the carry ; Clean up (carry flag correct at this point) done: lahf ; flags => AH add sp, size EventTableEntry ; restore the stack mov bp, bx ; put EventRange back to SS:BP sahf ; restore the carry flag .leave ret DayPlanLoadRepeat endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RepeatExistAlready %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Checks if a specific RepeatID has already been loaded CALLED BY: DayPlanLoadRepeat PASS: DS:*SI = DayPlan instance dat AX = Repeat ID CX = Month/Day DX = Year RETURN: Carry = Set if found = Clear if not DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/28/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ RepeatExistAlready proc near class DayPlanClass uses bx, di .enter ; Access the EventTable, to search for the RepeatID ; mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access instance data mov di, ds:[di].DPI_eventTable ; get table handle mov di, ds:[di] ; dereference the handle mov bx, ds:[di].ETH_last ; last offset position add bx, di ; last true position add di, (size EventTableHeader) - (size EventTableEntry) ; Look for the ID ; searchLoop: add di, size EventTableEntry cmp di, bx je done ; carry flag clear when equal cmp dx, ds:[di].ETE_year jne searchLoop cmp cx, {word} ds:[di].ETE_day jne searchLoop cmp ax, ds:[di].ETE_repeatID jne searchLoop ; jump if not equal stc ; found - set the carry flag done: .leave ret RepeatExistAlready endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DPHandleKeyStroke %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: A key was pressed from month view or week view Bring up details dialog CALLED BY: MSG_DP_HANDLE_KEY_STROKE PASS: *ds:si = DayPlanClass object ds:di = DayPlanClass instance data ds:bx = DayPlanClass object (same as *ds:si) es = segment of DayPlanClass ax = message # cx = character dx = hour bp = DayPlanHandleKeyStrokeFlag RETURN: nothing DESTROYED: ax, cx, dx REVISION HISTORY: Name Date Description ---- ---- ----------- jang 2/10/97 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanNewEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add a new event to a day plan at the specified date/time CALLED BY: Many (MSG_DP_NEW_EVENT) PASS: ES = DGroup DS:*SI = DayPlan instance data BP = Year DX = Month/Day CX = Hour/Minute RETURN: BP = Handle of new DayEvent (if on screen, else 0) Carry = Set if load failed DESTROYED: AX, BX, CX, DX, SI, DI, ES PSEUDO CODE/STRATEGY: Create the EventTableEntry Insert it into the EventTable Insert the event visually Attempt to select it Set the undo action KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 7/29/89 Initial version Don 12/6/89 Major revision %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanNewEvent method DayPlanClass, MSG_DP_NEW_EVENT .enter ; Some set-up work ; mov di, bp ; Year to DI sub sp, size EventTableEntry ; allocate room on the stack mov bp, sp ; SS:BP points to struct ; Stuff the EventTableEntry ; clr ax mov {word} ss:[bp].ETE_minute, cx mov {word} ss:[bp].ETE_day, dx mov ss:[bp].ETE_year, di mov ss:[bp].ETE_group, ax mov ss:[bp].ETE_item, ax mov ss:[bp].ETE_size, ax mov ss:[bp].ETE_handle, ax mov ss:[bp].ETE_repeatID, ax clr dx ; calculate the insertion point mov ax, MSG_DP_INSERT_ETE call ObjCallInstanceNoLock ; call myself to insert it jc done ; if no space, fail push dx ; save the actual event offset ; Now handle the screen update ; mov ax, MSG_DP_SCREEN_UPDATE mov dl, SUF_STEAL_FROM_BOTTOM ; steal from the bottom, if nec call ObjCallInstanceNoLock ; Now attempt to make it the selected item, and select the time ; pop cx ; event offset => CX sub sp, size ForceSelectArgs mov bp, sp mov ss:[bp].FSA_message, MSG_DE_SELECT_TIME mov ss:[bp].FSA_callBack, 0 ; must zero this out mov ax, MSG_DP_FORCE_SELECT call ObjCallInstanceNoLock add sp, size ForceSelectArgs call UndoNotifyInsertEvent clc ; ensure carry is clear ; We're outta here done: lahf ; flags => AH add sp, size EventTableEntry ; restore the stack sahf ; restore the carry flag .leave ret DayPlanNewEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanDeleteEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove the selected event from the dayplan CALLED BY: UI (MSG_DP_DELETE_EVENT) PASS: DS:*SI = DayPlanClass instance data DS:DI = DayPlanClass specific instance data ES = DGroup RETURN: AX = UndoActionValue, if event deleted (-1 otherwise) DESTROYED: CX, DX, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/7/90 Initial version Don 6/2/90 Incorporated DayPlanDeleteETE Don 7/10/90 Do nothing if event not found sean 1/3/96 Responder re-add template events reza 2/7/97 broke out Responder code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanDeleteEvent method dynamic DayPlanClass, MSG_DP_DELETE_EVENT .enter ; Access the current selected event ; mov bp, ds:[di].DPI_selectEvent ; get handle of selected event tst bp ; something selected ?? jz doneShort ; no, so do nothing if HANDLE_MAILBOX_MSG ; Do delete update SMS, if necessary. ; push si mov si, bp ; *ds:si <- DayEvent obj mov ax, MSG_DE_CANCEL_ALL_APPOINTMENT call ObjCallInstanceNoLock ; ax, cx, dx, bp destroyed mov bp, si pop si endif call DayPlanSearchByBuffer ; carry set it found jnc doneShort ; do nothing if not found ; Make certain we're not deleting a Repeating Event ; push di ; save the EventTable handle mov di, ds:[di] ; dereference the handle test ds:[di][bx].ETE_group, REPEAT_MASK mov cx, ds:[di][bx].ETE_repeatID pop di ; restore the EventTable handle jnz doneShort ; if RepeatEvent, do nothing! ; If we are deleting the descendant of a repeating event that still ; exists, we want to re-display the repeating event ; jcxz nukeEvent ; if not descendant, nuke event call RepeatIDStillExist ; RepeatStruct group:item=>CX:DX ; time => AX jnc nukeEvent ; if ID not found, delete event ; Now here is where things get cute. We fool ourselves by saying ; that we are about to perform a state change, from repeat to ; normal, and then immediately perform an undo of that non-existent ; change, which will result in the repeating event appearing. ; call UndoNotifyStateChange ; (registers already set up) mov ax, MSG_GEN_PROCESS_UNDO_PLAYBACK_CHAIN call GeodeGetProcessHandle call ObjMessage_dayplan_call doneShort: mov ax, -1 ; can't UNDO this jmp done ; Clear the selection; set the triggers' status nukeEvent: push bp ; save the DayEvent handle clr bp ; disable the undo trigger mov ax, MSG_DP_SET_SELECT call ObjCallInstanceNoLock pop bp ; restore the DayEvent handle ; Remove the EventTableEntry, the DayEvent from the visual tree, ; and ensure the DayEvent data is updated. Also, disable the ; display errors bit in case of an invalid time. ; and es:[systemStatus], not SF_DISPLAY_ERRORS push bp ; save the DayEvent handle mov ax, bp ; buffer handle => AX mov bp, di ; Event table => DS:*BP call BufferFree ; free the DayEvent call DayPlanDeleteCommon ; do the dirty work! ; For Responder, we want to re-add template events, if we ; happen to be deleting a template event. (sean 1/3/96) ; pop bp ; DayEvent handle => BP push bx ; save the EventTable offset or es:[systemStatus], SF_DISPLAY_ERRORS ; Now delete it from the database (also sets the undo action!) ; call GeodeGetProcessHandle mov ax, MSG_CALENDAR_DELETE_EVENT call ObjMessage_dayplan_call ; UndoActionValue => AX ; Finally, call for the screen to be updated properly ; pop cx ; offset to begin working push ax mov ax, MSG_DP_SCREEN_UPDATE ; update the screen mov dl, SUF_STEAL_FROM_TOP ; steal from the top, if nec call ObjCallInstanceNoLock ; send that method call DayPlanAbortSearch ; abort any search pop ax done: .leave ret DayPlanDeleteEvent endp if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DPChangeToDoEventStatus %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Changes DayPlan's selected event priority. This only makes sense for To Do list events. *Note*--An event's priority information is stored in the timeMinute field. Since To Do events don't use this field, and since code already exists to order events on time, we can prioritize To Do list events with use of the timeMinute field. CALLED BY: MSG_DP_CHANGE_EVENT_TO_NORMAL_PRIORITY, MSG_DP_CHANGE_EVENT_TO_HIGH_PRIORITY PASS: *ds:si = DayPlanClass object ds:di = DayPlanClass instance data ds:bx = DayPlanClass object (same as *ds:si) es = segment of DayPlanClass ax = message # RETURN: nothing DESTROYED: ax,bx,cx,dx,si,bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: Get the DayPlan's selected event If already this priority done Else Clear the event's complete field (no longer complete) Set event's time (since the timeMinute field is the event's priority for To do list events) Update this change to the database Change event within the EventTable Redraw Screen REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/15/95 Initial version sean 10/2/95 Force the event to be selected/EC code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DPChangeToDoEventStatus method dynamic DayPlanClass, MSG_DP_CHANGE_EVENT_TO_NORMAL_PRIORITY, MSG_DP_CHANGE_EVENT_TO_HIGH_PRIORITY .enter ; Access the current selected event ; mov dx, ax ; dx = message mov ax, MSG_DP_GET_SELECT call ObjCallInstanceNoLock ; bp = selected event tst bp ; something selected ?? EC < ERROR_Z MEMORY_HANDLE_DOESNT_EXIST > NEC < jz done ; no, so do nothing > call IsSamePriority ; check if same jc done ; priority ; Calculate the event's offset into EventTable ; call DayPlanSearchByBuffer ; bx = event ETE offset EC < ERROR_NC EVENT_TABLE_SEARCH_FAILED > NEC < jnc done > ; Clear the complete field ; mov ax, MSG_DP_CLEAR_COMPLETE ; clear completed field call ObjCallInstanceNoLock ; Since the priority information of a To Do event is ; stored in a DayEvent's time, we set its time ; mov ax, MSG_DE_SET_TIME mov ch, TODO_DUMMY_HOUR mov cl, TODO_NORMAL_PRIORITY ; priority info in event minute cmp dx, MSG_DP_CHANGE_EVENT_TO_NORMAL_PRIORITY je continue mov cl, TODO_HIGH_PRIORITY continue: push si ; save DayPlan handle mov si, bp ; DayEvent handle => si call ObjCallInstanceNoLock pop bp ; restore DayPlan handle ; Update this event ; mov ax, MSG_DE_UPDATE mov cl, DBUF_TIME ; we're updating event time call ObjCallInstanceNoLock ; Place event into correct place in EventTable ; Note--bx = offset of event in event table prior to shuffle ; call ShuffleETE ; cx => offset of new position push cx ; for event in event table ; We use the lower of the two offsets in the EventTable ; between bx and cx. ; mov ax, MSG_DP_SCREEN_UPDATE cmp cx, bx ; which is smaller ? jle highPriority ; cx = offset in EventTable mov cx, bx ; to begin update highPriority: mov si, bp ; dayPlan => si clr dl call ObjCallInstanceNoLock ; Force the changed event to be selected ; call CalendarIgnoreInput mov ax, MSG_DP_FORCE_SELECT pop cx ; restore offset in ETE mov dx, size ForceSelectArgs sub sp, dx mov bp, sp mov ss:[bp].FSA_message, MSG_DE_SELECT_TIME clr ss:[bp].FSA_callBack call ObjCallInstanceNoLock add sp, size ForceSelectArgs done: .leave ret DPChangeToDoEventStatus endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IsSamePriority %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Checks if a DayEvent is changing status. CALLED BY: DPNormalPriority (MSG_DP_CHANGE_EVENT_TO_NORMAL_PRIORITY) DPHighPriority (MSG_DP_CHANGE_EVENT_TO_HIGH_PRIORITY) PASS: dx = message TODO_NORMAL_PRIORITY TODO_HIGH_PRIORITY bp = DayEvent handle RETURN: carry set if event already has passed priority carry clear if event has different priority DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: If completed or different priority clear the carry flag Else (not completed and same priority) set the carry flag REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/16/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ IsSamePriority proc near uses bx,di,bp .enter EC < Assert objectPtr, dsbp, DayEventClass > mov bl, TODO_NORMAL_PRIORITY cmp dx, MSG_DP_CHANGE_EVENT_TO_NORMAL_PRIORITY je continue mov bl, TODO_HIGH_PRIORITY continue: mov di, ds:[bp] ; dereference dayevent add di, ds:[di].DayEvent_offset cmp ds:[di].DEI_alarmMinute, TODO_COMPLETED clc jz done ; completed--clear carry cmp ds:[di].DEI_timeMinute, bl clc jnz done ; not same priority--clear stc ; same priority & not complete done: .leave ret IsSamePriority endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ShuffleETE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Changes an EventTableEntry's position within the Event Table after its priority has changed. CALLED BY: DPHighPriority (MSG_DP_CHANGE_EVENT_TO_HIGH_PRIORITY) DPNormalPriority (MSG_DP_CHANGE_EVENT_TO_NORMAL_PRIORITY) PASS: ds:*si = DayEvent object ds:*bp = DayPlan object ds:*di = EventTable bx = offset of ETE into EventTable (i.e. ds:[*di][bx] = ETE) RETURN: cx = EventTableEntry offset for shuffled event DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: Copy event's EventTableEntry to stack call InsertETE putting Event into new position (based on new priority) Find old EventTableEntry with old DayEvent handle Delete old EventTableEntry Calculate new EventTableEntry offset REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/16/95 Initial version sean 10/2/95 Fixed bug, EC code sean 12/13/95 Fixed 40716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ShuffleETE proc near uses ax,bx,dx,si,di,bp,es .enter EC < Assert objectPtr, dssi, DayEventClass > EC < Assert objectPtr, dsbp, DayPlanClass > ; Force DayEvent to update if necessary. Fixes #40716. ; (sean 12/13/95). ; mov ax, MSG_DE_UPDATE mov cl, DBUF_IF_NECESSARY call ObjCallInstanceNoLock ; Copy EventTableEntry onto stack, then insert it ; push si ; save DayEvent handle mov si, ds:[di] ; deref EventTable EC < cmp bx, ds:[si].ETH_last > EC < ERROR_GE DP_SELECT_IF_POSSIBLE_BAD_OFFSET > cmp ds:[si].ETH_last, LARGEST_EVENT_TABLE jge popExit ; event table full add si, bx ; ds:si = EventTableEntry sub sp, size EventTableEntry ; create EventTableEntry segmov es, ss, di ; on stack mov di, sp ; es:di = EventTableEntry mov cx, size EventTableEntry ; # bytes to copy rep movsb ; copy ; Insert EventTableEntry into new position ; mov ax, MSG_DP_INSERT_ETE mov si, bp ; DayPlan handle mov bp, sp ; ss:bp = EventTableEntry clr dx ; calculate insertion call ObjCallInstanceNoLock ; dx => offset of event add sp, size EventTableEntry ; restore stack ; Delete old EventTableEntry ; pop bp ; DayEvent handle => bp call DayPlanSearchByBuffer ; bx = offset into EventTable mov ax, bp ; buffer handle => ax mov bp, di ; Event table => bp call BufferFree ; free the DayEvent call DayPlanDeleteCommon ; cx:dx = Gr:It of event ; Return new offset of event ; call DayPlanSearchByEvent ; bx = event ETE offset EC < ERROR_NC EVENT_TABLE_SEARCH_FAILED > mov cx, bx ; cx = event ETE offset exit: .leave ret ; Trying to shuffle when table is full. So pop, then ; return offset to update & force select first event. ; popExit: pop si mov cx, bx jmp exit ShuffleETE endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DPEventCompleted %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Tells the DayPlan object to mark the selected DayEvent as completed. Only To Do list events can be marked completed or not completed. *Note*--An event's completed information is stored in its alarmMinute field. To Do list events do not use this field, so it is reused to store completed information. CALLED BY: MSG_DP_EVENT_COMPLETED PASS: *ds:si = DayPlanClass object ds:di = DayPlanClass instance data ds:bx = DayPlanClass object (same as *ds:si) es = segment of DayPlanClass ax = message # RETURN: nothing DESTROYED: ax,bx,cx,dx,si,bp SIDE EFFECTS: none PSEUDO CODE/STRATEGY: Get the DayPlan's selected event If completed field set done Else Clear the selected event Change the event's alarmMinute (completed) field Update event (store new alarmMinute info to database) Redraw screen REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/17/95 Initial version sean 10/2/95 Cleaned up/EC code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DPEventCompleted method dynamic DayPlanClass, MSG_DP_EVENT_COMPLETED .enter ; Access the current selected event ; mov ax, MSG_DP_GET_SELECT call ObjCallInstanceNoLock ; bp = selected event tst bp ; something selected ?? EC < ERROR_Z MEMORY_HANDLE_DOESNT_EXIST > NEC < jz done ; no, so do nothing > ; If completed field is not set, we set it ; otherwise, nothing. Completed information ; is stored in the To Do event's alarmMinute field ; mov di, ds:[bp] ; dereference dayevent add di, ds:[di].DayEvent_offset cmp ds:[di].DEI_alarmMinute, TODO_COMPLETED je done ; completed info in alarmMinute ; Store this change ; mov ax, MSG_DE_UPDATE ; update DayEvent mov si, bp ; DayEvent => si mov dl, TODO_COMPLETED ; changing completed info mov ds:[di].DEI_alarmMinute, dl ; completed info in alarmMinute mov cl, DBUF_ALARM ; so we up date alarm info call ObjCallInstanceNoLock ; Redisplay event ; mov ax, MSG_VIS_INVALIDATE ; redraw DayEvent object call ObjCallInstanceNoLock done: .leave ret DPEventCompleted endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DPClearComplete %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Clear the completed field for the DayPlan's selected To Do list event. This method only makes sense if the DayPlan is in "To Do List" mode. *Note*--An event's completed information is stored in its alarmMinute field. To Do list events do not use this field, so it is reused to store completed information. CALLED BY: MSG_DP_CLEAR_COMPLETE PASS: *ds:si = DayPlanClass object ds:di = DayPlanClass instance data ds:bx = DayPlanClass object (same as *ds:si) es = segment of DayPlanClass ax = message # RETURN: nothing DESTROYED: ax,cx,di,si SIDE EFFECTS: none PSEUDO CODE/STRATEGY: Get the DayPlan's selected event If completed field clear done Else Clear the selected event Change the event's alarmMinute (completed) field Update event (store new alarmMinute info to database) REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/29/95 Initial version sean 10/2/95 Cleaned up/EC code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DPClearComplete method dynamic DayPlanClass, MSG_DP_CLEAR_COMPLETE uses dx, bp .enter ; Access the current selected event ; mov ax, MSG_DP_GET_SELECT call ObjCallInstanceNoLock ; bp = selected event tst bp ; something selected ?? EC < ERROR_Z MEMORY_HANDLE_DOESNT_EXIST > NEC < jz done ; no, so do nothing > ; If event is already NotCompleted, then done. ; Else change completed field (alarmMinute) to NotCompleted. ; mov di, ds:[bp] ; dereference dayevent mov si, bp ; DayEvent handle => si add di, ds:[di].DayEvent_offset cmp ds:[di].DEI_alarmMinute, TODO_NOT_COMPLETED je done ; completed info in alarmMinute mov dl, TODO_NOT_COMPLETED ; Store this change ; mov ds:[di].DEI_alarmMinute, dl ; completed info in alarmMinute mov ax, MSG_DE_UPDATE ; so we update alarm info mov cl, DBUF_ALARM call ObjCallInstanceNoLock done: .leave ret DPClearComplete endm endif ; if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanDeleteRepeatEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove all occurrences of the repeating event from the DayPlan CALLED BY: RepeatDelete (MSG_DP_DELETE_REPEAT_EVENT) PASS: ES = DGroup DS:*SI = DayPlan instance data CX = RepeatStruct - Group # DX = RepeatStruct - Item # RETURN: Nothing DESTROYED: AX, BX, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: This implementation is very slow, but hopefully easy. It should be OK to be slow becuase multiple occurrences of a single RepeatEvent should be pretty unusual. REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/15/90 Initial version Don 4/20/90 Utilized common search routine sean 1/3/96 Responder re-add template events Also, we update from deletion instead of entire screen. *Note*--Since Responder doesn't have more than occurance of a repeat event in the DayPlan at a time, we don't have to update the entire screen. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanDeleteRepeatEvent method DayPlanClass, MSG_DP_DELETE_REPEAT_EVENT uses cx, dx, bp .enter ; A little set-up work ; clr ax ; clear the initial offset or cx, REPEAT_MASK ; set the low bit, thank you ; Loop from the top loopAll: push ax ; save inital delete offset call DayPlanSearchByEvent ; => carry set if found jnc cleanUp ; if no carry, done! mov bp, di ; table handle => BP tst ax ; a valid handle (on screen?) je finishDelete ; no, so jump call BufferFree ; else free the buffer finishDelete: call DayPlanDeleteCommon ; delete the ETE (& header) pop ax ; restore the initial offset tst ax ; have we deleted yet? jnz loopAll ; yes, so loop mov ax, bx ; set first delete offset jmp loopAll ; loop again, dude! ; Finish by re-drawing the screen cleanUp: pop ax ; restore the initial offset tst ax ; did we delete any events? jz done ; no, so exit call DayPlanAbortSearch ; abort any search push ax ; save the first offset mov di, ds:[di] ; dereference the table handle mov ds:[di].ETH_screenFirst, OFF_SCREEN_TOP mov ds:[di].ETH_screenLast, OFF_SCREEN_BOTTOM mov cl, BufferUpdateFlags<1, 1, 1> ; delete, write-back, notify call BufferAllWriteAndFree ; free all buffer usage pop cx ; restore first offset mov ax, MSG_DP_SCREEN_UPDATE ; method to send clr dl ; send no ScreenUpdateFlags call ObjCallInstanceNoLock ; update the screen done: .leave ret DayPlanDeleteRepeatEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanAbortSearch %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Abort the search that is in progress CALLED BY: DayPlan & DayEvent INTERNAL PASS: DS = DPResource segment ES = DGroup RETURN: Nothing DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 11/14/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanAbortSearch proc near .enter ; Indicate that the next search should start from the beginning ; or es:[searchInfo], mask SI_RESET .leave ret DayPlanAbortSearch endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanInsertETE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Insert the events properly within the EventTable CALLED BY: DayPlanAddEvent, DayPlanNewEvent (MSG_DP_INSERT_ETE) PASS: DS:*SI = DayPlan instance data ES = DGroup DX = 0 to calculate insertion point = anything else to insert at end (blindly) SS:BP = EventTableEntry RETURN: CX = Offset to insertion point (update from here) DX = Offset to the actual event Carry = Set if too many events are now loaded DESTROYED: DI PSEUDO CODE/STRATEGY: Search for correct place to insert (if DX == 0) Do we need to insert a header Yes - insrt the header Increase table size (if necessary) Write the data KNOWN BUGS/SIDE EFFECTS/IDEAS: Note: Notice that the actual event offset may differ from the insertion point, as a header event could have been inserted BEFORE the actual event. REVISION HISTORY: Name Date Description ---- ---- ----------- Don 7/26/89 Initial version Don 9/26/89 Major revision Don 12/4/89 Changed to manage myself Don 6/2/90 Return both offsets, not just update offset %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ LARGEST_EVENT_TABLE = (size EventTableHeader + \ (MAX_NUM_EVENTS * (size EventTableEntry))) DayPlanInsertETE method DayPlanClass, MSG_DP_INSERT_ETE uses ax, bx, si, bp .enter ; Set some update flags, see if we need to delete events ; push si ; save the DayPlan chunk mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access my instance data or ds:[di].DPI_flags, DP_NEEDS_REDRAW test ds:[di].DPI_flags, DP_DEL_ON_LOAD je startInsert ; no need to delete, so jump and ds:[di].DPI_flags, not DP_DEL_ON_LOAD mov cl, BufferUpdateFlags <1, 0, 1> ; write back & visually remove mov ax, MSG_DP_DELETE_RANGE call ObjCallInstanceNoLock ; delete the template... mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access my instance data ; Go to the beginning of the table startInsert: or ds:[di].DPI_flags, DP_DIRTY ; set the dirty bit push ds:[di].DPI_viewWidth ; save width on the stack mov si, ds:[di].DPI_eventTable ; move the chunk handle to DI mov di, ds:[si] ; dereference the pointer mov bx, ds:[di].ETH_last ; go to the last position cmp bx, LARGEST_EVENT_TABLE ; too many events ?? jae tooManyEvents ; yes, so display error cmp dx, 1 ; just insert at the end ?? je insert ; go to insert the entry ; Search for the insertion point ; push bp ; save the EventTableEntry mov ax, ss:[bp].ETE_repeatID mov cx, {word} ss:[bp].ETE_minute mov dx, {word} ss:[bp].ETE_day mov bp, ss:[bp].ETE_year mov bx, (size EventTableHeader) - (size EventTableEntry) ; Loop until we find the insertion point search: add bx, size EventTableEntry ; go to the next structure cmp bx, ds:[di].ETH_last ; at the least entry ?? je doneSearch call EventCompare ; else compare the events jge search ; continue until time is less doneSearch: pop bp ; restore the EventTableEntry ; Perform the insertion insert: mov dx, bx ; original offset => DX call DayPlanInsertHeader ; insert the header here! call InsertETEAndUpdate ; insert an ETE; update header ; Store the EventTable information ; add di, bx ; go the this entry mov ax, ss:[bp].ETE_year mov ds:[di].ETE_year, ax mov ax, {word} ss:[bp].ETE_day mov {word} ds:[di].ETE_day, ax mov ax, {word} ss:[bp].ETE_minute mov {word} ds:[di].ETE_minute, ax mov ax, ss:[bp].ETE_repeatID mov ds:[di].ETE_repeatID, ax mov ax, ss:[bp].ETE_group mov ds:[di].ETE_group, ax ; group # => AX mov cx, ss:[bp].ETE_item mov ds:[di].ETE_item, cx ; item # => CX mov ds:[di].ETE_handle, 0 ; not currently displayed ; Calculate the correct size ; mov di, cx ; item # to DI pop cx ; width of window to CX sub cx, es:[timeOffset] ; take away offset to time sub cx, es:[timeWidth] ; take away the time width push dx ; save the original offset call EventCalcHeight ; calculate the height pop cx ; original insertion to CX mov di, ds:[si] ; dereference the table mov ds:[di][bx].ETE_size, dx ; save the size pop si ; DayPlan chunk => SI mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access my instance data add ds:[di].DPI_docHeight, dx ; update the document size mov dx, bx ; actual event offset => DX clc ; return success done: .leave ret ; Display error for too many events. For Responder, we ; display this error only when in wide mode(i.e event view ; or To-do list). Furthermore, if To-do list turn off "Mark ; as" trigger, since this messes with EventTable(bad). ; tooManyEvents: mov bp, CAL_ERROR_ET_TOO_BIG mov ax, MSG_CALENDAR_DISPLAY_ERROR mov bx, ds:[LMBH_handle] ; resource handle => BX call MemOwner ; my process => BX call ObjMessage_dayplan_call ; display the error pop ax, ax ; clear the stack stc ; carry indicates failure jmp done ; we're outta here DayPlanInsertETE endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EventCompare %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compare's two events by their time. If the times are the same, and both are repeating events, then order by Repeat ID (this is to ensure that modified repeating events are displayed in the correct order immediately after modification) CALLED BY: DayPlanInsertEvent PASS: DS:DI = EventTable BX = Offset to the EventTableEntry BP = Year DX = Month/Day CX = Hour/Minute AX = Repeat ID (if any) RETURN: Sets N & Z flags DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/27/89 Initial version Don 10/13/94 Ordering for repeating events %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EventCompare proc near class DayPlanClass ; friend to this class .enter ; Just do the comparison ; ; for responder this is removed because Reserve whole day events ; are treated as multiple day events and if we are on the 2nd ; reserve whole day event, event will automatically inserted into ; slot 00:00 regardless of its start time because ETE_day is smaller ; than current date. ; cmp bp, ds:[di][bx].ETE_year jne done cmp dx, {word} ds:[di][bx].ETE_day jne done cmp cx, {word} ds:[di][bx].ETE_minute jne done ; Times are the same. Perform comparison based upon Repeat ID, if ; both events are repeating (or a descendants of a repeating event) ; tst ax jz done ; not repeat, return Z = 1 tst ds:[di][bx].ETE_repeatID jz done ; not repeat, return Z = 1 cmp ax, ds:[di][bx].ETE_repeatID ; ...else perform comparison done: .leave ret EventCompare endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanDeleteCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Involved in removing an EventTableEntry. Does the following: - Update the document size - Remove a header, if necessary - Remove this structure CALLED BY: DayPlanDeleteETE, DayPlanDeleteRepeatEvent PASS: ES = DGroup DS:*SI = DayPlan instance data DS:*BP = EventTable BX = Offset to EventTableEntry to be removed RETURN: CX = Group of deleted ETE DX = Item of deleted ETE DESTROYED: AX, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/15/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanDeleteCommon proc near class DayPlanClass .enter ; Update the document height ; mov di, ds:[bp] ; dereference the event table push ds:[di][bx].ETE_group push ds:[di][bx].ETE_item ; push the group & item #'s mov cx, ds:[di][bx].ETE_size ; event size => CX mov di, ds:[si] ; dereference the DayPlan add di, ds:[di].DayPlan_offset ; access my instance data or ds:[di].DPI_flags, (DP_NEEDS_REDRAW or DP_DIRTY) sub ds:[di].DPI_docHeight, cx ; update the document size ; Delete (??) the header event, and this EventTableEntry ; mov di, bp ; EventTable handle => DI call DayPlanDeleteHeader ; delete header if any call DeleteETEAndUpdate ; delete the structure pop cx, dx ; group => CX; item => DX .leave ret DayPlanDeleteCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanInsertHeader %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Insert a header event into the EventTable (if necessary) CALLED BY: DayPlanInsertEvent PASS: DS:*SI = EventTable ES = DGroup SS:BP = New EventTableEntry BX = Offset to insert new entry RETURN: BX = Adjusted offset DESTROYED: AX, CX, DI PSEUDO CODE/STRATEGY: We need to insert a header event iff: headerFlag = TRUE EventTableEntry prior to new is of a different day KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/1/90 Initial version sean 3/19/95 To Do list changes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanInsertHeader proc near class DayPlanClass .enter ; First check the header flag ; sub bx, size EventTableEntry ; go backward one entry mov di, offset DPResource:DayPlanObject mov di, ds:[di] ; dereference the handle add di, ds:[di].DayPlan_offset ; access the instance data TODO < test ds:[di].DPI_prefFlags, PF_TODO > TODO < jnz done > test ds:[di].DPI_printFlags, mask DPPF_FORCE_HEADERS jnz checkPrior cmp ds:[di].DPI_rangeLength, 1 ; do we want headers ?? je done ; jump if only one day! ; Is prior ETE of the same day ?? checkPrior: mov di, ds:[si] ; derference the EventTable cmp bx, size EventTableHeader jl doInsert ; first entry - insert mov cx, {word} ss:[bp].ETE_day ; new month/day to CX cmp cx, {word} ds:[di][bx].ETE_day jne doInsert ; month/day not equal - insert mov cx, ss:[bp].ETE_year ; new year to CX cmp cx, ds:[di][bx].ETE_year je done ; years equal - done ; Insert the header doInsert: add bx, size EventTableEntry ; restore BX to insert position call InsertETEAndUpdate ; Store the EventTable information ; clr ax ; zero to AX add di, bx ; go the this entry mov cx, ss:[bp].ETE_year mov ds:[di].ETE_year, cx mov cx, {word} ss:[bp].ETE_day mov {word} ds:[di].ETE_day, cx mov {word} ds:[di].ETE_minute, -2 ; must precede blank, which =-1 mov ds:[di].ETE_repeatID, ax mov ds:[di].ETE_group, ax mov ds:[di].ETE_item, 1 mov ds:[di].ETE_handle, ax ; Update the size information ; mov cx, es:[oneLineTextHeight] ; one line size to CX mov ds:[di].ETE_size, cx ; store the size mov di, offset DPResource:DayPlanObject mov di, ds:[di] add di, ds:[di].DayPlan_offset add ds:[di].DPI_docHeight, cx ; track the document size done: add bx, size EventTableEntry ; update (or restore) index .leave ret DayPlanInsertHeader endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanDeleteHeader %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Delete header event, if no events on the given date no longer exist. CALLED BY: DayPlanDeleteEvent PASS: DS:*SI = DayPlan instance data DS:*DI = EventTable BX = Offset to ETE that will be deleted RETURN: BX = Updated offset DESTROYED: AX, CX, DX PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/6/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanDeleteHeader proc near class DayPlanClass uses di, si, bp .enter ; First some set-up work ; mov si, ds:[si] ; dereference the dayplan add si, ds:[si].DayPlan_offset ; access instance data cmp ds:[si].DPI_rangeLength, 1 ; if one day, no header je done test ds:[si].DPI_flags, DP_HEADERS ; do we want all headers?? jne done ; if so, do nothing mov ax, di ; table handle to AX mov di, ds:[di] ; dereference the table handle mov cx, {word} ds:[di][bx].ETE_day ; month/day => CX mov dx, ds:[di][bx].ETE_year ; year => DX ; Check for event of same date after us ; mov bp, bx ; offset to BP add bp, size EventTableEntry ; BP points at next ETE cmp bp, ds:[di].ETH_last ; offset too big ?? jge checkBefore ; yes, jump cmp cx, {word} ds:[di][bp].ETE_day ; compare month & day jne checkBefore cmp dx, ds:[di][bp].ETE_year ; compare the year je done ; a match - don't delete header ; Check for header before us checkBefore: mov bp, bx sub bp, size EventTableEntry ; go to previous ETE cmp ds:[di][bp].ETE_group, 0 ; is the group zero ?? jne done ; no, so can't be header cmp ds:[di][bp].ETE_item, 1 ; is this a header jne done ; no, so can't be a header ; We have a header - so remove it! ; mov bx, bp ; offset to delete to BX mov cx, ds:[di][bx].ETE_size ; size to CX push ds:[di][bx].ETE_handle ; save the handle sub ds:[si].DPI_docHeight, cx ; update document size mov di, ax ; Table handle back to DI call DeleteETEAndUpdate ; delete the header !! ; Free the handle, if any ; pop ax ; buffer handle to AX tst ax je done call BufferFree ; else free the buffer done: .leave ret DayPlanDeleteHeader endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InsertETEAndUpdate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Inserts an EventTableEntry into the EventTable, and updates the header CALLED BY: DayPlanInsertEvent, DayPlanInsertHeader PASS: DS:*SI = EventTable BX = Offset to insert at RETURN: DS:DI = EventTable DESTROYED: AX, CX PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/2/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InsertETEAndUpdate proc near .enter ; First insert the bytes ; mov ax, si mov cx, size EventTableEntry call LMemInsertAt ; insert the bytes at BX ; Update the header ; mov di, ds:[si] ; dereference the handle again add ds:[di].ETH_last, cx ; move things along cmp ds:[di].ETH_screenLast, OFF_SCREEN_BOTTOM EC < jne continue > EC < cmp ds:[di].ETH_screenFirst, OFF_SCREEN_TOP > EC < je done > EC < ERROR DP_VERIFY_INVALID_EVENT_TABLE > EC <continue: > je done ; if no prev events, do nothing cmp bx, ds:[di].ETH_screenLast ja done ; jump if larger add ds:[di].ETH_screenLast, cx cmp bx, ds:[di].ETH_screenFirst ja done ; jump if larger add ds:[di].ETH_screenFirst, cx done: .leave ret InsertETEAndUpdate endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DeleteETEAndUpdate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Deletes an EventTableEntry from the EventTable, and updates the header CALLED BY: GLOBAL PASS: DS:*DI = EventTable BX = Offset to delete at RETURN: Nothing DESTROYED: AX, CX PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: ScreenFirst could become garbaged! REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/6/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DeleteETEAndUpdate proc near uses si .enter ; First delete the bytes ; mov ax, di ; chunk handle to AX mov cx, size EventTableEntry ; bytes to remove call LMemDeleteAt ; insert the bytes at BX ; Update the header ; mov si, ds:[di] ; dereference the handle again sub ds:[si].ETH_last, cx ; move things along mov ax, ds:[si].ETH_screenLast cmp ax, ds:[si].ETH_screenFirst ; if first = last jne updateHeader ; then no more buffers are used mov ds:[si].ETH_screenFirst, OFF_SCREEN_TOP mov ds:[si].ETH_screenLast, OFF_SCREEN_BOTTOM jmp done updateHeader: cmp bx, ds:[si].ETH_screenLast ja done ; jump if larger sub ds:[si].ETH_screenLast, cx cmp bx, ds:[si].ETH_screenFirst jae done ; jump if larger sub ds:[si].ETH_screenFirst, cx done: .leave ret DeleteETEAndUpdate endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EventCalcHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the height of an event CALLED BY: GLOBAL PASS: AX = Group # for the Event DI = Item # for the Event CX = Width of the event's text field (not the window) DS = DPResource segment ES = DGroup RETURN: DX = The height of the object DESTROYED: AX, DX, DI, BP PSEUDO CODE/STRATEGY: If (AX == 0) Then size = one line height (header or virgin) Else { Stuff size object with the text Calculate the height } Also, if we are printing events inside of a month object, we want events without a time to occupy the entire width, so we calculate by re-adding in the timeWidth offset. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/4/89 Initial version sean 8/1/95 Responder changes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EventCalcHeightFar proc far call EventCalcHeight ret EventCalcHeightFar endp EventCalcHeight proc near uses ax, cx, si, es .enter ; Handle the header & virgin events ; mov dx, es:[oneLineTextHeight] ; one line height to DX tst ax ; no group ?? (VRIGIN EVENT ?) jz done ; If we're in "Narrow" mode for Responder, then we don't want ; multi-line events. ; test es:[searchInfo], mask SI_SEARCHING jnz done ; searching doesn't height push cx ; save the width test ax, REPEAT_MASK ; test for a repeat event jne repeat ; Handle the normal event ; call GP_DBLock ; lock the Event Struct mov bp, es:[di] ; dereference the handle mov cx, es:[bp].ES_dataLength ; # of bytes add bp, offset ES_data ; DX:BP points to the text jmp common ; Handle the repeat case repeat: and ax, not REPEAT_MASK ; clear the mask bit call GP_DBLock ; lock the Repeat Struct mov bp, es:[di] ; dereference the handle mov cx, es:[bp].RES_dataLength add bp, offset RES_data ; Set the text and call for the resize common: DBCS < shr cx, 1 ; cx <- # of chars > mov dx, es mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR ; set the text mov si, ss:[SizeTextObject] ; handle of object to SI call ObjCallInstanceNoLock RespCheckDB call DBUnlock ; unlock the database pop cx ; width => CX clr dx ; don't use cached size mov ax, MSG_VIS_TEXT_CALC_HEIGHT ; calculate the height call ObjCallInstanceNoLock ; returned in DX done: .leave ret EventCalcHeight endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanETEUpdate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Update the group & item numbers of an EventTableEntry CALLED BY: DayEventUpdate (MSG_DP_ETE_UPDATE) PASS: DS:*SI = DayPlan instance data DS:DI = DayPlan specific instance data (by method call) CX = Group # DX = Item # BP = DayEvent handle RETURN: Nothing DESTROYED: BX, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/13/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanETEUpdate method DayPlanClass, MSG_DP_ETE_UPDATE .enter ; Find the handle from the corresponding EventTableEntry ; or ds:[di].DPI_flags, DP_DIRTY ; the DayPlan is now dirty call DayPlanSearchByBuffer jnc done ; jump if not found ; Else reset the group & item numbers ; mov di, ds:[di] ; dereference the EventTable mov ds:[di][bx].ETE_group, cx ; store the group # mov ds:[di][bx].ETE_item, dx ; store the item # ; Get the current selection - see if we are it ; mov bx, bp ; buffer handle => BX mov ax, MSG_DP_GET_SELECT call ObjCallInstanceNoLock xchg bx, bp ; swap the handles cmp bx, bp ; are they the same ?? jne done ; no, so do nothing mov ax, MSG_DP_SET_SELECT ; else resert the selection call ObjCallInstanceNoLock ; send the method done: .leave ret DayPlanETEUpdate endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanETEHeightNotify %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Updates an ETE's size value as the event text changes height CALLED BY: DayEventHeightNotify PASS: DS:*SI = DayPlan instance data BP = Handle of DayEvent CX = DayEvent's top boundary DX = New height RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/9/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanETEHeightNotify method DayPlanClass, MSG_DP_ETE_HEIGHT_NOTIFY .enter ; For Responder, if we're showing the main view(Calendar & ; Events) we don't want events to be multi-line. This fixes ; it so events will only be shown as single-line. (Bug #39100) ; ; Find the handle in the corresponding EventTableEntry ; call DayPlanSearchByBuffer ; look for the event jnc done ; if not found, exit! ; Compare the sizes ; mov di, ds:[di] ; dereference the table handle sub dx, ds:[di][bx].ETE_size ; size difference to DX jz done ; if none, do nothing add ds:[di][bx].ETE_size, dx mov di, ds:[si] ; derference the DayPlan handle add di, ds:[di].DayPlan_offset ; access the instance data add ds:[di].DPI_docHeight, dx ; adjust the document height ; Assume the height has changed, and mark the thing's geometry as ; invalid. ; mov cl, mask VOF_GEOMETRY_INVALID ; mark the geometry as invalid mov dl, VUM_MANUAL call VisMarkInvalid ; Now re-position everything (and redraw) ; mov cx, bx ; ETE offset to CX mov dl, SUF_STEAL_FROM_TOP ; steal from the top mov ax, MSG_DP_SCREEN_UPDATE ; update the screen call ObjCallInstanceNoLock ; re-draws the screen! done: .leave ret DayPlanETEHeightNotify endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanTimeNotify %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Notify the DayPlan of a change in event time CALLED BY: GLOBAL PASS: DS:*SI = DayPlan instance data BP = DayEvent handle (buffer) CX = New time (hours:minutes) RETURN: Nothing DESTROYED: BX, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 5/17/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanTimeNotify method DayPlanClass, MSG_DP_ETE_TIME_NOTIFY .enter ; Find the handle in the corresponding EventTableEntry ; call DayPlanSearchByBuffer ; look for the event jnc done ; if not found, exit! mov di, ds:[di] ; dereference the table handle mov {word} ds:[di][bx].ETE_minute, cx done: .leave ret DayPlanTimeNotify endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanETELostBuffer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Notify an EventTableEntry that it no longer has a buffer (a DayEvent handle) CALLED BY: DayEventVisClose (MSG_DE_ETE_LOST_BUFFER) PASS: DS:*SI = DayEvent instance BP = DayEvent handle that's been lost RETURN: Nothing DESTROYED: AX, BX, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/21/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanETELostBuffer method DayPlanClass, MSG_DP_ETE_LOST_BUFFER .enter ; Find the EventTableEntry; clear the handle ; call DayPlanSearchByBuffer jnc done ; not found - do nothing mov di, ds:[di] ; dereference the EventTable mov ds:[di][bx].ETE_handle, 0 ; clear the stored handle done: .leave ret DayPlanETELostBuffer endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanETEForceUpdate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find (and update) a specific EventStruct CALLED BY: AlarmToScreen PASS: DS:*SI = DayPlan instance data CX = Group # DX = Item # RETURN: Nothing DESTROYED: AX, BX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/1/90 Initial version Don 3/22/90 Broke out separate search routine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanETEForceUpdate method DayPlanClass, MSG_DP_ETE_FORCE_UPDATE uses cx .enter ; Find the event ; call DayPlanSearchByEvent ; find the sucker jnc done ; if not found, done mov di, ds:[di] ; dereference the handle mov si, ds:[di][bx].ETE_handle tst si ; valid handle ?? je done ; no, so jump mov ax, MSG_DE_UPDATE ; else update as needed... mov cl, DBUF_IF_NECESSARY call ObjCallInstanceNoLock done: .leave ret DayPlanETEForceUpdate endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanETEFindEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Search to see if the EventStruct is currently loaded into a DayEvent buffer. CALLED BY: GLOBAL (MSG_DP_ETE_FIND_EVENT) PASS: ES = DGroup DS:*SI = DayEvent instance data CX:DX = Event Group:Item RETURN: BP = Offset in EventTable AX = DayEvent buffer (if present) Carry = Set if found (clear if not) DESTROYED: DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 3/20/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanETEFindEvent method DayPlanClass, MSG_DP_ETE_FIND_EVENT .enter call DayPlanSearchByEvent ; look for the event mov bp, bx ; offset to BP .leave ret DayPlanETEFindEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanSearchByBuffer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Look for a specific EventTableEntry in the EventTable CALLED BY: GLOBAL PASS: DS = DPResource segment BP = DayEvent handle to look for RETURN: DS:*DI = EventTable BX = Offset to the EventTableEntry Carry = Set if found DESTROYED: AX PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/9/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanSearchByBuffer proc near uses si .enter ; Some set-up work ; mov di, offset DPResource:EventTable mov si, ds:[di] ; derference the handle mov bx, (size EventTableHeader - size EventTableEntry) ; Search loop searchLoop: add bx, size EventTableEntry cmp bx, ds:[si].ETH_last ; at the end of the table ?? jge done ; not found, exit (carry clear) cmp bp, ds:[si][bx].ETE_handle jne searchLoop stc ; found, so set the carry bit done: .leave ret DayPlanSearchByBuffer endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanSearchByEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Search through the EventTable by event GROUP:ITEM values CALLED BY: GLOBAL PASS: DS = DPResource segment CX:DX = Event Group:Item to find RETURN: DS:*DI = EventTable BX = Offset to the EventTableEntry AX = DayEvent buffer handle (or 0 if none) Carry = Set if found DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 3/22/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanSearchByEvent proc near uses si .enter ; Some set-up work ; mov di, offset DPResource:EventTable mov si, ds:[di] ; derference the handle mov bx, size EventTableHeader - (size EventTableEntry) ; Search loop searchLoop: add bx, size EventTableEntry cmp bx, ds:[si].ETH_last ; at the end of the table ?? jge done ; not found, exit (carry clear) cmp dx, ds:[si][bx].ETE_item ; compare the items jne searchLoop ; jump if not equal cmp cx, ds:[si][bx].ETE_group ; compare the groups jne searchLoop ; jump if not equal mov ax, ds:[si][bx].ETE_handle ; buffer handle => AX stc ; set carry bit (we found it) done: .leave ret DayPlanSearchByEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanSearchByPosition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Search through the EventTable for an event by its Y position CALLED BY: GLOBAL PASS: DS:*SI = DayPlanClass instance data CX = Y position (document offset) RETURN: DS:*DI = EventTable BX = Offset to the EventTableEntry AX = Top position of the event DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: If the position passed no longer exists, then the offset to the end of the last event is returned. REVISION HISTORY: Name Date Description ---- ---- ----------- Don 4/3/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanSearchByPosition proc far class DayPlanClass uses si .enter ; Some set-up work ; mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access instance data mov di, ds:[di].DPI_eventTable ; access the event table mov si, ds:[di] ; dereference the handle mov bx, (size EventTableHeader) - (size EventTableEntry) clr ax ; begin offset count ; Loop to find position of the first object (actually one past) ; positionLoop: add bx, size EventTableEntry ; go to the next entry cmp bx, ds:[si].ETH_last ; compare with last entry je done ; we're done (carry clear) EC < ERROR_G DP_VERIFY_INVALID_EVENT_TABLE ; bizarre event table > add ax, ds:[si][bx].ETE_size ; add event size => doc offset cmp ax, cx ; compare current with desired jl positionLoop ; go 'round again sub ax, ds:[si][bx].ETE_size ; start position => AX done: .leave ret DayPlanSearchByPosition endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanScreenUpdate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Update the screen after an insertion CALLED BY: GLOBAL (MSG_DP_SCREEN_UPDATE) PASS: DS:*SI = DayEvent instance data CX = Offset to EventTableEntry to start update DL = ScreenUpdateFlags SUF_STEAL_FROM_TOP SUF_STEAL_FROM_BOTTOM SUF_NO_REDRAW SUF_NO_INVALIDATE RETURN: Nothing DESTROYED: AX, BX, DX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/18/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanScreenUpdate method DayPlanClass, MSG_DP_SCREEN_UPDATE .enter ; See if memory is a problem ; mov ax, ds:[LMBH_blockSize] sub ax, ds:[LMBH_totalFree] ; used space => AX cmp ax, LARGE_BLOCK_SIZE ; using too much ? jb setup ; if smaller, don't worry mov ax, MSG_DP_FREE_MEM ; else free some memory mov bx, ds:[LMBH_handle] ; block handle => BX mov di, mask MF_FORCE_QUEUE ; put on end of the queue call ObjMessage ; Access the event table ; setup: push dx ; save ScreenUpdateFlags mov bp, ds:[si] ; dereference the handle add bp, ds:[bp].DayPlan_offset ; access the instance data and ds:[bp].DPI_flags, not DP_NEEDS_REDRAW mov di, ds:[bp].DPI_eventTable ; get the table handle mov di, ds:[di] ; dereference the table handle ; Find the upper screen position of the first buffer ; clr ax ; inital screen offset mov bx, size EventTableHeader ; offset to first ETE jmp midLoop posLoop: add ax, ds:[di][bx].ETE_size ; update the screen add bx, size EventTableEntry ; go to the next structure midLoop: cmp bx, cx jl posLoop push ax, bx ; screen & EventTable offset cmp bx, ds:[di].ETH_last ; if buffer was very last one LONG je position ; ...then just update screen ; ...as that buffer was deleted ; At this point, we need to know if any portion of the original screen ; will still be displayed. If so, we allow the buffer to be allocated ; on an as-needed basis. Else we free all the buffers. This is all ; to keep the buffers allocated contiguously... ; mov cx, bx ; current position => CX sub cx, size EventTableEntry ; can actually be one past... cmp cx, ds:[di].ETH_screenLast ; beyond the last ?? jg freeAll ; yes, so free all mov ds:[di].ETH_temp, ax ; store the screen offset here mov cx, ds:[bp].DPI_docOffset add ax, ds:[di][bx].ETE_size ; bottom of event => AX cmp ax, cx ; my bottom vs document offset jl freeAll ; if not on screen, free all push ds:[di].ETH_temp ; save screen offset push bx ; save table offset add cx, ds:[bp].DPI_viewHeight ; final screen position => CX call CheckScreenPosition ; handle of last event => BX cmp bx, ds:[di].ETH_screenFirst ; compare with first on screen pop ax, bx ; restore screen, table offsets jge midStuffLoop ; if last >= original first ; Free all the current buffers & re-stuff visible events! freeAll: mov cl, BufferUpdateFlags <1, 1, 1> ; write back, notify, delete call BufferAllWriteAndFree ; else free all the buffers mov bp, ds:[si] ; dereference the handle add bp, ds:[bp].DayPlan_offset ; access the instance data mov di, ds:[bp].DPI_eventTable ; get the table handle mov di, ds:[di] ; dereference the handle mov ds:[di].ETH_screenFirst, OFF_SCREEN_TOP mov ds:[di].ETH_screenLast, OFF_SCREEN_BOTTOM pop ax, bx ; remove bogus values clr ax ; start at the top of screen mov bx, size EventTableHeader ; start with the first event push ax, bx ; screen & EventTable offset jmp midStuffLoop ; start at boundary check ; Loop here, allocating & stuffing events as needed ; DS:BP => DayPlan instance data ; DS:DI => EventTable ; AX => Current screen offset ; BX => Current table offset stuffLoop: mov cx, ds:[bp].DPI_docOffset ; screen offset => CX add ax, ds:[di][bx].ETE_size ; update the current offset cmp ax, cx ; compare with our position jl next ; if less, go the next ETE add cx, ds:[bp].DPI_viewHeight ; bottom offset => CX add cx, ds:[di][bx].ETE_size ; comparing with TOP offset cmp ax, cx ; compare current with bottom jge removeEndBuffers ; if greater, just re-position ; Yes, on screen. Need to allocate a buffer (maybe) ; tst ds:[di][bx].ETE_handle ; is this already filled ?? jnz next ; if filled, go to next event push ax ; save the screen position call BufferAllocNoErr ; allocate a buffer call InsertAndStuffEvent ; position & stuff it pop ax ; restore the screen position ; Go to the next event next: mov bp, ds:[si] ; dereference the handle add bp, ds:[bp].DayPlan_offset ; access the instance data mov di, ds:[bp].DPI_eventTable ; get the event table handle mov di, ds:[di] ; dereference the handle add bx, size EventTableEntry ; go to next EventTableEntry midStuffLoop: ; AX & BX MUST BE VALID HERE cmp bx, ds:[di].ETH_last ; any more events ?? jb stuffLoop ; yes, continue ; Remove any buffers that my be present between the current position ; and the ETH_screenLast, iff there is at least one EventTableEntry ; w/o a buffer. ; removeEndBuffers: cmp ds:[di].ETH_screenFirst, OFF_SCREEN_TOP je position ; if no buffers, skip test sub bx, size EventTableEntry removeLoop: add bx, size EventTableEntry cmp bx, ds:[di].ETH_screenLast ; check end condition... jae position ; jump if done tst ds:[di][bx].ETE_handle ; buffer present ?? jnz removeLoop ; yes, so loop again ; Else must free all buffers between current & screenLast ; push si ; save the DayPlan handle mov bp, ds:[di].ETH_screenLast ; last offset for buffers mov ds:[di].ETH_screenLast, bx ; store the new screenLast sub ds:[di].ETH_screenLast, size EventTableEntry mov si, ds:[si] ; dereference the handle add si, ds:[si].DayPlan_offset ; access the instance data mov di, ds:[si].DPI_eventTable ; get the event table handle call DayPlanRemoveBuffers ; remove a range of buffers pop si ; restore the DayPlan handle ; Now position the events position: EC < call DayPlanVerifyEventTable ; ensure valid table > pop cx, dx ; screen & EventTable offset pop bp ; restore ScreenUpdateFlags mov ax, MSG_DP_POSITION_RANGE call ObjCallInstanceNoLock ; send the method mov cx, dx ; ETE offset back to CX ; If we're showing the To Do list, we need to ; renumber the To Do events ; if _TODO push si mov si, ds:[si] add si, ds:[si].DayPlan_offset test ds:[si].DPI_prefFlags, PF_TODO ; To Do mode ? pop si jz continue call RenumberToDoEvents continue: endif .leave ret DayPlanScreenUpdate endp if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RenumberToDoEvents %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Renumbers the To Do list events CALLED BY: DayPlanScreenUpdate PASS: ds:*si = DayPlan object RETURN: nothing DESTROYED: ax,bx,cx,dx,di,si,bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: Get Event table number = 0 for each event in event table (events are in sequence) number++ send it the correct number (MSG_DE_TODO_NUMBER) REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/18/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ RenumberToDoEvents proc near .enter ; Get event table ; mov di, ds:[si] add di, ds:[di].DayPlan_offset mov bp, ds:[di].DPI_eventTable mov di, ds:[bp] ; deref Event table mov bx, size EventTableHeader ; first ETE => bx mov dx, ds:[di].ETH_last ; end of table => dx clr cx ; 0 => cx numberLoop: cmp bx, dx ; are we at end of Event jge done ; Table ? inc cx ; number for this event mov si, ds:[di][bx].ETE_handle ; DayEvent handle => si mov ax, MSG_DE_TODO_NUMBER cmp si,0 ; is there a DayEvent ? jz next ; if not don't number it EC < Assert objectPtr, dssi, DayEventClass > call ObjCallInstanceNoLock ; give event new number next: add bx, size EventTableEntry mov di, ds:[bp] ; redereference EventTable jmp numberLoop done: .leave ret RenumberToDoEvents endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanRemoveBuffers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Free buffers from the EventTable over the specified range CALLED BY: INTERNAL PASS: DS:*DI = EventTable BX = Offset to first ETE to delete at BP = Offset to last ETE to delete RETURN: Nothing DESTROYED: TBD PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/17/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanRemoveBuffers proc near uses ax, si .enter ; Some set-up work ; mov si, ds:[di] ; dereference the table handle jmp middle ; Loop until all handles deleted ; deleteLoop: mov ax, ds:[si][bx].ETE_handle ; buffer handle => AX tst ax ; valid handle ?? jz next ; no, so go to next ETE call BufferFree ; else free the buffer mov si, ds:[di] ; re-dereference the table next: add bx, size EventTableEntry ; go to the next entry middle: cmp bx, bp jbe deleteLoop .leave ret DayPlanRemoveBuffers endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckScreenPosition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the first buffer whose position exceeds the passed screen offset CALLED BY: DayPlanScreenUpdate PASS: DS:DI = EventTable BX = Offset in the EventTable with which to begin AX = Initial screen offset CX = Limit screen offset RETURN: BX = Offset in the EventTable AX = End offset of this Event DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 5/4/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckScreenPosition proc near .enter jmp midLoop ; start at bounds check positionLoop: add ax, ds:[di][bx].ETE_size ; update the screen offset cmp ax, cx ; compare screen positions jge done add bx, size EventTableEntry ; go to the next entry midLoop: cmp bx, ds:[di].ETH_last ; end of table ?? jb positionLoop ; loop if smaller done: .leave ret CheckScreenPosition endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InsertAndStuffEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Insert event into visual tree, and stuff the event CALLED BY: DayPlanScreenInsert PASS: DS:*SI = DayPlan instance data AX = DayEvent buffer BX = Offset to new EventTableEntry RETURN: Nothing DESTROYED: DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/18/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InsertAndStuffEvent proc near class DayPlanClass uses bx, cx, dx .enter ; Some set up work ; mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access the instance data mov di, ds:[di].DPI_eventTable ; get the table handle mov di, ds:[di] ; dereference the handle mov ds:[di][bx].ETE_handle, ax ; store the handle mov cx, bx ; Update the header ; cmp bx, ds:[di].ETH_screenFirst ; compare new offset with first jae last ; jump if larger or equal mov ds:[di].ETH_screenFirst, bx last: cmp bx, ds:[di].ETH_screenLast ; compare new offset with last jbe continue ; jump if less or equal mov ds:[di].ETH_screenLast, bx ; Three case (True first, first in window, other) continue: mov bp, ICO_FIRST ; assume we're 1st visual child cmp bx, size EventTableHeader ; are we absolute first ?? je stuff ; yes, jump sub bx, size EventTableEntry ; else look at previous mov dx, ds:[di][bx].ETE_handle ; get the handle tst dx ; is it zero ?? je stuff ; jump - first in window mov bp, ICO_AFTER_REFERENCE ; else visually add after ; Now stuff and leave stuff: add di, cx ; go to correct ETE call StuffDayEvent ; stuff all the values in .leave ret InsertAndStuffEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanScreenScroll %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Respond to the scrolling work CALLED BY: UI (MSG_META_CONTENT_TRACK_SCROLLING) PASS: DS:*SI = DayPlan instance data DX = size NormalPositionArgs CX = Scrollbar handle SS:BP = TrackScrollingParams RETURN: Nothing DESTROYED: TBD PSEUDO CODE/STRATEGY: Only scrolls vertically (ignores any horizontal scrolling) KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/15/89 Initial version Don 4/4/90 Major changes (simplification) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanScreenScroll method DayPlanClass, MSG_META_CONTENT_TRACK_SCROLLING ; Now see if we need to scroll at all. If so, which direction?? ; call GenSetupTrackingArgs ; set up some extra values mov di, ds:[si] ; dereference the handle add di, ds:[di].DayPlan_offset ; access my data mov dx, ss:[bp].TSP_newOrigin.PD_y.low ; new document offset => DX xchg dx, ds:[di].DPI_docOffset ; get new value; reset it also cmp ds:[di].DPI_docOffset, dx ; compare the offsets je ReturnCall ; if equal, do nothing ; Else store the new offset and request a screen update ; push cx, bp ; save the scrollbar handle mov dl, SUF_STEAL_FROM_TOP ; assume scrolling down jg continue ; new greater than old ?? mov dl, SUF_STEAL_FROM_BOTTOM ; actually scrolling up continue: mov cx, ds:[di].DPI_docOffset ; offset => CX mov bx, size EventTableHeader ; assume the worst test ds:[di].DPI_flags, DP_FILE_VALID jz update ; if no valid file, jump call DayPlanSearchByPosition ; else search for the position update: mov cx, bx ; EventTable offset => CX or dl, SUF_NO_REDRAW ; don't re-draw the DayPlan mov ax, MSG_DP_SCREEN_UPDATE ; update the screen call ObjCallInstanceNoLock ; send the method ; Make the return call ; pop cx, bp ; chunk handle to CX ReturnCall: call GenReturnTrackingArgs ; return arguments ret DayPlanScreenScroll endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanScrollIntoSubview %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Forces a scroll into subview to occur, delayed via the queue from a MyText object to enure the DP's height is correct. CALLED BY: MyTextShowSelection (MSG_DP_SCROLL_INTO_SUBVIEW) PASS: DS:SI = DayPlanClass instance data DS:DI = DayPlanClass specific instance data SS:BP = MakeRectVisibleParams DX = # of bytes on the stack ES = DGroup RETURN: Nothing DESTROYED: AX, BX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 6/28/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanScrollIntoSubview method DayPlanClass, MSG_DP_SCROLL_INTO_SUBVIEW mov ax, MSG_GEN_VIEW_MAKE_RECT_VISIBLE mov di, mask MF_STACK GOTO MessageToEventView DayPlanScrollIntoSubview endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% StuffDayEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Stuff a DayEvent with the database data CALLED BY: GLOBAL PASS: AX = DayEvent handle DX = Object to insert after if BP != ICO_LAST = or DO_NOT_INSERT_VALUE to not insert into a tree BP = InsertChildFlags (or none to not insert into tree) DS:DI = Event table entry RETURN: Nothing DESTROYED: DI PSEUDO CODE/STRATEGY: Must initialize the DayEvent Must position the DayEvent Insert the DayEvent KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/5/89 Initial version SS 3/19/95 To Do list changes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DO_NOT_INSERT_VALUE = 0xffff ; reference child value to not add ; DayEvent into the visual tree StuffDayEvent proc far class DayPlanClass uses ax, bx, cx, dx, si .enter ; Some set-up work ; push dx, bp ; save precede object, CCFlags EC < tst ax > EC < ERROR_Z DP_STUFF_DAY_EVENT_BAD_HANDLE > ; Initialize the event ; mov cx, ds:[di].ETE_group ; DBGroup => CX mov dx, ds:[di].ETE_item ; DBItem => DX mov si, ax ; DayEvent handle => SI tst cx ; no group number ?? je virgin test cx, REPEAT_MASK ; a repeat event ?? jne repeat ; Handle the regular case: ; mov ax, MSG_DE_INIT ; method to call jmp initialize ; initialize ; Handle the repeat case repeat: mov cx, di mov si, offset DPResource:DayPlanObject mov di, ds:[si] add di, ds:[di].DayPlan_offset mov di, ds:[di].DPI_eventTable sub cx, ds:[di] ; true offset to CX mov dx, di ; table handle to DX mov si, ax ; DayEvent handle to SI mov ax, MSG_DE_INIT_REPEAT jmp initialize ; Initialize the virgin event virgin: if _TODO ; a virgin "To Do" event? mov ax, MSG_DE_INIT_TODO push si, di ; if so, initialize it as mov si, offset DPResource:DayPlanObject mov di, ds:[si] ; a "To Do" event add di, ds:[di].DayPlan_offset test ds:[di].DPI_prefFlags, PF_TODO pop si, di jnz contVirgin endif mov ax, MSG_DE_INIT_VIRGIN ; assume not a header tst dx ; check the item # je contVirgin ; if zero, not a header event mov ax, MSG_DE_INIT_HEADER ; else we have a header contVirgin: mov bp, ds:[di].ETE_year mov dx, {word} ds:[di].ETE_day mov cx, {word} ds:[di].ETE_minute ; Now make the call initialize: call ObjCallInstanceNoLock ; method must be in AX ; Insert event into the visible tree ; mov cx, ds:[LMBH_handle] mov dx, si ; object to add (new) mov ax, cx pop bp ; CompChildFlags pop bx ; reference object mov si, offset DPResource:DayPlanObject cmp bx, DO_NOT_INSERT_VALUE ; should we not insert je done ; then don't insert call VisInsertChild done: .leave ret StuffDayEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanPositionRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Position a range (1 or more) or DayEvents CALLED BY: GLOBAL (MSG_DP_POSITION_RANGE) PASS: DS:*SI = DayPlanClass instance data DS:DI = DayPlanClass specific instance data DS:BX = Dereferenced handle ES = DGroup CX = Y position of first object DX = Offset in the EventTable to start at (an ETE) BP = ScreenUpdateFlags SUF_NO_REDRAW SUF_NO_INVALIDATE RETURN: Nothing DESTROYED: AX, BX, CX, SI, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/15/89 Initial version Don 6/18/90 Somewhat optimized Don 9/4/90 Fixed off-by-one bug in window width %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; Must leave room for an icon to get drawn, else we ; may go outside of the graphics bounds!! if ERROR_CHECK DP_MAX_COORD = 2000h else DP_MAX_COORD = MAX_COORD - (ICON_Y_OFFSET - ICON_HEIGHT) endif DayPlanPositionRange method DayPlanClass, MSG_DP_POSITION_RANGE uses dx .enter ; Some set-up work ; mov bx, bp ; flag => BX sub sp, size PositionStruct mov bp, sp push cx, bx, si ; save the draw flag, handle mov ax, ds:[di].DPI_viewWidth ; set up the Position struct mov ss:[bp].PS_totalWidth, ax ; store right position mov ax, ds:[di].DPI_textHeight ; mov ss:[bp].PS_timeHeight, ax ; mov ss:[bp].PS_timeLeft, EVENT_TIME_OFFSET ; If we're showing events in narrow mode, we don't show icons. ; Therefore, EVENT_TIME_OFFSET = 0 (Responder only) ; ; Set up the loop ; mov ax, ds:[di].DPI_docOffset ; top of the screen add ax, ds:[di].DPI_viewHeight ; ending offset => AX mov di, ds:[di].DPI_eventTable ; access the event table mov bx, dx ; offset to begin at jmp midLoop ; start position loop ; We ran out of screen space. Must remove all of the buffers ; below the current one, and reset the current to be the bottom ; of the screen. ; outOfSpace: mov si, ds:[di] ; derference the EventTable mov ds:[si].ETH_screenLast, bx ; this buffer is now the last add bx, size EventTableEntry ; go to the next ETE mov bp, ds:[si].ETH_last ; last offset => BP sub bp, size EventTableEntry ; point to start of last ETE call DayPlanRemoveBuffers ; nuke buffers [BX, BP] jmp update ; continue update process ; Loop while we find DayEvents (proceed until end of the table) sizeLoop: mov dx, ds:[si][bx].ETE_size ; Event height => DX mov si, ds:[si][bx].ETE_handle ; DayEvent handle => SI tst si ; look for no handle jz next ; if none, go to next handle call PositionDayEvent ; else position the event jc outOfSpace ; position failed -> abort! next: add cx, dx ; update the screen offset add bx, size EventTableEntry ; go to the next entry midLoop: mov si, ds:[di] ; derference the EventTable cmp bx, ds:[si].ETH_last ; are we done yet ?? jb sizeLoop ; go through the entire table ; Reset my geometry update: EC < call DayPlanVerifyEventTable ; ensure valid table > pop si ; DayPlan chunk => SI ; Resize if necessary ; mov di, ds:[si] ; dereference the handle mov bp, di ; also => BP add di, ds:[di].DayPlan_offset ; access my DayPlan data add bp, ds:[bp].Vis_offset ; access my visual data and ds:[bp].VI_optFlags, not (mask VOF_GEO_UPDATE_PATH) mov cx, ds:[di].DPI_viewWidth ; new width => CX mov dx, ds:[di].DPI_docHeight ; new height => DX mov bx, ds:[bp].VI_bounds.R_bottom sub bx, ds:[bp].VI_bounds.R_top inc bx ; old height => BX cmp dx, bx ; compare old/new heights jne resize mov ax, ds:[bp].VI_bounds.R_right sub ax, ds:[bp].VI_bounds.R_left inc ax ; width => AX cmp cx, ax je updateOnly resize: ; No bound on document size for Responder. We have a hard ; limit on the number of events instead. ; cmp dx, DP_MAX_COORD ; check for large value jbe resizeNow ; OK, so jump mov dx, DP_MAX_COORD ; else put in the maximum value call DayPlanDisplayTooBigError ; display the error! resizeNow: or ds:[bp].VI_optFlags, (mask VOF_GEO_UPDATE_PATH) call VisSetSize ; set the document size ; Now update the children's geometry flags & possibly the image ; updateOnly: pop dx ; ScreenUpdateFlags => DL pop bx ; restore screen position mov dh, dl ; ScreenUpdateFlags => DH test dh, SUF_NO_INVALIDATE ; don't invalidate ?? jnz done mov cl, mask VOF_WINDOW_INVALID ; force children update mov dl, VUM_NOW call VisMarkInvalid test dh, SUF_NO_REDRAW ; don't redraw (one pending) jnz done ; if set, don't redraw ; Attempt to setup a clip region, to prevent unecessary redraws ; call VisQueryWindow ; get our window => DI tst di ; a valid window ?? jz done ; no, so do nothing ; We need a gstate, so let's VUP for it mov ax, MSG_VIS_VUP_CREATE_GSTATE call ObjCallInstanceNoLock mov di, bp ; load up the bounds of what we want to invalidate clr ax ; left boundary mov bp, ds:[si] ; dereference the handle add bp, ds:[bp].Vis_offset ; access my visual data mov cx, ds:[bp].VI_bounds.R_right ; right boundary mov bp, ds:[si] add bp, ds:[bp].DayPlan_offset mov dx, ds:[bp].DPI_docOffset add dx, ds:[bp].DPI_viewHeight inc dx ; bottom boundary => DX call GrInvalRect call GrDestroyState ; get rid of VUP_CREATED GState done: add sp, size PositionStruct ; restore the stack .leave ret DayPlanPositionRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PositionDayEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Position the DayEvent CALLED BY: DayPlanPositionRange PASS: DS:*SI = DayEvent instance data SS:BP = PositionStruct ES = DGroup CX = Y document position DX = DayEvent height RETURN: Nothing DESTROYED: Nothing PSEUDO CODE/STRATEGY: Position the composite Position the event time Position the event text |----------Window width----------| |_______________________________ | |----------Event width----------|| |icon|-time-|--------text-------|| |___________|___________________|| KNOWN BUGS/SIDE EFFECTS/IDEAS: For DayEvent "headers", we do not want to see the time. Hence, we put the time TextObj off the screen. It is VERY important that the width of the event here EXACTLY match the width that was provided when the length of the event text was calculated. If these widths are not equal, the DayPlan code will die! REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/5/89 Initial version Don 12/13/89 Added the header check Don 9/4/90 Fixed off-by-one bug in positioning sean 3/19/95 Changes to position To Do list events correctly sean 8/9/95 Changes to correctly position end times %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; The event window is getting too long, so tell the user eventsTooLong: call DayPlanDisplayTooBigError mov dx, DP_MAX_COORD ; reset the bottom boundary jmp doneCheck ; we're done PositionDayEvent proc far class VisClass uses ax, bx, cx, dx, di, si .enter ; First position the composite ; mov di, ds:[si] ; dereference the handle mov bx, di add bx, ds:[bx].DayEvent_offset mov al, ds:[bx].DEI_stateFlags ; flags to AL mov ss:[bp].PS_flags, al ; store in the structure mov al, ds:[bx].DEI_timeHour ; time's hour => AL mov ss:[bp].PS_hour, al ; store in the structure add di, ds:[di].Vis_offset ; access visual bounds ; Set up the registers: ; AX => left ; BX => right ; CX => top ; DX => bottom add dx, cx ; bottom => DX ; For Responder, we don't have a bound on the document ; size. We have a bound on the number of events. ; EC < cmp cx, DP_MAX_COORD ; too big ?? > EC < ERROR_G DP_TEST_IN_BOUNDS_TOP_SHOULD_ALWAYS_FIT > cmp dx, DP_MAX_COORD ; bottom too big ?? ja eventsTooLong ; yes, so tell user clc ; else clear the carry doneCheck label near pushf ; save the carry flag push ds:[bx].DEI_textHandle push ds:[bx].DEI_timeHandle clr ax ; left => AX mov bx, ss:[bp].PS_totalWidth ; screen width => BX ; Position the composite first ; mov ds:[di].VI_bounds.R_left, ax mov ds:[di].VI_bounds.R_right, bx mov ds:[di].VI_bounds.R_top, cx mov ds:[di].VI_bounds.R_bottom, dx and ds:[di].VI_optFlags, not (mask VOF_GEOMETRY_INVALID or \ mask VOF_GEO_UPDATE_PATH) ; Now position the event time object ; pop si ; restore the time handle mov di, ds:[si] ; dereference the handle add di, ds:[di].Vis_offset ; access visual data push bx, dx ; save the bottom & right add ax, ss:[bp].PS_timeLeft ; adjust the left boundary mov dx, cx add dx, ss:[bp].PS_timeHeight ; new bottom => DX test ss:[bp].PS_flags, mask EIF_HEADER jnz finishPositionTime mov bx, ax add bx, es:[timeWidth] ; right boundary => BX ; For Responder, we need to see 1) if we're showing events in ; "narrow" mode, and 2) if this event has an end time. If ; we're in "wide" mode with an end time, then the time object ; must be made wider to accomodate the end time. ; finishPositionTime: if _TODO or ds:[di].VI_attrs, mask VA_DETECTABLE test ss:[bp].PS_flags, mask EIF_TODO jz continue ; if not todo it's detectable and ds:[di].VI_attrs, not (mask VA_DETECTABLE) mov bx, ax add bx, TODO_NUMBER_WIDTH continue: endif mov ds:[di].VI_bounds.R_left, ax mov ds:[di].VI_bounds.R_right, bx mov ds:[di].VI_bounds.R_top, cx mov ds:[di].VI_bounds.R_bottom, dx ; This "optimization" breaks the ability to right-justify the time ; text, so it was removed. I have no idea as to the performance ; gain it offers - but it no longer seems necessary. -Don 9/30/99 ; ;;; clr ds:[di].VTI_leftOffset ; one-line text optimization and ds:[di].VI_optFlags, not (mask VOF_GEOMETRY_INVALID or \ mask VOF_GEO_UPDATE_PATH) push bx push cx, bp ; save the bounds info mov ax, MSG_VIS_NOTIFY_GEOMETRY_VALID call ObjCallInstanceNoLock ; notify the text object pop cx, bp ; restore bounds (right=>left) pop ax inc ax ; move left over by one pixel pop bx, dx ; restore right & bottom ; Now position the event text object ; pop si ; restore the event handle mov di, ds:[si] ; dereference the handle add di, ds:[di].Vis_offset ; access visual data test es:[systemStatus], SF_PRINT_MONTH_EVENTS jz headerCheck ; if not printing, ignore clr ax ; else left bounds always 0 headerCheck: or ds:[di].VI_attrs, (mask VA_DRAWABLE or mask VA_DETECTABLE) test ss:[bp].PS_flags, mask EIF_HEADER jz normalText ; if not a header, jump and ds:[di].VI_attrs, not (mask VA_DRAWABLE or mask VA_DETECTABLE) normalText: mov ds:[di].VI_bounds.R_left, ax mov ds:[di].VI_bounds.R_right, bx mov ds:[di].VI_bounds.R_top, cx mov ds:[di].VI_bounds.R_bottom, dx and ds:[di].VI_optFlags, not (mask VOF_GEOMETRY_INVALID or \ mask VOF_GEO_UPDATE_PATH) mov ax, MSG_VIS_NOTIFY_GEOMETRY_VALID call ObjCallInstanceNoLock popf ; restore the carry flag .leave ret PositionDayEvent endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanDisplayTooBigError %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Displays the "document too large error" box. CALLED BY: INTERNAL PASS: ES = DGroup RETURN: Carry = Set DESTROYED: Nothing PSEUDO CODE/STRATEGY: Will only display error iff the SF_DOC_TOO_BIG_ERROR flag is clear, and sets this flag after displaying the message. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 7/20/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanDisplayTooBigError proc near uses ax, bx, di, bp .enter test es:[systemStatus], SF_DOC_TOO_BIG_ERROR jnz done or es:[systemStatus], SF_DOC_TOO_BIG_ERROR call GeodeGetProcessHandle ; process handle => BX mov bp, CAL_ERROR_DOC_TOO_LARGE ; error to display mov ax, MSG_CALENDAR_DISPLAY_ERROR call ObjMessage_dayplan_send ; send the method done: stc ; bad size return flag .leave ret DayPlanDisplayTooBigError endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanChangePreferences %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Force the DayPlan to reload its information CALLED BY: DayPlan preference routines PASS: DS:DI = DayPlanClass specific instance data CX = Start day minute/hour DX = End day minute/hour BP = (High) interval between events BP = (Low) DayPlanInfoFlags (modified) RETURN: Nothing DESTROYED: AX, BX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 4/22/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanChangePreferences method DayPlanClass, MSG_DP_CHANGE_PREFERENCES ; Tell year object to "zoom" on the selected day(s) ; mov dh, ds:[di].DPI_prefFlags ; preference flags => DH mov dl, dh ; also to DL and ds:[di].DPI_prefFlags, not (PF_SINGLE or PF_RANGE or PF_GLOBAL) and dh, (DP_HEADERS or DP_TEMPLATE) ; only real flags and ds:[di].DPI_flags, not (DP_HEADERS or DP_TEMPLATE) or ds:[di].DPI_flags, dh ; store new flags mov dh, PF_SINGLE ; assume one day displayed cmp ds:[di].DPI_rangeLength, 1 ; range length, please je needToChange mov dh, PF_RANGE ; Check if we need to change the Event Window display ; needToChange: test dl, dh ; is the flag set ?? jz checkGlobal ; no - just check for globals or ds:[di].DPI_flags, DP_RELOAD or DP_DIRTY mov ax, MSG_DP_SET_RANGE call ObjCallInstanceNoLock ; Check if globals have changes: ; checkGlobal: test dl, PF_GLOBAL ; global changes ?? jz done ; none - so leave or es:[showFlags], mask SF_SHOW_TODAY_ON_RELAUNCH or \ mask SF_SHOW_NEW_DAY_ON_DATE_CHANGE test dl, PF_ALWAYS_TODAY jnz checkDateChange and es:[showFlags], not (mask SF_SHOW_TODAY_ON_RELAUNCH) checkDateChange: test dl, PF_DATE_CHANGE jnz done and es:[showFlags], not (mask SF_SHOW_NEW_DAY_ON_DATE_CHANGE) done: ret DayPlanChangePreferences endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanUndo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Undo an action CALLED BY: UI (MSG_DP_UNDO) PASS: DS:DI = DayPlan instance data ES = DGroup RETURN: Nothing DESTROYED: AX, BX, CX, DX PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanUndo method DayPlanClass, MSG_DP_UNDO .enter ; Find this event's group & item ; mov bp, ds:[di].DPI_selectEvent ; DayEvent buffer handle => BP call DayPlanSearchByBuffer ; search for the event EC < ERROR_NC DP_UNDO_COULD_NOT_FIND_SELECT_EVENT > mov di, ds:[di] ; dereference the table handle mov cx, ds:[di][bx].ETE_group ; group # => CX mov dx, ds:[di][bx].ETE_item ; item # => DX ; Perform the undo action ; call GeodeGetProcessHandle ; get this process' handle mov ax, MSG_CALENDAR_UNDO ; method to send call ObjMessage_dayplan_call .leave ret DayPlanUndo endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanQuickAdd %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add an empty event to the current day plan CALLED BY: UI (MSG_DP_QUICK_ADD) PASS: DS:*SI = DayPlan instance data DS:DI = DayPlan specific instance data ES = DGroup RETURN: Nothing DESTROYED: AX, BX, CX, DX, BP, DI PSEUDO CODE/STRATEGY: Must loop once through queue, to ensure that any previous Quick Add's are complete (scrolling might have occurred) KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/15/89 Initial version Don 4/21/90 Now adds event after current event Don 7/11/90 Added loop mechanism %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanQuickAdd method DayPlanClass, MSG_DP_QUICK_ADD ; See if the current event's time is valid ; mov ax, MSG_DP_ENSURE_EVENTS_VISIBLE call ObjCallInstanceNoLock mov ax, MSG_DP_GET_SELECT ; get the selected event call ObjCallInstanceNoLock ; DayEvent => BP mov di, ds:[si] add di, ds:[di].DayPlan_offset mov cx, {word} ds:[di].DPI_beginMinute ; first Hour/Minute => CX tst bp ; is there a selected event ?? jz addFirst ; no, add the first event push si mov si, bp mov ax, MSG_DE_UPDATE_TIME call ObjCallInstanceNoLock mov bp, si pop si jc exit ; if error, don't add event ; Update the event time (if necessary) ; mov ax, MSG_DP_UPDATE_ALL_EVENTS ; cuase any times being edited call ObjCallInstanceNoLock ; ...to be updated now! ; Get the event's time & date ; call DayPlanSearchByBuffer ; look for the buffer EC < ERROR_NC DP_QUICK_ADD_SELECT_EVENT_NOT_FOUND > mov di, ds:[di] ; dereference the EventTable mov bp, ds:[di][bx].ETE_year mov dx, {word} ds:[di][bx].ETE_day cmp ds:[di][bx].ETE_item, 1 ; is this a header event ?? je common ; then add at the time in CX mov cx, {word} ds:[di][bx].ETE_minute cmp cx, -1 ; is this time empty ?? je common ; yes, make the new one also! cmp bx, ds:[di].ETH_last ; are we past the last entry ? je common ; if so, no average time add bx, size EventTableEntry ; else go to the next event cmp bp, ds:[di][bx].ETE_year jne common ; if years equal, do nothing... cmp dx, {word} ds:[di][bx].ETE_day jne common ; if day/month not equal, jmp mov ax, {word} ds:[di][bx].ETE_minute ; else next time => AX cmp ax, cx ; if next hour/minute is before jl common ; ...current time, use current call CalcAverageTime ; calculate the average time jmp common ; Else add an event to the top addFirst: mov dx, {word} ds:[di].DPI_startDay ; Month/Day => DX mov bp, ds:[di].DPI_startYear ; Year => BP ; Quickly add an event to the DayPlan common: mov ax, MSG_DP_NEW_EVENT ; add a new event call ObjCallInstanceNoLock exit: ret DayPlanQuickAdd endp if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DPNewTodoEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Create a new To Do list event, making sure the To Do list is shown. CALLED BY: MSG_DP_NEW_TODO_EVENT PASS: *ds:si = DayPlanClass object ds:di = DayPlanClass instance data ds:bx = DayPlanClass object (same as *ds:si) es = segment of DayPlanClass ax = message # RETURN: nothing DESTROYED: ax,cx,dx,bp SIDE EFFECTS: none PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- sean 3/ 9/95 Initial version sean 9/1/95 Changes to allow an alarm event to be added to the To-do list with this message sean 10/27/95 Simplified immensely %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DPNewTodoEvent method dynamic DayPlanClass, MSG_DP_NEW_TODO_EVENT .enter ; Must be showing DayPlan in To-do mode. ; EC < cmp es:[viewInfo], VT_TODO > EC < ERROR_NE WRONG_VIEW_FOR_NEW_TO_DO_ITEM > ; Create new event w/ To Do event values. ; mov ax, MSG_DP_NEW_EVENT mov bp, TODO_DUMMY_YEAR mov dx, TODO_DUMMY_MONTH_DAY mov ch, TODO_DUMMY_HOUR mov cl, TODO_NORMAL_PRIORITY ; priority in minute call ObjCallInstanceNoLock ; New event created, and we only want one new To-do item ; available at any time, so turn off "New" trigger. ; mov ax, MSG_GEN_SET_NOT_ENABLED call ChangeToDoNewTrigger .leave ret DPNewTodoEvent endm endif ; if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanEnsureEventsVisible %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Ensure the events window is made visible CALLED BY: GLOBAL (MSG_DP_ENSURE_EVENTS_VISIBLE) PASS: *DS:SI = DayPlanClass object DS:DI = DayPlanClassInstance RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/ 8/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanEnsureEventsVisible method dynamic DayPlanClass, MSG_DP_ENSURE_EVENTS_VISIBLE .enter ; If we have the additional view of a To Do list we ; must do things differentely ; if _TODO call CheckView else ; First ensure the right hand side is visible ; GetResourceHandleNS MenuBlock, bx test es:[viewInfo], VT_CALENDAR jz checkInk mov si, offset MenuBlock:ViewViewList mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION mov cx, VT_EVENTS clr dx call ObjMessage_dayplan_send mov ax, MSG_GEN_ITEM_GROUP_SET_MODIFIED_STATE mov cx, 1 ; mark as modified call ObjMessage_dayplan_send mov ax, MSG_GEN_APPLY call ObjMessage_dayplan_send ; Now ensure the EventView is visible checkInk: test es:[viewInfo], mask VI_INK jz done if _USE_INK mov si, offset MenuBlock:ViewInkList mov ax, MSG_GEN_BOOLEAN_GROUP_SET_GROUP_STATE clr cx, dx call ObjMessage_dayplan_send mov ax, MSG_GEN_BOOLEAN_GROUP_SET_GROUP_MODIFIED_STATE mov cx, mask VI_INK call ObjMessage_dayplan_send mov ax, MSG_GEN_APPLY call ObjMessage_dayplan_send endif ; if _USE_INK done: endif ; if _TODO .leave ret DayPlanEnsureEventsVisible endm if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckView %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Routine needed if we are using the To Do list, to ensure the correct view is shown when we press the "New Event" button. CALLED BY: DayPlanEnsureEventsVisible PASS: es = dgroup bx = MenuBlock RETURN: zeroFlag - clear if we want to pop up the Event window zeroFlag - set if we don't want to pop up Event window DESTROYED: ax,cx,dx,si SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- SS 3/21/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckView proc near .enter ; Check what type of view we are showing currently ; mov dl, es:[viewInfo] and dl, mask VI_TYPE ; clr dh ; mov cx,dx ; call ToDoGrabFocusAndTarget cmp dl, VT_EVENTS ; event view ? je done cmp dl, VT_CALENDAR_AND_EVENTS ; Calendar/Event view ? je done ; don't change view cmp dl, VT_TODO ; To Do list view ? mov cx, VT_EVENTS shl offset VI_TYPE je eventView ; Show event view mov cx, VT_CALENDAR_AND_EVENTS shl offset VI_TYPE cmp dl, VT_CALENDAR_AND_TODO_LIST ; Calendar/To Do ? je eventView ; Show Calendar/Events ; Must be Calendar view ; push si ; Save DayPlan mov ax, MSG_GEN_SET_USABLE GetResourceHandleNS CalendarRight, bx ; Show CalendarRight mov si, offset CalendarRight clr di call ObjMessage pop si ; restore DayPlan eventView: ; Update viewInfo global ; and es:[viewInfo], not (mask VI_TYPE) or es:[viewInfo], cl ; Change view menu button ; push si ; save DayPlan mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION GetResourceHandleNS MenuBlock, bx mov si, offset MenuBlock:ViewViewList clr dx ; not indeterminate clr di call ObjMessage pop si ; restore DayPlan ; Make sure DayPlan is in "Event" mode ; mov ax, MSG_DP_EVENT_VIEW call ObjCallInstanceNoLock ; Give focus and target to EventView ; GetResourceHandleNS EventView, bx mov si, offset EventView mov ax, MSG_META_GRAB_FOCUS_EXCL clr di call ObjMessage mov ax, MSG_META_GRAB_TARGET_EXCL clr di call ObjMessage done: .leave ret CheckView endp endif ; if _TODO COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CalcAverageTime %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Takes the average of two times (always rounds down) CALLED BY: GLOBAL PASS: CX = Hours:Minutes AX = Hours:Minutes RETURN: CX: = Average - Hours:Minutes DESTROYED: BX PSEUDO CODE/STRATEGY: Assumes that CX is not -1 (the emtpy time) If AX is -1, then CX is unchanged KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 5/17/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CalcAverageTime proc near .enter ; Turn AX into minutes ; cmp ax, -1 ; is the last time empty ?? je done ; if so, perfrom no average mov bh, 60 ; divisor & multiplicand mov bl, al ; store the inital minutes mov al, ah ; hours => AL clr ah mul bh ; compute minutes clr bh add ax, bx ; total minutes => AX xchg cx, ax ; Turn CX into minutes ; mov bh, 60 ; divisor & multiplicand mov bl, al ; store the inital minutes mov al, ah ; hours => AL clr ah mul bh ; compute minutes clr bh add ax, bx ; total minutes => AX add ax, cx ; total minutes => AX shr ax, 1 ; take the average jnc makeTime inc ax ; always round up ; Turn minutes into hours:minutes makeTime: mov bl, 60 div bl ; perform the division mov ch, al ; hours => CH mov cl, ah ; minutes => CL done: .leave ret CalcAverageTime endp ObjMessage_dayplan_send proc near clr di GOTO ObjMessage_dayplan ObjMessage_dayplan_send endp ObjMessage_dayplan_call proc near mov di, mask MF_CALL or mask MF_FIXUP_DS or mask MF_FIXUP_ES FALL_THRU ObjMessage_dayplan ObjMessage_dayplan_call endp ObjMessage_dayplan proc near call ObjMessage ret ObjMessage_dayplan endp MessageToYearObject proc near GetResourceHandleNS YearObject, bx mov si, offset YearObject GOTO ObjMessage_dayplan MessageToYearObject endp MessageToEventView proc far GetResourceHandleNS EventView, bx mov si, offset EventView ; view OD => BX:SI GOTO ObjMessage MessageToEventView endp DayPlanCode ends ReminderCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanAlarmSettings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Brings up the Alarm Settings box for the selected DayEvent CALLED BY: UI (MSG_DP_ALARM_SETTINGS) PASS: DS:DI = DayPlanClass specific instance data ES = DGroup RETURN: Nothing DESTROYED: TBD PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 7/3/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanAlarmSettings method DayPlanClass, MSG_DP_ALARM_SETTINGS .enter mov si, ds:[di].DPI_selectEvent ; selected event => SI tst si ; is there one ?? jz done mov ax, MSG_DE_UPDATE ; force an update, please mov cl, DBUF_IF_NECESSARY call ObjCallInstanceNoLock mov ax, MSG_DE_STUFF_ALARM ; stuff the alarm... call ObjCallInstanceNoLock ; and put it on the screen done: .leave ret DayPlanAlarmSettings endp ReminderCode ends if _USE_INK InkCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanCleanInk %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove the current ink from the screen. CALLED BY: GLOBAL (MSG_DP_CLEAN_INK) PASS: *DS:SI = DayPlanClass object DS:DI = DayPlanClassInstance RETURN: Nothing DESTROYED: AX, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanCleanInk method dynamic DayPlanClass, MSG_DP_CLEAN_INK uses cx, dx, bp .enter ; Clean all the ink off of the page ; clr ds:[di].DPI_inkGroup clr ds:[di].DPI_inkItem and ds:[di].DPI_inkFlags, mask DPIF_INK_DIRTY mov si, offset DPResource:InkObject ; Clear out the ink data, and mark the object as clean. sub sp, size InkDBFrame mov bp, sp clr ss:[bp].IDBF_VMFile clrdw ss:[bp].IDBF_DBGroupAndItem clr ss:[bp].IDBF_bounds.R_left clr ss:[bp].IDBF_bounds.R_top mov ax, MSG_INK_LOAD_FROM_DB_ITEM call ObjCallInstanceNoLock add sp, size InkDBFrame .leave ret DayPlanCleanInk endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanLInk %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load data into the ink object CALLED BY: GLOBAL (MSG_DP_LOAD_INK) PASS: *DS:SI = DayPlanClass object DS:DI = DayPlanClassInstance SS:BP = EventTableEntry RETURN: CX = Offset to insertion point (bougs) Carry = Clear (continue loading events) DESTROYED: AX, BX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanLoadInk method dynamic DayPlanClass, MSG_DP_LOAD_INK uses dx, bp .enter ; First see if we have the correct day ; mov ax, {word} ss:[bp].ETE_day cmp ax, {word} ds:[di].DPI_startDay jne done mov ax, ss:[bp].ETE_year cmp ax, ds:[di].DPI_startYear jne done ; We have the correct day. Load the ink ; mov bx, bp ; EventTableEntry => SS:BX mov dx, size InkDBFrame sub sp, dx mov bp, sp ; InkDBFrame => SS:BP mov ax, ss:[bx].ETE_group mov ss:[bp].IDBF_DBGroupAndItem.DBGI_group, ax mov ds:[di].DPI_inkGroup, ax mov ax, ss:[bx].ETE_item mov ss:[bp].IDBF_DBGroupAndItem.DBGI_item, ax mov ds:[di].DPI_inkItem, ax mov ss:[bp].IDBF_DBExtra, (size EventStruct) call GP_GetVMFileHanFar mov ss:[bp].IDBF_VMFile, bx clr ss:[bp].IDBF_bounds.R_left clr ss:[bp].IDBF_bounds.R_top ; Now send messages to the ink object ; mov si, offset DPResource:InkObject mov ax, MSG_INK_LOAD_FROM_DB_ITEM call ObjCallInstanceNoLock add sp, size InkDBFrame done: mov cx, size EventTableHeader clc .leave ret DayPlanLoadInk endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanStoreInk %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Store the ink away into a DB item CALLED BY: GLOBAL (MSG_DP_STORE_INK) PASS: *DS:SI = DayPlanClass object DS:DI = DayPlanClassInstance RETURN: Nothing DESTROYED: AX, BX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanStoreInk method dynamic DayPlanClass, MSG_DP_STORE_INK uses cx, dx, bp .enter ; If we need to save anything away, do it ; test ds:[di].DPI_inkFlags, mask DPIF_INK_DIRTY jz done ; if not dirty, do nothing and ds:[di].DPI_inkFlags, not (mask DPIF_INK_DIRTY) tst ds:[di].DPI_inkGroup jnz update ; We have new ink, so create a new ink event ; mov bp, ds:[di].DPI_startYear mov dx, {word} dS:[di].DPI_startDay call DBCreateInkEvent mov ds:[di].DPI_inkGroup, cx mov ds:[di].DPI_inkItem, dx ; We need to update an existing ink event update: mov dx, size InkDBFrame sub sp, dx mov bp, sp ; InkDBFrame => SS:BP mov ax, ds:[di].DPI_inkGroup mov ss:[bp].IDBF_DBGroupAndItem.DBGI_group, ax mov ax, ds:[di].DPI_inkItem mov ss:[bp].IDBF_DBGroupAndItem.DBGI_item, ax mov ss:[bp].IDBF_DBExtra, (size EventStruct) call GP_GetVMFileHanFar mov ss:[bp].IDBF_VMFile, bx clr ss:[bp].IDBF_bounds.R_left clr ss:[bp].IDBF_bounds.R_top mov ss:[bp].IDBF_bounds.R_right, 0xffff mov ss:[bp].IDBF_bounds.R_bottom, 0xffff ; Now send messages to the ink object ; mov si, offset DPResource:InkObject mov ax, MSG_INK_SAVE_TO_DB_ITEM call ObjCallInstanceNoLock add sp, size InkDBFrame ; clean up the stack done: .leave ret DayPlanStoreInk endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DayPlanInkDirty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Note that the ink has become dirty CALLED BY: GLOBAL (MSG_DP_INK_DIRTY) PASS: *DS:SI = DayPlanClass object DS:DI = DayPlanClassInstance RETURN: Nothing DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DayPlanInkDirty method dynamic DayPlanClass, MSG_DP_INK_DIRTY .enter ; Set the dirty flag ; or ds:[di].DPI_inkFlags, mask DPIF_INK_DIRTY .leave ret DayPlanInkDirty endm InkCode ends endif ; if _USE_INK
; A053798: Number of basis partitions of n+16 with Durfee square size 4. ; 1,2,4,8,14,22,34,50,70,96,128,166,212,266,328,400,482,574,678,794,922,1064,1220,1390,1576,1778,1996,2232,2486,2758,3050,3362,3694,4048,4424,4822,5244,5690,6160,6656,7178,7726,8302,8906,9538,10200,10892,11614,12368,13154,13972,14824,15710,16630,17586,18578,19606,20672,21776,22918,24100,25322,26584,27888,29234,30622,32054,33530,35050,36616,38228,39886,41592,43346,45148,47000,48902,50854,52858,54914,57022,59184,61400,63670,65996,68378,70816,73312,75866,78478,81150,83882,86674,89528,92444,95422 lpb $0 mov $2,$0 sub $0,1 seq $2,97921 ; G.f.: (1-x^6)*(1-x^8)/((1-x)*(1-x^2)*(1-x^3)^2*(1-x^4)). add $1,$2 lpe add $1,1 mov $0,$1
cpu xag3 page 0 include stddefxa segment io port1 ds.b 1 port2 ds.b 1 segment code supmode on regbit1 bit r3l.4 regbit2 bit sp.5 regbit3 bit r5h.5 regbit4 bit sp.14 membit1 bit 22h.5 membit2 bit 50023h.5 iobit1 bit port1.2 regbit5 bit regbit4+1 add.b r4h,r1l add.w r5,r3 add.b r5l,[r6] add.w r4,[sp] add.b [r6],r5l add.w [sp],r4 add.b r3h,[r6+2] add.w r4,[r3+100] add.b [r6+2],r3h add.w [r3+100],r4 add.b r3h,[r6+200] add.w r4,[r3+1000] add.b [r6+200],r3h add.w [r3+1000],r4 add.b r4h,[r1+] add.w r5,[r6+] add.b [r1+],r4h add.w [r6+],r5 add.b 200h,r2l add.w 123h,r6 add.b r2l,200h add.w r6,123h add.b r5h,#34h add.w r3,#1234h add.b [r5],#34h add.w [r3],#1234h add.b [r5+],#34h add.w [r3+],#1234h add.b [r5+2],#34h add.w [r3+100],#1234h add.b [r5+200],#34h add.w [r3+1000],#1234h add.b 200h,#34h add.w 123h,#1234h addc.b r4h,r1l addc.w r5,r3 addc.b r5l,[r6] addc.w r4,[sp] addc.b [r6],r5l addc.w [sp],r4 addc.b r3h,[r6+2] addc.w r4,[r3+100] addc.b [r6+2],r3h addc.w [r3+100],r4 addc.b r3h,[r6+200] addc.w r4,[r3+1000] addc.b [r6+200],r3h addc.w [r3+1000],r4 addc.b r4h,[r1+] addc.w r5,[r6+] addc.b [r1+],r4h addc.w [r6+],r5 addc.b 200h,r2l addc.w 123h,r6 addc.b r2l,200h addc.w r6,123h addc.b r5h,#34h addc.w r3,#1234h addc.b [r5],#34h addc.w [r3],#1234h addc.b [r5+],#34h addc.w [r3+],#1234h addc.b [r5+2],#34h addc.w [r3+100],#1234h addc.b [r5+200],#34h addc.w [r3+1000],#1234h addc.b 200h,#34h addc.w 123h,#1234h adds.b r5h,#3 adds.w r6,#5 adds.b [r4],#3 adds.w [sp],#5 adds.b [r4+],#3 adds.w [sp+],#5 adds.b [r4+20],#3 adds.w [sp+20],#5 adds.b [r4-200],#3 adds.w [sp-200],#5 adds.b 200h,#3 adds.w 123h,#5 and.b r4h,r1l and.w r5,r3 and.b r5l,[r6] and.w r4,[sp] and.b [r6],r5l and.w [sp],r4 and.b r3h,[r6+2] and.w r4,[r3+100] and.b [r6+2],r3h and.w [r3+100],r4 and.b r3h,[r6+200] and.w r4,[r3+1000] and.b [r6+200],r3h and.w [r3+1000],r4 and.b r4h,[r1+] and.w r5,[r6+] and.b [r1+],r4h and.w [r6+],r5 and.b 200h,r2l and.w 123h,r6 and.b r2l,200h and.w r6,123h and.b r5h,#34h and.w r3,#1234h and.b [r5],#34h and.w [r3],#1234h and.b [r5+],#34h and.w [r3+],#1234h and.b [r5+2],#34h and.w [r3+100],#1234h and.b [r5+200],#34h and.w [r3+1000],#1234h and.b 200h,#34h and.w 123h,#1234h anl c,regbit1 anl c,/iobit1 anl c,r5.12 anl c,/r4h.1 asl.b r4h,r1l asl.w r6,r3h asl.d r2,r4l asl.b r4h,#6 asl.w r6,#12 asl.d r2,#24 asr.b r4h,r1l asr.w r6,r3h asr.d r2,r4l asr.b r4h,#6 asr.w r6,#12 asr.d r2,#24 bcc label1 nop bcc label2 nop bcs label1 beq label1 bg label1 bge label1 bgt label1 ble label1 blt label1 bmi label1 bne label1 bnv label1 bov label1 bpl label1 br label1 call label1 call label1 call [r4] cjne r5l,123h,label1 cjne r6,456h,label1 cjne r5l,#34h,label1 cjne r6,#1234h,label1 cjne.b [r6],#34h,label1 cjne.w [r6],#1234h,label1 label1: nop label2: nop clr regbit1 cmp.b r4h,r1l cmp.w r5,r3 cmp.b r5l,[r6] cmp.w r4,[sp] cmp.b [r6],r5l cmp.w [sp],r4 cmp.b r3h,[r6+2] cmp.w r4,[r3+100] cmp.b [r6+2],r3h cmp.w [r3+100],r4 cmp.b r3h,[r6+200] cmp.w r4,[r3+1000] cmp.b [r6+200],r3h cmp.w [r3+1000],r4 cmp.b r4h,[r1+] cmp.w r5,[r6+] cmp.b [r1+],r4h cmp.w [r6+],r5 cmp.b 200h,r2l cmp.w 123h,r6 cmp.b r2l,200h cmp.w r6,123h cmp.b r5h,#34h cmp.w r3,#1234h cmp.b [r5],#34h cmp.w [r3],#1234h cmp.b [r5+],#34h cmp.w [r3+],#1234h cmp.b [r5+2],#34h cmp.w [r3+100],#1234h cmp.b [r5+200],#34h cmp.w [r3+1000],#1234h cmp.b 200h,#34h cmp.w 123h,#1234h cpl r4l cpl sp da r4l div.w r4,r1h div.w r5,#23 div.d r2,r5 div.d r6,#1234h divu.b r4l,r5l divu.b r4l,#23 divu.w r4,r1h divu.w r5,#23 divu.d r2,r5 divu.d r6,#1234h d1: djnz r5l,d1 d2: djnz.b 123h,d2 d3: djnz r5,d3 d4: djnz.w 123h,d4 fcall 123456h fjmp 123456h jb regbit1,d1 jbc regbit1,d2 jmp 1234h jmp [r3] jmp [a+dptr] jmp [[r5+]] jnb regbit1,d3 jnz d3 jz d3 lea r5,r4+4 lea r6,r1+1000 lsr.b r4h,r1l lsr.w r6,r3h lsr.d r2,r4l lsr.b r4h,#6 lsr.w r6,#12 lsr.d r2,#24 mov c,regbit1 mov regbit1,c mov usp,r4 mov sp,usp mov.b r4h,r1l mov.w r5,r3 mov.b r5l,[r6] mov.w r4,[sp] mov.b [r6],r5l mov.w [sp],r4 mov.b r3h,[r6+2] mov.w r4,[r3+100] mov.b [r6+2],r3h mov.w [r3+100],r4 mov.b r3h,[r6+200] mov.w r4,[r3+1000] mov.b [r6+200],r3h mov.w [r3+1000],r4 mov.b r4h,[r1+] mov.w r5,[r6+] mov.b [r1+],r4h mov.w [r6+],r5 mov.b [r3+],[r4+] mov.w [r3+],[r4+] mov.b 200h,r2l mov.w 123h,r6 mov.b r2l,200h mov.w r6,123h mov.b 123h,[r5] mov.w 456h,[sp] mov.b [r5],123h mov.w [sp],456h mov.b r5h,#34h mov.w r3,#1234h mov.b [r5],#34h mov.w [r3],#1234h mov.b [r5+],#34h mov.w [r3+],#1234h mov.b [r5+2],#34h mov.w [r3+100],#1234h mov.b [r5+200],#34h mov.w [r3+1000],#1234h mov.b 200h,#34h mov.w 123h,#1234h mov.b 123h,200h mov.w 123h,200h movc r4l,[r5+] movc r4,[r5+] movc a,[a+dptr] movc a,[a+pc] movs.b r5h,#3 movs.w r6,#5 movs.b [r4],#3 movs.w [sp],#5 movs.b [r4+],#3 movs.w [sp+],#5 movs.b [r4+20],#3 movs.w [sp+20],#5 movs.b [r4-200],#3 movs.w [sp-200],#5 movs.b 200h,#3 movs.w 123h,#5 movx r3l,[r6] movx r3,[sp] movx [r6],r3l movx [sp],r3 mul r0,r5 mul r6,#1234h mulu r3l,r4h mulu r5l,#100 mulu r0,r5 mulu r6,#1234h neg r4l neg sp nop norm.b r4h,r1l norm.w r6,r3h norm.d r2,r4l or.b r4h,r1l or.w r5,r3 or.b r5l,[r6] or.w r4,[sp] or.b [r6],r5l or.w [sp],r4 or.b r3h,[r6+2] or.w r4,[r3+100] or.b [r6+2],r3h or.w [r3+100],r4 or.b r3h,[r6+200] or.w r4,[r3+1000] or.b [r6+200],r3h or.w [r3+1000],r4 or.b r4h,[r1+] or.w r5,[r6+] or.b [r1+],r4h or.w [r6+],r5 or.b 200h,r2l or.w 123h,r6 or.b r2l,200h or.w r6,123h or.b r5h,#34h or.w r3,#1234h or.b [r5],#34h or.w [r3],#1234h or.b [r5+],#34h or.w [r3+],#1234h or.b [r5+2],#34h or.w [r3+100],#1234h or.b [r5+200],#34h or.w [r3+1000],#1234h or.b 200h,#34h or.w 123h,#1234h orl c,regbit1 orl c,/iobit1 orl c,r5.12 orl c,/r4h.1 pop.b 123h pop.w 200h pop r2l pop r2l,r3l pop r4h pop r4h,r5h pop r2l,r3l,r4h,r5h pop r1 pop r2,r5;,sp popu.b 123h popu.w 200h popu r2l popu r2l,r3l popu r4h popu r4h,r5h popu r2l,r3l,r4h,r5h popu r1 popu r2,r5,sp push.b 123h push.w 200h push r2l push r2l,r3l push r4h push r4h,r5h push r2l,r3l,r4h,r5h push r1 push r2,r5,sp pushu.b 123h pushu.w 200h pushu r2l pushu r2l,r3l pushu r4h pushu r4h,r5h pushu r2l,r3l,r4h,r5h pushu r1 pushu r2,r5,sp reset ret reti rl r3h,#3 rl r5,#12 rlc r3h,#3 rlc r5,#12 rr r3h,#3 rr r5,#12 rrc r3h,#3 rrc r5,#12 setb regbit1 sext r1l sext r2 sub.b r4h,r1l sub.w r5,r3 sub.b r5l,[r6] sub.w r4,[sp] sub.b [r6],r5l sub.w [sp],r4 sub.b r3h,[r6+2] sub.w r4,[r3+100] sub.b [r6+2],r3h sub.w [r3+100],r4 sub.b r3h,[r6+200] sub.w r4,[r3+1000] sub.b [r6+200],r3h sub.w [r3+1000],r4 sub.b r4h,[r1+] sub.w r5,[r6+] sub.b [r1+],r4h sub.w [r6+],r5 sub.b 200h,r2l sub.w 123h,r6 sub.b r2l,200h sub.w r6,123h sub.b r5h,#34h sub.w r3,#1234h sub.b [r5],#34h sub.w [r3],#1234h sub.b [r5+],#34h sub.w [r3+],#1234h sub.b [r5+2],#34h sub.w [r3+100],#1234h sub.b [r5+200],#34h sub.w [r3+1000],#1234h sub.b 200h,#34h sub.w 123h,#1234h subb.b r4h,r1l subb.w r5,r3 subb.b r5l,[r6] subb.w r4,[sp] subb.b [r6],r5l subb.w [sp],r4 subb.b r3h,[r6+2] subb.w r4,[r3+100] subb.b [r6+2],r3h subb.w [r3+100],r4 subb.b r3h,[r6+200] subb.w r4,[r3+1000] subb.b [r6+200],r3h subb.w [r3+1000],r4 subb.b r4h,[r1+] subb.w r5,[r6+] subb.b [r1+],r4h subb.w [r6+],r5 subb.b 200h,r2l subb.w 123h,r6 subb.b r2l,200h subb.w r6,123h subb.b r5h,#34h subb.w r3,#1234h subb.b [r5],#34h subb.w [r3],#1234h subb.b [r5+],#34h subb.w [r3+],#1234h subb.b [r5+2],#34h subb.w [r3+100],#1234h subb.b [r5+200],#34h subb.w [r3+1000],#1234h subb.b 200h,#34h subb.w 123h,#1234h trap #5 xch r3h,r5l xch r5l,r3h xch r3,r5 xch r5,r3 xch r3h,[r5] xch [r5],r3h xch r3,[r5] xch [r5],r3 xch r3h,123h xch 123h,r3h xch r3,200h xch 200h,r3 xor.b r4h,r1l xor.w r5,r3 xor.b r5l,[r6] xor.w r4,[sp] xor.b [r6],r5l xor.w [sp],r4 xor.b r3h,[r6+2] xor.w r4,[r3+100] xor.b [r6+2],r3h xor.w [r3+100],r4 xor.b r3h,[r6+200] xor.w r4,[r3+1000] xor.b [r6+200],r3h xor.w [r3+1000],r4 xor.b r4h,[r1+] xor.w r5,[r6+] xor.b [r1+],r4h xor.w [r6+],r5 xor.b 200h,r2l xor.w 123h,r6 xor.b r2l,200h xor.w r6,123h xor.b r5h,#34h xor.w r3,#1234h xor.b [r5],#34h xor.w [r3],#1234h xor.b [r5+],#34h xor.w [r3+],#1234h xor.b [r5+2],#34h xor.w [r3+100],#1234h xor.b [r5+200],#34h xor.w [r3+1000],#1234h xor.b 200h,#34h xor.w 123h,#1234h mov.b [r5+],[r5+] xch r4l,r4l pop r7 norm.b r4l,r4l norm.w r4,r4h norm.d r4,r5l mov [r4+],r4l mov r4h,[r4+] movc r4h,[r4+] add [r4+],r4l add r4h,[r4+] mov r5,[r5+]
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x1c2f8, %rcx nop nop xor $7913, %r8 movw $0x6162, (%rcx) nop nop add $55205, %rbp lea addresses_A_ht+0x1c78, %rdx nop inc %rbp mov (%rdx), %r13w nop nop sub %rdx, %rdx lea addresses_A_ht+0x140f8, %r13 dec %r8 mov (%r13), %rcx nop cmp %r8, %r8 lea addresses_WC_ht+0x73f8, %rsi lea addresses_A_ht+0x1bdf8, %rdi nop nop nop nop nop xor $30740, %r13 mov $110, %rcx rep movsl nop nop and $42157, %rdi lea addresses_WC_ht+0x18d68, %rsi lea addresses_A_ht+0x1a4f8, %rdi nop nop add $64967, %r8 mov $73, %rcx rep movsb lfence lea addresses_WT_ht+0x3166, %rdi nop nop nop nop nop cmp %rdx, %rdx mov $0x6162636465666768, %rsi movq %rsi, (%rdi) nop nop nop sub %r8, %r8 lea addresses_D_ht+0x1b298, %r14 nop nop nop nop cmp %r13, %r13 mov (%r14), %rdx nop nop nop nop sub $50538, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r12 push %r8 push %rax push %rbx push %rdx // Faulty Load lea addresses_WT+0x1e2f8, %rax nop nop nop and %rdx, %rdx vmovups (%rax), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %r12 lea oracles, %r8 and $0xff, %r12 shlq $12, %r12 mov (%r8,%r12,1), %r12 pop %rdx pop %rbx pop %rax pop %r8 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 4}} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
; A349993: a(n) is the number of squares k^2 with n^2 <= k^2 <= n^3. ; Submitted by Jon Maiga ; 1,1,1,3,5,7,9,12,15,19,22,26,30,34,39,44,49,54,59,64,70,76,82,88,94,101,107,114,121,128,135,142,150,157,165,173,181,189,197,205,213,222,231,239,248,257,266,276,285,295,304,314,323,333,343,353,364,374,384,395,405 mov $2,$0 seq $0,93 ; a(n) = floor(n^(3/2)). sub $0,$2 add $0,1
; Lab-7.asm ; Created on: Oct 18, 2018 ; Author: Daniel Laden INCLUDE 'derivative.inc' XDEF _Startup, main XREF __SEF_END_SSTACK SCL EQU 7 SDA EQU 6 DACADDR EQU $2C ORG $0060 BitCounter DS.B 1 Value DS.B 1 Direction DS.B 1 ;Start of Program Code ORG $E000 main: _Startup: ;Initialize variables CLR Value CLR BitCounter CLR Direction ;Of Mice and Men'ing the Watchdog LDA SOPT1 AND #%01111111 STA SOPT1 ;Setup parallel ports BSET 6, PTBD BSET 7, PTBD BSET 6, PTBDD BSET 7, PTBDD mainLoop: ;Start condition JSR I2CStartBit LDA #DACADDR ASLA JSR I2CTxByte sendValue: ;Send Data LDA Value JSR I2CTxByte INC Value LDA Value CMP #$0A BNE sendValue CLR Value ;Stop condition JSR I2CStopBit JSR I2CBitDelay BRA mainLoop I2CTxByte: ;Initialize variable LDX #$08 STX BitCounter I2CNextBit: ROLA BCC SendLow SendHigh: BSET SDA, PTBD JSR I2CSetupDelay setup: BSET SCL, PTBD JSR I2CBitDelay BRA I2CTxCont SendLow: BCLR SDA, PTBD JSR I2CSetupDelay BSET SCL, PTBD JSR I2CBitDelay I2CTxCont: BCLR SCL, PTBD DEC BitCounter BEQ 12CAckPoll BRA I2CNextBit I2CAckPoll: BSET SDA, PTBD BCLR SDA, PTBD JSR I2CSetupDelay BSET SCL, PTBD JSR I2CBitDelay BRSET SDA, PTBD, I2CNoAck BCLR SCL, PTBD BCLR SDA, PTBDD RTS I2CNoAck: BCLR SCL, PTBD BSET SDA, PTBDD RTS I2CStartBit: BCLR SDA, PTBD JSR I2CBitDelay BCLR SCL, PTBD RTS I2CStopBit: BCLR SDA, PTBD BSET SCL, PTBD BSET SDA, PTBD JSR I2CBitDelay RTS I2CSetupDelay: NOP NOP RTS I2CBitDelay: NOP NOP NOP NOP NOP NOP NOP RTS
/** * Sanity check for basic functionality * * Combines several old regression tests into one quick test. */ #include <maxtest/testconnections.hh> void test_rwsplit(TestConnections& test) { test.reset_timeout(); test.repl->connect(); std::string master_id = test.repl->get_server_id_str(0); test.repl->disconnect(); auto c = test.maxscale->rwsplit(); test.expect(c.connect(), "Connection to readwritesplit should succeed"); // Test simple reads and writes outside of transactions test.expect(c.query("CREATE OR REPLACE TABLE table_for_writes(id INT)"), "Failed to create table: %s", c.error()); for (int i = 0; i < 100 && test.ok(); i++) { if (test.repl->check_backend_versions(100500)) { auto id = c.field("INSERT INTO table_for_writes VALUES (@@server_id) RETURNING id"); if (test.expect(!id.empty(), "INSERT failed: %s", c.error())) { test.expect(id == master_id, "INSERT was not routed to master: %s", id.c_str()); } } else { test.expect(c.query("INSERT INTO table_for_writes VALUES (@@server_id)"), "INSERT failed: %s", c.error()); } } test.repl->sync_slaves(); for (int i = 0; i < 100 && test.ok(); i++) { auto row = c.row("SELECT id, @@server_id FROM table_for_writes"); if (test.expect(!row.empty(), "SELECT returned no data")) { test.expect(row[0] == master_id, "Expected %s to be stored in the table, not %s", master_id.c_str(), row[0].c_str()); test.expect(row[1] != master_id, "SELECT was not routed to a slave"); } } test.expect(c.query("DROP TABLE table_for_writes"), "Failed to DROP TABLE: %s", c.error()); // Transactions to master c.query("START TRANSACTION"); test.expect(c.field("SELECT @@server_id") == master_id, "START TRANSACTION should go to the master"); c.query("COMMIT"); // Read-only transactions to slave c.query("START TRANSACTION READ ONLY"); test.expect(c.field("SELECT @@server_id") != master_id, "START TRANSACTION READ ONLY should go to a slave"); c.query("COMMIT"); // @@last_insert_id routed to master test.expect(c.field("SELECT @@server_id, @@last_insert_id") == master_id, "@@last_insert_id should go to the master"); test.expect(c.field("SELECT last_insert_id(), @@server_id", 1) == master_id, "@@last_insert_id should go to the master"); // Replication related queries test.expect(!c.row("SHOW SLAVE STATUS").empty(), "SHOW SLAVE STATUS should go to a slave"); // User variable modification in SELECT test.expect(!c.query("SELECT @a:=@a+1 as a, user FROM mysql"), "Query with variable modification should fail"); // Repeated session commands for (int i = 0; i < 10000; i++) { test.expect(c.query("set @test=" + std::to_string(i)), "SET should work: %s", c.error()); } // Large result sets for (int i = 1; i < 5000; i += 7) { c.query("SELECT REPEAT('a'," + std::to_string(i) + ")"); } // Non ASCII characters c.query("CREATE OR REPLACE TABLE test.t1 AS SELECT 'Кот'"); c.query("BEGIN"); c.check("SELECT * FROM test.t1", "Кот"); c.query("COMMIT"); c.query("DROP TABLE test.t1"); // Temporary tables for (auto a : { "USE test", "CREATE OR REPLACE TABLE t1(`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY)", "CREATE OR REPLACE TABLE t2(`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY)", "CREATE TEMPORARY TABLE temp1(`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY)", "INSERT INTO temp1 values (1), (2), (3)", "INSERT INTO t1 values (1), (2), (3)", "INSERT INTO t2 values (1), (2), (3)", "CREATE TEMPORARY TABLE temp2 SELECT DISTINCT p.id FROM temp1 p JOIN t1 t " " ON (t.id = p.id) LEFT JOIN t2 ON (t.id = t2.id) WHERE p.id IS NOT NULL " " AND @@server_id IS NOT NULL", "SELECT * FROM temp2", "DROP TABLE t1", "DROP TABLE t2" }) { test.expect(c.query(a), "Temp table query failed"); } // Temporary and real table overlap c.query("CREATE OR REPLACE TABLE test.t1 AS SELECT 1 AS id"); c.query("CREATE TEMPORARY TABLE test.t1 AS SELECT 2 AS id"); c.check("SELECT id FROM test.t1", "2"); c.query("DROP TABLE test.t1"); c.query("DROP TABLE test.t1"); // COM_STATISTICS test.maxscale->connect(); for (int i = 0; i < 10; i++) { mysql_stat(test.maxscale->conn_rwsplit[0]); test.try_query(test.maxscale->conn_rwsplit[0], "SELECT 1"); } // // MXS-3229: Hang with COM_SET_OPTION // mysql_set_server_option(test.maxscale->conn_rwsplit[0], MYSQL_OPTION_MULTI_STATEMENTS_ON); mysql_set_server_option(test.maxscale->conn_rwsplit[0], MYSQL_OPTION_MULTI_STATEMENTS_OFF); // Make sure the connection is still OK test.try_query(test.maxscale->conn_rwsplit[0], "SELECT 1"); test.maxscale->disconnect(); } int main(int argc, char** argv) { TestConnections test(argc, argv); auto connections = [&]() { return test.maxctrl("api get servers/server1 data.attributes.statistics.connections").output; }; test.expect(connections()[0] == '0', "The master should have no connections"); test.maxscale->connect(); test.expect(connections()[0] == '2', "The master should have two connections"); test.maxscale->disconnect(); test.expect(connections()[0] == '0', "The master should have no connections"); test.maxscale->connect(); for (auto a : {"show status", "show variables", "show global status"}) { for (int i = 0; i < 10; i++) { test.try_query(test.maxscale->conn_rwsplit[0], "%s", a); test.try_query(test.maxscale->conn_master, "%s", a); } } test.maxscale->disconnect(); // Readwritesplit sanity checks test_rwsplit(test); return test.global_result; }
; =============================================================== ; Jan 2014 ; =============================================================== ; ; char *strerror(int errnum) ; ; Return string message corresponding to errnum. ; ; =============================================================== SECTION code_clib SECTION code_string PUBLIC asm_strerror EXTERN __rodata_error_strings_head, __str_locate_nul asm_strerror: ; enter : hl = errnum ; ; exit : hl = char *message ; carry set if errnum was not found ; ; uses : af, bc, e, hl ld a,h or a jr nz, use_default or l jr z, use_ok ld e,l ld hl,__rodata_error_strings_head ld a,(hl) search_loop: cp e inc hl ret z ; if found string call __str_locate_nul inc hl ld a,(hl) or a jr nz, search_loop ; if end of strings not met use_default: ld hl,__error_string_default scf ret use_ok: ld hl,__error_string_ok ret __error_string_default: IF __CLIB_OPT_ERROR & $02 defm "ERR - Unknown" defb 0 ELSE defm "ERR" defb 0 ENDIF __error_string_ok: IF __CLIB_OPT_ERROR & $02 defm "EOK - No error" defb 0 ELSE defm "EOK" defb 0 ENDIF
; A052759: E.g.f.: x^3*log(1/(1-x)). ; 0,0,0,0,24,60,240,1260,8064,60480,518400,4989600,53222400,622702080,7925299200,108972864000,1609445376000,25406244864000,426824913715200,7602818775552000,143111882833920000,2838385676206080000,59157933040926720000,1292600836944248832000,29545161987297116160000,705055001969590272000000,17534411353330679808000000,453702893767431340032000000,12195533784468554420060160000,340067768989988536713216000000,9824179993044113282826240000000,293672809077782957775912960000000,9073477135644604488524759040000000,289443920627062883183939813376000000 mov $2,$0 seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters). mov $1,5 sub $2,1 lpb $0 trn $0,$1 mul $0,2 add $2,4 lpe sub $2,2 div $0,$2
_stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 81 ec 30 02 00 00 sub $0x230,%esp int fd, i; char path[] = "stressfs0"; c: c7 84 24 1e 02 00 00 movl $0x65727473,0x21e(%esp) 13: 73 74 72 65 17: c7 84 24 22 02 00 00 movl $0x73667373,0x222(%esp) 1e: 73 73 66 73 22: 66 c7 84 24 26 02 00 movw $0x30,0x226(%esp) 29: 00 30 00 char data[512]; printf(1, "stressfs starting\n"); 2c: c7 44 24 04 32 0d 00 movl $0xd32,0x4(%esp) 33: 00 34: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b: e8 83 05 00 00 call 5c3 <printf> memset(data, 'a', sizeof(data)); 40: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 47: 00 48: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) 4f: 00 50: 8d 44 24 1e lea 0x1e(%esp),%eax 54: 89 04 24 mov %eax,(%esp) 57: e8 12 02 00 00 call 26e <memset> for(i = 0; i < 4; i++) 5c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 63: 00 00 00 00 67: eb 13 jmp 7c <main+0x7c> if(fork() > 0) 69: e8 a5 03 00 00 call 413 <fork> 6e: 85 c0 test %eax,%eax 70: 7e 02 jle 74 <main+0x74> break; 72: eb 12 jmp 86 <main+0x86> char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); for(i = 0; i < 4; i++) 74: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 7b: 01 7c: 83 bc 24 2c 02 00 00 cmpl $0x3,0x22c(%esp) 83: 03 84: 7e e3 jle 69 <main+0x69> if(fork() > 0) break; printf(1, "write %d\n", i); 86: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax 8d: 89 44 24 08 mov %eax,0x8(%esp) 91: c7 44 24 04 45 0d 00 movl $0xd45,0x4(%esp) 98: 00 99: c7 04 24 01 00 00 00 movl $0x1,(%esp) a0: e8 1e 05 00 00 call 5c3 <printf> path[8] += i; a5: 0f b6 84 24 26 02 00 movzbl 0x226(%esp),%eax ac: 00 ad: 89 c2 mov %eax,%edx af: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax b6: 01 d0 add %edx,%eax b8: 88 84 24 26 02 00 00 mov %al,0x226(%esp) fd = open(path, O_CREATE | O_RDWR); bf: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) c6: 00 c7: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax ce: 89 04 24 mov %eax,(%esp) d1: e8 85 03 00 00 call 45b <open> d6: 89 84 24 28 02 00 00 mov %eax,0x228(%esp) for(i = 0; i < 20; i++) dd: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) e4: 00 00 00 00 e8: eb 27 jmp 111 <main+0x111> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); ea: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) f1: 00 f2: 8d 44 24 1e lea 0x1e(%esp),%eax f6: 89 44 24 04 mov %eax,0x4(%esp) fa: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 101: 89 04 24 mov %eax,(%esp) 104: e8 32 03 00 00 call 43b <write> printf(1, "write %d\n", i); path[8] += i; fd = open(path, O_CREATE | O_RDWR); for(i = 0; i < 20; i++) 109: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 110: 01 111: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp) 118: 13 119: 7e cf jle ea <main+0xea> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); close(fd); 11b: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 122: 89 04 24 mov %eax,(%esp) 125: e8 19 03 00 00 call 443 <close> printf(1, "read\n"); 12a: c7 44 24 04 4f 0d 00 movl $0xd4f,0x4(%esp) 131: 00 132: c7 04 24 01 00 00 00 movl $0x1,(%esp) 139: e8 85 04 00 00 call 5c3 <printf> fd = open(path, O_RDONLY); 13e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 145: 00 146: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax 14d: 89 04 24 mov %eax,(%esp) 150: e8 06 03 00 00 call 45b <open> 155: 89 84 24 28 02 00 00 mov %eax,0x228(%esp) for (i = 0; i < 20; i++) 15c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 163: 00 00 00 00 167: eb 27 jmp 190 <main+0x190> read(fd, data, sizeof(data)); 169: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 170: 00 171: 8d 44 24 1e lea 0x1e(%esp),%eax 175: 89 44 24 04 mov %eax,0x4(%esp) 179: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 180: 89 04 24 mov %eax,(%esp) 183: e8 ab 02 00 00 call 433 <read> close(fd); printf(1, "read\n"); fd = open(path, O_RDONLY); for (i = 0; i < 20; i++) 188: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 18f: 01 190: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp) 197: 13 198: 7e cf jle 169 <main+0x169> read(fd, data, sizeof(data)); close(fd); 19a: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 1a1: 89 04 24 mov %eax,(%esp) 1a4: e8 9a 02 00 00 call 443 <close> wait(); 1a9: e8 75 02 00 00 call 423 <wait> exit(); 1ae: e8 68 02 00 00 call 41b <exit> 000001b3 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1b3: 55 push %ebp 1b4: 89 e5 mov %esp,%ebp 1b6: 57 push %edi 1b7: 53 push %ebx asm volatile("cld; rep stosb" : 1b8: 8b 4d 08 mov 0x8(%ebp),%ecx 1bb: 8b 55 10 mov 0x10(%ebp),%edx 1be: 8b 45 0c mov 0xc(%ebp),%eax 1c1: 89 cb mov %ecx,%ebx 1c3: 89 df mov %ebx,%edi 1c5: 89 d1 mov %edx,%ecx 1c7: fc cld 1c8: f3 aa rep stos %al,%es:(%edi) 1ca: 89 ca mov %ecx,%edx 1cc: 89 fb mov %edi,%ebx 1ce: 89 5d 08 mov %ebx,0x8(%ebp) 1d1: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 1d4: 5b pop %ebx 1d5: 5f pop %edi 1d6: 5d pop %ebp 1d7: c3 ret 000001d8 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1d8: 55 push %ebp 1d9: 89 e5 mov %esp,%ebp 1db: 83 ec 10 sub $0x10,%esp char *os; os = s; 1de: 8b 45 08 mov 0x8(%ebp),%eax 1e1: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 1e4: 90 nop 1e5: 8b 45 08 mov 0x8(%ebp),%eax 1e8: 8d 50 01 lea 0x1(%eax),%edx 1eb: 89 55 08 mov %edx,0x8(%ebp) 1ee: 8b 55 0c mov 0xc(%ebp),%edx 1f1: 8d 4a 01 lea 0x1(%edx),%ecx 1f4: 89 4d 0c mov %ecx,0xc(%ebp) 1f7: 0f b6 12 movzbl (%edx),%edx 1fa: 88 10 mov %dl,(%eax) 1fc: 0f b6 00 movzbl (%eax),%eax 1ff: 84 c0 test %al,%al 201: 75 e2 jne 1e5 <strcpy+0xd> ; return os; 203: 8b 45 fc mov -0x4(%ebp),%eax } 206: c9 leave 207: c3 ret 00000208 <strcmp>: int strcmp(const char *p, const char *q) { 208: 55 push %ebp 209: 89 e5 mov %esp,%ebp while(*p && *p == *q) 20b: eb 08 jmp 215 <strcmp+0xd> p++, q++; 20d: 83 45 08 01 addl $0x1,0x8(%ebp) 211: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 215: 8b 45 08 mov 0x8(%ebp),%eax 218: 0f b6 00 movzbl (%eax),%eax 21b: 84 c0 test %al,%al 21d: 74 10 je 22f <strcmp+0x27> 21f: 8b 45 08 mov 0x8(%ebp),%eax 222: 0f b6 10 movzbl (%eax),%edx 225: 8b 45 0c mov 0xc(%ebp),%eax 228: 0f b6 00 movzbl (%eax),%eax 22b: 38 c2 cmp %al,%dl 22d: 74 de je 20d <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 22f: 8b 45 08 mov 0x8(%ebp),%eax 232: 0f b6 00 movzbl (%eax),%eax 235: 0f b6 d0 movzbl %al,%edx 238: 8b 45 0c mov 0xc(%ebp),%eax 23b: 0f b6 00 movzbl (%eax),%eax 23e: 0f b6 c0 movzbl %al,%eax 241: 29 c2 sub %eax,%edx 243: 89 d0 mov %edx,%eax } 245: 5d pop %ebp 246: c3 ret 00000247 <strlen>: uint strlen(char *s) { 247: 55 push %ebp 248: 89 e5 mov %esp,%ebp 24a: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 24d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 254: eb 04 jmp 25a <strlen+0x13> 256: 83 45 fc 01 addl $0x1,-0x4(%ebp) 25a: 8b 55 fc mov -0x4(%ebp),%edx 25d: 8b 45 08 mov 0x8(%ebp),%eax 260: 01 d0 add %edx,%eax 262: 0f b6 00 movzbl (%eax),%eax 265: 84 c0 test %al,%al 267: 75 ed jne 256 <strlen+0xf> ; return n; 269: 8b 45 fc mov -0x4(%ebp),%eax } 26c: c9 leave 26d: c3 ret 0000026e <memset>: void* memset(void *dst, int c, uint n) { 26e: 55 push %ebp 26f: 89 e5 mov %esp,%ebp 271: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 274: 8b 45 10 mov 0x10(%ebp),%eax 277: 89 44 24 08 mov %eax,0x8(%esp) 27b: 8b 45 0c mov 0xc(%ebp),%eax 27e: 89 44 24 04 mov %eax,0x4(%esp) 282: 8b 45 08 mov 0x8(%ebp),%eax 285: 89 04 24 mov %eax,(%esp) 288: e8 26 ff ff ff call 1b3 <stosb> return dst; 28d: 8b 45 08 mov 0x8(%ebp),%eax } 290: c9 leave 291: c3 ret 00000292 <strchr>: char* strchr(const char *s, char c) { 292: 55 push %ebp 293: 89 e5 mov %esp,%ebp 295: 83 ec 04 sub $0x4,%esp 298: 8b 45 0c mov 0xc(%ebp),%eax 29b: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 29e: eb 14 jmp 2b4 <strchr+0x22> if(*s == c) 2a0: 8b 45 08 mov 0x8(%ebp),%eax 2a3: 0f b6 00 movzbl (%eax),%eax 2a6: 3a 45 fc cmp -0x4(%ebp),%al 2a9: 75 05 jne 2b0 <strchr+0x1e> return (char*)s; 2ab: 8b 45 08 mov 0x8(%ebp),%eax 2ae: eb 13 jmp 2c3 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 2b0: 83 45 08 01 addl $0x1,0x8(%ebp) 2b4: 8b 45 08 mov 0x8(%ebp),%eax 2b7: 0f b6 00 movzbl (%eax),%eax 2ba: 84 c0 test %al,%al 2bc: 75 e2 jne 2a0 <strchr+0xe> if(*s == c) return (char*)s; return 0; 2be: b8 00 00 00 00 mov $0x0,%eax } 2c3: c9 leave 2c4: c3 ret 000002c5 <gets>: char* gets(char *buf, int max) { 2c5: 55 push %ebp 2c6: 89 e5 mov %esp,%ebp 2c8: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 2cb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2d2: eb 4c jmp 320 <gets+0x5b> cc = read(0, &c, 1); 2d4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2db: 00 2dc: 8d 45 ef lea -0x11(%ebp),%eax 2df: 89 44 24 04 mov %eax,0x4(%esp) 2e3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2ea: e8 44 01 00 00 call 433 <read> 2ef: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 2f2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2f6: 7f 02 jg 2fa <gets+0x35> break; 2f8: eb 31 jmp 32b <gets+0x66> buf[i++] = c; 2fa: 8b 45 f4 mov -0xc(%ebp),%eax 2fd: 8d 50 01 lea 0x1(%eax),%edx 300: 89 55 f4 mov %edx,-0xc(%ebp) 303: 89 c2 mov %eax,%edx 305: 8b 45 08 mov 0x8(%ebp),%eax 308: 01 c2 add %eax,%edx 30a: 0f b6 45 ef movzbl -0x11(%ebp),%eax 30e: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 310: 0f b6 45 ef movzbl -0x11(%ebp),%eax 314: 3c 0a cmp $0xa,%al 316: 74 13 je 32b <gets+0x66> 318: 0f b6 45 ef movzbl -0x11(%ebp),%eax 31c: 3c 0d cmp $0xd,%al 31e: 74 0b je 32b <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 320: 8b 45 f4 mov -0xc(%ebp),%eax 323: 83 c0 01 add $0x1,%eax 326: 3b 45 0c cmp 0xc(%ebp),%eax 329: 7c a9 jl 2d4 <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 32b: 8b 55 f4 mov -0xc(%ebp),%edx 32e: 8b 45 08 mov 0x8(%ebp),%eax 331: 01 d0 add %edx,%eax 333: c6 00 00 movb $0x0,(%eax) return buf; 336: 8b 45 08 mov 0x8(%ebp),%eax } 339: c9 leave 33a: c3 ret 0000033b <stat>: int stat(char *n, struct stat *st) { 33b: 55 push %ebp 33c: 89 e5 mov %esp,%ebp 33e: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 341: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 348: 00 349: 8b 45 08 mov 0x8(%ebp),%eax 34c: 89 04 24 mov %eax,(%esp) 34f: e8 07 01 00 00 call 45b <open> 354: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 357: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 35b: 79 07 jns 364 <stat+0x29> return -1; 35d: b8 ff ff ff ff mov $0xffffffff,%eax 362: eb 23 jmp 387 <stat+0x4c> r = fstat(fd, st); 364: 8b 45 0c mov 0xc(%ebp),%eax 367: 89 44 24 04 mov %eax,0x4(%esp) 36b: 8b 45 f4 mov -0xc(%ebp),%eax 36e: 89 04 24 mov %eax,(%esp) 371: e8 fd 00 00 00 call 473 <fstat> 376: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 379: 8b 45 f4 mov -0xc(%ebp),%eax 37c: 89 04 24 mov %eax,(%esp) 37f: e8 bf 00 00 00 call 443 <close> return r; 384: 8b 45 f0 mov -0x10(%ebp),%eax } 387: c9 leave 388: c3 ret 00000389 <atoi>: int atoi(const char *s) { 389: 55 push %ebp 38a: 89 e5 mov %esp,%ebp 38c: 83 ec 10 sub $0x10,%esp int n; n = 0; 38f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 396: eb 25 jmp 3bd <atoi+0x34> n = n*10 + *s++ - '0'; 398: 8b 55 fc mov -0x4(%ebp),%edx 39b: 89 d0 mov %edx,%eax 39d: c1 e0 02 shl $0x2,%eax 3a0: 01 d0 add %edx,%eax 3a2: 01 c0 add %eax,%eax 3a4: 89 c1 mov %eax,%ecx 3a6: 8b 45 08 mov 0x8(%ebp),%eax 3a9: 8d 50 01 lea 0x1(%eax),%edx 3ac: 89 55 08 mov %edx,0x8(%ebp) 3af: 0f b6 00 movzbl (%eax),%eax 3b2: 0f be c0 movsbl %al,%eax 3b5: 01 c8 add %ecx,%eax 3b7: 83 e8 30 sub $0x30,%eax 3ba: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3bd: 8b 45 08 mov 0x8(%ebp),%eax 3c0: 0f b6 00 movzbl (%eax),%eax 3c3: 3c 2f cmp $0x2f,%al 3c5: 7e 0a jle 3d1 <atoi+0x48> 3c7: 8b 45 08 mov 0x8(%ebp),%eax 3ca: 0f b6 00 movzbl (%eax),%eax 3cd: 3c 39 cmp $0x39,%al 3cf: 7e c7 jle 398 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3d1: 8b 45 fc mov -0x4(%ebp),%eax } 3d4: c9 leave 3d5: c3 ret 000003d6 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3d6: 55 push %ebp 3d7: 89 e5 mov %esp,%ebp 3d9: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 3dc: 8b 45 08 mov 0x8(%ebp),%eax 3df: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 3e2: 8b 45 0c mov 0xc(%ebp),%eax 3e5: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 3e8: eb 17 jmp 401 <memmove+0x2b> *dst++ = *src++; 3ea: 8b 45 fc mov -0x4(%ebp),%eax 3ed: 8d 50 01 lea 0x1(%eax),%edx 3f0: 89 55 fc mov %edx,-0x4(%ebp) 3f3: 8b 55 f8 mov -0x8(%ebp),%edx 3f6: 8d 4a 01 lea 0x1(%edx),%ecx 3f9: 89 4d f8 mov %ecx,-0x8(%ebp) 3fc: 0f b6 12 movzbl (%edx),%edx 3ff: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 401: 8b 45 10 mov 0x10(%ebp),%eax 404: 8d 50 ff lea -0x1(%eax),%edx 407: 89 55 10 mov %edx,0x10(%ebp) 40a: 85 c0 test %eax,%eax 40c: 7f dc jg 3ea <memmove+0x14> *dst++ = *src++; return vdst; 40e: 8b 45 08 mov 0x8(%ebp),%eax } 411: c9 leave 412: c3 ret 00000413 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 413: b8 01 00 00 00 mov $0x1,%eax 418: cd 40 int $0x40 41a: c3 ret 0000041b <exit>: SYSCALL(exit) 41b: b8 02 00 00 00 mov $0x2,%eax 420: cd 40 int $0x40 422: c3 ret 00000423 <wait>: SYSCALL(wait) 423: b8 03 00 00 00 mov $0x3,%eax 428: cd 40 int $0x40 42a: c3 ret 0000042b <pipe>: SYSCALL(pipe) 42b: b8 04 00 00 00 mov $0x4,%eax 430: cd 40 int $0x40 432: c3 ret 00000433 <read>: SYSCALL(read) 433: b8 05 00 00 00 mov $0x5,%eax 438: cd 40 int $0x40 43a: c3 ret 0000043b <write>: SYSCALL(write) 43b: b8 10 00 00 00 mov $0x10,%eax 440: cd 40 int $0x40 442: c3 ret 00000443 <close>: SYSCALL(close) 443: b8 15 00 00 00 mov $0x15,%eax 448: cd 40 int $0x40 44a: c3 ret 0000044b <kill>: SYSCALL(kill) 44b: b8 06 00 00 00 mov $0x6,%eax 450: cd 40 int $0x40 452: c3 ret 00000453 <exec>: SYSCALL(exec) 453: b8 07 00 00 00 mov $0x7,%eax 458: cd 40 int $0x40 45a: c3 ret 0000045b <open>: SYSCALL(open) 45b: b8 0f 00 00 00 mov $0xf,%eax 460: cd 40 int $0x40 462: c3 ret 00000463 <mknod>: SYSCALL(mknod) 463: b8 11 00 00 00 mov $0x11,%eax 468: cd 40 int $0x40 46a: c3 ret 0000046b <unlink>: SYSCALL(unlink) 46b: b8 12 00 00 00 mov $0x12,%eax 470: cd 40 int $0x40 472: c3 ret 00000473 <fstat>: SYSCALL(fstat) 473: b8 08 00 00 00 mov $0x8,%eax 478: cd 40 int $0x40 47a: c3 ret 0000047b <link>: SYSCALL(link) 47b: b8 13 00 00 00 mov $0x13,%eax 480: cd 40 int $0x40 482: c3 ret 00000483 <mkdir>: SYSCALL(mkdir) 483: b8 14 00 00 00 mov $0x14,%eax 488: cd 40 int $0x40 48a: c3 ret 0000048b <chdir>: SYSCALL(chdir) 48b: b8 09 00 00 00 mov $0x9,%eax 490: cd 40 int $0x40 492: c3 ret 00000493 <dup>: SYSCALL(dup) 493: b8 0a 00 00 00 mov $0xa,%eax 498: cd 40 int $0x40 49a: c3 ret 0000049b <getpid>: SYSCALL(getpid) 49b: b8 0b 00 00 00 mov $0xb,%eax 4a0: cd 40 int $0x40 4a2: c3 ret 000004a3 <sbrk>: SYSCALL(sbrk) 4a3: b8 0c 00 00 00 mov $0xc,%eax 4a8: cd 40 int $0x40 4aa: c3 ret 000004ab <sleep>: SYSCALL(sleep) 4ab: b8 0d 00 00 00 mov $0xd,%eax 4b0: cd 40 int $0x40 4b2: c3 ret 000004b3 <uptime>: SYSCALL(uptime) 4b3: b8 0e 00 00 00 mov $0xe,%eax 4b8: cd 40 int $0x40 4ba: c3 ret 000004bb <clone>: SYSCALL(clone) 4bb: b8 16 00 00 00 mov $0x16,%eax 4c0: cd 40 int $0x40 4c2: c3 ret 000004c3 <texit>: SYSCALL(texit) 4c3: b8 17 00 00 00 mov $0x17,%eax 4c8: cd 40 int $0x40 4ca: c3 ret 000004cb <tsleep>: SYSCALL(tsleep) 4cb: b8 18 00 00 00 mov $0x18,%eax 4d0: cd 40 int $0x40 4d2: c3 ret 000004d3 <twakeup>: SYSCALL(twakeup) 4d3: b8 19 00 00 00 mov $0x19,%eax 4d8: cd 40 int $0x40 4da: c3 ret 000004db <test>: SYSCALL(test) 4db: b8 1a 00 00 00 mov $0x1a,%eax 4e0: cd 40 int $0x40 4e2: c3 ret 000004e3 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 4e3: 55 push %ebp 4e4: 89 e5 mov %esp,%ebp 4e6: 83 ec 18 sub $0x18,%esp 4e9: 8b 45 0c mov 0xc(%ebp),%eax 4ec: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 4ef: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4f6: 00 4f7: 8d 45 f4 lea -0xc(%ebp),%eax 4fa: 89 44 24 04 mov %eax,0x4(%esp) 4fe: 8b 45 08 mov 0x8(%ebp),%eax 501: 89 04 24 mov %eax,(%esp) 504: e8 32 ff ff ff call 43b <write> } 509: c9 leave 50a: c3 ret 0000050b <printint>: static void printint(int fd, int xx, int base, int sgn) { 50b: 55 push %ebp 50c: 89 e5 mov %esp,%ebp 50e: 56 push %esi 50f: 53 push %ebx 510: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 513: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 51a: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 51e: 74 17 je 537 <printint+0x2c> 520: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 524: 79 11 jns 537 <printint+0x2c> neg = 1; 526: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 52d: 8b 45 0c mov 0xc(%ebp),%eax 530: f7 d8 neg %eax 532: 89 45 ec mov %eax,-0x14(%ebp) 535: eb 06 jmp 53d <printint+0x32> } else { x = xx; 537: 8b 45 0c mov 0xc(%ebp),%eax 53a: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 53d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 544: 8b 4d f4 mov -0xc(%ebp),%ecx 547: 8d 41 01 lea 0x1(%ecx),%eax 54a: 89 45 f4 mov %eax,-0xc(%ebp) 54d: 8b 5d 10 mov 0x10(%ebp),%ebx 550: 8b 45 ec mov -0x14(%ebp),%eax 553: ba 00 00 00 00 mov $0x0,%edx 558: f7 f3 div %ebx 55a: 89 d0 mov %edx,%eax 55c: 0f b6 80 8c 11 00 00 movzbl 0x118c(%eax),%eax 563: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 567: 8b 75 10 mov 0x10(%ebp),%esi 56a: 8b 45 ec mov -0x14(%ebp),%eax 56d: ba 00 00 00 00 mov $0x0,%edx 572: f7 f6 div %esi 574: 89 45 ec mov %eax,-0x14(%ebp) 577: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 57b: 75 c7 jne 544 <printint+0x39> if(neg) 57d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 581: 74 10 je 593 <printint+0x88> buf[i++] = '-'; 583: 8b 45 f4 mov -0xc(%ebp),%eax 586: 8d 50 01 lea 0x1(%eax),%edx 589: 89 55 f4 mov %edx,-0xc(%ebp) 58c: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 591: eb 1f jmp 5b2 <printint+0xa7> 593: eb 1d jmp 5b2 <printint+0xa7> putc(fd, buf[i]); 595: 8d 55 dc lea -0x24(%ebp),%edx 598: 8b 45 f4 mov -0xc(%ebp),%eax 59b: 01 d0 add %edx,%eax 59d: 0f b6 00 movzbl (%eax),%eax 5a0: 0f be c0 movsbl %al,%eax 5a3: 89 44 24 04 mov %eax,0x4(%esp) 5a7: 8b 45 08 mov 0x8(%ebp),%eax 5aa: 89 04 24 mov %eax,(%esp) 5ad: e8 31 ff ff ff call 4e3 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 5b2: 83 6d f4 01 subl $0x1,-0xc(%ebp) 5b6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5ba: 79 d9 jns 595 <printint+0x8a> putc(fd, buf[i]); } 5bc: 83 c4 30 add $0x30,%esp 5bf: 5b pop %ebx 5c0: 5e pop %esi 5c1: 5d pop %ebp 5c2: c3 ret 000005c3 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 5c3: 55 push %ebp 5c4: 89 e5 mov %esp,%ebp 5c6: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5c9: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 5d0: 8d 45 0c lea 0xc(%ebp),%eax 5d3: 83 c0 04 add $0x4,%eax 5d6: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 5d9: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 5e0: e9 7c 01 00 00 jmp 761 <printf+0x19e> c = fmt[i] & 0xff; 5e5: 8b 55 0c mov 0xc(%ebp),%edx 5e8: 8b 45 f0 mov -0x10(%ebp),%eax 5eb: 01 d0 add %edx,%eax 5ed: 0f b6 00 movzbl (%eax),%eax 5f0: 0f be c0 movsbl %al,%eax 5f3: 25 ff 00 00 00 and $0xff,%eax 5f8: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 5fb: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 5ff: 75 2c jne 62d <printf+0x6a> if(c == '%'){ 601: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 605: 75 0c jne 613 <printf+0x50> state = '%'; 607: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 60e: e9 4a 01 00 00 jmp 75d <printf+0x19a> } else { putc(fd, c); 613: 8b 45 e4 mov -0x1c(%ebp),%eax 616: 0f be c0 movsbl %al,%eax 619: 89 44 24 04 mov %eax,0x4(%esp) 61d: 8b 45 08 mov 0x8(%ebp),%eax 620: 89 04 24 mov %eax,(%esp) 623: e8 bb fe ff ff call 4e3 <putc> 628: e9 30 01 00 00 jmp 75d <printf+0x19a> } } else if(state == '%'){ 62d: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 631: 0f 85 26 01 00 00 jne 75d <printf+0x19a> if(c == 'd'){ 637: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 63b: 75 2d jne 66a <printf+0xa7> printint(fd, *ap, 10, 1); 63d: 8b 45 e8 mov -0x18(%ebp),%eax 640: 8b 00 mov (%eax),%eax 642: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 649: 00 64a: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 651: 00 652: 89 44 24 04 mov %eax,0x4(%esp) 656: 8b 45 08 mov 0x8(%ebp),%eax 659: 89 04 24 mov %eax,(%esp) 65c: e8 aa fe ff ff call 50b <printint> ap++; 661: 83 45 e8 04 addl $0x4,-0x18(%ebp) 665: e9 ec 00 00 00 jmp 756 <printf+0x193> } else if(c == 'x' || c == 'p'){ 66a: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 66e: 74 06 je 676 <printf+0xb3> 670: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 674: 75 2d jne 6a3 <printf+0xe0> printint(fd, *ap, 16, 0); 676: 8b 45 e8 mov -0x18(%ebp),%eax 679: 8b 00 mov (%eax),%eax 67b: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 682: 00 683: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 68a: 00 68b: 89 44 24 04 mov %eax,0x4(%esp) 68f: 8b 45 08 mov 0x8(%ebp),%eax 692: 89 04 24 mov %eax,(%esp) 695: e8 71 fe ff ff call 50b <printint> ap++; 69a: 83 45 e8 04 addl $0x4,-0x18(%ebp) 69e: e9 b3 00 00 00 jmp 756 <printf+0x193> } else if(c == 's'){ 6a3: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 6a7: 75 45 jne 6ee <printf+0x12b> s = (char*)*ap; 6a9: 8b 45 e8 mov -0x18(%ebp),%eax 6ac: 8b 00 mov (%eax),%eax 6ae: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 6b1: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 6b5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 6b9: 75 09 jne 6c4 <printf+0x101> s = "(null)"; 6bb: c7 45 f4 55 0d 00 00 movl $0xd55,-0xc(%ebp) while(*s != 0){ 6c2: eb 1e jmp 6e2 <printf+0x11f> 6c4: eb 1c jmp 6e2 <printf+0x11f> putc(fd, *s); 6c6: 8b 45 f4 mov -0xc(%ebp),%eax 6c9: 0f b6 00 movzbl (%eax),%eax 6cc: 0f be c0 movsbl %al,%eax 6cf: 89 44 24 04 mov %eax,0x4(%esp) 6d3: 8b 45 08 mov 0x8(%ebp),%eax 6d6: 89 04 24 mov %eax,(%esp) 6d9: e8 05 fe ff ff call 4e3 <putc> s++; 6de: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6e2: 8b 45 f4 mov -0xc(%ebp),%eax 6e5: 0f b6 00 movzbl (%eax),%eax 6e8: 84 c0 test %al,%al 6ea: 75 da jne 6c6 <printf+0x103> 6ec: eb 68 jmp 756 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 6ee: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 6f2: 75 1d jne 711 <printf+0x14e> putc(fd, *ap); 6f4: 8b 45 e8 mov -0x18(%ebp),%eax 6f7: 8b 00 mov (%eax),%eax 6f9: 0f be c0 movsbl %al,%eax 6fc: 89 44 24 04 mov %eax,0x4(%esp) 700: 8b 45 08 mov 0x8(%ebp),%eax 703: 89 04 24 mov %eax,(%esp) 706: e8 d8 fd ff ff call 4e3 <putc> ap++; 70b: 83 45 e8 04 addl $0x4,-0x18(%ebp) 70f: eb 45 jmp 756 <printf+0x193> } else if(c == '%'){ 711: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 715: 75 17 jne 72e <printf+0x16b> putc(fd, c); 717: 8b 45 e4 mov -0x1c(%ebp),%eax 71a: 0f be c0 movsbl %al,%eax 71d: 89 44 24 04 mov %eax,0x4(%esp) 721: 8b 45 08 mov 0x8(%ebp),%eax 724: 89 04 24 mov %eax,(%esp) 727: e8 b7 fd ff ff call 4e3 <putc> 72c: eb 28 jmp 756 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 72e: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 735: 00 736: 8b 45 08 mov 0x8(%ebp),%eax 739: 89 04 24 mov %eax,(%esp) 73c: e8 a2 fd ff ff call 4e3 <putc> putc(fd, c); 741: 8b 45 e4 mov -0x1c(%ebp),%eax 744: 0f be c0 movsbl %al,%eax 747: 89 44 24 04 mov %eax,0x4(%esp) 74b: 8b 45 08 mov 0x8(%ebp),%eax 74e: 89 04 24 mov %eax,(%esp) 751: e8 8d fd ff ff call 4e3 <putc> } state = 0; 756: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 75d: 83 45 f0 01 addl $0x1,-0x10(%ebp) 761: 8b 55 0c mov 0xc(%ebp),%edx 764: 8b 45 f0 mov -0x10(%ebp),%eax 767: 01 d0 add %edx,%eax 769: 0f b6 00 movzbl (%eax),%eax 76c: 84 c0 test %al,%al 76e: 0f 85 71 fe ff ff jne 5e5 <printf+0x22> putc(fd, c); } state = 0; } } } 774: c9 leave 775: c3 ret 00000776 <free>: static Header base; static Header *freep; void free(void *ap) { 776: 55 push %ebp 777: 89 e5 mov %esp,%ebp 779: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 77c: 8b 45 08 mov 0x8(%ebp),%eax 77f: 83 e8 08 sub $0x8,%eax 782: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 785: a1 ac 11 00 00 mov 0x11ac,%eax 78a: 89 45 fc mov %eax,-0x4(%ebp) 78d: eb 24 jmp 7b3 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 78f: 8b 45 fc mov -0x4(%ebp),%eax 792: 8b 00 mov (%eax),%eax 794: 3b 45 fc cmp -0x4(%ebp),%eax 797: 77 12 ja 7ab <free+0x35> 799: 8b 45 f8 mov -0x8(%ebp),%eax 79c: 3b 45 fc cmp -0x4(%ebp),%eax 79f: 77 24 ja 7c5 <free+0x4f> 7a1: 8b 45 fc mov -0x4(%ebp),%eax 7a4: 8b 00 mov (%eax),%eax 7a6: 3b 45 f8 cmp -0x8(%ebp),%eax 7a9: 77 1a ja 7c5 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7ab: 8b 45 fc mov -0x4(%ebp),%eax 7ae: 8b 00 mov (%eax),%eax 7b0: 89 45 fc mov %eax,-0x4(%ebp) 7b3: 8b 45 f8 mov -0x8(%ebp),%eax 7b6: 3b 45 fc cmp -0x4(%ebp),%eax 7b9: 76 d4 jbe 78f <free+0x19> 7bb: 8b 45 fc mov -0x4(%ebp),%eax 7be: 8b 00 mov (%eax),%eax 7c0: 3b 45 f8 cmp -0x8(%ebp),%eax 7c3: 76 ca jbe 78f <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7c5: 8b 45 f8 mov -0x8(%ebp),%eax 7c8: 8b 40 04 mov 0x4(%eax),%eax 7cb: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 7d2: 8b 45 f8 mov -0x8(%ebp),%eax 7d5: 01 c2 add %eax,%edx 7d7: 8b 45 fc mov -0x4(%ebp),%eax 7da: 8b 00 mov (%eax),%eax 7dc: 39 c2 cmp %eax,%edx 7de: 75 24 jne 804 <free+0x8e> bp->s.size += p->s.ptr->s.size; 7e0: 8b 45 f8 mov -0x8(%ebp),%eax 7e3: 8b 50 04 mov 0x4(%eax),%edx 7e6: 8b 45 fc mov -0x4(%ebp),%eax 7e9: 8b 00 mov (%eax),%eax 7eb: 8b 40 04 mov 0x4(%eax),%eax 7ee: 01 c2 add %eax,%edx 7f0: 8b 45 f8 mov -0x8(%ebp),%eax 7f3: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 7f6: 8b 45 fc mov -0x4(%ebp),%eax 7f9: 8b 00 mov (%eax),%eax 7fb: 8b 10 mov (%eax),%edx 7fd: 8b 45 f8 mov -0x8(%ebp),%eax 800: 89 10 mov %edx,(%eax) 802: eb 0a jmp 80e <free+0x98> } else bp->s.ptr = p->s.ptr; 804: 8b 45 fc mov -0x4(%ebp),%eax 807: 8b 10 mov (%eax),%edx 809: 8b 45 f8 mov -0x8(%ebp),%eax 80c: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 80e: 8b 45 fc mov -0x4(%ebp),%eax 811: 8b 40 04 mov 0x4(%eax),%eax 814: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 81b: 8b 45 fc mov -0x4(%ebp),%eax 81e: 01 d0 add %edx,%eax 820: 3b 45 f8 cmp -0x8(%ebp),%eax 823: 75 20 jne 845 <free+0xcf> p->s.size += bp->s.size; 825: 8b 45 fc mov -0x4(%ebp),%eax 828: 8b 50 04 mov 0x4(%eax),%edx 82b: 8b 45 f8 mov -0x8(%ebp),%eax 82e: 8b 40 04 mov 0x4(%eax),%eax 831: 01 c2 add %eax,%edx 833: 8b 45 fc mov -0x4(%ebp),%eax 836: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 839: 8b 45 f8 mov -0x8(%ebp),%eax 83c: 8b 10 mov (%eax),%edx 83e: 8b 45 fc mov -0x4(%ebp),%eax 841: 89 10 mov %edx,(%eax) 843: eb 08 jmp 84d <free+0xd7> } else p->s.ptr = bp; 845: 8b 45 fc mov -0x4(%ebp),%eax 848: 8b 55 f8 mov -0x8(%ebp),%edx 84b: 89 10 mov %edx,(%eax) freep = p; 84d: 8b 45 fc mov -0x4(%ebp),%eax 850: a3 ac 11 00 00 mov %eax,0x11ac } 855: c9 leave 856: c3 ret 00000857 <morecore>: static Header* morecore(uint nu) { 857: 55 push %ebp 858: 89 e5 mov %esp,%ebp 85a: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 85d: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 864: 77 07 ja 86d <morecore+0x16> nu = 4096; 866: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 86d: 8b 45 08 mov 0x8(%ebp),%eax 870: c1 e0 03 shl $0x3,%eax 873: 89 04 24 mov %eax,(%esp) 876: e8 28 fc ff ff call 4a3 <sbrk> 87b: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 87e: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 882: 75 07 jne 88b <morecore+0x34> return 0; 884: b8 00 00 00 00 mov $0x0,%eax 889: eb 22 jmp 8ad <morecore+0x56> hp = (Header*)p; 88b: 8b 45 f4 mov -0xc(%ebp),%eax 88e: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 891: 8b 45 f0 mov -0x10(%ebp),%eax 894: 8b 55 08 mov 0x8(%ebp),%edx 897: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 89a: 8b 45 f0 mov -0x10(%ebp),%eax 89d: 83 c0 08 add $0x8,%eax 8a0: 89 04 24 mov %eax,(%esp) 8a3: e8 ce fe ff ff call 776 <free> return freep; 8a8: a1 ac 11 00 00 mov 0x11ac,%eax } 8ad: c9 leave 8ae: c3 ret 000008af <malloc>: void* malloc(uint nbytes) { 8af: 55 push %ebp 8b0: 89 e5 mov %esp,%ebp 8b2: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 8b5: 8b 45 08 mov 0x8(%ebp),%eax 8b8: 83 c0 07 add $0x7,%eax 8bb: c1 e8 03 shr $0x3,%eax 8be: 83 c0 01 add $0x1,%eax 8c1: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 8c4: a1 ac 11 00 00 mov 0x11ac,%eax 8c9: 89 45 f0 mov %eax,-0x10(%ebp) 8cc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8d0: 75 23 jne 8f5 <malloc+0x46> base.s.ptr = freep = prevp = &base; 8d2: c7 45 f0 a4 11 00 00 movl $0x11a4,-0x10(%ebp) 8d9: 8b 45 f0 mov -0x10(%ebp),%eax 8dc: a3 ac 11 00 00 mov %eax,0x11ac 8e1: a1 ac 11 00 00 mov 0x11ac,%eax 8e6: a3 a4 11 00 00 mov %eax,0x11a4 base.s.size = 0; 8eb: c7 05 a8 11 00 00 00 movl $0x0,0x11a8 8f2: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8f5: 8b 45 f0 mov -0x10(%ebp),%eax 8f8: 8b 00 mov (%eax),%eax 8fa: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 8fd: 8b 45 f4 mov -0xc(%ebp),%eax 900: 8b 40 04 mov 0x4(%eax),%eax 903: 3b 45 ec cmp -0x14(%ebp),%eax 906: 72 4d jb 955 <malloc+0xa6> if(p->s.size == nunits) 908: 8b 45 f4 mov -0xc(%ebp),%eax 90b: 8b 40 04 mov 0x4(%eax),%eax 90e: 3b 45 ec cmp -0x14(%ebp),%eax 911: 75 0c jne 91f <malloc+0x70> prevp->s.ptr = p->s.ptr; 913: 8b 45 f4 mov -0xc(%ebp),%eax 916: 8b 10 mov (%eax),%edx 918: 8b 45 f0 mov -0x10(%ebp),%eax 91b: 89 10 mov %edx,(%eax) 91d: eb 26 jmp 945 <malloc+0x96> else { p->s.size -= nunits; 91f: 8b 45 f4 mov -0xc(%ebp),%eax 922: 8b 40 04 mov 0x4(%eax),%eax 925: 2b 45 ec sub -0x14(%ebp),%eax 928: 89 c2 mov %eax,%edx 92a: 8b 45 f4 mov -0xc(%ebp),%eax 92d: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 930: 8b 45 f4 mov -0xc(%ebp),%eax 933: 8b 40 04 mov 0x4(%eax),%eax 936: c1 e0 03 shl $0x3,%eax 939: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 93c: 8b 45 f4 mov -0xc(%ebp),%eax 93f: 8b 55 ec mov -0x14(%ebp),%edx 942: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 945: 8b 45 f0 mov -0x10(%ebp),%eax 948: a3 ac 11 00 00 mov %eax,0x11ac return (void*)(p + 1); 94d: 8b 45 f4 mov -0xc(%ebp),%eax 950: 83 c0 08 add $0x8,%eax 953: eb 38 jmp 98d <malloc+0xde> } if(p == freep) 955: a1 ac 11 00 00 mov 0x11ac,%eax 95a: 39 45 f4 cmp %eax,-0xc(%ebp) 95d: 75 1b jne 97a <malloc+0xcb> if((p = morecore(nunits)) == 0) 95f: 8b 45 ec mov -0x14(%ebp),%eax 962: 89 04 24 mov %eax,(%esp) 965: e8 ed fe ff ff call 857 <morecore> 96a: 89 45 f4 mov %eax,-0xc(%ebp) 96d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 971: 75 07 jne 97a <malloc+0xcb> return 0; 973: b8 00 00 00 00 mov $0x0,%eax 978: eb 13 jmp 98d <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 97a: 8b 45 f4 mov -0xc(%ebp),%eax 97d: 89 45 f0 mov %eax,-0x10(%ebp) 980: 8b 45 f4 mov -0xc(%ebp),%eax 983: 8b 00 mov (%eax),%eax 985: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 988: e9 70 ff ff ff jmp 8fd <malloc+0x4e> } 98d: c9 leave 98e: c3 ret 0000098f <xchg>: asm volatile("sti"); } static inline uint xchg(volatile uint *addr, uint newval) { 98f: 55 push %ebp 990: 89 e5 mov %esp,%ebp 992: 83 ec 10 sub $0x10,%esp uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 995: 8b 55 08 mov 0x8(%ebp),%edx 998: 8b 45 0c mov 0xc(%ebp),%eax 99b: 8b 4d 08 mov 0x8(%ebp),%ecx 99e: f0 87 02 lock xchg %eax,(%edx) 9a1: 89 45 fc mov %eax,-0x4(%ebp) "+m" (*addr), "=a" (result) : "1" (newval) : "cc"); return result; 9a4: 8b 45 fc mov -0x4(%ebp),%eax } 9a7: c9 leave 9a8: c3 ret 000009a9 <lock_init>: #include "mmu.h" #include "spinlock.h" #include "x86.h" #include "proc.h" void lock_init(lock_t *lock){ 9a9: 55 push %ebp 9aa: 89 e5 mov %esp,%ebp lock->locked = 0; 9ac: 8b 45 08 mov 0x8(%ebp),%eax 9af: c7 00 00 00 00 00 movl $0x0,(%eax) } 9b5: 5d pop %ebp 9b6: c3 ret 000009b7 <lock_acquire>: void lock_acquire(lock_t *lock){ 9b7: 55 push %ebp 9b8: 89 e5 mov %esp,%ebp 9ba: 83 ec 08 sub $0x8,%esp while(xchg(&lock->locked,1) != 0); 9bd: 90 nop 9be: 8b 45 08 mov 0x8(%ebp),%eax 9c1: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 9c8: 00 9c9: 89 04 24 mov %eax,(%esp) 9cc: e8 be ff ff ff call 98f <xchg> 9d1: 85 c0 test %eax,%eax 9d3: 75 e9 jne 9be <lock_acquire+0x7> } 9d5: c9 leave 9d6: c3 ret 000009d7 <lock_release>: void lock_release(lock_t *lock){ 9d7: 55 push %ebp 9d8: 89 e5 mov %esp,%ebp 9da: 83 ec 08 sub $0x8,%esp xchg(&lock->locked,0); 9dd: 8b 45 08 mov 0x8(%ebp),%eax 9e0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 9e7: 00 9e8: 89 04 24 mov %eax,(%esp) 9eb: e8 9f ff ff ff call 98f <xchg> } 9f0: c9 leave 9f1: c3 ret 000009f2 <thread_create>: void *thread_create(void(*start_routine)(void*), void *arg){ 9f2: 55 push %ebp 9f3: 89 e5 mov %esp,%ebp 9f5: 83 ec 28 sub $0x28,%esp int tid; void * stack = malloc(2 * 4096); 9f8: c7 04 24 00 20 00 00 movl $0x2000,(%esp) 9ff: e8 ab fe ff ff call 8af <malloc> a04: 89 45 f4 mov %eax,-0xc(%ebp) void *garbage_stack = stack; a07: 8b 45 f4 mov -0xc(%ebp),%eax a0a: 89 45 f0 mov %eax,-0x10(%ebp) // printf(1,"start routine addr : %d\n",(uint)start_routine); if((uint)stack % 4096){ a0d: 8b 45 f4 mov -0xc(%ebp),%eax a10: 25 ff 0f 00 00 and $0xfff,%eax a15: 85 c0 test %eax,%eax a17: 74 14 je a2d <thread_create+0x3b> stack = stack + (4096 - (uint)stack % 4096); a19: 8b 45 f4 mov -0xc(%ebp),%eax a1c: 25 ff 0f 00 00 and $0xfff,%eax a21: 89 c2 mov %eax,%edx a23: b8 00 10 00 00 mov $0x1000,%eax a28: 29 d0 sub %edx,%eax a2a: 01 45 f4 add %eax,-0xc(%ebp) } if (stack == 0){ a2d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) a31: 75 1b jne a4e <thread_create+0x5c> printf(1,"malloc fail \n"); a33: c7 44 24 04 5c 0d 00 movl $0xd5c,0x4(%esp) a3a: 00 a3b: c7 04 24 01 00 00 00 movl $0x1,(%esp) a42: e8 7c fb ff ff call 5c3 <printf> return 0; a47: b8 00 00 00 00 mov $0x0,%eax a4c: eb 6f jmp abd <thread_create+0xcb> } tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg); a4e: 8b 4d 0c mov 0xc(%ebp),%ecx a51: 8b 55 08 mov 0x8(%ebp),%edx a54: 8b 45 f4 mov -0xc(%ebp),%eax a57: 89 4c 24 0c mov %ecx,0xc(%esp) a5b: 89 54 24 08 mov %edx,0x8(%esp) a5f: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) a66: 00 a67: 89 04 24 mov %eax,(%esp) a6a: e8 4c fa ff ff call 4bb <clone> a6f: 89 45 ec mov %eax,-0x14(%ebp) if(tid < 0){ a72: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) a76: 79 1b jns a93 <thread_create+0xa1> printf(1,"clone fails\n"); a78: c7 44 24 04 6a 0d 00 movl $0xd6a,0x4(%esp) a7f: 00 a80: c7 04 24 01 00 00 00 movl $0x1,(%esp) a87: e8 37 fb ff ff call 5c3 <printf> return 0; a8c: b8 00 00 00 00 mov $0x0,%eax a91: eb 2a jmp abd <thread_create+0xcb> } if(tid > 0){ a93: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) a97: 7e 05 jle a9e <thread_create+0xac> //store threads on thread table return garbage_stack; a99: 8b 45 f0 mov -0x10(%ebp),%eax a9c: eb 1f jmp abd <thread_create+0xcb> } if(tid == 0){ a9e: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) aa2: 75 14 jne ab8 <thread_create+0xc6> printf(1,"tid = 0 return \n"); aa4: c7 44 24 04 77 0d 00 movl $0xd77,0x4(%esp) aab: 00 aac: c7 04 24 01 00 00 00 movl $0x1,(%esp) ab3: e8 0b fb ff ff call 5c3 <printf> } // wait(); // free(garbage_stack); return 0; ab8: b8 00 00 00 00 mov $0x0,%eax } abd: c9 leave abe: c3 ret 00000abf <random>: unsigned long rands = 1; // generate 0 -> max random number exclude max. int random(int max){ abf: 55 push %ebp ac0: 89 e5 mov %esp,%ebp rands = rands * 1664525 + 1013904233; ac2: a1 a0 11 00 00 mov 0x11a0,%eax ac7: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax acd: 05 69 f3 6e 3c add $0x3c6ef369,%eax ad2: a3 a0 11 00 00 mov %eax,0x11a0 return (int)(rands % max); ad7: a1 a0 11 00 00 mov 0x11a0,%eax adc: 8b 4d 08 mov 0x8(%ebp),%ecx adf: ba 00 00 00 00 mov $0x0,%edx ae4: f7 f1 div %ecx ae6: 89 d0 mov %edx,%eax ae8: 5d pop %ebp ae9: c3 ret 00000aea <init_q>: #include "queue.h" #include "types.h" #include "user.h" void init_q(struct queue *q){ aea: 55 push %ebp aeb: 89 e5 mov %esp,%ebp q->size = 0; aed: 8b 45 08 mov 0x8(%ebp),%eax af0: c7 00 00 00 00 00 movl $0x0,(%eax) q->head = 0; af6: 8b 45 08 mov 0x8(%ebp),%eax af9: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) q->tail = 0; b00: 8b 45 08 mov 0x8(%ebp),%eax b03: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } b0a: 5d pop %ebp b0b: c3 ret 00000b0c <add_q>: void add_q(struct queue *q, int v){ b0c: 55 push %ebp b0d: 89 e5 mov %esp,%ebp b0f: 83 ec 28 sub $0x28,%esp struct node * n = malloc(sizeof(struct node)); b12: c7 04 24 08 00 00 00 movl $0x8,(%esp) b19: e8 91 fd ff ff call 8af <malloc> b1e: 89 45 f4 mov %eax,-0xc(%ebp) n->next = 0; b21: 8b 45 f4 mov -0xc(%ebp),%eax b24: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) n->value = v; b2b: 8b 45 f4 mov -0xc(%ebp),%eax b2e: 8b 55 0c mov 0xc(%ebp),%edx b31: 89 10 mov %edx,(%eax) if(q->head == 0){ b33: 8b 45 08 mov 0x8(%ebp),%eax b36: 8b 40 04 mov 0x4(%eax),%eax b39: 85 c0 test %eax,%eax b3b: 75 0b jne b48 <add_q+0x3c> q->head = n; b3d: 8b 45 08 mov 0x8(%ebp),%eax b40: 8b 55 f4 mov -0xc(%ebp),%edx b43: 89 50 04 mov %edx,0x4(%eax) b46: eb 0c jmp b54 <add_q+0x48> }else{ q->tail->next = n; b48: 8b 45 08 mov 0x8(%ebp),%eax b4b: 8b 40 08 mov 0x8(%eax),%eax b4e: 8b 55 f4 mov -0xc(%ebp),%edx b51: 89 50 04 mov %edx,0x4(%eax) } q->tail = n; b54: 8b 45 08 mov 0x8(%ebp),%eax b57: 8b 55 f4 mov -0xc(%ebp),%edx b5a: 89 50 08 mov %edx,0x8(%eax) q->size++; b5d: 8b 45 08 mov 0x8(%ebp),%eax b60: 8b 00 mov (%eax),%eax b62: 8d 50 01 lea 0x1(%eax),%edx b65: 8b 45 08 mov 0x8(%ebp),%eax b68: 89 10 mov %edx,(%eax) } b6a: c9 leave b6b: c3 ret 00000b6c <empty_q>: int empty_q(struct queue *q){ b6c: 55 push %ebp b6d: 89 e5 mov %esp,%ebp if(q->size == 0) b6f: 8b 45 08 mov 0x8(%ebp),%eax b72: 8b 00 mov (%eax),%eax b74: 85 c0 test %eax,%eax b76: 75 07 jne b7f <empty_q+0x13> return 1; b78: b8 01 00 00 00 mov $0x1,%eax b7d: eb 05 jmp b84 <empty_q+0x18> else return 0; b7f: b8 00 00 00 00 mov $0x0,%eax } b84: 5d pop %ebp b85: c3 ret 00000b86 <pop_q>: int pop_q(struct queue *q){ b86: 55 push %ebp b87: 89 e5 mov %esp,%ebp b89: 83 ec 28 sub $0x28,%esp int val; struct node *destroy; if(!empty_q(q)){ b8c: 8b 45 08 mov 0x8(%ebp),%eax b8f: 89 04 24 mov %eax,(%esp) b92: e8 d5 ff ff ff call b6c <empty_q> b97: 85 c0 test %eax,%eax b99: 75 5d jne bf8 <pop_q+0x72> val = q->head->value; b9b: 8b 45 08 mov 0x8(%ebp),%eax b9e: 8b 40 04 mov 0x4(%eax),%eax ba1: 8b 00 mov (%eax),%eax ba3: 89 45 f4 mov %eax,-0xc(%ebp) destroy = q->head; ba6: 8b 45 08 mov 0x8(%ebp),%eax ba9: 8b 40 04 mov 0x4(%eax),%eax bac: 89 45 f0 mov %eax,-0x10(%ebp) q->head = q->head->next; baf: 8b 45 08 mov 0x8(%ebp),%eax bb2: 8b 40 04 mov 0x4(%eax),%eax bb5: 8b 50 04 mov 0x4(%eax),%edx bb8: 8b 45 08 mov 0x8(%ebp),%eax bbb: 89 50 04 mov %edx,0x4(%eax) free(destroy); bbe: 8b 45 f0 mov -0x10(%ebp),%eax bc1: 89 04 24 mov %eax,(%esp) bc4: e8 ad fb ff ff call 776 <free> q->size--; bc9: 8b 45 08 mov 0x8(%ebp),%eax bcc: 8b 00 mov (%eax),%eax bce: 8d 50 ff lea -0x1(%eax),%edx bd1: 8b 45 08 mov 0x8(%ebp),%eax bd4: 89 10 mov %edx,(%eax) if(q->size == 0){ bd6: 8b 45 08 mov 0x8(%ebp),%eax bd9: 8b 00 mov (%eax),%eax bdb: 85 c0 test %eax,%eax bdd: 75 14 jne bf3 <pop_q+0x6d> q->head = 0; bdf: 8b 45 08 mov 0x8(%ebp),%eax be2: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) q->tail = 0; be9: 8b 45 08 mov 0x8(%ebp),%eax bec: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } return val; bf3: 8b 45 f4 mov -0xc(%ebp),%eax bf6: eb 05 jmp bfd <pop_q+0x77> } return -1; bf8: b8 ff ff ff ff mov $0xffffffff,%eax } bfd: c9 leave bfe: c3 ret 00000bff <sem_init>: #include "types.h" #include "user.h" #include "semaphore.h" void sem_init(struct semaphore *s, int size){ bff: 55 push %ebp c00: 89 e5 mov %esp,%ebp c02: 83 ec 18 sub $0x18,%esp s->size = size; c05: 8b 45 08 mov 0x8(%ebp),%eax c08: 8b 55 0c mov 0xc(%ebp),%edx c0b: 89 50 08 mov %edx,0x8(%eax) s->count = size; c0e: 8b 45 08 mov 0x8(%ebp),%eax c11: 8b 55 0c mov 0xc(%ebp),%edx c14: 89 50 04 mov %edx,0x4(%eax) lock_init(&s->lock); c17: 8b 45 08 mov 0x8(%ebp),%eax c1a: 89 04 24 mov %eax,(%esp) c1d: e8 87 fd ff ff call 9a9 <lock_init> } c22: c9 leave c23: c3 ret 00000c24 <sem_init_full>: void sem_init_full(struct semaphore *s, int size){ c24: 55 push %ebp c25: 89 e5 mov %esp,%ebp c27: 83 ec 18 sub $0x18,%esp s->size = size; c2a: 8b 45 08 mov 0x8(%ebp),%eax c2d: 8b 55 0c mov 0xc(%ebp),%edx c30: 89 50 08 mov %edx,0x8(%eax) s->count= 0; c33: 8b 45 08 mov 0x8(%ebp),%eax c36: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) lock_init(&s->lock); c3d: 8b 45 08 mov 0x8(%ebp),%eax c40: 89 04 24 mov %eax,(%esp) c43: e8 61 fd ff ff call 9a9 <lock_init> } c48: c9 leave c49: c3 ret 00000c4a <sem_aquire>: //Attempts to aquire a lock. If count is not //full then we will add the process to the list of //processes holding the lock. void sem_aquire(struct semaphore * s){ c4a: 55 push %ebp c4b: 89 e5 mov %esp,%ebp c4d: 83 ec 28 sub $0x28,%esp //Disable interrupts? nah //We need to only get a hold of waiters? //If count is full then place proccess on waiters list //Else add to the holding list lock_acquire(&s->lock); c50: 8b 45 08 mov 0x8(%ebp),%eax c53: 89 04 24 mov %eax,(%esp) c56: e8 5c fd ff ff call 9b7 <lock_acquire> if(s->count == 0){ c5b: 8b 45 08 mov 0x8(%ebp),%eax c5e: 8b 40 04 mov 0x4(%eax),%eax c61: 85 c0 test %eax,%eax c63: 75 2f jne c94 <sem_aquire+0x4a> //printf(1, "Sem F\n"); //add proc to waiters list int tid = getpid(); c65: e8 31 f8 ff ff call 49b <getpid> c6a: 89 45 f4 mov %eax,-0xc(%ebp) //place requesting process to sleep add_q(&s->waiters, tid); //Add process to queue c6d: 8b 45 08 mov 0x8(%ebp),%eax c70: 8d 50 0c lea 0xc(%eax),%edx c73: 8b 45 f4 mov -0xc(%ebp),%eax c76: 89 44 24 04 mov %eax,0x4(%esp) c7a: 89 14 24 mov %edx,(%esp) c7d: e8 8a fe ff ff call b0c <add_q> //printf(1, " Added to waiters semaphore with size: %d\n", s->size); lock_release(&s->lock); c82: 8b 45 08 mov 0x8(%ebp),%eax c85: 89 04 24 mov %eax,(%esp) c88: e8 4a fd ff ff call 9d7 <lock_release> tsleep(); c8d: e8 39 f8 ff ff call 4cb <tsleep> c92: eb 1a jmp cae <sem_aquire+0x64> } else{ //printf(1, "Sem A\n"); s->count--; c94: 8b 45 08 mov 0x8(%ebp),%eax c97: 8b 40 04 mov 0x4(%eax),%eax c9a: 8d 50 ff lea -0x1(%eax),%edx c9d: 8b 45 08 mov 0x8(%ebp),%eax ca0: 89 50 04 mov %edx,0x4(%eax) lock_release(&s->lock); ca3: 8b 45 08 mov 0x8(%ebp),%eax ca6: 89 04 24 mov %eax,(%esp) ca9: e8 29 fd ff ff call 9d7 <lock_release> } } cae: c9 leave caf: c3 ret 00000cb0 <sem_signal>: //Removes a process from a lock and decreases count //to indicate that more process can hold the lock. void sem_signal(struct semaphore * s){ cb0: 55 push %ebp cb1: 89 e5 mov %esp,%ebp cb3: 83 ec 28 sub $0x28,%esp //printf(1, "Sem R\n"); //If count is full then place proccess on waiters list lock_acquire(&s->lock); cb6: 8b 45 08 mov 0x8(%ebp),%eax cb9: 89 04 24 mov %eax,(%esp) cbc: e8 f6 fc ff ff call 9b7 <lock_acquire> if(s->count < s->size){ cc1: 8b 45 08 mov 0x8(%ebp),%eax cc4: 8b 50 04 mov 0x4(%eax),%edx cc7: 8b 45 08 mov 0x8(%ebp),%eax cca: 8b 40 08 mov 0x8(%eax),%eax ccd: 39 c2 cmp %eax,%edx ccf: 7d 0f jge ce0 <sem_signal+0x30> s->count++; cd1: 8b 45 08 mov 0x8(%ebp),%eax cd4: 8b 40 04 mov 0x4(%eax),%eax cd7: 8d 50 01 lea 0x1(%eax),%edx cda: 8b 45 08 mov 0x8(%ebp),%eax cdd: 89 50 04 mov %edx,0x4(%eax) } int tid; tid = pop_q(&s->waiters); ce0: 8b 45 08 mov 0x8(%ebp),%eax ce3: 83 c0 0c add $0xc,%eax ce6: 89 04 24 mov %eax,(%esp) ce9: e8 98 fe ff ff call b86 <pop_q> cee: 89 45 f4 mov %eax,-0xc(%ebp) if(tid != -1){ cf1: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) cf5: 74 2e je d25 <sem_signal+0x75> //printf(1, "Sem A\n"); twakeup(tid); cf7: 8b 45 f4 mov -0xc(%ebp),%eax cfa: 89 04 24 mov %eax,(%esp) cfd: e8 d1 f7 ff ff call 4d3 <twakeup> s->count--; d02: 8b 45 08 mov 0x8(%ebp),%eax d05: 8b 40 04 mov 0x4(%eax),%eax d08: 8d 50 ff lea -0x1(%eax),%edx d0b: 8b 45 08 mov 0x8(%ebp),%eax d0e: 89 50 04 mov %edx,0x4(%eax) if(s->count < 0) s->count = 0; d11: 8b 45 08 mov 0x8(%ebp),%eax d14: 8b 40 04 mov 0x4(%eax),%eax d17: 85 c0 test %eax,%eax d19: 79 0a jns d25 <sem_signal+0x75> d1b: 8b 45 08 mov 0x8(%ebp),%eax d1e: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) } lock_release(&s->lock); d25: 8b 45 08 mov 0x8(%ebp),%eax d28: 89 04 24 mov %eax,(%esp) d2b: e8 a7 fc ff ff call 9d7 <lock_release> d30: c9 leave d31: c3 ret
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "extern/beatsaber-hook/shared/utils/typedefs.h" // Including type: Zenject.IValidatable #include "Zenject/IValidatable.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "extern/beatsaber-hook/shared/utils/utils.h" // Completed includes // Begin forward declares // Forward declaring namespace: Zenject namespace Zenject { // Forward declaring type: DiContainer class DiContainer; // Forward declaring type: InjectContext class InjectContext; } // Completed forward declares // Type namespace: Zenject namespace Zenject { // WARNING Size may be invalid! // Autogenerated type: Zenject.LazyInject`1 // [ZenjectAllowDuringValidationAttribute] Offset: DDCE90 // [NoReflectionBakingAttribute] Offset: DDCE90 template<typename T> class LazyInject_1 : public ::Il2CppObject/*, public Zenject::IValidatable*/ { public: // private readonly Zenject.DiContainer _container // Size: 0x8 // Offset: 0x0 Zenject::DiContainer* container; // Field size check static_assert(sizeof(Zenject::DiContainer*) == 0x8); // private readonly Zenject.InjectContext _context // Size: 0x8 // Offset: 0x0 Zenject::InjectContext* context; // Field size check static_assert(sizeof(Zenject::InjectContext*) == 0x8); // private System.Boolean _hasValue // Size: 0x1 // Offset: 0x0 bool hasValue; // Field size check static_assert(sizeof(bool) == 0x1); // private T _value // Size: 0xFFFFFFFF // Offset: 0x0 T value; // Creating value type constructor for type: LazyInject_1 LazyInject_1(Zenject::DiContainer* container_ = {}, Zenject::InjectContext* context_ = {}, bool hasValue_ = {}, T value_ = {}) noexcept : container{container_}, context{context_}, hasValue{hasValue_}, value{value_} {} // Creating interface conversion operator: operator Zenject::IValidatable operator Zenject::IValidatable() noexcept { return *reinterpret_cast<Zenject::IValidatable*>(this); } // public System.Void .ctor(Zenject.DiContainer container, Zenject.InjectContext context) // Offset: 0xFFFFFFFF template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static LazyInject_1<T>* New_ctor(Zenject::DiContainer* container, Zenject::InjectContext* context) { static auto ___internal__logger = ::Logger::get().WithContext("Zenject::LazyInject_1::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<LazyInject_1<T>*, creationType>(container, context))); } // private System.Void Zenject.IValidatable.Validate() // Offset: 0xFFFFFFFF void Zenject_IValidatable_Validate() { static auto ___internal__logger = ::Logger::get().WithContext("Zenject::LazyInject_1::Zenject.IValidatable.Validate"); auto* ___internal__method = THROW_UNLESS((::il2cpp_utils::FindMethod(this, "Zenject.IValidatable.Validate", std::vector<Il2CppClass*>{}, ::std::vector<const Il2CppType*>{}))); ::il2cpp_utils::RunMethodThrow<void, false>(this, ___internal__method); } // public T get_Value() // Offset: 0xFFFFFFFF T get_Value() { static auto ___internal__logger = ::Logger::get().WithContext("Zenject::LazyInject_1::get_Value"); static auto* ___internal__method = THROW_UNLESS((::il2cpp_utils::FindMethod(this, "get_Value", std::vector<Il2CppClass*>{}, ::std::vector<const Il2CppType*>{}))); return ::il2cpp_utils::RunMethodThrow<T, false>(this, ___internal__method); } }; // Zenject.LazyInject`1 // Could not write size check! Type: Zenject.LazyInject`1 is generic, or has no fields that are valid for size checks! } DEFINE_IL2CPP_ARG_TYPE_GENERIC_CLASS(Zenject::LazyInject_1, "Zenject", "LazyInject`1");
; A068426: Expansion of log(2) in base 2. ; Submitted by Jon Maiga ; 1,0,1,1,0,0,0,1,0,1,1,1,0,0,1,0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,0,1,1,0,1,0,1,0,1,1,1,1,0,0,1,0,0,1,1,1,1,0,0,0,1,1,1,0,1,1,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0 mov $1,1 mov $2,1 mov $3,$0 mul $3,5 lpb $3 mul $1,$3 mov $5,$3 mul $5,2 add $5,2 mul $2,$5 add $1,$2 cmp $4,0 mov $5,$0 add $5,$4 div $1,$5 div $2,$5 sub $3,1 lpe lpb $0 sub $0,1 mul $1,2 lpe div $1,$2 mov $0,$1 mod $0,2
//===-- StackProtector.cpp - Stack Protector Insertion --------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This pass inserts stack protectors into functions which need them. A variable // with a random value in it is stored onto the stack before the local variables // are allocated. Upon exiting the block, the stored value is checked. If it's // changed, then there was some sort of violation and the program aborts. // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/StackProtector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/CodeGen/Analysis.h" #include "llvm/CodeGen/Passes.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Module.h" #include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetSubtargetInfo.h" #include <cstdlib> using namespace llvm; #define DEBUG_TYPE "stack-protector" STATISTIC(NumFunProtected, "Number of functions protected"); STATISTIC(NumAddrTaken, "Number of local variables that have their address" " taken."); static cl::opt<bool> EnableSelectionDAGSP("enable-selectiondag-sp", cl::init(true), cl::Hidden); char StackProtector::ID = 0; INITIALIZE_PASS(StackProtector, "stack-protector", "Insert stack protectors", false, true) FunctionPass *llvm::createStackProtectorPass(const TargetMachine *TM) { return new StackProtector(TM); } StackProtector::SSPLayoutKind StackProtector::getSSPLayout(const AllocaInst *AI) const { return AI ? Layout.lookup(AI) : SSPLK_None; } void StackProtector::adjustForColoring(const AllocaInst *From, const AllocaInst *To) { // When coloring replaces one alloca with another, transfer the SSPLayoutKind // tag from the remapped to the target alloca. The remapped alloca should // have a size smaller than or equal to the replacement alloca. SSPLayoutMap::iterator I = Layout.find(From); if (I != Layout.end()) { SSPLayoutKind Kind = I->second; Layout.erase(I); // Transfer the tag, but make sure that SSPLK_AddrOf does not overwrite // SSPLK_SmallArray or SSPLK_LargeArray, and make sure that // SSPLK_SmallArray does not overwrite SSPLK_LargeArray. I = Layout.find(To); if (I == Layout.end()) Layout.insert(std::make_pair(To, Kind)); else if (I->second != SSPLK_LargeArray && Kind != SSPLK_AddrOf) I->second = Kind; } } bool StackProtector::runOnFunction(Function &Fn) { F = &Fn; M = F->getParent(); DominatorTreeWrapperPass *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>(); DT = DTWP ? &DTWP->getDomTree() : nullptr; TLI = TM->getSubtargetImpl(Fn)->getTargetLowering(); Attribute Attr = Fn.getFnAttribute("stack-protector-buffer-size"); if (Attr.isStringAttribute() && Attr.getValueAsString().getAsInteger(10, SSPBufferSize)) return false; // Invalid integer string if (!RequiresStackProtector()) return false; ++NumFunProtected; return InsertStackProtectors(); } /// \param [out] IsLarge is set to true if a protectable array is found and /// it is "large" ( >= ssp-buffer-size). In the case of a structure with /// multiple arrays, this gets set if any of them is large. bool StackProtector::ContainsProtectableArray(Type *Ty, bool &IsLarge, bool Strong, bool InStruct) const { if (!Ty) return false; if (ArrayType *AT = dyn_cast<ArrayType>(Ty)) { if (!AT->getElementType()->isIntegerTy(8)) { // If we're on a non-Darwin platform or we're inside of a structure, don't // add stack protectors unless the array is a character array. // However, in strong mode any array, regardless of type and size, // triggers a protector. if (!Strong && (InStruct || !Trip.isOSDarwin())) return false; } // If an array has more than SSPBufferSize bytes of allocated space, then we // emit stack protectors. if (SSPBufferSize <= TLI->getDataLayout()->getTypeAllocSize(AT)) { IsLarge = true; return true; } if (Strong) // Require a protector for all arrays in strong mode return true; } const StructType *ST = dyn_cast<StructType>(Ty); if (!ST) return false; bool NeedsProtector = false; for (StructType::element_iterator I = ST->element_begin(), E = ST->element_end(); I != E; ++I) if (ContainsProtectableArray(*I, IsLarge, Strong, true)) { // If the element is a protectable array and is large (>= SSPBufferSize) // then we are done. If the protectable array is not large, then // keep looking in case a subsequent element is a large array. if (IsLarge) return true; NeedsProtector = true; } return NeedsProtector; } bool StackProtector::HasAddressTaken(const Instruction *AI) { for (const User *U : AI->users()) { if (const StoreInst *SI = dyn_cast<StoreInst>(U)) { if (AI == SI->getValueOperand()) return true; } else if (const PtrToIntInst *SI = dyn_cast<PtrToIntInst>(U)) { if (AI == SI->getOperand(0)) return true; } else if (isa<CallInst>(U)) { return true; } else if (isa<InvokeInst>(U)) { return true; } else if (const SelectInst *SI = dyn_cast<SelectInst>(U)) { if (HasAddressTaken(SI)) return true; } else if (const PHINode *PN = dyn_cast<PHINode>(U)) { // Keep track of what PHI nodes we have already visited to ensure // they are only visited once. if (VisitedPHIs.insert(PN).second) if (HasAddressTaken(PN)) return true; } else if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(U)) { if (HasAddressTaken(GEP)) return true; } else if (const BitCastInst *BI = dyn_cast<BitCastInst>(U)) { if (HasAddressTaken(BI)) return true; } } return false; } /// \brief Check whether or not this function needs a stack protector based /// upon the stack protector level. /// /// We use two heuristics: a standard (ssp) and strong (sspstrong). /// The standard heuristic which will add a guard variable to functions that /// call alloca with a either a variable size or a size >= SSPBufferSize, /// functions with character buffers larger than SSPBufferSize, and functions /// with aggregates containing character buffers larger than SSPBufferSize. The /// strong heuristic will add a guard variables to functions that call alloca /// regardless of size, functions with any buffer regardless of type and size, /// functions with aggregates that contain any buffer regardless of type and /// size, and functions that contain stack-based variables that have had their /// address taken. bool StackProtector::RequiresStackProtector() { bool Strong = false; bool NeedsProtector = false; if (F->hasFnAttribute(Attribute::StackProtectReq)) { NeedsProtector = true; Strong = true; // Use the same heuristic as strong to determine SSPLayout } else if (F->hasFnAttribute(Attribute::StackProtectStrong)) Strong = true; else if (!F->hasFnAttribute(Attribute::StackProtect)) return false; for (const BasicBlock &BB : *F) { for (const Instruction &I : BB) { if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) { if (AI->isArrayAllocation()) { // SSP-Strong: Enable protectors for any call to alloca, regardless // of size. if (Strong) return true; if (const auto *CI = dyn_cast<ConstantInt>(AI->getArraySize())) { if (CI->getLimitedValue(SSPBufferSize) >= SSPBufferSize) { // A call to alloca with size >= SSPBufferSize requires // stack protectors. Layout.insert(std::make_pair(AI, SSPLK_LargeArray)); NeedsProtector = true; } else if (Strong) { // Require protectors for all alloca calls in strong mode. Layout.insert(std::make_pair(AI, SSPLK_SmallArray)); NeedsProtector = true; } } else { // A call to alloca with a variable size requires protectors. Layout.insert(std::make_pair(AI, SSPLK_LargeArray)); NeedsProtector = true; } continue; } bool IsLarge = false; if (ContainsProtectableArray(AI->getAllocatedType(), IsLarge, Strong)) { Layout.insert(std::make_pair(AI, IsLarge ? SSPLK_LargeArray : SSPLK_SmallArray)); NeedsProtector = true; continue; } if (Strong && HasAddressTaken(AI)) { ++NumAddrTaken; Layout.insert(std::make_pair(AI, SSPLK_AddrOf)); NeedsProtector = true; } } } } return NeedsProtector; } static bool InstructionWillNotHaveChain(const Instruction *I) { return !I->mayHaveSideEffects() && !I->mayReadFromMemory() && isSafeToSpeculativelyExecute(I); } /// Identify if RI has a previous instruction in the "Tail Position" and return /// it. Otherwise return 0. /// /// This is based off of the code in llvm::isInTailCallPosition. The difference /// is that it inverts the first part of llvm::isInTailCallPosition since /// isInTailCallPosition is checking if a call is in a tail call position, and /// we are searching for an unknown tail call that might be in the tail call /// position. Once we find the call though, the code uses the same refactored /// code, returnTypeIsEligibleForTailCall. static CallInst *FindPotentialTailCall(BasicBlock *BB, ReturnInst *RI, const TargetLoweringBase *TLI) { // Establish a reasonable upper bound on the maximum amount of instructions we // will look through to find a tail call. unsigned SearchCounter = 0; const unsigned MaxSearch = 4; bool NoInterposingChain = true; for (BasicBlock::reverse_iterator I = std::next(BB->rbegin()), E = BB->rend(); I != E && SearchCounter < MaxSearch; ++I) { Instruction *Inst = &*I; // Skip over debug intrinsics and do not allow them to affect our MaxSearch // counter. if (isa<DbgInfoIntrinsic>(Inst)) continue; // If we find a call and the following conditions are satisifed, then we // have found a tail call that satisfies at least the target independent // requirements of a tail call: // // 1. The call site has the tail marker. // // 2. The call site either will not cause the creation of a chain or if a // chain is necessary there are no instructions in between the callsite and // the call which would create an interposing chain. // // 3. The return type of the function does not impede tail call // optimization. if (CallInst *CI = dyn_cast<CallInst>(Inst)) { if (CI->isTailCall() && (InstructionWillNotHaveChain(CI) || NoInterposingChain) && returnTypeIsEligibleForTailCall(BB->getParent(), CI, RI, *TLI)) return CI; } // If we did not find a call see if we have an instruction that may create // an interposing chain. NoInterposingChain = NoInterposingChain && InstructionWillNotHaveChain(Inst); // Increment max search. SearchCounter++; } return nullptr; } /// Insert code into the entry block that stores the __stack_chk_guard /// variable onto the stack: /// /// entry: /// StackGuardSlot = alloca i8* /// StackGuard = load __stack_chk_guard /// call void @llvm.stackprotect.create(StackGuard, StackGuardSlot) /// /// Returns true if the platform/triple supports the stackprotectorcreate pseudo /// node. static bool CreatePrologue(Function *F, Module *M, ReturnInst *RI, const TargetLoweringBase *TLI, const Triple &TT, AllocaInst *&AI, Value *&StackGuardVar) { bool SupportsSelectionDAGSP = false; PointerType *PtrTy = Type::getInt8PtrTy(RI->getContext()); unsigned AddressSpace, Offset; if (TLI->getStackCookieLocation(AddressSpace, Offset)) { Constant *OffsetVal = ConstantInt::get(Type::getInt32Ty(RI->getContext()), Offset); StackGuardVar = ConstantExpr::getIntToPtr(OffsetVal, PointerType::get(PtrTy, AddressSpace)); } else if (TT.isOSOpenBSD()) { StackGuardVar = M->getOrInsertGlobal("__guard_local", PtrTy); cast<GlobalValue>(StackGuardVar) ->setVisibility(GlobalValue::HiddenVisibility); } else { SupportsSelectionDAGSP = true; StackGuardVar = M->getOrInsertGlobal("__stack_chk_guard", PtrTy); } IRBuilder<> B(&F->getEntryBlock().front()); AI = B.CreateAlloca(PtrTy, nullptr, "StackGuardSlot"); LoadInst *LI = B.CreateLoad(StackGuardVar, "StackGuard"); B.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::stackprotector), {LI, AI}); return SupportsSelectionDAGSP; } /// InsertStackProtectors - Insert code into the prologue and epilogue of the /// function. /// /// - The prologue code loads and stores the stack guard onto the stack. /// - The epilogue checks the value stored in the prologue against the original /// value. It calls __stack_chk_fail if they differ. bool StackProtector::InsertStackProtectors() { bool HasPrologue = false; bool SupportsSelectionDAGSP = EnableSelectionDAGSP && !TM->Options.EnableFastISel; AllocaInst *AI = nullptr; // Place on stack that stores the stack guard. Value *StackGuardVar = nullptr; // The stack guard variable. for (Function::iterator I = F->begin(), E = F->end(); I != E;) { BasicBlock *BB = I++; ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator()); if (!RI) continue; if (!HasPrologue) { HasPrologue = true; SupportsSelectionDAGSP &= CreatePrologue(F, M, RI, TLI, Trip, AI, StackGuardVar); } if (SupportsSelectionDAGSP) { // Since we have a potential tail call, insert the special stack check // intrinsic. Instruction *InsertionPt = nullptr; if (CallInst *CI = FindPotentialTailCall(BB, RI, TLI)) { InsertionPt = CI; } else { InsertionPt = RI; // At this point we know that BB has a return statement so it *DOES* // have a terminator. assert(InsertionPt != nullptr && "BB must have a terminator instruction at this point."); } Function *Intrinsic = Intrinsic::getDeclaration(M, Intrinsic::stackprotectorcheck); CallInst::Create(Intrinsic, StackGuardVar, "", InsertionPt); } else { // If we do not support SelectionDAG based tail calls, generate IR level // tail calls. // // For each block with a return instruction, convert this: // // return: // ... // ret ... // // into this: // // return: // ... // %1 = load __stack_chk_guard // %2 = load StackGuardSlot // %3 = cmp i1 %1, %2 // br i1 %3, label %SP_return, label %CallStackCheckFailBlk // // SP_return: // ret ... // // CallStackCheckFailBlk: // call void @__stack_chk_fail() // unreachable // Create the FailBB. We duplicate the BB every time since the MI tail // merge pass will merge together all of the various BB into one including // fail BB generated by the stack protector pseudo instruction. BasicBlock *FailBB = CreateFailBB(); // Split the basic block before the return instruction. BasicBlock *NewBB = BB->splitBasicBlock(RI, "SP_return"); // Update the dominator tree if we need to. if (DT && DT->isReachableFromEntry(BB)) { DT->addNewBlock(NewBB, BB); DT->addNewBlock(FailBB, BB); } // Remove default branch instruction to the new BB. BB->getTerminator()->eraseFromParent(); // Move the newly created basic block to the point right after the old // basic block so that it's in the "fall through" position. NewBB->moveAfter(BB); // Generate the stack protector instructions in the old basic block. IRBuilder<> B(BB); LoadInst *LI1 = B.CreateLoad(StackGuardVar); LoadInst *LI2 = B.CreateLoad(AI); Value *Cmp = B.CreateICmpEQ(LI1, LI2); unsigned SuccessWeight = BranchProbabilityInfo::getBranchWeightStackProtector(true); unsigned FailureWeight = BranchProbabilityInfo::getBranchWeightStackProtector(false); MDNode *Weights = MDBuilder(F->getContext()) .createBranchWeights(SuccessWeight, FailureWeight); B.CreateCondBr(Cmp, NewBB, FailBB, Weights); } } // Return if we didn't modify any basic blocks. i.e., there are no return // statements in the function. if (!HasPrologue) return false; return true; } /// CreateFailBB - Create a basic block to jump to when the stack protector /// check fails. BasicBlock *StackProtector::CreateFailBB() { LLVMContext &Context = F->getContext(); BasicBlock *FailBB = BasicBlock::Create(Context, "CallStackCheckFailBlk", F); IRBuilder<> B(FailBB); if (Trip.isOSOpenBSD()) { Constant *StackChkFail = M->getOrInsertFunction("__stack_smash_handler", Type::getVoidTy(Context), Type::getInt8PtrTy(Context), nullptr); B.CreateCall(StackChkFail, B.CreateGlobalStringPtr(F->getName(), "SSH")); } else { Constant *StackChkFail = M->getOrInsertFunction("__stack_chk_fail", Type::getVoidTy(Context), nullptr); B.CreateCall(StackChkFail, {}); } B.CreateUnreachable(); return FailBB; }
.global s_prepare_buffers s_prepare_buffers: push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x133d2, %rsi lea addresses_UC_ht+0xb62, %rdi nop nop nop add %rdx, %rdx mov $18, %rcx rep movsq xor %r8, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r14 push %r15 push %rcx push %rdi push %rsi // REPMOV lea addresses_D+0x6906, %rsi lea addresses_normal+0x9162, %rdi nop nop and %r15, %r15 mov $82, %rcx rep movsb nop nop add $56287, %r12 // Load lea addresses_A+0x9d62, %r12 dec %r15 mov (%r12), %rsi nop nop nop nop xor %rsi, %rsi // Load lea addresses_PSE+0x6c3a, %r10 and %rcx, %rcx movups (%r10), %xmm2 vpextrq $1, %xmm2, %r14 nop nop nop xor $4245, %r10 // Faulty Load lea addresses_US+0xa562, %rdi nop nop nop nop and %r10, %r10 mov (%rdi), %esi lea oracles, %r15 and $0xff, %rsi shlq $12, %rsi mov (%r15,%rsi,1), %rsi pop %rsi pop %rdi pop %rcx pop %r15 pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal', 'congruent': 9, 'same': False}} {'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_A', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_PSE', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'00': 240} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
%include "core.asm" %include "util.asm" %include "console.asm" %include "piano.asm" global _start section .data file1 dd 0 section .bss resb 10 buffer resb 1024 section .code _start: enter 4,0 ; regza ; reglog ; console.getMode ; reglog ; and eax, ~CONSOLE_EN_ECHO_INPUT ; and eax, ~CONSOLE_EN_LINE_INPUT ; console.setMode ; reglog ; reglog ; console.read buffer, 1 ; reglog ; putstr buffer, 10 ; putcstr ".End" ; leave ; ret putcstr "Enter file path: " fgets buffer, 1024 putcstr `Open:\n` file.open buffer, FILE_OPEN_ALWAYS mov [file1], EAX file.read [file1], buffer, 100 file.close [file1] mov eax, buffer call piano.string leave ret ;call piano.keyboard ;leave ;ret ;defstr sample1, `EeE EEE EGCD*E FFF FFx EE EE EDDED |G EEE EEE EGC DE FFFF FEEEE GG FD C\0` ;defstr sample1, `EeE EEE EGCD Ex\0` ;defstr sample1, `AAA AA A A A A A A\0` ;defstr sample1, `G G A G C B\0` ;defstr sample1, `A B C D E F G\0` ;mov eax, sample1 ;call piano.string ;leave ;ret ; putcstr "Enter file path: " ; fgets buffer, 1024 ; putcstr `Open:\n` ; file.open buffer, FILE_OPEN_ALWAYS ; mov [file1], EAX ; putcstr `Seek:\n` ; file.seek [file1], 0, FILE_SEEK_END ;mov ECX, 5 ;writer: ;file.write [file1], message, message.len ;loop writer ; file.seek [file1], 0, FILE_SEEK_BEGIN ; file.read [file1], buffer, 100 ; putcstr `Result:\n` ; putstr buffer ; file.close [file1] leave ret filePath db ".\\test.txt", NULL ; "D:\\test.txt", NULL title db 'Hossain', NULL title.len EQU $-title-1 message db 'Hello, World', CR, LF, 'How Are you?', CR, LF, NULL message.len EQU $-message-1
#ifndef H_XD_ENTITY #define H_XD_ENTITY #include "detail/entity.hpp" #include "event_bus.hpp" #include <any> #include <unordered_map> #include <functional> #include <algorithm> #include <memory> #include <list> #include <map> #include <type_traits> namespace xd { template <typename T> struct logic_component : detail::logic_component<T> { }; template <typename T> struct render_component : detail::render_component<T> { }; template <typename T> struct component : detail::component<T> { }; class entity_placeholder { protected: ~entity_placeholder() {} }; template <typename Class = entity_placeholder> class entity { public: // component ptr typedefs typedef typename std::shared_ptr<xd::component<Class>> component_ptr; typedef typename std::shared_ptr<xd::logic_component<Class>> logic_component_ptr; typedef typename std::shared_ptr<xd::render_component<Class>> render_component_ptr; virtual ~entity() { } template <typename T> T& get() { std::size_t hash = typeid(T).hash_code(); auto i = m_type_to_data.find(hash); if (i == m_type_to_data.end()) i = m_type_to_data.emplace(hash, T()).first; return *std::any_cast<T>(&i->second); } template <typename T> T& get(const std::string& key) { auto i = m_key_to_data.find(key); if (i == m_key_to_data.end()) i = m_key_to_data.emplace(key, T()).first; return *std::any_cast<T>(&i->second); } template <typename T> bool has() { std::size_t hash = typeid(T).hash_code(); return m_type_to_data.find(hash) != m_type_to_data.end(); } template <typename T> bool has(const std::string& key) { return m_key_to_data.find(key) != m_key_to_data.end(); } template <typename T> void on(const std::string& name, std::function<bool (const T&)> callback, std::function<bool (const T&)> filter = nullptr) { get_event_bus<T>()[name].add(callback); } template <typename T> void on(const std::string& name, bool (*callback)(const T&), std::function<bool (const typename detail::identity<T>::type&)> filter = nullptr) { get_event_bus<T>()[name].add(callback); } template <typename T, typename C> void on(const std::string& name, bool (C::*callback)(const T&), C *obj, std::function<bool (const typename detail::identity<T>::type&)> filter = nullptr) { get_event_bus<T>()[name].add(std::bind(callback, obj, std::placeholders::_1)); } template <typename T, typename C> void on(const std::string& name, bool (C::*callback)(const T&) const, C *obj, std::function<bool (const typename detail::identity<T>::type&)> filter = nullptr) { get_event_bus<T>()[name].add(std::bind(callback, obj, std::placeholders::_1)); } template <typename T> void on(const std::string& name, T obj) { on(name, &T::operator(), &obj); //get_event_bus<typename detail::first_argument<T>::type>()[name].add(obj); } template <typename T, typename U> void on(const std::string& name, T obj, U filter) { on(name, &T::operator(), &obj, filter); //get_event_bus<typename detail::first_argument<T>::type>()[name].add(obj, filter); } template <typename T> void trigger(const std::string& name, const T& args) { get_event_bus<T>()[name](args); } void add_component(const logic_component_ptr& component, int priority = 0) { m_components[priority].logic_components.push_back(component); component->init(*static_cast<Class*>(this)); } void add_component(const render_component_ptr& component, int priority = 0) { m_components[priority].render_components.push_back(component); component->init(*static_cast<Class*>(this)); } void add_component(const component_ptr& component, int priority = 0) { m_components[priority].logic_components.push_back(component); m_components[priority].render_components.push_back(component); component->init(*static_cast<Class*>(this)); } void del_component(const logic_component_ptr& component, int priority) { logic_component_list_t& components = m_components[priority].logic_components; auto i = std::find(components.begin(), components.end(), component); if (i != components.end()) { components.erase(i); } } void del_component(const logic_component_ptr& component) { for (auto i = m_components.begin(); i != m_components.end(); ++i) { del_component(component, i->first); } } void del_component(const render_component_ptr& component, int priority) { logic_component_list_t& components = m_components[priority].logic_components; auto i = std::find(components.begin(), components.end(), component); if (i != components.end()) { components.erase(i); } } void del_component(const render_component_ptr& component) { for (auto i = m_components.begin(); i != m_components.end(); ++i) { del_component(component, i->first); } } void del_component(const component_ptr& component, int priority) { components_set& components = m_components[priority]; { auto i = std::find(components.logic_components.begin(), components.logic_components.end(), component); if (i != components.logic_components.end()) { components.logic_components.erase(i); } } { auto i = std::find(components.render_components.begin(), components.render_components.end(), component); if (i != components.render_components.end()) { components.render_components.erase(i); } } } void del_component(const component_ptr& component) { for (auto i = m_components.begin(); i != m_components.end(); ++i) { del_component(component, i->first); } } void clear_components() { m_components.clear(); } void update() { for (auto i = m_components.begin(); i != m_components.end(); ++i) { for (auto j = i->second.logic_components.begin(); j != i->second.logic_components.end(); ++j) { (*j)->update(*static_cast<Class*>(this)); } } } void render() { for (auto i = m_components.begin(); i != m_components.end(); ++i) { for (auto j = i->second.render_components.begin(); j != i->second.render_components.end(); ++j) { (*j)->render(*static_cast<Class*>(this)); } } } protected: // you should always construct entity using the derived class // hence constructor is protected to prevent mistakes entity() { } private: typedef std::list<std::shared_ptr<detail::logic_component<Class>>> logic_component_list_t; typedef std::list<std::shared_ptr<detail::render_component<Class>>> render_component_list_t; // data std::unordered_map<std::size_t, std::any> m_type_to_data; std::unordered_map<std::string, std::any> m_key_to_data; // internal struct to hold component lists per priority struct components_set { logic_component_list_t logic_components; render_component_list_t render_components; }; // we have a list of logic and render components per priority std::map<int, components_set> m_components; // the bound events std::unordered_map<std::size_t, std::any> m_events; // utility function to return event_bus for given arg type template <typename T> event_bus<T>& get_event_bus() { // calculate hash of the argument type std::size_t hash = typeid(T).hash_code(); // find from the events auto i = m_events.find(hash); if (i == m_events.end()) { // not found, insert an empty event_bus m_events[hash] = event_bus<T>(); } // return the event bus return *std::any_cast<event_bus<T>>(&m_events[hash]); } }; } #endif
/* Copyright 2020 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 https://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 "ml_metadata/tools/mlmd_bench/fill_nodes_workload.h" #include <algorithm> #include <random> #include <type_traits> #include <vector> #include "absl/strings/str_cat.h" #include "absl/time/clock.h" #include "ml_metadata/metadata_store/metadata_store.h" #include "ml_metadata/metadata_store/types.h" #include "ml_metadata/proto/metadata_store.pb.h" #include "ml_metadata/proto/metadata_store_service.pb.h" #include "ml_metadata/tools/mlmd_bench/proto/mlmd_bench.pb.h" #include "ml_metadata/tools/mlmd_bench/util.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/core/status.h" namespace ml_metadata { namespace { constexpr int64 kInt64TypeIdSize = 8; // Parameters for nodes to be inserted per put request. struct NodesParam { std::string nodes_name; int64 num_properties; int64 string_value_bytes; }; // Template function that initializes `put_request` to contain `num_nodes` nodes // inside. template <typename T> void InitializePutRequest(const int64 num_nodes, FillNodesWorkItemType& put_request) { put_request.emplace<T>(); for (int64 i = 0; i < num_nodes; ++i) { if (std::is_same<T, PutArtifactsRequest>::value) { absl::get<PutArtifactsRequest>(put_request).add_artifacts(); } else if (std::is_same<T, PutExecutionsRequest>::value) { absl::get<PutExecutionsRequest>(put_request).add_executions(); } else if (std::is_same<T, PutContextsRequest>::value) { absl::get<PutContextsRequest>(put_request).add_contexts(); } else { LOG(FATAL) << "Unexpected Node Types for initializing current node batch"; } } } // Gets all types inside db. Returns FAILED_PRECONDITION if there is no types // inside db for any nodes to insert. tensorflow::Status GetAndValidateExistingTypes( const FillNodesConfig& fill_nodes_config, MetadataStore& store, std::vector<Type>& existing_types) { TF_RETURN_IF_ERROR( GetExistingTypes(fill_nodes_config, store, existing_types)); if (existing_types.empty()) { return tensorflow::errors::FailedPrecondition( "There are no types inside db for inserting nodes!"); } return tensorflow::Status::OK(); } // Generates random integer within the range of specified `dist`. int64 GenerateRandomNumberFromUD(const UniformDistribution& dist, std::minstd_rand0& gen) { std::uniform_int_distribution<int64> uniform_dist{dist.minimum(), dist.maximum()}; return uniform_dist(gen); } // Initializes the parameters of current node batch inside current put request. void InitializeCurrentNodeBatchParameters( const int64 i, const FillNodesConfig& fill_nodes_config, std::uniform_int_distribution<int64>& uniform_dist_type_index, std::minstd_rand0& gen, int64& num_nodes, int64& type_index, NodesParam& nodes_param) { nodes_param.nodes_name = absl::StrCat("nodes", absl::FormatTime(absl::Now()), "_", i); nodes_param.num_properties = GenerateRandomNumberFromUD(fill_nodes_config.num_properties(), gen); nodes_param.string_value_bytes = GenerateRandomNumberFromUD(fill_nodes_config.string_value_bytes(), gen); num_nodes = GenerateRandomNumberFromUD(fill_nodes_config.num_nodes(), gen); type_index = uniform_dist_type_index(gen); } // TODO(b/152220177) Moves the GetTransferredBytes to util with better // docstrings and tests. // Gets the transferred bytes for certain property of a node and returns the // bytes. int64 GetTransferredBytesForNodeProperty( const std::string& property_name, const std::string& property_string_value) { int64 bytes = property_name.size(); bytes += property_string_value.size(); return bytes; } // Calculates and returns the transferred bytes for each node that will be // inserted or updated later. template <typename NT> int64 GetTransferredBytesForNodeAttributes(const bool& update, const NT& node) { // For update, since node's name and type id will not be updated, returns 0. if (update) { return 0; } return node.name().size() + kInt64TypeIdSize; } // Sets ArtifactType `update_type` for modifying the selected update node's // properties in later SetNodePropertiesGivenType(). Returns detailed error if // query executions failed. tensorflow::Status SetTypeForUpdateNode(const Artifact& selected_node, MetadataStore& store, ArtifactType& update_type) { GetArtifactTypesByIDRequest request; request.add_type_ids(selected_node.type_id()); GetArtifactTypesByIDResponse response; TF_RETURN_IF_ERROR(store.GetArtifactTypesByID(request, &response)); update_type = response.artifact_types(0); return tensorflow::Status::OK(); } // Sets ExecutionType `update_type` for modifying the selected update node's // properties in later SetNodePropertiesGivenType(). Returns detailed error if // query executions failed. tensorflow::Status SetTypeForUpdateNode(const Execution& selected_node, MetadataStore& store, ExecutionType& update_type) { GetExecutionTypesByIDRequest request; request.add_type_ids(selected_node.type_id()); GetExecutionTypesByIDResponse response; TF_RETURN_IF_ERROR(store.GetExecutionTypesByID(request, &response)); update_type = response.execution_types(0); return tensorflow::Status::OK(); } // Sets ContextType `update_type` for modifying the selected update node's // properties in later SetNodePropertiesGivenType(). Returns detailed error if // query executions failed. tensorflow::Status SetTypeForUpdateNode(const Context& selected_node, MetadataStore& store, ContextType& update_type) { GetContextTypesByIDRequest request; request.add_type_ids(selected_node.type_id()); GetContextTypesByIDResponse response; TF_RETURN_IF_ERROR(store.GetContextTypesByID(request, &response)); update_type = response.context_types(0); return tensorflow::Status::OK(); } // Inserts the makeup artifact into db for later update. Returns // detailed error if query executions failed. tensorflow::Status PrepareMakeUpNodeInDbAndUpdateNodeId(MetadataStore& store, Artifact& node) { PutArtifactsRequest request; request.add_artifacts()->CopyFrom(node); PutArtifactsResponse response; TF_RETURN_IF_ERROR(store.PutArtifacts(request, &response)); // Sets the node id for indicating this is an update when calling the APIs. node.set_id(response.artifact_ids(0)); return tensorflow::Status::OK(); } // Inserts the makeup execution into db for later update. Returns // detailed error if query executions failed. tensorflow::Status PrepareMakeUpNodeInDbAndUpdateNodeId(MetadataStore& store, Execution& node) { PutExecutionsRequest request; request.add_executions()->CopyFrom(node); PutExecutionsResponse response; TF_RETURN_IF_ERROR(store.PutExecutions(request, &response)); // Sets the node id for indicating this is an update when calling the APIs. node.set_id(response.execution_ids(0)); return tensorflow::Status::OK(); } // Inserts the makeup context into db for later update. Returns // detailed error if query executions failed. tensorflow::Status PrepareMakeUpNodeInDbAndUpdateNodeId(MetadataStore& store, Context& node) { PutContextsRequest request; request.add_contexts()->CopyFrom(node); PutContextsResponse response; TF_RETURN_IF_ERROR(store.PutContexts(request, &response)); // Sets the node id for indicating this is an update when calling the APIs. node.set_id(response.context_ids(0)); return tensorflow::Status::OK(); } // Prepares update node for later update. If there is no left existing nodes in // `existing_nodes` to select from, generates a random makeup node under // `insert_type` and inserts it into db. Returns detailed error if query // executions failed. template <typename T, typename N> tensorflow::Status PrepareNodeForUpdate(const T& insert_type, const int64 i, MetadataStore& store, std::vector<Node>& existing_nodes, N& node, T& update_type) { if (!existing_nodes.empty()) { Node existing_node = existing_nodes.back(); node = absl::get<N>(existing_node); TF_RETURN_IF_ERROR(SetTypeForUpdateNode(node, store, update_type)); // Removes this existing update node from `existing_nodes` for avoiding // abort errors under multi-thread environment. existing_nodes.pop_back(); } else { // Sets `update_type` to `insert_type` for makeup node. update_type = insert_type; node.set_type_id(insert_type.id()); node.set_name( absl::StrCat("makeup_node", absl::FormatTime(absl::Now()), "_", i)); // Inserts the makeup node into db. TF_RETURN_IF_ERROR(PrepareMakeUpNodeInDbAndUpdateNodeId(store, node)); } return tensorflow::Status::OK(); } // Clears some custom node properties for update node to ensure that for update // cases, the number of properties / custom properties being added, deleted or // updated is equal to `nodes_param.num_properties`. Returns the cleared // properties' bytes. template <typename N> int64 ClearSomeProperitesForUpdateNode(const NodesParam& nodes_param, int64& num_custom_properties_to_clear, N& node) { int64 bytes = 0; num_custom_properties_to_clear = std::min( (int64)node.custom_properties_size(), nodes_param.num_properties); auto it = node.custom_properties().begin(); for (int64 i = 0; i < num_custom_properties_to_clear; ++i) { node.mutable_custom_properties()->erase(it->first); bytes += GetTransferredBytesForNodeProperty(it->first, it->second.string_value()); it++; } return bytes; } // Adds or updates `node`'s properties / custom properties. Returns the added or // updated properties' bytes. template <typename T, typename N> int64 AddOrUpdateNodeProperties(const NodesParam& nodes_param, const T& type, int64 remain_num_properties_to_change, N& node) { CHECK_GT(remain_num_properties_to_change, 0) << "remain_num_properties_to_change should be greater than 0."; int bytes = 0; // Uses "********" as the fake property value for current node. std::string property_value(nodes_param.string_value_bytes, '*'); // Loops over the types properties while generating the node's properties // accordingly. // TODO(briansong) Adds more property types support. for (const auto& p : type.properties()) { (*node.mutable_properties())[p.first].set_string_value(property_value); bytes += GetTransferredBytesForNodeProperty(p.first, property_value); if (--remain_num_properties_to_change == 0) { break; } } // If the node's number of properties is greater than the type, uses custom // properties instead. while (remain_num_properties_to_change-- > 0) { (*node.mutable_custom_properties())[absl::StrCat( "custom_p-", remain_num_properties_to_change)] .set_string_value(property_value); bytes += GetTransferredBytesForNodeProperty( absl::StrCat("custom_p-", remain_num_properties_to_change), property_value); } return bytes; } // Sets node's properties and custom properties given `type`. Returns the // transferred bytes for inserting or updating current `node`. template <typename T, typename N> int64 SetNodePropertiesGivenType(const FillNodesConfig& fill_nodes_config, const NodesParam& nodes_param, const T& type, N& node) { int64 num_custom_properties_to_clear = 0; int64 transferred_bytes_for_cleared_node_properties = 0; if (fill_nodes_config.update()) { transferred_bytes_for_cleared_node_properties += ClearSomeProperitesForUpdateNode(nodes_param, num_custom_properties_to_clear, node); } int64 remain_num_properties_to_change = nodes_param.num_properties - num_custom_properties_to_clear; // If there are no properties that needed to be added or updated further, // return the current total transferred bytes directly. if (remain_num_properties_to_change == 0) { return GetTransferredBytesForNodeAttributes<N>(fill_nodes_config.update(), node) + transferred_bytes_for_cleared_node_properties; } int64 transferred_bytes_for_added_or_updated_node_properties = AddOrUpdateNodeProperties(nodes_param, type, remain_num_properties_to_change, node); return GetTransferredBytesForNodeAttributes<N>(fill_nodes_config.update(), node) + transferred_bytes_for_cleared_node_properties + transferred_bytes_for_added_or_updated_node_properties; } // Generates insert / update node. Returns detailed error if query executions // failed. template <typename T, typename N> tensorflow::Status GenerateNodes(const FillNodesConfig& fill_nodes_config, const NodesParam& nodes_param, const T& insert_type, MetadataStore& store, std::vector<Node>& existing_nodes, google::protobuf::RepeatedPtrField<N>& nodes, int64& curr_bytes) { CHECK((std::is_same<T, ArtifactType>::value || std::is_same<T, ExecutionType>::value || std::is_same<T, ContextType>::value)) << "Unexpected Types"; CHECK((std::is_same<N, Artifact>::value || std::is_same<N, Execution>::value || std::is_same<N, Context>::value)) << "Unexpected Node Types"; // Insert nodes cases. // Loops over all the node inside `nodes` and sets up one by one. for (int64 i = 0; i < nodes.size(); ++i) { if (fill_nodes_config.update()) { // Update mode. T update_type; TF_RETURN_IF_ERROR(PrepareNodeForUpdate<T, N>( insert_type, i, store, existing_nodes, nodes[i], update_type)); // Uses `update_type` when calling SetNodePropertiesGivenType() for update // mode. curr_bytes += SetNodePropertiesGivenType(fill_nodes_config, nodes_param, update_type, nodes[i]); } else { // Insert mode. nodes[i].set_name(absl::StrCat(nodes_param.nodes_name, "_node_", i)); nodes[i].set_type_id(insert_type.id()); // Uses `insert_type` when calling SetNodePropertiesGivenType() for insert // mode. curr_bytes += SetNodePropertiesGivenType(fill_nodes_config, nodes_param, insert_type, nodes[i]); } } return tensorflow::Status::OK(); } // Sets additional fields(uri, state) for artifacts and returns transferred // bytes for these additional fields. int64 SetArtifactsAdditionalFields(const std::string& nodes_name, google::protobuf::RepeatedPtrField<Artifact>& nodes) { int64 bytes = 0; for (int64 i = 0; i < nodes.size(); ++i) { nodes[i].set_uri(absl::StrCat(nodes_name, "_node_", i, "_uri")); nodes[i].set_state(Artifact::UNKNOWN); bytes += nodes[i].uri().size() + 1; } return bytes; } // Sets additional field(state) for executions and returns transferred // bytes for these additional fields. int64 SetExecutionsAdditionalFields( google::protobuf::RepeatedPtrField<Execution>& nodes) { int64 bytes = 0; for (int64 i = 0; i < nodes.size(); ++i) { nodes[i].set_last_known_state(Execution::UNKNOWN); bytes += 1; } return bytes; } } // namespace FillNodes::FillNodes(const FillNodesConfig& fill_nodes_config, const int64 num_operations) : fill_nodes_config_(fill_nodes_config), num_operations_(num_operations), name_(([fill_nodes_config]() { std::string name = absl::StrCat("FILL_", fill_nodes_config.Specification_Name( fill_nodes_config.specification())); if (fill_nodes_config.update()) { name += "(UPDATE)"; } return name; }())) {} tensorflow::Status FillNodes::SetUpImpl(MetadataStore* store) { LOG(INFO) << "Setting up ..."; int64 curr_bytes = 0; // Gets all the specific types in db to choose from when inserting nodes. // If there's no types in the store, return error. std::vector<Type> existing_types; TF_RETURN_IF_ERROR( GetAndValidateExistingTypes(fill_nodes_config_, *store, existing_types)); std::uniform_int_distribution<int64> uniform_dist_type_index{ 0, (int64)(existing_types.size() - 1)}; std::minstd_rand0 gen(absl::ToUnixMillis(absl::Now())); // Gets all existing nodes in db to choose from when updating nodes. std::vector<Node> existing_nodes; TF_RETURN_IF_ERROR( GetExistingNodes(fill_nodes_config_, *store, existing_nodes)); std::shuffle(std::begin(existing_nodes), std::end(existing_nodes), gen); for (int64 i = 0; i < num_operations_; ++i) { curr_bytes = 0; FillNodesWorkItemType put_request; int64 num_nodes, type_index; NodesParam nodes_param; InitializeCurrentNodeBatchParameters(i, fill_nodes_config_, uniform_dist_type_index, gen, num_nodes, type_index, nodes_param); switch (fill_nodes_config_.specification()) { case FillNodesConfig::ARTIFACT: { InitializePutRequest<PutArtifactsRequest>(num_nodes, put_request); auto nodes = absl::get<PutArtifactsRequest>(put_request).mutable_artifacts(); TF_RETURN_IF_ERROR(GenerateNodes<ArtifactType, Artifact>( fill_nodes_config_, nodes_param, absl::get<ArtifactType>(existing_types[type_index]), *store, existing_nodes, *nodes, curr_bytes)); curr_bytes += SetArtifactsAdditionalFields(nodes_param.nodes_name, *nodes); break; } case FillNodesConfig::EXECUTION: { InitializePutRequest<PutExecutionsRequest>(num_nodes, put_request); auto nodes = absl::get<PutExecutionsRequest>(put_request).mutable_executions(); TF_RETURN_IF_ERROR(GenerateNodes<ExecutionType, Execution>( fill_nodes_config_, nodes_param, absl::get<ExecutionType>(existing_types[type_index]), *store, existing_nodes, *nodes, curr_bytes)); curr_bytes += SetExecutionsAdditionalFields(*nodes); break; } case FillNodesConfig::CONTEXT: { InitializePutRequest<PutContextsRequest>(num_nodes, put_request); TF_RETURN_IF_ERROR(GenerateNodes<ContextType, Context>( fill_nodes_config_, nodes_param, absl::get<ContextType>(existing_types[type_index]), *store, existing_nodes, *absl::get<PutContextsRequest>(put_request).mutable_contexts(), curr_bytes)); break; } default: LOG(FATAL) << "Wrong specification for FillNodes!"; } work_items_.emplace_back(put_request, curr_bytes); } return tensorflow::Status::OK(); } // Executions of work items. tensorflow::Status FillNodes::RunOpImpl(const int64 work_items_index, MetadataStore* store) { switch (fill_nodes_config_.specification()) { case FillNodesConfig::ARTIFACT: { PutArtifactsRequest put_request = absl::get<PutArtifactsRequest>(work_items_[work_items_index].first); PutArtifactsResponse put_response; return store->PutArtifacts(put_request, &put_response); } case FillNodesConfig::EXECUTION: { PutExecutionsRequest put_request = absl::get<PutExecutionsRequest>(work_items_[work_items_index].first); PutExecutionsResponse put_response; return store->PutExecutions(put_request, &put_response); } case FillNodesConfig::CONTEXT: { PutContextsRequest put_request = absl::get<PutContextsRequest>(work_items_[work_items_index].first); PutContextsResponse put_response; return store->PutContexts(put_request, &put_response); } default: return tensorflow::errors::InvalidArgument("Wrong specification!"); } } tensorflow::Status FillNodes::TearDownImpl() { work_items_.clear(); return tensorflow::Status::OK(); } std::string FillNodes::GetName() { return name_; } } // namespace ml_metadata
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0xb894, %r15 nop nop nop nop nop sub $16006, %r14 mov $0x6162636465666768, %rbx movq %rbx, %xmm2 movups %xmm2, (%r15) nop nop nop xor $54539, %rcx lea addresses_D_ht+0xc894, %rax nop nop nop and %r14, %r14 mov $0x6162636465666768, %rsi movq %rsi, %xmm4 movups %xmm4, (%rax) xor %r14, %r14 lea addresses_normal_ht+0x16094, %r14 and $57341, %rdi mov $0x6162636465666768, %rcx movq %rcx, (%r14) nop nop nop dec %rdi lea addresses_normal_ht+0x10094, %r14 and $894, %rsi movb (%r14), %r15b nop nop nop nop xor %rcx, %rcx lea addresses_WC_ht+0xd7da, %rbx nop nop nop nop xor %rsi, %rsi movl $0x61626364, (%rbx) nop nop nop nop nop dec %rax lea addresses_normal_ht+0xcc94, %rax nop nop nop add $30028, %rsi movw $0x6162, (%rax) nop sub %r15, %r15 lea addresses_WC_ht+0x19094, %rax nop nop nop dec %rbx mov $0x6162636465666768, %rcx movq %rcx, %xmm3 vmovups %ymm3, (%rax) nop nop add $47759, %rsi lea addresses_normal_ht+0x1d224, %rdi nop nop nop nop nop dec %rbx mov $0x6162636465666768, %r14 movq %r14, %xmm1 and $0xffffffffffffffc0, %rdi movaps %xmm1, (%rdi) nop nop nop cmp $52174, %rcx lea addresses_WT_ht+0x15914, %rcx nop nop nop nop nop xor $61394, %r15 mov $0x6162636465666768, %r14 movq %r14, %xmm4 vmovups %ymm4, (%rcx) nop sub %rbx, %rbx lea addresses_normal_ht+0x5b29, %rbx nop nop sub $25175, %rdi mov $0x6162636465666768, %rsi movq %rsi, %xmm1 vmovups %ymm1, (%rbx) nop nop add $35207, %rax lea addresses_D_ht+0xf36e, %rdi nop nop nop add %rcx, %rcx mov (%rdi), %r15w nop nop nop nop xor $38842, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r8 push %rax push %rdi push %rdx // Store lea addresses_D+0x14514, %r11 sub $48472, %r12 movl $0x51525354, (%r11) nop nop nop nop nop xor $12721, %rdi // Store lea addresses_UC+0x4894, %r10 nop nop xor %rdx, %rdx mov $0x5152535455565758, %rax movq %rax, %xmm2 vmovups %ymm2, (%r10) nop nop nop sub $39452, %rdi // Load lea addresses_US+0xd894, %r10 nop nop inc %rax movb (%r10), %r8b sub $55884, %r8 // Load lea addresses_PSE+0x4e94, %r12 clflush (%r12) nop nop nop nop nop add $52142, %rdx vmovups (%r12), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %r11 nop nop nop nop sub %r10, %r10 // Faulty Load lea addresses_US+0xd894, %rax and %r11, %r11 mov (%rax), %edx lea oracles, %r10 and $0xff, %rdx shlq $12, %rdx mov (%r10,%rdx,1), %rdx pop %rdx pop %rdi pop %rax pop %r8 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': True, 'type': 'addresses_D', 'same': False, 'AVXalign': True, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_US', 'same': True, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 9}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_US', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': True, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r15 push %r8 push %rax push %rcx push %rdi push %rsi lea addresses_WT_ht+0x12a3b, %r8 nop nop nop nop add %r11, %r11 movw $0x6162, (%r8) inc %r11 lea addresses_WT_ht+0x6b33, %rax nop nop nop nop nop dec %rcx mov $0x6162636465666768, %r8 movq %r8, (%rax) nop nop nop cmp $8948, %rax lea addresses_WT_ht+0x30f3, %r15 nop nop nop nop dec %r14 movl $0x61626364, (%r15) nop nop nop nop lfence lea addresses_UC_ht+0x16753, %rsi lea addresses_WT_ht+0xc6d3, %rdi nop nop sub %rax, %rax mov $3, %rcx rep movsb nop nop nop nop add %rsi, %rsi lea addresses_D_ht+0x10973, %rsi nop nop nop inc %r14 mov (%rsi), %r11w nop sub $58334, %r11 lea addresses_D_ht+0x79f3, %rsi lea addresses_D_ht+0x12df3, %rdi clflush (%rsi) nop sub $51306, %r15 mov $78, %rcx rep movsq nop and $45370, %r15 lea addresses_UC_ht+0x12c97, %rax nop nop nop nop nop xor $2270, %rsi movw $0x6162, (%rax) nop nop nop nop sub %rcx, %rcx lea addresses_A_ht+0xa9f3, %r8 nop and %rsi, %rsi movb (%r8), %r14b nop nop cmp %r15, %r15 lea addresses_WC_ht+0x160f3, %rsi nop nop dec %r15 movl $0x61626364, (%rsi) nop nop add $53686, %r14 lea addresses_D_ht+0xb5cb, %rax nop nop nop and %r8, %r8 mov $0x6162636465666768, %r11 movq %r11, (%rax) nop nop nop inc %rax pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r15 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi // REPMOV lea addresses_A+0x1b943, %rsi lea addresses_US+0x1ed73, %rdi add %r15, %r15 mov $89, %rcx rep movsb nop nop nop nop add %r15, %r15 // Store lea addresses_D+0x7389, %r15 nop nop nop nop cmp %rcx, %rcx movb $0x51, (%r15) nop and $54315, %rcx // Store lea addresses_RW+0x11f3, %r15 add %rdi, %rdi movl $0x51525354, (%r15) nop nop nop nop cmp $30014, %rdi // Store mov $0xc59, %rbx dec %r15 mov $0x5152535455565758, %rsi movq %rsi, %xmm7 vmovups %ymm7, (%rbx) nop nop nop add %rbp, %rbp // Store lea addresses_RW+0x11f3, %rsi nop nop xor %rdi, %rdi movb $0x51, (%rsi) nop cmp $25196, %rcx // Store lea addresses_WC+0xcc56, %rcx nop cmp $15963, %r9 movw $0x5152, (%rcx) nop nop cmp %rbp, %rbp // Faulty Load lea addresses_RW+0x11f3, %rsi add $1547, %rbp movntdqa (%rsi), %xmm7 vpextrq $1, %xmm7, %rcx lea oracles, %r15 and $0xff, %rcx shlq $12, %rcx mov (%r15,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r15 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_US', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': True, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 5, 'size': 8, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}} {'46': 1, '00': 5} 00 00 00 00 00 46 */
; A163805: Expansion of (1 - x) * (1 - x^6) / ((1 - x^3) * (1 - x^4)) in powers of x. ; 1,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1 mov $1,-1 pow $1,$0 sub $2,$0 bin $2,2 bin $1,$2 mov $0,$1
/** * \file * \author Thomas Fischer * \date 2010-06-16 * \brief Implementation of string helper functions. * * \copyright * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license * */ #include "StringTools.h" #include <algorithm> #include <cctype> #include <cstdarg> #include <cstdio> #include <iomanip> #include <logog/include/logog.hpp> #include <boost/algorithm/string/replace.hpp> namespace BaseLib { std::vector<std::string> splitString(std::string const& str) { std::istringstream str_stream(str); std::vector<std::string> items; std::copy(std::istream_iterator<std::string>(str_stream), std::istream_iterator<std::string>(), std::back_inserter(items)); return items; } std::list<std::string> splitString(const std::string &str, char delim) { std::list<std::string> strList; std::stringstream ss(str); std::string item; while (getline(ss, item, delim)) { strList.push_back(item); } return strList; } std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace) { boost::replace_all(stringToReplace, searchString, replaceString); return stringToReplace; } void trim(std::string &str, char ch) { std::string::size_type pos = str.find_last_not_of(ch); if(pos != std::string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(ch); if (pos != std::string::npos) { str.erase(0, pos); } } else { str.erase(str.begin(), str.end()); } } void simplify(std::string &str) { trim (str); str.erase( std::unique(str.begin(), str.end(), [](char a, char b) { return a == ' ' && b == ' '; }), str.end() ); } std::string padLeft(std::string const& str, int maxlen, char ch) { std::stringstream ss(str); ss << std::right << std::setw(maxlen) << std::setfill(ch) << str; return ss.str(); } std::string const& tostring(std::string const& value) { return value; } std::string format(const char* format_str, ... ) { va_list args; va_start(args, format_str); // get the number of chars to write va_list args_tmp; va_copy(args_tmp, args); int char_length = std::vsnprintf(nullptr, 0, format_str, args_tmp); va_end(args_tmp); // allocate buffer and store formatted output there std::vector<char> buffer(char_length + 1); // note +1 for null terminator vsnprintf(buffer.data(), buffer.size(), format_str, args); va_end(args); return std::string(buffer.data()); } } // end namespace BaseLib
// Copyright 2015 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 <stdio.h> #include <memory> #include "base/environment.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "sandbox/win/tests/common/controller.h" #include "testing/gtest/include/gtest/gtest.h" namespace sandbox { class AddressSanitizerTests : public ::testing::Test { public: void SetUp() override { env_ = base::Environment::Create(); had_asan_options_ = env_->GetVar("ASAN_OPTIONS", &old_asan_options_); } void TearDown() override { if (had_asan_options_) ASSERT_TRUE(env_->SetVar("ASAN_OPTIONS", old_asan_options_)); else env_->UnSetVar("ASAN_OPTIONS"); } protected: std::unique_ptr<base::Environment> env_; bool had_asan_options_; std::string old_asan_options_; }; SBOX_TESTS_COMMAND int AddressSanitizerTests_Report(int argc, wchar_t** argv) { // AddressSanitizer should detect an out of bounds write (heap buffer // overflow) in this code. volatile int idx = 42; int* volatile blah = new int[42]; blah[idx] = 42; delete [] blah; return SBOX_TEST_FAILED; } TEST_F(AddressSanitizerTests, TestAddressSanitizer) { // This test is only supposed to work when using AddressSanitizer. // However, ASan/Win is not on the CQ yet, so compiler breakages may get into // the code unnoticed. To avoid that, we compile this test in all Windows // builds, but only run the AddressSanitizer-specific part of the test when // compiled with AddressSanitizer. #if defined(ADDRESS_SANITIZER) bool asan_build = true; #else bool asan_build = false; #endif base::ScopedTempDir temp_directory; base::FilePath temp_file_name; ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); ASSERT_TRUE( CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file_name)); SECURITY_ATTRIBUTES attrs = {}; attrs.nLength = sizeof(attrs); attrs.bInheritHandle = TRUE; base::win::ScopedHandle tmp_handle( CreateFile(temp_file_name.value().c_str(), GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, &attrs, OPEN_EXISTING, 0, NULL)); EXPECT_TRUE(tmp_handle.IsValid()); TestRunner runner; ASSERT_EQ(SBOX_ALL_OK, runner.GetPolicy()->SetStderrHandle(tmp_handle.Get())); base::FilePath exe; ASSERT_TRUE(PathService::Get(base::FILE_EXE, &exe)); base::FilePath pdb_path = exe.DirName().Append(L"*.pdb"); ASSERT_TRUE(runner.AddFsRule(TargetPolicy::FILES_ALLOW_READONLY, pdb_path.value().c_str())); env_->SetVar("ASAN_OPTIONS", "exitcode=123"); if (asan_build) { int result = runner.RunTest(L"AddressSanitizerTests_Report"); EXPECT_EQ(123, result); std::string data; ASSERT_TRUE(base::ReadFileToString(base::FilePath(temp_file_name), &data)); // Redirection uses a feature that was added in Windows Vista. ASSERT_TRUE( strstr(data.c_str(), "ERROR: AddressSanitizer: heap-buffer-overflow")) << "There doesn't seem to be an ASan report:\n" << data; ASSERT_TRUE(strstr(data.c_str(), "AddressSanitizerTests_Report")) << "The ASan report doesn't appear to be symbolized:\n" << data; std::string source_file_basename(__FILE__); size_t last_slash = source_file_basename.find_last_of("/\\"); last_slash = last_slash == std::string::npos ? 0 : last_slash + 1; ASSERT_TRUE(strstr(data.c_str(), &source_file_basename[last_slash])) << "The stack trace doesn't have a correct filename:\n" << data; } else { LOG(WARNING) << "Not an AddressSanitizer build, skipping the run."; } } } // namespace sandbox
; A000027: The positive integers. Also called the natural numbers, the whole numbers or the counting numbers, but these terms are ambiguous. ; 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100 add $0,1
.include "defaults_request.asm" table_file_jp equ "exe6-utf8.tbl" table_file_en equ "bn6-utf8.tbl" game_code_len equ 3 game_code equ 0x4252354A // BR5J game_code_2 equ 0x42523545 // BR5E game_code_3 equ 0x42523550 // BR5P card_type equ 4 card_id equ 4 card_no equ "004" card_sub equ "Request Event Card 004" card_sub_x equ 32 card_name_jp_full equ "ペンギンが逃げ出した!" card_name_jp_game equ "ペンギンがにげだした!" card_name_en_full equ "Penguins Ran Away" card_name_en_game equ "PenguinsRanAway" card_desc_len equ 1 card_desc_1 equ "Penguins Ran Away" card_desc_2 equ "" card_desc_3 equ ""
// Copyright 2016 Google Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "chrome_usb/types.h" #include <google_smart_card_common/pp_var_utils/enum_converter.h> #include <google_smart_card_common/pp_var_utils/struct_converter.h> namespace google_smart_card { using chrome_usb::Direction; using chrome_usb::Device; using chrome_usb::ConnectionHandle; using chrome_usb::EndpointDescriptorType; using chrome_usb::EndpointDescriptorSynchronization; using chrome_usb::EndpointDescriptorUsage; using chrome_usb::EndpointDescriptor; using chrome_usb::InterfaceDescriptor; using chrome_usb::ConfigDescriptor; using chrome_usb::GenericTransferInfo; using chrome_usb::ControlTransferInfoRecipient; using chrome_usb::ControlTransferInfoRequestType; using chrome_usb::ControlTransferInfo; using chrome_usb::TransferResultInfo; using chrome_usb::DeviceFilter; using chrome_usb::GetDevicesOptions; using chrome_usb::GetUserSelectedDevicesOptions; using DirectionConverter = EnumConverter<Direction, std::string>; using DeviceConverter = StructConverter<Device>; using ConnectionHandleConverter = StructConverter<ConnectionHandle>; using EndpointDescriptorTypeConverter = EnumConverter< EndpointDescriptorType, std::string>; using EndpointDescriptorSynchronizationConverter = EnumConverter< EndpointDescriptorSynchronization, std::string>; using EndpointDescriptorUsageConverter = EnumConverter< EndpointDescriptorUsage, std::string>; using EndpointDescriptorConverter = StructConverter<EndpointDescriptor>; using InterfaceDescriptorConverter = StructConverter<InterfaceDescriptor>; using ConfigDescriptorConverter = StructConverter<ConfigDescriptor>; using GenericTransferInfoConverter = StructConverter<GenericTransferInfo>; using ControlTransferInfoRecipientConverter = EnumConverter< ControlTransferInfoRecipient, std::string>; using ControlTransferInfoRequestTypeConverter = EnumConverter< ControlTransferInfoRequestType, std::string>; using ControlTransferInfoConverter = StructConverter<ControlTransferInfo>; using TransferResultInfoConverter = StructConverter<TransferResultInfo>; using DeviceFilterConverter = StructConverter<DeviceFilter>; using GetDevicesOptionsConverter = StructConverter<GetDevicesOptions>; using GetUserSelectedDevicesOptionsConverter = StructConverter<GetUserSelectedDevicesOptions>; namespace { bool IsSameOptionalArrayBuffer( const optional<pp::VarArrayBuffer>& lhs, const optional<pp::VarArrayBuffer>& rhs) { if (!lhs || !rhs) return lhs == rhs; return VarAs<std::vector<uint8_t>>(*lhs) == VarAs<std::vector<uint8_t>>(*rhs); } } // namespace bool Device::operator==(const Device& other) const { return device == other.device && vendor_id == other.vendor_id && product_id == other.product_id && version == other.version && product_name == other.product_name && manufacturer_name == other.manufacturer_name && serial_number == other.serial_number; } bool ConnectionHandle::operator==(const ConnectionHandle& other) const { return handle == other.handle && vendor_id == other.vendor_id && product_id == other.product_id; } bool ControlTransferInfo::operator==(const ControlTransferInfo& other) const { return direction == other.direction && recipient == other.recipient && request_type == other.request_type && request == other.request && value == other.value && index == other.index && length == other.length && IsSameOptionalArrayBuffer(data, other.data) && timeout == other.timeout; } // static template <> constexpr const char* DirectionConverter::GetEnumTypeName() { return "chrome_usb::Direction"; } // static template <> template <typename Callback> void DirectionConverter::VisitCorrespondingPairs(Callback callback) { callback(Direction::kIn, "in"); callback(Direction::kOut, "out"); } // static template <> constexpr const char* DeviceConverter::GetStructTypeName() { return "chrome_usb::Device"; } // static template <> template <typename Callback> void DeviceConverter::VisitFields(const Device& value, Callback callback) { callback(&value.device, "device"); callback(&value.vendor_id, "vendorId"); callback(&value.product_id, "productId"); callback(&value.version, "version"); callback(&value.product_name, "productName"); callback(&value.manufacturer_name, "manufacturerName"); callback(&value.serial_number, "serialNumber"); } // static template <> constexpr const char* ConnectionHandleConverter::GetStructTypeName() { return "chrome_usb::ConnectionHandle"; } // static template <> template <typename Callback> void ConnectionHandleConverter::VisitFields( const ConnectionHandle& value, Callback callback) { callback(&value.handle, "handle"); callback(&value.vendor_id, "vendorId"); callback(&value.product_id, "productId"); } // static template <> constexpr const char* EndpointDescriptorTypeConverter::GetEnumTypeName() { return "chrome_usb::EndpointDescriptorType"; } // static template <> template <typename Callback> void EndpointDescriptorTypeConverter::VisitCorrespondingPairs( Callback callback) { callback(EndpointDescriptorType::kControl, "control"); callback(EndpointDescriptorType::kInterrupt, "interrupt"); callback(EndpointDescriptorType::kIsochronous, "isochronous"); callback(EndpointDescriptorType::kBulk, "bulk"); } // static template <> constexpr const char* EndpointDescriptorSynchronizationConverter::GetEnumTypeName() { return "chrome_usb::EndpointDescriptorSynchronization"; } // static template <> template <typename Callback> void EndpointDescriptorSynchronizationConverter::VisitCorrespondingPairs( Callback callback) { callback(EndpointDescriptorSynchronization::kAsynchronous, "asynchronous"); callback(EndpointDescriptorSynchronization::kAdaptive, "adaptive"); callback(EndpointDescriptorSynchronization::kSynchronous, "synchronous"); } // static template <> constexpr const char* EndpointDescriptorUsageConverter::GetEnumTypeName() { return "chrome_usb::EndpointDescriptorUsage"; } // static template <> template <typename Callback> void EndpointDescriptorUsageConverter::VisitCorrespondingPairs( Callback callback) { callback(EndpointDescriptorUsage::kData, "data"); callback(EndpointDescriptorUsage::kFeedback, "feedback"); callback(EndpointDescriptorUsage::kExplicitFeedback, "explicitFeedback"); callback(EndpointDescriptorUsage::kPeriodic, "periodic"); callback(EndpointDescriptorUsage::kNotification, "notification"); } // static template <> constexpr const char* EndpointDescriptorConverter::GetStructTypeName() { return "chrome_usb::EndpointDescriptor"; } // static template <> template <typename Callback> void EndpointDescriptorConverter::VisitFields( const EndpointDescriptor& value, Callback callback) { callback(&value.address, "address"); callback(&value.type, "type"); callback(&value.direction, "direction"); callback(&value.maximum_packet_size, "maximumPacketSize"); callback(&value.synchronization, "synchronization"); callback(&value.usage, "usage"); callback(&value.polling_interval, "pollingInterval"); callback(&value.extra_data, "extra_data"); } // static template <> constexpr const char* InterfaceDescriptorConverter::GetStructTypeName() { return "chrome_usb::InterfaceDescriptor"; } // static template <> template <typename Callback> void InterfaceDescriptorConverter::VisitFields( const InterfaceDescriptor& value, Callback callback) { callback(&value.interface_number, "interfaceNumber"); callback(&value.alternate_setting, "alternateSetting"); callback(&value.interface_class, "interfaceClass"); callback(&value.interface_subclass, "interfaceSubclass"); callback(&value.interface_protocol, "interfaceProtocol"); callback(&value.description, "description"); callback(&value.endpoints, "endpoints"); callback(&value.extra_data, "extra_data"); } // static template <> constexpr const char* ConfigDescriptorConverter::GetStructTypeName() { return "chrome_usb::ConfigDescriptor"; } // static template <> template <typename Callback> void ConfigDescriptorConverter::VisitFields( const ConfigDescriptor& value, Callback callback) { callback(&value.active, "active"); callback(&value.configuration_value, "configurationValue"); callback(&value.description, "description"); callback(&value.self_powered, "selfPowered"); callback(&value.remote_wakeup, "remoteWakeup"); callback(&value.max_power, "maxPower"); callback(&value.interfaces, "interfaces"); callback(&value.extra_data, "extra_data"); } // static template <> constexpr const char* GenericTransferInfoConverter::GetStructTypeName() { return "chrome_usb::GenericTransferInfo"; } // static template <> template <typename Callback> void GenericTransferInfoConverter::VisitFields( const GenericTransferInfo& value, Callback callback) { callback(&value.direction, "direction"); callback(&value.endpoint, "endpoint"); callback(&value.length, "length"); callback(&value.data, "data"); callback(&value.timeout, "timeout"); } // static template <> constexpr const char* ControlTransferInfoRecipientConverter::GetEnumTypeName() { return "chrome_usb::ControlTransferInfoRecipient"; } // static template <> template <typename Callback> void ControlTransferInfoRecipientConverter::VisitCorrespondingPairs( Callback callback) { callback(ControlTransferInfoRecipient::kDevice, "device"); callback(ControlTransferInfoRecipient::kInterface, "interface"); callback(ControlTransferInfoRecipient::kEndpoint, "endpoint"); callback(ControlTransferInfoRecipient::kOther, "other"); } // static template <> constexpr const char* ControlTransferInfoRequestTypeConverter::GetEnumTypeName() { return "chrome_usb::ControlTransferInfoRequestType"; } // static template <> template <typename Callback> void ControlTransferInfoRequestTypeConverter::VisitCorrespondingPairs( Callback callback) { callback(ControlTransferInfoRequestType::kStandard, "standard"); callback(ControlTransferInfoRequestType::kClass, "class"); callback(ControlTransferInfoRequestType::kVendor, "vendor"); callback(ControlTransferInfoRequestType::kReserved, "reserved"); } // static template <> constexpr const char* ControlTransferInfoConverter::GetStructTypeName() { return "chrome_usb::ControlTransferInfo"; } // static template <> template <typename Callback> void ControlTransferInfoConverter::VisitFields( const ControlTransferInfo& value, Callback callback) { callback(&value.direction, "direction"); callback(&value.recipient, "recipient"); callback(&value.request_type, "requestType"); callback(&value.request, "request"); callback(&value.value, "value"); callback(&value.index, "index"); callback(&value.length, "length"); callback(&value.data, "data"); callback(&value.timeout, "timeout"); } // static template <> constexpr const char* TransferResultInfoConverter::GetStructTypeName() { return "chrome_usb::TransferResultInfo"; } // static template <> template <typename Callback> void TransferResultInfoConverter::VisitFields( const TransferResultInfo& value, Callback callback) { callback(&value.result_code, "resultCode"); callback(&value.data, "data"); } // static template <> constexpr const char* DeviceFilterConverter::GetStructTypeName() { return "chrome_usb::DeviceFilter"; } // static template <> template <typename Callback> void DeviceFilterConverter::VisitFields( const DeviceFilter& value, Callback callback) { callback(&value.vendor_id, "vendorId"); callback(&value.product_id, "productId"); callback(&value.interface_class, "interfaceClass"); callback(&value.interface_subclass, "interfaceSubclass"); callback(&value.interface_protocol, "interfaceProtocol"); } // static template <> constexpr const char* GetDevicesOptionsConverter::GetStructTypeName() { return "chrome_usb::GetDevicesOptions"; } // static template <> template <typename Callback> void GetDevicesOptionsConverter::VisitFields( const GetDevicesOptions& value, Callback callback) { callback(&value.filters, "filters"); } // static template <> constexpr const char* GetUserSelectedDevicesOptionsConverter::GetStructTypeName() { return "chrome_usb::GetUserSelectedDevicesOptions"; } // static template <> template <typename Callback> void GetUserSelectedDevicesOptionsConverter::VisitFields( const GetUserSelectedDevicesOptions& value, Callback callback) { callback(&value.filters, "filters"); } namespace chrome_usb { bool VarAs(const pp::Var& var, Direction* result, std::string* error_message) { return DirectionConverter::ConvertFromVar(var, result, error_message); } pp::Var MakeVar(Direction value) { return DirectionConverter::ConvertToVar(value); } bool VarAs(const pp::Var& var, Device* result, std::string* error_message) { return DeviceConverter::ConvertFromVar(var, result, error_message); } pp::Var MakeVar(const Device& value) { return DeviceConverter::ConvertToVar(value); } bool VarAs( const pp::Var& var, ConnectionHandle* result, std::string* error_message) { return ConnectionHandleConverter::ConvertFromVar(var, result, error_message); } pp::Var MakeVar(const ConnectionHandle& value) { return ConnectionHandleConverter::ConvertToVar(value); } bool VarAs( const pp::Var& var, EndpointDescriptorType* result, std::string* error_message) { return EndpointDescriptorTypeConverter::ConvertFromVar( var, result, error_message); } pp::Var MakeVar(EndpointDescriptorType value) { return EndpointDescriptorTypeConverter::ConvertToVar(value); } bool VarAs( const pp::Var& var, EndpointDescriptorSynchronization* result, std::string* error_message) { return EndpointDescriptorSynchronizationConverter::ConvertFromVar( var, result, error_message); } pp::Var MakeVar(EndpointDescriptorSynchronization value) { return EndpointDescriptorSynchronizationConverter::ConvertToVar(value); } bool VarAs( const pp::Var& var, EndpointDescriptorUsage* result, std::string* error_message) { return EndpointDescriptorUsageConverter::ConvertFromVar( var, result, error_message); } pp::Var MakeVar(EndpointDescriptorUsage value) { return EndpointDescriptorUsageConverter::ConvertToVar(value); } bool VarAs( const pp::Var& var, EndpointDescriptor* result, std::string* error_message) { return EndpointDescriptorConverter::ConvertFromVar( var, result, error_message); } bool VarAs( const pp::Var& var, InterfaceDescriptor* result, std::string* error_message) { return InterfaceDescriptorConverter::ConvertFromVar( var, result, error_message); } bool VarAs( const pp::Var& var, ConfigDescriptor* result, std::string* error_message) { return ConfigDescriptorConverter::ConvertFromVar(var, result, error_message); } pp::Var MakeVar(const GenericTransferInfo& value) { return GenericTransferInfoConverter::ConvertToVar(value); } pp::Var MakeVar(ControlTransferInfoRecipient value) { return ControlTransferInfoRecipientConverter::ConvertToVar(value); } pp::Var MakeVar(ControlTransferInfoRequestType value) { return ControlTransferInfoRequestTypeConverter::ConvertToVar(value); } pp::Var MakeVar(const ControlTransferInfo& value) { return ControlTransferInfoConverter::ConvertToVar(value); } bool VarAs( const pp::Var& var, TransferResultInfo* result, std::string* error_message) { return TransferResultInfoConverter::ConvertFromVar( var, result, error_message); } pp::Var MakeVar(const DeviceFilter& value) { return DeviceFilterConverter::ConvertToVar(value); } pp::Var MakeVar(const GetDevicesOptions& value) { return GetDevicesOptionsConverter::ConvertToVar(value); } pp::Var MakeVar(const GetUserSelectedDevicesOptions& value) { return GetUserSelectedDevicesOptionsConverter::ConvertToVar(value); } } // namespace chrome_usb } // namespace google_smart_card
.global s_prepare_buffers s_prepare_buffers: push %r8 push %r9 push %rbp push %rdx lea addresses_normal_ht+0x822e, %rdx nop nop inc %r8 vmovups (%rdx), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rbp nop xor $26350, %r9 pop %rdx pop %rbp pop %r9 pop %r8 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %r8 push %rax push %rcx // Store lea addresses_normal+0x11c4e, %r11 nop nop nop nop cmp %rax, %rax mov $0x5152535455565758, %r13 movq %r13, %xmm1 movups %xmm1, (%r11) nop nop nop nop add $24596, %rcx // Faulty Load lea addresses_normal+0x11c4e, %r8 nop nop nop dec %r11 vmovups (%r8), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $0, %xmm4, %r13 lea oracles, %r8 and $0xff, %r13 shlq $12, %r13 mov (%r8,%r13,1), %r13 pop %rcx pop %rax pop %r8 pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 16}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
//Optimise #include <bits/stdc++.h> using namespace std; // #define multitest 1 // #define Debug #ifdef Debug #define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__); template <typename Arg1> void ZZ(const char *name, Arg1 &&arg1) { std::cerr << name << " = " << arg1 << endl; } template <typename Arg1, typename... Args> void ZZ(const char *names, Arg1 &&arg1, Args &&... args) { const char *comma = strchr(names + 1, ','); std::cerr.write(names, comma - names) << " = " << arg1; ZZ(comma, args...); } #else #define db(...) #endif using ll = long long; #define f first #define s second #define pb push_back const long long mod = 1000000007; const int nax = 2e5 + 10; class Refactoring { private: map<pair<int, int>, int> Dp; int solve(int n, int last) { auto it = Dp.find({n, last}); if (it != Dp.end()) return it->s; int ret = 0; for (int i = last; i * i <= n; ++i) if (n % i == 0) ret += 1 + solve(n / i, i); Dp[{n, last}] = ret; return ret; } public: int refactor(int n) { return solve(n, 2); } }; #ifdef Offline int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; #ifdef multitest cin >> t; #endif Refactoring S; while (t--) { int n; cin >> n; cout << S.refactor(n) << '\n'; } return 0; } #endif
; A022323: a(n) = a(n-1) + a(n-2) + 1, with a(0) = 1 and a(1) = 9. ; 1,9,11,21,33,55,89,145,235,381,617,999,1617,2617,4235,6853,11089,17943,29033,46977,76011,122989,199001,321991,520993,842985,1363979,2206965,3570945,5777911,9348857,15126769,24475627,39602397,64078025,103680423,167758449,271438873,439197323,710636197,1149833521,1860469719,3010303241,4870772961,7881076203,12751849165,20632925369,33384774535,54017699905,87402474441,141420174347,228822648789,370242823137,599065471927,969308295065,1568373766993,2537682062059,4106055829053,6643737891113,10749793720167,17393531611281,28143325331449,45536856942731,73680182274181,119217039216913,192897221491095,312114260708009,505011482199105,817125742907115,1322137225106221,2139262968013337,3461400193119559,5600663161132897,9062063354252457 mov $1,1 mov $2,4 lpb $0,1 sub $0,1 mov $3,$2 mov $2,$1 add $1,$3 lpe mul $1,2 sub $1,1
.gba .open "Clean\Boktai 2 (J).gba","Boktai 2 (J)(Hack).gba",0x08000000 .org 0x080000D4 // sunlight changer .area 0xCC ldr r0,=30057C8h ldr r0,[r0] // r0 = sunlight bl 82416C8h // r0 = amount of bars ldr r1,=30044E0h ldrh r2,[r1] // r2 = BUTTON_HELD ldrh r1,[r1,2h] // r1 = BUTTON_DOWN mov r3,4h tst r2,r3 // if Select held beq @@sunwrite @@righttest: mov r3,10h tst r1,r3 beq @@lefttest cmp r0,0Ah bge @@sunwrite add r0,1h @@lefttest: mov r3,20h tst r1,r3 beq @@sunwrite cmp r0,0h ble @@sunwrite sub r0,1h @@sunwrite: add r3,=dataarea ldrb r0,[r3,r0] ldr r1,=30057C8h str r0,[r1] bl 8241740h // get modified sun level bl 82416C8h // get modified sun bars @@updategauge: ldr r2,=2037492h ldr r1,=0D05Ch ldrh r3,[r2] cmp r3,r1 bne @@end add r1,1h mov r3,0Ah sub r3,r3,r0 @@sunloop: add r2,2h cmp r0,0h ble @@darkgauge strh r1,[r2] sub r0,1h b @@sunloop @@darkgauge: add r1,1h @@darkloop: cmp r3,0h ble @@end strh r1,[r2] add r2,2h sub r3,1h b @@darkloop @@end: pop r15 .pool dataarea: dcb 0x00,0x03,0x09,0x12,0x1D,0x2A,0x3D,0x4D,0x62,0x7D,0x8C .endarea .org 0x0822E6CA // hook bl 80000D4h .org 0x082416CC // treat negative as empty gauge bgt 82416D2h .org 0x0824181A // skip sunlight value adjustment pop r15 .org 0x08241634 // set default sensor calibration value mov r0,0E6h nop .org 0x08247650 // stop sensor from saving sunlight value nop .org 0x082474C6 // skip solar sensor reset nop .org 0x082476EC // skip solar sensor reset nop .org 0x08247720 // skip solar sensor reset nop .close
#note: r40 (the exception handler) and r46 (the start of usermode code) must #be specified in hex (0xwhatever) #I just don't see any reason not to, and it makes programming the script #much nicer to deal with... #load exception handler lc r40, 0x80000050 leh r40 #enable exceptions cle #load TLB entries #virtual page 0 is for instructions #virtual page 1 is for data lc r46, 0x0000005c #usermode start address lc r47, 1 #interrupts off lc r48, 1 #in user mode lc r42, 0x00000000 #denotes VPN 0 lc r43, 0x0000000d #denotes VPN 0 maps to physical page 0 #and is fetchable, readable, and valid tlbse r0, r42 #load into entry 0 lc r42, 0x00001000 #denotes VPN 1 lc r43, 0x0000101e #denotes VPN 1 maps to physical page 1 #and is readable, writable, valid, and dirty #(dirty to prevent taking a #read-only exception) tlbse r48, r42 #load into entry 1 #this last tlb entry is designed to produce a bus error lc r44, 2 #load into TLB entry 2 lc r42, 0x3fffe000 #denotes VPN 0x3fffe lc r43, 0x3fffe01f #map VPN 0x3fffe to page 0x3fffe #and is readable, writable, valid, and dirty #(dirty to prevent taking a #read-only exception) tlbse r44, r42 #warp to user mode rfe r46, r47, r48 #handle exceptions lc r49, 0xdeadbeef halt #or rather don't =) lc r30, 1 cli trap #@expected values #e3 = 0x00000050 #mode = S #interrupts = off #exceptions = off #r40 = 0x80000050 #r46 = 0x0000005c #r47 = 1 #r48 = 1 #r42 = 0x3fffe000 #r43 = 0x3fffe01f #r44 = 2 #r49 = 0xdeadbeef #pc = 0x8000005c #e0 = 0x00000060 #e2 = 0x00000060 #e1 = 0x00000001 #tlb 0: # vpn = 0x00000 # os = 0x000 # ppn = 0x00000 # at = 0x00d #tlb 1: # vpn = 0x00001 # os = 0x000 # ppn = 0x00001 # at = 0x01e #tlb 2: # vpn = 0x3fffe # os = 0x000 # ppn = 0x3fffe # at = 0x01f
// Copyright 2018 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include <boost/core/lightweight_test.hpp> #include <boost/regex.hpp> int main() { boost::regex rx("(\\d+)-+(\\d+)-+(\\d+)"); std::string s = boost::regex_replace(std::string("+1--2--3+"), rx, "$1$2$3"); BOOST_TEST_EQ(s, "+123+"); return boost::report_errors(); }
// // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2013-2018 // // Copyright: See COPYING file that comes with this distribution // #pragma once #include "statistics_config.hpp" #include <wfc/domain_object.hpp> #include <wfc/iinterface.hpp> #include <wfc/statistics/meters.hpp> #include <unordered_map> #include <string> #include <memory> namespace wfc{ namespace io{ class statistics : public domain_object<iinterface, statistics_config, statistics_stat> { typedef domain_object<iinterface, statistics_config, statistics_stat> super; public: virtual void initialize() override; virtual void reg_io(io_id_t io_id, std::weak_ptr<iinterface> itf) override; virtual void unreg_io(io_id_t io_id) override; virtual void perform_io(data_ptr d, io_id_t io_id, output_handler_t handler) override; private: typedef std::mutex mutex_type; std::weak_ptr<iinterface> _target; composite_meter _meter; value_meter _connections_meter; mutex_type _mutex; timer_id_t _timer_id = -1; }; }}
; A006584: If n mod 2 = 0 then n*(n^2-4)/12 else n*(n^2-1)/12. ; 0,0,0,2,4,10,16,28,40,60,80,110,140,182,224,280,336,408,480,570,660,770,880,1012,1144,1300,1456,1638,1820,2030,2240,2480,2720,2992,3264,3570,3876,4218,4560,4940,5320 mov $1,$0 pow $1,2 sub $1,1 mov $2,$1 div $2,4 mul $0,$2 div $0,6 mul $0,2
// // Game state data for where the player wants to go. // // Places an entry in the index table that has no revisit. macro state_index_single label db ({label} - state_table_base) / {state_entry_size} db ({label} - state_table_base) / {state_entry_size} endmacro // Places an entry in the index table that has a revisit. macro state_index_revisit label1, label2 db ({label1} - state_table_base) / {state_entry_size} db ({label2} - state_table_base) / {state_entry_size} endmacro // Label used to denote the bank. state_bank_marker: // Top-level table, mapping categories to route tables. state_category_table: dw state_route_table_anyp // Mid-level table for Any% category, mapping routes to index tables. state_route_table_anyp: dw state_indexes_table_anyp // Index table for Any%. state_indexes_table_anyp: {state_index_revisit state_data_anyp_hornet, state_data_anyp_doppler1} {state_index_single state_data_anyp_buffalo} {state_index_single state_data_anyp_intro} {state_index_single state_data_anyp_beetle} {state_index_revisit state_data_anyp_seahorse, state_data_anyp_doppler2} {state_index_revisit state_data_anyp_catfish, state_data_anyp_doppler3} {state_index_single state_data_anyp_crawfish} {state_index_single state_data_anyp_vile} {state_index_single state_data_anyp_rhino} {state_index_revisit state_data_anyp_tiger, state_data_anyp_doppler4} db 1 // Flag: Yes, there is a Vile stage. // Base address for representing index table addresses. state_table_base: // // Any% state table // state_data_anyp_intro: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$02,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 db $DC,$00,$10,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 state_data_anyp_buffalo: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02,$00 db $00,$00,$00,$00,$02,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 db $DC,$00,$10,$01,$00,$00,$09,$00,$00,$00,$00,$00,$00,$00,$00,$00 state_data_anyp_seahorse: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$04,$00 db $00,$00,$00,$00,$02,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00,$DC,$00,$00,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$24,$00,$00,$00,$00,$00,$00,$00,$00,$00 state_data_anyp_rhino: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$07,$00 db $40,$00,$00,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00,$DC,$00,$00,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$48,$00,$00,$00,$00,$00,$00,$00,$00,$00 state_data_anyp_tiger: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$08,$00 db $40,$00,$04,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$51,$00,$01,$07,$00,$00,$00,$00,$00,$00 state_data_anyp_catfish: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$05,$00 db $40,$00,$04,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $00,$00,$00,$00,$DC,$00,$00,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$2D,$00,$01,$07,$00,$00,$00,$00,$00,$00 state_data_anyp_crawfish: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$06,$00 db $40,$00,$04,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $DC,$00,$00,$00,$DC,$00,$00,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$36,$00,$01,$07,$00,$00,$00,$00,$00,$00 state_data_anyp_vile: // Crush Crawfish stage db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$09,$00 db $40,$00,$0C,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $DC,$00,$00,$00,$DC,$00,$00,$00,$DC,$00,$57,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$36,$00,$05,$67,$00,$00,$00,$00,$00,$00 state_data_anyp_beetle: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$00 db $40,$00,$1C,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $DC,$00,$DC,$00,$DC,$00,$00,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$1B,$00,$35,$67,$00,$00,$00,$00,$00,$00 state_data_anyp_hornet: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00 db $40,$00,$1C,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$00,$00 db $DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$00,$00,$00,$35,$67,$00,$00,$00,$00,$00,$00 state_data_anyp_doppler1: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0A,$00 db $E0,$00,$3C,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$DC,$00 db $DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$01,$3F,$00,$35,$67,$00,$00,$00,$00,$00,$00 state_data_anyp_doppler2: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0B,$01 db $E0,$00,$3C,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$DC,$00 db $DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$01,$3F,$00,$35,$67,$00,$00,$00,$00,$00,$00 state_data_anyp_doppler3: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0C,$02 db $E0,$00,$FC,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$DC,$00 db $DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$01,$3F,$00,$35,$67,$00,$00,$00,$00,$00,$00 state_data_anyp_doppler4: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0D,$03 db $E0,$00,$FC,$00,$02,$00,$01,$00,$00,$00,$00,$00,$DC,$00,$DC,$00 db $DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$DC,$00,$00,$00,$00,$00 db $DC,$08,$10,$01,$00,$01,$3F,$00,$35,$67,$FF,$00,$00,$00,$00,$00
.global s_prepare_buffers s_prepare_buffers: push %r9 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x57d6, %rdx nop nop add $13180, %rsi vmovups (%rdx), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %rbp and $65024, %rax lea addresses_normal_ht+0xd9e, %rsi lea addresses_A_ht+0x7786, %rdi add $11727, %r9 mov $16, %rcx rep movsb nop nop nop nop xor $28928, %rax lea addresses_D_ht+0xa51a, %r9 nop dec %rcx movw $0x6162, (%r9) nop sub $4545, %r9 lea addresses_normal_ht+0x146e6, %rdi clflush (%rdi) xor %rdx, %rdx mov (%rdi), %rsi nop sub $26646, %rsi lea addresses_WT_ht+0x15e76, %r9 nop nop nop nop add %rsi, %rsi movb $0x61, (%r9) nop nop cmp %rax, %rax lea addresses_WT_ht+0x1bed6, %rbp nop nop nop nop nop add $18849, %rdx mov $0x6162636465666768, %rdi movq %rdi, %xmm5 movups %xmm5, (%rbp) nop nop nop nop nop add %rbp, %rbp lea addresses_WT_ht+0x19cc6, %rsi lea addresses_A_ht+0x8bd6, %rdi clflush (%rdi) nop nop nop nop nop add $26784, %rax mov $79, %rcx rep movsq nop dec %rbp pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r9 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r8 push %rax push %rbx // Store lea addresses_WC+0x17bd6, %r14 nop dec %r8 mov $0x5152535455565758, %r11 movq %r11, (%r14) nop nop nop cmp %r10, %r10 // Faulty Load lea addresses_WC+0x153d6, %r14 nop nop nop dec %r10 mov (%r14), %rbx lea oracles, %r11 and $0xff, %rbx shlq $12, %rbx mov (%r11,%rbx,1), %rbx pop %rbx pop %rax pop %r8 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 11}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}, 'dst': {'same': True, 'congruent': 10, 'type': 'addresses_A_ht'}} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
; A266257: Total number of ON (black) cells after n iterations of the "Rule 11" elementary cellular automaton starting with a single ON (black) cell. ; 1,2,4,9,11,20,22,35,37,54,56,77,79,104,106,135,137,170,172,209,211,252,254,299,301,350,352,405,407,464,466,527,529,594,596,665,667,740,742,819,821,902,904,989,991,1080,1082,1175,1177,1274,1276,1377,1379,1484,1486,1595,1597,1710,1712,1829,1831,1952,1954,2079,2081,2210,2212,2345,2347,2484,2486,2627,2629,2774,2776,2925,2927,3080,3082,3239,3241,3402,3404,3569,3571,3740,3742,3915,3917,4094,4096,4277,4279,4464,4466,4655,4657,4850,4852,5049 mul $0,2 lpb $0 sub $0,1 mov $2,$0 div $0,4 mul $0,4 add $1,$2 lpe add $1,1 mov $0,$1
%include "boot.inc" ;section loader vstart=LOADER_BASE_ADDR [BITS 16] ; Tells nasm to build 16 bits code [ORG LOADER_BASE_ADDR] ; The address the code will start ;构建gdt及其内部的描述符 GDT_BASE:dd 0x00000000 dd 0x00000000 CODE_DESC:dd 0x0000FFFF dd DESC_CODE_HIGH4 DATA_STACK_DESC:dd 0x0000FFFF dd DESC_DATA_HIGH4 VIDEO_DESC:dd 0x80000007;limit=(0xbffff-0xb8000)/4k=0x7 dd DESC_VIDEO_HIGH4 ;此时dpl为0 GDT_SIZE equ $ - GDT_BASE GDT_LIMIT equ GDT_SIZE - 1 times 60 dq 0 ; 此处预留60个描述符的空位 SELECTOR_CODE equ (0x0001<<3) + TI_GDT + RPL0 ;相当于(CODE_DESC - GDT_BASE)/8 + TI_GDT + RPL0 SELECTOR_DATA equ (0x0002<<3) + TI_GDT + RPL0 ;同上 SELECTOR_VIDEO equ (0x0003<<3) + TI_GDT + RPL0 ;同上 ; total_mem_bytes 用于保存内存容量,以字节为单位,此位置比较好记 ; 当前偏移 loader.bin 头文件 0x200 字节, loader.bin 的加载地址是 0x900 ; 故 total_mem_bytes 内存中的地址是 0xb00. 将来在内核中咱们会引用到此地址 total_mem_bytes dd 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;以下是gdt的指针,前2字节是gdt界限,后4字节是gdt起始地址 gdt_ptr dw GDT_LIMIT dd GDT_BASE ;人工对齐:total_mem_bytes4+gdt_ptr6+ards_buf224+ards_nr2,共 256 字节 ards_buf times 244 db 0 ards_nr dw 0 ;用于记录 ARDS 结构体数量 loader_start: LOADER_TEXT_BASE_ADDR equ 0x140 ;相当于(CODE_DESC - GDT_BASE)/8 + TI_GDT + RPL0 LOADER_TEXT_BASE_ATTRIBUTE equ 0x4A ;--------------------- 0.显示loader ----------------------------------- ; 输出背景色绿色,前景色红色,并且跳动的字符串"1 MBR" mov byte [gs:LOADER_TEXT_BASE_ADDR],'l' mov byte [gs:LOADER_TEXT_BASE_ADDR+1],LOADER_TEXT_BASE_ATTRIBUTE mov byte [gs:LOADER_TEXT_BASE_ADDR+2],'o' mov byte [gs:LOADER_TEXT_BASE_ADDR+3],LOADER_TEXT_BASE_ATTRIBUTE mov byte [gs:LOADER_TEXT_BASE_ADDR+4],'a' mov byte [gs:LOADER_TEXT_BASE_ADDR+5],LOADER_TEXT_BASE_ATTRIBUTE mov byte [gs:LOADER_TEXT_BASE_ADDR+6],'d' mov byte [gs:LOADER_TEXT_BASE_ADDR+7],LOADER_TEXT_BASE_ATTRIBUTE mov byte [gs:LOADER_TEXT_BASE_ADDR+8],'e' mov byte [gs:LOADER_TEXT_BASE_ADDR+9],LOADER_TEXT_BASE_ATTRIBUTE mov byte [gs:LOADER_TEXT_BASE_ADDR+10],'r' mov byte [gs:LOADER_TEXT_BASE_ADDR+11],LOADER_TEXT_BASE_ATTRIBUTE ;--------------------- 1.加载 kernel ----------------------------------- mov eax, KERNEL_BIN_BASE_ADDR_SEG ; 0x6000 mov si, KERNEL_START_SECTOR ;0x9 mov edx, 0 mov ecx, 400 xor ebx, ebx call read_sectors ;-------------------- 2.通过 int 15h eax = 0000E820h, edx = 534D4150h ('SMAP') 获取内存布局 -------- xor ebx,ebx ;第一次调用时,ebx值要为0 mov edx, 0x534d4150 ;edx 只赋值一次,循环体中不会改变 mov di, ards_buf ;ards 结构缓冲区 .e820_mem_get_loop: ;循环获取每个 ARDS 内存范围描述结构 mov eax, 0x0000e820 ;执行 int 0x15 后,eax 值变为 0x534d4150,所以每次执行 int 前都要更新为子功能号 mov ecx, 20 ;ARDS 地址范围描述符结构大小是20字节 int 0x15 jc .e820_failed_so_try_e801 ;若cf位为 1 则有错误发生,尝试 0xe801 子功能 add di, cx ;使 di 增加 20 字节指向缓冲区新的 ARDS 结构体位置 inc word [ards_nr] ;记录 ARDS 数量 cmp ebx, 0 ;若 ebx 为 0 且 cf 不为1,这说明 ards 全部返回,当前已是最后一个 jnz .e820_mem_get_loop ;在所有 ards 结构体中,找出(base_add_low + length_low)的最大值,即内存的容量 mov cx,[ards_nr] ;遍历每一个 ARDS 结构体,循环次数是 ARDS 的数量 mov ebx, ards_buf xor edx,edx ;edx 为最大的内存容量,在此先清0 .find_max_mem_area: ;无需判断 type 是否为1,最大的内存块一定是可被使用的 mov eax, [ebx] ;base_add_low add eax, [ebx+8] ;length_low add ebx, 20 ;指向缓冲区下一个 ARDS 结构 cmp edx, eax ;冒泡排序,找出最大,edx寄存器始终是最大的内存容量 jge .next_ards mov edx, eax ;edx为总内存大小 .next_ards: loop .find_max_mem_area jmp .mem_get_ok ;---------------- int 15h ax = E801h 获取内存大小,最大支持 4G ----------- ; 返回后,ax cx 值一样,已 KB 为单位,bx dx 值一样,以 64KB 为单位 ; 在 ax 和 cx 寄存器中为低 16MB, 在 dx 和 dx 寄存器中为 16MB 到 4GB .e820_failed_so_try_e801: mov ax, 0xe801 int 0x15 jc .e801_failed_so_try88 ;若当前 e801 方法失败,就尝试 0x88 方法 ;1 先计算出低 15MB 的内存, ax 和 cx 中是以 KB 为单位的内存数量,将其转换为以 byte 为单温 mov cx, 0x400 ;cx 和 ax 值一样,cx 用作乘数 mul cx shl edx, 16 and eax, 0x0000FFFF or edx, eax add edx, 0x100000 ;ax只是15MB,故要加1MB mov esi, edx ;先把低 15MB 的内存容量存入 esi 寄存器备份 ;2 再将 16MB 以上的内存转换为 byte 为单位,寄存器 bx 和 dx 中是以 64KB 为单位的内存数量 xor eax, eax mov ax, bx mov ecx, 0x10000 ;0x10000 十进制为 64KB mul ecx ;32位乘法,默认的被乘数是eax,积为64位 add esi, eax;由于此方法只能测出 4GB 以内的内存, 故 32 位 eax 足够了,edx 肯定为 0,只加 eax 便可 mov edx, esi ;edx 为总内存大小 jmp .mem_get_ok ;--------------- int 15h ah = 0x88 获取内存大小,只能获取 64MB 之内 ------- .e801_failed_so_try88: ;int 15 后,ax 存入的是以 KB 为单位的内存容量 mov ah, 0x88 int 0x15 jc .error_hlt and eax, 0x0000FFFF ;16 位乘法,被乘数是 ax,积为 32 位。 积的高 16 位在 dx 中,积的低 16 位在 ax 中 mov cx, 0x400 ;0x400 等于 1024,将 ax 中的内存容量换为以 byte 为单位 mul cx shl edx, 16 ;把 dx 移到高 16 位 or edx, eax ;把积的低 16 位组合到 edx, 为 32 位的积 add edx, 0x100000 ;0x88 子功能只会返回到 1MB 以上的内存,故实际内存大小要加上 1MB .mem_get_ok: mov [total_mem_bytes], edx ;将内存换为 byte 单位后存入 total_mem_bytes 处 ;------------------- 3.准备进入保护模式 ------------------ ;0 关闭中断 ;1 打开A20 如果A20Gate被打开,当访问到0x100000~0x10FFEF之间的地址时,CPU将真正访问这块物理内存。 ;如果A20Gate被禁止,当访问0x100000~0x10FFEF之间的地址时,CPU将采用8086/8088的地址回绕。 ;2 加载gdt 保护模式下,有这样一个数据结构,它叫全局描述符表(Global Descriptor Table,GDT),这个表中的每一项称为段描述符。 ;3 将cr0的pe位置1 更准确地说,我们要用到 CR0 寄存器的第 0 位,即 PE 位,Protection Enable,此位用于启用保护模式,是保护模式的开关, cli ;close the interruption ;------------------- 3.1 打开A20 ---------------------- in al,0x92 ;从92H端口读取一字节数据到AL or al,0000_0010b out 0x92,al ; 将AL的值写入92H端口 ;------------------- 3.2 加载GDT -------------------- lgdt [gdt_ptr] ;------------------- 3.3 cr0第0位置1 ----------------- mov eax,cr0 or eax,0x00000001 ; pe 位 mov cr0,eax .jump_test: ;jmp .jump_test ;------------------ 4.跳转至 保护模式 ----------------- jmp word SELECTOR_CODE:p_mode_start ; 刷新流水线,避免分支预测的影响,这种cpu优化策略,最怕jmp跳转, ; 这将导致之前做的预测失效,从而起了刷新的作用。 .error_hlt: ;出错则挂起 ;hlt align 4 DAP: ; disk address packet db 0x10 ; [0]: packet size in bytes db 0 ; [1]: reserved, must be 0 db 0 ; [2]: nr of blocks to transfer (0~127) db 0 ; [3]: reserved, must be 0 dw 0 ; [4]: buf addr(offset) dw 0 ; [6]: buf addr(seg) dd 0 ; [8]: lba. low 32-bit dd 0 ; [12]: lba. high 32-bit ; function: read a sector data from harddisk ; @input: ; ax: dx -> buffer seg: off ; si -> lba low 32 bits harddisk_read_sector: push ax push bx push cx push dx push si mov word [DAP + 2], 1 ; count mov word [DAP + 4], dx ; offset mov word [DAP + 6], ax ; segment mov word [DAP + 8], si ; lba low 32 bits mov dword [DAP + 12], 0 ; lba high 32 bits xor bx, bx mov ah, 0x42 mov dl, 0x80 mov si, DAP int 0x13 pop si pop dx pop cx pop bx pop ax ret read_sectors: push ax push bx push cx push dx push si push di push es .reply: call harddisk_read_sector add ax, 0x20 ; next buffer inc si ; next lba loop .reply pop es pop di pop si pop dx pop cx pop bx pop ax ret ;------------------ 5.保护模式,代码开始 ----------------------- [bits 32] p_mode_start: mov ax,SELECTOR_DATA mov ds,ax mov es,ax mov ss,ax mov esp,LOADER_STACK_TOP ;0x900 mov ax,SELECTOR_VIDEO mov gs,ax ;设置 显存 ;5.1 创建页目录及页表并初始化页内存位图 call setup_page ;5.2 要将描述符地址及偏移量写入内存 gdt_ptr,修改后,一会儿用新地址重新加载 sgdt [gdt_ptr] ;存储到原来 gdt 所有的位置 ;将 gdt 描述符中视频段描述符中的段基址 + 0xc0000000 mov ebx, [gdt_ptr + 2] or dword [ebx + 0x18 + 4], 0xc0000000 ;视频段是第3个段描述符,每个描述符是8字节,故0x18。 ;段描述符的高4字节的最高位是段基址的31~24位 ;将gdt的基址加上0xc0000000使其成为内核所在的高地址 add dword [gdt_ptr + 2], 0xc0000000 ;5.3 将修改后的基于 保护模式高地址的 gdt 重新加载 lgdt [gdt_ptr] ; 重新加载 add esp, 0xc0000000 ; 将栈指针同样映射到内核地址 ;5.4 把页目录·地址赋值给 cr3 ;分页机制打开前要将页表地址加载到控制寄存器 cr3 中,这是启用分页机制的先决条件之一,在 ;介绍二级页表时会细说。所以,在打开分页机制前加载到寄存器 cr3 中的是页表的物理地址,页表中页表 项的地址自然也是物理地址了。 mov eax, PAGE_DIR_TABLE_POS mov cr3, eax ;5.5 打开 cr0 的pg位 (第 31 位) ;启动分页机制的开关是将控制寄存器 cr0 的 PG 位置 1, PG位是cr0寄存器的最后一位 mov eax, cr0 or eax, 0x80000000 mov cr0, eax ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 此时不刷新流水线也没问题 ;;;;;;;;;;;;;;;;;;;;;;; ;由于一直处在 32 位下,原则上不需要强制刷新,经过实际测试以下两句也没问题. ;但以防万一,还是加上了,免得将来出来莫名其妙的问题. ;------------------ 6.解析内核 elf格式文件,取出代码带,跳转到 main 函数 ----------------------- jmp SELECTOR_CODE:enter_kernel ;强制刷新流水线,更新gdt enter_kernel: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; call kernel_init mov esp, 0xc009f000 ;0xd3d jmp KERNEL_ENTRY_POINT ; 用地址 0x1500 访问测试,结果ok 0xd42 ;--------------- 讲 kernel.bin 中的 segment 拷贝到编译的地址 ---------------- kernel_init: ; 0x0d47 xor eax, eax xor ebx, ebx ;ebx 记录程序头表地址 xor ecx, ecx ;cx 记录程序头表中的 program header 数量 xor edx, edx ;dx 记录program header 尺寸,即 e_phentsize mov dx,[KERNEL_BIN_BASE_ADDR + 42] ;编译文件 42 字节处的属性是 e_phentsize, 表示 program header 大小 mov ebx, [KERNEL_BIN_BASE_ADDR + 28] ;偏移文件开始部分 28 字节的地方是 e_phoff,表示第 1 个program header 在文件中的偏移量 ;其实该值是 0x34,不过还是谨慎一点,这里来读取实际值 add ebx, KERNEL_BIN_BASE_ADDR mov cx, [KERNEL_BIN_BASE_ADDR + 44] ;偏移文件开始部分 44 字节的地方是 e_phnum,表示有几个 program header .each_segment: cmp byte [ebx + 0], PT_NULL ; 若 p_type 等于 PT_NULL, 说明此 program header 未使用 0xd62 je .PTNULL ;为函数 memcpy 压入参数,参数是从右往左依次压入,函数原型类似于 memcpy(dst, src, size) push dword [ebx + 16] ; program header 中偏移 16 字节的地方是 p_filesz,压入函数 memcpy 的第三个参数:size mov eax, [ebx + 4] ; 距程序偏移量为 4 字节的位置是 p_offset add eax, KERNEL_BIN_BASE_ADDR ;加上 kernel.bin 被加载到的物理地址, eax 为该段的物理地址 push eax ; 压入函数 memcpy 的第二个参数: 源地址 mov eax,[ebx + 8] push eax ;push dword [ebx + 8]; 压入函数 memcpy 的第一个参数: 目的地址,偏移程序头 8 字节的位置是 p_vaddr, 这就是目的地址 call mem_cpy ; 调用 mem_cpy 完成段复制 add esp, 12 ; 清理栈中压入的三个参数 .PTNULL: add ebx, edx ; edx 为 program header 大小,即 e_phentsize,在此 ebx 指向下一个 program header loop .each_segment ret ;-------------------------- 逐字节拷贝 mem_cpy(dst, src, size) ----------- ; 输入:栈中三个参数(dst,src,size) ;输出: 无 ;-------------------------------------------------------------------------- mem_cpy: ;0xd8a cld push ebp mov ebp, esp push ecx ; rep 指令用到了 ecx,但 ecx 对于外层段的循环还有用,故先入栈备份 mov edi, [ebp + 8] ;dst mov esi, [ebp + 12] ;src mov ecx, [ebp + 16] ;size rep movsb ;逐字节拷贝 0xd98 ;恢复环境 pop ecx ; 0xd9a pop ebp ret ;-------------------- 创建页目录及页表 ------------------------ setup_page: ;先把页目录占用的空间逐字节清0 mov ecx, 4096 mov esi, 0 .clear_page_dir: mov byte [PAGE_DIR_TABLE_POS + esi], 0 inc esi loop .clear_page_dir ;开始创建页目录项(PDE) .create_pde: ;创建 Page Directory Entry mov eax, PAGE_DIR_TABLE_POS add eax, 0x1000 ; 此时 eax 为第一个页表的位置及属性 mov ebx, eax ; 此处为 ebx 赋值, 是为 .create_pte 做准备, ebx 为基址 ;下面将页目录 0 和 0xc00 都存为第一个页表的地址,每个页表表示 4MB 内存 ;这样 0xc03fffff 以下的地址和 0x003fffff 以下的地址都指向相同的页表 ;这是为将地址映射为内核地址做准备 or eax, PG_US_U | PG_RW_W | PG_P ;页目录项的属性 RW 和 P 位为1, US 为 1,表示用户属性,所有特权级别都可以访问 mov [PAGE_DIR_TABLE_POS + 0x0], eax ;第1个目录项,在页目录表中的第1个目录项写入第一个页表的位置(0x101000)及属性(3) mov [PAGE_DIR_TABLE_POS + 0xc00], eax;一个页表占用 4 字节,0xc00 表示第 768 个页表占用的目录项,0xc00 以上的目录项用于内核控件 ;也就是页表的 0xc0000000 ~ 0xffffffff 共计 1G 属于内核, 0x0~0xbfffffff共计3G属于用户进程 sub eax, 0x1000 mov [PAGE_DIR_TABLE_POS + 4092], eax ;使最后一个目录项指向页目录表自己的地址 ;下面创建页表项(PTE) mov ecx, 256 ; 1M 低端内存 / 每页大小 4k = 256 mov esi, 0 mov edx, PG_US_U | PG_RW_W | PG_P ; 属性为7, US=1,RW=1,P=1 .create_pte: ;创建 Page Table Entry mov [ebx+esi*4], edx ;此时的 ebx 已经在上面通过 eax 赋值为 0x101000,也就是第一个页表的地址 add edx, 4096 inc esi loop .create_pte ;创建内核其他页表的PDE,创建 >=769 的页目录项 mov eax, PAGE_DIR_TABLE_POS add eax, 0x2000 ;此时eax 为第二个页表的位置 or eax, PG_US_U | PG_RW_W | PG_P ; 页目录项的属性US,RW和P位都为1 mov ebx, PAGE_DIR_TABLE_POS mov ecx,254 ; 范围为第 769~1022 的所有目录数量 mov esi,769 .create_kernel_pde: mov [ebx+esi*4], eax inc esi add eax, 0x1000 loop .create_kernel_pde ret
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.16.27026.1 include listing.inc INCLUDELIB MSVCRTD INCLUDELIB OLDNAMES msvcjmc SEGMENT __7B7A869E_ctype@h DB 01H __457DD326_basetsd@h DB 01H __4384A2D9_corecrt_memcpy_s@h DB 01H __4E51A221_corecrt_wstring@h DB 01H __2140C079_string@h DB 01H __1887E595_winnt@h DB 01H __9FC7C64B_processthreadsapi@h DB 01H __FA470AEC_memoryapi@h DB 01H __F37DAFF1_winerror@h DB 01H __7A450CCC_winbase@h DB 01H __B4B40122_winioctl@h DB 01H __86261D59_stralign@h DB 01H __7B8DBFC3_pmc_uint_internal@h DB 01H __15109A3D_pmc_clone@c DB 01H msvcjmc ENDS PUBLIC Initialize_Clone PUBLIC PMC_Clone_X PUBLIC __JustMyCode_Default EXTRN CheckNumber:PROC EXTRN DuplicateNumber:PROC EXTRN _RTC_CheckStackVars:PROC EXTRN _RTC_InitBase:PROC EXTRN _RTC_Shutdown:PROC EXTRN __CheckForDebuggerJustMyCode:PROC EXTRN number_zero:BYTE ; COMDAT pdata pdata SEGMENT $pdata$Initialize_Clone DD imagerel $LN3 DD imagerel $LN3+66 DD imagerel $unwind$Initialize_Clone pdata ENDS ; COMDAT pdata pdata SEGMENT $pdata$PMC_Clone_X DD imagerel $LN10 DD imagerel $LN10+266 DD imagerel $unwind$PMC_Clone_X pdata ENDS ; COMDAT rtc$TMZ rtc$TMZ SEGMENT _RTC_Shutdown.rtc$TMZ DQ FLAT:_RTC_Shutdown rtc$TMZ ENDS ; COMDAT rtc$IMZ rtc$IMZ SEGMENT _RTC_InitBase.rtc$IMZ DQ FLAT:_RTC_InitBase rtc$IMZ ENDS ; COMDAT xdata xdata SEGMENT $unwind$PMC_Clone_X DD 025052f01H DD 01132318H DD 0700c0029H DD 0500bH xdata ENDS ; COMDAT CONST CONST SEGMENT PMC_Clone_X$rtcName$0 DB 06eH DB 06fH DB 00H ORG $+13 PMC_Clone_X$rtcVarDesc DD 068H DD 08H DQ FLAT:PMC_Clone_X$rtcName$0 ORG $+48 PMC_Clone_X$rtcFrameData DD 01H DD 00H DQ FLAT:PMC_Clone_X$rtcVarDesc CONST ENDS ; COMDAT xdata xdata SEGMENT $unwind$Initialize_Clone DD 025052a01H DD 010e2313H DD 07007001dH DD 05006H xdata ENDS ; Function compile flags: /Odt ; COMDAT __JustMyCode_Default _TEXT SEGMENT __JustMyCode_Default PROC ; COMDAT ret 0 __JustMyCode_Default ENDP _TEXT ENDS ; Function compile flags: /Odtp /RTCsu /ZI ; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_clone.c ; COMDAT PMC_Clone_X _TEXT SEGMENT nx$ = 8 result$ = 36 no$ = 72 x$ = 320 o$ = 328 PMC_Clone_X PROC ; COMDAT ; 38 : { $LN10: mov QWORD PTR [rsp+16], rdx mov QWORD PTR [rsp+8], rcx push rbp push rdi sub rsp, 328 ; 00000148H lea rbp, QWORD PTR [rsp+32] mov rdi, rsp mov ecx, 82 ; 00000052H mov eax, -858993460 ; ccccccccH rep stosd mov rcx, QWORD PTR [rsp+360] lea rcx, OFFSET FLAT:__15109A3D_pmc_clone@c call __CheckForDebuggerJustMyCode ; 39 : if (x == NULL) cmp QWORD PTR x$[rbp], 0 jne SHORT $LN2@PMC_Clone_ ; 40 : return (PMC_STATUS_ARGUMENT_ERROR); mov eax, -1 jmp $LN1@PMC_Clone_ $LN2@PMC_Clone_: ; 41 : if (o == NULL) cmp QWORD PTR o$[rbp], 0 jne SHORT $LN3@PMC_Clone_ ; 42 : return (PMC_STATUS_ARGUMENT_ERROR); mov eax, -1 jmp $LN1@PMC_Clone_ $LN3@PMC_Clone_: ; 43 : NUMBER_HEADER* nx = (NUMBER_HEADER*)x; mov rax, QWORD PTR x$[rbp] mov QWORD PTR nx$[rbp], rax ; 44 : PMC_STATUS_CODE result; ; 45 : if ((result = CheckNumber(nx)) != PMC_STATUS_OK) mov rcx, QWORD PTR nx$[rbp] call CheckNumber mov DWORD PTR result$[rbp], eax cmp DWORD PTR result$[rbp], 0 je SHORT $LN4@PMC_Clone_ ; 46 : return (result); mov eax, DWORD PTR result$[rbp] jmp SHORT $LN1@PMC_Clone_ $LN4@PMC_Clone_: ; 47 : NUMBER_HEADER* no; ; 48 : if (nx->IS_ZERO) mov rax, QWORD PTR nx$[rbp] mov eax, DWORD PTR [rax+40] shr eax, 1 and eax, 1 test eax, eax je SHORT $LN5@PMC_Clone_ ; 49 : no = &number_zero; lea rax, OFFSET FLAT:number_zero mov QWORD PTR no$[rbp], rax jmp SHORT $LN6@PMC_Clone_ $LN5@PMC_Clone_: ; 50 : else ; 51 : { ; 52 : if ((result = DuplicateNumber(nx, &no)) != PMC_STATUS_OK) lea rdx, QWORD PTR no$[rbp] mov rcx, QWORD PTR nx$[rbp] call DuplicateNumber mov DWORD PTR result$[rbp], eax cmp DWORD PTR result$[rbp], 0 je SHORT $LN7@PMC_Clone_ ; 53 : return (result); mov eax, DWORD PTR result$[rbp] jmp SHORT $LN1@PMC_Clone_ $LN7@PMC_Clone_: $LN6@PMC_Clone_: ; 54 : } ; 55 : *o = no; mov rax, QWORD PTR o$[rbp] mov rcx, QWORD PTR no$[rbp] mov QWORD PTR [rax], rcx ; 56 : #ifdef _DEBUG ; 57 : if ((result = CheckNumber(*o)) != PMC_STATUS_OK) mov rax, QWORD PTR o$[rbp] mov rcx, QWORD PTR [rax] call CheckNumber mov DWORD PTR result$[rbp], eax cmp DWORD PTR result$[rbp], 0 je SHORT $LN8@PMC_Clone_ ; 58 : return (result); mov eax, DWORD PTR result$[rbp] jmp SHORT $LN1@PMC_Clone_ $LN8@PMC_Clone_: ; 59 : #endif ; 60 : return (PMC_STATUS_OK); xor eax, eax $LN1@PMC_Clone_: ; 61 : } mov rdi, rax lea rcx, QWORD PTR [rbp-32] lea rdx, OFFSET FLAT:PMC_Clone_X$rtcFrameData call _RTC_CheckStackVars mov rax, rdi lea rsp, QWORD PTR [rbp+296] pop rdi pop rbp ret 0 PMC_Clone_X ENDP _TEXT ENDS ; Function compile flags: /Odtp /RTCsu /ZI ; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_clone.c ; COMDAT Initialize_Clone _TEXT SEGMENT feature$ = 224 Initialize_Clone PROC ; COMDAT ; 64 : { $LN3: mov QWORD PTR [rsp+8], rcx push rbp push rdi sub rsp, 232 ; 000000e8H lea rbp, QWORD PTR [rsp+32] mov rdi, rsp mov ecx, 58 ; 0000003aH mov eax, -858993460 ; ccccccccH rep stosd mov rcx, QWORD PTR [rsp+264] lea rcx, OFFSET FLAT:__15109A3D_pmc_clone@c call __CheckForDebuggerJustMyCode ; 65 : return (PMC_STATUS_OK); xor eax, eax ; 66 : } lea rsp, QWORD PTR [rbp+200] pop rdi pop rbp ret 0 Initialize_Clone ENDP _TEXT ENDS END
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosEnterCritSec DOS wrapper ; ; (c) osFree Project 2022, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ; ; ;*/ .8086 ; Helpers INCLUDE HELPERS.INC _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @PROLOG DOSENTERCRITSEC @START DOSENTERCRITSEC XOR AX, AX EXIT: @EPILOG DOSENTERCRITSEC _TEXT ENDS END
.data return.0: .word 0 return.1: .word 0 b.0: .word 0 d.1: .word 0 x.2: .word 0 a.3: .word 0 c.4: .word 0 e.5: .word 0 f.6: .word 0 g.7: .word 0 .text runtime: addi $sp, $sp, -4 sw $ra, 0($sp) lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra .end runtime temp: addi $sp, $sp, -4 sw $ra, 0($sp) li $3, 1 # return.0 -> $3 sw $3, return.0 # spilled return.0, freed $3 li $3, 2 # return.1 -> $3 # Store dirty variables back into memory sw $3, return.1 lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra .end temp .globl main .ent main main: li $3, 6 # b.0 -> $3 sw $3, b.0 # spilled b.0, freed $3 li $3, 3 # d.1 -> $3 li $5, 3 # x.2 -> $5 sw $5, x.2 # spilled x.2, freed $5 move $5, $3 # a.3 -> $5 li $2, 1 move $4, $5 syscall sw $3, d.1 sw $5, a.3 jal temp lw $3, d.1 lw $5, a.3 lw $6, return.0 # return.0 -> $6 move $7, $6 # c.4 -> $7 sw $7, c.4 # spilled c.4, freed $7 lw $7, return.1 # return.1 -> $7 move $8, $7 # e.5 -> $8 sw $8, e.5 # spilled e.5, freed $8 li $8, 0 # f.6 -> $8 sw $8, f.6 # spilled f.6, freed $8 li $8, 0 # g.7 -> $8 sw $3, d.1 sw $5, a.3 sw $6, return.0 sw $7, return.1 sw $8, g.7 jal temp lw $3, d.1 lw $5, a.3 lw $8, g.7 move $8, $6 # f.6 -> $8 move $9, $7 # g.7 -> $9 li $2, 1 move $4, $8 syscall li $2, 1 move $4, $9 syscall # Store dirty variables back into memory sw $8, f.6 sw $9, g.7 li $2, 10 syscall .end main
#ifndef Y3_CLUSTER_CPP_MOR_DES_T_HH #define Y3_CLUSTER_CPP_MOR_DES_T_HH #include "utils/datablock.hh" #include "utils/datablock_reader.hh" #include "utils/interp_2d.hh" #include "utils/mz_power_law.hh" #include "utils/primitives.hh" #include "utils/str_to_doubles.hh" #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <istream> #include <ostream> #include <string> namespace y3_cluster { class MOR_DES_t { // Read from l_sat_grid.dat static std::array<double, 42> constexpr test_lsat = { 0.500000, 0.600000, 0.700000, 0.800000, 0.900000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000, 7.000000, 8.000000, 9.000000, 10.000000, 11.000000, 12.000000, 13.000000, 14.000000, 24.000000, 34.000000, 44.000000, 54.000000, 64.000000, 74.000000, 84.000000, 94.000000, 104.000000, 114.000000, 124.000000, 134.000000, 144.000000, 154.000000, 164.000000, 174.000000, 184.000000, 194.000000, 204.000000, 214.000000, 224.000000, 234.000000, 244.000000}; // Read from sig_intr_grid.dat static std::array<double, 14> constexpr test_sigintr = {0.050000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000, 0.600000, 0.700000, 0.800000, 0.900000, 1.000000, 1.300000, 1.700000, 2.000000}; // Read from sig_skew_table.dat; static std::array<std::array<double, 42>, 14> constexpr sig_skewnorml_flat = { {{1.211319, 1.307980, 1.455547, 1.242204, 1.260416, 1.287859, 1.604654, 1.883786, 2.133369, 2.357737, 2.565367, 2.759611, 2.939715, 3.113878, 3.277425, 3.435430, 3.584226, 3.730049, 3.872571, 5.091403, 6.118126, 7.024295, 7.861908, 8.647303, 9.392576, 10.110787, 10.799733, 11.464516, 12.127780, 12.770096, 13.393245, 14.018971, 14.625637, 15.228590, 15.823349, 16.405359, 16.995068, 17.565897, 18.144194, 18.704318, 19.271479, 19.830625}, {1.211227, 1.309620, 1.455854, 1.241931, 1.259493, 1.287663, 1.605865, 1.898566, 2.160331, 2.397456, 2.621481, 2.828296, 3.026425, 3.213295, 3.393675, 3.568839, 3.735769, 3.899172, 4.061805, 5.508045, 6.791948, 7.997309, 9.155444, 10.276979, 11.376409, 12.460638, 13.535322, 14.584471, 15.645481, 16.685029, 17.736828, 18.756013, 19.791557, 20.837728, 21.859120, 22.878280, 23.911779, 24.911220, 25.953940, 26.954718, 27.983187, 28.968243}, {1.211671, 1.309826, 1.456078, 1.242446, 1.260993, 1.290490, 1.647297, 1.975678, 2.278038, 2.560308, 2.830641, 3.086770, 3.336938, 3.585123, 3.821795, 4.058084, 4.285488, 4.513090, 4.741029, 6.911372, 9.004724, 11.059253, 13.091911, 15.109313, 17.140012, 19.159858, 21.177185, 23.182035, 25.199804, 27.212651, 29.216700, 31.205516, 33.209544, 35.219265, 37.216348, 39.230041, 41.242532, 43.245237, 45.252177, 47.220149, 49.236398, 51.248283}, {1.211565, 1.311895, 1.460779, 1.251060, 1.277766, 1.312986, 1.716564, 2.098457, 2.459967, 2.805381, 3.143568, 3.475037, 3.798101, 4.120511, 4.438261, 4.753240, 5.068811, 5.378748, 5.691811, 8.755126, 11.787875, 14.802370, 17.808191, 20.817430, 23.841264, 26.825406, 29.846444, 32.848399, 35.844798, 38.838005, 41.835642, 44.807681, 47.874351, 50.846945, 53.843309, 56.831403, 59.850411, 62.868051, 65.831786, 68.818846, 71.820014, 74.862193}, {1.214203, 1.316602, 1.475982, 1.273027, 1.306867, 1.349644, 1.807364, 2.254934, 2.688736, 3.113848, 3.533751, 3.945386, 4.358664, 4.765982, 5.172834, 5.580771, 5.985243, 6.394095, 6.800004, 10.816307, 14.825071, 18.828409, 22.833925, 26.835960, 30.840218, 34.822678, 38.821903, 42.845150, 46.865463, 50.844324, 54.834713, 58.883133, 62.837446, 66.850908, 70.830658, 74.871135, 78.816211, 82.872843, 86.830251, 90.827108, 94.868737, 98.851579}, {1.223224, 1.305364, 1.282591, 1.302511, 1.343813, 1.391583, 1.915889, 2.438440, 2.954782, 3.463715, 3.972178, 4.475866, 4.981030, 5.484776, 5.988101, 6.489089, 6.987325, 7.492044, 7.992565, 13.002149, 18.004261, 23.007252, 27.992595, 32.997420, 38.007604, 42.995294, 47.960506, 53.006768, 57.998229, 62.978091, 67.990712, 73.025313, 77.988608, 82.992045, 87.948481, 93.020257, 98.037134, 103.005688, 107.968164, 112.955753, 118.091016, 123.064706}, {1.237303, 1.297838, 1.299703, 1.336018, 1.386345, 1.440389, 2.038549, 2.643681, 3.246379, 3.847373, 4.449428, 5.049205, 5.648647, 6.246004, 6.847078, 7.447189, 8.042671, 8.641741, 9.246661, 15.240034, 21.245192, 27.235472, 33.234248, 39.222670, 45.239112, 51.237171, 57.234173, 63.224968, 69.264088, 75.216487, 81.220146, 87.247497, 93.207614, 99.264302, 105.290686, 111.221248, 117.130732, 123.207067, 129.211764, 135.248975, 141.199774, 147.221067}, {1.255781, 1.301398, 1.326024, 1.373377, 1.431998, 1.494301, 2.170349, 2.863678, 3.556875, 4.254405, 4.951657, 5.648337, 6.344185, 7.042540, 7.738373, 8.438037, 9.135133, 9.842018, 10.534453, 17.527653, 24.518568, 31.522017, 38.530695, 45.531330, 52.535863, 59.486804, 66.539248, 73.511258, 80.457846, 87.477414, 94.477479, 101.512152, 108.536001, 115.476406, 122.473642, 129.513069, 136.476210, 143.513249, 150.550130, 157.499933, 164.525677, 171.621905}, {1.276646, 1.315435, 1.357289, 1.415508, 1.481102, 1.551490, 2.313390, 3.097829, 3.885637, 4.678081, 5.472808, 6.266119, 7.063419, 7.858818, 8.656639, 9.454800, 10.253293, 11.045166, 11.850929, 19.840428, 27.836272, 35.842002, 43.822372, 51.811789, 59.830339, 67.850225, 75.868274, 83.871893, 91.824629, 99.842206, 107.837178, 115.747088, 123.801923, 131.879473, 139.904745, 147.825008, 155.800340, 163.858451, 171.872588, 179.842903, 187.749487, 195.829631}, {1.296820, 1.336911, 1.392021, 1.460964, 1.534856, 1.613478, 2.460424, 3.337350, 4.224161, 5.113733, 6.005077, 6.902279, 7.794092, 8.695950, 9.585411, 10.488258, 11.382026, 12.283516, 13.176733, 22.163355, 31.175048, 40.148876, 49.169087, 58.188614, 67.159212, 76.140945, 85.190444, 94.138865, 103.180710, 112.151019, 121.169030, 130.155468, 139.123738, 148.199908, 157.191572, 166.110967, 175.158204, 184.278367, 193.189233, 202.156366, 211.208459, 220.106192}, {1.314956, 1.362826, 1.430397, 1.507732, 1.590281, 1.677336, 2.615813, 3.587581, 4.569082, 5.561364, 6.549072, 7.547573, 8.537343, 9.537660, 10.527682, 11.533997, 12.527410, 13.528436, 14.527811, 24.523978, 34.511355, 44.495985, 54.522808, 64.523901, 74.496739, 84.506243, 94.476834, 104.521732, 114.526516, 124.492931, 134.507726, 144.512764, 154.469854, 164.565066, 174.511718, 184.505784, 194.563024, 204.550301, 214.551573, 224.414200, 234.453502, 244.490757}, {1.377952, 1.458798, 1.554977, 1.660817, 1.772187, 1.886016, 3.108236, 4.371942, 5.654082, 6.943083, 8.236469, 9.529075, 10.822614, 12.119244, 13.411976, 14.715629, 16.011403, 17.304457, 18.609621, 31.606019, 44.629317, 57.606470, 70.570352, 83.623095, 96.649602, 109.608422, 122.636289, 135.528202, 148.553542, 161.627864, 174.639075, 187.644904, 200.648839, 213.598369, 226.691110, 239.567775, 252.597781, 265.726680, 278.632619, 291.690736, 304.684948, 317.539261}, {1.484981, 1.607807, 1.744091, 1.888228, 2.038241, 2.191676, 3.805323, 5.474649, 7.158217, 8.843498, 10.533764, 12.229865, 13.922527, 15.619515, 17.316468, 19.033038, 20.717065, 22.416868, 24.117551, 41.117558, 58.087372, 75.122262, 92.070802, 109.109606, 126.060604, 143.111422, 160.052720, 176.993527, 193.966219, 210.996823, 228.048774, 244.927949, 262.217855, 279.071730, 295.979342, 313.206434, 329.907372, 347.043429, 364.039406, 381.250446, 398.166340, 414.966776}, {1.576173, 1.731248, 1.898551, 2.074172, 2.252728, 2.436570, 4.353815, 6.322445, 8.313083, 10.294745, 12.287411, 14.277241, 16.277280, 18.268876, 20.271681, 22.276521, 24.263926, 26.265196, 28.259014, 48.256424, 68.222320, 88.220667, 108.266808, 128.276115, 148.278550, 168.292247, 188.270702, 208.207174, 228.281385, 248.326064, 268.274824, 288.273748, 308.305930, 328.090806, 348.214194, 368.297940, 388.180241, 408.444446, 428.281276, 448.256689, 468.212324, 488.220129}}}; // Read from skew_table.dat; static std::array<std::array<double, 42>, 14> constexpr skews = { {{9.120214, 11.475627, 38.412414, 2.221504, 1.684393, 1.446896, 0.781268, 0.600871, 0.508428, 0.446559, 0.403048, 0.369343, 0.343748, 0.322870, 0.304779, 0.289879, 0.276274, 0.265372, 0.255227, 0.191968, 0.160551, 0.140669, 0.124834, 0.115103, 0.105681, 0.099399, 0.092551, 0.088156, 0.082999, 0.080240, 0.076111, 0.073012, 0.071480, 0.068041, 0.065188, 0.063611, 0.062579, 0.059057, 0.057525, 0.056310, 0.055544, 0.053913}, {9.145098, 11.542642, 38.444059, 2.215191, 1.685763, 1.446827, 0.785224, 0.600837, 0.504202, 0.441256, 0.399798, 0.366120, 0.340445, 0.319289, 0.299703, 0.285555, 0.271096, 0.259854, 0.250297, 0.185038, 0.152457, 0.130736, 0.115380, 0.103652, 0.095467, 0.087519, 0.081429, 0.075389, 0.070460, 0.066910, 0.063430, 0.060366, 0.057555, 0.054277, 0.051492, 0.050459, 0.048013, 0.045600, 0.044636, 0.042930, 0.040863, 0.040592}, {9.130929, 11.496395, 38.553494, 2.213733, 1.686796, 1.444697, 0.773524, 0.587195, 0.491120, 0.427417, 0.383929, 0.349077, 0.322633, 0.300579, 0.282022, 0.265832, 0.250816, 0.239020, 0.228564, 0.160977, 0.124857, 0.103811, 0.088318, 0.078253, 0.068526, 0.061949, 0.056645, 0.051888, 0.047442, 0.044319, 0.042033, 0.038364, 0.036582, 0.034254, 0.032967, 0.030693, 0.029447, 0.027500, 0.027629, 0.025326, 0.023565, 0.024128}, {9.090881, 11.387960, 36.486987, 2.138348, 1.651012, 1.419899, 0.750984, 0.567105, 0.468460, 0.404457, 0.358641, 0.324854, 0.296326, 0.273723, 0.254571, 0.238595, 0.224091, 0.211870, 0.200157, 0.133642, 0.100628, 0.080240, 0.067621, 0.057301, 0.050274, 0.045249, 0.040040, 0.036396, 0.033308, 0.031502, 0.029914, 0.027198, 0.026498, 0.023856, 0.022186, 0.022131, 0.021086, 0.019331, 0.018129, 0.017506, 0.017330, 0.015956}, {8.495180, 10.051448, 30.876760, 1.985017, 1.581239, 1.371586, 0.722252, 0.536916, 0.439019, 0.374528, 0.328893, 0.293841, 0.266643, 0.243633, 0.224536, 0.209399, 0.195256, 0.183810, 0.174124, 0.110965, 0.081662, 0.064387, 0.053649, 0.045021, 0.040079, 0.034299, 0.031512, 0.028912, 0.025870, 0.023838, 0.022831, 0.021006, 0.020104, 0.018436, 0.016838, 0.016731, 0.016235, 0.015160, 0.013796, 0.013969, 0.012440, 0.012756}, {7.280436, 6.954720, 2.759347, 1.828208, 1.501224, 1.304616, 0.684929, 0.504954, 0.406041, 0.342880, 0.299160, 0.264531, 0.237149, 0.217317, 0.199300, 0.183890, 0.171015, 0.160512, 0.150267, 0.093537, 0.067263, 0.054102, 0.044438, 0.037667, 0.032276, 0.028385, 0.025535, 0.023194, 0.021282, 0.019795, 0.019279, 0.017462, 0.015565, 0.015138, 0.013917, 0.013269, 0.013570, 0.012332, 0.011480, 0.010412, 0.009803, 0.009744}, {6.044311, 4.464386, 2.270965, 1.683147, 1.408570, 1.231329, 0.647790, 0.469020, 0.374580, 0.313057, 0.270302, 0.238628, 0.213000, 0.192970, 0.176484, 0.162463, 0.150547, 0.139979, 0.130501, 0.079703, 0.057365, 0.045737, 0.036707, 0.031797, 0.027383, 0.024354, 0.022312, 0.020679, 0.017407, 0.016420, 0.014826, 0.014685, 0.013240, 0.012463, 0.012894, 0.010440, 0.010327, 0.009738, 0.009333, 0.009624, 0.008553, 0.009300}, {5.035575, 3.204568, 1.987774, 1.555399, 1.318778, 1.160449, 0.606904, 0.436103, 0.343434, 0.287311, 0.246226, 0.215142, 0.192055, 0.171639, 0.157195, 0.144339, 0.133287, 0.123859, 0.115028, 0.069635, 0.051185, 0.039354, 0.031507, 0.026961, 0.023131, 0.020698, 0.019201, 0.017478, 0.016249, 0.014521, 0.013224, 0.012654, 0.011854, 0.011207, 0.010067, 0.010211, 0.008342, 0.008700, 0.008625, 0.007851, 0.006954, 0.007121}, {4.237669, 2.575665, 1.795866, 1.443392, 1.233284, 1.092845, 0.570030, 0.404245, 0.316789, 0.262220, 0.223466, 0.194478, 0.172904, 0.155156, 0.141943, 0.130392, 0.120730, 0.111397, 0.102695, 0.063214, 0.045266, 0.033946, 0.028248, 0.024592, 0.020644, 0.018409, 0.016099, 0.014638, 0.013580, 0.012534, 0.011060, 0.010175, 0.009928, 0.009802, 0.009131, 0.008032, 0.008216, 0.006900, 0.007915, 0.007030, 0.006235, 0.006205}, {3.567612, 2.217888, 1.638238, 1.343229, 1.157161, 1.025149, 0.533331, 0.375971, 0.293297, 0.240604, 0.204908, 0.178419, 0.157993, 0.141526, 0.128039, 0.117845, 0.107844, 0.100090, 0.093206, 0.055927, 0.039632, 0.031419, 0.025441, 0.022017, 0.017970, 0.017046, 0.013781, 0.013837, 0.011788, 0.010844, 0.010719, 0.009848, 0.008781, 0.008666, 0.008390, 0.007383, 0.006704, 0.006690, 0.006704, 0.005597, 0.005315, 0.006187}, {3.025613, 1.971907, 1.508690, 1.253347, 1.085729, 0.964902, 0.500720, 0.350103, 0.270796, 0.222378, 0.189370, 0.163883, 0.144245, 0.129899, 0.117215, 0.106412, 0.098729, 0.091369, 0.084997, 0.050933, 0.035450, 0.028079, 0.022752, 0.019002, 0.016494, 0.014958, 0.013209, 0.011917, 0.010909, 0.011051, 0.009086, 0.008943, 0.008319, 0.007697, 0.007308, 0.006254, 0.006289, 0.006687, 0.005169, 0.005813, 0.005401, 0.005271}, {2.103528, 1.521551, 1.224627, 1.037122, 0.908020, 0.811763, 0.418322, 0.287979, 0.220201, 0.178456, 0.150544, 0.130941, 0.114658, 0.101290, 0.093054, 0.083796, 0.078241, 0.071278, 0.066739, 0.039318, 0.027836, 0.021947, 0.017540, 0.015152, 0.012936, 0.011566, 0.010478, 0.008942, 0.008706, 0.008533, 0.007591, 0.006950, 0.005415, 0.006408, 0.005202, 0.005010, 0.005253, 0.005104, 0.004322, 0.005458, 0.004121, 0.004314}, {1.536751, 1.182345, 0.975411, 0.837641, 0.736944, 0.660374, 0.337183, 0.229715, 0.174118, 0.140625, 0.118463, 0.102568, 0.089017, 0.079632, 0.072125, 0.066294, 0.059757, 0.055515, 0.051649, 0.030344, 0.020841, 0.016917, 0.013317, 0.011891, 0.010315, 0.008493, 0.007762, 0.006624, 0.007287, 0.006208, 0.005151, 0.005726, 0.004994, 0.004219, 0.004152, 0.003915, 0.003437, 0.003389, 0.003397, 0.002747, 0.002961, 0.003400}, {1.286577, 1.011802, 0.843325, 0.727349, 0.642881, 0.577038, 0.293274, 0.199210, 0.150758, 0.121809, 0.101102, 0.087423, 0.077013, 0.067438, 0.060997, 0.055508, 0.050853, 0.048553, 0.044361, 0.026014, 0.018513, 0.014217, 0.011612, 0.009604, 0.007862, 0.007154, 0.005997, 0.006527, 0.005605, 0.004194, 0.004040, 0.004002, 0.004299, 0.004607, 0.004030, 0.003770, 0.002902, 0.003709, 0.002591, 0.001857, 0.002333, 0.002402}}}; static y3_cluster::Interp2D const sig_interp; static y3_cluster::Interp2D const skews_interp; double _A = 0.0; double _B = 0.0; double _C = 0.0; double _sigma_intr = 0.0; double _epsilon = 0.0; double _z_pivot = 0.0; public: MOR_DES_t() = default; MOR_DES_t(double A, double B, double C, double sigma_i, double epsilon, double z_pivot) : _A(A) , _B(B) , _C(C) , _sigma_intr(sigma_i) , _epsilon(epsilon) , _z_pivot(z_pivot) {} explicit MOR_DES_t(cosmosis::DataBlock& sample) : _A(get_datablock<double>(sample, "cluster_abundance", "mor_A")) , _B(get_datablock<double>(sample, "cluster_abundance", "mor_B")) , _C(get_datablock<double>(sample, "cluster_abundance", "mor_alpha")) , _sigma_intr( get_datablock<double>(sample, "cluster_abundance", "mor_sigma")) , _epsilon( get_datablock<double>(sample, "cluster_abundance", "mor_epsilon")) , _z_pivot( get_datablock<double>(sample, "cluster_abundance", "z_mor_pivot")) {} double operator()(double lt, double lnM, double zt) const { // Now _lambda returns the evaluation of the eq.(9) of the // Matteo's paper, i.e., lambda_sat_given_M. 1. is a dummy // value for z. We are not using z here. double const ltm = pow((std::exp(lnM) - _A) / (_B - _A), _C) * pow((1.0 + zt) / (1.0 + _z_pivot), _epsilon); // Computing sigma from the interpolation // ltm is lambda_true_given_M; _sigma_intr is sigma_intrisic double const _sigma = sig_interp.clamp(_sigma_intr, ltm); double const _skw = skews_interp.clamp(_sigma_intr, ltm); // Eq. B1 of Matteo's paper, adding the normalization part double const x = lt - ltm; double const erfarg = -1.0 * _skw * (x) / (std::sqrt(2.) * _sigma); double const erfterm = std::erfc(erfarg); return y3_cluster::gaussian(x, 0.0, _sigma) * erfterm; } friend std::ostream& operator<<(std::ostream& os, MOR_DES_t const& m) { auto const old_flags = os.flags(); os << std::hexfloat; os << m._A << ' ' << m._B << ' ' << m._C << ' ' << m._sigma_intr << ' ' << m._epsilon << ' ' << m._z_pivot; os.flags(old_flags); return os; } friend std::istream& operator>>(std::istream& is, MOR_DES_t& m) { std::string buffer; std::getline(is, buffer); std::vector<double> vals_read = cosmosis::str_to_doubles(buffer); if (vals_read.size() == 6) { m._A = vals_read[0]; m._B = vals_read[1]; m._C = vals_read[2]; m._sigma_intr = vals_read[3]; m._epsilon = vals_read[4]; m._z_pivot = vals_read[5]; } else { is.setstate(std::ios_base::failbit); } return is; } }; } #endif
; A014018: Inverse of 9th cyclotomic polynomial. ; 1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1,0,0,-1,0,0,0 mod $0,9 mov $1,9 sub $1,$0 add $1,9 mov $2,9 lpb $0,1 fac $0 sub $0,5 mov $1,$2 add $2,1 lpe div $1,$2 sub $1,1
#pragma once #include "pch.hpp" #include "types.hpp" namespace nd::src::tools { class Scope final { public: using Event = func<void(const shared<logger>&, const str_v, const u64)>; Scope(const str_v, Event&&, Event&&) noexcept; ~Scope(); static void set(const shared<logger> logPtr) noexcept { assert(s_logPtr == nullptr); s_logPtr = logPtr; } private: static shared<logger> s_logPtr; static u64 s_depth; const Event onEnd_ {}; const str_v name_ {}; }; void onScopeBegin(const shared<logger>&, const str_v, const u64) noexcept; void onScopeEnd(const shared<logger>&, const str_v, const u64) noexcept; } // namespace nd::src::tools
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 University of Washington * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "simulator.h" #include "realtime-simulator-impl.h" #include "wall-clock-synchronizer.h" #include "scheduler.h" #include "event-impl.h" #include "synchronizer.h" #include "ptr.h" #include "pointer.h" #include "assert.h" #include "fatal-error.h" #include "log.h" #include "system-mutex.h" #include "boolean.h" #include "enum.h" #include <cmath> /** * \file * \ingroup realtime * ns3::RealTimeSimulatorImpl implementation. */ namespace ns3 { // Note: Logging in this file is largely avoided due to the // number of calls that are made to these functions and the possibility // of causing recursions leading to stack overflow NS_LOG_COMPONENT_DEFINE ("RealtimeSimulatorImpl"); NS_OBJECT_ENSURE_REGISTERED (RealtimeSimulatorImpl); TypeId RealtimeSimulatorImpl::GetTypeId (void) { static TypeId tid = TypeId ("ns3::RealtimeSimulatorImpl") .SetParent<SimulatorImpl> () .SetGroupName ("Core") .AddConstructor<RealtimeSimulatorImpl> () .AddAttribute ("SynchronizationMode", "What to do if the simulation cannot keep up with real time.", EnumValue (SYNC_BEST_EFFORT), MakeEnumAccessor (&RealtimeSimulatorImpl::SetSynchronizationMode), MakeEnumChecker (SYNC_BEST_EFFORT, "BestEffort", SYNC_HARD_LIMIT, "HardLimit")) .AddAttribute ("HardLimit", "Maximum acceptable real-time jitter (used in conjunction with SynchronizationMode=HardLimit)", TimeValue (Seconds (0.1)), MakeTimeAccessor (&RealtimeSimulatorImpl::m_hardLimit), MakeTimeChecker ()) ; return tid; } RealtimeSimulatorImpl::RealtimeSimulatorImpl () { NS_LOG_FUNCTION (this); m_stop = false; m_running = false; // uids are allocated from 4. // uid 0 is "invalid" events // uid 1 is "now" events // uid 2 is "destroy" events m_uid = 4; // before ::Run is entered, the m_currentUid will be zero m_currentUid = 0; m_currentTs = 0; m_currentContext = Simulator::NO_CONTEXT; m_unscheduledEvents = 0; m_main = SystemThread::Self(); // Be very careful not to do anything that would cause a change or assignment // of the underlying reference counts of m_synchronizer or you will be sorry. m_synchronizer = CreateObject<WallClockSynchronizer> (); } RealtimeSimulatorImpl::~RealtimeSimulatorImpl () { NS_LOG_FUNCTION (this); } void RealtimeSimulatorImpl::DoDispose (void) { NS_LOG_FUNCTION (this); while (!m_events->IsEmpty ()) { Scheduler::Event next = m_events->RemoveNext (); next.impl->Unref (); } m_events = 0; m_synchronizer = 0; SimulatorImpl::DoDispose (); } void RealtimeSimulatorImpl::Destroy () { NS_LOG_FUNCTION (this); // // This function is only called with the private version "disconnected" from // the main simulator functions. We rely on the user not calling // Simulator::Destroy while there is a chance that a worker thread could be // accessing the current instance of the private object. In practice this // means shutting down the workers and doing a Join() before calling the // Simulator::Destroy(). // while (m_destroyEvents.empty () == false) { Ptr<EventImpl> ev = m_destroyEvents.front ().PeekEventImpl (); m_destroyEvents.pop_front (); NS_LOG_LOGIC ("handle destroy " << ev); if (ev->IsCancelled () == false) { ev->Invoke (); } } } void RealtimeSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory) { NS_LOG_FUNCTION (this << schedulerFactory); Ptr<Scheduler> scheduler = schedulerFactory.Create<Scheduler> (); { CriticalSection cs (m_mutex); if (m_events != 0) { while (m_events->IsEmpty () == false) { Scheduler::Event next = m_events->RemoveNext (); scheduler->Insert (next); } } m_events = scheduler; } } void RealtimeSimulatorImpl::ProcessOneEvent (void) { // // The idea here is to wait until the next event comes due. In the case of // a realtime simulation, we want real time to be consumed between events. // It is the realtime synchronizer that causes real time to be consumed by // doing some kind of a wait. // // We need to be able to have external events (such as a packet reception event) // cause us to re-evaluate our state. The way this works is that the synchronizer // gets interrupted and returns. So, there is a possibility that things may change // out from under us dynamically. In this case, we need to re-evaluate how long to // wait in a for-loop until we have waited successfully (until a timeout) for the // event at the head of the event list. // // m_synchronizer->Synchronize will return true if the wait was completed without // interruption, otherwise it will return false indicating that something has changed // out from under us. If we sit in the for-loop trying to synchronize until // Synchronize() returns true, we will have successfully synchronized the execution // time of the next event with the wall clock time of the synchronizer. // for (;;) { uint64_t tsDelay = 0; uint64_t tsNext = 0; // // It is important to understand that m_currentTs is interpreted only as the // timestamp of the last event we executed. Current time can a bit of a // slippery concept in realtime mode. What we have here is a discrete event // simulator, so the last event is, by definition, executed entirely at a single // discrete time. This is the definition of m_currentTs. It really has // nothing to do with the current real time, except that we are trying to arrange // that at the instant of the beginning of event execution, the current real time // and m_currentTs coincide. // // We use tsNow as the indication of the current real time. // uint64_t tsNow; { CriticalSection cs (m_mutex); // // Since we are in realtime mode, the time to delay has got to be the // difference between the current realtime and the timestamp of the next // event. Since m_currentTs is actually the timestamp of the last event we // executed, it's not particularly meaningful for us here since real time has // certainly elapsed since it was last updated. // // It is possible that the current realtime has drifted past the next event // time so we need to be careful about that and not delay in that case. // NS_ASSERT_MSG (m_synchronizer->Realtime (), "RealtimeSimulatorImpl::ProcessOneEvent (): Synchronizer reports not Realtime ()"); // // tsNow is set to the normalized current real time. When the simulation was // started, the current real time was effectively set to zero; so tsNow is // the current "real" simulation time. // // tsNext is the simulation time of the next event we want to execute. // tsNow = m_synchronizer->GetCurrentRealtime (); tsNext = NextTs (); // // tsDelay is therefore the real time we need to delay in order to bring the // real time in sync with the simulation time. If we wait for this amount of // real time, we will accomplish moving the simulation time at the same rate // as the real time. This is typically called "pacing" the simulation time. // // We do have to be careful if we are falling behind. If so, tsDelay must be // zero. If we're late, don't dawdle. // if (tsNext <= tsNow) { tsDelay = 0; } else { tsDelay = tsNext - tsNow; } // // We've figured out how long we need to delay in order to pace the // simulation time with the real time. We're going to sleep, but need // to work with the synchronizer to make sure we're awakened if something // external happens (like a packet is received). This next line resets // the synchronizer so that any future event will cause it to interrupt. // m_synchronizer->SetCondition (false); } // // We have a time to delay. This time may actually not be valid anymore // since we released the critical section immediately above, and a real-time // ScheduleReal or ScheduleRealNow may have snuck in, well, between the // closing brace above and this comment so to speak. If this is the case, // that schedule operation will have done a synchronizer Signal() that // will set the condition variable to true and cause the Synchronize call // below to return immediately. // // It's easiest to understand if you just consider a short tsDelay that only // requires a SpinWait down in the synchronizer. What will happen is that // whan Synchronize calls SpinWait, SpinWait will look directly at its // condition variable. Note that we set this condition variable to false // inside the critical section above. // // SpinWait will go into a forever loop until either the time has expired or // until the condition variable becomes true. A true condition indicates that // the wait should stop. The condition is set to true by one of the Schedule // methods of the simulator; so if we are in a wait down in Synchronize, and // a Simulator::ScheduleReal is done, the wait down in Synchronize will exit and // Synchronize will return false. This means we have not actually synchronized // to the event expiration time. If no real-time schedule operation is done // while down in Synchronize, the wait will time out and Synchronize will return // true. This indicates that we have synchronized to the event time. // // So we need to stay in this for loop, looking for the next event timestamp and // attempting to sleep until its due. If we've slept until the timestamp is due, // Synchronize returns true and we break out of the sync loop. If an external // event happens that requires a re-schedule, Synchronize returns false and // we re-evaluate our timing by continuing in the loop. // // It is expected that tsDelay become shorter as external events interrupt our // waits. // if (m_synchronizer->Synchronize (tsNow, tsDelay)) { NS_LOG_LOGIC ("Interrupted ..."); break; } // // If we get to this point, we have been interrupted during a wait by a real-time // schedule operation. This means all bets are off regarding tsDelay and we need // to re-evaluate what it is we want to do. We'll loop back around in the // for-loop and start again from scratch. // } // // If we break out of the for-loop above, we have waited until the time specified // by the event that was at the head of the event list when we started the process. // Since there is a bunch of code that was executed outside a critical section (the // Synchronize call) we cannot be sure that the event at the head of the event list // is the one we think it is. What we can be sure of is that it is time to execute // whatever event is at the head of this list if the list is in time order. // Scheduler::Event next; { CriticalSection cs (m_mutex); // // We do know we're waiting for an event, so there had better be an event on the // event queue. Let's pull it off. When we release the critical section, the // event we're working on won't be on the list and so subsequent operations won't // mess with us. // NS_ASSERT_MSG (m_events->IsEmpty () == false, "RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty"); next = m_events->RemoveNext (); m_unscheduledEvents--; // // We cannot make any assumption that "next" is the same event we originally waited // for. We can only assume that only that it must be due and cannot cause time // to move backward. // NS_ASSERT_MSG (next.key.m_ts >= m_currentTs, "RealtimeSimulatorImpl::ProcessOneEvent(): " "next.GetTs() earlier than m_currentTs (list order error)"); NS_LOG_LOGIC ("handle " << next.key.m_ts); // // Update the current simulation time to be the timestamp of the event we're // executing. From the rest of the simulation's point of view, simulation time // is frozen until the next event is executed. // m_currentTs = next.key.m_ts; m_currentContext = next.key.m_context; m_currentUid = next.key.m_uid; // // We're about to run the event and we've done our best to synchronize this // event execution time to real time. Now, if we're in SYNC_HARD_LIMIT mode // we have to decide if we've done a good enough job and if we haven't, we've // been asked to commit ritual suicide. // // We check the simulation time against the current real time to make this // judgement. // if (m_synchronizationMode == SYNC_HARD_LIMIT) { uint64_t tsFinal = m_synchronizer->GetCurrentRealtime (); uint64_t tsJitter; if (tsFinal >= m_currentTs) { tsJitter = tsFinal - m_currentTs; } else { tsJitter = m_currentTs - tsFinal; } if (tsJitter > static_cast<uint64_t> (m_hardLimit.GetTimeStep ())) { NS_FATAL_ERROR ("RealtimeSimulatorImpl::ProcessOneEvent (): " "Hard real-time limit exceeded (jitter = " << tsJitter << ")"); } } } // // We have got the event we're about to execute completely disentangled from the // event list so we can execute it outside a critical section without fear of someone // changing things out from under us. EventImpl *event = next.impl; m_synchronizer->EventStart (); event->Invoke (); m_synchronizer->EventEnd (); event->Unref (); } bool RealtimeSimulatorImpl::IsFinished (void) const { bool rc; { CriticalSection cs (m_mutex); rc = m_events->IsEmpty () || m_stop; } return rc; } // // Peeks into event list. Should be called with critical section locked. // uint64_t RealtimeSimulatorImpl::NextTs (void) const { NS_ASSERT_MSG (m_events->IsEmpty () == false, "RealtimeSimulatorImpl::NextTs(): event queue is empty"); Scheduler::Event ev = m_events->PeekNext (); return ev.key.m_ts; } void RealtimeSimulatorImpl::Run (void) { NS_LOG_FUNCTION (this); NS_ASSERT_MSG (m_running == false, "RealtimeSimulatorImpl::Run(): Simulator already running"); // Set the current threadId as the main threadId m_main = SystemThread::Self(); m_stop = false; m_running = true; m_synchronizer->SetOrigin (m_currentTs); // Sleep until signalled uint64_t tsNow = 0; uint64_t tsDelay = 1000000000; // wait time of 1 second (in nanoseconds) while (!m_stop) { bool process = false; { CriticalSection cs (m_mutex); if (!m_events->IsEmpty ()) { process = true; } else { // Get current timestamp while holding the critical section tsNow = m_synchronizer->GetCurrentRealtime (); } } if (!process) { // Sleep until signalled tsNow = m_synchronizer->Synchronize (tsNow, tsDelay); // Re-check event queue continue; } ProcessOneEvent (); } // // If the simulator stopped naturally by lack of events, make a // consistency test to check that we didn't lose any events along the way. // { CriticalSection cs (m_mutex); NS_ASSERT_MSG (m_events->IsEmpty () == false || m_unscheduledEvents == 0, "RealtimeSimulatorImpl::Run(): Empty queue and unprocessed events"); } m_running = false; } bool RealtimeSimulatorImpl::Running (void) const { return m_running; } bool RealtimeSimulatorImpl::Realtime (void) const { return m_synchronizer->Realtime (); } void RealtimeSimulatorImpl::Stop (void) { NS_LOG_FUNCTION (this); m_stop = true; } void RealtimeSimulatorImpl::Stop (Time const &delay) { NS_LOG_FUNCTION (this << delay); Simulator::Schedule (delay, &Simulator::Stop); } // // Schedule an event for a _relative_ time in the future. // EventId RealtimeSimulatorImpl::Schedule (Time const &delay, EventImpl *impl) { NS_LOG_FUNCTION (this << delay << impl); Scheduler::Event ev; { CriticalSection cs (m_mutex); // // This is the reason we had to bring the absolute time calculation in from the // simulator.h into the implementation. Since the implementations may be // multi-threaded, we need this calculation to be atomic. You can see it is // here since we are running in a CriticalSection. // Time tAbsolute = Simulator::Now () + delay; NS_ASSERT_MSG (delay.IsPositive (), "RealtimeSimulatorImpl::Schedule(): Negative delay"); ev.impl = impl; ev.key.m_ts = (uint64_t) tAbsolute.GetTimeStep (); ev.key.m_context = GetContext (); ev.key.m_uid = m_uid; m_uid++; m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } return EventId (impl, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); } void RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *impl) { NS_LOG_FUNCTION (this << context << delay << impl); { CriticalSection cs (m_mutex); uint64_t ts; if (SystemThread::Equals (m_main)) { ts = m_currentTs + delay.GetTimeStep (); } else { // // If the simulator is running, we're pacing and have a meaningful // realtime clock. If we're not, then m_currentTs is where we stopped. // ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs; ts += delay.GetTimeStep (); } NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtime(): schedule for time < m_currentTs"); Scheduler::Event ev; ev.impl = impl; ev.key.m_ts = ts; ev.key.m_context = context; ev.key.m_uid = m_uid; m_uid++; m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } } EventId RealtimeSimulatorImpl::ScheduleNow (EventImpl *impl) { NS_LOG_FUNCTION (this << impl); Scheduler::Event ev; { CriticalSection cs (m_mutex); ev.impl = impl; ev.key.m_ts = m_currentTs; ev.key.m_context = GetContext (); ev.key.m_uid = m_uid; m_uid++; m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } return EventId (impl, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); } Time RealtimeSimulatorImpl::Now (void) const { return TimeStep (m_currentTs); } // // Schedule an event for a _relative_ time in the future. // void RealtimeSimulatorImpl::ScheduleRealtimeWithContext (uint32_t context, Time const &time, EventImpl *impl) { NS_LOG_FUNCTION (this << context << time << impl); { CriticalSection cs (m_mutex); uint64_t ts = m_synchronizer->GetCurrentRealtime () + time.GetTimeStep (); NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtime(): schedule for time < m_currentTs"); Scheduler::Event ev; ev.impl = impl; ev.key.m_ts = ts; ev.key.m_uid = m_uid; m_uid++; m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } } void RealtimeSimulatorImpl::ScheduleRealtime (Time const &time, EventImpl *impl) { NS_LOG_FUNCTION (this << time << impl); ScheduleRealtimeWithContext (GetContext (), time, impl); } void RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext (uint32_t context, EventImpl *impl) { NS_LOG_FUNCTION (this << context << impl); { CriticalSection cs (m_mutex); // // If the simulator is running, we're pacing and have a meaningful // realtime clock. If we're not, then m_currentTs is were we stopped. // uint64_t ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs; NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext(): schedule for time < m_currentTs"); Scheduler::Event ev; ev.impl = impl; ev.key.m_ts = ts; ev.key.m_uid = m_uid; ev.key.m_context = context; m_uid++; m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } } void RealtimeSimulatorImpl::ScheduleRealtimeNow (EventImpl *impl) { NS_LOG_FUNCTION (this << impl); ScheduleRealtimeNowWithContext (GetContext (), impl); } Time RealtimeSimulatorImpl::RealtimeNow (void) const { return TimeStep (m_synchronizer->GetCurrentRealtime ()); } EventId RealtimeSimulatorImpl::ScheduleDestroy (EventImpl *impl) { NS_LOG_FUNCTION (this << impl); EventId id; { CriticalSection cs (m_mutex); // // Time doesn't really matter here (especially in realtime mode). It is // overridden by the uid of 2 which identifies this as an event to be // executed at Simulator::Destroy time. // id = EventId (Ptr<EventImpl> (impl, false), m_currentTs, 0xffffffff, 2); m_destroyEvents.push_back (id); m_uid++; } return id; } Time RealtimeSimulatorImpl::GetDelayLeft (const EventId &id) const { // // If the event has expired, there is no delay until it runs. It is not the // case that there is a negative time until it runs. // if (IsExpired (id)) { return TimeStep (0); } return TimeStep (id.GetTs () - m_currentTs); } void RealtimeSimulatorImpl::Remove (const EventId &id) { if (id.GetUid () == 2) { // destroy events. for (DestroyEvents::iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++) { if (*i == id) { m_destroyEvents.erase (i); break; } } return; } if (IsExpired (id)) { return; } { CriticalSection cs (m_mutex); Scheduler::Event event; event.impl = id.PeekEventImpl (); event.key.m_ts = id.GetTs (); event.key.m_context = id.GetContext (); event.key.m_uid = id.GetUid (); m_events->Remove (event); m_unscheduledEvents--; event.impl->Cancel (); event.impl->Unref (); } } void RealtimeSimulatorImpl::Cancel (const EventId &id) { if (IsExpired (id) == false) { id.PeekEventImpl ()->Cancel (); } } bool RealtimeSimulatorImpl::IsExpired (const EventId &id) const { if (id.GetUid () == 2) { if (id.PeekEventImpl () == 0 || id.PeekEventImpl ()->IsCancelled ()) { return true; } // destroy events. for (DestroyEvents::const_iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++) { if (*i == id) { return false; } } return true; } // // If the time of the event is less than the current timestamp of the // simulator, the simulator has gone past the invocation time of the // event, so the statement ev.GetTs () < m_currentTs does mean that // the event has been fired even in realtime mode. // // The same is true for the next line involving the m_currentUid. // if (id.PeekEventImpl () == 0 || id.GetTs () < m_currentTs || (id.GetTs () == m_currentTs && id.GetUid () <= m_currentUid) || id.PeekEventImpl ()->IsCancelled ()) { return true; } else { return false; } } Time RealtimeSimulatorImpl::GetMaximumSimulationTime (void) const { return TimeStep (0x7fffffffffffffffLL); } // System ID for non-distributed simulation is always zero uint32_t RealtimeSimulatorImpl::GetSystemId (void) const { return 0; } uint32_t RealtimeSimulatorImpl::GetContext (void) const { return m_currentContext; } void RealtimeSimulatorImpl::SetSynchronizationMode (enum SynchronizationMode mode) { NS_LOG_FUNCTION (this << mode); m_synchronizationMode = mode; } RealtimeSimulatorImpl::SynchronizationMode RealtimeSimulatorImpl::GetSynchronizationMode (void) const { NS_LOG_FUNCTION (this); return m_synchronizationMode; } void RealtimeSimulatorImpl::SetHardLimit (Time limit) { NS_LOG_FUNCTION (this << limit); m_hardLimit = limit; } Time RealtimeSimulatorImpl::GetHardLimit (void) const { NS_LOG_FUNCTION (this); return m_hardLimit; } } // namespace ns3
// // Created by Baoxing song on 2019-01-08. // #include "Node.h" Node::Node(int _v, int _w){ v = _v; weight = _w; } int Node::getV(){ return v; } int Node::getWeight() { return weight; }
_tstsjf: file format elf32-i386 Disassembly of section .text: 00000000 <main>: argv[3]=minp_runtime argv[4]=maxp_runtime arg[5]=maxnum_processes */ int main ( int argc, char *argv[] ){ 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 57 push %edi 4: 56 push %esi 5: 53 push %ebx 6: 83 e4 f0 and $0xfffffff0,%esp 9: 83 ec 20 sub $0x20,%esp c: 8b 5d 0c mov 0xc(%ebp),%ebx int i; int minp_time, maxp_time, minp_runtime, maxp_runtime, maxnum_processes; minp_time=atoi(argv[1]); f: 8b 43 04 mov 0x4(%ebx),%eax 12: 89 04 24 mov %eax,(%esp) 15: e8 86 03 00 00 call 3a0 <atoi> 1a: 89 c6 mov %eax,%esi 1c: 89 44 24 18 mov %eax,0x18(%esp) maxp_time=atoi(argv[2]); 20: 8b 43 08 mov 0x8(%ebx),%eax 23: 89 04 24 mov %eax,(%esp) 26: e8 75 03 00 00 call 3a0 <atoi> 2b: 89 c7 mov %eax,%edi minp_runtime=atoi(argv[3]); 2d: 8b 43 0c mov 0xc(%ebx),%eax maxp_runtime=atoi(argv[4]); maxnum_processes=atoi(argv[5]); //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); int inittime=(minp_time+random(maxp_time-minp_time)); 30: 29 f7 sub %esi,%edi int i; int minp_time, maxp_time, minp_runtime, maxp_runtime, maxnum_processes; minp_time=atoi(argv[1]); maxp_time=atoi(argv[2]); minp_runtime=atoi(argv[3]); 32: 89 04 24 mov %eax,(%esp) 35: e8 66 03 00 00 call 3a0 <atoi> 3a: 89 44 24 10 mov %eax,0x10(%esp) maxp_runtime=atoi(argv[4]); 3e: 8b 43 10 mov 0x10(%ebx),%eax 41: 89 04 24 mov %eax,(%esp) 44: e8 57 03 00 00 call 3a0 <atoi> 49: 89 44 24 0c mov %eax,0xc(%esp) maxnum_processes=atoi(argv[5]); 4d: 8b 43 14 mov 0x14(%ebx),%eax //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); int inittime=(minp_time+random(maxp_time-minp_time)); //printf(1,"inittime=%d\n",inittime); //INITTIME PRINT sleep((int)(1000*inittime/15)); for(i=0;i<maxnum_processes;i++){ //reference: init.c 50: 31 db xor %ebx,%ebx int minp_time, maxp_time, minp_runtime, maxp_runtime, maxnum_processes; minp_time=atoi(argv[1]); maxp_time=atoi(argv[2]); minp_runtime=atoi(argv[3]); maxp_runtime=atoi(argv[4]); maxnum_processes=atoi(argv[5]); 52: 89 04 24 mov %eax,(%esp) 55: e8 46 03 00 00 call 3a0 <atoi> 5a: 89 44 24 1c mov %eax,0x1c(%esp) //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); 5e: e8 37 04 00 00 call 49a <uptime> int inittime=(minp_time+random(maxp_time-minp_time)); 63: 89 3c 24 mov %edi,(%esp) minp_runtime=atoi(argv[3]); maxp_runtime=atoi(argv[4]); maxnum_processes=atoi(argv[5]); //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); 66: 89 44 24 14 mov %eax,0x14(%esp) int inittime=(minp_time+random(maxp_time-minp_time)); 6a: e8 33 04 00 00 call 4a2 <random> //printf(1,"inittime=%d\n",inittime); //INITTIME PRINT sleep((int)(1000*inittime/15)); 6f: ba 89 88 88 88 mov $0x88888889,%edx maxp_runtime=atoi(argv[4]); maxnum_processes=atoi(argv[5]); //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); int inittime=(minp_time+random(maxp_time-minp_time)); 74: 8d 0c 30 lea (%eax,%esi,1),%ecx //printf(1,"inittime=%d\n",inittime); //INITTIME PRINT sleep((int)(1000*inittime/15)); 77: 69 c9 e8 03 00 00 imul $0x3e8,%ecx,%ecx 7d: 89 c8 mov %ecx,%eax 7f: f7 ea imul %edx 81: 01 ca add %ecx,%edx 83: c1 fa 03 sar $0x3,%edx 86: c1 f9 1f sar $0x1f,%ecx 89: 29 ca sub %ecx,%edx 8b: 89 14 24 mov %edx,(%esp) 8e: e8 ff 03 00 00 call 492 <sleep> for(i=0;i<maxnum_processes;i++){ //reference: init.c 93: 8b 44 24 1c mov 0x1c(%esp),%eax 97: 85 c0 test %eax,%eax 99: 7e 7d jle 118 <main+0x118> 9b: 90 nop 9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int pid=fork(); a0: e8 55 03 00 00 call 3fa <fork> if(pid < 0){ a5: 85 c0 test %eax,%eax a7: 0f 88 bb 00 00 00 js 168 <main+0x168> ad: 8d 76 00 lea 0x0(%esi),%esi printf(1, "init: fork failed\n"); exit(); } if(pid == 0){ b0: 0f 84 cb 00 00 00 je 181 <main+0x181> } if(pid>0){ //while((wpid=wait())>0 && wpid!=pid) //printf(1, "zombie!\n"); //parent gonna sleep until the next proc is to be generated signalinfo(getpid(),10); b6: e8 c7 03 00 00 call 482 <getpid> //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); int inittime=(minp_time+random(maxp_time-minp_time)); //printf(1,"inittime=%d\n",inittime); //INITTIME PRINT sleep((int)(1000*inittime/15)); for(i=0;i<maxnum_processes;i++){ //reference: init.c bb: 83 c3 01 add $0x1,%ebx } if(pid>0){ //while((wpid=wait())>0 && wpid!=pid) //printf(1, "zombie!\n"); //parent gonna sleep until the next proc is to be generated signalinfo(getpid(),10); be: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) c5: 00 c6: 89 04 24 mov %eax,(%esp) c9: e8 e4 03 00 00 call 4b2 <signalinfo> int sleeptime=(minp_time+random(maxp_time-minp_time)); ce: 89 3c 24 mov %edi,(%esp) d1: e8 cc 03 00 00 call 4a2 <random> d6: 8b 4c 24 18 mov 0x18(%esp),%ecx //printf(1,"parent sleeptime=%d\n",sleeptime); //PARENT SLEEPTIME (time btw process generation) printf(1,"parent!"); da: c7 44 24 04 f6 08 00 movl $0x8f6,0x4(%esp) e1: 00 e2: c7 04 24 01 00 00 00 movl $0x1,(%esp) if(pid>0){ //while((wpid=wait())>0 && wpid!=pid) //printf(1, "zombie!\n"); //parent gonna sleep until the next proc is to be generated signalinfo(getpid(),10); int sleeptime=(minp_time+random(maxp_time-minp_time)); e9: 8d 34 08 lea (%eax,%ecx,1),%esi //printf(1,"parent sleeptime=%d\n",sleeptime); //PARENT SLEEPTIME (time btw process generation) printf(1,"parent!"); sleep((int)(1000*sleeptime/15)); ec: 69 f6 e8 03 00 00 imul $0x3e8,%esi,%esi //printf(1, "zombie!\n"); //parent gonna sleep until the next proc is to be generated signalinfo(getpid(),10); int sleeptime=(minp_time+random(maxp_time-minp_time)); //printf(1,"parent sleeptime=%d\n",sleeptime); //PARENT SLEEPTIME (time btw process generation) printf(1,"parent!"); f2: e8 79 04 00 00 call 570 <printf> sleep((int)(1000*sleeptime/15)); f7: b8 89 88 88 88 mov $0x88888889,%eax fc: f7 ee imul %esi fe: 01 f2 add %esi,%edx 100: c1 fa 03 sar $0x3,%edx 103: c1 fe 1f sar $0x1f,%esi 106: 29 f2 sub %esi,%edx 108: 89 14 24 mov %edx,(%esp) 10b: e8 82 03 00 00 call 492 <sleep> //char *list[] = { "sleep_sec", "1", 0 }; int init_ticks=uptime(); int inittime=(minp_time+random(maxp_time-minp_time)); //printf(1,"inittime=%d\n",inittime); //INITTIME PRINT sleep((int)(1000*inittime/15)); for(i=0;i<maxnum_processes;i++){ //reference: init.c 110: 3b 5c 24 1c cmp 0x1c(%esp),%ebx 114: 75 8a jne a0 <main+0xa0> 116: 66 90 xchg %ax,%ax } /* for(i=0;i<maxnum_processes;i++) //instead of wait in the parent, let the parent sleep for required time and use this loop { wait(); }*/ while(wait()>0); //busy wait as long as there remain children 118: e8 ed 02 00 00 call 40a <wait> 11d: 85 c0 test %eax,%eax 11f: 90 nop 120: 7f f6 jg 118 <main+0x118> int final_ticks=uptime(); 122: e8 73 03 00 00 call 49a <uptime> printf(1,"Total execution time in seconds = %d\n",15*(final_ticks-init_ticks)/1000); 127: ba d3 4d 62 10 mov $0x10624dd3,%edx 12c: c7 44 24 04 00 09 00 movl $0x900,0x4(%esp) 133: 00 134: c7 04 24 01 00 00 00 movl $0x1,(%esp) 13b: 2b 44 24 14 sub 0x14(%esp),%eax 13f: 89 c1 mov %eax,%ecx 141: c1 e1 04 shl $0x4,%ecx 144: 29 c1 sub %eax,%ecx 146: 89 c8 mov %ecx,%eax 148: f7 ea imul %edx 14a: c1 f9 1f sar $0x1f,%ecx 14d: c1 fa 06 sar $0x6,%edx 150: 29 ca sub %ecx,%edx 152: 89 54 24 08 mov %edx,0x8(%esp) 156: e8 15 04 00 00 call 570 <printf> return 1; } 15b: 8d 65 f4 lea -0xc(%ebp),%esp 15e: b8 01 00 00 00 mov $0x1,%eax 163: 5b pop %ebx 164: 5e pop %esi 165: 5f pop %edi 166: 5d pop %ebp 167: c3 ret sleep((int)(1000*inittime/15)); for(i=0;i<maxnum_processes;i++){ //reference: init.c int pid=fork(); if(pid < 0){ printf(1, "init: fork failed\n"); 168: c7 44 24 04 d8 08 00 movl $0x8d8,0x4(%esp) 16f: 00 170: c7 04 24 01 00 00 00 movl $0x1,(%esp) 177: e8 f4 03 00 00 call 570 <printf> exit(); 17c: e8 81 02 00 00 call 402 <exit> } if(pid == 0){ int runtime=(minp_runtime+random(maxp_runtime-minp_runtime)); 181: 8b 5c 24 10 mov 0x10(%esp),%ebx 185: 8b 44 24 0c mov 0xc(%esp),%eax 189: 29 d8 sub %ebx,%eax 18b: 89 04 24 mov %eax,(%esp) 18e: e8 0f 03 00 00 call 4a2 <random> 193: 01 c3 add %eax,%ebx //printf(1,"runtime=%d\n",runtime); //CHILD RUNTIME PRINT signalinfo(getpid(),runtime); 195: e8 e8 02 00 00 call 482 <getpid> 19a: 89 5c 24 04 mov %ebx,0x4(%esp) 19e: 89 04 24 mov %eax,(%esp) 1a1: e8 0c 03 00 00 call 4b2 <signalinfo> sleep((int)(1000*runtime/15)); //sleep for a randomly chosen runtime 1a6: 69 c3 e8 03 00 00 imul $0x3e8,%ebx,%eax 1ac: b9 0f 00 00 00 mov $0xf,%ecx 1b1: 99 cltd 1b2: f7 f9 idiv %ecx 1b4: 89 04 24 mov %eax,(%esp) 1b7: e8 d6 02 00 00 call 492 <sleep> //exec("sleep_sec", list); //printf(1, "init: exec sleep_sec failed\n"); printf(1,"Child %d \n",getpid()); 1bc: e8 c1 02 00 00 call 482 <getpid> 1c1: c7 44 24 04 eb 08 00 movl $0x8eb,0x4(%esp) 1c8: 00 1c9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1d0: 89 44 24 08 mov %eax,0x8(%esp) 1d4: e8 97 03 00 00 call 570 <printf> exit(); 1d9: e8 24 02 00 00 call 402 <exit> 1de: 66 90 xchg %ax,%ax 000001e0 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 8b 45 08 mov 0x8(%ebp),%eax 1e6: 8b 4d 0c mov 0xc(%ebp),%ecx 1e9: 53 push %ebx char *os; os = s; while((*s++ = *t++) != 0) 1ea: 89 c2 mov %eax,%edx 1ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1f0: 83 c1 01 add $0x1,%ecx 1f3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 1f7: 83 c2 01 add $0x1,%edx 1fa: 84 db test %bl,%bl 1fc: 88 5a ff mov %bl,-0x1(%edx) 1ff: 75 ef jne 1f0 <strcpy+0x10> ; return os; } 201: 5b pop %ebx 202: 5d pop %ebp 203: c3 ret 204: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 20a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000210 <strcmp>: int strcmp(const char *p, const char *q) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 8b 55 08 mov 0x8(%ebp),%edx 216: 53 push %ebx 217: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 21a: 0f b6 02 movzbl (%edx),%eax 21d: 84 c0 test %al,%al 21f: 74 2d je 24e <strcmp+0x3e> 221: 0f b6 19 movzbl (%ecx),%ebx 224: 38 d8 cmp %bl,%al 226: 74 0e je 236 <strcmp+0x26> 228: eb 2b jmp 255 <strcmp+0x45> 22a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 230: 38 c8 cmp %cl,%al 232: 75 15 jne 249 <strcmp+0x39> p++, q++; 234: 89 d9 mov %ebx,%ecx 236: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 239: 0f b6 02 movzbl (%edx),%eax p++, q++; 23c: 8d 59 01 lea 0x1(%ecx),%ebx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 23f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx 243: 84 c0 test %al,%al 245: 75 e9 jne 230 <strcmp+0x20> 247: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 249: 29 c8 sub %ecx,%eax } 24b: 5b pop %ebx 24c: 5d pop %ebp 24d: c3 ret 24e: 0f b6 09 movzbl (%ecx),%ecx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 251: 31 c0 xor %eax,%eax 253: eb f4 jmp 249 <strcmp+0x39> 255: 0f b6 cb movzbl %bl,%ecx 258: eb ef jmp 249 <strcmp+0x39> 25a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000260 <strlen>: return (uchar)*p - (uchar)*q; } uint strlen(char *s) { 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 266: 80 39 00 cmpb $0x0,(%ecx) 269: 74 12 je 27d <strlen+0x1d> 26b: 31 d2 xor %edx,%edx 26d: 8d 76 00 lea 0x0(%esi),%esi 270: 83 c2 01 add $0x1,%edx 273: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 277: 89 d0 mov %edx,%eax 279: 75 f5 jne 270 <strlen+0x10> ; return n; } 27b: 5d pop %ebp 27c: c3 ret uint strlen(char *s) { int n; for(n = 0; s[n]; n++) 27d: 31 c0 xor %eax,%eax ; return n; } 27f: 5d pop %ebp 280: c3 ret 281: eb 0d jmp 290 <memset> 283: 90 nop 284: 90 nop 285: 90 nop 286: 90 nop 287: 90 nop 288: 90 nop 289: 90 nop 28a: 90 nop 28b: 90 nop 28c: 90 nop 28d: 90 nop 28e: 90 nop 28f: 90 nop 00000290 <memset>: void* memset(void *dst, int c, uint n) { 290: 55 push %ebp 291: 89 e5 mov %esp,%ebp 293: 8b 55 08 mov 0x8(%ebp),%edx 296: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 297: 8b 4d 10 mov 0x10(%ebp),%ecx 29a: 8b 45 0c mov 0xc(%ebp),%eax 29d: 89 d7 mov %edx,%edi 29f: fc cld 2a0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 2a2: 89 d0 mov %edx,%eax 2a4: 5f pop %edi 2a5: 5d pop %ebp 2a6: c3 ret 2a7: 89 f6 mov %esi,%esi 2a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002b0 <strchr>: char* strchr(const char *s, char c) { 2b0: 55 push %ebp 2b1: 89 e5 mov %esp,%ebp 2b3: 8b 45 08 mov 0x8(%ebp),%eax 2b6: 53 push %ebx 2b7: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 2ba: 0f b6 18 movzbl (%eax),%ebx 2bd: 84 db test %bl,%bl 2bf: 74 1d je 2de <strchr+0x2e> if(*s == c) 2c1: 38 d3 cmp %dl,%bl 2c3: 89 d1 mov %edx,%ecx 2c5: 75 0d jne 2d4 <strchr+0x24> 2c7: eb 17 jmp 2e0 <strchr+0x30> 2c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2d0: 38 ca cmp %cl,%dl 2d2: 74 0c je 2e0 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 2d4: 83 c0 01 add $0x1,%eax 2d7: 0f b6 10 movzbl (%eax),%edx 2da: 84 d2 test %dl,%dl 2dc: 75 f2 jne 2d0 <strchr+0x20> if(*s == c) return (char*)s; return 0; 2de: 31 c0 xor %eax,%eax } 2e0: 5b pop %ebx 2e1: 5d pop %ebp 2e2: c3 ret 2e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 2e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002f0 <gets>: char* gets(char *buf, int max) { 2f0: 55 push %ebp 2f1: 89 e5 mov %esp,%ebp 2f3: 57 push %edi 2f4: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 2f5: 31 f6 xor %esi,%esi return 0; } char* gets(char *buf, int max) { 2f7: 53 push %ebx 2f8: 83 ec 2c sub $0x2c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ cc = read(0, &c, 1); 2fb: 8d 7d e7 lea -0x19(%ebp),%edi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 2fe: eb 31 jmp 331 <gets+0x41> cc = read(0, &c, 1); 300: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 307: 00 308: 89 7c 24 04 mov %edi,0x4(%esp) 30c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 313: e8 02 01 00 00 call 41a <read> if(cc < 1) 318: 85 c0 test %eax,%eax 31a: 7e 1d jle 339 <gets+0x49> break; buf[i++] = c; 31c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 320: 89 de mov %ebx,%esi cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 322: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 325: 3c 0d cmp $0xd,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 327: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 32b: 74 0c je 339 <gets+0x49> 32d: 3c 0a cmp $0xa,%al 32f: 74 08 je 339 <gets+0x49> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 331: 8d 5e 01 lea 0x1(%esi),%ebx 334: 3b 5d 0c cmp 0xc(%ebp),%ebx 337: 7c c7 jl 300 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 339: 8b 45 08 mov 0x8(%ebp),%eax 33c: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 340: 83 c4 2c add $0x2c,%esp 343: 5b pop %ebx 344: 5e pop %esi 345: 5f pop %edi 346: 5d pop %ebp 347: c3 ret 348: 90 nop 349: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000350 <stat>: int stat(char *n, struct stat *st) { 350: 55 push %ebp 351: 89 e5 mov %esp,%ebp 353: 56 push %esi 354: 53 push %ebx 355: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 358: 8b 45 08 mov 0x8(%ebp),%eax 35b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 362: 00 363: 89 04 24 mov %eax,(%esp) 366: e8 d7 00 00 00 call 442 <open> if(fd < 0) 36b: 85 c0 test %eax,%eax stat(char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 36d: 89 c3 mov %eax,%ebx if(fd < 0) 36f: 78 27 js 398 <stat+0x48> return -1; r = fstat(fd, st); 371: 8b 45 0c mov 0xc(%ebp),%eax 374: 89 1c 24 mov %ebx,(%esp) 377: 89 44 24 04 mov %eax,0x4(%esp) 37b: e8 da 00 00 00 call 45a <fstat> close(fd); 380: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 383: 89 c6 mov %eax,%esi close(fd); 385: e8 a0 00 00 00 call 42a <close> return r; 38a: 89 f0 mov %esi,%eax } 38c: 83 c4 10 add $0x10,%esp 38f: 5b pop %ebx 390: 5e pop %esi 391: 5d pop %ebp 392: c3 ret 393: 90 nop 394: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 398: b8 ff ff ff ff mov $0xffffffff,%eax 39d: eb ed jmp 38c <stat+0x3c> 39f: 90 nop 000003a0 <atoi>: return r; } int atoi(const char *s) { 3a0: 55 push %ebp 3a1: 89 e5 mov %esp,%ebp 3a3: 8b 4d 08 mov 0x8(%ebp),%ecx 3a6: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 3a7: 0f be 11 movsbl (%ecx),%edx 3aa: 8d 42 d0 lea -0x30(%edx),%eax 3ad: 3c 09 cmp $0x9,%al int atoi(const char *s) { int n; n = 0; 3af: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 3b4: 77 17 ja 3cd <atoi+0x2d> 3b6: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 3b8: 83 c1 01 add $0x1,%ecx 3bb: 8d 04 80 lea (%eax,%eax,4),%eax 3be: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3c2: 0f be 11 movsbl (%ecx),%edx 3c5: 8d 5a d0 lea -0x30(%edx),%ebx 3c8: 80 fb 09 cmp $0x9,%bl 3cb: 76 eb jbe 3b8 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 3cd: 5b pop %ebx 3ce: 5d pop %ebp 3cf: c3 ret 000003d0 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3d0: 55 push %ebp char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 3d1: 31 d2 xor %edx,%edx return n; } void* memmove(void *vdst, void *vsrc, int n) { 3d3: 89 e5 mov %esp,%ebp 3d5: 56 push %esi 3d6: 8b 45 08 mov 0x8(%ebp),%eax 3d9: 53 push %ebx 3da: 8b 5d 10 mov 0x10(%ebp),%ebx 3dd: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 3e0: 85 db test %ebx,%ebx 3e2: 7e 12 jle 3f6 <memmove+0x26> 3e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 3e8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 3ec: 88 0c 10 mov %cl,(%eax,%edx,1) 3ef: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 3f2: 39 da cmp %ebx,%edx 3f4: 75 f2 jne 3e8 <memmove+0x18> *dst++ = *src++; return vdst; } 3f6: 5b pop %ebx 3f7: 5e pop %esi 3f8: 5d pop %ebp 3f9: c3 ret 000003fa <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3fa: b8 01 00 00 00 mov $0x1,%eax 3ff: cd 40 int $0x40 401: c3 ret 00000402 <exit>: SYSCALL(exit) 402: b8 02 00 00 00 mov $0x2,%eax 407: cd 40 int $0x40 409: c3 ret 0000040a <wait>: SYSCALL(wait) 40a: b8 03 00 00 00 mov $0x3,%eax 40f: cd 40 int $0x40 411: c3 ret 00000412 <pipe>: SYSCALL(pipe) 412: b8 04 00 00 00 mov $0x4,%eax 417: cd 40 int $0x40 419: c3 ret 0000041a <read>: SYSCALL(read) 41a: b8 05 00 00 00 mov $0x5,%eax 41f: cd 40 int $0x40 421: c3 ret 00000422 <write>: SYSCALL(write) 422: b8 10 00 00 00 mov $0x10,%eax 427: cd 40 int $0x40 429: c3 ret 0000042a <close>: SYSCALL(close) 42a: b8 15 00 00 00 mov $0x15,%eax 42f: cd 40 int $0x40 431: c3 ret 00000432 <kill>: SYSCALL(kill) 432: b8 06 00 00 00 mov $0x6,%eax 437: cd 40 int $0x40 439: c3 ret 0000043a <exec>: SYSCALL(exec) 43a: b8 07 00 00 00 mov $0x7,%eax 43f: cd 40 int $0x40 441: c3 ret 00000442 <open>: SYSCALL(open) 442: b8 0f 00 00 00 mov $0xf,%eax 447: cd 40 int $0x40 449: c3 ret 0000044a <mknod>: SYSCALL(mknod) 44a: b8 11 00 00 00 mov $0x11,%eax 44f: cd 40 int $0x40 451: c3 ret 00000452 <unlink>: SYSCALL(unlink) 452: b8 12 00 00 00 mov $0x12,%eax 457: cd 40 int $0x40 459: c3 ret 0000045a <fstat>: SYSCALL(fstat) 45a: b8 08 00 00 00 mov $0x8,%eax 45f: cd 40 int $0x40 461: c3 ret 00000462 <link>: SYSCALL(link) 462: b8 13 00 00 00 mov $0x13,%eax 467: cd 40 int $0x40 469: c3 ret 0000046a <mkdir>: SYSCALL(mkdir) 46a: b8 14 00 00 00 mov $0x14,%eax 46f: cd 40 int $0x40 471: c3 ret 00000472 <chdir>: SYSCALL(chdir) 472: b8 09 00 00 00 mov $0x9,%eax 477: cd 40 int $0x40 479: c3 ret 0000047a <dup>: SYSCALL(dup) 47a: b8 0a 00 00 00 mov $0xa,%eax 47f: cd 40 int $0x40 481: c3 ret 00000482 <getpid>: SYSCALL(getpid) 482: b8 0b 00 00 00 mov $0xb,%eax 487: cd 40 int $0x40 489: c3 ret 0000048a <sbrk>: SYSCALL(sbrk) 48a: b8 0c 00 00 00 mov $0xc,%eax 48f: cd 40 int $0x40 491: c3 ret 00000492 <sleep>: SYSCALL(sleep) 492: b8 0d 00 00 00 mov $0xd,%eax 497: cd 40 int $0x40 499: c3 ret 0000049a <uptime>: SYSCALL(uptime) 49a: b8 0e 00 00 00 mov $0xe,%eax 49f: cd 40 int $0x40 4a1: c3 ret 000004a2 <random>: SYSCALL(random) 4a2: b8 16 00 00 00 mov $0x16,%eax 4a7: cd 40 int $0x40 4a9: c3 ret 000004aa <cprocstate>: SYSCALL(cprocstate) 4aa: b8 18 00 00 00 mov $0x18,%eax 4af: cd 40 int $0x40 4b1: c3 ret 000004b2 <signalinfo>: SYSCALL(signalinfo) 4b2: b8 19 00 00 00 mov $0x19,%eax 4b7: cd 40 int $0x40 4b9: c3 ret 000004ba <setseed>: SYSCALL(setseed) 4ba: b8 17 00 00 00 mov $0x17,%eax 4bf: cd 40 int $0x40 4c1: c3 ret 4c2: 66 90 xchg %ax,%ax 4c4: 66 90 xchg %ax,%ax 4c6: 66 90 xchg %ax,%ax 4c8: 66 90 xchg %ax,%ax 4ca: 66 90 xchg %ax,%ax 4cc: 66 90 xchg %ax,%ax 4ce: 66 90 xchg %ax,%ax 000004d0 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 4d0: 55 push %ebp 4d1: 89 e5 mov %esp,%ebp 4d3: 57 push %edi 4d4: 56 push %esi 4d5: 89 c6 mov %eax,%esi 4d7: 53 push %ebx 4d8: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 4db: 8b 5d 08 mov 0x8(%ebp),%ebx 4de: 85 db test %ebx,%ebx 4e0: 74 09 je 4eb <printint+0x1b> 4e2: 89 d0 mov %edx,%eax 4e4: c1 e8 1f shr $0x1f,%eax 4e7: 84 c0 test %al,%al 4e9: 75 75 jne 560 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 4eb: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 4ed: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4f4: 89 75 c0 mov %esi,-0x40(%ebp) x = -xx; } else { x = xx; } i = 0; 4f7: 31 ff xor %edi,%edi 4f9: 89 ce mov %ecx,%esi 4fb: 8d 5d d7 lea -0x29(%ebp),%ebx 4fe: eb 02 jmp 502 <printint+0x32> do{ buf[i++] = digits[x % base]; 500: 89 cf mov %ecx,%edi 502: 31 d2 xor %edx,%edx 504: f7 f6 div %esi 506: 8d 4f 01 lea 0x1(%edi),%ecx 509: 0f b6 92 2f 09 00 00 movzbl 0x92f(%edx),%edx }while((x /= base) != 0); 510: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 512: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 515: 75 e9 jne 500 <printint+0x30> if(neg) 517: 8b 55 c4 mov -0x3c(%ebp),%edx x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 51a: 89 c8 mov %ecx,%eax 51c: 8b 75 c0 mov -0x40(%ebp),%esi }while((x /= base) != 0); if(neg) 51f: 85 d2 test %edx,%edx 521: 74 08 je 52b <printint+0x5b> buf[i++] = '-'; 523: 8d 4f 02 lea 0x2(%edi),%ecx 526: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 52b: 8d 79 ff lea -0x1(%ecx),%edi 52e: 66 90 xchg %ax,%ax 530: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 535: 83 ef 01 sub $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 538: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 53f: 00 540: 89 5c 24 04 mov %ebx,0x4(%esp) 544: 89 34 24 mov %esi,(%esp) 547: 88 45 d7 mov %al,-0x29(%ebp) 54a: e8 d3 fe ff ff call 422 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 54f: 83 ff ff cmp $0xffffffff,%edi 552: 75 dc jne 530 <printint+0x60> putc(fd, buf[i]); } 554: 83 c4 4c add $0x4c,%esp 557: 5b pop %ebx 558: 5e pop %esi 559: 5f pop %edi 55a: 5d pop %ebp 55b: c3 ret 55c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 560: 89 d0 mov %edx,%eax 562: f7 d8 neg %eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 564: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 56b: eb 87 jmp 4f4 <printint+0x24> 56d: 8d 76 00 lea 0x0(%esi),%esi 00000570 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 570: 55 push %ebp 571: 89 e5 mov %esp,%ebp 573: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 574: 31 ff xor %edi,%edi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 576: 56 push %esi 577: 53 push %ebx 578: 83 ec 3c sub $0x3c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 57b: 8b 5d 0c mov 0xc(%ebp),%ebx char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 57e: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 581: 8b 75 08 mov 0x8(%ebp),%esi char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 584: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 587: 0f b6 13 movzbl (%ebx),%edx 58a: 83 c3 01 add $0x1,%ebx 58d: 84 d2 test %dl,%dl 58f: 75 39 jne 5ca <printf+0x5a> 591: e9 c2 00 00 00 jmp 658 <printf+0xe8> 596: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 598: 83 fa 25 cmp $0x25,%edx 59b: 0f 84 bf 00 00 00 je 660 <printf+0xf0> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5a1: 8d 45 e2 lea -0x1e(%ebp),%eax 5a4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5ab: 00 5ac: 89 44 24 04 mov %eax,0x4(%esp) 5b0: 89 34 24 mov %esi,(%esp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; } else { putc(fd, c); 5b3: 88 55 e2 mov %dl,-0x1e(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5b6: e8 67 fe ff ff call 422 <write> 5bb: 83 c3 01 add $0x1,%ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 5be: 0f b6 53 ff movzbl -0x1(%ebx),%edx 5c2: 84 d2 test %dl,%dl 5c4: 0f 84 8e 00 00 00 je 658 <printf+0xe8> c = fmt[i] & 0xff; if(state == 0){ 5ca: 85 ff test %edi,%edi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 5cc: 0f be c2 movsbl %dl,%eax if(state == 0){ 5cf: 74 c7 je 598 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 5d1: 83 ff 25 cmp $0x25,%edi 5d4: 75 e5 jne 5bb <printf+0x4b> if(c == 'd'){ 5d6: 83 fa 64 cmp $0x64,%edx 5d9: 0f 84 31 01 00 00 je 710 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 5df: 25 f7 00 00 00 and $0xf7,%eax 5e4: 83 f8 70 cmp $0x70,%eax 5e7: 0f 84 83 00 00 00 je 670 <printf+0x100> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 5ed: 83 fa 73 cmp $0x73,%edx 5f0: 0f 84 a2 00 00 00 je 698 <printf+0x128> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 5f6: 83 fa 63 cmp $0x63,%edx 5f9: 0f 84 35 01 00 00 je 734 <printf+0x1c4> putc(fd, *ap); ap++; } else if(c == '%'){ 5ff: 83 fa 25 cmp $0x25,%edx 602: 0f 84 e0 00 00 00 je 6e8 <printf+0x178> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 608: 8d 45 e6 lea -0x1a(%ebp),%eax 60b: 83 c3 01 add $0x1,%ebx 60e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 615: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 616: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 618: 89 44 24 04 mov %eax,0x4(%esp) 61c: 89 34 24 mov %esi,(%esp) 61f: 89 55 d0 mov %edx,-0x30(%ebp) 622: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 626: e8 f7 fd ff ff call 422 <write> } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 62b: 8b 55 d0 mov -0x30(%ebp),%edx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 62e: 8d 45 e7 lea -0x19(%ebp),%eax 631: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 638: 00 639: 89 44 24 04 mov %eax,0x4(%esp) 63d: 89 34 24 mov %esi,(%esp) } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 640: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 643: e8 da fd ff ff call 422 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 648: 0f b6 53 ff movzbl -0x1(%ebx),%edx 64c: 84 d2 test %dl,%dl 64e: 0f 85 76 ff ff ff jne 5ca <printf+0x5a> 654: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, c); } state = 0; } } } 658: 83 c4 3c add $0x3c,%esp 65b: 5b pop %ebx 65c: 5e pop %esi 65d: 5f pop %edi 65e: 5d pop %ebp 65f: c3 ret ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 660: bf 25 00 00 00 mov $0x25,%edi 665: e9 51 ff ff ff jmp 5bb <printf+0x4b> 66a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 670: 8b 45 d4 mov -0x2c(%ebp),%eax 673: b9 10 00 00 00 mov $0x10,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 678: 31 ff xor %edi,%edi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 67a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 681: 8b 10 mov (%eax),%edx 683: 89 f0 mov %esi,%eax 685: e8 46 fe ff ff call 4d0 <printint> ap++; 68a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 68e: e9 28 ff ff ff jmp 5bb <printf+0x4b> 693: 90 nop 694: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 698: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 69b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ s = (char*)*ap; 69f: 8b 38 mov (%eax),%edi ap++; if(s == 0) s = "(null)"; 6a1: b8 28 09 00 00 mov $0x928,%eax 6a6: 85 ff test %edi,%edi 6a8: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 6ab: 0f b6 07 movzbl (%edi),%eax 6ae: 84 c0 test %al,%al 6b0: 74 2a je 6dc <printf+0x16c> 6b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 6b8: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6bb: 8d 45 e3 lea -0x1d(%ebp),%eax ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 6be: 83 c7 01 add $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 6c8: 00 6c9: 89 44 24 04 mov %eax,0x4(%esp) 6cd: 89 34 24 mov %esi,(%esp) 6d0: e8 4d fd ff ff call 422 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6d5: 0f b6 07 movzbl (%edi),%eax 6d8: 84 c0 test %al,%al 6da: 75 dc jne 6b8 <printf+0x148> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 6dc: 31 ff xor %edi,%edi 6de: e9 d8 fe ff ff jmp 5bb <printf+0x4b> 6e3: 90 nop 6e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6e8: 8d 45 e5 lea -0x1b(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 6eb: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6ed: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 6f4: 00 6f5: 89 44 24 04 mov %eax,0x4(%esp) 6f9: 89 34 24 mov %esi,(%esp) 6fc: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 700: e8 1d fd ff ff call 422 <write> 705: e9 b1 fe ff ff jmp 5bb <printf+0x4b> 70a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 710: 8b 45 d4 mov -0x2c(%ebp),%eax 713: b9 0a 00 00 00 mov $0xa,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 718: 66 31 ff xor %di,%di } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 71b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 722: 8b 10 mov (%eax),%edx 724: 89 f0 mov %esi,%eax 726: e8 a5 fd ff ff call 4d0 <printint> ap++; 72b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 72f: e9 87 fe ff ff jmp 5bb <printf+0x4b> while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 734: 8b 45 d4 mov -0x2c(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 737: 31 ff xor %edi,%edi while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 739: 8b 00 mov (%eax),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 73b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 742: 00 743: 89 34 24 mov %esi,(%esp) while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 746: 88 45 e4 mov %al,-0x1c(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 749: 8d 45 e4 lea -0x1c(%ebp),%eax 74c: 89 44 24 04 mov %eax,0x4(%esp) 750: e8 cd fc ff ff call 422 <write> putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; 755: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 759: e9 5d fe ff ff jmp 5bb <printf+0x4b> 75e: 66 90 xchg %ax,%ax 00000760 <free>: static Header base; static Header *freep; void free(void *ap) { 760: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 761: a1 b8 0b 00 00 mov 0xbb8,%eax static Header base; static Header *freep; void free(void *ap) { 766: 89 e5 mov %esp,%ebp 768: 57 push %edi 769: 56 push %esi 76a: 53 push %ebx 76b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 76e: 8b 08 mov (%eax),%ecx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 770: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 773: 39 d0 cmp %edx,%eax 775: 72 11 jb 788 <free+0x28> 777: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 778: 39 c8 cmp %ecx,%eax 77a: 72 04 jb 780 <free+0x20> 77c: 39 ca cmp %ecx,%edx 77e: 72 10 jb 790 <free+0x30> 780: 89 c8 mov %ecx,%eax free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 782: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 784: 8b 08 mov (%eax),%ecx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 786: 73 f0 jae 778 <free+0x18> 788: 39 ca cmp %ecx,%edx 78a: 72 04 jb 790 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 78c: 39 c8 cmp %ecx,%eax 78e: 72 f0 jb 780 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 790: 8b 73 fc mov -0x4(%ebx),%esi 793: 8d 3c f2 lea (%edx,%esi,8),%edi 796: 39 cf cmp %ecx,%edi 798: 74 1e je 7b8 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 79a: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 79d: 8b 48 04 mov 0x4(%eax),%ecx 7a0: 8d 34 c8 lea (%eax,%ecx,8),%esi 7a3: 39 f2 cmp %esi,%edx 7a5: 74 28 je 7cf <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 7a7: 89 10 mov %edx,(%eax) freep = p; 7a9: a3 b8 0b 00 00 mov %eax,0xbb8 } 7ae: 5b pop %ebx 7af: 5e pop %esi 7b0: 5f pop %edi 7b1: 5d pop %ebp 7b2: c3 ret 7b3: 90 nop 7b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 7b8: 03 71 04 add 0x4(%ecx),%esi 7bb: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 7be: 8b 08 mov (%eax),%ecx 7c0: 8b 09 mov (%ecx),%ecx 7c2: 89 4b f8 mov %ecx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 7c5: 8b 48 04 mov 0x4(%eax),%ecx 7c8: 8d 34 c8 lea (%eax,%ecx,8),%esi 7cb: 39 f2 cmp %esi,%edx 7cd: 75 d8 jne 7a7 <free+0x47> p->s.size += bp->s.size; 7cf: 03 4b fc add -0x4(%ebx),%ecx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 7d2: a3 b8 0b 00 00 mov %eax,0xbb8 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 7d7: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 7da: 8b 53 f8 mov -0x8(%ebx),%edx 7dd: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 7df: 5b pop %ebx 7e0: 5e pop %esi 7e1: 5f pop %edi 7e2: 5d pop %ebp 7e3: c3 ret 7e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 7ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000007f0 <malloc>: return freep; } void* malloc(uint nbytes) { 7f0: 55 push %ebp 7f1: 89 e5 mov %esp,%ebp 7f3: 57 push %edi 7f4: 56 push %esi 7f5: 53 push %ebx 7f6: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7f9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 7fc: 8b 1d b8 0b 00 00 mov 0xbb8,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 802: 8d 48 07 lea 0x7(%eax),%ecx 805: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 808: 85 db test %ebx,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 80a: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 80d: 0f 84 9b 00 00 00 je 8ae <malloc+0xbe> 813: 8b 13 mov (%ebx),%edx 815: 8b 7a 04 mov 0x4(%edx),%edi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 818: 39 fe cmp %edi,%esi 81a: 76 64 jbe 880 <malloc+0x90> 81c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 823: bb 00 80 00 00 mov $0x8000,%ebx 828: 89 45 e4 mov %eax,-0x1c(%ebp) 82b: eb 0e jmp 83b <malloc+0x4b> 82d: 8d 76 00 lea 0x0(%esi),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 830: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 832: 8b 78 04 mov 0x4(%eax),%edi 835: 39 fe cmp %edi,%esi 837: 76 4f jbe 888 <malloc+0x98> 839: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 83b: 3b 15 b8 0b 00 00 cmp 0xbb8,%edx 841: 75 ed jne 830 <malloc+0x40> morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 843: 8b 45 e4 mov -0x1c(%ebp),%eax 846: 81 fe 00 10 00 00 cmp $0x1000,%esi 84c: bf 00 10 00 00 mov $0x1000,%edi 851: 0f 43 fe cmovae %esi,%edi 854: 0f 42 c3 cmovb %ebx,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 857: 89 04 24 mov %eax,(%esp) 85a: e8 2b fc ff ff call 48a <sbrk> if(p == (char*)-1) 85f: 83 f8 ff cmp $0xffffffff,%eax 862: 74 18 je 87c <malloc+0x8c> return 0; hp = (Header*)p; hp->s.size = nu; 864: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 867: 83 c0 08 add $0x8,%eax 86a: 89 04 24 mov %eax,(%esp) 86d: e8 ee fe ff ff call 760 <free> return freep; 872: 8b 15 b8 0b 00 00 mov 0xbb8,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 878: 85 d2 test %edx,%edx 87a: 75 b4 jne 830 <malloc+0x40> return 0; 87c: 31 c0 xor %eax,%eax 87e: eb 20 jmp 8a0 <malloc+0xb0> if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 880: 89 d0 mov %edx,%eax 882: 89 da mov %ebx,%edx 884: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 888: 39 fe cmp %edi,%esi 88a: 74 1c je 8a8 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 88c: 29 f7 sub %esi,%edi 88e: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; 891: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; 894: 89 70 04 mov %esi,0x4(%eax) } freep = prevp; 897: 89 15 b8 0b 00 00 mov %edx,0xbb8 return (void*)(p + 1); 89d: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 8a0: 83 c4 1c add $0x1c,%esp 8a3: 5b pop %ebx 8a4: 5e pop %esi 8a5: 5f pop %edi 8a6: 5d pop %ebp 8a7: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 8a8: 8b 08 mov (%eax),%ecx 8aa: 89 0a mov %ecx,(%edx) 8ac: eb e9 jmp 897 <malloc+0xa7> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 8ae: c7 05 b8 0b 00 00 bc movl $0xbbc,0xbb8 8b5: 0b 00 00 base.s.size = 0; 8b8: ba bc 0b 00 00 mov $0xbbc,%edx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 8bd: c7 05 bc 0b 00 00 bc movl $0xbbc,0xbbc 8c4: 0b 00 00 base.s.size = 0; 8c7: c7 05 c0 0b 00 00 00 movl $0x0,0xbc0 8ce: 00 00 00 8d1: e9 46 ff ff ff jmp 81c <malloc+0x2c>
Sound_99_Header: smpsHeaderStartSong 3 smpsHeaderVoice Sound_99_Voices smpsHeaderTempoSFX $01 smpsHeaderChanSFX $01 smpsHeaderSFXChannel cFM3, Sound_99_FM3, $07, $00 ; FM3 Data Sound_99_FM3: smpsSetvoice $00 dc.b nG2, $48 smpsStop Sound_99_Voices: ; Voice $00 ; $03 ; $10, $70, $00, $3F, $1F, $1F, $1F, $1F, $17, $1F, $00, $15 ; $00, $00, $00, $00, $FF, $0F, $0F, $FF, $03, $1B, $2C, $80 smpsVcAlgorithm $03 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $03, $00, $07, $01 smpsVcCoarseFreq $0F, $00, $00, $00 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $15, $00, $1F, $17 smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $0F, $00, $00, $0F smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $2C, $1B, $03
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: UnityEngine.MonoBehaviour #include "UnityEngine/MonoBehaviour.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "beatsaber-hook/shared/utils/utils.h" #include "beatsaber-hook/shared/utils/typedefs-array.hpp" #include "beatsaber-hook/shared/utils/typedefs-string.hpp" // Completed includes // Begin forward declares // Forward declaring namespace: VROSC namespace VROSC { // Forward declaring type: TransformMover class TransformMover; // Forward declaring type: PadUI class PadUI; // Forward declaring type: LaunchPadEffectOnSignal class LaunchPadEffectOnSignal; // Forward declaring type: PredictiveHittable class PredictiveHittable; // Forward declaring type: LaunchpadSpawner class LaunchpadSpawner; // Forward declaring type: Signal class Signal; // Forward declaring type: GrabData class GrabData; } // Forward declaring namespace: TMPro namespace TMPro { // Forward declaring type: TextMeshPro class TextMeshPro; } // Forward declaring namespace: System namespace System { // Forward declaring type: Action`1<T> template<typename T> class Action_1; } // Forward declaring namespace: UnityEngine namespace UnityEngine { // Forward declaring type: Collider class Collider; // Forward declaring type: Color struct Color; } // Completed forward declares // Type namespace: VROSC namespace VROSC { // Forward declaring type: Launchpad class Launchpad; } #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" NEED_NO_BOX(::VROSC::Launchpad); DEFINE_IL2CPP_ARG_TYPE(::VROSC::Launchpad*, "VROSC", "Launchpad"); // Type namespace: VROSC namespace VROSC { // Size: 0x84 #pragma pack(push, 1) // Autogenerated type: VROSC.Launchpad // [TokenAttribute] Offset: FFFFFFFF class Launchpad : public ::UnityEngine::MonoBehaviour { public: // Nested type: ::VROSC::Launchpad::$LaunchpadHit$d__25 struct $LaunchpadHit$d__25; #ifdef USE_CODEGEN_FIELDS public: #else #ifdef CODEGEN_FIELD_ACCESSIBILITY CODEGEN_FIELD_ACCESSIBILITY: #else protected: #endif #endif // private VROSC.TransformMover _mover // Size: 0x8 // Offset: 0x18 ::VROSC::TransformMover* mover; // Field size check static_assert(sizeof(::VROSC::TransformMover*) == 0x8); // private VROSC.PadUI _UI // Size: 0x8 // Offset: 0x20 ::VROSC::PadUI* UI; // Field size check static_assert(sizeof(::VROSC::PadUI*) == 0x8); // protected VROSC.LaunchPadEffectOnSignal _visual // Size: 0x8 // Offset: 0x28 ::VROSC::LaunchPadEffectOnSignal* visual; // Field size check static_assert(sizeof(::VROSC::LaunchPadEffectOnSignal*) == 0x8); // private VROSC.PredictiveHittable _hittable // Size: 0x8 // Offset: 0x30 ::VROSC::PredictiveHittable* hittable; // Field size check static_assert(sizeof(::VROSC::PredictiveHittable*) == 0x8); // private TMPro.TextMeshPro _trackName // Size: 0x8 // Offset: 0x38 ::TMPro::TextMeshPro* trackName; // Field size check static_assert(sizeof(::TMPro::TextMeshPro*) == 0x8); // private VROSC.LaunchpadSpawner _launchpadSpawner // Size: 0x8 // Offset: 0x40 ::VROSC::LaunchpadSpawner* launchpadSpawner; // Field size check static_assert(sizeof(::VROSC::LaunchpadSpawner*) == 0x8); // public System.Action`1<VROSC.Launchpad> OnLaunchPadHit // Size: 0x8 // Offset: 0x48 ::System::Action_1<::VROSC::Launchpad*>* OnLaunchPadHit; // Field size check static_assert(sizeof(::System::Action_1<::VROSC::Launchpad*>*) == 0x8); // public System.Action`1<VROSC.Launchpad> OnLaunchPadMoved // Size: 0x8 // Offset: 0x50 ::System::Action_1<::VROSC::Launchpad*>* OnLaunchPadMoved; // Field size check static_assert(sizeof(::System::Action_1<::VROSC::Launchpad*>*) == 0x8); // public System.Action`1<VROSC.Launchpad> OnLaunchPadDeletedByUser // Size: 0x8 // Offset: 0x58 ::System::Action_1<::VROSC::Launchpad*>* OnLaunchPadDeletedByUser; // Field size check static_assert(sizeof(::System::Action_1<::VROSC::Launchpad*>*) == 0x8); // private System.String <ID>k__BackingField // Size: 0x8 // Offset: 0x60 ::StringW _ID; // Field size check static_assert(sizeof(::StringW) == 0x8); // private System.String <TargetID>k__BackingField // Size: 0x8 // Offset: 0x68 ::StringW TargetID; // Field size check static_assert(sizeof(::StringW) == 0x8); // private UnityEngine.Collider[] _overlaps // Size: 0x8 // Offset: 0x70 ::ArrayW<::UnityEngine::Collider*> overlaps; // Field size check static_assert(sizeof(::ArrayW<::UnityEngine::Collider*>) == 0x8); // private VROSC.LaunchpadSpawner _overlappingSpawner // Size: 0x8 // Offset: 0x78 ::VROSC::LaunchpadSpawner* overlappingSpawner; // Field size check static_assert(sizeof(::VROSC::LaunchpadSpawner*) == 0x8); // private System.Single _spawnerDeleteDistance // Size: 0x4 // Offset: 0x80 float spawnerDeleteDistance; // Field size check static_assert(sizeof(float) == 0x4); public: // Deleting conversion operator: operator ::System::IntPtr constexpr operator ::System::IntPtr() const noexcept = delete; // Get instance field reference: private VROSC.TransformMover _mover ::VROSC::TransformMover*& dyn__mover(); // Get instance field reference: private VROSC.PadUI _UI ::VROSC::PadUI*& dyn__UI(); // Get instance field reference: protected VROSC.LaunchPadEffectOnSignal _visual ::VROSC::LaunchPadEffectOnSignal*& dyn__visual(); // Get instance field reference: private VROSC.PredictiveHittable _hittable ::VROSC::PredictiveHittable*& dyn__hittable(); // Get instance field reference: private TMPro.TextMeshPro _trackName ::TMPro::TextMeshPro*& dyn__trackName(); // Get instance field reference: private VROSC.LaunchpadSpawner _launchpadSpawner ::VROSC::LaunchpadSpawner*& dyn__launchpadSpawner(); // Get instance field reference: public System.Action`1<VROSC.Launchpad> OnLaunchPadHit ::System::Action_1<::VROSC::Launchpad*>*& dyn_OnLaunchPadHit(); // Get instance field reference: public System.Action`1<VROSC.Launchpad> OnLaunchPadMoved ::System::Action_1<::VROSC::Launchpad*>*& dyn_OnLaunchPadMoved(); // Get instance field reference: public System.Action`1<VROSC.Launchpad> OnLaunchPadDeletedByUser ::System::Action_1<::VROSC::Launchpad*>*& dyn_OnLaunchPadDeletedByUser(); // Get instance field reference: private System.String <ID>k__BackingField ::StringW& dyn_$ID$k__BackingField(); // Get instance field reference: private System.String <TargetID>k__BackingField ::StringW& dyn_$TargetID$k__BackingField(); // Get instance field reference: private UnityEngine.Collider[] _overlaps ::ArrayW<::UnityEngine::Collider*>& dyn__overlaps(); // Get instance field reference: private VROSC.LaunchpadSpawner _overlappingSpawner ::VROSC::LaunchpadSpawner*& dyn__overlappingSpawner(); // Get instance field reference: private System.Single _spawnerDeleteDistance float& dyn__spawnerDeleteDistance(); // public System.String get_ID() // Offset: 0x138A87C ::StringW get_ID(); // private System.Void set_ID(System.String value) // Offset: 0x138A874 void set_ID(::StringW value); // public System.String get_TargetID() // Offset: 0x138A88C ::StringW get_TargetID(); // private System.Void set_TargetID(System.String value) // Offset: 0x138A884 void set_TargetID(::StringW value); // private System.Void Awake() // Offset: 0x138A894 void Awake(); // protected System.Void OnDestroy() // Offset: 0x138A9E0 void OnDestroy(); // public System.Void Setup(VROSC.LaunchpadSpawner launchpadSpawner, System.String id, System.String targetID, System.String displayName, UnityEngine.Color color) // Offset: 0x138AC44 void Setup(::VROSC::LaunchpadSpawner* launchpadSpawner, ::StringW id, ::StringW targetID, ::StringW displayName, ::UnityEngine::Color color); // public System.Void SetColor(UnityEngine.Color color) // Offset: 0x138AE40 void SetColor(::UnityEngine::Color color); // public System.Void SetDisplayName(System.String newName) // Offset: 0x138AE1C void SetDisplayName(::StringW newName); // public System.Void LaunchpadHit(VROSC.Signal signal) // Offset: 0x138AEAC void LaunchpadHit(::VROSC::Signal* signal); // public System.Void Grab(VROSC.GrabData grabData, System.Boolean grabbing) // Offset: 0x138AF74 void Grab(::VROSC::GrabData* grabData, bool grabbing); // public System.Void GrabEnded(VROSC.TransformMover mover) // Offset: 0x138AF98 void GrabEnded(::VROSC::TransformMover* mover); // private System.Void DeletePressed() // Offset: 0x138B224 void DeletePressed(); // public System.Void Delete() // Offset: 0x138B0E4 void Delete(); // public System.Void .ctor() // Offset: 0x138B284 // Implemented from: UnityEngine.MonoBehaviour // Base method: System.Void MonoBehaviour::.ctor() // Base method: System.Void Behaviour::.ctor() // Base method: System.Void Component::.ctor() // Base method: System.Void Object::.ctor() // Base method: System.Void Object::.ctor() template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static Launchpad* New_ctor() { static auto ___internal__logger = ::Logger::get().WithContext("::VROSC::Launchpad::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<Launchpad*, creationType>())); } }; // VROSC.Launchpad #pragma pack(pop) static check_size<sizeof(Launchpad), 128 + sizeof(float)> __VROSC_LaunchpadSizeCheck; static_assert(sizeof(Launchpad) == 0x84); } #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: VROSC::Launchpad::get_ID // Il2CppName: get_ID template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (VROSC::Launchpad::*)()>(&VROSC::Launchpad::get_ID)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "get_ID", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::set_ID // Il2CppName: set_ID template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::StringW)>(&VROSC::Launchpad::set_ID)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "set_ID", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::get_TargetID // Il2CppName: get_TargetID template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (VROSC::Launchpad::*)()>(&VROSC::Launchpad::get_TargetID)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "get_TargetID", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::set_TargetID // Il2CppName: set_TargetID template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::StringW)>(&VROSC::Launchpad::set_TargetID)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "set_TargetID", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::Awake // Il2CppName: Awake template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)()>(&VROSC::Launchpad::Awake)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "Awake", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::OnDestroy // Il2CppName: OnDestroy template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)()>(&VROSC::Launchpad::OnDestroy)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "OnDestroy", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::Setup // Il2CppName: Setup template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::VROSC::LaunchpadSpawner*, ::StringW, ::StringW, ::StringW, ::UnityEngine::Color)>(&VROSC::Launchpad::Setup)> { static const MethodInfo* get() { static auto* launchpadSpawner = &::il2cpp_utils::GetClassFromName("VROSC", "LaunchpadSpawner")->byval_arg; static auto* id = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg; static auto* targetID = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg; static auto* displayName = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg; static auto* color = &::il2cpp_utils::GetClassFromName("UnityEngine", "Color")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "Setup", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{launchpadSpawner, id, targetID, displayName, color}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::SetColor // Il2CppName: SetColor template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::UnityEngine::Color)>(&VROSC::Launchpad::SetColor)> { static const MethodInfo* get() { static auto* color = &::il2cpp_utils::GetClassFromName("UnityEngine", "Color")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "SetColor", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{color}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::SetDisplayName // Il2CppName: SetDisplayName template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::StringW)>(&VROSC::Launchpad::SetDisplayName)> { static const MethodInfo* get() { static auto* newName = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "SetDisplayName", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{newName}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::LaunchpadHit // Il2CppName: LaunchpadHit template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::VROSC::Signal*)>(&VROSC::Launchpad::LaunchpadHit)> { static const MethodInfo* get() { static auto* signal = &::il2cpp_utils::GetClassFromName("VROSC", "Signal")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "LaunchpadHit", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{signal}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::Grab // Il2CppName: Grab template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::VROSC::GrabData*, bool)>(&VROSC::Launchpad::Grab)> { static const MethodInfo* get() { static auto* grabData = &::il2cpp_utils::GetClassFromName("VROSC", "GrabData")->byval_arg; static auto* grabbing = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "Grab", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{grabData, grabbing}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::GrabEnded // Il2CppName: GrabEnded template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)(::VROSC::TransformMover*)>(&VROSC::Launchpad::GrabEnded)> { static const MethodInfo* get() { static auto* mover = &::il2cpp_utils::GetClassFromName("VROSC", "TransformMover")->byval_arg; return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "GrabEnded", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{mover}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::DeletePressed // Il2CppName: DeletePressed template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)()>(&VROSC::Launchpad::DeletePressed)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "DeletePressed", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::Delete // Il2CppName: Delete template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (VROSC::Launchpad::*)()>(&VROSC::Launchpad::Delete)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(VROSC::Launchpad*), "Delete", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: VROSC::Launchpad::New_ctor // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead!
_kill: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char **argv) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 56 push %esi e: 53 push %ebx f: 51 push %ecx 10: 83 ec 0c sub $0xc,%esp 13: 8b 01 mov (%ecx),%eax 15: 8b 51 04 mov 0x4(%ecx),%edx int i; if(argc < 2){ 18: 83 f8 01 cmp $0x1,%eax 1b: 7e 2c jle 49 <main+0x49> 1d: 8d 5a 04 lea 0x4(%edx),%ebx 20: 8d 34 82 lea (%edx,%eax,4),%esi 23: 90 nop 24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) kill(atoi(argv[i])); 28: 83 ec 0c sub $0xc,%esp 2b: ff 33 pushl (%ebx) 2d: 83 c3 04 add $0x4,%ebx 30: e8 0b 02 00 00 call 240 <atoi> 35: 89 04 24 mov %eax,(%esp) 38: e8 a5 02 00 00 call 2e2 <kill> for(i=1; i<argc; i++) 3d: 83 c4 10 add $0x10,%esp 40: 39 f3 cmp %esi,%ebx 42: 75 e4 jne 28 <main+0x28> exit(); 44: e8 69 02 00 00 call 2b2 <exit> printf(2, "usage: kill pid...\n"); 49: 50 push %eax 4a: 50 push %eax 4b: 68 78 07 00 00 push $0x778 50: 6a 02 push $0x2 52: e8 c9 03 00 00 call 420 <printf> exit(); 57: e8 56 02 00 00 call 2b2 <exit> 5c: 66 90 xchg %ax,%ax 5e: 66 90 xchg %ax,%ax 00000060 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 45 08 mov 0x8(%ebp),%eax 67: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 6a: 89 c2 mov %eax,%edx 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 70: 83 c1 01 add $0x1,%ecx 73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 77: 83 c2 01 add $0x1,%edx 7a: 84 db test %bl,%bl 7c: 88 5a ff mov %bl,-0x1(%edx) 7f: 75 ef jne 70 <strcpy+0x10> ; return os; } 81: 5b pop %ebx 82: 5d pop %ebp 83: c3 ret 84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 53 push %ebx 94: 8b 55 08 mov 0x8(%ebp),%edx 97: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 9a: 0f b6 02 movzbl (%edx),%eax 9d: 0f b6 19 movzbl (%ecx),%ebx a0: 84 c0 test %al,%al a2: 75 1c jne c0 <strcmp+0x30> a4: eb 2a jmp d0 <strcmp+0x40> a6: 8d 76 00 lea 0x0(%esi),%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; b0: 83 c2 01 add $0x1,%edx while(*p && *p == *q) b3: 0f b6 02 movzbl (%edx),%eax p++, q++; b6: 83 c1 01 add $0x1,%ecx b9: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) bc: 84 c0 test %al,%al be: 74 10 je d0 <strcmp+0x40> c0: 38 d8 cmp %bl,%al c2: 74 ec je b0 <strcmp+0x20> return (uchar)*p - (uchar)*q; c4: 29 d8 sub %ebx,%eax } c6: 5b pop %ebx c7: 5d pop %ebp c8: c3 ret c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi d0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; d2: 29 d8 sub %ebx,%eax } d4: 5b pop %ebx d5: 5d pop %ebp d6: c3 ret d7: 89 f6 mov %esi,%esi d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000e0 <strlen>: uint strlen(const char *s) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) e6: 80 39 00 cmpb $0x0,(%ecx) e9: 74 15 je 100 <strlen+0x20> eb: 31 d2 xor %edx,%edx ed: 8d 76 00 lea 0x0(%esi),%esi f0: 83 c2 01 add $0x1,%edx f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) f7: 89 d0 mov %edx,%eax f9: 75 f5 jne f0 <strlen+0x10> ; return n; } fb: 5d pop %ebp fc: c3 ret fd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 100: 31 c0 xor %eax,%eax } 102: 5d pop %ebp 103: c3 ret 104: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 10a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000110 <memset>: void* memset(void *dst, int c, uint n) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 117: 8b 4d 10 mov 0x10(%ebp),%ecx 11a: 8b 45 0c mov 0xc(%ebp),%eax 11d: 89 d7 mov %edx,%edi 11f: fc cld 120: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 122: 89 d0 mov %edx,%eax 124: 5f pop %edi 125: 5d pop %ebp 126: c3 ret 127: 89 f6 mov %esi,%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000130 <strchr>: char* strchr(const char *s, char c) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 53 push %ebx 134: 8b 45 08 mov 0x8(%ebp),%eax 137: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 13a: 0f b6 10 movzbl (%eax),%edx 13d: 84 d2 test %dl,%dl 13f: 74 1d je 15e <strchr+0x2e> if(*s == c) 141: 38 d3 cmp %dl,%bl 143: 89 d9 mov %ebx,%ecx 145: 75 0d jne 154 <strchr+0x24> 147: eb 17 jmp 160 <strchr+0x30> 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 150: 38 ca cmp %cl,%dl 152: 74 0c je 160 <strchr+0x30> for(; *s; s++) 154: 83 c0 01 add $0x1,%eax 157: 0f b6 10 movzbl (%eax),%edx 15a: 84 d2 test %dl,%dl 15c: 75 f2 jne 150 <strchr+0x20> return (char*)s; return 0; 15e: 31 c0 xor %eax,%eax } 160: 5b pop %ebx 161: 5d pop %ebp 162: c3 ret 163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000170 <gets>: char* gets(char *buf, int max) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 57 push %edi 174: 56 push %esi 175: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 176: 31 f6 xor %esi,%esi 178: 89 f3 mov %esi,%ebx { 17a: 83 ec 1c sub $0x1c,%esp 17d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 180: eb 2f jmp 1b1 <gets+0x41> 182: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 188: 8d 45 e7 lea -0x19(%ebp),%eax 18b: 83 ec 04 sub $0x4,%esp 18e: 6a 01 push $0x1 190: 50 push %eax 191: 6a 00 push $0x0 193: e8 32 01 00 00 call 2ca <read> if(cc < 1) 198: 83 c4 10 add $0x10,%esp 19b: 85 c0 test %eax,%eax 19d: 7e 1c jle 1bb <gets+0x4b> break; buf[i++] = c; 19f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1a3: 83 c7 01 add $0x1,%edi 1a6: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1a9: 3c 0a cmp $0xa,%al 1ab: 74 23 je 1d0 <gets+0x60> 1ad: 3c 0d cmp $0xd,%al 1af: 74 1f je 1d0 <gets+0x60> for(i=0; i+1 < max; ){ 1b1: 83 c3 01 add $0x1,%ebx 1b4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1b7: 89 fe mov %edi,%esi 1b9: 7c cd jl 188 <gets+0x18> 1bb: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1bd: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1c0: c6 03 00 movb $0x0,(%ebx) } 1c3: 8d 65 f4 lea -0xc(%ebp),%esp 1c6: 5b pop %ebx 1c7: 5e pop %esi 1c8: 5f pop %edi 1c9: 5d pop %ebp 1ca: c3 ret 1cb: 90 nop 1cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1d0: 8b 75 08 mov 0x8(%ebp),%esi 1d3: 8b 45 08 mov 0x8(%ebp),%eax 1d6: 01 de add %ebx,%esi 1d8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1da: c6 03 00 movb $0x0,(%ebx) } 1dd: 8d 65 f4 lea -0xc(%ebp),%esp 1e0: 5b pop %ebx 1e1: 5e pop %esi 1e2: 5f pop %edi 1e3: 5d pop %ebp 1e4: c3 ret 1e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001f0 <stat>: int stat(const char *n, struct stat *st) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 56 push %esi 1f4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1f5: 83 ec 08 sub $0x8,%esp 1f8: 6a 00 push $0x0 1fa: ff 75 08 pushl 0x8(%ebp) 1fd: e8 f0 00 00 00 call 2f2 <open> if(fd < 0) 202: 83 c4 10 add $0x10,%esp 205: 85 c0 test %eax,%eax 207: 78 27 js 230 <stat+0x40> return -1; r = fstat(fd, st); 209: 83 ec 08 sub $0x8,%esp 20c: ff 75 0c pushl 0xc(%ebp) 20f: 89 c3 mov %eax,%ebx 211: 50 push %eax 212: e8 f3 00 00 00 call 30a <fstat> close(fd); 217: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 21a: 89 c6 mov %eax,%esi close(fd); 21c: e8 b9 00 00 00 call 2da <close> return r; 221: 83 c4 10 add $0x10,%esp } 224: 8d 65 f8 lea -0x8(%ebp),%esp 227: 89 f0 mov %esi,%eax 229: 5b pop %ebx 22a: 5e pop %esi 22b: 5d pop %ebp 22c: c3 ret 22d: 8d 76 00 lea 0x0(%esi),%esi return -1; 230: be ff ff ff ff mov $0xffffffff,%esi 235: eb ed jmp 224 <stat+0x34> 237: 89 f6 mov %esi,%esi 239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000240 <atoi>: int atoi(const char *s) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp 243: 53 push %ebx 244: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 247: 0f be 11 movsbl (%ecx),%edx 24a: 8d 42 d0 lea -0x30(%edx),%eax 24d: 3c 09 cmp $0x9,%al n = 0; 24f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 254: 77 1f ja 275 <atoi+0x35> 256: 8d 76 00 lea 0x0(%esi),%esi 259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 260: 8d 04 80 lea (%eax,%eax,4),%eax 263: 83 c1 01 add $0x1,%ecx 266: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 26a: 0f be 11 movsbl (%ecx),%edx 26d: 8d 5a d0 lea -0x30(%edx),%ebx 270: 80 fb 09 cmp $0x9,%bl 273: 76 eb jbe 260 <atoi+0x20> return n; } 275: 5b pop %ebx 276: 5d pop %ebp 277: c3 ret 278: 90 nop 279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000280 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 280: 55 push %ebp 281: 89 e5 mov %esp,%ebp 283: 56 push %esi 284: 53 push %ebx 285: 8b 5d 10 mov 0x10(%ebp),%ebx 288: 8b 45 08 mov 0x8(%ebp),%eax 28b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 28e: 85 db test %ebx,%ebx 290: 7e 14 jle 2a6 <memmove+0x26> 292: 31 d2 xor %edx,%edx 294: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 298: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 29c: 88 0c 10 mov %cl,(%eax,%edx,1) 29f: 83 c2 01 add $0x1,%edx while(n-- > 0) 2a2: 39 d3 cmp %edx,%ebx 2a4: 75 f2 jne 298 <memmove+0x18> return vdst; } 2a6: 5b pop %ebx 2a7: 5e pop %esi 2a8: 5d pop %ebp 2a9: c3 ret 000002aa <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2aa: b8 01 00 00 00 mov $0x1,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <exit>: SYSCALL(exit) 2b2: b8 02 00 00 00 mov $0x2,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <wait>: SYSCALL(wait) 2ba: b8 03 00 00 00 mov $0x3,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <pipe>: SYSCALL(pipe) 2c2: b8 04 00 00 00 mov $0x4,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <read>: SYSCALL(read) 2ca: b8 05 00 00 00 mov $0x5,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <write>: SYSCALL(write) 2d2: b8 10 00 00 00 mov $0x10,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <close>: SYSCALL(close) 2da: b8 15 00 00 00 mov $0x15,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <kill>: SYSCALL(kill) 2e2: b8 06 00 00 00 mov $0x6,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <exec>: SYSCALL(exec) 2ea: b8 07 00 00 00 mov $0x7,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <open>: SYSCALL(open) 2f2: b8 0f 00 00 00 mov $0xf,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <mknod>: SYSCALL(mknod) 2fa: b8 11 00 00 00 mov $0x11,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <unlink>: SYSCALL(unlink) 302: b8 12 00 00 00 mov $0x12,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <fstat>: SYSCALL(fstat) 30a: b8 08 00 00 00 mov $0x8,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <link>: SYSCALL(link) 312: b8 13 00 00 00 mov $0x13,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <mkdir>: SYSCALL(mkdir) 31a: b8 14 00 00 00 mov $0x14,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <chdir>: SYSCALL(chdir) 322: b8 09 00 00 00 mov $0x9,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <dup>: SYSCALL(dup) 32a: b8 0a 00 00 00 mov $0xa,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <getpid>: SYSCALL(getpid) 332: b8 0b 00 00 00 mov $0xb,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <sbrk>: SYSCALL(sbrk) 33a: b8 0c 00 00 00 mov $0xc,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <sleep>: SYSCALL(sleep) 342: b8 0d 00 00 00 mov $0xd,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <uptime>: SYSCALL(uptime) 34a: b8 0e 00 00 00 mov $0xe,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <waitx>: SYSCALL(waitx) 352: b8 16 00 00 00 mov $0x16,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <getpinfo>: SYSCALL(getpinfo) 35a: b8 17 00 00 00 mov $0x17,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <ps>: SYSCALL(ps) 362: b8 18 00 00 00 mov $0x18,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <set_priority>: SYSCALL(set_priority) 36a: b8 19 00 00 00 mov $0x19,%eax 36f: cd 40 int $0x40 371: c3 ret 372: 66 90 xchg %ax,%ax 374: 66 90 xchg %ax,%ax 376: 66 90 xchg %ax,%ax 378: 66 90 xchg %ax,%ax 37a: 66 90 xchg %ax,%ax 37c: 66 90 xchg %ax,%ax 37e: 66 90 xchg %ax,%ax 00000380 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 380: 55 push %ebp 381: 89 e5 mov %esp,%ebp 383: 57 push %edi 384: 56 push %esi 385: 53 push %ebx 386: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 389: 85 d2 test %edx,%edx { 38b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 38e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 390: 79 76 jns 408 <printint+0x88> 392: f6 45 08 01 testb $0x1,0x8(%ebp) 396: 74 70 je 408 <printint+0x88> x = -xx; 398: f7 d8 neg %eax neg = 1; 39a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 3a1: 31 f6 xor %esi,%esi 3a3: 8d 5d d7 lea -0x29(%ebp),%ebx 3a6: eb 0a jmp 3b2 <printint+0x32> 3a8: 90 nop 3a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 3b0: 89 fe mov %edi,%esi 3b2: 31 d2 xor %edx,%edx 3b4: 8d 7e 01 lea 0x1(%esi),%edi 3b7: f7 f1 div %ecx 3b9: 0f b6 92 94 07 00 00 movzbl 0x794(%edx),%edx }while((x /= base) != 0); 3c0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3c2: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3c5: 75 e9 jne 3b0 <printint+0x30> if(neg) 3c7: 8b 45 c4 mov -0x3c(%ebp),%eax 3ca: 85 c0 test %eax,%eax 3cc: 74 08 je 3d6 <printint+0x56> buf[i++] = '-'; 3ce: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 3d3: 8d 7e 02 lea 0x2(%esi),%edi 3d6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 3da: 8b 7d c0 mov -0x40(%ebp),%edi 3dd: 8d 76 00 lea 0x0(%esi),%esi 3e0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 3e3: 83 ec 04 sub $0x4,%esp 3e6: 83 ee 01 sub $0x1,%esi 3e9: 6a 01 push $0x1 3eb: 53 push %ebx 3ec: 57 push %edi 3ed: 88 45 d7 mov %al,-0x29(%ebp) 3f0: e8 dd fe ff ff call 2d2 <write> while(--i >= 0) 3f5: 83 c4 10 add $0x10,%esp 3f8: 39 de cmp %ebx,%esi 3fa: 75 e4 jne 3e0 <printint+0x60> putc(fd, buf[i]); } 3fc: 8d 65 f4 lea -0xc(%ebp),%esp 3ff: 5b pop %ebx 400: 5e pop %esi 401: 5f pop %edi 402: 5d pop %ebp 403: c3 ret 404: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 408: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 40f: eb 90 jmp 3a1 <printint+0x21> 411: eb 0d jmp 420 <printf> 413: 90 nop 414: 90 nop 415: 90 nop 416: 90 nop 417: 90 nop 418: 90 nop 419: 90 nop 41a: 90 nop 41b: 90 nop 41c: 90 nop 41d: 90 nop 41e: 90 nop 41f: 90 nop 00000420 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 420: 55 push %ebp 421: 89 e5 mov %esp,%ebp 423: 57 push %edi 424: 56 push %esi 425: 53 push %ebx 426: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 429: 8b 75 0c mov 0xc(%ebp),%esi 42c: 0f b6 1e movzbl (%esi),%ebx 42f: 84 db test %bl,%bl 431: 0f 84 b3 00 00 00 je 4ea <printf+0xca> ap = (uint*)(void*)&fmt + 1; 437: 8d 45 10 lea 0x10(%ebp),%eax 43a: 83 c6 01 add $0x1,%esi state = 0; 43d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 43f: 89 45 d4 mov %eax,-0x2c(%ebp) 442: eb 2f jmp 473 <printf+0x53> 444: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 448: 83 f8 25 cmp $0x25,%eax 44b: 0f 84 a7 00 00 00 je 4f8 <printf+0xd8> write(fd, &c, 1); 451: 8d 45 e2 lea -0x1e(%ebp),%eax 454: 83 ec 04 sub $0x4,%esp 457: 88 5d e2 mov %bl,-0x1e(%ebp) 45a: 6a 01 push $0x1 45c: 50 push %eax 45d: ff 75 08 pushl 0x8(%ebp) 460: e8 6d fe ff ff call 2d2 <write> 465: 83 c4 10 add $0x10,%esp 468: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 46b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 46f: 84 db test %bl,%bl 471: 74 77 je 4ea <printf+0xca> if(state == 0){ 473: 85 ff test %edi,%edi c = fmt[i] & 0xff; 475: 0f be cb movsbl %bl,%ecx 478: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 47b: 74 cb je 448 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 47d: 83 ff 25 cmp $0x25,%edi 480: 75 e6 jne 468 <printf+0x48> if(c == 'd'){ 482: 83 f8 64 cmp $0x64,%eax 485: 0f 84 05 01 00 00 je 590 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 48b: 81 e1 f7 00 00 00 and $0xf7,%ecx 491: 83 f9 70 cmp $0x70,%ecx 494: 74 72 je 508 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 496: 83 f8 73 cmp $0x73,%eax 499: 0f 84 99 00 00 00 je 538 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 49f: 83 f8 63 cmp $0x63,%eax 4a2: 0f 84 08 01 00 00 je 5b0 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 4a8: 83 f8 25 cmp $0x25,%eax 4ab: 0f 84 ef 00 00 00 je 5a0 <printf+0x180> write(fd, &c, 1); 4b1: 8d 45 e7 lea -0x19(%ebp),%eax 4b4: 83 ec 04 sub $0x4,%esp 4b7: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4bb: 6a 01 push $0x1 4bd: 50 push %eax 4be: ff 75 08 pushl 0x8(%ebp) 4c1: e8 0c fe ff ff call 2d2 <write> 4c6: 83 c4 0c add $0xc,%esp 4c9: 8d 45 e6 lea -0x1a(%ebp),%eax 4cc: 88 5d e6 mov %bl,-0x1a(%ebp) 4cf: 6a 01 push $0x1 4d1: 50 push %eax 4d2: ff 75 08 pushl 0x8(%ebp) 4d5: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4d8: 31 ff xor %edi,%edi write(fd, &c, 1); 4da: e8 f3 fd ff ff call 2d2 <write> for(i = 0; fmt[i]; i++){ 4df: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 4e3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 4e6: 84 db test %bl,%bl 4e8: 75 89 jne 473 <printf+0x53> } } } 4ea: 8d 65 f4 lea -0xc(%ebp),%esp 4ed: 5b pop %ebx 4ee: 5e pop %esi 4ef: 5f pop %edi 4f0: 5d pop %ebp 4f1: c3 ret 4f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 4f8: bf 25 00 00 00 mov $0x25,%edi 4fd: e9 66 ff ff ff jmp 468 <printf+0x48> 502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 508: 83 ec 0c sub $0xc,%esp 50b: b9 10 00 00 00 mov $0x10,%ecx 510: 6a 00 push $0x0 512: 8b 7d d4 mov -0x2c(%ebp),%edi 515: 8b 45 08 mov 0x8(%ebp),%eax 518: 8b 17 mov (%edi),%edx 51a: e8 61 fe ff ff call 380 <printint> ap++; 51f: 89 f8 mov %edi,%eax 521: 83 c4 10 add $0x10,%esp state = 0; 524: 31 ff xor %edi,%edi ap++; 526: 83 c0 04 add $0x4,%eax 529: 89 45 d4 mov %eax,-0x2c(%ebp) 52c: e9 37 ff ff ff jmp 468 <printf+0x48> 531: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 538: 8b 45 d4 mov -0x2c(%ebp),%eax 53b: 8b 08 mov (%eax),%ecx ap++; 53d: 83 c0 04 add $0x4,%eax 540: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 543: 85 c9 test %ecx,%ecx 545: 0f 84 8e 00 00 00 je 5d9 <printf+0x1b9> while(*s != 0){ 54b: 0f b6 01 movzbl (%ecx),%eax state = 0; 54e: 31 ff xor %edi,%edi s = (char*)*ap; 550: 89 cb mov %ecx,%ebx while(*s != 0){ 552: 84 c0 test %al,%al 554: 0f 84 0e ff ff ff je 468 <printf+0x48> 55a: 89 75 d0 mov %esi,-0x30(%ebp) 55d: 89 de mov %ebx,%esi 55f: 8b 5d 08 mov 0x8(%ebp),%ebx 562: 8d 7d e3 lea -0x1d(%ebp),%edi 565: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 568: 83 ec 04 sub $0x4,%esp s++; 56b: 83 c6 01 add $0x1,%esi 56e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 571: 6a 01 push $0x1 573: 57 push %edi 574: 53 push %ebx 575: e8 58 fd ff ff call 2d2 <write> while(*s != 0){ 57a: 0f b6 06 movzbl (%esi),%eax 57d: 83 c4 10 add $0x10,%esp 580: 84 c0 test %al,%al 582: 75 e4 jne 568 <printf+0x148> 584: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 587: 31 ff xor %edi,%edi 589: e9 da fe ff ff jmp 468 <printf+0x48> 58e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 590: 83 ec 0c sub $0xc,%esp 593: b9 0a 00 00 00 mov $0xa,%ecx 598: 6a 01 push $0x1 59a: e9 73 ff ff ff jmp 512 <printf+0xf2> 59f: 90 nop write(fd, &c, 1); 5a0: 83 ec 04 sub $0x4,%esp 5a3: 88 5d e5 mov %bl,-0x1b(%ebp) 5a6: 8d 45 e5 lea -0x1b(%ebp),%eax 5a9: 6a 01 push $0x1 5ab: e9 21 ff ff ff jmp 4d1 <printf+0xb1> putc(fd, *ap); 5b0: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 5b3: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 5b6: 8b 07 mov (%edi),%eax write(fd, &c, 1); 5b8: 6a 01 push $0x1 ap++; 5ba: 83 c7 04 add $0x4,%edi putc(fd, *ap); 5bd: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 5c0: 8d 45 e4 lea -0x1c(%ebp),%eax 5c3: 50 push %eax 5c4: ff 75 08 pushl 0x8(%ebp) 5c7: e8 06 fd ff ff call 2d2 <write> ap++; 5cc: 89 7d d4 mov %edi,-0x2c(%ebp) 5cf: 83 c4 10 add $0x10,%esp state = 0; 5d2: 31 ff xor %edi,%edi 5d4: e9 8f fe ff ff jmp 468 <printf+0x48> s = "(null)"; 5d9: bb 8c 07 00 00 mov $0x78c,%ebx while(*s != 0){ 5de: b8 28 00 00 00 mov $0x28,%eax 5e3: e9 72 ff ff ff jmp 55a <printf+0x13a> 5e8: 66 90 xchg %ax,%ax 5ea: 66 90 xchg %ax,%ax 5ec: 66 90 xchg %ax,%ax 5ee: 66 90 xchg %ax,%ax 000005f0 <free>: static Header base; static Header *freep; void free(void *ap) { 5f0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5f1: a1 40 0a 00 00 mov 0xa40,%eax { 5f6: 89 e5 mov %esp,%ebp 5f8: 57 push %edi 5f9: 56 push %esi 5fa: 53 push %ebx 5fb: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 5fe: 8d 4b f8 lea -0x8(%ebx),%ecx 601: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 608: 39 c8 cmp %ecx,%eax 60a: 8b 10 mov (%eax),%edx 60c: 73 32 jae 640 <free+0x50> 60e: 39 d1 cmp %edx,%ecx 610: 72 04 jb 616 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 612: 39 d0 cmp %edx,%eax 614: 72 32 jb 648 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 616: 8b 73 fc mov -0x4(%ebx),%esi 619: 8d 3c f1 lea (%ecx,%esi,8),%edi 61c: 39 fa cmp %edi,%edx 61e: 74 30 je 650 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 620: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 623: 8b 50 04 mov 0x4(%eax),%edx 626: 8d 34 d0 lea (%eax,%edx,8),%esi 629: 39 f1 cmp %esi,%ecx 62b: 74 3a je 667 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 62d: 89 08 mov %ecx,(%eax) freep = p; 62f: a3 40 0a 00 00 mov %eax,0xa40 } 634: 5b pop %ebx 635: 5e pop %esi 636: 5f pop %edi 637: 5d pop %ebp 638: c3 ret 639: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 640: 39 d0 cmp %edx,%eax 642: 72 04 jb 648 <free+0x58> 644: 39 d1 cmp %edx,%ecx 646: 72 ce jb 616 <free+0x26> { 648: 89 d0 mov %edx,%eax 64a: eb bc jmp 608 <free+0x18> 64c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 650: 03 72 04 add 0x4(%edx),%esi 653: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 656: 8b 10 mov (%eax),%edx 658: 8b 12 mov (%edx),%edx 65a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 65d: 8b 50 04 mov 0x4(%eax),%edx 660: 8d 34 d0 lea (%eax,%edx,8),%esi 663: 39 f1 cmp %esi,%ecx 665: 75 c6 jne 62d <free+0x3d> p->s.size += bp->s.size; 667: 03 53 fc add -0x4(%ebx),%edx freep = p; 66a: a3 40 0a 00 00 mov %eax,0xa40 p->s.size += bp->s.size; 66f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 672: 8b 53 f8 mov -0x8(%ebx),%edx 675: 89 10 mov %edx,(%eax) } 677: 5b pop %ebx 678: 5e pop %esi 679: 5f pop %edi 67a: 5d pop %ebp 67b: c3 ret 67c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000680 <malloc>: return freep; } void* malloc(uint nbytes) { 680: 55 push %ebp 681: 89 e5 mov %esp,%ebp 683: 57 push %edi 684: 56 push %esi 685: 53 push %ebx 686: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 689: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 68c: 8b 15 40 0a 00 00 mov 0xa40,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 692: 8d 78 07 lea 0x7(%eax),%edi 695: c1 ef 03 shr $0x3,%edi 698: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 69b: 85 d2 test %edx,%edx 69d: 0f 84 9d 00 00 00 je 740 <malloc+0xc0> 6a3: 8b 02 mov (%edx),%eax 6a5: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 6a8: 39 cf cmp %ecx,%edi 6aa: 76 6c jbe 718 <malloc+0x98> 6ac: 81 ff 00 10 00 00 cmp $0x1000,%edi 6b2: bb 00 10 00 00 mov $0x1000,%ebx 6b7: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 6ba: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 6c1: eb 0e jmp 6d1 <malloc+0x51> 6c3: 90 nop 6c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6c8: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6ca: 8b 48 04 mov 0x4(%eax),%ecx 6cd: 39 f9 cmp %edi,%ecx 6cf: 73 47 jae 718 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6d1: 39 05 40 0a 00 00 cmp %eax,0xa40 6d7: 89 c2 mov %eax,%edx 6d9: 75 ed jne 6c8 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 6db: 83 ec 0c sub $0xc,%esp 6de: 56 push %esi 6df: e8 56 fc ff ff call 33a <sbrk> if(p == (char*)-1) 6e4: 83 c4 10 add $0x10,%esp 6e7: 83 f8 ff cmp $0xffffffff,%eax 6ea: 74 1c je 708 <malloc+0x88> hp->s.size = nu; 6ec: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6ef: 83 ec 0c sub $0xc,%esp 6f2: 83 c0 08 add $0x8,%eax 6f5: 50 push %eax 6f6: e8 f5 fe ff ff call 5f0 <free> return freep; 6fb: 8b 15 40 0a 00 00 mov 0xa40,%edx if((p = morecore(nunits)) == 0) 701: 83 c4 10 add $0x10,%esp 704: 85 d2 test %edx,%edx 706: 75 c0 jne 6c8 <malloc+0x48> return 0; } } 708: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 70b: 31 c0 xor %eax,%eax } 70d: 5b pop %ebx 70e: 5e pop %esi 70f: 5f pop %edi 710: 5d pop %ebp 711: c3 ret 712: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 718: 39 cf cmp %ecx,%edi 71a: 74 54 je 770 <malloc+0xf0> p->s.size -= nunits; 71c: 29 f9 sub %edi,%ecx 71e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 721: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 724: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 727: 89 15 40 0a 00 00 mov %edx,0xa40 } 72d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 730: 83 c0 08 add $0x8,%eax } 733: 5b pop %ebx 734: 5e pop %esi 735: 5f pop %edi 736: 5d pop %ebp 737: c3 ret 738: 90 nop 739: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 740: c7 05 40 0a 00 00 44 movl $0xa44,0xa40 747: 0a 00 00 74a: c7 05 44 0a 00 00 44 movl $0xa44,0xa44 751: 0a 00 00 base.s.size = 0; 754: b8 44 0a 00 00 mov $0xa44,%eax 759: c7 05 48 0a 00 00 00 movl $0x0,0xa48 760: 00 00 00 763: e9 44 ff ff ff jmp 6ac <malloc+0x2c> 768: 90 nop 769: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 770: 8b 08 mov (%eax),%ecx 772: 89 0a mov %ecx,(%edx) 774: eb b1 jmp 727 <malloc+0xa7>
Mov #100,R6 Mov #20,R2 Mov R6,R2 And R2,R2 Loopa: INc R4 Inc R4 NOP CMP R4,R4 BNE loopa HLT
; --------------------------------------------------------------------------- ; Sprite mappings - electrocution orbs (SBZ) ; --------------------------------------------------------------------------- Map_Elec_internal: dc.w @normal-Map_Elec_internal dc.w @zap1-Map_Elec_internal dc.w @zap2-Map_Elec_internal dc.w @zap3-Map_Elec_internal dc.w @zap4-Map_Elec_internal dc.w @zap5-Map_Elec_internal @normal: dc.b 2 dc.b $F8, 4, $60, 0, $F8 dc.b 0, 6, $40, 2, $F8 @zap1: dc.b 3 dc.b $F8, 5, 0, 8, $F8 dc.b $F8, 4, $60, 0, $F8 dc.b 0, 6, $40, 2, $F8 @zap2: dc.b 5 dc.b $F8, 5, 0, 8, $F8 dc.b $F8, 4, $60, 0, $F8 dc.b 0, 6, $40, 2, $F8 dc.b $F6, $D, 0, $C, 8 dc.b $F6, $D, 8, $C, $DC @zap3: dc.b 4 dc.b $F8, 4, $60, 0, $F8 dc.b 0, 6, $40, 2, $F8 dc.b $F6, $D, 0, $C, 8 dc.b $F6, $D, 8, $C, $DC @zap4: dc.b 6 dc.b $F8, 4, $60, 0, $F8 dc.b 0, 6, $40, 2, $F8 dc.b $F6, $D, $10, $C, 8 dc.b $F6, $D, $18, $C, $DC dc.b $F6, $D, 0, $C, $24 dc.b $F6, $D, 8, $C, $C0 @zap5: dc.b 4 dc.b $F8, 4, $60, 0, $F8 dc.b 0, 6, $40, 2, $F8 dc.b $F6, $D, $10, $C, $24 dc.b $F6, $D, $18, $C, $C0 even
/* * Copyright 2014, Pythia authors (see AUTHORS file). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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. */ #include "../schema.h" #include "../comparator.h" int main() { char tup1a[16]; char tup1b[16]; char tup2 [16]; int idummy = 0; int ival1 = 4; int ival2 = 5; double dval = 4.5; Schema s1; s1.add(CT_INTEGER); s1.add(CT_INTEGER); s1.writeData(tup1a, 0, &idummy); s1.writeData(tup1a, 1, &ival1); s1.writeData(tup1b, 0, &idummy); s1.writeData(tup1b, 1, &ival2); Schema s2; s2.add(CT_DECIMAL); s2.writeData(tup2, 0, &dval); Comparator comp1 = Schema::createComparator(s1, 1, s2, 0, Comparator::Less); Comparator comp2 = Schema::createComparator(s1, 1, s2, 0, Comparator::Greater); assert(comp1.eval(tup1a, tup2)); assert(comp2.eval(tup1b, tup2)); }
#include "DHTPeerAnnounceStorage.h" #include <cstring> #include <cppunit/extensions/HelperMacros.h> #include "Exception.h" #include "util.h" #include "DownloadContext.h" #include "DHTConstants.h" #include "Peer.h" #include "FileEntry.h" #include "bittorrent_helper.h" namespace aria2 { class DHTPeerAnnounceStorageTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DHTPeerAnnounceStorageTest); CPPUNIT_TEST(testAddAnnounce); CPPUNIT_TEST_SUITE_END(); public: void testAddAnnounce(); }; CPPUNIT_TEST_SUITE_REGISTRATION(DHTPeerAnnounceStorageTest); void DHTPeerAnnounceStorageTest::testAddAnnounce() { unsigned char infohash1[DHT_ID_LENGTH]; memset(infohash1, 0xff, DHT_ID_LENGTH); unsigned char infohash2[DHT_ID_LENGTH]; memset(infohash2, 0xf0, DHT_ID_LENGTH); DHTPeerAnnounceStorage storage; storage.addPeerAnnounce(infohash1, "192.168.0.1", 6881); storage.addPeerAnnounce(infohash1, "192.168.0.2", 6882); storage.addPeerAnnounce(infohash2, "192.168.0.3", 6883); storage.addPeerAnnounce(infohash2, "192.168.0.4", 6884); std::vector<SharedHandle<Peer> > peers; storage.getPeers(peers, infohash2); CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size()); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), peers[0]->getIPAddress()); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.4"), peers[1]->getIPAddress()); } } // namespace aria2
; A266074: Total number of OFF (white) cells after n iterations of the "Rule 3" elementary cellular automaton starting with a single ON (black) cell. ; 0,2,6,8,16,18,30,32,48,50,70,72,96,98,126,128,160,162,198,200,240,242,286,288,336,338,390,392,448,450,510,512,576,578,646,648,720,722,798,800,880,882,966,968,1056,1058,1150,1152,1248,1250,1350,1352,1456,1458,1566,1568,1680,1682,1798,1800,1920,1922,2046,2048,2176,2178,2310,2312,2448,2450,2590,2592,2736,2738,2886,2888,3040,3042,3198,3200,3360,3362,3526,3528,3696,3698,3870,3872,4048,4050,4230,4232,4416,4418,4606,4608,4800,4802,4998,5000,5200,5202,5406,5408,5616,5618,5830,5832,6048,6050,6270,6272,6496,6498,6726,6728,6960,6962,7198,7200,7440,7442,7686,7688,7936,7938,8190,8192,8448,8450,8710,8712,8976,8978,9246,9248,9520,9522,9798,9800,10080,10082,10366,10368,10656,10658,10950,10952,11248,11250,11550,11552,11856,11858,12166,12168,12480,12482,12798,12800,13120,13122,13446,13448,13776,13778,14110,14112,14448,14450,14790,14792,15136,15138,15486,15488,15840,15842,16198,16200,16560,16562,16926,16928,17296,17298,17670,17672,18048,18050,18430,18432,18816,18818,19206,19208,19600,19602,19998,20000,20400,20402,20806,20808,21216,21218,21630,21632,22048,22050,22470,22472,22896,22898,23326,23328,23760,23762,24198,24200,24640,24642,25086,25088,25536,25538,25990,25992,26448,26450,26910,26912,27376,27378,27846,27848,28320,28322,28798,28800,29280,29282,29766,29768,30256,30258,30750,30752,31248,31250 mov $1,$0 div $1,2 pow $1,2 add $1,$0 mul $1,2
.constant_pool .const 0 string [start] .const 1 string [constructor] .const 2 string [Hello world !!!] .const 3 int [1] .const 4 string [io.writeln] .const 5 string [metodo1] .const 6 string [Depois de metodo1/0] .const 7 string [metodo2] .const 8 string [Depois de metodo2/0] .const 9 string [metodo3] .const 10 string [Depois de metodo3/0] .const 11 string [Hello world in action1/0 !!!] .const 12 string [Hello world in action2/0 !!!] .const 13 string [Hello world in action3/0 !!!] .const 14 string [Depois da acao2/0 na acao 3] .end .entity start .valid_context_when (always) .method constructor ldconst 2 --> [Hello world !!!] ldconst 3 --> [1] lcall 4 --> [io.writeln] ldself mcall 5 --> [metodo1] ldconst 6 --> [Depois de metodo1/0] ldconst 3 --> [1] lcall 4 --> [io.writeln] ldself mcall 7 --> [metodo2] ldconst 8 --> [Depois de metodo2/0] ldconst 3 --> [1] lcall 4 --> [io.writeln] ldself mcall 9 --> [metodo3] ldconst 10 --> [Depois de metodo3/0] ldconst 3 --> [1] lcall 4 --> [io.writeln] exit .end .method metodo1 ldconst 11 --> [Hello world in action1/0 !!!] ldconst 3 --> [1] lcall 4 --> [io.writeln] ret .end .method metodo2 ldconst 12 --> [Hello world in action2/0 !!!] ldconst 3 --> [1] lcall 4 --> [io.writeln] ret .end .method metodo3 ldconst 13 --> [Hello world in action3/0 !!!] ldconst 3 --> [1] lcall 4 --> [io.writeln] ldself mcall 7 --> [metodo2] ldconst 14 --> [Depois da acao2/0 na acao 3] ldconst 3 --> [1] lcall 4 --> [io.writeln] ret .end .end
# MIPS32 assembly code bubble sort ADDI R3, R0, 100 # begin idx ADDI R4, R0, 102 # min idx ADDI R5, R0, 109 # max idx, total 10 Begin: ADDI R1, R3, 0 # pos one ADDI R2, R3, 1 # pos two Comp: LW R11, 0(R1) LW R12, 0(R2) OR R20, R20, R20 # dummy SLT R13, R11, R12 OR R20, R20, R20 # dummy BNEQZ R13, Inc OR R20, R20, R20 # dummy SW R11, 0(R2) # swap SW R12, 0(R1) Inc: SLT R22, R2, R5 OR R20, R20, R20 # dummy BEQZ R22, Cond # finish condition check OR R20, R20, R20 # dummy ADDI R1, R1, 1 ADDI R2, R2, 1 BEQZ R0, Comp # next OR R20, R20, R20 # dummy Cond: SLT R21, R4, R5 OR R20, R20, R20 # dummy BEQZ R21, Done OR R20, R20, R20 # dummy SUBI R5, R5, 1 BEQZ R0, Begin # rewind OR R20, R20, R20 # dummy Done: HLT
//---------------------------------------------------------------------------// // Copyright (c) 2020 Mikhail Komarov <nemo@nil.foundation> // // Distributed under the terms and conditions of the BSD 3-Clause License or // (at your option) under the terms and conditions of the Boost Software // License 1.0. See accompanying files LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt. //---------------------------------------------------------------------------// #pragma once #include <nil/actor/cuda/global.hpp> namespace nil { namespace actor { namespace cuda { class nd_range { public: nd_range(const opencl::dim_vec &dimensions, const opencl::dim_vec &offsets = {}, const opencl::dim_vec &local_dimensions = {}) : dims_ {dimensions}, offset_ {offsets}, local_dims_ {local_dimensions} { // nop } nd_range(opencl::dim_vec &&dimensions, opencl::dim_vec &&offsets = {}, opencl::dim_vec &&local_dimensions = {}) : dims_ {std::move(dimensions)}, offset_ {std::move(offsets)}, local_dims_ {std::move(local_dimensions)} { // nop } nd_range(const nd_range &) = default; nd_range(nd_range &&) = default; nd_range &operator=(const nd_range &) = default; nd_range &operator=(nd_range &&) = default; const opencl::dim_vec &dimensions() const { return dims_; } const opencl::dim_vec &offsets() const { return offset_; } const opencl::dim_vec &local_dimensions() const { return local_dims_; } private: opencl::dim_vec dims_; opencl::dim_vec offset_; opencl::dim_vec local_dims_; }; } // namespace cuda } // namespace actor } // namespace nil
/* ======================================== * C5RawChannel - C5RawChannel.h * Copyright (c) 2016 airwindows, All rights reserved * ======================================== */ #ifndef __C5RawChannel_H #include "C5RawChannel.h" #endif AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new C5RawChannel(audioMaster);} C5RawChannel::C5RawChannel(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, kNumPrograms, kNumParameters) { A = 0.0; lastFXChannelL = 0.0; lastSampleChannelL = 0.0; lastFXChannelR = 0.0; lastSampleChannelR = 0.0; fpNShapeL = 0.0; fpNShapeR = 0.0; //this is reset: values being initialized only once. Startup values, whatever they are. _canDo.insert("plugAsChannelInsert"); // plug-in can be used as a channel insert effect. _canDo.insert("plugAsSend"); // plug-in can be used as a send effect. _canDo.insert("x2in2out"); setNumInputs(kNumInputs); setNumOutputs(kNumOutputs); setUniqueID(kUniqueId); canProcessReplacing(); // supports output replacing canDoubleReplacing(); // supports double precision processing programsAreChunks(true); vst_strncpy (_programName, "Default", kVstMaxProgNameLen); // default program name } C5RawChannel::~C5RawChannel() {} VstInt32 C5RawChannel::getVendorVersion () {return 1000;} void C5RawChannel::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} void C5RawChannel::getProgramName(char *name) {vst_strncpy (name, _programName, kVstMaxProgNameLen);} //airwindows likes to ignore this stuff. Make your own programs, and make a different plugin rather than //trying to do versioning and preventing people from using older versions. Maybe they like the old one! static float pinParameter(float data) { if (data < 0.0f) return 0.0f; if (data > 1.0f) return 1.0f; return data; } VstInt32 C5RawChannel::getChunk (void** data, bool isPreset) { float *chunkData = (float *)calloc(kNumParameters, sizeof(float)); chunkData[0] = A; /* Note: The way this is set up, it will break if you manage to save settings on an Intel machine and load them on a PPC Mac. However, it's fine if you stick to the machine you started with. */ *data = chunkData; return kNumParameters * sizeof(float); } VstInt32 C5RawChannel::setChunk (void* data, VstInt32 byteSize, bool isPreset) { float *chunkData = (float *)data; A = pinParameter(chunkData[0]); /* We're ignoring byteSize as we found it to be a filthy liar */ /* calculate any other fields you need here - you could copy in code from setParameter() here. */ return 0; } void C5RawChannel::setParameter(VstInt32 index, float value) { switch (index) { case kParamA: A = value; break; default: throw; // unknown parameter, shouldn't happen! } } float C5RawChannel::getParameter(VstInt32 index) { switch (index) { case kParamA: return A; break; default: break; // unknown parameter, shouldn't happen! } return 0.0; //we only need to update the relevant name, this is simple to manage } void C5RawChannel::getParameterName(VstInt32 index, char *text) { switch (index) { case kParamA: vst_strncpy (text, "Center", kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } //this is our labels for displaying in the VST host } void C5RawChannel::getParameterDisplay(VstInt32 index, char *text) { switch (index) { case kParamA: float2string (A, text, kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } //this displays the values and handles 'popups' where it's discrete choices } void C5RawChannel::getParameterLabel(VstInt32 index, char *text) { switch (index) { case kParamA: vst_strncpy (text, "", kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } } VstInt32 C5RawChannel::canDo(char *text) { return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know bool C5RawChannel::getEffectName(char* name) { vst_strncpy(name, "C5RawChannel", kVstMaxProductStrLen); return true; } VstPlugCategory C5RawChannel::getPlugCategory() {return kPlugCategEffect;} bool C5RawChannel::getProductString(char* text) { vst_strncpy (text, "airwindows C5RawChannel", kVstMaxProductStrLen); return true; } bool C5RawChannel::getVendorString(char* text) { vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; }
#include "NumberSourceDataModel.hpp" #include <QtCore/QJsonValue> #include <QtGui/QDoubleValidator> #include "DecimalData.hpp" NumberSourceDataModel:: NumberSourceDataModel() : _lineEdit(new QLineEdit()) { _lineEdit->setValidator(new QDoubleValidator()); _lineEdit->setMaximumSize(_lineEdit->sizeHint()); connect(_lineEdit, &QLineEdit::textChanged, this, &NumberSourceDataModel::onTextEdited); _lineEdit->setText("0.0"); } QJsonObject NumberSourceDataModel:: save() const { QJsonObject modelJson = NodeDataModel::save(); if (_number) modelJson["number"] = QString::number(_number->number()); return modelJson; } void NumberSourceDataModel:: restore(QJsonObject const &p) { QJsonValue v = p["number"]; if (!v.isUndefined()) { QString strNum = v.toString(); bool ok; double d = strNum.toDouble(&ok); if (ok) { _number = std::make_shared<DecimalData>(d); _lineEdit->setText(strNum); } } } unsigned int NumberSourceDataModel:: nPorts(PortType portType) const { unsigned int result = 1; switch (portType) { case PortType::In: result = 0; break; case PortType::Out: result = 1; default: break; } return result; } void NumberSourceDataModel:: onTextEdited(QString const &string) { Q_UNUSED(string); bool ok = false; double number = _lineEdit->text().toDouble(&ok); if (ok) { _number = std::make_shared<DecimalData>(number); Q_EMIT dataUpdated(0); } else { Q_EMIT dataInvalidated(0); } } const NodeDataType& NumberSourceDataModel:: dataType(PortType, PortIndex) const { return DecimalData().type(); } std::shared_ptr<NodeData> NumberSourceDataModel:: outData(PortIndex) { return _number; }
[bits 32] [extern _KERNEL_START] ;_bc] [extern _ATA_ack] [extern _exc_ack] [extern _keyb_irq] ADDR_CONST equ 0x1000 lidt [idt_descr] ;SET PIC mov al, 0x11 out 0x20, al out 0xA0, al mov al, 40 out 0x21, al mov al, 32 out 0xA1, al mov al, 0x4 out 0x21, al mov al, 0x2 out 0xA1, al ;ICW4 mov al, 0x0 out 0x21, al out 0xA1, al ;MASK mov al, 0x1 out 0x21, al mov al, 0x0 out 0xA1, al sti jmp _KERNEL_START ;in case of error, print a red pixel on top left corner mov [0xa0000], byte 4 cli hlt ;INTERRUPT SERVICE ROUTINES ;----------------------------------------------------- timer_handler: pushad mov al, 0x20 out 0x20, al mov al, 0xA0 out 0x20, al popad iret ;----------------------------------------------------- isr_keyboard: pushad call _keyb_irq mov al, 0x20 out 0x20, al mov al, 0xA0 out 0x20, al popad iret ;----------------------------------------------------- ATA_handler: pushad call _ATA_ack mov al, 0x20 out 0x20, al mov al, 0xA0 out 0x20, al popad iret ;----------------------------------------------------- exception_handler: pushad call _exc_ack popad cli hlt ;----------------------------------------------------- hwi_handler: pushad mov al, 0x20 out 0x20, al mov al, 0xA0 out 0x20, al popad iret ;----------------------------------------------------- swi_handler: pushad popad iret ;---DATA STRUCTURES--- ;IDT ;offseta_1 dw 0x0 ;selector dw 0x0 ;zero db 0x0 ;type_attr db 0x0 ;offsetb_1 dw 0x0 ;allocate 400 byte(50 irs descriptor) idt_start: dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Divide-by-zero Error dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Debug dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Non-maskable Interrupt dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Breakpoint dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Overflow dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Bound Range Exceeded dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Invalid Opcode dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Device Not Available dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Double Fault dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Coprocessor Segment Overrun(deleted on osdev) dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;-------first 10 isr dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Invalid TSS dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Segment Not Present dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Stack-Segment Fault dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;General Protection Fault dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Page Fault dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;x87 Floating-Point Exception dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Alignment Check dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Machine Check dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;SIMD Floating-Point Exception dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;-------first 20 isr dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Virtualization Exception dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;-------first 30 isr dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Security Exception dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + exception_handler - $$) & 0xFFFF ;Reserved dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + exception_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;CMOS real-time clock dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;Free for peripherals / legacy SCSI / NIC dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;Free for peripherals / SCSI / NIC dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;Free for peripherals / SCSI / NIC dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;PS2 Mouse dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;FPU / Coprocessor / Inter-processor dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + ATA_handler - $$) & 0xFFFF ;Primary ATA Hard Disk dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + ATA_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;Secondary ATA Hard Disk dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;-------first 40 isr dw (ADDR_CONST + timer_handler - $$) & 0xFFFF ;Programmable Interrupt Timer Interrupt dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + timer_handler - $$) >> 16 ;------- dw (ADDR_CONST + isr_keyboard - $$) & 0xFFFF ;Keyboard Interrupt dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + isr_keyboard - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;Cascade (used internally by the two PICs. never raised) dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;COM2 (if enabled) dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;COM1 (if enabled) dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;LPT2 (if enabled) dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;Floppy Disk dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + hwi_handler - $$) & 0xFFFF ;LPT1 / Unreliable "spurious" interrupt (usually) dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + hwi_handler - $$) >> 16 ;------- dw (ADDR_CONST + swi_handler - $$) & 0xFFFF ;free slot interrupt dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + swi_handler - $$) >> 16 ;------- dw (ADDR_CONST + swi_handler - $$) & 0xFFFF ;free slot interrupt dw 0x8 db 0x0 db 0x8E dw (ADDR_CONST + swi_handler - $$) >> 16 ;-------first 50 isr ;PIC hardware interrupt idt_end: ;IDT DESCR idt_descr: dw idt_end - idt_start dd idt_start dw 0x77EE ;signature showing end of kernel entry file, for debug purpose.
// file_input.hpp // Copyright (c) 2008-2009 Ben Hanson (http://www.benhanson.net/) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_FILE_INPUT_HPP #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_FILE_INPUT_HPP #include "char_traits.hpp" // memcpy #include <cstring> #include <fstream> #include "size_t.hpp" #include "state_machine.hpp" namespace boost { namespace lexer { template<typename CharT, typename Traits = char_traits<CharT> > class basic_file_input { public: class iterator { public: friend class basic_file_input; struct data { std::size_t id; std::size_t unique_id; const CharT *start; const CharT *end; std::size_t state; // Construct in end() state. data () : id (0), unique_id (npos), state (npos) { } bool operator == (const data &rhs_) const { return id == rhs_.id && unique_id == rhs_.unique_id && start == rhs_.start && end == rhs_.end && state == rhs_.state; } }; iterator () : _input (0) { } bool operator == (const iterator &rhs_) const { return _data == rhs_._data; } bool operator != (const iterator &rhs_) const { return !(*this == rhs_); } data &operator * () { return _data; } data *operator -> () { return &_data; } // Let compiler generate operator = (). // prefix version iterator &operator ++ () { next_token (); return *this; } // postfix version iterator operator ++ (int) { iterator iter_ = *this; next_token (); return iter_; } void next_token () { const detail::internals &internals_ = _input->_state_machine->data (); _data.start = _data.end; if (internals_._dfa->size () == 1) { _data.id = _input->next (&internals_._lookup->front ()-> front (), internals_._dfa_alphabet.front (), &internals_._dfa->front ()->front (), _data.start, _data.end, _data.unique_id); } else { _data.id = _input->next (internals_, _data.state, _data.start, _data.end, _data.unique_id); } if (_data.id == 0) { _data.start = 0; _data.end = 0; // Ensure current state matches that returned by end(). _data.state = npos; } } private: // Not owner (obviously!) basic_file_input *_input; data _data; }; friend class iterator; // Make it explicit that we are NOT taking a copy of state_machine_! basic_file_input (const basic_state_machine<CharT> *state_machine_, std::basic_ifstream<CharT> *is_, const std::streamsize buffer_size_ = 4096, const std::streamsize buffer_increment_ = 1024) : _state_machine (state_machine_), _stream (is_), _buffer_size (buffer_size_), _buffer_increment (buffer_increment_), _buffer (_buffer_size, '!') { _start_buffer = &_buffer.front (); _end_buffer = _start_buffer + _buffer.size (); _start_token = _end_buffer; _end_token = _end_buffer; } iterator begin () { iterator iter_; iter_._input = this; // Over-ride default of 0 (EOF) iter_._data.id = npos; iter_._data.start = 0; iter_._data.end = 0; iter_._data.state = 0; ++iter_; return iter_; } iterator end () { iterator iter_; iter_._input = this; iter_._data.start = 0; iter_._data.end = 0; return iter_; } void flush () { // This temporary is mandatory, otherwise the // pointer calculations won't work! const CharT *temp_ = _end_buffer; _start_token = _end_token = _end_buffer; reload_buffer (temp_, true, _end_token); } private: typedef std::basic_istream<CharT> istream; typedef std::vector<CharT> buffer; const basic_state_machine<CharT> *_state_machine; const std::streamsize _buffer_size; const std::streamsize _buffer_increment; buffer _buffer; CharT *_start_buffer; istream *_stream; const CharT *_start_token; const CharT *_end_token; CharT *_end_buffer; std::size_t next (const detail::internals &internals_, std::size_t &start_state_, const CharT * &start_, const CharT * &end_, std::size_t &unique_id_) { _start_token = _end_token; again: const std::size_t * lookup_ = &internals_._lookup[start_state_]-> front (); std::size_t dfa_alphabet_ = internals_._dfa_alphabet[start_state_]; const std::size_t *dfa_ = &internals_._dfa[start_state_]->front (); const std::size_t *ptr_ = dfa_ + dfa_alphabet_; const CharT *curr_ = _start_token; bool end_state_ = *ptr_ != 0; std::size_t id_ = *(ptr_ + id_index); std::size_t uid_ = *(ptr_ + unique_id_index); const CharT *end_token_ = curr_; for (;;) { if (curr_ >= _end_buffer) { if (!reload_buffer (curr_, end_state_, end_token_)) { // EOF break; } } const std::size_t BOL_state_ = ptr_[bol_index]; const std::size_t EOL_state_ = ptr_[eol_index]; if (BOL_state_ && (_start_token == _start_buffer || *(_start_token - 1) == '\n')) { ptr_ = &dfa_[BOL_state_ * dfa_alphabet_]; } else if (EOL_state_ && *curr_ == '\n') { ptr_ = &dfa_[EOL_state_ * dfa_alphabet_]; } else { const std::size_t state_ = ptr_[lookup_[static_cast<typename Traits::index_type> (*curr_++)]]; if (state_ == 0) { break; } ptr_ = &dfa_[state_ * dfa_alphabet_]; } if (*ptr_) { end_state_ = true; id_ = *(ptr_ + id_index); uid_ = *(ptr_ + unique_id_index); start_state_ = *(ptr_ + state_index); end_token_ = curr_; } } if (_start_token >= _end_buffer) { // No more tokens... unique_id_ = npos; return 0; } const std::size_t EOL_state_ = ptr_[eol_index]; if (EOL_state_ && curr_ == end_) { ptr_ = &dfa_[EOL_state_ * dfa_alphabet_]; if (*ptr_) { end_state_ = true; id_ = *(ptr_ + id_index); uid_ = *(ptr_ + unique_id_index); start_state_ = *(ptr_ + state_index); end_token_ = curr_; } } if (end_state_) { // return longest match _end_token = end_token_; if (id_ == 0) goto again; } else { // No match causes char to be skipped _end_token = _start_token + 1; id_ = npos; uid_ = npos; } start_ = _start_token; end_ = _end_token; unique_id_ = uid_; return id_; } std::size_t next (const std::size_t * const lookup_, const std::size_t dfa_alphabet_, const std::size_t * const dfa_, const CharT * &start_, const CharT * &end_, std::size_t &unique_id_) { _start_token = _end_token; const std::size_t *ptr_ = dfa_ + dfa_alphabet_; const CharT *curr_ = _start_token; bool end_state_ = *ptr_ != 0; std::size_t id_ = *(ptr_ + id_index); std::size_t uid_ = *(ptr_ + unique_id_index); const CharT *end_token_ = curr_; for (;;) { if (curr_ >= _end_buffer) { if (!reload_buffer (curr_, end_state_, end_token_)) { // EOF break; } } const std::size_t BOL_state_ = ptr_[bol_index]; const std::size_t EOL_state_ = ptr_[eol_index]; if (BOL_state_ && (_start_token == _start_buffer || *(_start_token - 1) == '\n')) { ptr_ = &dfa_[BOL_state_ * dfa_alphabet_]; } else if (EOL_state_ && *curr_ == '\n') { ptr_ = &dfa_[EOL_state_ * dfa_alphabet_]; } else { const std::size_t state_ = ptr_[lookup_[static_cast<typename Traits::index_type> (*curr_++)]]; if (state_ == 0) { break; } ptr_ = &dfa_[state_ * dfa_alphabet_]; } if (*ptr_) { end_state_ = true; id_ = *(ptr_ + id_index); uid_ = *(ptr_ + unique_id_index); end_token_ = curr_; } } if (_start_token >= _end_buffer) { // No more tokens... unique_id_ = npos; return 0; } const std::size_t EOL_state_ = ptr_[eol_index]; if (EOL_state_ && curr_ == end_) { ptr_ = &dfa_[EOL_state_ * dfa_alphabet_]; if (*ptr_) { end_state_ = true; id_ = *(ptr_ + id_index); uid_ = *(ptr_ + unique_id_index); end_token_ = curr_; } } if (end_state_) { // return longest match _end_token = end_token_; } else { // No match causes char to be skipped _end_token = _start_token + 1; id_ = npos; uid_ = npos; } start_ = _start_token; end_ = _end_token; unique_id_ = uid_; return id_; } bool reload_buffer (const CharT * &curr_, const bool end_state_, const CharT * &end_token_) { bool success_ = !_stream->eof (); if (success_) { const CharT *old_start_token_ = _start_token; std::size_t old_size_ = _buffer.size (); std::size_t count_ = 0; if (_start_token - 1 == _start_buffer) { // Run out of buffer space, so increase. _buffer.resize (old_size_ + _buffer_increment, '!'); _start_buffer = &_buffer.front (); _start_token = _start_buffer + 1; _stream->read (_start_buffer + old_size_, _buffer_increment); count_ = _stream->gcount (); _end_buffer = _start_buffer + old_size_ + count_; } else if (_start_token < _end_buffer) { const std::size_t len_ = _end_buffer - _start_token; // Some systems have memcpy in namespace std. using namespace std; memcpy (_start_buffer, _start_token - 1, (len_ + 1) * sizeof (CharT)); _stream->read (_start_buffer + len_ + 1, static_cast<std::streamsize> (_buffer.size () - len_ - 1)); count_ = _stream->gcount (); _start_token = _start_buffer + 1; _end_buffer = _start_buffer + len_ + 1 + count_; } else { _stream->read (_start_buffer, static_cast<std::streamsize> (_buffer.size ())); count_ = _stream->gcount (); _start_token = _start_buffer; _end_buffer = _start_buffer + count_; } if (end_state_) { end_token_ = _start_token + (end_token_ - old_start_token_); } curr_ = _start_token + (curr_ - old_start_token_); } return success_; } // Disallow copying of buffer basic_file_input (const basic_file_input &); const basic_file_input &operator = (const basic_file_input &); }; typedef basic_file_input<char> file_input; typedef basic_file_input<wchar_t> wfile_input; } } #endif
; A070374: a(n) = 5^n mod 21. ; 1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20,16,17,1,5,4,20 mov $1,1 mov $2,$0 lpb $2 mul $1,5 mod $1,21 sub $2,1 lpe mov $0,$1
#include <bits/stdc++.h> using namespace std; const int mxm = 1000001; int main() { int T,i,j,n; int sv[mxm], return 0; }
; A097299: Ninth column (m=8) of (1,6)-Pascal triangle A096956. ; Submitted by Jamie Morken(s2) ; 6,49,225,765,2145,5247,11583,23595,45045,81510,140998,234702,377910,591090,901170,1343034,1961256,2812095,3965775,5509075,7548255,10212345,13656825,18067725,23666175,30713436,39516444,50433900,63882940 mov $1,$0 add $0,7 bin $0,$1 add $1,48 mul $0,$1 mul $0,7 div $0,56
; Robert French has permitted making the enclosed freely downloadable with the ; following copyright notice: ; ; This material is licensed under Attribution-ShareAlike 4.0 International ; (CC BY-SA 4.0) https://creativecommons.org/licenses/by-sa/4.0/ ; ; [Sep 2020 Tim Halloran] Original code for floppy disk version of the driver. ; ; ORG 0B000H ;FOR 32K MACHINES ORG 0F000H ;FOR 48K MACHINES ; GO JP INIDOS ; INIT1 JP MODE1 ;INITIALIZE MODE 1 GRAPHICS INIT2 JP MODE2 ;INITIALIZE MODE 2 GRAPHICS CLS JP CLEAR ;CLEAR SCREEN, SET BACKROUND SET JP PON ;TURN ON A POINT RESET JP POFF ;TURN OFF A POINT TEST JP PTEST ;IS POINT ON? DEFPAT JP PATERN ;MOVE SPRITE PATTERN TO VRAM DEFSPR JP SETSPR ;SET GIVEN SPRITE TO PATTERN MOVSPR JP MOVESP ;MOVE SPRITE TO X,Y COORDINATE INSPR JP INITSP ;SET ALL SPRITE PATTERNS TO ZEROS ; LINE JP DRLINE ;DRAW LINE FILL JP FILLER ;FILL AREA WRSTR JP STRING ;WRITE STRING WRINT JP INTGER ;WRITE INTERGER ; TONE JP SOUND ;OUTPUT TONE RDPAD JP PADDL ;READ ATARI PADDLE RDJOY JP FORJOY ;READ ATARI JOYSTICK ; COLOR DEFB 1FH ;FORGROUND/BACKROUND BKDROP DEFB 0CH ;BACKDROP COLOR XCOR DEFB 0 YCOR DEFB 0 XLINE DEFW 0 YLINE DEFW 0 XPRIME DEFB 0 YPRIME DEFB 0 SCOLOR DEFB 0 SPATRN DEFS 32 SPNUM DEFB 0 PNUM DEFB 0 SPXCOR DEFB 0 SPYCOR DEFB 0 INTNUM DEFW 0 STRADR DEFW 0 STRLEN DEFB 0 FREQ DEFB 0 AMP DEFB 0 DUR DEFB 0 JOYSTK DEFB 0 IFLAG DEFB 0 ; STATUS EQU 79H ;READ STATUS PORT REG EQU 79H ;WRITE REG PORT ADDR EQU 79H ;WRITE VRAM DATA ADDR DATA EQU 78H ;READ/WRITE VRAM DATA ; INIDOS LD HL,GO LD A,(125H) ;CHECK MODEL i OR iii CP 49H ;IF MODiii THEN YES JP Z,MODIII LD (4049H),HL ;MOD i JP CONT MODIII LD (4411H),HL ;MODIII CONT CALL MODE2 CALL CLS CALL INSPR LD HL,LINE1 CALL IMESG LD HL,LINE2 CALL IMESG LD HL,LINE3 CALL IMESG LD HL,LINE4 CALL IMESG CALL CBAR JP 402DH ; LINE1 DEFW 140AH ;X COR,Y COR,STR LEN,COLOR DEFW 6F26H ; DEFM 'CHROMAtrs 32K Diskette Software, V 1.1' DEFM 'CHROMAtrs 48k Diskette Software, V 1.1' LINE2 DEFW 1414H DEFW 5F27H DEFM '(C) 1982, SOUTH SHORE COMPUTER CONCEPTS' LINE3 DEFW 141EH DEFW 0DF21H DEFM '1590 BROADWAY, HEWLETT, NY 11557 ' LINE4 DEFW 1428H DEFW 0CF23H DEFM 'ORDERS & INFO: (516) 569-4390 ' LINE5 DEFW 64B4H ; IMESG LD A,(HL) ;PLACE 4 PARAMETERS & STR ADDRESS LD (YCOR),A ;INTO PROPER MEM LOC'S INC HL LD A,(HL) LD (XCOR),A INC HL LD A,(HL) LD (STRLEN),A INC HL LD A,(HL) LD (COLOR),A INC HL LD (STRADR),HL CALL WRSTR RET ; CBAR LD HL,LINE6+4 ;CREATE BARS LD B,26 ; # OF CHARECTERS LD A,91 ;CHAR VALUE (FULL BLOCK) ICBLP LD (HL),A INC HL DJNZ ICBLP CBARLP LD A,(LINE6) ;INC Y BY 8 ADD A,8 LD (LINE6),A LD A,(LINE6+1) ;INC X BY 4 ADD A,4 LD (LINE6+1),A LD A,(LINE6+3) ;CHANGE COLOR OF BAR ADD A,10H CP 0FFH RET Z LD (LINE6+3),A LD HL,LINE6 CALL IMESG JP CBARLP LINE6 DEFW 2430H DEFW 0F16H DEFM ' ' ; PORTON PUSH AF ;ENABLE SYSTEM I/O BUS LD A,10H OUT (0ECH),A IN A,(REG) ;TMS9918A STATUS POP AF RET ; ; ROUTINE TO WRITE AN ADDRESS IN VRAM ; ADDRESS IN HL, DATA IN A RAMOUT CALL PORTON ;ENABLE I/O BUS LD C,REG ;WRITE REG PORT SET 6,H ;SEE TABLE 2-1 OF TMS9918A MANUAL RES 7,H OUT (C),L ;OUTPUT ADDRESS OUT (C),H NOP OUT (DATA),A ;SEND DATA TO VRAM RET ; ; ADDRESS IN HL, DATA RETURNED IN A RAMIN CALL PORTON LD C,REG ;WRITE REG PORT RES 6,H ;SEE TABLE 2-1 OF TMS9918A MANUAL RES 7,H OUT (C),L OUT (C),H NOP IN A,(DATA) ;GET DATA RET ; ; ROUTINE TO WRITE DATA TO A REGISTER ; DATA IN A, REG # IN B REGOUT CALL PORTON ;SEE TABLE 2-1 OF TMS9918A MANUAL OUT (REG),A LD A,B OR 80H OUT (REG),A RET ; ; ROUTINE TO INITILIZE MODE 2 GRAPHICS ; MODE2 LD HL,M2TBL ;DATA LD B,6 ;REGISTER # LP0 LD A,(HL) CALL REGOUT ;OUT DATA TO REGISTERS INC HL DEC B JP P,LP0 RET ; M2TBL DEFB 7 ;SEE SECTIONS 2.2 TO 2.7 OF DEFB 56 ;TMS9918A MANUAL DEFB 3 DEFB 255 DEFB 6 DEFB 0C2H DEFB 2 ; ; ROUTINE TO CLEAR THE SCREEN, ; SET BACKROUND & BACKDROP ; FIRST WRITE PATTERN NAME TABLE... CLEAR XOR A LD HL,1800H ;BASE OF NAME TABLE CALL RAMOUT LD B,3 LP1 INC A ;SEQUENTIAL DATA TO VRAM SENT OUT (DATA),A ;W/O UPDATING ADDRESS JP NZ,LP1 ;(SEE TABLE 2-1 AGAIN!) DJNZ LP1 ; CLEAR PATTERN TABLE TO ZEROS LD HL,0 XOR A CALL RAMOUT LD HL,17FFH ;PATTERN TABLE -1 LD BC,1 LP2 OUT (DATA),A ;ZAP PATTERN TABLE SBC HL,BC JP NZ,LP2 ; CLEAR COLOR TABLE LD HL,2000H XOR A LD A,(COLOR) ;OUT FIRST BYTE CALL RAMOUT LD HL,17FFH LD BC,1 LP3 OUT (DATA),A ;OUT REST OF BYTES SBC HL,BC JP NZ,LP3 LD A,(BKDROP) ;SEE TMS9918A MANUAL LD B,7 ;SECTION 2.2.8 CALL REGOUT RET ; ; ROUTINE TO TRANSLATE X,Y COORDINATE TO ; A VRAM LOCATION AND GET IT INTO THE A REGISTER BIT DEFB 0 BYTE DEFB 0 XYCALC LD A,(XCOR) ;DETERMIN BIT SET CPL ;BY DIVIDING BY 8 AND 7 ;AND COMPLEMENTING THE REMAINDER LD (BIT),A LD A,(YCOR) ;DIV Y BY 8 & STORE AND 7 LD (BYTE),A LD H,0 LD A,(YCOR) ;CALC # OF 8X8 ROWS ABOVE AND 0F8H LD L,A ADD HL,HL ADD HL,HL LD A,(XCOR) ;DIV X BY 8 SRL A SRL A SRL A ADD A,L ;ADD # 8X8 ROWS ABOVE TO # LEFT LD L,A ;OF THE POINT ADD HL,HL ;MULTIPLY # 8X8 PATS BY 8 AND ADD HL,HL ADD HL,HL LD B,0 ;ADD Y/8 REMAINDER = ADDRESS LD A,(BYTE) LD C,A ADD HL,BC CALL RAMIN ;GET DATA FROM ADDRESS RET ; MODE1 RET ;NOT AVAILABLE PON CALL XYCALC ;CONVERT TO VRAM ADDRESS PUSH AF ;SAVE DATA LD A,(BIT) ;GET BIT TO SET SLA A ;POSITION SO BIT SET IS IN POS SLA A ;5, 4, & 3 SLA A OR 0C7H ;SET BITS 6,7,0,1,&2 LD (INS+1),A ;SEE Z80 MANUAL 'SET B,R POP AF INS SET 0,A ;NOW SET WITH PROPER BIT CALL RAMOUT ;SET POINT LD BC,2000H ;OFFSET TO COLOR TABLE LD A,(COLOR) ;& CHANGE PTS COLOR ADD HL,BC CALL RAMOUT RET ; POFF CALL XYCALC ;SEE PON PUSH AF LD A,(BIT) SLA A SLA A SLA A OR 087H ;SEE PON & Z80 MANUAL 'RES B,R LD (INS1+1),A POP AF INS1 RES 0,A CALL RAMOUT RET PTEST CALL XYCALC ;SEE PON PUSH AF LD A,(BIT) SLA A SLA A SLA A OR 47H ;SEE PON & Z80 MANUAL 'BIT B,R LD (INS2+1),A POP AF INS2 BIT 0,A ;TEST BIT JP Z,CLR ;RETURN SET LD A,0 LD (JOYSTK),A RET CLR LD A,0FFH ;RETURN RESET LD (JOYSTK),A RET ; ; ROUTINE TO CLEAR THE SPRITE ATTRIBUTE TABLE INITSP XOR A ;SIMPLY ZAP THE 2K TABLE LD HL,3800H ;TABLE ADDRESS CALL RAMOUT LD HL,2047 ;LENGTH -1 LD BC,1 LP4 OUT (DATA),A ;ZAP THE REST SBC HL,BC JP NZ,LP4 RET ; ; ROUTINE TO MOVE A PATTERN IN RAM TO THE ; SPRITE # GIVEN. PATERN LD H,0 LD A,(SPNUM) LD L,A LD B,5 LP5 ADD HL,HL ;SPNUM*32 DJNZ LP5 LD BC,3800H ADD HL,BC ;SPNUM*32+3800H -> VRAM ADDRESS LD A,(SPATRN) ;OUTPUT FIRST BYTE CALL RAMOUT LD C,DATA ;SET CONDITIONS FOR OUTI LD HL,SPATRN+1 LD B,31 LP6 OUTI ;OUTPUT 31 SUBSEQUENT BYTES JP NZ,LP6 ; ; ROUTINE TO SET A SPRITE TO A PATTERN SETSPR LD H,0 LD A,(SPNUM) LD L,A ADD HL,HL ADD HL,HL ;SPNUM*4 LD BC,7170 ;BASE ADDRESS + 2 -> NAME POINTER ADD HL,BC ;SPNUM*4 + BASE ADDRESS LD A,(PNUM) ;PATTERN # SPRITE CALL RAMOUT LD A,(SCOLOR) ;COLOR FOR SPRITE OUT (DATA),A ;SET SPRITE COLOR RET ; ; ROUTINE TO MOVE THE PSRITE TO AN X,Y LOCATION. MOVESP LD H,0 LD A,(SPNUM) LD L,A ADD HL,HL ;SPRITE # X 4 ADD HL,HL LD BC,7168 ;BASE ADDRESS ADD HL,BC ;GET ADDRESS FOR "Y" LD A,(SPYCOR) ;OUTPUT y COORDINATE CALL RAMOUT LD A,(SPXCOR) ;OUTPUT X COORDINATE OUT (DATA),A RET ; ; ROUTINE TO DRAW A LINE BETWEEN TWO POINTS XSLOPE DEFB 0 YSLOPE DEFB 0 DRLINE XOR A LD (YADD+1),A ;MAKE SURE ZERO LD A,(XLINE) ;IF X > OR = X' NXTST LD B,A LD A,(XPRIME) CP B JP Z,NXTST JP NC,NXTST LD (XLINE),A ;EX X & X' LD A,B LD (XPRIME),A LD A,(YLINE) ;EX Y & Y' LD B,A LD A,(YPRIME) LD (YLINE),A LD A,B LD (YPRIME),A NXTST LD A,(YLINE) ;IF Y > OR = Y' THEN DRAW LD B,A LD A,(YPRIME) CP B JP Z,DRAWLN JP NC,DRAWLN LD A,255 ;MAKE Y OFFSET NEG 1 LD (YADD+1),A DRAWLN LD A,(XLINE) ;COMPUTE DIFFERENCE LD B,A ;IN X VALS & STORE LD A,(XPRIME) ;COMP DIFF IN Y VALS SUB B ;STORE LD C,A LD A,(YLINE) LD B,A LD A,(YPRIME) SUB B LD B,8 BEXIT LD (YSLOPE),A ;DIFF IN Y VALS=YSLOPE LD A,C LD (XSLOPE),A ;DIFF IN X VALS=XSLOPE LD A,(XLINE) LD (XLINE+1),A ;PUT STARTING X & Y IN LD A,(YLINE) ;B03BH &B03DH LD (YLINE+1),A XOR A ;ZERO B03AH &B03CH LD (XLINE),A LD (YLINE),A POINT LD A,(XLINE+1) ;XCOR=X & YCOR=Y LD (XCOR),A LD A,(YLINE+1) LD (YCOR),A CALL SET ;SET XCOR,YCOR LD A,(XCOR) ;IF X <> X' ADD XOFFSET LD B,A LD A,(XPRIME) CP B JP NZ,ADD LD A,(YCOR) ;IF Y <> Y' ADD YOFFSET LD B,A LD A,(YPRIME) CP B JP NZ,ADD RET ;IF X=X' & Y=Y' RETURN ADD LD HL,(XLINE) ;ADD X CORDINATE LD A,(XSLOPE) ;TO X OFFSET LD E,A ;& STORE LD D,0 ADD HL,DE LD (XLINE),HL LD HL,(YLINE) ;ADD Y COORDINATE LD A,(YSLOPE) ;TO Y OFFSET LD E,A ;& STORE YADD LD D,0 ADD HL,DE LD (YLINE),HL JP POINT ;NEXT POINT ; ; ;ROUTINE TO MAKE SOUNDS FROM SOUND PORT. ;VARIABLE AMPLITUDE, FREQ, AND DURATION. SOUND LD A,(DUR) LD B,A CALL PORTON XOR A LD (IFLAG),A ;ZERO IFLAG LD A,I ;GET INTERUPT STATUS JP PO,DURLP ;IF STATUS = 0 (PARITY LD A,1 ;ODD) THEN GO LD (IFLAG),A ;ELSE SAVE PARITY EVEN (1) DI DURLP LD A,B LD (CNTR),A ;SAVE DURATION LD A,(AMP) OR 80H OUT (7EH),A ;OUTPUT AMPLITUDE + 128 CALL DELAY ;DELAY FOR FREQUENCY LD A,80H ;OUTPUT 128 (NULL) OUT (7EH),A CALL DELAY ;DELAY FOR FREQUENCY LD A,(CNTR) ;GO UNLESS DURATION DONE LD B,A DJNZ DURLP LD A,(IFLAG) ;REENABLE I/O STATUS CP 0 RET Z EI RET DELAY LD A,(FREQ) LD B,A DELLP PUSH BC ;DELAY - HO HUMMMMM POP BC DJNZ DELLP RET ; CNTR DEFB 0 ; ;SCANS A STRING AND PRINTS IT ON THE SCREEN ;AT THE DESIRED LOCATION. STRING LD HL,(STRADR) ;ADDRESS LD A,(STRLEN) ;LENGTH LD B,A STRLP LD A,(HL) ;GET CHAR PUSH BC ;SAVE REGISTERS PUSH HL CALL WRITE ;PUT ON SCREEN POP HL ;RESTORE REGISTERS POP BC INC HL ;POINT NEXT DJNZ STRLP ;PRINT NEXT ELSE DONE RET ; INTGER LD A,5 ;SETUP STRING ADDRESSES LD (STRLEN),A ;5 DIGIT INTEGER # LD HL,STRBUF ;BUFFER FOR INT STRING LD (STRADR),HL ;STRADR PT TO STRBUF LD IY,FTBL LD IX,STRBUF LD B,5 ;SET BUFFER TO ZEROS LD HL,STRBUF ;ZAP FOR REENTRIES LD A,30H TLP LD (HL),A INC HL DJNZ TLP LD B,5 ;5 DIGIT LENGTH GETFTR LD E,(IY) ;CURRENT VAL TO BE TESTED INC IY LD D,(IY) ;PUT NEXT IN D INC IY ;POINT NEXT FTRLP LD HL,(INTNUM) ;INTEGER # SCF ;RESET CARRY FLAG CCF SBC HL,DE ;IF DE>HL GET NEXT DE JP C,NXFTR LD (INTNUM),HL ;STORE NEW LOWER INTNUM INC (IX) ;INCREMENT COUNTER JP FTRLP ;CHECK IF DE>HL AGAIN NXFTR INC IX DJNZ GETFTR LD B,4 ;POINT NEXT COUNTER LD HL,STRBUF ZSLP LD A,(HL) ;IF LEFT$(INT STR,1)<>0 PRINT IT CP 30H JP NZ,STRING ;ELSE TRY NEXT LD A,20H LD (HL),A INC HL DJNZ ZSLP JP STRING STRBUF DEFS 5 FTBL DEFW 10000 ;POWERS OF 10 DEFW 1000 DEFW 100 DEFW 10 DEFW 1 ; FORJOY LD A,(14400) ;MEM LOC FOR ARROW KEYS CP 0 JP Z,RDJOYS ;NO? CHECK JOYSTICKS LD C,A ;PUT VAL IN C XOR A BIT 3,C ;TEST WHICH KEY PRESSED AND JP Z,JDOWN ;SIMULATE JOYSTICK DATA RETURN SET 3,A JDOWN BIT 4,C JP Z,JRITE SET 2,A JRITE BIT 6,C JP Z,JLEFT SET 0,A JLEFT BIT 5,C JP Z,JFIRE SET 1,A JFIRE BIT 7,C JP Z,JOVER SET 4,A JOVER LD (JOYSTK),A ;RETURN DATA RET RDJOYS LD A,(JOYSTK) ;JOYSTICK # LD C,A ;PORT = 7D + JOYSTICK # LD A,7DH ADD A,C LD C,A CALL PORTON IN A,(C) ;READ JOYSTICK CPL ;COMPLEMENT SO 1=SET & 0=NORMAL (READ SEC.4.4 & 4.5 OF CHROMATRS MANUAL) AND 1FH ;SEND ONLY BITS 0-4 LD (JOYSTK),A ;RETURN DATA RET ; FILLER RET ;NOT AVAILABLE. ; PADDL CALL PORTON ;READ SEC. 4.6 & 4.7 OF CHROMATRS MANUAL XOR A ;SEE TONE (SOUND) LD (IFLAG),A LD A,I JP PO,PCONTU LD A,1 LD (IFLAG),A DI ;DI FOR ACCURATE TIMING LOOPS PCONTU LD HL,0 LD A,0 OUT (7EH),A ;TRIG ONESHOTS (READ SEC. 4.7 OF CHROMATRS MANUAL) CALL BOTADJ CALL CKPAD ADJUST LD A,0 ;IF PADDLE POS>255 RETURN 255 CP H JP Z,NORMP LD A,255 LD (JOYSTK),A JP PEX NORMP LD A,L ;RETURN CORRECT POSITION LD (JOYSTK),A PEX LD A,80H ;RESET ONESHOTS (SEE 4.6 AGAIN) OUT (7EH),A LD A,(IFLAG) CP 0 RET Z EI RET BOTADJ LD B,180 ;DELAY (READ SEC 4.7 OF CHROMATRS MANUAL) BALP DJNZ BALP RET CKPAD LD A,(JOYSTK) ;GET PADDLE # & CHECK CP 0 JP Z,CK0 CP 1 JP Z,CK1 CP 2 JP Z,CK2 CK3 IN A,(7EH) ;COUNT UNTIL D7 OF 7EH GOES HI BIT 7,A RET NZ INC HL CALL PDEL JP CK3 CK2 IN A,(7EH) ;COUNT UNTIL D6 OF 7EH GOES HI BIT 6,A RET NZ INC HL CALL PDEL JP CK2 CK1 IN A,(7DH) ;COUNT UNTIL D7 OF 7DH GOES HI BIT 7,A RET NZ INC HL CALL PDEL JP CK1 CK0 IN A,(7DH) ;COUNT UNTIL D6 OF 7DH GOES HI BIT 6,A RET NZ INC HL CALL PDEL JP CK0 PDEL RET ; WRITE LD H,0 ;CHAR VAL*6+TABLE LOCATION LD L,A LD D,0 LD E,A LD B,5 ATLP ADD HL,DE DJNZ ATLP LD DE,CTABLE ADD HL,DE ;NOW HL POINTS TO CHAR TABLE LD IX,XCOR LD IY,YCOR LD A,6 EX AF,AF' GETBYT LD A,(HL) LD B,8 SLP SRL A ;SHIFT LEFT NO CARRY RESET JP NC,RESETP PUSH BC PUSH AF PUSH HL CALL SET POP HL POP AF POP BC INYCOR INC (IY) ;POINT NEXT LINE DJNZ SLP INC (IX) ;POINT NEXT X LOCATION LD A,(IY) ;GET CURRENT Y LOCATION SUB 8 ;RESTORE TO Y LOCATION LD (IY),A EX AF,AF' ;CHECK IF ALL 6 X'S DONE DEC A RET Z ;YES RETURN ELSE NEXT EX AF,AF' INC HL JP GETBYT RESETP PUSH BC ;SAVE REGISTERS PUSH AF PUSH HL CALL RESET ;RESET POINT POP HL ;RESTORE POP AF POP BC JP INYCOR ;INC Y COORDINATE CTABLE DEFS 0C0H DEFB 0 DEFB 0 DEFB 0 DEFB 0 DEFB 0 DEFB 0 DEFB 0 ;! DEFB 0 DEFB 5FH DEFB 0 DEFB 0 DEFB 0 DEFB 8H ;" DEFB 7H DEFB 0 DEFB 8H DEFB 7H DEFB 0 DEFB 14H ;# DEFB 7FH DEFB 14H DEFB 7FH DEFB 14H DEFB 0 DEFB 0 ;$ DEFB 24H DEFB 6BH DEFB 6BH DEFB 12H DEFB 0 DEFB 63H ;% DEFB 13H DEFB 8H DEFB 64H DEFB 63H DEFB 0 DEFB 36H ;& DEFB 49H DEFB 49H DEFB 36H DEFB 50H DEFB 0 DEFB 0 ;' DEFB 8H DEFB 7H DEFB 0 DEFB 0 DEFB 0 DEFB 1CH ;( DEFB 22H DEFB 41H DEFB 0 DEFB 0 DEFB 0 DEFB 0 ;) DEFB 0 DEFB 0 DEFB 41H DEFB 22H DEFB 1CH DEFB 2AH ;* DEFB 1CH DEFB 7FH DEFB 1CH DEFB 2AH DEFB 0 DEFB 8H ;+ DEFB 8H DEFB 7FH DEFB 8H DEFB 8H DEFB 0 DEFB 0 ;, DEFB 80H DEFB 70H DEFB 0 DEFB 0 DEFB 0 DEFB 8H ;- DEFB 8H DEFB 8H DEFB 8H DEFB 8H DEFB 0 DEFB 0 ;. DEFB 0 DEFB 40H DEFB 40H DEFB 0H DEFB 0 DEFB 60H ;/ DEFB 10H DEFB 8H DEFB 4H DEFB 3H DEFB 0 DEFB 3EH ;0 DEFB 41H DEFB 41H DEFB 41H DEFB 3EH DEFB 0 DEFB 0 ;1 DEFB 42H DEFB 7FH DEFB 40H DEFB 0 DEFB 0 DEFB 62H ;2 DEFB 51H DEFB 49H DEFB 49H DEFB 46H DEFB 0 DEFB 21H ;3 DEFB 41H DEFB 49H DEFB 4DH DEFB 33H DEFB 0 DEFB 18H ;4 DEFB 14H DEFB 12H DEFB 7FH DEFB 10H DEFB 0 DEFB 4FH ;5 DEFB 49H DEFB 49H DEFB 49H DEFB 31H DEFB 0 DEFB 3EH ;6 DEFB 59H DEFB 49H DEFB 49H DEFB 30H DEFB 0 DEFB 1H ;7 DEFB 71H DEFB 9 DEFB 5 DEFB 3 DEFB 0 DEFB 36H ;8 DEFB 49H DEFB 49H DEFB 49H DEFB 36H DEFB 0 DEFB 06H ;9 DEFB 49H DEFB 49H DEFB 49H DEFB 3EH DEFB 0 DEFB 0 ;: DEFB 0 DEFB 14H DEFB 0 DEFB 0 DEFB 0 DEFB 0 ;; DEFB 40H DEFB 34H DEFB 0 DEFB 0 DEFB 0 DEFB 0 ;< DEFB 08H DEFB 14H DEFB 22H DEFB 41H DEFB 0 DEFB 0 ;= DEFB 14H DEFB 14H DEFB 14H DEFB 14H DEFB 0 DEFB 0 ;> DEFB 41H DEFB 22H DEFB 14H DEFB 08H DEFB 0 DEFB 0 ;? DEFB 02H DEFB 51H DEFB 09H DEFB 06H DEFB 0 DEFB 3EH ;@ DEFB 4BH DEFB 55H DEFB 59H DEFB 0EH DEFB 0 DEFB 7CH ;A DEFB 12H DEFB 11H DEFB 12H DEFB 7CH DEFB 0 DEFB 7FH ;B DEFB 49H DEFB 49H DEFB 49H DEFB 36H DEFB 0 DEFB 3EH ;C DEFB 41H DEFB 41H DEFB 41H DEFB 22H DEFB 0 DEFB 7FH ;D DEFB 41H DEFB 41H DEFB 41H DEFB 3EH DEFB 0 DEFB 7FH ;E DEFB 49H DEFB 49H DEFB 41H DEFB 41H DEFB 0 DEFB 7FH ;F DEFB 09H DEFB 09H DEFB 01H DEFB 01H DEFB 0 DEFB 3EH ;G DEFB 41H DEFB 41H DEFB 51H DEFB 72H DEFB 0 DEFB 7FH ;H DEFB 08H DEFB 08H DEFB 08H DEFB 7FH DEFB 0 DEFB 41H ;I DEFB 41H DEFB 7FH DEFB 41H DEFB 41H DEFB 0 DEFB 30H ;J DEFB 40H DEFB 40H DEFB 40H DEFB 3FH DEFB 0 DEFB 7FH ;K DEFB 08H DEFB 14H DEFB 22H DEFB 41H DEFB 0 DEFB 7FH ;L DEFB 40H DEFB 40H DEFB 40H DEFB 40H DEFB 0 DEFB 7FH ;M DEFB 02H DEFB 0CH DEFB 02H DEFB 7FH DEFB 0 DEFB 7FH ;N DEFB 06H DEFB 08H DEFB 30H DEFB 7FH DEFB 0 DEFB 3EH ;O DEFB 41H DEFB 41H DEFB 41H DEFB 3EH DEFB 0 DEFB 7FH ;P DEFB 9H DEFB 9H DEFB 9H DEFB 6H DEFB 0 DEFB 3EH ;Q DEFB 41H DEFB 51H DEFB 61H DEFB 3EH DEFB 0 DEFB 7FH ;R DEFB 9H DEFB 19H DEFB 29H DEFB 46H DEFB 0 DEFB 26H ;S DEFB 49H DEFB 49H DEFB 49H DEFB 32H DEFB 0 DEFB 1H ;T DEFB 1H DEFB 7FH DEFB 1H DEFB 1H DEFB 0 DEFB 3FH ;U DEFB 40H DEFB 40H DEFB 40H DEFB 3FH DEFB 0 DEFB 1FH ;V DEFB 20H DEFB 40H DEFB 20H DEFB 1FH DEFB 0 DEFB 7FH ;W DEFB 20H DEFB 10H DEFB 20H DEFB 7FH DEFB 0 DEFB 63H ;X DEFB 14H DEFB 8H DEFB 14H DEFB 63H DEFB 0 DEFB 3H ;Y DEFB 4H DEFB 78H DEFB 4H DEFB 3H DEFB 0 DEFB 61H ;Z DEFB 51H DEFB 49H DEFB 45H DEFB 43H DEFB 0 DEFB 255 ;SOLID BLOCK DEFB 255 DEFB 255 DEFB 255 DEFB 255 DEFB 255 DEFS 30 ;GAP TO LOWER CASE DEFB 0 ;SM A DEFB 24H DEFB 54H DEFB 54H DEFB 38H DEFB 40H DEFB 0 ;SM B DEFB 7EH DEFB 44H DEFB 44H DEFB 38H DEFB 0 DEFB 0 ;SM C DEFB 38H DEFB 44H DEFB 44H DEFB 48H DEFB 0 DEFB 0 ;SM D DEFB 38H DEFB 44H DEFB 44H DEFB 7EH DEFB 0 DEFB 0 ;SM E DEFB 38H DEFB 54H DEFB 54H DEFB 58H DEFB 0 DEFB 0 ;SM F DEFB 10H DEFB 7EH DEFB 12H DEFB 4H DEFB 0 DEFB 0 ;SM G DEFB 98H DEFB 0A4H DEFB 0A4H DEFB 78H DEFB 0 DEFB 0 ;SM H DEFB 7EH DEFB 8H DEFB 4H DEFB 78H DEFB 0 DEFB 0 ;SM I DEFB 0 DEFB 7AH DEFB 0 DEFB 0 DEFB 0 DEFB 0 ;SM J DEFB 80H DEFB 80H DEFB 80H DEFB 7AH DEFB 0 DEFB 0 ;SM K DEFB 7EH DEFB 10H DEFB 18H DEFB 66H DEFB 0 DEFB 0 ;SM L DEFB 0 DEFB 3EH DEFB 40H DEFB 0 DEFB 0 DEFB 78H ;SM M DEFB 4H DEFB 78H DEFB 4H DEFB 78H DEFB 0 DEFB 0 ;SM N DEFB 78H DEFB 4H DEFB 4H DEFB 78H DEFB 0 DEFB 0 ;SM O DEFB 38H DEFB 44H DEFB 44H DEFB 38H DEFB 0 DEFB 0 ;SM P DEFB 0F8H DEFB 24H DEFB 24H DEFB 18H DEFB 0 DEFB 18H ;SM Q DEFB 24H DEFB 24H DEFB 0F8H DEFB 80H DEFB 0 DEFB 0 ;SM R DEFB 78H DEFB 4H DEFB 4H DEFB 8H DEFB 0 DEFB 0 ;SM S DEFB 48H DEFB 54H DEFB 54H DEFB 24H DEFB 0 DEFB 0 ;SM T DEFB 8H DEFB 3EH DEFB 48H DEFB 0 DEFB 0 DEFB 0 ;SM U DEFB 3CH DEFB 40H DEFB 40H DEFB 3CH DEFB 40H DEFB 1CH ;SM V DEFB 20H DEFB 40H DEFB 20H DEFB 1CH DEFB 0 DEFB 3CH ;SM W DEFB 40H DEFB 30H DEFB 40H DEFB 3CH DEFB 0 DEFB 0 ;SM X DEFB 6CH DEFB 10H DEFB 10H DEFB 6CH DEFB 0 DEFB 0 ;SM Y DEFB 9CH DEFB 0A0H DEFB 0A0H DEFB 7CH DEFB 0 DEFB 0 ;SM Z DEFB 64H DEFB 54H DEFB 4CH DEFB 44H DEFB 0 ; END GO
;Parameter passing via the stack PROCSWAP.ASM ; ; Objective: To show parameter passing via the stack. ; Input: Requests a character string from the user. ; Output: Outputs the input string with the first ; two characters swapped. BUF_LEN EQU 41 ; string buffer length %include "io.mac" .DATA prompt_msg db "Please input a string: ",0 output_msg db "The swapped string is: ",0 .UDATA string resb BUF_LEN ;input string < BUF_LEN chars. .CODE .STARTUP PutStr prompt_msg ; request string input GetStr string,BUF_LEN ; read string from the user mov EAX,string ; EAX = string[0] pointer push EAX ; push string[0] pointer on stack inc EAX ; EAX = string[1] pointer push EAX ; push string[1] pointer on stack call swap ; swaps the first two characters PutStr output_msg ; display the swapped string PutStr string nwln done: .EXIT ;----------------------------------------------------------- ;Procedure swap receives two pointers (via the stack) to ; characters of a string. It exchanges these two characters. ;----------------------------------------------------------- .CODE swap: enter 0,0 push EBX ; save EBX - procedure uses EBX ; swap begins here. Because of xchg, AL is preserved. mov EBX,[EBP+12] ; EBX = first character pointer xchg AL,[EBX] mov EBX,[EBP+8] ; EBX = second character pointer xchg AL,[EBX] mov EBX,[EBP+12] ; EBX = first character pointer xchg AL,[EBX] ; swap ends here pop EBX ; restore registers leave ret 4 ; return and clear parameters
; Z88 Small C+ Run Time Library ; Long functions ; PUBLIC l_long_ne ; ; DEHL != secondary ; set carry if result true ; stack = secondary MSW, secondary LSW, ret .l_long_ne pop ix ; return address pop bc ; secondary LSW ld a,c cp l jp nz, notequal0 ld a,b cp h jp nz, notequal0 pop bc ; secondary MSW ld a,c cp e jp nz, notequal1 ld a,b cp d jr z, equal .notequal1 scf .equal jp (ix) .notequal0 pop bc ; clear secondary MSW from stack scf jp (ix) ; call l_long_cmp ; scf ; ret nz ; ccf ; dec hl ; ret
;; ;; Copyright (c) 2019-2020, Intel Corporation ;; ;; 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 "job_aes_hmac.asm" %include "include/os.asm" %include "include/memcpy.asm" %include "include/clear_regs.asm" ;;; This is implementation of stitched algorithms: AES128-CTR + CRC32 + BIP ;;; This combination is required by PON/xPON/gPON standard. ;;; Note: BIP is running XOR of double words ;;; Order of operations: ;;; - encrypt: CRC32, AES-CTR and BIP ;;; - decrypt: BIP, AES-CTR and CRC32 %ifndef DEC_FN_NAME %define DEC_FN_NAME submit_job_pon_dec_sse %endif %ifndef ENC_FN_NAME %define ENC_FN_NAME submit_job_pon_enc_sse %endif %ifndef ENC_NO_CTR_FN_NAME %define ENC_NO_CTR_FN_NAME submit_job_pon_enc_no_ctr_sse %endif %ifndef DEC_NO_CTR_FN_NAME %define DEC_NO_CTR_FN_NAME submit_job_pon_dec_no_ctr_sse %endif extern byteswap_const extern ddq_add_1 section .data default rel ;;; Precomputed constants for CRC32 (Ethernet FCS) ;;; Details of the CRC algorithm and 4 byte buffer of ;;; {0x01, 0x02, 0x03, 0x04}: ;;; Result Poly Init RefIn RefOut XorOut ;;; 0xB63CFBCD 0x04C11DB7 0xFFFFFFFF true true 0xFFFFFFFF align 16 rk1: dq 0x00000000ccaa009e, 0x00000001751997d0 align 16 rk5: dq 0x00000000ccaa009e, 0x0000000163cd6124 align 16 rk7: dq 0x00000001f7011640, 0x00000001db710640 align 16 pshufb_shf_table: ;; use these values for shift registers with the pshufb instruction dq 0x8786858483828100, 0x8f8e8d8c8b8a8988 dq 0x0706050403020100, 0x000e0d0c0b0a0908 align 16 init_crc_value: dq 0x00000000FFFFFFFF, 0x0000000000000000 align 16 mask: dq 0xFFFFFFFFFFFFFFFF, 0x0000000000000000 align 16 mask2: dq 0xFFFFFFFF00000000, 0xFFFFFFFFFFFFFFFF align 16 mask3: dq 0x8080808080808080, 0x8080808080808080 align 16 mask_out_top_bytes: dq 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF dq 0x0000000000000000, 0x0000000000000000 ;; Precomputed constants for HEC calculation (XGEM header) ;; POLY 0x53900000: ;; k1 = 0xf9800000 ;; k2 = 0xa0900000 ;; k3 = 0x7cc00000 ;; q = 0x46b927ec ;; p_res = 0x53900000 align 16 k3_q: dq 0x7cc00000, 0x46b927ec align 16 p_res: dq 0x53900000, 0 align 16 mask_out_top_64bits: dq 0xffffffff_ffffffff, 0 section .text %define NUM_AES_ROUNDS 10 ;; note: leave xmm0 free for implicit blend %define xcounter xmm7 %define xbip xmm1 %define xcrc xmm2 %define xcrckey xmm3 %define xtmp1 xmm4 %define xtmp2 xmm5 %define xtmp3 xmm6 %define xtmp4 xmm8 %ifdef LINUX %define arg1 rdi %define arg2 rsi %define arg3 rdx %define arg4 rcx %define tmp_1 r8 %define tmp_2 r9 %define tmp_3 r10 %define tmp_4 r11 %define tmp_5 r12 %define tmp_6 r13 %define tmp_7 r14 %else %define arg1 rcx %define arg2 rdx %define arg3 r8 %define arg4 r9 %define tmp_1 r10 %define tmp_2 r11 %define tmp_3 rax %define tmp_4 r12 %define tmp_5 r13 %define tmp_6 r14 %define tmp_7 r15 %endif %define job arg1 %define p_in arg2 %define p_keys arg3 %define p_out arg4 %define num_bytes tmp_1 ; bytes to cipher %define tmp tmp_2 %define ctr_check tmp_3 ; counter block overflow check %define bytes_to_crc tmp_4 ; number of bytes to CRC ( < num_bytes) %define ethernet_fcs tmp_6 ; not used together with tmp3 %define tmp2 tmp_5 %define tmp3 tmp_6 %define write_back_crc tmp_7 %define decrypt_not_done tmp_7 ;;; ============================================================================ ;;; Does all AES encryption rounds %macro AES_ENC_ROUNDS 3 %define %%KP %1 ; [in] pointer to expanded keys %define %%N_ROUNDS %2 ; [in] max rounds (128bit: 10, 12, 14) %define %%BLOCK %3 ; [in/out] XMM with encrypted block %assign round 0 pxor %%BLOCK, [%%KP + (round * 16)] %rep (%%N_ROUNDS - 1) %assign round (round + 1) aesenc %%BLOCK, [%%KP + (round * 16)] %endrep %assign round (round + 1) aesenclast %%BLOCK, [%%KP + (round * 16)] %endmacro ;;; ============================================================================ ;;; PON stitched algorithm round on a single AES block (16 bytes): ;;; AES-CTR (optional, depending on %%CIPH) ;;; - prepares counter blocks ;;; - encrypts counter blocks ;;; - loads text ;;; - xor's text against encrypted blocks ;;; - stores cipher text ;;; BIP ;;; - BIP update on 4 x 32-bits ;;; CRC32 ;;; - CRC32 calculation ;;; Note: via selection of no_crc, no_bip, no_load, no_store different macro ;;; behaviour can be achieved to match needs of the overall algorithm. %macro DO_PON 15 %define %%KP %1 ; [in] GP, pointer to expanded keys %define %%N_ROUNDS %2 ; [in] number of AES rounds (10, 12 or 14) %define %%CTR %3 ; [in/out] XMM with counter block %define %%INP %4 ; [in/out] GP with input text pointer or "no_load" %define %%OUTP %5 ; [in/out] GP with output text pointer or "no_store" %define %%XBIP_IN_OUT %6 ; [in/out] XMM with BIP value or "no_bip" %define %%XCRC_IN_OUT %7 ; [in/out] XMM with CRC (can be anything if "no_crc" below) %define %%XCRC_MUL %8 ; [in] XMM with CRC multiplier constant (can be anything if "no_crc" below) %define %%TXMM0 %9 ; [clobbered|out] XMM temporary or data out (no_store) %define %%TXMM1 %10 ; [clobbered|in] XMM temporary or data in (no_load) %define %%TXMM2 %11 ; [clobbered] XMM temporary %define %%CRC_TYPE %12 ; [in] "first_crc" or "next_crc" or "no_crc" %define %%DIR %13 ; [in] "ENC" or "DEC" %define %%CIPH %14 ; [in] "CTR" or "NO_CTR" %define %%CTR_CHECK %15 ; [in/out] GP with 64bit counter (to identify overflow) %ifidn %%CIPH, CTR ;; prepare counter blocks for encryption movdqa %%TXMM0, %%CTR pshufb %%TXMM0, [rel byteswap_const] ;; perform 1 increment on whole 128 bits movdqa %%TXMM2, [rel ddq_add_1] paddq %%CTR, %%TXMM2 add %%CTR_CHECK, 1 jnc %%_no_ctr_overflow ;; Add 1 to the top 64 bits. First shift left value 1 by 64 bits. pslldq %%TXMM2, 8 paddq %%CTR, %%TXMM2 %%_no_ctr_overflow: %endif ;; CRC calculation %ifidn %%CRC_TYPE, next_crc movdqa %%TXMM2, %%XCRC_IN_OUT pclmulqdq %%TXMM2, %%XCRC_MUL, 0x01 pclmulqdq %%XCRC_IN_OUT, %%XCRC_MUL, 0x10 %endif %ifnidn %%INP, no_load movdqu %%TXMM1, [%%INP] %endif %ifidn %%CIPH, CTR ;; AES rounds AES_ENC_ROUNDS %%KP, %%N_ROUNDS, %%TXMM0 ;; xor plaintext/ciphertext against encrypted counter blocks pxor %%TXMM0, %%TXMM1 %else ;; CIPH = NO_CTR ;; if no encryption needs to be done, move from input to output reg movdqa %%TXMM0, %%TXMM1 %endif ;; CIPH = CTR %ifidn %%CIPH, CTR %ifidn %%DIR, ENC ;; CRC calculation for ENCRYPTION %ifidn %%CRC_TYPE, first_crc ;; in the first run just XOR initial CRC with the first block pxor %%XCRC_IN_OUT, %%TXMM1 %endif %ifidn %%CRC_TYPE, next_crc ;; - XOR results of CLMUL's together ;; - then XOR against text block pxor %%XCRC_IN_OUT, %%TXMM2 pxor %%XCRC_IN_OUT, %%TXMM1 %endif %else ;; CRC calculation for DECRYPTION %ifidn %%CRC_TYPE, first_crc ;; in the first run just XOR initial CRC with the first block pxor %%XCRC_IN_OUT, %%TXMM0 %endif %ifidn %%CRC_TYPE, next_crc ;; - XOR results of CLMUL's together ;; - then XOR against text block pxor %%XCRC_IN_OUT, %%TXMM2 pxor %%XCRC_IN_OUT, %%TXMM0 %endif %endif ; DECRYPT %else ;; CIPH = NO_CTR ;; CRC calculation for DECRYPTION %ifidn %%CRC_TYPE, first_crc ;; in the first run just XOR initial CRC with the first block pxor %%XCRC_IN_OUT, %%TXMM1 %endif %ifidn %%CRC_TYPE, next_crc ;; - XOR results of CLMUL's together ;; - then XOR against text block pxor %%XCRC_IN_OUT, %%TXMM2 pxor %%XCRC_IN_OUT, %%TXMM1 %endif %endif ;; CIPH = CTR ;; store the result in the output buffer %ifnidn %%OUTP, no_store movdqu [%%OUTP], %%TXMM0 %endif ;; update BIP value - always use cipher text for BIP %ifidn %%DIR, ENC %ifnidn %%XBIP_IN_OUT, no_bip pxor %%XBIP_IN_OUT, %%TXMM0 %endif %else %ifnidn %%XBIP_IN_OUT, no_bip pxor %%XBIP_IN_OUT, %%TXMM1 %endif %endif ; DECRYPT ;; increment in/out pointers %ifnidn %%INP, no_load add %%INP, 16 %endif %ifnidn %%OUTP, no_store add %%OUTP, 16 %endif %endmacro ; DO_PON ;;; ============================================================================ ;;; CIPHER and BIP specified number of bytes %macro CIPHER_BIP_REST 14 %define %%NUM_BYTES %1 ; [in/clobbered] number of bytes to cipher %define %%DIR %2 ; [in] "ENC" or "DEC" %define %%CIPH %3 ; [in] "CTR" or "NO_CTR" %define %%PTR_IN %4 ; [in/clobbered] GPR pointer to input buffer %define %%PTR_OUT %5 ; [in/clobbered] GPR pointer to output buffer %define %%PTR_KEYS %6 ; [in] GPR pointer to expanded keys %define %%XBIP_IN_OUT %7 ; [in/out] XMM 128-bit BIP state %define %%XCTR_IN_OUT %8 ; [in/out] XMM 128-bit AES counter block %define %%XMMT1 %9 ; [clobbered] temporary XMM %define %%XMMT2 %10 ; [clobbered] temporary XMM %define %%XMMT3 %11 ; [clobbered] temporary XMM %define %%CTR_CHECK %12 ; [in/out] GP with 64bit counter (to identify overflow) %define %%GPT1 %13 ; [clobbered] temporary GP %define %%GPT2 %14 ; [clobbered] temporary GP %%_cipher_last_blocks: cmp %%NUM_BYTES, 16 jb %%_partial_block_left DO_PON %%PTR_KEYS, NUM_AES_ROUNDS, %%XCTR_IN_OUT, %%PTR_IN, %%PTR_OUT, %%XBIP_IN_OUT, \ no_crc, no_crc, %%XMMT1, %%XMMT2, %%XMMT3, no_crc, %%DIR, %%CIPH, %%CTR_CHECK sub %%NUM_BYTES, 16 jz %%_bip_done jmp %%_cipher_last_blocks %%_partial_block_left: simd_load_sse_15_1 %%XMMT2, %%PTR_IN, %%NUM_BYTES ;; DO_PON() is not loading nor storing the data in this case: ;; XMMT2 = data in ;; XMMT1 = data out DO_PON %%PTR_KEYS, NUM_AES_ROUNDS, %%XCTR_IN_OUT, no_load, no_store, no_bip, \ no_crc, no_crc, %%XMMT1, %%XMMT2, %%XMMT3, no_crc, %%DIR, %%CIPH, %%CTR_CHECK ;; BIP update for partial block (mask out bytes outside the message) lea %%GPT1, [rel mask_out_top_bytes + 16] sub %%GPT1, %%NUM_BYTES movdqu %%XMMT3, [%%GPT1] ;; put masked cipher text into XMMT2 for BIP update %ifidn %%DIR, ENC movdqa %%XMMT2, %%XMMT1 pand %%XMMT2, %%XMMT3 %else pand %%XMMT2, %%XMMT3 %endif pxor %%XBIP_IN_OUT, %%XMMT2 ;; store partial bytes in the output buffer simd_store_sse_15 %%PTR_OUT, %%XMMT1, %%NUM_BYTES, %%GPT1, %%GPT2 %%_bip_done: %endmacro ; CIPHER_BIP_REST ;; ============================================================================= ;; Barrett reduction from 128-bits to 32-bits modulo Ethernet FCS polynomial %macro CRC32_REDUCE_128_TO_32 5 %define %%CRC %1 ; [out] GP to store 32-bit Ethernet FCS value %define %%XCRC %2 ; [in/clobbered] XMM with CRC %define %%XT1 %3 ; [clobbered] temporary xmm register %define %%XT2 %4 ; [clobbered] temporary xmm register %define %%XT3 %5 ; [clobbered] temporary xmm register %define %%XCRCKEY %%XT3 ;; compute CRC of a 128-bit value movdqa %%XCRCKEY, [rel rk5] ;; 64b fold movdqa %%XT1, %%XCRC pclmulqdq %%XT1, %%XCRCKEY, 0x00 psrldq %%XCRC, 8 pxor %%XCRC, %%XT1 ;; 32b fold movdqa %%XT1, %%XCRC pslldq %%XT1, 4 pclmulqdq %%XT1, %%XCRCKEY, 0x10 pxor %%XCRC, %%XT1 %%_crc_barrett: ;; Barrett reduction pand %%XCRC, [rel mask2] movdqa %%XT1, %%XCRC movdqa %%XT2, %%XCRC movdqa %%XCRCKEY, [rel rk7] pclmulqdq %%XCRC, %%XCRCKEY, 0x00 pxor %%XCRC, %%XT2 pand %%XCRC, [rel mask] movdqa %%XT2, %%XCRC pclmulqdq %%XCRC, %%XCRCKEY, 0x10 pxor %%XCRC, %%XT2 pxor %%XCRC, %%XT1 pextrd DWORD(%%CRC), %%XCRC, 2 ; 32-bit CRC value not DWORD(%%CRC) %endmacro ;; ============================================================================= ;; Barrett reduction from 128-bits to 32-bits modulo 0x53900000 polynomial %macro HEC_REDUCE_128_TO_32 4 %define %%XMM_IN_OUT %1 ; [in/out] xmm register with data in and out %define %%XT1 %2 ; [clobbered] temporary xmm register %define %%XT2 %3 ; [clobbered] temporary xmm register %define %%XT3 %4 ; [clobbered] temporary xmm register %define %%K3_Q %%XT1 %define %%P_RES %%XT2 %define %%XTMP %%XT3 ;; 128 to 64 bit reduction movdqa %%K3_Q, [k3_q] movdqa %%P_RES, [p_res] movdqa %%XTMP, %%XMM_IN_OUT pclmulqdq %%XTMP, %%K3_Q, 0x01 ; K3 pxor %%XTMP, %%XMM_IN_OUT pclmulqdq %%XTMP, %%K3_Q, 0x01 ; K3 pxor %%XMM_IN_OUT, %%XTMP pand %%XMM_IN_OUT, [rel mask_out_top_64bits] ;; 64 to 32 bit reduction movdqa %%XTMP, %%XMM_IN_OUT psrldq %%XTMP, 4 pclmulqdq %%XTMP, %%K3_Q, 0x10 ; Q pxor %%XTMP, %%XMM_IN_OUT psrldq %%XTMP, 4 pclmulqdq %%XTMP, %%P_RES, 0x00 ; P pxor %%XMM_IN_OUT, %%XTMP %endmacro ;; ============================================================================= ;; Barrett reduction from 64-bits to 32-bits modulo 0x53900000 polynomial %macro HEC_REDUCE_64_TO_32 4 %define %%XMM_IN_OUT %1 ; [in/out] xmm register with data in and out %define %%XT1 %2 ; [clobbered] temporary xmm register %define %%XT2 %3 ; [clobbered] temporary xmm register %define %%XT3 %4 ; [clobbered] temporary xmm register %define %%K3_Q %%XT1 %define %%P_RES %%XT2 %define %%XTMP %%XT3 movdqa %%K3_Q, [k3_q] movdqa %%P_RES, [p_res] ;; 64 to 32 bit reduction movdqa %%XTMP, %%XMM_IN_OUT psrldq %%XTMP, 4 pclmulqdq %%XTMP, %%K3_Q, 0x10 ; Q pxor %%XTMP, %%XMM_IN_OUT psrldq %%XTMP, 4 pclmulqdq %%XTMP, %%P_RES, 0x00 ; P pxor %%XMM_IN_OUT, %%XTMP %endmacro ;; ============================================================================= ;; HEC compute and header update for 32-bit XGEM headers %macro HEC_COMPUTE_32 6 %define %%HEC_IN_OUT %1 ; [in/out] GP register with HEC in LE format %define %%GT1 %2 ; [clobbered] temporary GP register %define %%XT1 %4 ; [clobbered] temporary xmm register %define %%XT2 %5 ; [clobbered] temporary xmm register %define %%XT3 %6 ; [clobbered] temporary xmm register %define %%XT4 %7 ; [clobbered] temporary xmm register mov DWORD(%%GT1), DWORD(%%HEC_IN_OUT) ;; shift out 13 bits of HEC value for CRC computation shr DWORD(%%GT1), 13 ;; mask out current HEC value to merge with an updated HEC at the end and DWORD(%%HEC_IN_OUT), 0xffff_e000 ;; prepare the message for CRC computation movd %%XT1, DWORD(%%GT1) pslldq %%XT1, 4 ; shift left by 32-bits HEC_REDUCE_64_TO_32 %%XT1, %%XT2, %%XT3, %%XT4 ;; extract 32-bit value ;; - normally perform 20 bit shift right but bit 0 is a parity bit movd DWORD(%%GT1), %%XT1 shr DWORD(%%GT1), (20 - 1) ;; merge header bytes with updated 12-bit CRC value and ;; compute parity or DWORD(%%GT1), DWORD(%%HEC_IN_OUT) popcnt DWORD(%%HEC_IN_OUT), DWORD(%%GT1) and DWORD(%%HEC_IN_OUT), 1 or DWORD(%%HEC_IN_OUT), DWORD(%%GT1) %endmacro ;; ============================================================================= ;; HEC compute and header update for 64-bit XGEM headers %macro HEC_COMPUTE_64 6 %define %%HEC_IN_OUT %1 ; [in/out] GP register with HEC in LE format %define %%GT1 %2 ; [clobbered] temporary GP register %define %%XT1 %3 ; [clobbered] temporary xmm register %define %%XT2 %4 ; [clobbered] temporary xmm register %define %%XT3 %5 ; [clobbered] temporary xmm register %define %%XT4 %6 ; [clobbered] temporary xmm register mov %%GT1, %%HEC_IN_OUT ;; shift out 13 bits of HEC value for CRC computation shr %%GT1, 13 ;; mask out current HEC value to merge with an updated HEC at the end and %%HEC_IN_OUT, 0xffff_ffff_ffff_e000 ;; prepare the message for CRC computation movq %%XT1, %%GT1 pslldq %%XT1, 4 ; shift left by 32-bits HEC_REDUCE_128_TO_32 %%XT1, %%XT2, %%XT3, %%XT4 ;; extract 32-bit value ;; - normally perform 20 bit shift right but bit 0 is a parity bit movd DWORD(%%GT1), %%XT1 shr DWORD(%%GT1), (20 - 1) ;; merge header bytes with updated 12-bit CRC value and ;; compute parity or %%GT1, %%HEC_IN_OUT popcnt %%HEC_IN_OUT, %%GT1 and %%HEC_IN_OUT, 1 or %%HEC_IN_OUT, %%GT1 %endmacro ;;; ============================================================================ ;;; PON stitched algorithm of AES128-CTR, CRC and BIP ;;; - this is master macro that implements encrypt/decrypt API ;;; - calls other macros and directly uses registers ;;; defined at the top of the file %macro AES128_CTR_PON 2 %define %%DIR %1 ; [in] direction "ENC" or "DEC" %define %%CIPH %2 ; [in] cipher "CTR" or "NO_CTR" push r12 push r13 push r14 %ifndef LINUX push r15 %endif %ifidn %%DIR, ENC ;; by default write back CRC for encryption mov DWORD(write_back_crc), 1 %else ;; mark decryption as finished mov DWORD(decrypt_not_done), 1 %endif ;; START BIP (and update HEC if encrypt direction) ;; - load XGEM header (8 bytes) for BIP (not part of encrypted payload) ;; - convert it into LE ;; - update HEC field in the header ;; - convert it into BE ;; - store back the header (with updated HEC) ;; - start BIP ;; (free to use tmp_1, tmp_2 and tmp_3 at this stage) mov tmp_2, [job + _src] add tmp_2, [job + _hash_start_src_offset_in_bytes] mov tmp_3, [tmp_2] %ifidn %%DIR, ENC bswap tmp_3 ; go to LE HEC_COMPUTE_64 tmp_3, tmp_1, xtmp1, xtmp2, xtmp3, xtmp4 mov bytes_to_crc, tmp_3 shr bytes_to_crc, (48 + 2) ; PLI = MSB 14 bits bswap tmp_3 ; go back to BE mov [tmp_2], tmp_3 movq xbip, tmp_3 %else movq xbip, tmp_3 mov bytes_to_crc, tmp_3 bswap bytes_to_crc ; go to LE shr bytes_to_crc, (48 + 2) ; PLI = MSB 14 bits %endif cmp bytes_to_crc, 4 ja %%_crc_not_zero ;; XGEM payload shorter or equal to 4 bytes %ifidn %%DIR, ENC ;; Don't write Ethernet FCS on encryption xor DWORD(write_back_crc), DWORD(write_back_crc) %else ;; Mark decryption as not finished ;; - Ethernet FCS is not computed ;; - decrypt + BIP to be done at the end xor DWORD(decrypt_not_done), DWORD(decrypt_not_done) %endif mov DWORD(bytes_to_crc), 4 ; it will be zero after the sub (avoid jmp) %%_crc_not_zero: sub bytes_to_crc, 4 ; subtract size of the CRC itself %ifidn %%CIPH, CTR ;; - read 16 bytes of IV ;; - convert to little endian format ;; - save least significant 8 bytes in GP register for overflow check mov tmp, [job + _iv] movdqu xcounter, [tmp] pshufb xcounter, [rel byteswap_const] movq ctr_check, xcounter %endif ;; get input buffer (after XGEM header) mov p_in, [job + _src] add p_in, [job + _cipher_start_src_offset_in_bytes] ;; get output buffer mov p_out, [job + _dst] %ifidn %%CIPH, CTR ;; get key pointers mov p_keys, [job + _aes_enc_key_expanded] %endif ;; initial CRC value movdqa xcrc, [rel init_crc_value] ;; load CRC constants movdqa xcrckey, [rel rk1] ; rk1 and rk2 in xcrckey ;; get number of bytes to cipher %ifidn %%CIPH, CTR mov num_bytes, [job + _msg_len_to_cipher_in_bytes] %else ;; Message length to cipher is 0 ;; - length is obtained from message length to hash (BIP) minus XGEM header size mov num_bytes, [job + _msg_len_to_hash_in_bytes] sub num_bytes, 8 %endif or bytes_to_crc, bytes_to_crc jz %%_crc_done cmp bytes_to_crc, 32 jae %%_at_least_32_bytes %ifidn %%DIR, DEC ;; decrypt the buffer first mov tmp, num_bytes CIPHER_BIP_REST tmp, %%DIR, %%CIPH, p_in, p_out, p_keys, xbip, \ xcounter, xtmp1, xtmp2, xtmp3, ctr_check, tmp2, tmp3 ;; correct in/out pointers - go back to start of the buffers mov tmp, num_bytes and tmp, -16 ; partial block handler doesn't increment pointers sub p_in, tmp sub p_out, tmp %endif ; DECRYPTION ;; less than 32 bytes cmp bytes_to_crc, 16 je %%_exact_16_left jl %%_less_than_16_left ;; load the plaintext %ifidn %%DIR, ENC movdqu xtmp1, [p_in] %else movdqu xtmp1, [p_out] %endif pxor xcrc, xtmp1 ; xor the initial crc value jmp %%_crc_two_xmms %%_exact_16_left: %ifidn %%DIR, ENC movdqu xtmp1, [p_in] %else movdqu xtmp1, [p_out] %endif pxor xcrc, xtmp1 ; xor the initial CRC value jmp %%_128_done %%_less_than_16_left: %ifidn %%DIR, ENC simd_load_sse_15_1 xtmp1, p_in, bytes_to_crc %else simd_load_sse_15_1 xtmp1, p_out, bytes_to_crc %endif pxor xcrc, xtmp1 ; xor the initial CRC value lea tmp, [rel pshufb_shf_table] movdqu xtmp1, [tmp + bytes_to_crc] pshufb xcrc, xtmp1 jmp %%_128_done %%_at_least_32_bytes: DO_PON p_keys, NUM_AES_ROUNDS, xcounter, p_in, p_out, xbip, \ xcrc, xcrckey, xtmp1, xtmp2, xtmp3, first_crc, %%DIR, %%CIPH, ctr_check sub num_bytes, 16 sub bytes_to_crc, 16 %%_main_loop: cmp bytes_to_crc, 16 jb %%_exit_loop DO_PON p_keys, NUM_AES_ROUNDS, xcounter, p_in, p_out, xbip, \ xcrc, xcrckey, xtmp1, xtmp2, xtmp3, next_crc, %%DIR, %%CIPH, ctr_check sub num_bytes, 16 sub bytes_to_crc, 16 %ifidn %%DIR, ENC jz %%_128_done %endif jmp %%_main_loop %%_exit_loop: %ifidn %%DIR, DEC ;; decrypt rest of the message including CRC and optional padding mov tmp, num_bytes CIPHER_BIP_REST tmp, %%DIR, %%CIPH, p_in, p_out, p_keys, xbip, \ xcounter, xtmp1, xtmp2, xtmp3, ctr_check, tmp2, tmp3 mov tmp, num_bytes ; correct in/out pointers - to point before cipher & BIP and tmp, -16 ; partial block handler doesn't increment pointers sub p_in, tmp sub p_out, tmp or bytes_to_crc, bytes_to_crc jz %%_128_done %endif ; DECRYPTION ;; Partial bytes left - complete CRC calculation %%_crc_two_xmms: lea tmp, [rel pshufb_shf_table] movdqu xtmp2, [tmp + bytes_to_crc] %ifidn %%DIR, ENC movdqu xtmp1, [p_in - 16 + bytes_to_crc] ; xtmp1 = data for CRC %else movdqu xtmp1, [p_out - 16 + bytes_to_crc] ; xtmp1 = data for CRC %endif movdqa xtmp3, xcrc pshufb xcrc, xtmp2 ; top num_bytes with LSB xcrc pxor xtmp2, [rel mask3] pshufb xtmp3, xtmp2 ; bottom (16 - num_bytes) with MSB xcrc ;; data num_bytes (top) blended with MSB bytes of CRC (bottom) movdqa xmm0, xtmp2 pblendvb xtmp3, xtmp1 ; xmm0 implicit ;; final CRC calculation movdqa xtmp1, xcrc pclmulqdq xtmp1, xcrckey, 0x01 pclmulqdq xcrc, xcrckey, 0x10 pxor xcrc, xtmp3 pxor xcrc, xtmp1 %%_128_done: CRC32_REDUCE_128_TO_32 ethernet_fcs, xcrc, xtmp1, xtmp2, xcrckey %%_crc_done: ;; @todo - store-to-load problem in ENC case (to be fixed later) ;; - store CRC in input buffer and authentication tag output ;; - encrypt remaining bytes %ifidn %%DIR, ENC or DWORD(write_back_crc), DWORD(write_back_crc) jz %%_skip_crc_write_back mov [p_in + bytes_to_crc], DWORD(ethernet_fcs) %%_skip_crc_write_back: %endif mov tmp, [job + _auth_tag_output] mov [tmp + 4], DWORD(ethernet_fcs) or num_bytes, num_bytes jz %%_do_not_cipher_the_rest ;; encrypt rest of the message ;; - partial bytes including CRC and optional padding ;; decrypt rest of the message ;; - this may only happen when XGEM payload is short and padding is added %ifidn %%DIR, DEC or DWORD(decrypt_not_done), DWORD(decrypt_not_done) jnz %%_do_not_cipher_the_rest %endif CIPHER_BIP_REST num_bytes, %%DIR, %%CIPH, p_in, p_out, p_keys, xbip, \ xcounter, xtmp1, xtmp2, xtmp3, ctr_check, tmp2, tmp3 %%_do_not_cipher_the_rest: ;; finalize BIP movdqa xtmp1, xbip movdqa xtmp2, xbip movdqa xtmp3, xbip psrldq xtmp1, 4 psrldq xtmp2, 8 psrldq xtmp3, 12 pxor xtmp1, xtmp2 pxor xbip, xtmp3 pxor xbip, xtmp1 movd [tmp], xbip ;; set job status or dword [job + _status], STS_COMPLETED ;; return job mov rax, job %ifndef LINUX pop r15 %endif pop r14 pop r13 pop r12 %ifdef SAFE_DATA clear_all_xmms_sse_asm %endif ;; SAFE_DATA %endmacro ; AES128_CTR_PON ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; aes_cntr_128_pon_enc_sse(JOB_AES_HMAC *job) align 32 MKGLOBAL(ENC_FN_NAME,function,internal) ENC_FN_NAME: AES128_CTR_PON ENC, CTR ret ;;; aes_cntr_128_pon_dec_sse(JOB_AES_HMAC *job) align 32 MKGLOBAL(DEC_FN_NAME,function,internal) DEC_FN_NAME: AES128_CTR_PON DEC, CTR ret ;;; aes_cntr_128_pon_enc_no_ctr_sse(JOB_AES_HMAC *job) align 32 MKGLOBAL(ENC_NO_CTR_FN_NAME,function,internal) ENC_NO_CTR_FN_NAME: AES128_CTR_PON ENC, NO_CTR ret ;;; aes_cntr_128_pon_dec_no_ctr_sse(JOB_AES_HMAC *job) align 32 MKGLOBAL(DEC_NO_CTR_FN_NAME,function,internal) DEC_NO_CTR_FN_NAME: AES128_CTR_PON DEC, NO_CTR ret %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
; A159333: Roman factorial of n. ; -1,1,1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000 sub $2,$0 sub $0,2 cal $0,142 mov $1,$0 cmp $2,0 mul $2,2 sub $1,$2
dnl SPARC v9 32-bit mpn_mul_1 -- Multiply a limb vector with a limb and store dnl the result in a second limb vector. dnl Copyright 1998, 2000, 2001, 2003 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 Algorithm: We use two floating-point multiplies per limb product, with the C invariant v operand split into two 16-bit pieces, and the u operand split C into 32-bit pieces. We convert the two 48-bit products and transfer them to C the integer unit. C cycles/limb C UltraSPARC 1&2: 6.5 C UltraSPARC 3: ? C Possible optimizations: C 1. Combine 32-bit memory operations into 64-bit operations. Since we're C memory bandwidth limited, this could save 1.5 cycles/limb. C 2. Unroll the inner loop. Since we already use alternate temporary areas, C it is very straightforward to unroll, using an exit branch midways. C Unrolling would allow deeper scheduling which could improve speed for L2 C cache case. C 3. For mpn_mul_1: Use more alternating temp areas. The std'es and ldx'es C aren't sufficiently apart-scheduled with just two temp areas. C 4. Specialize for particular v values. If its upper 16 bits are zero, we C could save many operations. C INPUT PARAMETERS C rp i0 C up i1 C n i2 C v i3 define(`FSIZE',224) ASM_START() PROLOGUE(mpn_mul_1) add %sp, -FSIZE, %sp sethi %hi(0xffff), %g1 srl %o3, 16, %g2 or %g1, %lo(0xffff), %g1 and %o3, %g1, %g1 stx %g1, [%sp+104] stx %g2, [%sp+112] ldd [%sp+104], %f6 ldd [%sp+112], %f8 fxtod %f6, %f6 fxtod %f8, %f8 ld [%sp+104], %f10 C zero f10 mov 0, %g3 C cy = 0 define(`fanop', `fitod %f18, %f0') C A quasi nop running in the FA pipe add %sp, 160, %o5 C point in scratch area and %o5, -32, %o5 C align at 0 (mod 32) in scratch area subcc %o2, 1, %o2 ld [%o1], %f11 C read up[i] add %o1, 4, %o1 C up++ bne,pt %icc, .L_two_or_more fxtod %f10, %f2 fmuld %f2, %f8, %f16 fmuld %f2, %f6, %f4 fdtox %f16, %f14 fdtox %f4, %f12 std %f14, [%o5+16] std %f12, [%o5+24] ldx [%o5+16], %g2 C p16 ldx [%o5+24], %g1 C p0 b .L1 add %o0, -16, %o0 .align 16 .L_two_or_more: subcc %o2, 1, %o2 ld [%o1], %f11 C read up[i] fmuld %f2, %f8, %f16 fmuld %f2, %f6, %f4 add %o1, 4, %o1 C up++ bne,pt %icc, .L_three_or_more fxtod %f10, %f2 fdtox %f16, %f14 fdtox %f4, %f12 std %f14, [%o5+16] fmuld %f2, %f8, %f16 std %f12, [%o5+24] fmuld %f2, %f6, %f4 fdtox %f16, %f14 fdtox %f4, %f12 std %f14, [%o5+0] std %f12, [%o5+8] ldx [%o5+16], %g2 C p16 ldx [%o5+24], %g1 C p0 b .L2 add %o0, -12, %o0 .align 16 .L_three_or_more: subcc %o2, 1, %o2 ld [%o1], %f11 C read up[i] fdtox %f16, %f14 fdtox %f4, %f12 std %f14, [%o5+16] fmuld %f2, %f8, %f16 std %f12, [%o5+24] fmuld %f2, %f6, %f4 add %o1, 4, %o1 C up++ bne,pt %icc, .L_four_or_more fxtod %f10, %f2 fdtox %f16, %f14 fdtox %f4, %f12 std %f14, [%o5+0] fmuld %f2, %f8, %f16 std %f12, [%o5+8] fmuld %f2, %f6, %f4 fdtox %f16, %f14 ldx [%o5+16], %g2 C p16 fdtox %f4, %f12 ldx [%o5+24], %g1 C p0 std %f14, [%o5+16] std %f12, [%o5+24] b .L3 add %o0, -8, %o0 .align 16 .L_four_or_more: subcc %o2, 1, %o2 ld [%o1], %f11 C read up[i] fdtox %f16, %f14 fdtox %f4, %f12 std %f14, [%o5+0] fmuld %f2, %f8, %f16 std %f12, [%o5+8] fmuld %f2, %f6, %f4 add %o1, 4, %o1 C up++ bne,pt %icc, .L_five_or_more fxtod %f10, %f2 fdtox %f16, %f14 ldx [%o5+16], %g2 C p16 fdtox %f4, %f12 ldx [%o5+24], %g1 C p0 std %f14, [%o5+16] fmuld %f2, %f8, %f16 std %f12, [%o5+24] fmuld %f2, %f6, %f4 add %o1, 4, %o1 C up++ b .L4 add %o0, -4, %o0 .align 16 .L_five_or_more: subcc %o2, 1, %o2 ld [%o1], %f11 C read up[i] fdtox %f16, %f14 ldx [%o5+16], %g2 C p16 fdtox %f4, %f12 ldx [%o5+24], %g1 C p0 std %f14, [%o5+16] fmuld %f2, %f8, %f16 std %f12, [%o5+24] fmuld %f2, %f6, %f4 add %o1, 4, %o1 C up++ bne,pt %icc, .Loop fxtod %f10, %f2 b,a .L5 C BEGIN MAIN LOOP .align 16 C -- 0 .Loop: nop subcc %o2, 1, %o2 ld [%o1], %f11 C read up[i] fdtox %f16, %f14 C -- 1 sllx %g2, 16, %g4 C (p16 << 16) add %o0, 4, %o0 C rp++ ldx [%o5+0], %g2 C p16 fdtox %f4, %f12 C -- 2 nop add %g1, %g4, %g4 C p = p0 + (p16 << 16) ldx [%o5+8], %g1 C p0 fanop C -- 3 nop add %g3, %g4, %g4 C p += cy std %f14, [%o5+0] fmuld %f2, %f8, %f16 C -- 4 srlx %g4, 32, %g3 C new cy add %o1, 4, %o1 C up++ std %f12, [%o5+8] fmuld %f2, %f6, %f4 C -- 5 xor %o5, 16, %o5 C alternate scratch variables stw %g4, [%o0-4] bne,pt %icc, .Loop fxtod %f10, %f2 C END MAIN LOOP .L5: fdtox %f16, %f14 sllx %g2, 16, %g4 C (p16 << 16) ldx [%o5+0], %g2 C p16 fdtox %f4, %f12 add %g1, %g4, %g4 C p = p0 + (p16 << 16) ldx [%o5+8], %g1 C p0 add %g4, %g3, %g4 C p += cy std %f14, [%o5+0] fmuld %f2, %f8, %f16 std %f12, [%o5+8] fmuld %f2, %f6, %f4 xor %o5, 16, %o5 stw %g4, [%o0+0] srlx %g4, 32, %g3 C new cy .L4: fdtox %f16, %f14 sllx %g2, 16, %g4 C (p16 << 16) ldx [%o5+0], %g2 C p16 fdtox %f4, %f12 add %g1, %g4, %g4 C p = p0 + (p16 << 16) ldx [%o5+8], %g1 C p0 add %g3, %g4, %g4 C p += cy std %f14, [%o5+0] std %f12, [%o5+8] xor %o5, 16, %o5 stw %g4, [%o0+4] srlx %g4, 32, %g3 C new cy .L3: sllx %g2, 16, %g4 C (p16 << 16) ldx [%o5+0], %g2 C p16 add %g1, %g4, %g4 C p = p0 + (p16 << 16) ldx [%o5+8], %g1 C p0 add %g3, %g4, %g4 C p += cy xor %o5, 16, %o5 stw %g4, [%o0+8] srlx %g4, 32, %g3 C new cy .L2: sllx %g2, 16, %g4 C (p16 << 16) ldx [%o5+0], %g2 C p16 add %g1, %g4, %g4 C p = p0 + (p16 << 16) ldx [%o5+8], %g1 C p0 add %g3, %g4, %g4 C p += cy stw %g4, [%o0+12] srlx %g4, 32, %g3 C new cy .L1: sllx %g2, 16, %g4 C (p16 << 16) add %g1, %g4, %g4 C p = p0 + (p16 << 16) add %g3, %g4, %g4 C p += cy stw %g4, [%o0+16] srlx %g4, 32, %g3 C new cy mov %g3, %o0 retl sub %sp, -FSIZE, %sp EPILOGUE(mpn_mul_1)
SECTION "ROM Bank 1A", ROMX[$4000], BANK[$1A] initialize: ld sp, $FFFF .waitForVBlank: ifEq [gbLY], 145, .waitForVBlank clear [gbLCDC] assign [RST_0000], $0A memsetWithValue gbVRAM, $2000, $00 memsetWithValue gbRAM, $2000, $00 ld sp, $E000 memsetWithValue gbOAMRAM, $0100, $00 memsetWithValue hDMARegion, $007F, $00 memsetWithValue gbCARTRAM, $1C00, $00 clear [gbIF] assign [gbIE], IE_LCDC | IE_TIMEROVERFLOW | IE_VBLANK assign [gbTIMA], $FF assign [gbTMA], $BC clear [gbTAC] assign [gbSTAT], STATF_LYC assign [gbLYC], 255 ld [wDesiredLYC], a _changebank $1A memcpyFromTo $40E8, $FF88, $000A ld hl, $DA21 ld a, $02 ldd [hl], a ld [hl], $2B clear [$DA1C] cbcall $1E, $4232 cbcall $07, $57BC cbcall $07, $401D clear [gbBGP] ld [$CD00], a ld [gbOBP0], a ld [$CD01], a ld [gbOBP1], a ld [$CD02], a ld [gbSCY], a ld [gbSCX], a ld [gbWY], a ld [gbWX], a ld [$DA2B], a assign [$DA08], $C0 assign [$DA28], $C2 assign [wTrampoline], INSTRUCTION_jp_imm16 ld hl, $0342 call stashHL ld hl, wLCDInterruptTrampoline ld a, $C3 ldi [hl], a ld a, $42 ldi [hl], a ld [hl], $03 ld hl, $DA16 ld a, $42 ldi [hl], a ld [hl], $03 ei assign [gbTAC], $04 jp toc_01_10DE DMARoutine: assign [gbDMA], $C0 ld a, $28 .wait: dec a jr nz, .wait ret db $36, $41, $3B, $41, $40, $41, $45, $41 db $4A, $41, $4F, $41, $54, $41, $59, $41 db $5E, $41, $63, $41, $68, $41, $6D, $41 db $72, $41, $77, $41, $7C, $41, $81, $41 db $86, $41, $8B, $41, $90, $41, $95, $41 db $9A, $41, $A4, $41, $9F, $41, $AE, $41 db $A9, $41, $B3, $41, $B8, $41, $BD, $41 db $C2, $41, $C7, $41, $CC, $41, $D1, $41 db $D6, $41, $DB, $41, $03, $34, $37, $36 db $08, $03, $34, $39, $38, $10, $03, $34 db $3B, $3A, $1F, $03, $34, $3D, $3C, $0B db $03, $34, $3F, $3E, $0E, $03, $34, $41 db $40, $11, $03, $34, $43, $42, $13, $03 db $34, $45, $44, $12, $03, $34, $47, $46 db $14, $03, $34, $49, $48, $15, $03, $34 db $4D, $4C, $0A, $03, $34, $4B, $4A, $0F db $03, $34, $4F, $4E, $1D, $03, $34, $51 db $50, $16, $03, $35, $53, $52, $16, $03 db $35, $55, $54, $17, $03, $35, $57, $56 db $18, $03, $35, $59, $58, $19, $03, $35 db $5B, $5A, $1B, $03, $35, $5D, $5C, $1A db $03, $35, $5F, $5E, $1C, $03, $35, $61 db $60, $1E, $03, $34, $63, $62, $1E, $03 db $35, $65, $64, $23, $03, $34, $67, $66 db $23, $03, $34, $69, $68, $21, $03, $34 db $6B, $6A, $22, $03, $34, $6D, $6C, $00 db $03, $34, $6F, $6E, $01, $03, $34, $71 db $70, $02, $03, $34, $73, $72, $03, $03 db $34, $75, $74, $04, $03, $34, $77, $76 db $05, $03, $34, $79, $78, $06 toc_1A_41E0: ld a, [$DEED] or a ret z pop hl ld a, d ld hl, $40F2 add a, a add a, l ld l, a jr nc, .else_1A_41F0 inc h .else_1A_41F0: ldi a, [hl] ld h, [hl] ld l, a ld a, [hl] ld c, a ld de, $CD0C ld [de], a inc e ld b, $00 add hl, bc .loop_1A_41FD: ldd a, [hl] ld [de], a inc e dec c jr nz, .loop_1A_41FD jr toc_1A_4205.toc_1A_4235 toc_1A_4205: ld a, [$DEED] or a ret z pop hl ld a, d ld hl, $40F2 add a, a add a, l ld l, a jr nc, .else_1A_4215 inc h .else_1A_4215: ldi a, [hl] ld h, [hl] ld l, a ldi a, [hl] ld c, a ld de, $CD0C ld [de], a inc e inc hl .loop_1A_4220: ldi a, [hl] ld [de], a inc e dec c jr nz, .loop_1A_4220 ld hl, $CD09 ld de, $CD00 ld b, $03 .loop_1A_422E: ldi a, [hl] ld [de], a ld [$ff00+c], a inc e dec b jr nz, .loop_1A_422E .toc_1A_4235: assign [$DA34], $0D assign [$DA38], $01 assign [$FF84], $04 jp toc_1A_42A4.toc_1A_42CA toc_1A_4246: assign [$DA37], $FF call toc_1A_4205 .toc_1A_424E: ld a, e ld [$FF84], a ld a, [$CD00] or a ld a, $00 jr z, .else_1A_425B ld a, $01 .else_1A_425B: ld [$DA35], a ld hl, $CD08 ld de, $CD0B ld c, $06 .loop_1A_4266: ld a, [de] dec e call toc_1A_42DD ldd [hl], a dec c jr nz, .loop_1A_4266 jr toc_1A_42A4.toc_1A_42C5 db $CD, $92, $42, $18, $0D, $CD, $9A, $42 db $18, $08 toc_1A_427B: call toc_1A_42A4 jr toc_1A_4283 db $CD, $AC, $42 toc_1A_4283: assign [$DA39], $01 call toc_01_0343 ld a, [$DA36] or a jr nz, toc_1A_4283 ret db $3E, $01, $EA, $37, $DA, $CD, $E0, $41 db $3E, $01, $EA, $35, $DA, $7B, $E0, $84 db $18, $10 toc_1A_42A4: assign [$DA37], $00 call toc_1A_41E0 assign [$DA35], $00 ld a, e ld [$FF84], a ld hl, $CD03 ld de, $CD00 ld c, $09 .loop_1A_42BC: ld a, [de] inc e call toc_1A_42DD ldi [hl], a dec c jr nz, .loop_1A_42BC .toc_1A_42C5: assign [$DA34], $03 .toc_1A_42CA: copyFromTo [$FF84], [$DA32] ld [$DA33], a assign [$DA36], $01 ld hl, $0684 jp toc_01_05F9 toc_1A_42DD: ld b, a ld a, [$DA35] cp $00 ld a, b jr nz, .else_1A_4305 ld b, a and %11000000 ld a, b jr z, .else_1A_42EF sub a, $40 ld b, a .else_1A_42EF: and %00110000 ld a, b jr z, .else_1A_42F7 sub a, $10 ld b, a .else_1A_42F7: and %00001100 ld a, b jr z, .else_1A_42FF sub a, $04 ld b, a .else_1A_42FF: and %00000011 ld a, b ret z dec a ret .else_1A_4305: ld b, a and %11000000 cp $C0 ld a, b jr z, .else_1A_4310 add a, $40 ld b, a .else_1A_4310: and %00110000 cp $30 ld a, b jr z, .else_1A_431A add a, $10 ld b, a .else_1A_431A: and %00001100 cp $0C ld a, b jr z, .else_1A_4324 add a, $04 ld b, a .else_1A_4324: and %00000011 cp $03 ld a, b ret z inc a ret db $17, $FF, $0D, $0F, $46, $D8, $0F, $5E db $03, $0F, $5F, $08, $0F, $60, $0B, $03 db $4E, $43, $5A, $19, $00, $0A, $19, $01 db $0A, $19, $00, $0A, $19, $02, $0A, $06 db $3F, $43, $01, $7B, $43, $CD, $5B, $25 db $CD, $63, $43, $CD, $89, $43, $C0, $1E db $1A, $01, $A1, $43, $C3, $46, $08, $FA db $2C, $DD, $CB, $47, $20, $03, $CB, $4F db $C8, $1E, $39, $21, $99, $42, $3E, $1E db $CD, $CF, $05, $F0, $9A, $57, $C9, $FF db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $26, $A8, $7C db $BA, $28, $0B, $2E, $00, $7E, $3C, $28 db $05, $2E, $4C, $7E, $B7, $C0, $24, $7C db $FE, $B2, $20, $EB, $C9, $03, $AE, $43 db $5A, $22, $3F, $43, $1A, $05, $3C, $06 db $B7, $43, $01, $7B, $43, $CD, $5B, $25 db $C3, $63, $43, $0D, $C2, $43, $03, $CB db $43, $5A, $0D, $E4, $43, $00, $21, $CE db $52, $3E, $03, $CD, $CF, $05, $C9, $01 db $7B, $43, $CD, $5B, $25, $CD, $63, $43 db $CD, $22, $24, $FA, $4D, $CD, $B7, $C0 db $1E, $1A, $01, $54, $44, $C3, $46, $08 db $C5, $21, $4D, $CD, $3E, $01, $22, $3E db $60, $22, $3E, $88, $22, $FA, $71, $A0 db $4F, $1E, $5B, $1A, $FE, $04, $28, $1B db $B7, $20, $15, $1E, $09, $CD, $3B, $06 db $1E, $01, $FE, $04, $38, $06, $1C, $FE db $06, $38, $01, $1C, $7B, $1E, $5B, $12 db $B9, $20, $19, $CD, $47, $06, $E6, $07 db $3E, $04, $20, $02, $3E, $05, $12, $01 db $91, $5D, $11, $40, $02, $20, $1D, $01 db $D1, $5F, $18, $18, $01, $91, $58, $11 db $80, $02, $FE, $02, $28, $0E, $01, $31 db $56, $11, $60, $02, $38, $06, $01, $11 db $5B, $11, $80, $02, $71, $2C, $70, $2C db $73, $2C, $72, $C1, $F0, $9A, $57, $C9 db $10, $5B, $13, $04, $5C, $44, $24, $5C db $03, $63, $44, $5A, $06, $3F, $43, $1E db $15, $01, $00, $02, $CD, $35, $0D, $CD db $A4, $0D, $CD, $25, $1A, $CB, $7F, $28 db $08, $1E, $1A, $01, $86, $44, $C3, $46 db $08, $01, $7B, $43, $CD, $5B, $25, $C3 db $63, $43, $10, $5B, $13, $04, $9A, $44 db $14, $05, $95, $44, $24, $5D, $06, $9C db $44, $24, $60, $06, $9C, $44, $24, $23 db $18, $0F, $5E, $03, $0F, $5F, $08, $0F db $60, $0A, $0F, $61, $40, $03, $3C, $45 db $5A, $0D, $50, $0F, $1F, $A8, $B2, $0D db $50, $0F, $20, $A8, $B2, $0D, $50, $0F db $21, $A8, $B2, $05, $02, $27, $0F, $46 db $86, $10, $5B, $0E, $06, $D5, $44, $D5 db $44, $DC, $44, $E3, $44, $EA, $44, $F1 db $44, $04, $C1, $6D, $0A, $06, $FB, $44 db $04, $2D, $6E, $0A, $06, $FB, $44, $04 db $99, $6E, $0A, $06, $FB, $44, $04, $05 db $6F, $0A, $06, $F5, $44, $04, $56, $6F db $0A, $19, $00, $30, $06, $0A, $45, $19 db $00, $28, $19, $03, $04, $19, $00, $04 db $19, $03, $04, $19, $00, $04, $08, $80 db $FE, $03, $22, $45, $5A, $01, $01, $00 db $18, $03, $3C, $45, $5A, $19, $02, $0A db $19, $01, $0A, $06, $19, $45, $1E, $15 db $01, $00, $02, $CD, $35, $0D, $CD, $A4 db $0D, $CD, $25, $1A, $CB, $7F, $28, $08 db $1E, $1A, $01, $14, $45, $C3, $46, $08 db $01, $7B, $43, $CD, $5B, $25, $CD, $63 db $43, $FA, $2C, $DD, $CB, $5F, $C8, $CD db $09, $28, $D8, $1E, $5B, $1A, $FE, $04 db $30, $24, $FA, $51, $A0, $FE, $0C, $C8 db $1E, $5B, $1A, $EA, $43, $A0, $1E, $02 db $01, $40, $73, $CD, $48, $0C, $21, $03 db $A0, $5D, $06, $06, $1A, $22, $1C, $05 db $20, $FA, $62, $C3, $BA, $0B, $20, $21 db $FA, $71, $A0, $B7, $21, $4C, $A0, $1E db $0C, $06, $02, $28, $07, $21, $72, $A0 db $1E, $06, $06, $01, $7E, $BB, $30, $02 db $80, $77, $1E, $10, $CD, $AA, $10, $18 db $D9, $21, $7C, $7C, $3E, $03, $CD, $CF db $05, $3E, $01, $EA, $62, $DD, $18, $CA db $0B, $D4, $45, $07, $98, $FE, $08, $98 db $FE, $19, $FF, $02, $19, $00, $04, $18 db $05, $06, $16, $0B, $D4, $45, $08, $00 db $FE, $06, $B5, $45, $0B, $D4, $45, $07 db $68, $01, $08, $98, $FE, $06, $B5, $45 db $17, $F6, $0D, $03, $A4, $0D, $40, $04 db $46, $72, $0B, $0D, $E3, $45, $0C, $C5 db $1E, $48, $1A, $67, $2E, $5B, $7E, $21 db $FE, $45, $85, $6F, $30, $01, $24, $7E db $62, $2E, $07, $86, $22, $7E, $CE, $FF db $77, $C1, $C9, $F8, $F6, $F8, $F8, $F2 db $FE, $17, $FF, $0D, $03, $13, $46, $5A db $00, $05, $3C, $0D, $C2, $43, $16, $CD db $89, $43, $C0, $1E, $1A, $01, $0D, $46 db $C3, $46, $08, $17, $F6, $0D, $04, $52 db $6F, $0B, $0F, $4C, $00, $0F, $5E, $08 db $0F, $5F, $08, $0D, $8B, $46, $0F, $60 db $00, $0F, $61, $40, $0F, $3D, $10, $0F db $40, $20, $0F, $3A, $78, $0F, $3B, $00 db $0D, $A5, $1A, $1A, $3E, $12, $6B, $46 db $0F, $3A, $2C, $0F, $3B, $01, $10, $39 db $0E, $03, $5C, $46, $62, $46, $68, $46 db $26, $A0, $00, $06, $6B, $46, $26, $C0 db $00, $06, $6B, $46, $26, $E0, $00, $0F db $45, $00, $03, $AC, $46, $5A, $01, $07 db $1F, $7D, $46, $0D, $91, $46, $06, $74 db $46, $1E, $3E, $1A, $B7, $3E, $08, $28 db $02, $3E, $03, $1E, $24, $12, $C9, $C5 db $CD, $64, $19, $C1, $C9, $1E, $0E, $1A db $17, $1E, $15, $1A, $30, $09, $3D, $FE db $06, $20, $0B, $3E, $0A, $18, $07, $3C db $FE, $0B, $20, $02, $3E, $07, $12, $C9 db $1E, $3E, $1A, $B7, $1E, $15, $01, $00 db $02, $28, $05, $1E, $04, $01, $30, $00 db $CD, $35, $0D, $CD, $A4, $0D, $1E, $3E db $1A, $B7, $20, $19, $CD, $B3, $1A, $20 db $14, $3E, $01, $1E, $3E, $12, $1E, $0D db $AF, $12, $1C, $12, $1E, $3A, $3E, $78 db $12, $1C, $3E, $00, $12, $CD, $25, $1A db $47, $CB, $78, $28, $13, $1E, $3E, $1A db $B7, $21, $80, $FD, $28, $03, $21, $00 db $00, $1E, $0F, $7D, $12, $1C, $7C, $12 db $CB, $68, $28, $0D, $1E, $0D, $1A, $2F db $C6, $01, $12, $1C, $1A, $2F, $CE, $00 db $12, $78, $E6, $A0, $28, $0D, $1E, $41 db $21, $99, $42, $3E, $1E, $CD, $CF, $05 db $F0, $9A, $57, $1E, $3D, $1A, $B7, $28 db $04, $3D, $12, $18, $0D, $01, $66, $47 db $CD, $5B, $25, $D8, $FA, $5B, $A0, $3C db $20, $0F, $62, $2E, $3A, $7E, $D6, $01 db $22, $30, $0E, $7E, $D6, $01, $77, $30 db $08, $1E, $03, $01, $33, $4E, $C3, $46 db $08, $1E, $40, $1A, $B7, $28, $04, $3D db $12, $18, $0E, $D5, $CD, $EA, $1A, $CD db $46, $16, $D1, $E6, $7F, $FE, $08, $28 db $E0, $C9, $FF, $00, $9B, $4D, $03, $33 db $4E, $03, $00, $00, $00, $33, $4E, $03 db $17, $FF, $0D, $0F, $46, $00, $19, $00 db $08, $19, $01, $08, $19, $02, $08, $19 db $03, $08, $06, $7A, $47, $17, $FF, $0D db $0F, $27, $00, $0D, $F6, $47, $12, $E3 db $47, $05, $01, $0D, $F6, $47, $11, $95 db $47, $10, $46, $1A, $39, $0F, $46, $00 db $04, $E6, $72, $0B, $19, $1B, $04, $19 db $1A, $03, $19, $19, $02, $19, $18, $02 db $19, $17, $02, $19, $16, $02, $19, $15 db $01, $19, $14, $01, $19, $13, $01, $19 db $07, $01, $04, $52, $6F, $0B, $19, $07 db $03, $19, $08, $03, $0F, $5B, $06, $0D db $50, $0F, $1F, $A8, $B2, $0D, $50, $0F db $21, $A8, $B2, $10, $39, $1A, $46, $04 db $7B, $7B, $0C, $19, $00, $3C, $19, $01 db $03, $19, $02, $03, $19, $03, $03, $06 db $E7, $47, $1E, $5B, $1A, $5F, $21, $60 db $DB, $7E, $CD, $2A, $16, $A7, $C8, $1E db $27, $12, $C9, $17, $FF, $0D, $0D, $29 db $48, $12, $1A, $48, $01, $FF, $05, $01 db $0D, $29, $48, $11, $12, $48, $19, $04 db $3C, $19, $05, $03, $19, $06, $03, $19 db $07, $03, $06, $1A, $48, $FA, $60, $DB db $5F, $1C, $FA, $6A, $DB, $1F, $1D, $20 db $FC, $3E, $00, $17, $1E, $27, $12, $C9 db $1E, $04, $1A, $C6, $05, $12, $1C, $1A db $CE, $00, $12, $C9, $04, $92, $73, $0A db $03, $A4, $0D, $40, $07, $00, $00, $08 db $40, $00, $19, $0A, $0A, $19, $0B, $0A db $19, $0C, $0A, $19, $0D, $0A, $19, $0E db $0A, $19, $0F, $0A, $19, $10, $0A, $19 db $11, $0A, $19, $12, $0A, $0D, $7A, $48 db $05, $3C, $0D, $89, $48, $00, $C5, $D5 db $1E, $0C, $21, $AC, $42, $3E, $1A, $CD db $CF, $05, $D1, $C1, $C9, $3E, $07, $EA db $82, $A0, $C9, $10, $09, $14, $50, $9F db $48, $0D, $BB, $35, $18, $00, $69, $00 db $06, $A6, $48, $0D, $BB, $35, $88, $00 db $69, $00, $1C, $F4, $74, $08, $0F, $46 db $00, $10, $09, $14, $50, $B9, $48, $0F db $45, $40, $06, $BC, $48, $0F, $45, $C0 db $04, $40, $4F, $0A, $01, $00, $0D, $87 db $4A, $11, $8A, $49, $03, $FD, $34, $40 db $0D, $68, $35, $33, $05, $01, $10, $64 db $12, $D0, $48, $0F, $1F, $80, $0B, $77 db $4E, $01, $00, $05, $0A, $01, $07, $08 db $80, $FD, $2A, $3D, $24, $0D, $05, $0A db $01, $04, $05, $0A, $01, $05, $08, $00 db $00, $2A, $00, $05, $06, $01, $00, $05 db $06, $01, $07, $08, $80, $FD, $2A, $3D db $24, $0D, $05, $0A, $01, $04, $05, $0A db $01, $05, $08, $00, $00, $2A, $00, $05 db $06, $01, $00, $05, $0A, $01, $01, $08 db $00, $FE, $2A, $0D, $24, $0D, $05, $20 db $24, $16, $0D, $50, $0F, $AB, $A0, $B3 db $0D, $50, $0F, $AF, $A0, $B3, $01, $02 db $05, $04, $0D, $50, $0F, $AC, $A0, $B3 db $0D, $50, $0F, $B0, $A0, $B3, $01, $02 db $05, $04, $0D, $50, $0F, $AD, $A0, $B3 db $0D, $50, $0F, $B1, $A0, $B3, $01, $03 db $05, $02, $0D, $50, $0F, $AE, $A0, $B3 db $2A, $0C, $05, $06, $01, $04, $2A, $0D db $05, $1E, $08, $00, $00, $2A, $00, $05 db $01, $01, $05, $08, $00, $00, $2A, $00 db $24, $0E, $05, $07, $0D, $50, $0F, $B2 db $A0, $B3, $01, $06, $25, $2A, $05, $3C db $05, $F0, $0D, $81, $4A, $00, $03, $FD db $34, $40, $0D, $68, $35, $2E, $05, $01 db $10, $64, $12, $92, $49, $0D, $68, $35 db $2F, $05, $01, $10, $64, $12, $9D, $49 db $0F, $1F, $80, $0D, $91, $4A, $0B, $7E db $4E, $01, $07, $05, $14, $25, $15, $0D db $50, $0F, $B3, $A0, $B3, $05, $5A, $09 db $44, $01, $31, $05, $04, $01, $07, $05 db $06, $0A, $01, $31, $05, $04, $09, $0F db $01, $31, $05, $02, $01, $07, $05, $02 db $0A, $01, $31, $05, $02, $01, $07, $05 db $14, $01, $19, $08, $00, $FD, $2A, $5A db $05, $08, $01, $1A, $24, $5B, $25, $FF db $05, $08, $01, $1B, $08, $00, $00, $2A db $00, $0D, $88, $35, $05, $1E, $09, $02 db $01, $1D, $05, $04, $01, $1C, $05, $04 db $01, $1D, $05, $04, $01, $1B, $05, $04 db $0A, $09, $02, $01, $1D, $05, $02, $01 db $1C, $05, $02, $01, $1D, $05, $02, $01 db $1B, $05, $02, $0A, $09, $02, $01, $1D db $05, $01, $01, $1C, $05, $01, $01, $1D db $05, $01, $01, $1B, $05, $01, $0A, $09 db $06, $01, $1D, $05, $01, $01, $1C, $05 db $01, $0A, $09, $06, $01, $1E, $05, $01 db $01, $1F, $05, $01, $0A, $0D, $50, $0F db $BE, $A0, $B3, $09, $80, $01, $1E, $05 db $02, $01, $1F, $05, $01, $0A, $2A, $F6 db $24, $3B, $09, $04, $0D, $50, $0F, $BA db $A0, $B3, $0D, $50, $0F, $BB, $A0, $B3 db $0D, $50, $0F, $BC, $A0, $B3, $0D, $50 db $0F, $BD, $A0, $B3, $01, $20, $05, $14 db $0A, $0D, $A6, $4E, $16, $3E, $06, $EA db $82, $A0, $C9, $FA, $63, $DD, $F6, $80 db $3C, $1E, $27, $12, $C9, $3E, $01, $EA db $16, $DF, $C9, $B3, $4A, $BC, $4A, $C5 db $4A, $CE, $4A, $D7, $4A, $E0, $4A, $E9 db $4A, $F2, $4A, $FB, $4A, $00, $4B, $05 db $4B, $0A, $4B, $0F, $4B, $14, $4B, $02 db $F8, $F8, $46, $00, $F8, $00, $30, $01 db $02, $F8, $F8, $38, $00, $F8, $00, $3A db $01, $02, $F8, $00, $2E, $00, $F8, $F8 db $28, $01, $02, $F8, $00, $3E, $00, $F8 db $F8, $3C, $01, $02, $F8, $00, $0E, $00 db $F8, $F8, $06, $01, $02, $F8, $00, $0A db $00, $F8, $F8, $08, $01, $02, $F8, $00 db $36, $00, $F8, $F8, $34, $01, $02, $F8 db $00, $02, $00, $F8, $F8, $00, $01, $01 db $F4, $FC, $80, $01, $01, $F4, $FC, $40 db $11, $01, $F4, $FC, $42, $11, $01, $EE db $02, $80, $01, $01, $EE, $02, $40, $11 db $01, $EE, $02, $42, $11, $7D, $4B, $86 db $4B, $8F, $4B, $98, $4B, $A1, $4B, $AA db $4B, $B3, $4B, $BC, $4B, $C5, $4B, $CE db $4B, $D7, $4B, $E0, $4B, $E9, $4B, $F2 db $4B, $FB, $4B, $04, $4C, $0D, $4C, $12 db $4C, $17, $4C, $20, $4C, $29, $4C, $36 db $4C, $43, $4C, $50, $4C, $5D, $4C, $6A db $4C, $73, $4C, $84, $4C, $95, $4C, $A6 db $4C, $B7, $4C, $C8, $4C, $D9, $4C, $EA db $4C, $F7, $4C, $04, $4D, $11, $4D, $1E db $4D, $2B, $4D, $38, $4D, $51, $4D, $7A db $4D, $A7, $4D, $D0, $4D, $F1, $4D, $0A db $4E, $2B, $4E, $50, $4E, $55, $4E, $6E db $4E, $02, $F8, $F8, $50, $00, $F8, $00 db $52, $01, $02, $F8, $F8, $54, $00, $F8 db $00, $56, $01, $02, $F8, $F8, $58, $00 db $F8, $00, $5A, $01, $02, $F8, $F8, $5C db $00, $F8, $00, $5E, $01, $02, $F8, $00 db $58, $60, $F8, $F8, $5A, $61, $02, $F8 db $00, $54, $60, $F8, $F8, $56, $61, $02 db $F8, $00, $50, $60, $F8, $F8, $52, $61 db $02, $F8, $F8, $00, $00, $F8, $00, $10 db $01, $02, $F8, $F8, $38, $00, $F8, $00 db $38, $61, $02, $F8, $F8, $38, $10, $F8 db $00, $38, $71, $02, $F8, $F8, $D4, $00 db $F8, $00, $D4, $61, $02, $F8, $F8, $D4 db $10, $F8, $00, $D4, $71, $02, $F8, $F8 db $D6, $00, $F8, $00, $D6, $21, $02, $F8 db $F8, $D8, $00, $F8, $00, $D8, $21, $02 db $F8, $F8, $CA, $00, $F8, $00, $CA, $21 db $02, $F8, $F8, $CA, $10, $F8, $00, $CA db $31, $01, $F8, $FC, $CC, $01, $01, $F8 db $FC, $CC, $11, $02, $EE, $FC, $CE, $00 db $F6, $FC, $CE, $41, $02, $EE, $FC, $CE db $10, $F6, $FC, $CE, $51, $03, $E4, $FC db $DA, $00, $F4, $FC, $DC, $00, $04, $FC db $DE, $01, $03, $E4, $FC, $EA, $00, $F4 db $FC, $EC, $00, $04, $FC, $EE, $01, $03 db $E4, $FC, $92, $00, $F4, $FC, $94, $00 db $04, $FC, $96, $01, $03, $E4, $FC, $92 db $10, $F4, $FC, $94, $10, $04, $FC, $96 db $11, $03, $E4, $FC, $98, $00, $F4, $FC db $9A, $00, $04, $FC, $9C, $01, $02, $F8 db $F8, $20, $00, $F8, $00, $40, $01, $04 db $F8, $F8, $02, $00, $F8, $00, $12, $00 db $D8, $FC, $98, $00, $E8, $FC, $9A, $01 db $04, $F8, $00, $30, $00, $F8, $F8, $48 db $00, $D8, $F6, $98, $00, $E8, $F6, $9A db $01, $04, $F8, $00, $30, $00, $F8, $F8 db $48, $00, $D8, $F6, $92, $00, $E8, $F6 db $94, $01, $04, $D8, $F6, $92, $10, $E8 db $F6, $94, $10, $F8, $00, $E6, $00, $F8 db $F8, $E8, $01, $04, $F8, $00, $30, $00 db $F8, $F8, $48, $00, $D8, $F6, $DA, $00 db $E8, $F6, $DC, $01, $04, $F8, $00, $E6 db $00, $F8, $F8, $E8, $00, $D8, $F6, $EA db $00, $E8, $F6, $EC, $01, $04, $D8, $F9 db $98, $00, $E8, $F9, $9A, $00, $F8, $F8 db $BE, $00, $F8, $00, $C8, $01, $03, $FA db $02, $22, $20, $FA, $FA, $32, $20, $FA db $F2, $42, $21, $03, $FA, $F2, $22, $00 db $FA, $FA, $32, $00, $FA, $02, $42, $01 db $03, $FA, $02, $04, $20, $FA, $FA, $14 db $20, $FA, $F2, $24, $21, $03, $FA, $02 db $06, $20, $FA, $FA, $16, $20, $FA, $F2 db $26, $21, $03, $FA, $F2, $04, $00, $FA db $FA, $14, $00, $FA, $02, $24, $01, $03 db $FA, $F2, $06, $00, $FA, $FA, $16, $00 db $FA, $02, $26, $01, $06, $E9, $02, $A4 db $20, $E9, $FA, $B4, $20, $E9, $F2, $C4 db $20, $F9, $02, $A6, $20, $F9, $FA, $B6 db $20, $F9, $F2, $C6, $21, $0A, $D9, $05 db $08, $20, $D9, $FD, $18, $20, $E9, $02 db $0A, $20, $E9, $FA, $1A, $20, $E9, $F2 db $2A, $20, $F9, $02, $0C, $20, $F9, $FA db $1C, $20, $F9, $F2, $2C, $20, $D9, $EE db $08, $00, $D9, $F6, $18, $01, $0B, $F7 db $FE, $34, $20, $F7, $F6, $44, $20, $CF db $06, $A8, $20, $CF, $FE, $B8, $20, $DF db $02, $AA, $20, $DF, $FA, $BA, $20, $EF db $FA, $BC, $20, $DF, $F2, $AC, $20, $EF db $F2, $AE, $20, $CF, $EF, $A8, $00, $CF db $F7, $B8, $01, $0A, $FC, $FA, $36, $20 db $D4, $06, $A8, $20, $D4, $FE, $B8, $20 db $E4, $02, $AA, $20, $E4, $FA, $BA, $20 db $F4, $FA, $BC, $20, $E4, $F2, $AC, $20 db $F4, $F2, $AE, $20, $D4, $EF, $A8, $00 db $D4, $F7, $B8, $01, $08, $C8, $EF, $3E db $00, $C8, $F7, $4E, $00, $D8, $EF, $28 db $00, $D8, $F7, $E0, $00, $C8, $06, $3E db $20, $C8, $FE, $4E, $20, $D8, $06, $28 db $20, $D8, $FE, $E0, $21, $06, $C4, $FE db $0E, $20, $C4, $F7, $0E, $00, $D4, $EF db $1E, $00, $D4, $F7, $2E, $00, $D4, $06 db $1E, $20, $D4, $FE, $2E, $21, $08, $C8 db $06, $3A, $20, $C8, $FE, $4A, $20, $C8 db $EF, $3A, $00, $C8, $F7, $4A, $00, $D8 db $EF, $3C, $00, $D8, $F7, $4C, $00, $D8 db $06, $3C, $20, $D8, $FE, $4C, $21, $09 db $F3, $EF, $A0, $00, $F3, $F7, $B0, $00 db $F3, $FF, $C0, $00, $F3, $07, $D0, $00 db $03, $EF, $A2, $00, $03, $F7, $B2, $00 db $03, $FF, $C2, $00, $03, $07, $D2, $00 db $FB, $0F, $9E, $01, $01, $F4, $FC, $80 db $01, $06, $00, $EF, $90, $00, $00, $07 db $86, $00, $F0, $FF, $88, $00, $00, $FF db $8A, $00, $F0, $F7, $8C, $00, $00, $F7 db $8E, $01, $02, $F8, $00, $E2, $00, $F8 db $F8, $E4, $01, $04, $97, $4A, $1A, $06 db $82, $4E, $04, $19, $4B, $1A, $17, $F6 db $0D, $03, $34, $54, $5A, $29, $00, $2A db $00, $18, $0C, $04, $19, $4B, $1A, $17 db $05, $0E, $03, $34, $54, $5A, $29, $00 db $2A, $00, $18, $20, $00, $00, $21, $00 db $00, $0C, $21, $82, $A0, $36, $03, $C9 db $1E, $39, $C3, $1A, $10, $FA, $45, $A8 db $1E, $45, $12, $2F, $18, $06, $FA, $45 db $A0, $1E, $39, $12, $1E, $04, $21, $51 db $DB, $17, $30, $1B, $C5, $2A, $C6, $A0 db $4F, $7E, $CE, $00, $47, $E1, $79, $96 db $23, $12, $1C, $78, $9E, $23, $12, $44 db $4D, $C9, $1E, $07, $21, $53, $DB, $0A db $03, $86, $23, $12, $1C, $0A, $03, $8E db $12, $C9, $0B, $77, $4E, $01, $08, $07 db $80, $FE, $08, $00, $02, $29, $18, $2A db $E0, $05, $08, $01, $09, $05, $05, $01 db $0A, $05, $03, $16, $0B, $77, $4E, $01 db $08, $07, $A0, $FD, $29, $26, $05, $08 db $01, $09, $05, $05, $01, $0A, $05, $03 db $16, $0B, $77, $4E, $01, $08, $07, $30 db $FE, $08, $00, $FE, $29, $1D, $2A, $20 db $05, $08, $01, $09, $05, $05, $01, $0A db $05, $03, $16, $0B, $77, $4E, $01, $08 db $08, $00, $FD, $2A, $30, $05, $08, $01 db $09, $05, $05, $01, $0A, $05, $03, $16 db $0B, $77, $4E, $01, $08, $07, $D0, $01 db $08, $00, $FE, $29, $E3, $2A, $20, $05 db $08, $01, $09, $05, $05, $01, $0A, $05 db $03, $16, $0B, $77, $4E, $01, $08, $07 db $60, $02, $29, $DA, $05, $08, $01, $09 db $05, $05, $01, $0A, $05, $03, $16, $0B db $77, $4E, $01, $08, $07, $00, $02, $08 db $00, $02, $29, $E0, $2A, $E0, $05, $08 db $01, $09, $05, $05, $01, $0A, $05, $03 db $16, $0B, $77, $4E, $0D, $AD, $4F, $01 db $0B, $08, $00, $FD, $2A, $30, $05, $08 db $01, $0C, $05, $05, $01, $0D, $05, $03 db $16, $FA, $45, $A0, $1E, $45, $12, $C9 db $0B, $7E, $4E, $0D, $BA, $4E, $18, $00 db $0D, $DE, $4E, $F8, $FF, $09, $03, $01 db $00, $08, $10, $01, $05, $04, $01, $01 db $05, $04, $01, $02, $05, $04, $01, $03 db $05, $04, $01, $04, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $0A, $01 db $00, $08, $00, $00, $05, $08, $01, $08 db $05, $08, $01, $09, $05, $08, $09, $02 db $01, $08, $05, $04, $01, $09, $05, $04 db $0A, $09, $04, $01, $0A, $05, $02, $01 db $0B, $05, $02, $0A, $01, $0C, $05, $04 db $01, $0D, $05, $04, $09, $03, $01, $0E db $05, $04, $01, $0F, $05, $04, $0A, $24 db $5F, $0D, $50, $0F, $B4, $A0, $B3, $09 db $02, $01, $0D, $05, $08, $01, $0C, $05 db $08, $01, $0D, $05, $08, $01, $0E, $05 db $08, $01, $0F, $05, $08, $0A, $0D, $50 db $0F, $B5, $A0, $B3, $09, $02, $01, $0D db $05, $08, $01, $0C, $05, $08, $01, $0D db $05, $08, $01, $0E, $05, $08, $01, $0F db $05, $08, $0A, $0D, $50, $0F, $B6, $A0 db $B3, $09, $02, $01, $0D, $05, $08, $01 db $0C, $05, $08, $01, $0D, $05, $08, $01 db $0E, $05, $08, $01, $0F, $05, $08, $0A db $0D, $50, $0F, $B7, $A0, $B3, $09, $02 db $01, $0D, $05, $08, $01, $0C, $05, $08 db $01, $0D, $05, $08, $01, $0E, $05, $08 db $01, $0F, $05, $08, $0A, $0D, $50, $0F db $B8, $A0, $B3, $09, $02, $01, $0D, $05 db $08, $01, $0C, $05, $08, $01, $0D, $05 db $08, $01, $0E, $05, $08, $01, $0F, $05 db $08, $0A, $0D, $50, $0F, $B9, $A0, $B3 db $09, $04, $01, $0D, $05, $08, $01, $0C db $05, $08, $01, $0D, $05, $08, $01, $0E db $05, $08, $01, $0F, $05, $08, $0A, $09 db $02, $01, $0E, $05, $04, $01, $0F, $05 db $04, $0A, $09, $03, $01, $0E, $05, $02 db $01, $0F, $05, $02, $0A, $09, $02, $01 db $10, $05, $02, $01, $11, $05, $02, $0A db $09, $02, $01, $12, $05, $02, $01, $13 db $05, $02, $0A, $09, $02, $01, $14, $05 db $04, $01, $15, $05, $04, $0A, $09, $02 db $01, $16, $05, $04, $01, $17, $05, $04 db $0A, $01, $18, $05, $04, $09, $02, $01 db $16, $05, $04, $01, $17, $05, $04, $0A db $01, $18, $05, $1E, $16, $0B, $7E, $4E db $0D, $BA, $4E, $08, $00, $0D, $DE, $4E db $F8, $FF, $09, $03, $01, $00, $0D, $AC db $4E, $2D, $00, $08, $10, $01, $05, $04 db $01, $01, $05, $04, $01, $02, $05, $04 db $01, $03, $05, $04, $01, $04, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $0A, $01, $08, $0D, $AC, $4E, $00, $00 db $08, $00, $00, $05, $08, $01, $09, $05 db $08, $09, $02, $01, $08, $05, $04, $01 db $09, $05, $04, $0A, $09, $02, $01, $0A db $05, $02, $01, $0B, $05, $02, $0A, $24 db $5F, $16, $0B, $7E, $4E, $0D, $BA, $4E db $98, $00, $0D, $DE, $4E, $F8, $FF, $09 db $03, $01, $00, $0D, $AC, $4E, $80, $FE db $08, $10, $01, $05, $04, $01, $01, $05 db $04, $01, $02, $05, $04, $01, $03, $05 db $04, $01, $04, $05, $04, $01, $05, $05 db $04, $01, $06, $05, $04, $0A, $01, $08 db $0D, $AC, $4E, $00, $00, $08, $00, $00 db $05, $08, $01, $09, $05, $08, $09, $02 db $01, $08, $05, $04, $01, $09, $05, $04 db $0A, $09, $02, $01, $0A, $05, $02, $01 db $0B, $05, $02, $0A, $24, $5F, $16, $0B db $7E, $4E, $0D, $BA, $4E, $F8, $FF, $0D db $DE, $4E, $18, $00, $09, $03, $01, $00 db $0D, $AC, $4E, $64, $00, $08, $AA, $00 db $05, $04, $01, $01, $05, $04, $01, $02 db $05, $04, $01, $03, $05, $04, $01, $04 db $05, $04, $01, $05, $05, $04, $01, $06 db $05, $04, $0A, $01, $08, $0D, $AC, $4E db $00, $00, $08, $00, $00, $05, $08, $01 db $09, $05, $08, $09, $02, $01, $08, $05 db $04, $01, $09, $05, $04, $0A, $09, $02 db $01, $0A, $05, $02, $01, $0B, $05, $02 db $0A, $24, $5F, $16, $0B, $7E, $4E, $0D db $BA, $4E, $A8, $00, $0D, $DE, $4E, $18 db $00, $09, $03, $01, $00, $0D, $AC, $4E db $50, $FE, $08, $AA, $00, $05, $04, $01 db $01, $05, $04, $01, $02, $05, $04, $01 db $03, $05, $04, $01, $04, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $0A db $01, $08, $0D, $AC, $4E, $00, $00, $08 db $00, $00, $05, $08, $01, $09, $05, $08 db $09, $02, $01, $08, $05, $04, $01, $09 db $05, $04, $0A, $09, $02, $01, $0A, $05 db $02, $01, $0B, $05, $02, $0A, $24, $5F db $16, $0B, $7E, $4E, $0D, $BA, $4E, $F8 db $FF, $0D, $DE, $4E, $52, $00, $09, $03 db $01, $00, $0D, $AC, $4E, $60, $00, $05 db $04, $01, $01, $05, $04, $01, $02, $05 db $04, $01, $03, $05, $04, $01, $04, $05 db $04, $01, $05, $05, $04, $01, $06, $05 db $04, $0A, $01, $08, $0D, $AC, $4E, $00 db $00, $05, $08, $01, $09, $05, $08, $09 db $02, $01, $08, $05, $04, $01, $09, $05 db $04, $0A, $09, $02, $01, $0A, $05, $02 db $01, $0B, $05, $02, $0A, $24, $5F, $16 db $0B, $7E, $4E, $0D, $BA, $4E, $A8, $00 db $0D, $DE, $4E, $52, $00, $09, $03, $01 db $00, $0D, $AC, $4E, $4C, $FE, $05, $04 db $01, $01, $05, $04, $01, $02, $05, $04 db $01, $03, $05, $04, $01, $04, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $0A, $01, $08, $0D, $AC, $4E, $00, $00 db $05, $08, $01, $09, $05, $08, $09, $02 db $01, $08, $05, $04, $01, $09, $05, $04 db $0A, $09, $02, $01, $0A, $05, $02, $01 db $0B, $05, $02, $0A, $24, $5F, $16, $0B db $8F, $4E, $0D, $44, $10, $FE, $FF, $0D db $40, $10, $E0, $FF, $01, $2F, $07, $70 db $FF, $08, $00, $FF, $2A, $20, $05, $64 db $16, $0B, $8F, $4E, $0D, $44, $10, $FE db $FF, $0D, $40, $10, $E0, $FF, $01, $2F db $07, $B0, $FF, $08, $00, $FE, $2A, $20 db $05, $64, $16, $0B, $8F, $4E, $0D, $44 db $10, $FE, $FF, $0D, $40, $10, $E0, $FF db $01, $2F, $07, $50, $00, $08, $80, $FD db $2A, $20, $05, $64, $16, $0B, $8F, $4E db $0D, $44, $10, $FE, $FF, $0D, $40, $10 db $E0, $FF, $01, $2F, $07, $90, $00, $08 db $E0, $FE, $2A, $20, $05, $64, $16, $0B db $7E, $4E, $0D, $B1, $4E, $50, $00, $0D db $DE, $4E, $56, $00, $25, $28, $09, $02 db $01, $21, $05, $08, $01, $22, $05, $08 db $0A, $09, $04, $01, $23, $05, $04, $01 db $24, $05, $04, $01, $25, $05, $04, $01 db $26, $05, $04, $0A, $09, $04, $01, $27 db $05, $04, $01, $28, $05, $06, $0A, $01 db $28, $05, $06, $01, $29, $05, $02, $01 db $2A, $05, $02, $09, $02, $01, $2C, $05 db $06, $01, $2D, $05, $04, $0A, $01, $2C db $05, $10, $01, $2B, $05, $1E, $09, $03 db $01, $2C, $05, $08, $01, $2B, $05, $0A db $01, $2D, $05, $08, $01, $2B, $05, $0A db $0A, $01, $2B, $08, $00, $01, $2A, $E0 db $24, $36, $05, $08, $01, $2D, $08, $00 db $00, $2A, $00, $05, $06, $01, $2B, $2A db $D0, $05, $04, $01, $2C, $05, $1A, $16 db $CD, $80, $0C, $CD, $91, $0C, $C3, $A4 db $0D, $44, $FF, $00, $00, $FE, $23, $00 db $88, $00, $01, $02, $F0, $00, $00, $88 db $00, $0B, $02, $FC, $00, $C0, $3C, $00 db $1B, $03, $00, $07, $00, $0F, $00, $1F db $00, $3E, $01, $7D, $02, $1F, $00, $FF db $00, $FA, $05, $F5, $0A, $EA, $15, $54 db $AB, $A0, $5F, $40, $BF, $85, $00, $58 db $42, $00, $FF, $13, $05, $FF, $0A, $FF db $80, $7F, $00, $FF, $01, $FF, $0A, $FF db $55, $FF, $AA, $FF, $57, $FF, $BF, $FF db $2B, $00, $01, $0F, $00, $8C, $00, $7F db $04, $00, $FF, $00, $FF, $00, $B1, $00 db $80, $00, $01, $8C, $00, $43, $07, $FA db $05, $F4, $0B, $E8, $17, $D0, $2F, $83 db $00, $5C, $05, $81, $7F, $02, $FF, $80 db $7F, $85, $00, $6A, $06, $55, $FF, $AB db $FF, $57, $FF, $AF, $86, $00, $D7, $0A db $BF, $FF, $7F, $FF, $FC, $FC, $F0, $F0 db $C0, $C0, $7F, $22, $FF, $05, $FC, $FC db $E0, $E0, $80, $80, $25, $00, $02, $07 db $00, $1F, $42, $00, $3F, $05, $00, $1F db $00, $03, $00, $00, $46, $00, $FF, $01 db $00, $1F, $4E, $00, $FF, $01, $00, $F8 db $B0, $00, $FF, $00, $00, $88, $00, $AF db $05, $07, $00, $0E, $01, $1F, $00, $83 db $00, $6C, $04, $15, $FF, $2F, $FF, $5F db $86, $00, $E5, $83, $00, $E8, $08, $F8 db $F8, $E0, $E0, $C0, $C0, $80, $80, $00 db $C6, $01, $0F, $03, $7F, $00, $FF, $00 db $C9, $01, $86, $04, $03, $00, $0F, $00 db $3F, $42, $00, $7F, $83, $01, $01, $8E db $01, $0F, $AD, $01, $A0, $00, $FC, $A4 db $00, $AF, $00, $F0, $8E, $01, $45, $87 db $01, $4E, $83, $00, $B2, $04, $3E, $01 db $3D, $02, $7A, $84, $00, $C1, $01, $F0 db $0F, $83, $00, $C4, $06, $85, $7F, $0B db $FF, $17, $FF, $2F, $84, $00, $DB, $07 db $5E, $FE, $BC, $FC, $F8, $F8, $F0, $F0 db $89, $01, $76, $02, $00, $00, $FF, $92 db $00, $35, $83, $00, $46, $10, $0E, $01 db $1D, $02, $1A, $05, $3C, $03, $A1, $5F db $C2, $3F, $85, $7F, $43, $BF, $87, $84 db $01, $F1, $02, $0E, $FE, $78, $86, $02 db $01, $89, $02, $06, $02, $07, $00, $3F db $88, $01, $83, $00, $0F, $A3, $02, $4F db $88, $01, $AF, $02, $FE, $00, $E0, $8C db $00, $FB, $02, $0F, $00, $00, $8E, $01 db $0D, $00, $00, $B0, $02, $6F, $18, $3A db $05, $74, $0B, $68, $17, $F0, $0F, $E9 db $17, $D0, $2F, $A1, $5F, $D2, $2F, $1E db $FE, $3C, $FC, $5C, $FC, $B8, $F8, $70 db $22, $F0, $00, $60, $22, $E0, $00, $07 db $8A, $01, $9F, $00, $3E, $A6, $00, $3F db $A3, $00, $48, $00, $F8, $86, $00, $17 db $41, $03, $00, $0D, $06, $01, $07, $00 db $06, $01, $05, $02, $0E, $01, $0D, $02 db $A5, $5F, $83, $02, $36, $09, $4B, $BF db $97, $7F, $2E, $FE, $16, $FE, $2C, $FC db $83, $01, $78, $01, $80, $80, $8D, $00 db $38, $00, $3F, $C3, $01, $9B, $94, $02 db $79, $01, $1F, $00, $8C, $01, $4D, $00 db $0F, $88, $03, $2D, $02, $80, $00, $E0 db $A5, $01, $81, $02, $0F, $00, $7F, $A8 db $00, $07, $22, $00, $01, $81, $F8, $A3 db $03, $17, $25, $00, $04, $18, $00, $7E db $00, $FF, $A4, $02, $CE, $C9, $00, $8D db $00, $80, $AE, $03, $70, $00, $00, $88 db $02, $4C, $83, $03, $53, $AF, $03, $8D db $22, $00, $1F, $0A, $05, $1C, $03, $18 db $07, $14, $0B, $39, $07, $30, $0F, $29 db $17, $32, $0F, $5C, $FC, $38, $F8, $78 db $F8, $B0, $F0, $70, $F0, $E0, $E0, $60 db $E0, $C0, $C0, $87, $02, $53, $06, $C1 db $FF, $E3, $FF, $F7, $FF, $FF, $88, $00 db $00, $02, $86, $FF, $CF, $24, $FF, $01 db $00, $E7, $AE, $03, $E2, $86, $00, $00 db $02, $98, $FF, $FD, $85, $03, $EB, $02 db $E0, $00, $FB, $41, $00, $FF, $00, $00 db $A7, $03, $D9, $02, $C0, $00, $F0, $87 db $01, $AF, $03, $C0, $FF, $FC, $FF, $88 db $00, $3D, $00, $CF, $8C, $02, $87, $A7 db $01, $90, $10, $FF, $20, $0E, $51, $05 db $23, $0B, $45, $15, $22, $0A, $41, $01 db $02, $02, $00, $00, $23, $C0, $87, $03 db $00, $85, $00, $F8, $02, $3C, $00, $FF db $34, $00, $84, $04, $72, $01, $00, $1F db $8B, $03, $51, $AF, $04, $8D, $02, $00 db $00, $00, $29, $FF, $05, $E0, $FF, $00 db $FF, $30, $CF, $27, $FF, $05, $C0, $FF db $00, $FF, $01, $FE, $87, $04, $AF, $02 db $80, $FF, $00, $AA, $04, $C9, $83, $04 db $C8, $05, $60, $9F, $00, $FF, $03, $FC db $83, $04, $AF, $00, $F8, $84, $04, $C9 db $01, $10, $EF, $C7, $03, $E4, $01, $00 db $FF, $83, $04, $F8, $01, $02, $FD, $A3 db $05, $06, $00, $00, $A4, $05, $01, $02 db $80, $7F, $00, $C9, $03, $E7, $8E, $01 db $20, $02, $FF, $FF, $0F, $8C, $01, $10 db $01, $D5, $D5, $8D, $05, $30, $06, $55 db $55, $BA, $BA, $FF, $FF, $0F, $CC, $04 db $07, $00, $FF, $8A, $05, $2F, $23, $FF db $03, $EE, $EE, $BB, $BB, $87, $03, $FC db $00, $80, $C4, $04, $D6, $03, $9B, $9B db $FE, $FE, $86, $03, $FC, $84, $04, $AF db $01, $9F, $9F, $C9, $04, $B7, $00, $E0 db $C6, $04, $BA, $03, $3B, $3B, $EE, $EE db $87, $03, $DE, $04, $18, $E7, $3C, $C3 db $18, $86, $03, $F1, $A3, $04, $EC, $0C db $03, $FC, $30, $CF, $78, $87, $30, $CF db $00, $FF, $0C, $F3, $00, $88, $05, $AF db $48, $00, $FF, $01, $15, $EA, $43, $00 db $FF, $07, $02, $FD, $15, $EA, $AA, $55 db $55, $AA, $87, $05, $E8, $83, $05, $FC db $85, $05, $FC, $01, $01, $FE, $83, $06 db $08, $89, $06, $08, $AB, $06, $14, $09 db $55, $AA, $AA, $55, $55, $AA, $AA, $55 db $55, $AA, $B5, $06, $22, $02, $40, $BF db $AA, $86, $06, $21, $03, $A8, $57, $40 db $BF, $89, $05, $B0, $93, $05, $DA, $83 db $05, $06, $A3, $00, $64, $03, $01, $FE db $0A, $F5, $95, $06, $22, $83, $06, $58 db $01, $AA, $55, $83, $00, $62, $45, $00 db $FF, $00, $2A, $C4, $00, $E1, $A4, $05 db $89, $02, $FF, $FC, $FC, $89, $06, $B4 db $01, $F8, $F8, $83, $00, $F8, $01, $7F db $FF, $C7, $05, $A9, $8B, $04, $AA, $01 db $C0, $C0, $8F, $03, $88, $00, $1F, $86 db $01, $95, $04, $00, $00, $07, $00, $7F db $89, $02, $83, $90, $01, $0D, $00, $00 db $8C, $02, $5F, $00, $FF, $83, $06, $FF db $8C, $02, $55, $02, $00, $00, $00, $AA db $01, $81, $01, $F0, $00, $A5, $04, $D1 db $43, $FF, $C7, $26, $FF, $41, $11, $FF db $00, $01, $CA, $07, $68, $04, $01, $FF db $1F, $FF, $03, $C3, $07, $78, $83, $06 db $D6, $2D, $00, $04, $7F, $00, $3F, $00 db $0F, $8E, $00, $91, $04, $FF, $00, $FF db $00, $07, $D0, $02, $93, $00, $1F, $A3 db $07, $AB, $B3, $03, $23, $00, $00, $C5 db $06, $BF, $03, $BF, $BF, $EC, $EC, $C7 db $04, $B1, $00, $FE, $A6, $06, $D0, $03 db $E7, $E7, $00, $00, $87, $07, $E0, $CE db $04, $B5, $02, $00, $FC, $FC, $28, $FF db $01, $18, $FF, $C3, $05, $12, $00, $10 db $C8, $08, $16, $00, $81, $42, $FF, $88 db $C3, $08, $26, $00, $F8, $90, $07, $11 db $00, $C0, $A8, $06, $F7, $C6, $03, $A8 db $C8, $07, $4F, $83, $02, $9A, $85, $06 db $50, $01, $40, $BF, $A8, $05, $48, $02 db $FF, $54, $AB, $45, $00, $FF, $00, $AA db $90, $05, $21, $2D, $FF, $83, $05, $D0 db $AB, $05, $CE, $02, $00, $FF, $C0, $8C db $01, $A0, $FF, $2F, $00, $2F, $FF, $42 db $00, $03, $09, $00, $07, $00, $0F, $00 db $1F, $00, $3F, $00, $7F, $47, $00, $FF db $23, $FF, $04, $01, $01, $1F, $1F, $03 db $C9, $00, $48, $05, $FF, $11, $11, $83 db $83, $C7, $CA, $00, $58, $01, $81, $81 db $22, $1F, $CA, $00, $68, $27, $1F, $01 db $01, $01, $C4, $00, $11, $02, $E0, $00 db $FC, $8A, $00, $30, $25, $00, $00, $F0 db $8E, $00, $88, $02, $00, $00, $E0, $44 db $00, $FF, $00, $F1, $22, $FF, $09, $0F db $0F, $07, $04, $07, $06, $03, $02, $01 db $FF, $C4, $00, $74, $00, $E0, $42, $FF db $00, $01, $FE, $00, $CB, $00, $43, $0D db $8F, $00, $63, $60, $F0, $F0, $E0, $E0 db $F8, $78, $FE, $0E, $FF, $03, $8D, $00 db $9B, $01, $00, $03, $86, $00, $2E, $06 db $01, $00, $07, $00, $1F, $00, $7F, $8B db $00, $38, $23, $FF, $01, $F1, $F1, $25 db $F0, $29, $FF, $03, $7F, $7F, $3F, $3F db $C5, $00, $75, $0A, $18, $18, $08, $08 db $00, $00, $10, $10, $18, $18, $FF, $A6 db $00, $3F, $27, $E3, $00, $FF, $8E, $00 db $EA, $C8, $00, $92, $00, $3F, $D0, $00 db $A8, $C3, $00, $FB, $02, $01, $00, $00 db $CF, $00, $3E, $01, $03, $03, $23, $01 db $01, $81, $81, $27, $80, $43, $FC, $00 db $00, $FE, $42, $80, $FF, $0B, $80, $D1 db $D0, $F1, $F0, $61, $60, $01, $00, $03 db $00, $8F, $49, $00, $FF, $B0, $01, $7F db $86, $00, $C9, $04, $FC, $00, $F0, $00 db $E0, $A4, $01, $7C, $02, $F8, $00, $80 db $2B, $00, $25, $F8, $23, $FC, $23, $FE db $84, $00, $B6, $04, $07, $03, $03, $01 db $01, $93, $00, $08, $83, $01, $2A, $A5 db $00, $50, $00, $88, $C4, $02, $36, $01 db $88, $88, $CE, $00, $11, $04, $03, $00 db $0F, $00, $3F, $41, $00, $1F, $8A, $00 db $2A, $00, $00, $C5, $01, $95, $07, $03 db $02, $07, $06, $0F, $0C, $1F, $18, $83 db $01, $AA, $49, $FF, $00, $00, $FE, $84 db $01, $E4, $00, $F8, $42, $00, $FF, $02 db $F0, $0F, $0C, $41, $03, $02, $05, $43 db $42, $23, $22, $00, $FC, $41, $00, $F8 db $AA, $02, $52, $A6, $02, $61, $C3, $00 db $E3, $03, $F0, $F0, $F8, $F8, $83, $01 db $2C, $83, $02, $10, $02, $07, $07, $03 db $C4, $02, $68, $01, $00, $C0, $8D, $00 db $30, $01, $00, $03, $4B, $00, $FF, $09 db $03, $FF, $0F, $FF, $3C, $FC, $7F, $60 db $FF, $C0, $CB, $02, $7E, $1D, $F0, $00 db $C1, $01, $80, $00, $88, $88, $84, $84 db $C2, $42, $C1, $41, $E3, $23, $17, $14 db $0F, $0C, $8F, $88, $5F, $50, $3F, $20 db $7F, $40, $FF, $80, $CE, $00, $10, $02 db $01, $00, $7F, $8C, $02, $42, $89, $00 db $8D, $00, $03, $A8, $00, $84, $02, $07 db $00, $0F, $8B, $00, $2E, $0A, $0C, $FC db $04, $FC, $06, $FE, $02, $FE, $03, $FF db $01, $8E, $00, $EA, $83, $02, $B4, $04 db $40, $C0, $80, $FF, $C0, $C4, $03, $2C db $09, $30, $3F, $18, $1F, $08, $0F, $0C db $0F, $00, $FE, $C3, $02, $8B, $90, $00 db $86, $02, $00, $00, $80, $83, $00, $82 db $00, $00, $C6, $00, $10, $93, $00, $A0 db $A3, $03, $5C, $8A, $00, $A8, $04, $FE db $00, $F8, $00, $F0, $8A, $01, $6E, $00 db $07, $D0, $00, $96, $00, $7F, $A3, $01 db $EA, $07, $60, $E0, $30, $F0, $10, $F0 db $18, $F8, $83, $03, $70, $83, $03, $76 db $07, $06, $07, $02, $03, $01, $01, $01 db $01, $8D, $01, $58, $85, $03, $90, $02 db $60, $7F, $31, $AB, $00, $85, $06, $FF db $70, $FF, $F8, $DF, $00, $FC, $D0, $01 db $8E, $00, $00, $A3, $00, $24, $01, $00 db $F8, $C5, $01, $66, $B6, $03, $40, $89 db $01, $5B, $00, $FC, $C3, $04, $6A, $44 db $00, $C0, $02, $01, $7F, $01, $C7, $00 db $2D, $A4, $04, $95, $87, $03, $88, $85 db $04, $10, $19, $08, $F8, $17, $1F, $1F db $1C, $0F, $0C, $0F, $04, $0F, $0C, $0F db $09, $1F, $13, $3F, $27, $F8, $1F, $F8 db $3F, $F0, $3F, $E0, $7F, $41, $E0, $FF db $03, $F8, $FF, $9E, $9F, $AA, $03, $05 db $04, $FF, $0F, $FF, $7F, $FE, $8E, $00 db $36, $8C, $01, $7F, $83, $04, $DA, $C3 db $04, $96, $92, $00, $84, $02, $C0, $00 db $F0, $90, $04, $6A, $00, $C3, $8C, $00 db $9C, $00, $3C, $90, $04, $6A, $87, $02 db $DB, $00, $03, $8B, $01, $02, $05, $08 db $F8, $0F, $FD, $0F, $FF, $84, $04, $D1 db $0C, $E1, $7F, $E3, $7F, $CF, $7E, $4E db $FC, $9C, $F8, $38, $F8, $70, $25, $E0 db $03, $70, $E0, $07, $07, $83, $02, $64 db $03, $06, $06, $04, $04, $86, $01, $FA db $01, $F0, $C0, $A6, $04, $25, $05, $20 db $20, $50, $50, $10, $10, $29, $00, $06 db $40, $40, $A0, $A0, $20, $20, $3C, $A3 db $05, $86, $01, $03, $01, $83, $04, $24 db $8C, $04, $2B, $07, $F8, $FF, $FE, $FF db $07, $07, $01, $01, $CD, $02, $7F, $00 db $C0, $87, $00, $C8, $02, $F0, $00, $80 db $89, $01, $5A, $01, $00, $01, $90, $01 db $56, $02, $7F, $00, $3F, $90, $03, $FA db $A4, $04, $8F, $02, $7C, $FF, $38, $CB db $00, $8B, $08, $00, $38, $E0, $3C, $F0 db $3E, $F0, $1F, $10, $41, $1F, $19, $23 db $0F, $87, $03, $84, $23, $80, $07, $8F db $00, $9F, $00, $30, $20, $E1, $E1, $22 db $E3, $01, $C3, $C3, $C6, $05, $3B, $03 db $60, $60, $C0, $C0, $A7, $02, $14, $03 db $1F, $00, $1F, $00, $AF, $03, $2F, $01 db $60, $7F, $83, $03, $98, $02, $18, $1F db $1C, $41, $0F, $3C, $02, $0F, $7C, $1F db $8E, $06, $81, $00, $F0, $B0, $03, $C0 db $8B, $03, $33, $02, $1F, $00, $FF, $41 db $00, $0F, $01, $00, $0F, $AA, $05, $12 db $02, $FC, $00, $FC, $A7, $02, $54, $90 db $01, $50, $02, $80, $00, $F8, $83, $02 db $C6, $2B, $03, $00, $0E, $8E, $06, $81 db $03, $00, $00, $7F, $3E, $22, $7F, $02 db $71, $7F, $61, $41, $3E, $22, $01, $1C db $1C, $AD, $06, $AF, $00, $07, $CE, $06 db $BF, $01, $C0, $C0, $A8, $03, $B3, $00 db $03, $A3, $02, $BC, $02, $0F, $03, $78 db $85, $04, $D1, $C3, $04, $39, $C4, $01 db $E3, $D8, $05, $30, $00, $F8, $84, $07 db $76, $A5, $05, $DF, $02, $81, $00, $00 db $D2, $03, $B8, $C4, $06, $D7, $00, $01 db $AE, $02, $70, $84, $02, $B2, $83, $02 db $B5, $00, $C0, $83, $05, $8C, $03, $70 db $F0, $1F, $1C, $C4, $03, $99, $00, $60 db $43, $7F, $40, $05, $F0, $70, $F8, $18 db $FC, $0C, $A3, $07, $D6, $A4, $07, $67 db $07, $01, $1F, $03, $3F, $03, $3E, $07 db $7E, $41, $07, $FC, $05, $0F, $F8, $1F db $F8, $9F, $00, $84, $01, $A0, $A3, $00 db $2C, $D2, $01, $66, $A9, $03, $57, $01 db $FF, $7E, $23, $FF, $01, $C7, $FF, $8B db $05, $E1, $D0, $00, $43, $83, $01, $1F db $05, $00, $80, $00, $80, $00, $C0, $92 db $00, $96, $84, $07, $8F, $01, $30, $FF db $AA, $06, $A6, $A4, $07, $71, $05, $00 db $0F, $00, $1F, $00, $3F, $4B, $00, $FF db $01, $00, $F8, $8F, $02, $D2, $08, $38 db $F0, $3C, $F8, $1E, $FC, $0F, $FE, $07 db $8E, $00, $E8, $07, $C0, $80, $F0, $E0 db $FF, $FC, $3F, $FF, $C3, $07, $DA, $41 db $3F, $20, $07, $3F, $30, $3F, $10, $FF db $0C, $FF, $FE, $CE, $07, $BF, $04, $03 db $F0, $BF, $E0, $FF, $83, $06, $72, $C4 db $06, $5B, $A9, $01, $7D, $00, $1F, $86 db $01, $7A, $02, $00, $FF, $F8, $A3, $02 db $F9, $01, $FF, $30, $8C, $00, $31, $07 db $38, $BF, $3C, $3F, $3C, $FF, $FC, $FF db $C3, $04, $4E, $00, $0F, $8D, $01, $D3 db $06, $C0, $FF, $FB, $FF, $FE, $1F, $FF db $83, $08, $B8, $05, $83, $7F, $43, $3C db $3C, $C0, $86, $08, $47, $84, $04, $34 db $03, $FF, $C0, $FF, $00, $8E, $08, $E0 db $88, $04, $8C, $02, $F8, $00, $FC, $83 db $05, $EC, $CB, $06, $B0, $03, $10, $10 db $38, $FF, $8C, $06, $B4, $00, $1F, $83 db $06, $14, $AC, $08, $04, $05, $FF, $0F db $FF, $07, $FE, $03, $87, $03, $77, $06 db $F8, $00, $C0, $FF, $FF, $FF, $01, $87 db $04, $31, $08, $7F, $71, $3F, $3F, $FF db $8F, $FC, $FC, $F8, $AA, $09, $B1, $90 db $03, $CA, $00, $01, $8C, $03, $62, $00 db $F0, $C8, $08, $C0, $00, $FF, $A3, $06 db $90, $01, $0C, $0C, $93, $01, $D1, $87 db $03, $E5, $04, $E0, $00, $00, $00, $FC db $C3, $04, $6A, $01, $00, $C0, $30, $00 db $86, $02, $62, $01, $03, $CE, $41, $FF db $CF, $42, $FC, $87, $41, $FE, $FF, $0A db $FE, $01, $FF, $C1, $FF, $F3, $FF, $FF db $3F, $FF, $0F, $A5, $00, $C6, $03, $F0 db $7F, $F8, $1F, $84, $08, $B5, $A6, $07 db $66, $07, $78, $FF, $78, $EF, $F8, $CF db $F8, $C8, $41, $FC, $8C, $41, $FE, $06 db $CA, $08, $80, $A7, $03, $B9, $06, $F8 db $00, $F0, $00, $F0, $00, $F8, $B5, $05 db $1A, $01, $0E, $0F, $88, $0A, $B6, $00 db $FC, $AA, $01, $04, $84, $05, $F7, $03 db $30, $30, $38, $38, $88, $08, $7A, $00 db $07, $A6, $0A, $A6, $00, $C0, $A5, $0A db $98, $87, $03, $A4, $03, $0E, $0E, $07 db $07, $A6, $08, $F6, $84, $07, $B1, $AF db $06, $7E, $05, $07, $07, $0D, $0F, $0C db $0F, $84, $06, $94, $04, $1F, $0C, $0F db $0E, $0F, $C5, $07, $6B, $02, $7F, $F0 db $7F, $A3, $0A, $75, $00, $E0, $8C, $03 db $02, $04, $0C, $FF, $07, $FF, $07, $8A db $00, $31, $05, $04, $FF, $84, $FF, $E4 db $FE, $42, $07, $FF, $0B, $06, $FF, $00 db $FF, $89, $FF, $99, $FF, $BF, $00, $FF db $E0, $C6, $09, $5F, $00, $80, $A9, $05 db $EB, $C3, $0A, $6A, $CC, $01, $15, $02 db $E0, $FF, $FE, $8A, $0B, $89, $01, $30 db $FF, $A3, $09, $29, $00, $BF, $24, $FF db $04, $3C, $FF, $3E, $FF, $7F, $A4, $09 db $43, $01, $FF, $80, $87, $01, $CC, $02 db $F0, $FF, $FE, $C5, $04, $EC, $02, $02 db $FF, $06, $89, $05, $E4, $05, $E0, $7F db $F0, $1F, $F8, $0F, $83, $0A, $06, $05 db $1E, $FE, $3C, $FC, $30, $F0, $41, $60 db $E0, $01, $60, $E0, $87, $03, $B3, $00 db $C0, $A3, $04, $A8, $8E, $06, $AE, $0B db $08, $08, $06, $06, $10, $10, $08, $08 db $0C, $0C, $06, $06, $25, $02, $01, $04 db $04, $83, $02, $C6, $AB, $08, $F4, $85 db $0B, $75, $01, $FF, $00, $C8, $0B, $7B db $02, $03, $FE, $0E, $84, $07, $E6, $C4 db $09, $B2, $E0, $22, $FC, $00, $3F, $3C db $37, $34, $1B, $18, $03, $00, $0F, $0F db $F8, $F8, $91, $11, $08, $08, $F6, $F7 db $D6, $D7, $67, $67, $07, $05, $CF, $CD db $3F, $3E, $9F, $90, $23, $20, $07, $84 db $0C, $48, $09, $0F, $FF, $9F, $FF, $9E db $FE, $DC, $FC, $FD, $FD, $A3, $02, $C2 db $23, $F2, $03, $F0, $F0, $38, $38, $23 db $1F, $83, $01, $2A, $0F, $3D, $3D, $38 db $38, $78, $78, $F8, $F8, $F1, $F1, $E3 db $E3, $FF, $FE, $FF, $FE, $83, $00, $13 db $CE, $01, $17, $09, $81, $FF, $83, $FF db $DF, $FF, $CE, $FF, $C0, $FF, $A8, $06 db $30, $06, $FF, $0C, $FF, $0E, $FF, $06 db $FC, $83, $09, $B2, $CA, $08, $EF, $04 db $30, $F0, $3F, $FF, $1F, $41, $FE, $07 db $01, $FE, $83, $C4, $0C, $BA, $FF, $0D db $6D, $61, $17, $F6, $0D, $0D, $3D, $61 db $05, $01, $0D, $67, $10, $09, $05, $19 db $00, $10, $19, $FF, $08, $0A, $0D, $C7 db $10, $2C, $19, $03, $40, $0D, $C7, $10 db $29, $19, $04, $20, $0D, $80, $10, $05 db $08, $01, $FF, $0D, $60, $61, $0E, $07 db $68, $60, $75, $60, $82, $60, $CC, $60 db $D9, $60, $E6, $60, $05, $01, $0D, $56 db $61, $11, $68, $60, $05, $F0, $06, $F6 db $60, $09, $1C, $0B, $91, $69, $05, $22 db $0A, $05, $F0, $06, $F6, $60, $03, $AC db $60, $5A, $29, $01, $05, $00, $29, $00 db $05, $01, $0D, $56, $61, $11, $8C, $60 db $29, $F5, $05, $17, $29, $00, $0D, $A5 db $60, $05, $3C, $0F, $05, $06, $06, $F6 db $60, $AF, $21, $77, $A0, $22, $77, $C9 db $1E, $11, $1A, $4F, $17, $9F, $47, $21 db $77, $A0, $7E, $81, $22, $7E, $88, $77 db $FA, $3D, $DB, $3D, $21, $52, $DB, $BE db $20, $05, $3E, $01, $EA, $24, $DF, $C9 db $09, $1C, $0B, $91, $69, $05, $3F, $0A db $05, $F0, $06, $F6, $60, $05, $01, $0D db $56, $61, $11, $D9, $60, $05, $64, $06 db $F6, $60, $09, $1C, $0D, $50, $0F, $C7 db $A8, $B2, $05, $4A, $0A, $05, $F0, $06 db $F6, $60, $0D, $80, $61, $05, $01, $0D db $51, $61, $11, $F9, $60, $0D, $5B, $61 db $14, $0E, $0E, $61, $05, $3C, $0D, $67 db $61, $16, $0D, $C7, $10, $2D, $09, $08 db $19, $01, $08, $19, $FF, $04, $0A, $0D db $28, $61, $19, $02, $3C, $0D, $31, $61 db $0D, $67, $61, $16, $21, $7C, $7C, $3E db $03, $CD, $CF, $05, $C9, $FA, $60, $DB db $CD, $63, $06, $21, $6C, $DB, $B6, $77 db $C9, $21, $19, $A0, $CB, $EE, $2E, $1C db $CB, $EE, $2E, $1F, $CB, $EE, $C9, $3E db $01, $EA, $24, $DF, $C9, $FA, $22, $DF db $18, $0D, $FA, $24, $DF, $18, $08, $FA db $23, $DF, $18, $03, $FA, $60, $DB, $1E db $27, $12, $C9, $3E, $05, $EA, $82, $A0 db $C9, $FA, $60, $DB, $B7, $1E, $0A, $20 db $02, $1E, $10, $AF, $21, $22, $DF, $22 db $1D, $20, $FC, $C9, $C5, $1E, $1A, $01 db $8B, $61, $CD, $3A, $0C, $C1, $C9, $1C db $43, $6D, $08, $0D, $0A, $62, $1C, $F4 db $74, $08, $18, $0D, $5B, $61, $14, $0E db $BE, $61, $10, $71, $0E, $04, $AA, $61 db $AF, $61, $B4, $61, $B9, $61, $01, $00 db $06, $00, $62, $01, $02, $06, $00, $62 db $01, $08, $06, $00, $62, $01, $05, $06 db $00, $62, $10, $71, $12, $CF, $61, $04 db $40, $4F, $0A, $0F, $46, $00, $01, $1E db $06, $00, $62, $03, $FD, $34, $40, $0D db $4B, $62, $05, $01, $10, $64, $12, $D6 db $61, $0F, $1F, $80, $10, $71, $0E, $04 db $EC, $61, $EC, $61, $F3, $61, $FA, $61 db $04, $9D, $7C, $1A, $06, $FE, $61, $04 db $B8, $7C, $1A, $06, $FE, $61, $04, $DB db $7C, $1A, $01, $00, $0D, $04, $62, $00 db $3E, $01, $EA, $22, $DF, $C9, $C5, $FA db $60, $DB, $21, $21, $62, $87, $85, $6F db $30, $01, $24, $2A, $66, $6F, $44, $4D db $CD, $BB, $35, $C1, $C9, $2F, $62, $33 db $62, $37, $62, $3B, $62, $3F, $62, $43 db $62, $47, $62, $50, $00, $69, $00, $50 db $00, $69, $00, $50, $00, $59, $00, $50 db $00, $69, $00, $50, $00, $69, $00, $50 db $00, $69, $00, $50, $00, $69, $00, $FA db $71, $A0, $C6, $2F, $EA, $11, $DF, $21 db $8B, $74, $3E, $07, $CD, $CF, $05, $C9 db $0D, $60, $62, $16, $1E, $46, $1A, $EA db $21, $DF, $C9, $0D, $60, $62, $17, $F6 db $0D, $0F, $3D, $FF, $0F, $3C, $01, $0B db $B1, $62, $0D, $08, $63, $14, $04, $A2 db $62, $01, $00, $1F, $D8, $62, $05, $04 db $19, $03, $18, $0B, $91, $69, $19, $04 db $08, $19, $03, $28, $0D, $F4, $62, $11 db $A8, $62, $0D, $FD, $62, $12, $84, $62 db $19, $03, $08, $06, $76, $62, $0B, $B1 db $62, $06, $76, $62, $19, $03, $08, $0D db $4B, $61, $01, $00, $00, $19, $00, $08 db $10, $3C, $0E, $03, $BE, $62, $C3, $62 db $C8, $62, $09, $01, $06, $CA, $62, $09 db $02, $06, $CA, $62, $09, $03, $19, $00 db $06, $19, $01, $02, $19, $02, $07, $19 db $01, $02, $0A, $0C, $FA, $27, $DF, $26 db $14, $FE, $08, $38, $0E, $26, $10, $FE db $0F, $38, $08, $26, $0C, $FE, $15, $38 db $02, $26, $08, $7C, $1E, $24, $12, $C9 db $FA, $27, $DF, $D6, $1C, $1E, $27, $12 db $C9, $1E, $3C, $1A, $67, $3D, $12, $7C db $1E, $27, $12, $C9, $1E, $3D, $1A, $3C db $FE, $10, $38, $01, $AF, $12, $87, $87 db $67, $CD, $47, $06, $E6, $03, $84, $21 db $31, $63, $85, $6F, $30, $01, $24, $7E db $1E, $27, $12, $FE, $04, $38, $02, $D6 db $04, $1E, $3C, $12, $C9, $00, $00, $01 db $01, $05, $05, $05, $05, $01, $01, $01 db $01, $05, $05, $05, $05, $02, $02, $02 db $02, $06, $06, $06, $06, $02, $02, $03 db $03, $04, $04, $04, $04, $03, $03, $03 db $02, $04, $04, $04, $04, $03, $03, $03 db $03, $04, $04, $04, $04, $03, $03, $03 db $03, $04, $04, $04, $04, $03, $03, $03 db $03, $06, $06, $06, $06, $0D, $7A, $63 db $12, $EB, $6E, $06, $F6, $69, $1E, $03 db $CD, $3B, $06, $B7, $28, $02, $3E, $01 db $EA, $2A, $DF, $FE, $01, $20, $11, $21 db $29, $DF, $7E, $FE, $0E, $30, $03, $34 db $18, $12, $AF, $EA, $2A, $DF, $18, $0C db $21, $28, $DF, $7E, $FE, $07, $38, $EF db $3E, $01, $18, $EF, $1E, $27, $FA, $2A db $DF, $12, $C9, $0D, $60, $62, $17, $F6 db $0D, $0F, $60, $1A, $0F, $61, $00, $0F db $5E, $04, $0F, $5F, $04, $0F, $4A, $00 db $0F, $4B, $00, $0F, $4C, $01, $03, $AE db $68, $5A, $0F, $3A, $00, $0D, $7A, $69 db $90, $00, $0D, $81, $69, $68, $00, $0D db $7A, $69, $90, $00, $0D, $81, $69, $68 db $00, $09, $04, $01, $00, $08, $C0, $FF db $05, $04, $01, $01, $05, $04, $01, $00 db $08, $40, $00, $05, $04, $01, $01, $05 db $04, $0A, $08, $00, $FE, $09, $05, $01 db $02, $05, $04, $01, $03, $05, $04, $0A db $01, $04, $08, $00, $00, $05, $04, $0D db $7A, $69, $90, $00, $0D, $81, $69, $18 db $00, $0F, $3A, $01, $09, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $0A, $22 db $AA, $64, $1A, $0D, $7A, $69, $90, $00 db $0D, $81, $69, $18, $00, $07, $00, $00 db $29, $F8, $09, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $0A, $07, $00, $FF db $29, $00, $09, $0C, $01, $05, $05, $04 db $01, $06, $05, $04, $0A, $29, $08, $09 db $04, $01, $05, $05, $04, $01, $06, $05 db $04, $0A, $07, $00, $00, $29, $00, $0D db $7A, $69, $10, $00, $0D, $81, $69, $18 db $00, $07, $00, $00, $29, $08, $09, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $0A, $07, $00, $01, $29, $00, $09, $0C db $01, $05, $05, $04, $01, $06, $05, $04 db $0A, $29, $F8, $09, $04, $01, $05, $05 db $04, $01, $06, $05, $04, $0A, $07, $00 db $00, $29, $00, $06, $2F, $64, $0F, $39 db $FF, $1F, $BF, $64, $0B, $91, $69, $0D db $F4, $62, $12, $AD, $64, $05, $78, $0D db $4B, $61, $00, $1E, $39, $1A, $3C, $12 db $21, $D1, $64, $85, $6F, $30, $01, $24 db $7E, $1E, $25, $12, $C9, $78, $48, $48 db $78, $48, $48, $78, $48, $48, $48, $48 db $48, $50, $32, $32, $50, $32, $32, $50 db $32, $32, $32, $32, $32, $32, $32, $32 db $17, $F6, $0D, $0F, $60, $1A, $0F, $61 db $00, $0F, $5E, $05, $0F, $5F, $07, $0F db $4A, $00, $0F, $4B, $00, $0F, $4C, $01 db $03, $BE, $68, $5A, $0D, $7A, $69, $10 db $00, $0D, $81, $69, $64, $00, $0D, $7A db $69, $10, $00, $0D, $81, $69, $64, $00 db $01, $07, $07, $00, $00, $08, $00, $00 db $29, $00, $2A, $00, $05, $40, $01, $08 db $08, $00, $FC, $2A, $21, $05, $3D, $0D db $7A, $69, $10, $00, $0D, $81, $69, $64 db $00, $07, $00, $00, $08, $00, $00, $29 db $00, $2A, $00, $09, $02, $01, $09, $07 db $80, $00, $05, $02, $01, $0A, $07, $80 db $FF, $05, $02, $01, $0B, $07, $80, $00 db $05, $02, $01, $0C, $07, $80, $FF, $05 db $02, $01, $0D, $07, $80, $00, $05, $02 db $01, $0E, $07, $80, $FF, $05, $02, $01 db $0F, $07, $80, $00, $05, $02, $01, $10 db $07, $80, $FF, $05, $02, $01, $11, $07 db $80, $00, $05, $02, $01, $12, $07, $80 db $FF, $05, $02, $0A, $24, $36, $09, $06 db $01, $09, $07, $00, $01, $05, $02, $01 db $0A, $05, $02, $01, $0B, $05, $02, $01 db $0C, $05, $02, $01, $0D, $05, $02, $01 db $0E, $05, $02, $01, $0F, $05, $02, $01 db $10, $05, $02, $01, $11, $05, $02, $01 db $12, $05, $02, $0A, $01, $09, $05, $02 db $01, $0A, $05, $02, $01, $0B, $05, $02 db $01, $0C, $05, $02, $0D, $7A, $69, $90 db $00, $0D, $81, $69, $64, $00, $07, $40 db $FF, $08, $7B, $FD, $2A, $0F, $24, $17 db $09, $04, $01, $09, $05, $02, $01, $12 db $05, $02, $01, $11, $05, $02, $01, $10 db $05, $02, $01, $0F, $05, $02, $01, $0E db $05, $02, $01, $0D, $05, $02, $01, $0C db $05, $02, $01, $0B, $05, $02, $01, $0A db $05, $02, $0A, $01, $09, $05, $02, $01 db $12, $05, $02, $01, $11, $05, $01, $24 db $17, $01, $11, $07, $40, $FF, $08, $7B db $FD, $2A, $0F, $05, $01, $09, $04, $01 db $10, $05, $02, $01, $0F, $05, $02, $01 db $0E, $05, $02, $01, $0D, $05, $02, $01 db $0C, $05, $02, $01, $0B, $05, $02, $01 db $0A, $05, $02, $01, $09, $05, $02, $01 db $12, $05, $02, $01, $11, $05, $02, $0A db $01, $10, $05, $02, $01, $0F, $05, $02 db $0D, $7A, $69, $10, $00, $0D, $81, $69 db $64, $00, $24, $17, $07, $C0, $00, $08 db $7B, $FD, $2A, $0F, $09, $04, $01, $10 db $05, $02, $01, $11, $05, $02, $01, $12 db $05, $02, $01, $09, $05, $02, $01, $0A db $05, $02, $01, $0B, $05, $02, $01, $0C db $05, $02, $01, $0D, $05, $02, $01, $0E db $05, $02, $01, $0F, $05, $02, $0A, $01 db $10, $05, $02, $01, $11, $05, $02, $01 db $12, $05, $01, $24, $17, $01, $12, $07 db $C0, $00, $08, $7B, $FD, $2A, $0F, $05 db $01, $09, $04, $01, $09, $05, $02, $01 db $0A, $05, $02, $01, $0B, $05, $02, $01 db $0C, $05, $02, $01, $0D, $05, $02, $01 db $0E, $05, $02, $01, $0F, $05, $02, $01 db $10, $05, $02, $01, $11, $05, $02, $01 db $12, $05, $02, $0A, $01, $09, $05, $02 db $01, $0A, $05, $02, $0D, $7A, $69, $90 db $00, $0D, $81, $69, $64, $00, $07, $00 db $00, $08, $00, $00, $29, $00, $2A, $00 db $24, $17, $09, $02, $01, $09, $07, $80 db $00, $05, $02, $01, $12, $07, $80, $FF db $05, $02, $01, $11, $07, $80, $00, $05 db $02, $01, $10, $07, $80, $FF, $05, $02 db $01, $0F, $07, $80, $00, $05, $02, $01 db $0E, $07, $80, $FF, $05, $02, $01, $0D db $07, $80, $00, $05, $02, $01, $0C, $07 db $80, $FF, $05, $02, $01, $0B, $07, $80 db $00, $05, $02, $01, $0A, $07, $80, $FF db $05, $02, $0A, $07, $00, $FF, $24, $36 db $09, $06, $01, $09, $05, $02, $01, $12 db $05, $02, $01, $11, $05, $02, $01, $10 db $05, $02, $01, $0F, $05, $02, $01, $0E db $05, $02, $01, $0D, $05, $02, $01, $0C db $05, $02, $01, $0B, $05, $02, $01, $0A db $05, $02, $0A, $01, $09, $05, $02, $01 db $12, $05, $02, $01, $11, $05, $02, $01 db $10, $05, $02, $0D, $7A, $69, $10, $00 db $0D, $81, $69, $64, $00, $07, $C0, $00 db $08, $7B, $FD, $2A, $0F, $24, $17, $09 db $04, $01, $09, $05, $02, $01, $0A, $05 db $02, $01, $0B, $05, $02, $01, $0C, $05 db $02, $01, $0D, $05, $02, $01, $0E, $05 db $02, $01, $0F, $05, $02, $01, $10, $05 db $02, $01, $11, $05, $02, $01, $12, $05 db $02, $0A, $01, $09, $05, $02, $01, $0A db $05, $02, $01, $0B, $05, $01, $24, $17 db $01, $0B, $07, $C0, $00, $08, $7B, $FD db $2A, $0F, $05, $01, $09, $04, $01, $0C db $05, $02, $01, $0D, $05, $02, $01, $0E db $05, $02, $01, $0F, $05, $02, $01, $10 db $05, $02, $01, $11, $05, $02, $01, $12 db $05, $02, $01, $09, $05, $02, $01, $0A db $05, $02, $01, $0B, $05, $02, $0A, $01 db $0C, $05, $02, $01, $0D, $05, $02, $0D db $7A, $69, $90, $00, $0D, $81, $69, $64 db $00, $07, $40, $FF, $08, $7B, $FD, $2A db $0F, $24, $17, $09, $04, $01, $0C, $05 db $02, $01, $0B, $05, $02, $01, $0A, $05 db $02, $01, $09, $05, $02, $01, $12, $05 db $02, $01, $11, $05, $02, $01, $10, $05 db $02, $01, $0F, $05, $02, $01, $0E, $05 db $02, $01, $0D, $05, $02, $0A, $01, $0C db $05, $02, $01, $0B, $05, $02, $01, $0A db $05, $01, $24, $17, $01, $0A, $07, $40 db $FF, $08, $7B, $FD, $2A, $0F, $05, $01 db $09, $04, $01, $09, $05, $02, $01, $12 db $05, $02, $01, $11, $05, $02, $01, $10 db $05, $02, $01, $0F, $05, $02, $01, $0E db $05, $02, $01, $0D, $05, $02, $01, $0C db $05, $02, $01, $0B, $05, $02, $01, $0A db $05, $02, $0A, $01, $09, $05, $02, $01 db $12, $05, $02, $0D, $7A, $69, $10, $00 db $0D, $81, $69, $64, $00, $24, $17, $06 db $33, $65, $1E, $3A, $1A, $B7, $28, $0A db $AF, $12, $3E, $E9, $EA, $78, $DB, $EA db $00, $CD, $CD, $80, $0C, $CD, $91, $0C db $CD, $A4, $0D, $01, $DA, $68, $CD, $5B db $25, $FA, $24, $DF, $B7, $C8, $1E, $03 db $01, $33, $4E, $C3, $46, $08, $FF, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $24, $38, $17, $F6 db $0D, $04, $33, $79, $1A, $0D, $AB, $6E db $0D, $21, $69, $09, $02, $01, $04, $05 db $06, $01, $05, $05, $06, $0A, $01, $06 db $05, $06, $01, $07, $05, $06, $01, $08 db $05, $06, $01, $0D, $05, $06, $0D, $50 db $0F, $C8, $A8, $B2, $01, $06, $05, $06 db $01, $05, $05, $06, $16, $1E, $03, $CD db $FB, $6C, $21, $2C, $69, $C3, $77, $6D db $10, $00, $70, $00, $30, $00, $70, $00 db $50, $00, $70, $00, $70, $00, $70, $00 db $90, $00, $70, $00, $0D, $81, $69, $56 db $00, $0D, $A5, $69, $12, $EB, $6E, $06 db $F6, $69, $0D, $81, $69, $70, $00, $17 db $F6, $0D, $04, $33, $79, $1A, $0D, $AB db $6E, $01, $04, $05, $06, $01, $06, $05 db $06, $01, $09, $05, $06, $01, $0A, $05 db $06, $01, $0B, $05, $06, $01, $0C, $05 db $06, $01, $05, $05, $06, $16, $1E, $04 db $21, $51, $DB, $18, $05, $1E, $07, $21 db $53, $DB, $0A, $03, $86, $23, $12, $1C db $0A, $03, $8E, $12, $C9, $0D, $A5, $69 db $12, $9E, $69, $0D, $50, $0F, $C1, $A8 db $B2, $0C, $0D, $50, $0F, $C2, $A8, $B2 db $0C, $21, $27, $DF, $34, $21, $2B, $DF db $7E, $B7, $28, $0B, $36, $00, $21, $2A db $DF, $7E, $EE, $01, $77, $18, $13, $CD db $47, $06, $E6, $01, $21, $2A, $DF, $5E db $77, $BB, $20, $06, $3E, $01, $EA, $2B db $DF, $7B, $FE, $01, $20, $11, $21, $29 db $DF, $7E, $FE, $0E, $30, $03, $34, $18 db $12, $AF, $EA, $2A, $DF, $18, $0C, $21 db $28, $DF, $7E, $FE, $0E, $38, $EF, $3E db $01, $18, $EF, $1E, $27, $FA, $2A, $DF db $12, $C9, $17, $FF, $0D, $0F, $60, $00 db $0F, $61, $00, $0F, $5E, $08, $0F, $5F db $08, $0F, $4A, $00, $0F, $4B, $00, $0F db $4C, $01, $03, $B2, $6E, $5A, $0D, $60 db $61, $0E, $07, $23, $6A, $2A, $6D, $9C db $6D, $AB, $6D, $57, $6E, $7A, $6E, $24 db $1A, $0D, $AB, $6E, $04, $6D, $76, $1A db $0F, $39, $0E, $0D, $E0, $35, $64, $00 db $58, $00, $0D, $E3, $6C, $0E, $04, $43 db $6A, $DC, $6A, $7D, $6B, $31, $6C, $01 db $05, $07, $40, $FF, $08, $70, $FE, $2A db $06, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $01 db $05, $05, $04, $01, $06, $05, $04, $01 db $07, $05, $04, $01, $08, $05, $04, $16 db $01, $05, $07, $40, $FF, $08, $00, $FE db $2A, $12, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $0D, $20, $6D, $01, $05, $08, $00, $FE db $2A, $0D, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $01, $05, $05, $04, $01, $06, $05, $04 db $01, $07, $05, $04, $01, $08, $05, $04 db $16, $01, $05, $07, $00, $FD, $08, $00 db $04, $2A, $08, $05, $04, $0D, $20, $6D db $01, $06, $07, $40, $FF, $08, $F8, $FC db $2A, $18, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $0D, $20, $6D, $01, $06, $08, $F8, $FC db $2A, $18, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $01, $06, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $01, $05, $05, $04 db $0D, $20, $6D, $01, $06, $08, $00, $FD db $2A, $18, $05, $04, $01, $07, $05, $04 db $01, $08, $05, $04, $16, $01, $05, $07 db $40, $FF, $08, $00, $01, $2A, $10, $05 db $04, $01, $06, $05, $04, $01, $07, $05 db $04, $0D, $20, $6D, $01, $08, $08, $F8 db $FE, $2A, $20, $05, $04, $01, $05, $05 db $04, $01, $06, $05, $04, $01, $07, $05 db $04, $0D, $20, $6D, $01, $08, $08, $80 db $FF, $2A, $00, $05, $04, $01, $05, $08 db $80, $00, $05, $04, $0D, $20, $6D, $01 db $06, $08, $00, $00, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $01, $05 db $05, $04, $01, $06, $05, $04, $01, $07 db $05, $04, $01, $08, $05, $04, $16, $1E db $03, $CD, $EC, $6C, $1E, $27, $12, $C9 db $21, $26, $DF, $CD, $3B, $06, $3C, $86 db $1C, $BB, $38, $01, $93, $77, $C9, $21 db $26, $DF, $CD, $3B, $06, $3C, $86, $1C db $1C, $BB, $38, $01, $93, $21, $25, $DF db $BE, $20, $07, $FA, $26, $DF, $83, $3D db $18, $EF, $F5, $FA, $26, $DF, $77, $F1 db $EA, $26, $DF, $C9, $1E, $39, $1A, $5F db $C5, $CD, $AA, $10, $C1, $C9, $0D, $AB db $6E, $0D, $44, $6D, $04, $EC, $76, $1A db $26, $C0, $00, $09, $0D, $19, $00, $06 db $19, $01, $06, $19, $02, $06, $0A, $16 db $1E, $05, $CD, $EC, $6C, $E0, $84, $21 db $5F, $6D, $CD, $77, $6D, $F0, $84, $FE db $03, $3E, $40, $38, $02, $3E, $C0, $1E db $45, $12, $C9, $F8, $FF, $28, $00, $F8 db $FF, $48, $00, $F8, $FF, $68, $00, $A8 db $00, $28, $00, $A8, $00, $48, $00, $A8 db $00, $68, $00, $C5, $87, $87, $85, $6F db $30, $01, $24, $1E, $04, $01, $51, $DB db $0A, $03, $86, $23, $12, $1C, $0A, $03 db $8E, $23, $12, $1C, $1C, $0A, $03, $86 db $23, $12, $1C, $0A, $8E, $12, $C1, $C9 db $0F, $60, $1A, $0F, $61, $00, $19, $00 db $08, $19, $01, $08, $06, $A2, $6D, $0D db $AB, $6E, $04, $0D, $77, $1A, $0D, $2F db $6E, $0D, $CA, $6F, $0D, $4E, $6E, $0E db $03, $C3, $6D, $D9, $6D, $12, $6E, $01 db $00, $08, $00, $01, $05, $71, $24, $41 db $26, $40, $00, $08, $88, $FE, $2A, $1E db $05, $18, $06, $25, $6E, $01, $00, $08 db $00, $02, $05, $05, $01, $00, $08, $00 db $00, $05, $08, $09, $04, $01, $00, $26 db $00, $01, $08, $00, $00, $05, $02, $26 db $00, $FF, $05, $02, $0A, $26, $00, $00 db $01, $00, $08, $80, $01, $05, $44, $24 db $41, $26, $40, $00, $08, $F0, $FD, $2A db $11, $05, $3C, $06, $25, $6E, $01, $00 db $08, $00, $02, $05, $38, $24, $41, $26 db $40, $00, $08, $00, $FE, $2A, $2A, $05 db $18, $18, $0F, $1F, $80, $2A, $00, $1B db $33, $4E, $03, $1E, $03, $CD, $FB, $6C db $21, $3A, $6E, $C3, $77, $6D, $10, $00 db $F8, $FF, $30, $00, $F8, $FF, $50, $00 db $F8, $FF, $70, $00, $F8, $FF, $90, $00 db $F8, $FF, $1E, $03, $CD, $3B, $06, $1E db $27, $12, $C9, $24, $35, $0F, $60, $1A db $0F, $61, $00, $0D, $AB, $6E, $04, $18 db $77, $1A, $0D, $81, $69, $18, $00, $01 db $13, $08, $00, $02, $05, $2A, $01, $14 db $08, $00, $00, $05, $04, $16, $0D, $AB db $6E, $04, $33, $79, $1A, $08, $00, $FE db $2A, $08, $09, $02, $01, $03, $05, $10 db $01, $02, $05, $10, $0A, $09, $02, $01 db $01, $05, $10, $01, $00, $05, $10, $0A db $01, $01, $05, $08, $0D, $50, $0F, $C9 db $A8, $B2, $01, $01, $05, $02, $16, $FA db $21, $DF, $1E, $46, $12, $C9, $CD, $80 db $0C, $CD, $91, $0C, $CD, $A4, $0D, $FA db $60, $DB, $FE, $02, $01, $DD, $6E, $28 db $07, $FE, $04, $28, $03, $01, $CF, $6E db $C3, $5B, $25, $FF, $00, $9B, $4D, $03 db $33, $4E, $03, $00, $00, $00, $2A, $4F db $03, $FF, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $17 db $FF, $0D, $04, $78, $75, $0C, $0F, $60 db $08, $0F, $61, $C0, $0F, $5E, $08, $0F db $5F, $08, $03, $E1, $6F, $5A, $0D, $60 db $61, $0E, $07, $13, $6F, $1B, $6F, $25 db $6F, $2B, $6F, $9C, $6F, $DE, $6F, $24 db $1A, $0F, $39, $41, $06, $2F, $6A, $0D db $44, $6D, $26, $C0, $00, $19, $00, $FF db $16, $0F, $46, $00, $01, $00, $00, $0D db $2F, $6E, $0D, $CA, $6F, $0D, $4E, $6E db $0E, $03, $3C, $6F, $5C, $6F, $7C, $6F db $01, $00, $08, $00, $01, $05, $71, $24 db $41, $26, $10, $00, $08, $80, $FE, $2A db $0C, $05, $3C, $24, $41, $26, $10, $00 db $08, $80, $FE, $2A, $13, $05, $3C, $16 db $01, $00, $08, $80, $01, $05, $4B, $24 db $41, $26, $60, $00, $08, $00, $FE, $2A db $19, $05, $28, $24, $41, $26, $40, $00 db $08, $80, $FE, $2A, $13, $05, $3C, $16 db $01, $00, $08, $00, $02, $05, $38, $24 db $41, $26, $60, $00, $08, $00, $FE, $2A db $19, $05, $28, $24, $41, $26, $40, $00 db $08, $80, $FE, $2A, $13, $05, $3C, $16 db $24, $1A, $0D, $81, $69, $18, $00, $0D db $CA, $6F, $01, $15, $08, $00, $02, $05 db $2B, $24, $41, $01, $15, $26, $60, $00 db $08, $80, $FE, $2A, $13, $05, $28, $24 db $41, $01, $15, $26, $40, $00, $08, $00 db $FF, $2A, $0C, $05, $50, $16, $FA, $51 db $DB, $C6, $50, $67, $1E, $04, $1A, $94 db $3E, $40, $38, $02, $3E, $C0, $1E, $45 db $12, $C9, $06, $81, $6E, $AF, $1E, $15 db $12, $CD, $80, $0C, $CD, $91, $0C, $CD db $A4, $0D, $01, $1A, $70, $CD, $5B, $25 db $FA, $2C, $DD, $CB, $5F, $C8, $1E, $10 db $CD, $AA, $10, $21, $D8, $7C, $3E, $03 db $CD, $CF, $05, $21, $23, $DF, $34, $FA db $60, $DB, $4F, $06, $00, $21, $2C, $DF db $09, $34, $62, $C3, $BA, $0B, $FF, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $23, $00, $01, $0F db $00, $44, $0F, $07, $03, $7F, $00, $FF db $3F, $42, $FF, $70, $02, $FF, $3F, $7F db $26, $00, $07, $F3, $00, $FF, $E3, $FF db $77, $FF, $E7, $C5, $00, $2A, $41, $FF db $77, $01, $FF, $7F, $C4, $00, $36, $26 db $00, $03, $FF, $00, $FF, $E7, $41, $FF db $77, $C6, $00, $4A, $00, $3E, $85, $00 db $32, $8C, $00, $3A, $0E, $3B, $FF, $BB db $FF, $FB, $FF, $7B, $FF, $39, $FF, $00 db $FF, $73, $FF, $7B, $84, $00, $36, $00 db $73, $8A, $00, $3C, $0C, $B9, $FF, $BB db $FF, $B9, $FF, $B8, $FF, $F3, $FF, $00 db $FF, $9F, $42, $FF, $B8, $01, $FF, $9F db $87, $00, $3C, $13, $FC, $00, $FC, $F8 db $FC, $C0, $FC, $F0, $FC, $78, $FC, $F0 db $FF, $00, $FF, $BF, $FF, $38, $FF, $3F db $C3, $00, $B6, $00, $FF, $32, $00, $06 db $C0, $00, $C0, $80, $C0, $00, $80, $86 db $00, $CF, $00, $00, $46, $00, $01, $D3 db $00, $CF, $02, $00, $FF, $FC, $A4, $00 db $32, $03, $FC, $FF, $E0, $E1, $95, $00 db $ED, $04, $FE, $FF, $E0, $FF, $FC, $C3 db $01, $26, $00, $FF, $9D, $00, $ED, $01 db $EE, $FF, $9C, $01, $0D, $02, $F1, $E0 db $F1, $95, $00, $ED, $00, $7E, $42, $FF db $E0, $01, $FF, $7E, $98, $01, $4C, $43 db $38, $7C, $32, $00, $04, $3F, $00, $3F db $1E, $3F, $43, $0E, $1F, $95, $00, $ED db $43, $EE, $FF, $00, $7C, $93, $00, $BC db $00, $FE, $88, $01, $01, $02, $FE, $E0 db $F0, $95, $00, $ED, $A6, $00, $53, $01 db $FF, $EE, $9C, $01, $2C, $03, $EE, $FF db $FC, $FE, $99, $01, $CD, $01, $7C, $FE db $83, $01, $A9, $B7, $01, $ED, $00, $70 db $BC, $02, $46, $00, $3E, $BB, $01, $E4 db $01, $F8, $00, $A7, $01, $C6, $B5, $01 db $CA, $FF, $23, $00, $00, $10, $23, $38 db $2C, $7C, $07, $38, $7C, $38, $38, $10 db $38, $00, $00, $A6, $00, $00, $A6, $00 db $11, $01, $08, $1C, $39, $00, $01, $7E db $FF, $39, $00, $09, $03, $00, $0B, $0C db $37, $38, $2F, $30, $17, $18, $41, $0B db $0C, $08, $17, $18, $2F, $30, $1B, $1C db $05, $06, $01, $28, $00, $03, $F8, $10 db $F8, $20, $41, $F8, $40, $41, $F8, $80 db $00, $F8, $C8, $00, $8F, $01, $F0, $18 db $84, $00, $60, $14, $03, $4C, $4F, $32 db $3F, $34, $3F, $4C, $7F, $59, $7E, $A3 db $FC, $87, $F8, $DC, $A3, $90, $EF, $80 db $FF, $41, $40, $7F, $0F, $20, $3F, $18 db $1F, $07, $07, $E0, $E0, $98, $78, $04 db $FC, $C2, $3E, $82, $7E, $41, $81, $7F db $42, $01, $FF, $AB, $00, $B4, $FF, $E0 db $2C, $00, $00, $05, $07, $18, $1F, $03 db $1C, $6C, $73, $10, $6F, $E3, $DC, $24 db $DB, $C0, $FF, $00, $FF, $80, $FF, $40 db $7F, $43, $7F, $64, $7C, $78, $78, $30 db $30, $00, $00, $C0, $C0, $30, $F0, $88 db $78, $74, $9C, $0B, $FF, $0B, $41, $FD db $03, $03, $FD, $0E, $FE, $0C, $22, $FC db $2B, $00, $06, $05, $07, $10, $1F, $03 db $3C, $2C, $83, $00, $09, $0C, $FC, $00 db $FF, $E0, $FF, $C0, $FF, $E0, $FF, $1C db $1F, $03, $03, $27, $00, $0F, $80, $80 db $60, $E0, $90, $70, $68, $98, $14, $EC db $04, $FC, $92, $7E, $0A, $FE, $85, $00 db $2C, $07, $16, $FE, $F8, $F8, $30, $30 db $00, $00, $86, $00, $00, $00, $3C, $83 db $00, $08, $03, $C3, $FC, $04, $FB, $83 db $00, $10, $09, $42, $7F, $01, $3F, $33 db $3F, $0F, $0F, $01, $01, $89, $00, $60 db $15, $48, $B8, $08, $F8, $04, $FC, $24 db $FC, $14, $FC, $16, $FA, $06, $FA, $0C db $F4, $18, $F8, $E0, $E0, $80, $80, $FF db $1B, $7F, $7F, $66, $59, $63, $5C, $33 db $2C, $31, $2E, $11, $1E, $1B, $14, $1F db $10, $0E, $09, $0C, $0B, $04, $07, $06 db $05, $02, $03, $03, $02, $23, $01, $00 db $FE, $41, $FE, $1A, $06, $F6, $34, $EC db $B4, $6C, $E8, $78, $41, $E8, $F8, $41 db $70, $F0, $41, $60, $E0, $23, $C0, $23 db $80, $FF, $2A, $00, $41, $02, $00, $00 db $08, $41, $00, $4C, $0D, $08, $42, $48 db $06, $48, $36, $7C, $83, $FF, $3C, $C3 db $FF, $00, $FF, $41, $06, $F9, $41, $00 db $FF, $E0, $25, $C3, $BD, $66, $DB, $24 db $FF, $A5, $7E, $81, $7E, $3C, $E7, $18 db $FF, $C3, $FF, $FF, $3C, $3C, $C3, $00 db $7E, $38, $3F, $7D, $46, $FF, $8A, $FE db $87, $FF, $85, $F5, $CE, $78, $7B, $00 db $01, $E4, $20, $00, $0E, $80, $1E, $DE db $AF, $73, $EF, $91, $7F, $C1, $3F, $E1 db $3A, $E6, $1C, $F4, $CD, $00, $5B, $41 db $01, $1E, $08, $02, $1D, $05, $1B, $FA db $07, $7C, $07, $74, $41, $0F, $38, $00 db $0F, $41, $18, $2F, $09, $14, $6F, $1C db $67, $1A, $E7, $1D, $03, $1E, $01, $41 db $1F, $00, $99, $00, $4E, $09, $7E, $81 db $7E, $FF, $83, $FF, $07, $FC, $0C, $FA db $41, $0C, $F8, $04, $0C, $FA, $07, $FC db $03, $46, $FF, $00, $01, $FF, $81, $41 db $FF, $7E, $00, $81, $30, $00, $41, $A0 db $00, $04, $80, $80, $00, $80, $28, $41 db $80, $78, $07, $C8, $B2, $68, $D2, $38 db $E0, $38, $E2, $42, $18, $F6, $85, $00 db $89, $15, $00, $04, $00, $06, $00, $17 db $04, $13, $04, $03, $05, $02, $07, $19 db $06, $5B, $0C, $77, $4C, $37, $38, $4F db $41, $18, $2F, $8B, $00, $E4, $41, $00 db $FF, $00, $24, $84, $00, $DF, $00, $08 db $88, $00, $37, $0D, $08, $0F, $1D, $06 db $37, $0A, $38, $07, $1B, $05, $01, $02 db $00, $03, $95, $00, $4E, $07, $80, $01 db $C0, $03, $E0, $07, $F0, $0F, $83, $00 db $DD, $02, $BD, $7E, $C3, $46, $FF, $00 db $2A, $00, $03, $66, $81, $66, $C3, $42 db $C3, $81, $04, $C3, $A5, $7E, $C3, $3C db $90, $01, $9B, $A3, $00, $8A, $0E, $C0 db $80, $80, $00, $10, $00, $38, $10, $30 db $1C, $3C, $58, $EC, $38, $CC, $42, $F8 db $0C, $0C, $F8, $10, $FC, $18, $F0, $20 db $F8, $50, $E0, $A0, $C0, $80, $40, $3D db $00, $03, $1E, $1E, $3D, $23, $41, $7F db $41, $07, $47, $7F, $7F, $79, $0E, $1F db $0C, $17, $42, $18, $0F, $03, $1B, $0F db $16, $0D, $C4, $02, $23, $00, $18, $42 db $1F, $10, $05, $1E, $11, $15, $1B, $0E db $0E, $B9, $00, $58, $62, $01, $06, $05 db $06, $0B, $0C, $07, $04, $1F, $41, $18 db $0F, $03, $19, $0F, $1B, $0E, $41, $1F db $0D, $13, $07, $1E, $0F, $06, $07, $0A db $03, $05, $07, $04, $0E, $0B, $1F, $11 db $3F, $20, $5E, $61, $7F, $7F, $93, $00 db $5E, $E0, $2B, $40, $A0, $E0, $D0, $30 db $E0, $78, $F0, $FC, $80, $80, $40, $84 db $00, $84, $0A, $8E, $54, $FE, $8C, $76 db $FC, $E6, $1C, $08, $FE, $0C, $F8, $18 db $F4, $30, $E8, $E0, $D0, $52, $B2, $7F db $ED, $BF, $C1, $FE, $02, $FC, $FC, $30 db $00, $0F, $89, $00, $00, $04, $21, $01 db $00, $0D, $84, $2F, $0A, $07, $04, $1F db $A0, $18, $41, $00, $7E, $49, $00, $FF db $C5, $02, $E5, $00, $00, $95, $02, $A0 db $01, $40, $A0, $A7, $00, $4E, $07, $09 db $FF, $69, $9F, $01, $FF, $1E, $F3, $41 db $9F, $FE, $03, $AE, $DD, $9C, $E3, $41 db $80, $FF, $0B, $E0, $FF, $DF, $BF, $1F db $20, $3E, $22, $3C, $24, $38, $38, $31 db $00, $0D, $3F, $40, $BF, $7F, $CE, $F1 db $00, $FF, $08, $F7, $1C, $FB, $0D, $FF db $83, $03, $20, $09, $81, $FF, $82, $FF db $EF, $F4, $F4, $3B, $F8, $4F, $41, $F8 db $0F, $0D, $F0, $1F, $E0, $FF, $BF, $7F db $3F, $40, $87, $87, $85, $86, $03, $03 db $FF, $0D, $07, $07, $79, $7E, $77, $58 db $77, $78, $4F, $70, $BE, $C1, $BD, $C3 db $41, $FB, $87, $1B, $BB, $C7, $BD, $C3 db $4E, $71, $77, $78, $77, $58, $79, $7E db $07, $07, $00, $00, $63, $63, $7D, $5E db $37, $38, $2F, $30, $3F, $20, $5F, $61 db $41, $7F, $43, $0B, $5F, $63, $3F, $21 db $2F, $30, $37, $38, $7D, $5E, $63, $63 db $31, $00, $07, $F8, $F8, $06, $FE, $F9 db $07, $FE, $01, $43, $FF, $00, $25, $00 db $0B, $07, $07, $18, $1F, $27, $38, $5F db $60, $BF, $C0, $7F, $80, $46, $FF, $00 db $25, $00, $09, $03, $03, $0C, $0F, $33 db $3C, $4F, $70, $5F, $60, $45, $BF, $C0 db $41, $5F, $60, $01, $3F, $20, $42, $2F db $30, $83, $00, $8C, $99, $00, $6C, $07 db $00, $00, $1C, $1C, $22, $3E, $5D, $63 db $41, $BD, $C3, $05, $BA, $C6, $44, $7C db $38, $38, $2B, $00, $83, $00, $86, $03 db $13, $1C, $17, $18, $43, $2F, $30, $05 db $17, $18, $13, $1C, $0C, $0F, $C5, $00 db $87, $A9, $00, $00, $0D, $3D, $C3, $DD db $E3, $EF, $F1, $EF, $31, $ED, $33, $DD db $E3, $32, $CE, $B4, $00, $18, $08, $C6 db $FE, $E2, $FE, $22, $FA, $26, $FC, $C4 db $B5, $00, $36, $07, $0F, $0F, $70, $7F db $8F, $F0, $7F, $80, $93, $00, $B4, $87 db $00, $E2, $01, $27, $38, $87, $00, $A6 db $85, $00, $8E, $A9, $00, $C2, $03, $9A db $E6, $BD, $C3, $90, $00, $AE, $E4, $20 db $00, $FF, $F8, $75, $15, $76, $3A, $76 db $47, $76, $60, $76, $07, $F8, $17, $0C db $00, $F8, $0F, $0A, $00, $F8, $07, $08 db $00, $F8, $FF, $06, $00, $F8, $F7, $04 db $00, $F8, $EF, $02, $00, $F8, $E7, $00 db $01, $09, $FD, $1A, $2C, $00, $FD, $12 db $1A, $00, $FD, $0A, $18, $00, $FD, $02 db $12, $00, $FD, $FA, $16, $00, $FD, $F2 db $14, $00, $FD, $EA, $12, $00, $FD, $E2 db $10, $00, $FD, $DA, $0E, $01, $03, $FD db $03, $20, $00, $FD, $FB, $1E, $00, $FD db $F3, $1C, $01, $06, $FD, $0D, $26, $00 db $FD, $05, $24, $00, $FD, $FD, $22, $00 db $FD, $F5, $12, $00, $FD, $E5, $0E, $00 db $FD, $ED, $14, $01, $03, $FD, $06, $2C db $00, $FD, $FE, $2A, $00, $FD, $F6, $28 db $01, $7F, $76, $8C, $76, $99, $76, $A6 db $76, $B7, $76, $C8, $76, $D1, $76, $DA db $76, $E3, $76, $03, $0B, $FE, $00, $00 db $ED, $05, $00, $00, $ED, $FA, $00, $01 db $03, $0B, $FE, $00, $00, $F1, $04, $02 db $00, $F1, $F9, $02, $01, $03, $0A, $FD db $02, $00, $F1, $04, $04, $00, $F1, $F9 db $04, $01, $04, $09, $FD, $08, $00, $09 db $F5, $06, $00, $ED, $05, $00, $00, $ED db $FA, $00, $01, $04, $09, $FB, $08, $00 db $09, $F3, $06, $00, $ED, $05, $00, $00 db $ED, $FA, $00, $01, $02, $F8, $00, $0C db $00, $F8, $F8, $0A, $01, $02, $F8, $00 db $0C, $40, $F8, $F8, $0A, $41, $02, $F8 db $F8, $0C, $60, $F8, $00, $0A, $61, $02 db $F8, $F8, $0C, $20, $F8, $00, $0A, $21 db $F2, $76, $FB, $76, $04, $77, $02, $F8 db $00, $02, $00, $F8, $F8, $00, $01, $02 db $F8, $00, $06, $00, $F8, $F8, $04, $01 db $02, $F8, $00, $0A, $00, $F8, $F8, $08 db $01, $0F, $77, $02, $F8, $00, $02, $00 db $F8, $F8, $00, $01, $42, $77, $5B, $77 db $74, $77, $8D, $77, $A6, $77, $BF, $77 db $D8, $77, $F1, $77, $0A, $78, $23, $78 db $3C, $78, $55, $78, $6E, $78, $87, $78 db $A0, $78, $B9, $78, $D2, $78, $EB, $78 db $04, $79, $1D, $79, $2A, $79, $06, $F1 db $F4, $12, $00, $F1, $04, $10, $00, $01 db $04, $04, $20, $01, $F4, $04, $00, $FA db $FC, $02, $00, $EA, $FC, $00, $01, $06 db $F1, $04, $12, $20, $F1, $F4, $10, $20 db $01, $04, $04, $20, $01, $F4, $04, $00 db $FA, $FC, $02, $00, $EA, $FC, $00, $21 db $06, $FF, $F4, $12, $40, $FF, $04, $10 db $40, $06, $FC, $00, $40, $EF, $F4, $06 db $20, $EF, $04, $06, $00, $F6, $FC, $14 db $41, $06, $FF, $04, $12, $60, $FF, $F4 db $10, $60, $06, $FC, $00, $60, $EF, $F4 db $06, $20, $EF, $04, $06, $00, $F6, $FC db $14, $41, $06, $EF, $04, $16, $60, $EF db $F4, $16, $40, $FF, $F4, $12, $40, $FF db $04, $10, $40, $06, $FC, $00, $40, $F6 db $FC, $14, $41, $06, $00, $F4, $0A, $00 db $00, $FC, $18, $60, $00, $04, $08, $60 db $F0, $04, $0A, $60, $F0, $FC, $18, $00 db $F0, $F4, $08, $01, $06, $00, $04, $0A db $20, $00, $FC, $18, $40, $00, $F4, $08 db $40, $F0, $F4, $0A, $40, $F0, $FC, $18 db $20, $F0, $04, $08, $21, $06, $FD, $03 db $2A, $00, $ED, $03, $28, $00, $FD, $FB db $36, $00, $FD, $F3, $26, $00, $ED, $FB db $34, $00, $ED, $F3, $24, $01, $06, $ED db $04, $28, $00, $ED, $FC, $34, $00, $FD db $04, $30, $00, $FD, $FC, $32, $00, $FD db $F4, $22, $00, $ED, $F4, $20, $01, $06 db $F3, $FC, $1A, $20, $F3, $F4, $1E, $60 db $F3, $04, $1E, $40, $03, $04, $1E, $00 db $03, $F4, $1E, $20, $03, $FC, $0E, $21 db $06, $F3, $04, $1C, $00, $F3, $FC, $0C db $00, $F3, $F4, $1E, $60, $03, $F4, $1E db $20, $03, $04, $1E, $00, $03, $FC, $0E db $01, $06, $F3, $FC, $0E, $40, $F0, $03 db $28, $00, $03, $FC, $0E, $00, $00, $03 db $30, $00, $F3, $F4, $1E, $60, $03, $F4 db $1E, $21, $06, $03, $FC, $0E, $00, $06 db $03, $28, $40, $F3, $FC, $0E, $40, $F6 db $03, $30, $40, $03, $F4, $1E, $20, $F3 db $F4, $1E, $61, $06, $03, $04, $1C, $40 db $03, $FC, $0C, $40, $03, $F4, $1E, $20 db $F3, $F4, $1E, $60, $F3, $04, $1E, $40 db $F3, $FC, $0E, $41, $06, $03, $FC, $1A db $60, $03, $F4, $1E, $20, $03, $04, $1E db $00, $F3, $04, $1E, $40, $F3, $F4, $1E db $60, $F3, $FC, $0E, $61, $06, $03, $F4 db $1C, $60, $03, $FC, $0C, $60, $03, $04 db $1E, $00, $F3, $04, $1E, $40, $F3, $F4 db $1E, $60, $F3, $FC, $0E, $61, $06, $03 db $FC, $0E, $20, $06, $F5, $28, $60, $F3 db $FC, $0E, $60, $F6, $F5, $30, $60, $03 db $04, $1E, $00, $F3, $04, $1E, $41, $06 db $F3, $FC, $0E, $60, $F0, $F5, $28, $20 db $03, $FC, $0E, $20, $00, $F5, $30, $20 db $F3, $04, $1E, $40, $03, $04, $1E, $01 db $06, $F3, $F4, $1C, $20, $F3, $FC, $0C db $20, $F3, $04, $1E, $40, $03, $04, $1E db $00, $03, $F4, $1E, $20, $03, $FC, $0E db $21, $03, $F4, $F4, $2E, $00, $F4, $04 db $2E, $00, $FC, $FC, $2E, $01, $02, $F4 db $EC, $2C, $00, $F4, $0C, $2C, $21, $4F db $79, $58, $79, $61, $79, $6A, $79, $73 db $79, $7C, $79, $85, $79, $8E, $79, $97 db $79, $A8, $79, $B9, $79, $CA, $79, $DB db $79, $EC, $79, $02, $F8, $00, $10, $00 db $F8, $F8, $00, $01, $02, $F8, $00, $12 db $00, $F8, $F8, $02, $01, $02, $F8, $00 db $10, $40, $F8, $F8, $00, $41, $02, $F8 db $00, $12, $40, $F8, $F8, $02, $41, $02 db $F8, $00, $04, $20, $F8, $F8, $04, $01 db $02, $F8, $00, $14, $20, $F8, $F8, $14 db $01, $02, $F8, $00, $06, $20, $F8, $F8 db $06, $01, $02, $F0, $00, $16, $20, $F0 db $F8, $16, $01, $04, $F8, $00, $0A, $20 db $E8, $00, $08, $20, $F8, $F8, $0A, $00 db $E8, $F8, $08, $01, $04, $F0, $F0, $0C db $20, $F0, $08, $0C, $00, $F8, $00, $18 db $20, $F8, $F8, $18, $01, $04, $EE, $EE db $0C, $20, $EE, $0A, $0C, $00, $F8, $00 db $18, $20, $F8, $F8, $18, $01, $04, $EC db $EC, $1A, $00, $EC, $0C, $1A, $00, $F8 db $00, $06, $20, $F8, $F8, $06, $01, $04 db $EC, $EB, $1A, $00, $EC, $0D, $1A, $00 db $F8, $00, $06, $20, $F8, $F8, $06, $01 db $04, $F0, $00, $16, $20, $F0, $F8, $16 db $00, $E0, $00, $0E, $20, $E0, $F8, $0E db $01, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $1E, $1E, $2D, $33, $3D db $22, $3F, $20, $2F, $30, $17, $18, $17 db $18, $0F, $08, $0B, $0F, $06, $05, $06 db $05, $04, $07, $04, $07, $08, $0F, $08 db $0F, $0B, $0C, $17, $18, $1F, $10, $2F db $30, $3F, $20, $3F, $22, $3F, $21, $3F db $20, $1F, $10, $13, $1C, $0C, $0F, $03 db $03, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $F8, $F8, $76, $8E, $FD db $2B, $FE, $29, $39, $EE, $FF, $00, $FF db $10, $FF, $10, $7D, $83, $FE, $FF, $00 db $FF, $00, $FF, $C3, $BD, $C3, $FF, $18 db $FF, $CB, $3C, $FF, $00, $FF, $00, $7E db $81, $FF, $42, $FF, $42, $FF, $81, $FF db $00, $FF, $00, $FF, $00, $FF, $00, $FF db $FF, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $80, $80, $80, $80, $40, $C0, $40 db $C0, $C0, $40, $C0, $C0, $C0, $40, $C0 db $40, $20, $E0, $20, $E0, $20, $E0, $10 db $F0, $D0, $30, $E8, $18, $F8, $08, $F4 db $0C, $FC, $04, $FC, $44, $FC, $84, $FC db $04, $F8, $08, $C8, $38, $30, $F0, $C0 db $C0, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $01, $01, $01, $01, $02 db $03, $02, $03, $04, $07, $1C, $1B, $3C db $23, $7C, $43, $70, $4F, $7C, $43, $3C db $33, $0E, $0F, $01, $01, $01, $01, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $1D, $1D, $2B, $36, $3F, $20, $3F db $20, $2F, $30, $3C, $33, $5F, $68, $7B db $4C, $FD, $C6, $3E, $E3, $1F, $F1, $6D db $9E, $F3, $4F, $F0, $CF, $60, $9F, $00 db $FF, $03, $FE, $07, $FC, $06, $FD, $03 db $FF, $00, $FF, $00, $FF, $80, $7F, $C0 db $BF, $7B, $64, $1F, $1F, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $E0, $E0, $F8, $18, $FC, $04, $FE db $A2, $FD, $A3, $E7, $B9, $FE, $01, $FF db $00, $FA, $45, $E9, $1F, $FE, $F7, $EC db $1F, $F0, $FF, $00, $FF, $00, $FF, $00 db $FF, $E0, $3F, $F0, $1F, $B0, $5F, $E0 db $FF, $00, $FF, $00, $FF, $00, $FF, $01 db $FE, $6F, $93, $FC, $FC, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $80, $80, $80 db $80, $80, $80, $40, $C0, $40, $C0, $20 db $E0, $20, $E0, $10, $F0, $1C, $EC, $1E db $E2, $1F, $E1, $07, $F9, $1F, $E1, $1E db $E6, $38, $F8, $40, $C0, $C0, $40, $80 db $80, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $03, $03, $02, $03, $02 db $03, $02, $03, $03, $03, $04, $07, $05 db $07, $08, $0F, $09, $0F, $10, $1F, $10 db $1F, $20, $3F, $29, $3E, $2B, $3C, $3B db $3C, $39, $3E, $1C, $1F, $0F, $0F, $03 db $03, $05, $06, $0B, $0C, $0F, $08, $0F db $08, $09, $0E, $05, $06, $05, $06, $03 db $02, $03, $03, $04, $07, $04, $07, $03 db $03, $00, $00, $63, $63, $DD, $FF, $49 db $FF, $00, $FF, $80, $FF, $E3, $FF, $F7 db $BE, $F7, $BE, $F7, $C9, $08, $FF, $7E db $89, $FF, $00, $FF, $00, $24, $DB, $66 db $99, $FF, $00, $FF, $00, $00, $FF, $D5 db $FF, $6A, $D5, $FF, $00, $FF, $14, $FF db $14, $9C, $77, $FF, $00, $FF, $08, $FF db $08, $FF, $00, $3E, $C1, $1C, $FF, $F7 db $F7, $00, $00, $60, $60, $A0, $E0, $20 db $E0, $20, $E0, $E0, $E0, $90, $F0, $D0 db $F0, $88, $F8, $C8, $F8, $04, $FC, $04 db $FC, $82, $7E, $CA, $3E, $EA, $1E, $EE db $1E, $CE, $3E, $9C, $7C, $78, $F8, $A0 db $E0, $A0, $E0, $C0, $40, $E0, $20, $F0 db $10, $F0, $10, $F8, $08, $F8, $08, $A8 db $58, $F0, $70, $10, $F0, $10, $F0, $E0 db $E0, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $9F, $7C, $06, $FD, $04, $0A, $00 db $ED, $04, $08, $00, $FD, $FC, $06, $00 db $ED, $FC, $04, $00, $FD, $F4, $02, $00 db $ED, $F4, $00, $01, $BA, $7C, $08, $FF db $08, $0E, $00, $EF, $08, $0C, $00, $FF db $00, $0A, $00, $EF, $00, $08, $00, $FF db $F8, $06, $00, $EF, $F8, $04, $00, $FF db $F0, $02, $00, $EF, $F0, $00, $01, $DD db $7C, $06, $FD, $04, $0A, $00, $ED, $04 db $08, $00, $FD, $FC, $06, $00, $ED, $FC db $04, $00, $FD, $F4, $02, $00, $ED, $F4 db $00, $01, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $7F, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $02, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $10, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $20, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $40, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $20, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $DF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $00
; A014217: a(n) = floor(phi^n), where phi = (1+sqrt(5))/2 is the golden ratio. ; 1,1,2,4,6,11,17,29,46,76,122,199,321,521,842,1364,2206,3571,5777,9349,15126,24476,39602,64079,103681,167761,271442,439204,710646,1149851,1860497,3010349,4870846,7881196,12752042,20633239,33385281,54018521,87403802,141422324,228826126,370248451,599074577,969323029,1568397606,2537720636,4106118242,6643838879,10749957121,17393796001,28143753122,45537549124,73681302246,119218851371,192900153617,312119004989,505019158606,817138163596,1322157322202,2139295485799,3461452808001,5600748293801,9062201101802,14662949395604,23725150497406,38388099893011,62113250390417,100501350283429,162614600673846,263115950957276,425730551631122,688846502588399,1114577054219521,1803423556807921,2918000611027442,4721424167835364,7639424778862806 add $0,1 mov $3,4 lpb $0 sub $0,1 trn $2,4 trn $3,3 sub $5,$4 mov $4,$5 add $5,$2 add $2,$1 add $4,2 add $2,$4 add $5,$3 mov $1,$5 add $1,2 mov $5,3 lpe sub $1,2
; A226201: 8^n + n. ; 1,9,66,515,4100,32773,262150,2097159,16777224,134217737,1073741834,8589934603,68719476748,549755813901,4398046511118,35184372088847,281474976710672,2251799813685265,18014398509482002,144115188075855891,1152921504606846996,9223372036854775829,73786976294838206486,590295810358705651735,4722366482869645213720,37778931862957161709593,302231454903657293676570,2417851639229258349412379,19342813113834066795298844,154742504910672534362390557,1237940039285380274899124254,9903520314283042199192993823,79228162514264337593543950368,633825300114114700748351602721,5070602400912917605986812821538,40564819207303340847894502572067,324518553658426726783156020576292,2596148429267413814265248164610085,20769187434139310514121985316880422,166153499473114484112975882535043111 mov $2,8 pow $2,$0 add $0,$2
// // Class AliRsnCutV0 // // General implementation of a single cut strategy, which can be: // - a value contained in a given interval [--> IsBetween() ] // - a value equal to a given reference [--> MatchesValue()] // // In all cases, the reference value(s) is (are) given as data members // and each kind of cut requires a given value type (Int, UInt, Double), // but the cut check procedure is then automatized and chosen thanks to // an enumeration of the implemented cut types. // At the end, the user (or any other point which uses this object) has // to use the method IsSelected() to check if this cut has been passed. // // authors: Massimo Venaruzzo (massimo.venaruzzo@ts.infn.it) // modified: Enrico Fragiacomo (enrico.fragiacomo@ts.infn.it) // modified: Kunal Garg (kgarg@cern.ch) // Modifications: Added Competing V0 Rejection, Lifetime cut and a switch for using or not using Competing V0 Rejection //Modification (13 March 2018): Added pT dependent Mass Tolerance cut for K* charged /* Note: Competing V0 Rejection For selection of V0 particle, we typically set a wide range around the mass of the particle. With Competing V0 rejection, we reject the other V0 particle in the same region with a small range. Lifetime cut should be quite intuitive. Set the value to a high value if not needed in the analysis. */ /*Switch to a pT dependent Mass Tolerance Cut has been added. fpT_Tolerance is a flag to switch to this pT dependent version of the cut. fMassTolSigma is as it says, how strict you want the cut to be. fpT_Tolerance takes values from 0-3. The values go as follows: fpT_Tolerance = 0 ; Default. Fixed cut for mass tolerance fpT_Tolerance = 1, 2, 3; for 13 TeV, 8 TeV and 5.02 TeV respectively for K* charged analysis P.S: these values have been calculated for K* charged at different energies. For other analysis, it's recommended to stick to the fix Mass Tolerance Cut (Date Modified: 4 May 2018 by Kunal Garg) */ //modified: Prottay Das (prottay.das@cern.ch) //Modification (14/12/2021): Added armentous cut for misidentification of lambda as K0s in Pb-Pb collisions #include <Riostream.h> #include <TFormula.h> #include <TBits.h> #include "AliLog.h" #include "AliESDtrackCuts.h" #include "AliRsnEvent.h" #include "AliRsnDaughter.h" #include "AliRsnCutV0.h" ClassImp(AliRsnCutV0) //_________________________________________________________________________________________________ AliRsnCutV0::AliRsnCutV0(const char *name, Int_t hypothesis, AliPID::EParticleType pid, AliPID::EParticleType pid2) : AliRsnCut(name, AliRsnTarget::kDaughter), fHypothesis(0), fpT_Tolerance(0), fMassTolSigma(0), fMass(0.0), fTolerance(0.01), fToleranceVeto(0.01), fSwitch(0), fLife(0), fLowRadius(0), fHighRadius(0), fMaxDCAVertex(0.3), fMinCosPointAngle(0.95), fMaxDaughtersDCA(0.5), fMinArm(0.2), fMinTPCcluster(70), fMaxRapidity(0.8), fMaxPseudorapidity(1e20), fPID(pid), fPID2(pid2), fPIDCutProton(0), fPIDCutPion(0), fESDtrackCuts(0x0), fCutQuality(Form("%sDaughtersQuality", name)), fAODTestFilterBit(5), fCustomTrackDCACuts(kFALSE), fMinDCAPositiveTrack(0.001), fMinDCANegativeTrack(0.001), fCheckOOBPileup(kFALSE) { // // Default constructor. // Initializes all cuts in such a way that all of them are disabled. // SetHypothesis(hypothesis); } //_________________________________________________________________________________________________ AliRsnCutV0::AliRsnCutV0(const AliRsnCutV0 &copy) : AliRsnCut(copy), fHypothesis(copy.fHypothesis), fpT_Tolerance(copy.fpT_Tolerance), fMassTolSigma(copy.fMassTolSigma), fMass(copy.fMass), fTolerance(copy.fTolerance), fToleranceVeto(copy.fToleranceVeto), fSwitch(copy.fSwitch), fLife(copy.fLife), fLowRadius(copy.fLowRadius), fHighRadius(copy.fHighRadius), fMaxDCAVertex(copy.fMaxDCAVertex), fMinCosPointAngle(copy.fMinCosPointAngle), fMaxDaughtersDCA(copy.fMaxDaughtersDCA), fMinArm(copy.fMinArm), fMinTPCcluster(copy.fMinTPCcluster), fMaxRapidity(copy.fMaxRapidity), fMaxPseudorapidity(copy.fMaxPseudorapidity), fPID(copy.fPID), fPID2(copy.fPID2), fPIDCutProton(copy.fPIDCutProton), fPIDCutPion(copy.fPIDCutPion), fESDtrackCuts(copy.fESDtrackCuts), fCutQuality(copy.fCutQuality), fAODTestFilterBit(copy.fAODTestFilterBit), fCustomTrackDCACuts(copy.fCustomTrackDCACuts), fMinDCAPositiveTrack(copy.fMinDCAPositiveTrack), fMinDCANegativeTrack(copy.fMinDCANegativeTrack), fCheckOOBPileup(copy.fCheckOOBPileup) { // // Copy constructor. // Just copy all data member values.:IsSelected: Object is not a V0 (RESONANCES/AliRsnCutV0.cxx:149) // fCutQuality.SetPtRange(0.15, 1E+20); fCutQuality.SetEtaRange(-0.8, 0.8); fCutQuality.SetSPDminNClusters(1); fCutQuality.SetITSminNClusters(0); fCutQuality.SetITSmaxChi2(1E+20); fCutQuality.SetTPCminNClusters(fMinTPCcluster); fCutQuality.SetTPCmaxChi2(4.0); fCutQuality.SetRejectKinkDaughters(); fCutQuality.SetAODTestFilterBit(5); } //_________________________________________________________________________________________________ AliRsnCutV0 &AliRsnCutV0::operator=(const AliRsnCutV0 &copy) { // // Assignment operator. // Just copy all data member values. // if (this == &copy) return *this; fHypothesis = copy.fHypothesis; fpT_Tolerance = copy.fpT_Tolerance; fMassTolSigma = copy.fMassTolSigma; fMass = copy.fMass; fTolerance = copy.fTolerance; fToleranceVeto = copy.fToleranceVeto; fSwitch = copy.fSwitch; fLife = copy.fLife; fLowRadius = copy.fLowRadius; fHighRadius = copy.fHighRadius; fMaxDCAVertex = copy.fMaxDCAVertex; fMinCosPointAngle = copy.fMinCosPointAngle; fMaxDaughtersDCA = copy.fMaxDaughtersDCA; fMinArm=copy.fMinArm; fMinTPCcluster = copy.fMinTPCcluster; fMaxRapidity = copy.fMaxRapidity; fMaxPseudorapidity = copy.fMaxPseudorapidity; fCutQuality = copy.fCutQuality; fPID = copy.fPID; fPID2 = copy.fPID2; fPIDCutProton = copy.fPIDCutProton; fPIDCutPion = copy.fPIDCutPion; fESDtrackCuts = copy.fESDtrackCuts; fCutQuality = copy.fCutQuality; fAODTestFilterBit = copy.fAODTestFilterBit; fCustomTrackDCACuts = copy.fCustomTrackDCACuts; fMinDCAPositiveTrack = copy.fMinDCAPositiveTrack; fMinDCANegativeTrack = copy.fMinDCANegativeTrack; fCheckOOBPileup = copy.fCheckOOBPileup; return (*this); } //_________________________________________________________________________________________________ Bool_t AliRsnCutV0::IsSelected(TObject *object) { //:IsSelected: Object is not a V0 (RESONANCES/AliRsnCutV0.cxx:149) // Cut checker. // Checks the type of object being evaluated // and then calls the appropriate sub-function (for ESD or AOD) // // coherence check if (!TargetOK(object)) return kFALSE; // The Cascade classes inherit from the V0 classes. Cascades will therefore be counted as V0s unless we remove them. AliESDcascade *Xesd = fDaughter->Ref2ESDcascade(); AliAODcascade *Xaod = fDaughter->Ref2AODcascade(); if (Xesd || Xaod) return kFALSE; // check cast AliESDv0 *v0esd = fDaughter->Ref2ESDv0(); AliAODv0 *v0aod = fDaughter->Ref2AODv0(); //cout << fDaughter->GetRef()->ClassName() << ' ' << v0esd << ' ' << v0aod << endl; // operate depending on cast:IsSelected: Object is not a V0 (RESONANCES/AliRsnCutV0.cxx:149) if (v0esd) { return CheckESD(v0esd); } else if (v0aod) { return CheckAOD(v0aod); } else { AliDebugClass(1, "Object is not a V0"); return kFALSE; } } //_________________________________________________________________________________________________ Bool_t AliRsnCutV0::CheckESD(AliESDv0 *v0) { // // Check an ESD V0. // This is done using the default track checker for ESD. // It is declared static, not to recreate it every time. // AliDebugClass(1, "Check ESD"); if (v0->GetOnFlyStatus()) { AliDebugClass(1, "Rejecting V0 in 'on fly' status"); return kFALSE; // if kTRUE, then this V0 is recontructed } // retrieve pointer to owner event AliESDEvent *lESDEvent = fEvent->GetRefESD(); Double_t xPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetX(); Double_t yPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetY(); Double_t zPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetZ(); AliDebugClass(2, Form("Primary vertex: %f %f %f", xPrimaryVertex, yPrimaryVertex, zPrimaryVertex)); // retrieve the V0 daughters UInt_t lIdxPos = (UInt_t) TMath::Abs(v0->GetPindex()); UInt_t lIdxNeg = (UInt_t) TMath::Abs(v0->GetNindex()); AliESDtrack *pTrack = lESDEvent->GetTrack(lIdxPos); AliESDtrack *nTrack = lESDEvent->GetTrack(lIdxNeg); // filter like-sign V0 if ( TMath::Abs( ((pTrack->GetSign()) - (nTrack->GetSign())) ) < 0.1) { AliDebugClass(2, "Failed like-sign V0 check"); return kFALSE; } if (fCheckOOBPileup) { Double_t bfield = lESDEvent->GetMagneticField(); if(!TrackPassesOOBPileupCut(pTrack, bfield) && !TrackPassesOOBPileupCut(nTrack, bfield)) return kFALSE; } // check quality cuts if (fESDtrackCuts) { AliDebugClass(2, "Checking quality cuts"); if (!fESDtrackCuts->IsSelected(pTrack)) { AliDebugClass(2, "Positive daughter failed quality cuts"); return kFALSE; } if (!fESDtrackCuts->IsSelected(nTrack)) { AliDebugClass(2, "Negative daughter failed quality cuts"); return kFALSE; } } // Apply different DCAxy cut for positive and negative V0 daughters if (fCustomTrackDCACuts) { Float_t impParPos[2], impParNeg[2]; Float_t covMatPos[3], covMatNeg[3]; pTrack->GetImpactParameters(impParPos,covMatPos); nTrack->GetImpactParameters(impParNeg,covMatNeg); if (covMatPos[0]<=0 || covMatPos[2]<=0) { Printf("Estimated b resolution lower or equal zero!"); covMatPos[0]=0; covMatPos[2]=0; } if (covMatNeg[0]<=0 || covMatNeg[2]<=0) { Printf("Estimated b resolution lower or equal zero!"); covMatNeg[0]=0; covMatNeg[2]=0; } if(TMath::Abs(impParPos[0])<fMinDCAPositiveTrack) return kFALSE; if(TMath::Abs(impParNeg[0])<fMinDCANegativeTrack) return kFALSE; } // topological checks if (TMath::Abs(v0->GetDcaV0Daughters()) > fMaxDaughtersDCA) { AliDebugClass(2, "Failed check on DCA between daughters"); return kFALSE; } if (TMath::Abs(v0->GetD(xPrimaryVertex, yPrimaryVertex, zPrimaryVertex)) > fMaxDCAVertex) { AliDebugClass(2, "Failed check on DCA to primary vertes"); return kFALSE; } if ((v0->PtArmV0()/TMath::Abs(v0->AlphaV0())) < fMinArm) { //if ((v0->GetArmCut() > fMinArm) { AliDebugClass(2, "Failed check on Armentous Cut"); return kFALSE; } //if (TMath::Abs(v0->GetV0CosineOfPointingAngle()) < fMinCosPointAngle) { if ( (TMath::Abs(v0->GetV0CosineOfPointingAngle()) < fMinCosPointAngle) || (TMath::Abs(v0->GetV0CosineOfPointingAngle()) >= 1 ) ) { AliDebugClass(2, "Failed check on cosine of pointing angle"); return kFALSE; } if (TMath::Abs(v0->Y(fHypothesis)) > fMaxRapidity) { AliDebugClass(2, "Failed check on V0 rapidity"); return kFALSE; } if (TMath::Abs(v0->Eta()) > fMaxPseudorapidity) { AliDebugClass(2, "Failed check on V0 pseudorapidity"); return kFALSE; } // Double_t v0Position[3]; // from $ALICE_ROOT/ANALYSIS/AliESDV0Cuts.cxx v0->GetXYZ(v0Position[0],v0Position[1],v0Position[2]); Double_t radius = TMath::Sqrt(TMath::Power(v0Position[0],2) + TMath::Power(v0Position[1],2)); if ( ( radius < fLowRadius ) || ( radius > fHighRadius ) ) { AliDebugClass(2, "Failed fiducial volume"); return kFALSE; } // Lifetime cut for negative and positive track // Total Momentum Double_t tV0mom[3]; v0->GetPxPyPz( tV0mom[0],tV0mom[1],tV0mom[2] ); Double_t lV0TotalMomentum = TMath::Sqrt(tV0mom[0]*tV0mom[0]+tV0mom[1]*tV0mom[1]+tV0mom[2]*tV0mom[2] ); Double_t fLength = TMath::Sqrt(TMath::Power(v0Position[0]- xPrimaryVertex,2) + TMath::Power(v0Position[1] - yPrimaryVertex,2)+ TMath::Power(v0Position[2]- zPrimaryVertex,2)); if( TMath::Abs(fMass*fLength/lV0TotalMomentum) > fLife) { AliDebugClass(2, "Failed Lifetime Cut on positive track V0"); return kFALSE; } Double_t v0pT = TMath::Abs(TMath::Sqrt(tV0mom[0]*tV0mom[0] + tV0mom[1]*tV0mom[1])); if(fpT_Tolerance==0) { v0->ChangeMassHypothesis(fHypothesis); if ((TMath::Abs(v0->GetEffMass() - fMass)) > fTolerance) { AliDebugClass(2, "V0 is not in the expected inv mass range"); return kFALSE; } } Double_t upper_limit =0, lower_limit =0; if(fpT_Tolerance==1 || fpT_Tolerance==2) //Read the Note at the top of the code for more information . { v0->ChangeMassHypothesis(fHypothesis); if(v0pT<=1.5) { if(v0pT<0.15){v0pT = 0.15;} upper_limit = 0.49722 + 9.83285e-04* log(v0pT) + fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); lower_limit = 0.49722 + 9.83285e-04* log(v0pT) - fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); } else if(v0pT > 1.5) { upper_limit = 0.49761 + fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); lower_limit = 0.49761 - fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); } if ((v0->GetEffMass() < lower_limit ) || (v0->GetEffMass() > upper_limit)) { AliDebugClass(2, "V0 is not in the expected inv mass range"); return kFALSE; } } if(fpT_Tolerance==3) { v0->ChangeMassHypothesis(fHypothesis); Double_t upper_limit =0, lower_limit =0; if(v0pT<=1.5) { if(v0pT<0.15) {v0pT = 0.15;} upper_limit = 0.49797 + 9.99398e-04* log(v0pT) + fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); lower_limit = 0.49797 + 9.99398e-04* log(v0pT) - fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); } else if(v0pT > 1.5) { upper_limit = 0.498375 + fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); lower_limit = 0.498375 - fMassTolSigma*(3.47153e-03 + 2.70453e-04* v0pT); } if ((v0->GetEffMass() < lower_limit ) || (v0->GetEffMass() > upper_limit)) { AliDebugClass(2, "V0 is not in the expected inv mass range"); return kFALSE; } } //Set Switch to kTRUE to use Competing V0 Rejection if(fSwitch){ if(fHypothesis == kK0Short) {v0->ChangeMassHypothesis(kLambda0); if ((TMath::Abs(v0->GetEffMass() - 1.115683)) < fToleranceVeto) { v0->ChangeMassHypothesis(kK0Short); return kFALSE; } v0->ChangeMassHypothesis(kK0Short); } if(fHypothesis == kLambda0) {v0->ChangeMassHypothesis(kK0Short); if ((TMath::Abs(v0->GetEffMass() - 0.497614)) < fToleranceVeto) { v0->ChangeMassHypothesis(kLambda0); return kFALSE; } v0->ChangeMassHypothesis(kLambda0); } if(fHypothesis == kLambda0Bar) {v0->ChangeMassHypothesis(kK0Short); if ((TMath::Abs(v0->GetEffMass() - 0.497614)) < fToleranceVeto) { v0->ChangeMassHypothesis(kLambda0Bar); return kFALSE; } v0->ChangeMassHypothesis(kLambda0Bar); } } // check PID on proton or antiproton from V0 // check initialization of PID object AliPIDResponse *pid = fEvent->GetPIDResponse(); if (!pid) { AliFatal("NULL PID response"); return kFALSE; } // check if TOF is matched // and computes all values used in the PID cut //Bool_t isTOFpos = MatchTOF(ptrack); //Bool_t isTOFneg = MatchTOF(ntrack); //Double_t pospTPC = pTrack->GetTPCmomentum(); //Double_t negpTPC = nTrack->GetTPCmomentum(); //Double_t posp = pTrack->P(); //Double_t negp = nTrack->P(); Double_t posnsTPC = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, fPID)); Double_t posnsTPC2 = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, fPID2)); //Double_t posnsTOF = TMath::Abs(pid->NumberOfSigmasTOF(ptrack, fPID)); Double_t negnsTPC = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, fPID)); Double_t negnsTPC2 = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, fPID2)); //Double_t negnsTOF = TMath::Abs(pid->NumberOfSigmasTOF(ntrack, fPID)); Double_t maxTPC = 1E20; Double_t maxTPC2 = 1E20; //Double_t maxTOF = 1E20; // applies the cut differently depending on the PID and the momentum if(fHypothesis==kLambda0) { //if (isTOFpos) { // TPC: 5sigma cut for all //if (posnsTPC > 5.0) return kFALSE; // TOF: 3sigma // maxTOF = 3.0; //return (posnsTOF <= maxTOF); //} else { // TPC: maxTPC = fPIDCutProton; maxTPC2 = fPIDCutPion; if (! ((posnsTPC <= maxTPC) && (negnsTPC2 <= maxTPC2)) ) { AliDebugClass(2, "Failed check on V0 PID"); return kFALSE; } } else if(fHypothesis==kLambda0Bar) { //if (isTOFneg) { // TPC: 5sigma cut for all //if (negnsTPC > 5.0) return kFALSE; // TOF: 3sigma // maxTOF = 3.0; //return (negnsTOF <= maxTOF); //} else { // TPC: maxTPC = fPIDCutProton; maxTPC2 = fPIDCutPion; if(! ((negnsTPC <= maxTPC) && (posnsTPC2 <= maxTPC2)) ) { AliDebugClass(2, "Failed check on V0 PID"); return kFALSE; } } else if(fHypothesis==kK0Short) { //if (isTOFneg) { // TPC: 5sigma cut for all //if (negnsTPC > 5.0) return kFALSE; // TOF: 3sigma // maxTOF = 3.0; //return (negnsTOF <= maxTOF); //} else { // TPC: maxTPC = fPIDCutPion; maxTPC2 = fPIDCutPion; if(! ((negnsTPC <= maxTPC) && (posnsTPC2 <= maxTPC2)) ) { AliDebugClass(2, "Failed check on V0 PID"); return kFALSE; } } // if we reach this point, all checks were successful AliDebugClass(2, "Good V0"); return kTRUE; } //_________________________________________________________________________________________________ Bool_t AliRsnCutV0::CheckAOD(AliAODv0 *v0) { // // Check an AOD V0. // This is done doing directly all checks, since there is not // an equivalend checker for AOD tracks // AliDebugClass(2, "Check AOD"); if (v0->GetOnFlyStatus()) { AliDebugClass(2, "Rejecting V0 in 'on fly' status"); return kFALSE; // if kTRUE, then this V0 is recontructed } // retrieve pointer to owner event AliAODEvent *lAODEvent = fEvent->GetRefAOD(); Double_t xPrimaryVertex = lAODEvent->GetPrimaryVertex()->GetX(); Double_t yPrimaryVertex = lAODEvent->GetPrimaryVertex()->GetY(); Double_t zPrimaryVertex = lAODEvent->GetPrimaryVertex()->GetZ(); AliDebugClass(2, Form("Primary vertex: %f %f %f", xPrimaryVertex, yPrimaryVertex, zPrimaryVertex)); // retrieve the V0 daughters AliAODTrack *pTrack = (AliAODTrack *) (v0->GetSecondaryVtx()->GetDaughter(0)); AliAODTrack *nTrack = (AliAODTrack *) (v0->GetSecondaryVtx()->GetDaughter(1)); // check quality cuts UInt_t filtermapP = 9999; UInt_t filtermapN = 9999; filtermapP = pTrack->GetFilterMap(); filtermapN = nTrack->GetFilterMap(); //----- // next lines commented out by EF - 17/01/2014 // NOTE that the filter bit test on V0 daughters removes a huge amount of V0 candidates, including good ones. // Likely wrong -> requires a DCA max! // Removing the test, there's a little gain in efficiency in the // final search for Sigma* candidates // NOTE that further constrains (e.g. DCA of daughters greater than xxx), // necessary to remove background, are already in V0s. (see also below) /* if ( !pTrack->TestFilterBit(fAODTestFilterBit) ) { AliDebugClass(2, Form("Positive daughter failed quality cuts filtermapP=%d",filtermapP)); return kFALSE; } if ( !nTrack->TestFilterBit(fAODTestFilterBit) ) { AliDebugClass(2, Form("Negative daughter failed quality cuts filtermapN=%d",filtermapN)); return kFALSE; } */ if (!AODTrackAccepted(pTrack) || !AODTrackAccepted(nTrack)) return kFALSE; //---- // next lines are not necessary. Just left there (commented-out) to remind that the requirement on the DCA of V0 daughters // is already in the V0, so requiring dca>0.050 (with 0.050 cm the default value from the Lambda analysis) // does not remove V0s candidates Double_t dca = v0->DcaPosToPrimVertex() ; // AliDebugClass(2, Form("DCA of V0 positive daughter %f",dca)); if (fESDtrackCuts && dca < fESDtrackCuts->GetMinDCAToVertexXY()) { AliDebugClass(2, Form("DCA of V0 positive daughter (%f) less than %f", dca, fESDtrackCuts->GetMinDCAToVertexXY())); return kFALSE; } dca = v0->DcaNegToPrimVertex(); if (fESDtrackCuts && dca < fESDtrackCuts->GetMinDCAToVertexXY()) { AliDebugClass(2, Form("DCA of V0 negative daughter (%f) less than %f", dca, fESDtrackCuts->GetMinDCAToVertexXY())); return kFALSE; } // EF - 17/01/2014 - next check apparently not effective!? Already in V0s? // filter like-sign V0 if ( TMath::Abs( ((pTrack->Charge()) - (nTrack->Charge())) ) < 0.1) { AliDebugClass(2, "Failed like-sign V0 check"); return kFALSE; } if (fCheckOOBPileup) { Double_t bfield = lAODEvent->GetMagneticField(); if(!TrackPassesOOBPileupCut(pTrack, bfield) && !TrackPassesOOBPileupCut(nTrack, bfield)) return kFALSE; } // check compatibility with expected species hypothesis Double_t mass = 0.0; if(fHypothesis==kLambda0) { mass = v0->MassLambda(); } else if (fHypothesis==kLambda0Bar) { mass = v0->MassAntiLambda(); } else if (fHypothesis==kK0Short) { mass = v0->MassK0Short(); } if ((TMath::Abs(mass - fMass)) > fTolerance) { AliDebugClass(2, Form("V0 is not in the expected inv mass range Mass: %d %f %f", fHypothesis, fMass, mass)); return kFALSE; } AliDebugClass(2, Form("Mass: %d %f %f", fHypothesis, fMass, mass)); // competing V0 rejection Double_t altmass = 0.0; if (fSwitch) { if(fHypothesis==kLambda0 || fHypothesis==kLambda0Bar) { altmass = v0->MassK0Short(); if ((TMath::Abs(altmass - 0.497614)) < fToleranceVeto) { AliDebugClass(2, Form("Failed competing V0 rejection check Mass: %d %f %f", fHypothesis, mass, altmass)); return kFALSE; } } else if (fHypothesis==kK0Short) { altmass = v0->MassLambda(); if ((TMath::Abs(altmass - 1.115683)) < fToleranceVeto) { AliDebugClass(2, Form("Failed competing V0 rejection check Mass: %d %f %f", fHypothesis, mass, altmass)); return kFALSE; } altmass = v0->MassAntiLambda(); if ((TMath::Abs(altmass - 1.115683)) < fToleranceVeto) { AliDebugClass(2, Form("Failed competing V0 rejection check Mass: %d %f %f", fHypothesis, mass, altmass)); return kFALSE; } } } // topological checks if (TMath::Abs(v0->DcaV0ToPrimVertex()) > fMaxDCAVertex) { AliDebugClass(2, Form("Failed check on DCA to primary vertes dca=%f maxdca=%f",TMath::Abs(v0->DcaV0ToPrimVertex()),fMaxDCAVertex)); return kFALSE; } // next cut is effective (should it be in AODV0?) AliAODVertex *vertex = lAODEvent->GetPrimaryVertex(); Double_t cospointangle = v0->CosPointingAngle(vertex); if (TMath::Abs( cospointangle ) < fMinCosPointAngle) { AliDebugClass(2, "Failed check on cosine of pointing angle"); return kFALSE; } // next cut is effective (should it be in AODV0?) if (TMath::Abs(v0->DcaV0Daughters()) > fMaxDaughtersDCA) { AliDebugClass(2, "Failed check on DCA between daughters"); return kFALSE; } // rapidity if (fHypothesis==kK0Short) { if (TMath::Abs(v0->RapK0Short()) > fMaxRapidity) { AliDebugClass(2, "Failed check on V0 rapidity"); return kFALSE; } } else if(fHypothesis==kLambda0 || fHypothesis==kLambda0Bar) { if (TMath::Abs(v0->RapLambda()) > fMaxRapidity) { AliDebugClass(2, "Failed check on V0 rapidity"); return kFALSE; } } // pseudorapidity if (TMath::Abs(v0->Eta()) > fMaxPseudorapidity) { AliDebugClass(2, "Failed check on V0 pseusorapidity"); return kFALSE; } // radius Double_t radius = v0->RadiusV0(); if ( ( radius < fLowRadius ) || ( radius > fHighRadius ) ){ AliDebugClass(2, "Failed fiducial volume"); return kFALSE; } // lifetime Double_t mom = TMath::Sqrt(v0->Ptot2V0()); Double_t length = TMath::Sqrt(TMath::Power(v0->DecayVertexV0X() - xPrimaryVertex,2) + TMath::Power(v0->DecayVertexV0Y() - yPrimaryVertex,2) + TMath::Power(v0->DecayVertexV0Z() - zPrimaryVertex,2)); if( TMath::Abs(fMass*length/mom) > fLife) { AliDebugClass(2, Form("Failed V0 Lifetime Cut %d %f", fHypothesis, TMath::Abs(fMass*length/mom))); return kFALSE; } //----------------------------------------------------------- // check initialization of PID object AliPIDResponse *pid = fEvent->GetPIDResponse(); if (!pid) { AliFatal("NULL PID response"); return kFALSE; } Double_t posnsTPC = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, fPID)); Double_t posnsTPC2 = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, fPID2)); Double_t negnsTPC = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, fPID)); Double_t negnsTPC2 = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, fPID2)); Double_t maxTPC = 1E20; Double_t maxTPC2 = 1E20; // applies the cut differently depending on the PID and the momentum if(fHypothesis==kLambda0) { maxTPC = fPIDCutProton; maxTPC2 = fPIDCutPion; if (! ((posnsTPC <= maxTPC) && (negnsTPC2 <= maxTPC2)) ) { AliDebugClass(2, "Failed check on V0 PID"); return kFALSE; } } else if(fHypothesis==kLambda0Bar) { maxTPC = fPIDCutProton; maxTPC2 = fPIDCutPion; if(! ((negnsTPC <= maxTPC) && (posnsTPC2 <= maxTPC2)) ) { AliDebugClass(2, "Failed check on V0 PID"); return kFALSE; } } else if(fHypothesis==kK0Short) { maxTPC = fPIDCutPion; maxTPC2 = fPIDCutPion; if(! ((negnsTPC <= maxTPC) && (posnsTPC2 <= maxTPC2)) ) { AliDebugClass(2, "Failed check on V0 PID"); return kFALSE; } } //--------------------------------------------------------------- // if we reach this point, all checks were successful AliDebugClass(1, "Good AOD V0"); AliDebugClass(1, Form("Mass: %d %f %f %d %d", fHypothesis, fMass, mass, filtermapP, filtermapN)); return kTRUE; } //_________________________________________________________________________________________________ void AliRsnCutV0::Print(const Option_t *) const { // // Print information on this cut // } //_________________________________________________________________________________________________ Bool_t AliRsnCutV0::TrackPassesOOBPileupCut(AliESDtrack* t, Double_t b){ if (!t) return true; if ((t->GetStatus() & AliESDtrack::kITSrefit) == AliESDtrack::kITSrefit) return true; if (t->GetTOFExpTDiff(b, true) + 2500 > 1e-6) return true; return false; } //_________________________________________________________________________________________________ Bool_t AliRsnCutV0::TrackPassesOOBPileupCut(AliAODTrack* t, Double_t b){ if (!t) return true; if ((t->GetStatus() & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) return true; if (t->GetTOFExpTDiff(b, true) + 2500 > 1e-6) return true; return false; } //_________________________________________________________________________________________________ Bool_t AliRsnCutV0::AODTrackAccepted(AliAODTrack* t){ if (!t || !fESDtrackCuts) return true; // Implements basic quality cuts for V0 daughters. // Uses ESDtrackCuts object as a container for the cut values. Float_t etamin = -1e5, etamax = 1e5; fESDtrackCuts->GetEtaRange(etamin, etamax); if(t->Eta() < etamin || t->Eta() > etamax) return false; if(t->GetTPCClusterInfo(2, 1) < fESDtrackCuts->GetMinNCrossedRowsTPC()) return false; if(t->GetTPCNclsF() < fESDtrackCuts->GetMinRatioCrossedRowsOverFindableClustersTPC()) return false; ULong64_t s = t->GetStatus(); if(fESDtrackCuts->GetRequireTPCRefit() && !(s & AliESDtrack::kTPCrefit)) return false; // Disable this: being fixed by Strangeness PAG (January 2021). // AliAODVertex* v = t->GetProdVertex(); // if(pv && !fESDtrackCuts->GetAcceptKinkDaughters() && (pv->GetType() & AliAODVertex::kKink)) return false; return true; }
/**************************************************************************** * * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 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. * ****************************************************************************/ /** * @file rgbled.cpp * * Driver for the onboard RGB LED controller (TCA62724FMG) connected via I2C. * * @author Julian Oes <julian@px4.io> * @author Anton Babushkin <anton.babushkin@me.com> */ #include <px4_config.h> #include <px4_getopt.h> #include <drivers/device/i2c.h> #include <sys/types.h> #include <stdint.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <ctype.h> #include <px4_workqueue.h> #include <systemlib/perf_counter.h> #include <systemlib/err.h> #include <systemlib/systemlib.h> #include <board_config.h> #include <drivers/drv_led.h> #include <lib/led/led.h> #include "uORB/topics/parameter_update.h" #define RGBLED_ONTIME 120 #define RGBLED_OFFTIME 120 #define ADDR 0x55 /**< I2C adress of TCA62724FMG */ #define SUB_ADDR_START 0x01 /**< write everything (with auto-increment) */ #define SUB_ADDR_PWM0 0x81 /**< blue (without auto-increment) */ #define SUB_ADDR_PWM1 0x82 /**< green (without auto-increment) */ #define SUB_ADDR_PWM2 0x83 /**< red (without auto-increment) */ #define SUB_ADDR_SETTINGS 0x84 /**< settings (without auto-increment)*/ #define SETTING_NOT_POWERSAVE 0x01 /**< power-save mode not off */ #define SETTING_ENABLE 0x02 /**< on */ class RGBLED : public device::I2C { public: RGBLED(int bus, int rgbled); virtual ~RGBLED(); virtual int init(); virtual int probe(); int status(); private: work_s _work; float _brightness; float _max_brightness; uint8_t _r; uint8_t _g; uint8_t _b; volatile bool _running; volatile bool _should_run; bool _leds_enabled; int _param_sub; LedController _led_controller; static void led_trampoline(void *arg); void led(); int send_led_enable(bool enable); int send_led_rgb(); int get(bool &on, bool &powersave, uint8_t &r, uint8_t &g, uint8_t &b); void update_params(); }; /* for now, we only support one RGBLED */ namespace { RGBLED *g_rgbled = nullptr; } void rgbled_usage(); extern "C" __EXPORT int rgbled_main(int argc, char *argv[]); RGBLED::RGBLED(int bus, int rgbled) : I2C("rgbled", RGBLED0_DEVICE_PATH, bus, rgbled #ifdef __PX4_NUTTX , 100000 /* maximum speed supported */ #endif ), _work{}, _brightness(1.0f), _max_brightness(1.0f), _r(0), _g(0), _b(0), _running(false), _should_run(true), _leds_enabled(true), _param_sub(-1) { } RGBLED::~RGBLED() { _should_run = false; int counter = 0; while (_running && ++counter < 10) { usleep(100000); } } int RGBLED::init() { int ret; ret = I2C::init(); if (ret != OK) { return ret; } /* switch off LED on start */ send_led_enable(false); send_led_rgb(); update_params(); _running = true; // kick off work queue work_queue(LPWORK, &_work, (worker_t)&RGBLED::led_trampoline, this, 0); return OK; } int RGBLED::probe() { int ret; bool on, powersave; uint8_t r, g, b; /** this may look strange, but is needed. There is a serial EEPROM (Microchip-24aa01) that responds to a bunch of I2C addresses, including the 0x55 used by this LED device. So we need to do enough operations to be sure we are talking to the right device. These 3 operations seem to be enough, as the 3rd one consistently fails if no RGBLED is on the bus. */ unsigned prevretries = _retries; _retries = 4; if ((ret = get(on, powersave, r, g, b)) != OK || (ret = send_led_enable(false) != OK) || (ret = send_led_enable(false) != OK)) { return ret; } _retries = prevretries; return ret; } int RGBLED::status() { int ret; bool on, powersave; uint8_t r, g, b; ret = get(on, powersave, r, g, b); if (ret == OK) { /* we don't care about power-save mode */ DEVICE_LOG("state: %s", on ? "ON" : "OFF"); DEVICE_LOG("red: %u, green: %u, blue: %u", (unsigned)r, (unsigned)g, (unsigned)b); } else { PX4_WARN("failed to read led"); } return ret; } void RGBLED::led_trampoline(void *arg) { RGBLED *rgbl = reinterpret_cast<RGBLED *>(arg); rgbl->led(); } /** * Main loop function */ void RGBLED::led() { if (!_should_run) { if (_param_sub >= 0) { orb_unsubscribe(_param_sub); } int led_control_sub = _led_controller.led_control_subscription(); if (led_control_sub >= 0) { orb_unsubscribe(led_control_sub); } _running = false; return; } if (_param_sub < 0) { _param_sub = orb_subscribe(ORB_ID(parameter_update)); } if (!_led_controller.is_init()) { int led_control_sub = orb_subscribe(ORB_ID(led_control)); _led_controller.init(led_control_sub); } if (_param_sub >= 0) { bool updated = false; orb_check(_param_sub, &updated); if (updated) { parameter_update_s pupdate; orb_copy(ORB_ID(parameter_update), _param_sub, &pupdate); update_params(); // Immediately update to change brightness send_led_rgb(); } } LedControlData led_control_data; if (_led_controller.update(led_control_data) == 1) { switch (led_control_data.leds[0].color) { case led_control_s::COLOR_RED: _r = 255; _g = 0; _b = 0; send_led_enable(true); break; case led_control_s::COLOR_GREEN: _r = 0; _g = 255; _b = 0; send_led_enable(true); break; case led_control_s::COLOR_BLUE: _r = 0; _g = 0; _b = 255; send_led_enable(true); break; case led_control_s::COLOR_AMBER: //make it the same as yellow case led_control_s::COLOR_YELLOW: _r = 255; _g = 255; _b = 0; send_led_enable(true); break; case led_control_s::COLOR_PURPLE: _r = 255; _g = 0; _b = 255; send_led_enable(true); break; case led_control_s::COLOR_CYAN: _r = 0; _g = 255; _b = 255; send_led_enable(true); break; case led_control_s::COLOR_WHITE: _r = 255; _g = 255; _b = 255; send_led_enable(true); break; default: // led_control_s::COLOR_OFF _r = 0; _g = 0; _b = 0; send_led_enable(false); break; } _brightness = (float)led_control_data.leds[0].brightness / 255.f; send_led_rgb(); } /* re-queue ourselves to run again later */ work_queue(LPWORK, &_work, (worker_t)&RGBLED::led_trampoline, this, USEC2TICK(_led_controller.maximum_update_interval())); } /** * Sent ENABLE flag to LED driver */ int RGBLED::send_led_enable(bool enable) { if (_leds_enabled && enable) { // already enabled return 0; } _leds_enabled = enable; uint8_t settings_byte = 0; if (enable) { settings_byte |= SETTING_ENABLE; } settings_byte |= SETTING_NOT_POWERSAVE; const uint8_t msg[2] = { SUB_ADDR_SETTINGS, settings_byte}; return transfer(msg, sizeof(msg), nullptr, 0); } /** * Send RGB PWM settings to LED driver according to current color and brightness */ int RGBLED::send_led_rgb() { /* To scale from 0..255 -> 0..15 shift right by 4 bits */ const uint8_t msg[6] = { SUB_ADDR_PWM0, static_cast<uint8_t>((_b >> 4) * _brightness * _max_brightness + 0.5f), SUB_ADDR_PWM1, static_cast<uint8_t>((_g >> 4) * _brightness * _max_brightness + 0.5f), SUB_ADDR_PWM2, static_cast<uint8_t>((_r >> 4) * _brightness * _max_brightness + 0.5f) }; return transfer(msg, sizeof(msg), nullptr, 0); } int RGBLED::get(bool &on, bool &powersave, uint8_t &r, uint8_t &g, uint8_t &b) { uint8_t result[2] = {0, 0}; int ret; ret = transfer(nullptr, 0, &result[0], 2); if (ret == OK) { on = result[0] & SETTING_ENABLE; powersave = !(result[0] & SETTING_NOT_POWERSAVE); /* XXX check, looks wrong */ r = (result[0] & 0x0f) << 4; g = (result[1] & 0xf0); b = (result[1] & 0x0f) << 4; } return ret; } void RGBLED::update_params() { int32_t maxbrt = 15; param_get(param_find("LED_RGB_MAXBRT"), &maxbrt); maxbrt = maxbrt > 15 ? 15 : maxbrt; maxbrt = maxbrt < 0 ? 0 : maxbrt; // A minimum of 2 "on" steps is required for breathe effect if (maxbrt == 1) { maxbrt = 2; } _max_brightness = maxbrt / 15.0f; } void rgbled_usage() { PX4_INFO("missing command: try 'start', 'status', 'stop'"); PX4_INFO("options:"); PX4_INFO(" -b i2cbus (%d)", PX4_I2C_BUS_LED); PX4_INFO(" -a addr (0x%x)", ADDR); } int rgbled_main(int argc, char *argv[]) { int i2cdevice = -1; int rgbledadr = ADDR; /* 7bit */ int ch; /* jump over start/off/etc and look at options first */ int myoptind = 1; const char *myoptarg = nullptr; while ((ch = px4_getopt(argc, argv, "a:b:", &myoptind, &myoptarg)) != EOF) { switch (ch) { case 'a': rgbledadr = strtol(myoptarg, nullptr, 0); break; case 'b': i2cdevice = strtol(myoptarg, nullptr, 0); break; default: rgbled_usage(); return 1; } } if (myoptind >= argc) { rgbled_usage(); return 1; } const char *verb = argv[myoptind]; if (!strcmp(verb, "start")) { if (g_rgbled != nullptr) { PX4_WARN("already started"); return 1; } if (i2cdevice == -1) { // try the external bus first i2cdevice = PX4_I2C_BUS_EXPANSION; g_rgbled = new RGBLED(PX4_I2C_BUS_EXPANSION, rgbledadr); if (g_rgbled != nullptr && OK != g_rgbled->init()) { delete g_rgbled; g_rgbled = nullptr; } if (g_rgbled == nullptr) { // fall back to default bus if (PX4_I2C_BUS_LED == PX4_I2C_BUS_EXPANSION) { PX4_WARN("no RGB led on bus #%d", i2cdevice); return 1; } i2cdevice = PX4_I2C_BUS_LED; } } if (g_rgbled == nullptr) { g_rgbled = new RGBLED(i2cdevice, rgbledadr); if (g_rgbled == nullptr) { PX4_WARN("alloc failed"); return 1; } if (OK != g_rgbled->init()) { delete g_rgbled; g_rgbled = nullptr; PX4_WARN("no RGB led on bus #%d", i2cdevice); return 1; } } return 0; } /* need the driver past this point */ if (g_rgbled == nullptr) { PX4_WARN("not started"); rgbled_usage(); return 1; } if (!strcmp(verb, "status")) { g_rgbled->status(); return 0; } if (!strcmp(verb, "stop")) { delete g_rgbled; g_rgbled = nullptr; return 0; } rgbled_usage(); return 1; }