text
stringlengths
1
1.05M
#include <Storages/IStorage.h> #include <Storages/ColumnsDescription.h> #include <Storages/StorageValues.h> #include <DataStreams/OneBlockInputStream.h> namespace DB { StorageValues::StorageValues(const StorageID & table_id_, const ColumnsDescription & columns_, const Block & res_block_) : IStorage(table_id_), res_block(res_block_) { setColumns(columns_); } BlockInputStreams StorageValues::read( const Names & column_names, const SelectQueryInfo & /*query_info*/, const Context & /*context*/, QueryProcessingStage::Enum /*processed_stage*/, size_t /*max_block_size*/, unsigned /*num_streams*/) { check(column_names, true); return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(res_block)); } }
COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1993 -- All Rights Reserved PROJECT: PC GEOS MODULE: Epson 24-pin printer driver FILE: epson24zManager.asm AUTHOR: Dave Durran REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 2/90 initial version Dave 3/90 added 24-pin print resources. DESCRIPTION: This file contains the source for the epson 24-pin printer driver $Id: epson24zManager.asm,v 1.1 97/04/18 11:53:19 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} ;-------------------------------------- ; Include files ;-------------------------------------- include printcomInclude.def ;------------------------------------------------------------------------------ ; Constants and Macros ;------------------------------------------------------------------------------ include printcomConstant.def include epson24Constant.def include printcomMacro.def include printcomEpsonFX.rdef ;------------------------------------------------------------------------------ ; Driver Info Table ;------------------------------------------------------------------------------ idata segment ; MODULE_FIXED DriverTable DriverExtendedInfoStruct \ < < Entry:DriverStrategy, ; DIS_strategy mask DA_HAS_EXTENDED_INFO, ; DIS_driverAttributes DRIVER_TYPE_PRINTER ; DIS_driverType >, handle DriverInfo ; DEIS_resource > public DriverTable idata ends ;------------------------------------------------------------------------------ ; Entry Code ;------------------------------------------------------------------------------ Entry segment resource ; MODULE_FIXED include printcomEntry.asm ; entry point, misc bookeeping routines include printcomInfo.asm ; various info getting/setting routines include printcomAdmin.asm ; misc init routines include printcomTables.asm ; module jump table for driver calls include printcomNoEscapes.asm ; module jump table for driver escape calls Entry ends ;------------------------------------------------------------------------------ ; Driver code ;------------------------------------------------------------------------------ CommonCode segment resource ; MODULE_STANDARD include printcomEpsonJob.asm ; StartJob/EndJob/SetPaperpath routines include printcomCountryDialog.asm ; code to implement UI setting include printcomDotMatrixPage.asm ; code to implement Page routines include printcomEpsonLQText.asm ; common code to implement text routines include printcomEpsonStyles.asm ; code to implement Style setting routines include printcomStream.asm ; code to talk with the stream driver include printcomDotMatrixBuffer.asm ; code to deal with graphic print buffers include printcomEpsonColor.asm ; code to implement Color routines include printcomEpsonLQ1Graphics.asm ; common Epson specific graphics routines include printcomEpsonLQ1Cursor.asm ; code to implement Cursor routines include epson24ControlCodes.asm ; Escape and control codes CommonCode ends ;------------------------------------------------------------------------------ ; Device Info Resources (each in their own resource) ;------------------------------------------------------------------------------ include epson24zDriverInfo.asm ; overall driver info include epson24lq800Info.asm ; specific info for LQ-800 printer include epson24lq1000Info.asm ; specific info for LQ-1000 printer include epson24lq2500Info.asm ; specific info for LQ-2500 printer include Color/Correct/correctInk.asm ; color correction table end
_cat: file format elf32-i386 Disassembly of section .text: 00000000 <cat>: char buf[512]; void cat(int fd) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 18 sub $0x18,%esp int n; while((n = read(fd, buf, sizeof(buf))) > 0) 6: eb 15 jmp 1d <cat+0x1d> write(1, buf, n); 8: 83 ec 04 sub $0x4,%esp b: ff 75 f4 pushl -0xc(%ebp) e: 68 00 0c 00 00 push $0xc00 13: 6a 01 push $0x1 15: e8 b1 03 00 00 call 3cb <write> 1a: 83 c4 10 add $0x10,%esp void cat(int fd) { int n; while((n = read(fd, buf, sizeof(buf))) > 0) 1d: 83 ec 04 sub $0x4,%esp 20: 68 00 02 00 00 push $0x200 25: 68 00 0c 00 00 push $0xc00 2a: ff 75 08 pushl 0x8(%ebp) 2d: e8 91 03 00 00 call 3c3 <read> 32: 83 c4 10 add $0x10,%esp 35: 89 45 f4 mov %eax,-0xc(%ebp) 38: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3c: 7f ca jg 8 <cat+0x8> write(1, buf, n); if(n < 0){ 3e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 42: 79 17 jns 5b <cat+0x5b> printf(1, "cat: read error\n"); 44: 83 ec 08 sub $0x8,%esp 47: 68 18 09 00 00 push $0x918 4c: 6a 01 push $0x1 4e: e8 0f 05 00 00 call 562 <printf> 53: 83 c4 10 add $0x10,%esp exit(); 56: e8 50 03 00 00 call 3ab <exit> } } 5b: 90 nop 5c: c9 leave 5d: c3 ret 0000005e <main>: int main(int argc, char *argv[]) { 5e: 8d 4c 24 04 lea 0x4(%esp),%ecx 62: 83 e4 f0 and $0xfffffff0,%esp 65: ff 71 fc pushl -0x4(%ecx) 68: 55 push %ebp 69: 89 e5 mov %esp,%ebp 6b: 53 push %ebx 6c: 51 push %ecx 6d: 83 ec 10 sub $0x10,%esp 70: 89 cb mov %ecx,%ebx int fd, i; if(argc <= 1){ 72: 83 3b 01 cmpl $0x1,(%ebx) 75: 7f 12 jg 89 <main+0x2b> cat(0); 77: 83 ec 0c sub $0xc,%esp 7a: 6a 00 push $0x0 7c: e8 7f ff ff ff call 0 <cat> 81: 83 c4 10 add $0x10,%esp exit(); 84: e8 22 03 00 00 call 3ab <exit> } for(i = 1; i < argc; i++){ 89: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) 90: eb 71 jmp 103 <main+0xa5> if((fd = open(argv[i], 0)) < 0){ 92: 8b 45 f4 mov -0xc(%ebp),%eax 95: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 9c: 8b 43 04 mov 0x4(%ebx),%eax 9f: 01 d0 add %edx,%eax a1: 8b 00 mov (%eax),%eax a3: 83 ec 08 sub $0x8,%esp a6: 6a 00 push $0x0 a8: 50 push %eax a9: e8 3d 03 00 00 call 3eb <open> ae: 83 c4 10 add $0x10,%esp b1: 89 45 f0 mov %eax,-0x10(%ebp) b4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) b8: 79 29 jns e3 <main+0x85> printf(1, "cat: cannot open %s\n", argv[i]); ba: 8b 45 f4 mov -0xc(%ebp),%eax bd: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx c4: 8b 43 04 mov 0x4(%ebx),%eax c7: 01 d0 add %edx,%eax c9: 8b 00 mov (%eax),%eax cb: 83 ec 04 sub $0x4,%esp ce: 50 push %eax cf: 68 29 09 00 00 push $0x929 d4: 6a 01 push $0x1 d6: e8 87 04 00 00 call 562 <printf> db: 83 c4 10 add $0x10,%esp exit(); de: e8 c8 02 00 00 call 3ab <exit> } cat(fd); e3: 83 ec 0c sub $0xc,%esp e6: ff 75 f0 pushl -0x10(%ebp) e9: e8 12 ff ff ff call 0 <cat> ee: 83 c4 10 add $0x10,%esp close(fd); f1: 83 ec 0c sub $0xc,%esp f4: ff 75 f0 pushl -0x10(%ebp) f7: e8 d7 02 00 00 call 3d3 <close> fc: 83 c4 10 add $0x10,%esp if(argc <= 1){ cat(0); exit(); } for(i = 1; i < argc; i++){ ff: 83 45 f4 01 addl $0x1,-0xc(%ebp) 103: 8b 45 f4 mov -0xc(%ebp),%eax 106: 3b 03 cmp (%ebx),%eax 108: 7c 88 jl 92 <main+0x34> exit(); } cat(fd); close(fd); } exit(); 10a: e8 9c 02 00 00 call 3ab <exit> 0000010f <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 10f: 55 push %ebp 110: 89 e5 mov %esp,%ebp 112: 57 push %edi 113: 53 push %ebx asm volatile("cld; rep stosb" : 114: 8b 4d 08 mov 0x8(%ebp),%ecx 117: 8b 55 10 mov 0x10(%ebp),%edx 11a: 8b 45 0c mov 0xc(%ebp),%eax 11d: 89 cb mov %ecx,%ebx 11f: 89 df mov %ebx,%edi 121: 89 d1 mov %edx,%ecx 123: fc cld 124: f3 aa rep stos %al,%es:(%edi) 126: 89 ca mov %ecx,%edx 128: 89 fb mov %edi,%ebx 12a: 89 5d 08 mov %ebx,0x8(%ebp) 12d: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 130: 90 nop 131: 5b pop %ebx 132: 5f pop %edi 133: 5d pop %ebp 134: c3 ret 00000135 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 135: 55 push %ebp 136: 89 e5 mov %esp,%ebp 138: 83 ec 10 sub $0x10,%esp char *os; os = s; 13b: 8b 45 08 mov 0x8(%ebp),%eax 13e: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 141: 90 nop 142: 8b 45 08 mov 0x8(%ebp),%eax 145: 8d 50 01 lea 0x1(%eax),%edx 148: 89 55 08 mov %edx,0x8(%ebp) 14b: 8b 55 0c mov 0xc(%ebp),%edx 14e: 8d 4a 01 lea 0x1(%edx),%ecx 151: 89 4d 0c mov %ecx,0xc(%ebp) 154: 0f b6 12 movzbl (%edx),%edx 157: 88 10 mov %dl,(%eax) 159: 0f b6 00 movzbl (%eax),%eax 15c: 84 c0 test %al,%al 15e: 75 e2 jne 142 <strcpy+0xd> ; return os; 160: 8b 45 fc mov -0x4(%ebp),%eax } 163: c9 leave 164: c3 ret 00000165 <strcmp>: int strcmp(const char *p, const char *q) { 165: 55 push %ebp 166: 89 e5 mov %esp,%ebp while(*p && *p == *q) 168: eb 08 jmp 172 <strcmp+0xd> p++, q++; 16a: 83 45 08 01 addl $0x1,0x8(%ebp) 16e: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 172: 8b 45 08 mov 0x8(%ebp),%eax 175: 0f b6 00 movzbl (%eax),%eax 178: 84 c0 test %al,%al 17a: 74 10 je 18c <strcmp+0x27> 17c: 8b 45 08 mov 0x8(%ebp),%eax 17f: 0f b6 10 movzbl (%eax),%edx 182: 8b 45 0c mov 0xc(%ebp),%eax 185: 0f b6 00 movzbl (%eax),%eax 188: 38 c2 cmp %al,%dl 18a: 74 de je 16a <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 18c: 8b 45 08 mov 0x8(%ebp),%eax 18f: 0f b6 00 movzbl (%eax),%eax 192: 0f b6 d0 movzbl %al,%edx 195: 8b 45 0c mov 0xc(%ebp),%eax 198: 0f b6 00 movzbl (%eax),%eax 19b: 0f b6 c0 movzbl %al,%eax 19e: 29 c2 sub %eax,%edx 1a0: 89 d0 mov %edx,%eax } 1a2: 5d pop %ebp 1a3: c3 ret 000001a4 <strlen>: uint strlen(char *s) { 1a4: 55 push %ebp 1a5: 89 e5 mov %esp,%ebp 1a7: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 1aa: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 1b1: eb 04 jmp 1b7 <strlen+0x13> 1b3: 83 45 fc 01 addl $0x1,-0x4(%ebp) 1b7: 8b 55 fc mov -0x4(%ebp),%edx 1ba: 8b 45 08 mov 0x8(%ebp),%eax 1bd: 01 d0 add %edx,%eax 1bf: 0f b6 00 movzbl (%eax),%eax 1c2: 84 c0 test %al,%al 1c4: 75 ed jne 1b3 <strlen+0xf> ; return n; 1c6: 8b 45 fc mov -0x4(%ebp),%eax } 1c9: c9 leave 1ca: c3 ret 000001cb <memset>: void* memset(void *dst, int c, uint n) { 1cb: 55 push %ebp 1cc: 89 e5 mov %esp,%ebp stosb(dst, c, n); 1ce: 8b 45 10 mov 0x10(%ebp),%eax 1d1: 50 push %eax 1d2: ff 75 0c pushl 0xc(%ebp) 1d5: ff 75 08 pushl 0x8(%ebp) 1d8: e8 32 ff ff ff call 10f <stosb> 1dd: 83 c4 0c add $0xc,%esp return dst; 1e0: 8b 45 08 mov 0x8(%ebp),%eax } 1e3: c9 leave 1e4: c3 ret 000001e5 <strchr>: char* strchr(const char *s, char c) { 1e5: 55 push %ebp 1e6: 89 e5 mov %esp,%ebp 1e8: 83 ec 04 sub $0x4,%esp 1eb: 8b 45 0c mov 0xc(%ebp),%eax 1ee: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 1f1: eb 14 jmp 207 <strchr+0x22> if(*s == c) 1f3: 8b 45 08 mov 0x8(%ebp),%eax 1f6: 0f b6 00 movzbl (%eax),%eax 1f9: 3a 45 fc cmp -0x4(%ebp),%al 1fc: 75 05 jne 203 <strchr+0x1e> return (char*)s; 1fe: 8b 45 08 mov 0x8(%ebp),%eax 201: eb 13 jmp 216 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 203: 83 45 08 01 addl $0x1,0x8(%ebp) 207: 8b 45 08 mov 0x8(%ebp),%eax 20a: 0f b6 00 movzbl (%eax),%eax 20d: 84 c0 test %al,%al 20f: 75 e2 jne 1f3 <strchr+0xe> if(*s == c) return (char*)s; return 0; 211: b8 00 00 00 00 mov $0x0,%eax } 216: c9 leave 217: c3 ret 00000218 <gets>: char* gets(char *buf, int max) { 218: 55 push %ebp 219: 89 e5 mov %esp,%ebp 21b: 83 ec 18 sub $0x18,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 21e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 225: eb 42 jmp 269 <gets+0x51> cc = read(0, &c, 1); 227: 83 ec 04 sub $0x4,%esp 22a: 6a 01 push $0x1 22c: 8d 45 ef lea -0x11(%ebp),%eax 22f: 50 push %eax 230: 6a 00 push $0x0 232: e8 8c 01 00 00 call 3c3 <read> 237: 83 c4 10 add $0x10,%esp 23a: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 23d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 241: 7e 33 jle 276 <gets+0x5e> break; buf[i++] = c; 243: 8b 45 f4 mov -0xc(%ebp),%eax 246: 8d 50 01 lea 0x1(%eax),%edx 249: 89 55 f4 mov %edx,-0xc(%ebp) 24c: 89 c2 mov %eax,%edx 24e: 8b 45 08 mov 0x8(%ebp),%eax 251: 01 c2 add %eax,%edx 253: 0f b6 45 ef movzbl -0x11(%ebp),%eax 257: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 259: 0f b6 45 ef movzbl -0x11(%ebp),%eax 25d: 3c 0a cmp $0xa,%al 25f: 74 16 je 277 <gets+0x5f> 261: 0f b6 45 ef movzbl -0x11(%ebp),%eax 265: 3c 0d cmp $0xd,%al 267: 74 0e je 277 <gets+0x5f> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 269: 8b 45 f4 mov -0xc(%ebp),%eax 26c: 83 c0 01 add $0x1,%eax 26f: 3b 45 0c cmp 0xc(%ebp),%eax 272: 7c b3 jl 227 <gets+0xf> 274: eb 01 jmp 277 <gets+0x5f> cc = read(0, &c, 1); if(cc < 1) break; 276: 90 nop buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 277: 8b 55 f4 mov -0xc(%ebp),%edx 27a: 8b 45 08 mov 0x8(%ebp),%eax 27d: 01 d0 add %edx,%eax 27f: c6 00 00 movb $0x0,(%eax) return buf; 282: 8b 45 08 mov 0x8(%ebp),%eax } 285: c9 leave 286: c3 ret 00000287 <stat>: int stat(char *n, struct stat *st) { 287: 55 push %ebp 288: 89 e5 mov %esp,%ebp 28a: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 28d: 83 ec 08 sub $0x8,%esp 290: 6a 00 push $0x0 292: ff 75 08 pushl 0x8(%ebp) 295: e8 51 01 00 00 call 3eb <open> 29a: 83 c4 10 add $0x10,%esp 29d: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 2a0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2a4: 79 07 jns 2ad <stat+0x26> return -1; 2a6: b8 ff ff ff ff mov $0xffffffff,%eax 2ab: eb 25 jmp 2d2 <stat+0x4b> r = fstat(fd, st); 2ad: 83 ec 08 sub $0x8,%esp 2b0: ff 75 0c pushl 0xc(%ebp) 2b3: ff 75 f4 pushl -0xc(%ebp) 2b6: e8 48 01 00 00 call 403 <fstat> 2bb: 83 c4 10 add $0x10,%esp 2be: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 2c1: 83 ec 0c sub $0xc,%esp 2c4: ff 75 f4 pushl -0xc(%ebp) 2c7: e8 07 01 00 00 call 3d3 <close> 2cc: 83 c4 10 add $0x10,%esp return r; 2cf: 8b 45 f0 mov -0x10(%ebp),%eax } 2d2: c9 leave 2d3: c3 ret 000002d4 <atoi>: // new atoi added 4/22/17 to be able to handle negative numbers int atoi(const char *s) { 2d4: 55 push %ebp 2d5: 89 e5 mov %esp,%ebp 2d7: 83 ec 10 sub $0x10,%esp int n, sign; n=0; 2da: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while(*s==' ')s++;//Remove leading spaces 2e1: eb 04 jmp 2e7 <atoi+0x13> 2e3: 83 45 08 01 addl $0x1,0x8(%ebp) 2e7: 8b 45 08 mov 0x8(%ebp),%eax 2ea: 0f b6 00 movzbl (%eax),%eax 2ed: 3c 20 cmp $0x20,%al 2ef: 74 f2 je 2e3 <atoi+0xf> sign =(*s=='-')?-1 : 1; 2f1: 8b 45 08 mov 0x8(%ebp),%eax 2f4: 0f b6 00 movzbl (%eax),%eax 2f7: 3c 2d cmp $0x2d,%al 2f9: 75 07 jne 302 <atoi+0x2e> 2fb: b8 ff ff ff ff mov $0xffffffff,%eax 300: eb 05 jmp 307 <atoi+0x33> 302: b8 01 00 00 00 mov $0x1,%eax 307: 89 45 f8 mov %eax,-0x8(%ebp) if(*s=='+' || *s=='-') 30a: 8b 45 08 mov 0x8(%ebp),%eax 30d: 0f b6 00 movzbl (%eax),%eax 310: 3c 2b cmp $0x2b,%al 312: 74 0a je 31e <atoi+0x4a> 314: 8b 45 08 mov 0x8(%ebp),%eax 317: 0f b6 00 movzbl (%eax),%eax 31a: 3c 2d cmp $0x2d,%al 31c: 75 2b jne 349 <atoi+0x75> s++; 31e: 83 45 08 01 addl $0x1,0x8(%ebp) while('0' <= *s&&*s<='9') 322: eb 25 jmp 349 <atoi+0x75> n = n*10 + *s++ - '0'; 324: 8b 55 fc mov -0x4(%ebp),%edx 327: 89 d0 mov %edx,%eax 329: c1 e0 02 shl $0x2,%eax 32c: 01 d0 add %edx,%eax 32e: 01 c0 add %eax,%eax 330: 89 c1 mov %eax,%ecx 332: 8b 45 08 mov 0x8(%ebp),%eax 335: 8d 50 01 lea 0x1(%eax),%edx 338: 89 55 08 mov %edx,0x8(%ebp) 33b: 0f b6 00 movzbl (%eax),%eax 33e: 0f be c0 movsbl %al,%eax 341: 01 c8 add %ecx,%eax 343: 83 e8 30 sub $0x30,%eax 346: 89 45 fc mov %eax,-0x4(%ebp) n=0; while(*s==' ')s++;//Remove leading spaces sign =(*s=='-')?-1 : 1; if(*s=='+' || *s=='-') s++; while('0' <= *s&&*s<='9') 349: 8b 45 08 mov 0x8(%ebp),%eax 34c: 0f b6 00 movzbl (%eax),%eax 34f: 3c 2f cmp $0x2f,%al 351: 7e 0a jle 35d <atoi+0x89> 353: 8b 45 08 mov 0x8(%ebp),%eax 356: 0f b6 00 movzbl (%eax),%eax 359: 3c 39 cmp $0x39,%al 35b: 7e c7 jle 324 <atoi+0x50> n = n*10 + *s++ - '0'; return sign*n; 35d: 8b 45 f8 mov -0x8(%ebp),%eax 360: 0f af 45 fc imul -0x4(%ebp),%eax } 364: c9 leave 365: c3 ret 00000366 <memmove>: return n; } */ void* memmove(void *vdst, void *vsrc, int n) { 366: 55 push %ebp 367: 89 e5 mov %esp,%ebp 369: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 36c: 8b 45 08 mov 0x8(%ebp),%eax 36f: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 372: 8b 45 0c mov 0xc(%ebp),%eax 375: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 378: eb 17 jmp 391 <memmove+0x2b> *dst++ = *src++; 37a: 8b 45 fc mov -0x4(%ebp),%eax 37d: 8d 50 01 lea 0x1(%eax),%edx 380: 89 55 fc mov %edx,-0x4(%ebp) 383: 8b 55 f8 mov -0x8(%ebp),%edx 386: 8d 4a 01 lea 0x1(%edx),%ecx 389: 89 4d f8 mov %ecx,-0x8(%ebp) 38c: 0f b6 12 movzbl (%edx),%edx 38f: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 391: 8b 45 10 mov 0x10(%ebp),%eax 394: 8d 50 ff lea -0x1(%eax),%edx 397: 89 55 10 mov %edx,0x10(%ebp) 39a: 85 c0 test %eax,%eax 39c: 7f dc jg 37a <memmove+0x14> *dst++ = *src++; return vdst; 39e: 8b 45 08 mov 0x8(%ebp),%eax } 3a1: c9 leave 3a2: c3 ret 000003a3 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3a3: b8 01 00 00 00 mov $0x1,%eax 3a8: cd 40 int $0x40 3aa: c3 ret 000003ab <exit>: SYSCALL(exit) 3ab: b8 02 00 00 00 mov $0x2,%eax 3b0: cd 40 int $0x40 3b2: c3 ret 000003b3 <wait>: SYSCALL(wait) 3b3: b8 03 00 00 00 mov $0x3,%eax 3b8: cd 40 int $0x40 3ba: c3 ret 000003bb <pipe>: SYSCALL(pipe) 3bb: b8 04 00 00 00 mov $0x4,%eax 3c0: cd 40 int $0x40 3c2: c3 ret 000003c3 <read>: SYSCALL(read) 3c3: b8 05 00 00 00 mov $0x5,%eax 3c8: cd 40 int $0x40 3ca: c3 ret 000003cb <write>: SYSCALL(write) 3cb: b8 10 00 00 00 mov $0x10,%eax 3d0: cd 40 int $0x40 3d2: c3 ret 000003d3 <close>: SYSCALL(close) 3d3: b8 15 00 00 00 mov $0x15,%eax 3d8: cd 40 int $0x40 3da: c3 ret 000003db <kill>: SYSCALL(kill) 3db: b8 06 00 00 00 mov $0x6,%eax 3e0: cd 40 int $0x40 3e2: c3 ret 000003e3 <exec>: SYSCALL(exec) 3e3: b8 07 00 00 00 mov $0x7,%eax 3e8: cd 40 int $0x40 3ea: c3 ret 000003eb <open>: SYSCALL(open) 3eb: b8 0f 00 00 00 mov $0xf,%eax 3f0: cd 40 int $0x40 3f2: c3 ret 000003f3 <mknod>: SYSCALL(mknod) 3f3: b8 11 00 00 00 mov $0x11,%eax 3f8: cd 40 int $0x40 3fa: c3 ret 000003fb <unlink>: SYSCALL(unlink) 3fb: b8 12 00 00 00 mov $0x12,%eax 400: cd 40 int $0x40 402: c3 ret 00000403 <fstat>: SYSCALL(fstat) 403: b8 08 00 00 00 mov $0x8,%eax 408: cd 40 int $0x40 40a: c3 ret 0000040b <link>: SYSCALL(link) 40b: b8 13 00 00 00 mov $0x13,%eax 410: cd 40 int $0x40 412: c3 ret 00000413 <mkdir>: SYSCALL(mkdir) 413: b8 14 00 00 00 mov $0x14,%eax 418: cd 40 int $0x40 41a: c3 ret 0000041b <chdir>: SYSCALL(chdir) 41b: b8 09 00 00 00 mov $0x9,%eax 420: cd 40 int $0x40 422: c3 ret 00000423 <dup>: SYSCALL(dup) 423: b8 0a 00 00 00 mov $0xa,%eax 428: cd 40 int $0x40 42a: c3 ret 0000042b <getpid>: SYSCALL(getpid) 42b: b8 0b 00 00 00 mov $0xb,%eax 430: cd 40 int $0x40 432: c3 ret 00000433 <sbrk>: SYSCALL(sbrk) 433: b8 0c 00 00 00 mov $0xc,%eax 438: cd 40 int $0x40 43a: c3 ret 0000043b <sleep>: SYSCALL(sleep) 43b: b8 0d 00 00 00 mov $0xd,%eax 440: cd 40 int $0x40 442: c3 ret 00000443 <uptime>: SYSCALL(uptime) 443: b8 0e 00 00 00 mov $0xe,%eax 448: cd 40 int $0x40 44a: c3 ret 0000044b <halt>: SYSCALL(halt) 44b: b8 16 00 00 00 mov $0x16,%eax 450: cd 40 int $0x40 452: c3 ret 00000453 <date>: //Project additions SYSCALL(date) 453: b8 17 00 00 00 mov $0x17,%eax 458: cd 40 int $0x40 45a: c3 ret 0000045b <getuid>: SYSCALL(getuid) 45b: b8 18 00 00 00 mov $0x18,%eax 460: cd 40 int $0x40 462: c3 ret 00000463 <getgid>: SYSCALL(getgid) 463: b8 19 00 00 00 mov $0x19,%eax 468: cd 40 int $0x40 46a: c3 ret 0000046b <getppid>: SYSCALL(getppid) 46b: b8 1a 00 00 00 mov $0x1a,%eax 470: cd 40 int $0x40 472: c3 ret 00000473 <setuid>: SYSCALL(setuid) 473: b8 1b 00 00 00 mov $0x1b,%eax 478: cd 40 int $0x40 47a: c3 ret 0000047b <setgid>: SYSCALL(setgid) 47b: b8 1c 00 00 00 mov $0x1c,%eax 480: cd 40 int $0x40 482: c3 ret 00000483 <getprocs>: SYSCALL(getprocs) 483: b8 1d 00 00 00 mov $0x1d,%eax 488: cd 40 int $0x40 48a: c3 ret 0000048b <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 48b: 55 push %ebp 48c: 89 e5 mov %esp,%ebp 48e: 83 ec 18 sub $0x18,%esp 491: 8b 45 0c mov 0xc(%ebp),%eax 494: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 497: 83 ec 04 sub $0x4,%esp 49a: 6a 01 push $0x1 49c: 8d 45 f4 lea -0xc(%ebp),%eax 49f: 50 push %eax 4a0: ff 75 08 pushl 0x8(%ebp) 4a3: e8 23 ff ff ff call 3cb <write> 4a8: 83 c4 10 add $0x10,%esp } 4ab: 90 nop 4ac: c9 leave 4ad: c3 ret 000004ae <printint>: static void printint(int fd, int xx, int base, int sgn) { 4ae: 55 push %ebp 4af: 89 e5 mov %esp,%ebp 4b1: 53 push %ebx 4b2: 83 ec 24 sub $0x24,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 4b5: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 4bc: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 4c0: 74 17 je 4d9 <printint+0x2b> 4c2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 4c6: 79 11 jns 4d9 <printint+0x2b> neg = 1; 4c8: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 4cf: 8b 45 0c mov 0xc(%ebp),%eax 4d2: f7 d8 neg %eax 4d4: 89 45 ec mov %eax,-0x14(%ebp) 4d7: eb 06 jmp 4df <printint+0x31> } else { x = xx; 4d9: 8b 45 0c mov 0xc(%ebp),%eax 4dc: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 4df: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 4e6: 8b 4d f4 mov -0xc(%ebp),%ecx 4e9: 8d 41 01 lea 0x1(%ecx),%eax 4ec: 89 45 f4 mov %eax,-0xc(%ebp) 4ef: 8b 5d 10 mov 0x10(%ebp),%ebx 4f2: 8b 45 ec mov -0x14(%ebp),%eax 4f5: ba 00 00 00 00 mov $0x0,%edx 4fa: f7 f3 div %ebx 4fc: 89 d0 mov %edx,%eax 4fe: 0f b6 80 b4 0b 00 00 movzbl 0xbb4(%eax),%eax 505: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 509: 8b 5d 10 mov 0x10(%ebp),%ebx 50c: 8b 45 ec mov -0x14(%ebp),%eax 50f: ba 00 00 00 00 mov $0x0,%edx 514: f7 f3 div %ebx 516: 89 45 ec mov %eax,-0x14(%ebp) 519: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 51d: 75 c7 jne 4e6 <printint+0x38> if(neg) 51f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 523: 74 2d je 552 <printint+0xa4> buf[i++] = '-'; 525: 8b 45 f4 mov -0xc(%ebp),%eax 528: 8d 50 01 lea 0x1(%eax),%edx 52b: 89 55 f4 mov %edx,-0xc(%ebp) 52e: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 533: eb 1d jmp 552 <printint+0xa4> putc(fd, buf[i]); 535: 8d 55 dc lea -0x24(%ebp),%edx 538: 8b 45 f4 mov -0xc(%ebp),%eax 53b: 01 d0 add %edx,%eax 53d: 0f b6 00 movzbl (%eax),%eax 540: 0f be c0 movsbl %al,%eax 543: 83 ec 08 sub $0x8,%esp 546: 50 push %eax 547: ff 75 08 pushl 0x8(%ebp) 54a: e8 3c ff ff ff call 48b <putc> 54f: 83 c4 10 add $0x10,%esp buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 552: 83 6d f4 01 subl $0x1,-0xc(%ebp) 556: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 55a: 79 d9 jns 535 <printint+0x87> putc(fd, buf[i]); } 55c: 90 nop 55d: 8b 5d fc mov -0x4(%ebp),%ebx 560: c9 leave 561: c3 ret 00000562 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 562: 55 push %ebp 563: 89 e5 mov %esp,%ebp 565: 83 ec 28 sub $0x28,%esp char *s; int c, i, state; uint *ap; state = 0; 568: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 56f: 8d 45 0c lea 0xc(%ebp),%eax 572: 83 c0 04 add $0x4,%eax 575: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 578: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 57f: e9 59 01 00 00 jmp 6dd <printf+0x17b> c = fmt[i] & 0xff; 584: 8b 55 0c mov 0xc(%ebp),%edx 587: 8b 45 f0 mov -0x10(%ebp),%eax 58a: 01 d0 add %edx,%eax 58c: 0f b6 00 movzbl (%eax),%eax 58f: 0f be c0 movsbl %al,%eax 592: 25 ff 00 00 00 and $0xff,%eax 597: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 59a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 59e: 75 2c jne 5cc <printf+0x6a> if(c == '%'){ 5a0: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 5a4: 75 0c jne 5b2 <printf+0x50> state = '%'; 5a6: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 5ad: e9 27 01 00 00 jmp 6d9 <printf+0x177> } else { putc(fd, c); 5b2: 8b 45 e4 mov -0x1c(%ebp),%eax 5b5: 0f be c0 movsbl %al,%eax 5b8: 83 ec 08 sub $0x8,%esp 5bb: 50 push %eax 5bc: ff 75 08 pushl 0x8(%ebp) 5bf: e8 c7 fe ff ff call 48b <putc> 5c4: 83 c4 10 add $0x10,%esp 5c7: e9 0d 01 00 00 jmp 6d9 <printf+0x177> } } else if(state == '%'){ 5cc: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 5d0: 0f 85 03 01 00 00 jne 6d9 <printf+0x177> if(c == 'd'){ 5d6: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 5da: 75 1e jne 5fa <printf+0x98> printint(fd, *ap, 10, 1); 5dc: 8b 45 e8 mov -0x18(%ebp),%eax 5df: 8b 00 mov (%eax),%eax 5e1: 6a 01 push $0x1 5e3: 6a 0a push $0xa 5e5: 50 push %eax 5e6: ff 75 08 pushl 0x8(%ebp) 5e9: e8 c0 fe ff ff call 4ae <printint> 5ee: 83 c4 10 add $0x10,%esp ap++; 5f1: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5f5: e9 d8 00 00 00 jmp 6d2 <printf+0x170> } else if(c == 'x' || c == 'p'){ 5fa: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 5fe: 74 06 je 606 <printf+0xa4> 600: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 604: 75 1e jne 624 <printf+0xc2> printint(fd, *ap, 16, 0); 606: 8b 45 e8 mov -0x18(%ebp),%eax 609: 8b 00 mov (%eax),%eax 60b: 6a 00 push $0x0 60d: 6a 10 push $0x10 60f: 50 push %eax 610: ff 75 08 pushl 0x8(%ebp) 613: e8 96 fe ff ff call 4ae <printint> 618: 83 c4 10 add $0x10,%esp ap++; 61b: 83 45 e8 04 addl $0x4,-0x18(%ebp) 61f: e9 ae 00 00 00 jmp 6d2 <printf+0x170> } else if(c == 's'){ 624: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 628: 75 43 jne 66d <printf+0x10b> s = (char*)*ap; 62a: 8b 45 e8 mov -0x18(%ebp),%eax 62d: 8b 00 mov (%eax),%eax 62f: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 632: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 636: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 63a: 75 25 jne 661 <printf+0xff> s = "(null)"; 63c: c7 45 f4 3e 09 00 00 movl $0x93e,-0xc(%ebp) while(*s != 0){ 643: eb 1c jmp 661 <printf+0xff> putc(fd, *s); 645: 8b 45 f4 mov -0xc(%ebp),%eax 648: 0f b6 00 movzbl (%eax),%eax 64b: 0f be c0 movsbl %al,%eax 64e: 83 ec 08 sub $0x8,%esp 651: 50 push %eax 652: ff 75 08 pushl 0x8(%ebp) 655: e8 31 fe ff ff call 48b <putc> 65a: 83 c4 10 add $0x10,%esp s++; 65d: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 661: 8b 45 f4 mov -0xc(%ebp),%eax 664: 0f b6 00 movzbl (%eax),%eax 667: 84 c0 test %al,%al 669: 75 da jne 645 <printf+0xe3> 66b: eb 65 jmp 6d2 <printf+0x170> putc(fd, *s); s++; } } else if(c == 'c'){ 66d: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 671: 75 1d jne 690 <printf+0x12e> putc(fd, *ap); 673: 8b 45 e8 mov -0x18(%ebp),%eax 676: 8b 00 mov (%eax),%eax 678: 0f be c0 movsbl %al,%eax 67b: 83 ec 08 sub $0x8,%esp 67e: 50 push %eax 67f: ff 75 08 pushl 0x8(%ebp) 682: e8 04 fe ff ff call 48b <putc> 687: 83 c4 10 add $0x10,%esp ap++; 68a: 83 45 e8 04 addl $0x4,-0x18(%ebp) 68e: eb 42 jmp 6d2 <printf+0x170> } else if(c == '%'){ 690: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 694: 75 17 jne 6ad <printf+0x14b> putc(fd, c); 696: 8b 45 e4 mov -0x1c(%ebp),%eax 699: 0f be c0 movsbl %al,%eax 69c: 83 ec 08 sub $0x8,%esp 69f: 50 push %eax 6a0: ff 75 08 pushl 0x8(%ebp) 6a3: e8 e3 fd ff ff call 48b <putc> 6a8: 83 c4 10 add $0x10,%esp 6ab: eb 25 jmp 6d2 <printf+0x170> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 6ad: 83 ec 08 sub $0x8,%esp 6b0: 6a 25 push $0x25 6b2: ff 75 08 pushl 0x8(%ebp) 6b5: e8 d1 fd ff ff call 48b <putc> 6ba: 83 c4 10 add $0x10,%esp putc(fd, c); 6bd: 8b 45 e4 mov -0x1c(%ebp),%eax 6c0: 0f be c0 movsbl %al,%eax 6c3: 83 ec 08 sub $0x8,%esp 6c6: 50 push %eax 6c7: ff 75 08 pushl 0x8(%ebp) 6ca: e8 bc fd ff ff call 48b <putc> 6cf: 83 c4 10 add $0x10,%esp } state = 0; 6d2: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6d9: 83 45 f0 01 addl $0x1,-0x10(%ebp) 6dd: 8b 55 0c mov 0xc(%ebp),%edx 6e0: 8b 45 f0 mov -0x10(%ebp),%eax 6e3: 01 d0 add %edx,%eax 6e5: 0f b6 00 movzbl (%eax),%eax 6e8: 84 c0 test %al,%al 6ea: 0f 85 94 fe ff ff jne 584 <printf+0x22> putc(fd, c); } state = 0; } } } 6f0: 90 nop 6f1: c9 leave 6f2: c3 ret 000006f3 <free>: static Header base; static Header *freep; void free(void *ap) { 6f3: 55 push %ebp 6f4: 89 e5 mov %esp,%ebp 6f6: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 6f9: 8b 45 08 mov 0x8(%ebp),%eax 6fc: 83 e8 08 sub $0x8,%eax 6ff: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 702: a1 e8 0b 00 00 mov 0xbe8,%eax 707: 89 45 fc mov %eax,-0x4(%ebp) 70a: eb 24 jmp 730 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 70c: 8b 45 fc mov -0x4(%ebp),%eax 70f: 8b 00 mov (%eax),%eax 711: 3b 45 fc cmp -0x4(%ebp),%eax 714: 77 12 ja 728 <free+0x35> 716: 8b 45 f8 mov -0x8(%ebp),%eax 719: 3b 45 fc cmp -0x4(%ebp),%eax 71c: 77 24 ja 742 <free+0x4f> 71e: 8b 45 fc mov -0x4(%ebp),%eax 721: 8b 00 mov (%eax),%eax 723: 3b 45 f8 cmp -0x8(%ebp),%eax 726: 77 1a ja 742 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 728: 8b 45 fc mov -0x4(%ebp),%eax 72b: 8b 00 mov (%eax),%eax 72d: 89 45 fc mov %eax,-0x4(%ebp) 730: 8b 45 f8 mov -0x8(%ebp),%eax 733: 3b 45 fc cmp -0x4(%ebp),%eax 736: 76 d4 jbe 70c <free+0x19> 738: 8b 45 fc mov -0x4(%ebp),%eax 73b: 8b 00 mov (%eax),%eax 73d: 3b 45 f8 cmp -0x8(%ebp),%eax 740: 76 ca jbe 70c <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 742: 8b 45 f8 mov -0x8(%ebp),%eax 745: 8b 40 04 mov 0x4(%eax),%eax 748: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 74f: 8b 45 f8 mov -0x8(%ebp),%eax 752: 01 c2 add %eax,%edx 754: 8b 45 fc mov -0x4(%ebp),%eax 757: 8b 00 mov (%eax),%eax 759: 39 c2 cmp %eax,%edx 75b: 75 24 jne 781 <free+0x8e> bp->s.size += p->s.ptr->s.size; 75d: 8b 45 f8 mov -0x8(%ebp),%eax 760: 8b 50 04 mov 0x4(%eax),%edx 763: 8b 45 fc mov -0x4(%ebp),%eax 766: 8b 00 mov (%eax),%eax 768: 8b 40 04 mov 0x4(%eax),%eax 76b: 01 c2 add %eax,%edx 76d: 8b 45 f8 mov -0x8(%ebp),%eax 770: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 773: 8b 45 fc mov -0x4(%ebp),%eax 776: 8b 00 mov (%eax),%eax 778: 8b 10 mov (%eax),%edx 77a: 8b 45 f8 mov -0x8(%ebp),%eax 77d: 89 10 mov %edx,(%eax) 77f: eb 0a jmp 78b <free+0x98> } else bp->s.ptr = p->s.ptr; 781: 8b 45 fc mov -0x4(%ebp),%eax 784: 8b 10 mov (%eax),%edx 786: 8b 45 f8 mov -0x8(%ebp),%eax 789: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 78b: 8b 45 fc mov -0x4(%ebp),%eax 78e: 8b 40 04 mov 0x4(%eax),%eax 791: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 798: 8b 45 fc mov -0x4(%ebp),%eax 79b: 01 d0 add %edx,%eax 79d: 3b 45 f8 cmp -0x8(%ebp),%eax 7a0: 75 20 jne 7c2 <free+0xcf> p->s.size += bp->s.size; 7a2: 8b 45 fc mov -0x4(%ebp),%eax 7a5: 8b 50 04 mov 0x4(%eax),%edx 7a8: 8b 45 f8 mov -0x8(%ebp),%eax 7ab: 8b 40 04 mov 0x4(%eax),%eax 7ae: 01 c2 add %eax,%edx 7b0: 8b 45 fc mov -0x4(%ebp),%eax 7b3: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 7b6: 8b 45 f8 mov -0x8(%ebp),%eax 7b9: 8b 10 mov (%eax),%edx 7bb: 8b 45 fc mov -0x4(%ebp),%eax 7be: 89 10 mov %edx,(%eax) 7c0: eb 08 jmp 7ca <free+0xd7> } else p->s.ptr = bp; 7c2: 8b 45 fc mov -0x4(%ebp),%eax 7c5: 8b 55 f8 mov -0x8(%ebp),%edx 7c8: 89 10 mov %edx,(%eax) freep = p; 7ca: 8b 45 fc mov -0x4(%ebp),%eax 7cd: a3 e8 0b 00 00 mov %eax,0xbe8 } 7d2: 90 nop 7d3: c9 leave 7d4: c3 ret 000007d5 <morecore>: static Header* morecore(uint nu) { 7d5: 55 push %ebp 7d6: 89 e5 mov %esp,%ebp 7d8: 83 ec 18 sub $0x18,%esp char *p; Header *hp; if(nu < 4096) 7db: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 7e2: 77 07 ja 7eb <morecore+0x16> nu = 4096; 7e4: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 7eb: 8b 45 08 mov 0x8(%ebp),%eax 7ee: c1 e0 03 shl $0x3,%eax 7f1: 83 ec 0c sub $0xc,%esp 7f4: 50 push %eax 7f5: e8 39 fc ff ff call 433 <sbrk> 7fa: 83 c4 10 add $0x10,%esp 7fd: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 800: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 804: 75 07 jne 80d <morecore+0x38> return 0; 806: b8 00 00 00 00 mov $0x0,%eax 80b: eb 26 jmp 833 <morecore+0x5e> hp = (Header*)p; 80d: 8b 45 f4 mov -0xc(%ebp),%eax 810: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 813: 8b 45 f0 mov -0x10(%ebp),%eax 816: 8b 55 08 mov 0x8(%ebp),%edx 819: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 81c: 8b 45 f0 mov -0x10(%ebp),%eax 81f: 83 c0 08 add $0x8,%eax 822: 83 ec 0c sub $0xc,%esp 825: 50 push %eax 826: e8 c8 fe ff ff call 6f3 <free> 82b: 83 c4 10 add $0x10,%esp return freep; 82e: a1 e8 0b 00 00 mov 0xbe8,%eax } 833: c9 leave 834: c3 ret 00000835 <malloc>: void* malloc(uint nbytes) { 835: 55 push %ebp 836: 89 e5 mov %esp,%ebp 838: 83 ec 18 sub $0x18,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 83b: 8b 45 08 mov 0x8(%ebp),%eax 83e: 83 c0 07 add $0x7,%eax 841: c1 e8 03 shr $0x3,%eax 844: 83 c0 01 add $0x1,%eax 847: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 84a: a1 e8 0b 00 00 mov 0xbe8,%eax 84f: 89 45 f0 mov %eax,-0x10(%ebp) 852: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 856: 75 23 jne 87b <malloc+0x46> base.s.ptr = freep = prevp = &base; 858: c7 45 f0 e0 0b 00 00 movl $0xbe0,-0x10(%ebp) 85f: 8b 45 f0 mov -0x10(%ebp),%eax 862: a3 e8 0b 00 00 mov %eax,0xbe8 867: a1 e8 0b 00 00 mov 0xbe8,%eax 86c: a3 e0 0b 00 00 mov %eax,0xbe0 base.s.size = 0; 871: c7 05 e4 0b 00 00 00 movl $0x0,0xbe4 878: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 87b: 8b 45 f0 mov -0x10(%ebp),%eax 87e: 8b 00 mov (%eax),%eax 880: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 883: 8b 45 f4 mov -0xc(%ebp),%eax 886: 8b 40 04 mov 0x4(%eax),%eax 889: 3b 45 ec cmp -0x14(%ebp),%eax 88c: 72 4d jb 8db <malloc+0xa6> if(p->s.size == nunits) 88e: 8b 45 f4 mov -0xc(%ebp),%eax 891: 8b 40 04 mov 0x4(%eax),%eax 894: 3b 45 ec cmp -0x14(%ebp),%eax 897: 75 0c jne 8a5 <malloc+0x70> prevp->s.ptr = p->s.ptr; 899: 8b 45 f4 mov -0xc(%ebp),%eax 89c: 8b 10 mov (%eax),%edx 89e: 8b 45 f0 mov -0x10(%ebp),%eax 8a1: 89 10 mov %edx,(%eax) 8a3: eb 26 jmp 8cb <malloc+0x96> else { p->s.size -= nunits; 8a5: 8b 45 f4 mov -0xc(%ebp),%eax 8a8: 8b 40 04 mov 0x4(%eax),%eax 8ab: 2b 45 ec sub -0x14(%ebp),%eax 8ae: 89 c2 mov %eax,%edx 8b0: 8b 45 f4 mov -0xc(%ebp),%eax 8b3: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 8b6: 8b 45 f4 mov -0xc(%ebp),%eax 8b9: 8b 40 04 mov 0x4(%eax),%eax 8bc: c1 e0 03 shl $0x3,%eax 8bf: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 8c2: 8b 45 f4 mov -0xc(%ebp),%eax 8c5: 8b 55 ec mov -0x14(%ebp),%edx 8c8: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 8cb: 8b 45 f0 mov -0x10(%ebp),%eax 8ce: a3 e8 0b 00 00 mov %eax,0xbe8 return (void*)(p + 1); 8d3: 8b 45 f4 mov -0xc(%ebp),%eax 8d6: 83 c0 08 add $0x8,%eax 8d9: eb 3b jmp 916 <malloc+0xe1> } if(p == freep) 8db: a1 e8 0b 00 00 mov 0xbe8,%eax 8e0: 39 45 f4 cmp %eax,-0xc(%ebp) 8e3: 75 1e jne 903 <malloc+0xce> if((p = morecore(nunits)) == 0) 8e5: 83 ec 0c sub $0xc,%esp 8e8: ff 75 ec pushl -0x14(%ebp) 8eb: e8 e5 fe ff ff call 7d5 <morecore> 8f0: 83 c4 10 add $0x10,%esp 8f3: 89 45 f4 mov %eax,-0xc(%ebp) 8f6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8fa: 75 07 jne 903 <malloc+0xce> return 0; 8fc: b8 00 00 00 00 mov $0x0,%eax 901: eb 13 jmp 916 <malloc+0xe1> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 903: 8b 45 f4 mov -0xc(%ebp),%eax 906: 89 45 f0 mov %eax,-0x10(%ebp) 909: 8b 45 f4 mov -0xc(%ebp),%eax 90c: 8b 00 mov (%eax),%eax 90e: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 911: e9 6d ff ff ff jmp 883 <malloc+0x4e> } 916: c9 leave 917: c3 ret
; A022282: a(n) = n*(25*n - 1)/2. ; 0,12,49,111,198,310,447,609,796,1008,1245,1507,1794,2106,2443,2805,3192,3604,4041,4503,4990,5502,6039,6601,7188,7800,8437,9099,9786,10498,11235,11997,12784,13596,14433,15295,16182,17094,18031,18993,19980,20992,22029,23091,24178,25290,26427,27589,28776,29988,31225,32487,33774,35086,36423,37785,39172,40584,42021,43483,44970,46482,48019,49581,51168,52780,54417,56079,57766,59478,61215,62977,64764,66576,68413,70275,72162,74074,76011,77973,79960,81972,84009,86071,88158,90270,92407,94569,96756,98968,101205,103467,105754,108066,110403,112765,115152,117564,120001,122463,124950,127462,129999,132561,135148,137760,140397,143059,145746,148458,151195,153957,156744,159556,162393,165255,168142,171054,173991,176953,179940,182952,185989,189051,192138,195250,198387,201549,204736,207948,211185,214447,217734,221046,224383,227745,231132,234544,237981,241443,244930,248442,251979,255541,259128,262740,266377,270039,273726,277438,281175,284937,288724,292536,296373,300235,304122,308034,311971,315933,319920,323932,327969,332031,336118,340230,344367,348529,352716,356928,361165,365427,369714,374026,378363,382725,387112,391524,395961,400423,404910,409422,413959,418521,423108,427720,432357,437019,441706,446418,451155,455917,460704,465516,470353,475215,480102,485014,489951,494913,499900,504912,509949,515011,520098,525210,530347,535509,540696,545908,551145,556407,561694,567006,572343,577705,583092,588504,593941,599403,604890,610402,615939,621501,627088,632700,638337,643999,649686,655398,661135,666897,672684,678496,684333,690195,696082,701994,707931,713893,719880,725892,731929,737991,744078,750190,756327,762489,768676,774888 mov $1,$0 mul $1,25 bin $1,2 div $1,25
.data string: .asciiz "Xin chao" .text la $t1,string
; A299646: a(n) = Sum_{k = n..2*n+1} k^2. ; Submitted by Jamie Morken(s1) ; 1,14,54,135,271,476,764,1149,1645,2266,3026,3939,5019,6280,7736,9401,11289,13414,15790,18431,21351,24564,28084,31925,36101,40626,45514,50779,56435,62496,68976,75889,83249,91070,99366,108151,117439,127244,137580,148461,159901,171914,184514,197715,211531,225976,241064,256809,273225,290326,308126,326639,345879,365860,386596,408101,430389,453474,477370,502091,527651,554064,581344,609505,638561,668526,699414,731239,764015,797756,832476,868189,904909,942650,981426,1021251,1062139,1104104,1147160 add $0,1 mov $1,$0 bin $0,2 mul $1,14 add $1,11 mul $0,$1 div $0,3 add $0,1
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include <config/bitcoin-config.h> #endif #include <init.h> #include <addrman.h> #include <amount.h> #include <chain.h> #include <chainparams.h> #include <checkpoints.h> #include <compat/sanity.h> #include <consensus/validation.h> #include <fs.h> #include <httpserver.h> #include <httprpc.h> #include <key.h> #include <validation.h> #include <miner.h> #include <netbase.h> #include <net.h> #include <net_processing.h> #include <policy/feerate.h> #include <policy/fees.h> #include <policy/policy.h> #include <rpc/server.h> #include <rpc/register.h> #include <rpc/safemode.h> #include <rpc/blockchain.h> #include <script/standard.h> #include <script/sigcache.h> #include <scheduler.h> #include <timedata.h> #include <txdb.h> #include <txmempool.h> #include <torcontrol.h> #include <ui_interface.h> #include <util.h> #include <utilmoneystr.h> #include <validationinterface.h> #ifdef ENABLE_WALLET #include <wallet/init.h> #endif #include <warnings.h> #include <stdint.h> #include <stdio.h> #include <memory> #ifndef WIN32 #include <signal.h> #endif #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/split.hpp> #include <boost/bind.hpp> #include <boost/interprocess/sync/file_lock.hpp> #include <boost/thread.hpp> #include <openssl/crypto.h> #if ENABLE_ZMQ #include <zmq/zmqnotificationinterface.h> #endif bool fFeeEstimatesInitialized = false; static const bool DEFAULT_PROXYRANDOMIZE = true; static const bool DEFAULT_REST_ENABLE = false; static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; std::unique_ptr<CConnman> g_connman; std::unique_ptr<PeerLogicValidation> peerLogic; #if ENABLE_ZMQ static CZMQNotificationInterface* pzmqNotificationInterface = nullptr; #endif #ifdef WIN32 // Win32 LevelDB doesn't use filedescriptors, and the ones used for // accessing block files don't count towards the fd_set size limit // anyway. #define MIN_CORE_FILEDESCRIPTORS 0 #else #define MIN_CORE_FILEDESCRIPTORS 150 #endif static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat"; ////////////////////////////////////////////////////////////////////////////// // // Shutdown // // // Thread management and startup/shutdown: // // The network-processing threads are all part of a thread group // created by AppInit() or the Qt main() function. // // A clean exit happens when StartShutdown() or the SIGTERM // signal handler sets fRequestShutdown, which makes main thread's // WaitForShutdown() interrupts the thread group. // And then, WaitForShutdown() makes all other on-going threads // in the thread group join the main thread. // Shutdown() is then called to clean up database connections, and stop other // threads that should only be stopped after the main network-processing // threads have exited. // // Shutdown for Qt is very similar, only it uses a QTimer to detect // fRequestShutdown getting set, and then does the normal Qt // shutdown thing. // std::atomic<bool> fRequestShutdown(false); std::atomic<bool> fDumpMempoolLater(false); void StartShutdown() { fRequestShutdown = true; } bool ShutdownRequested() { return fRequestShutdown; } /** * This is a minimally invasive approach to shutdown on LevelDB read errors from the * chainstate, while keeping user interface out of the common library, which is shared * between bitcoind, and bitcoin-qt and non-server tools. */ class CCoinsViewErrorCatcher final : public CCoinsViewBacked { public: explicit CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {} bool GetCoin(const COutPoint &outpoint, Coin &coin) const override { try { return CCoinsViewBacked::GetCoin(outpoint, coin); } catch(const std::runtime_error& e) { uiInterface.ThreadSafeMessageBox(_("Error reading from database, shutting down."), "", CClientUIInterface::MSG_ERROR); LogPrintf("Error reading from database: %s\n", e.what()); // Starting the shutdown sequence and returning false to the caller would be // interpreted as 'entry not found' (as opposed to unable to read data), and // could lead to invalid interpretation. Just exit immediately, as we can't // continue anyway, and all writes should be atomic. abort(); } } // Writes do not need similar protection, as failure to write is handled by the caller. }; static std::unique_ptr<CCoinsViewErrorCatcher> pcoinscatcher; static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle; static boost::thread_group threadGroup; static CScheduler scheduler; void Interrupt() { InterruptHTTPServer(); InterruptHTTPRPC(); InterruptRPC(); InterruptREST(); InterruptTorControl(); if (g_connman) g_connman->Interrupt(); } void Shutdown() { LogPrintf("%s: In progress...\n", __func__); static CCriticalSection cs_Shutdown; TRY_LOCK(cs_Shutdown, lockShutdown); if (!lockShutdown) return; /// Note: Shutdown() must be able to handle cases in which initialization failed part of the way, /// for example if the data directory was found to be locked. /// Be sure that anything that writes files or flushes caches only does this if the respective /// module was initialized. RenameThread("bitcoin-shutoff"); mempool.AddTransactionsUpdated(1); StopHTTPRPC(); StopREST(); StopRPC(); StopHTTPServer(); #ifdef ENABLE_WALLET FlushWallets(); #endif MapPort(false); // Because these depend on each-other, we make sure that neither can be // using the other before destroying them. if (peerLogic) UnregisterValidationInterface(peerLogic.get()); if (g_connman) g_connman->Stop(); peerLogic.reset(); g_connman.reset(); StopTorControl(); // After everything has been shut down, but before things get flushed, stop the // CScheduler/checkqueue threadGroup threadGroup.interrupt_all(); threadGroup.join_all(); if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { DumpMempool(); } if (fFeeEstimatesInitialized) { ::feeEstimator.FlushUnconfirmed(::mempool); fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; CAutoFile est_fileout(fsbridge::fopen(est_path, "wb"), SER_DISK, CLIENT_VERSION); if (!est_fileout.IsNull()) ::feeEstimator.Write(est_fileout); else LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, est_path.string()); fFeeEstimatesInitialized = false; } // FlushStateToDisk generates a SetBestChain callback, which we should avoid missing if (pcoinsTip != nullptr) { FlushStateToDisk(); } // After there are no more peers/RPC left to give us new data which may generate // CValidationInterface callbacks, flush them... GetMainSignals().FlushBackgroundCallbacks(); // Any future callbacks will be dropped. This should absolutely be safe - if // missing a callback results in an unrecoverable situation, unclean shutdown // would too. The only reason to do the above flushes is to let the wallet catch // up with our current chain to avoid any strange pruning edge cases and make // next startup faster by avoiding rescan. { LOCK(cs_main); if (pcoinsTip != nullptr) { FlushStateToDisk(); } pcoinsTip.reset(); pcoinscatcher.reset(); pcoinsdbview.reset(); pblocktree.reset(); } #ifdef ENABLE_WALLET StopWallets(); #endif #if ENABLE_ZMQ if (pzmqNotificationInterface) { UnregisterValidationInterface(pzmqNotificationInterface); delete pzmqNotificationInterface; pzmqNotificationInterface = nullptr; } #endif #ifndef WIN32 try { fs::remove(GetPidFile()); } catch (const fs::filesystem_error& e) { LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what()); } #endif UnregisterAllValidationInterfaces(); GetMainSignals().UnregisterBackgroundSignalScheduler(); GetMainSignals().UnregisterWithMempoolSignals(mempool); #ifdef ENABLE_WALLET CloseWallets(); #endif globalVerifyHandle.reset(); ECC_Stop(); LogPrintf("%s: done\n", __func__); } /** * Signal handlers are very limited in what they are allowed to do. * The execution context the handler is invoked in is not guaranteed, * so we restrict handler operations to just touching variables: */ #ifndef WIN32 static void HandleSIGTERM(int) { fRequestShutdown = true; } static void HandleSIGHUP(int) { fReopenDebugLog = true; } #else static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType) { fRequestShutdown = true; Sleep(INFINITE); return true; } #endif #ifndef WIN32 static void registerSignalHandler(int signal, void(*handler)(int)) { struct sigaction sa; sa.sa_handler = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(signal, &sa, nullptr); } #endif void OnRPCStarted() { uiInterface.NotifyBlockTip.connect(&RPCNotifyBlockChange); } void OnRPCStopped() { uiInterface.NotifyBlockTip.disconnect(&RPCNotifyBlockChange); RPCNotifyBlockChange(false, nullptr); cvBlockChange.notify_all(); LogPrint(BCLog::RPC, "RPC stopped.\n"); } std::string HelpMessage(HelpMessageMode mode) { const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET); const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN); const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET); const bool showDebug = gArgs.GetBoolArg("-help-debug", false); // When adding new options to the categories, please keep and ensure alphabetical ordering. // Do not translate _(...) -help-debug options, Many technical terms, and only a very small audience, so is unnecessary stress to translators. std::string strUsage = HelpMessageGroup(_("Options:")); strUsage += HelpMessageOpt("-?", _("Print this help message and exit")); strUsage += HelpMessageOpt("-version", _("Print version and exit")); strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)")); strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)")); if (showDebug) strUsage += HelpMessageOpt("-blocksonly", strprintf(_("Whether to operate in a blocks only mode (default: %u)"), DEFAULT_BLOCKSONLY)); strUsage +=HelpMessageOpt("-assumevalid=<hex>", strprintf(_("If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s)"), defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex())); strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), BITCOIN_CONF_FILENAME)); if (mode == HMM_BITCOIND) { #if HAVE_DECL_DAEMON strUsage += HelpMessageOpt("-daemon", _("Run in the background as a daemon and accept commands")); #endif } strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory")); if (showDebug) { strUsage += HelpMessageOpt("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize)); } strUsage += HelpMessageOpt("-dbcache=<n>", strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache)); if (showDebug) strUsage += HelpMessageOpt("-feefilter", strprintf("Tell other nodes to filter invs to us by our mempool min fee (default: %u)", DEFAULT_FEEFILTER)); strUsage += HelpMessageOpt("-loadblock=<file>", _("Imports blocks from external blk000??.dat file on startup")); strUsage += HelpMessageOpt("-debuglogfile=<file>", strprintf(_("Specify location of debug log file: this can be an absolute path or a path relative to the data directory (default: %s)"), DEFAULT_DEBUGLOGFILE)); strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS)); strUsage += HelpMessageOpt("-maxmempool=<n>", strprintf(_("Keep the transaction memory pool below <n> megabytes (default: %u)"), DEFAULT_MAX_MEMPOOL_SIZE)); strUsage += HelpMessageOpt("-mempoolexpiry=<n>", strprintf(_("Do not keep transactions in the mempool longer than <n> hours (default: %u)"), DEFAULT_MEMPOOL_EXPIRY)); if (showDebug) { strUsage += HelpMessageOpt("-minimumchainwork=<hex>", strprintf("Minimum work assumed to exist on a valid chain in hex (default: %s, testnet: %s)", defaultChainParams->GetConsensus().nMinimumChainWork.GetHex(), testnetChainParams->GetConsensus().nMinimumChainWork.GetHex())); } strUsage += HelpMessageOpt("-persistmempool", strprintf(_("Whether to save the mempool on shutdown and load on restart (default: %u)"), DEFAULT_PERSIST_MEMPOOL)); strUsage += HelpMessageOpt("-blockreconstructionextratxn=<n>", strprintf(_("Extra transactions to keep in memory for compact block reconstructions (default: %u)"), DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN)); strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS)); #ifndef WIN32 strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), BITCOIN_PID_FILENAME)); #endif strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. " "Warning: Reverting this setting requires re-downloading the entire blockchain. " "(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >=%u = automatically prune block files to stay under the specified target size in MiB)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); strUsage += HelpMessageOpt("-reindex-chainstate", _("Rebuild chain state from the currently indexed blocks")); strUsage += HelpMessageOpt("-reindex", _("Rebuild chain state and block index from the blk*.dat files on disk")); #ifndef WIN32 strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); #endif strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX)); strUsage += HelpMessageGroup(_("Connection options:")); strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info)")); strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD)); strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME)); strUsage += HelpMessageOpt("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6")); strUsage += HelpMessageOpt("-connect=<ip>", _("Connect only to the specified node(s); -connect=0 disables automatic connections (the rules for this peer are the same as for -addnode)")); strUsage += HelpMessageOpt("-discover", _("Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)")); strUsage += HelpMessageOpt("-dns", _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + strprintf(_("(default: %u)"), DEFAULT_NAME_LOOKUP)); strUsage += HelpMessageOpt("-dnsseed", _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)")); strUsage += HelpMessageOpt("-externalip=<ip>", _("Specify your own public address")); strUsage += HelpMessageOpt("-forcednsseed", strprintf(_("Always query for peer addresses via DNS lookup (default: %u)"), DEFAULT_FORCEDNSSEED)); strUsage += HelpMessageOpt("-listen", _("Accept connections from outside (default: 1 if no -proxy or -connect)")); strUsage += HelpMessageOpt("-listenonion", strprintf(_("Automatically create Tor hidden service (default: %d)"), DEFAULT_LISTEN_ONION)); strUsage += HelpMessageOpt("-maxconnections=<n>", strprintf(_("Maintain at most <n> connections to peers (default: %u)"), DEFAULT_MAX_PEER_CONNECTIONS)); strUsage += HelpMessageOpt("-maxreceivebuffer=<n>", strprintf(_("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXRECEIVEBUFFER)); strUsage += HelpMessageOpt("-maxsendbuffer=<n>", strprintf(_("Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXSENDBUFFER)); strUsage += HelpMessageOpt("-maxtimeadjustment", strprintf(_("Maximum allowed median peer time offset adjustment. Local perspective of time may be influenced by peers forward or backward by this amount. (default: %u seconds)"), DEFAULT_MAX_TIME_ADJUSTMENT)); strUsage += HelpMessageOpt("-onion=<ip:port>", strprintf(_("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"), "-proxy")); strUsage += HelpMessageOpt("-onlynet=<net>", _("Only connect to nodes in network <net> (ipv4, ipv6 or onion)")); strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), DEFAULT_PERMIT_BAREMULTISIG)); strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with bloom filters (default: %u)"), DEFAULT_PEERBLOOMFILTERS)); strUsage += HelpMessageOpt("-port=<port>", strprintf(_("Listen for connections on <port> (default: %u or testnet: %u)"), defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort())); strUsage += HelpMessageOpt("-proxy=<ip:port>", _("Connect through SOCKS5 proxy")); strUsage += HelpMessageOpt("-proxyrandomize", strprintf(_("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), DEFAULT_PROXYRANDOMIZE)); strUsage += HelpMessageOpt("-seednode=<ip>", _("Connect to a node to retrieve peer addresses, and disconnect")); strUsage += HelpMessageOpt("-timeout=<n>", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT)); strUsage += HelpMessageOpt("-torcontrol=<ip>:<port>", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL)); strUsage += HelpMessageOpt("-torpassword=<pass>", _("Tor control port password (default: empty)")); #ifdef USE_UPNP #if USE_UPNP strUsage += HelpMessageOpt("-upnp", _("Use UPnP to map the listening port (default: 1 when listening and no -proxy)")); #else strUsage += HelpMessageOpt("-upnp", strprintf(_("Use UPnP to map the listening port (default: %u)"), 0)); #endif #endif strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6")); strUsage += HelpMessageOpt("-whitelist=<IP address or network>", _("Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple times.") + " " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway")); strUsage += HelpMessageOpt("-maxuploadtarget=<n>", strprintf(_("Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), DEFAULT_MAX_UPLOAD_TARGET)); #ifdef ENABLE_WALLET strUsage += GetWalletHelpString(showDebug); #endif #if ENABLE_ZMQ strUsage += HelpMessageGroup(_("ZeroMQ notification options:")); strUsage += HelpMessageOpt("-zmqpubhashblock=<address>", _("Enable publish hash block in <address>")); strUsage += HelpMessageOpt("-zmqpubhashtx=<address>", _("Enable publish hash transaction in <address>")); strUsage += HelpMessageOpt("-zmqpubrawblock=<address>", _("Enable publish raw block in <address>")); strUsage += HelpMessageOpt("-zmqpubrawtx=<address>", _("Enable publish raw transaction in <address>")); #endif strUsage += HelpMessageGroup(_("Debugging/Testing options:")); strUsage += HelpMessageOpt("-uacomment=<cmt>", _("Append comment to the user agent string")); if (showDebug) { strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS)); strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL)); strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", defaultChainParams->DefaultConsistencyChecks())); strUsage += HelpMessageOpt("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks())); strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED)); strUsage += HelpMessageOpt("-disablesafemode", strprintf("Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE)); strUsage += HelpMessageOpt("-deprecatedrpc=<method>", "Allows deprecated RPC method(s) to be used"); strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", DEFAULT_TESTSAFEMODE)); strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages"); strUsage += HelpMessageOpt("-fuzzmessagestest=<n>", "Randomly fuzz 1 of every <n> network messages"); strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT)); strUsage += HelpMessageOpt("-stopatheight", strprintf("Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT)); strUsage += HelpMessageOpt("-limitancestorcount=<n>", strprintf("Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT)); strUsage += HelpMessageOpt("-limitancestorsize=<n>", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT)); strUsage += HelpMessageOpt("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT)); strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT)); strUsage += HelpMessageOpt("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest-only)"); } strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " + _("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + ListLogCategories() + "."); strUsage += HelpMessageOpt("-debugexclude=<category>", strprintf(_("Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories."))); strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)")); strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), DEFAULT_LOGIPS)); strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), DEFAULT_LOGTIMESTAMPS)); if (showDebug) { strUsage += HelpMessageOpt("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS)); strUsage += HelpMessageOpt("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)"); strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE)); strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE)); } strUsage += HelpMessageOpt("-maxtxfee=<amt>", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction or raw transaction; setting this too low may abort large transactions (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE))); strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file")); if (showDebug) { strUsage += HelpMessageOpt("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY)); } strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)")); AppendParamsHelpMessages(strUsage, showDebug); strUsage += HelpMessageGroup(_("Node relay options:")); if (showDebug) { strUsage += HelpMessageOpt("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !testnetChainParams->RequireStandard())); strUsage += HelpMessageOpt("-incrementalrelayfee=<amt>", strprintf("Fee rate (in %s/kB) used to define cost of relay, used for mempool limiting and BIP 125 replacement. (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_INCREMENTAL_RELAY_FEE))); strUsage += HelpMessageOpt("-dustrelayfee=<amt>", strprintf("Fee rate (in %s/kB) used to defined dust, the value of an output such that it will cost more than its value in fees at this fee rate to spend it. (default: %s)", CURRENCY_UNIT, FormatMoney(DUST_RELAY_TX_FEE))); } strUsage += HelpMessageOpt("-bytespersigop", strprintf(_("Equivalent bytes per sigop in transactions for relay and mining (default: %u)"), DEFAULT_BYTES_PER_SIGOP)); strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER)); strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY)); strUsage += HelpMessageOpt("-mempoolreplacement", strprintf(_("Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT)); strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE))); strUsage += HelpMessageOpt("-whitelistrelay", strprintf(_("Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)"), DEFAULT_WHITELISTRELAY)); strUsage += HelpMessageOpt("-whitelistforcerelay", strprintf(_("Force relay of transactions from whitelisted peers even if they violate local relay policy (default: %d)"), DEFAULT_WHITELISTFORCERELAY)); strUsage += HelpMessageGroup(_("Block creation options:")); strUsage += HelpMessageOpt("-blockmaxweight=<n>", strprintf(_("Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT)); strUsage += HelpMessageOpt("-blockmintxfee=<amt>", strprintf(_("Set lowest fee rate (in %s/kB) for transactions to be included in block creation. (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_BLOCK_MIN_TX_FEE))); if (showDebug) strUsage += HelpMessageOpt("-blockversion=<n>", "Override block version to test forking scenarios"); strUsage += HelpMessageGroup(_("RPC server options:")); strUsage += HelpMessageOpt("-server", _("Accept command line and JSON-RPC commands")); strUsage += HelpMessageOpt("-rest", strprintf(_("Accept public REST requests (default: %u)"), DEFAULT_REST_ENABLE)); strUsage += HelpMessageOpt("-rpcbind=<addr>[:port]", _("Bind to given address to listen for JSON-RPC connections. This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)")); strUsage += HelpMessageOpt("-rpccookiefile=<loc>", _("Location of the auth cookie (default: data dir)")); strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcauth=<userpw>", _("Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times")); strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort())); strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times")); strUsage += HelpMessageOpt("-rpcserialversion", strprintf(_("Sets the serialization of raw transaction or block hex returned in non-verbose mode, non-segwit(0) or segwit(1) (default: %d)"), DEFAULT_RPC_SERIALIZE_VERSION)); strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS)); if (showDebug) { strUsage += HelpMessageOpt("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE)); strUsage += HelpMessageOpt("-rpcservertimeout=<n>", strprintf("Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT)); } return strUsage; } std::string LicenseInfo() { const std::string URL_SOURCE_CODE = "<https://github.com/Equibit/equibit>"; const std::string URL_WEBSITE = "<https://equibit.org/>"; return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR) + " ") + "\n" + "\n" + strprintf(_("Please contribute if you find %s useful. " "Visit %s for further information about the software."), PACKAGE_NAME, URL_WEBSITE) + "\n" + strprintf(_("The source code is available from %s."), URL_SOURCE_CODE) + "\n" + "\n" + _("This is experimental software.") + "\n" + strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/licenses/MIT>") + "\n" + "\n" + strprintf(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit %s and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard."), "<https://www.openssl.org>") + "\n"; } static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex) { if (initialSync || !pBlockIndex) return; std::string strCmd = gArgs.GetArg("-blocknotify", ""); if (!strCmd.empty()) { boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } } static bool fHaveGenesis = false; static CWaitableCriticalSection cs_GenesisWait; static CConditionVariable condvar_GenesisWait; static void BlockNotifyGenesisWait(bool, const CBlockIndex *pBlockIndex) { if (pBlockIndex != nullptr) { { WaitableLock lock_GenesisWait(cs_GenesisWait); fHaveGenesis = true; } condvar_GenesisWait.notify_all(); } } struct CImportingNow { CImportingNow() { assert(fImporting == false); fImporting = true; } ~CImportingNow() { assert(fImporting == true); fImporting = false; } }; // If we're using -prune with -reindex, then delete block files that will be ignored by the // reindex. Since reindexing works by starting at block file 0 and looping until a blockfile // is missing, do the same here to delete any later block files after a gap. Also delete all // rev files since they'll be rewritten by the reindex anyway. This ensures that vinfoBlockFile // is in sync with what's actually on disk by the time we start downloading, so that pruning // works correctly. void CleanupBlockRevFiles() { std::map<std::string, fs::path> mapBlockFiles; // Glob all blk?????.dat and rev?????.dat files from the blocks directory. // Remove the rev files immediately and insert the blk file paths into an // ordered map keyed by block file index. LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n"); fs::path blocksdir = GetDataDir() / "blocks"; for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) { if (fs::is_regular_file(*it) && it->path().filename().string().length() == 12 && it->path().filename().string().substr(8,4) == ".dat") { if (it->path().filename().string().substr(0,3) == "blk") mapBlockFiles[it->path().filename().string().substr(3,5)] = it->path(); else if (it->path().filename().string().substr(0,3) == "rev") remove(it->path()); } } // Remove all block files that aren't part of a contiguous set starting at // zero by walking the ordered map (keys are block file indices) by // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist) // start removing block files. int nContigCounter = 0; for (const std::pair<std::string, fs::path>& item : mapBlockFiles) { if (atoi(item.first) == nContigCounter) { nContigCounter++; continue; } remove(item.second); } } void ThreadImport(std::vector<fs::path> vImportFiles) { const CChainParams& chainparams = Params(); RenameThread("bitcoin-loadblk"); { CImportingNow imp; // -reindex if (fReindex) { int nFile = 0; while (true) { CDiskBlockPos pos(nFile, 0); if (!fs::exists(GetBlockPosFilename(pos, "blk"))) break; // No block files left to reindex FILE *file = OpenBlockFile(pos, true); if (!file) break; // This error is logged in OpenBlockFile LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile); LoadExternalBlockFile(chainparams, file, &pos); nFile++; } pblocktree->WriteReindexing(false); fReindex = false; LogPrintf("Reindexing finished\n"); // To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked): LoadGenesisBlock(chainparams); } // hardcoded $DATADIR/bootstrap.dat fs::path pathBootstrap = GetDataDir() / "bootstrap.dat"; if (fs::exists(pathBootstrap)) { FILE *file = fsbridge::fopen(pathBootstrap, "rb"); if (file) { fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; LogPrintf("Importing bootstrap.dat...\n"); LoadExternalBlockFile(chainparams, file); RenameOver(pathBootstrap, pathBootstrapOld); } else { LogPrintf("Warning: Could not open bootstrap file %s\n", pathBootstrap.string()); } } // -loadblock= for (const fs::path& path : vImportFiles) { FILE *file = fsbridge::fopen(path, "rb"); if (file) { LogPrintf("Importing blocks file %s...\n", path.string()); LoadExternalBlockFile(chainparams, file); } else { LogPrintf("Warning: Could not open blocks file %s\n", path.string()); } } // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; if (!ActivateBestChain(state, chainparams)) { LogPrintf("Failed to connect best block\n"); StartShutdown(); return; } if (gArgs.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) { LogPrintf("Stopping after block import\n"); StartShutdown(); return; } } // End scope of CImportingNow if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { LoadMempool(); fDumpMempoolLater = !fRequestShutdown; } } /** Sanity checks * Ensure that Bitcoin is running in a usable environment with all * necessary library support. */ bool InitSanityCheck(void) { if(!ECC_InitSanityCheck()) { InitError("Elliptic curve cryptography sanity check failure. Aborting."); return false; } if (!glibc_sanity_test() || !glibcxx_sanity_test()) return false; if (!Random_SanityCheck()) { InitError("OS cryptographic RNG sanity check failure. Aborting."); return false; } return true; } bool AppInitServers() { RPCServer::OnStarted(&OnRPCStarted); RPCServer::OnStopped(&OnRPCStopped); if (!InitHTTPServer()) return false; if (!StartRPC()) return false; if (!StartHTTPRPC()) return false; if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST()) return false; if (!StartHTTPServer()) return false; return true; } // Parameter interaction based on rules void InitParameterInteraction() { // when specifying an explicit binding address, you want to listen on it // even when -connect or -proxy is specified if (gArgs.IsArgSet("-bind")) { if (gArgs.SoftSetBoolArg("-listen", true)) LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__); } if (gArgs.IsArgSet("-whitebind")) { if (gArgs.SoftSetBoolArg("-listen", true)) LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); } if (gArgs.IsArgSet("-connect")) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default if (gArgs.SoftSetBoolArg("-dnsseed", false)) LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); if (gArgs.SoftSetBoolArg("-listen", false)) LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__); } if (gArgs.IsArgSet("-proxy")) { // to protect privacy, do not listen by default if a default proxy server is specified if (gArgs.SoftSetBoolArg("-listen", false)) LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); // to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1 // to listen locally, so don't rely on this happening through -listen below. if (gArgs.SoftSetBoolArg("-upnp", false)) LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__); // to protect privacy, do not discover addresses by default if (gArgs.SoftSetBoolArg("-discover", false)) LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); } if (!gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) { // do not map ports or try to retrieve public IP when not listening (pointless) if (gArgs.SoftSetBoolArg("-upnp", false)) LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__); if (gArgs.SoftSetBoolArg("-discover", false)) LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); if (gArgs.SoftSetBoolArg("-listenonion", false)) LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__); } if (gArgs.IsArgSet("-externalip")) { // if an explicit public IP is specified, do not try to find others if (gArgs.SoftSetBoolArg("-discover", false)) LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); } // disable whitelistrelay in blocksonly mode if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) { if (gArgs.SoftSetBoolArg("-whitelistrelay", false)) LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__); } // Forcing relay from whitelisted hosts implies we will accept relays from them in the first place. if (gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) { if (gArgs.SoftSetBoolArg("-whitelistrelay", true)) LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__); } } static std::string ResolveErrMsg(const char * const optname, const std::string& strBind) { return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind); } void InitLogging() { fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false); fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); std::string version_string = FormatFullVersion(); #ifdef DEBUG version_string += " (debug build)"; #else version_string += " (release build)"; #endif LogPrintf(PACKAGE_NAME " version %s\n", version_string); } namespace { // Variables internal to initialization process only int nMaxConnections; int nUserMaxConnections; int nFD; ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED); } // namespace [[noreturn]] static void new_handler_terminate() { // Rather than throwing std::bad-alloc if allocation fails, terminate // immediately to (try to) avoid chain corruption. // Since LogPrintf may itself allocate memory, set the handler directly // to terminate first. std::set_new_handler(std::terminate); LogPrintf("Error: Out of memory. Terminating.\n"); // The log was successful, terminate now. std::terminate(); }; bool AppInitBasicSetup() { // ********************************************************* Step 1: setup #ifdef _MSC_VER // Turn off Microsoft heap dump noise _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0)); // Disable confusing "helpful" text message on abort, Ctrl-C _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #endif #ifdef WIN32 // Enable Data Execution Prevention (DEP) // Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008 // A failure is non-critical and needs no further attention! #ifndef PROCESS_DEP_ENABLE // We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7), // which is not correct. Can be removed, when GCCs winbase.h is fixed! #define PROCESS_DEP_ENABLE 0x00000001 #endif typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD); PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy"); if (setProcDEPPol != nullptr) setProcDEPPol(PROCESS_DEP_ENABLE); #endif if (!SetupNetworking()) return InitError("Initializing networking failed"); #ifndef WIN32 if (!gArgs.GetBoolArg("-sysperms", false)) { umask(077); } // Clean shutdown on SIGTERM registerSignalHandler(SIGTERM, HandleSIGTERM); registerSignalHandler(SIGINT, HandleSIGTERM); // Reopen debug.log on SIGHUP registerSignalHandler(SIGHUP, HandleSIGHUP); // Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly signal(SIGPIPE, SIG_IGN); #else SetConsoleCtrlHandler(consoleCtrlHandler, true); #endif std::set_new_handler(new_handler_terminate); return true; } bool AppInitParameterInteraction() { const CChainParams& chainparams = Params(); // ********************************************************* Step 2: parameter interactions // also see: InitParameterInteraction() // if using block pruning, then disallow txindex if (gArgs.GetArg("-prune", 0)) { if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) return InitError(_("Prune mode is incompatible with -txindex.")); } // -bind and -whitebind can't be set when not listening size_t nUserBind = gArgs.GetArgs("-bind").size() + gArgs.GetArgs("-whitebind").size(); if (nUserBind != 0 && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) { return InitError("Cannot set -bind or -whitebind together with -listen=0"); } // Make sure enough file descriptors are available int nBind = std::max(nUserBind, size_t(1)); nUserMaxConnections = gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); nMaxConnections = std::max(nUserMaxConnections, 0); // Trim requested connection counts, to fit into system limitations nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS)), 0); nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + MAX_ADDNODE_CONNECTIONS); if (nFD < MIN_CORE_FILEDESCRIPTORS) return InitError(_("Not enough file descriptors available.")); nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, nMaxConnections); if (nMaxConnections < nUserMaxConnections) InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections)); // ********************************************************* Step 3: parameter-to-internal-flags if (gArgs.IsArgSet("-debug")) { // Special-case: if -debug=0/-nodebug is set, turn off debugging messages const std::vector<std::string> categories = gArgs.GetArgs("-debug"); if (std::none_of(categories.begin(), categories.end(), [](std::string cat){return cat == "0" || cat == "none";})) { for (const auto& cat : categories) { uint32_t flag = 0; if (!GetLogCategory(&flag, &cat)) { InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat)); continue; } logCategories |= flag; } } } // Now remove the logging categories which were explicitly excluded for (const std::string& cat : gArgs.GetArgs("-debugexclude")) { uint32_t flag = 0; if (!GetLogCategory(&flag, &cat)) { InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat)); continue; } logCategories &= ~flag; } // Check for -debugnet if (gArgs.GetBoolArg("-debugnet", false)) InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net.")); // Check for -socks - as this is a privacy risk to continue, exit here if (gArgs.IsArgSet("-socks")) return InitError(_("Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported.")); // Check for -tor - as this is a privacy risk to continue, exit here if (gArgs.GetBoolArg("-tor", false)) return InitError(_("Unsupported argument -tor found, use -onion.")); if (gArgs.GetBoolArg("-benchmark", false)) InitWarning(_("Unsupported argument -benchmark ignored, use -debug=bench.")); if (gArgs.GetBoolArg("-whitelistalwaysrelay", false)) InitWarning(_("Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay.")); if (gArgs.IsArgSet("-blockminsize")) InitWarning("Unsupported argument -blockminsize ignored."); // Checkmempool and checkblockindex default to true in regtest mode int ratio = std::min<int>(std::max<int>(gArgs.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000); if (ratio != 0) { mempool.setSanityCheck(1.0 / ratio); } fCheckBlockIndex = gArgs.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks()); fCheckpointsEnabled = gArgs.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED); hashAssumeValid = uint256S(gArgs.GetArg("-assumevalid", chainparams.GetConsensus().defaultAssumeValid.GetHex())); if (!hashAssumeValid.IsNull()) LogPrintf("Assuming ancestors of block %s have valid signatures.\n", hashAssumeValid.GetHex()); else LogPrintf("Validating signatures for all blocks.\n"); if (gArgs.IsArgSet("-minimumchainwork")) { const std::string minChainWorkStr = gArgs.GetArg("-minimumchainwork", ""); if (!IsHexNumber(minChainWorkStr)) { return InitError(strprintf("Invalid non-hex (%s) minimum chain work value specified", minChainWorkStr)); } nMinimumChainWork = UintToArith256(uint256S(minChainWorkStr)); } else { nMinimumChainWork = UintToArith256(chainparams.GetConsensus().nMinimumChainWork); } LogPrintf("Setting nMinimumChainWork=%s\n", nMinimumChainWork.GetHex()); if (nMinimumChainWork < UintToArith256(chainparams.GetConsensus().nMinimumChainWork)) { LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainparams.GetConsensus().nMinimumChainWork.GetHex()); } // mempool limits int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; int64_t nMempoolSizeMin = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40; if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin) return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0))); // incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool // and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting. if (gArgs.IsArgSet("-incrementalrelayfee")) { CAmount n = 0; if (!ParseMoney(gArgs.GetArg("-incrementalrelayfee", ""), n)) return InitError(AmountErrMsg("incrementalrelayfee", gArgs.GetArg("-incrementalrelayfee", ""))); incrementalRelayFee = CFeeRate(n); } // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency nScriptCheckThreads = gArgs.GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS); if (nScriptCheckThreads <= 0) nScriptCheckThreads += GetNumCores(); if (nScriptCheckThreads <= 1) nScriptCheckThreads = 0; else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS) nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; // block pruning; get the amount of disk space (in MiB) to allot for block & undo files int64_t nPruneArg = gArgs.GetArg("-prune", 0); if (nPruneArg < 0) { return InitError(_("Prune cannot be configured with a negative value.")); } nPruneTarget = (uint64_t) nPruneArg * 1024 * 1024; if (nPruneArg == 1) { // manual pruning: -prune=1 LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n"); nPruneTarget = std::numeric_limits<uint64_t>::max(); fPruneMode = true; } else if (nPruneTarget) { if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) { return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); } LogPrintf("Prune configured to target %uMiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024); fPruneMode = true; } nConnectTimeout = gArgs.GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT); if (nConnectTimeout <= 0) nConnectTimeout = DEFAULT_CONNECT_TIMEOUT; if (gArgs.IsArgSet("-minrelaytxfee")) { CAmount n = 0; if (!ParseMoney(gArgs.GetArg("-minrelaytxfee", ""), n)) { return InitError(AmountErrMsg("minrelaytxfee", gArgs.GetArg("-minrelaytxfee", ""))); } // High fee check is done afterward in WalletParameterInteraction() ::minRelayTxFee = CFeeRate(n); } else if (incrementalRelayFee > ::minRelayTxFee) { // Allow only setting incrementalRelayFee to control both ::minRelayTxFee = incrementalRelayFee; LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n",::minRelayTxFee.ToString()); } // Sanity check argument for min fee for including tx in block // TODO: Harmonize which arguments need sanity checking and where that happens if (gArgs.IsArgSet("-blockmintxfee")) { CAmount n = 0; if (!ParseMoney(gArgs.GetArg("-blockmintxfee", ""), n)) return InitError(AmountErrMsg("blockmintxfee", gArgs.GetArg("-blockmintxfee", ""))); } // Feerate used to define dust. Shouldn't be changed lightly as old // implementations may inadvertently create non-standard transactions if (gArgs.IsArgSet("-dustrelayfee")) { CAmount n = 0; if (!ParseMoney(gArgs.GetArg("-dustrelayfee", ""), n) || 0 == n) return InitError(AmountErrMsg("dustrelayfee", gArgs.GetArg("-dustrelayfee", ""))); dustRelayFee = CFeeRate(n); } fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard()); if (chainparams.RequireStandard() && !fRequireStandard) return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString())); nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp); #ifdef ENABLE_WALLET if (!WalletParameterInteraction()) return false; #endif fIsBareMultisigStd = gArgs.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG); fAcceptDatacarrier = gArgs.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER); nMaxDatacarrierBytes = gArgs.GetArg("-datacarriersize", nMaxDatacarrierBytes); // Option to startup with mocktime set (used for regression testing): SetMockTime(gArgs.GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op if (gArgs.GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS)) nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM); if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0) return InitError("rpcserialversion must be non-negative."); if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1) return InitError("unknown rpcserialversion requested."); nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); fEnableReplacement = gArgs.GetBoolArg("-mempoolreplacement", DEFAULT_ENABLE_REPLACEMENT); if ((!fEnableReplacement) && gArgs.IsArgSet("-mempoolreplacement")) { // Minimal effort at forwards compatibility std::string strReplacementModeList = gArgs.GetArg("-mempoolreplacement", ""); // default is impossible std::vector<std::string> vstrReplacementModes; boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",")); fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end()); } if (gArgs.IsArgSet("-vbparams")) { // Allow overriding version bits parameters for testing if (!chainparams.MineBlocksOnDemand()) { return InitError("Version bits parameters may only be overridden on regtest."); } for (const std::string& strDeployment : gArgs.GetArgs("-vbparams")) { std::vector<std::string> vDeploymentParams; boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":")); if (vDeploymentParams.size() != 3) { return InitError("Version bits parameters malformed, expecting deployment:start:end"); } int64_t nStartTime, nTimeout; if (!ParseInt64(vDeploymentParams[1], &nStartTime)) { return InitError(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1])); } if (!ParseInt64(vDeploymentParams[2], &nTimeout)) { return InitError(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2])); } bool found = false; for (int j=0; j<(int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) { if (vDeploymentParams[0].compare(VersionBitsDeploymentInfo[j].name) == 0) { UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout); found = true; LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout); break; } } if (!found) { return InitError(strprintf("Invalid deployment (%s)", vDeploymentParams[0])); } } } return true; } static bool LockDataDirectory(bool probeOnly) { // Make sure only a single Bitcoin process is using the data directory. fs::path datadir = GetDataDir(); if (!LockDirectory(datadir, ".lock", probeOnly)) { return InitError(strprintf(_("Cannot obtain a lock on data directory %s. %s is probably already running."), datadir.string(), _(PACKAGE_NAME))); } return true; } bool AppInitSanityChecks() { // ********************************************************* Step 4: sanity checks // Initialize elliptic curve code std::string sha256_algo = SHA256AutoDetect(); LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo); RandomInit(); ECC_Start(); globalVerifyHandle.reset(new ECCVerifyHandle()); // Sanity check if (!InitSanityCheck()) return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), _(PACKAGE_NAME))); // Probe the data directory lock to give an early error message, if possible // We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened, // and a fork will cause weird behavior to it. return LockDataDirectory(true); } bool AppInitLockDataDirectory() { // After daemonization get the data directory lock again and hold on to it until exit // This creates a slight window for a race condition to happen, however this condition is harmless: it // will at most make us exit without printing a message to console. if (!LockDataDirectory(false)) { // Detailed error printed inside LockDataDirectory return false; } return true; } bool AppInitMain() { const CChainParams& chainparams = Params(); // ********************************************************* Step 4a: application initialization #ifndef WIN32 CreatePidFile(GetPidFile(), getpid()); #endif if (gArgs.GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) { // Do this first since it both loads a bunch of debug.log into memory, // and because this needs to happen before any other debug.log printing ShrinkDebugFile(); } if (fPrintToDebugLog) { if (!OpenDebugLog()) { return InitError(strprintf("Could not open debug log file %s", GetDebugLogPath().string())); } } if (!fLogTimestamps) LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime())); LogPrintf("Default data directory %s\n", GetDefaultDataDir().string()); LogPrintf("Using data directory %s\n", GetDataDir().string()); LogPrintf("Using config file %s\n", GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string()); LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); // Warn about relative -datadir path. if (gArgs.IsArgSet("-datadir") && !fs::path(gArgs.GetArg("-datadir", "")).is_absolute()) { #ifdef BUILD_BTC LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " "current working directory '%s'. This is fragile, because if bitcoin is started in the future " "from a different location, it will be unable to locate the current data files. There could " "also be data loss if bitcoin is started while in a temporary directory.\n", gArgs.GetArg("-datadir", ""), fs::current_path().string()); #else // BUILD_EQB LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " "current working directory '%s'. This is fragile, because if equibit is started in the future " "from a different location, it will be unable to locate the current data files. There could " "also be data loss if equibit is started while in a temporary directory.\n", gArgs.GetArg("-datadir", ""), fs::current_path().string()); #endif // END_BUILD } InitSignatureCache(); InitScriptExecutionCache(); LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads); if (nScriptCheckThreads) { for (int i=0; i<nScriptCheckThreads-1; i++) threadGroup.create_thread(&ThreadScriptCheck); } // Start the lightweight task scheduler thread CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler); threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>, "scheduler", serviceLoop)); GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); GetMainSignals().RegisterWithMempoolSignals(mempool); /* Register RPC commands regardless of -server setting so they will be * available in the GUI RPC console even if external calls are disabled. */ RegisterAllCoreRPCCommands(tableRPC); #ifdef ENABLE_WALLET RegisterWalletRPC(tableRPC); #endif /* Start the RPC server already. It will be started in "warmup" mode * and not really process calls already (but it will signify connections * that the server is there and will be ready later). Warmup mode will * be disabled when initialisation is finished. */ if (gArgs.GetBoolArg("-server", false)) { uiInterface.InitMessage.connect(SetRPCWarmupStatus); if (!AppInitServers()) return InitError(_("Unable to start HTTP server. See debug log for details.")); } int64_t nStart; // ********************************************************* Step 5: verify wallet database integrity #ifdef ENABLE_WALLET if (!VerifyWallets()) return false; #endif // ********************************************************* Step 6: network initialization // Note that we absolutely cannot open any actual connections // until the very end ("start node") as the UTXO/block state // is not yet setup and may end up being set up twice if we // need to reindex later. assert(!g_connman); g_connman = std::unique_ptr<CConnman>(new CConnman(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()))); CConnman& connman = *g_connman; peerLogic.reset(new PeerLogicValidation(&connman, scheduler)); RegisterValidationInterface(peerLogic.get()); // sanitize comments per BIP-0014, format user agent and check total size std::vector<std::string> uacomments; for (const std::string& cmt : gArgs.GetArgs("-uacomment")) { if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt)); uacomments.push_back(cmt); } strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments); if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) { return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."), strSubVersion.size(), MAX_SUBVERSION_LENGTH)); } if (gArgs.IsArgSet("-onlynet")) { std::set<enum Network> nets; for (const std::string& snet : gArgs.GetArgs("-onlynet")) { enum Network net = ParseNetwork(snet); if (net == NET_UNROUTABLE) return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); nets.insert(net); } for (int n = 0; n < NET_MAX; n++) { enum Network net = (enum Network)n; if (!nets.count(net)) SetLimited(net); } } // Check for host lookup allowed before parsing any network related parameters fNameLookup = gArgs.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP); bool proxyRandomize = gArgs.GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE); // -proxy sets a proxy for all outgoing network traffic // -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default std::string proxyArg = gArgs.GetArg("-proxy", ""); SetLimited(NET_TOR); if (proxyArg != "" && proxyArg != "0") { CService proxyAddr; if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) { return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg)); } proxyType addrProxy = proxyType(proxyAddr, proxyRandomize); if (!addrProxy.IsValid()) return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg)); SetProxy(NET_IPV4, addrProxy); SetProxy(NET_IPV6, addrProxy); SetProxy(NET_TOR, addrProxy); SetNameProxy(addrProxy); SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later } // -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses // -noonion (or -onion=0) disables connecting to .onion entirely // An empty string is used to not override the onion proxy (in which case it defaults to -proxy set above, or none) std::string onionArg = gArgs.GetArg("-onion", ""); if (onionArg != "") { if (onionArg == "0") { // Handle -noonion/-onion=0 SetLimited(NET_TOR); // set onions as unreachable } else { CService onionProxy; if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) { return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg)); } proxyType addrOnion = proxyType(onionProxy, proxyRandomize); if (!addrOnion.IsValid()) return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg)); SetProxy(NET_TOR, addrOnion); SetLimited(NET_TOR, false); } } // see Step 2: parameter interactions for more information about these fListen = gArgs.GetBoolArg("-listen", DEFAULT_LISTEN); fDiscover = gArgs.GetBoolArg("-discover", true); fRelayTxes = !gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); for (const std::string& strAddr : gArgs.GetArgs("-externalip")) { CService addrLocal; if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid()) AddLocal(addrLocal, LOCAL_MANUAL); else return InitError(ResolveErrMsg("externalip", strAddr)); } #if ENABLE_ZMQ pzmqNotificationInterface = CZMQNotificationInterface::Create(); if (pzmqNotificationInterface) { RegisterValidationInterface(pzmqNotificationInterface); } #endif uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME; if (gArgs.IsArgSet("-maxuploadtarget")) { nMaxOutboundLimit = gArgs.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024; } // ********************************************************* Step 7: load block chain fReindex = gArgs.GetBoolArg("-reindex", false); bool fReindexChainState = gArgs.GetBoolArg("-reindex-chainstate", false); // cache size calculations int64_t nTotalCache = (gArgs.GetArg("-dbcache", nDefaultDbCache) << 20); nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache int64_t nBlockTreeDBCache = nTotalCache / 8; nBlockTreeDBCache = std::min(nBlockTreeDBCache, (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20); nTotalCache -= nBlockTreeDBCache; int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20); // cap total coins db cache nTotalCache -= nCoinDBCache; nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; LogPrintf("Cache configuration:\n"); LogPrintf("* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024)); LogPrintf("* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024)); LogPrintf("* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024)); bool fLoaded = false; while (!fLoaded && !fRequestShutdown) { bool fReset = fReindex; std::string strLoadError; uiInterface.InitMessage(_("Loading block index...")); nStart = GetTimeMillis(); do { try { UnloadBlockIndex(); pcoinsTip.reset(); pcoinsdbview.reset(); pcoinscatcher.reset(); // new CBlockTreeDB tries to delete the existing file, which // fails if it's still open from the previous loop. Close it first: pblocktree.reset(); pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset)); if (fReset) { pblocktree->WriteReindexing(true); //If we're reindexing in prune mode, wipe away unusable block files and all undo data files if (fPruneMode) CleanupBlockRevFiles(); } if (fRequestShutdown) break; // LoadBlockIndex will load fTxIndex from the db, or set it if // we're reindexing. It will also load fHavePruned if we've // ever removed a block file from disk. // Note that it also sets fReindex based on the disk flag! // From here on out fReindex and fReset mean something different! if (!LoadBlockIndex(chainparams)) { strLoadError = _("Error loading block database"); break; } // If the loaded chain has a wrong genesis, bail out immediately // (we're likely using a testnet datadir, or the other way around). if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0) return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?")); // Check for changed -txindex state if (fTxIndex != gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { strLoadError = _("You need to rebuild the database using -reindex to change -txindex"); break; } // Check for changed -prune state. What we are concerned about is a user who has pruned blocks // in the past, but is now trying to run unpruned. if (fHavePruned && !fPruneMode) { strLoadError = _("You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain"); break; } // At this point blocktree args are consistent with what's on disk. // If we're not mid-reindex (based on disk + args), add a genesis block on disk // (otherwise we use the one already on disk). // This is called again in ThreadImport after the reindex completes. if (!fReindex && !LoadGenesisBlock(chainparams)) { strLoadError = _("Error initializing block database"); break; } // At this point we're either in reindex or we've loaded a useful // block tree into mapBlockIndex! pcoinsdbview.reset(new CCoinsViewDB(nCoinDBCache, false, fReset || fReindexChainState)); pcoinscatcher.reset(new CCoinsViewErrorCatcher(pcoinsdbview.get())); // If necessary, upgrade from older database format. // This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate if (!pcoinsdbview->Upgrade()) { strLoadError = _("Error upgrading chainstate database"); break; } // ReplayBlocks is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate if (!ReplayBlocks(chainparams, pcoinsdbview.get())) { strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate."); break; } // The on-disk coinsdb is now in a good state, create the cache pcoinsTip.reset(new CCoinsViewCache(pcoinscatcher.get())); bool is_coinsview_empty = fReset || fReindexChainState || pcoinsTip->GetBestBlock().IsNull(); if (!is_coinsview_empty) { // LoadChainTip sets chainActive based on pcoinsTip's best block if (!LoadChainTip(chainparams)) { strLoadError = _("Error initializing block database"); break; } assert(chainActive.Tip() != nullptr); } if (!fReset) { // Note that RewindBlockIndex MUST run even if we're about to -reindex-chainstate. // It both disconnects blocks based on chainActive, and drops block data in // mapBlockIndex based on lack of available witness data. uiInterface.InitMessage(_("Rewinding blocks...")); if (!RewindBlockIndex(chainparams)) { strLoadError = _("Unable to rewind the database to a pre-fork state. You will need to redownload the blockchain"); break; } } if (!is_coinsview_empty) { uiInterface.InitMessage(_("Verifying blocks...")); if (fHavePruned && gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) { LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks", MIN_BLOCKS_TO_KEEP); } { LOCK(cs_main); CBlockIndex* tip = chainActive.Tip(); RPCNotifyBlockChange(true, tip); if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) { strLoadError = _("The block database contains a block which appears to be from the future. " "This may be due to your computer's date and time being set incorrectly. " "Only rebuild the block database if you are sure that your computer's date and time are correct"); break; } } if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview.get(), gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL), gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) { strLoadError = _("Corrupted block database detected"); break; } } } catch (const std::exception& e) { LogPrintf("%s\n", e.what()); strLoadError = _("Error opening block database"); break; } fLoaded = true; } while(false); if (!fLoaded && !fRequestShutdown) { // first suggest a reindex if (!fReset) { bool fRet = uiInterface.ThreadSafeQuestion( strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?"), strLoadError + ".\nPlease restart with -reindex or -reindex-chainstate to recover.", "", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT); if (fRet) { fReindex = true; fRequestShutdown = false; } else { LogPrintf("Aborted block database rebuild. Exiting.\n"); return false; } } else { return InitError(strLoadError); } } } // As LoadBlockIndex can take several minutes, it's possible the user // requested to kill the GUI during the last operation. If so, exit. // As the program has not fully started yet, Shutdown() is possibly overkill. if (fRequestShutdown) { LogPrintf("Shutdown requested. Exiting.\n"); return false; } if (fLoaded) { LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); } fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; CAutoFile est_filein(fsbridge::fopen(est_path, "rb"), SER_DISK, CLIENT_VERSION); // Allowed to fail as this file IS missing on first startup. if (!est_filein.IsNull()) ::feeEstimator.Read(est_filein); fFeeEstimatesInitialized = true; // ********************************************************* Step 8: load wallet #ifdef ENABLE_WALLET if (!OpenWallets()) return false; #else LogPrintf("No wallet support compiled in!\n"); #endif // ********************************************************* Step 9: data directory maintenance // if pruning, unset the service bit and perform the initial blockstore prune // after any wallet rescanning has taken place. if (fPruneMode) { LogPrintf("Unsetting NODE_NETWORK on prune mode\n"); nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK); if (!fReindex) { uiInterface.InitMessage(_("Pruning blockstore...")); PruneAndFlush(); } } if (chainparams.GetConsensus().vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0) { // Only advertise witness capabilities if they have a reasonable start time. // This allows us to have the code merged without a defined softfork, by setting its // end time to 0. // Note that setting NODE_WITNESS is never required: the only downside from not // doing so is that after activation, no upgraded nodes will fetch from you. nLocalServices = ServiceFlags(nLocalServices | NODE_WITNESS); } // ********************************************************* Step 10: import blocks if (!CheckDiskSpace()) return false; // Either install a handler to notify us when genesis activates, or set fHaveGenesis directly. // No locking, as this happens before any background thread is started. if (chainActive.Tip() == nullptr) { uiInterface.NotifyBlockTip.connect(BlockNotifyGenesisWait); } else { fHaveGenesis = true; } if (gArgs.IsArgSet("-blocknotify")) uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); std::vector<fs::path> vImportFiles; for (const std::string& strFile : gArgs.GetArgs("-loadblock")) { vImportFiles.push_back(strFile); } threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); // Wait for genesis block to be processed { WaitableLock lock(cs_GenesisWait); // We previously could hang here if StartShutdown() is called prior to // ThreadImport getting started, so instead we just wait on a timer to // check ShutdownRequested() regularly. while (!fHaveGenesis && !ShutdownRequested()) { condvar_GenesisWait.wait_for(lock, std::chrono::milliseconds(500)); } uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); } if (ShutdownRequested()) { return false; } // ********************************************************* Step 11: start node int chain_active_height; //// debug print { LOCK(cs_main); LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); chain_active_height = chainActive.Height(); } LogPrintf("nBestHeight = %d\n", chain_active_height); if (gArgs.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) StartTorControl(threadGroup, scheduler); Discover(threadGroup); // Map ports with UPnP MapPort(gArgs.GetBoolArg("-upnp", DEFAULT_UPNP)); CConnman::Options connOptions; connOptions.nLocalServices = nLocalServices; connOptions.nMaxConnections = nMaxConnections; connOptions.nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, connOptions.nMaxConnections); connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS; connOptions.nMaxFeeler = 1; connOptions.nBestHeight = chain_active_height; connOptions.uiInterface = &uiInterface; connOptions.m_msgproc = peerLogic.get(); connOptions.nSendBufferMaxSize = 1000*gArgs.GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER); connOptions.nReceiveFloodSize = 1000*gArgs.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); connOptions.m_added_nodes = gArgs.GetArgs("-addnode"); connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe; connOptions.nMaxOutboundLimit = nMaxOutboundLimit; for (const std::string& strBind : gArgs.GetArgs("-bind")) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) { return InitError(ResolveErrMsg("bind", strBind)); } connOptions.vBinds.push_back(addrBind); } for (const std::string& strBind : gArgs.GetArgs("-whitebind")) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, 0, false)) { return InitError(ResolveErrMsg("whitebind", strBind)); } if (addrBind.GetPort() == 0) { return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind)); } connOptions.vWhiteBinds.push_back(addrBind); } for (const auto& net : gArgs.GetArgs("-whitelist")) { CSubNet subnet; LookupSubNet(net.c_str(), subnet); if (!subnet.IsValid()) return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net)); connOptions.vWhitelistedRange.push_back(subnet); } connOptions.vSeedNodes = gArgs.GetArgs("-seednode"); // Initiate outbound connections unless connect=0 connOptions.m_use_addrman_outgoing = !gArgs.IsArgSet("-connect"); if (!connOptions.m_use_addrman_outgoing) { const auto connect = gArgs.GetArgs("-connect"); if (connect.size() != 1 || connect[0] != "0") { connOptions.m_specified_outgoing = connect; } } if (!connman.Start(scheduler, connOptions)) { return false; } // ********************************************************* Step 12: finished SetRPCWarmupFinished(); uiInterface.InitMessage(_("Done loading")); #ifdef ENABLE_WALLET StartWallets(scheduler); #endif return true; }
#include "VM/Vars/Base.hpp" namespace june { VarBool::VarBool(const bool data, const size_t &srcId, const size_t &idx) : VarBase(type_id<VarBool>(), srcId, idx, false, false), _data(data) {} bool &VarBool::get() { return _data; } VarBase *VarBool::copy(const size_t &srcId, const size_t &idx) { return new VarBool(_data, srcId, idx); } void VarBool::set(VarBase *from) { if (from->isa<VarBool>()) { _data = from->as<VarBool>()->get(); } else { _data = false; } } } // namespace june
%ifdef CONFIG { "RegData": { "XMM0": ["0x0", "0x0"], "XMM1": ["0x0101010101010101", "0x0101010101010101"], "XMM2": ["0x0101010101010101", "0x0101010101010101"], "XMM3": ["0x0100010001010100", "0x0100010001010100"] } } %endif mov rdx, 0xe0000000 mov rax, 0x0000000000000000 mov [rdx + 8 * 0], rax mov [rdx + 8 * 1], rax mov rax, 0xFFFFFFFFFFFFFFFF mov [rdx + 8 * 2], rax mov [rdx + 8 * 3], rax mov rax, 0x0101010101010101 mov [rdx + 8 * 4], rax mov [rdx + 8 * 5], rax mov rax, 0xFF000100FF01FF00 mov [rdx + 8 * 6], rax mov [rdx + 8 * 7], rax ; Test with full zero pabsb xmm0, [rdx + 8 * 0] ; Test with full negative pabsb xmm1, [rdx + 8 * 2] ; Test with full positive pabsb xmm2, [rdx + 8 * 4] ; Test a mix pabsb xmm3, [rdx + 8 * 6] hlt
; A155590: 7^n+2^n-1^n. ; 1,8,52,350,2416,16838,117712,823670,5765056,40354118,282476272,1977328790,13841291296,96889018598,678223089232,4747561542710,33232930635136,232630514118278,1628413598172592,11398895185897430 mov $1,7 pow $1,$0 mov $2,2 pow $2,$0 add $1,$2 mov $0,$1 sub $0,1
#include "s2smtp/network/base_channel.hpp" #include "smtp/commands.hpp" #include <boost/test/unit_test.hpp> #include <chrono> #include <string> class mock_channel_t : public s2smtp::network::base_channel_t { public: void write(const std::string &data, s2smtp::network::duration_t timeout = std::chrono::seconds(0)) override { (void)timeout; in << data; } std::string read_until(std::string_view delim, s2smtp::network::duration_t timeout) override { (void)timeout; std::string res; char ldc = *(delim.rbegin()); size_t delim_size = delim.size(), res_size; do { std::string temp; if (!std::getline(out, temp, ldc)) throw std::runtime_error("empty stream"); res += temp + ldc; res_size = res.size(); } while ((res_size < delim_size) || (res.substr(res_size - delim_size, delim_size) != delim)); return res; } void upgrade_to_secure(s2smtp::network::ssl_protocol_t ssl_protocol, s2smtp::network::duration_t timeout) override { (void)ssl_protocol; (void)timeout; handshaked = true; } void clear() { out.str(""); in.str(""); handshaked = false; } std::stringstream out; std::stringstream in; bool handshaked = false; }; BOOST_AUTO_TEST_SUITE(test_commands) BOOST_AUTO_TEST_CASE(test_receive_greeting) { using namespace std::chrono_literals; using namespace s2smtp; mock_channel_t mock; { mock.out << "220 ISIF.USC.EDU Service ready\r\n"; auto reply = command::receive_greeting(mock, 0s); BOOST_CHECK_EQUAL(reply.code, 220); BOOST_CHECK_EQUAL(reply.text(), "ISIF.USC.EDU Service ready"); } { mock.out << "220 mail.example.com SuperSMTP v 6.1.2 Service ready\r\n"; auto reply = command::receive_greeting(mock, 0s); BOOST_CHECK_EQUAL(reply.code, 220); BOOST_CHECK_EQUAL(reply.text(), "mail.example.com SuperSMTP v 6.1.2 Service ready"); } { mock.out << "220 [10.0.0.1] Clueless host service ready\r\n"; auto reply = command::receive_greeting(mock, 0s); BOOST_CHECK_EQUAL(reply.code, 220); BOOST_CHECK_EQUAL(reply.text(), "[10.0.0.1] Clueless host service ready"); } { mock.out << "554\r\n"; auto reply = command::receive_greeting(mock, 0s); BOOST_CHECK_EQUAL(reply.code, 554); BOOST_CHECK_EQUAL(reply.text(), ""); } } BOOST_AUTO_TEST_CASE(test_command_helo) { using namespace std::chrono_literals; using namespace s2smtp; mock_channel_t mock; { std::string test_domain = "USC-ISIF.ARPA"; mock.out << "250 BBN-UNIX.ARPA\r\n"; auto reply = command::helo(mock, test_domain).execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "HELO USC-ISIF.ARPA\r\n"); BOOST_CHECK_EQUAL(reply.code, 250); BOOST_CHECK_EQUAL(reply.text(), "BBN-UNIX.ARPA"); } } BOOST_AUTO_TEST_CASE(test_command_ehlo) { using namespace std::chrono_literals; using namespace s2smtp; mock_channel_t mock; { std::string test_domain = "bar.com"; mock.out << "250-foo.com greets bar.com\r\n"; mock.out << "250-8BITMIME\r\n"; mock.out << "250-SIZE\r\n"; mock.out << "250-DSN\r\n"; mock.out << "250 HELP\r\n"; auto reply = command::ehlo(mock, test_domain).execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "EHLO bar.com\r\n"); BOOST_CHECK_EQUAL(reply.code, 250); BOOST_CHECK_EQUAL(reply.text(), "foo.com greets bar.com\n" "8BITMIME\n" "SIZE\n" "DSN\n" "HELP"); } } BOOST_AUTO_TEST_CASE(test_command_mail_from) { using namespace std::chrono_literals; using namespace s2smtp; using namespace s2smtp::mime; mock_channel_t mock; { mock.out << "250 OK\r\n"; auto reply = command::mail_from(mock, mailbox_t("user", "mail.com", "user")) .execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "MAIL FROM:<user@mail.com>\r\n"); BOOST_CHECK_EQUAL(reply.code, 250); BOOST_CHECK_EQUAL(reply.text(), "OK"); mock.clear(); } { mock.out << "451\r\n"; auto reply = command::mail_from(mock, mailbox_t("user@mail.com", "user")) .execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "MAIL FROM:<user@mail.com>\r\n"); BOOST_CHECK_EQUAL(reply.code, 451); BOOST_CHECK_EQUAL(reply.text(), ""); mock.clear(); } } BOOST_AUTO_TEST_CASE(test_command_rcpt_to) { using namespace std::chrono_literals; using namespace s2smtp; using namespace s2smtp::mime; mock_channel_t mock; { mock.out << "250 OK\r\n"; auto reply = command::rcpt_to(mock, mailbox_t("user", "mail.com", "user")) .execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "RCPT TO:<user@mail.com>\r\n"); BOOST_CHECK_EQUAL(reply.code, 250); BOOST_CHECK_EQUAL(reply.text(), "OK"); mock.clear(); } { mock.out << "451\r\n"; auto reply = command::rcpt_to(mock, mailbox_t("user@mail.com", "user")).execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "RCPT TO:<user@mail.com>\r\n"); BOOST_CHECK_EQUAL(reply.code, 451); BOOST_CHECK_EQUAL(reply.text(), ""); mock.clear(); } } BOOST_AUTO_TEST_CASE(test_command_quit) { using namespace std::chrono_literals; using namespace s2smtp; using namespace s2smtp::mime; mock_channel_t mock; { mock.out << "221 foo.com Service closing transmission channel\r\n"; auto reply = command::quit(mock).execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "QUIT\r\n"); BOOST_CHECK_EQUAL(reply.code, 221); BOOST_CHECK_EQUAL(reply.text(), "foo.com Service closing transmission channel"); } } BOOST_AUTO_TEST_CASE(test_command_starttls) { using namespace std::chrono_literals; using namespace s2smtp; using namespace s2smtp::mime; mock_channel_t mock; { mock.out << "220 Go ahead\r\n"; auto reply = command::starttls(mock, s2smtp::network::ssl_protocol_t::e_tls) .execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "STARTTLS\r\n"); BOOST_CHECK(mock.handshaked); BOOST_CHECK_EQUAL(reply.code, 220); BOOST_CHECK_EQUAL(reply.text(), "Go ahead"); mock.clear(); } { mock.out << "501 Syntax error (no parameters allowed)\r\n"; auto reply = command::starttls(mock, s2smtp::network::ssl_protocol_t::e_tls) .execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "STARTTLS\r\n"); BOOST_CHECK(mock.handshaked == false); BOOST_CHECK_EQUAL(reply.code, 501); BOOST_CHECK_EQUAL(reply.text(), "Syntax error (no parameters allowed)"); mock.clear(); } } BOOST_AUTO_TEST_CASE(test_command_auth_login) { using namespace std::chrono_literals; using namespace s2smtp; using namespace s2smtp::mime; mock_channel_t mock; { mock.out << "334 VXNlciBOYW1lAA==\r\n"; mock.out << "334 UGFzc3dvcmQA\r\n"; mock.out << "235 Authentication successful.\r\n"; auto reply = command::auth_login(mock, "tim", "tanstaaftanstaaf").execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "AUTH LOGIN\r\n" "dGlt\r\n" "dGFuc3RhYWZ0YW5zdGFhZg==\r\n"); BOOST_CHECK_EQUAL(reply.code, 235); BOOST_CHECK_EQUAL(reply.text(), "Authentication successful."); mock.clear(); } { mock.out << "334 VXNlciBOYW1lAA==\r\n"; mock.out << "454 4.7.0 Temporary authentication failure\r\n"; auto reply = command::auth_login(mock, "tim", "tanstaaftanstaaf").execute(0s); BOOST_CHECK_EQUAL(mock.in.str(), "AUTH LOGIN\r\n" "dGlt\r\n"); BOOST_CHECK_EQUAL(reply.code, 454); BOOST_CHECK_EQUAL(reply.text(), "4.7.0 Temporary authentication failure"); mock.clear(); } } BOOST_AUTO_TEST_SUITE_END()
; npctrade struct members (see data/events/npc_trades.asm) NPCTRADE_DIALOG EQU 0 ; db NPCTRADE_GIVEMON EQU 1 ; dw NPCTRADE_GETMON EQU 3 ; dw NPCTRADE_NICK EQU 5 ; ds MON_NAME_LENGTH NPCTRADE_DVS EQU 16 ; dw NPCTRADE_ITEM EQU 18 ; db NPCTRADE_OT_ID EQU 19 ; dw NPCTRADE_OT_NAME EQU 21 ; ds PLAYER_NAME_LENGTH NPCTRADE_GENDER EQU 29 ; db NPCTRADE_PADDING EQU 30 ; ds 2 ; NPCTrades indexes (see data/events/npc_trades.asm) const_def const NPC_TRADE_MIKE ; 0 const NPC_TRADE_KYLE ; 1 const NPC_TRADE_TIM ; 2 const NPC_TRADE_EMY ; 3 const NPC_TRADE_CHRIS ; 4 const NPC_TRADE_KIM ; 5 const NPC_TRADE_FOREST ; 6 NUM_NPC_TRADES EQU const_value ; trade gender limits const_def const TRADE_GENDER_EITHER const TRADE_GENDER_MALE const TRADE_GENDER_FEMALE ; TradeTexts indexes (see engine/events/npc_trade.asm) ; trade dialogs const_def const TRADE_DIALOG_INTRO const TRADE_DIALOG_CANCEL const TRADE_DIALOG_WRONG const TRADE_DIALOG_COMPLETE const TRADE_DIALOG_AFTER ; trade dialog sets const_def const TRADE_DIALOGSET_COLLECTOR const TRADE_DIALOGSET_HAPPY const TRADE_DIALOGSET_NEWBIE const TRADE_DIALOGSET_GIRL
; A184585: floor[(n+1/3)(1+r)], where r=sqrt(5); complement of A184584. ; 2,4,6,7,9,11,13,15,16,18,20,22,24,25,27,29,31,33,34,36,38,40,42,44,45,47,49,51,53,54,56,58,60,62,63,65,67,69,71,72,74,76,78,80,82,83,85,87,89,91,92,94,96,98,100,101,103,105,107,109,110,112,114,116,118,119,121,123,125,127,129,130,132,134,136,138,139,141,143,145,147,148,150,152,154,156,157,159,161,163,165,167,168,170,172,174,176,177,179,181,183,185,186,188,190,192,194,195,197,199,201,203,205,206,208,210,212,214,215,217 mov $2,$0 add $0,2 cal $0,330063 ; Beatty sequence for x, where 1/x + sech(x) = 1. div $0,2 mov $1,$0 add $1,$2
; A075839: Numbers k such that 11*k^2 - 2 is a square. ; Submitted by Jamie Morken(s1) ; 1,19,379,7561,150841,3009259,60034339,1197677521,23893516081,476672644099,9509559365899,189714514673881,3784780734111721,75505900167560539,1506333222617099059,30051158552174420641,599516837820871313761,11960285597865251854579,238606195119484165777819,4760163616791818063701801,94964666140716877108258201,1894533159197545724101462219,37795698517810197604920986179,754019437197006406374318261361,15042593045422317929881444241041,300097841471249352191254566559459,5986914236379564725895209886948139 lpb $0 sub $0,1 mov $1,$3 mul $1,18 add $2,1 add $2,$1 add $3,$2 lpe mov $0,$3 mul $0,18 add $0,1
; A165866: Totally multiplicative sequence with a(p) = 45. ; 1,45,45,2025,45,2025,45,91125,2025,2025,45,91125,45,2025,2025,4100625,45,91125,45,91125,2025,2025,45,4100625,2025,2025,91125,91125,45,91125,45,184528125,2025,2025,2025,4100625,45,2025,2025,4100625,45,91125,45,91125,91125,2025,45,184528125,2025,91125,2025,91125,45,4100625,2025,4100625,2025,2025,45,4100625,45,2025,91125,8303765625,2025,91125,45,91125,2025,91125,45,184528125,45,2025,91125,91125,2025,91125,45,184528125,4100625,2025,45,4100625,2025,2025,2025,4100625,45,4100625,2025,91125,2025,2025,2025,8303765625,45,91125,91125,4100625 seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)). mov $1,45 pow $1,$0 mov $0,$1
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2018 The PIVX developers // Copyright (c) 2018 The XIM developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "addresstablemodel.h" #include "guiutil.h" #include "walletmodel.h" #include "base58.h" #include "wallet.h" #include "askpassphrasedialog.h" #include <QDebug> #include <QFont> const QString AddressTableModel::Send = "S"; const QString AddressTableModel::Receive = "R"; const QString AddressTableModel::Zerocoin = "X"; struct AddressTableEntry { enum Type { Sending, Receiving, Zerocoin, Hidden /* QSortFilterProxyModel will filter these out */ }; Type type; QString label; QString address; QString pubcoin; AddressTableEntry() {} AddressTableEntry(Type type, const QString &pubcoin): type(type), pubcoin(pubcoin) {} AddressTableEntry(Type type, const QString& label, const QString& address) : type(type), label(label), address(address) {} }; struct AddressTableEntryLessThan { bool operator()(const AddressTableEntry& a, const AddressTableEntry& b) const { return a.address < b.address; } bool operator()(const AddressTableEntry& a, const QString& b) const { return a.address < b; } bool operator()(const QString& a, const AddressTableEntry& b) const { return a < b.address; } }; /* Determine address type from address purpose */ static AddressTableEntry::Type translateTransactionType(const QString& strPurpose, bool isMine) { AddressTableEntry::Type addressType = AddressTableEntry::Hidden; // "refund" addresses aren't shown, and change addresses aren't in mapAddressBook at all. if (strPurpose == "send") addressType = AddressTableEntry::Sending; else if (strPurpose == "receive") addressType = AddressTableEntry::Receiving; else if (strPurpose == "unknown" || strPurpose == "") // if purpose not set, guess addressType = (isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending); return addressType; } // Private implementation class AddressTablePriv { public: CWallet* wallet; QList<AddressTableEntry> cachedAddressTable; AddressTableModel* parent; AddressTablePriv(CWallet* wallet, AddressTableModel* parent) : wallet(wallet), parent(parent) {} void refreshAddressTable() { cachedAddressTable.clear(); { LOCK(wallet->cs_wallet); BOOST_FOREACH (const PAIRTYPE(CTxDestination, CAddressBookData) & item, wallet->mapAddressBook) { const CBitcoinAddress& address = item.first; bool fMine = IsMine(*wallet, address.Get()); AddressTableEntry::Type addressType = translateTransactionType( QString::fromStdString(item.second.purpose), fMine); const std::string& strName = item.second.name; cachedAddressTable.append(AddressTableEntry(addressType, QString::fromStdString(strName), QString::fromStdString(address.ToString()))); } } // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order // Even though the map is already sorted this re-sorting step is needed because the originating map // is sorted by binary address, not by base58() address. qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); } void updateEntry(const QString& address, const QString& label, bool isMine, const QString& purpose, int status) { // Find address / label in model QList<AddressTableEntry>::iterator lower = qLowerBound( cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); QList<AddressTableEntry>::iterator upper = qUpperBound( cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); int lowerIndex = (lower - cachedAddressTable.begin()); int upperIndex = (upper - cachedAddressTable.begin()); bool inModel = (lower != upper); AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine); switch (status) { case CT_NEW: if (inModel) { qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_NEW, but entry is already in model"; break; } parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex); cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address)); parent->endInsertRows(); break; case CT_UPDATED: if (!inModel) { qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model"; break; } lower->type = newEntryType; lower->label = label; parent->emitDataChanged(lowerIndex); break; case CT_DELETED: if (!inModel) { qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model"; break; } parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex - 1); cachedAddressTable.erase(lower, upper); parent->endRemoveRows(); break; } } void updateEntry(const QString &pubCoin, const QString &isUsed, int status) { // Find address / label in model QList<AddressTableEntry>::iterator lower = qLowerBound( cachedAddressTable.begin(), cachedAddressTable.end(), pubCoin, AddressTableEntryLessThan()); QList<AddressTableEntry>::iterator upper = qUpperBound( cachedAddressTable.begin(), cachedAddressTable.end(), pubCoin, AddressTableEntryLessThan()); int lowerIndex = (lower - cachedAddressTable.begin()); bool inModel = (lower != upper); AddressTableEntry::Type newEntryType = AddressTableEntry::Zerocoin; switch(status) { case CT_NEW: if(inModel) { qWarning() << "AddressTablePriv_ZC::updateEntry : Warning: Got CT_NEW, but entry is already in model"; } parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex); cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, isUsed, pubCoin)); parent->endInsertRows(); break; case CT_UPDATED: if(!inModel) { qWarning() << "AddressTablePriv_ZC::updateEntry : Warning: Got CT_UPDATED, but entry is not in model"; break; } lower->type = newEntryType; lower->label = isUsed; parent->emitDataChanged(lowerIndex); break; } } int size() { return cachedAddressTable.size(); } AddressTableEntry* index(int idx) { if (idx >= 0 && idx < cachedAddressTable.size()) { return &cachedAddressTable[idx]; } else { return 0; } } }; AddressTableModel::AddressTableModel(CWallet* wallet, WalletModel* parent) : QAbstractTableModel(parent), walletModel(parent), wallet(wallet), priv(0) { columns << tr("Label") << tr("Address"); priv = new AddressTablePriv(wallet, this); priv->refreshAddressTable(); } AddressTableModel::~AddressTableModel() { delete priv; } int AddressTableModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); return priv->size(); } int AddressTableModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); return columns.length(); } QVariant AddressTableModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); AddressTableEntry* rec = static_cast<AddressTableEntry*>(index.internalPointer()); if (role == Qt::DisplayRole || role == Qt::EditRole) { switch (index.column()) { case Label: if (rec->label.isEmpty() && role == Qt::DisplayRole) { return tr("(no label)"); } else { return rec->label; } case Address: return rec->address; } } else if (role == Qt::FontRole) { QFont font; if (index.column() == Address) { font = GUIUtil::bitcoinAddressFont(); } return font; } else if (role == TypeRole) { switch (rec->type) { case AddressTableEntry::Sending: return Send; case AddressTableEntry::Receiving: return Receive; default: break; } } return QVariant(); } bool AddressTableModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (!index.isValid()) return false; AddressTableEntry* rec = static_cast<AddressTableEntry*>(index.internalPointer()); std::string strPurpose = (rec->type == AddressTableEntry::Sending ? "send" : "receive"); editStatus = OK; if (role == Qt::EditRole) { LOCK(wallet->cs_wallet); /* For SetAddressBook / DelAddressBook */ CTxDestination curAddress = CBitcoinAddress(rec->address.toStdString()).Get(); if (index.column() == Label) { // Do nothing, if old label == new label if (rec->label == value.toString()) { editStatus = NO_CHANGES; return false; } wallet->SetAddressBook(curAddress, value.toString().toStdString(), strPurpose); } else if (index.column() == Address) { CTxDestination newAddress = CBitcoinAddress(value.toString().toStdString()).Get(); // Refuse to set invalid address, set error status and return false if (boost::get<CNoDestination>(&newAddress)) { editStatus = INVALID_ADDRESS; return false; } // Do nothing, if old address == new address else if (newAddress == curAddress) { editStatus = NO_CHANGES; return false; } // Check for duplicate addresses to prevent accidental deletion of addresses, if you try // to paste an existing address over another address (with a different label) else if (wallet->mapAddressBook.count(newAddress)) { editStatus = DUPLICATE_ADDRESS; return false; } // Double-check that we're not overwriting a receiving address else if (rec->type == AddressTableEntry::Sending) { // Remove old entry wallet->DelAddressBook(curAddress); // Add new entry with new address wallet->SetAddressBook(newAddress, rec->label.toStdString(), strPurpose); } } return true; } return false; } QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal) { if (role == Qt::DisplayRole && section < columns.size()) { return columns[section]; } } return QVariant(); } Qt::ItemFlags AddressTableModel::flags(const QModelIndex& index) const { if (!index.isValid()) return 0; AddressTableEntry* rec = static_cast<AddressTableEntry*>(index.internalPointer()); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; // Can edit address and label for sending addresses, // and only label for receiving addresses. if (rec->type == AddressTableEntry::Sending || (rec->type == AddressTableEntry::Receiving && index.column() == Label)) { retval |= Qt::ItemIsEditable; } return retval; } QModelIndex AddressTableModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); AddressTableEntry* data = priv->index(row); if (data) { return createIndex(row, column, priv->index(row)); } else { return QModelIndex(); } } void AddressTableModel::updateEntry(const QString& address, const QString& label, bool isMine, const QString& purpose, int status) { // Update address book model from XimBlock core priv->updateEntry(address, label, isMine, purpose, status); } void AddressTableModel::updateEntry(const QString &pubCoin, const QString &isUsed, int status) { // Update stealth address book model from Bitcoin core priv->updateEntry(pubCoin, isUsed, status); } QString AddressTableModel::addRow(const QString& type, const QString& label, const QString& address) { std::string strLabel = label.toStdString(); std::string strAddress = address.toStdString(); editStatus = OK; if (type == Send) { if (!walletModel->validateAddress(address)) { editStatus = INVALID_ADDRESS; return QString(); } // Check for duplicate addresses { LOCK(wallet->cs_wallet); if (wallet->mapAddressBook.count(CBitcoinAddress(strAddress).Get())) { editStatus = DUPLICATE_ADDRESS; return QString(); } } } else if (type == Receive) { // Generate a new address to associate with given label CPubKey newKey; if (!wallet->GetKeyFromPool(newKey)) { WalletModel::UnlockContext ctx(walletModel->requestUnlock(AskPassphraseDialog::Context::Unlock_Full, true)); if (!ctx.isValid()) { // Unlock wallet failed or was cancelled editStatus = WALLET_UNLOCK_FAILURE; return QString(); } if (!wallet->GetKeyFromPool(newKey)) { editStatus = KEY_GENERATION_FAILURE; return QString(); } } strAddress = CBitcoinAddress(newKey.GetID()).ToString(); } else { return QString(); } // Add entry { LOCK(wallet->cs_wallet); wallet->SetAddressBook(CBitcoinAddress(strAddress).Get(), strLabel, (type == Send ? "send" : "receive")); } return QString::fromStdString(strAddress); } bool AddressTableModel::removeRows(int row, int count, const QModelIndex& parent) { Q_UNUSED(parent); AddressTableEntry* rec = priv->index(row); if (count != 1 || !rec || rec->type == AddressTableEntry::Receiving) { // Can only remove one row at a time, and cannot remove rows not in model. // Also refuse to remove receiving addresses. return false; } { LOCK(wallet->cs_wallet); wallet->DelAddressBook(CBitcoinAddress(rec->address.toStdString()).Get()); } return true; } /* Look up label for address in address book, if not found return empty string. */ QString AddressTableModel::labelForAddress(const QString& address) const { { LOCK(wallet->cs_wallet); CBitcoinAddress address_parsed(address.toStdString()); std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(address_parsed.Get()); if (mi != wallet->mapAddressBook.end()) { return QString::fromStdString(mi->second.name); } } return QString(); } int AddressTableModel::lookupAddress(const QString& address) const { QModelIndexList lst = match(index(0, Address, QModelIndex()), Qt::EditRole, address, 1, Qt::MatchExactly); if (lst.isEmpty()) { return -1; } else { return lst.at(0).row(); } } void AddressTableModel::emitDataChanged(int idx) { emit dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length() - 1, QModelIndex())); }
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 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 "primitives/transaction.h" #include "hash.h" #include "tinyformat.h" #include "utilstrencodings.h" #include "librustzcash.h" JSDescription::JSDescription( bool makeGrothProof, ZCJoinSplit& params, const uint256& joinSplitPubKey, const uint256& anchor, const std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs, const std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs, CAmount vpub_old, CAmount vpub_new, bool computeProof, uint256 *esk // payment disclosure ) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor) { std::array<libzcash::SproutNote, ZC_NUM_JS_OUTPUTS> notes; proof = params.prove( makeGrothProof, inputs, outputs, notes, ciphertexts, ephemeralKey, joinSplitPubKey, randomSeed, macs, nullifiers, commitments, vpub_old, vpub_new, anchor, computeProof, esk // payment disclosure ); } JSDescription JSDescription::Randomized( bool makeGrothProof, ZCJoinSplit& params, const uint256& joinSplitPubKey, const uint256& anchor, std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs, std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs, std::array<size_t, ZC_NUM_JS_INPUTS>& inputMap, std::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap, CAmount vpub_old, CAmount vpub_new, bool computeProof, uint256 *esk, // payment disclosure std::function<int(int)> gen ) { // Randomize the order of the inputs and outputs inputMap = {0, 1}; outputMap = {0, 1}; assert(gen); MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen); MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen); return JSDescription( makeGrothProof, params, joinSplitPubKey, anchor, inputs, outputs, vpub_old, vpub_new, computeProof, esk // payment disclosure ); } class SproutProofVerifier : public boost::static_visitor<bool> { ZCJoinSplit& params; libzcash::ProofVerifier& verifier; const uint256& joinSplitPubKey; const JSDescription& jsdesc; public: SproutProofVerifier( ZCJoinSplit& params, libzcash::ProofVerifier& verifier, const uint256& joinSplitPubKey, const JSDescription& jsdesc ) : params(params), jsdesc(jsdesc), verifier(verifier), joinSplitPubKey(joinSplitPubKey) {} bool operator()(const libzcash::PHGRProof& proof) const { return params.verify( proof, verifier, joinSplitPubKey, jsdesc.randomSeed, jsdesc.macs, jsdesc.nullifiers, jsdesc.commitments, jsdesc.vpub_old, jsdesc.vpub_new, jsdesc.anchor ); } bool operator()(const libzcash::GrothProof& proof) const { uint256 h_sig = params.h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey); return librustzcash_sprout_verify( proof.begin(), jsdesc.anchor.begin(), h_sig.begin(), jsdesc.macs[0].begin(), jsdesc.macs[1].begin(), jsdesc.nullifiers[0].begin(), jsdesc.nullifiers[1].begin(), jsdesc.commitments[0].begin(), jsdesc.commitments[1].begin(), jsdesc.vpub_old, jsdesc.vpub_new ); } }; bool JSDescription::Verify( ZCJoinSplit& params, libzcash::ProofVerifier& verifier, const uint256& joinSplitPubKey ) const { auto pv = SproutProofVerifier(params, verifier, joinSplitPubKey, *this); return boost::apply_visitor(pv, proof); } uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const { return params.h_sig(randomSeed, nullifiers, joinSplitPubKey); } std::string COutPoint::ToString() const { return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); } std::string SaplingOutPoint::ToString() const { return strprintf("SaplingOutPoint(%s, %u)", hash.ToString().substr(0, 10), n); } CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, uint32_t nSequenceIn) { prevout = prevoutIn; scriptSig = scriptSigIn; nSequence = nSequenceIn; } CTxIn::CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn, uint32_t nSequenceIn) { prevout = COutPoint(hashPrevTx, nOut); scriptSig = scriptSigIn; nSequence = nSequenceIn; } std::string CTxIn::ToString() const { std::string str; str += "CTxIn("; str += prevout.ToString(); if (prevout.IsNull()) str += strprintf(", coinbase %s", HexStr(scriptSig)); else str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24)); if (nSequence != std::numeric_limits<unsigned int>::max()) str += strprintf(", nSequence=%u", nSequence); str += ")"; return str; } CTxOut::CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn) { nValue = nValueIn; scriptPubKey = scriptPubKeyIn; } uint256 CTxOut::GetHash() const { return SerializeHash(*this); } std::string CTxOut::ToString() const { return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30)); } CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION), fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0), nLockTime(0), valueBalance(0) {} CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), valueBalance(tx.valueBalance), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput), vjoinsplit(tx.vjoinsplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig), bindingSig(tx.bindingSig) { } uint256 CMutableTransaction::GetHash() const { return SerializeHash(*this); } void CTransaction::UpdateHash() const { *const_cast<uint256*>(&hash) = SerializeHash(*this); } CTransaction::CTransaction() : nVersion(CTransaction::SPROUT_MIN_CURRENT_VERSION), fOverwintered(false), nVersionGroupId(0), nExpiryHeight(0), vin(), vout(), nLockTime(0), valueBalance(0), vShieldedSpend(), vShieldedOutput(), vjoinsplit(), joinSplitPubKey(), joinSplitSig(), bindingSig() { } CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), valueBalance(tx.valueBalance), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput), vjoinsplit(tx.vjoinsplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig), bindingSig(tx.bindingSig) { UpdateHash(); } // Protected constructor which only derived classes can call. // For developer testing only. CTransaction::CTransaction( const CMutableTransaction &tx, bool evilDeveloperFlag) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), nExpiryHeight(tx.nExpiryHeight), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), valueBalance(tx.valueBalance), vShieldedSpend(tx.vShieldedSpend), vShieldedOutput(tx.vShieldedOutput), vjoinsplit(tx.vjoinsplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig), bindingSig(tx.bindingSig) { assert(evilDeveloperFlag); } CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), vin(std::move(tx.vin)), vout(std::move(tx.vout)), nLockTime(tx.nLockTime), nExpiryHeight(tx.nExpiryHeight), valueBalance(tx.valueBalance), vShieldedSpend(std::move(tx.vShieldedSpend)), vShieldedOutput(std::move(tx.vShieldedOutput)), vjoinsplit(std::move(tx.vjoinsplit)), joinSplitPubKey(std::move(tx.joinSplitPubKey)), joinSplitSig(std::move(tx.joinSplitSig)) { UpdateHash(); } CTransaction& CTransaction::operator=(const CTransaction &tx) { *const_cast<bool*>(&fOverwintered) = tx.fOverwintered; *const_cast<int*>(&nVersion) = tx.nVersion; *const_cast<uint32_t*>(&nVersionGroupId) = tx.nVersionGroupId; *const_cast<std::vector<CTxIn>*>(&vin) = tx.vin; *const_cast<std::vector<CTxOut>*>(&vout) = tx.vout; *const_cast<unsigned int*>(&nLockTime) = tx.nLockTime; *const_cast<uint32_t*>(&nExpiryHeight) = tx.nExpiryHeight; *const_cast<CAmount*>(&valueBalance) = tx.valueBalance; *const_cast<std::vector<SpendDescription>*>(&vShieldedSpend) = tx.vShieldedSpend; *const_cast<std::vector<OutputDescription>*>(&vShieldedOutput) = tx.vShieldedOutput; *const_cast<std::vector<JSDescription>*>(&vjoinsplit) = tx.vjoinsplit; *const_cast<uint256*>(&joinSplitPubKey) = tx.joinSplitPubKey; *const_cast<joinsplit_sig_t*>(&joinSplitSig) = tx.joinSplitSig; *const_cast<binding_sig_t*>(&bindingSig) = tx.bindingSig; *const_cast<uint256*>(&hash) = tx.hash; return *this; } CAmount CTransaction::GetValueOut() const { CAmount nValueOut = 0; for (std::vector<CTxOut>::const_iterator it(vout.begin()); it != vout.end(); ++it) { nValueOut += it->nValue; if (!MoneyRange(it->nValue) || !MoneyRange(nValueOut)) throw std::runtime_error("CTransaction::GetValueOut(): value out of range"); } if (valueBalance <= 0) { // NB: negative valueBalance "takes" money from the transparent value pool just as outputs do nValueOut += -valueBalance; if (!MoneyRange(-valueBalance) || !MoneyRange(nValueOut)) { throw std::runtime_error("CTransaction::GetValueOut(): value out of range"); } } for (std::vector<JSDescription>::const_iterator it(vjoinsplit.begin()); it != vjoinsplit.end(); ++it) { // NB: vpub_old "takes" money from the transparent value pool just as outputs do nValueOut += it->vpub_old; if (!MoneyRange(it->vpub_old) || !MoneyRange(nValueOut)) throw std::runtime_error("CTransaction::GetValueOut(): value out of range"); } return nValueOut; } // SAPLINGTODO: make this accurate for all transactions, including sapling CAmount CTransaction::GetShieldedValueIn() const { CAmount nValue = 0; if (valueBalance >= 0) { // NB: positive valueBalance "gives" money to the transparent value pool just as inputs do nValue += valueBalance; if (!MoneyRange(valueBalance) || !MoneyRange(nValue)) { throw std::runtime_error("CTransaction::GetShieldedValueIn(): value out of range"); } } for (std::vector<JSDescription>::const_iterator it(vjoinsplit.begin()); it != vjoinsplit.end(); ++it) { // NB: vpub_new "gives" money to the transparent value pool just as inputs do nValue += it->vpub_new; if (!MoneyRange(it->vpub_new) || !MoneyRange(nValue)) throw std::runtime_error("CTransaction::GetShieldedValueIn(): value out of range"); } return nValue; } double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSize) const { nTxSize = CalculateModifiedSize(nTxSize); if (nTxSize == 0) return 0.0; return dPriorityInputs / nTxSize; } unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const { // In order to avoid disincentivizing cleaning up the UTXO set we don't count // the constant overhead for each txin and up to 110 bytes of scriptSig (which // is enough to cover a compressed pubkey p2sh redemption) for priority. // Providing any more cleanup incentive than making additional inputs free would // risk encouraging people to create junk outputs to redeem later. if (nTxSize == 0) nTxSize = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION); for (std::vector<CTxIn>::const_iterator it(vin.begin()); it != vin.end(); ++it) { unsigned int offset = 41U + std::min(110U, (unsigned int)it->scriptSig.size()); if (nTxSize > offset) nTxSize -= offset; } return nTxSize; } // will return the open time or block if this is a time locked transaction output that we recognize. // if we can't determine that it has a valid time lock, it returns 0 int64_t CTransaction::UnlockTime(uint32_t voutNum) const { if (vout.size() > voutNum + 1 && vout[voutNum].scriptPubKey.IsPayToScriptHash()) { uint32_t voutNext = voutNum + 1; std::vector<uint8_t> opretData; uint160 scriptID = uint160(std::vector<unsigned char>(vout[voutNum].scriptPubKey.begin() + 2, vout[voutNum].scriptPubKey.begin() + 22)); CScript::const_iterator it = vout[voutNext].scriptPubKey.begin() + 1; opcodetype op; if (vout[voutNext].scriptPubKey.GetOp2(it, op, &opretData)) { if (opretData.size() > 0 && opretData.data()[0] == OPRETTYPE_TIMELOCK) { int64_t unlocktime; CScript opretScript = CScript(opretData.begin() + 1, opretData.end()); if (Hash160(opretScript) == scriptID && opretScript.IsCheckLockTimeVerify(&unlocktime)) { return(unlocktime); } } } } return(0); } std::string CTransaction::ToString() const { std::string str; if (!fOverwintered) { str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n", GetHash().ToString().substr(0,10), nVersion, vin.size(), vout.size(), nLockTime); } else if (nVersion >= SAPLING_MIN_TX_VERSION) { str += strprintf("CTransaction(hash=%s, ver=%d, fOverwintered=%d, nVersionGroupId=%08x, vin.size=%u, vout.size=%u, nLockTime=%u, nExpiryHeight=%u, valueBalance=%u, vShieldedSpend.size=%u, vShieldedOutput.size=%u)\n", GetHash().ToString().substr(0,10), nVersion, fOverwintered, nVersionGroupId, vin.size(), vout.size(), nLockTime, nExpiryHeight, valueBalance, vShieldedSpend.size(), vShieldedOutput.size()); } else if (nVersion >= 3) { str += strprintf("CTransaction(hash=%s, ver=%d, fOverwintered=%d, nVersionGroupId=%08x, vin.size=%u, vout.size=%u, nLockTime=%u, nExpiryHeight=%u)\n", GetHash().ToString().substr(0,10), nVersion, fOverwintered, nVersionGroupId, vin.size(), vout.size(), nLockTime, nExpiryHeight); } for (unsigned int i = 0; i < vin.size(); i++) str += " " + vin[i].ToString() + "\n"; for (unsigned int i = 0; i < vout.size(); i++) str += " " + vout[i].ToString() + "\n"; return str; }
#include "NormalTraderAgent.h" #include "../exchange/exchange_api/ExchangeApi.h" #include "../exchange/exchange_api/TraderRecordInExchange.h" using exchange::TraderStock; void trader::NormalTraderAgent::choose_random_settings() { auto get_norm_normal = [this]() { return this->rng->next_f64_normal(0, 1, 0.5, 0.2); }; this->position_count = this->rng->next_usize(1, this->config->get_max_trader_positions()); this->finance_bias = get_norm_normal(); this->leadership_bias = get_norm_normal(); this->sector_focus = this->rng->next_normal(); this->focus_sector_threshold = get_norm_normal(); this->volume_sensitivity = get_norm_normal(); this->price_sensitivity = get_norm_normal(); this->nonce_focus = this->rng->next_f64(0, 1); this->stop_loss = get_norm_normal() + 0.2; this->bought_bias = get_norm_normal() / 2.0; this->stop_win = this->rng->next_f64(0.05, 0.20); } void trader::NormalTraderAgent::on_cycle(exchange::ExchangeApi &api) { this->adjust_profiles_with_events(api); this->adjust_profiles_with_price_data(api); this->negotiate_orders(api); this->sell_stocks(api); this->buy_up_stocks(api); this->had_cycle = true; } void trader::NormalTraderAgent::init(trader::TraderAgentInitPayload payload) { TraderAgent::init(payload); for (usize ii = 0; ii < payload.companies->size(); ii++) { auto el = payload.companies->at(ii); this->company_profiles.push_back(TraderCompanyProfile{ el->get_id(), this->get_fundamentals(el), 0, 0, 0, }); } this->position_count = std::min(this->position_count, payload.companies->size()); } f64 trader::NormalTraderAgent::get_fundamentals(const Rc<Company> &cmp) { const auto base_rk = this->leadership_bias + this->finance_bias + this->focus_sector_threshold; auto sector_bias = std::abs(cmp->get_sector() - this->sector_focus) * this->focus_sector_threshold; auto lds = cmp->get_leadership() * this->leadership_bias; auto fns = cmp->get_financials() * this->finance_bias; return (lds + fns + sector_bias) / base_rk; } void trader::NormalTraderAgent::buy_up_stocks(ExchangeApi &api) { auto positions = api.get_owned_stocks(); auto target_pos_count = (usize) std::max((int) this->position_count - (int) positions.size(), 0); for (usize ii = 0; ii < target_pos_count; ++ii) { this->buy_one_stock(api); } } void trader::NormalTraderAgent::buy_one_stock(ExchangeApi &api) { auto cmp = this->choose_company_to_buy(api); if (!cmp) { return; } auto cmp_prof = this->company_profiles.find([&cmp](Rc<TraderCompanyProfile> prof) { return prof->company_id == cmp->get_id(); }); if (!cmp_prof) { return; } auto worth = this->get_per_stock_spending(api.get_trader_available_balance()) * (1 + this->rng->next_f64(0, 0.2) - 0.1); auto base_pr = cmp->get_stock_price(); auto adjusted_negotiation_pr = (usize) (base_pr * (1 - NormalTraderAgent::negotiation_percentage(cmp_prof->sentiment, 0))); auto price_per_share = std::max(adjusted_negotiation_pr, (usize) 1); auto shares = (usize) std::floor(worth / price_per_share); if (shares < 1) { return; } if (shares * price_per_share > api.get_trader_available_balance()) { return; } // api.get_cli()->os() << "T opening Buy: " << this->get_id() <<", " << shares << " symb: "<< cmp->get_symbol(); // api.get_cli()->print_ln(); api.open_order(exchange::OrderCreationPayload{ exchange::OrderType::Buy, cmp->get_id(), shares, price_per_share, Option<usize>() }); } Rc<Company> trader::NormalTraderAgent::choose_company_to_buy(ExchangeApi &api) { auto positions = api.get_owned_stocks(); auto sorted_profiles = this->company_profiles.sort_by([](Rc<TraderCompanyProfile> aa, Rc<TraderCompanyProfile> bb) { return aa->sentiment > bb->sentiment; }); auto at_profile = (usize) 0; auto market = api.get_market_context(); auto company_chosen = nhflib::make_rc<Company>(); while (true) { if (at_profile == sorted_profiles.size() || company_chosen) { break; } auto profile = sorted_profiles.at(at_profile); auto comp = market.companies->find([&profile](Rc<Company> cmp) { return cmp->get_id() == profile->company_id; }); auto has_pos = positions.some([&profile](Rc<TraderStock> stc) { return stc->company_id == profile->company_id; }); auto has_open_order = api.get_orders().some([&profile](Rc<Order> ord) { return ord->company_id == profile->company_id; }); auto can_afford = comp->get_ask().unwrap_or(0) >= this->get_per_stock_spending(api.get_trader_available_balance()); if (has_pos || has_open_order || !comp->get_had_an_ipo() || can_afford) { at_profile++; continue; } company_chosen = comp; } return company_chosen; } bool trader::NormalTraderAgent::is_retail() const { return true; } void trader::NormalTraderAgent::adjust_profiles_with_events(ExchangeApi &api) { auto evs = api.get_unseen_events(); for (auto ev: evs) { if (ev->target == event::EventTarget::Global) { this->adjust_with_global_event(ev); } else if (ev->target == event::EventTarget::Sector) { this->adjust_with_sector(api, ev); } else { this->adjust_with_company(api, ev); } } } void trader::NormalTraderAgent::adjust_with_global_event(Rc<Event> event) { for (auto prof : this->company_profiles) { auto sent_diff = this->get_event_personal_take(event); prof->sentiment += sent_diff; } } void trader::NormalTraderAgent::adjust_with_sector(ExchangeApi &api, Rc<Event> event) { auto companies = api.get_market_context().companies; for (auto prof : this->company_profiles) { auto cmp = companies->find([&prof](Rc<Company> aa) { return aa->get_id() == prof->company_id; }); auto sent_diff = this->get_event_personal_take(event); auto sector_diff = 1 - std::abs(cmp->get_sector() - event->sector_target.unwrap_or(0.5)); prof->sentiment += sent_diff * sector_diff * event->weight; } } void trader::NormalTraderAgent::adjust_with_company(ExchangeApi &api, Rc<Event> event) { auto companies = api.get_market_context().companies; auto cmp = companies->find([&event](Rc<Company> aa) { return aa->get_id() == event->company_target.unwrap_or(0); }); auto cmp_prof = this->company_profiles.find([&cmp](Rc<TraderCompanyProfile> prof) { return prof->company_id == cmp->get_id(); }); if (!cmp_prof) { return; } auto sent_diff = this->get_event_personal_take(event) * event->weight * event->weight; cmp_prof->sentiment += sent_diff; } f64 trader::NormalTraderAgent::get_event_personal_take(Rc<Event> event) const { return event->sentiment * event->weight * std::abs(this->nonce_focus - event->nonce); } void trader::NormalTraderAgent::adjust_profiles_with_price_data(ExchangeApi &api) { auto companies = api.get_market_context().companies; for (auto profile : this->company_profiles) { auto cmp = companies->find([&profile](Rc<Company> cmp) { return cmp->get_id() == profile->company_id; }); auto buy_change = (int) cmp->get_buy_vol() - (int) profile->last_buy_vol; auto sell_change = (int) cmp->get_sel_vol() - (int) profile->last_sell_vol; auto pos_delta = (buy_change > 0 ? buy_change : 0) + (sell_change < 0 ? -sell_change : 0); auto neg_delta = std::abs(buy_change) + std::abs(sell_change) - pos_delta; auto vol = (profile->last_buy_vol + profile->last_sell_vol); auto vol_safe = (vol == 0 ? 1 : vol); auto pos_diff = pos_delta / vol_safe; auto neg_diff = neg_delta / vol_safe; auto price_diff = ((int) cmp->get_stock_price() - (int) profile->last_price) / (f64) (profile->last_price); if (this->had_cycle) { profile->sentiment += pos_diff * this->volume_sensitivity; profile->sentiment += neg_diff * this->volume_sensitivity; profile->sentiment += price_diff * this->price_sensitivity; } profile->last_sell_vol = cmp->get_sel_vol(); profile->last_buy_vol = cmp->get_buy_vol(); profile->last_price = cmp->get_stock_price(); } } usize trader::NormalTraderAgent::get_per_stock_spending(usize balance) const { return (usize) ((1.0 / this->position_count) * balance); } void trader::NormalTraderAgent::sell_stocks(ExchangeApi &api) { auto portfolio = api.get_owned_stocks(); auto companies = api.get_market_context().companies; auto orders = api.get_orders(); for (auto stock : portfolio) { auto profile = this->company_profiles.find([&stock](Rc<TraderCompanyProfile> prof) { return stock->company_id == prof->company_id; }); auto cmp = companies->find([&stock](Rc<Company> cmp) { return cmp->get_id() == stock->company_id; }); auto order_for_comp = orders.find([&stock](Rc<Order> cmp) { return cmp->company_id == stock->company_id; }); if (!profile || order_for_comp) { continue; } auto bias = this->bought_bias * this->get_fundamentals(cmp); auto stop_loss_s = -(bias + this->stop_loss); auto stop_win_ws = bias + this->stop_win; auto price = cmp->get_stock_price(); auto profit = stock->bought_for / (f64) (price == 0 ? 1 : price) - 1; if (profit > stop_loss_s && profit < stop_win_ws) { continue; } auto price_per_share = (usize) ((NormalTraderAgent::negotiation_percentage(profile->sentiment, 0) + 1) * cmp->get_ask().unwrap_or(0)); // api.get_cli()->os() << "T opening Sell: " << this->get_id() <<", " << stock->amount << " symb: "<< cmp->get_symbol() << ", for/sh: "<< utils::format_money(price_per_share); // api.get_cli()->print_ln(); api.open_order(exchange::OrderCreationPayload{ exchange::OrderType::Sell, cmp->get_id(), stock->free_amount, price_per_share, Option<usize>() }); } } f64 trader::NormalTraderAgent::negotiation_percentage(f64 sentiment, usize time) { auto senti_norm = std::min(std::max(sentiment, -1.0), 1.0); auto pp = (0.1 * senti_norm) / (time + 1); return pp >= 0.01 ? pp : 0; } void trader::NormalTraderAgent::negotiate_orders(ExchangeApi &api) { auto orders = api.get_orders().clone(); auto companies = api.get_market_context().companies; for (auto ord: orders) { auto negot = this->negotiations.find([&ord](Rc<OrderNegotiation> nn) { return nn->order_id == ord->id; }); auto cmp = companies->find([&ord](Rc<Company> cmp) { return cmp->get_id() == ord->company_id; }); auto profile = company_profiles.find([&ord](Rc<TraderCompanyProfile> prof) { return prof->company_id == ord->company_id; }); if (!cmp || !profile) { continue;; } if (!negot) { OrderNegotiation nn{ ord->id, 0 }; negot = nhflib::make_rc(nn); this->negotiations.push_back(negot); } auto new_price = ord->target_price; if (ord->type == exchange::OrderType::Buy) { auto base_pr = cmp->get_bid().unwrap_or(0); auto adjusted_negotiation_pr = (usize) (base_pr * (1 - NormalTraderAgent::negotiation_percentage( profile->sentiment, negot->times))); new_price = std::max(adjusted_negotiation_pr, (usize) 1); } else { new_price = (usize) ((NormalTraderAgent::negotiation_percentage(profile->sentiment, negot->times) + 1) * cmp->get_ask().unwrap_or(0)); } exchange::OrderCreationPayload new_ord{ ord->type, ord->company_id, ord->amount, new_price, Option<usize>(), }; api.cancel_order(ord->id); if (api.get_trader_available_balance() >= new_ord.get_total_price()) { auto oo = api.open_order(new_ord); negot->order_id = oo.id; negot->times++; } else { this->negotiations.filter_in_place([&negot](Rc<OrderNegotiation> nn){ return nn->order_id != negot->order_id; }); } } }
; c definition of memory mapped register SECTION code_clib PUBLIC _MM_FRAME1_CONTROL_REGISTER EXTERN __MM_FRAME1_CONTROL_REGISTER defc _MM_FRAME1_CONTROL_REGISTER = __MM_FRAME1_CONTROL_REGISTER
/* * Copyright (c) 2017, Respective Authors. * * The MIT License * * 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 #include <fc/exception/exception.hpp> #include <eos/chain/protocol.hpp> #define EOS_ASSERT( expr, exc_type, FORMAT, ... ) \ FC_MULTILINE_MACRO_BEGIN \ if( !(expr) ) \ FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ FC_MULTILINE_MACRO_END #define EOS_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ op_name ## _validate_exception, \ eos::chain::message_validate_exception, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value, \ #op_name "_operation validation exception" \ ) \ FC_DECLARE_DERIVED_EXCEPTION( \ op_name ## _evaluate_exception, \ eos::chain::message_evaluate_exception, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value, \ #op_name "_operation evaluation exception" \ ) #define EOS_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ op_name ## _ ## exc_name, \ eos::chain::op_name ## _validate_exception, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value \ + seqnum, \ msg \ ) #define EOS_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ op_name ## _ ## exc_name, \ eos::chain::op_name ## _evaluate_exception, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value \ + seqnum, \ msg \ ) namespace eos { namespace chain { FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" ) FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, eos::chain::chain_exception, 3010000, "database query exception" ) FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, eos::chain::chain_exception, 3020000, "block validation exception" ) FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, eos::chain::chain_exception, 3030000, "transaction validation exception" ) FC_DECLARE_DERIVED_EXCEPTION( message_validate_exception, eos::chain::chain_exception, 3040000, "message validation exception" ) FC_DECLARE_DERIVED_EXCEPTION( message_precondition_exception, eos::chain::chain_exception, 3050000, "message precondition exception" ) FC_DECLARE_DERIVED_EXCEPTION( message_evaluate_exception, eos::chain::chain_exception, 3060000, "message evaluation exception" ) FC_DECLARE_DERIVED_EXCEPTION( utility_exception, eos::chain::chain_exception, 3070000, "utility method exception" ) FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, eos::chain::chain_exception, 3080000, "undo database exception" ) FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, eos::chain::chain_exception, 3090000, "unlinkable block" ) FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, eos::chain::chain_exception, 3100000, "black swan" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_block_exception, eos::chain::chain_exception, 3110000, "unknown block" ) FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, eos::chain::transaction_exception, 3030001, "missing required active authority" ) FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, eos::chain::transaction_exception, 3030002, "missing required owner authority" ) FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, eos::chain::transaction_exception, 3030003, "missing required other authority" ) FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, eos::chain::transaction_exception, 3030004, "irrelevant signature included" ) FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, eos::chain::transaction_exception, 3030005, "duplicate signature included" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, eos::chain::transaction_exception, 3030006, "committee account cannot directly approve transaction" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, eos::chain::transaction_exception, 3030007, "insufficient fee" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, eos::chain::utility_exception, 3060001, "invalid pts address" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, eos::chain::chain_exception, 37006, "insufficient feeds" ) FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, eos::chain::undo_database_exception, 3070001, "there are no blocks to pop" ) // EOS_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" ) // EOS_DECLARE_OP_EVALUATE_EXCEPTION( to_account_not_whitelisted, transfer, 2, "owner mismatch" ) // EOS_DECLARE_OP_EVALUATE_EXCEPTION( restricted_transfer_asset, transfer, 3, "restricted transfer asset" ) /* FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, eos::chain::chain_exception, 30002, "addition overflow" ) FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, eos::chain::chain_exception, 30003, "subtraction overflow" ) FC_DECLARE_DERIVED_EXCEPTION( asset_type_mismatch, eos::chain::chain_exception, 30004, "asset/price mismatch" ) FC_DECLARE_DERIVED_EXCEPTION( unsupported_chain_operation, eos::chain::chain_exception, 30005, "unsupported chain operation" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_transaction, eos::chain::chain_exception, 30006, "unknown transaction" ) FC_DECLARE_DERIVED_EXCEPTION( duplicate_transaction, eos::chain::chain_exception, 30007, "duplicate transaction" ) FC_DECLARE_DERIVED_EXCEPTION( zero_amount, eos::chain::chain_exception, 30008, "zero amount" ) FC_DECLARE_DERIVED_EXCEPTION( zero_price, eos::chain::chain_exception, 30009, "zero price" ) FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_self, eos::chain::chain_exception, 30010, "asset divide by self" ) FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_zero, eos::chain::chain_exception, 30011, "asset divide by zero" ) FC_DECLARE_DERIVED_EXCEPTION( new_database_version, eos::chain::chain_exception, 30012, "new database version" ) FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block, eos::chain::chain_exception, 30013, "unlinkable block" ) FC_DECLARE_DERIVED_EXCEPTION( price_out_of_range, eos::chain::chain_exception, 30014, "price out of range" ) FC_DECLARE_DERIVED_EXCEPTION( block_numbers_not_sequential, eos::chain::chain_exception, 30015, "block numbers not sequential" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_previous_block_id, eos::chain::chain_exception, 30016, "invalid previous block" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_block_time, eos::chain::chain_exception, 30017, "invalid block time" ) FC_DECLARE_DERIVED_EXCEPTION( time_in_past, eos::chain::chain_exception, 30018, "time is in the past" ) FC_DECLARE_DERIVED_EXCEPTION( time_in_future, eos::chain::chain_exception, 30019, "time is in the future" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, eos::chain::chain_exception, 30020, "invalid block digest" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_member_signee, eos::chain::chain_exception, 30021, "invalid committee_member signee" ) FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, eos::chain::chain_exception, 30022, "failed checkpoint verification" ) FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, eos::chain::chain_exception, 30023, "wrong chain id" ) FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, eos::chain::chain_exception, 30025, "block is older than our undo history allows us to process" ) FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" ) FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, eos::chain::evaluation_error, 31001, "negative deposit" ) FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member, eos::chain::evaluation_error, 31002, "not a committee_member" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_balance_record, eos::chain::evaluation_error, 31003, "unknown balance record" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_funds, eos::chain::evaluation_error, 31004, "insufficient funds" ) FC_DECLARE_DERIVED_EXCEPTION( missing_signature, eos::chain::evaluation_error, 31005, "missing signature" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_claim_password, eos::chain::evaluation_error, 31006, "invalid claim password" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_withdraw_condition, eos::chain::evaluation_error, 31007, "invalid withdraw condition" ) FC_DECLARE_DERIVED_EXCEPTION( negative_withdraw, eos::chain::evaluation_error, 31008, "negative withdraw" ) FC_DECLARE_DERIVED_EXCEPTION( not_an_active_committee_member, eos::chain::evaluation_error, 31009, "not an active committee_member" ) FC_DECLARE_DERIVED_EXCEPTION( expired_transaction, eos::chain::evaluation_error, 31010, "expired transaction" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_transaction_expiration, eos::chain::evaluation_error, 31011, "invalid transaction expiration" ) FC_DECLARE_DERIVED_EXCEPTION( oversized_transaction, eos::chain::evaluation_error, 31012, "transaction exceeded the maximum transaction size" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_account_name, eos::chain::evaluation_error, 32001, "invalid account name" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_account_id, eos::chain::evaluation_error, 32002, "unknown account id" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_account_name, eos::chain::evaluation_error, 32003, "unknown account name" ) FC_DECLARE_DERIVED_EXCEPTION( missing_parent_account_signature, eos::chain::evaluation_error, 32004, "missing parent account signature" ) FC_DECLARE_DERIVED_EXCEPTION( parent_account_retracted, eos::chain::evaluation_error, 32005, "parent account retracted" ) FC_DECLARE_DERIVED_EXCEPTION( account_expired, eos::chain::evaluation_error, 32006, "account expired" ) FC_DECLARE_DERIVED_EXCEPTION( account_already_registered, eos::chain::evaluation_error, 32007, "account already registered" ) FC_DECLARE_DERIVED_EXCEPTION( account_key_in_use, eos::chain::evaluation_error, 32008, "account key already in use" ) FC_DECLARE_DERIVED_EXCEPTION( account_retracted, eos::chain::evaluation_error, 32009, "account retracted" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_parent_account_name, eos::chain::evaluation_error, 32010, "unknown parent account name" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_committee_member_slate, eos::chain::evaluation_error, 32011, "unknown committee_member slate" ) FC_DECLARE_DERIVED_EXCEPTION( too_may_committee_members_in_slate, eos::chain::evaluation_error, 32012, "too many committee_members in slate" ) FC_DECLARE_DERIVED_EXCEPTION( pay_balance_remaining, eos::chain::evaluation_error, 32013, "pay balance remaining" ) FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member_signature, eos::chain::evaluation_error, 33002, "not committee_members signature" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_precision, eos::chain::evaluation_error, 35001, "invalid precision" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_symbol, eos::chain::evaluation_error, 35002, "invalid asset symbol" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_id, eos::chain::evaluation_error, 35003, "unknown asset id" ) FC_DECLARE_DERIVED_EXCEPTION( asset_symbol_in_use, eos::chain::evaluation_error, 35004, "asset symbol in use" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_amount, eos::chain::evaluation_error, 35005, "invalid asset amount" ) FC_DECLARE_DERIVED_EXCEPTION( negative_issue, eos::chain::evaluation_error, 35006, "negative issue" ) FC_DECLARE_DERIVED_EXCEPTION( over_issue, eos::chain::evaluation_error, 35007, "over issue" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_symbol, eos::chain::evaluation_error, 35008, "unknown asset symbol" ) FC_DECLARE_DERIVED_EXCEPTION( asset_id_in_use, eos::chain::evaluation_error, 35009, "asset id in use" ) FC_DECLARE_DERIVED_EXCEPTION( not_user_issued, eos::chain::evaluation_error, 35010, "not user issued" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_name, eos::chain::evaluation_error, 35011, "invalid asset name" ) FC_DECLARE_DERIVED_EXCEPTION( committee_member_vote_limit, eos::chain::evaluation_error, 36001, "committee_member_vote_limit" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, eos::chain::evaluation_error, 36002, "insufficient fee" ) FC_DECLARE_DERIVED_EXCEPTION( negative_fee, eos::chain::evaluation_error, 36003, "negative fee" ) FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, eos::chain::evaluation_error, 36004, "missing deposit" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, eos::chain::evaluation_error, 36005, "insufficient relay fee" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_market, eos::chain::evaluation_error, 37001, "invalid market" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_market_order, eos::chain::evaluation_error, 37002, "unknown market order" ) FC_DECLARE_DERIVED_EXCEPTION( shorting_base_shares, eos::chain::evaluation_error, 37003, "shorting base shares" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_collateral, eos::chain::evaluation_error, 37004, "insufficient collateral" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_depth, eos::chain::evaluation_error, 37005, "insufficient depth" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, eos::chain::evaluation_error, 37006, "insufficient feeds" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_feed_price, eos::chain::evaluation_error, 37007, "invalid feed price" ) FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_overflow, eos::chain::evaluation_error, 38001, "price multiplication overflow" ) FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_underflow, eos::chain::evaluation_error, 38002, "price multiplication underflow" ) FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_undefined, eos::chain::evaluation_error, 38003, "price multiplication undefined product 0*inf" ) */ #define EOS_RECODE_EXC( cause_type, effect_type ) \ catch( const cause_type& e ) \ { throw( effect_type( e.what(), e.get_log() ) ); } } } // eos::chain
#include <iostream> #include <memory> #include "plot.hpp" #include <unity/lib/visualization/process_wrapper.hpp> #include <unity/lib/visualization/thread.hpp> #include <unity/lib/visualization/transformation.hpp> #include <unity/lib/visualization/vega_data.hpp> #include <unity/lib/visualization/histogram.hpp> #include <unity/lib/visualization/item_frequency.hpp> #include <unity/lib/visualization/summary_view.hpp> #include <sstream> namespace turi{ namespace visualization{ void Plot::show(const std::string& path_to_client) { std::shared_ptr<Plot> self = std::make_shared<Plot>(*this); ::turi::visualization::run_thread([self, path_to_client]() { process_wrapper ew(path_to_client); ew << "{\"vega_spec\": " << self->m_vega_spec << "}\n"; while(ew.good()) { vega_data vd; vd << self->m_transformer->get()->vega_column_data(); double num_rows_processed = static_cast<double>(self->m_transformer->get_rows_processed()); double percent_complete = num_rows_processed/self->m_size_array; ew << "{\"data_spec\": " << vd.get_data_spec(percent_complete) << "}\n"; if (self->m_transformer->eof()) { break; } } }); } void Plot::materialize() { do { m_transformer->get()->vega_column_data(); } while(!m_transformer->eof()); DASSERT_EQ(get_percent_complete(), 1.0); } bool Plot::finished_streaming() const { return m_transformer->eof(); } double Plot::get_percent_complete() const { return m_transformer->get_percent_complete(); } std::string Plot::get_next_data() { vega_data vd; vd << m_transformer->get()->vega_column_data(); return vd.get_data_spec(get_percent_complete()); } std::string Plot::get_data() { this->materialize(); DASSERT_TRUE(m_transformer->eof()); vega_data vd; vd << m_transformer->get()->vega_column_data(); return vd.get_data_spec(100 /* percent_complete */); } std::string Plot::get_spec() { return m_vega_spec; } } BEGIN_CLASS_REGISTRATION REGISTER_CLASS(visualization::Plot) END_CLASS_REGISTRATION }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x14f, %rsi lea addresses_D_ht+0xfdf, %rdi nop sub $33797, %r10 mov $67, %rcx rep movsb and %rdi, %rdi lea addresses_WT_ht+0x1a27f, %r15 nop nop xor %r14, %r14 mov $0x6162636465666768, %rsi movq %rsi, %xmm1 vmovups %ymm1, (%r15) nop nop nop nop nop cmp $35880, %r14 lea addresses_D_ht+0x525f, %r15 nop and %rdx, %rdx mov $0x6162636465666768, %rdi movq %rdi, %xmm4 vmovups %ymm4, (%r15) nop nop nop cmp %rcx, %rcx lea addresses_WC_ht+0x16087, %r10 nop nop nop nop dec %r15 movw $0x6162, (%r10) nop nop cmp %r10, %r10 lea addresses_D_ht+0x1443f, %r15 nop nop nop cmp $29984, %rdx mov (%r15), %r14w sub %rcx, %rcx lea addresses_UC_ht+0x7a9f, %r15 nop nop nop nop cmp $61091, %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm5 movups %xmm5, (%r15) nop nop nop nop nop dec %r10 lea addresses_D_ht+0x12d07, %rdx clflush (%rdx) nop nop nop nop nop cmp $49046, %rcx movb $0x61, (%rdx) nop nop nop inc %rcx lea addresses_A_ht+0x295f, %rsi lea addresses_D_ht+0xd72f, %rdi nop nop nop nop nop xor $22582, %rax mov $61, %rcx rep movsl nop nop nop sub %r10, %r10 lea addresses_UC_ht+0x775f, %rsi lea addresses_D_ht+0x85f, %rdi nop xor $2079, %rdx mov $95, %rcx rep movsb nop nop xor %rsi, %rsi lea addresses_normal_ht+0x1a15f, %rdx nop xor %rax, %rax movups (%rdx), %xmm6 vpextrq $1, %xmm6, %r15 inc %rax lea addresses_A_ht+0x1cb9f, %rsi lea addresses_WC_ht+0xcbbf, %rdi clflush (%rsi) nop nop inc %r14 mov $61, %rcx rep movsb cmp %rax, %rax lea addresses_UC_ht+0x1e5ef, %rsi lea addresses_UC_ht+0x15fa3, %rdi nop nop nop nop and %rax, %rax mov $74, %rcx rep movsq nop nop nop nop sub $34109, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r8 push %r9 push %rbp push %rcx push %rdi // Store lea addresses_WC+0x795f, %r9 nop nop nop and %rdi, %rdi movw $0x5152, (%r9) nop nop nop nop nop and %r8, %r8 // Faulty Load lea addresses_PSE+0x195f, %rcx xor $45190, %r10 mov (%rcx), %r14d lea oracles, %rbp and $0xff, %r14 shlq $12, %r14 mov (%rbp,%r14,1), %r14 pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_PSE', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC', 'congruent': 11}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_PSE', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT_ht', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 3}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 4}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D_ht', 'congruent': 1}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 8, 'type': 'addresses_UC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 11}} {'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 6, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
// Generated by Haxe 4.1.5 #include <hxcpp.h> #ifndef INCLUDED___ASSET__flixel_flixel_ui_img_plus_mark_png #include <__ASSET__flixel_flixel_ui_img_plus_mark_png.h> #endif #ifndef INCLUDED_haxe_Resource #include <haxe/Resource.h> #endif #ifndef INCLUDED_haxe_io_Bytes #include <haxe/io/Bytes.h> #endif #ifndef INCLUDED_lime_graphics_Image #include <lime/graphics/Image.h> #endif #ifndef INCLUDED_lime_graphics_ImageBuffer #include <lime/graphics/ImageBuffer.h> #endif #ifndef INCLUDED_lime_graphics_ImageType #include <lime/graphics/ImageType.h> #endif HX_DEFINE_STACK_FRAME(_hx_pos_65a45912254a7412_346_new,"__ASSET__flixel_flixel_ui_img_plus_mark_png","new",0xeb13a037,"__ASSET__flixel_flixel_ui_img_plus_mark_png.new","lime/_internal/macros/AssetsMacro.hx",346,0xc651f030) HX_LOCAL_STACK_FRAME(_hx_pos_1dad041c69502e60_576_boot,"__ASSET__flixel_flixel_ui_img_plus_mark_png","boot",0xbe31907b,"__ASSET__flixel_flixel_ui_img_plus_mark_png.boot","ManifestResources.hx",576,0xf77aa668) void __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__construct( ::lime::graphics::ImageBuffer buffer, ::Dynamic offsetX, ::Dynamic offsetY, ::Dynamic width, ::Dynamic height, ::Dynamic color, ::lime::graphics::ImageType type){ HX_STACKFRAME(&_hx_pos_65a45912254a7412_346_new) HXLINE( 375) super::__construct(null(),null(),null(),null(),null(),null(),null()); HXLINE( 377) this->_hx___fromBytes(::haxe::Resource_obj::getBytes(::__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::resourceName),null()); } Dynamic __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__CreateEmpty() { return new __ASSET__flixel_flixel_ui_img_plus_mark_png_obj; } void *__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::_hx_vtable = 0; Dynamic __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__Create(::hx::DynamicArray inArgs) { ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_plus_mark_png_obj > _hx_result = new __ASSET__flixel_flixel_ui_img_plus_mark_png_obj(); _hx_result->__construct(inArgs[0],inArgs[1],inArgs[2],inArgs[3],inArgs[4],inArgs[5],inArgs[6]); return _hx_result; } bool __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::_hx_isInstanceOf(int inClassId) { if (inClassId<=(int)0x33f052f7) { return inClassId==(int)0x00000001 || inClassId==(int)0x33f052f7; } else { return inClassId==(int)0x7f43fe05; } } ::String __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::resourceName; ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_plus_mark_png_obj > __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__new( ::lime::graphics::ImageBuffer buffer, ::Dynamic offsetX, ::Dynamic offsetY, ::Dynamic width, ::Dynamic height, ::Dynamic color, ::lime::graphics::ImageType type) { ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_plus_mark_png_obj > __this = new __ASSET__flixel_flixel_ui_img_plus_mark_png_obj(); __this->__construct(buffer,offsetX,offsetY,width,height,color,type); return __this; } ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_plus_mark_png_obj > __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__alloc(::hx::Ctx *_hx_ctx, ::lime::graphics::ImageBuffer buffer, ::Dynamic offsetX, ::Dynamic offsetY, ::Dynamic width, ::Dynamic height, ::Dynamic color, ::lime::graphics::ImageType type) { __ASSET__flixel_flixel_ui_img_plus_mark_png_obj *__this = (__ASSET__flixel_flixel_ui_img_plus_mark_png_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(__ASSET__flixel_flixel_ui_img_plus_mark_png_obj), true, "__ASSET__flixel_flixel_ui_img_plus_mark_png")); *(void **)__this = __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::_hx_vtable; __this->__construct(buffer,offsetX,offsetY,width,height,color,type); return __this; } __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__ASSET__flixel_flixel_ui_img_plus_mark_png_obj() { } bool __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp) { switch(inName.length) { case 12: if (HX_FIELD_EQ(inName,"resourceName") ) { outValue = ( resourceName ); return true; } } return false; } bool __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,::hx::PropertyAccess inCallProp) { switch(inName.length) { case 12: if (HX_FIELD_EQ(inName,"resourceName") ) { resourceName=ioValue.Cast< ::String >(); return true; } } return false; } #ifdef HXCPP_SCRIPTABLE static ::hx::StorageInfo *__ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sMemberStorageInfo = 0; static ::hx::StaticInfo __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sStaticStorageInfo[] = { {::hx::fsString,(void *) &__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::resourceName,HX_("resourceName",39,7a,62,90)}, { ::hx::fsUnknown, 0, null()} }; #endif static void __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::resourceName,"resourceName"); }; #ifdef HXCPP_VISIT_ALLOCS static void __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::resourceName,"resourceName"); }; #endif ::hx::Class __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__mClass; static ::String __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sStaticFields[] = { HX_("resourceName",39,7a,62,90), ::String(null()) }; void __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__register() { __ASSET__flixel_flixel_ui_img_plus_mark_png_obj _hx_dummy; __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::_hx_vtable = *(void **)&_hx_dummy; ::hx::Static(__mClass) = new ::hx::Class_obj(); __mClass->mName = HX_("__ASSET__flixel_flixel_ui_img_plus_mark_png",c5,b8,2b,b2); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__GetStatic; __mClass->mSetStaticField = &__ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__SetStatic; __mClass->mMarkFunc = __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sMarkStatics; __mClass->mStatics = ::hx::Class_obj::dupFunctions(__ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sStaticFields); __mClass->mMembers = ::hx::Class_obj::dupFunctions(0 /* sMemberFields */); __mClass->mCanCast = ::hx::TCanCast< __ASSET__flixel_flixel_ui_img_plus_mark_png_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = __ASSET__flixel_flixel_ui_img_plus_mark_png_obj_sStaticStorageInfo; #endif ::hx::_hx_RegisterClass(__mClass->mName, __mClass); } void __ASSET__flixel_flixel_ui_img_plus_mark_png_obj::__boot() { { HX_STACKFRAME(&_hx_pos_1dad041c69502e60_576_boot) HXDLIN( 576) resourceName = HX_("__ASSET__:image___ASSET__flixel_flixel_ui_img_plus_mark_png",f7,d6,28,cb); } }
; A186421: Even numbers interleaved with repeated odd numbers. ; 0,1,2,1,4,3,6,3,8,5,10,5,12,7,14,7,16,9,18,9,20,11,22,11,24,13,26,13,28,15,30,15,32,17,34,17,36,19,38,19,40,21,42,21,44,23,46,23,48,25,50,25,52,27,54,27,56,29,58,29,60,31,62,31,64,33,66,33,68,35,70,35,72,37,74,37,76,39,78,39,80,41,82,41,84,43,86,43,88,45,90,45,92,47,94,47,96,49,98,49,100,51,102,51,104,53,106,53,108,55,110,55,112,57,114,57,116,59,118,59,120,61,122,61,124,63,126,63,128,65,130,65,132,67,134,67,136,69,138,69,140,71,142,71,144,73,146,73,148,75,150,75,152,77,154,77,156,79,158,79,160,81,162,81,164,83,166,83,168,85,170,85,172,87,174,87,176,89,178,89,180,91,182,91,184,93,186,93,188,95,190,95,192,97,194,97,196,99,198,99,200,101,202,101,204,103,206,103,208,105,210,105,212,107,214,107,216,109,218,109,220,111,222,111,224,113,226,113,228,115,230,115,232,117,234,117,236,119,238,119,240,121,242,121,244,123,246,123,248,125 mov $1,$0 mod $0,2 mov $2,$0 mov $3,$1 mov $4,4 lpb $2,1 lpb $4,1 div $3,4 mul $3,2 mov $1,$3 div $4,6 lpe add $1,1 sub $2,1 lpe
;//enables soft reset enable_pad_reset: lda #$AA sta soft_reset+0 lda #$55 sta soft_reset+1 lda #$3c sta soft_reset+2 rts ;#end
#include "Player.h" #include "j1App.h" #include "j1Render.h" #include "j1Textures.h" #include "j1Input.h" #include "Fow.h" #include "j1Window.h" Player::Player() : j2Entity(ENTITY_TYPE::PLAYER) { } Player::~Player() { } bool Player::Start() { //App->win->GetWindowSize(win_width, win_height); entity_rect = { 0,0,32,32 }; entity_tex = App->tex->Load("textures/pipo-balloon.png"); // TODO 2: Create the fow entity for the player. // Remember the player will be providing visibility. // TODO 5: Create a first sight quad (createsightquad in fow.cpp). This is gonna store the tile id's nearby to the emitting visibility entity. // Store the pointer at fow_entity->frontier // Once we have it done, fulfill the tile types with fulfillSight. This is called the Line of Sight. (LOS) return true; } bool Player::Update(float dt, bool do_logic) { iPoint last_pos = position; if (App->input->GetKey(SDL_SCANCODE_UP) == KEY_REPEAT) position.y -= 1; if (App->input->GetKey(SDL_SCANCODE_DOWN) == KEY_REPEAT) position.y += 1; if (App->input->GetKey(SDL_SCANCODE_LEFT) == KEY_REPEAT) position.x -= 1; if (App->input->GetKey(SDL_SCANCODE_RIGHT) == KEY_REPEAT) position.x += 1; Camera_Control(dt); // TODO 3: Update the state of visibility; sync this entity's visibility with it's fow_entity visibility. // We are doing this because the FowManager is already taking care of the fow_entity visibility, here we are just updating the entity state. // TODO 4: Update the fow_entity position from this position. // If we don't do this, our providing visibility entity won't be synced with the sight emitted. return true; } bool Player::CleanUp() { App->tex->UnLoad(entity_tex); return true; } void Player::Draw() { App->render->Blit(entity_tex, position.x - 16, position.y -64, &entity_rect); } void Player::Camera_Control(float dt) { if (App->input->GetKey(SDL_SCANCODE_A) == KEY_REPEAT) { App->render->camera.x += camera_speed; } if (App->input->GetKey(SDL_SCANCODE_D) == KEY_REPEAT) { App->render->camera.x -= camera_speed; } if (App->input->GetKey(SDL_SCANCODE_W) == KEY_REPEAT) { App->render->camera.y += camera_speed; } if (App->input->GetKey(SDL_SCANCODE_S) == KEY_REPEAT) { App->render->camera.y -= camera_speed; } }
.proc iniEAX_ECX_WORD mva :STACKORIGIN,x ecx mva :STACKORIGIN+STACKWIDTH,x ecx+1 mva :STACKORIGIN-1,x eax mva :STACKORIGIN-1+STACKWIDTH,x eax+1 mva #$00 ecx+2 sta ecx+3 sta eax+2 sta eax+3 rts .endp .proc iniEAX_ECX_CARD mva :STACKORIGIN,x ecx mva :STACKORIGIN+STACKWIDTH,x ecx+1 mva :STACKORIGIN+STACKWIDTH*2,x ecx+2 mva :STACKORIGIN+STACKWIDTH*3,x ecx+3 mva :STACKORIGIN-1,x eax mva :STACKORIGIN-1+STACKWIDTH,x eax+1 mva :STACKORIGIN-1+STACKWIDTH*2,x eax+2 mva :STACKORIGIN-1+STACKWIDTH*3,x eax+3 rts .endp
// Copyright 2015 Google Inc. 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 "benchmark/reporter.h" #include "complexity.h" #include <algorithm> #include <cstdint> #include <cstdio> #include <iostream> #include <string> #include <tuple> #include <vector> #include "check.h" #include "colorprint.h" #include "commandlineflags.h" #include "internal_macros.h" #include "string_util.h" #include "walltime.h" DECLARE_bool(color_print); namespace benchmark { bool ConsoleReporter::ReportContext(const Context& context) { name_field_width_ = context.name_field_width; PrintBasicContext(&GetErrorStream(), context); #ifdef BENCHMARK_OS_WINDOWS if (FLAGS_color_print && &std::cout != &GetOutputStream()) { GetErrorStream() << "Color printing is only supported for stdout on windows." " Disabling color printing\n"; FLAGS_color_print = false; } #endif std::string str = FormatString("%-*s %13s %13s %10s\n", static_cast<int>(name_field_width_), "Benchmark", "Time", "CPU", "Iterations"); GetOutputStream() << str << std::string(str.length() - 1, '-') << "\n"; return true; } void ConsoleReporter::ReportRuns(const std::vector<Run>& reports) { for (const auto& run : reports) PrintRunData(run); } void ConsoleReporter::PrintRunData(const Run& result) { auto& Out = GetOutputStream(); auto name_color = (result.report_big_o || result.report_rms) ? COLOR_BLUE : COLOR_GREEN; ColorPrintf(Out, name_color, "%-*s ", name_field_width_, result.benchmark_name.c_str()); if (result.error_occurred) { ColorPrintf(Out, COLOR_RED, "ERROR OCCURRED: \'%s\'", result.error_message.c_str()); ColorPrintf(Out, COLOR_DEFAULT, "\n"); return; } // Format bytes per second std::string rate; if (result.bytes_per_second > 0) { rate = StrCat(" ", HumanReadableNumber(result.bytes_per_second), "B/s"); } // Format items per second std::string items; if (result.items_per_second > 0) { items = StrCat(" ", HumanReadableNumber(result.items_per_second), " items/s"); } const double real_time = result.GetAdjustedRealTime(); const double cpu_time = result.GetAdjustedCPUTime(); if (result.report_big_o) { std::string big_o = GetBigOString(result.complexity); ColorPrintf(Out, COLOR_YELLOW, "%10.2f %s %10.2f %s ", real_time, big_o.c_str(), cpu_time, big_o.c_str()); } else if (result.report_rms) { ColorPrintf(Out, COLOR_YELLOW, "%10.0f %% %10.0f %% ", real_time * 100, cpu_time * 100); } else { const char* timeLabel = GetTimeUnitString(result.time_unit); ColorPrintf(Out, COLOR_YELLOW, "%10.0f %s %10.0f %s ", real_time, timeLabel, cpu_time, timeLabel); } if (!result.report_big_o && !result.report_rms) { ColorPrintf(Out, COLOR_CYAN, "%10lld", result.iterations); } if (!rate.empty()) { ColorPrintf(Out, COLOR_DEFAULT, " %*s", 13, rate.c_str()); } if (!items.empty()) { ColorPrintf(Out, COLOR_DEFAULT, " %*s", 18, items.c_str()); } if (!result.report_label.empty()) { ColorPrintf(Out, COLOR_DEFAULT, " %s", result.report_label.c_str()); } ColorPrintf(Out, COLOR_DEFAULT, "\n"); } } // end namespace benchmark
;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ TITLE EXTENDED MEMORY RAMDRIVE PAGE 58,132 ; --------------------------------------------------------------------------- ; NOTE: Change volume creation date (see VOLID) for each new driver version. ; --------------------------------------------------------------------------- ; ; Will use XMS extended memory or ; use Above Board on PC, XT, or AT or ; use main memory on PC, XT, or AT ; ; ; device = ramdrive.sys [bbbb] [ssss] [dddd] [/E | /A] ; ; bbbb First numeric argument, if present, is disk size ; in K bytes. Default value is 64. Min is 4. Max ; is 32767 (32M-1K). (M001, M002) ; ; ssss Second numeric argument, if present, is sector size ; in bytes. Default value is 512. Allowed values are ; 128, 256, 512, 1024. ; NOTE: In the case of IBM PC DOS the MAX value is 512. ; If 1024 is specified the device will not be installed. ; This "error" is detected by DOS and is not due to ; the code in RAMDrive. ; The 1024 byte size is included for those MS-DOS systems ; where it might be allowed. ; ; dddd Third numeric argument, if present, is the number of ; root directory entries. Default is 64. Min is 2 ; max is 1024. The value is rounded up to the nearest ; sector size boundary. ; NOTE: In the event that there is not enough memory ; to create the RAMDrive volume, RAMDrive will try to make ; a DOS volume with 16 directory entries. This may ; result in a volume with a different number of directory ; entries than the dddd parameter specifies. ; ; /E Specifies that XMS Extended Memory is to be used. ; It is an error if /E is specified and an XMS driver ; is not already installed. ; ; /A Specifies that Above Board memory is to be used. It ; is an error if the above board device driver is not ; present. ; NOTE: Information on RAMDrive drives in Above Board memory ; will be lost at system re-boot (warm or cold). This is ; due to the fact that the EMM device driver performs a ; destructive test when it is installed which zeros all ; of the Above Board memory. ; ; Neither /A or /E Specifies drive is to be set up below the ; 640K boundary in main memory. ; The RAMDRIVE.SYS program looks for memory to assign to the RAMDrive ; drives by looking for functioning system RAM between the ; "end of memory" as determined by the INT 12H ROM BIOS ; function, and the start of the video RAM (0A000:0H). ; [This method no longer attempted.] ; If RAM is found by the above scan, it is assigned to ; RAMDrive and managed in the same way as extended memory ; is when the /E switch is used. As with /E there is ; 1k of RAMDrive overhead. That is to say, if there are 256k ; bytes of memory above the INT 12 memory size, there ; will be 255k bytes available for assignment to RAMDrive ; drives. This 1k overhead is fixed and does not depend ; on the number of RAMDrive drives installed. ; Information on such RAMDrive drives will NOT be lost on ; a "warm boot" (INT 19H or Ctrl-Alt-DEL). ; [This method no longer attempted.] ; If RAM is NOT found by the above scan, RAMDrive will attempt ; to allocate memory for the device AS PART OF THE DEVICE. ; In other words the device starts immediately after the ; RAMDrive resident code. ; Information on such RAMDrive drives WILL BE lost on ; a "warm boot" (INT 19H or Ctrl-Alt-DEL). ; ; ; MODIFICATION HISTORY ; ; 1.00 5/30/85 ARR Initial version. ; ; 1.01 6/03/85 ARR Added CSIZE home code in INIDRV. Does a better ; job of computing good CSIZE value. ; ; 1.10 6/05/85 ARR Changed name of program from VDISK to RAMDRIVE ; ; 1.11 6/06/85 ARR Changed BAD_AT message ; ; 1.12 6/06/85 ARR Fixed bug in /A BLKMOV code. Was forgetting ; to save and restore page mapping context ; ; 1.13 6/14/85 ARR Was using 32 bit shifts to do div/mul by ; powers of two. As it turns out, using the ; DIV or MUL instruction is faster. This is ; so even for small numbers like 16. This is ; due to the fact that the LOOP involved in ; doing a 32 bit shift is expensive. ; ; 1.14 6/14/85 ARR dddd param minimum changed from 4 to 2 ; to be IBM compatible. Code added to round ; up to sector size boundaries. ; ; 1.15 6/24/85 ARR Assorted clean up, mostly in Above Board ; code. ; ; 1.16 7/09/85 ARR Align code more closely to the G.L. ; coding standard. ; ; Changed ITOA routine. Smaller and will print any ; 16 bit value. ; ; DISK_ABORT would run through EMM_CTRL reset code ; on a RESMEM_SPECIAL driver. Added code ; to skip if this type of driver. ; ; Added check in CHECK_DOS_VOL in event valid BPB ; is found to make sure SSIZE and DIRNUM values ; match. If you edit DEVICE = to change these ; values on an existing drive and re-boot ; RAMDrive would ignore you and suck up old ; values. ; ; 11/12/85 ARR DEBUG EQU added and some RESMEM debug code ; stuck in to discover that the HP Vectra is ; not as AT compatible as HP thinks. ; ; 02/11/86 ARR Message area identified by "TRANSLATION" ; and translation notes added to several ; messages ; ; 04/03/86 ARR Changed use of SIDT to set GDT descriptor ; in /E init code to SGDT. Previous masm wouldn't ; assemble SGDT, new one works OK. ; ; 1.17 5/26/86 ARR New version for "above" insignificgant changes. And ; fixed major oops in /e RESET_SYSTEM code which would ; hang the system if an interrupt occured at the wrong ; time. ; ; 1.19 3/4/87 SP Fixed CSIZ homing oscillation bug. Shifted Ramdriv ; configuration display code before relocation code ; to facilitate creation of message module. Shifted ; translatable messages to message module. ; ; 2.00 8/23/87 sp 386 support ( both prot mode transfer and int15 ) ; 286 loadall kludge ; new int15 allocation ; new above_blkmov routine (to handle overlapping ; transfers in above board memory ; olivetti support ; removed int 9 trapping ; reset code different for extended memory ; ; 2.01 9/28/87 sp Fixed bug in parsing for /u option ; ; 2.02 3/02/88 sp Extended PS2 model 80 recognition to more than ; one sub-model ; 2.03 5/13/88 SP extended version check to include dos 4.00 ; ; 2.04 5/23/88 SP reworked messages to mention expanded memory ; ; 2.10 6/13/88 CHIPA Merged in HP Vectra stuff ; 11/20/87 RCP Fixed a20 enabling/disabling problems on ; Vectra machines. ; ; 2.12 7/26/88 SP Ramdrives installed between int12 and A000 are ; no longer attempted. ; ; 3.00 9/12/89 DBO Use XMS driver for extended memory (type 1 ; driver). Cut out most support for pre-XMS ; extended memory. Also removed vestigial ; support for type 3 driver. ; Removed BAD_AT message. ; Removed INT 9, INT 15h support. ; Restricted INT 19h support to TYPE 2 driver. ; DOS version check accepts up to 4.10. ; 10/9/89 DBO DOS version check accepts up to 4.01. ; 3.00.02 10/13/89 DBO DOS version check accepts 4.x. ; ; 3.00 (debug 00) ; 12/21/89 DBO Removed /V (himem.sys version check). ; Hook XMS int 2f to ward off Windows/386 v2.x. ; 3.00 (debug 01) ; 12/22/89 DBO Accept DOS versions thru 5.x. ; 3.00 (debug 02) ; 1/4/90 DBO Change XMS hook to approved method, don't watch ; int 2F. ; 3.03 2/1/90 Replace popf in XmmGuard to work around old ; 80286 bug. ; Sense errors correctly in XMS block move. ; 3.04 2/4/90 2M byte ramdisk screws up as file goes off ; end of disk and wraps around. Is cluster ; # FF0 valid? Changed initialization so ; maximum # clusters is 4096-18 instead of ; 4096-10. ; 3.05 7/30/90 DBO M00: Make sure EMS page frame really exists. ; 3.05 11/27/90 DB M001: Extend max. RAMDrive size from 4M to 32M-1K. ; 3.05 12/14/90 DB M002: Decrease min. RAMDrive size from 16K to 4K. ; Versions >= Dos 5.X use memory limit ; provided in INIT packet BREAK address, ; rather value returned by INT 12h. ; 3.05 08/21/91 EA Updated Vol Creation Date for Windows 3.10 Setup, left same version. BREAK MACRO subtitle SUBTTL subtitle PAGE ENDM DEBUG EQU 0 ; enable/disable debug messages IF1 IF DEBUG %out DEBUG VERSION!!!!!! ENDIF ENDIF .xlist include devsym.inc include syscall.inc include dirent.inc .list ; The RAMDrive device driver has 4 basic configurations. ; ; TYPE 1 - /E configuration using XMS extended memory. ; ; TYPE 2 - /A configuration using Above Board memory and EMM device ; driver. ; ; TYPE 3 - Neither /A or /E (RESMEM) configuration using main memory ; and normal 8086 addressing, RAMDrive memory is located ; somewhere AFTER the "end of memory" as indicated by the ; INT 12H memory size. ; [NOTE: Type 3 configuration no longer attempted.] ; ; TYPE 4 - RESMEM configuration as TYPE 3 EXCEPT that the RAMDrive ; memory is part of the RAMDrive device driver. ; ; The TYPE 2 driver uses the Above Board EMM device driver via INT 67H ; to control access to, and to access the available memory. ; ; The TYPE 4 driver needs no external help to control access to the available ; memory since the RAMDrive memory is part of the device driver and ; immediately follows the RAMDrive code in memory. ; ; The TYPE 1 configuration uses a resident XMS manager to ; control access to the available memory include emm.inc include above.inc include ab_macro.inc include xmm.inc BREAK <I/O Packet offset declarations> ; ; Define I/O packet offsets for useful values. ; ; SEE ALSO ; MS-DOS Technical Reference manual section on Installable Device Drivers ; ; READ/WRITE PACKET OFFSETS RW_COUNT EQU WORD PTR (SIZE SRHEAD) + 5 RW_TRANS EQU DWORD PTR (SIZE SRHEAD) + 1 RW_START EQU WORD PTR (SIZE SRHEAD) + 7 ; MEDIA CHECK PACKET OFFSETS MCH_RETVAL EQU BYTE PTR (SIZE SRHEAD) + 1 MCH_MEDIA EQU BYTE PTR (SIZE SRHEAD) + 0 ; BUILD BPB PACKET OFFSETS BPB_BUFFER EQU DWORD PTR (SIZE SRHEAD) + 1 BPB_MEDIA EQU BYTE PTR (SIZE SRHEAD) + 0 BPB_BPB EQU DWORD PTR (SIZE SRHEAD) + 5 ; INIT PACKET OFFSETS INIT_NUM EQU BYTE PTR (SIZE SRHEAD) + 0 INIT_BREAK EQU DWORD PTR (SIZE SRHEAD) + 1 INIT_BPB EQU DWORD PTR (SIZE SRHEAD) + 5 INIT_DOSDEV EQU BYTE PTR (SIZE SRHEAD) + 9 BREAK <Device header> RAMCODE SEGMENT ASSUME CS:RAMCODE,DS:NOTHING,ES:NOTHING,SS:NOTHING ;** ; ; RAMDRIVE DEVICE HEADER ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; RAMDEV LABEL WORD DW -1,-1 DEVATS DW DEVOPCL DW STRATEGY DW RAM$IN DB 1 ;1 RAMDRIVE BREAK <Command dispatch table> ;** ; ; This is the device driver command dispatch table. ; ; The first byte indicates the size of the table and therefore defines ; which device function codes are valid. ; ; The entries in the table are NEAR word addresses of the appropriate ; device routine. Thus the address of the routine to handle device function ; 3 is: ; WORD at ((RAMTBL + 1) + (2 * 3)) ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ; RAMTBL LABEL WORD DB 15 ; Max allowed command code DW RAM$INIT DW MEDIA$CHK DW GET$BPB DW CMDERR DW RAM$READ DW DEVEXIT DW DEVEXIT DW DEVEXIT DW RAM$WRIT DW RAM$WRIT DW DEVEXIT DW DEVEXIT DW DEVEXIT DW DEVEXIT DW DEVEXIT DW RAM$REM BREAK <BPB and boot sector for installed device> ;** RAMDRIVE BIOS PARAMETER BLOCK AND BOGUS BOOT SECTOR ; ; This region is a valid DOS 2.X 3.X "boot sector" which contains ; the BPB. This is used for signiture verification of a valid ; RAMDrive as well as for storage of the relevant BPB parameters. ; ; The BOOT_START code is a very simple stub which does nothing ; except go into an infinite loop. THIS "CODE" SHOULD NEVER ; BE EXECUTED BY ANYONE. ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ; BOOT_SECTOR LABEL BYTE JMP BOOT_START ; WARNING- don't change to short jump! DB "RDV 1.20" RDRIVEBPB: SSIZE DW 512 ; Physical sector size in bytes CSIZE DB 0 ; Sectors/allocation unit RESSEC DW 1 ; Reserved sectors for DOS FATNUM DB 1 ; No. allocation tables DIRNUM DW 64 ; Number directory entries SECLIM DW 0 ; Number sectors DB 0F8H ; Media descriptor FATSEC DW 1 ; Number of FAT sectors DW 1 ; Number of sectors per track DW 1 ; Number of heads DW 0 ; Number of hidden sectors SEC_SHFT DB 8 ; Shifting number of ; sectors LEFT by this ; many bits yields #words ; in that many sectors. ; 128 6 ; 256 7 ; 512 8 ; 1024 9 BOOT_START: JMP BOOT_START BOOT_SIG LABEL BYTE DB (128 - (OFFSET BOOT_SIG - OFFSET BOOT_SECTOR)) DUP ("A") ; ; The following label is used to determine the size of the boot record ; OFFSET BOOT_END - OFFSET BOOT_SECTOR ; BOOT_END LABEL BYTE BREAK <Common Device code> ; RAMDRIVE DEVICE ENTRY POINTS - STRATEGY, RAM$IN ; ; This code is standard DOS device driver function dispatch ; code. STRATEGY is the device driver strategy routine, RAM$IN ; is the driver interrupt routine. ; ; RAM$IN uses RAMTBL to dispatch to the appropriate handler ; for each device function. It also does standard packet ; unpacking. ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ASSUME CS:RAMCODE,DS:NOTHING,ES:NOTHING,SS:NOTHING PTRSAV DD 0 ; Storage location for packet addr XmmControl dd 0 ; interface to himem (XMS) PrevXmm dd 0 ; previous installed XMS manager ext_handle dw -1 ; contains handle of ext. mem block XmmMoveBuf extmemmovestruct <> reboot_flg db 0 ; true when reset code is being executed ;** STRATEGY - Device strategy routine ; ; Standard DOS 2.X 3.X device driver strategy routine. All it does ; is save the packet address in PTRSAV. ; ; ENTRY ES:BX -> Device packet ; EXIT NONE ; USES NONE ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ; STRATP PROC FAR STRATEGY: MOV WORD PTR [PTRSAV],BX ; Save packet addr MOV WORD PTR [PTRSAV+2],ES RET STRATP ENDP ;** RAM$IN - Device interrupt routine ; ; Standard DOS 2.X 3.X device driver interrupt routine. ; ; ; ENTRY PTRSAV has packet address saved by previous STRATEGY call. ; EXIT Dispatch to appropriate function handler ; CX = Packet RW_COUNT ; DX = Packet RW_START ; ES:DI = Packet RW_TRANS ; DS = RAMCODE ; STACK has saved values of all regs but FLAGS ; All function handlers must return through one of ; the standard exit points ; USES FLAGS ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ; RAM$IN: PUSH SI PUSH AX PUSH CX PUSH DX PUSH DI PUSH BP PUSH DS PUSH ES PUSH BX LDS BX,[PTRSAV] ;GET POINTER TO I/O PACKET ; ; Set up registers for READ or WRITE since this is the most common case ; MOV CX,DS:[BX.RW_COUNT] ;CX = COUNT MOV DX,DS:[BX.RW_START] ;DX = START SECTOR MOV AL,DS:[BX.REQFUNC] ; Command code MOV AH,BYTE PTR [RAMTBL] ; Valid range CMP AL,AH JA CMDERR ; Out of range command code MOV SI,OFFSET RAMTBL + 1 ; Table of routines CBW ; Make command code a word ADD SI,AX ; Add it twice since one word in ADD SI,AX ; table per command. LES DI,DS:[BX.RW_TRANS] ; ES:DI transfer address PUSH CS POP DS ASSUME DS:RAMCODE JMP WORD PTR [SI] ; GO DO COMMAND ;** EXIT - ALL ROUTINES RETURN THROUGH ONE OF THESE PATHS ; ; Exit code entry points: ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; GENERAL ENTRY for all entry points ; All packet values appropriate to the specific device function ; filled in except for the status word in the static request ; header. ; ; CMDERR - Used when an invalid device command is detected ; ; ENTRY Stack has frame set up by RAM$IN ; EXIT Standard Device driver with error 3 ; USES FLAGS ; ; ERR$CNT - Used when READ or WRITE wants to return with error code. ; The packet RW_COUNT field is zeroed ; ; ENTRY AL is error code for low byte of packet status word ; Stack has frame set up by RAM$IN ; EXIT Standard Device driver with error AL ; USES FLAGS ; ; ERR$EXIT - Used when a function other that READ or WRITE wants to ; return an error ; ; ENTRY AL is error code for low byte of packet status word ; Stack has frame set up by RAM$IN ; EXIT Standard Device driver with error AL ; USES FLAGS ; ; DEVEXIT - Used when a function wants to return with no error ; ; ENTRY AL is value for low byte of packet status word ; NOTE: Typically there is no meaningful value ; in the AL register when EXITing through here. ; This is OK as the low 8 bits of the status word ; have no meaning unless an error occured. ; Stack has frame set up by RAM$IN ; EXIT Standard Device driver with no error ; USES FLAGS ; ; ERR1 - Used when a function wants to return with a value ; for the whole status word ; ; ENTRY AX is value for packet status word ; Stack has frame set up by RAM$IN ; EXIT Standard Device driver with or without error ; USES FLAGS ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ; ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING CMDERR: MOV AL,3 ;UNKNOWN COMMAND ERROR JMP SHORT ERR$EXIT ERR$CNT: LDS BX,[PTRSAV] MOV [BX.RW_COUNT],0 ; NO sectors transferred ERR$EXIT: ; Error in AL MOV AH,(STERR + STDON) SHR 8 ;MARK ERROR RETURN JMP SHORT ERR1 EXITP PROC FAR DEVEXIT: MOV AH,STDON SHR 8 ERR1: LDS BX,[PTRSAV] MOV [BX.REQSTAT],AX ; Set return status POP BX POP ES POP DS POP BP POP DI POP DX POP CX POP AX POP SI RET ;RESTORE REGS AND RETURN EXITP ENDP ;** MEDIA$CHK - Device Driver Media check routine ; ; RAMDRIVE Media check routine. ALWAYS returns media not changed ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; ENTRY from RAM$IN ; EXIT through DEVEXIT ; USES DS,BX ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; MEDIA$CHK: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING LDS BX,[PTRSAV] ASSUME DS:NOTHING MOV [BX.MCH_RETVAL],1 ; ALWAYS NOT CHANGED JMP DEVEXIT ;** GET$BPB - Device Driver Build BPB routine ; ; RAMDRIVE Build BPB routine. Returns pointer to BPB at RDRIVEBPB ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; ENTRY from RAM$IN ; EXIT through DEVEXIT ; USES DS,BX ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; GET$BPB: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING LDS BX,[PTRSAV] ASSUME DS:NOTHING MOV WORD PTR [BX.BPB_BPB],OFFSET RDRIVEBPB MOV WORD PTR [BX.BPB_BPB + 2],CS JMP DEVEXIT ;** RAM$REM - Device Driver Removable Media routine ; ; RAMDRIVE Removable Media routine. ALWAYS returns media not removable ; NOTE: This routine is never called if running on DOS 2.X ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; ENTRY from RAM$IN ; EXIT through ERR1 ; USES AX ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; RAM$REM: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING MOV AX,STBUI + STDON ; Media NOT removable JMP ERR1 ;** RAM$READ - Device Driver READ routine ; ; RAMDRIVE READ routine. Perform device READ by calling MEMIO ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; DO_OP entry point used by RAM$WRITE ; ; ENTRY from RAM$IN ; ES:DI is transfer address ; CX is sector transfer count ; DX is start sector number ; EXIT through DEVEXIT or ERR$CNT ; USES ALL ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; RAM$READ: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING XOR BH,BH DO_OP: CALL MEMIO JC T_ERR JMP DEVEXIT T_ERR: ; AL has error number JMP ERR$CNT ;** RAM$WRITE - Device Driver WRITE routine ; ; RAMDRIVE WRITE routine. Perform device WRITE by calling MEMIO ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; ENTRY from RAM$IN ; ES:DI is transfer address ; CX is sector transfer count ; DX is start sector number ; EXIT Jump to DO_OP to call MEMIO with BH = 1 (WRITE) ; USES BH ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; RAM$WRIT: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING MOV BH,1 JMP DO_OP ;** MEMIO - Perform READ or WRITE to RAMDrive ; ; This routine performs common pre-amble code for the BLKMOV ; routine which is the one which does the real work. It checks ; the I/O parameters for validity and sets up the inputs to ; BLKMOV. What it does is convert the sector count in CX to ; the number of words in that many sectors or 8000H which ever ; is less. It also converts the start sector number in DX into ; a 32 bit byte offset equal to that many sectors. ; ; NOTE that we convert the number of sectors to transfer ; to a number of words to transfer. ; Sector size is always a power of two, therefore a multiple ; of two so there are no "half word" problems. ; DOS NEVER asks for a transfer larger than 64K bytes except ; in one case where we can ignore the extra anyway. ; ; ENTRY: ; ES:DI is packet transfer address. ; CX is number of sectors to transfer. ; DX is starting sector number ; BH is 1 for WRITE, 0 for READ ; EXIT: ; If error detected ; Carry Set ; Error on operation, AL is error number ; else ; through BLKMOV ; ES:DI is packet transfer address. ; CX is number of words to transfer. ; DX:AX is 32 bit start byte offset (0 = sector 0 of RAMDrive drive) ; BH is 1 for WRITE, 0 for READ ; USES: ; AX, DX, CX, FLAGS ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; SEC_NOT_FOUND: MOV AL,8 ; Sector not found error STC RET MEMIO: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING CMP DX,[SECLIM] ; Check for valid I/O JAE SEC_NOT_FOUND ; Start is beyond end MOV AX,DX ADD AX,CX CMP AX,[SECLIM] JA SEC_NOT_FOUND ; End is beyond end ; ; Convert sector count to word count ; MOV AX,CX MOV CL,[SEC_SHFT] SHL AX,CL ; AX is # words to move JNC CNT_SET ; Overflow??? MOV AX,8000H ; Limit to 64K bytes CNT_SET: MOV CX,AX ; ; Now compute start offset of I/O ; MOV AX,DX MUL [SSIZE] ; DX:AX is byte offset of start JMP SHORT BLKMOV ; Perform I/O BREAK <Drive code for /E driver> ; ; The following label defines the start of the I/O code which is driver type ; specific. ; ; THE TYPE 2 driver must REPLACE this code with code appropriate ; to the driver type. ; EVEN ; Force start of drive code to word boundary DRIVE_CODE LABEL WORD EXTMEM_LOW EQU 0000H ; 24 bit addr of start of extended memory EXTMEM_HIGH EQU 0010H ;** BASE_ADDR data element ; ; The next value defines the 24 bit address of the start of the memory for ; the cache. ; ; NOTE THAT IT IS INITIALIZED TO THE START OF EXTENDED MEMORY. ; ; NOTE: This data element is shared by TYPE 1, 2 drivers, but ; its meaning and correct initial value are driver type specific. ; [Now set but NOT USED by TYPE 1 driver.] ; BASE_ADDR LABEL DWORD ; 24 bit address of start of this RAMDRV DW EXTMEM_LOW DW EXTMEM_HIGH ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;** BLKMOV - Perform transfer for TYPE 1 driver ; ; ENTRY: ; ES:DI is packet transfer address. ; CX is number of words to transfer. ; DX:AX is 32 bit start byte offset (0 = start of cache) ; BH is 1 for WRITE, 0 for READ ; ; EXIT: ; Carry Clear ; OK, operation performed successfully ; Carry Set ; Error during operation, AL is error number (INT 13 error) ; ; USES: ; ALL ; ; This routine is specific to TYPE 1 driver ; BLKMOV: ASSUME DS:ramcode,ES:NOTHING,SS:NOTHING ;############################################################################ ;[This is the XMS version, copied from Smartdrv.] ; ; Function : blkmov ; Inputs : es:di -> points to packet ; dx:ax -> points to cache ; cx - > no. of words to transfer ; bh = 1 (WRITE) 0 (READ) ; ; Outputs : If error CY flag is set ; else move accomplished ; ; Description: ; Fills up the XmmMoveBuf structure with the correct ; values supplied by the input parameters and calls the XMM Extended ; Block Move function to perform the move. ; ; written: HKN 2/15/89 ; ;############################################################################ ; int 3 push dx push ax push bx push cx push si mov si, offset XmmMoveBuf ; cs:si points to buffer ; initialize length field shl cx, 1 ; cx = # of bytes to transfer mov word ptr cs:[si.mov_length], cx mov word ptr cs:[si.mov_length + 2], 0 or bh, bh jnz xmm_cache_write ; initialize source handle mov bx, [ext_handle] mov cs:[si.src_handle], bx ; initialize source offset mov word ptr cs:[si.src_offset], ax mov word ptr cs:[si.src_offset + 2], dx ; initialize destination handle and offset mov cs:[si.dst_handle], 0 ; offset is Segment:Offset mov word ptr cs:[si.dst_offset], di mov word ptr cs:[si.dst_offset + 2], es jmp short do_move xmm_cache_write: ; initialize source handle and offset mov cs:[si.src_handle], 0 ; offset is Segment:Offset mov word ptr cs:[si.src_offset], di mov word ptr cs:[si.src_offset + 2], es ; initialize destination handle mov bx, [ext_handle] mov cs:[si.dst_handle], bx ; initialize destination offset mov word ptr cs:[si.dst_offset], ax mov word ptr cs:[si.dst_offset + 2], dx ; call XMM to move memory do_move: mov ah, XMM_MOVE_EMB ; move ext. mem. block function call [XMMcontrol] shr ax,1 ; rotate 'success' bit into carry cmc ; make it a failure flag pop si pop cx pop bx pop ax pop dx ret ;*** XmmGuard - XMM front for Windows/386 v2.x detection ; ; This routine gets in front of the XMM control function, in ; order to detect Windows/386 v2.x as it loads. These versions ; of Windows corrupt XMS memory. When we spot the weird XMS ; call that these versions of Windows make, we'll fail the ; request, and Windows won't load. ; ; The call that Windows makes: ; ; AX = 0140h ; DX = current total free XMS extended memory ; ; If we spot these register values in an XMS call, we return ; ; AX = 0 'HMA not assigned to caller' ; BL = 91h 'HMA already in use' ; other registers unchanged ; ; Otherwise we pass the call on to the XMM. AnIret: iret ; used for popf workaround for 80286 bug assume cs:RAMCODE,ds:NOTHING,es:NOTHING,ss:NOTHING XmmGuard proc far ; Supply a standard XMS control header (see XMS document). jmp short XmmGuardEntry nop nop nop XmmGuardEntry: pushf ; preserve flags register cmp ax,0140h je CouldBe ; could be Windows/386 v2.x ToXmm: push cs call AnIret ; restore flags w/o popf (old 286 bug) jmp PrevXmm ; xfr to previous installed XMS handler CouldBe: push ax ; save caller's registers push bx push dx mov ah,XMM_QUERY_FREE_EXTMEM call XmmControl mov ax,dx ; AX = total kbytes free extended memory pop dx ; restore caller's DX cmp ax,dx ; caller's DX = total free ext'd mem? pop bx ; restore rest of caller's registers pop ax jne ToXmm ; DX doesn't match, it's not Win/386 v2.x ;* It's Windows/386 v2.x. Fail the Request HMA call. xor ax,ax ; AX = 'HMA not assigned to caller' mov bl,91h ; BL = 'HMA already in use' popf ; restore flags register ret XmmGuard endp ; Toss in enough space for swapped-in code. db 250h dup (?) ;** TRUE LOCATION OF ABOVE_PID ; ; Define the TRUE (runtime TYPE 2 driver) location of ABOVE_PID. ; This is the only piece of TYPE 2 specific data that we need ; in the resident image. We must define it HERE rather than down ; at ABOVE_BLKMOV so that we have its TRUE location after the ; TYPE 2 code is swapped in at initialization. If we defined ; it down at ABOVE_BLKMOV any instruction like: ; ; MOV DX,[ABOVE_PID] ; ; Would have to be "fixed up" when we moved the ABOVE_BLKMOV ; code into its final location. ; ABOVE_PID EQU WORD PTR $ - 2 ; TRUE location of ABOVE_PID ; ; The following label defines the end of the region where BLKMOV code ; may be swapped in. BLKMOV code to be swapped in MUST fit ; between DRIVE_CODE and DRIVE_END ; DRIVE_END LABEL WORD BREAK <BPB POINTER ARRAY> ;** BPB pointer array data ; ; BPB pointer array returned by INIT call. Must be part of resident image. ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; INITAB DW RDRIVEBPB ; ; The following label defines the end of the RAMDrive resident code ; for cases where no INT 9/19 code is included. ; DEVICE_END LABEL BYTE BREAK <INT 19 Handler. Incl if /A> ; ; The drive TYPE dependant piece of code works as follows: ; ; TYPE 2 DOES NOT use the EMM_CTRL sector but it still has ; a handler. What this handler does is issue an ; ABOVE_DEALLOC call to deallocate the Above Board ; memory allocated to the RAMDrive. In current versions ; of the EMM device driver this step is unnecessary ; as the EMM device driver is thrown away together ; with all of the allocation information when the system ; is re-booted. We do it anyway because some future version ; of the EMM device driver may be smarter and retain ; allocation information through a warm-boot. Currently, ; doing this doesn't hurt anything. Since this code cannot ; do a global ABOVE_DEALLOC for all TYPE 2 drivers in the ; system, it does an ABOVE_DEALLOC only for its memory ; and EACH TYPE 2 driver in the system includes the INT 19/9 ; code. ; ; Storage locations for the "next" INT 19 vector, the one ; that was in the interrupt table when the device driver was loaded. ; It is initialized to -1 to indicate it contains no useful information. ; OLD_19 LABEL DWORD DW -1 DW -1 ;** INT 19 Software re-boot handler ; ; All this piece of code does is sit on INT 19 waiting for ; a re-boot to be signaled by being called. It calls ; RESET_SYSTEM to perform driver TYPE specific re-boot code, ; resets the INT 19 and INT 9 vectors, ; and then jumps to OLD_19 to pass on the event. ; ; NOTE THAT UNLIKE INT 9 THIS HANDLER NEEDS TO RESET ; THE INT 9 AND INT 19 VECTORS. This is because the INT 19 ; IBM ROM re-boot code DOES NOT reset these vectors, and we ; don't want to leave them pointing to routines that are not ; protected from getting stomped on by the re-boot. ; ; SEE ALSO ; INT 19 IBM ROM code in ROM BIOS listing of ; IBM PC Technical Reference manual for any PC family member ; ; ENTRY ; NONE ; EXIT ; NONE, via OLD_19 ; USES ; FLAGS ; ; THIS CODE IS USED BY TYPE 1,2 and 3 drivers. ; INT_19: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING CALL RESET_SYSTEM PUSH AX PUSH DS XOR AX,AX MOV DS,AX ; ; Since INT 19 DOES NOT reset any vectors (like INT 9 Ctrl Alt DEL does), ; we must replace those vectors we have mucked with. ; ; NOTE THAT WE RESET VECTORS DIRECTLY!!!!!!!!!!!!!!!!!! ; We are not sure that DOS is reliable enough to call. ; MOV AX,WORD PTR [OLD_19] CLI MOV WORD PTR DS:[19H * 4],AX MOV AX,WORD PTR [OLD_19 + 2] MOV WORD PTR DS:[(19H * 4) + 2],AX POP DS POP AX JMP [OLD_19] ;** RESET_SYSTEM perform TYPE 1 (/E) driver specific reboot code ; ; NOTE: RESET_SYSTEM ALSO defines the start of ANOTHER piece of ; driver TYPE specific code that TYPE 2, 3 and 4 drivers ; will have to swap in a different piece of code for. ; ; ENTRY ; NONE ; EXIT ; NONE ; USES ; NONE ; ; This code is specific to TYPE 1 drivers ; RESET_SYSTEM: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING ; ; Is this ever executed for TYPE 1 driver? ; ; must leave space because other guys relocate ; on top of this ; .286 ; enable 80286 instructions pusha mov cs:[reboot_flg], 0ffh mov dx, [ext_handle] cmp dx, -1 je reset_skip mov ah, XMM_UNLOCK_EMB call [XmmControl] mov ah, XMM_FREE_EMB call [XmmControl] reset_skip: popa ret .8086 ; disable 80286 instructions ; Allow space for swapped-in code. db 30h dup (?) ; ; The following label performs two functions. It defines the end of the ; Driver TYPE specific RESET_SYSTEM code which will have to be replaced ; for different driver TYPEs as the code between RESET_SYSTEM and ; RESET_INCLUDE. Swapped in code MUST FIT between RESET_SYSTEM and ; RESET_INCLUDE. It also defines the end of the resident device driver ; code for a driver which wants to include the INT 19/ INT 9 code. ; RESET_INCLUDE LABEL BYTE BREAK <COMMON INIT CODE> ;** DISPOSABLE INIT DATA ; ; INIT data which need not be part of resident image ; DRIVER_SEL DB 2 ; 0 if /E (TYPE 1), 1 if /A (TYPE 2), ; 2 if resmem (TYPE 3 or 4) DEV_SIZE DW 64 ; Size in K of this device EXT_K DW ? ; Size in K of Exteneded memory. NUM_ARG DB 1 ; Counter for order dependent numeric ; arguments bbbb ssss dddd. INIT_DRIVE DB 1 ; 0 means drive is inited ; 1 means drive is to be inited ; MUST BE DEFAULT SETTING ; 2 means drive is to be inited ; REGARDLESS of the existence of ; a valid DOS volume signature. GOTSWITCH DB 0 ; 0 if no switch, NZ if switch seen DIRSEC DW ? ; Number of directory SECTORS TERM_ADDR LABEL DWORD ; Address to return as break address in INIT packet DW OFFSET DEVICE_END ; INIT to NOT include INT 19 code DW ? ; RAMDrive CS filled in at INIT TRUE_CS DW ? ; Used to store the "true" location of ; the driver when the relocation at ; RAMDrive_RELOC is performed. DosVersion DW ? ; M002: MS-DOS version # (high byte = Major, ; low byte = Minor). RESMEM_SPECIAL DB 0 ; 0 means NORMAL TYPE 3 RAMDrive ; NZ means SPECIAL TYPE 4 RESMEM version ; see code at RAMDrive_RELOC XmmControlBase label dword ; base address of XMM control headers dw -1 dw -1 XmmControlJmpVal db ? ; offset byte of short jmp instruction ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;** PRINT - Print a "$" terminated message on stdout ; ; This routine prints "$" terminated messages on stdout. ; It may be called with only the DX part of the DS:DX message ; pointer set, the routine puts the correct value in DS to point ; at the RAMDrive messages. ; ; ENTRY: ; DX pointer to "$" terminated message (RAMCODE relative) ; EXIT: ; NONE ; USES: ; AX ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; PRINT: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING PUSH DS PUSH CS POP DS MOV AH,Std_Con_String_Output INT 21H POP DS RET ;** ITOA - Print Decimal Integer on stdout ; ; Print an unsigned 16 bit value as a decimal integer on stdout ; with leading zero supression. Prints from 1 to 5 digits. Value ; 0 prints as "0". ; ; Routine uses divide instruction and a recursive call. Maximum ; recursion is four (five digit number) plus one word on stack ; for each level. ; ; ENTRY AX has binary value to be printed ; EXIT NONE ; USES AX,CX,DX,FLAGS ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; ITOA: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING MOV CX,10 XOR DX,DX DIV CX ; DX is low digit, AX is higher digits OR AX,AX JZ PRINT_THIS_DIGIT ; No more higher digits PUSH DX ; Save this digit CALL ITOA ; Print higher digits first POP DX ; Recover this digit PRINT_THIS_DIGIT: ADD DL,"0" ; Convert to ASCII MOV AH,Std_CON_Output INT 21H RET ;** RAM$INIT - Device Driver Initialization routine ; ; RAMDRIVE Initialization routine. This is the COMMON initialization ; code used by ALL driver TYPEs. Its jobs are to: ; ; 1. Initialize various global values ; 2. Check for correct DOS version and do changes to the device ; based on the DOS version if needed. ; 3. Parse the command line and set values accordingly ; 4. Call a TYPE specific INIT routine based on the Parse ; to set up a specific driver TYPE. ; 5. Initialize the DOS volume in the RAMDrive memory if appropriate ; 6. Print out report of RAMDrive parameters ; 7. Set the return INIT I/O packet values ; ; The first two lines perform step 1. Step two starts after and ; goes through VER_OK. Step 3 starts at VER_OK and goes through ; ARGS_DONE. Step 4 starts at ARGS_DONE and goes through I001. ; Step 5 starts at I001 and goes through DRIVE_SET. Step 6 starts ; at DRIVE_SET and goes through SETBPB. Step 7 starts at SETBPB ; and ends at the JMP DEVEXIT 10 lines later. ; ; At any time during the above steps an error may be detected. When ; this happens one of the error messages is printed and RAMDrive ; "de-installs" itself by returning a unit count of 0 in the INIT ; device I/O packet. The DOS device installation code is responsible ; for taking care of the details of re-claiming the memory used by the ; device driver. All RAMDrive needs to do is make sure any INT vectors ; it changed (INT 19) get restored to what they were when RAMDrive ; first started. A TYPE 1 driver must make sure any XMS memory it ; allocated is deallocated and must unhook from the XMM control chain. ; A TYPE 2 driver must ABOVE_DEALLOC any memory it allocated from the ; EMM device. The duty of reclaiming XMS or Above Board memory, ; re-setting vectors, and unhooking from the XMM control chain is done ; by the DISK_ABORT routine which may be called by either this COMMON ; INIT code, or the TYPE specific INIT code. ; ; Step 1 initializes the segment part of TERM_ADDR to the correct ; value for type 1, 2 and 3 drivers. A TYPE 4 driver will put a ; different value in TERM_ADDR as it must include the space taken up ; by the RAMDrive memory itself which is part of the device. TRUE_CS ; is also initialized. This datum is relevant to the RESMEM_SPECIAL ; (TYPE 4) driver which relocates the driver code at RAMDrive_RELOC. ; This datum stores the CS of the REAL driver (the driver location ; BEFORE the relocation took place). ; ; Step 2 checks to make sure that we are running on a DOS in the ; 2.X or 3.X series which this driver is restricted to. If running ; on a 2.X series the device header attribute word and device command ; table are patched to exclude those device calls that don't exist ; on DOS 2.X. The HEADERMES message is also patched to not include ; the DOS drive letter part because 2.X DOS does not provide this ; information to the device at INIT time. ; ; Step 3 uses the "DEVICE = xxxxxxxxx" line pointer provided by ; DOS to look for the various device parameters. NOTE: This pointer ; IS NOT DOCUMENTED in the DOS 2.X tech ref material, but it does ; exist in the same way as 3.X. This code is simple even though ; it looks rather long. First it skips over the device name field ; to get to the arguments. In then parses the arguments as they are ; encountered. All parameter errors are detected here. NOTE THAT ; THIS ROUTINE IS NOT RESPONSIBLE FOR SETTING DEFAULT VALUES OF ; PARAMETER VARIABLES. This is accomplished by static initialization ; of the parameter variables. ; ; Step 4 calls a device TYPE specific initialization routine based ; on the parse in step 3 (presence or absense of /E and /A switches). ; NOTE THAT THERE IS ONE ROUTINE FOR TYPE 3 AND 4 DRIVERS. It is up ; to this routine itself to make the distinction between TYPE 3 and ; TYPE 4. NOTE that one of the prime jobs of these device TYPE specific ; routines is to set all of the variables that are needed by Step ; 5 and 7 that haven't been set by the COMMON init code: ; ; DEV_SIZE set to TRUE size of device ; BASE_ADDR set to TRUE start of device so MEMIO ; can be called ; TERM_ADDR set to correct end of device ; INIT_DRIVE set to indicate if DOS volume needs to ; be set up ; RESMEM_SPECIAL set if TYPE 4 driver ; ; Step 5 looks at the INIT_DRIVE variable to see if the DOS volume ; needs to be initialized. The only time we do not need to INITialize ; the DOS volume is when the driver TYPE specific INIT code finds ; that there is a VALID DOS volume in the RAMDrive memory it just ; set up. If the DOS volume does not need to be initialized, we ; go on to step 6. Otherwise the device BPB must be set, the ; RESERVED (boot) sector, FAT sectors, and root directory sectors ; must be initialized and written out to the RAMDrive. The first step ; is to initialize all of the BPB values. The code is a typical piece ; of MS-DOS code which given BYTES/SECTOR, TOTAL DISK SIZE ; and NUMBER OF ROOT DIRECTORY ENTRIES inputs figures out reasonable ; values for SEC/CLUSTER and SECTORS/FAT and TOTAL NUMBER OF CLUSTERS. ; NOTE THAT THIS CODE IS TUNED AND SPECIFIC TO 12 BIT FATS. Don't ; expect it to work AT ALL with a 16 bit FAT. The next step is to write ; out the BOOT record containing the BPB to sector 0, write out ; a FAT with all of the clusters free, and write out a root directory ; with ONE entry (the Volume ID at VOLID). Take CAREFUL note of the ; special code and comments at RAMDrive_RELOC. ; ; Step 6 makes the status report display of DEVICE SIZE, SECTOR SIZE, ; CLUSTER SIZE, and DIRECTORY SIZE by simply printing out the values ; from the BPB. ; ; Step 7 sets the INIT I/O packet return values for # of units, ; Break address, and BPB array pointer and returns via DEVEXIT. ; ; SEE ALSO ; MS-DOS Technical Reference manual section on ; Installable Device Drivers ; ; ENTRY from RAM$IN ; EXIT Through DEVEXIT ; USES ALL ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; RAM$INIT: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING ; ; 1. Initialize various global values ; MOV WORD PTR [TERM_ADDR + 2],CS MOV [TRUE_CS],CS ; ; 2. Check for correct DOS version and do changes to the device ; based on the DOS version if needed. ; CLD MOV AH,GET_VERSION INT 21H XCHG AH,AL MOV DosVersion,AX ; M002: Save MS-DOS version #. CMP AX,(2 SHL 8) + 00 JB BADVER ; Below 2.00, BAD CMP AX,(3 SHL 8) + 00 JB VER2X ; 2.X requires some patches CMP AX,(7 SHL 8) + 00 JB VER_OK ; thru 6.x ok BADVER: MOV DX,OFFSET BADVERMES JMP DEVABORT VER2X: AND [DEVATS],NOT DEVOPCL ; No such bit in 2.X MOV BYTE PTR [RAMTBL],11 ; Fewer functions too MOV WORD PTR [PATCH2X],0A0DH ; Don't know DOS drive MOV BYTE PTR [PATCH2X + 2],"$" VER_OK: ; ; 3. Parse the command line and set values accordingly ; LDS SI,[PTRSAV] ASSUME DS:NOTHING MOV AL,[SI.INIT_DOSDEV] ; DOS drive letter ADD CS:[DOS_DRV],AL ; Need explicit over, this is a forward ref MOV DX,OFFSET HEADERMES CALL PRINT LDS SI,[SI.INIT_BPB] ; DS:SI points to config.sys SKIPLP1: ; Skip leading delims to start of name LODSB CMP AL," " JZ SKIPLP1 CMP AL,9 JZ SKIPLP1 CMP AL,"," JZ SKIPLP1 JMP SHORT SKIPNM ARGS_DONEJ: JMP ARGS_DONE SWITCHJ: JMP SWITCH SKIPLP2: ; Skip over device name LODSB SKIPNM: CMP AL,13 JZ ARGS_DONEJ CMP AL,10 JZ ARGS_DONEJ CMP AL," " JZ FIRST_ARG CMP AL,9 JZ FIRST_ARG CMP AL,"," JZ FIRST_ARG CMP AL,0 ; Need this for 2.0 2.1 JNZ SKIPLP2 SCAN_LOOP: ; PROCESS arguments LODSB FIRST_ARG: OR AL,AL ; Need this for 2.0 2.1 JZ ARGS_DONEJ CMP AL,13 JZ ARGS_DONEJ CMP AL,10 JZ ARGS_DONEJ CMP AL," " JZ SCAN_LOOP CMP AL,9 JZ SCAN_LOOP CMP AL,"," JZ SCAN_LOOP CMP AL,"/" JZ SWITCHJ CMP AL,"0" JB BAD_PARMJ CMP AL,"9" JA BAD_PARMJ DEC SI CALL GETNUM CMP [NUM_ARG],3 JA BAD_PARMJ ; Only 3 numeric arguments JZ SET_DIR CMP [NUM_ARG],2 JZ SET_SECTOR SET_SIZE: CMP BX,4 ;M002: 4K minimum drive size. JB BAD_PARMJ CMP BX,32768 ;M001: Drive size must be < 32M. JAE BAD_PARMJ ;M001 MOV [DEV_SIZE],BX JMP SHORT NUM_DONE ;M001 ;Currently, the drive size must be < 32Meg. The total sectors of the drive ;must be < 64K (16-bit #). This constrains the sector size as follows: ; ; Sector size Drive size Shift factor ; ----------- ---------- ------------ ; 1024 < 32M 9 ; 512 < 32M 8 ; 256 < 16M 7 ; 128 < 8M 6 SET_SECTOR: mov [SSIZE],bx ;Temporarily store input bytes/sect. mov dx,[DEV_SIZE] ;Drive size has already been parsed. mov al,6 ;Shift factor = 6. ss128: cmp bx,128 ;Bytes/sect = 128? jne ss256 ; -no, jump. cmp dx,8192 ; -yes; drive size < 8M? jb ssOK ; -yes, jump. shl bx,1 ; -no, adjust sector size. ss256: inc al ;Shift factor = 7. cmp bx,256 ;Bytes/sect = 256? jne ss512 ; -no, jump. cmp dx,16384 ; -yes; drive size < 16M? jb ssOK ; -yes, jump. shl bx,1 ss512: inc al ;Shift factor = 8. cmp bx,512 ;Bytes/sect = 512? je ssOK ; -yes, jump: 512 always OK. ss1024: inc al ;Shift factor = 9. cmp bx,1024 ;Bytes/sect = 1024? jne BAD_PARM ; -no, jump: invalid input parameter. ; -yes: 1024 always OK. ssOK: mov [SEC_SHFT],al cmp bx,[SSIZE] ;Sector adjusted? je NUM_DONE ; -no, jump. mov [SSIZE],bx mov dx,OFFSET SECT_ADJ call PRINT ;Notify user of sector adjustment. jmp short NUM_DONE BAD_PARMJ: jmp short BAD_PARM ;M001 SET_DIR: CMP BX,2 JB BAD_PARM CMP BX,1024 JA BAD_PARM ; ; NOTE: Since DIRNUM is the 3rd numeric arg and SSIZE is the first, ; we know the desired sector size has been given. ; MOV DI,[SSIZE] MOV CL,5 ; 32 bytes per dir ent SHR DI,CL ; DI is number of dir ents in a sector MOV AX,BX XOR DX,DX DIV DI ; Rem in DX is partial dir sector OR DX,DX JZ SET_DSZ ; User specified groovy number SUB DI,DX ; Figure how much user goofed by ADD BX,DI ; Round UP by DI entries SET_DSZ: MOV [DIRNUM],BX NUM_DONE: INC [NUM_ARG] ; Next numeric argument SCAN_LOOPJ: JMP SCAN_LOOP BAD_PARM: MOV DX,OFFSET ERRMSG1 DEVABORT: CALL PRINT DEVABORT_NOMES: XOR AX,AX ;Indicate no devices JMP SETBPB ;and return SWITCH: MOV AL,0FFH XCHG AL,[GOTSWITCH] ; Switch already? OR AL,AL JNZ BAD_PARM ; Yes, only one allowed LODSB CMP AL,"E" JZ EXT_SET CMP AL,"e" JNZ ABOVE_TEST EXT_SET: MOV [DRIVER_SEL],0 JMP SCAN_LOOP ABOVE_TEST: CMP AL,"A" JZ ABOVE_SET CMP AL,"a" JNZ BAD_PARM ABOVE_SET: MOV [DRIVER_SEL],1 JMP SCAN_LOOP ARGS_DONE: ; ; 4. Call a TYPE specific INIT routine based on the Parse ; to set up a specific driver TYPE. ; PUSH CS POP DS ASSUME DS:RAMCODE MOV AL,[DRIVER_SEL] ; Find out which init to call OR AL,AL JNZ NEXTV CALL EXT_INIT JMP SHORT INI_RET NEXTV: DEC AL JNZ DORESM CALL ABOVE_INIT JMP SHORT INI_RET DORESM: CALL RESMEM_INIT INI_RET: JNC I001 JMP DEVABORT_NOMES I001: ; ; 5. Initialize the DOS volume in the RAMDrive memory if appropriate ; CMP [INIT_DRIVE],0 JNZ INIDRV ; Need to initialize drive JMP DRIVE_SET ; All set to go INIDRV: ; ; We must figure out what to do. ; All values are set so we can call MEMIO to read and write disk ; SSIZE is user sector size in bytes ; DIRNUM is user directory entries ; DEV_SIZE is size of device in K bytes ; ; Figure out total number of sectors in logical image MOV AX,[DEV_SIZE] MOV CX,1024 MUL CX ; DX:AX is size in bytes of image DIV [SSIZE] ; AX is total sectors ; Any remainder in DX is ignored MOV [SECLIM],AX ; Compute # of directory sectors MOV AX,[DIRNUM] MOV CL,5 ; Mult by 32 bytes per entry SHL AX,CL ; Don't need to worry about overflow, # ents ; is at most 1024 XOR DX,DX DIV [SSIZE] OR DX,DX JZ NOINC INC AX NOINC: ; AX is # sectors for root dir MOV [DIRSEC],AX ADD AX,2 ; One reserved, At least one FAT sector CMP AX,[SECLIM] JB OK001 ; we're OK MOV [DIRNUM],16 ; Smallest reasonable number XOR DX,DX MOV AX,512 ; 16*32 = 512 bytes for dir DIV [SSIZE] OR DX,DX JZ NOINC2 INC AX NOINC2: ; AX is # sectors for root dir MOV [DIRSEC],AX ADD AX,2 ; One reserved, At least one FAT sector CMP AX,[SECLIM] JB OK001 ; 16 directory sectors got us to OK CALL DISK_ABORT ; Barf MOV DX,OFFSET ERRMSG2 JMP DEVABORT OK001: mov si,64 ; set a loop bound for the homing process ; to avoid oscillation in homing CLUSHOME: ; Figure a reasonable cluster size MOV AX,[SECLIM] ; AX is total sectors on disk SUB AX,[RESSEC] ; Sub off reserved sectors MOV CL,[FATNUM] ; CX is number of FATs XOR CH,CH FATSUB: SUB AX,[FATSEC] ; Sub off FAT sectors LOOP FATSUB SUB AX,[DIRSEC] ; Sub off directory sectors, AX is # data sectors ; BUGBUG ; Note: The following four instances of "4096-18" were ; "4096-10". I've changed to this because DOS was freaked ; out by a 2M byte drive with 64 directory entries and ; 1 sector per cluster. Note that the last cluster # for ; such a drive is FF0. I've seen it stated that FF0-FF6 ; are used for "reserved" clusters. I'm going to force ; a 2M byte ramdisk to use 2 sectors per cluster. It seems ; to fix the bug, and it may even be correct. -davidols, 2/90 MOV BX,1 ; Start at 1 sec per alloc unit CMP AX,4096-18 JB CSET ; 1 sector per cluster is OK MOV BX,2 CMP AX,(4096-18) * 2 JB CSET ; 2 sector per cluster is OK MOV BX,4 CMP AX,(4096-18) * 4 JB CSET ; 4 sector per cluster is OK MOV BX,8 CMP AX,(4096-18) * 8 JB CSET ; 8 sector per cluster is OK MOV BX,16 ;M001 CMP AX,(4096-18) * 16 JB CSET ; 16 sector per cluster is OK MOV BX,32 ; 32 sector per cluster is OK ;M001 CSET: ; Figure FAT size. AX is reasonable approx to number of DATA sectors ; BX is reasonable sec/cluster XOR DX,DX DIV BX ; AX is total clusters, ignore remainder ; can't have a "partial" cluster MOV CX,AX SHR CX,1 JNC ADDIT INC CX ADDIT: ADD AX,CX ; AX is Bytes for fat (1.5 * # of clusters) ADD AX,3 ; Plus two reserved clusters XOR DX,DX DIV [SSIZE] ; AX is # sectors for a FAT this size OR DX,DX JZ NOINC4 INC AX ; Round up NOINC4: ; AX is # sectors for FAT XCHG AX,[FATSEC] ; Set newly computed value XCHG BL,[CSIZE] ; Set newly computed value dec si ; have we looped enough? jz homfin ; yes, time to get out CMP BL,[CSIZE] ; Did we compute a different size? JNZ CLUSHOME ; Keep performing FATSEC and CSIZE computation ; until the values don't change. CMP AX,[FATSEC] ; Did we compute a different size? JNZ CLUSHOME ; Keep performing FATSEC and CSIZE computation ; until the values don't change. HOMFIN: ; ; 6. Print out report of RAMDrive parameters ; MOV DX,OFFSET STATMES1 CALL PRINT MOV AX,[DEV_SIZE] CALL ITOA MOV DX,OFFSET STATMES2 CALL PRINT MOV AX,[SSIZE] CALL ITOA MOV DX,OFFSET STATMES3 CALL PRINT MOV AL,[CSIZE] XOR AH,AH CALL ITOA MOV DX,OFFSET STATMES4 CALL PRINT MOV AX,[DIRNUM] CALL ITOA MOV DX,OFFSET STATMES5 CALL PRINT CMP [RESMEM_SPECIAL],0 JZ NO_RELOC ; ; We are in a special case. The RAMDrive driver area starts at DEVICE_END. ; If we left this INIT code where it is and executed it the act of ; Initializing the boot sector, FAT, and root directory would overwrite ; this INIT code as we are executing it. So what we do is COPY this ; code into the DATA area of the RAMDrive and execute it from there. ; RAMDrive_RELOC: MOV AX,1 ; AX is sec # of start of FAT ADD AX,[FATSEC] ; AX is sec # of start of directory ADD AX,[DIRSEC] ; AX is sec # of start of DATA MUL [SSIZE] ; DX:AX is byte offset of start of DATA ADD AX,WORD PTR [BASE_ADDR] ADC DX,WORD PTR [BASE_ADDR + 2] ; DX:AX is 32 addr of first byte of DATA ADD AX,15 ; PARA round up ADC DX,0 MOV CX,16 DIV CX ; AX is Seg addr of DATA region ; ; At this point we need to do a little check. We need to make ; sure the distance between where we are now, and where we ; are relocating to is AT LEAST as much as we are moving ; so that we don't modify ourselves while we're moving ; MOV BX,AX MOV DX,CS SUB BX,DX ; BX is para between segs CMP BX,((OFFSET RAMDrive_END - OFFSET RAMDEV) + 15) / 16 ; CMP to para moving JAE OKMOV ; Distance is enough MOV AX,CS ; Move far enough away ADD AX,((OFFSET RAMDrive_END - OFFSET RAMDEV) + 15) / 16 OKMOV: MOV ES,AX XOR SI,SI MOV DI,SI MOV CX,OFFSET RAMDrive_END ; Amount to move CLD REP MOVSB ; Reloc to data region PUSH ES ; Push FAR return MOV AX,OFFSET NO_RELOC PUSH AX PUSH ES POP DS ; DS is NEW RAMCODE RELOCR PROC FAR RET RELOCR ENDP NO_RELOC: PUSH CS POP ES XOR DX,DX ; Sector 0 MOV CX,1 ; One sector MOV DI,OFFSET BOOT_SECTOR ; Boot sector MOV BH,1 ; Write CALL INIMEMIO INC DX ; First FAT sector MOV DI,OFFSET SECTOR_BUFFER XOR AX,AX MOV CX,512 CLD REP STOSW MOV DI,OFFSET SECTOR_BUFFER MOV CX,1 MOV WORD PTR ES:[DI],0FFF8H MOV BYTE PTR ES:[DI + 2],0FFH CALL INIMEMIO INC DX ; Next sector MOV WORD PTR ES:[DI],0 MOV BYTE PTR ES:[DI + 2],0 MOV CX,[FATSEC] DEC CX JCXZ FATDONE FATZERO: PUSH CX MOV CX,1 CALL INIMEMIO INC DX ; Next sector POP CX LOOP FATZERO FATDONE: MOV CX,1 MOV DI,OFFSET VOLID CALL INIMEMIO ; FIRST directory sector INC DX MOV CX,[DIRSEC] DEC CX JCXZ DRIVE_SET MOV DI,OFFSET SECTOR_BUFFER DIRZERO: PUSH CX MOV CX,1 CALL INIMEMIO INC DX ; Next sector POP CX LOOP DIRZERO ; DRIVE_SET: ; ; BPB IS NOW ALL SET ; MOV AL,1 ;Number of ramdrives ; ; NOTE FALL THROUGH!!!!!!! ; ;** SETBPB - Set INIT packet I/O return values ; ; This entry is used in ERROR situations to return ; a unit count of 0 by jumping here with AL = 0. ; The successful code path falls through to here ; with AL = 1 ; ; ENTRY ; AL = INIT packet unit count ; EXIT ; through DEVEXIT ; USES ; DS, BX, CX ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; SETBPB: ASSUME DS:NOTHING ; ; 7. Set the return INIT I/O packet values ; LDS BX,[PTRSAV] MOV [BX.INIT_NUM],AL MOV CX,WORD PTR [TERM_ADDR] MOV WORD PTR [BX.INIT_BREAK],CX ;SET BREAK ADDRESS MOV CX,WORD PTR [TERM_ADDR + 2] MOV WORD PTR [BX.INIT_BREAK + 2],CX MOV WORD PTR [BX.INIT_BPB],OFFSET INITAB ;SET POINTER TO BPB ARRAY MOV CX,[TRUE_CS] MOV WORD PTR [BX.INIT_BPB + 2],CX JMP DEVEXIT ;** INIMEMIO call MEMIO but preserve registers ; ; MEMIO is very register destructive, all this routine ; does is provide a less destructive way to call MEMIO. ; ; ENTRY ; Same as MEMIO ; EXIT ; Same as MEMIO ; USES ; AX, SI, BP ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; INIMEMIO: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING PUSH ES PUSH DI PUSH DS PUSH CX PUSH DX PUSH BX CALL MEMIO POP BX POP DX POP CX POP DS POP DI POP ES RET ;** GETNUM - Read an unsigned integer ; ; This routine looks at DS:SI for a decimal unsigned integer. ; It is up to the caller to make sure DS:SI points to the start ; of a number. If it is called without DS:SI pointing to a valid ; decimal digit the routine will return 0. Any non decimal digit ; defines the end of the number and SI is advanced over the ; digits which composed the number. Leading "0"s are OK. ; ; THIS ROUTINE DOES NOT CHECK FOR NUMBERS LARGER THAN WILL FIT ; IN 16 BITS. If it is passed a pointer to a number larger than ; 16 bits it will return the low 16 bits of the number. ; ; This routine uses the MUL instruction to multiply the running ; number by 10 (initial value is 0) and add the numeric value ; of the current digit. Any overflow on the MUL or ADD is ignored. ; ; ENTRY: ; DS:SI -> ASCII text of number ; EXIT: ; BX is binary for number ; SI advanced to point to char after number ; USES: ; AX,BX,DX,SI ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; GETNUM: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING XOR BX,BX GETNUM1: LODSB SUB AL,"0" JB NUMRET CMP AL,9 JA NUMRET CBW XCHG AX,BX MOV DX,10 MUL DX ADD BX,AX JMP GETNUM1 NUMRET: DEC SI RET BREAK <RAMDrive COMMON INIT ROUTINES> ;** DISK_ABORT - De-install RAMDrive after init ; ; This routine MUST BE CALLED to de-install a RAMDrive driver ; if the de-installation takes place: ; ; AFTER the INT 19 vector is replaced for TYPE 2 ; AFTER ABOVE_PID is valid for TYPE 2 ; AFTER XMS memory has been allocated for TYPE 1 ; ; NOTE: Since a TYPE 4 driver does NONE of the above things it is ; not necessary to call this routine, but the routine is ; designed so that it is OK to call for a TYPE 4 driver. ; ; In all cases the INT 19 vector is replaced if the ; value of both words of OLD_19 is NOT -1. This is why the initial value ; of this datum is -1. In the event that the INT 19 vector ; is replaced, this datum takes on some value other than -1. ; ; If this is a TYPE 1 driver and we have allocated XMS memory ; (true if ext_handle is NOT -1), the XMS memory block is deallocated. ; Also, if we have hooked into the XMM control chain (true if the ; doubleword at XmmControlBase is not -1), we unhook. ; ; If this is a TYPE 2 driver, an ABOVE_DEALLOC call is made on ; ABOVE_PID. ; ; ENTRY: ; NONE ; ; ext_handle valid or -1 if TYPE 1 ; ABOVE_PID valid if TYPE 2 ; ; EXIT: ; NONE ; USES: ; ALL but DS ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; DISK_ABORT: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING CMP [DRIVER_SEL],1 JNZ NOT_ABOVE AGAIN: ; ; TYPE 2, Deallocate the Above Board memory ; MOV DX,[ABOVE_PID] MOV AH,ABOVE_DEALLOC INT 67H CMP AH,ABOVE_ERROR_BUSY JZ AGAIN JMP SHORT RET002 NOT_ABOVE: CMP [RESMEM_SPECIAL],0 JNZ RET002 ; No EMM_CTRL on TYPE 4 ; ; TYPE 1, Deallocate XMS memory ; mov dx, [ext_handle] cmp dx, -1 je xmsdealloc_skip ; XMS memory not allocated mov ah, XMM_UNLOCK_EMB call [XmmControl] mov ah, XMM_FREE_EMB call [XmmControl] xmsdealloc_skip: ; ; Remove ourselves from the XMM control chain if XmmControlBase ; is not -1. ; ; We assume that no one has hooked us, since we're still in driver ; initialization. ; cmp word ptr XmmControlBase,-1 jne UnhookXmm cmp word ptr XmmControlBase+2,-1 je Ret002 ; we didn't hook- don't unhook UnhookXmm: mov al,0EBh ; AL = opcode for short jump mov ah,XmmControlJmpVal ; AH = displacement for short jump les bx,XmmControlBase ; ES:BX = ptr to previous XMM header mov word ptr es:[bx],ax ; restore previous XMM's short jump mov word ptr es:[bx+2],9090h; followed by nop's mov byte ptr es:[bx+4],90h RET002: ; ; Reset INT 19 if OLD_19 is not -1 ; PUSH DS LDS DX,[OLD_19] ASSUME DS:NOTHING MOV AX,DS CMP AX,-1 JNZ RESET_VECS CMP AX,DX JZ NO_VECS RESET_VECS: MOV AX,(Set_Interrupt_Vector SHL 8) OR 19H INT 21H NO_VECS: POP DS RET ;** CTRL_IO - Read/Write the first 1024 bytes at BASE_ADDR ; ; This routine is used at INIT time to read the first 1024 ; bytes at BASE_ADDR. If TYPE 1 or TYPE 3 and BASE_ADDR points ; to the EMM_CTRL address (initial value), the EMM_CTRL sector ; is read/written. If TYPE 1 or TYPE 3 and BASE_ADDR has been set ; to the start of a RAMDrive, the first 1024 bytes of the DOS volume ; are read/written. If TYPE 2 or TYPE 4, the first 1024 bytes of ; the DOS volume are read/written. All this routine does is ; set inputs to BLKMOV to transfer 1024 bytes at offset 0 to/from ; SECTOR_BUFFER. ; ; ENTRY: ; BH = 0 for READ, 1 for WRITE ; EXIT: ; SECTOR_BUFFER filled in with 1024 bytes at BASE_ADDR ; USES: ; ALL but DS ; ; COMMON TO TYPE 1, 2, 3, 4 drivers ; CTRL_IO: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING XOR DX,DX MOV AX,DX ; Offset 0 MOV CX,512 ; 1024 bytes PUSH CS POP ES MOV DI,OFFSET SECTOR_BUFFER PUSH DS CALL BLKMOV ; Read in EMM_CTRL POP DS RET ;** CHECK_DOS_VOL examine RAMDrive region for valid DOS volume. ; ; This routine is used by TYPE 1, 2 and 3 drivers to check and see ; if the RAMDrive memory contains a valid DOS volume (one that lived ; through a re-boot). Its prime job is to set INIT_DRIVE to indicate ; whether the DOS volume needs to be initialized. ; ; First the first 1024 bytes of the drive are read in to SECTOR_BUFFER ; Next we check for a match of the signature areas up at BOOT_SECTOR ; to see if this drive contains a VALID RAMDrive boot record. ; IF the signatures are valid AND INIT_DRIVE != 2 (ignore valid signature) ; We check to make sure that SSIZE and DIRNUM set by the user ; match the values in the BPB we just found. ; IF they match ; we set INIT_DRIVE to 0 (don't init) ; and transfer the BPB out of the boot sector on the drive ; (in SECTOR_BUFFER) into the BPB for this driver at ; RDRIVEBPB. ; ELSE ; Leave INIT_DRIVE set to whatever it was on input (1 or 2) ; indicating that the drive must be INITed. ; ELSE ; Leave INIT_DRIVE set to whatever it was on input (1 or 2) ; indicating that the drive must be INITed. ; ; WARNING! This routine DOES NOT check to make sure that the size of ; the device as indicated in the BPB transfered in if a valid ; DOS volume is found is consistent with the actual size ; of the memory allocated to the device (DEV_SIZE). It ; is up to the caller to check this if so desired. ; ; ENTRY: ; BASE_ADDR set to point at START of DOS device ; Except for TYPE 1, which uses ext_handle ; EXIT: ; CARRY SET - error, message already printed ; CARRY CLEAR ; INIT_DRIVE set ; SECTOR_BUFFER contains first 1024 bytes of device ; USES: ; All but DS ; ; Used by TYPE 1, 2 and 3 drivers ; CHECK_DOS_VOL: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING XOR BH,BH ; READ ; ; NOTE: WE CANNOT CALL MEMIO, WE MUST STILL USE CTRL_IO because the BPB ; is not set up. ; CALL CTRL_IO ; Since BASE_ADDR is set, reads start of DEVICE MOV DX,OFFSET INIT_IO_ERR JC ERR_RET2 PUSH CS POP ES MOV DI,OFFSET SECTOR_BUFFER MOV SI,OFFSET BOOT_SECTOR MOV CX,OFFSET RDRIVEBPB - OFFSET BOOT_SECTOR CLD REPE CMPSB JNZ OK_RET ; No DOS device ADD DI,OFFSET BOOT_START - OFFSET RDRIVEBPB ADD SI,OFFSET BOOT_START - OFFSET RDRIVEBPB MOV CX,OFFSET BOOT_END - OFFSET BOOT_START REPE CMPSB JNZ OK_RET ; No DOS device CMP [INIT_DRIVE],2 JZ NOT_VALID ; Current value 2 means we CANNOT ; assume this BPB is valid. ; ; Check to make sure found BPB has same SSIZE and DIRNUM values ; MOV SI,OFFSET SECTOR_BUFFER + (OFFSET SSIZE - OFFSET BOOT_SECTOR) LODSW CMP AX,[SSIZE] JNZ NOT_VALID ; Sector size different than user request MOV SI,OFFSET SECTOR_BUFFER + (OFFSET DIRNUM - OFFSET BOOT_SECTOR) LODSW CMP AX,[DIRNUM] JNZ NOT_VALID ; Sector size different than user request MOV [INIT_DRIVE],0 ; Found a DOS drive MOV DI,OFFSET RDRIVEBPB MOV SI,OFFSET SECTOR_BUFFER + (OFFSET RDRIVEBPB - OFFSET BOOT_SECTOR) MOV CX,OFFSET BOOT_START - OFFSET RDRIVEBPB REP MOVSB ; Set correct BPB NOT_VALID: OK_RET: CLC RET ERR_RET2: CALL PRINT STC RET ;** SET_RESET - Set up INT 19/INT 9 vectors ; ; This routine will do nothing if BX is non-zero ; otherwise it will install the INT 19 ; code by saving the current INT 19 ; vector in OLD_19 (NOTE: the change in the value of OLD_19 ; to something other than -1 indicates that the vector has been ; replaced), setting the vector to point to INT_19, ; and adjusting TERM_ADDR to include the code as part of the resident ; image. ; ; ENTRY: ; BX is 0 if INT 19 code to be installed ; EXIT: ; NONE ; USES: ; None ; ; COMMON TO TYPE 1, 2, 3, 4 drivers (?) ; SET_RESET: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING OR BX,BX JNZ RET005 PUSH AX PUSH DX PUSH BX PUSH ES MOV AX,(Get_Interrupt_Vector SHL 8) OR 19H INT 21H MOV WORD PTR [OLD_19],BX MOV WORD PTR [OLD_19 + 2],ES MOV DX,OFFSET INT_19 MOV AX,(Set_Interrupt_Vector SHL 8) OR 19H INT 21H MOV WORD PTR [TERM_ADDR],OFFSET RESET_INCLUDE POP ES POP BX POP DX POP AX RET005: RET page ;****************************************************************************** ; check_XMM: routine to check presence of XMM driver ; ; ENTRY: DS = INT13CODE ; EXIT: carry set if error occurred ; USED: none ; ;****************************************************************************** check_XMM proc near assume ds:RAMCODE, es:NOTHING, ss:NOTHING ; ; determine whether or not an XMM driver is installed ; push ax mov ax,XMM_MULTIPLEX SHL 8 + XMM_INSTALL_CHECK int 2Fh cmp al,80h ; Q: installed jne cXMM_no_driver ; N: set error, quit ; ; get the XMM control functions entry point, save it, we ; need to call it later. ; push es push bx mov ax,XMM_MULTIPLEX SHL 8 + XMM_FUNCTION_ADDR int 2Fh ; push ds ; push seg INT13CODE ; pop ds mov word ptr [XMMcontrol], bx mov word ptr [XMMcontrol+2],es ; pop ds pop bx pop es pop ax clc ret ; done ; ; flag error : XMM driver not present ; cXMM_no_driver: stc pop ax ret check_XMM endp BREAK </E INIT Code> ;** EXT_INIT - Perform /E (TYPE 1) specific initialization ; ; This code does the drive TYPE specific initialization for TYPE 1 ; drivers. ; ; Determine if XMS driver is installed. ; If no XMS driver answers, cough politely and don't install. ; Determine extended memory available. ; If not enough memory is available, sniff and don't install. ; Allocate extended memory via XMS driver. ; Place ourselves in XMM control chain to watch for Windows/386 2.x. ; If the previous control chain is invalid, flatulate and don't install. ; ; ENTRY: ; Invokation line parameter values set. ; EXIT: ; CARRY SET ; Error, message already printed. Driver not installed. ; CARRY CLEAR ; DEV_SIZE set to TRUE size ; INIT_DRIVE set appropriatly ; TERM_ADDR set to correct device end. ; RESET_SYSTEM code included if this is the first ; TYPE 1 RAMDrive in the system. ; ; USES: ; ALL but DS ; ; Code is specific to TYPE 1 driver ; EXT_INIT: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING IF DEBUG JMP SHORT DEBINIT DEBINITMES DB "Initializing /e version",13,10,"$" DEBINIT: PUSH DX PUSHF PUSH AX MOV DX,OFFSET DEBINITMES CALL PRINT POP AX POPF POP DX ENDIF ; XMM init code taken from smartdrv.asm (written by Harish?) -- ; ; Check for presence of XMM driver. ; call check_xmm jnc xmm_ok mov dx, offset noxmm jmp err_ret xmm_ok: ; ; Get extended memory in K size into AX ; mov ah, XMM_QUERY_FREE_EXTMEM call [XmmControl] or ax, ax ; is there any ext. memory? jnz mem_avail ; yes. test bl, XMM_ERROR_BIT ; error code returned? jz no_mem_avail ; no. no memory available mov dx, offset errxmm ; yes. problem from xmm jmp err_ret no_mem_avail: mov dx, offset no_mem jmp err_ret mem_avail: mov dx, offset errmsg2 cmp ax, 4 ; M002: available memory >= 4K? jnb @F ; -yes, jump. jmp err_ret ; -no, memory is below minimum. @@: mov [ext_k], ax cmp [dev_size], ax ; is there enuff mem for cache? jbe dev_size_ok ; yes. mov [dev_size], ax ; no - limit dev_size to size available dev_size_ok: mov dx, [dev_size] ; dx = amt. of mem requested in K mov ah, XMM_ALLOC_EMB ; allocate dx K of extended mem. call [XmmControl] or ax, ax jnz alloc_ok mov dx, offset errxmm jmp short err_ret alloc_ok: ; dx has handle for extended memory block. mov [ext_handle], dx ; Get in XMM control chain to watch for Windows/386 v2.x. mov bx,word ptr XmmControl mov es,word ptr XmmControl+2 ; ES:BX = ptr to 1st XMM header NextXmmHeader: mov word ptr PrevXmm+2,es ; save seg of prev control adr mov word ptr XmmControlBase+2,es mov word ptr XmmControlBase,bx mov cx,word ptr es:[bx] cmp cl,0EBh ; compare short jmp opcode je ShortJmp cmp cl,0EAh ; compare far jmp opcode jne XmmChainHosed ; bad XMM control chain FarJmp: mov si,word ptr es:[bx+1] ; SI = offset of jmp mov es,word ptr es:[bx+1+2] ; ES = segment of jmp mov bx,si jmp NextXmmHeader ; continue down control chain ShortJmp: cmp word ptr es:[bx+2],9090h ; check NOPs jne XmmChainHosed ; bad XMM control chain cmp byte ptr es:[bx+4],90h jne XmmChainHosed ; bad XMM control chain mov di,bx ; DI = ptr to XMM header xor ax,ax mov al,ch ; AX = offset of short jmp mov XmmControlJmpVal,al ; save offset of short jmp add ax,2 ; add length of jmp instr add bx,ax ; BX = target of jmp mov word ptr PrevXmm,bx ; save previous control addr ; Install ourselves in XMM control chain. mov byte ptr es:[di],0EAh ; far immediate jmp opcode mov word ptr es:[di+1],offset XmmGuard mov word ptr es:[di+3],cs jmp short ext_init_done XmmChainHosed: mov dx,offset XmmChain ; DX = ptr to bad chain msg err_ret: call print stc ext_init_done: ret BREAK </A INIT Code> ;** EMM device driver name ; ; The following datum defines the Above Board EMM 8 character ; device driver name that is looked for as part of TYPE 2 ; specific initialization. ; ; This datum is specific to TYPE 2 drivers ; ABOVE_DEV_NAME DB "EMMXXXX0" ;** ABOVE_INIT - Perform /A (TYPE 2) specific initialization ; ; This code performes the driver specific initialization for ; type 2 drivers. ; ; Swap ABOVE_BLKMOV code in for TYPE 1 code at BLKMOV ; Swap ABOVE_RESET code in for TYPE 1 code at RESET_SYSTEM ; Check to make sure EMM Above Board device driver is installed ; by looking for device name relative to INT 67H segment ; address. This is method 2 described on page 36 and 37 ; of the Expanded Memory Manager Programming Specification. ; ; WARNING! If run on a version of DOS where all INT vectors ; are managed by the kernel, or on a system where some ; foreign program (not EMM.SYS) is also using INT 67H, this ; method will fail to find the EMM device driver. ; The reason this method was used rather than the more portable ; method 1 described on pages 33 and 34 of the EMM Programming ; Specification is that the DOS Installable Device Driver ; document makes a statement about which DOS system calls ; may be made in a device initialization routine, and ; OPEN, IOCTL, and CLOSE are not included in the allowed ; set. Adherance to the Installable Device Driver document, ; therefore, excludes the use of method 1. ; ; Check the EMM device status ; Make sure the page frame really exists. The first four EMS ; physical pages must be contiguous. (M00) ; Get the EMM map window address and set BASE_ADDR ; Get the available Above Board memory ; Adjust DEV_SIZE to be consistent with the available memory if needed, ; and also round DEV_SIZE up so that it is a multiple of the 16K ; granularity of the Above Board memory. ; Allocate DEV_SIZE worth of Above Board memory and set ABOVE_PID. ; After this point we can use CTRL_IO and/or BLKMOV to ; read/write the memory we have allocated. ; Install the INT 9 and INT 19 code by calling SET_RESET with BX = 0. ; Adjust the TERM_ADDR set by SET_RESET to a more appropriate size. ; Call CHECK_DOS_VOL to look for a DOS volume and set INIT_DRIVE. ; IF INIT_DRIVE indicates that a DOS volume was found ; Check to make sure that the size of the found DOS ; volume is consistent with DEV_SIZE. ; IF it is not ; Set INIT_DRIVE to 2 to indicate that the found volume ; is invalid and needs to be re-initialized. ; ; SEE ALSO ; INTEL Expanded Memory Manager Programming Specification ; ; ENTRY: ; Invokation line parameter values set. ; EXIT: ; ABOVE_BLKMOV code swapped in at BLKMOV ; ABOVE_RESET code swapped in at RESET_SYSTEM ; CARRY SET ; Error, message already printed. Driver not installed. ; No Above Board memory allocated. ; CARRY CLEAR ; BASE_ADDR set to segment address of Above Board map window ; ABOVE_PID contains PID of allocated above board memory ; DEV_SIZE set to TRUE size ; INIT_DRIVE set appropriatly ; TERM_ADDR set to correct device end. ; RESET_SYSTEM code and INT 9/INT 19 code included. ; ; USES: ; ALL but DS ; ; Code is specific to TYPE 2 driver ; ABOVE_INIT: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING ; ; Swap above code into place ; PUSH CS POP ES MOV SI,OFFSET ABOVE_CODE MOV DI,OFFSET DRIVE_CODE MOV CX,OFFSET DRIVE_END - OFFSET DRIVE_CODE REP MOVSB MOV SI,OFFSET ABOVE_RESET MOV DI,OFFSET RESET_SYSTEM MOV CX,OFFSET RESET_INCLUDE - OFFSET RESET_SYSTEM REP MOVSB ; ; Check for presence of Above board memory manager ; MOV AX,(Get_Interrupt_Vector SHL 8) OR 67H INT 21H MOV DI,SDEVNAME MOV SI,OFFSET ABOVE_DEV_NAME MOV CX,8 REPE CMPSB JZ GOT_MANAGER MOV DX,OFFSET NO_ABOVE ABOVE_ERR: CALL PRINT STC RET GOT_MANAGER: ; ; Check memory status ; MOV CX,8000H STLOOP: MOV AH,ABOVE_STATUS INT 67H CMP AH,ABOVE_SUCCESSFUL JZ CHECK_PAGEFRAME ;M00 CMP AH,ABOVE_ERROR_BUSY LOOPZ STLOOP ST_ERR: MOV DX,OFFSET BAD_ABOVE JMP ABOVE_ERR ; BEGIN M00 CODE CHECK_PAGEFRAME: ; ; Make sure page frame really exists ; GET_EMSVER: MOV AH,ABOVE_GET_VERSION INT 67H CMP AH,ABOVE_ERROR_BUSY JZ GET_EMSVER CMP AH,ABOVE_SUCCESSFUL JNZ ST_ERR CMP AL,40H JB MEM_OK ; version < 4.0, page frame is ok GET_PAGEMAP: ; ; Get addresses of mappable pages ; MOV AX,ABOVE_GET_ADDR_MAP PUSH DS POP ES MOV DI,OFFSET SECTOR_BUFFER ; ES:DI = ptr to buffer MOV SI,DI ; DS:SI = ptr to buffer, too INT 67H CMP AH,ABOVE_SUCCESSFUL JNZ ST_ERR CLD SCAN_PAGEMAP: ; ; Look for page 0 ; LODSW ; AX = page segment address LODSW ; AX = physical page number OR AX,AX JZ CHECK_CONTIG ; found page 0, check pages 0-3 LOOP SCAN_PAGEMAP ; keep looking CHECK_CONTIG: ; ; Make sure pages 0-3 are contiguous ; MOV DX,AX ; DX = page # = 0 MOV BX,[SI-4] ; BX = page 0 segment address MOV CX,3 ; CX = # pages to check NEXT_CONTIG: ; ; Note page address array is in order by segment address ; INC DX ; DX = next expected page # ADD BX,0400H ; BX = next expected seg addr LODSW ; AX = next segment address CMP AX,BX JNE ST_ERR ; segment address not contiguous LODSW ; AX = next page # CMP AX,DX JNE ST_ERR ; page # not contiguous LOOP NEXT_CONTIG ; check rest of page frame pages ; END M00 CODE MEM_OK: ; ; Get base address of map region and set BASE_ADDR ; MOV AH,ABOVE_GET_SEG INT 67H CMP AH,ABOVE_ERROR_BUSY JZ MEM_OK CMP AH,ABOVE_SUCCESSFUL JNZ ST_ERR MOV WORD PTR [BASE_ADDR],0 MOV WORD PTR [BASE_ADDR + 2],BX ; ; Allocate drive memory ; GET_AVAIL: MOV AH,ABOVE_GET_FREE INT 67H CMP AH,ABOVE_ERROR_BUSY JZ GET_AVAIL CMP AH,ABOVE_SUCCESSFUL JNZ ST_ERR MOV AX,DX ; AX is total 16K pages ; BX is un-allocated 16K pages MOV DX,OFFSET NO_MEM OR AX,AX JNZ @F JMP ABOVE_ERR @@: MOV DX,OFFSET ERRMSG2 OR BX,BX ; 16k is min. (expanded mem.) Ramdrive JNZ @F JMP ABOVE_ERR @@: TEST BX,0F000H JNZ AB001 ; Avialable K is REAL big MOV CX,4 SHL BX,CL ; BX is un-allocated K CMP [DEV_SIZE],BX JBE AB001 ; DEV_SIZE OK MOV [DEV_SIZE],BX ; Limit DEV_SIZE to available AB001: MOV BX,[DEV_SIZE] ; M002 (updated comment only) ; ; BX = drive size (Kbytes) requested (adjusted to be no greater than ; available expanded memory). ; The drive size is now rounded up to the next multiple of 16K (since the ; granularity of expanded memory is 16K). ; MOV AX,BX MOV CX,4 ; Convert back to # of 16K pages SHR BX,CL TEST AX,0FH ; Even???? JZ OKAYU ; Yes INC BX ; Gotta round up PUSH BX MOV CX,4 SHL BX,CL MOV [DEV_SIZE],BX ; Correct dev size too by rounding it up to ; next multiple of 16K, no sense wasting ; part of a page. POP BX OKAYU: MOV AH,ABOVE_ALLOC INT 67H CMP AH,ABOVE_ERROR_BUSY JZ OKAYU CMP AH,ABOVE_SUCCESSFUL JZ GOT_ID CMP AH,ABOVE_ERROR_MAP_CNTXT JZ ST_ERRJ CMP AH,ABOVE_ERROR_OUT_OF_PIDS JB ST_ERRJ MOV DX,OFFSET ERRMSG2 JMP ABOVE_ERR ST_ERRJ: JMP ST_ERR GOT_ID: MOV [ABOVE_PID],DX ; ; INSTALL ABOVE RESET handler ; XOR BX,BX CALL SET_RESET ; ; The above RESET_SYSTEM handler is real small, and since we include it in ; EACH driver, we make sure the size is minimal ; MOV WORD PTR [TERM_ADDR],OFFSET RESET_SYSTEM + (OFFSET ABOVE_RESET_END - OFFSET ABOVE_RESET) ; ; We are now in good shape. Can call BLKMOV to read drive ; CALL CHECK_DOS_VOL ; Snoop for DOS volume JNC DOUBLE_CHECK CALL DISK_ABORT STC RET DOUBLE_CHECK: CMP [INIT_DRIVE],0 JNZ RETAB ; No DOS volume found ; ; We MUST check to see if the FOUND DOS volume is consistent ; with DEV_SIZE. ; MOV AX,[SECLIM] MUL [SSIZE] ; DX:AX is size of volume in bytes MOV CX,1024 DIV CX ; AX is size in K CMP AX,[DEV_SIZE] JE RETAB ; Volume is OK RE_INIT: MOV [INIT_DRIVE],2 ; Force re-compute of volume RETAB: CLC RET BREAK <Drive code for /A driver. Swapped in at BLKMOV> ; ; This label defines the start of the code swapped in at DRIVE_CODE ; ABOVE_CODE LABEL WORD ; ; WARNING DANGER!!!!!!! ; ; This code is tranfered over the /E driver code at DRIVE_CODE ; ; ALL jmps etc. must be IP relative. ; ALL data references must be to cells at the FINAL, TRUE location ; (no data cells may be named HERE, must be named up at BLKMOV). ; OFFSET of ABOVE_BLKMOV relative to ABOVE_CODE MUST be the same as ; the OFFSET of BLKMOV relative to DRIVE_CODE. ; SIZE of stuff between ABOVE_CODE and ABOVE_END MUST be less than ; or equal to size of stuff between DRIVE_CODE and DRIVE_END. IF2 IF((OFFSET ABOVE_BLKMOV - OFFSET ABOVE_CODE) NE (OFFSET BLKMOV - OFFSET DRIVE_CODE)) %out ERROR BLKMOV, ABOVE_BLKMOV NOT ALIGNED ENDIF IF((OFFSET ABOVE_END - OFFSET ABOVE_CODE) GT (OFFSET DRIVE_END - OFFSET DRIVE_CODE)) %out ERROR ABOVE CODE TOO BIG ENDIF ENDIF DD ? ; 24 bit address of start of this RAMDRV ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;** ABOVE_BLKMOV - Perform transfer for TYPE 2 driver ; ; This routine is the transfer routine for moving bytes ; to and from the Above Board memory containing the cache. ; ; The Above Board is implemented as 4 16K windows into the Above ; Board memory, giving a total window of 64K wich starts on some ; 16K boundary of the Above Board memory. Given that a DOS I/O ; request is up to 64K bytes starting on some sector boundary, ; the most general I/O picture is: ; ; |------------|------------|------------|------------|------------| ; | Above Brd | Above Brd | Above Brd | Above Brd | Above Brd | ; |Log page n |Log page n+1|Log page n+2|log page n+3|Log page n+4| ; |------------|------------|------------|------------|------------| ; |---|---| | | ; | | |---------------- 64K bytes of sectors -------------| ; Byte | | | ; offset|------------------|------------------------| | ; of first| Number of words in | | ; byte of | first part of I/O that |---|---| ; I/O in | can be performed once Number ; first | logical pages n - n+3 of words ; Log page| are mapped into physical in tail ; | pages 0 - 3 part of I/O ; Location of that have ; first byte to be done ; of sector M, once logical ; the start sector page n+4 is ; of the I/O mapped into ; physical page ; 0 ; ; One or both of "Byte offset of first byte of I/O in first page" and ; "Number of words in tail part of I/O" may be zero depending on the ; size of the I/O and its start offset in the first logical page it is ; possible to map. ; ; WARNING: IF A PRE-EMPTIVE MULTITASKING SYSTEM SCHEDULES A TASK WHICH ; IS USING THE ABOVE BOARD DURING THE TIME THIS DRIVER IS IN THE ; MIDDLE OF PERFORMING AN I/O, THE SYSTEM HAD BETTER MANAGE THE A ; BOARD MAPPING CONTEXT CORRECTLY OR ALL SORTS OF STRANGE UNPLEASANT ; THINGS WILL OCCUR. ; ; SEE ALSO ; INTEL Expanded Memory Manager Programming Specification ; ; ENTRY: ; ES:DI is packet transfer address. ; CX is number of words to transfer. ; DX:AX is 32 bit start byte offset (0 = start of cache) ; BH is 1 for WRITE, 0 for READ ; ; BASE_ADDR set to point to Above Board mapping window in main memory ; This "input" is not the responsibility of the caller. It ; is up to the initialization code to set it up when the ; device is installed ; ; EXIT: ; Carry Clear ; OK, operation performed successfully ; Carry Set ; Error during operation, AL is error number ; ; USES: ; ALL ; ; This routine is specific to TYPE 2 driver ; ; sunilp - note that this has one limitation. in the case where ; one is using the above board for ramdrive and for ; the buffer then one is limited to 32k byte transfers ; ; tonyg - above limitation removed - now handles 64kb transfers ; which can overlap the page frame ; above_blkmov: assume ds:ramcode,es:nothing,ss:nothing ; ; save mapping context and return with error if save fails ; save_mapping_context jnc ab_blk$1 ret ; ; find logical page number, offset of i/o in first page ; ab_blk$1: push cx mov cx,1024*16 ; 16k bytes / page div cx ; dx:ax / 16k --> log page numb in ax ; --> offset of i/o in dx mov si,dx ; transfer offset to si mov dx,ax ; store the page number in dx pop cx ; ; find case and dispatch accordingly ; ; case 0 : user buffer below page map, can use aaron's code ; case 1 : user buffer above page map, can use aaron's code ; case 2 : user buffer partly/totally in page map, use pai's code ; push bx push cx ; ; if( final_user_off < pm_base_addr ) then case 0 ; mov ax,di ; get user buffer initial offset into ax add ax,1 ; round up (add to get carry) rcr ax,1 ; convert to word offset dec cx ; convert word count to 0 based number add ax,cx ; user buffer final word offset shr ax,1 ; convert to segment shr ax,1 ; shr ax,1 ; mov bx,es ; get segment of buffer add ax,bx ; now we have the last segment of the user buffer ; with offset < 16 sub ax,word ptr [base_addr+2] ; compare against page map jc aar_cd ; if end below page map then execute old code ; ; if( initial_user_off < pm_base_addr ) then case 2 ; mov cx,4 mov bp,di ; get initial segment in bp shr bp,cl ; add bp,bx ; sub bp,word ptr [base_addr +2] jc within_pm ; case 2 ; ; if ( initial_user_off >= pm_end_addr ) then case1 ; cmp bp,4*1024 ; jae aar_cd ; case 1 ; ; case 2 ; within_pm: jmp new_code ; user buffer in page map ; so we need to execute new code aar_cd: pop cx pop bx ; ; Referring back to the diagram given above the following routine is ; to take care of transfer of the most general case. ; What this routine does is break every I/O down into the above parts. ; The first or main part of the I/O is performed by mapping 1 to 4 ; sequential logical pages into the 4 physical pages and executing one ; REP MOVSW. If the tail word count is non-zero then the fith sequential ; logical page is mapped into physical page 0 and another REP MOVSW is ; executed. ; ; METHOD: ; Break I/O down as described above into main piece and tail piece ; Map the appropriate number of sequential pages (up to 4) ; into the page window at BASE_ADDR to set up the main piece ; of the I/O. ; Set appropriate seg and index registers and CX to perform the ; main piece of the I/O into the page window ; REP MOVSW ; IF there is a tail piece ; Map the next logical page into physical page 0 ; Reset the appropriate index register to point at phsical page 0 ; Move tail piece word count into CX ; REP MOVSW ; Restore Above Board page mapping context ; XOR BP,BP ; No tail page PUSH BX ; ; DX is first page #, SI is byte offset of start of I/O in first page ; MOV AX,DX MOV BX,SI SHR BX,1 ; # Words in first 16k page which are not part ; of I/O PUSH CX ADD BX,CX ; # of words we need to map to perform I/O MOV DX,BX AND DX,1FFFH ; DX is number of words to transfer last page ; remainder of div by words in 16K bytes MOV CL,13 ; Div by # words in 16K SHR BX,CL ; BX is number of pages to map (may need round up) OR DX,DX ; Remainder? JZ NO_REM INC BX ; Need one more page NO_REM: MOV CX,BX ; CX is total pages we need to map MOV BX,AX ; BX is first logical page CMP CX,4 ; We can map up to 4 pages JBE NO_TAIL MOV BP,DX ; Words to move in tail page saved in BP DEC CX ; Need second map for the 5th page POP AX SUB AX,DX ; Words to move in first 4 pages is input ; word count minus words in tail page PUSH AX ; Count for first mapping back on stack NO_TAIL: ; Map CX pages MOV DX,[ABOVE_PID] MOV AX,ABOVE_MAP SHL 8 ; Physical page 0 PUSH AX MAP_NEXT: POP AX ; Recover correct AX register PUSH AX PUSH BX PUSH DX INT 67H ; Damn call ABOVE_MAP zaps BX,DX,AX POP DX POP BX OR AH,AH JNZ MAP_ERR1 ; error IF2 IF (ABOVE_SUCCESSFUL) %out ASSUMPTION IN CODE THAT ABOVE_SUCCESSFUL = 0 IS INVALID ENDIF ENDIF NEXT_PAGE: INC BX ; Next logical page POP AX INC AL ; Next physical page PUSH AX LOOP MAP_NEXT POP AX ; Clean stack POP CX ; Word count for first page mapping POP AX ; Operation in AH ; ; BX has # of next logical page (Tail page if BP is non-zero) ; BP has # of words to move in tail page (0 if no tail) ; CX has # of words to move in current mapping ; SI is offset into current mapping of start of I/O ; AH indicates READ or WRITE ; PUSH AX ; Save op for possible second I/O OR AH,AH JZ READ_A ; ; WRITE ; PUSH ES PUSH DI MOV DI,SI ; Start page offset to DI POP SI ; DS:SI is transfer addr POP DS ASSUME DS:NOTHING MOV ES,WORD PTR [BASE_ADDR + 2] ; ES:DI -> start JMP SHORT FIRST_MOVE READ_A: ASSUME DS:ramcode MOV DS,WORD PTR [BASE_ADDR + 2] ; DS:SI -> start ASSUME DS:NOTHING FIRST_MOVE: REP MOVSW OR BP,BP ; Tail? JNZ TAIL_IO ; Yup ALL_DONE: POP AX CLC REST_CONT: ; Restore page mapping context PUSH AX ; Save possible error code PUSHF ; And carry state REST_AGN: MOV DX,[ABOVE_PID] MOV AH,ABOVE_RESTORE_MAP_PID INT 67H OR AH,AH JZ ROK IF2 IF (ABOVE_SUCCESSFUL) %out ASSUMPTION IN CODE THAT ABOVE_SUCCESSFUL = 0 IS INVALID ENDIF ENDIF CMP AH,ABOVE_ERROR_BUSY JZ REST_AGN CMP AH,ABOVE_ERROR_NO_CNTXT JZ ROK ; Ignore the invalid PID error POP DX POP DX ; Clean stack MOV AL,0cH ; General failure STC RET ROK: POPF ; Recover carry state POP AX ; and possible error code RET TAIL_IO: MOV DX,[ABOVE_PID] MAP_AGN: MOV AX,ABOVE_MAP SHL 8 ; map logical page BX to phys page 0 PUSH BX PUSH DX INT 67H ; Damn call ABOVE_MAP zaps BX,DX,AX POP DX POP BX OR AH,AH JNZ MAP_ERR2 ; Error IF2 IF (ABOVE_SUCCESSFUL) %out ASSUMPTION IN CODE THAT ABOVE_SUCCESSFUL = 0 IS INVALID ENDIF ENDIF SECOND_MOVE: POP AX ; Recover Op type PUSH AX OR AH,AH JZ READ_SEC ; ; WRITE ; XOR DI,DI ; ES:DI -> start of tail JMP SHORT SMOVE READ_SEC: XOR SI,SI ; DS:SI -> start of tail SMOVE: MOV CX,BP REP MOVSW JMP ALL_DONE MAP_ERR1: CMP AH,ABOVE_ERROR_BUSY ; Busy? JZ MAP_NEXT ; Yes, wait till not busy (INTs are ON) ADD SP,6 ; Clean stack JMP SHORT DNR_ERR MAP_ERR2: CMP AH,ABOVE_ERROR_BUSY JZ MAP_AGN ADD SP,2 DNR_ERR: MOV AL,02H ; Drive not ready STC JMP REST_CONT ; ; ; this code has been written to handle te cases of overlapping usage ; of the above board page frame segment by the cache and user buffer ; assumption: in dos tracks cannot be more than 64 sectors long so ; in the worst case we shall have the user buffer occupying three ; pages is the page frame. we attempt to find the page that is ; available for the cache and use it repeatedly to access the cache ; ; above comment was for smartdrv. 128 sector reads are possible here ; see the kludge in step 2 and step 4 to handle this ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ; the algorithm is: ; ****************************************************** ; [STEP1: determine the page we can use for the cache] ; ; if (initial_para_offset_user in page 1, 2 or 3 ) then { ; physical_cache_page = 0; ; cache_segment = above board segment; ; } ; else { ; physical_cache_page = 3; ; cache_segment = above_board_segment + 3*1024; ; } ; ; ****************************************************** ; [STEP2: initial setup] ; ; count = user_count_requested; ; number_to_be_transferred = min ( count, (16K - si) >> 2 ); ; exchange source and destination if necessary; ; ; ******************************************************* ; [STEP3: set up transfer and do it] ; ; count = count - number_to_be_transferred; ; map_page cache_handle,physical_cache_page,logical_cache_page ; mov data ; ; ******************************************************* ; [STEP4: determine if another transfer needed and setup if so] ; ; if ( count == 0 ) then exit; ; if ( operation == read ) then source_offset = 0; ; else dest_offset = 0; ; number_to_be_transferred = min ( count, 8*1024 ); ; logical_page_number++ ; ; ; ******************************************************* ; [STEP5: go to do next block] ; ; goto [STEP3] ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ; new_code: assume ds:ramcode,es:nothing,ss:nothing ; ; input parameters: ; ; bp : start para offset of user buffer from start of physical page frame ; ax : end para offset of user buffer in physical page frame ; di : transfer offset of user buffer ; es : transfer segment of user buffer ; dx : logical page number in cache ; si : offset from start in logical page number ; ; on stack { cx,bx } where cx = number of words, bx = read / write status ; ; [STEP1: finding physical cache page and page frame] ; ; ; assume is physical page 0 ; xor al, al ; use page 0 for cache mov bx,word ptr [base_addr+2] ; ; see if this assumption valid ; cmp bp, 4*1024 ; base is below start of page frame jae ab$300 cmp bp,1024 ; is initial in page 1 or above jae ab$30 ; if so or assumption is valid ; ; else we have to correct our assumption ; ab$300: mov al, 3 ; use page 3 for cache add bx, 3*1024 ; segment of page 3 ; ; initialise page frame segment ; ab$30: add bp, 2*1024 ; base of second transfer mov cx, bp mov ds,bx ; assume ds:nothing ; ; [STEP2: initialising transfer parameters] ; ; pop bp ; bp will have count of words left to be transferred pop bx ; read / write status ; ; kludged to handle 64k byte transfers ; push cx ; base of second transfer ; ; initialise the number of words needed for a second transfer to 0 ; xor cx,cx ; ; ; compare the number to be transferred to 16k words. any more than this ; will have to be done in the second transfer ; cmp bp,16*1024 ; more than 16k word transfers jbe ab$301 ; if not cx is fine mov cx,bp ; else cx = number of words - 16*1024 mov bp,16*1024 ; and bp = 16*1024 sub cx,bp ; ab$301: ; ; store this on stack ; push cx ; ; end of kludge in step 2 ; push bx ; save it back again push dx ; save this too ; ; initially si offset into logical page, so we can only do 16*1024 - si ; byte transfer ; mov cx,16*1024 sub cx,si shr cx,1 ; convert to word count ; ; number to be transferred is the minimum of this and the user requested ; count ; cmp cx,bp jb ab$31 mov cx,bp ; ab$31: ; ; see if write, then we have to switch source with destination ; or bh,bh je ab$32 ; if read we don't have to do anything ; else we have to switch src_dest_switch ab$32: ; ; set direction flag so that we don't have to do it repeatedly ; cld ; ; [STEP3: set up transfer and do it] ; ab$33: ; ; update count of words still left to be transferred after this ; sub bp,cx ; ; map the logical page in cache to the physical page selected ; mov bx,dx ; get logical page into bx ; al already holds the physical page # map_page jnc ab$34 ; suceeded ? ; ; else report error ; add sp,6 stc jmp restore_mp ; and go to restore page map ab$34: ; ; succeeded, do the transfer ; rep movsw ; ; ; [STEP4: check if transfer done, if not set up for next block] ; [STEP5: go back to STEP3] ; ; check if done ; or bp,bp ; count 0 je ab$40 ; yes, go to finish up ; ; recover original dx and bx, increment dx and then save both again ; pop dx pop bx inc dx push bx push dx ; ; words to be transferred minimum of count and 8*1024 words ; mov cx,8*1024 ; 8k words in a page cmp cx,bp ; jbe ab$35 ; if below or equal this is what we want ; mov cx,bp ; else we can transfer the whole count ab$35: ; ; see whether cache src or dest and accordingly reset either si or di ; or bh,bh ; read? jne ab$36 ; if write go to modify ; ; read, zero si and go back to step3 ; xor si,si jmp short ab$33 ; to step 3 ab$36: ; ; write, zero di and go back to step3 ; xor di,di jmp short ab$33 ; to step 3 ; ; finishing up we have to restore the page map ; ab$40: ; ; also kludged to handle 64k byte transfers ; pop dx pop bx pop bp ; number of words for second transfer pop ax ; base of second transfer or bp,bp ; are we done? jne ab$407 ; no, we have to do another transfer jmp ab$405 ; yes we can go to finish up ab$407: ; apologies for such abominations push ax ; dummy transfer base xor cx, cx push cx ; zero count for next time ; ; restore the mapping context ; clc push dx ; dx is destroyed by restore mapping context restore_mapping_context pop dx ; jnc ab$401 ; ; error we should quit here ; add sp, 4 ; throw base & count ret ; ; we need to save the mapping context again ; ab$401: save_mapping_context jnc ab$406 ; if we couldn't save it then error add sp, 4 ret ; ; reset physical page to be mapped to 0 and ds or es to page map base ; and increment logical page if we have si = 0 (read) or di=0 (write) ; ab$406: mov cx, word ptr [base_addr+2] cmp ax, 1024 ; new base in page 0? jb ab$4060 cmp ax, 4*1024 jae ab$4060 xor ax, ax jmp short ab$4061 ab$4060: mov al, 3 add cx, 3*1024 ab$4061: or bh,bh ; read or write? jne ab$402 ; if write branch ; ; ; read, reset ds to base address ; mov ds,cx mov cx,16*1024 ; cmp si, cx ; at end of page? jbe ab$4030 inc dx xor si, si ab$4030: sub cx,si shr cx,1 ab$403: push bx ; save these push dx ; cmp cx,bp ; is the cx appropriate jbe ab$404 ; if yes go to do transfer mov cx,bp ; else cx <--- bp ab$404: jmp ab$33 ; and go to do transfer ; ab$402: ; ; write, reset es to base address ; mov es,cx mov cx,16*1024 cmp di, cx jb ab$4020 xor di, di inc dx ab$4020: sub cx,di shr cx,1 jmp short ab$403 ; ; add sp,4 ab$405: clc restore_mp: restore_mapping_context ret DW ? ; SPACE for ABOVE_PID ; ; This label defines the end of the code swapped in at DRIVE_CODE ; ABOVE_END LABEL WORD BREAK <Drive code for /A driver. Swapped in at RESET_SYSTEM> ; ; WARNING DANGER!!!!!!! ; ; This code is tranfered over the /E driver code at RESET_SYSTEM ; ; ALL jmps etc. must be IP relative. ; ALL data references must be to cells at the FINAL, TRUE location ; (no data cells may be named HERE, must be named up at RESET_SYSTEM). ; SIZE of stuff between ABOVE_RESET and ABOVE_RESET_END MUST be less than ; or equal to size of stuff between RESET_SYSTEM and RESET_INCLUDE. ; ; NOTE: EACH ABOVE BOARD driver has an INT 19 and 9 handler. This is ; different from /E and RESMEM in which only the first ; driver has an INT 19 and 9 handler. ; IF2 IF((OFFSET ABOVE_RESET_END - OFFSET ABOVE_RESET) GT (OFFSET RESET_INCLUDE - OFFSET RESET_SYSTEM)) %out ERROR ABOVE_RESET CODE TOO BIG ENDIF ENDIF ;** ABOVE_RESET perform TYPE 2 (/A) driver specific reboot code ; ; This code issues an ABOVE_DEALLOC call for the memory ; associated with this particular TYPE 2 RAMDrive since the ; system is being re-booted and the driver is "gone". ; ; ENTRY ; NONE ; EXIT ; NONE ; USES ; NONE ; ; This code is specific to TYPE 2 drivers ; ABOVE_RESET: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING PUSH AX PUSH DX AGAIN_RESET: MOV DX,[ABOVE_PID] MOV AH,ABOVE_DEALLOC ; Close PID INT 67H CMP AH,ABOVE_ERROR_BUSY JZ AGAIN_RESET POP DX POP AX RET ; ; This label defines the end of the code swapped in at RESET_SYSTEM ; ABOVE_RESET_END LABEL BYTE BREAK <RESMEM INIT Code> ;** RESMEM specific data ; ; The following datums are specific to the RESMEM (TYPE 3 ; or 4) drivers ; ; Specific to TYPE 3 or TYPE 4 drivers ; HIGH_SEG DW ? ; Segment addr of "end of memory" from INT 12 ; or from INIT packet BREAK address (M002). RAMSEG DW 0 ; Segment addr of the start of RAMDrive memory. ; Basically a segment register version of ; BASE_ADDR CRTSEG EQU 0A000H ; Memory past this segment value is RESERVED ; Memory scan must stop here. ;** RESMEM_INIT - Perform RESMEM (TYPE 3 or 4) specific initialization ; ; This code performs the driver TYPE specific initialization for ; TYPE 3 and TYPE 4 drivers. [Type 3 no longer supported.] ; ; M002: The size of memory is obtained from 1 of 2 sources; for DOS ; versions prior to DOS 5.X, this size is obtained from INT 12h. For ; DOS version 5.X and beyond, this size is taken from the INIT packet ; BREAK address. ; ; Memory scan (No longer attempted) ; The method used by this code to "find" valid RAM between ; the "end of memory" as determined from the INT 12 memory ; size and CRTSEG is to look for memory which will correctly ; store data. It looks on 1K boundaries. If the first 2 words ; of a 1k block are good, it is assumed that the rest of the ; 1K block is good without explicitly checking it. The scan ; is interested only in the FIRST block it finds. If two ; separated (by invalid RAM) blocks of RAM exist in the ; above range, the second block WILL NOT be found. ; NOTE that this can be fooled by a bad memory chip in ; a block of RAM. In this case RAMDrive will use the ; memory up to the bad spot and ignore the rest. ; Also note that since 16K is the minimum RAMDrive ; size, and the EMM_CTRL sector takes 1k, a block ; of size < 17K results in an insufficient memory error. ; [M002: Minimum RAMDrive is now 4K, but this is irrelevant ; since the described memory scan no longer takes place.] ; ; Since access to invalid RAM (RAM that isn't present) ; results in a parity error, the above scan must be done ; with parity checking disabled. ; ; Since the ROM BIOS memory initialization code and tests ; is only run on the memory indicated by INT 12, one of ; the things this code must do when it finds memory "above ; INT 12" is make sure all of the parity bits are set correctly. ; This is accomplished easily by just copying the memory to ; itself. ; ; The scan is NON-DESTRUCTIVE so that any data contained in ; the memory will not be destroyed. ; ; The result of this scan also makes the determination between ; a TYPE 3 and TYPE 4 RAMDrive. If memory is found, then we're ; TYPE 3. If no memory is found, then we're TYPE 4. ; ; ; RESMEM_BLKMOV code swapped in at BLKMOV ; RESMEM_RESET code swapped in at RESET_SYSTEM ; NOTE: This step is not needed for a TYPE 4 driver ; since TYPE 4 NEVER has an INT 9 or INT 19 handler, ; but it isn't harmful either, so we do it always. ; IF Dos version < 5.X ; Issue INT 12 to get size of memory ; ELSE ; Get memory size from INIT packet BREAK address ; Convert INT 12 result to segment address of first byte after system ; memory. ; IF this segment address is equal to or grater than CRTSEG ; There cannot be any memory "above INT 12" so we are TYPE 4. ; Skip the memory scan since there is no memory to scan and ; go to the TYPE 4 init code at CASE1. ; Disable parity checking so access to non-existent RAM won't crash ; the system. ; Perform the memory scan. This starts at FOO and ends at HAVE_MEM ; if we find some valid memory, or at CASE1 if we don't. ; A word about the scan. ; There are two cases for valid RAM. ; 1.) Valid memory starts at the INT 12 address ; 2.) There is invalid RAM for a while, then valid RAM starts. ; The DX register is used to tell us what is going on. It is ; non-zero if we are skipping over invalid RAM looking for ; some valid RAM (case 2), or 0 is we have found some valid RAM ; (case 1, or case 2 after skipping invalid RAM) and are scanning ; to set parity and find the end of the valid RAM. ; RAMSEG is given the initial value of 0 to indicate we have not ; found the start of a valid block. ; When the scan is finished ENABLE_PARITY is called to turn parity ; checking back on. ; IF we have valid RAM and end at HAVE_MEM ; We are TYPE 3. ; RAMSEG contains the segment address of the start of the block ; BX is the segment address of the end of the block ; Subtract RAMSEG from BX to get size of region in paragraphs ; Convert size in Paragraphs to size in K ; Check that size is AT LEAST 17k (minimum size) ; Jump to GOT_RESMEM if OK else error ; Set EXT_K to size of block ; Adjust DEV_SIZE if bigger than EXT_K - 1 (-1 for EMM_CTRL) ; Convert RAMSEG to 32 bit address and set it into BASE_ADDR ; This sets BASE_ADDR to point to EMM_CTRL sector. ; Set BASE_RESET to BASE_ADDR plus 1024 ; Call MM_SETDRIVE to complete TYPE 3 specific initialization ; ELSE we end up at CASE1 ; We are TYPE 4. ; Set RESMEM_SPECIAL to indicate TYPE 4 ; Set INIT_DRIVE to 2 (DOS volume MUST be initialized) ; Set BASE_ADDR to be the first para boundary after the resident ; code (which DOES NOT include INT 19/INT 9 code). ; Compute TERM_ADDR based on DEV_SIZE Kbytes of device starting at ; BASE_ADDR. ; NOTE: We must make sure the specified DEV_SIZE is reasonable: ; It must not be bigger than 10 bits (1 Meg) ; as this is the memory limit of the 8086. ; It must not be so big that there is less than 48k of system ; memory after the device is installed. ; This is checked by computing the segment address ; of the end of the device and comparing it to the ; INT 12 memory end address minus 48k worth of paragraphs ; ; ENTRY: ; Invokation line parameter values set. ; EXIT: ; RESMEM_BLKMOV code swapped in at BLKMOV ; RESMEM_RESET code swapped in at RESET_SYSTEM ; Determination of TYPE 3 or TYPE 4 made by setting RESMEM_SPECIAL ; if TYPE 4. ; CARRY SET ; Error, message already printed. Driver not installed. ; If TYPE 3 ; EMM_CTRL not marked (but MAY be initialized if ; a valid one was not found). ; CARRY CLEAR ; DEV_SIZE set to TRUE size ; INIT_DRIVE set appropriatly ; IF TYPE 3 ; BASE_ADDR set for this drive from EMM_BASE of EMM_REC ; BASE_RESET set from BASE_ADDR ; EMM_REC is marked EMM_ISDRIVER ; TERM_ADDR set to correct device end. ; RESET_SYSTEM code and INT 9/INT 19 code included, ; INT 19 and 9 vector patched if this is the first ; TYPE 3 RAMDrive in the system. ; IF TYPE 4 ; BASE_ADDR set for this drive by computing address of ; start of memory after RAMDrive code. ; BASE_RESET set from BASE_ADDR ; TERM_ADDR set to correct device end which includes ; the memory taken up by the RAMDrive itself. ; ; USES: ; ALL but DS ; ; Code is specific to TYPE 3 and TYPE 4 drivers ; RESMEM_INIT: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING ; ; Swap RESMEM code into place ; PUSH CS POP ES MOV SI,OFFSET RESMEM_CODE MOV DI,OFFSET DRIVE_CODE MOV CX,OFFSET DRIVE_END - OFFSET DRIVE_CODE REP MOVSB MOV SI,OFFSET RESMEM_RESET MOV DI,OFFSET RESET_SYSTEM MOV CX,OFFSET RESET_INCLUDE - OFFSET RESET_SYSTEM REP MOVSB ; ; We have THREE cases to contend with: ; [M002: For Dos versions >= 5.X, the memory limit passed to RAMDrive in ; the INIT packet BREAK address is used instead of the INT 12h value.] ; ; 1. There is NO memory above the INT 12H switch setting. ; In this case we will use the user specified device ; size (within limits) to allocate some memory as part ; of the RAMDRIVE.SYS resident image. ; NOTE: This type of a RAMDrive will not live through a warm boot ; ; 2. There is memory immediately after the INT 12H memory size. ; We will check for a EMM_CTRL there etc. ; ; 3. There is memory after the INT 12H memory size, but not ; Immediately after. ; We will check for a EMM_CTRL there etc. ; ;M002 cmp DosVersion,(5 shl 8)+00 ; DOS version < 5.X ? jb rmi20 ; -yes, jump. ; -no, get memory size from INIT ; packet BREAK address. push es ASSUME ES:NOTHING les bx,[PTRSAV] IF DEBUG jmp short deb0 Deb0MesA DB " Init Break SEG = $" Deb0MesB DB " Init Break OFFSET = $" deb0: push cx push dx mov dx,offset Deb0MesA call PRINT mov ax,word ptr es:[bx].INIT_BREAK+2 call ITOA mov dx,offset Deb0MesB call PRINT mov ax,word ptr es:[bx].INIT_BREAK call ITOA pop dx pop cx ENDIF mov ax,WORD PTR es:[bx].INIT_BREAK+2 pop es jmp short rmi40 ; AX = Segment # of top of available ; memory. rmi20: INT 12H ; Get size of memory set on switches ;M002 IF DEBUG JMP SHORT DEB1 DEB1MES DB 13,10,"INT 12 returned $" DEB1: PUSH CX PUSH DX PUSHF PUSH AX MOV DX,OFFSET DEB1MES CALL PRINT POP AX PUSH AX CALL ITOA POP AX POPF POP DX POP CX ENDIF MOV CL,6 SHL AX,CL ; Convert to Segment register value rmi40: MOV BX,AX ; M002: BX = [HIGH_SEG] = end Segment MOV [HIGH_SEG],AX ; of available memory. ; ;***************************************************************************** ; Ramdrives installed between int12 reported memory and crtseg (A000h) are ; no longer allowed because on several machines including the model 50/60 ; and the Tandy AT clone this area is used for something else. The idea to ; install a ramdrive in system memory is bad anyway but we shall still support ; the installation of a ramdrive in low memory as part of the driver. isp ; ; [Some code was commented out here. In other places, uncalled routines ; still supported type 3 driver. I deleted it. -dbo] CASE1: ; ; Have CASE 1. ; Driver is TYPE 4 ; IF DEBUG JMP SHORT DEB4 DEB4MES DB 13,10,"CASE 1$" DEB4: PUSH CX PUSH DX PUSHF PUSH AX MOV DX,OFFSET DEB4MES CALL PRINT POP AX POPF POP DX POP CX ENDIF PUSH CS POP DS ASSUME DS:RAMCODE INC [RESMEM_SPECIAL] ; Flag SPECIAL case for INIDRV MOV [INIT_DRIVE],2 ; This type must ALWAYS be inited ; ; Compute BASE_ADDR to be right after DEVICE_END, NO INT 19/9 handler ; MOV AX,OFFSET DEVICE_END ADD AX,15 ; Para round up MOV CL,4 SHR AX,CL ; # of para in RAMDrive resident code MOV DX,CS ADD AX,DX ; AX is seg addr of start of RAMDrive PUSH AX MOV CX,16 MUL CX ; DX:AX is byte offset of that many paras MOV WORD PTR [BASE_ADDR],AX MOV WORD PTR [BASE_ADDR + 2],DX POP AX ; ; Compute correct ending address and set TERM_ADDR ; Check that there is at least 48k of system memory after device end ; AX is the segment address of the start of the device ; MOV DX,[DEV_SIZE] ; Get size in K ; ; DEV_SIZE can be at most a 10 bit number as that is 1 Meg, the memory ; limit on the 8086 ; TEST DX,0FC00H ; If any of high 6 bits set, too big JNZ rmi60 ; M002 MOV CL,6 SHL DX,CL ; DX is # of PARA in that many k ADD AX,DX ; AX is end seg addr ;M002 jnc rmi70 ; No overflow rmi60: jmp short RES_NOMEM ; Overflow. rmi70: ; ; Dos versions < 5.X: Leave at least 48K after RAMDrive for COMMAND.COM; ; This is really only a guess, and may be ; insufficient if other less considerate devices ; are loaded after RAMDrive. ; Dos versions >= 5.X: Since RAMDrive could be loaded into UMBs (which ; wouldn't contain COMMAND.COM), leaving space for ; COMMAND.COM would not be valid in all situations. ; Thus, in this case, we do not make any attempt to ; leave extra memory. ; Note that in all cases, the system will die gracefully if insufficient ; memory is left to run COMMAND.COM. (This is a characteristic of MS-DOS, ; and is independent of RAMDrive.) ; mov dx,[HIGH_SEG] ; DX = end Segment of available mem. cmp DosVersion,(5 shl 8)+00 ; DOS version >= 5.X ? jae rmi80 ; -yes, jump: don't leave extra. sub dx,0C00H ; -no: leave 48K (in PARAs) for ; COMMAND.COM. rmi80: ; DX = adjusted ending Segment of ; available memory. ;M002 IF DEBUG JMP SHORT DEB5 DEB5MESA DB " Max end is $" DEB5MESB DB " end is $" DEB5: PUSH CX PUSHF PUSH DX PUSH AX MOV DX,OFFSET DEB5MESA CALL PRINT POP DX POP AX PUSH AX PUSH DX CALL ITOA MOV DX,OFFSET DEB5MESB CALL PRINT POP AX PUSH AX CALL ITOA POP AX POP DX POPF POP CX ENDIF JC RES_NOMEM CMP AX,DX JA RES_NOMEM ; Too big MOV WORD PTR [TERM_ADDR],0 MOV WORD PTR [TERM_ADDR + 2],AX IF DEBUG JMP SHORT DEB6 DEB6MES DB " OK term $" DEB6: PUSH CX PUSHF PUSH DX PUSH AX MOV DX,OFFSET DEB6MES CALL PRINT POP AX PUSH AX CALL ITOA POP AX POP DX POPF POP CX ENDIF CLC RET RES_NOMEM: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING MOV DX,OFFSET ERRMSG2 CALL PRINT PUSH CS POP DS STC RET BREAK <Drive code for resmem driver. Swapped in at BLKMOV> ; ; This label defines the start of the TYPE 3 and 4 code swapped ; in at BLKMOV ; RESMEM_CODE LABEL WORD ; ; WARNING DANGER!!!!!!! ; ; This code is tranfered over the /E driver code at DRIVE_CODE ; ; ALL jmps etc. must be IP relative. ; ALL data references must be to cells at the FINAL, TRUE location ; (no data cells may be named HERE, must be named up at BLKMOV). ; OFFSET of RESMEM_BLKMOV relative to RESMEM_CODE MUST be the same as ; the OFFSET of BLKMOV relative to DRIVE_CODE. ; SIZE of stuff between RESMEM_CODE and RESMEM_END MUST be less than ; or equal to size of stuff between DRIVE_CODE and DRIVE_END. IF2 IF((OFFSET RESMEM_BLKMOV - OFFSET RESMEM_CODE) NE (OFFSET BLKMOV - OFFSET DRIVE_CODE)) %out ERROR BLKMOV, RESMEM_BLKMOV NOT ALIGNED ENDIF IF((OFFSET RESMEM_END - OFFSET RESMEM_CODE) GT (OFFSET DRIVE_END - OFFSET DRIVE_CODE)) %out ERROR RESMEM CODE TOO BIG ENDIF ENDIF DD ? ; 24 bit address of start of this RAMDRV ;** RESMEM_BLKMOV - Perform transfer for TYPE 3 and 4 driver ; ; This routine is the transfer routine for moving bytes ; to and from a RAMDrive located in main memory. ; ; METHOD: ; Convert start address into segreg index reg pair ; Mov computed segreg index reg pairs into correct registers ; Execute REP MOVSW to perform transfer ; ; ENTRY: ; ES:DI is packet transfer address. ; CX is number of words to transfer. ; DX:AX is 32 bit start byte offset (0 = sector 0 of RAMDrive drive) ; BH is 1 for WRITE, 0 for READ ; ; BASE_ADDR set to point to start of RAMDrive memory ; This "input" is not the responsibility of the caller. It ; is up to the initialization code to set it up when the ; device is installed ; ; EXIT: ; Carry Clear ; OK, operation performed successfully ; Carry Set ; Error during operation, AL is error number ; ; USES: ; ALL ; ; This routine is specific to TYPE 3 and 4 drivers ; RESMEM_BLKMOV: ASSUME DS:RAMCODE,ES:NOTHING,SS:NOTHING ADD AX,WORD PTR [BASE_ADDR] ADC DX,WORD PTR [BASE_ADDR + 2] PUSH CX MOV CX,16 DIV CX ; AX is seg reg value, DX is index register POP CX OR BH,BH JZ READ_ITR ; ; WRITE ; PUSH ES POP DS ASSUME DS:NOTHING MOV SI,DI MOV ES,AX MOV DI,DX TRANS: REP MOVSW CLC RET READ_ITR: MOV DS,AX ASSUME DS:NOTHING MOV SI,DX JMP TRANS ; ; This label defines the end of the RESMEM code swapped in at BLKMOV ; RESMEM_END LABEL WORD BREAK <Drive code for resmem driver. Swapped in at RESET_SYSTEM> ; ; WARNING DANGER!!!!!!! ; ; This code is tranfered over the /E driver code at RESET_SYSTEM ; ; ALL jmps etc. must be IP relative. ; ALL data references must be to cells at the FINAL, TRUE location ; (no data cells may be named HERE, must be named up at RESET_SYSTEM). ; SIZE of stuff between RESMEM_RESET and RESMEM_RESET_END MUST be less than ; or equal to size of stuff between RESET_SYSTEM and RESET_INCLUDE. IF2 IF((OFFSET RESMEM_RESET_END - OFFSET RESMEM_RESET) GT (OFFSET RESET_INCLUDE - OFFSET RESET_SYSTEM)) %out ERROR RESMEM_RESET CODE TOO BIG ENDIF ENDIF ;** RESMEM_RESET perform TYPE 3 (RESMEM) driver specific reboot code ; ; This code performs the EMM_ISDRIVER reset function as described ; in EMM.ASM for all EMM_REC structures which are EMM_ALLOC and ; EMM_ISDRIVER and of type EMM_MSDOS. ; ; ENTRY ; NONE ; EXIT ; NONE ; USES ; NONE ; ; This code is specific to TYPE 3 drivers ; RESMEM_RESET: ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING PUSH SI PUSH DI PUSH AX PUSH BX PUSH CX PUSH DX PUSH DS PUSH ES PUSH CS POP DS ASSUME DS:RAMCODE MOV AX,WORD PTR [BASE_ADDR] MOV DX,WORD PTR [BASE_ADDR + 2] SUB AX,1024 ; Point back to EMM block SBB DX,0 ; ; NOTE: We can address the EMM block by just backing up ; by 1024 bytes from BASE_ADDR because the RESET_SYSTEM handler ; is in the FIRST RAMDrive driver ; MOV CX,16 DIV CX ; AX is seg reg, DX is index reg MOV DS,AX ASSUME DS:NOTHING MOV SI,DX ; DS:SI -> EMM_CTRL MOV DI,SI ADD DI,EMM_RECORD MOV CX,EMM_NUMREC LOOK_RECRY: ; ; Scan EMM_CTRL for all ISDRIVER MS-DOS regions and turn off ISDRIVER ; TEST [DI.EMM_FLAGS],EMM_ALLOC JZ DONERY TEST [DI.EMM_FLAGS],EMM_ISDRIVER JZ NEXTRECRY ; No Driver CMP [DI.EMM_SYSTEM],EMM_MSDOS JNZ NEXTRECRY AND [DI.EMM_FLAGS],NOT EMM_ISDRIVER NEXTRECRY: ADD DI,SIZE EMM_REC LOOP LOOK_RECRY DONERY: POP ES POP DS ASSUME DS:NOTHING POP DX POP CX POP BX POP AX POP DI POP SI RET ; ; This label defines the end of the RESMEM code swapped in at RESET_SYSTEM ; RESMEM_RESET_END LABEL BYTE BREAK <messages and common data> ;** Message texts and common data ; ; Init data. This data is disposed of after initialization. ; it is mostly texts of all of the messages ; ; COMMON to TYPE 1,2,3 and 4 drivers ; ; ; translatable messages moved to message module (SP) EXTRN NO_ABOVE:BYTE,BAD_ABOVE:BYTE,NO_MEM:BYTE EXTRN NOXMM:BYTE,ERRXMM:BYTE,XMMCHAIN:BYTE EXTRN ERRMSG1:BYTE,ERRMSG2:BYTE,INIT_IO_ERR:BYTE,BADVERMES:BYTE EXTRN HEADERMES:BYTE,PATCH2X:BYTE,DOS_DRV:BYTE EXTRN STATMES1:BYTE,STATMES2:BYTE,STATMES3:BYTE EXTRN STATMES4:BYTE,STATMES5:BYTE EXTRN SECT_ADJ:BYTE ;M001 db "RAMDrive is a trademark of Microsoft Corporation." db "This program is the property of Microsoft Corporation." VOLID DB 'MS-RAMDRIVE',ATTR_VOLUME_ID DB 10 DUP (0) ; ; Volume creation date = driver release date ; DW 0 ;time=midnight DW ((1992-1980)*512)+(7*32)+21 ;date=1992 Jul 21 DW 0,0,0 SECTOR_BUFFER DB 1024 DUP(0) ; ; Note (M00): SECTOR_BUFFER is used during ABOVE_INIT to hold ; the addresses of mappable EMS pages. Max size required is ; 1024K / 16K * 4 = 256 bytes. ; RAMDrive_END LABEL BYTE RAMCODE ENDS END  
; DLL loader for Ninja %include "inc/stackops.inc" bits 32 extern LoadLibraryA extern GetProcAddress extern SetUnhandledExceptionFilter extern Ninja export DllMain section .data DLLhndl dd 0x0 _GetFaultReason dd GetFaultReason.init _GetFirstStackTraceString dd GetFirstStackTraceString.init _GetNextStackTraceString dd GetNextStackTraceString.init _GetRegisterString dd GetRegisterString.init _SetCrashHandlerFilter dd SetCrashHandlerFilter.init %define DLLFileName 'BUGSLAYERUTILG.DLL' msgFaultReasonDLLNotFound db 'Fault reason could not be determined, because ', DLLFileName,' was not ' db 'found.', 0 msgStackTraceDLLNotFound db 'Stack trace could not be determined, because ', DLLFileName,' was not ' db 'found.', 0 msgRegisterDLLNotFound db 'Registers could not be determined, because ', DLLFileName,' was not ' db 'found.', 0 dllFileName db DLLFileName, 0 char_GetFaultReason db 'GetFaultReason', 0 char_GetFirstStackTraceString db 'GetFirstStackTraceString', 0 char_GetNextStackTraceString db 'GetNextStackTraceString', 0 char_GetRegisterString db 'GetRegisterString', 0 char_SetCrashHandlerFilter db 'SetCrashHandlerFilter', 0 section .text ; int __cdecl redirectDLL(void) redirectDLL: resetStackoffset push dllFileName call LoadLibraryA addStack 4 test eax, eax jnz .getProcAddr ret .getProcAddr: mov DWORD [DLLhndl], eax %macro fillAPI 1 push char_%1 push DWORD [DLLhndl] call GetProcAddress test eax, eax jnz %%succ ret %%succ: mov DWORD [_%1], eax addStack 2*4 %endmacro fillAPI GetFaultReason fillAPI GetFirstStackTraceString fillAPI GetNextStackTraceString fillAPI GetRegisterString fillAPI SetCrashHandlerFilter verifyStackoffset mov eax, [DLLhndl] ret ; bool __stdcall DLLMain(DWORD hinstDLL, DWORD fdwReason, void *lpvReserved) DllMain: resetStackoffset mov eax, [esp+stackoffset+0x8] ; fdwReason mov eax, DWORD 0x1 ret 0xC verifyStackoffset ; Load library on very first call, after that jump to function directly %macro setupAPI 3 export %1 %1: jmp DWORD [_%1] .init: call redirectDLL test eax, eax jnz %1 mov eax, %3 ret %2 %endmacro setupAPI GetFaultReason,0x4,msgFaultReasonDLLNotFound setupAPI GetFirstStackTraceString,0x8,msgStackTraceDLLNotFound ; Must always return a valid string pointer setupAPI GetNextStackTraceString,0x8,0 ; May always return zero (do-while condition) setupAPI GetRegisterString,0x4,msgRegisterDLLNotFound ; int __stdcall SetCrashHandlerFilter(int (__stdcall *lpTopLevelExceptionFilter)()) export SetCrashHandlerFilter SetCrashHandlerFilter: jmp DWORD [_SetCrashHandlerFilter] .init: call redirectDLL test eax, eax jnz SetCrashHandlerFilter push DWORD [esp+0x4] ; If DLL not found, set manually call SetUnhandledExceptionFilter xor eax, eax ret 0x4
TxtOS464EN: db 'OS 464 EN',0 TxtOS464SP: db 'OS 464 SP',0 TxtOS464FR: db 'OS 464 FR',0 TxtOS664EN: db 'OS 664',0 TxtOS6128EN: db 'OS 6128 EN',0 TxtOS6128SP: db 'OS 6128 SP',0 TxtOS6128FR: db 'OS 6128 FR',0 TxtOSSch464SP: db 'OS 464 SCHNEIDER SP',0 TxtBASIC464EN: db '464 BASIC EN',0 TxtBASIC464SP: db '464 BASIC SP',0 TxtBASIC664EN: db '664 BASIC',0 TxtBASIC6128EN: db '6128 BASIC EN',0 TxtBASIC6128SP: db '6128 BASIC SP',0 TxtBASIC6128FR: db '6128 BASIC FR',0 TxtAMSDOS: db 'AMSDOS',0 TxtPARADOS: db 'PARADOS',0 TxtEmpty: db 'EMPTY',0 ROMInfoTable: defw #5D07, TxtOS464EN defw #3E84, TxtOS464SP defw #0EEA, TxtOS464FR defw #FD6F, TxtOS664EN defw #B360, TxtOS6128EN defw #BAF7, TxtOS6128SP defw #8051, TxtOS6128FR defw #DCCF, TxtOSSch464SP defw #6098, TxtBASIC464EN defw #5646, TxtBASIC464SP defw #1440, TxtBASIC664EN defw #CAA0, TxtBASIC6128EN defw #03E4, TxtBASIC6128SP defw #814D, TxtBASIC6128FR defw #0F91, TxtAMSDOS defw #D75F, TxtPARADOS defw #FFF0, TxtEmpty ROMCount equ ($-ROMInfoTable)/4
; A023510: Greatest exponent in prime-power factorization of prime(n) + 1. ; 1,2,1,3,2,1,2,2,3,1,5,1,1,2,4,3,2,1,2,3,1,4,2,2,2,1,3,3,1,1,7,2,1,2,2,3,1,2,3,1,2,1,6,1,2,3,2,5,2,1,2,4,2,2,1,3,3,4,1,1,2,2,2,3,1,1,2,2,2,2,1,3,4,1,2,7,1,1,1,1,2,1,4,1,3,2,2,1,1,4,2,5,3,2,3,3,1,2,2,1 seq $0,6005 ; The odd prime numbers together with 1. seq $0,51903 ; Maximal exponent in prime factorization of n.
############################################################################### # Copyright 2018 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. ############################################################################### .text .p2align 6, 0x90 .globl _k0_Encrypt_RIJ128_AES_NI _k0_Encrypt_RIJ128_AES_NI: movdqu (%rdi), %xmm0 pxor (%rcx), %xmm0 lea (,%rdx,4), %rax lea (-144)(%rcx,%rax,4), %rcx cmp $(12), %rdx jl .Lkey_128gas_1 jz .Lkey_192gas_1 .Lkey_256gas_1: aesenc (-64)(%rcx), %xmm0 aesenc (-48)(%rcx), %xmm0 .Lkey_192gas_1: aesenc (-32)(%rcx), %xmm0 aesenc (-16)(%rcx), %xmm0 .Lkey_128gas_1: aesenc (%rcx), %xmm0 aesenc (16)(%rcx), %xmm0 aesenc (32)(%rcx), %xmm0 aesenc (48)(%rcx), %xmm0 aesenc (64)(%rcx), %xmm0 aesenc (80)(%rcx), %xmm0 aesenc (96)(%rcx), %xmm0 aesenc (112)(%rcx), %xmm0 aesenc (128)(%rcx), %xmm0 aesenclast (144)(%rcx), %xmm0 movdqu %xmm0, (%rsi) vzeroupper ret
; A055014: Sum of 5th powers of digits of n. ; 0,1,32,243,1024,3125,7776,16807,32768,59049,1,2,33,244,1025,3126,7777,16808,32769,59050,32,33,64,275,1056,3157,7808,16839,32800,59081,243,244,275,486,1267,3368,8019,17050,33011,59292,1024,1025,1056,1267,2048,4149,8800,17831,33792,60073,3125,3126,3157,3368,4149,6250,10901,19932,35893,62174,7776,7777,7808,8019,8800,10901,15552,24583,40544,66825,16807,16808,16839,17050,17831,19932,24583,33614,49575,75856,32768,32769,32800,33011,33792,35893,40544,49575,65536,91817,59049,59050,59081,59292,60073,62174,66825,75856,91817,118098,1,2,33,244,1025,3126,7777,16808,32769,59050,2,3,34,245,1026,3127,7778,16809,32770,59051,33,34,65,276,1057,3158,7809,16840,32801,59082,244,245,276,487,1268,3369,8020,17051,33012,59293,1025,1026,1057,1268,2049,4150,8801,17832,33793,60074,3126,3127,3158,3369,4150,6251,10902,19933,35894,62175,7777,7778,7809,8020,8801,10902,15553,24584,40545,66826,16808,16809,16840,17051,17832,19933,24584,33615,49576,75857,32769,32770,32801,33012,33793,35894,40545,49576,65537,91818,59050,59051,59082,59293,60074,62175,66826,75857,91818,118099,32,33,64,275,1056,3157,7808,16839,32800,59081,33,34,65,276,1057,3158,7809,16840,32801,59082,64,65,96,307,1088,3189,7840,16871,32832,59113,275,276,307,518,1299,3400,8051,17082,33043,59324,1056,1057,1088,1299,2080,4181,8832,17863,33824,60105 lpb $0 mov $2,$0 div $0,10 mod $2,10 pow $2,5 add $1,$2 lpe
; A029747: Numbers of the form 2^k times 1, 3 or 5. ; 1,2,3,4,5,6,8,10,12,16,20,24,32,40,48,64,80,96,128,160,192,256,320,384,512,640,768,1024,1280,1536,2048,2560,3072,4096,5120,6144,8192,10240,12288,16384,20480,24576,32768,40960,49152,65536,81920,98304,131072,163840,196608,262144,327680,393216,524288,655360,786432,1048576,1310720,1572864,2097152,2621440,3145728,4194304,5242880,6291456,8388608,10485760,12582912,16777216,20971520,25165824,33554432,41943040,50331648,67108864,83886080,100663296,134217728,167772160,201326592,268435456,335544320,402653184,536870912,671088640,805306368,1073741824,1342177280,1610612736,2147483648,2684354560,3221225472,4294967296,5368709120,6442450944,8589934592,10737418240,12884901888,17179869184,21474836480,25769803776,34359738368,42949672960,51539607552,68719476736,85899345920,103079215104,137438953472,171798691840,206158430208,274877906944,343597383680,412316860416,549755813888,687194767360,824633720832,1099511627776,1374389534720,1649267441664,2199023255552,2748779069440,3298534883328,4398046511104,5497558138880,6597069766656,8796093022208,10995116277760,13194139533312,17592186044416,21990232555520,26388279066624,35184372088832,43980465111040,52776558133248,70368744177664,87960930222080,105553116266496,140737488355328,175921860444160,211106232532992,281474976710656,351843720888320,422212465065984,562949953421312,703687441776640,844424930131968,1125899906842624,1407374883553280,1688849860263936,2251799813685248,2814749767106560,3377699720527872,4503599627370496,5629499534213120,6755399441055744,9007199254740992 mov $3,2 lpb $0,1 add $2,1 add $1,$2 mov $2,$1 sub $2,$3 mov $4,$0 sub $0,1 trn $2,$0 mov $3,$4 lpe add $0,1 mul $0,2 add $1,1 trn $1,$3 add $1,3 sub $1,$0
; A327329: Twice the sum of all divisors of all positive integers <= n. ; 2,8,16,30,42,66,82,112,138,174,198,254,282,330,378,440,476,554,594,678,742,814,862,982,1044,1128,1208,1320,1380,1524,1588,1714,1810,1918,2014,2196,2272,2392,2504,2684,2768,2960,3048,3216,3372,3516,3612,3860,3974,4160,4304,4500,4608,4848,4992 add $0,1 mul $0,2 cal $0,271342 ; Sum of all even divisors of all positive integers <= n. mov $1,$0
; A217782: Expansion of (1-x)*(1-2x)*(1-3x)/((1-5x+5*x^2)*(1-3x+x^2)). ; Submitted by Jon Maiga ; 1,2,6,20,69,242,857,3054,10930,39236,141153,508598,1834641,6623450,23926334,86468052,312587197,1130277914,4087621545,14784539846,53478888618,193456813508,699850536281,2531866279710,9159810802849,33139021206962,119894215708662 mov $1,1 lpb $0 sub $0,1 add $1,$3 sub $3,$4 add $3,1 sub $2,$3 add $5,1 mov $3,$5 add $4,$1 add $4,$2 mul $5,4 add $5,$2 lpe add $2,$5 mov $0,$2 div $0,2 add $0,1
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0xe238, %r10 nop and $9494, %r13 mov $0x6162636465666768, %rdi movq %rdi, %xmm6 movups %xmm6, (%r10) nop nop nop nop and %rsi, %rsi lea addresses_UC_ht+0x32b3, %r13 dec %r9 movb $0x61, (%r13) cmp %rsi, %rsi lea addresses_normal_ht+0x16f13, %r13 cmp $57593, %r14 movw $0x6162, (%r13) nop nop nop nop nop dec %rdi lea addresses_D_ht+0x1d2b3, %r14 nop nop and %rdx, %rdx mov (%r14), %di nop add %r14, %r14 lea addresses_D_ht+0x1c173, %rsi lea addresses_WC_ht+0x126b3, %rdi nop and %rdx, %rdx mov $106, %rcx rep movsw and $38014, %rdx lea addresses_WC_ht+0x8533, %r10 clflush (%r10) cmp $30576, %rdx mov (%r10), %rdi and $32717, %rsi lea addresses_normal_ht+0x166b3, %r10 and $38457, %rcx mov (%r10), %r13 nop nop xor %rcx, %rcx lea addresses_WT_ht+0x154b3, %rsi lea addresses_WT_ht+0x42b3, %rdi nop nop nop nop add $8937, %r13 mov $90, %rcx rep movsq nop nop xor $31522, %r14 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r8 push %rax push %rbp push %rdi push %rsi // Store lea addresses_WT+0x16eb3, %rbp nop nop cmp %rax, %rax mov $0x5152535455565758, %rdi movq %rdi, (%rbp) nop nop nop nop cmp $49649, %rdi // Load lea addresses_D+0x130b3, %r14 nop nop and $2919, %rsi mov (%r14), %ax nop nop nop nop nop add $677, %r14 // Store lea addresses_RW+0x76b3, %rdi nop nop nop nop xor %r8, %r8 mov $0x5152535455565758, %r14 movq %r14, %xmm3 vmovups %ymm3, (%rdi) nop nop nop cmp %rbp, %rbp // Store lea addresses_D+0x130e7, %rbp nop nop nop nop cmp $19820, %rax movb $0x51, (%rbp) nop nop sub $64133, %rsi // Faulty Load lea addresses_RW+0x76b3, %rsi nop nop nop nop nop sub $65031, %r14 movups (%rsi), %xmm6 vpextrq $0, %xmm6, %rdi lea oracles, %r14 and $0xff, %rdi shlq $12, %rdi mov (%r14,%rdi,1), %rdi pop %rsi pop %rdi pop %rbp pop %rax pop %r8 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT', 'congruent': 6}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D', 'congruent': 9}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_RW', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D', 'congruent': 2}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC_ht', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 4}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 8}} {'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 11}} {'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}} {'58': 95} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
//================================================================================================= /*! // \file src/mathtest/operations/dvecrepeat/VUb.cpp // \brief Source file for the VUb dense vector repeat operation math test // // Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/UniformVector.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/operations/dvecrepeat/OperationTest.h> #include <blazetest/system/MathTest.h> #ifdef BLAZE_USE_HPX_THREADS # include <hpx/hpx_main.hpp> #endif //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'VUb'..." << std::endl; using blazetest::mathtest::TypeB; try { // Vector type definitions using VUb = blaze::UniformVector<TypeB>; // Creator type definitions using CVUb = blazetest::Creator<VUb>; // Running tests with small vectors for( size_t i=0UL; i<=6UL; ++i ) { RUN_DVECREPEAT_OPERATION_TEST( CVUb( i ) ); } // Running tests with large vectors RUN_DVECREPEAT_OPERATION_TEST( CVUb( 127UL ) ); RUN_DVECREPEAT_OPERATION_TEST( CVUb( 128UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense vector repeat operation:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r8 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_normal_ht+0x1a479, %r8 clflush (%r8) nop nop xor $43723, %r11 movw $0x6162, (%r8) nop nop sub %rdi, %rdi lea addresses_WT_ht+0xf797, %rsi lea addresses_UC_ht+0x5077, %rdi sub $55359, %rbp mov $47, %rcx rep movsb nop nop inc %rsi lea addresses_WT_ht+0x5e07, %r11 nop nop nop xor %rax, %rax movups (%r11), %xmm3 vpextrq $0, %xmm3, %rsi nop dec %r8 lea addresses_normal_ht+0x11d67, %rsi lea addresses_WT_ht+0x15477, %rdi clflush (%rdi) nop cmp $7844, %r13 mov $11, %rcx rep movsq nop nop nop nop nop inc %rax lea addresses_A_ht+0x1bf2b, %rsi nop nop sub %rcx, %rcx vmovups (%rsi), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rdi nop nop nop nop xor $24058, %rcx lea addresses_UC_ht+0xf677, %r13 sub $49719, %rcx movb $0x61, (%r13) nop cmp %r11, %r11 lea addresses_D_ht+0x19a77, %r8 and $38147, %r13 vmovups (%r8), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %rcx nop nop nop nop nop dec %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r9 push %rbx push %rdi // Faulty Load lea addresses_WT+0xd277, %r15 and %rdi, %rdi movb (%r15), %bl lea oracles, %r15 and $0xff, %rbx shlq $12, %rbx mov (%r15,%rbx,1), %rbx pop %rdi pop %rbx pop %r9 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 11, 'size': 32, 'same': False, 'NT': False}} {'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 */
; A086951: n3^n(4n-1)/9. ; 0,1,14,99,540,2565,11178,45927,180792,688905,2558790,9310059,33303636,117448461,409209570,1410975855,4821232752,16343405073,55013709438,184024732275,612124372620,2025821736981,6673705343514,21893519253879 mov $1,$0 mul $1,4 mov $2,$0 mov $3,2 lpb $2,1 lpb $4,1 mov $3,3 sub $4,3 lpe mul $0,3 sub $2,1 sub $3,1 mul $3,2 add $1,$3 add $4,$1 lpe mul $1,$0 div $1,18
L3: MVI A,00 L2: INR A CPI 09 JZ L3 L1: MVI B,01 DCR B JNZ L1 JMP L2 HLT
.text .globl func .def func; .scl 2; .type 32; .endef .seh_proc func func: .seh_pushframe @code subq $24, %rsp .seh_stackalloc 24 movq %rsi, 16(%rsp) .seh_savereg %rsi, 16 movups %xmm8, (%rsp) .seh_savexmm %xmm8, 0 pushq %rbx .seh_pushreg 3 mov %rsp, %rbx .seh_setframe 3, 0 .seh_endprologue .seh_handler __C_specific_handler, @except .seh_handlerdata .long 0 .text .seh_startchained .seh_endprologue .seh_endchained lea (%rbx), %rsp pop %rbx addq $24, %rsp ret .seh_endproc // Test emission of small functions. .globl smallFunc .def smallFunc; .scl 2; .type 32; .endef .seh_proc smallFunc smallFunc: ret .seh_endproc // Function with big stack allocation. .globl allocFunc .def allocFunc; .scl 2; .type 32; .endef .seh_proc allocFunc allocFunc: .seh_pushframe @code subq $65520, %rsp .seh_stackalloc 65520 sub $8454128, %rsp .seh_stackalloc 8454128 .seh_endprologue add $8454128, %rsp addq $65520, %rsp ret .seh_endproc
_init: file format elf32-i386 Disassembly of section .text: 00000000 <main>: char *argv[] = { "sh", 0 }; int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 14 sub $0x14,%esp int pid, wpid; if(open("console", O_RDWR) < 0){ 11: 83 ec 08 sub $0x8,%esp 14: 6a 02 push $0x2 16: 68 84 08 00 00 push $0x884 1b: e8 78 03 00 00 call 398 <open> 20: 83 c4 10 add $0x10,%esp 23: 85 c0 test %eax,%eax 25: 79 26 jns 4d <main+0x4d> mknod("console", 1, 1); 27: 83 ec 04 sub $0x4,%esp 2a: 6a 01 push $0x1 2c: 6a 01 push $0x1 2e: 68 84 08 00 00 push $0x884 33: e8 68 03 00 00 call 3a0 <mknod> 38: 83 c4 10 add $0x10,%esp open("console", O_RDWR); 3b: 83 ec 08 sub $0x8,%esp 3e: 6a 02 push $0x2 40: 68 84 08 00 00 push $0x884 45: e8 4e 03 00 00 call 398 <open> 4a: 83 c4 10 add $0x10,%esp } dup(0); // stdout 4d: 83 ec 0c sub $0xc,%esp 50: 6a 00 push $0x0 52: e8 79 03 00 00 call 3d0 <dup> 57: 83 c4 10 add $0x10,%esp dup(0); // stderr 5a: 83 ec 0c sub $0xc,%esp 5d: 6a 00 push $0x0 5f: e8 6c 03 00 00 call 3d0 <dup> 64: 83 c4 10 add $0x10,%esp for(;;){ printf(1, "init: starting sh\n"); 67: 83 ec 08 sub $0x8,%esp 6a: 68 8c 08 00 00 push $0x88c 6f: 6a 01 push $0x1 71: e8 55 04 00 00 call 4cb <printf> 76: 83 c4 10 add $0x10,%esp pid = fork(); 79: e8 d2 02 00 00 call 350 <fork> 7e: 89 45 f4 mov %eax,-0xc(%ebp) if(pid < 0){ 81: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 85: 79 17 jns 9e <main+0x9e> printf(1, "init: fork failed\n"); 87: 83 ec 08 sub $0x8,%esp 8a: 68 9f 08 00 00 push $0x89f 8f: 6a 01 push $0x1 91: e8 35 04 00 00 call 4cb <printf> 96: 83 c4 10 add $0x10,%esp exit(); 99: e8 ba 02 00 00 call 358 <exit> } if(pid == 0){ 9e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) a2: 75 3e jne e2 <main+0xe2> exec("sh", argv); a4: 83 ec 08 sub $0x8,%esp a7: 68 1c 0b 00 00 push $0xb1c ac: 68 81 08 00 00 push $0x881 b1: e8 da 02 00 00 call 390 <exec> b6: 83 c4 10 add $0x10,%esp printf(1, "init: exec sh failed\n"); b9: 83 ec 08 sub $0x8,%esp bc: 68 b2 08 00 00 push $0x8b2 c1: 6a 01 push $0x1 c3: e8 03 04 00 00 call 4cb <printf> c8: 83 c4 10 add $0x10,%esp exit(); cb: e8 88 02 00 00 call 358 <exit> } while((wpid=wait()) >= 0 && wpid != pid) printf(1, "zombie!\n"); d0: 83 ec 08 sub $0x8,%esp d3: 68 c8 08 00 00 push $0x8c8 d8: 6a 01 push $0x1 da: e8 ec 03 00 00 call 4cb <printf> df: 83 c4 10 add $0x10,%esp while((wpid=wait()) >= 0 && wpid != pid) e2: e8 79 02 00 00 call 360 <wait> e7: 89 45 f0 mov %eax,-0x10(%ebp) ea: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) ee: 0f 88 73 ff ff ff js 67 <main+0x67> f4: 8b 45 f0 mov -0x10(%ebp),%eax f7: 3b 45 f4 cmp -0xc(%ebp),%eax fa: 75 d4 jne d0 <main+0xd0> printf(1, "init: starting sh\n"); fc: e9 66 ff ff ff jmp 67 <main+0x67> 00000101 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 101: 55 push %ebp 102: 89 e5 mov %esp,%ebp 104: 57 push %edi 105: 53 push %ebx asm volatile("cld; rep stosb" : 106: 8b 4d 08 mov 0x8(%ebp),%ecx 109: 8b 55 10 mov 0x10(%ebp),%edx 10c: 8b 45 0c mov 0xc(%ebp),%eax 10f: 89 cb mov %ecx,%ebx 111: 89 df mov %ebx,%edi 113: 89 d1 mov %edx,%ecx 115: fc cld 116: f3 aa rep stos %al,%es:(%edi) 118: 89 ca mov %ecx,%edx 11a: 89 fb mov %edi,%ebx 11c: 89 5d 08 mov %ebx,0x8(%ebp) 11f: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 122: 90 nop 123: 5b pop %ebx 124: 5f pop %edi 125: 5d pop %ebp 126: c3 ret 00000127 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 127: 55 push %ebp 128: 89 e5 mov %esp,%ebp 12a: 83 ec 10 sub $0x10,%esp char *os; os = s; 12d: 8b 45 08 mov 0x8(%ebp),%eax 130: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 133: 90 nop 134: 8b 55 0c mov 0xc(%ebp),%edx 137: 8d 42 01 lea 0x1(%edx),%eax 13a: 89 45 0c mov %eax,0xc(%ebp) 13d: 8b 45 08 mov 0x8(%ebp),%eax 140: 8d 48 01 lea 0x1(%eax),%ecx 143: 89 4d 08 mov %ecx,0x8(%ebp) 146: 0f b6 12 movzbl (%edx),%edx 149: 88 10 mov %dl,(%eax) 14b: 0f b6 00 movzbl (%eax),%eax 14e: 84 c0 test %al,%al 150: 75 e2 jne 134 <strcpy+0xd> ; return os; 152: 8b 45 fc mov -0x4(%ebp),%eax } 155: c9 leave 156: c3 ret 00000157 <strcmp>: int strcmp(const char *p, const char *q) { 157: 55 push %ebp 158: 89 e5 mov %esp,%ebp while(*p && *p == *q) 15a: eb 08 jmp 164 <strcmp+0xd> p++, q++; 15c: 83 45 08 01 addl $0x1,0x8(%ebp) 160: 83 45 0c 01 addl $0x1,0xc(%ebp) while(*p && *p == *q) 164: 8b 45 08 mov 0x8(%ebp),%eax 167: 0f b6 00 movzbl (%eax),%eax 16a: 84 c0 test %al,%al 16c: 74 10 je 17e <strcmp+0x27> 16e: 8b 45 08 mov 0x8(%ebp),%eax 171: 0f b6 10 movzbl (%eax),%edx 174: 8b 45 0c mov 0xc(%ebp),%eax 177: 0f b6 00 movzbl (%eax),%eax 17a: 38 c2 cmp %al,%dl 17c: 74 de je 15c <strcmp+0x5> return (uchar)*p - (uchar)*q; 17e: 8b 45 08 mov 0x8(%ebp),%eax 181: 0f b6 00 movzbl (%eax),%eax 184: 0f b6 d0 movzbl %al,%edx 187: 8b 45 0c mov 0xc(%ebp),%eax 18a: 0f b6 00 movzbl (%eax),%eax 18d: 0f b6 c0 movzbl %al,%eax 190: 29 c2 sub %eax,%edx 192: 89 d0 mov %edx,%eax } 194: 5d pop %ebp 195: c3 ret 00000196 <strlen>: uint strlen(char *s) { 196: 55 push %ebp 197: 89 e5 mov %esp,%ebp 199: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 19c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 1a3: eb 04 jmp 1a9 <strlen+0x13> 1a5: 83 45 fc 01 addl $0x1,-0x4(%ebp) 1a9: 8b 55 fc mov -0x4(%ebp),%edx 1ac: 8b 45 08 mov 0x8(%ebp),%eax 1af: 01 d0 add %edx,%eax 1b1: 0f b6 00 movzbl (%eax),%eax 1b4: 84 c0 test %al,%al 1b6: 75 ed jne 1a5 <strlen+0xf> ; return n; 1b8: 8b 45 fc mov -0x4(%ebp),%eax } 1bb: c9 leave 1bc: c3 ret 000001bd <memset>: void* memset(void *dst, int c, uint n) { 1bd: 55 push %ebp 1be: 89 e5 mov %esp,%ebp stosb(dst, c, n); 1c0: 8b 45 10 mov 0x10(%ebp),%eax 1c3: 50 push %eax 1c4: ff 75 0c pushl 0xc(%ebp) 1c7: ff 75 08 pushl 0x8(%ebp) 1ca: e8 32 ff ff ff call 101 <stosb> 1cf: 83 c4 0c add $0xc,%esp return dst; 1d2: 8b 45 08 mov 0x8(%ebp),%eax } 1d5: c9 leave 1d6: c3 ret 000001d7 <strchr>: char* strchr(const char *s, char c) { 1d7: 55 push %ebp 1d8: 89 e5 mov %esp,%ebp 1da: 83 ec 04 sub $0x4,%esp 1dd: 8b 45 0c mov 0xc(%ebp),%eax 1e0: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 1e3: eb 14 jmp 1f9 <strchr+0x22> if(*s == c) 1e5: 8b 45 08 mov 0x8(%ebp),%eax 1e8: 0f b6 00 movzbl (%eax),%eax 1eb: 38 45 fc cmp %al,-0x4(%ebp) 1ee: 75 05 jne 1f5 <strchr+0x1e> return (char*)s; 1f0: 8b 45 08 mov 0x8(%ebp),%eax 1f3: eb 13 jmp 208 <strchr+0x31> for(; *s; s++) 1f5: 83 45 08 01 addl $0x1,0x8(%ebp) 1f9: 8b 45 08 mov 0x8(%ebp),%eax 1fc: 0f b6 00 movzbl (%eax),%eax 1ff: 84 c0 test %al,%al 201: 75 e2 jne 1e5 <strchr+0xe> return 0; 203: b8 00 00 00 00 mov $0x0,%eax } 208: c9 leave 209: c3 ret 0000020a <gets>: char* gets(char *buf, int max) { 20a: 55 push %ebp 20b: 89 e5 mov %esp,%ebp 20d: 83 ec 18 sub $0x18,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 210: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 217: eb 42 jmp 25b <gets+0x51> cc = read(0, &c, 1); 219: 83 ec 04 sub $0x4,%esp 21c: 6a 01 push $0x1 21e: 8d 45 ef lea -0x11(%ebp),%eax 221: 50 push %eax 222: 6a 00 push $0x0 224: e8 47 01 00 00 call 370 <read> 229: 83 c4 10 add $0x10,%esp 22c: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 22f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 233: 7e 33 jle 268 <gets+0x5e> break; buf[i++] = c; 235: 8b 45 f4 mov -0xc(%ebp),%eax 238: 8d 50 01 lea 0x1(%eax),%edx 23b: 89 55 f4 mov %edx,-0xc(%ebp) 23e: 89 c2 mov %eax,%edx 240: 8b 45 08 mov 0x8(%ebp),%eax 243: 01 c2 add %eax,%edx 245: 0f b6 45 ef movzbl -0x11(%ebp),%eax 249: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 24b: 0f b6 45 ef movzbl -0x11(%ebp),%eax 24f: 3c 0a cmp $0xa,%al 251: 74 16 je 269 <gets+0x5f> 253: 0f b6 45 ef movzbl -0x11(%ebp),%eax 257: 3c 0d cmp $0xd,%al 259: 74 0e je 269 <gets+0x5f> for(i=0; i+1 < max; ){ 25b: 8b 45 f4 mov -0xc(%ebp),%eax 25e: 83 c0 01 add $0x1,%eax 261: 39 45 0c cmp %eax,0xc(%ebp) 264: 7f b3 jg 219 <gets+0xf> 266: eb 01 jmp 269 <gets+0x5f> break; 268: 90 nop break; } buf[i] = '\0'; 269: 8b 55 f4 mov -0xc(%ebp),%edx 26c: 8b 45 08 mov 0x8(%ebp),%eax 26f: 01 d0 add %edx,%eax 271: c6 00 00 movb $0x0,(%eax) return buf; 274: 8b 45 08 mov 0x8(%ebp),%eax } 277: c9 leave 278: c3 ret 00000279 <stat>: int stat(char *n, struct stat *st) { 279: 55 push %ebp 27a: 89 e5 mov %esp,%ebp 27c: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 27f: 83 ec 08 sub $0x8,%esp 282: 6a 00 push $0x0 284: ff 75 08 pushl 0x8(%ebp) 287: e8 0c 01 00 00 call 398 <open> 28c: 83 c4 10 add $0x10,%esp 28f: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 292: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 296: 79 07 jns 29f <stat+0x26> return -1; 298: b8 ff ff ff ff mov $0xffffffff,%eax 29d: eb 25 jmp 2c4 <stat+0x4b> r = fstat(fd, st); 29f: 83 ec 08 sub $0x8,%esp 2a2: ff 75 0c pushl 0xc(%ebp) 2a5: ff 75 f4 pushl -0xc(%ebp) 2a8: e8 03 01 00 00 call 3b0 <fstat> 2ad: 83 c4 10 add $0x10,%esp 2b0: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 2b3: 83 ec 0c sub $0xc,%esp 2b6: ff 75 f4 pushl -0xc(%ebp) 2b9: e8 c2 00 00 00 call 380 <close> 2be: 83 c4 10 add $0x10,%esp return r; 2c1: 8b 45 f0 mov -0x10(%ebp),%eax } 2c4: c9 leave 2c5: c3 ret 000002c6 <atoi>: int atoi(const char *s) { 2c6: 55 push %ebp 2c7: 89 e5 mov %esp,%ebp 2c9: 83 ec 10 sub $0x10,%esp int n; n = 0; 2cc: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 2d3: eb 25 jmp 2fa <atoi+0x34> n = n*10 + *s++ - '0'; 2d5: 8b 55 fc mov -0x4(%ebp),%edx 2d8: 89 d0 mov %edx,%eax 2da: c1 e0 02 shl $0x2,%eax 2dd: 01 d0 add %edx,%eax 2df: 01 c0 add %eax,%eax 2e1: 89 c1 mov %eax,%ecx 2e3: 8b 45 08 mov 0x8(%ebp),%eax 2e6: 8d 50 01 lea 0x1(%eax),%edx 2e9: 89 55 08 mov %edx,0x8(%ebp) 2ec: 0f b6 00 movzbl (%eax),%eax 2ef: 0f be c0 movsbl %al,%eax 2f2: 01 c8 add %ecx,%eax 2f4: 83 e8 30 sub $0x30,%eax 2f7: 89 45 fc mov %eax,-0x4(%ebp) while('0' <= *s && *s <= '9') 2fa: 8b 45 08 mov 0x8(%ebp),%eax 2fd: 0f b6 00 movzbl (%eax),%eax 300: 3c 2f cmp $0x2f,%al 302: 7e 0a jle 30e <atoi+0x48> 304: 8b 45 08 mov 0x8(%ebp),%eax 307: 0f b6 00 movzbl (%eax),%eax 30a: 3c 39 cmp $0x39,%al 30c: 7e c7 jle 2d5 <atoi+0xf> return n; 30e: 8b 45 fc mov -0x4(%ebp),%eax } 311: c9 leave 312: c3 ret 00000313 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 313: 55 push %ebp 314: 89 e5 mov %esp,%ebp 316: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 319: 8b 45 08 mov 0x8(%ebp),%eax 31c: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 31f: 8b 45 0c mov 0xc(%ebp),%eax 322: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 325: eb 17 jmp 33e <memmove+0x2b> *dst++ = *src++; 327: 8b 55 f8 mov -0x8(%ebp),%edx 32a: 8d 42 01 lea 0x1(%edx),%eax 32d: 89 45 f8 mov %eax,-0x8(%ebp) 330: 8b 45 fc mov -0x4(%ebp),%eax 333: 8d 48 01 lea 0x1(%eax),%ecx 336: 89 4d fc mov %ecx,-0x4(%ebp) 339: 0f b6 12 movzbl (%edx),%edx 33c: 88 10 mov %dl,(%eax) while(n-- > 0) 33e: 8b 45 10 mov 0x10(%ebp),%eax 341: 8d 50 ff lea -0x1(%eax),%edx 344: 89 55 10 mov %edx,0x10(%ebp) 347: 85 c0 test %eax,%eax 349: 7f dc jg 327 <memmove+0x14> return vdst; 34b: 8b 45 08 mov 0x8(%ebp),%eax } 34e: c9 leave 34f: c3 ret 00000350 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 350: b8 01 00 00 00 mov $0x1,%eax 355: cd 40 int $0x40 357: c3 ret 00000358 <exit>: SYSCALL(exit) 358: b8 02 00 00 00 mov $0x2,%eax 35d: cd 40 int $0x40 35f: c3 ret 00000360 <wait>: SYSCALL(wait) 360: b8 03 00 00 00 mov $0x3,%eax 365: cd 40 int $0x40 367: c3 ret 00000368 <pipe>: SYSCALL(pipe) 368: b8 04 00 00 00 mov $0x4,%eax 36d: cd 40 int $0x40 36f: c3 ret 00000370 <read>: SYSCALL(read) 370: b8 05 00 00 00 mov $0x5,%eax 375: cd 40 int $0x40 377: c3 ret 00000378 <write>: SYSCALL(write) 378: b8 10 00 00 00 mov $0x10,%eax 37d: cd 40 int $0x40 37f: c3 ret 00000380 <close>: SYSCALL(close) 380: b8 15 00 00 00 mov $0x15,%eax 385: cd 40 int $0x40 387: c3 ret 00000388 <kill>: SYSCALL(kill) 388: b8 06 00 00 00 mov $0x6,%eax 38d: cd 40 int $0x40 38f: c3 ret 00000390 <exec>: SYSCALL(exec) 390: b8 07 00 00 00 mov $0x7,%eax 395: cd 40 int $0x40 397: c3 ret 00000398 <open>: SYSCALL(open) 398: b8 0f 00 00 00 mov $0xf,%eax 39d: cd 40 int $0x40 39f: c3 ret 000003a0 <mknod>: SYSCALL(mknod) 3a0: b8 11 00 00 00 mov $0x11,%eax 3a5: cd 40 int $0x40 3a7: c3 ret 000003a8 <unlink>: SYSCALL(unlink) 3a8: b8 12 00 00 00 mov $0x12,%eax 3ad: cd 40 int $0x40 3af: c3 ret 000003b0 <fstat>: SYSCALL(fstat) 3b0: b8 08 00 00 00 mov $0x8,%eax 3b5: cd 40 int $0x40 3b7: c3 ret 000003b8 <link>: SYSCALL(link) 3b8: b8 13 00 00 00 mov $0x13,%eax 3bd: cd 40 int $0x40 3bf: c3 ret 000003c0 <mkdir>: SYSCALL(mkdir) 3c0: b8 14 00 00 00 mov $0x14,%eax 3c5: cd 40 int $0x40 3c7: c3 ret 000003c8 <chdir>: SYSCALL(chdir) 3c8: b8 09 00 00 00 mov $0x9,%eax 3cd: cd 40 int $0x40 3cf: c3 ret 000003d0 <dup>: SYSCALL(dup) 3d0: b8 0a 00 00 00 mov $0xa,%eax 3d5: cd 40 int $0x40 3d7: c3 ret 000003d8 <getpid>: SYSCALL(getpid) 3d8: b8 0b 00 00 00 mov $0xb,%eax 3dd: cd 40 int $0x40 3df: c3 ret 000003e0 <sbrk>: SYSCALL(sbrk) 3e0: b8 0c 00 00 00 mov $0xc,%eax 3e5: cd 40 int $0x40 3e7: c3 ret 000003e8 <sleep>: SYSCALL(sleep) 3e8: b8 0d 00 00 00 mov $0xd,%eax 3ed: cd 40 int $0x40 3ef: c3 ret 000003f0 <uptime>: SYSCALL(uptime) 3f0: b8 0e 00 00 00 mov $0xe,%eax 3f5: cd 40 int $0x40 3f7: c3 ret 000003f8 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 3f8: 55 push %ebp 3f9: 89 e5 mov %esp,%ebp 3fb: 83 ec 18 sub $0x18,%esp 3fe: 8b 45 0c mov 0xc(%ebp),%eax 401: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 404: 83 ec 04 sub $0x4,%esp 407: 6a 01 push $0x1 409: 8d 45 f4 lea -0xc(%ebp),%eax 40c: 50 push %eax 40d: ff 75 08 pushl 0x8(%ebp) 410: e8 63 ff ff ff call 378 <write> 415: 83 c4 10 add $0x10,%esp } 418: 90 nop 419: c9 leave 41a: c3 ret 0000041b <printint>: static void printint(int fd, int xx, int base, int sgn) { 41b: 55 push %ebp 41c: 89 e5 mov %esp,%ebp 41e: 83 ec 28 sub $0x28,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 421: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 428: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 42c: 74 17 je 445 <printint+0x2a> 42e: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 432: 79 11 jns 445 <printint+0x2a> neg = 1; 434: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 43b: 8b 45 0c mov 0xc(%ebp),%eax 43e: f7 d8 neg %eax 440: 89 45 ec mov %eax,-0x14(%ebp) 443: eb 06 jmp 44b <printint+0x30> } else { x = xx; 445: 8b 45 0c mov 0xc(%ebp),%eax 448: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 44b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 452: 8b 4d 10 mov 0x10(%ebp),%ecx 455: 8b 45 ec mov -0x14(%ebp),%eax 458: ba 00 00 00 00 mov $0x0,%edx 45d: f7 f1 div %ecx 45f: 89 d1 mov %edx,%ecx 461: 8b 45 f4 mov -0xc(%ebp),%eax 464: 8d 50 01 lea 0x1(%eax),%edx 467: 89 55 f4 mov %edx,-0xc(%ebp) 46a: 0f b6 91 24 0b 00 00 movzbl 0xb24(%ecx),%edx 471: 88 54 05 dc mov %dl,-0x24(%ebp,%eax,1) }while((x /= base) != 0); 475: 8b 4d 10 mov 0x10(%ebp),%ecx 478: 8b 45 ec mov -0x14(%ebp),%eax 47b: ba 00 00 00 00 mov $0x0,%edx 480: f7 f1 div %ecx 482: 89 45 ec mov %eax,-0x14(%ebp) 485: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 489: 75 c7 jne 452 <printint+0x37> if(neg) 48b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 48f: 74 2d je 4be <printint+0xa3> buf[i++] = '-'; 491: 8b 45 f4 mov -0xc(%ebp),%eax 494: 8d 50 01 lea 0x1(%eax),%edx 497: 89 55 f4 mov %edx,-0xc(%ebp) 49a: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 49f: eb 1d jmp 4be <printint+0xa3> putc(fd, buf[i]); 4a1: 8d 55 dc lea -0x24(%ebp),%edx 4a4: 8b 45 f4 mov -0xc(%ebp),%eax 4a7: 01 d0 add %edx,%eax 4a9: 0f b6 00 movzbl (%eax),%eax 4ac: 0f be c0 movsbl %al,%eax 4af: 83 ec 08 sub $0x8,%esp 4b2: 50 push %eax 4b3: ff 75 08 pushl 0x8(%ebp) 4b6: e8 3d ff ff ff call 3f8 <putc> 4bb: 83 c4 10 add $0x10,%esp while(--i >= 0) 4be: 83 6d f4 01 subl $0x1,-0xc(%ebp) 4c2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 4c6: 79 d9 jns 4a1 <printint+0x86> } 4c8: 90 nop 4c9: c9 leave 4ca: c3 ret 000004cb <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4cb: 55 push %ebp 4cc: 89 e5 mov %esp,%ebp 4ce: 83 ec 28 sub $0x28,%esp char *s; int c, i, state; uint *ap; state = 0; 4d1: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 4d8: 8d 45 0c lea 0xc(%ebp),%eax 4db: 83 c0 04 add $0x4,%eax 4de: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 4e1: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 4e8: e9 59 01 00 00 jmp 646 <printf+0x17b> c = fmt[i] & 0xff; 4ed: 8b 55 0c mov 0xc(%ebp),%edx 4f0: 8b 45 f0 mov -0x10(%ebp),%eax 4f3: 01 d0 add %edx,%eax 4f5: 0f b6 00 movzbl (%eax),%eax 4f8: 0f be c0 movsbl %al,%eax 4fb: 25 ff 00 00 00 and $0xff,%eax 500: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 503: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 507: 75 2c jne 535 <printf+0x6a> if(c == '%'){ 509: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 50d: 75 0c jne 51b <printf+0x50> state = '%'; 50f: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 516: e9 27 01 00 00 jmp 642 <printf+0x177> } else { putc(fd, c); 51b: 8b 45 e4 mov -0x1c(%ebp),%eax 51e: 0f be c0 movsbl %al,%eax 521: 83 ec 08 sub $0x8,%esp 524: 50 push %eax 525: ff 75 08 pushl 0x8(%ebp) 528: e8 cb fe ff ff call 3f8 <putc> 52d: 83 c4 10 add $0x10,%esp 530: e9 0d 01 00 00 jmp 642 <printf+0x177> } } else if(state == '%'){ 535: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 539: 0f 85 03 01 00 00 jne 642 <printf+0x177> if(c == 'd'){ 53f: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 543: 75 1e jne 563 <printf+0x98> printint(fd, *ap, 10, 1); 545: 8b 45 e8 mov -0x18(%ebp),%eax 548: 8b 00 mov (%eax),%eax 54a: 6a 01 push $0x1 54c: 6a 0a push $0xa 54e: 50 push %eax 54f: ff 75 08 pushl 0x8(%ebp) 552: e8 c4 fe ff ff call 41b <printint> 557: 83 c4 10 add $0x10,%esp ap++; 55a: 83 45 e8 04 addl $0x4,-0x18(%ebp) 55e: e9 d8 00 00 00 jmp 63b <printf+0x170> } else if(c == 'x' || c == 'p'){ 563: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 567: 74 06 je 56f <printf+0xa4> 569: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 56d: 75 1e jne 58d <printf+0xc2> printint(fd, *ap, 16, 0); 56f: 8b 45 e8 mov -0x18(%ebp),%eax 572: 8b 00 mov (%eax),%eax 574: 6a 00 push $0x0 576: 6a 10 push $0x10 578: 50 push %eax 579: ff 75 08 pushl 0x8(%ebp) 57c: e8 9a fe ff ff call 41b <printint> 581: 83 c4 10 add $0x10,%esp ap++; 584: 83 45 e8 04 addl $0x4,-0x18(%ebp) 588: e9 ae 00 00 00 jmp 63b <printf+0x170> } else if(c == 's'){ 58d: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 591: 75 43 jne 5d6 <printf+0x10b> s = (char*)*ap; 593: 8b 45 e8 mov -0x18(%ebp),%eax 596: 8b 00 mov (%eax),%eax 598: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 59b: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 59f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5a3: 75 25 jne 5ca <printf+0xff> s = "(null)"; 5a5: c7 45 f4 d1 08 00 00 movl $0x8d1,-0xc(%ebp) while(*s != 0){ 5ac: eb 1c jmp 5ca <printf+0xff> putc(fd, *s); 5ae: 8b 45 f4 mov -0xc(%ebp),%eax 5b1: 0f b6 00 movzbl (%eax),%eax 5b4: 0f be c0 movsbl %al,%eax 5b7: 83 ec 08 sub $0x8,%esp 5ba: 50 push %eax 5bb: ff 75 08 pushl 0x8(%ebp) 5be: e8 35 fe ff ff call 3f8 <putc> 5c3: 83 c4 10 add $0x10,%esp s++; 5c6: 83 45 f4 01 addl $0x1,-0xc(%ebp) while(*s != 0){ 5ca: 8b 45 f4 mov -0xc(%ebp),%eax 5cd: 0f b6 00 movzbl (%eax),%eax 5d0: 84 c0 test %al,%al 5d2: 75 da jne 5ae <printf+0xe3> 5d4: eb 65 jmp 63b <printf+0x170> } } else if(c == 'c'){ 5d6: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 5da: 75 1d jne 5f9 <printf+0x12e> putc(fd, *ap); 5dc: 8b 45 e8 mov -0x18(%ebp),%eax 5df: 8b 00 mov (%eax),%eax 5e1: 0f be c0 movsbl %al,%eax 5e4: 83 ec 08 sub $0x8,%esp 5e7: 50 push %eax 5e8: ff 75 08 pushl 0x8(%ebp) 5eb: e8 08 fe ff ff call 3f8 <putc> 5f0: 83 c4 10 add $0x10,%esp ap++; 5f3: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5f7: eb 42 jmp 63b <printf+0x170> } else if(c == '%'){ 5f9: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 5fd: 75 17 jne 616 <printf+0x14b> putc(fd, c); 5ff: 8b 45 e4 mov -0x1c(%ebp),%eax 602: 0f be c0 movsbl %al,%eax 605: 83 ec 08 sub $0x8,%esp 608: 50 push %eax 609: ff 75 08 pushl 0x8(%ebp) 60c: e8 e7 fd ff ff call 3f8 <putc> 611: 83 c4 10 add $0x10,%esp 614: eb 25 jmp 63b <printf+0x170> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 616: 83 ec 08 sub $0x8,%esp 619: 6a 25 push $0x25 61b: ff 75 08 pushl 0x8(%ebp) 61e: e8 d5 fd ff ff call 3f8 <putc> 623: 83 c4 10 add $0x10,%esp putc(fd, c); 626: 8b 45 e4 mov -0x1c(%ebp),%eax 629: 0f be c0 movsbl %al,%eax 62c: 83 ec 08 sub $0x8,%esp 62f: 50 push %eax 630: ff 75 08 pushl 0x8(%ebp) 633: e8 c0 fd ff ff call 3f8 <putc> 638: 83 c4 10 add $0x10,%esp } state = 0; 63b: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) for(i = 0; fmt[i]; i++){ 642: 83 45 f0 01 addl $0x1,-0x10(%ebp) 646: 8b 55 0c mov 0xc(%ebp),%edx 649: 8b 45 f0 mov -0x10(%ebp),%eax 64c: 01 d0 add %edx,%eax 64e: 0f b6 00 movzbl (%eax),%eax 651: 84 c0 test %al,%al 653: 0f 85 94 fe ff ff jne 4ed <printf+0x22> } } } 659: 90 nop 65a: c9 leave 65b: c3 ret 0000065c <free>: static Header base; static Header *freep; void free(void *ap) { 65c: 55 push %ebp 65d: 89 e5 mov %esp,%ebp 65f: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 662: 8b 45 08 mov 0x8(%ebp),%eax 665: 83 e8 08 sub $0x8,%eax 668: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 66b: a1 40 0b 00 00 mov 0xb40,%eax 670: 89 45 fc mov %eax,-0x4(%ebp) 673: eb 24 jmp 699 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 675: 8b 45 fc mov -0x4(%ebp),%eax 678: 8b 00 mov (%eax),%eax 67a: 39 45 fc cmp %eax,-0x4(%ebp) 67d: 72 12 jb 691 <free+0x35> 67f: 8b 45 f8 mov -0x8(%ebp),%eax 682: 3b 45 fc cmp -0x4(%ebp),%eax 685: 77 24 ja 6ab <free+0x4f> 687: 8b 45 fc mov -0x4(%ebp),%eax 68a: 8b 00 mov (%eax),%eax 68c: 39 45 f8 cmp %eax,-0x8(%ebp) 68f: 72 1a jb 6ab <free+0x4f> for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 691: 8b 45 fc mov -0x4(%ebp),%eax 694: 8b 00 mov (%eax),%eax 696: 89 45 fc mov %eax,-0x4(%ebp) 699: 8b 45 f8 mov -0x8(%ebp),%eax 69c: 3b 45 fc cmp -0x4(%ebp),%eax 69f: 76 d4 jbe 675 <free+0x19> 6a1: 8b 45 fc mov -0x4(%ebp),%eax 6a4: 8b 00 mov (%eax),%eax 6a6: 39 45 f8 cmp %eax,-0x8(%ebp) 6a9: 73 ca jae 675 <free+0x19> break; if(bp + bp->s.size == p->s.ptr){ 6ab: 8b 45 f8 mov -0x8(%ebp),%eax 6ae: 8b 40 04 mov 0x4(%eax),%eax 6b1: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 6b8: 8b 45 f8 mov -0x8(%ebp),%eax 6bb: 01 c2 add %eax,%edx 6bd: 8b 45 fc mov -0x4(%ebp),%eax 6c0: 8b 00 mov (%eax),%eax 6c2: 39 c2 cmp %eax,%edx 6c4: 75 24 jne 6ea <free+0x8e> bp->s.size += p->s.ptr->s.size; 6c6: 8b 45 f8 mov -0x8(%ebp),%eax 6c9: 8b 50 04 mov 0x4(%eax),%edx 6cc: 8b 45 fc mov -0x4(%ebp),%eax 6cf: 8b 00 mov (%eax),%eax 6d1: 8b 40 04 mov 0x4(%eax),%eax 6d4: 01 c2 add %eax,%edx 6d6: 8b 45 f8 mov -0x8(%ebp),%eax 6d9: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 6dc: 8b 45 fc mov -0x4(%ebp),%eax 6df: 8b 00 mov (%eax),%eax 6e1: 8b 10 mov (%eax),%edx 6e3: 8b 45 f8 mov -0x8(%ebp),%eax 6e6: 89 10 mov %edx,(%eax) 6e8: eb 0a jmp 6f4 <free+0x98> } else bp->s.ptr = p->s.ptr; 6ea: 8b 45 fc mov -0x4(%ebp),%eax 6ed: 8b 10 mov (%eax),%edx 6ef: 8b 45 f8 mov -0x8(%ebp),%eax 6f2: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 6f4: 8b 45 fc mov -0x4(%ebp),%eax 6f7: 8b 40 04 mov 0x4(%eax),%eax 6fa: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 701: 8b 45 fc mov -0x4(%ebp),%eax 704: 01 d0 add %edx,%eax 706: 39 45 f8 cmp %eax,-0x8(%ebp) 709: 75 20 jne 72b <free+0xcf> p->s.size += bp->s.size; 70b: 8b 45 fc mov -0x4(%ebp),%eax 70e: 8b 50 04 mov 0x4(%eax),%edx 711: 8b 45 f8 mov -0x8(%ebp),%eax 714: 8b 40 04 mov 0x4(%eax),%eax 717: 01 c2 add %eax,%edx 719: 8b 45 fc mov -0x4(%ebp),%eax 71c: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 71f: 8b 45 f8 mov -0x8(%ebp),%eax 722: 8b 10 mov (%eax),%edx 724: 8b 45 fc mov -0x4(%ebp),%eax 727: 89 10 mov %edx,(%eax) 729: eb 08 jmp 733 <free+0xd7> } else p->s.ptr = bp; 72b: 8b 45 fc mov -0x4(%ebp),%eax 72e: 8b 55 f8 mov -0x8(%ebp),%edx 731: 89 10 mov %edx,(%eax) freep = p; 733: 8b 45 fc mov -0x4(%ebp),%eax 736: a3 40 0b 00 00 mov %eax,0xb40 } 73b: 90 nop 73c: c9 leave 73d: c3 ret 0000073e <morecore>: static Header* morecore(uint nu) { 73e: 55 push %ebp 73f: 89 e5 mov %esp,%ebp 741: 83 ec 18 sub $0x18,%esp char *p; Header *hp; if(nu < 4096) 744: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 74b: 77 07 ja 754 <morecore+0x16> nu = 4096; 74d: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 754: 8b 45 08 mov 0x8(%ebp),%eax 757: c1 e0 03 shl $0x3,%eax 75a: 83 ec 0c sub $0xc,%esp 75d: 50 push %eax 75e: e8 7d fc ff ff call 3e0 <sbrk> 763: 83 c4 10 add $0x10,%esp 766: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 769: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 76d: 75 07 jne 776 <morecore+0x38> return 0; 76f: b8 00 00 00 00 mov $0x0,%eax 774: eb 26 jmp 79c <morecore+0x5e> hp = (Header*)p; 776: 8b 45 f4 mov -0xc(%ebp),%eax 779: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 77c: 8b 45 f0 mov -0x10(%ebp),%eax 77f: 8b 55 08 mov 0x8(%ebp),%edx 782: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 785: 8b 45 f0 mov -0x10(%ebp),%eax 788: 83 c0 08 add $0x8,%eax 78b: 83 ec 0c sub $0xc,%esp 78e: 50 push %eax 78f: e8 c8 fe ff ff call 65c <free> 794: 83 c4 10 add $0x10,%esp return freep; 797: a1 40 0b 00 00 mov 0xb40,%eax } 79c: c9 leave 79d: c3 ret 0000079e <malloc>: void* malloc(uint nbytes) { 79e: 55 push %ebp 79f: 89 e5 mov %esp,%ebp 7a1: 83 ec 18 sub $0x18,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7a4: 8b 45 08 mov 0x8(%ebp),%eax 7a7: 83 c0 07 add $0x7,%eax 7aa: c1 e8 03 shr $0x3,%eax 7ad: 83 c0 01 add $0x1,%eax 7b0: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 7b3: a1 40 0b 00 00 mov 0xb40,%eax 7b8: 89 45 f0 mov %eax,-0x10(%ebp) 7bb: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 7bf: 75 23 jne 7e4 <malloc+0x46> base.s.ptr = freep = prevp = &base; 7c1: c7 45 f0 38 0b 00 00 movl $0xb38,-0x10(%ebp) 7c8: 8b 45 f0 mov -0x10(%ebp),%eax 7cb: a3 40 0b 00 00 mov %eax,0xb40 7d0: a1 40 0b 00 00 mov 0xb40,%eax 7d5: a3 38 0b 00 00 mov %eax,0xb38 base.s.size = 0; 7da: c7 05 3c 0b 00 00 00 movl $0x0,0xb3c 7e1: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7e4: 8b 45 f0 mov -0x10(%ebp),%eax 7e7: 8b 00 mov (%eax),%eax 7e9: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 7ec: 8b 45 f4 mov -0xc(%ebp),%eax 7ef: 8b 40 04 mov 0x4(%eax),%eax 7f2: 39 45 ec cmp %eax,-0x14(%ebp) 7f5: 77 4d ja 844 <malloc+0xa6> if(p->s.size == nunits) 7f7: 8b 45 f4 mov -0xc(%ebp),%eax 7fa: 8b 40 04 mov 0x4(%eax),%eax 7fd: 39 45 ec cmp %eax,-0x14(%ebp) 800: 75 0c jne 80e <malloc+0x70> prevp->s.ptr = p->s.ptr; 802: 8b 45 f4 mov -0xc(%ebp),%eax 805: 8b 10 mov (%eax),%edx 807: 8b 45 f0 mov -0x10(%ebp),%eax 80a: 89 10 mov %edx,(%eax) 80c: eb 26 jmp 834 <malloc+0x96> else { p->s.size -= nunits; 80e: 8b 45 f4 mov -0xc(%ebp),%eax 811: 8b 40 04 mov 0x4(%eax),%eax 814: 2b 45 ec sub -0x14(%ebp),%eax 817: 89 c2 mov %eax,%edx 819: 8b 45 f4 mov -0xc(%ebp),%eax 81c: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 81f: 8b 45 f4 mov -0xc(%ebp),%eax 822: 8b 40 04 mov 0x4(%eax),%eax 825: c1 e0 03 shl $0x3,%eax 828: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 82b: 8b 45 f4 mov -0xc(%ebp),%eax 82e: 8b 55 ec mov -0x14(%ebp),%edx 831: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 834: 8b 45 f0 mov -0x10(%ebp),%eax 837: a3 40 0b 00 00 mov %eax,0xb40 return (void*)(p + 1); 83c: 8b 45 f4 mov -0xc(%ebp),%eax 83f: 83 c0 08 add $0x8,%eax 842: eb 3b jmp 87f <malloc+0xe1> } if(p == freep) 844: a1 40 0b 00 00 mov 0xb40,%eax 849: 39 45 f4 cmp %eax,-0xc(%ebp) 84c: 75 1e jne 86c <malloc+0xce> if((p = morecore(nunits)) == 0) 84e: 83 ec 0c sub $0xc,%esp 851: ff 75 ec pushl -0x14(%ebp) 854: e8 e5 fe ff ff call 73e <morecore> 859: 83 c4 10 add $0x10,%esp 85c: 89 45 f4 mov %eax,-0xc(%ebp) 85f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 863: 75 07 jne 86c <malloc+0xce> return 0; 865: b8 00 00 00 00 mov $0x0,%eax 86a: eb 13 jmp 87f <malloc+0xe1> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 86c: 8b 45 f4 mov -0xc(%ebp),%eax 86f: 89 45 f0 mov %eax,-0x10(%ebp) 872: 8b 45 f4 mov -0xc(%ebp),%eax 875: 8b 00 mov (%eax),%eax 877: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 87a: e9 6d ff ff ff jmp 7ec <malloc+0x4e> } } 87f: c9 leave 880: c3 ret
; A325473: Number of compositions of n with no part divisible by 3 and an even number of parts congruent to 4 or 5 modulo 6. ; 1,1,2,3,5,8,13,22,38,67,120,217,395,722,1323,2428,4460,8197,15070,27711,50961,93724,172377,317042,583122,1072519,1972660,3628277,6673431,12274342,22576023,41523768,76374104,140473865,258371706,475219643,874065181,1607656496 sub $0,1 lpb $0 mov $2,$0 cal $2,192804 ; Constant term in the reduction of the polynomial 1+x+x^2+...+x^n by x^3->x^2+x+1. See Comments. sub $0,1 add $1,$2 lpe add $1,1
; ; CPC Maths Routines ; ; August 2003 **_|warp6|_** <kbaccam /at/ free.fr> ; ; $Id: stkequcmp.asm,v 1.2 2007/07/21 21:28:22 dom Exp $ ; INCLUDE "#cpcfp.def" XLIB stkequcmp .stkequcmp pop de ;return address pop bc ;dump number.. pop bc pop bc push de ;put it back ld l,a ld h,0 ret
; ; File: ap_boot.asm ; ; Copyright (c) 2017-2018 Sydney Erickson, John Davis ; ; 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. ; ; Constants. These should match the ones in smp.h. SMP_PAGING_ADDRESS equ 0x500 SMP_PAGING_PAE_ADDRESS equ 0x510 SMP_GDT32_ADDRESS equ 0x5A0 _ap_bootstrap_protected_real equ _ap_bootstrap_protected - 0xC0000000 ap_bootstrap_stack_end equ 0x1000 + ap_bootstrap_stack ; Allocate stack section .bss align 32 ap_bootstrap_stack: resb 4096 section .text ; 16-bit bootstrap code [bits 16] global _ap_bootstrap_init global _ap_bootstrap_end _ap_bootstrap_init: ; Ensure interrupts are disabled. cli ; Check if A20 line is enabled. call _check_a20 ; Enable A20 gate if needed. cmp eax, 1 je _ap_bootstrap_a20_enabled ; If we get here, A20 line needs enabling. call _enable_A20 _ap_bootstrap_a20_enabled: ; Load GDT that was setup earlier in boot. mov eax, SMP_GDT32_ADDRESS lgdt [eax] ; Enable protected mode. mov eax, cr0 or al, 1 mov cr0, eax ; Far jump into protected mode. jmp 0x08:dword _ap_bootstrap_protected_real ; Checks A20 line status. ; 0 = disabled; 1 = enabled. _check_a20: pushf push ds push es push di push si xor ax, ax ; ax = 0 mov es, ax not ax ; ax = 0xFFFF mov ds, ax mov di, 0x0500 mov si, 0x0510 mov al, byte [es:di] push ax mov al, byte [ds:si] push ax mov byte [es:di], 0x00 mov byte [ds:si], 0xFF cmp byte [es:di], 0xFF pop ax mov byte [ds:si], al pop ax mov byte [es:di], al mov ax, 0 je _check_a20_exit mov ax, 1 _check_a20_exit: pop si pop di pop es pop ds popf ret _enable_A20: call _a20wait mov al,0xAD out 0x64,al call _a20wait mov al,0xD0 out 0x64, al call _a20wait2 in al, 0x60 push eax call _a20wait mov al, 0xD1 out 0x64, al call _a20wait pop eax or al, 2 out 0x60, al call _a20wait mov al, 0xAE out 0x64, al call _a20wait ret _a20wait: in al, 0x64 test al, 2 jnz _a20wait ret _a20wait2: in al, 0x64 test al, 1 jz _a20wait2 ret ; 32-bit bootstrap code. [bits 32] _ap_bootstrap_protected: ; Set up segments. mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; Set up paging using the root paging structure ; thats already set up. mov eax, [SMP_PAGING_ADDRESS] mov cr3, eax ; Should PAE be enabled? mov eax, [SMP_PAGING_PAE_ADDRESS] cmp eax, 0 je _ap_bootstrap_pae_done ; Enable PAE. mov eax, cr4 or eax, 0x00000020 mov cr4, eax _ap_bootstrap_pae_done: ; Enable paging. mov eax, cr0 or eax, 0x80000000 mov cr0, eax ; Jump into higher half. lea eax, [_ap_bootstrap_higherhalf] jmp eax _ap_bootstrap_end: _ap_bootstrap_size equ $ - _ap_bootstrap_init - 1 _ap_bootstrap_higherhalf: ; Set up temporary stack. mov esp, ap_bootstrap_stack_end ; Get the ID for this processor's LAPIC. ID is placed in EAX. extern lapic_id call lapic_id ; Get stack address. Address is placed in EAX. push eax extern smp_ap_get_stack call smp_ap_get_stack ; Load up stack for this processor. mov esp, eax add esp, 0x4000 mov ebp, esp ; Pop into C code. extern smp_ap_main call smp_ap_main ; Never should get here, but if we do halt the processor. jmp $ hlt
COMMENT @-------------------------------------------------------------------- Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC/GEOS MODULE: Kernel/Initfile FILE: initfileLow.asm AUTHOR: Cheng, 11/89 ROUTINES: Name Description ---- ----------- Read: INT LoadVarSegDS_PInitFile INT VInitFile Release the thread lock for the init file INT CorruptedIniFileError Shuts down the system and whines about the corrupted .ini file INT EnterInitfile Start access to Initfile code. INT ExitInitfile Finish processing the initialization file INT ExitInitfileGet Finish processing the initialization file INT EnterInitfileAndFindKey Call EnterInitfile, then find the given category and key in any .ini file along the path. INT FindCategory Locates the given category. INT FindKey Sets the file position at the first body position if the key exists. Search halts when an EOF is encountered or when a new category is started. INT GetBodySize Returns the size of the current body. The original buffer position is also returned in case the caller wishes to restore it. INT SkipWhiteSpace Return the next relevant character. White space and carraige returns are skipped. INT SkipToEndOfLine Skip to end of line. INT FindCharFar Searches the file buffer for the given unescaped, uncommented character. INT FindChar Searches the file buffer for the given unescaped, uncommented character. INT GetCharFar Fetch the next character from the file buffer. INT GetChar Fetch the next character from the file buffer. INT CmpString Compares the given string with the string at the current init file buffer location. The comparison is case-insensitive and white space is ignored. INT LegalCmpChar Sets the carry flag based on whether or not the given character can be used for comparison. Since we are ignoring white space, the carry bit is set if the character is a space or tab. The routine has the side effect of transforming all alphabet chars into upper case since comparison is case-insensitive. INT GetStringLength Return the length of the given string. INT AsciiToHex Converts the ASCII number at the current init file buffer position to its binary equivalent. INT IsNumeric Boolean routine that tells if argument is a numeric ASCII character. INT GetStringSectionByIndex Return ptr to and length of specified string section. String section is run of alpha numeric chars INT GetStringSectionPtr Return ptr to string section. String section is next contiguous set of acceptable chars INT ScanStringForCharType Scan a string until call back routine says to stop or end of string buffer has been reached INT IsPrintableAsciiChar? Determines if character is acceptable in a printer name INT IsUnprintableAsciiChar? Determines if character is acceptable in a printer name Write: INT ValidateIniFileFar Scans the passed buffer for non-ascii characters. INT ValidateIniFile Scans the passed buffer for non-ascii characters. INT DeleteEntry Deletes the current entry by shifting the next entry over it. Updates the internal size of the file. INT CreateCategory Inserts the category into the init file buffer at the current location. INT MakeSpace Extends the init file buffer to fit the string construction buffer. Updates the internal size of the file. INT Hex16ToAscii Converts a hex word to its ASCII representation without leading zeros. INT Hex8ToAscii Converts a hex byte to its ASCII representation (two hex digits) REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial revision DESCRIPTION: $Id: initfileLow.asm,v 1.1 97/04/05 01:18:00 newdeal Exp $ ----------------------------------------------------------------------------@ CATEGORY_NOT_CACHED equ 0 CATEGORY_NOT_PRESENT equ -1 InitfileRead segment resource LoadVarSegDS_PInitFile proc far uses ax, bx .enter LoadVarSeg ds, ax LockModule ds:[currentThread], ds, [initFileSem], TRASH_AX_BX .leave ret LoadVarSegDS_PInitFile endp VInitFile proc near EC < pushf > EC < call IFCheckDgroupDS > EC < popf > UnlockModule ds:[currentThread], ds, [initFileSem] ret VInitFile endp VInitFileWrite proc far call VInitFile ret VInitFileWrite endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CorruptedIniFileError %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Shuts down the system and whines about the corrupted .ini file CALLED BY: INTERNAL PASS: nothing RETURN: doesn't return DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 10/11/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CorruptedIniFileError proc far LoadVarSeg ds call VInitFile if ERROR_CHECK ERROR CORRUPTED_INI_FILE else ifdef GPC mov al, KS_TE_SYSTEM_ERROR call AddStringAtMessageBufferFar mov al, KS_CORRUPTED_INI_BUFFER call AddStringAtESDIFar mov si, offset messageBuffer clr di else mov bx, handle corruptedIniBufferStringOne call MemLock mov ds, ax assume ds:segment corruptedIniBufferStringOne mov si, ds:[corruptedIniBufferStringOne] mov di, ds:[corruptedIniBufferStringTwo] endif mov ax, mask SNF_EXIT call SysNotify mov si, -1 mov ax, SST_DIRTY GOTO SysShutdown assume ds:dgroup .unreached endif CorruptedIniFileError endp if ERROR_CHECK and DBCS_PCGEOS COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckASCIIString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Verify the passed string is valid ASCII CALLED BY: EnterInitfile() PASS: ds:si - NULL-terminated ASCII string (SBCS) RETURN: none DESTROYED: none (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 7/ 7/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckASCIIString proc near uses ax, cx, si .enter pushf clr cx charLoop: lodsb ;al <- character tst al ;reached NULL? jz doneChars ;branch if reached NULL cmp al, 0x80 ;too large for ASCII? jae annoyMe ;branch if too large for ASCII inc cx jmp charLoop doneChars: cmp cx, 1 ;long enough? ja stringOK ;branch if so annoyMe: WARNING BAD_INI_STRING stringOK: popf .leave ret CheckASCIIString endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EnterInitfile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Start access to Initfile code. CALLED BY: EnterInitfileAndFindKey PASS: ds:si - category ASCIIZ string cx:dx - key ASCIIZ string es:di - address of buffer/string bp - InitFileReadFlags RETURN: all parameters stored away in variables initFileSem grabbed buffer locked with segment stored in initFileBufSegAddr es, bp - dgroup DESTROYED: ax, bx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/24/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EnterInitfile proc far uses cx, di .enter if DBCS_PCGEOS EC < call CheckASCIIString > EC < pushdw dssi > EC < movdw dssi, cxdx EC < call CheckASCIIString > EC < popdw dssi > endif ; ; Gain exclusive access to the file first. ; push ds call LoadVarSegDS_PInitFile ; ; Now store the passed-in parameters in their respective variables. ; mov ds:[catStrAddr.offset], si pop ds:[catStrAddr.segment] mov ds:[keyStrAddr.offset], dx mov ds:[keyStrAddr.segment], cx mov ds:[bufAddr.offset], di mov ds:[bufAddr.segment], es mov ds:[bufFlag], bp ; ; Perform common processing on the given strings ; les di, ds:[catStrAddr] call GetStringLength EC < cmp cx, MAX_INITFILE_CATEGORY_LENGTH > EC < ERROR_AE INIT_FILE_CATEGORY_STRING_TOO_LONG > mov ds:[catStrLen], cx les di, ds:[keyStrAddr] call GetStringLength mov ds:[keyStrLen], cx ; ; Lock down the buffer and save its (new) segment. ; mov bx, ds:[loaderVars].KLV_initFileBufHan call MemLock mov ds:[initFileBufSegAddr], ax if HASH_INIFILE ; ; Signal that we're starting with the first ini file. This ; is for the hash table. ; clr ds:[currentIniOffset] endif ; HASH_INIFILE if ERROR_CHECK push ds call CheckNormalECEnabled jz 30$ mov cx, ds:[loaderVars].KLV_initFileSize dec cx ;Check out ini file buffer mov ds, ax call ValidateIniFile jnc 30$ ;Branch if no error GOTO CorruptedIniFileError 30$: pop ds endif ; ; Recover ds in case caller needs it, but put dgroup into bp and es for ; ease of use. ; mov bp, ds mov es, bp mov ds, ds:[catStrAddr.segment] .leave ret EnterInitfile endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExitInitfile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Finish processing the initialization file CALLED BY: All access routines PASS: nothing RETURN: buffer unlocked initFileSem released DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/24/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExitInitfile proc far uses bx, ds .enter pushf ; Save flags as well ; ; Release the buffer so it can move again. ; segmov ds,dgroup,bx mov bx, ds:[loaderVars].KLV_initFileBufHan call MemUnlock EC < mov ds:[initFileBufSegAddr], 0xa000 ; Point at video memory> ; ; Release exclusive access to file. ; call VInitFile popf .leave ret ExitInitfile endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExitInitfileGet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Finish processing the initialization file CALLED BY: All access routines PASS: nothing RETURN: buffer unlocked initFileSem released DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 2/24/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExitInitfileGet proc near uses bx, ds .enter pushf ; Save flags as well segmov ds,dgroup,bx ; ; If there is more than one .ini file then clear curCatOffset ; (cached offset to current category) ; tst ds:[loaderVars].KLV_initFileBufHan[2] jz noClearCache mov ds:[curCatOffset], CATEGORY_NOT_CACHED noClearCache: ; ; Release the buffer so it can move again. ; mov bx, ds:[initFileHanLocked] tst bx jz noUnlock call MemUnlock noUnlock: EC < mov ds:[initFileBufSegAddr], 0xa000 ; Point at video memory> ; ; Release exclusive access to file. ; call VInitFile popf .leave ret ExitInitfileGet endp COMMENT @------------------------------------------------------------------- FUNCTION: EnterInitfileAndFindKey DESCRIPTION: Call EnterInitfile, then find the given category and key in any .ini file along the path. CALLED BY: InitFileReadInteger, InitFileReadBoolean, InitFileReadString, InitFileRead PASS: ds:si - category ASCIIZ string cx:dx - key ASCIIZ string bp - InitFileReadFlags RETURN: carry - set if error (category or key not found) all parameters stored away in variables initFileSem grabbed es, bp - dgroup initFileHanLocked - handle of buffer locked (0 if error) if no error: buffer locked with segment stored in initFileBufSegAddr dgroup:[initFileBufPos] - offset from BufAddr to body DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/91 Initial version ---------------------------------------------------------------------------@ EnterInitfileAndFindKey proc near uses ax, bx .enter call EnterInitfile ;locks first .ini file mov es:[initFileHanLocked], 0 mov bx, offset loaderVars.KLV_initFileBufHan searchLoop: call FindCategory jc notFound call FindKey jnc doneGood notFound: ; ; category or key not found in .ini file, progress down the ; path, unless the caller doesn't want us to. ; push bx mov bx, es:[bx] call MemUnlock ;unlock old buffer pop bx test es:[bufFlag], mask IFRF_FIRST_ONLY jnz error ; get handle of next .ini file in the path add bx, size word cmp bx, (offset loaderVars.KLV_initFileBufHan)+ \ ((size word)*MAX_INI_FILES) je error cmp {word} es:[bx], 0 je error if HASH_INIFILE add es:[currentIniOffset], size word endif ; HASH_INIFILE push bx mov bx, es:[bx] call MemLock pop bx mov es:[initFileBufSegAddr], ax mov es:[curCatOffset], CATEGORY_NOT_CACHED jmp searchLoop error: stc jmp done doneGood: cmp bx, offset loaderVars.KLV_initFileBufHan je 10$ mov es:[curCatOffset], CATEGORY_NOT_CACHED 10$: mov bx, es:[bx] mov es:[initFileHanLocked], bx done: .leave ret EnterInitfileAndFindKey endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetNextInitFileAndFindKey %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Unlock this init file, and lock the next one CALLED BY: InitFileReadAll PASS: es - dgroup ds:si - category string cx:dx - key string RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Unlock the current initfile buffer, find the next one, and lock it. Search for the passed category/key. If it's not in that file, then go to the next one KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chrisb 2/ 4/93 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetNextInitFileAndFindKey proc near uses ax,bx,cx,dx,di,si,bp .enter nextInitFile: clr bx xchg bx, es:[initFileHanLocked] call MemUnlock mov_tr ax, bx mov bx, offset loaderVars.KLV_initFileBufHan ; ; Find the currently locked init file ; searchLoop: cmp es:[bx], ax lea bx, es:[bx][size word] jne searchLoop ; ; Now, lock the next one if such there be ; cmp bx, (offset loaderVars.KLV_initFileBufHan)+ \ ((size word)*MAX_INI_FILES) jae notFound mov bx, es:[bx] tst bx jz notFound if HASH_INIFILE add es:[currentIniOffset], size word endif ; call MemLock mov es:[initFileBufSegAddr], ax mov es:[curCatOffset], CATEGORY_NOT_CACHED mov es:[initFileHanLocked], bx mov bp, es call FindCategory jc nextInitFile call FindKey jc nextInitFile done: .leave ret notFound: stc jmp done GetNextInitFileAndFindKey endp COMMENT @-------------------------------------------------------------------- FUNCTION: FindCategory DESCRIPTION: Locates the given category. CALLED BY: INTERNAL (InitFileWrite, InitFileGet, InitFileReadInteger) PASS: es, bp - dgroup dgroup:[catStrAddr] - category ASCIIZ string dgroup:[catStrOffset] dgroup:[catStrLen] RETURN: IF CATEGORY FOUND: CARRY CLEAR dgroup:[initFileBufPos] - offset from BufAddr to character after ']' ELSE CARRY SET initFileBufPos - destroyed DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version CDB 4/29/92 added comments. Fixed a bug. ----------------------------------------------------------------------------@ FindCategory proc far EC < call IFCheckDgroupRegs > push ax,bx,cx,si,di,ds if HASH_INIFILE tst es:[hashTableBlkHandle] jz slowWay call HashFindCategory jmp exit slowWay: endif ; HASH_INIFILE lds si, es:[catStrAddr] EC < cmp {char} ds:[si], 0 > EC < ERROR_Z INIT_FILE_NULL_CATEGORY_PASSED > ; See if we're looking at the cached category. If no category ; cached, then cache the passed category. mov ax, es:[curCatOffset] .assert CATEGORY_NOT_CACHED eq 0 tst ax ; cmp ax, CATEGORY_NOT_CACHED jz cachePassedCategory ; Now, compare the passed category with the cached category. ; If not the same, then cache the new one. push si lea di, curCategory ; es:di - cached category mov cx, es:catStrLen inc cx repe cmpsb pop si jne cachePassedCategory ; They're equal. If the category isn't present, then set ; carry and exit. cmp ax, CATEGORY_NOT_PRESENT stc je exit ; if category IS present, then set buffer position mov es:[initFileBufPos], ax clc jmp exit cachePassedCategory: push si lea di, curCategory mov cx, es:catStrLen inc cx rep movsb pop si mov es:[initFileBufPos], 0 clr bx ; not starting inside blob findLoop: ;-------------------------------------------------------------------- ;skip to next category mov al, '[' call FindChar jc notFound call CmpString jc findLoop call SkipWhiteSpace call GetChar jc error cmp al, ']' jne findLoop mov ax, es:[initFileBufPos] mov es:[curCatOffset], ax clc exit: pop ax,bx,cx,si,di,ds ret error: GOTO CorruptedIniFileError notFound: ; Carry flag is set. mov es:[curCatOffset], CATEGORY_NOT_PRESENT jmp exit FindCategory endp COMMENT @-------------------------------------------------------------------- FUNCTION: FindKey DESCRIPTION: Sets the file position at the first body position if the key exists. Search halts when an EOF is encountered or when a new category is started. CALLED BY: INTERNAL (InitFileWrite) PASS: es, bp - dgroup dgroup:[ketStrAddr] - key ASCIIZ string RETURN: carry clear if successful dgroup:[initFileBufPos] - offset from BufAddr to body DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: done <- false repeat skip white space if first char = ';' then line <- line + 1 else if key found then done <- true else locate '=' skip white space if char <> '{' then line <- line + 1 else skip blob endif endif until done KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ FindKey proc far EC< call IFCheckDgroupRegs > push ax,bx,cx,si,ds clr bx ; assume not starting inside blob findLoop: call SkipWhiteSpace jc goToExit call GetChar jc goToExit cmp al, INIT_FILE_COMMENT je processComment dec es:[initFileBufPos] ;unget char cmp al, '[' ;new category? jne checkKey stc goToExit: jmp exit ;done if so checkKey: lds si, es:[keyStrAddr] ;Make sure that we were not passed a null keyword. Otherwise, ;we would search for it and fail, and then create a null keyword ;in the file, corrupting it. -EDS 10/14/92 EC < cmp {char} ds:[si], 0 > EC < ERROR_Z INIT_FILE_NULL_KEYWORD_PASSED > mov ax, es:[initFileBufPos] mov es:[curKeyOffset], ax call CmpString jc noMatch call SkipWhiteSpace jc error call GetChar jc error cmp al, '=' jne noMatch jmp short keyFound noMatch: mov al, '=' call FindChar jc error call SkipWhiteSpace jc error call GetChar jc error cmp al, '{' ;blob? je blobFound call SkipToEndOfLine jmp short findLoop blobFound: ;-------------------------------------------------------------------- ;skip blob mov bx, TRUE ;now processing blob mov al, '}' call FindChar EC< ERROR_C INIT_FILE_BAD_BLOB > EC< tst bx ;assert no longer in blob > EC< ERROR_NZ INIT_FILE_BAD_BLOB > jnc findLoop error: GOTO CorruptedIniFileError processComment: call SkipToEndOfLine jmp findLoop keyFound: call SkipWhiteSpace clc exit: pop ax,bx,cx,si,ds ret FindKey endp COMMENT @-------------------------------------------------------------------- FUNCTION: GetBodySize DESCRIPTION: Returns the size of the current body. The original buffer position is also returned in case the caller wishes to restore it. CALLED BY: INTERNAL (InitFileGet, DeleteEntry) PASS: es, bp - dgroup dgroup:[initFileBufPos] - offset to first char in body RETURN: ax - size of body cx - dgroup:[initFileBufPos] on entry dgroup:[initFileBufPos] - offset to char past entry terminator DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ GetBodySize proc far uses dx .enter EC< call IFCheckDgroupRegs > mov cx, es:[initFileBufPos] call GetChar jc done cmp al, '{' je locateBlobEnd ; ; We allow whitespace in the entry, but we need to ignore comments ; and trim off any trailing whitespace. ; clr dx ; no whitespace seen yet. scanLoop: ; comment? done if so cmp al, INIT_FILE_COMMENT je nonBlobComplete ; whitespace? record pos if so cmp al, ' ' je nonBlobWS cmp al, C_TAB ; tab je nonBlobWS ; end-of-line? done if so cmp al, '\r' je nonBlobComplete cmp al, '\n' je nonBlobComplete clr dx ; non-whitespace => no whitespace at end yet next: call GetChar jnc scanLoop nonBlobComplete: tst dx ; trailing whitespace? jz done ; nope clr al ; signal not at EOF mov es:[initFileBufPos], dx ; Backup to start of end jmp done nonBlobWS: tst dx jne next mov dx, es:[initFileBufPos] ; record current position -- dec ; in nonBlobComplete handles backing ; up to actual position of char. jmp next locateBlobEnd: push bx mov bx, TRUE ;now processing blob mov al, '}' ;look for matching curly-brace call FindChar pop bx jc closeNotFound mov ax, es:[initFileBufPos] sub ax, cx ;size from '{' to '}', inclusive sub ax, 2 ;don't count '{' and '}' jmp short exit closeNotFound: GOTO CorruptedIniFileError done: ; ; If al is ^Z here, it means we hit the end of the file w/o hitting ; a return or linefeed, so we need to include all the chars up to ; initFileBufPos (which won't advance beyond the ^Z). In the normal ; case (a blob or a return-terminated string), we want to not include ; the final character. ; cmp al, MSDOS_TEXT_FILE_EOF je figureSize ; (carry clear) ignoreChar:: stc ; perform extra decrement to ignore ; char before initFileBufPos figureSize: mov ax, es:[initFileBufPos] sbb ax, cx ;ax <- size of body exit: .leave ret GetBodySize endp COMMENT @-------------------------------------------------------------------- FUNCTION: SkipWhiteSpace DESCRIPTION: Return the next relevant character. White space and carraige returns are skipped. CALLED BY: INTERNAL (FindKey) PASS: es, bp - dgroup RETURN: dgroup:[initFileBufPos] updated, next call to GetChar will retrieve non white space character DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ SkipWhiteSpace proc near uses si, ds .enter EC< call IFCheckDgroupRegs > lds si, es:[initFileBufPos] ;get current pos in ds:si skipLoop: lodsb SBCS < cmp al, VC_BLANK > DBCS < cmp al, C_SPACE > je skipLoop ;next if blank SBCS < cmp al, VC_TAB > DBCS < cmp al, C_TAB > je skipLoop ;next if tab SBCS < cmp al, VC_ENTER > DBCS < cmp al, C_ENTER > je skipLoop ;next if carraige return SBCS < cmp al, VC_LF > DBCS < cmp al, C_LINEFEED > je skipLoop ;next if line feed dec si ; unget char cmp al, MSDOS_TEXT_FILE_EOF ;Clears carry if they are equal stc jz exit clc ;Clear the carry... exit: mov es:[initFileBufPos], si ; store back new position .leave ret SkipWhiteSpace endp COMMENT @-------------------------------------------------------------------- FUNCTION: SkipToEndOfLine DESCRIPTION: Skip to end of line. CALLED BY: INTERNAL (FindKey) PASS: es, bp - dgroup RETURN: carry clear if ok DESTROYED: al REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ SkipToEndOfLine proc near EC< call IFCheckDgroupRegs > mov al, '\n' ;locate a carraige return call FindChar ret SkipToEndOfLine endp COMMENT @-------------------------------------------------------------------- FUNCTION: FindChar DESCRIPTION: Searches the file buffer for the given unescaped, uncommented character. CALLED BY: INTERNAL (SkipToNextCategory, FindKey, SkipBlob, SkipToEndOfLine) PASS: es, bp - dgroup al - character to locate NOTE: MUST MATCH STORED CHARACTER EXACTLY. This routine no longer upcases/downcases chars before doing comparison. This should be OK as this routine is only be called for the chars '[', '=', '}' and EOLN. -- Doug bx - flag indicating if [initFileBufPos] is pointing to a blob (any char immediately following '{', or prior to or at '}') RETURN: carry clear if found dgroup:[initFileBufPos] updated to byte past char ie. a call to GetChar will fetch the next char bx - blob flag updated to reflect new position DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: unfortunately, the speed of the 8086 scas instructions cannot be taken advantage of KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version Doug 8/90 Optimized for speed dhunter 6/6/2000 Added special non-blob escape handling ----------------------------------------------------------------------------@ FindCharFar proc far call FindChar ret FindCharFar endp FindChar proc near uses ax, si, ds .enter EC< call IFCheckDgroupRegs > mov ah, al lds si, es:[initFileBufPos] ;get cur pos in ds:si findCharLoop: lodsb cmp al, MSDOS_TEXT_FILE_EOF je eof checkEscaped: cmp al, '\\' je escapedChar notEscaped: cmp al, INIT_FILE_COMMENT je commentChar cmp al, '{' ;found start of blob? je blobStart cmp al, '}' ;found blob terminator? je blobEnd afterComment: cmp ah, al jne findCharLoop clc exit: mov es:[initFileBufPos], si ; store new offset back to var .leave ret eof: dec si ; back up to point at EOF stc ; return EOF found jmp short exit escapedChar: ; Escaped char hit... lodsb ; read in escaped char cmp al, MSDOS_TEXT_FILE_EOF je eof tst bx ; Reading in blob? jnz findCharLoop ; nope, continue w/NEXT char ; ; Only certain chars are escaped outside of a blob, and the backslash ; is not one of them. If we don't find one of those chars, that ; means the '\\' was not really an escape and we should not skip the ; next char. -dhunter 6/6/2000 ; cmp al, '{' ; '{' is always escaped je findCharLoop ; found, goto next cmp al, '[' ; '[' is always escaped je findCharLoop ; found, goto next jmp short checkEscaped ; otherwise, it was just '\\' commentChar: ; Comment char hit... lodsb ; read through EOLN, cmp al, MSDOS_TEXT_FILE_EOF je eof cmp al, '\n' jne commentChar jmp short afterComment ; continue with EOLN itself blobStart: mov bx, TRUE ;now in blob. jmp short afterComment blobEnd: clr bx ;no longer in blob. jmp short afterComment FindChar endp COMMENT @-------------------------------------------------------------------- FUNCTION: GetChar DESCRIPTION: Fetch the next character from the file buffer. CALLED BY: INTERNAL (SkipBlob, SkipWhiteSpace) PASS: es, bp - dgroup RETURN: carry clear if successful al - next character dgroup:[initFileBufPos] updated carry set if end of file encountered al - EOF DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: buffer position is post incremented, ie. current value is offset to the next character KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version Cheng 4/90 Upcased all lowercase characters ----------------------------------------------------------------------------@ GetCharFar proc far call GetChar ret GetCharFar endp GetChar proc near uses si .enter EC< call IFCheckDgroupRegs > les si, es:[initFileBufPos] ;get cur pos ;This can be done because the initFileBufSegAddr ; directly follows initFileBufPos. These should ; actually be one variable, but, hell, I didn't ; write this stuff. lodsb es: ;fetch character mov es, bp ;es <- dgroup cmp al, MSDOS_TEXT_FILE_EOF stc je exit mov es:[initFileBufPos], si CheckHack <(IFCC_INTACT shl offset IFRF_CHAR_CONVERT) eq 0> CheckHack <(IFCC_UPCASE shl offset IFRF_CHAR_CONVERT) eq 0x4000> CheckHack <(IFCC_DOWNCASE shl offset IFRF_CHAR_CONVERT) eq 0x8000> test es:[bufFlag], mask IFRF_CHAR_CONVERT jz exit ; => IFCC_INTACT js downcase ; => IFCC_DOWNCASE ;upcase: cmp al, 'a' jb ok cmp al, 'z' ja exit sub al, 'a' - 'A' ;upcase all lowercase chars jmp exit ; (subtraction cannot cause ; borrow, since al is between ; 'a' and 'z', so carry is clr) ok: clc jmp exit downcase: cmp al, 'A' jb ok cmp al, 'Z' ja exit add al, 'a' - 'A' ;upcase all lowercase chars ; (addition cannot cause carry, ; so carry is clear) exit: .leave ret GetChar endp COMMENT @-------------------------------------------------------------------- FUNCTION: CmpString DESCRIPTION: Compares the given string with the string at the current init file buffer location. The comparison is case-insensitive and white space is ignored. CALLED BY: INTERNAL () PASS: ds:si - ASCIIZ string dgroup:[initFileBufPos] - current buffer position es, bp - dgroup RETURN: carry clear if strings 'match' initFileBufPos - positioned at next char after matched string set otherwise initFileBufPos - unchanged DESTROYED: REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 12/89 Initial version ----------------------------------------------------------------------------@ CmpString proc near uses ax, bx, si .enter EC< call IFCheckDgroupRegs > ; ; The behavior here is a little tricky - we want to preserve the current ; ini-file position if no match is found. ; mov bx, es:[initFileBufPos] fetchStr1: lodsb tst_clc al je exit ; carry cleared by "or" in tst call LegalCmpChar ;can this char be used for comparison? jc fetchStr1 ;loop if not mov ah, al ;save it in ah fetchStr2: call GetChar jc noMatch call LegalCmpChar ;can this char be used for comparison? jc fetchStr2 cmp ah, al je fetchStr1 noMatch: mov es:[initFileBufPos],bx ;Restore initFile position stc ;signal chokage exit: .leave ret CmpString endp COMMENT @-------------------------------------------------------------------- FUNCTION: LegalCmpChar DESCRIPTION: Sets the carry flag based on whether or not the given character can be used for comparison. Since we are ignoring white space, the carry bit is set if the character is a space or tab. The routine has the side effect of transforming all alphabet chars into upper case since comparison is case-insensitive. CALLED BY: INTERNAL (CmpString) PASS: al - char RETURN: carry clear if character is cmp-able al - made uppercase if passed al was a lowercase letter carry set if character is white space DESTROYED: REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 12/89 Initial version ----------------------------------------------------------------------------@ LegalCmpChar proc near cmp al, 'z' ja legal SBCS < cmp al, VC_BLANK > DBCS < cmp al, C_SPACE > je illegal SBCS < cmp al, VC_TAB > DBCS < cmp al, C_TAB > je illegal cmp al, 'a' jb legal sub al, 'a'-'A' legal: clc ret illegal: stc ret LegalCmpChar endp COMMENT @-------------------------------------------------------------------- FUNCTION: GetStringLength DESCRIPTION: Return the length of the given string. CALLED BY: INTERNAL (BuildEntryFromString) PASS: es:di - ASCIIZ string RETURN: cx - number of bytes in string (excluding null terminator) DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ GetStringLength proc near uses di .enter mov cx, -1 clr al repne scasb not cx dec cx .leave ret GetStringLength endp COMMENT @-------------------------------------------------------------------- FUNCTION: AsciiToHex DESCRIPTION: Converts the ASCII number at the current init file buffer position to its binary equivalent. CALLED BY: INTERNAL (ReconstructData, InitFileReadInteger) PASS: es - dgroup dgroup:[initFileBufPos] - offset to numeric entry RETURN: carry - set if no number parsed dx - binary equivalent al - terminating char DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: ASCII number must be less than 65536 REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ AsciiToHex proc near uses bx, cx .enter mov bx, 10 clr cx clr dx ;found digit flag convLoop: call GetChar call IsNumeric jc done clr ah sub ax, '0' ;convert to digit xchg ax, cx mul bx ;dx:ax <- digit * 10 add ax, cx mov cx, ax inc dx jmp short convLoop ;loop till done done: tst dx ;clears carry jnz 99$ stc 99$: mov dx, cx .leave ret AsciiToHex endp COMMENT @-------------------------------------------------------------------- FUNCTION: IsNumeric DESCRIPTION: Boolean routine that tells if argument is a numeric ASCII character. CALLED BY: INTERNAL (AsciiToHex) PASS: al - ASCII char RETURN: carry clear if numeric set otherwise DESTROYED: nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version Don 1/92 Optimized, I hope ----------------------------------------------------------------------------@ IsNumeric proc near cmp al, '0' ; carry is already set correctly jb done cmp al, '9'+ 1 ; carry is clear fort above/eq cmc ; invert it, please done: ret IsNumeric endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetStringSectionByIndex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return ptr to and length of specified string section. String section is run of alpha numeric chars CALLED BY: InitFileReadStringSection PASS: ds:si - ptr to begining of string dx - 0 based string section number cx - number of bytes in string RETURN: clc - section found ds:si - ptr to begining of string section cx - number of chars in string section ax - number of chars left in string - or - stc - error DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/ 9/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetStringSectionByIndex proc far uses bx, dx, di .enter ; Loop until we're done ; next: call GetStringSectionPtr tst ax ;any string? stc ;assume the worst jz done tst dx ;section index jz found ;carry is clear already stc ;assume the worst jcxz done ;remaining chars dec dx mov si, di jmp next found: xchg cx, ax ;string length => CX done: ;remaining characters => AX EC < pushf > EC < cmp ax, 2048 > EC < ERROR_AE -1 > EC < popf > .leave ret GetStringSectionByIndex endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetStringSectionPtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return ptr to string section. String section is next contiguous set of acceptable chars CALLED BY: GetStringSectionByIndex PASS: ds:si - ptr into string buffer cx - remaining chars in string buffer including ds:si char RETURN: ax - length ds:si - ptr to first char of section ds:di - ptr to byte after last char of section cx - remaining chars in string buffer including ds:di char DESTROYED: bx PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/ 9/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetStringSectionPtr proc near uses dx .enter ; Scan for first acceptable char ; mov bx, offset IsPrintableAsciiChar? call ScanStringForCharType ; Scan for first unacceptable char after acceptable char ; mov si, di mov bx, offset IsUnprintableAsciiChar? call ScanStringForCharType .leave ret GetStringSectionPtr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ScanStringForCharType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Scan a string until call back routine says to stop or end of string buffer has been reached CALLED BY: InitFileGetStringSectionLengthPtr PASS: DS:SI = Ptr into string buffer CX = Remaining chars in string including current char BX = Callback routine (near, of course) RETURN: DS:DI = First rejected char or byte after end of buffer AX = Length of accepted string CX = Eemaining chars in string including current char DESTROYED: BX PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/ 9/90 Initial version don 1/30/92 Used near callback routines, now %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ScanStringForCharType proc near uses bp, si .enter mov di, si jcxz noChars nextChar: LocalGetChar ax, dssi call bx ; call callback routine jnc stop loop nextChar LocalNextChar dssi ; make up for dec si below stop: LocalPrevChar dssi ; back to reject char noChars: ; Calc number of remaining chars and length ; mov ax, si sub ax, di ; length DBCS < shr ax, 1 ; ax <- length > mov di, si .leave ret ScanStringForCharType endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IsPrintableAsciiChar? %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determines if character is acceptable in a printer name CALLED BY: ScanStringForCharType() PASS: al - char RETURN: clc - yes stc - no DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/ 9/90 Initial version don 1/21/92 Optimized, I hope %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ IsPrintableAsciiChar? proc near SBCS < cmp al,C_SPACE ; sets the carry as desired > DBCS < cmp ax,C_SPACE ; sets the carry as desired > ret IsPrintableAsciiChar? endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IsUnprintableAsciiChar? %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determines if character is acceptable in a printer name CALLED BY: ScanStringForCharType() PASS: al - char RETURN: clc - it is not a printer char stc - it is a printer char DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/ 9/90 Initial version don 1/21/92 Optimized, I hope %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ IsUnprintableAsciiChar? proc near SBCS < cmp al,C_SPACE ; sets carry opposite of desire> DBCS < cmp ax,C_SPACE ; sets carry opposite of desire> cmc ret IsUnprintableAsciiChar? endp InitfileRead ends InitfileWrite segment resource COMMENT @-------------------------------------------------------------------- FUNCTION: DeleteEntry DESCRIPTION: Deletes the current entry by shifting the next entry over it. Updates the internal size of the file. CALLED BY: INTERNAL (InitFileWrite) PASS: es, bp - dgroup dgroup:[initFileBufPos] dgroup:[initFileBufSegAddr] dgroup:[curKeyOffset] dgroup:[loaderVars].KLV_initFileSize RETURN: dgroup:[initFileBufPos] - offset to where key was dgroup:[loaderVars].KLV_initFileSize - reduced by size of entry DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ DeleteEntry proc near EC < call IFCheckDgroupRegs > push cx,di,si,ds call GetBodySize ;ax,cx <- func(es,bp) ;initFileBufPos points 1 past terminator lds si, es:[initFileBufPos] EC < call ECCheckBounds > cmp byte ptr ds:[si], '\r' jne checkLF inc si checkLF: cmp byte ptr ds:[si], '\n' jne doDel inc si doDel: mov di, es:[curKeyOffset] push di mov ax, si sub ax, di ;ax <- size of entry mov cx, es:[loaderVars].KLV_initFileSize sub cx, si push ds pop es rep movsb mov es, bp ;es <- dgroup pop es:[initFileBufPos] sub es:[loaderVars].KLV_initFileSize, ax if HASH_INIFILE mov cx, ax neg cx call HashUpdateHashTable endif ; HASH_INIFILE pop cx,di,si,ds ret DeleteEntry endp COMMENT @-------------------------------------------------------------------- FUNCTION: CreateCategory DESCRIPTION: Inserts the category into the init file buffer at the current location. CALLED BY: INTERNAL (InitFileWrite) PASS: es, bp - dgroup dgroup:[catStrAddr] - category ASCIIZ string dgroup:[initFileBufPos] - offset from buffer to insertion loc (new data will start at this location) RETURN: dgroup:[initFileBufSegAddr] - possibly changed dgroup:[loaderVars].KLV_initFileSize - increased by size of category + 2 dgroup:[initFileBufPos] - 1 after terminating ']' DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: tack new category on to end of file body insertion pos = eof KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ CreateCategory proc near uses cx, di, si, ds .enter if HASH_INIFILE ; ; Jump to the end of the file ; mov ax, es:[loaderVars].KLV_initFileSize ; size including EOF dec ax ; offset of EOF mov es:[initFileBufPos], ax endif ;HASH_INIFILE ; First make space for the new category name ; EC < call IFCheckDgroupRegs > mov cx, es:[catStrLen] push cx add cx, 4 ; '[', ']', CR, LF call MakeSpace ; func(es, cx), destroys ax, di pop cx ; Store the new category, and associate formatting bytes ; lds si, es:[catStrAddr] mov di, es:[initFileBufPos] mov es, es:[initFileBufSegAddr] ; destination -> es:di mov al, '[' stosb ; now write the open bracket if HASH_INIFILE push di ; remember this position endif ; HASH_INIFILE rep movsb ; now write the category name mov al, ']' stosb ; write the close bracket SBCS < mov ax, (VC_LF shl 8) or VC_ENTER > DBCS < mov ax, (C_LINEFEED shl 8) or C_ENTER > stosw ; finally, go to the next line ; Store the current file position, and cache the category position ; mov es, bp mov es:[initFileBufPos], di mov es:[curCatOffset], di if HASH_INIFILE pop cx ; pointer to category name call HashAddPrimaryEntry endif ;HASH_INIFILE .leave ret CreateCategory endp COMMENT @-------------------------------------------------------------------- FUNCTION: MakeSpace DESCRIPTION: Extends the init file buffer to fit the string construction buffer. Updates the internal size of the file. CALLED BY: INTERNAL (CreateCategory, InitFileWrite) PASS: es, bp - dgroup dgroup:[initFileBufPos] - offset from buffer to insertion loc (new data will start at this location) cx - size of entry RETURN: dgroup:[initFileBufSegAddr] dgroup:[loaderVars].KLV_initFileSize DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: get a bigger buffer shift tail portion down KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ MakeSpace proc near EC< call IFCheckDgroupRegs > push bx,cx,di,si,ds mov ax, es:[loaderVars].KLV_initFileSize mov si, ax ;si <- old buffer size add ax, cx mov di, ax ;di <- new buffer size mov bx, es:[loaderVars].KLV_initFileBufHan mov ch, mask HAF_ZERO_INIT or mask HAF_NO_ERR call MemReAlloc ;-------------------------------------------------------------------- ;es = dgroup ;si = old init file buffer size ;di = new size mov es:[initFileBufSegAddr], ax mov es:[loaderVars].KLV_initFileSize, di mov cx, si sub cx, es:[initFileBufPos] ;cx <- num bytes to relocate dec di ;point di at last dest byte dec si ;point si at last source byte mov ds, ax ;ds <- buffer addr mov es, ax ;es <- buffer addr std ;get mov to decrement di and si rep movsb cld mov es, bp pop bx,cx,di,si,ds if HASH_INIFILE call HashUpdateHashTable endif ; HASH_INIFILE ret MakeSpace endp COMMENT @-------------------------------------------------------------------- FUNCTION: Hex16ToAscii DESCRIPTION: Converts a hex word to its ASCII representation without leading zeros. CALLED BY: INTERNAL (InitFileWriteInteger) PASS: ax - number to convert es:di - location to place ASCII string (not null terminated) RETURN: di - offset to one char past last char stored DESTROYED: ax, cx REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: The number is converted to decimal as it's easily user-editable and is used in keys where the user could well want to edit things (namely integers). KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ Hex16ToAscii proc near push bx,dx mov bx, 10 clr cx ;cx = count for number of digits convLoop: clr dx div bx push dx ;save remainder inc cx ;inc digit count tst ax ;done? jne convLoop ;loop if not storeLoop: pop ax add al, '0' stosb loop storeLoop pop bx,dx ret Hex16ToAscii endp COMMENT @-------------------------------------------------------------------- FUNCTION: Hex8ToAscii DESCRIPTION: Converts a hex byte to its ASCII representation (two hex digits) CALLED BY: INTERNAL (BuildEntryFromData) PASS: al - number to convert es:di - location to place ASCII string (not null terminated) RETURN: di - offset to one char past last char stored DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 11/89 Initial version ----------------------------------------------------------------------------@ nibbles db "0123456789ABCDEF" Hex8ToAscii proc near uses bx .enter push ax mov bx, offset nibbles shr al, 1 shr al, 1 shr al, 1 shr al, 1 and al, 0fh xlatb cs: stosb pop ax and al, 0fh xlatb cs: stosb .leave ret Hex8ToAscii endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InitFileHex8ToAscii %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a byte to its 2-hex-digit ASCII representation CALLED BY: EXTERNAL PASS: al = number to convert es:di = place to store result (won't be null-terminated) RETURN: es:di = points after last char stored DESTROYED: ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 8/27/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not DBCS_PCGEOS InitFileHex8ToAscii proc far .enter call Hex8ToAscii .leave ret InitFileHex8ToAscii endp endif InitfileWrite ends COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% We want the validate routine to reside in the Read resource for the EC kernel, and the Write resource in the non-EC kernel, to avoid ugly deadlock situations. Thanks for letting us know what those ugly deadlock situations were, Cheng. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EC < InitfileRead segment resource > NEC < InitfileWrite segment resource > COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ValidateIniFile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Scans the passed buffer for non-ascii characters. CALLED BY: INTERNAL PASS: ds - segment of ini file cx - # chars in .ini file RETURN: carry set if file is trashed (has non-ascii chars) DESTROYED: nothing but flags PSEUDO CODE/STRATEGY: 1) If any non-ascii characters are found, return TRASHED 2) for each line: A) if the line begins with C_CR -> ignore rest of line B) else if the line begings with '[', it must end with ']' C) else the line must contain a '=' 1) if the first non-whitespace character is a '{', skip to the matching '}' KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 10/25/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VIF_State etype byte VIF_START_OF_LINE enum VIF_State ;Looking for any string VIF_CATEGORY_LINE_NO_END_BRACKET enum VIF_State ;Line starts with [ VIF_COMMENT enum VIF_State ;Line starts with ; VIF_LOOKING_FOR_EQUAL enum VIF_State ;Looking for '=' in line VIF_IN_BRACE enum VIF_State ;Parse '{', looking '}' VIF_EXPECT_EOL enum VIF_State ;Looking for CR or LF if ERROR_CHECK or BACKUP_AND_RESTORE_INI_FILE ValidateIniFileFar proc far call ValidateIniFile ret ValidateIniFileFar endp endif ValidateIniFile proc near uses ax, cx, dx, si .enter clr si ;ds:si <- pointer to text charLoopStartLine: mov dl, VIF_START_OF_LINE ;starting state charLoop: EC < tst cx > EC < ERROR_S INI_FILE_VERIFICATION_ERROR > jcxz toEndOfBuffer lodsb dec cx ;decrement count cmp al, C_CTRL_Z ;If at EOF, this is the end of jz toEndOfBuffer ; the buffer. cmp al, C_CR jz handleCR cmp al, C_TAB jz charLoop cmp al, ' ' jz charLoop cmp al, 0x20 jae charOK toError: jmp error toEndOfBuffer: jmp endOfBuffer charOK: ; if comment then slip cmp dl, VIF_COMMENT jz charLoop ; if first char on line... cmp dl, VIF_START_OF_LINE jnz notStartOfLine mov dl, VIF_CATEGORY_LINE_NO_END_BRACKET ;assume '[' cmp al, '[' jz charLoop mov dl, VIF_COMMENT ;assume comment cmp al, INIT_FILE_COMMENT jz charLoop mov dl, VIF_LOOKING_FOR_EQUAL jmp charLoop notStartOfLine: cmp dl, VIF_LOOKING_FOR_EQUAL jnz notLookingForEqual cmp al, '=' jnz charLoop ; char is '=', look for '[' skipWhite: lodsb ;get next char dec cx jcxz toError cmp al, C_TAB jz skipWhite cmp al, ' ' jb toError ;if control char then error (CR is error ;also) jz skipWhite mov dl, VIF_IN_BRACE cmp al, '{' ;if '{' then scan for '}' jz charLoop ; (skip to end of line) mov dl, VIF_COMMENT jmp charLoop notLookingForEqual: cmp dl, VIF_CATEGORY_LINE_NO_END_BRACKET jnz notLookingForEndBracket ; looking for ']' cmp al, ']' jnz charLoop mov dl, VIF_EXPECT_EOL jmp charLoop notLookingForEndBracket: cmp dl, VIF_EXPECT_EOL jz error EC < cmp dl, VIF_IN_BRACE > EC < ERROR_NZ INI_FILE_VERIFICATION_ERROR > cmp al, '}' jnz toCharLoop mov dl, VIF_EXPECT_EOL toCharLoop: jmp charLoop handleCR: ; end of line cmp dl, VIF_COMMENT jz lookForLF cmp dl, VIF_EXPECT_EOL jz lookForLF cmp dl, VIF_IN_BRACE jz lookForLF cmp dl, VIF_CATEGORY_LINE_NO_END_BRACKET jz error cmp dl, VIF_LOOKING_FOR_EQUAL jz error EC < cmp dl, VIF_START_OF_LINE > EC < ERROR_NZ INI_FILE_VERIFICATION_ERROR > lookForLF: jcxz error lodsb dec cx cmp al, C_LF jnz error cmp dl, VIF_IN_BRACE jz toCharLoop jmp charLoopStartLine endOfBuffer: cmp dl, VIF_IN_BRACE jz error cmp dl, VIF_CATEGORY_LINE_NO_END_BRACKET jz error cmp dl, VIF_LOOKING_FOR_EQUAL jz error ; allow VIF_EXPECT_EOL and VIF_START_OF_LINE and VIF_COMMENT clc jmp common error: stc common: .leave ret ValidateIniFile endp EC < InitfileRead ends > NEC < InitfileWrite ends >
/* * Speck_Sce1_LinRAM.asm * * Created: 2015/9/17 14:26:45 * Author: Administrator */ .EQU INITV_NUM_BYTE = 8 .EQU PTEXT_NUM_BYTE = 128 .EQU MASTER_KEY_NUM_BYTE = 16 .EQU KEYS_NUM_BYTE = 108 .EQU KEY_SCHEDULE_ROUNDS = 26 .EQU ENC_DEC_ROUNDS = 27 .EQU BLOCK_SIZE = 16 #define KEYSCHEDULE #define ENCRYPT #define DECRYPT .def temp = r22; .def transferL = r23; .def currentRound = r24; .def currentBlock = r25; /* * Subroutine: keyschedule * Function: compute the sub keys. The values of L are all stored in RAM. * RAM: lRAM * keys * Register: [r0, r7] key schedule * r22 temp * r23 transferL * r24 currentRound * r25 currentBlock * X the address of keys * Y the address of lRAM * Z the address of lRAM */ #ifdef KEYSCHEDULE keyschedule: ; load k[0] ldi r26, low(SRAM_KEYS); ldi r27, high(SRAM_KEYS); ldi r28, low(SRAM_MASTER_KEY); ldi r29, high(SRAM_MASTER_KEY); ld temp, y+; st x+, temp; ld temp, y+; st x+, temp; ld temp, y+; st x+, temp; ld temp, y+; st x+, temp; ldi r26, low(SRAM_L); ldi r27, high(SRAM_L); clr currentRound; loadL: ld temp, y+; st x+, temp; inc currentRound; cpi currentRound, 12; brne loadL ; prepare for key schedule clr currentRound; clr r21; store the value of zero ldi r26, low(SRAM_KEYS); ldi r27, high(SRAM_KEYS); ldi r28, low(SRAM_L); ldi r29, high(SRAM_L); subkey: ;[r3,r2,r1,r0] to store ki ld r0, x+; ld r1, x+; ld r2, x+; ld r3, x+; ;[r7,r6,r5,r4] to store li ld r4, y+; ld r5, y+; ld r6, y+; ld r7, y+; ; k(i)+S(-8)l(i) add r5, r0; adc r6, r1; adc r7, r2; adc r4, r3; ; eor i eor r5, currentRound; ; S3(ki) lsl r0; rol r1; rol r2; rol r3; adc r0, r21; lsl r0; rol r1; rol r2; rol r3; adc r0, r21; lsl r0; rol r1; rol r2; rol r3; adc r0, r21; ; k(i+1) eor r0, r5; eor r1, r6; eor r2, r7; eor r3, r4; ; store k(i+1) st x+, r0; st x+, r1; st x+, r2; st x+, r3; sbiw r26, 4; adiw z, 8; st z+, r5; st z+, r6; st z+, r7; st z+, r4; sbiw z, 12; ; loop control inc currentRound; cpi currentRound, KEY_SCHEDULE_ROUNDS; 27 may be wrong brne subkey; ret; #endif /* * Subroutine: encryption * Function: encyrpt the 128 bytes of data * RAM: sendData * keys * vector * Register: [r0, r7] plain text * [r12, r15] round key * [r16, r23] the vector or cipher text of last round * r24, currentRound * r25, currentBlock * X the address of data * Y the address of keys * r30 store 0 */ #ifdef ENCRYPT encrypt: ; load the vector to [r23-r16] ldi r26, low(SRAM_INITV); ldi r27, high(SRAM_INITV); ld r16, x+; ld r17, x+; ld r18, x+; ld r19, x+; ld r20, x+; ld r21, x+; ld r22, x+; ld r23, x+; ; start encyrption clr currentBlock; ldi r26, low(SRAM_PTEXT); x stores the current address of data ldi r27, high(SRAM_PTEXT); encAnotherBlock: clr currentRound; reset ldi r28, low(SRAM_KEYS); stores the start address of keys ldi r29, high(SRAM_KEYS); ; load the plaintext from RAM to registers [r7,...,r0], X = [r7, r6, r5, r4], Y = [r3, r2, r1, r0] ld r7, x+ ; ld r6, x+ ; ld r5, x+ ; ld r4, x+ ; ld r3, x+ ; ld r2, x+ ; ld r1, x+ ; ld r0, x+ ; ; eor with the init vector or the cipher text of last block eor r0, r16 eor r1, r17 eor r2, r18 eor r3, r19 eor r4, r20 eor r5, r21 eor r6, r22 eor r7, r23 clr r30; encLoop: ; load k: [r15, r14, r13, r12], r12 is the lowest byte ld r12, y+; ld r13, y+; ld r14, y+; ld r15, y+; ; x = S(8)( S(-8)(x) + y) add r5, r0; x1 = x1 + y0 adc r6, r1; x2 = x2 + y1 adc r7, r2; x3 = x3 + y2 adc r4, r3; x0 = x0 + y3; ; k = ( S(-8)(x) + y ) eor k eor r12, r5; eor r13, r6; eor r14, r7; eor r15, r4; ; y = s(3)y lsl r0; loop 1 rol r1; rol r2; rol r3; adc r0, r30; lsl r0; loop 2 rol r1; rol r2; rol r3; adc r0, r30; lsl r0; loop 3 rol r1; rol r2; rol r3; adc r0, r30; ; y = S(3)(y) eor ( S(-8)(x) + y ) eor k eor r0, r12; eor r1, r13; eor r2, r14; eor r3, r15; ; x = ( S(-8)(x) + y ) eor k movw r4, r12; r5:r4 = r13:r12 movw r6, r14; r7:r6 = r15:r14 inc currentRound; cpi currentRound, ENC_DEC_ROUNDS; brne encLoop; ; one block has been encrypted. move cipher text to tempCipher movw r16, r0; movw r18, r2; movw r20, r4; movw r22, r6; ; move cipher text back to plain text st -x, r0; st -x, r1; st -x, r2; st -x, r3; st -x, r4; st -x, r5; st -x, r6; st -x, r7; ; x = x + 8, let x point the start address of next block adiw r26, 8; adiw rd, K ==== rd+1:rd <- rd+1:rd + K inc currentBlock; cpi currentBlock, BLOCK_SIZE; breq encAllEnd; rjmp encAnotherBlock; encAllEnd: ret; #endif /* * Subroutine: decryption * Function: decyrpt the 128 bytes of data * RAM: sendData * keys * vector * tempCipher. The cipher text will be overwritten during decryption. But he next round will use it. * Therefore, the cipher text must be stored before decryption. * Register: [r0, r7] cipher text. From low byte to high. * [r8, r11] round key. From low byte to high. * [r16, r23] the vector or cipher text of last round. From low byte to high. * r24, currentRound * r25, currentBlock * X the address of data * Y the address of keys * Z the address of tempCipher */ #ifdef DECRYPT decrypt: ; load the vector to register[r16-r23] ldi r26, low(SRAM_INITV); ldi r27, high(SRAM_INITV); ld r16, x+; ld r17, x+; ld r18, x+; ld r19, x+; ld r20, x+; ld r21, x+; ld r22, x+; ld r23, x+; ; start decyrption clr currentBlock; ldi r26, low(SRAM_PTEXT); x stores the current address of data ldi r27, high(SRAM_PTEXT); decAnotherBlock: clr currentRound; reset ; load the ciphertext from RAM to registers [r7,...,r0], X = [r7, r6, r5, r4], Y = [r3, r2, r1, r0] ld r7, x+ ; ld r6, x+ ; ld r5, x+ ; ld r4, x+ ; ld r3, x+ ; ld r2, x+ ; ld r1, x+ ; ld r0, x+ ; ; store the ciphertext of last round ldi r30, low(SRAM_TempCipher); x stores the current address of data ldi r31, high(SRAM_TempCipher); st z+, r0; st z+, r1; st z+, r2; st z+, r3; st z+, r4; st z+, r5; st z+, r6; st z+, r7; ; SRAM_INITV must be next and near to SRAM_KEYS in RAM ldi r28, low(SRAM_KEYS+KEYS_NUM_BYTE); the address of (the last byte keys + 1) ldi r29, high(SRAM_KEYS+KEYS_NUM_BYTE); ;sbiw r28, 1; y is just the start address of keys + 108. So it does not need sub 1. decLoop: ; get the sub key k /* ld r11, -y ; store the 4 bytes of sub key to K = [r11, r10, r9, r8] ld r10, -y ; ld r9, -y ; ld r8, -y ; ; k = k eor x eor r8, r4; eor r9, r5; eor r10, r6; eor r11, r7; ; x = x eor y eor r4, r0; eor r5, r1; eor r6, r2; eor r7, r3; ; x = S(-3)x lsr r7; ror r6; ror r5; bst r4, 0; ror r4; bld r7, 7; lsr r7; ror r6; ror r5; bst r4, 0; ror r4; bld r7, 7; lsr r7; ror r6; ror r5; bst r4, 0; ror r4; bld r7, 7; ; y = x movw r0, r4; movw r2, r6; ; x = k - x; sub r8, r4; sbc r9, r5; sbc r10, r6; sbc r11, r7; ; x = S(8)k mov r4, r11; mov r5, r8; mov r6, r9; mov r7, r10; */ ; can reduce one instruction ld r11, -y ; ld r10, -y ; ld r9, -y ; ld r8, -y ; ; y = y eor x eor r0, r4; eor r1, r5; eor r2, r6; eor r3, r7; ; y = S(-3)y lsr r3; ror r2; ror r1; bst r0, 0; ror r0; bld r3, 7; lsr r3; ror r2; ror r1; bst r0, 0; ror r0; bld r3, 7; lsr r3; ror r2; ror r1; bst r0, 0; ror r0; bld r3, 7; ; x = x eor k eor r4, r8; eor r5, r9; eor r6, r10; eor r7, r11; ; x = x - y; sub r4, r0; sbc r5, r1; sbc r6, r2; sbc r7, r3; ; x = S(8)x mov r8, r7; mov r7, r6; mov r6, r5; mov r5, r4; mov r4, r8; inc currentRound; cpi currentRound, ENC_DEC_ROUNDS; brne decLoop; ; eor with the init vector or the cipher text of last block eor r0, r16 eor r1, r17 eor r2, r18 eor r3, r19 eor r4, r20 eor r5, r21 eor r6, r22 eor r7, r23 ; move cipher text back to plain text st -x, r0; st -x, r1; st -x, r2; st -x, r3; st -x, r4; st -x, r5; st -x, r6; st -x, r7; ; x = x + 8, let x point the start address of next block adiw r26, 8;K adiw rd, K ==== rd+1:rd <- rd+1:rd + K ; reset vector: move from tempCipher to vector ldi r30, low(SRAM_TempCipher); ldi r31, high(SRAM_TempCipher); ld r16, z+; ld r17, z+; ld r18, z+; ld r19, z+; ld r20, z+; ld r21, z+; ld r22, z+; ld r23, z+; inc currentBlock; cpi currentBlock, BLOCK_SIZE; breq decAllEnd; rjmp decAnotherBlock; decAllEnd: ret; #endif
; A268149: A double binomial sum involving absolute values. ; 0,24,1120,33264,823680,18475600,389398464,7862853600,153876579840,2940343837200,55138611528000,1018383898440480,18574619721465600,335240928272918304,5996573430996184960,106438123408375281600,1876607120325212706816,32891715945378106711440 mov $1,$0 mul $0,2 mul $1,4 bin $1,$0 mov $2,$0 mul $2,$0 mul $1,$2 mov $0,$1
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: GrObj FILE: objectVisGuardian.asm AUTHOR: Steve Scholl, Dec 6, 1991 ROUTINES: Name Description ---- ----------- GrObjVisGuardianSendGrObjMouseMessageToVisWard GrObjVisGuardianMessageToVisWard GrObjVisGuardianInitAndFillPriorityList GrObjVisGuardianSendClassedEvent GrObjVisGuardianEvaluateEditGrabForEdit GrObjVisGuardianAttemptToEditOther GrObjVisGuardianStartSelectToEditGrab GrObjVisGuardianCalcScaleFactorVISToOBJECT GrObjVisGuardianBeginEditGeometryCommon GrObjVisGuardianEndEditGeometryCommon MESSAGE HANDLERS Name Description ---- ----------- GrObjVisGuardianInitialize GrObjVisGuardianSetVisWardClass GrObjVisGuardianCreateVisWard GrObjVisGuardianSendAnotherToolActivated GrObjVisGuardianKbdChar GrObjVisGuardianDuplicateFloater GrObjVisGuardianAddVisWard GrObjVisGuardianLargeStartSelect GrObjVisGuardianLargePtr GrObjVisGuardianLargeDragSelect GrObjVisGuardianLargeEndSelect GrObjVisGuardianConvertLargeMouseData GrObjVisGuardianDrawFG GrObjVisGuardianSetVisWardToolActiveStatus GrObjVisGuardianGetVisWardToolActiveStatus GrObjVisGuardianSetVisWardMouseEventType GrObjVisGuardianAfterAddedToBody GrObjVisGuardianBeforeRemovedFromBody GrObjVisGuardianApplyOBJECTToVISTransform GrObjVisGuardianNotifyGrObjValid GrObjVisGuardianVisBoundsSetup GrObjVisGuardianHaveWardDestroyCachedGStates GrObjVisGuardianObjFree GrObjVisGuardianGainedTargetExcl GrObjVisGuardianLostTargetExcl GrObjVisGuardianGainedFocusExcl GrObjVisGuardianLostFocusExcl GrObjVisGuardianAlterFTVMCExcl GrObjVisGuardianNotifyVisWardChangeBounds GrObjVisGuardianCreateGState GrObjVisGuardianPARENTPointForEdit GrObjVisGuardianBeginCreate GrObjVisGuardianGetVisWardOD REVISION HISTORY: Name Date Description ---- ---- ----------- Steve 12/ 6/91 Initial revision DESCRIPTION: $Id: grobjVisGuardian.asm,v 1.1 97/04/04 18:08:59 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjClassStructures segment resource GrObjVisGuardianClass ;Define the class record GrObjClassStructures ends GrObjVisGuardianCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianMetaInitialize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initialize object PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianMetaInitialize method dynamic GrObjVisGuardianClass, \ MSG_META_INITIALIZE .enter ; Initialize mouse flags to small mouse events and ; to not pass mouse events to ward ; clr ds:[di].GOVGI_flags mov di, offset GrObjVisGuardianClass CallSuper MSG_META_INITIALIZE .leave ret GrObjVisGuardianMetaInitialize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianInitialize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Create the vis ward and then call our superclass to initialize instance data and attributes PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ss:bp - GrObjInitializeData RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 4/19/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianInitialize method dynamic GrObjVisGuardianClass, MSG_GO_INITIALIZE .enter mov ax,MSG_GB_GET_BLOCK_FOR_ONE_GROBJ mov di,mask MF_FIXUP_DS or mask MF_CALL call GrObjMessageToBody EC < ERROR_Z GROBJ_CANT_SEND_MESSAGE_TO_BODY > mov ax,MSG_GOVG_CREATE_VIS_WARD call ObjCallInstanceNoLock mov di,offset GrObjVisGuardianClass mov ax,MSG_GO_INITIALIZE call ObjCallSuperNoLock ; Initialize the vis bounds of the ward to be the ; OBJECT dimensions. This is the default for most ; ward/guardian pairs. ; call GrObjVisGuardianSetVisBoundsToOBJECTDimensions .leave ret GrObjVisGuardianInitialize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrobjVisGuardianSetVisWardClass %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the class of the vis ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass cx:dx - ftpr to class of vis ward RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 5/21/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrobjVisGuardianSetVisWardClass method dynamic GrObjVisGuardianClass, MSG_GOVG_SET_VIS_WARD_CLASS .enter EC < tst ds:[di].GOVGI_ward.handle > EC < ERROR_NZ GROBJ_CANT_SET_VIS_WARD_CLASS_AFTER_WARD_CREATED > mov ds:[di].GOVGI_class.segment,cx mov ds:[di].GOVGI_class.offset,dx .leave ret GrobjVisGuardianSetVisWardClass endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianCreateVisWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Create ward of the class in GOVGI_class and store OD in GOVGI_ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass cx - block to create ward in RETURN: cx:dx - ward od DESTROYED: nothing WARNING: May cause block in cx to move PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianCreateVisWard method dynamic GrObjVisGuardianClass, MSG_GOVG_CREATE_VIS_WARD uses ax .enter ; Create ward of class ; push si ;parent chunk mov bx,cx ;block handle mov cx,ds:[di].GOVGI_class.segment EC < tst cx > EC < ERROR_Z OBJECT_VIS_PARENT_HAS_NO_CHILD_CLASS > mov es,cx mov di,ds:[di].GOVGI_class.offset call ObjInstantiate ; Add ward ; movdw cxdx,bxsi ;ward pop si ;parent chunk mov ax, MSG_GOVG_ADD_VIS_WARD call ObjCallInstanceNoLock ; Update body's info on how big objects in the wards ; block can get. ; pushdw cxdx ;ward od mov dx,cx ;ward handle mov di,mask MF_FIXUP_DS or mask MF_CALL mov ax,MSG_GV_GET_POTENTIAL_WARD_SIZE call GrObjVisGuardianMessageToVisWard mov di,mask MF_FIXUP_DS mov ax,MSG_GB_INCREASE_POTENTIAL_EXPANSION call GrObjMessageToBody popdw cxdx ;ward od .leave ret GrObjVisGuardianCreateVisWard endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianAddVisWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add ward as visual child PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass cx:dx - vis ward to add RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianAddVisWard method dynamic GrObjVisGuardianClass, \ MSG_GOVG_ADD_VIS_WARD uses ax, cx, dx .enter EC < tst ds:[di].GOVGI_ward.handle > EC < ERROR_NZ OBJECT_VIS_PARENT_ALREADY_HAS_CHILD > call ObjMarkDirty movdw ds:[di].GOVGI_ward,cxdx mov cx, ds:[LMBH_handle] mov dx, si mov ax,MSG_GV_SET_GUARDIAN_LINK mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave ret GrObjVisGuardianAddVisWard endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianPassToWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pass message to ward. Watch what you pass because this handler automatically destroys everything. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass depends on message RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/ 4/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianPassToWard method dynamic GrObjVisGuardianClass, MSG_META_SUSPEND, MSG_META_UNSUSPEND .enter push ax ;message mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock pop ax ;message mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave Destroy ax,cx,dx,bp ret GrObjVisGuardianPassToWard endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianKbdChar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send any keypresses onto the ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 5/ 3/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianKbdChar method dynamic GrObjVisGuardianClass, MSG_META_KBD_CHAR .enter clr di call GrObjVisGuardianMessageToVisWard .leave ret GrObjVisGuardianKbdChar endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianSendAnotherToolActivated %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send MSG_GO_ANOTHER_TOOL_ACTIVATED to selected and editable grobjects PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/15/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianSendAnotherToolActivated method dynamic \ GrObjVisGuardianClass, MSG_GO_SEND_ANOTHER_TOOL_ACTIVATED uses ax,cx,dx,bp .enter mov cx,ds:[LMBH_handle] mov dx,si mov bp,mask ATAF_GUARDIAN mov ax,MSG_GO_ANOTHER_TOOL_ACTIVATED clr di ;MessageFlags call GrObjSendToSelectedGrObjsAndEditAndMouseGrabSuspended .leave ret GrObjVisGuardianSendAnotherToolActivated endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGetEditClass %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This default handler returns the class of the guardian PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: cx:dx - fptr to class DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 5/14/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGetEditClass method dynamic GrObjVisGuardianClass, MSG_GOVG_GET_EDIT_CLASS .enter mov di, ds:[si] ;access meta movdw cxdx,ds:[di].MI_base.MB_class .leave ret GrObjVisGuardianGetEditClass endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianDuplicateFloater %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy object and its visual ward to a block in the vm file. Get handle of block from body PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianParentClass cx:dx - od of body RETURN: cx:dx - od of new object DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianDuplicateFloater method dynamic GrObjVisGuardianClass, \ MSG_GO_DUPLICATE_FLOATER uses ax .enter EC < test ds:[di].GOI_optFlags, mask GOOF_FLOATER > EC < ERROR_Z OBJECT_BEING_DUPLICATED_IS_NOT_THE_FLOATER > push cx,dx ;body od ; Use super class to copy this object ; mov di, offset GrObjVisGuardianClass CallSuper MSG_GO_DUPLICATE_FLOATER pop bx, si ;body od push cx, dx ;new guardian od ; get block for vis ward into cx ; mov ax,MSG_GB_GET_BLOCK_FOR_ONE_GROBJ mov di,mask MF_FIXUP_DS or mask MF_CALL call ObjMessage pop bx, si ;new guardian od mov ax, MSG_GOVG_CREATE_VIS_WARD clr di call ObjMessage movdw cxdx, bxsi ;^lcx:dx <-new guardian .leave ret GrObjVisGuardianDuplicateFloater endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianLargeStartSelect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle start select event. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ax - Message ss:bp - GrObjMouseData RETURN: ax - MouseReturnFlags if MRF_SET_POINTER_IMAGE cx:dx - optr of pointer image else cx,dx - DESTROYED DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianLargeStartSelect method dynamic GrObjVisGuardianClass, MSG_GO_LARGE_START_SELECT .enter test ds:[di].GOI_optFlags, mask GOOF_FLOATER jz document test ds:[di].GOVGI_flags,mask GOVGF_CAN_EDIT_EXISTING_OBJECTS jnz attemptFloaterEdit checkFloaterCreate: ; If the floater is allowed to create objects ; then call super class to duplicate floater ; GrObjDeref di,ds,si mov cl,ds:[di].GOVGI_flags andnf cl,mask GOVGF_CREATE_MODE cmp cl,GOVGCM_NO_CREATE je unprocessed callSuper: mov di, offset GrObjVisGuardianClass CallSuper MSG_GO_LARGE_START_SELECT done: .leave ret attemptFloaterEdit: call GrObjVisGuardianEvaluateEditGrabForEdit call GrObjVisGuardianAttemptToEditOther cmp bl,GOAEOR_NOTHING_TO_EDIT je checkFloaterCreate cmp bl,GOAEOR_EAT_START_SELECT je unprocessed call GrObjVisGuardianStartSelectToEditGrab jmp done unprocessed: clr ax jmp done document: ; Object in document has received start select. ; test ds:[di].GOI_actionModes, mask GOAM_CREATE jnz creating test ds:[di].GOI_tempState,mask GOTM_EDITED jz unprocessed test ds:[di].GOI_tempState,mask GOTM_SYS_TARGET jz unprocessed sendToWard: push ax mov ax, MSG_GOVG_RULE_LARGE_START_SELECT_FOR_WARD call ObjCallInstanceNoLock pop ax call GrObjVisGuardianHaveBodyGrabTargetAndFocus call GrObjVisGuardianSendGrObjMouseMessageToVisWard jmp done creating: ; If the guardian should control create then call ; the super class to start a drag create ; mov cl,ds:[di].GOVGI_flags andnf cl,mask GOVGF_CREATE_MODE cmp cl,GOVGCM_GUARDIAN_CREATE je callSuper ; Object in document in create mode has received a ; start select. if the action is activated, then ; mark happening and proceed. Otherwise bail because ; we never received a MSG_GO_BEGIN_CREATE. ; test ds:[di].GOI_actionModes, mask GOAM_ACTION_ACTIVATED jz unprocessed ; ; clear GOAM_ACTION_ACTIVATED and set GOAM_ACTION_HAPPENING ; xornf ds:[di].GOI_actionModes, mask GOAM_ACTION_ACTIVATED or \ mask GOAM_ACTION_HAPPENING jmp sendToWard GrObjVisGuardianLargeStartSelect endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianHaveBodyGrabTargetAndFocus %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send message to body telling it to grab target and focus. This routine is called just before sending a start select to the ward. Most wards grab the target when they get a start select, but if the body hasn't grabbed the target from it's parent then the ward won't be able to gain the target. This should only be a problem if the user has been working in another application and then moves back over a body and clicks in it. One would expect that the body would just grab the target when it got a start select, but the edit text guardian is not supposed to grab the target unless it really is going to edit something. CALLED BY: INTERNAL GrObjVisGuardianLargeStartSelect PASS: *ds:si - guardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/11/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianHaveBodyGrabTargetAndFocus proc near uses ax,di .enter EC < call ECGrObjVisGuardianCheckLMemObject > mov ax,MSG_GB_GRAB_TARGET_FOCUS mov di,mask MF_FIXUP_DS call GrObjMessageToBody EC < ERROR_Z GROBJ_CANT_SEND_MESSAGE_TO_BODY > .leave ret GrObjVisGuardianHaveBodyGrabTargetAndFocus endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianLargeStartMoveCopy %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle start MoveCopy event. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ax - Message ss:bp - GrObjMouseData RETURN: ax - MouseReturnFlags if MRF_SET_POINTER_IMAGE cx:dx - optr of pointer image else cx,dx - DESTROYED DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianLargeStartMoveCopy method dynamic GrObjVisGuardianClass, MSG_GO_LARGE_START_MOVE_COPY, MSG_GO_LARGE_END_MOVE_COPY .enter ; ; If we're the floater, hooey it ; test ds:[di].GOI_optFlags, mask GOOF_FLOATER jnz done ; Object in document has received start MoveCopy. ; test ds:[di].GOI_tempState,mask GOTM_EDITED jz unprocessed test ds:[di].GOI_tempState,mask GOTM_SYS_TARGET jz unprocessed call GrObjVisGuardianSendGrObjMouseMessageToVisWard done: .leave ret unprocessed: clr ax jmp done GrObjVisGuardianLargeStartMoveCopy endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianAttemptToEditOther %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determine if some other object is more interested in the edit point than the edit grab. If so, give it the edit grab. CALLED BY: INTERNAL GrObjVisGuardianLargeStartSelect EditTextGuardianLargeStartSelect PASS: *ds:si - grobjVisGuardian ss:bp - GrObjMouseData bl - EvaluatePositionRating of edit grab RETURN: bl - GrObjAttemptToEditOtherResults DESTROYED: bh PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/13/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjAttemptEditOtherResults etype byte GOAEOR_EDIT_GRAB_SET enum GrObjAttemptEditOtherResults GOAEOR_NOTHING_TO_EDIT enum GrObjAttemptEditOtherResults GOAEOR_EAT_START_SELECT enum GrObjAttemptEditOtherResults GrObjVisGuardianAttemptToEditOther proc far uses ax,cx,dx,di,si .enter EC < call ECGrObjVisGuardianCheckLMemObject > ; If edit grabs evaluation is high we can't beat it. ; cmp bl, EVALUATE_HIGH je edit call GrObjVisGuardianGetObjectUnderPointToEdit jcxz noOther ; If priority of other object is not greater than ; the edit grab priority then edit the edit grab ; cmp al,bl ;other priority, edit priority jle edit ; Send message to object to put it in edit mode. ; push si ;floater chunk mov bx,cx ;object to edit handle mov si,dx ;object to edit chunk mov di,mask MF_FIXUP_DS mov ax,MSG_GO_BECOME_EDITABLE call ObjMessage pop si ;floater chunk ; See if the floater should starting editing the object with this ; start select or if it should just make the object ; editable. This is mainly for the beginner poly* tools ; which would add an anchor point at a the location of ; the click if we edited them right away. ; mov ax,MSG_GOVG_CHECK_FOR_EDIT_WITH_FIRST_START_SELECT call ObjCallInstanceNoLock jnc eatStartSelect edit: mov bl,GOAEOR_EDIT_GRAB_SET done: .leave ret eatStartSelect: mov bl,GOAEOR_EAT_START_SELECT jmp done noOther: ; There is no other object to edit, if the edit grab ; is even remotely interested then edit it ; cmp bl,EVALUATE_NONE jne edit mov bl,GOAEOR_NOTHING_TO_EDIT jmp done GrObjVisGuardianAttemptToEditOther endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianCheckForEditWithFirstStartSelect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Default handler returns carry set to signify the object should be edited with the first start select. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: stc - edit with this start select DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianCheckForEditWithFirstStartSelect method dynamic\ GrObjVisGuardianClass, MSG_GOVG_CHECK_FOR_EDIT_WITH_FIRST_START_SELECT .enter stc .leave ret GrObjVisGuardianCheckForEditWithFirstStartSelect endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGetObjectUnderPointToEdit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get OD of object that the guardian can edit that is under the passed point CALLED BY: INTERNAL UTILITY PASS: *ds:si - grobjVisGuardian ss:bp - GrObjMouseData RETURN: ^lcx:dx - object to edit al - EvaluatePositionNotes or cx:dx = 0 if no object DESTROYED: ah PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGetObjectUnderPointToEdit proc far .enter ; See if click is on object of class that we can edit. ; We process all objects, regardless of class, so that ; we don't edit objects of our class that are blocked out by ; objects on top of them. ; mov ax,MSG_GO_EVALUATE_PARENT_POINT_FOR_EDIT mov cx,1 ;return only one object mov dl, mask PLI_ONLY_INSERT_CLASS or \ mask PLI_ONLY_INSERT_HIGH call GrObjVisGuardianInitAndFillPriorityList ; Get od of object to edit and priority ; clr cx ;first child mov ax,MSG_GB_PRIORITY_LIST_GET_ELEMENT mov di,mask MF_CALL or mask MF_FIXUP_DS call GrObjMessageToBody jbe noObject ;if carry or zero then ;we have no object done: .leave ret noObject: clr cx,dx jmp done GrObjVisGuardianGetObjectUnderPointToEdit endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianEvaluateEditGrabForEdit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determine if current edit grab is interested in start select and is of correct class CALLED BY: INTERNAL GrObjVisGuardianLargeStartSelect PASS: *ds:si - objectVisGuardian ss:bp - GrObjMouseData RETURN: bl - EvaluatePositionRating DESTROYED: bh PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 8/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianEvaluateEditGrabForEdit proc far class GrObjVisGuardianClass uses ax,cx,dx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject > ; If edit object is not of same class as guardians vis ward ; then punt. ; mov ax,MSG_GOVG_GET_EDIT_CLASS call ObjCallInstanceNoLock push bp mov ax,MSG_META_IS_OBJECT_IN_CLASS mov di,mask MF_FIXUP_DS or mask MF_CALL call GrObjMessageToEdit pop bp jz none ;jmp if no edit grab jnc none ;jmp if not of class ; Get and return evaluation of point from edit grab ; mov ax,MSG_GO_EVALUATE_PARENT_POINT_FOR_EDIT mov dx,size PointDWFixed mov di,mask MF_FIXUP_DS or mask MF_CALL or mask MF_STACK call GrObjMessageToEdit mov bl,al done: .leave ret none: mov bl,EVALUATE_NONE jmp done GrObjVisGuardianEvaluateEditGrabForEdit endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianStartSelectToEditGrab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: START_SELECT was received by the floater with an active ward. Attempt to edit currently editing object, else attempt to edit object of same class under point. CALLED BY: INTERNAL GrObjVisGuardianLargeStartSelect PASS: *ds:si - objectVisGuardian ss:bp - GrObjMouseData RETURN: ax - MouseReturnFlags cx, dx - data DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/13/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianStartSelectToEditGrab proc far uses di .enter EC < call ECGrObjVisGuardianCheckLMemObject > call GrObjVisGuardianHaveBodyGrabTargetAndFocus ; Update the edit grab with any stored data. ; This will get things like the bitmap tool class ; to the BitmapGuardian and its Bitmap vis ward. ; mov ax,MSG_GOVG_UPDATE_EDIT_GRAB_WITH_STORED_DATA call ObjCallInstanceNoLock ; Send start select on to editable object ; mov ax,MSG_GO_LARGE_START_SELECT mov di,mask MF_FIXUP_DS or mask MF_CALL or mask MF_STACK mov dx,size GrObjMouseData call GrObjMessageToEdit .leave ret GrObjVisGuardianStartSelectToEditGrab endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianLargePtr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Either pass message on to super class or to vis ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ss:bp - GrObjMouseData RETURN: ax - MouseReturnFlags if MRF_SET_POINTER_IMAGE cx:dx - optr of pointer image else cx,dx - DESTROYED DESTROYED: see RETURN PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianLargePtr method dynamic GrObjVisGuardianClass, MSG_GO_LARGE_DRAG_SELECT, MSG_GO_LARGE_PTR .enter ; Floater shouldn't be handling these events so ; just eat it. ; test ds:[di].GOI_optFlags,mask GOOF_FLOATER jnz setPointerImage ; Guardian in document received ptr event. ; If we are being edited then ward must be handling mouse events, ; so send mouse event to ward ; test ds:[di].GOI_tempState,mask GOTM_EDITED jz checkCreate test ds:[di].GOI_tempState,mask GOTM_SYS_TARGET jnz sendToWard checkCreate: ; If we are not in create mode then we don't know what is ; going on, so punt to superclass ; test ds:[di].GOI_actionModes,mask GOAM_CREATE jz callSuper ; If vis ward is controlling create then pass mouse ; event onto ward, otherwise call our superclass ; to continue drag open create ; mov cl,ds:[di].GOVGI_flags andnf cl,mask GOVGF_CREATE_MODE cmp cl,GOVGCM_VIS_WARD_CREATE je sendToWard callSuper: mov di, offset GrObjVisGuardianClass call ObjCallSuperNoLock done: .leave ret sendToWard: ; Send mouse event to vis ward so it can create/edit itself ; ; ; Let the ruler do what it will ; push ax mov ax, MSG_GOVG_RULE_LARGE_PTR_FOR_WARD call ObjCallInstanceNoLock pop ax call GrObjVisGuardianSendGrObjMouseMessageToVisWard jmp done setPointerImage: mov ax,MSG_GO_GET_POINTER_IMAGE call ObjCallInstanceNoLock ornf ax,mask MRF_PROCESSED jmp done GrObjVisGuardianLargePtr endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianLargeEndSelect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Either pass message on to super class or to vis ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ss:bp - GrObjMouseData RETURN: ax - MouseReturnFlags if MRF_SET_POINTER_IMAGE cx:dx - optr of pointer image else cx,dx - DESTROYED DESTROYED: see RETURN PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianLargeEndSelect method dynamic GrObjVisGuardianClass, MSG_GO_LARGE_END_SELECT .enter ; Floater shouldn't be handling these events so ; just eat it. ; test ds:[di].GOI_optFlags,mask GOOF_FLOATER jnz setPointerImage ; Guardian in document received ptr event. ; If we are being edited then ward must be handling mouse events, ; so send mouse event to ward ; test ds:[di].GOI_tempState,mask GOTM_EDITED jz checkCreate test ds:[di].GOI_tempState,mask GOTM_SYS_TARGET jnz sendToWard checkCreate: ; If we are not in create mode then we don't know what is ; going on, so punt to superclass ; test ds:[di].GOI_actionModes,mask GOAM_CREATE jz callSuper ; If vis ward is controlling create then pass mouse ; event onto ward, otherwise call our superclass ; to complete drag open create ; mov cl,ds:[di].GOVGI_flags andnf cl,mask GOVGF_CREATE_MODE cmp cl,GOVGCM_VIS_WARD_CREATE je sendToWard callSuper: mov di, offset GrObjVisGuardianClass call ObjCallSuperNoLock done: .leave ret sendToWard: ; Send mouse event to vis ward so it can create/edit itself ; ; ; Let the ruler do what it will ; push ax mov ax, MSG_GOVG_RULE_LARGE_END_SELECT_FOR_WARD call ObjCallInstanceNoLock pop ax call GrObjVisGuardianSendGrObjMouseMessageToVisWard jmp done setPointerImage: mov ax,MSG_GO_GET_POINTER_IMAGE call ObjCallInstanceNoLock ornf ax,mask MRF_PROCESSED push ax ;MouseReturnFlags mov ax,MSG_GO_RELEASE_MOUSE call ObjCallInstanceNoLock pop ax ;MouseReturnFlags jmp done GrObjVisGuardianLargeEndSelect endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianRuleLargeStartSelectForWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObjVisGuardian method for MSG_GOVG_RULE_LARGE_START_SELECT_FOR_WARD Called by: MSG_GOVG_RULE_LARGE_START_SELECT_FOR_WARD Pass: *ds:si = GrObjVisGuardian object ds:di = GrObjVisGuardian instance Return: nothing Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon Jan 20, 1993 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianRuleLargeStartSelectForWard method dynamic GrObjVisGuardianClass, MSG_GOVG_RULE_LARGE_START_SELECT_FOR_WARD uses cx .enter mov cx, mask VRCS_SET_REFERENCE call GrObjVisGuardianRuleCommon .leave ret GrObjVisGuardianRuleLargeStartSelectForWard endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianRuleLargeEndSelectForWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: GrObjVisGuardian method for MSG_GOVG_RULE_LARGE_END_SELECT_FOR_WARD Called by: MSG_GOVG_RULE_LARGE_END_SELECT_FOR_WARD Pass: *ds:si = GrObjVisGuardian object ds:di = GrObjVisGuardian instance Return: nothing Destroyed: ax Comments: Revision History: Name Date Description ---- ------------ ----------- jon Jan 20, 1993 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianRuleLargeEndSelectForWard method dynamic GrObjVisGuardianClass, MSG_GOVG_RULE_LARGE_END_SELECT_FOR_WARD, MSG_GOVG_RULE_LARGE_PTR_FOR_WARD uses cx .enter clr cx call GrObjVisGuardianRuleCommon .leave ret GrObjVisGuardianRuleLargeEndSelectForWard endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianRuleCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: Pass: *ds:si - guardian ss:[bp] - GrObjMouseData ax - grobj mouse message cx - mask VRCS_SET_REFERENCE if so desired; 0 otherwise Return: ss:[bp] - point ruled if applicable Destroyed: nothing Comments: Revision History: Name Date Description ---- ------------ ----------- jon May 25, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianRuleCommon proc near uses ax, cx, di .enter test ss:[bp].GOMD_goFA, mask GOFA_SNAP_TO or mask GOFA_CONSTRAIN jnz checkSnap ; ; Pass the mouse event on anyway, so that ruler feedback shows ; while manipulating the ward ; sendToRuler: ornf cx, mask VRCS_OVERRIDE mov ax, MSG_VIS_RULER_RULE_LARGE_PTR mov di, mask MF_FIXUP_DS call GrObjMessageToRuler .leave ret checkSnap: test ss:[bp].GOMD_goFA, mask GOFA_SNAP_TO jz doGuides ;must be guides ornf cx, VRCS_SNAP_TO_GRID_ABSOLUTE or VRCS_SNAP_TO_GUIDES test ss:[bp].GOMD_goFA, mask GOFA_CONSTRAIN jz sendToRuler doGuides: ornf cx, VRCS_CONSTRAIN_TO_HV_AXES or VRCS_CONSTRAIN_TO_DIAGONALS jmp sendToRuler GrObjVisGuardianRuleCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianSendGrObjMouseMessageToVisWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert GrObj Mouse Message to a system mouse message and send to visual ward CALLED BY: INTERNAL GrObjVisGuardianLargeStartSelect GrObjVisGuardianLargeDragSelect GrObjVisGuardianLargePtr GrObjVisGuardianLargeEndSelect PASS: *ds:si - GrObjVisGuardian ss:bp - GrObjMouseData ax - GrObj Message RETURN: ax - MouseReturnFlags if MRF_SET_POINTER_IMAGE cx:dx - optr of pointer image else cx,dx - DESTROYED DESTROYED: see RETURN PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianSendGrObjMouseMessageToVisWard proc far class GrObjVisGuardianClass uses bx,bp,di .enter ; Always convert mouse event to large data structure ; mov cx,bp sub sp,size LargeMouseData mov bp,sp push ax ;grobj message mov ax,MSG_GOVG_CONVERT_LARGE_MOUSE_DATA call ObjCallInstanceNoLock pop ax ;grobj message GrObjDeref di,ds,si test ds:[di].GOVGI_flags, mask GOVGF_LARGE jnz reallyLarge ; If ward really wants small mouse event then ; take data from LargeMouseData stack frame and ; pass it in registers to ward ; mov_tr cx,ax ;grobj message CallMod GrObjConvertGrObjMouseMessageToSmall mov cx, ss:[bp].LMD_location.PDF_x.DWF_int.low mov bx, ss:[bp].LMD_location.PDF_x.DWF_frac rndwwf cxbx mov dx, ss:[bp].LMD_location.PDF_y.DWF_int.low mov bx, ss:[bp].LMD_location.PDF_y.DWF_frac rndwwf dxbx mov bh,ss:[bp].LMD_uiFunctionsActive mov bl,ss:[bp].LMD_buttonInfo mov bp, bx send: ; Send mouse message to ward, using MF_CALL so that ward ; can return MouseReturnFlags ; mov di, mask MF_FIXUP_DS or mask MF_CALL call GrObjVisGuardianMessageToVisWard add sp,size LargeMouseData .leave ret reallyLarge: ; Ward wanting large mouse events is not handled yet ; mov_tr cx,ax ;grobj mouse message CallMod GrObjConvertGrObjMouseMessageToLarge jmp send GrObjVisGuardianSendGrObjMouseMessageToVisWard endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianConvertLargeMouseData %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert data in GrObjMouseData to LargeMouseData PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ss:cx - GrObjMouseData - GOMD_point - in PARENT coords GOMD_gstate - not used GOMD_goFA - GOMD_buttonInfo - from orig system mouse event GOMD_uiFA - from orig system mouse event ss:bp - LargeMouseData - empty RETURN: ss:bp - LargeMouseData LMD_location - in vis bounds coordinate system of ward LMD_buttonInfo LMD_uiFA DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: WARNING: This routine takes data on two different areas of the stack and it returns data on the stack so it may only be called from the same thread REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianConvertLargeMouseData method dynamic GrObjVisGuardianClass, MSG_GOVG_CONVERT_LARGE_MOUSE_DATA uses ax,cx,dx .enter mov bx,cx ;GrObjMouseData offset ; Copy point to LargeMouseData ; push ds,si ;object ptr mov ax,ss mov ds,ax ;source segment mov es,ax ;dest segment lea si, [bx.GOMD_point] ;source offset lea di, [bp.LMD_location] ;dest offset MoveConstantNumBytes <size PointDWFixed> ,cx pop ds,si ;object ptr ; Untransform the document coordinate mouse postion into ; the vis coordinates of ward ; clr di call GrCreateState call GrObjApplyNormalTransform mov dx,di ;gstate call GrObjVisGuardianOptApplyOBJECTToVISTransform mov dx,bp ;LargeMouseData call GrUntransformDWFixed call GrDestroyState ; Copy ButtonInfo and UIFA into LargeMouseData ; mov cl,ss:[bx].GOMD_uiFA ornf cl,mask UIFA_IN mov ss:[bp].LMD_uiFunctionsActive,cl mov cl,ss:[bx].GOMD_buttonInfo mov ss:[bp].LMD_buttonInfo,cl .leave ret GrObjVisGuardianConvertLargeMouseData endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianInitAndFillPriorityList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initialize PriorityList and fill it with objects that can be edited by the guardian CALLED BY: INTERNAL GrObjVisGuardianAttemptToEditOther PASS: *(ds:si) - pointer instance data ss:bp - PointDWFixed ax - method cx - max elements dl - PriorityListInstructions RETURN: PriorityListChanged DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 6/10/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianInitAndFillPriorityList proc near class GrObjVisGuardianClass uses ax,bx,cx,dx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject > push ax,cx,dx mov ax,MSG_GOVG_GET_EDIT_CLASS call ObjCallInstanceNoLock movdw bxdi,cxdx pop ax,cx,dx call GrObjGlobalInitAndFillPriorityList .leave ret GrObjVisGuardianInitAndFillPriorityList endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGainedTargetExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pass gained target onto the ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardian RETURN: none DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/14/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGainedTargetExcl method dynamic GrObjVisGuardianClass, MSG_META_GAINED_TARGET_EXCL .enter call GrObjVisGuardianIncVisWardsInteractibleCount ; We need body to be suspended so that we don't get multiple ; ui updates as selected objects become unselected and this ; object becomes editable. ; HACK. Because we are suspending body after gaining ; target this object will receive a MSG_META_SUSPEND from the ; body. But when this object sends MSG_META_GAINED_TARGET_EXCL ; to its superclass, the superclass handler will send a ; MSG_META_SUSPEND to the object for each time the body ; is suspended. One of those MSG_META_SUSPENDs this object ; already received directly from the body. So we got it ; twice. Counteract it by sending an MSG_META_UNSUSPEND ; to ourself. ; clr di mov ax, MSG_GB_IGNORE_UNDO_ACTIONS_AND_SUSPEND call GrObjMessageToBody mov ax,MSG_META_UNSUSPEND call ObjCallInstanceNoLock mov ax, MSG_META_GAINED_TARGET_EXCL mov di, offset GrObjVisGuardianClass call ObjCallSuperNoLock mov ax,MSG_META_GAINED_TARGET_EXCL mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard mov ax, MSG_GB_UNSUSPEND_AND_ACCEPT_UNDO_ACTIONS clr di call GrObjMessageToBody ; Must do this last because the spline changes its ; bounds upon gaining of target. ; Not marking the object dirty on purpose, because ; object can't be discard while it is being edited. ; GrObjDeref di,ds,si BitClr ds:[di].GOVGI_flags, GOVGF_VIS_BOUNDS_HAVE_CHANGED .leave Destroy ax,cx,dx,bp ret GrObjVisGuardianGainedTargetExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianLostTargetExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Passed lost target onto the ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/18/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianLostTargetExcl method dynamic GrObjVisGuardianClass, MSG_META_LOST_TARGET_EXCL .enter test ds:[di].GOI_tempState, mask GOTM_EDITED jz done ; We need to be suspended so that we don't get two updates. ; One from this object losing the target and the other ; from this object becoming selected. ; HACK. Because we are suspending body while we have the ; target this object will receive a MSG_META_SUSPEND from the ; body. But when this object sends MSG_META_LOST_TARGET_EXCL ; to its superclass, the superclass handler will send a ; MSG_META_UNSUSPEND to the object for each time the body ; is suspended. One of those MSG_META_UNSUSPENDs this object ; isn't supposed to have received yet because this object ; hasn't unsuspended the body yet. So we have received ; a MSG_META_UNSUSPEND ahead of time. To counteract this ; so that we can sucessfully unsuspend the body we ; need to suspend just ourselves one more time. ; clr di mov ax, MSG_GB_IGNORE_UNDO_ACTIONS_AND_SUSPEND call GrObjMessageToBody mov ax,MSG_META_SUSPEND call ObjCallInstanceNoLock mov ax,MSG_META_LOST_TARGET_EXCL mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock mov ax,MSG_META_LOST_TARGET_EXCL mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard call GrObjVisGuardianDecVisWardsInteractibleCount mov ax, MSG_GB_UNSUSPEND_AND_ACCEPT_UNDO_ACTIONS clr di call GrObjMessageToBody call GrObjVisGuardianSendResizeActionNotificationIfBoundsChanged done: .leave Destroy ax,cx,dx,bp ret GrObjVisGuardianLostTargetExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianReleaseExcls %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Tell our ward to release the gadget exclusive PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- jdashe 3/29/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianReleaseExcls method dynamic GrObjVisGuardianClass, MSG_GO_RELEASE_EXCLS uses cx,dx .enter ; In case the ward has the gadget, tell the body to ; take the gadget away from it. ; movdw cxdx,ds:[di].GOVGI_ward mov ax, MSG_VIS_RELEASE_GADGET_EXCL mov di, mask MF_FIXUP_DS call GrObjMessageToBody mov ax, MSG_GO_RELEASE_EXCLS mov di, offset GrObjVisGuardianClass call ObjCallSuperNoLock .leave Destroy ax ret GrObjVisGuardianReleaseExcls endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianIncVisWardsInteractibleCount %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Increment the interactible count of the block that the vis ward is in. This is normally used when the the guardian gains the target or focus so that the ward won't be discarded while targeted or focused CALLED BY: INTERNAL GrObjVisGuardianGainedTargetExcl GrObjVisGuardianGainedFocusExcl PASS: *ds:si - guardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: wards is in same block as guardian REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/ 3/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianIncVisWardsInteractibleCount proc far class GrObjVisGuardianClass uses ax,bx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject EC < push si > ; If the ward is in the same block as the guardian then ; no need to lock the ward block ; GrObjDeref di,ds,si mov bx,ds:[di].GOVGI_ward.handle tst bx jz done EC < mov si,ds:[di].GOVGI_ward.chunk > cmp bx,ds:[LMBH_handle] jne notSameBlock call ObjIncInteractibleCount done: EC < pop si > .leave ret notSameBlock: push ds ;guardian segment call ObjLockObjBlock ;lock ward block mov ds,ax ;ward segment call ObjIncInteractibleCount ;wards interactible call MemUnlock ;unlock ward block pop ds ;guardian segment jmp done GrObjVisGuardianIncVisWardsInteractibleCount endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianDecVisWardsInteractibleCount %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Decrement the interactible count of the block that the vis ward is in. This is normally used when the the guardian loses the target or focus to counteract the incing when the target or focus was gained. CALLED BY: INTERNAL GrObjVisGuardianLostTargetExcl GrObjVisGuardianLostFocusExcl PASS: *ds:si - guardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: wards is in same block as guardian REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/ 3/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianDecVisWardsInteractibleCount proc far class GrObjVisGuardianClass uses ax,bx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject EC < push si > ; If the ward is in the same block as the guardian then ; no need to lock the ward block ; GrObjDeref di,ds,si mov bx,ds:[di].GOVGI_ward.handle tst bx jz done EC < mov si,ds:[di].GOVGI_ward.chunk > cmp bx,ds:[LMBH_handle] jne notSameBlock call ObjDecInteractibleCount done: EC < pop si > .leave ret notSameBlock: push ds ;guardian segment call ObjLockObjBlock ;lock ward block mov ds,ax ;ward segment call ObjDecInteractibleCount ;wards interactible call MemUnlock ;unlock ward block pop ds ;guardian segment jmp done GrObjVisGuardianDecVisWardsInteractibleCount endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianSendResizeActionNotificationIfBoundsChanged %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: If the GOVGF_VIS_BOUNDS_CHANGED bit is set then clear the bit and send a GOANT_RESIZED action notification. CALLED BY: INTERNAL UTILITY PASS: *ds:si - GrObjVisGuardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianSendResizeActionNotificationIfBoundsChanged proc far class GrObjVisGuardianClass uses di .enter EC < call ECGrObjVisGuardianCheckLMemObject > GrObjDeref di,ds,si test ds:[di].GOVGI_flags, mask GOVGF_VIS_BOUNDS_HAVE_CHANGED jz done BitClr ds:[di].GOVGI_flags,GOVGF_VIS_BOUNDS_HAVE_CHANGED mov bp,GOANT_RESIZED call GrObjOptNotifyAction done: .leave ret GrObjVisGuardianSendResizeActionNotificationIfBoundsChanged endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianUpdateSysExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pass message onto ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown WARNING: This method is not dynamic REVISION HISTORY: Name Date Description ---- ---- ----------- srs 9/16/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianUpdateSysExcl method GrObjVisGuardianClass, MSG_META_GAINED_SYS_TARGET_EXCL, MSG_META_LOST_SYS_TARGET_EXCL, MSG_META_GAINED_SYS_FOCUS_EXCL, MSG_META_LOST_SYS_FOCUS_EXCL .enter push ax ;message mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock pop ax ;message mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave Destroy ax,cx,dx,bp ret GrObjVisGuardianUpdateSysExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGainedFocusExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Bad things happen if vis objects get discarded while they have the focus. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 6/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGainedFocusExcl method dynamic GrObjVisGuardianClass, MSG_META_GAINED_FOCUS_EXCL .enter call GrObjVisGuardianIncVisWardsInteractibleCount call GrObjVisGuardianUpdateSysExcl .leave ret GrObjVisGuardianGainedFocusExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianLostFocusExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Bad things happen if vis objects get discarded while they have the focus. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 6/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianLostFocusExcl method dynamic GrObjVisGuardianClass, MSG_META_LOST_FOCUS_EXCL .enter call GrObjVisGuardianUpdateSysExcl call GrObjVisGuardianDecVisWardsInteractibleCount .leave ret GrObjVisGuardianLostFocusExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianAlterFTVMCExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: If message is a grab target from our ward then grab the edit. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass cx:dx - optr to grab/release exclusive for bp - MetaAlterFTVMCExclFlags RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/12/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianAlterFTVMCExcl method dynamic GrObjVisGuardianClass, MSG_META_MUP_ALTER_FTVMC_EXCL .enter test bp, mask MAEF_NOT_HERE jnz callSuper ; If this is not for the target and focus then handle normally ; test bp, mask MAEF_TARGET jnz target checkFocus: test bp,mask MAEF_FOCUS jnz focus callSuper: ; Pass message on to superclass for handling outside of ; this class. ; test bp, MAEF_MASK_OF_ALL_HIERARCHIES jz done mov di, offset GrObjVisGuardianClass call ObjCallSuperNoLock done: Destroy ax,cx,dx,bp .leave ret target: mov ax,MSG_GO_BECOME_EDITABLE ;assume test bp, mask MAEF_GRAB jnz send mov ax,MSG_GO_BECOME_UNEDITABLE mov cl,SELECT_AFTER_EDIT send: call ObjCallInstanceNoLock BitClr bp, MAEF_TARGET jmp checkFocus focus: BitClr bp,MAEF_FOCUS test bp,mask MAEF_GRAB jz releaseFocus call GrObjCanEdit? jnc callSuper call MetaGrabFocusExclLow jmp callSuper releaseFocus: call MetaReleaseFocusExclLow jmp callSuper GrObjVisGuardianAlterFTVMCExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianSendClassedEvent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handler for a classed event passed via MSG_META_SEND_CLASSED_EVENT. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass cx - handle of ClassedEvent dx - TravelOptions RETURN: if Event delivered if MF_CALL ax,cx,dx,bp - from method DESTROYED: ax,cx,dx,bp - unless returned PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/16/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianSendClassedEvent method dynamic GrObjVisGuardianClass, \ MSG_META_SEND_CLASSED_EVENT .enter ; Guardian and its ward are generally consider one object ; so self may be sent to vis ward ; cmp dx,TO_SELF je checkWard ; Attempt to send the message to the vis ward for these ; travel options ; cmp dx, TO_TARGET je checkWard cmp dx, TO_FOCUS je checkWard callSuper: mov di, offset GrObjVisGuardianClass CallSuper MSG_META_SEND_CLASSED_EVENT done: .leave ret checkWard: ; If vis ward is not able to handle event then send message ; to superclass, otherwise send to ward. So that the ; ward can handle MSG_META_COPY and such we pass messages ; with a zero class to the ward. ; push ax,cx,dx ;message, event, TO mov bx,cx ;event handle mov dx,si ;guardian chunk call ObjGetMessageInfo xchg dx,si ;event class offset, guard chunk jcxz popToWard ;class segment push bp mov ax,MSG_META_IS_OBJECT_IN_CLASS mov di,mask MF_CALL or mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard pop bp pop ax,cx,dx ;message, event, TO jz callSuper ;jmp if no ward jnc callSuper ;jmp if ward not of class sendToWard: ; Send message to ward ; mov di,mask MF_CALL or mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard jmp done popToWard: pop ax,cx,dx ;message, event, TO jmp sendToWard GrObjVisGuardianSendClassedEvent endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianNotifyGrObjValid %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Notify object that it now has a valid normalTransform and attribute. The vis guardian needs to set up the geometry in its vis ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 3/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianNotifyGrObjValid method dynamic GrObjVisGuardianClass, MSG_GO_NOTIFY_GROBJ_VALID uses cx .enter ; Ignore if already valid ; test ds:[di].GOI_optFlags, mask GOOF_GROBJ_INVALID jz done mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock ; Do any initialization necessary for ward. ; mov ax,MSG_VIS_NOTIFY_GEOMETRY_VALID mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard done: .leave ret GrObjVisGuardianNotifyGrObjValid endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianNotifyGrObjInvalid %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Notify object that it is no longer valid. Mark ward as geometry invalid PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 3/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianNotifyGrObjInvalid method dynamic GrObjVisGuardianClass, MSG_GO_NOTIFY_GROBJ_INVALID .enter ; Ignore if already invalid ; test ds:[di].GOI_optFlags, mask GOOF_GROBJ_INVALID jnz done mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock call GrObjVisGuardianMarkVisWardGeometryInvalid done: .leave ret GrObjVisGuardianNotifyGrObjInvalid endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianMarkVisWardGeometryInvalid %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Mark the vis ward as having invalid geometry CALLED BY: INTERNAL UTILITY PASS: *ds:si - guardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/28/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianMarkVisWardGeometryInvalid proc far uses ax,cx,dx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject > mov ax,MSG_VIS_MARK_INVALID mov cl, mask VOF_GEOMETRY_INVALID mov dl, VUM_MANUAL mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave ret GrObjVisGuardianMarkVisWardGeometryInvalid endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianHaveWardDestroyCachedGStates %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: After the object has been transformed or translated when need to have the ward destroy any cached gstates, because those gstates will no longer map to proper place in the document. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass MSG_GO_COMPLETE_TRANSFORM bp - GrObjActionNotificationType MSG_GO_COMPLETE_TRANSLATE bp - GrObjActionNotificationType RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianHaveWardDestroyCachedGStates method dynamic \ GrObjVisGuardianClass, MSG_GO_COMPLETE_TRANSFORM, MSG_GO_COMPLETE_TRANSLATE uses ax .enter mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock mov ax,MSG_VIS_RECREATE_CACHED_GSTATES mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave ret GrObjVisGuardianHaveWardDestroyCachedGStates endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianVisBoundsSetup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This default handler for the VisGuardian sets the height and width of the vis ward to the OBJECT dimensions and notify the ward that its geometry is valid. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 9/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianVisBoundsSetup method dynamic GrObjVisGuardianClass, MSG_GOVG_VIS_BOUNDS_SETUP .enter call GrObjVisGuardianSetVisBoundsToOBJECTDimensions GrObjDeref di,ds,si test ds:[di].GOI_optFlags, mask GOOF_GROBJ_INVALID jnz done ; Objects will do any necessary calculations to handle their ; new geometry upon receiving this message. For instance ; text objects will re-wrap. ; mov di,mask MF_FIXUP_DS mov ax,MSG_VIS_NOTIFY_GEOMETRY_VALID call GrObjVisGuardianMessageToVisWard done: .leave ret GrObjVisGuardianVisBoundsSetup endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianSetVisBoundsToOBJECTDimensions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the vis bounds of the ward to match the OBJECT dimensions of the object CALLED BY: INTERNAL UTILITY PASS: *ds:si - guardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/28/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianSetVisBoundsToOBJECTDimensions proc far uses ax,bx,cx,dx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject > call GrObjGetAbsNormalOBJECTDimensions rndwwf dxcx rndwwf bxax mov cx,dx ;width mov dx,bx ;height mov ax,MSG_VIS_SET_SIZE mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave ret GrObjVisGuardianSetVisBoundsToOBJECTDimensions endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianCreateGState %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Create a gstate with the transformations of all groups above this object and its own transform PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: bp - gstate DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 7/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianCreateGState method dynamic GrObjVisGuardianClass, MSG_GOVG_CREATE_GSTATE .enter mov di,OBJECT_GSTATE call GrObjCreateGState mov dx,di ;gstate call GrObjVisGuardianOptApplyOBJECTToVISTransform mov bp,di ;gstate .leave ret GrObjVisGuardianCreateGState endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianSetVisWardMouseEventType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the type (large or small) of mouse event that the vis ward is interested in PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardian cl - VisWardMouseEventType RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 9/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianSetVisWardMouseEventType method dynamic \ GrObjVisGuardianClass, MSG_GOVG_SET_VIS_WARD_MOUSE_EVENT_TYPE .enter ; Assume small mouse events ; andnf ds:[di].GOVGI_flags, not mask GOVGF_LARGE ; If assumption correct then bail, otherwise deactive ; cmp cl,VWMET_SMALL je done ornf ds:[di].GOVGI_flags, mask GOVGF_LARGE done: .leave ret GrObjVisGuardianSetVisWardMouseEventType endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianQuickTotalBodyClear %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Must destroy the wards data in other blocks. The easiest way to do this is just to destroy the little pecker completely. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/22/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianQuickTotalBodyClear method dynamic GrObjVisGuardianClass, MSG_GO_QUICK_TOTAL_BODY_CLEAR .enter ; Normally MSG_META_OBJ_FREE would inc the in use count ; of the ward, but we are pulling a short cut here by ; just sending MSG_META_FINAL_OBJ_FREE, so we must ; inc the in use count ourselves. ; call GrObjVisGuardianIncVisWardsInUseCount mov di,mask MF_FIXUP_DS mov ax,MSG_META_FINAL_OBJ_FREE call GrObjVisGuardianMessageToVisWard mov di, offset GrObjVisGuardianClass mov ax,MSG_GO_QUICK_TOTAL_BODY_CLEAR call ObjCallSuperNoLock .leave ret GrObjVisGuardianQuickTotalBodyClear endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianFinalObjFree %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Generally guardian's do not flush their queue before sending themselves MSG_META_FINAL_OBJ_FREE. However, the vis wards always send MSG_META_FINAL_OBJ_FREE via the queue. So the ward my still exist after the guardian is gone. We must prevent the ward from attempt to send messages to the guardian. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/30/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianFinalObjFree method dynamic GrObjVisGuardianClass, MSG_META_FINAL_OBJ_FREE .enter clrdw cxdx mov di,mask MF_FIXUP_DS mov ax,MSG_GV_SET_GUARDIAN_LINK call GrObjVisGuardianMessageToVisWard mov ax,MSG_META_FINAL_OBJ_FREE mov di,offset GrObjVisGuardianClass call ObjCallSuperNoLock .leave ret GrObjVisGuardianFinalObjFree endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianClearVisWardOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Default handler PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/30/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianClearVisWardOD method dynamic GrObjVisGuardianClass, MSG_GOVG_CLEAR_VIS_WARD_OD .enter clr ax mov ds:[di].GOVGI_ward.handle,ax mov ds:[di].GOVGI_ward.chunk,ax .leave ret GrObjVisGuardianClearVisWardOD endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianIncVisWardsInUseCount %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Increment the in use count of the block that the vis ward is in. This is normally used when the the guardian gains the target or focus so that the ward won't be discarded while targeted or focused CALLED BY: INTERNAL GrObjVisGuardianQuickTotalBodyClear PASS: *ds:si - guardian RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: wards is in same block as guardian REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/ 3/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianIncVisWardsInUseCount proc near class GrObjVisGuardianClass uses ax,bx,di .enter EC < call ECGrObjVisGuardianCheckLMemObject EC < push si > ; If the ward is in the same block as the guardian then ; no need to lock the ward block ; GrObjDeref di,ds,si mov bx,ds:[di].GOVGI_ward.handle tst bx jz done EC < mov si,ds:[di].GOVGI_ward.chunk > cmp bx,ds:[LMBH_handle] jne notSameBlock call ObjIncInUseCount done: EC < pop si > .leave ret notSameBlock: push ds ;guardian segment call ObjLockObjBlock ;lock ward block mov ds,ax ;ward segment call ObjIncInUseCount ;wards interactible call MemUnlock ;unlock ward block pop ds ;guardian segment jmp done GrObjVisGuardianIncVisWardsInUseCount endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianMetaObjFree %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pass message onto vis ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/18/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianMetaObjFree method dynamic GrObjVisGuardianClass, MSG_META_OBJ_FREE mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard mov di,offset GrObjVisGuardianClass GOTO ObjCallSuperNoLock GrObjVisGuardianMetaObjFree endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianObjFree %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Free an object *now* PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/18/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianObjFree method dynamic GrObjVisGuardianClass, MSG_GO_OBJ_FREE ; The Vis Wards must always use the queue flushing messages. ; For instance the text object may have a flash cursor ; message in the queue. ; push ax mov ax, MSG_META_OBJ_FREE mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard pop ax mov di,offset GrObjVisGuardianClass GOTO ObjCallSuperNoLock GrObjVisGuardianObjFree endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianObjFreeGuaranteedNoQueuedMessages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Free an object *now* without queueing any messages. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/18/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianObjFreeGuaranteedNoQueuedMessages method dynamic \ GrObjVisGuardianClass, MSG_GO_OBJ_FREE_GUARANTEED_NO_QUEUED_MESSAGES push ax call GrObjVisGuardianIncVisWardsInUseCount mov ax, MSG_META_FINAL_OBJ_FREE mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard pop ax mov di,offset GrObjVisGuardianClass GOTO ObjCallSuperNoLock GrObjVisGuardianObjFreeGuaranteedNoQueuedMessages endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianNormalize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert the object into a rectangle with its GrObjTransMatrix as the Identity Matrix PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 4/ 7/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianNormalize method dynamic GrObjVisGuardianClass, MSG_GOVG_NORMALIZE .enter ; Calculate the bounds of the object in the PARENT ; coordinate system. Use the dimensions of the ; bounds as the width and height ; sub sp,size BoundingRectData mov bp,sp mov di,PARENT_GSTATE call GrObjCreateGStateForBoundsCalc mov ss:[bp].BRD_parentGState,di mov di,PARENT_GSTATE call GrObjCreateGStateForBoundsCalc mov ss:[bp].BRD_destGState,di mov ax,MSG_GO_GET_BOUNDING_RECTDWFIXED call ObjCallInstanceNoLock CallMod GrObjGlobalGetWWFixedDimensionsFromRectDWFixed EC < ERROR_NC BUG_IN_DIMENSIONS_CALC > mov di,ss:[bp].BRD_parentGState call GrDestroyState mov di,ss:[bp].BRD_destGState call GrDestroyState add sp, size BoundingRectData rndwwf dxcx rndwwf bxax clr ax, cx call GrObjSetOBJECTDimensionsAndIdentityMatrix .leave ret GrObjVisGuardianNormalize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianNotifyVisWardChangeBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Notify the guardian that the vis ward wishes to changes its vis bounds. This default handler sets the OBJECT dimensions to match the desired vis bounds. Moves the grobj the amount the vis bounds have moved. Sets the vis bounds of the ward. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass ss:bp - Rect, desired vis bounds RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 4/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianNotifyVisWardChangeBounds method dynamic GrObjVisGuardianClass, MSG_GOVG_NOTIFY_VIS_WARD_CHANGE_BOUNDS uses cx,dx moveDeltas local PointDWFixed mov bx, bp ;ss:bx <- passed Rect .enter call GrObjVisGuardianBeginEditGeometryCommon GrObjDeref di,ds,si BitSet ds:[di].GOVGI_flags, GOVGF_VIS_BOUNDS_HAVE_CHANGED ; Set OBJECT dimensions from the new VisBounds ; mov dx, ss:[bx].R_right sub dx, ss:[bx].R_left mov ax, ss:[bx].R_bottom sub ax, ss:[bx].R_top push bx ;passed frame offset mov_tr bx,ax ;height int clr ax, cx ;height/width frac call GrObjSetNormalOBJECTDimensions pop bx ;passed frame offset ; Calculate the delta from the original vis bound center ; to the new vis bounds center. ; clr ax mov cx, ss:[bx].R_right add cx, ss:[bx].R_left sarwwf cxax movwwf ({WWFixed}ss:moveDeltas.PDF_x.DWF_frac),cxax clr ax mov cx, ss:[bx].R_bottom add cx, ss:[bx].R_top sarwwf cxax movwwf ({WWFixed}ss:moveDeltas.PDF_y.DWF_frac),cxax call GrObjVisGuardianGetWardWWFixedCenter subwwf ({WWFixed}ss:moveDeltas.PDF_x.DWF_frac),dxcx subwwf ({WWFixed}ss:moveDeltas.PDF_y.DWF_frac),bxax ; Convert to PointDWFixed ; mov ax,moveDeltas.PDF_x.DWF_int.low cwd mov moveDeltas.PDF_x.DWF_int.high,dx mov ax,moveDeltas.PDF_y.DWF_int.low cwd mov moveDeltas.PDF_y.DWF_int.high,dx ; Convert center delta into PARENT coords. ; We don't need to include the transformation from ; vis to object because we are setting the object dimensions ; to equal the vis bounds. ; clr di ;no window call GrCreateState mov dx,di ;gstate call GrObjApplyNormalTransformSansCenterTranslation segmov es,ss lea dx,ss:moveDeltas call GrTransformDWFixed mov dx,di ;gstate call GrDestroyState push bp ;locals frame lea bp, ss:moveDeltas call GrObjMoveNormalRelative pop bp ;locals frame ; This leave restores the passed bp which has the ; Rectangle in it. ; .leave ; Actually change bounds of ward ; mov ax, MSG_GV_SET_VIS_BOUNDS mov di,mask MF_FIXUP_DS or mask MF_STACK mov dx, size Rectangle call GrObjVisGuardianMessageToVisWard mov ax,MSG_GO_CALC_PARENT_DIMENSIONS call ObjCallInstanceNoLock call GrObjVisGuardianEndEditGeometryCommon ret GrObjVisGuardianNotifyVisWardChangeBounds endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianBeginEditGeometryCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform some common functionality for the methods the do geometry manipulations on a grobject CALLED BY: INTERNAL UTILITY PASS: *ds:si - GrObject RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/21/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianBeginEditGeometryCommon proc far uses ax,di,dx .enter EC < call ECGrObjCheckLMemObject > ; Get gstate to pass with handle drawing messages ; mov di,BODY_GSTATE call GrObjCreateGState mov dx,di ;gstate ; Erase handle of object in case it is selected ; mov ax,MSG_GO_UNDRAW_HANDLES call ObjCallInstanceNoLock mov ax,MSG_GO_UNDRAW_EDIT_INDICATOR call ObjCallInstanceNoLock ; If we are being edited then let the object ; do any necessary invalidations to allow for ; object specific optimizations. ; GrObjDeref di,ds,si test ds:[di].GOI_tempState,mask GOTM_EDITED jz invalidate destroy: mov di,dx call GrDestroyState .leave ret invalidate: call GrObjOptInvalidate jmp destroy GrObjVisGuardianBeginEditGeometryCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianEndEditGeometryCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform some common functionality for the methods the do geometry manipulations on a grobject CALLED BY: INTERNAL UTILITY PASS: *ds:si - GrObject RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/21/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianEndEditGeometryCommon proc far uses ax,di,dx .enter EC < call ECGrObjCheckLMemObject > ; Get gstate to pass with handle drawing messages ; mov di,BODY_GSTATE call GrObjCreateGState mov dx,di ;gstate ; Redraw handles of object if it is selected ; mov ax,MSG_GO_DRAW_HANDLES call ObjCallInstanceNoLock mov ax,MSG_GO_DRAW_EDIT_INDICATOR call ObjCallInstanceNoLock ; If we are being edited then let the object ; do any necessary invalidations to allow for ; object specific optimizations. ; GrObjDeref di,ds,si test ds:[di].GOI_tempState,mask GOTM_EDITED jz invalidate destroy: mov di,dx call GrDestroyState .leave ret invalidate: call GrObjOptInvalidate jmp destroy GrObjVisGuardianEndEditGeometryCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGetVisWardOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return OD of vis ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: cx:dx - od DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 5/14/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGetVisWardOD method dynamic GrObjVisGuardianClass, MSG_GOVG_GET_VIS_WARD_OD .enter movdw cxdx,ds:[di].GOVGI_ward .leave ret GrObjVisGuardianGetVisWardOD endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianRecreateCachedGStates %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pass message onto ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax,cx,dx,bp PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 8/26/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianRecreateCachedGStates method dynamic GrObjVisGuardianClass, MSG_GO_RECREATE_CACHED_GSTATES .enter mov ax,MSG_VIS_RECREATE_CACHED_GSTATES mov di,mask MF_FIXUP_DS call GrObjVisGuardianMessageToVisWard .leave Destroy ax,cx,dx,bp ret GrObjVisGuardianRecreateCachedGStates endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianRoundOBJECTDimensions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Round width and height so that the OBJECT dimensions can match up with the interger vis bounds of the ward CALLED BY: INTERNAL UTILITY PASS: *ds:si - object RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 9/ 3/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianRoundOBJECTDimensions proc far uses ax,bx,cx,dx .enter EC < call ECGrObjVisGuardianCheckLMemObject > call GrObjGetNormalOBJECTDimensions rndwwf dxcx rndwwf bxax clr ax,cx call GrObjSetNormalOBJECTDimensions .leave ret GrObjVisGuardianRoundOBJECTDimensions endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianQuickTransferTakeMouseGrabIfPossible %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Decides if this VisGuardian object should take the mouse grab. This is called during a quick transfer when the body has the grab but there is also an object within the body that has the target exclusive. CALLED BY: MSG_GO_QUICK_TRANSFER_TAKE_MOUSE_GRAB_IF_POSSIBLE PASS: *ds:si = GrObjVisGuardianClass object ds:di = GrObjVisGuardianClass instance data ds:bx = GrObjVisGuardianClass object (same as *ds:si) es = segment of GrObjVisGuardianClass ax = message # ss:bp = LargeMouseData ^lcx:dx = optr to the owner of the Quick Transfer Object RETURN: carry: SET - Object was eligible and mouse was grabbed. CLEAR - Object was not eligible, mouse grab was not changed. DESTROYED: ax SIDE EFFECTS: May take mouse grab. NOT TO BE CALLED WITH MF_STACK. PSEUDO CODE/STRATEGY: 1) Check if this object's VisWard is the owner of the quick transfer object. 2) Check to see if the mouse's position is inside our bounds. If both of these are true, then take the mouse grab. REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 7/20/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianQuickTransferTakeMouseGrabIfPossible method dynamic \ GrObjVisGuardianClass, MSG_GO_QUICK_TRANSFER_TAKE_MOUSE_GRAB_IF_POSSIBLE uses cx, dx, bp .enter ; Check to see if the VisWard of this guardian is the owner of the ; quick transfer object. cmpdw ds:[di].GOVGI_ward, cxdx clc jne exit ; not affected by C ; Check to see if the mouse point is inside my bounds! ; Will return false if this object is the floater. mov bx, bp lea bp, ss:[bp].LMD_location mov ax, MSG_GO_IS_POINT_INSIDE_OBJECT_BOUNDS mov dx, size PointDWFixed call ObjCallInstanceNoLock mov bp, bx jnc exit ; not in bounds (clc) ; Okay.. we can now take the grab! Cool. mov ax, MSG_GO_GRAB_MOUSE call ObjCallInstanceNoLock ; SUCCESS! stc exit: .leave ret GrObjVisGuardianQuickTransferTakeMouseGrabIfPossible endm GrObjVisGuardianCode ends GrObjStyleSheetCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianStyleCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Description: Forwards any MSG_META_STYLED_OBJECT_* messages to the appropriate object(s). Pass: *ds:si - GrObjVisGuardian object ds:di - GrObjVisGuardian instance ax - MSG_META_STYLED_OBJECT_* (except RECALL_STYLE) cx,dx,bp - data Return: nothing Destroyed: nothing Comments: Revision History: Name Date Description ---- ------------ ----------- jon Apr 27, 1992 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianStyleCommon method dynamic GrObjVisGuardianClass, MSG_META_STYLED_OBJECT_REQUEST_ENTRY_MONIKER, MSG_META_STYLED_OBJECT_UPDATE_MODIFY_BOX, MSG_META_STYLED_OBJECT_MODIFY_STYLE, MSG_META_STYLED_OBJECT_DEFINE_STYLE, MSG_META_STYLED_OBJECT_REDEFINE_STYLE, MSG_META_STYLED_OBJECT_SAVE_STYLE, MSG_META_STYLED_OBJECT_LOAD_STYLE_SHEET, MSG_META_STYLED_OBJECT_DESCRIBE_STYLE, MSG_META_STYLED_OBJECT_DESCRIBE_ATTRS, MSG_META_STYLED_OBJECT_APPLY_STYLE, MSG_META_STYLED_OBJECT_RETURN_TO_BASE_STYLE, MSG_META_STYLED_OBJECT_DELETE_STYLE .enter push ax, cx, dx, bp movdw cxdx, ss:[bp] mov ax, MSG_META_IS_OBJECT_IN_CLASS call ObjCallInstanceNoLock pop ax, cx, dx, bp jnc checkWard ; ; It's a grobj style message; call the super class ; mov di, segment GrObjVisGuardianClass mov es, di mov di, offset GrObjVisGuardianClass call ObjCallSuperNoLock done: .leave ret checkWard: push ax, cx, dx, bp movdw cxdx, ss:[bp] mov ax, MSG_META_IS_OBJECT_IN_CLASS mov di, mask MF_CALL call GrObjVisGuardianMessageToVisWard pop ax, cx, dx, bp jnc done ; ; The style message is intended for the ward ; clr di call GrObjVisGuardianMessageToVisWard jmp done GrObjVisGuardianStyleCommon endm GrObjStyleSheetCode ends GrObjDrawCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianMessageToVisWard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send message to vis ward CALLED BY: INTERNAL GrObjVisGuardianSendGrObjMouseMessageToVisWard PASS: *ds:si - object ax - message cx,dx,bp - other data with message di - MessageFlags RETURN: if no vis ward return zero flag set else zero flag cleared if MF_CALL ax,cx,dx,bp no flags except carry otherwise nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianMessageToVisWard proc far class GrObjVisGuardianClass uses bx,si,di .enter EC < call ECGrObjVisGuardianCheckLMemObject > ; If no ward, then return with zero flag set ; GrObjDeref si,ds,si mov bx,ds:[si].GOVGI_ward.handle tst bx jz done mov si,ds:[si].GOVGI_ward.chunk ornf di, mask MF_FIXUP_DS call ObjMessage ; Clear zero flag to signify message being sent ; ClearZeroFlagPreserveCarry si done: .leave ret GrObjVisGuardianMessageToVisWard endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianOptApplyOBJECTToVISTransform %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSYS: Apply transformation from OBJECT coordinate system to the VIS to OBJECT coordinate system taking into account the GOVGF_APPLY_OBJECT_TO_VIS_TRANSFORM bit CALLED BY: INTERNAL UTILITY PASS: *ds:si - object dx - gstate RETURN: dx - gstate with transform applied DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: opt bit not set REVISION HISTORY: Name Date Description ---- ---- ----------- srs 8/27/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianOptApplyOBJECTToVISTransform proc far class GrObjVisGuardianClass uses di .enter EC < call ECGrObjVisGuardianCheckLMemObject > GrObjDeref di,ds,si test ds:[di].GOVGI_flags, mask GOVGF_APPLY_OBJECT_TO_VIS_TRANSFORM jnz send call GrObjVisGuardianApplyOBJECTToVISTransform done: .leave ret send: push ax mov ax,MSG_GOVG_APPLY_OBJECT_TO_VIS_TRANSFORM call ObjCallInstanceNoLock pop ax jmp done GrObjVisGuardianOptApplyOBJECTToVISTransform endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianApplyOBJECTToVISTransform %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Apply transformation from OBJECT coordinate system to the VIS coordinate system This will transform VIS coordinates into OBJECT coordinates PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass dx - gstate RETURN: dx - gstate with transform applied DESTROYED: nothing PSEUDO CODE/STRATEGY: The goal is to create a transformation to transform the vis bounds into a rectangle with the same dimensions as the object bounds with its center a 0,0. This default handler does the following A scale factor is calculated from the vis bounds to the object dimensions and then applied. Then the center of the vis bounds is translated to 0,0 KNOWN BUGS/SIDE EFFECTS/IDEAS: WARNING: This method is not dynamic, so the passed parameters are more limited and you must be careful what you destroy. REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianApplyOBJECTToVISTransform method GrObjVisGuardianClass, MSG_GOVG_APPLY_OBJECT_TO_VIS_TRANSFORM uses ax,bx,cx,bp,di .enter mov di,dx ;gstate ; Calc scale factor from vis bounds to object dimensions ; and apply it if both not 1.0 ; call GrObjVisGuardianCalcScaleFactorVISToOBJECT jc translate call GrApplyScale translate: ; Calc translation, (- center), and apply it ; push di ;gstate call GrObjVisGuardianGetWardWWFixedCenter negwwf dxcx negwwf bxax pop di ;gstate call GrApplyTranslation mov dx,di ;gstate .leave ret GrObjVisGuardianApplyOBJECTToVISTransform endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianApplySPRITEOBJECTToVISTransform %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Apply transformation from SPRITEOBJECT coordinate system to the VIS coordinate system This will transform VIS coordinates into SPRITEOBJECT coordinates PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass dx - gstate RETURN: dx - gstate with transform applied DESTROYED: nothing PSEUDO CODE/STRATEGY: The goal is to create a transformation to transform the vis bounds into a rectangle with the same dimensions as the object bounds with its center a 0,0. This default handler does the following A scale factor is calculated from the vis bounds to the object dimensions and then applied. Then the center of the vis bounds is translated to 0,0 KNOWN BUGS/SIDE EFFECTS/IDEAS: WARNING: This method is not dynamic, so the passed parameters are more limited and you must be careful what you destroy. REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianApplySPRITEOBJECTToVISTransform method dynamic \ GrObjVisGuardianClass, MSG_GOVG_APPLY_SPRITE_OBJECT_TO_VIS_TRANSFORM uses ax,cx,bp .enter mov di,dx ;gstate ; Calc scale factor from vis bounds to object dimensions ; and apply it if both not 1.0 ; call GrObjVisGuardianCalcScaleFactorVISToSPRITEOBJECT jc translate call GrApplyScale translate: ; Calc translation, (- center), and apply it ; push di ;gstate call GrObjVisGuardianGetWardWWFixedCenter negwwf dxcx negwwf bxax pop di ;gstate call GrApplyTranslation mov dx,di ;gstate .leave ret GrObjVisGuardianApplySPRITEOBJECTToVISTransform endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianCalcScaleFactorVISToOBJECT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate scale factor from vis wards vis bounds to object dimensions of guardian CALLED BY: INTERNAL GrObjVisGuardianApplyOBJECTToVISTransform BitmapGuardianGainedEditGrab PASS: *ds:si - GrObjVisGuardian RETURN: dx:cx - WWFixed x scale factor bx:ax - WWFixed y scale factor stc - if both scale factors are 1.0 DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SPEED over SMALL_SIZE as it is called for drawing and for each mouse event Common cases: Vis bounds equal object dimensions REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/16/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianCalcScaleFactorVISToOBJECT proc far class GrObjVisGuardianClass uses di,si .enter EC < call ECGrObjVisGuardianCheckLMemObject > GrObjDeref di,ds,si tst ds:[di].GOI_normalTransform jz noNormalTransform CallMod GrObjGetNormalOBJECTDimensions call GrObjVisGuardianCalcScaleFactorVISToDimensions done: .leave ret noNormalTransform: ; There is no normalTransform so just return the scale factor ; as zero. ; clr ax,bx,cx,dx ;clears carry stc jmp done GrObjVisGuardianCalcScaleFactorVISToOBJECT endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianCalcScaleFactorVISToSPRITEOBJECT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate scale factor from vis wards vis bounds to sprite object dimensions of guardian CALLED BY: INTERNAL GrObjVisGuardianApplySPRITE_OBJECTToVISTransform PASS: *ds:si - GrObjVisGuardian RETURN: dx:cx - WWFixed x scale factor bx:ax - WWFixed y scale factor stc - if both scale factors are 1.0 DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SPEED over SMALL_SIZE as it is called for drawing and for each mouse event during a move or resize Common cases: Vis bounds equal object dimensions REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/16/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianCalcScaleFactorVISToSPRITEOBJECT proc far class GrObjVisGuardianClass uses di,si .enter EC < call ECGrObjVisGuardianCheckLMemObject > GrObjDeref di,ds,si tst ds:[di].GOI_spriteTransform jz noSpriteTransform CallMod GrObjGetSpriteOBJECTDimensions call GrObjVisGuardianCalcScaleFactorVISToDimensions done: .leave ret noSpriteTransform: ; There is no spriteTransform so just return the scale factor ; as zero. ; clr ax,bx,cx,dx ;clears carry stc jmp done GrObjVisGuardianCalcScaleFactorVISToSPRITEOBJECT endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianCalcScaleFactorVISToDimensions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate scale factor from vis ward's vis bounds to passed dimensions CALLED BY: INTERNAL GrObjVisGuardianCalcScaleFactorVISToSPRITE GrObjVisGuardianCalcScaleFactorVISToOBJECT PASS: *ds:si - GrObjVisGuardian dxcx - WWFixed x dimension bxax - WWFixed y dimension RETURN: dx:cx - WWFixed x scale factor bx:ax - WWFixed y scale factor stc - if both scale factors are 1.0 DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SPEED over SMALL_SIZE as it is called for drawing and for each mouse event Common cases: Vis bounds equal object dimensions REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/16/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianCalcScaleFactorVISToDimensions proc far class GrObjVisGuardianClass objectWidth local WWFixed uses di,si .enter EC < call ECGrObjVisGuardianCheckLMemObject > movwwf objectWidth, dxcx call GrObjVisGuardianGetWardSize ; ; If either vis dimension is zero: ; actually, we want to stuff the Ward's Size such that ; that direction's transform is 1 jcxz fixFirst checkOther: tst dx jz fixSecond continue: ; Check for vis bounds equaling object dimensions ; cmp bx,dx ;height ints jne doDivide cmp objectWidth.WWF_int,cx jne doDivide tst ax ;object height frac jnz doDivide tst objectWidth.WWF_frac jnz doDivide ; Set both scale factors to 1.0 and flag nice results ; mov cx,1 mov dx,cx clr ax, bx stc done: .leave ret fixFirst: mov cx,bx ; if Ward's size was zero, stuff the ; int part of the passed coord into ; the size so we get a scale of 1 jmp checkOther fixSecond: mov dx,objectWidth.WWF_int ; same as above except in ; other dimension jmp continue doDivide: ; Divide object width and height by VIS width and height ; push cx ;VIS width int xchg dx,bx ;OBJECT height int, VIS height int mov_tr cx,ax ;OBJECT height frac clr ax ;VIS height frac call GrSDivWWFixed ;calc y scale factor pop bx ;VIS width int push dx,cx ;y scale factor movwwf dxcx,objectWidth call GrSDivWWFixed ;calc x scale factor pop bx,ax ;y scale factor clc jmp done GrObjVisGuardianCalcScaleFactorVISToDimensions endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianDrawFGArea %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the visual ward PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass cl - DrawFlags dx - gstate bp - GrObjDrawFlags RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianDrawFGArea method dynamic GrObjVisGuardianClass, MSG_GO_DRAW_FG_AREA, MSG_GO_DRAW_FG_AREA_HI_RES, MSG_GO_DRAW_CLIP_AREA, MSG_GO_DRAW_CLIP_AREA_HI_RES .enter mov di,dx ;gstate call GrSaveTransform call GrObjVisGuardianOptApplyOBJECTToVISTransform ; Send draw message to vis ward ; push cx,dx,bp ;DrawFlags,gstate,GrObjDrawFlags test bp, mask GODF_DRAW_OBJECTS_ONLY jnz foolVisObjects continue: mov bp,dx ;gstate mov di,mask MF_FIXUP_DS mov ax, MSG_VIS_DRAW call GrObjVisGuardianMessageToVisWard pop cx,dx,bp ;DrawFlags,gstate,GrObjDrawFlags ; Restore gstate transformation ; mov di,dx ;gstate call GrRestoreTransform .leave ret foolVisObjects: ; If we are supposed to only draw the objects prevent the vis objects ; from drawing their selections and such by passing the print flag. ; ornf cl,mask DF_PRINT jmp continue GrObjVisGuardianDrawFGArea endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGetWardWWFixedCenter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the WWFixed center of the vis wards vis bounds. This routine can be used instead of MSG_GV_GET_WWFIXED_CENTER for speed purposes. CALLED BY: INTERNAL UTILITY PASS: *ds:si - GrObjVisGuardian RETURN: dx:cx - WWFixed x of center bx:ax - WWFixed y of center DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 8/27/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGetWardWWFixedCenter proc far class VisClass uses si,ds,bp .enter EC < call ECGrObjVisGuardianCheckLMemObject > .warn -private GrObjDeref si,ds,si movdw bxsi,ds:[si].GOVGI_ward tst bx jz bummer .warn +private push bx ;ward handle call ObjLockObjBlock mov ds,ax mov si,ds:[si] add si,ds:[si].Vis_offset ; (width)/2 + left ; mov dx,ds:[si].VI_bounds.R_right mov bx,ds:[si].VI_bounds.R_left sub dx,bx ;width int clr cx ;width frac sar dx,1 ;width/2 int rcr cx,1 ;width/2 frac add dx,bx ;width/2 + left ; (height)/2 + top ; mov bp,ds:[si].VI_bounds.R_bottom mov bx,ds:[si].VI_bounds.R_top sub bp,bx ;height int clr ax ;height frac sar bp,1 ;height/2 rcr rcr ax,1 ;height/2 frac add bp,bx ;height/2 + top pop bx ;ward handle call MemUnlock mov bx,bp done: .leave ret bummer: ; Hopefully this won't cause any trouble. This situation ; occurs when the text object decides to send out messages ; while it is handling MSG_META_FINAL_OBJ_FREE. ; mov dx,10 mov bx,dx clrdw axcx jmp done GrObjVisGuardianGetWardWWFixedCenter endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianGetWardSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the size of the vis bounds of the ward This routine can be used instead of MSG_VIS_GET_SIZE for speed purposes. CALLED BY: INTERNAL UTILITY PASS: *ds:si - GrObjVisGuardian RETURN: cx -- width of object dx -- height of object DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine should be optimized for SMALL SIZE over SPEED Common cases: unknown REVISION HISTORY: Name Date Description ---- ---- ----------- srs 8/27/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianGetWardSize proc far class GrObjVisGuardianClass uses ax,si,ds,bx .enter EC < call ECGrObjVisGuardianCheckLMemObject > GrObjDeref si,ds,si movdw bxsi,ds:[si].GOVGI_ward tst bx jz bummer call ObjLockObjBlock mov ds,ax call VisGetSize call MemUnlock done: .leave ret bummer: ; Hopefully this won't cause any trouble. This situation ; occurs when the text object decides to send out messages ; while it is handling MSG_META_FINAL_OBJ_FREE. ; mov cx,10 mov dx,cx jmp done GrObjVisGuardianGetWardSize endp GrObjDrawCode ends GrObjAlmostRequiredCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianAfterAddedToBody %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sent to object just after it is added to the body Set guardian link in vis ward Mark the vis object as realized so it can draw and set an upward link to the body. This is needed for fuping characters and such. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/19/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianAfterAddedToBody method dynamic GrObjVisGuardianClass, MSG_GO_AFTER_ADDED_TO_BODY uses cx,dx,bp .enter mov di,offset GrObjVisGuardianClass CallSuper MSG_GO_AFTER_ADDED_TO_BODY push si ;guardian chunk GrObjGetBodyOD mov cx,bx ;body handle mov dx,si ;body chunk pop si ;guardian chunk mov di, mask MF_FIXUP_DS mov ax,MSG_GV_SET_REALIZED_AND_UPWARD_LINK call GrObjVisGuardianMessageToVisWard .leave ret GrObjVisGuardianAfterAddedToBody endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianBeforeRemovedFromBody %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sent to object just before it is removed from body. Remove vis ward visually from body. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjVisGuardianClass RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 1/ 7/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianBeforeRemovedFromBody method dynamic GrObjVisGuardianClass, MSG_GO_BEFORE_REMOVED_FROM_BODY .enter mov di, mask MF_FIXUP_DS mov ax,MSG_GV_CLEAR_REALIZED_AND_UPWARD_LINK call GrObjVisGuardianMessageToVisWard mov ax,MSG_GO_BEFORE_REMOVED_FROM_BODY mov di,offset GrObjVisGuardianClass CallSuper MSG_GO_BEFORE_REMOVED_FROM_BODY .leave ret GrObjVisGuardianBeforeRemovedFromBody endm GrObjAlmostRequiredCode ends GrObjRequiredInteractiveCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjVisGuardianPARENTPointForEdit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Have object evaluate the passed point in terms of editing. (ie could the object edit it self at this point)(eg for a bitmap, anywhere within its bounds, for a spline, somewhere along the spline or drawn control points). PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass ss:bp - PointDWFixed in PARENT coordinate system RETURN: al - EvaluatePositionRating dx - EvaluatePositionNotes DESTROYED: ah PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SMALL SIZE over SPEED Common cases: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 4/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjVisGuardianPARENTPointForEdit method dynamic GrObjVisGuardianClass, MSG_GO_EVALUATE_PARENT_POINT_FOR_EDIT .enter mov ax,MSG_GO_EVALUATE_PARENT_POINT_FOR_SELECTION call ObjCallInstanceNoLock call GrObjCanEdit? jnc cantEdit done: .leave ret cantEdit: ; Object can't be edited, so evaluate as none but leave the ; notes intact. ; mov al,EVALUATE_NONE jmp done GrObjVisGuardianPARENTPointForEdit endm GrObjRequiredInteractiveCode ends if ERROR_CHECK GrObjErrorCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECGrObjVisGuardianCheckLMemObject %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Checks to see if *ds:si* is a pointer to an object stored in an object block and that it is an GrObjVisGuardianClass or one of its subclasses CALLED BY: INTERNAL PASS: *(ds:si) - object chunk to check RETURN: none DESTROYED: nothing - not even flags PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 2/24/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ECGrObjVisGuardianCheckLMemObject proc far uses es,di .enter pushf mov di,segment GrObjVisGuardianClass mov es,di mov di,offset GrObjVisGuardianClass call ObjIsObjectInClass ERROR_NC OBJECT_NOT_OF_CORRECT_CLASS popf .leave ret ECGrObjVisGuardianCheckLMemObject endp GrObjErrorCode ends endif
#include "config_functions.h" #if USE_H3 #include <Columns/ColumnsNumber.h> #include <DataTypes/DataTypesNumber.h> #include <Functions/FunctionFactory.h> #include <Functions/IFunction.h> #include <Common/typeid_cast.h> #include <base/range.h> #include <h3api.h> namespace DB { namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; extern const int ILLEGAL_COLUMN; } namespace { class FunctionH3IsResClassIII : public IFunction { public: static constexpr auto name = "h3IsResClassIII"; static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionH3IsResClassIII>(); } std::string getName() const override { return name; } size_t getNumberOfArguments() const override { return 1; } bool useDefaultImplementationForConstants() const override { return true; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; } DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override { const auto * arg = arguments[0].get(); if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), 1, getName()); return std::make_shared<DataTypeUInt8>(); } ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override { auto non_const_arguments = arguments; for (auto & argument : non_const_arguments) argument.column = argument.column->convertToFullColumnIfConst(); const auto * column = checkAndGetColumn<ColumnUInt64>(non_const_arguments[0].column.get()); if (!column) throw Exception( ErrorCodes::ILLEGAL_COLUMN, "Illegal type {} of argument {} of function {}. Must be UInt64", arguments[0].type->getName(), 1, getName()); const auto & data = column->getData(); auto dst = ColumnVector<UInt8>::create(); auto & dst_data = dst->getData(); dst_data.resize(input_rows_count); for (size_t row = 0; row < input_rows_count; ++row) { UInt8 res = isResClassIII(data[row]); dst_data[row] = res; } return dst; } }; } void registerFunctionH3IsResClassIII(FunctionFactory & factory) { factory.registerFunction<FunctionH3IsResClassIII>(); } } #endif
; void *zx_saddrpright_callee(void *saddr, uint bitmask) SECTION code_arch PUBLIC _zx_saddrpright_callee _zx_saddrpright_callee: pop af pop hl pop de push af INCLUDE "arch/zx/display/z80/asm_zx_saddrpright.asm"
; A142072: Primes congruent to 19 mod 34. ; 19,53,223,257,359,461,563,631,733,937,971,1039,1277,1447,1481,1549,1583,1753,1787,1889,2161,2297,2399,2467,2671,2909,3011,3079,3181,3623,3691,3793,3929,4099,4133,4201,4337,4507,4643,4813,5051,5119,5153,5323,5527,5867,6037,6173,6343,6547,6581,7057,7159,7193,7499,7669,7703,7873,7907,8009,8111,8179,8689,8893,9029,9199,9403,9437,9539,9743,9811,10151,10253,10321,10457,10559,10627,10729,10831,11069,11171,11239,11273,11443,11579,11681,11783,11953,11987,12157,12497,12973,13007,13109,13177,13313,13381,13619,13687,13721 mov $2,$0 add $2,1 pow $2,2 lpb $2 add $1,18 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,16 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe div $1,2 sub $1,22 mul $1,2 add $1,29 mov $0,$1
/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HUGO_QUERY_BUILDER_HPP #define HUGO_QUERY_BUILDER_HPP #include <NDBT.hpp> #include <Vector.hpp> #include "../../src/ndbapi/NdbQueryBuilder.hpp" class HugoQueryBuilder { public: typedef Uint64 OptionMask; /** * Options that affects what kind of query is built */ enum QueryOption { /** * Query should be a lookup */ O_LOOKUP = 0x1, /** * Query should be a scan */ O_SCAN = 0x2, /** * Query might use primary key index */ O_PK_INDEX = 0x4, /** * Query might use unique index */ O_UNIQUE_INDEX = 0x8, /** * Query might use ordered index */ O_ORDERED_INDEX = 0x10, /** * Query might table scan */ O_TABLE_SCAN = 0x20, /** * If not any options set, random query qill be created */ O_RANDOM_OPTIONS = (OptionMask)((~(OptionMask)0) & ~(OptionMask)(O_SCAN | O_LOOKUP)) }; static const OptionMask OM_RANDOM_OPTIONS = (OptionMask)O_RANDOM_OPTIONS; HugoQueryBuilder(Ndb* ndb, const NdbDictionary::Table**tabptr, OptionMask om = OM_RANDOM_OPTIONS){ init(); for (; * tabptr != 0; tabptr++) addTable(ndb, * tabptr); setOptionMask(om); fixOptions(); } HugoQueryBuilder(Ndb* ndb, const NdbDictionary::Table* tab, QueryOption o) { init(); addTable(ndb, tab); setOption(o); fixOptions(); } virtual ~HugoQueryBuilder(); void setMinJoinLevel(int level) { m_joinLevel[0] = level;} int getMinJoinLevel() const { return m_joinLevel[0];} void setMaxJoinLevel(int level) { m_joinLevel[1] = level;} int getMaxJoinLevel() const { return m_joinLevel[1];} void setJoinLevel(int level) { setMinJoinLevel(level);setMaxJoinLevel(level);} int getJoinLevel() const; void addTable(Ndb*, const NdbDictionary::Table*); void removeTable(const NdbDictionary::Table*); void setOption(QueryOption o) { m_options |= (OptionMask)o;} void clearOption(QueryOption o) const { m_options &= ~(OptionMask)o;} bool testOption(QueryOption o) const { return (m_options & o) != 0;} OptionMask getOptionMask() const { return m_options;} void setOptionMask(OptionMask om) { m_options = om;} const NdbQueryDef * createQuery(bool takeOwnership = false); private: struct TableDef { const NdbDictionary::Table * m_table; Vector<const NdbDictionary::Index*> m_unique_indexes; Vector<const NdbDictionary::Index*> m_ordered_indexes; }; void init(); mutable OptionMask m_options; int m_joinLevel[2]; // min/max Vector<TableDef> m_tables; Vector<const NdbQueryDef*> m_queries; // get random table struct TableDef getTable() const; struct OpIdx { NdbQueryOperationDef::Type m_type; const NdbDictionary::Table * m_table; const NdbDictionary::Index * m_index; }; OpIdx getOp() const; struct Op { int m_parent; int m_idx; const NdbQueryOperationDef * m_op; }; Vector<Op> m_query; // Query built sofar /** * Check if all column in cols can be bound to a column in tables in * ops */ static bool checkBindable(Vector<const NdbDictionary::Column*> cols, Vector<Op> ops, bool allow_bind_nullable); Vector<Op> getParents(OpIdx); // NdbQueryOperand * createLink(NdbQueryBuilder&, const NdbDictionary::Column*, Vector<Op> & parents, bool allow_bind_nullable); const NdbQueryOperationDef* createOp(NdbQueryBuilder&); void fixOptions(); /** * We currently don't support busy-scan joins */ bool checkBusyScan(Op) const; bool isAncestor(const Op& parent, const Op& child) const; friend NdbOut& operator<<(NdbOut& out, const HugoQueryBuilder::Op& op); }; #endif
######## General Purpose Macros ######## # Print a string in memory -------------------- .macro print_string(%str_name) li $v0, 4 la $a0, %str_name syscall .end_macro .macro print_strings(%str1, %str2) li $v0, 4 la $a0, %str1 syscall la $a0, %str2 syscall .end_macro .macro print_strings(%str1, %str2, %str3) li $v0, 4 la $a0, %str1 syscall la $a0, %str2 syscall la $a0, %str3 syscall .end_macro .macro print_integer(%register) li $v0, 1 move $a0, %register syscall .end_macro # Print a newline ----------------------------- .macro print_newline() li $v0, 4 la $a0, newline syscall .end_macro # Print new string ----------------------------- .macro print(%str) .data string: .asciiz %str .text li $v0, 4 la $a0, string syscall .end_macro # Print new string w/ newline ----------------- .macro println(%str) .data string: .asciiz %str .text li $v0, 4 la $a0, string syscall la $a0, newline syscall .end_macro # Print specified num of newlines ------------- .macro print_newlines(%count) li $t9, %count li $t8, 0 li $v0, 4 la $a0, newline LOOP: syscall addi $t8, $t8, 1 bne $t8, $t9, LOOP .end_macro # Get integer from user ------------------------ # + Specify message & register to hold value --- .macro get_int_from_user(%message, %register) print(%message) li $v0, 5 syscall move %register, $v0 .end_macro .macro get_digit_from_user(%message, %register) print(%message) li $v0, 12 # Gets ascii character code syscall addi $v0, $v0, -48 # Remove ascii offset move %register, $v0 .end_macro # Exit program --------------------------------- .macro EXIT li $v0, 10 syscall .end_macro # Common/Useful Data Values -------------------- .data newline: .asciiz "\n"
COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: Lbp printer driver FILE: lbpManager.asm AUTHOR: Dave Durran REVISION HISTORY: Name Date Description ---- ---- ----------- Dave 2/90 initial version Dave 6/92 initial 2.0 version DESCRIPTION: This file contains the source for the Lbp printer driver $Id: lbpManager.asm,v 1.1 97/04/18 11:51:59 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} ;-------------------------------------- ; Include files ;-------------------------------------- include printcomInclude.def ;------------------------------------------------------------------------------ ; Constants and Macros ;------------------------------------------------------------------------------ include printcomConstant.def include lbpConstant.def include printcomMacro.def include printcomCapsl.rdef ;------------------------------------------------------------------------------ ; Driver Info Table ;------------------------------------------------------------------------------ idata segment ; MODULE_FIXED DriverTable DriverExtendedInfoStruct \ < <Entry:DriverStrategy, ; DIS_strategy mask DA_HAS_EXTENDED_INFO, ; DIS_driverAttributes DRIVER_TYPE_PRINTER >, ; DIS_driverType handle DriverInfo ; DEIS_resource > public DriverTable idata ends ;------------------------------------------------------------------------------ ; Entry Code ;------------------------------------------------------------------------------ Entry segment resource ; MODULE_FIXED include printcomEntry.asm ; entry point, misc bookeeping routines include printcomTables.asm ; jump table for some driver calls include printcomInfo.asm ; various info getting/setting routines include printcomAdmin.asm ; misc init routines include printcomNoEscapes.asm ; module jump table for driver escape calls Entry ends ;------------------------------------------------------------------------------ ; Driver code ;------------------------------------------------------------------------------ CommonCode segment resource ; MODULE_STANDARD include printcomCapslJob.asm ; misc setup/cleanup routines include printcomHexStream.asm ; code to talk with the stream driver include printcomCapslDialog.asm ; code to implement dialog box routines include printcomDotMatrixBuffer.asm ; code to implement Buffer routines include printcomCapslText.asm ; code to implement text routines include printcomCapslStyles.asm ; code to implement Style routines include printcomCapslGraphics.asm ; code to implement graphics routines include printcomCapslCursor.asm ; code to implement Cursor routines include printcomASFOnlyPage.asm ; code to implement Page routines include printcomNoColor.asm ;dummy color routines. include lbpControlCodes.asm ; Tables of printer commands CommonCode ends ;------------------------------------------------------------------------------ ; Device Info Resources (each in their own resource) ;------------------------------------------------------------------------------ include lbpDriverInfo.asm ; overall driver info include capsl2Info.asm include capsl3Info.asm end
; A090193: a(n) = A053838(n) + 1 modulo 3. ; 1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1 mov $2,$0 mov $3,34 lpb $0 sub $0,1 add $3,$2 div $2,3 lpe mov $0,1 mov $2,$3 mod $2,3 add $0,$2 mov $1,$0 sub $1,1
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0xb336, %rsi nop nop nop nop sub $48013, %r14 mov (%rsi), %rbp nop nop nop nop nop sub %r12, %r12 lea addresses_normal_ht+0x10d6e, %r8 nop inc %rcx movb (%r8), %bl nop and %r8, %r8 lea addresses_WT_ht+0x1484a, %rsi lea addresses_normal_ht+0x159b6, %rdi clflush (%rdi) nop sub %rbx, %rbx mov $20, %rcx rep movsl nop nop nop nop xor %r12, %r12 lea addresses_normal_ht+0x16cf6, %rsi lea addresses_WC_ht+0x17336, %rdi nop nop nop xor %rbp, %rbp mov $110, %rcx rep movsw add %rsi, %rsi lea addresses_WC_ht+0x5bb6, %rcx nop nop sub $4519, %rsi movw $0x6162, (%rcx) nop nop nop and $16152, %rdi lea addresses_D_ht+0x3aee, %r14 nop nop nop xor %r8, %r8 movw $0x6162, (%r14) nop nop nop nop nop xor $46186, %r12 lea addresses_WC_ht+0x136, %rdi and %rsi, %rsi mov $0x6162636465666768, %r14 movq %r14, %xmm3 movups %xmm3, (%rdi) cmp $49059, %rsi lea addresses_D_ht+0xf236, %r14 dec %r8 mov (%r14), %r12w nop nop nop nop nop cmp $33512, %r8 lea addresses_normal_ht+0x152b6, %rcx nop nop add $8297, %rdi movb (%rcx), %r8b nop nop nop nop nop and $14731, %r14 lea addresses_UC_ht+0x1125a, %rsi lea addresses_WT_ht+0x9136, %rdi nop nop sub %rbp, %rbp mov $98, %rcx rep movsb nop nop nop nop nop cmp $24634, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r8 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi // Store lea addresses_D+0x8e15, %rbx clflush (%rbx) nop nop nop and $46116, %rsi movl $0x51525354, (%rbx) add $35833, %rcx // Store lea addresses_D+0x10056, %rdi nop nop nop nop and %rcx, %rcx mov $0x5152535455565758, %rdx movq %rdx, (%rdi) nop nop nop nop nop xor $29313, %rbp // Store lea addresses_normal+0x12af6, %rdx nop nop nop nop nop sub $20233, %rcx movw $0x5152, (%rdx) nop nop nop nop nop xor $31449, %rbp // Store lea addresses_D+0x9d36, %rdi nop nop nop xor %r8, %r8 movl $0x51525354, (%rdi) nop nop nop nop nop xor %rcx, %rcx // Store lea addresses_WT+0x12d36, %rsi nop nop nop nop dec %rdi mov $0x5152535455565758, %rdx movq %rdx, %xmm5 movups %xmm5, (%rsi) nop dec %rdx // Store lea addresses_PSE+0x1cd1c, %rdi and %rbx, %rbx mov $0x5152535455565758, %r8 movq %r8, (%rdi) nop nop add %rbx, %rbx // Store lea addresses_UC+0xb796, %rdi add $12644, %r8 movw $0x5152, (%rdi) nop nop nop inc %r8 // Faulty Load lea addresses_WT+0x12d36, %rbp nop nop nop nop add $12120, %rbx movaps (%rbp), %xmm7 vpextrq $1, %xmm7, %rsi lea oracles, %rdi and $0xff, %rsi shlq $12, %rsi mov (%rdi,%rsi,1), %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_normal'}} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WT'}} {'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_PSE'}} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_UC'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 9, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}} {'00': 1} 00 */
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %r9 push %rax push %rbx push %rsi lea addresses_normal_ht+0x55a9, %r9 nop nop and $537, %rsi mov (%r9), %ebx nop nop nop nop cmp $49685, %r9 lea addresses_A_ht+0x7d69, %r9 nop nop nop nop dec %rsi mov (%r9), %r14w nop nop nop nop nop sub $6278, %r10 lea addresses_WC_ht+0xd869, %r12 nop nop sub $33344, %rax mov $0x6162636465666768, %r14 movq %r14, %xmm4 movups %xmm4, (%r12) cmp $47132, %rsi pop %rsi pop %rbx pop %rax pop %r9 pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %rax push %rcx push %rdx // Faulty Load lea addresses_WT+0x7969, %r10 nop nop add %rcx, %rcx movups (%r10), %xmm3 vpextrq $1, %xmm3, %rax lea oracles, %r12 and $0xff, %rax shlq $12, %rax mov (%r12,%rax,1), %rax pop %rdx pop %rcx pop %rax pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'00': 8541, '39': 956} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
#include "uritests.h" #include "../guiutil.h" #include "../walletmodel.h" #include <QUrl> void URITests::uriTests() { SendCoinsRecipient rv; QUrl uri; uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?req-dontexist=")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?dontexist=")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 0); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?label=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString("Wikipedia Example Address")); QVERIFY(rv.amount == 0); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=0.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100000); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=1.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100100000); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=100&label=Wikipedia Example")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.amount == 10000000000LL); QVERIFY(rv.label == QString("Wikipedia Example")); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?message=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); QVERIFY(GUIUtil::parseBitcoinURI("businesstechnologycoin://LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?message=Wikipedia Example Address", &rv)); QVERIFY(rv.address == QString("LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9")); QVERIFY(rv.label == QString()); // We currently don't implement the message parameter (ok, yea, we break spec...) uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?req-message=Wikipedia Example Address")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=1,000&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("businesstechnologycoin:LQDPC5rbjDB72fGFVHu4enYhxGAZuRiFh9?amount=1,000.0&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); }
#Loh Hao Bin 25461257 Prac 4 Task 1c .data m: .word 0 n: .word 0 a: .word 0 b: .word 0 c: .word 0 prompt: .asciiz "Please input an integer: " output1: .asciiz "\na = " output2: .asciiz "\nb = " output3: .asciiz "\nc = " msg: .asciiz "Please input only positive integers." .text la $a0, prompt #print prompt addi $v0, $0, 4 syscall addi $v0, $0, 5 #input read int syscall blt $v0, $0, positive_check #bltz $v0, positive_check #check if positive sw $v0, m #store read input from $v0 into m la $a0, prompt #print prompt addi $v0, $0, 4 syscall addi $v0, $0, 5 #input read int syscall blt $v0, $0, positive_check #bltz $v0, positive_check #check if positive sw $v0, n #store read input from $v0 into n j calc_a1 #start calculating a value positive_check: la $a0, msg #print output3 if the entered values are not positive addi $v0, $0, 4 syscall j quit calc_a1: lw $t1, m #load m mult $t1, $t1 #square m mflo $t1 lw $t2, n #load n mult $t2, $t2 #square n mflo $t2 j calc_c #use the square value to calculate c first calc_c: add $t0, $t1, $t2 #add m^2 and n^2 sw $t0, c #store into c j calc_a2 #go back to calculating a calc_a2: sub $t0, $t1, $t2 #subtract m^2 and n^2 blez $t0, abs #if $t0 is less than or equal to 0, branch to abs j add_to_a #branch to add_to_a abs: addi $t9, $0, -1 #set up multiplier -1 at $t9 mult $t0, $t9 #multiply $t0 with -1 mflo $t0 j add_to_a add_to_a: sw $t0, a #store value in a j calc_b #move on to calculate b calc_b: lw $t1, m #get m value lw $t2, n #get n value mult $t1, $t2 #multiply m and n mflo $t0 addi $t9, $0, 2 #setup multiplier 2 mult $t0, $t9 #multiply by 2 mflo $t0 sw $t0, b #store value in b j output output: la $a0, output1 #print output1 addi $v0, $0, 4 syscall lw $a0, a #load a's content into $a0 addi $v0, $0, 1 #print integer syscall la $a0, output2 #print output2 addi $v0, $0, 4 syscall lw $a0, b #load a's content into $a0 addi $v0, $0, 1 #print integer syscall la $a0, output3 #print output3 addi $v0, $0, 4 syscall lw $a0, c #load a's content into $a0 addi $v0, $0, 1 #print integer syscall j quit quit: addi $v0, $0, 10 #exit syscall
/* |INCLUDES: QT| */ #include <QLayout> #include <QToolBar> #include <QStackedWidget> #include <QProcess> /* |INCLUDES: SQUARE| */ #include "square.h" #include "square-Menu.h" #include "square-Frame.h" #include "square-TableFrame.h" #include "square-JsonFrame.h" #include "square-GraphFrame.h" /* |INCLUDES: PROJECT| */ #include "client-FrameDialog.h" #include "client-DragFrame.h" FrameDialog::FrameDialog(QWidget *parent) : QDialog(parent) { QSize buttonSize(50, 50); /* ---------------------------------------------------- (MENU FRAMES) */ Menu *squareMenu(new Menu(false)); { squareMenu->register_Frame(new ClientDragFrame(), SQUARE_OBJ::button("DragFrame", buttonSize)); squareMenu->register_Frame(new JsonFrame(), SQUARE_OBJ::button("JsonFrame", buttonSize)); squareMenu->register_Frame(new GraphFrame(), SQUARE_OBJ::button("Graph", buttonSize)); squareMenu->register_Frame(new TableFrame(QStringList() << "1" << "2"), SQUARE_OBJ::button("TableFrame", buttonSize)); squareMenu->set_Frame(0); } /* ---------------------------------------------------- (MENU TOOLBAR) */ QToolBar *toolbar(squareMenu->get_ToolBar()); { toolbar->setOrientation(Qt::Vertical); } /* ---------------------------------------------------- (MAIN LAYOUT) */ QHBoxLayout *mainLayout(new QHBoxLayout(this)); { mainLayout->addWidget(toolbar); mainLayout->addWidget(squareMenu->get_StackedWidget()); } }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x12ac0, %rcx nop nop nop nop nop sub $5994, %rbx movups (%rcx), %xmm0 vpextrq $1, %xmm0, %rdx nop nop dec %rax lea addresses_WT_ht+0x9dc0, %r14 add $320, %r10 movb (%r14), %r15b nop nop nop nop cmp %rax, %rax lea addresses_WC_ht+0x88c0, %rax sub %rdx, %rdx movw $0x6162, (%rax) nop nop nop nop nop xor $678, %rbx lea addresses_WC_ht+0x1c040, %rcx add $41492, %r15 movb (%rcx), %r14b nop and $28220, %r14 lea addresses_UC_ht+0x199b8, %rsi lea addresses_WT_ht+0x15b20, %rdi nop nop nop nop nop inc %r14 mov $119, %rcx rep movsw nop nop nop nop nop inc %rbx lea addresses_normal_ht+0x1be58, %r10 nop nop nop nop nop sub %r14, %r14 movw $0x6162, (%r10) nop nop nop dec %rax lea addresses_D_ht+0x56f0, %rsi lea addresses_D_ht+0x1e700, %rdi nop sub %rax, %rax mov $38, %rcx rep movsb xor $45708, %r15 lea addresses_normal_ht+0x5dc0, %rsi nop nop nop dec %rdx mov $0x6162636465666768, %rcx movq %rcx, (%rsi) xor %rax, %rax lea addresses_UC_ht+0x146c0, %rsi lea addresses_D_ht+0x5c0, %rdi nop nop nop xor $36622, %rax mov $46, %rcx rep movsb nop and $44680, %rsi lea addresses_WT_ht+0x95c0, %r14 add %rcx, %rcx mov (%r14), %rbx cmp $58748, %rax lea addresses_A_ht+0x66e, %rsi lea addresses_D_ht+0xce00, %rdi nop sub $59407, %r10 mov $69, %rcx rep movsw nop cmp %r15, %r15 lea addresses_normal_ht+0x7dc0, %rdx nop nop add $29132, %rax mov $0x6162636465666768, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%rdx) nop nop sub %rax, %rax lea addresses_normal_ht+0x9c80, %rsi lea addresses_A_ht+0x13c0, %rdi nop nop sub $18463, %r15 mov $62, %rcx rep movsb nop nop add %r14, %r14 lea addresses_WT_ht+0xe8f8, %rsi lea addresses_UC_ht+0x74c0, %rdi dec %r14 mov $96, %rcx rep movsw nop nop nop nop cmp $64622, %rsi lea addresses_A_ht+0x12640, %rsi lea addresses_UC_ht+0x9e10, %rdi clflush (%rdi) nop nop nop nop dec %r10 mov $11, %rcx rep movsb nop dec %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r8 push %rax push %rbp push %rbx push %rdi push %rdx // Store lea addresses_PSE+0x1cdc0, %rdx nop nop xor $8299, %rdi movw $0x5152, (%rdx) nop nop nop nop sub $58371, %r13 // Store mov $0xef0, %r8 nop nop add %rax, %rax movw $0x5152, (%r8) nop nop nop nop nop and %r8, %r8 // Store mov $0x640, %rbp nop nop nop nop nop and $40022, %rax mov $0x5152535455565758, %rdx movq %rdx, %xmm1 movups %xmm1, (%rbp) nop nop xor $1405, %r8 // Store lea addresses_normal+0x1ddc0, %r8 inc %rbp mov $0x5152535455565758, %rdi movq %rdi, %xmm6 vmovups %ymm6, (%r8) nop nop nop xor %rbp, %rbp // Store lea addresses_D+0xc160, %rbx nop and $30920, %r13 mov $0x5152535455565758, %rax movq %rax, (%rbx) nop nop nop nop nop add $32900, %r13 // Faulty Load lea addresses_D+0x4dc0, %rdx xor %rbx, %rbx movb (%rdx), %r13b lea oracles, %r8 and $0xff, %r13 shlq $12, %r13 mov (%r8,%r13,1), %r13 pop %rdx pop %rdi pop %rbx pop %rbp pop %rax pop %r8 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 11, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'congruent': 4, 'same': True, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 6, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'congruent': 8, 'same': True, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 11, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
Name: ys_w42.asm Type: file Size: 18446 Last-Modified: '2016-05-13T04:51:43Z' SHA-1: C9377154D0852F144CBB272C26653261242527F0 Description: null
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r15 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x9143, %r11 nop nop nop cmp %r8, %r8 movb (%r11), %bl nop cmp $18050, %r11 lea addresses_A_ht+0x3043, %r8 nop nop cmp $36948, %r10 and $0xffffffffffffffc0, %r8 vmovaps (%r8), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %rdi nop nop nop nop add %rdi, %rdi lea addresses_WT_ht+0x1bddf, %rsi lea addresses_WT_ht+0x12543, %rdi nop nop nop cmp %r10, %r10 mov $43, %rcx rep movsq add $22236, %r10 lea addresses_UC_ht+0x10383, %rsi lea addresses_WC_ht+0x3943, %rdi xor %r15, %r15 mov $108, %rcx rep movsl nop nop nop nop nop inc %r11 lea addresses_UC_ht+0x3ea3, %r8 nop nop nop sub $4541, %r10 movl $0x61626364, (%r8) nop nop nop dec %r11 lea addresses_A_ht+0x14323, %rsi nop nop nop nop nop cmp $42678, %r11 mov (%rsi), %rdi nop nop nop nop nop sub %rcx, %rcx lea addresses_A_ht+0xdc43, %r10 nop nop add %rdi, %rdi movb $0x61, (%r10) nop nop nop nop sub $3844, %r10 lea addresses_normal_ht+0x1c1b3, %rsi nop nop nop nop nop sub %r10, %r10 movb (%rsi), %r15b nop nop nop nop nop xor %rbx, %rbx lea addresses_A_ht+0x7043, %rsi lea addresses_A_ht+0x2d43, %rdi clflush (%rdi) nop nop nop nop nop and $25, %r11 mov $5, %rcx rep movsb nop nop nop and %rdi, %rdi lea addresses_WT_ht+0x1aba3, %rsi lea addresses_A_ht+0x1b033, %rdi nop sub $16234, %rbx mov $14, %rcx rep movsq nop nop cmp %r8, %r8 lea addresses_WT_ht+0x4003, %r8 inc %r11 movl $0x61626364, (%r8) nop nop nop add $4657, %r8 lea addresses_WT_ht+0xb46b, %r15 and %r10, %r10 mov (%r15), %r8d nop nop nop and $44959, %rcx lea addresses_normal_ht+0x737b, %r10 nop inc %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm7 and $0xffffffffffffffc0, %r10 movntdq %xmm7, (%r10) cmp %rbx, %rbx lea addresses_WT_ht+0x17d43, %r11 nop nop nop nop nop add %r10, %r10 movw $0x6162, (%r11) nop nop nop nop nop add $52403, %r15 lea addresses_A_ht+0xa0db, %rsi lea addresses_WC_ht+0xc683, %rdi clflush (%rdi) nop nop nop nop nop and %r11, %r11 mov $7, %rcx rep movsw nop nop nop dec %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %r15 push %r8 push %rbp push %rdi // Store lea addresses_UC+0x19343, %rbp nop nop nop nop cmp %r13, %r13 movl $0x51525354, (%rbp) // Exception!!! mov (0), %r14 nop nop nop sub %rbp, %rbp // Faulty Load lea addresses_WT+0x16143, %r15 add %r11, %r11 mov (%r15), %r13d lea oracles, %rdi and $0xff, %r13 shlq $12, %r13 mov (%rdi,%r13,1), %r13 pop %rdi pop %rbp pop %r8 pop %r15 pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 9}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': True, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 9}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': True, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': True, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}} {'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 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. ############################################################################### .text .p2align 6, 0x90 Lpoly: .quad 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, 0xFFFFFFFFFFFFFFFF LRR: .quad 0x1, 0x2, 0x1 LOne: .long 1,1,1,1,1,1,1,1 .p2align 6, 0x90 .globl _k0_p192r1_mul_by_2 _k0_p192r1_mul_by_2: push %r12 xor %r12, %r12 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 shld $(1), %r10, %r12 shld $(1), %r9, %r10 shld $(1), %r8, %r9 shl $(1), %r8 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r12 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_div_by_2 _k0_p192r1_div_by_2: push %r12 push %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 xor %r12, %r12 xor %r13, %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adc $(0), %r12 test $(1), %r8 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r13 shrd $(1), %r9, %r8 shrd $(1), %r10, %r9 shrd $(1), %r13, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r13 pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_mul_by_3 _k0_p192r1_mul_by_3: push %r12 xor %r12, %r12 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 shld $(1), %r10, %r12 shld $(1), %r9, %r10 shld $(1), %r8, %r9 shl $(1), %r8 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r12 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 xor %r12, %r12 addq (%rsi), %r8 adcq (8)(%rsi), %r9 adcq (16)(%rsi), %r10 adc $(0), %r12 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r12 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_add _k0_p192r1_add: push %r12 xor %r12, %r12 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 addq (%rdx), %r8 adcq (8)(%rdx), %r9 adcq (16)(%rdx), %r10 adc $(0), %r12 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r12 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_sub _k0_p192r1_sub: push %r12 xor %r12, %r12 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 subq (%rdx), %r8 sbbq (8)(%rdx), %r9 sbbq (16)(%rdx), %r10 sbb $(0), %r12 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx test %r12, %r12 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_neg _k0_p192r1_neg: push %r12 xor %r12, %r12 xor %r8, %r8 xor %r9, %r9 xor %r10, %r10 subq (%rsi), %r8 sbbq (8)(%rsi), %r9 sbbq (16)(%rsi), %r10 sbb $(0), %r12 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx test %r12, %r12 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r12 ret .p2align 6, 0x90 p192r1_mmull: xor %r12, %r12 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 sub %r8, %r9 sbb $(0), %r10 sbb $(0), %r8 add %r8, %r11 adc $(0), %r12 xor %r8, %r8 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 %rdx, %r12 adc $(0), %r8 sub %r9, %r10 sbb $(0), %r11 sbb $(0), %r9 add %r9, %r12 adc $(0), %r8 xor %r9, %r9 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 %rdx, %r8 adc $(0), %r9 sub %r10, %r11 sbb $(0), %r12 sbb $(0), %r10 add %r10, %r8 adc $(0), %r9 xor %r10, %r10 mov %r11, %rax mov %r12, %rdx mov %r8, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r9 cmovnc %rax, %r11 cmovnc %rdx, %r12 cmovnc %rcx, %r8 movq %r11, (%rdi) movq %r12, (8)(%rdi) movq %r8, (16)(%rdi) ret .p2align 6, 0x90 p192r1_mmulx: xor %r12, %r12 xor %rdx, %rdx movq (%rbx), %rdx mulxq (%rsi), %r8, %r9 mulxq (8)(%rsi), %rcx, %r10 add %rcx, %r9 mulxq (16)(%rsi), %rcx, %r11 adc %rcx, %r10 adc $(0), %r11 sub %r8, %r9 sbb $(0), %r10 sbb $(0), %r8 add %r8, %r11 adc $(0), %r12 xor %r8, %r8 movq (8)(%rbx), %rdx mulxq (%rsi), %rcx, %rax adcx %rcx, %r9 adox %rax, %r10 mulxq (8)(%rsi), %rcx, %rax adcx %rcx, %r10 adox %rax, %r11 mulxq (16)(%rsi), %rcx, %rax adcx %rcx, %r11 adox %rax, %r12 adcx %r8, %r12 adox %r8, %r8 adc $(0), %r8 sub %r9, %r10 sbb $(0), %r11 sbb $(0), %r9 add %r9, %r12 adc $(0), %r8 xor %r9, %r9 movq (16)(%rbx), %rdx mulxq (%rsi), %rcx, %rax adcx %rcx, %r10 adox %rax, %r11 mulxq (8)(%rsi), %rcx, %rax adcx %rcx, %r11 adox %rax, %r12 mulxq (16)(%rsi), %rcx, %rax adcx %rcx, %r12 adox %rax, %r8 adcx %r9, %r8 adox %r9, %r9 adc $(0), %r9 sub %r10, %r11 sbb $(0), %r12 sbb $(0), %r10 add %r10, %r8 adc $(0), %r9 xor %r10, %r10 mov %r11, %rax mov %r12, %rdx mov %r8, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r9 cmovnc %rax, %r11 cmovnc %rdx, %r12 cmovnc %rcx, %r8 movq %r11, (%rdi) movq %r12, (8)(%rdi) movq %r8, (16)(%rdi) ret .p2align 6, 0x90 .globl _k0_p192r1_mul_montl _k0_p192r1_mul_montl: push %rbx push %r12 mov %rdx, %rbx call p192r1_mmull vzeroupper pop %r12 pop %rbx ret .p2align 6, 0x90 .globl _k0_p192r1_mul_montx _k0_p192r1_mul_montx: push %rbx push %r12 mov %rdx, %rbx call p192r1_mmulx vzeroupper pop %r12 pop %rbx ret .p2align 6, 0x90 .globl _k0_p192r1_to_mont _k0_p192r1_to_mont: push %rbx push %r12 lea LRR(%rip), %rbx call p192r1_mmull vzeroupper pop %r12 pop %rbx ret .p2align 6, 0x90 .globl _k0_p192r1_sqr_montl _k0_p192r1_sqr_montl: push %r12 push %r13 movq (%rsi), %rcx movq (8)(%rsi), %rax mul %rcx mov %rax, %r9 mov %rdx, %r10 movq (16)(%rsi), %rax mul %rcx add %rax, %r10 adc $(0), %rdx mov %rdx, %r11 movq (8)(%rsi), %rcx movq (16)(%rsi), %rax mul %rcx add %rax, %r11 adc $(0), %rdx mov %rdx, %r12 xor %r13, %r13 shld $(1), %r12, %r13 shld $(1), %r11, %r12 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shl $(1), %r9 movq (%rsi), %rax mul %rax mov %rax, %r8 add %rdx, %r9 adc $(0), %r10 movq (8)(%rsi), %rax mul %rax add %rax, %r10 adc %rdx, %r11 adc $(0), %r12 movq (16)(%rsi), %rax mul %rax add %rax, %r12 adc %rdx, %r13 sub %r8, %r9 sbb $(0), %r10 sbb $(0), %r8 add %r8, %r11 mov $(0), %r8 adc $(0), %r8 sub %r9, %r10 sbb $(0), %r11 sbb $(0), %r9 add %r9, %r12 mov $(0), %r9 adc $(0), %r9 add %r8, %r12 adc $(0), %r9 sub %r10, %r11 sbb $(0), %r12 sbb $(0), %r10 add %r10, %r13 mov $(0), %r10 adc $(0), %r10 add %r9, %r13 adc $(0), %r10 mov %r11, %rax mov %r12, %rdx mov %r13, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r10 cmovnc %rax, %r11 cmovnc %rdx, %r12 cmovnc %rcx, %r13 movq %r11, (%rdi) movq %r12, (8)(%rdi) movq %r13, (16)(%rdi) vzeroupper pop %r13 pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_sqr_montx _k0_p192r1_sqr_montx: push %rbp push %rbx push %r12 push %r13 movq (%rsi), %rdx mulxq (8)(%rsi), %r9, %r10 mulxq (16)(%rsi), %rcx, %r11 add %rcx, %r10 adc $(0), %r11 movq (8)(%rsi), %rdx mulxq (16)(%rsi), %rcx, %r12 add %rcx, %r11 adc $(0), %r12 xor %r13, %r13 shld $(1), %r12, %r13 shld $(1), %r11, %r12 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shl $(1), %r9 xor %r8, %r8 movq (%rsi), %rdx mulx %rdx, %r8, %rax adcx %rax, %r9 movq (8)(%rsi), %rdx mulx %rdx, %rcx, %rax adcx %rcx, %r10 adcx %rax, %r11 movq (16)(%rsi), %rdx mulx %rdx, %rcx, %rax adcx %rcx, %r12 adcx %rax, %r13 sub %r8, %r9 sbb $(0), %r10 sbb $(0), %r8 add %r8, %r11 mov $(0), %r8 adc $(0), %r8 sub %r9, %r10 sbb $(0), %r11 sbb $(0), %r9 add %r9, %r12 mov $(0), %r9 adc $(0), %r9 add %r8, %r12 adc $(0), %r9 sub %r10, %r11 sbb $(0), %r12 sbb $(0), %r10 add %r10, %r13 mov $(0), %r10 adc $(0), %r10 add %r9, %r13 adc $(0), %r10 mov %r11, %rcx mov %r12, %rax mov %r13, %rdx subq Lpoly+0(%rip), %rcx sbbq Lpoly+8(%rip), %rax sbbq Lpoly+16(%rip), %rdx sbb $(0), %r10 cmovnc %rcx, %r11 cmovnc %rax, %r12 cmovnc %rdx, %r13 movq %r11, (%rdi) movq %r12, (8)(%rdi) movq %r13, (16)(%rdi) vzeroupper pop %r13 pop %r12 pop %rbx pop %rbp ret .p2align 6, 0x90 .globl _k0_p192r1_mont_back _k0_p192r1_mont_back: push %r12 movq (%rsi), %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 xor %r8, %r8 xor %r9, %r9 sub %r10, %r11 sbb $(0), %r12 sbb $(0), %r10 add %r10, %r8 adc $(0), %r9 xor %r10, %r10 sub %r11, %r12 sbb $(0), %r8 sbb $(0), %r11 add %r11, %r9 adc $(0), %r10 xor %r11, %r11 sub %r12, %r8 sbb $(0), %r9 sbb $(0), %r12 add %r12, %r10 adc $(0), %r11 xor %r12, %r12 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbb $(0), %r12 cmovnc %rax, %r8 cmovnc %rdx, %r9 cmovnc %rcx, %r10 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) vzeroupper pop %r12 ret .p2align 6, 0x90 .globl _k0_p192r1_select_pp_w5 _k0_p192r1_select_pp_w5: movdqa LOne(%rip), %xmm0 movdqa %xmm0, %xmm12 movd %edx, %xmm1 pshufd $(0), %xmm1, %xmm1 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 pxor %xmm5, %xmm5 pxor %xmm6, %xmm6 mov $(16), %rcx .Lselect_loop_sse_w5gas_13: movdqa %xmm12, %xmm13 pcmpeqd %xmm1, %xmm13 paddd %xmm0, %xmm12 movdqu (%rsi), %xmm7 movdqu (16)(%rsi), %xmm8 movdqu (32)(%rsi), %xmm9 movdqu (48)(%rsi), %xmm10 movq (64)(%rsi), %xmm11 add $(72), %rsi pand %xmm13, %xmm7 pand %xmm13, %xmm8 pand %xmm13, %xmm9 pand %xmm13, %xmm10 pand %xmm13, %xmm11 por %xmm7, %xmm2 por %xmm8, %xmm3 por %xmm9, %xmm4 por %xmm10, %xmm5 por %xmm11, %xmm6 dec %rcx jnz .Lselect_loop_sse_w5gas_13 movdqu %xmm2, (%rdi) movdqu %xmm3, (16)(%rdi) movdqu %xmm4, (32)(%rdi) movdqu %xmm5, (48)(%rdi) movq %xmm6, (64)(%rdi) vzeroupper ret .p2align 6, 0x90 .globl _k0_p192r1_select_ap_w7 _k0_p192r1_select_ap_w7: movdqa LOne(%rip), %xmm0 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 movdqa %xmm0, %xmm8 movd %edx, %xmm1 pshufd $(0), %xmm1, %xmm1 mov $(64), %rcx .Lselect_loop_sse_w7gas_14: movdqa %xmm8, %xmm9 pcmpeqd %xmm1, %xmm9 paddd %xmm0, %xmm8 movdqa (%rsi), %xmm5 movdqa (16)(%rsi), %xmm6 movdqa (32)(%rsi), %xmm7 add $(48), %rsi pand %xmm9, %xmm5 pand %xmm9, %xmm6 pand %xmm9, %xmm7 por %xmm5, %xmm2 por %xmm6, %xmm3 por %xmm7, %xmm4 dec %rcx jnz .Lselect_loop_sse_w7gas_14 movdqu %xmm2, (%rdi) movdqu %xmm3, (16)(%rdi) movdqu %xmm4, (32)(%rdi) vzeroupper ret
#pragma once #include <citro2d.h> #include <3dstris/config.hpp> #include <memory> class State; class Game { public: static Game& get() noexcept { static Game game; return game; } void update(double dt); void draw(); bool isPressed(u32 kDown, Keybinds::Action action) const noexcept; String translate(const StringView key) const noexcept; void loadLanguage(L10n::Language language) noexcept; C3D_RenderTarget* getTop() noexcept; C3D_RenderTarget* getBottom() noexcept; const C2D_SpriteSheet& getImageSheet() const noexcept; void pushState(std::unique_ptr<State> state, bool resetTop = false, bool resetBottom = false); // You should most likely return from the state's update method after // calling either one of these, unless you like dereferencing null pointers void setState(std::unique_ptr<State> state, bool resetTop = false, bool resetBottom = false); void popState(bool resetTop = false, bool resetBottom = false); State& getState(); Config& getConfig() noexcept; const Config& getConfig() const noexcept; Games& getGames() noexcept; Keybinds& getKeybinds() noexcept; const Keybinds& getKeybinds() const noexcept; const Theme& getTheme() const noexcept; bool exit = false; private: Game() noexcept; ~Game() noexcept; void reset(bool top, bool bottom) noexcept; C2D_SpriteSheet imageSheet; Config config; C3D_RenderTarget* top; C3D_RenderTarget* bottom; std::vector<std::unique_ptr<State>> states; };
//===- ModuleTranslation.cpp - MLIR to LLVM conversion --------------------===// // // Copyright 2019 The MLIR Authors. // // 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. // ============================================================================= // // This file implements the translation between an MLIR LLVM dialect module and // the corresponding LLVMIR module. It only handles core LLVM IR operations. // //===----------------------------------------------------------------------===// #include "mlir/Target/LLVMIR/ModuleTranslation.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Module.h" #include "mlir/LLVMIR/LLVMDialect.h" #include "mlir/Support/LLVM.h" #include "llvm/ADT/SetVector.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Transforms/Utils/Cloning.h" namespace mlir { namespace LLVM { // Convert an MLIR function type to LLVM IR. Arguments of the function must of // MLIR LLVM IR dialect types. Use `loc` as a location when reporting errors. // Return nullptr on errors. static llvm::FunctionType *convertFunctionType(llvm::LLVMContext &llvmContext, FunctionType type, Location loc, bool isVarArgs) { assert(type && "expected non-null type"); if (type.getNumResults() > 1) return emitError(loc, "LLVM functions can only have 0 or 1 result"), nullptr; SmallVector<llvm::Type *, 8> argTypes; argTypes.reserve(type.getNumInputs()); for (auto t : type.getInputs()) { auto wrappedLLVMType = t.dyn_cast<LLVM::LLVMType>(); if (!wrappedLLVMType) return emitError(loc, "non-LLVM function argument type"), nullptr; argTypes.push_back(wrappedLLVMType.getUnderlyingType()); } if (type.getNumResults() == 0) return llvm::FunctionType::get(llvm::Type::getVoidTy(llvmContext), argTypes, isVarArgs); auto wrappedResultType = type.getResult(0).dyn_cast<LLVM::LLVMType>(); if (!wrappedResultType) return emitError(loc, "non-LLVM function result"), nullptr; return llvm::FunctionType::get(wrappedResultType.getUnderlyingType(), argTypes, isVarArgs); } // Create an LLVM IR constant of `llvmType` from the MLIR attribute `attr`. // This currently supports integer, floating point, splat and dense element // attributes and combinations thereof. In case of error, report it to `loc` // and return nullptr. llvm::Constant *ModuleTranslation::getLLVMConstant(llvm::Type *llvmType, Attribute attr, Location loc) { if (auto intAttr = attr.dyn_cast<IntegerAttr>()) return llvm::ConstantInt::get(llvmType, intAttr.getValue()); if (auto floatAttr = attr.dyn_cast<FloatAttr>()) return llvm::ConstantFP::get(llvmType, floatAttr.getValue()); if (auto funcAttr = attr.dyn_cast<SymbolRefAttr>()) return functionMapping.lookup(funcAttr.getValue()); if (auto splatAttr = attr.dyn_cast<SplatElementsAttr>()) { auto *vectorType = cast<llvm::VectorType>(llvmType); auto *child = getLLVMConstant(vectorType->getElementType(), splatAttr.getSplatValue(), loc); return llvm::ConstantVector::getSplat(vectorType->getNumElements(), child); } if (auto denseAttr = attr.dyn_cast<DenseElementsAttr>()) { auto *vectorType = cast<llvm::VectorType>(llvmType); SmallVector<llvm::Constant *, 8> constants; uint64_t numElements = vectorType->getNumElements(); constants.reserve(numElements); for (auto n : denseAttr.getAttributeValues()) { constants.push_back( getLLVMConstant(vectorType->getElementType(), n, loc)); if (!constants.back()) return nullptr; } return llvm::ConstantVector::get(constants); } if (auto stringAttr = attr.dyn_cast<StringAttr>()) { return llvm::ConstantDataArray::get( llvmModule->getContext(), ArrayRef<char>{stringAttr.getValue().data(), stringAttr.getValue().size()}); } emitError(loc, "unsupported constant value"); return nullptr; } // Convert MLIR integer comparison predicate to LLVM IR comparison predicate. static llvm::CmpInst::Predicate getLLVMCmpPredicate(ICmpPredicate p) { switch (p) { case LLVM::ICmpPredicate::eq: return llvm::CmpInst::Predicate::ICMP_EQ; case LLVM::ICmpPredicate::ne: return llvm::CmpInst::Predicate::ICMP_NE; case LLVM::ICmpPredicate::slt: return llvm::CmpInst::Predicate::ICMP_SLT; case LLVM::ICmpPredicate::sle: return llvm::CmpInst::Predicate::ICMP_SLE; case LLVM::ICmpPredicate::sgt: return llvm::CmpInst::Predicate::ICMP_SGT; case LLVM::ICmpPredicate::sge: return llvm::CmpInst::Predicate::ICMP_SGE; case LLVM::ICmpPredicate::ult: return llvm::CmpInst::Predicate::ICMP_ULT; case LLVM::ICmpPredicate::ule: return llvm::CmpInst::Predicate::ICMP_ULE; case LLVM::ICmpPredicate::ugt: return llvm::CmpInst::Predicate::ICMP_UGT; case LLVM::ICmpPredicate::uge: return llvm::CmpInst::Predicate::ICMP_UGE; default: llvm_unreachable("incorrect comparison predicate"); } } static llvm::CmpInst::Predicate getLLVMCmpPredicate(FCmpPredicate p) { switch (p) { case LLVM::FCmpPredicate::_false: return llvm::CmpInst::Predicate::FCMP_FALSE; case LLVM::FCmpPredicate::oeq: return llvm::CmpInst::Predicate::FCMP_OEQ; case LLVM::FCmpPredicate::ogt: return llvm::CmpInst::Predicate::FCMP_OGT; case LLVM::FCmpPredicate::oge: return llvm::CmpInst::Predicate::FCMP_OGE; case LLVM::FCmpPredicate::olt: return llvm::CmpInst::Predicate::FCMP_OLT; case LLVM::FCmpPredicate::ole: return llvm::CmpInst::Predicate::FCMP_OLE; case LLVM::FCmpPredicate::one: return llvm::CmpInst::Predicate::FCMP_ONE; case LLVM::FCmpPredicate::ord: return llvm::CmpInst::Predicate::FCMP_ORD; case LLVM::FCmpPredicate::ueq: return llvm::CmpInst::Predicate::FCMP_UEQ; case LLVM::FCmpPredicate::ugt: return llvm::CmpInst::Predicate::FCMP_UGT; case LLVM::FCmpPredicate::uge: return llvm::CmpInst::Predicate::FCMP_UGE; case LLVM::FCmpPredicate::ult: return llvm::CmpInst::Predicate::FCMP_ULT; case LLVM::FCmpPredicate::ule: return llvm::CmpInst::Predicate::FCMP_ULE; case LLVM::FCmpPredicate::une: return llvm::CmpInst::Predicate::FCMP_UNE; case LLVM::FCmpPredicate::uno: return llvm::CmpInst::Predicate::FCMP_UNO; case LLVM::FCmpPredicate::_true: return llvm::CmpInst::Predicate::FCMP_TRUE; default: llvm_unreachable("incorrect comparison predicate"); } } // A helper to look up remapped operands in the value remapping table. template <typename Range> SmallVector<llvm::Value *, 8> ModuleTranslation::lookupValues(Range &&values) { SmallVector<llvm::Value *, 8> remapped; remapped.reserve(llvm::size(values)); for (Value *v : values) { remapped.push_back(valueMapping.lookup(v)); } return remapped; } // Given a single MLIR operation, create the corresponding LLVM IR operation // using the `builder`. LLVM IR Builder does not have a generic interface so // this has to be a long chain of `if`s calling different functions with a // different number of arguments. bool ModuleTranslation::convertOperation(Operation &opInst, llvm::IRBuilder<> &builder) { auto extractPosition = [](ArrayAttr attr) { SmallVector<unsigned, 4> position; position.reserve(attr.size()); for (Attribute v : attr) position.push_back(v.cast<IntegerAttr>().getValue().getZExtValue()); return position; }; #include "mlir/LLVMIR/LLVMConversions.inc" // Emit function calls. If the "callee" attribute is present, this is a // direct function call and we also need to look up the remapped function // itself. Otherwise, this is an indirect call and the callee is the first // operand, look it up as a normal value. Return the llvm::Value representing // the function result, which may be of llvm::VoidTy type. auto convertCall = [this, &builder](Operation &op) -> llvm::Value * { auto operands = lookupValues(op.getOperands()); ArrayRef<llvm::Value *> operandsRef(operands); if (auto attr = op.getAttrOfType<SymbolRefAttr>("callee")) { return builder.CreateCall(functionMapping.lookup(attr.getValue()), operandsRef); } else { return builder.CreateCall(operandsRef.front(), operandsRef.drop_front()); } }; // Emit calls. If the called function has a result, remap the corresponding // value. Note that LLVM IR dialect CallOp has either 0 or 1 result. if (isa<LLVM::CallOp>(opInst)) { llvm::Value *result = convertCall(opInst); if (opInst.getNumResults() != 0) { valueMapping[opInst.getResult(0)] = result; return false; } // Check that LLVM call returns void for 0-result functions. return !result->getType()->isVoidTy(); } // Emit branches. We need to look up the remapped blocks and ignore the block // arguments that were transformed into PHI nodes. if (auto brOp = dyn_cast<LLVM::BrOp>(opInst)) { builder.CreateBr(blockMapping[brOp.getSuccessor(0)]); return false; } if (auto condbrOp = dyn_cast<LLVM::CondBrOp>(opInst)) { builder.CreateCondBr(valueMapping.lookup(condbrOp.getOperand(0)), blockMapping[condbrOp.getSuccessor(0)], blockMapping[condbrOp.getSuccessor(1)]); return false; } opInst.emitError("unsupported or non-LLVM operation: ") << opInst.getName(); return true; } // Convert block to LLVM IR. Unless `ignoreArguments` is set, emit PHI nodes // to define values corresponding to the MLIR block arguments. These nodes // are not connected to the source basic blocks, which may not exist yet. bool ModuleTranslation::convertBlock(Block &bb, bool ignoreArguments) { llvm::IRBuilder<> builder(blockMapping[&bb]); // Before traversing operations, make block arguments available through // value remapping and PHI nodes, but do not add incoming edges for the PHI // nodes just yet: those values may be defined by this or following blocks. // This step is omitted if "ignoreArguments" is set. The arguments of the // first block have been already made available through the remapping of // LLVM function arguments. if (!ignoreArguments) { auto predecessors = bb.getPredecessors(); unsigned numPredecessors = std::distance(predecessors.begin(), predecessors.end()); for (auto *arg : bb.getArguments()) { auto wrappedType = arg->getType().dyn_cast<LLVM::LLVMType>(); if (!wrappedType) { emitError(bb.front().getLoc(), "block argument does not have an LLVM type"); return true; } llvm::Type *type = wrappedType.getUnderlyingType(); llvm::PHINode *phi = builder.CreatePHI(type, numPredecessors); valueMapping[arg] = phi; } } // Traverse operations. for (auto &op : bb) { if (convertOperation(op, builder)) return true; } return false; } // Get the SSA value passed to the current block from the terminator operation // of its predecessor. static Value *getPHISourceValue(Block *current, Block *pred, unsigned numArguments, unsigned index) { auto &terminator = *pred->getTerminator(); if (isa<LLVM::BrOp>(terminator)) { return terminator.getOperand(index); } // For conditional branches, we need to check if the current block is reached // through the "true" or the "false" branch and take the relevant operands. auto condBranchOp = dyn_cast<LLVM::CondBrOp>(terminator); assert(condBranchOp && "only branch operations can be terminators of a block that " "has successors"); assert((condBranchOp.getSuccessor(0) != condBranchOp.getSuccessor(1)) && "successors with arguments in LLVM conditional branches must be " "different blocks"); return condBranchOp.getSuccessor(0) == current ? terminator.getSuccessorOperand(0, index) : terminator.getSuccessorOperand(1, index); } void ModuleTranslation::connectPHINodes(FuncOp func) { // Skip the first block, it cannot be branched to and its arguments correspond // to the arguments of the LLVM function. for (auto it = std::next(func.begin()), eit = func.end(); it != eit; ++it) { Block *bb = &*it; llvm::BasicBlock *llvmBB = blockMapping.lookup(bb); auto phis = llvmBB->phis(); auto numArguments = bb->getNumArguments(); assert(numArguments == std::distance(phis.begin(), phis.end())); for (auto &numberedPhiNode : llvm::enumerate(phis)) { auto &phiNode = numberedPhiNode.value(); unsigned index = numberedPhiNode.index(); for (auto *pred : bb->getPredecessors()) { phiNode.addIncoming(valueMapping.lookup(getPHISourceValue( bb, pred, numArguments, index)), blockMapping.lookup(pred)); } } } } // TODO(mlir-team): implement an iterative version static void topologicalSortImpl(llvm::SetVector<Block *> &blocks, Block *b) { blocks.insert(b); for (Block *bb : b->getSuccessors()) { if (blocks.count(bb) == 0) topologicalSortImpl(blocks, bb); } } // Sort function blocks topologically. static llvm::SetVector<Block *> topologicalSort(FuncOp f) { // For each blocks that has not been visited yet (i.e. that has no // predecessors), add it to the list and traverse its successors in DFS // preorder. llvm::SetVector<Block *> blocks; for (Block &b : f.getBlocks()) { if (blocks.count(&b) == 0) topologicalSortImpl(blocks, &b); } assert(blocks.size() == f.getBlocks().size() && "some blocks are not sorted"); return blocks; } bool ModuleTranslation::convertOneFunction(FuncOp func) { // Clear the block and value mappings, they are only relevant within one // function. blockMapping.clear(); valueMapping.clear(); llvm::Function *llvmFunc = functionMapping.lookup(func.getName()); // Add function arguments to the value remapping table. // If there was noalias info then we decorate each argument accordingly. unsigned int argIdx = 0; for (const auto &kvp : llvm::zip(func.getArguments(), llvmFunc->args())) { llvm::Argument &llvmArg = std::get<1>(kvp); BlockArgument *mlirArg = std::get<0>(kvp); if (auto attr = func.getArgAttrOfType<BoolAttr>(argIdx, "llvm.noalias")) { // NB: Attribute already verified to be boolean, so check if we can indeed // attach the attribute to this argument, based on its type. auto argTy = mlirArg->getType().dyn_cast<LLVM::LLVMType>(); if (!argTy.getUnderlyingType()->isPointerTy()) { func.emitError( "llvm.noalias attribute attached to LLVM non-pointer argument"); return true; } if (attr.getValue()) llvmArg.addAttr(llvm::Attribute::AttrKind::NoAlias); } valueMapping[mlirArg] = &llvmArg; argIdx++; } // First, create all blocks so we can jump to them. llvm::LLVMContext &llvmContext = llvmFunc->getContext(); for (auto &bb : func) { auto *llvmBB = llvm::BasicBlock::Create(llvmContext); llvmBB->insertInto(llvmFunc); blockMapping[&bb] = llvmBB; } // Then, convert blocks one by one in topological order to ensure defs are // converted before uses. auto blocks = topologicalSort(func); for (auto indexedBB : llvm::enumerate(blocks)) { auto *bb = indexedBB.value(); if (convertBlock(*bb, /*ignoreArguments=*/indexedBB.index() == 0)) return true; } // Finally, after all blocks have been traversed and values mapped, connect // the PHI nodes to the results of preceding blocks. connectPHINodes(func); return false; } bool ModuleTranslation::convertFunctions() { // Declare all functions first because there may be function calls that form a // call graph with cycles. for (FuncOp function : mlirModule.getOps<FuncOp>()) { mlir::BoolAttr isVarArgsAttr = function.getAttrOfType<BoolAttr>("std.varargs"); bool isVarArgs = isVarArgsAttr && isVarArgsAttr.getValue(); llvm::FunctionType *functionType = convertFunctionType(llvmModule->getContext(), function.getType(), function.getLoc(), isVarArgs); if (!functionType) return true; llvm::FunctionCallee llvmFuncCst = llvmModule->getOrInsertFunction(function.getName(), functionType); assert(isa<llvm::Function>(llvmFuncCst.getCallee())); functionMapping[function.getName()] = cast<llvm::Function>(llvmFuncCst.getCallee()); } // Convert functions. for (FuncOp function : mlirModule.getOps<FuncOp>()) { // Ignore external functions. if (function.isExternal()) continue; if (convertOneFunction(function)) return true; } return false; } std::unique_ptr<llvm::Module> ModuleTranslation::prepareLLVMModule(ModuleOp m) { auto *dialect = m.getContext()->getRegisteredDialect<LLVM::LLVMDialect>(); assert(dialect && "LLVM dialect must be registered"); auto llvmModule = llvm::CloneModule(dialect->getLLVMModule()); if (!llvmModule) return nullptr; llvm::LLVMContext &llvmContext = llvmModule->getContext(); llvm::IRBuilder<> builder(llvmContext); // Inject declarations for `malloc` and `free` functions that can be used in // memref allocation/deallocation coming from standard ops lowering. llvmModule->getOrInsertFunction("malloc", builder.getInt8PtrTy(), builder.getInt64Ty()); llvmModule->getOrInsertFunction("free", builder.getVoidTy(), builder.getInt8PtrTy()); return llvmModule; } } // namespace LLVM } // namespace mlir
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_A_ht+0x14cf6, %rsi lea addresses_WT_ht+0x1b8f6, %rdi nop add $2616, %r13 mov $22, %rcx rep movsl nop nop nop nop nop xor $26739, %r8 lea addresses_WT_ht+0x7616, %r9 nop nop sub %r15, %r15 mov $0x6162636465666768, %rdi movq %rdi, %xmm1 vmovups %ymm1, (%r9) mfence lea addresses_UC_ht+0x13056, %rdi nop nop add $13578, %rsi mov $0x6162636465666768, %r13 movq %r13, (%rdi) nop nop nop dec %r8 lea addresses_A_ht+0x6a36, %r15 nop nop nop nop nop inc %r13 movb (%r15), %r8b nop add $58920, %r8 lea addresses_normal_ht+0x19756, %rsi lea addresses_A_ht+0x13dd6, %rdi nop nop nop nop add %rax, %rax mov $25, %rcx rep movsq nop nop sub $63932, %r13 lea addresses_WC_ht+0x1cfb2, %r15 nop nop nop and $3686, %rdi vmovups (%r15), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rcx nop nop nop nop cmp %r8, %r8 lea addresses_WT_ht+0x1acf6, %r13 nop nop nop sub $39294, %rsi mov (%r13), %eax cmp %rdi, %rdi lea addresses_UC_ht+0x45f6, %r15 nop nop nop nop nop dec %rsi mov $0x6162636465666768, %rdi movq %rdi, (%r15) and %rdi, %rdi lea addresses_normal_ht+0xaef4, %rsi lea addresses_WT_ht+0x1db76, %rdi nop nop nop nop cmp %r15, %r15 mov $104, %rcx rep movsb nop nop and $6248, %r8 lea addresses_A_ht+0x1c386, %r13 nop nop nop nop sub %r9, %r9 mov $0x6162636465666768, %r15 movq %r15, (%r13) inc %r9 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r8 push %rax push %rbx push %rcx push %rsi // Load lea addresses_RW+0x10a36, %rax nop nop nop nop nop add %r8, %r8 movups (%rax), %xmm2 vpextrq $1, %xmm2, %rbx nop nop nop nop and $52974, %rcx // Store lea addresses_D+0x1a8f6, %r8 nop and $37058, %rsi movl $0x51525354, (%r8) and %r11, %r11 // Faulty Load mov $0x8f6, %rax nop nop nop and %r11, %r11 movups (%rax), %xmm4 vpextrq $1, %xmm4, %r10 lea oracles, %rax and $0xff, %r10 shlq $12, %r10 mov (%rax,%r10,1), %r10 pop %rsi pop %rcx pop %rbx pop %rax pop %r8 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_P', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_RW', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_P', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'00': 50} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; routines for loading libload libraries ; returns z if loaded, nz if not loaded libload_load: call libload_unload jr .try .inram: call cesium.Arc_Unarc .try: ld hl,libload_name call ti.Mov9ToOP1 call ti.ChkFindSym jr c,.notfound call ti.ChkInRam jr z,.inram ; if in ram, archive LibLoad and search again ld hl,9 + 3 + libload_name.len add hl,de ; start of loader (required to be in hl) ld a,(hl) cp a,$1F ; ensure a valid libload version jr c,.notfound dec hl ; move to start of libload dec hl ld de,.relocations ; start of relocation data ld bc,.notfound push bc ld bc,$aa55aa ; tell libload to not show an error screen jp (hl) ; jump to the loader -- it should take care of everything else .notfound: xor a,a inc a ret .relocations: ; default libload library libload_libload: db $c0, "LibLoad", $00, $1F include 'used_funcs.asm' xor a,a ; return z (loaded) pop hl ; pop error return ret libload_name: db ti.AppVarObj, "LibLoad", 0 .len := $ - . ; remove loaded libraries from usermem libload_unload:=util_delete_prgm_from_usermem
; A318159: Figurate numbers based on the small stellated dodecahedron: a(n) = n*(21*n^2 - 33*n + 14)/2. ; 1,32,156,436,935,1716,2842,4376,6381,8920,12056,15852,20371,25676,31830,38896,46937,56016,66196,77540,90111,103972,119186,135816,153925,173576,194832,217756,242411,268860,297166,327392,359601,393856,430220,468756,509527,552596,598026,645880,696221,749112,804616,862796,923715,987436,1054022,1123536,1196041,1271600,1350276,1432132,1517231,1605636,1697410,1792616,1891317,1993576,2099456,2209020,2322331,2439452,2560446,2685376,2814305,2947296,3084412,3225716,3371271,3521140,3675386,3834072,3997261 mov $1,$0 mov $2,$0 mov $7,$0 lpb $2 add $3,$1 add $1,3 lpb $1 add $3,$1 sub $1,1 lpe add $0,$3 add $0,2 mov $1,2 sub $2,1 lpe add $4,3 add $0,$4 sub $0,2 mov $5,5 mov $8,$7 lpb $5 add $0,$8 sub $5,1 lpe mov $6,$7 lpb $6 sub $6,1 add $9,$8 lpe mov $5,2 mov $8,$9 lpb $5 add $0,$8 sub $5,1 lpe mov $6,$7 mov $9,0 lpb $6 sub $6,1 add $9,$8 lpe mov $5,10 mov $8,$9 lpb $5 add $0,$8 sub $5,1 lpe
; ; ZX IF1 & Microdrive functions ; ; int i1_from_mdv() ; ; returns TRUE if the current program ; has been loaded from the microdrive ; ; $Id: if1_from_mdv.asm,v 1.1 2006/06/28 22:21:26 stefano Exp $ ; XLIB if1_from_mdv if1_from_mdv: ld de,($5c53) ; PROG :location of BASIC program ld hl,($5c4b) ; VARS :location of variables sbc hl,de ; program length ld de,(23787) sbc hl,de ld hl,1 ret z dec hl ret
; A182767: Beatty sequence for 1+e^2. ; Submitted by Jon Maiga ; 8,16,25,33,41,50,58,67,75,83,92,100,109,117,125,134,142,151,159,167,176,184,192,201,209,218,226,234,243,251,260,268,276,285,293,302,310,318,327,335,343,352,360,369,377,385,394,402,411,419,427 mov $2,$0 add $2,1 mul $2,151 div $2,18 mov $0,$2
; A154691: Expansion of (1+x+x^2) / ((1-x-x^2)*(1-x)). ; 1,3,7,13,23,39,65,107,175,285,463,751,1217,1971,3191,5165,8359,13527,21889,35419,57311,92733,150047,242783,392833,635619,1028455,1664077,2692535,4356615,7049153,11405771,18454927,29860701,48315631,78176335,126491969,204668307,331160279,535828589,866988871,1402817463,2269806337,3672623803,5942430143,9615053949,15557484095,25172538047,40730022145,65902560195,106632582343,172535142541,279167724887,451702867431,730870592321,1182573459755,1913444052079,3096017511837,5009461563919,8105479075759 mov $1,4 mov $3,6 lpb $0 sub $0,1 mov $2,$1 mov $1,$3 add $3,$2 lpe sub $1,3 mov $0,$1
DATA SEGMENT OLD_OFF DW ? OLD_SEG DW ? MKBAK DB ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START PROC FAR MOV AL,13H ;8259a初始化 OUT 20H,AL MOV AL,8 OUT 21H,AL MOV AL,8 OUT 21H,AL MOV AX,DATA MOV DS,AX IN AL,21H MOV MKBAK,AL CLI AND AL,11111101B OUT 21H,AL MOV AH,35H ;取原键盘中断向量 MOV AL,9H INT 21H MOV OLD_OFF,BX ;设置新的中断向量 MOV BX,ES MOV OLD_SEG,BX MOV AH,25H MOV AL,9H MOV DX,SEG MYINT MOV DS,DX MOV DX,OFFSET MYINT INT 21H AGA: MOV AL,2 ;屏蔽键盘中断,大约10秒 OUT 21H,AL start1: mov dx,25000 del1:mov cx,5801 del2:loop del2 dec dx jnz del1 AND AL,11111101B ;接受键盘中断 OUT 21H,AL A1: STI start2: mov dx,25000 del11:mov cx,5801 del22:loop del22 dec dx jnz del11 CLI JMP AGA MOV AH,25H ;恢复原中断向量 MOV AL,9H MOV DX,OLD_SEG MOV DS,DX MOV DX,OLD_OFF INT 21H MOV AL,MKBAK OUT 21H,AL STI MOV AX,4C00H INT 21H RET START ENDP ;中断处理程序 MYINT PROC FAR STI PUSH DX IN AL,060H PUSH AX IN AL,61H MOV AH,AL OR AL,80H OUT 061H,AL XCHG AH,AL OUT 061H,AL POP AX MOV DH,AL CALL DISPLAY POP DX CLI MOV AL,20H OUT 20H,AL IRET MYINT ENDP DISPLAY PROC NEAR CMP DH,01EH JNE B MOV DL,62H JMP EXIT B:CMP DH,030H JNE C MOV DL,63H JMP EXIT C:CMP DH,02EH JNE D MOV DL,64H JMP EXIT D:CMP DH,020H JNE E MOV DL,65H JMP EXIT E:CMP DH,12H JNE F MOV DL,66H JMP EXIT F:CMP DH,021H JNE G MOV DL,67H JMP EXIT G:CMP DH,022H JNE H MOV DL,68H JMP EXIT H:CMP DH,023H JNE I MOV DL,69H JMP EXIT I:CMP DH,017H JNE J MOV DL,6AH JMP EXIT J:CMP DH,24H JNE K MOV DL,6BH JMP EXIT K:CMP DH,25H JNE L MOV DL,6CH JMP EXIT L:CMP DH,26H JNE M MOV DL,6DH JMP EXIT M:CMP DH,32H JNE N MOV DL,6EH JMP EXIT N:CMP DH,31H JNE O MOV DL,6FH JMP EXIT O:CMP DH,18H JNE P MOV DL,70H JMP EXIT P:CMP DH,19H JNE Q MOV DL,71H JMP EXIT Q:CMP DH,10H JNE R MOV DL,72H JMP EXIT R:CMP DH,13H JNE S MOV DL,73H JMP EXIT S:CMP DH,1FH JNE T MOV DL,74H JMP EXIT T:CMP DH,14H JNE U MOV DL,75H JMP EXIT U:CMP DH,16H JNE V MOV DL,76H JMP EXIT V:CMP DH,2FH JNE W MOV DL,77H JMP EXIT W: CMP DH,11H JNE X MOV DL,78H JMP EXIT X:CMP DH,2DH JNE Y MOV DL,79H JMP EXIT Y:CMP DH,15H JNE Z MOV DL,7AH JMP EXIT Z:CMP DH,2CH JNE EXIT2 MOV DL,61H JMP EXIT EXIT : MOV AH,02H INT 21H RET EXIT2: RET DISPLAY ENDP CODE ENDS END START
sll $4,$1,7 subu $4,$4,$3 and $0,$4,$3 lb $4,5($0) ori $5,$0,29733 subu $3,$3,$3 sw $1,8($0) lb $4,2($0) slt $5,$5,$3 and $0,$6,$3 srlv $0,$0,$3 addu $3,$5,$3 addu $5,$4,$3 sltu $3,$2,$3 addiu $2,$2,-28465 addu $3,$6,$3 sh $5,6($0) sltu $1,$1,$3 ori $3,$0,60363 sra $5,$3,30 sltu $1,$1,$3 ori $2,$2,13491 srlv $6,$3,$3 ori $3,$3,34748 xori $1,$5,13249 srl $3,$1,0 slt $3,$3,$3 or $1,$6,$3 srlv $3,$4,$3 addiu $3,$3,-6908 addiu $3,$3,19940 sra $3,$0,19 lw $4,12($0) lh $3,10($0) lbu $4,9($0) slt $3,$3,$3 srlv $4,$5,$3 sw $4,4($0) subu $4,$3,$3 nor $0,$5,$3 lbu $5,5($0) or $4,$6,$3 sw $5,8($0) sll $6,$1,12 xori $3,$5,28417 addu $3,$1,$3 sh $4,2($0) lbu $3,5($0) subu $1,$0,$3 andi $6,$2,9233 sra $3,$3,7 subu $0,$4,$3 addiu $3,$3,22052 addiu $4,$4,11699 lhu $3,6($0) sll $6,$4,11 sb $3,12($0) sw $3,12($0) and $1,$1,$3 srl $0,$3,17 and $4,$2,$3 sw $3,12($0) sra $3,$4,13 or $3,$4,$3 xori $3,$0,95 and $4,$4,$3 addu $5,$4,$3 sb $3,16($0) sltiu $3,$5,-19110 or $4,$3,$3 sltiu $1,$3,851 sltiu $4,$3,-31678 addu $5,$5,$3 srav $4,$1,$3 xori $3,$3,22977 xori $0,$1,24099 xori $0,$5,50643 slt $6,$4,$3 srlv $4,$4,$3 sltiu $0,$0,-16164 srlv $3,$3,$3 andi $5,$0,20458 sllv $5,$5,$3 nor $3,$6,$3 or $5,$0,$3 andi $5,$5,28978 lhu $0,4($0) ori $6,$4,7565 lbu $1,2($0) addu $3,$5,$3 xori $1,$1,63656 slt $1,$2,$3 slti $4,$1,-32061 lb $4,2($0) slt $3,$4,$3 nor $6,$4,$3 lhu $3,0($0) and $0,$0,$3 or $5,$3,$3 nor $1,$4,$3 subu $5,$6,$3 sltiu $6,$6,-23216 sllv $4,$1,$3 ori $4,$5,3708 srl $4,$1,23 srl $1,$5,11 lb $0,10($0) slt $0,$3,$3 subu $4,$4,$3 andi $5,$1,32469 sltiu $3,$4,31194 addiu $4,$3,-4463 sllv $4,$5,$3 lw $3,16($0) addu $4,$3,$3 lhu $6,2($0) lb $4,10($0) addiu $1,$4,-8170 sb $5,12($0) andi $4,$1,63423 ori $3,$3,26562 addiu $5,$1,19659 or $4,$6,$3 sra $3,$1,9 and $3,$3,$3 lbu $0,0($0) sra $3,$3,7 lw $5,16($0) addu $3,$4,$3 nor $4,$1,$3 srav $5,$4,$3 sll $1,$0,0 ori $0,$6,41650 subu $4,$4,$3 addu $0,$4,$3 lb $5,0($0) addiu $5,$3,17066 sltu $0,$0,$3 and $1,$2,$3 slti $4,$0,-21035 slt $3,$3,$3 slt $4,$4,$3 andi $3,$6,21411 addu $4,$4,$3 or $5,$3,$3 sltiu $4,$4,-16967 sh $6,12($0) addu $0,$0,$3 slti $5,$5,17558 sw $1,8($0) lh $4,14($0) lbu $0,3($0) sra $1,$1,29 addiu $1,$1,-28211 subu $4,$1,$3 lbu $6,14($0) subu $5,$1,$3 lh $3,14($0) lb $4,2($0) srlv $5,$4,$3 lb $3,9($0) or $4,$3,$3 lh $5,8($0) or $6,$4,$3 lbu $4,16($0) srlv $6,$4,$3 srlv $1,$3,$3 ori $1,$3,23711 subu $3,$2,$3 addiu $5,$6,20121 sb $0,4($0) lh $3,10($0) addu $1,$3,$3 addiu $4,$4,32548 xori $4,$4,17119 ori $3,$5,28070 addu $4,$4,$3 addu $1,$4,$3 sh $5,4($0) xor $3,$3,$3 or $3,$3,$3 ori $6,$1,41618 addu $2,$2,$3 lh $3,16($0) srlv $3,$6,$3 srl $3,$3,9 nor $0,$4,$3 sllv $6,$4,$3 subu $5,$4,$3 slti $5,$6,-30307 ori $4,$3,16546 sra $1,$3,11 addiu $1,$6,-32161 lb $3,6($0) lw $4,12($0) lhu $3,10($0) xor $0,$3,$3 addiu $5,$1,-5814 sb $3,7($0) addiu $1,$6,-12881 srl $5,$4,16 subu $0,$4,$3 xori $4,$5,5044 xor $4,$4,$3 lw $3,12($0) lw $5,16($0) xor $1,$4,$3 lhu $3,4($0) lw $1,12($0) or $3,$1,$3 srav $3,$3,$3 xor $3,$3,$3 lhu $5,6($0) sb $4,1($0) sw $1,0($0) srlv $5,$5,$3 sh $3,4($0) srlv $4,$4,$3 srl $3,$4,2 ori $5,$4,27228 srav $5,$6,$3 sllv $6,$4,$3 sw $1,8($0) sw $5,16($0) nor $0,$3,$3 andi $0,$6,39976 nor $4,$4,$3 slt $3,$6,$3 addiu $5,$0,16047 and $3,$1,$3 andi $3,$3,40436 srl $3,$3,12 srl $4,$3,10 slt $4,$3,$3 ori $6,$2,59751 sra $3,$4,29 or $3,$2,$3 sllv $4,$6,$3 or $1,$1,$3 slt $3,$3,$3 ori $1,$4,6723 addu $4,$6,$3 sh $3,2($0) xori $3,$3,431 addiu $0,$4,7377 sltiu $4,$5,-841 slti $5,$1,31054 andi $3,$3,13854 or $1,$1,$3 xori $4,$3,49132 xor $1,$5,$3 srlv $6,$5,$3 lb $0,9($0) lw $5,0($0) subu $5,$4,$3 srlv $3,$3,$3 ori $6,$2,1120 lh $1,2($0) addu $0,$6,$3 xori $3,$4,26406 lb $5,1($0) lh $1,0($0) srlv $0,$3,$3 srl $3,$3,10 addu $4,$5,$3 lh $3,4($0) srl $4,$3,2 slt $5,$0,$3 lhu $5,2($0) ori $4,$4,8887 srlv $3,$2,$3 addiu $4,$4,3005 sltu $3,$1,$3 sllv $4,$3,$3 sra $3,$5,28 lbu $3,13($0) lb $0,8($0) sltiu $3,$3,6403 xor $4,$3,$3 sllv $5,$4,$3 lb $3,0($0) andi $3,$3,55516 lw $1,4($0) addu $3,$5,$3 sb $2,14($0) addu $3,$1,$3 addu $1,$3,$3 lb $4,12($0) sw $5,0($0) slti $3,$3,31265 nor $4,$1,$3 sh $5,8($0) srl $5,$5,4 subu $5,$4,$3 sltiu $3,$3,-9684 subu $1,$3,$3 sltiu $4,$3,28847 lh $5,16($0) addu $4,$4,$3 sltu $3,$4,$3 lb $4,6($0) lh $3,12($0) srlv $3,$1,$3 lbu $3,3($0) srav $4,$4,$3 addu $1,$3,$3 sllv $1,$3,$3 slt $4,$4,$3 or $3,$3,$3 sll $6,$0,19 sw $5,8($0) lbu $0,0($0) slt $5,$5,$3 lw $6,8($0) and $5,$1,$3 or $3,$3,$3 lhu $6,16($0) sh $4,6($0) srlv $4,$4,$3 sh $4,14($0) xori $3,$2,40821 xori $1,$1,10590 lh $4,6($0) srav $5,$3,$3 addu $4,$3,$3 xori $4,$5,59938 lhu $5,12($0) xori $4,$4,16659 lb $4,6($0) srav $3,$4,$3 lhu $5,14($0) srlv $0,$1,$3 sra $1,$1,22 addiu $5,$5,-21997 addiu $3,$4,30419 ori $3,$4,10870 addu $4,$4,$3 sh $5,4($0) sltu $1,$5,$3 sra $1,$4,28 sb $3,1($0) ori $3,$1,53223 lbu $5,1($0) and $3,$4,$3 sltiu $3,$6,16759 sra $1,$3,24 subu $0,$3,$3 andi $3,$4,3196 srlv $6,$0,$3 srav $1,$0,$3 srlv $4,$4,$3 sllv $3,$4,$3 addiu $3,$5,22400 sltu $0,$6,$3 xor $1,$0,$3 sltiu $5,$5,32347 andi $3,$1,9255 lbu $1,2($0) ori $5,$3,49872 addu $0,$0,$3 or $1,$0,$3 subu $3,$5,$3 lw $1,12($0) sh $5,16($0) srav $1,$2,$3 sltu $6,$3,$3 addiu $5,$5,4990 sltu $5,$4,$3 addu $5,$4,$3 xor $4,$3,$3 addiu $3,$5,16444 sw $3,16($0) sra $1,$1,23 sw $3,0($0) lhu $1,2($0) and $3,$4,$3 subu $3,$3,$3 andi $4,$4,52873 addiu $4,$4,12888 subu $4,$2,$3 nor $5,$5,$3 xori $6,$0,51227 sh $0,0($0) srl $3,$1,27 sltiu $5,$5,19349 addu $6,$3,$3 nor $4,$3,$3 lbu $6,14($0) lhu $0,16($0) lw $3,0($0) addu $4,$4,$3 lhu $3,6($0) slti $3,$0,-15182 srl $0,$3,5 slti $4,$5,12199 slt $4,$4,$3 sltiu $5,$3,-23846 srav $4,$4,$3 ori $3,$3,56579 sllv $6,$3,$3 sltu $4,$1,$3 lhu $3,4($0) or $5,$4,$3 nor $5,$6,$3 srlv $3,$5,$3 sh $1,2($0) slti $6,$4,2689 sllv $0,$1,$3 srl $5,$5,7 addu $3,$6,$3 srl $3,$3,3 sra $1,$1,26 ori $4,$3,42923 sb $1,10($0) lbu $3,4($0) sllv $4,$4,$3 sh $1,0($0) xori $6,$6,21046 addu $5,$5,$3 lhu $4,14($0) slti $4,$5,-10084 sb $1,14($0) or $6,$0,$3 xor $3,$6,$3 lbu $1,3($0) and $4,$1,$3 sra $4,$3,22 srav $0,$6,$3 lhu $4,6($0) addu $3,$3,$3 or $1,$6,$3 sw $4,0($0) lw $5,12($0) srl $3,$0,5 slt $0,$3,$3 lbu $6,13($0) addiu $4,$3,22646 slt $4,$6,$3 or $3,$0,$3 xori $6,$6,55524 srl $3,$1,30 sltu $0,$1,$3 sra $3,$3,6 srav $4,$1,$3 subu $4,$4,$3 sltiu $4,$3,-24286 sw $5,4($0) slt $3,$3,$3 and $3,$5,$3 sh $4,8($0) or $4,$0,$3 srl $3,$4,6 slti $3,$6,28449 xor $4,$3,$3 srl $1,$4,3 lhu $3,10($0) lbu $5,1($0) sllv $5,$5,$3 srl $3,$3,19 subu $5,$5,$3 andi $3,$6,48951 srlv $3,$4,$3 addu $3,$1,$3 lb $6,14($0) addu $6,$3,$3 ori $1,$3,47784 subu $5,$3,$3 xor $3,$0,$3 addiu $5,$3,5732 lbu $0,2($0) slti $0,$1,6231 subu $3,$5,$3 nor $4,$1,$3 srl $3,$4,31 subu $3,$4,$3 sltiu $1,$5,-30150 ori $3,$5,20710 nor $3,$0,$3 sra $5,$5,11 sb $1,0($0) slt $5,$5,$3 slti $4,$4,10978 addiu $1,$5,-21295 sw $1,0($0) subu $5,$3,$3 addu $3,$3,$3 sh $3,12($0) addiu $3,$4,28882 xor $4,$3,$3 or $0,$3,$3 subu $0,$5,$3 sra $3,$3,2 xori $0,$3,37720 sll $3,$4,4 lb $3,15($0) lhu $3,4($0) nor $4,$5,$3 lhu $4,10($0) lhu $1,14($0) sw $3,4($0) ori $3,$5,60510 subu $3,$3,$3 ori $3,$3,412 subu $3,$4,$3 addiu $0,$0,-10221 lhu $6,2($0) lhu $3,14($0) srav $6,$0,$3 srav $5,$5,$3 addiu $3,$5,-23855 sb $4,16($0) xori $4,$3,15346 sltu $3,$5,$3 sltiu $1,$2,5616 sltiu $5,$3,-31569 sw $3,8($0) sltu $3,$3,$3 and $5,$1,$3 lb $1,4($0) srl $0,$0,18 sra $5,$5,22 and $3,$1,$3 lh $3,6($0) addu $5,$3,$3 sltu $3,$4,$3 sb $5,1($0) and $4,$4,$3 addiu $5,$3,16591 addu $3,$3,$3 addu $4,$6,$3 srlv $4,$3,$3 addu $1,$5,$3 sltu $5,$1,$3 sh $3,2($0) sh $3,14($0) sltiu $1,$3,-10911 sw $3,0($0) subu $3,$1,$3 addiu $4,$4,1748 sll $1,$1,17 sra $4,$5,7 or $4,$3,$3 xori $4,$2,17868 sra $6,$1,20 sb $4,7($0) addiu $0,$5,-30652 slt $3,$3,$3 sll $1,$6,13 sltiu $1,$0,-20936 addiu $4,$4,29958 sra $4,$4,27 andi $4,$4,53073 lbu $1,15($0) sb $0,0($0) or $3,$3,$3 addiu $4,$5,26147 sllv $4,$5,$3 xori $5,$3,2140 sw $4,16($0) xori $1,$1,21788 ori $4,$3,38895 lbu $5,11($0) lhu $4,8($0) sra $3,$4,27 lw $3,4($0) sh $5,4($0) xor $4,$4,$3 and $4,$1,$3 srl $3,$3,6 subu $4,$0,$3 lw $3,4($0) addu $3,$1,$3 addu $1,$3,$3 lhu $3,2($0) srlv $5,$0,$3 lb $5,9($0) andi $1,$5,48420 andi $0,$4,25794 slt $1,$6,$3 subu $4,$4,$3 lhu $0,14($0) xor $4,$6,$3 sll $3,$5,22 xor $3,$3,$3 addiu $4,$2,14102 subu $4,$5,$3 lbu $4,9($0) addu $4,$3,$3 and $3,$3,$3 or $3,$5,$3 lhu $1,16($0) addu $5,$5,$3 slt $0,$3,$3 lbu $4,9($0) xor $1,$5,$3 and $3,$3,$3 ori $6,$6,59766 slti $1,$1,18984 ori $1,$5,15612 lh $3,14($0) and $0,$4,$3 sltu $5,$6,$3 xor $3,$4,$3 andi $3,$0,29115 xor $3,$1,$3 sltiu $4,$4,26524 subu $4,$6,$3 lhu $4,14($0) lb $1,12($0) or $5,$5,$3 lw $5,4($0) sw $5,16($0) srlv $4,$4,$3 andi $1,$1,45398 srlv $1,$3,$3 sw $5,4($0) sh $3,0($0) lbu $5,11($0) nor $3,$4,$3 lh $3,6($0) or $3,$5,$3 or $3,$3,$3 addiu $5,$1,3236 lw $5,4($0) and $1,$1,$3 subu $3,$2,$3 or $4,$4,$3 subu $4,$3,$3 slt $5,$3,$3 addu $4,$6,$3 sra $3,$3,2 srlv $0,$6,$3 addu $5,$4,$3 srlv $3,$3,$3 sra $0,$5,13 ori $3,$3,8043 andi $4,$5,28378 addiu $3,$3,-12016 addu $1,$5,$3 srl $3,$3,25 sltiu $6,$3,3351 sh $3,0($0) sra $6,$4,7 srav $0,$0,$3 lhu $1,14($0) lh $3,4($0) addu $3,$3,$3 subu $3,$3,$3 andi $4,$2,44090 nor $5,$3,$3 addiu $3,$5,30846 lw $4,8($0) srlv $3,$3,$3 nor $5,$5,$3 addiu $5,$0,-19978 or $3,$3,$3 ori $3,$6,37661 addu $5,$5,$3 sltu $1,$5,$3 srlv $3,$3,$3 srl $4,$4,5 addiu $1,$1,-11753 sb $5,7($0) slt $3,$4,$3 slt $5,$5,$3 sll $4,$6,11 sllv $4,$4,$3 sll $0,$2,19 or $4,$0,$3 sra $6,$3,29 ori $1,$4,2880 srlv $3,$3,$3 sll $4,$6,21 sw $3,12($0) sra $4,$0,21 sb $3,4($0) sltiu $5,$4,-21076 sltu $4,$4,$3 addiu $3,$5,4793 or $4,$3,$3 addiu $0,$3,-26740 sllv $5,$6,$3 sra $3,$3,11 lh $4,12($0) lh $1,14($0) lw $4,12($0) xor $3,$4,$3 slt $3,$3,$3 addu $1,$4,$3 sltiu $5,$1,6667 lh $1,14($0) lbu $0,14($0) lw $5,8($0) addiu $3,$3,16411 or $5,$3,$3 srl $3,$3,27 subu $4,$4,$3 lb $3,0($0) srl $1,$5,24 sll $4,$0,22 lh $4,8($0) srav $0,$4,$3 sw $4,4($0) sltu $3,$3,$3 srav $3,$0,$3 sh $5,12($0) lbu $3,1($0) srl $4,$4,17 lh $5,4($0) sllv $3,$3,$3 andi $3,$5,21828 lb $0,14($0) srav $5,$3,$3 sltu $3,$3,$3 srl $0,$6,15 sltu $4,$0,$3 nor $0,$5,$3 lw $3,8($0) lbu $3,6($0) sllv $4,$6,$3 xori $4,$0,10575 sh $3,10($0) andi $1,$2,49392 sra $3,$3,31 lw $5,16($0) lb $4,9($0) xor $0,$5,$3 lh $5,10($0) lh $3,10($0) nor $0,$0,$3 lb $1,13($0) sw $6,4($0) srav $1,$1,$3 subu $3,$4,$3 sll $5,$3,31 addiu $1,$3,-23307 sll $6,$3,14 or $3,$3,$3 subu $5,$3,$3 sltiu $0,$3,-18068 or $3,$3,$3 sltiu $4,$5,17125 lh $4,4($0) sra $5,$3,14 lh $4,2($0) sw $4,12($0) nor $4,$4,$3 lw $4,12($0) xor $4,$3,$3 sllv $5,$3,$3 andi $3,$1,4990 addu $0,$1,$3 xori $6,$6,20297 sll $1,$0,30 sllv $5,$0,$3 lw $5,8($0) sllv $4,$6,$3 subu $4,$3,$3 srlv $1,$5,$3 slt $3,$3,$3 sltiu $1,$1,-32667 addiu $2,$2,17149 lw $3,4($0) slt $4,$3,$3 addu $4,$3,$3 sll $1,$0,27 sb $3,8($0) lw $4,8($0) sh $5,16($0) addu $4,$4,$3 lh $3,8($0) slti $3,$3,-2582 and $3,$1,$3 or $6,$3,$3 or $6,$4,$3 srlv $4,$5,$3 sw $5,8($0) srl $3,$3,8 lw $3,12($0) nor $4,$6,$3 srl $3,$1,23 xor $4,$0,$3 sb $3,0($0) sllv $4,$4,$3 addiu $3,$6,30067 or $4,$3,$3 xor $4,$4,$3 sra $4,$6,0 subu $4,$4,$3 srav $6,$4,$3 sll $1,$3,17 sltiu $4,$3,18319 addiu $0,$3,-5348 xor $5,$1,$3 lw $3,4($0) srlv $3,$3,$3 addiu $5,$6,640 sw $4,12($0) and $1,$4,$3 sb $5,5($0) sra $3,$1,31 subu $4,$3,$3 lhu $4,10($0) sllv $0,$4,$3 sltu $3,$3,$3 sra $3,$5,29 or $4,$4,$3 andi $5,$3,27772 slti $0,$4,24316 andi $3,$5,28979 lw $6,8($0) and $1,$6,$3 sb $3,5($0) addiu $6,$3,20163 slt $3,$1,$3 lw $4,0($0) addu $3,$1,$3 addiu $1,$1,15116 srav $5,$3,$3 ori $3,$4,43407 sll $6,$1,15 addiu $5,$3,31306 slt $3,$1,$3 or $0,$3,$3 sltiu $5,$5,24362 srlv $1,$6,$3 subu $3,$5,$3 sltiu $4,$4,-26970 sw $5,12($0) addu $3,$3,$3 sw $3,12($0) xor $4,$1,$3 sb $4,15($0) slti $5,$4,10373 sh $1,10($0) srav $3,$6,$3 sllv $3,$3,$3 sb $0,0($0) slt $3,$3,$3 sw $4,4($0) nor $3,$3,$3 lbu $3,16($0) sb $3,15($0) slt $4,$3,$3 and $1,$1,$3 lh $3,0($0) lhu $3,0($0) slti $6,$5,31877 and $3,$1,$3 slt $3,$3,$3 andi $3,$4,35967 and $3,$3,$3 sll $2,$2,1 andi $3,$3,34675 lb $1,12($0) lh $4,8($0) lw $3,0($0) sra $3,$3,24 sltu $3,$3,$3 subu $3,$3,$3 xori $1,$0,51606 or $3,$0,$3 or $0,$0,$3 and $3,$3,$3 lbu $4,7($0) lb $5,5($0) slti $0,$5,-11040 srlv $4,$4,$3 srav $3,$5,$3 addu $4,$5,$3 and $5,$5,$3 srl $3,$4,8 sb $3,6($0) sh $3,10($0) sra $4,$5,1 or $6,$3,$3 subu $5,$0,$3 addiu $5,$0,-10380 sb $5,10($0) subu $3,$3,$3 xori $6,$6,27716 sllv $1,$1,$3 or $4,$3,$3 lh $3,16($0) or $4,$4,$3 slt $3,$1,$3 lhu $3,0($0) lw $5,16($0)
; fs for particle system demo ; different from the others in that it uses branching, and a .SAT modifier ; uniform inputs ; u0.x u_time ; u0.yzw u_centerPosition ; uniform constants ; u1.x 1.0 ; u1.y -1000.0 ; u1.z 0.0 ; u1.w 40.0 ; u2.x 0.5 ; outputs ; t0 v_lifetime ; t1 position ; t2 pointsize BRANCH.GT void, u0.xxxx, t0.xxxx, label_5 MAD t1.xyz_, u0.xxxx, t2.xyzz, t1.xyzz ADD t1.xyz_, t1.xyzz, void, u0.yzww MOV t1.___w, void, void, u1.xxxx BRANCH void, void, void, label_6 label_5: MOV t1, void, void, u1.yyzz label_6: RCP t0.x___, void, void, t0.xxxx MOV t2, void, void, u0 MAD t0.x___, -t2.xxxx, t0.xxxx, u1.xxxx MOV.SAT t0.x___, void, void, t0.xxxx MUL t0._y__, t0.xxxx, t0.xxxx, void MUL t2.x___, t0.yyyy, u1.wwww, void ADD t1.__z_, t1.zzzz, void, t1.wwww MUL t1.__z_, t1.zzzz, u2.xxxx, void
; A005917: Rhombic dodecahedral numbers: a(n) = n^4 - (n - 1)^4. ; 1,15,65,175,369,671,1105,1695,2465,3439,4641,6095,7825,9855,12209,14911,17985,21455,25345,29679,34481,39775,45585,51935,58849,66351,74465,83215,92625,102719,113521,125055,137345,150415,164289,178991,194545,210975,228305,246559,265761,285935,307105,329295,352529,376831,402225,428735,456385,485199,515201,546415,578865,612575,647569,683871,721505,760495,800865,842639,885841,930495,976625,1024255,1073409,1124111,1176385,1230255,1285745,1342879,1401681,1462175,1524385,1588335,1654049,1721551,1790865 mul $0,2 add $0,1 mov $1,$0 pow $0,3 add $0,$1 div $0,2
// // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384 // // /// // Buffer Definitions: // // cbuffer cbMain // { // // float4x4 g_mWorld; // Offset: 0 Size: 64 [unused] // float4x4 g_mView; // Offset: 64 Size: 64 [unused] // float4x4 g_mProjection; // Offset: 128 Size: 64 [unused] // float4x4 g_mWorldViewProjection; // Offset: 192 Size: 64 [unused] // float4x4 g_mViewProjection; // Offset: 256 Size: 64 [unused] // float4x4 g_mInvView; // Offset: 320 Size: 64 [unused] // float4 g_vScreenResolution; // Offset: 384 Size: 16 [unused] // float4 g_vMeshColor; // Offset: 400 Size: 16 [unused] // float4 g_vTessellationFactor; // Offset: 416 Size: 16 [unused] // float4 g_vDetailTessellationHeightScale;// Offset: 432 Size: 16 [unused] // float4 g_vGridSize; // Offset: 448 Size: 16 [unused] // float4 g_vDebugColorMultiply; // Offset: 464 Size: 16 [unused] // float4 g_vDebugColorAdd; // Offset: 480 Size: 16 [unused] // float4 g_vFrustumPlaneEquation[4]; // Offset: 496 Size: 64 [unused] // // } // // cbuffer cbMaterial // { // // float4 g_materialAmbientColor; // Offset: 0 Size: 16 // float4 g_materialDiffuseColor; // Offset: 16 Size: 16 // float4 g_materialSpecularColor; // Offset: 32 Size: 16 [unused] // float4 g_fSpecularExponent; // Offset: 48 Size: 16 [unused] // float4 g_LightPosition; // Offset: 64 Size: 16 [unused] // float4 g_LightDiffuse; // Offset: 80 Size: 16 [unused] // float4 g_LightAmbient; // Offset: 96 Size: 16 [unused] // float4 g_vEye; // Offset: 112 Size: 16 [unused] // float4 g_fBaseTextureRepeat; // Offset: 128 Size: 16 [unused] // float4 g_fPOMHeightMapScale; // Offset: 144 Size: 16 [unused] // float4 g_fShadowSoftening; // Offset: 160 Size: 16 [unused] // int g_nMinSamples; // Offset: 176 Size: 4 // int g_nMaxSamples; // Offset: 180 Size: 4 // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // g_samLinear sampler NA NA 0 1 // g_baseTexture texture float4 2d 0 1 // g_nmhTexture texture float4 2d 1 1 // cbMain cbuffer NA NA 0 1 // cbMaterial cbuffer NA NA 1 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // TEXCOORD 0 xy 0 NONE float xy // TEXCOORD 3 zw 0 NONE float zw // TEXCOORD 1 xyz 1 NONE float xyz // TEXCOORD 2 xyz 2 NONE float // TEXCOORD 4 xyz 3 NONE float xyz // TEXCOORD 5 xyz 4 NONE float xyz // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_TARGET 0 xyzw 0 TARGET float xyzw // ps_4_0 dcl_constantbuffer cb0[1], immediateIndexed dcl_constantbuffer cb1[12], immediateIndexed dcl_sampler s0, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_resource_texture2d (float,float,float,float) t1 dcl_input_ps linear v0.xy dcl_input_ps linear v0.zw dcl_input_ps linear v1.xyz dcl_input_ps linear v3.xyz dcl_input_ps linear v4.xyz dcl_output o0.xyzw dcl_temps 7 dp3 r0.x, v4.xyzx, v4.xyzx rsq r0.x, r0.x mul r0.xyz, r0.xxxx, v4.xyzx dp3 r0.w, v1.xyzx, v1.xyzx rsq r0.w, r0.w mul r1.xyz, r0.wwww, v1.xyzx dp3 r0.w, v3.xyzx, v3.xyzx rsq r0.w, r0.w mul r2.xyz, r0.wwww, v3.xyzx deriv_rtx r3.xy, v0.xyxx deriv_rty r3.zw, v0.xxxy itof r4.xy, cb1[11].yxyy dp3 r0.x, r0.xyzx, r2.xyzx add r0.y, -r4.x, r4.y mad r0.x, r0.x, r0.y, r4.x ftoi r0.y, r0.x round_z r0.x, r0.x div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x iadd r0.z, r0.y, l(1) mov r2.xy, v0.xyxx mov r0.w, l(0) mov r4.zw, l(0,0,1.000000,1.000000) mov r5.xyzw, l(0,0,0,0) loop ige r1.w, r0.w, r0.y breakc_nz r1.w mad r2.xy, -r0.xxxx, v0.zwzz, r2.xyxx sample_d r6.xyzw, r2.xyxx, t1.xyzw, s0, r3.xyxx, r3.zwzz add r4.x, -r0.x, r4.z lt r1.w, r4.x, r6.w iadd r2.z, r0.w, l(1) movc r2.w, r1.w, r4.w, r6.w movc r0.w, r1.w, r0.z, r2.z mov r4.y, r6.w movc r5.xyzw, r1.wwww, r4.xyzw, r5.xyzw mov r4.w, r2.w mov r4.z, r4.x endloop add r0.xy, -r5.wyww, r5.zxzz add r0.z, -r0.y, r0.x eq r0.w, r0.z, l(0.000000) mul r0.y, r0.y, r5.z mad r0.x, r5.x, r0.x, -r0.y div r0.x, r0.x, r0.z add r0.x, -r0.x, l(1.000000) movc r0.x, r0.w, l(1.000000), r0.x mad r0.xy, -v0.zwzz, r0.xxxx, v0.xyxx sample r2.xyzw, r0.xyxx, t1.xyzw, s0 mad r2.xyzw, r2.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), l(-1.000000, -1.000000, -1.000000, -1.000000) dp4 r0.z, r2.xyzw, r2.xyzw rsq r0.z, r0.z mul r2.xyz, r0.zzzz, r2.xyzx sample r0.xyzw, r0.xyxx, t0.xyzw, s0 dp3_sat r1.x, r2.xyzx, r1.xyzx mad r1.xyzw, r1.xxxx, cb1[1].xyzw, cb1[0].xyzw mul o0.xyzw, r0.xyzw, r1.xyzw ret // Approximately 57 instruction slots used
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld b, 98 call lwaitly_b ld a, 01 ldff(45), a ld a, 40 ldff(41), a ld a, 00 ld(8000), a ld a, 01 ld(c000), a ld a, c0 ldff(51), a xor a, a ldff(52), a ldff(54), a ld a, 80 ldff(53), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei ld hl, 8000 ld a, 03 ldff(43), a halt .text@1000 lstatint: ld a, 80 ldff(55), a ld b, 07 .text@1031 xor a, a ldff(55), a .text@1068 ld a, (hl) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
; A263807: Total number of ON (black) cells after n iterations of the "Rule 157" elementary cellular automaton starting with a single ON (black) cell. ; 1,3,6,11,17,25,34,45,57,71,86,103,121,141,162,185,209,235,262,291,321,353,386,421,457,495,534,575,617,661,706,753,801,851,902,955,1009,1065,1122,1181,1241,1303,1366,1431,1497,1565,1634,1705,1777,1851,1926,2003,2081,2161,2242,2325,2409,2495,2582,2671,2761,2853,2946,3041,3137,3235,3334,3435,3537,3641,3746,3853,3961,4071,4182,4295,4409,4525,4642,4761,4881,5003,5126,5251,5377,5505,5634,5765,5897,6031,6166,6303,6441,6581,6722,6865,7009,7155,7302,7451,7601,7753,7906,8061,8217,8375,8534,8695,8857,9021,9186,9353,9521,9691,9862,10035,10209,10385,10562,10741,10921,11103,11286,11471,11657,11845,12034,12225,12417,12611,12806,13003,13201,13401,13602,13805,14009,14215,14422,14631,14841,15053,15266,15481,15697,15915,16134,16355,16577,16801,17026,17253,17481,17711,17942,18175,18409,18645,18882,19121,19361,19603,19846,20091,20337,20585,20834,21085,21337,21591,21846,22103,22361,22621,22882,23145,23409,23675,23942,24211,24481,24753,25026,25301,25577,25855,26134,26415,26697,26981,27266,27553,27841,28131,28422,28715,29009,29305,29602,29901,30201,30503,30806,31111,31417,31725,32034,32345,32657,32971,33286,33603,33921,34241,34562,34885,35209,35535,35862,36191,36521,36853,37186,37521,37857,38195,38534,38875,39217,39561,39906,40253,40601,40951,41302,41655,42009,42365,42722,43081,43441,43803,44166,44531,44897,45265,45634,46005,46377,46751 mul $0,6 add $0,4 pow $0,2 mov $1,$0 div $1,48 add $1,1
; A096191: a(n) = Sum_{k=1..n} C(n,k)^3 where C(n,k) is binomial(n,k). ; Submitted by Jon Maiga ; 1,9,55,345,2251,15183,104959,739161,5280931,38165259,278415919,2046924399,15148345759,112738423359,843126957055,6332299624281,47737325577619,361077477684435,2739270870994735,20836827035351595,158883473753259751,1214171997616258239,9297206748439774975,71321835387812803695,548057409594239814751,4217997789071070495903,32509700414484268142719,250900149362426273826111,1938786076426160669163391,14999045536109527518717183,116163417566507388158025727,900570078611885122763226969 add $0,1 mov $2,$0 lpb $0 mov $3,$2 bin $3,$0 sub $0,1 pow $3,3 add $1,$3 lpe mov $0,$1
; A167465: n^5 mod 16. ; 0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9,0,11,0,13,0,15,0,1,0,3,0,5,0,7,0,9 pow $0,5 mod $0,16 mov $1,$0
// Copyright (c) 2011 The Chromium OS 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 "metrics/timer.h" #include <string> #include "metrics/metrics_library.h" namespace chromeos_metrics { base::TimeTicks ClockWrapper::GetCurrentTime() const { return base::TimeTicks::Now(); } Timer::Timer() : timer_state_(kTimerStopped), clock_wrapper_(new ClockWrapper()) {} bool Timer::Start() { elapsed_time_ = base::TimeDelta(); // Sets elapsed_time_ to zero. start_time_ = clock_wrapper_->GetCurrentTime(); timer_state_ = kTimerRunning; return true; } bool Timer::Stop() { if (timer_state_ == kTimerStopped) return false; if (timer_state_ == kTimerRunning) elapsed_time_ += clock_wrapper_->GetCurrentTime() - start_time_; timer_state_ = kTimerStopped; return true; } bool Timer::Pause() { switch (timer_state_) { case kTimerStopped: if (!Start()) return false; timer_state_ = kTimerPaused; return true; case kTimerRunning: timer_state_ = kTimerPaused; elapsed_time_ += clock_wrapper_->GetCurrentTime() - start_time_; return true; default: return false; } } bool Timer::Resume() { switch (timer_state_) { case kTimerStopped: return Start(); case kTimerPaused: start_time_ = clock_wrapper_->GetCurrentTime(); timer_state_ = kTimerRunning; return true; default: return false; } } bool Timer::Reset() { elapsed_time_ = base::TimeDelta(); // Sets elapsed_time_ to zero. timer_state_ = kTimerStopped; return true; } bool Timer::HasStarted() const { return timer_state_ != kTimerStopped; } bool Timer::GetElapsedTime(base::TimeDelta* elapsed_time) const { if (start_time_.is_null() || !elapsed_time) return false; *elapsed_time = elapsed_time_; if (timer_state_ == kTimerRunning) { *elapsed_time += clock_wrapper_->GetCurrentTime() - start_time_; } return true; } // static MetricsLibraryInterface* TimerReporter::metrics_lib_ = nullptr; TimerReporter::TimerReporter(const std::string& histogram_name, int min, int max, int num_buckets) : histogram_name_(histogram_name), min_(min), max_(max), num_buckets_(num_buckets) {} bool TimerReporter::ReportMilliseconds() const { base::TimeDelta elapsed_time; if (!metrics_lib_ || !GetElapsedTime(&elapsed_time)) return false; return metrics_lib_->SendToUMA(histogram_name_, elapsed_time.InMilliseconds(), min_, max_, num_buckets_); } } // namespace chromeos_metrics
/* Copyright (c) 2005-2015, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. 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 University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "AbstractOdeSystem.hpp" #include "Exception.hpp" AbstractOdeSystem::AbstractOdeSystem(unsigned numberOfStateVariables) : AbstractParameterisedSystem<std::vector<double> >(numberOfStateVariables), mUseAnalyticJacobian(false) { } AbstractOdeSystem::~AbstractOdeSystem() { } bool AbstractOdeSystem::CalculateStoppingEvent(double time, const std::vector<double>& rY) { return false; } double AbstractOdeSystem::CalculateRootFunction(double time, const std::vector<double>& rY) { bool stop = CalculateStoppingEvent(time, rY); return stop ? 0.0 : 1.0; } bool AbstractOdeSystem::GetUseAnalyticJacobian() { return mUseAnalyticJacobian; } const std::vector<double>& AbstractOdeSystem::rGetConstStateVariables() const { return mStateVariables; }
; A321404: Number of non-isomorphic self-dual set multipartitions (multisets of sets) of weight n with no singletons. ; Submitted by Jamie Morken(s1) ; 1,0,0,0,1,0,1,1,3,4,6 mov $1,$0 div $1,2 sub $0,$1 sub $1,2 mul $1,$0 trn $0,2 add $0,1 sub $1,$0 div $1,2 mov $0,$1 add $0,1
; A034677: Sum of cubes of unitary divisors of n. ; Submitted by Jon Maiga ; 1,9,28,65,126,252,344,513,730,1134,1332,1820,2198,3096,3528,4097,4914,6570,6860,8190,9632,11988,12168,14364,15626,19782,19684,22360,24390,31752,29792,32769,37296,44226,43344,47450,50654,61740,61544,64638,68922,86688,79508,86580,91980,109512,103824,114716,117650,140634,137592,142870,148878,177156,167832,176472,192080,219510,205380,229320,226982,268128,251120,262145,276948,335664,300764,319410,340704,390096,357912,374490,389018,455886,437528,445900,458208,553896,493040,516222,531442,620298,571788 add $0,1 pow $0,3 mov $1,1 mov $2,2 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mod $4,$2 add $2,1 cmp $4,0 cmp $4,0 sub $3,$4 lpe mov $5,1 lpb $0 dif $0,$2 mul $5,$2 lpe add $5,1 mul $1,$5 lpe mov $0,$1
; ============================================================================ ; Palette Utils ; ============================================================================ ; R3 = index ; R4 = RGBx word ; Uses R0,R1 palette_set_colour: adrl r1, palette_osword_block strb r3, [r1, #0] ; logical colour mov r0, #16 strb r0, [r1, #1] ; physical colour and r0, r4, #0xff strb r0, [r1, #2] ; red mov r0, r4, lsr #8 strb r0, [r1, #3] ; green mov r0, r4, lsr #16 strb r0, [r1, #4] ; blue mov r0, #12 swi OS_Word mov pc,lr ; R2 = palette block ptr palette_set_block: str lr, [sp, #-4]! ; push lr on stack mov r3, #0 .1: ldr r4, [r2], #4 ; rgbx bl palette_set_colour add r3, r3, #1 cmp r3, #16 blt .1 ldr pc, [sp], #4 ; rts ; R2 = palette block ptr palette_make_greyscale: str lr, [sp, #-4]! ; push lr on stack adr r1, palette_interp_block mov r3, #16 .1: ldr r4, [r2], #4 ; rgbx mov r5, r4, lsr #2 ; red * 0.25 and r5, r5, #0xf0 mov r6, r4, lsr #9 ; green * 0.5 and r6, r6, #0xf0 mov r7, r4, lsr #18 ; blue * 0.25 and r7, r7, #0xf0 add r0, r5, r6 add r0, r0, r7 orr r0, r0, r0, lsl #8 orr r0, r0, r0, lsl #8 str r0, [r1], #4 subs r3, r3, #1 bne .1 ldr pc, [sp], #4 ; rts ; R0 = [0-16] interpolation ; R2 = palette block ptr palette_make_fade_to_black: str lr, [sp, #-4]! ; push lr on stack adr r1, palette_interp_block mov r3, #16 .1: ldr r4, [r2], #4 ; rgbx mov r5, r4, lsr #4 ; rgbx / 16 mul r6, r5, r0 ; r0 * rgbx / 16 str r6, [r1], #4 subs r3, r3, #1 bne .1 ldr pc, [sp], #4 ; rts ; R0 = [0-16] interpolation ; R2 = palette block ptr palette_make_fade_to_white: str lr, [sp, #-4]! ; push lr on stack adr r1, palette_interp_block add r1, r1, #4 ; ignore 0 add r2, r2, #4 ; ignore 0 ldr r7, solid_white mov r3, #15 .1: ldr r4, [r2], #4 ; rgbx sub r5, r7, r4 ; white - rgbx mov r5, r5, lsr #4 ; (white - rgbx) / 16 mla r6, r5, r0, r4 ; rgbx + r0 * (white - rgbx) / 16 str r6, [r1], #4 subs r3, r3, #1 bne .1 ldr pc, [sp], #4 ; rts solid_white: .long 0x00f0f0f0 palette_interp_block: .skip 64
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_normal_ht+0xe825, %r12 clflush (%r12) nop nop nop nop cmp %r8, %r8 movups (%r12), %xmm0 vpextrq $0, %xmm0, %r11 nop nop nop nop cmp $56541, %rsi lea addresses_A_ht+0x2ed5, %rsi lea addresses_D_ht+0x5225, %rdi nop nop nop nop cmp $64764, %r13 mov $100, %rcx rep movsq nop nop nop nop nop sub $35254, %r12 lea addresses_A_ht+0x87f5, %rsi lea addresses_normal_ht+0xef55, %rdi nop cmp %rbp, %rbp mov $26, %rcx rep movsb nop nop xor $37546, %r8 lea addresses_normal_ht+0x2025, %r11 nop nop nop nop nop cmp %r13, %r13 movups (%r11), %xmm3 vpextrq $1, %xmm3, %rdi nop nop sub %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r8 push %r9 push %rdx push %rsi // Store lea addresses_D+0xc37d, %rsi nop nop xor %r12, %r12 mov $0x5152535455565758, %r9 movq %r9, %xmm5 movups %xmm5, (%rsi) nop nop nop nop add %rsi, %rsi // Faulty Load lea addresses_RW+0x175a5, %r8 nop nop sub %rdx, %rdx mov (%r8), %r11d lea oracles, %rsi and $0xff, %r11 shlq $12, %r11 mov (%rsi,%r11,1), %r11 pop %rsi pop %rdx pop %r9 pop %r8 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D', 'size': 16, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'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 */
; A126423: a(n) = n^4 - n - 1. ; -1,13,77,251,619,1289,2393,4087,6551,9989,14629,20723,28547,38401,50609,65519,83503,104957,130301,159979,194459,234233,279817,331751,390599,456949,531413,614627,707251,809969,923489,1048543,1185887,1336301,1500589,1679579,1874123,2085097,2313401,2559959,2825719,3111653,3418757,3748051,4100579,4477409,4879633,5308367,5764751,6249949,6765149,7311563,7890427,8503001,9150569,9834439,10555943,11316437,12117301,12959939,13845779,14776273,15752897,16777151,17850559,18974669,20151053,21381307,22667051,24009929,25411609,26873783,28398167,29986501,31640549,33362099,35152963,37014977,38950001,40959919,43046639,45212093,47458237,49787051,52200539,54700729,57289673,59969447,62742151,65609909,68574869,71639203,74805107,78074801,81450529,84934559,88529183,92236717,96059501,99999899 mov $2,$0 add $0,1 pow $0,4 sub $0,$2 sub $0,2
PokemonTower1_h: db CEMETERY ; tileset db POKEMONTOWER_1_HEIGHT, POKEMONTOWER_1_WIDTH ; dimensions (y, x) dw PokemonTower1Blocks, PokemonTower1TextPointers, PokemonTower1Script ; blocks, texts, scripts db $00 ; connections dw PokemonTower1Object ; objects
/****************************************************************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/ #include "qwt_arrow_button.h" #include "qwt.h" #include <qpainter.h> #include <qstyle.h> #include <qstyleoption.h> #include <qevent.h> static const int QwtArrowButton_MaxNum = 3; static const int QwtArrowButton_Margin = 2; static const int QwtArrowButton_Spacing = 1; class QwtArrowButton::PrivateData { public: int num; Qt::ArrowType arrowType; }; static QStyleOptionButton QwtArrowButton_styleOpt( const QwtArrowButton* btn ) { QStyleOptionButton option; option.initFrom( btn ); option.features = QStyleOptionButton::None; if ( btn->isFlat() ) option.features |= QStyleOptionButton::Flat; if ( btn->menu() ) option.features |= QStyleOptionButton::HasMenu; if ( btn->autoDefault() || btn->isDefault() ) option.features |= QStyleOptionButton::AutoDefaultButton; if ( btn->isDefault() ) option.features |= QStyleOptionButton::DefaultButton; if ( btn->isDown() ) option.state |= QStyle::State_Sunken; if ( !btn->isFlat() && !btn->isDown() ) option.state |= QStyle::State_Raised; return option; } /*! \param num Number of arrows \param arrowType see Qt::ArrowType in the Qt docs. \param parent Parent widget */ QwtArrowButton::QwtArrowButton( int num, Qt::ArrowType arrowType, QWidget* parent ) : QPushButton( parent ) { m_data = new PrivateData; m_data->num = qBound( 1, num, QwtArrowButton_MaxNum ); m_data->arrowType = arrowType; setAutoRepeat( true ); setAutoDefault( false ); switch ( m_data->arrowType ) { case Qt::LeftArrow: case Qt::RightArrow: setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); break; default: setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); } } //! Destructor QwtArrowButton::~QwtArrowButton() { delete m_data; m_data = NULL; } /*! \brief The direction of the arrows */ Qt::ArrowType QwtArrowButton::arrowType() const { return m_data->arrowType; } /*! \brief The number of arrows */ int QwtArrowButton::num() const { return m_data->num; } /*! \return the bounding rectangle for the label */ QRect QwtArrowButton::labelRect() const { const int m = QwtArrowButton_Margin; QRect r = rect(); r.setRect( r.x() + m, r.y() + m, r.width() - 2 * m, r.height() - 2 * m ); if ( isDown() ) { QStyleOptionButton option = QwtArrowButton_styleOpt( this ); const int ph = style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &option, this ); const int pv = style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &option, this ); r.translate( ph, pv ); } return r; } /*! Paint event handler \param event Paint event */ void QwtArrowButton::paintEvent( QPaintEvent* event ) { QPushButton::paintEvent( event ); QPainter painter( this ); drawButtonLabel( &painter ); } /*! \brief Draw the button label \param painter Painter \sa The Qt Manual for QPushButton */ void QwtArrowButton::drawButtonLabel( QPainter* painter ) { const bool isVertical = m_data->arrowType == Qt::UpArrow || m_data->arrowType == Qt::DownArrow; const QRect r = labelRect(); QSize boundingSize = labelRect().size(); if ( isVertical ) boundingSize.transpose(); const int w = ( boundingSize.width() - ( QwtArrowButton_MaxNum - 1 ) * QwtArrowButton_Spacing ) / QwtArrowButton_MaxNum; QSize arrow = arrowSize( Qt::RightArrow, QSize( w, boundingSize.height() ) ); if ( isVertical ) arrow.transpose(); QRect contentsSize; // aligned rect where to paint all arrows if ( m_data->arrowType == Qt::LeftArrow || m_data->arrowType == Qt::RightArrow ) { contentsSize.setWidth( m_data->num * arrow.width() + ( m_data->num - 1 ) * QwtArrowButton_Spacing ); contentsSize.setHeight( arrow.height() ); } else { contentsSize.setWidth( arrow.width() ); contentsSize.setHeight( m_data->num * arrow.height() + ( m_data->num - 1 ) * QwtArrowButton_Spacing ); } QRect arrowRect( contentsSize ); arrowRect.moveCenter( r.center() ); arrowRect.setSize( arrow ); painter->save(); for ( int i = 0; i < m_data->num; i++ ) { drawArrow( painter, arrowRect, m_data->arrowType ); int dx = 0; int dy = 0; if ( isVertical ) dy = arrow.height() + QwtArrowButton_Spacing; else dx = arrow.width() + QwtArrowButton_Spacing; arrowRect.translate( dx, dy ); } painter->restore(); if ( hasFocus() ) { QStyleOptionFocusRect option; option.initFrom( this ); option.backgroundColor = palette().color( QPalette::Window ); style()->drawPrimitive( QStyle::PE_FrameFocusRect, &option, painter, this ); } } /*! Draw an arrow int a bounding rectangle \param painter Painter \param r Rectangle where to paint the arrow \param arrowType Arrow type */ void QwtArrowButton::drawArrow( QPainter* painter, const QRect& r, Qt::ArrowType arrowType ) const { QPolygon pa( 3 ); switch ( arrowType ) { case Qt::UpArrow: pa.setPoint( 0, r.bottomLeft() ); pa.setPoint( 1, r.bottomRight() ); pa.setPoint( 2, r.center().x(), r.top() ); break; case Qt::DownArrow: pa.setPoint( 0, r.topLeft() ); pa.setPoint( 1, r.topRight() ); pa.setPoint( 2, r.center().x(), r.bottom() ); break; case Qt::RightArrow: pa.setPoint( 0, r.topLeft() ); pa.setPoint( 1, r.bottomLeft() ); pa.setPoint( 2, r.right(), r.center().y() ); break; case Qt::LeftArrow: pa.setPoint( 0, r.topRight() ); pa.setPoint( 1, r.bottomRight() ); pa.setPoint( 2, r.left(), r.center().y() ); break; default: break; } painter->save(); painter->setRenderHint( QPainter::Antialiasing, true ); painter->setPen( Qt::NoPen ); painter->setBrush( palette().brush( QPalette::ButtonText ) ); painter->drawPolygon( pa ); painter->restore(); } /*! \return a size hint */ QSize QwtArrowButton::sizeHint() const { const QSize hint = minimumSizeHint(); return qwtExpandedToGlobalStrut( hint ); } /*! \brief Return a minimum size hint */ QSize QwtArrowButton::minimumSizeHint() const { const QSize asz = arrowSize( Qt::RightArrow, QSize() ); QSize sz( 2 * QwtArrowButton_Margin + ( QwtArrowButton_MaxNum - 1 ) * QwtArrowButton_Spacing + QwtArrowButton_MaxNum * asz.width(), 2 * QwtArrowButton_Margin + asz.height() ); if ( m_data->arrowType == Qt::UpArrow || m_data->arrowType == Qt::DownArrow ) sz.transpose(); QStyleOption styleOption; styleOption.initFrom( this ); sz = style()->sizeFromContents( QStyle::CT_PushButton, &styleOption, sz, this ); return sz; } /*! Calculate the size for a arrow that fits into a rectangle of a given size \param arrowType Arrow type \param boundingSize Bounding size \return Size of the arrow */ QSize QwtArrowButton::arrowSize( Qt::ArrowType arrowType, const QSize& boundingSize ) const { QSize bs = boundingSize; if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) bs.transpose(); const int MinLen = 2; const QSize sz = bs.expandedTo( QSize( MinLen, 2 * MinLen - 1 ) ); // minimum int w = sz.width(); int h = 2 * w - 1; if ( h > sz.height() ) { h = sz.height(); w = ( h + 1 ) / 2; } QSize arrSize( w, h ); if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) arrSize.transpose(); return arrSize; } /*! \brief autoRepeat for the space keys */ void QwtArrowButton::keyPressEvent( QKeyEvent* event ) { if ( event->isAutoRepeat() && event->key() == Qt::Key_Space ) Q_EMIT clicked(); QPushButton::keyPressEvent( event ); }
* Queue maintenance: put byte into a queue V2.00  Tony Tebby QJUMP * section ioq * xdef ioq_pbyt * xref ioq_nc xref ioq_eof * include dev8_keys_qu * * d0 r error condition (0, eof or not complete) * d1 c p next byte in queue (if d0=0) * a2 c p pointer to queue * a3 sp * * all other registers preserved * * ioq_pbyt move.l a3,-(sp) save scratch tst.b qu_eoff(a2) end of file? bmi.s ioq_eof ... yes, set it * move.l qu_nexti(a2),a3 next in move.b d1,(a3)+ set byte cmp.l qu_endq(a2),a3 next off end? bne.s iqp_seti ... no lea qu_strtq(a2),a3 ... yes, reset queue pointer iqp_seti cmp.l qu_nexto(a2),a3 is there room? beq.s ioq_nc ... no, set not complete move.l a3,qu_nexti(a2) set next in move.l (sp)+,a3 restore scratch register moveq #0,d0 ok rts end
/* Copyright 2018-present Barefoot Networks, Inc. * * 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. */ /* * Antonin Bas (antonin@barefootnetworks.com) * */ #include <boost/optional.hpp> #include <gmock/gmock.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/text_format.h> #include <algorithm> // std::transform #include <chrono> #include <condition_variable> #include <fstream> // std::ifstream #include <iterator> // std::back_inserter #include <mutex> #include <queue> #include <string> #include <thread> #include <vector> #include "src/common.h" #include "src/digest_mgr.h" #include "google/rpc/code.pb.h" #include "matchers.h" #include "mock_switch.h" #include "test_proto_fe_base.h" namespace pi { namespace proto { namespace testing { namespace { using pi::fe::proto::DigestMgr; using Status = DigestMgr::Status; using Clock = std::chrono::steady_clock; using SessionTemp = pi::fe::proto::common::SessionTemp; using ::testing::_; using ::testing::AnyNumber; class Sample { public: Sample &operator<<(std::string s) { values.push_back(std::move(s)); return *this; } bool eq(const p4v1::P4Data &data) const { if (data.data_case() != p4v1::P4Data::kStruct) return false; std::vector<std::string> tmp; for (const auto &member : data.struct_().members()) { if (member.data_case() != p4v1::P4Data::kBitstring) return false; tmp.push_back(member.bitstring()); } return (tmp == values); } std::string get() const { std::string ret; for (const auto &v : values) ret.append(v); return ret; } private: std::vector<std::string> values{}; }; class DigestMgrTest : public DeviceMgrBaseTest { public: DigestMgrTest() : digest_mgr(device_id) { } static void SetUpTestCase() { DeviceMgrBaseTest::SetUpTestCase(); std::ifstream istream(input_path); google::protobuf::io::IstreamInputStream istream_(&istream); google::protobuf::TextFormat::Parse(&istream_, &p4info_proto); for (const auto &digest : p4info_proto.digests()) { const auto &pre = digest.preamble(); if (pre.name() == "test_digest_t") { digest_id = pre.id(); break; } } ASSERT_NE(digest_id, 0u); } void SetUp() override { auto status = digest_mgr.p4_change(p4info_proto); ASSERT_OK(status); digest_mgr.stream_message_response_register_cb([this]( device_id_t, p4::v1::StreamMessageResponse *msg, void *) { if (!msg->has_digest()) return; Lock lock(mutex); digests.push(msg->digest()); cvar.notify_one(); }, nullptr); } void TearDown() override { digest_mgr.stream_message_response_unregister_cb(); } pi_status_t digest_inject(const std::vector<Sample> &samples) { std::vector<std::string> samples_; std::transform(samples.begin(), samples.end(), std::back_inserter(samples_), [](const Sample &s) { return s.get(); }); return mock->digest_inject(digest_id, ++msg_id, samples_); } template<typename Rep, typename Period> boost::optional<p4v1::DigestList> digest_receive( const std::chrono::duration<Rep, Period> &timeout) { Lock lock(mutex); // using wait_until and not wait_for to account for spurious awakenings. // if (cvar.wait_for(lock, timeout, [this] { return !digests.empty(); })) { if (cvar.wait_until(lock, Clock::now() + timeout, [this] { return !digests.empty(); })) { auto digest = digests.front(); digests.pop(); return digest; } return boost::none; } boost::optional<p4v1::DigestList> digest_receive() { return digest_receive(defaultTimeout); } Status config_write(const p4v1::DigestEntry &entry, p4v1::Update::Type type = p4v1::Update::INSERT) { EXPECT_CALL( *mock, learn_config_set(digest_id, EqDigestConfig(entry.config()))); return digest_mgr.config_write(entry, type, session); } Status config_delete() { p4v1::DigestEntry entry; entry.set_digest_id(digest_id); EXPECT_CALL(*mock, learn_config_set(digest_id, NULL)); return digest_mgr.config_write(entry, p4v1::Update::DELETE, session); } template<typename Rep1, typename Period1, typename Rep2, typename Period2> Status config_digest( int32_t max_list_size, const std::chrono::duration<Rep1, Period1> &max_timeout, const std::chrono::duration<Rep2, Period2> &ack_timeout, p4v1::Update::Type type = p4v1::Update::INSERT) { auto max_timeout_ns = std::chrono::duration_cast<std::chrono::nanoseconds>( max_timeout).count(); auto ack_timeout_ns = std::chrono::duration_cast<std::chrono::nanoseconds>( ack_timeout).count(); p4v1::DigestEntry entry; entry.set_digest_id(digest_id); auto *config = entry.mutable_config(); config->set_max_list_size(max_list_size); config->set_max_timeout_ns(max_timeout_ns); config->set_ack_timeout_ns(ack_timeout_ns); return config_write(entry, type); } Status config_digest_default(p4v1::Update::Type type = p4v1::Update::INSERT) { p4v1::DigestEntry entry; entry.set_digest_id(digest_id); return config_write(entry, type); } protected: using Lock = std::unique_lock<std::mutex>; static constexpr const char *input_path = TESTDATADIR "/" "unittest.p4info.txt"; static p4configv1::P4Info p4info_proto; static pi_p4_id_t digest_id; static constexpr std::chrono::milliseconds defaultTimeout{100}; std::queue<p4v1::DigestList> digests; mutable std::mutex mutex; mutable std::condition_variable cvar; DigestMgr digest_mgr; pi_learn_msg_id_t msg_id{0}; SessionTemp session{false /* = batch */}; }; /* static */ p4configv1::P4Info DigestMgrTest::p4info_proto; /* static */ pi_p4_id_t DigestMgrTest::digest_id = 0; /* static */ constexpr std::chrono::milliseconds DigestMgrTest::defaultTimeout; TEST_F(DigestMgrTest, Default) { ASSERT_OK(config_digest_default()); Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x01\x23"; EXPECT_CALL(*mock, learn_msg_ack(digest_id, _)); EXPECT_CALL(*mock, learn_msg_done(_)); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); auto digest = digest_receive(); ASSERT_NE(digest, boost::none); EXPECT_EQ(digest->digest_id(), digest_id); EXPECT_EQ(digest->data_size(), 1); EXPECT_TRUE(s.eq(digest->data(0))); } TEST_F(DigestMgrTest, Cache) { ASSERT_OK(config_digest_default()); auto ack_timeout = std::chrono::milliseconds(100); auto ack_timeout_ns = std::chrono::duration_cast<std::chrono::nanoseconds>( ack_timeout).count(); Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x01\x23"; EXPECT_CALL(*mock, learn_msg_ack(digest_id, _)).Times(AnyNumber()); EXPECT_CALL(*mock, learn_msg_done(_)).Times(AnyNumber()); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_NE(digest_receive(), boost::none); ASSERT_NE(digest_receive(), boost::none); // default config: no cache p4v1::DigestEntry config; config.set_digest_id(digest_id); config.mutable_config()->set_ack_timeout_ns(ack_timeout_ns); ASSERT_OK(config_write(config, p4v1::Update::MODIFY)); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_NE(digest_receive(), boost::none); ASSERT_EQ(digest_receive(3 * ack_timeout), boost::none); // cache hit // we have waited 3 * ack_timeout, cache should be clear ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_NE(digest_receive(), boost::none); } TEST_F(DigestMgrTest, Ack) { auto ack_timeout = std::chrono::milliseconds(1000); auto ack_timeout_ns = std::chrono::duration_cast<std::chrono::nanoseconds>( ack_timeout).count(); p4v1::DigestEntry config; config.set_digest_id(digest_id); config.mutable_config()->set_ack_timeout_ns(ack_timeout_ns); ASSERT_OK(config_write(config, p4v1::Update::INSERT)); Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x01\x23"; EXPECT_CALL(*mock, learn_msg_ack(digest_id, _)).Times(AnyNumber()); EXPECT_CALL(*mock, learn_msg_done(_)).Times(AnyNumber()); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); auto digest = digest_receive(); ASSERT_NE(digest, boost::none); // cache hit ASSERT_EQ(digest_receive(std::chrono::milliseconds(200)), boost::none); p4v1::DigestListAck ack; ack.set_digest_id(digest_id); ack.set_list_id(digest->list_id()); digest_mgr.ack(ack); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); // the ack call is asynchronous and there is no way to get completion // information, but we assume that 200ms is long enough for it to complete ASSERT_NE(digest_receive(std::chrono::milliseconds(200)), boost::none); } TEST_F(DigestMgrTest, MaxListSize) { ASSERT_OK(config_digest( 2, std::chrono::milliseconds(1000), std::chrono::milliseconds(1000))); EXPECT_CALL(*mock, learn_msg_ack(digest_id, _)).Times(AnyNumber()); EXPECT_CALL(*mock, learn_msg_done(_)).Times(AnyNumber()); { Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x01\x23"; ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); } { Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x23\x45"; ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); } auto digest = digest_receive(std::chrono::milliseconds(500)); ASSERT_NE(digest, boost::none); EXPECT_EQ(digest->data_size(), 2); } TEST_F(DigestMgrTest, MaxTimeout) { auto max_timeout = std::chrono::milliseconds(400); auto ack_timeout = std::chrono::milliseconds(2000); ASSERT_OK(config_digest(100, max_timeout, ack_timeout)); EXPECT_CALL(*mock, learn_msg_ack(digest_id, _)).Times(AnyNumber()); EXPECT_CALL(*mock, learn_msg_done(_)).Times(AnyNumber()); Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x01\x23"; ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); auto sent_at = Clock::now(); ASSERT_NE(digest_receive(std::chrono::milliseconds(1000)), boost::none); auto received_at = Clock::now(); auto diff = received_at - sent_at; EXPECT_GT(diff, max_timeout / 2); // it can take up to twice the max_timeout based on the current implementation EXPECT_LT(diff, max_timeout * 3); } TEST_F(DigestMgrTest, Reset) { auto ack_timeout = std::chrono::seconds(10); auto ack_timeout_ns = std::chrono::duration_cast<std::chrono::nanoseconds>( ack_timeout).count(); Sample s; s << "\x11\x22\x33\x44\x55\x66" << "\x01\x23"; EXPECT_CALL(*mock, learn_msg_ack(digest_id, _)).Times(AnyNumber()); EXPECT_CALL(*mock, learn_msg_done(_)).Times(AnyNumber()); p4v1::DigestEntry config; config.set_digest_id(digest_id); config.mutable_config()->set_ack_timeout_ns(ack_timeout_ns); ASSERT_OK(config_write(config, p4v1::Update::INSERT)); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_NE(digest_receive(), boost::none); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_EQ(digest_receive(), boost::none); // cache hit // deleting the config should reset the state of the DigestMgr, so it should // clear the cache ASSERT_OK(config_delete()); ASSERT_OK(config_write(config, p4v1::Update::INSERT)); ASSERT_EQ(digest_inject({s}), PI_STATUS_SUCCESS); ASSERT_NE(digest_receive(), boost::none); } } // namespace } // namespace testing } // namespace proto } // namespace pi
; A008790: a(n) = n^(n+4). ; 0,1,64,2187,65536,1953125,60466176,1977326743,68719476736,2541865828329,100000000000000,4177248169415651,184884258895036416,8650415919381337933,426878854210636742656,22168378200531005859375,1208925819614629174706176,69091933913008732880827217,4130428534112329328517709824,257829627945307727248226067259,16777216000000000000000000000000,1136272165922724266740722458520501,79981528839832616637508874879893504,5843211045545439551605946764725979847,442501521100279865673218454734216626176 mov $1,$0 add $1,4 pow $0,$1
; A102392: Odious numbers in odious places. ; 0,1,2,0,4,0,0,7,8,0,0,11,0,13,14,0,16,0,0,19,0,21,22,0,0,25,26,0,28,0,0,31,32,0,0,35,0,37,38,0,0,41,42,0,44,0,0,47,0,49,50,0,52,0,0,55,56,0,0,59,0,61,62,0,64,0,0,67,0,69,70,0,0,73,74,0,76,0,0,79,0,81,82,0,84,0,0,87,88,0,0,91,0,93,94,0,0,97,98,0,100,0,0,103,104,0,0,107,0,109,110,0,112,0,0,115,0,117,118,0,0,121,122,0,124,0,0,127,128,0,0,131,0,133,134,0,0,137,138,0,140,0,0,143,0,145,146,0,148,0,0,151,152,0,0,155,0,157,158,0,0,161,162,0,164,0,0,167,168,0,0,171,0,173,174,0,176,0,0,179,0,181,182,0,0,185,186,0,188,0,0,191,0,193,194,0,196,0,0,199,200,0,0,203,0,205,206,0,208,0,0,211,0,213,214,0,0,217,218,0,220,0,0,223,224,0,0,227,0,229,230,0,0,233,234,0,236,0,0,239,0,241,242,0,244,0,0,247,248,0 mov $1,$0 mov $3,$0 mov $4,$0 lpb $0 sub $0,1 div $4,2 sub $3,$4 lpe mov $2,$3 mod $2,2 mul $1,$2
; A168605: Number of ways of partitioning the multiset {1,1,1,2,3,...,n-2} into exactly three nonempty parts. ; 1,2,8,30,104,342,1088,3390,10424,31782,96368,291150,877544,2640822,7938848,23849310,71613464,214971462,645176528,1936053870,5809210184,17429727702,52293377408,156888520830,470682339704,1412080573542,4236308829488,12709060706190,38127450554024,114382888532982,343149739340768,1029451365505950,3088358391485144,9265083764390022,27795268473039248,83385839778856110,250157588056045064,750472901607088662,2251418979699172928,6754257488853332670,20262773566071625784,60788322897238132902,182364973089760909808,547094928065375751630,1641284801788313299304,4923854440549311986742,14771563392016680137888,44314690316787528768990,132944071231837563017624,398832214258462642474182,1196496643901287834265168,3589489933955663316480750,10768469806370589576812744,32305409428118967985179222,96916228302371302465019648,290748684943142704414022910,872246054901485707279996664,2616738164848572309915845862,7850214494833947305899249328,23550643485078302670001171470,70651930456387829514610361384,211955791371469331553044778102,635867374119019680677561722208,1907602122366282414069539942430,5722806367117293986282329378904,17168419101388775446994407239942,51505257304240113317278059926288,154515771912867913904423856191790,463547315738898889618450921401224,1390641947217286964665711469855382,4171925841653041485617851820869568,12515777524961485640094990285215550,37547332574889179286767840500860344,112641997724676982593269260793008422,337925993174049837245739260959880048 mov $1,2 lpb $0 sub $0,1 sub $2,1 trn $2,2 add $2,1 add $3,$1 mul $3,2 sub $3,1 mov $1,$3 sub $3,$2 add $2,$1 lpe sub $1,1 mov $0,$1
CLC AddValue #$03, myWater, #$03, #$00 LDA myWater+2 CMP MyWater100 BCS +CheckTens JMP +End +CheckTens: LDA myWater+1 CMP MyWater10 BCS +CheckOnes JMP +End +CheckOnes: LDA myWater CMP MyWater1 BCS +SetMax JMP +End +SetMax: LDA MyWater100 STA myWater+2 LDA MyWater10 STA myWater+1 LDA MyWater1 STA myWater +End: ;;;;;;;;;;;;; UPDATE HUD LDA #$03 ;; amount of places STA hudElementTilesToLoad LDA DrawHudBytes ORA #HUD_myWater STA DrawHudBytes PlaySound #SFX_GET_COIN
; ; Get the OSCA Architecture current bank ; by Stefano Bodrato, 2011 ; ; int get_bank(); ; Ask which of 15 32KB banks at Z80 address $8000-$FFFF is selected ; ; $Id: get_bank.asm,v 1.5 2016-06-22 22:13:09 dom Exp $ ; INCLUDE "target/osca/def/flos.def" SECTION code_clib PUBLIC get_bank PUBLIC _get_bank get_bank: _get_bank: call kjt_getbank ld h,0 ld l,a ret